stanley-king 4 лет назад
Родитель
Сommit
1d150540e5

+ 9 - 2
helper/refill/CalcMerchantPrice.php

@@ -13,9 +13,16 @@ use Log;
 class CalcMerchantPrice implements ICalc
 {
     private $mPrice;
-    public function __construct($mchid,$spec,$card_type,$quality,$policy,$pcode='',$count=1)
+    public function __construct($mchid,$spec,$card_type,$quality,$policy,$other = [])
     {
-        $price = $policy->price($mchid,$spec,$card_type,$quality);
+        if(empty($other) || empty($other['product_code'])) {
+            $pcode = '';
+        }
+        else {
+            $pcode = $other['product_code'];
+        }
+
+        $price = $policy->price($mchid,$spec,$card_type,$quality,$pcode);
 
         if($price === false) {
             throw new Exception("没有协商商品购买价格.");

+ 3 - 3
helper/refill/RefillBase.php

@@ -235,7 +235,7 @@ class RefillBase
     //     其它情况,则需要判断订单ID
     public function add($mchid, $buyer_id, $amount, $card_no,
                         $mch_order, $idcard, $card_name, $notify_url, $quality, $org_quality,
-                        $order_time, $commit_times, $last_orderid = 0, $card_type = 0,$regin_no = 0,$other = [])
+                        $order_time, $commit_times, $last_orderid = 0, $card_type = 0, $regin_no = 0, $quantity = 1, $third_params = [])
     {
         if($card_type == 0 && $card_type != mtopcard\ThirdRefillCard ) {
             $card_type = mtopcard\card_type($card_no,$regin_no);
@@ -259,7 +259,7 @@ class RefillBase
 
         try {
             $minfo = new member_info($buyer_id);
-            $calc = new CalcMerchantPrice($mchid, $amount, $card_type,$quality,$this->mPolicy);
+            $calc = new CalcMerchantPrice($mchid, $amount, $card_type,$quality,$this->mPolicy,$third_params);
             $mch_amount = $calc->calc_vgoods_price([]);
         }
         catch (Exception $ex) {
@@ -287,7 +287,7 @@ class RefillBase
             Log::record("start create order",Log::DEBUG);
 
             $input['goods_id'] = $goods_id;
-            $input['quantity'] = 1; //数量
+            $input['quantity'] = $quantity; //数量
             $input['buyer_phone'] = $minfo->mobile();
             $input['buyer_name']  = $minfo->truename();
             $input['buyer_msg']   = $_POST['buyer_msg'] ?? '';

+ 1 - 1
helper/refill/policy/IPolicy.php

@@ -10,5 +10,5 @@ interface IPolicy
     public function find_quality($mchid,$spec,$card_type,$quality,$times,$used_time): array;
     public function allow($mchid,$card_type,$amount,$quality) : bool;
     public function notify($order_info, $refill_info) : bool;
-    public function price($mchid,$spec,$card_type,$quality);
+    public function price($mchid,$spec,$card_type,$quality,$pcode);
 }

+ 2 - 2
helper/refill/policy/lingzh/policy.php

@@ -89,9 +89,9 @@ class policy extends ProviderManager implements IPolicy
         return [$result,$first];
     }
 
-    public function price($mchid,$spec,$card_type,$quality)
+    public function price($mchid,$spec,$card_type,$quality,$pcode)
     {
-        return $this->mPrices->price($mchid,$card_type,$spec,$quality);
+        return $this->mPrices->price($mchid,$card_type,$spec,$quality,$pcode);
     }
 
     public function find_quality($mchid,$spec,$card_type,$org_quality,$times,$used_time): array

+ 19 - 6
helper/refill/policy/merchant_price.php

@@ -1,6 +1,7 @@
 <?php
 
 namespace refill;
+use mtopcard;
 
 class merchant_price
 {
@@ -42,14 +43,26 @@ class merchant_price
         }
     }
 
-    public function price($mchid,$card_type,$spec,$quality)
+    public function price($mchid,$card_type,$spec,$quality,$pcode)
     {
-        $key = "{$mchid}-{$quality}-{$card_type}-{$spec}";
-        if(array_key_exists($key,$this->mPrices)) {
-            return $this->mPrices[$key];
+        $card_type = intval($card_type);
+        if(in_array($card_type,[1,2,4,5,6]))
+        {
+            $key = "{$mchid}-{$quality}-{$card_type}-{$spec}";
+            if(array_key_exists($key,$this->mPrices)) {
+                return $this->mPrices[$key];
+            }
+            else {
+                return false;
+            }
         }
-        else {
-            return false;
+        elseif($card_type === mtopcard\ThirdRefillCard) {
+            return $this->third_price($mchid,$card_type,$pcode);
         }
     }
+
+    private function third_price($mchid,$card_type,$pcode)
+    {
+
+    }
 }

+ 0 - 1
helper/refill/policy/mgroup.php

@@ -107,7 +107,6 @@ class rgroup
     {
         return $this->mChannelTurn;
     }
-
 }
 
 //通道控制

+ 1 - 1
helper/refill/policy/xyz/policy.php

@@ -105,7 +105,7 @@ class policy extends ProviderManager implements IPolicy
         return [$result,$first];
     }
 
-    public function price($mchid,$spec,$card_type,$quality)
+    public function price($mchid,$spec,$card_type,$quality,$pcode)
     {
         return $this->mPrices->price($mchid,$card_type,$spec,$quality);
     }

+ 2 - 0
helper/refill/util.php

@@ -16,6 +16,8 @@ use refill;
 
 class util
 {
+    const ThirdRefillAmount = 100;
+
     static function make_mobile()
     {
         static $prefix = ["139", "138", "137", "136", "135", "134", "159", "158", "157", "150", "151", "152",

+ 10 - 4
racc/control/lzrefill.php

@@ -153,20 +153,25 @@ class lzrefillControl extends lzbaseControl
         return true;
     }
 
+    private function check_pcode()
+    {
+        //todo
+    }
+
     public function add_thirdOp()
     {
-        $code = $this->check_params($_GET);
+        $code = $this->check_third($_GET);
         if($code !== true) {
             return self::outerr($code,$this->merchant_available);
         }
 
-        $amount = 10;
+        $amount = refill\util::ThirdRefillAmount;
         $mch_order = $_GET['ord'];
         $notify_url = $_GET['notifyurl'];
 
         //三方充值没有质量
         $quality = 1;
-        $card_type = 7;
+        $card_type = mtopcard\ThirdRefillCard;
 
         $product_code = $_GET['product_code'];
         $card_no = $_GET['mob'];
@@ -185,11 +190,12 @@ class lzrefillControl extends lzbaseControl
         $params = [ 'mchid' => $this->mchid(),
             'buyer_id' => $this->adminid(),
             'amount' => $amount,
-            'card_no' => $card_no,
             'mch_order' => $mch_order,
             'notify_url' => $notify_url,
             'org_quality' => $quality,
             'card_type' => $card_type,
+
+            'card_no' => $card_no,
             'product_code' => $product_code,
             'quantity' => $quantity,
             'third_card_type' => $third_card_type

+ 13 - 12
rdispatcher/proxy.php

@@ -32,6 +32,7 @@ class proxy
         $org_quality = intval($params['org_quality']) ?? 0;
         $card_type   = intval($params['card_type']) ?? 0;
         $regin_no   = intval($params['regin_no']) ?? 0;
+        $quantity = 1;
 
         Log::record("proxy::add mch_order={$mch_order} card_no = {$card_no}",Log::DEBUG);
 
@@ -65,7 +66,7 @@ class proxy
 
         [$errcode, $errmsg, $order_id, $neterr] = refill\RefillFactory::instance()->add($mchid, $buyer_id, $amount, $card_no,
             $mch_order, $idcard, $card_name, $notify_url, $quality,$org_quality,
-            $order_time, $commit_times, $last_order_id,$card_type,$regin_no);
+            $order_time, $commit_times, $last_order_id,$card_type,$regin_no,$quantity);
         $params['commit_times'] += 1;
         $commit_times += 1;
 
@@ -166,22 +167,22 @@ class proxy
         $last_order_id = $params['order_id'] ?? 0;
 
         $org_quality = intval($params['org_quality']) ?? 0;
-        $card_type   = intval($params['card_type']) ?? 0;
-        $regin_no   = intval($params['regin_no']) ?? 0;
+        $card_type   = intval($params['card_type']);
+        $regin_no   = 0;
 
-        Log::record("proxy::add mch_order={$mch_order} card_no = {$card_no}",Log::DEBUG);
+        $product_code = $params['product_code'];
+        $quantity = intval($params['quantity']);
+        $third_card_type = $params['card_type'];
+
+        $third_params = ['product_code' => $product_code,
+            'quantity' => $quantity,
+            'third_card_type' => $third_card_type];
 
         refill\util::incr_user_commit($card_type,$amount);
 
         [$errcode, $errmsg, $order_id, $neterr] = refill\RefillFactory::instance()->add($mchid, $buyer_id, $amount, $card_no,
-            $mch_order, $idcard, $card_name, $notify_url, $quality,$org_quality,
-            $order_time, $commit_times, $last_order_id,$card_type,$regin_no);
-        $params['commit_times'] += 1;
-        $commit_times += 1;
-
-        if(!empty($mch_order) && $last_order_id == 0 && $order_id > 0) {
-            refill\util::pop_queue($mchid,$mch_order);
-        }
+            $mch_order, $idcard, $card_name, $notify_url, $org_quality,$org_quality,
+            $order_time, $commit_times, $last_order_id,$card_type,$regin_no,$third_params);
 
         if($errcode !== true)
         {