Selaa lähdekoodia

Merge branch 'master' into dev

bianjunhui 2 vuotta sitten
vanhempi
commit
89e18028d0
1 muutettua tiedostoa jossa 40 lisäystä ja 4 poistoa
  1. 40 4
      application/api/controller/Raffle.php

+ 40 - 4
application/api/controller/Raffle.php

@@ -49,6 +49,7 @@ class Raffle extends Api
 
     public function getRaffle()
     {
+        $code = $this->request->post('code','USD');
         $userinfo =$this->userInfo;
         $web=$userinfo['website'];
         $list =  Db::name('raffle')->where("website='{$web}' and status ='normal' ")->order('id desc')->find();
@@ -56,11 +57,11 @@ class Raffle extends Api
         $data['website']=$list['website'];
         $data['name']=$list['name'];
         $data['image']=$list['image'];
-        $data['prize']=$this->getPrize($list['id'])['new'];
+        $data['prize']=$this->getPrize($list['id'],$code)['new'];
         $this->success('',$data);
     }
 
-    public function getPrize($rid){
+    public function getPrize($rid,$code='USD'){
         $list =  Db::name('raprize')->where("r_id='$rid' and status ='normal' ")->order('id desc')->select();
         $new=array();
         $prize =array();
@@ -69,8 +70,9 @@ class Raffle extends Api
             $new[$k]['title']=$v['t_type_name'];
             $new[$k]['price']=$v['price'];
             if($v['t_type_name']=='CASH'||$v['t_type_name']=='Coupon'){
-                $str='$';
-                $new[$k]['price']=$str.$v['price'];
+                /*$str='$';
+                $new[$k]['price']=$str.$v['price'];*/
+                $new[$k]['price']=$this->getCuPrice($code,$v['price']);
             }
             if($v['t_type_name']=='DiscountCoupon'){
                 $str='%';
@@ -85,6 +87,40 @@ class Raffle extends Api
         return $data;
     }
 
+    public function getCuPrice($code,$price){
+        switch ($code)
+        {
+            case 'USD':
+                $str='$';
+                break;
+            case 'AUD':
+                $str='A$';
+                $price =$price*1.5;
+                break;
+            case 'CAD':
+                $str='CA$';
+                $price =$price*1.35;
+                break;
+            case 'GBP':
+                $str='£';
+                $price =$price*0.81;
+                break;
+            case 'EUR':
+                $str='€';
+                $price =$price*0.95;
+                break;
+            case 'ZAR':
+                $str='ZAR';
+                $price =$price*19.5;
+                break;
+            default:
+                $str='$';
+        }
+        $prices=$str.$price;
+        return $prices;
+
+    }
+
     //分享增加抽奖次数
     public function shareAdd(){
         $where=$this->getWhere();