Explorar o código

change discount

stanley-king %!s(int64=4) %!d(string=hai) anos
pai
achega
08ec607021

+ 0 - 86
conf/nginx/nginx-debug-http-8080.conf

@@ -1,86 +0,0 @@
-
-user nginx;
-worker_processes  1;
-error_log   /var/error.log  info;
-#pid        logs/nginx.pid;
-worker_rlimit_nofile 1024;
-
-events {
-    worker_connections  1024;
-}
-
-http 
-{
-    include       mime.types;
-    default_type  application/octet-stream;
-    fastcgi_buffer_size 32k;
-    fastcgi_buffers 8 32k;
-    underscores_in_headers on;
-    client_max_body_size 1024M;
-
-    sendfile            on;
-    keepalive_timeout   65;
-
-    log_format  main  '$remote_addr - $remote_user [$time_local] "$request" '
-                      '$status $body_bytes_sent "$http_referer" '
-                      '"$http_user_agent" "$http_x_forwarded_for"';
-
-    server 
-    {
-    	listen       8080;
-        set  $folder_name /var/www/html;
-        server_name 192.168.1.200;
-        root $folder_name;
-        index index.html index.php; 
-    	client_max_body_size 100m;
-    	proxy_connect_timeout 500s;
-        proxy_read_timeout 500s;
-        proxy_send_timeout 500s;
-        fastcgi_connect_timeout 75;
-        fastcgi_read_timeout 600;   
-        fastcgi_send_timeout 600;   
-
-        charset utf-8;
-        
-        location /logs {
-            deny all;
-            return 403;
-        }
-
-        location /data/log {
-            deny all;
-            return 403;
-        }
-        location / {
-            index  index.html index.htm index.php;
-        }
-        
-        location /mshop {
-            root $folder_name;
-            autoindex on;        
-            index  index.html index.htm index.php;
-	        try_files $uri $uri/ /mshop/index.html;
-        }
-
-        location ~ /mobile/[/\w]+\.php$ {
-            root           $folder_name;
-            fastcgi_pass   tmobilesrv:9100;
-            fastcgi_index  index.php;
-            fastcgi_param  SCRIPT_FILENAME  $folder_name$fastcgi_script_name;
-            include fastcgi_params;
-        }
-
-        location ~ /mobile/[/\w]+\.html$ {
-            try_files $uri $uri/ /mobile/index.html;
-        }
-
-        location ~ \.php$ {
-	        add_header Cache-Control no-store;
-            root           $folder_name;
-            fastcgi_pass   tfpmsrv:9000;
-            fastcgi_index  index.php;
-            fastcgi_param  SCRIPT_FILENAME  $folder_name$fastcgi_script_name;
-            include        fastcgi_params;
-        }
-    }
-}

+ 8 - 6
data/config/dev/vgoods.ini.php

@@ -48,24 +48,26 @@ $config['vgoods_handlers'] = $handlers;
 
 //6220 话费 amount = 100
 $share_policy[6220] = [
-    ['num' => 1,  'discount' => 0.95, 'tip' => '邀请1人可享95折扣']
+    ['num' => 1,  'discount' => 0.05,'price' => 0.95]
 ];
 
 //6220 话费 amount = 200
 $share_policy[6221] = [
-    ['num' => 3,  'discount' => 0.95, 'tip' => '邀请3人可享95折扣'],
-    ['num' => 1,  'discount' => 0.96, 'tip' => '邀请1人可享96折扣']
+    ['num' => 3,  'discount' => 0.10,  'price' => 1.90],
+    ['num' => 2,  'discount' => 0.08,  'price' => 1.92],
+    ['num' => 1,  'discount' => 0.05,  'price' => 1.95]
 ];
 
 //6220 油费 amount = 100
 $share_policy[6218] = [
-    ['num' => 1,  'discount' => 0.95, 'tip' => '邀请1人可享95折扣']
+    ['num' => 1,  'discount' => 0.05, 'price' => 0.95]
 ];
 
 //6220 油费 amount = 200
 $share_policy[6219] = [
-    ['num' => 3,  'discount' => 0.95, 'tip' => '邀请3人可享95折扣'],
-    ['num' => 1,  'discount' => 0.96, 'tip' => '邀请1人可享96折扣']
+    ['num' => 3,  'discount' => 0.10,  'price' => 1.90],
+    ['num' => 2,  'discount' => 0.08,  'price' => 1.92],
+    ['num' => 1,  'discount' => 0.05,  'price' => 1.95]
 ];
 
 $config['goods_share_policy'] = $share_policy;

+ 35 - 0
data/config/test/vgoods.ini.php

@@ -40,3 +40,38 @@ $phone_card_prams = ['type' => 'phone_card', 'order_method' => 'OnReservePhoneCa
 $handlers[6221] = $phone_card_prams;
 
 $config['vgoods_handlers'] = $handlers;
+
+////////////////////////////////////////////////////
+//[6218 => 200, 6219 => 500, 6220 => 1000, 6227 => 100, 6221 => 100]
+//6220 话费 amount = 100
+$share_policy[6221] = [
+    ['num' => 1,  'discount' => 5,'price' => 95]
+];
+$share_policy[6227] = [
+    ['num' => 1,  'discount' => 5,'price' => 95]
+];
+
+//6220 话费 amount = 200
+$share_policy[6220] = [
+    ['num' => 3,  'discount' => 10,  'price' => 190],
+    ['num' => 2,  'discount' => 9,  'price'  => 191],
+    ['num' => 1,  'discount' => 6,  'price'  => 194]
+];
+
+//6220 油费 amount = 500
+$share_policy[6219] = [
+    ['num' => 3,  'discount' => 25,  'price' => 475],
+    ['num' => 2,  'discount' => 20,  'price' => 480],
+    ['num' => 1,  'discount' => 15,  'price' => 485]
+];
+
+//6220 油费 amount = 1000
+$share_policy[6219] = [
+    ['num' => 3,  'discount' => 50,  'price' => 950],
+    ['num' => 3,  'discount' => 40,  'price' => 960],
+    ['num' => 2,  'discount' => 30,  'price' => 970],
+    ['num' => 1,  'discount' => 25,  'price' => 975]
+];
+
+$config['goods_share_policy'] = $share_policy;
+

+ 2 - 2
data/model/goods_class.model.php

@@ -188,14 +188,14 @@ class goods_classModel extends Model
                     $v['childchild'] = implode(',', $c2[$k]);
                 }
             } 
-            else if ((string) $p[$p[$k]] == '0') 
+            elseif ((string) $p[$p[$k]] == '0')
             {
                 $v['depth'] = 2;
                 if ($data['children'][$k]) {
                     $v['child'] = implode(',', $c[$k]);
                 }
             } 
-            else if ((string) $p[$p[$p[$k]]] == '0') 
+            elseif ((string) $p[$p[$p[$k]]] == '0')
             {
                 $v['depth'] = 3;
             }

+ 34 - 22
helper/calc_helper.php

@@ -21,9 +21,6 @@ class CalcPrice implements ICalc
     public const CalcTypeInvitees = 4;
     public const CalcTypeNone = 5;
 
-    private const DEFAULT_ORDER_DISCOUNT = 0.98;
-
-
     private $mUserId;
     private $mUserCards = null;
     private $mMemberInfo = null;
@@ -228,13 +225,13 @@ class CalcPrice implements ICalc
 
     public function inviter_tips($goods_id)
     {
-        $now = time();
-        $nine = strtotime(date('Y-m-d',$now)) + 9*3600;
-        $twenty_first = strtotime(date('Y-m-d',$now)) + 21*3600;
-
-        if($now < $nine || $now > $twenty_first) {
-            return '试营业时间为9:00--21:00,其它时间会慢';
-        }
+//        $now = time();
+//        $nine = strtotime(date('Y-m-d',$now)) + 9*3600;
+//        $twenty_first = strtotime(date('Y-m-d',$now)) + 21*3600;
+//
+//        if($now < $nine || $now > $twenty_first) {
+//            return '试营业时间为9:00--21:00,其它时间会慢';
+//        }
 
         if($this->mCalcType == self::CalcTypeNormal || $this->mCalcType == self::CalcTypeInvitees)
         {
@@ -253,12 +250,12 @@ class CalcPrice implements ICalc
             }
 
             if(empty($next)) {
-                $discount = $cur['discount'] * 100;
-                $tip = "您的分享人数,已达最高优惠{$discount}折";
+                $discount = $cur['discount'];
+                $tip = "您的分享人数,已获最高补贴{$discount}元";
             } else {
                 $count = $next['num'] - $left_invitees;
-                $discount = $next['discount'] * 100;
-                $tip = "再分享{$count}人,即可享受{$discount}折";
+                $discount = $next['discount'];
+                $tip = "再分享{$count}人,可领补贴{$discount}元";
             }
 
             return $tip;
@@ -278,18 +275,32 @@ class CalcPrice implements ICalc
         }
         elseif($this->isVip()) {
             $this->mCalcType = self::CalcTypeVIP;
+            $goods_price = $this->goods_spec_amount($goods_id,$goods_price);
             $price = $this->mUserCards->calc_price($goods_id, $goods_price);
             return ['price_des' => '会员价', 'accu_price' => round($price,2)];
         }
         elseif(!empty($policy = $this->select_invitees($goods_id))) {
             $this->mCalcType = self::CalcTypeInvitees;
-            $discount = $policy['discount'];
-
-            return ['price_des' => '特惠价', 'accu_price' => round($goods_price * $discount,2)];
+            $price = $policy['price'];
+            return ['price_des' => '补贴价', 'accu_price' => round($price,2)];
         }
         else {
             $this->mCalcType = self::CalcTypeNormal;
-            return ['price_des' => '售价', 'accu_price' => round($goods_price * self::DEFAULT_ORDER_DISCOUNT,2)];
+            return ['price_des' => '售价', 'accu_price' => round($goods_price,2)];
+        }
+    }
+    //获取商品面额
+    private function goods_spec_amount($goods_id,$goods_price)
+    {
+        global $config;
+        $spec_card = $config['vgoods_spec_card'];
+
+        if(array_key_exists($goods_id,$spec_card)) {
+            return $spec_card[$goods_id];
+        }
+        else {
+            Log::record("cannot find goods_id = {$goods_id} spec",Log::ERR);
+            return $goods_price;
         }
     }
 
@@ -305,16 +316,17 @@ class CalcPrice implements ICalc
         }
         elseif($this->isVip()) {
             $this->mCalcType = self::CalcTypeVIP;
-            return $this->mUserCards->calc_amount($goods_id, $goods_price);
+            $goods_price = $this->goods_spec_amount($goods_id,$goods_price);
+            return $this->mUserCards->calc_amount($goods_id, $goods_price * $num);
         }
         elseif(!empty($policy = $this->select_invitees($goods_id))) {
             $this->mCalcType = self::CalcTypeInvitees;
-            $discount = $policy['discount'];
-            return round($goods_price * $discount * $num,2);
+            $price = $policy['price'];
+            return round($price * $num,2);
         }
         else {
             $this->mCalcType = self::CalcTypeNormal;
-            return round($goods_price * $num * self::DEFAULT_ORDER_DISCOUNT,2);
+            return round($goods_price * $num,2);
         }
     }