Quellcode durchsuchen

Merge branch 'rthrid' of 39.97.239.116:gyfl/xyzshop into rthrid

ayHaru vor 4 Jahren
Ursprung
Commit
eca3af3efd

+ 16 - 4
admin/control/merchant.php

@@ -933,7 +933,12 @@ class merchantControl extends SystemControl
             $tmp[] = array('data'=>$v['card_no']);
             $tmp[] = array('data'=>$this->scard_type($v['card_type']));
             $tmp[] = array('data'=>date('Y-m-d H:i:s',$v['order_time']));
-            $tmp[] = array('data'=>date('Y-m-d H:i:s',$v['notify_time']));
+            if(empty($v['notify_time'])) {
+                $tmp[] = array('data'=>'');
+            }else{
+                $tmp[] = array('data'=>date('Y-m-d H:i:s',$v['notify_time']));
+            }
+
             $tmp[] = array('data'=>$v['official_sn']);
             $tmp[] = array('data'=>orderState($v));
             $tmp[] = array('data'=>$v['mch_amount']);
@@ -1488,9 +1493,11 @@ class merchantControl extends SystemControl
         $condition['vr_order.order_state'] = ORDER_STATE_SEND;
 
         $condition['refill_order.order_time'] = ['lt', (time() - 1800)];
-        $merchant_list = Model('')->table('merchant')->limit(1000)->select();
-        foreach ($merchant_list as $key => $value) {
-            $merchants[$value['mchid']] = $value;
+        if (!empty($_GET['mchid'])) {
+            $condition['refill_order.mchid'] = $_GET['mchid'];
+        }
+        if (!empty($_GET['store_id'])) {
+            $condition['vr_order.store_id'] = $_GET['store_id'];
         }
         $time_cond = [
             ['between', [(time() - 3600), (time() - 1800)]],
@@ -1540,6 +1547,11 @@ class merchantControl extends SystemControl
             ->field('count(*) as order_count ,sum(refill_amount) as refill_amounts, sum(channel_amount) as channel_amounts, sum(mch_amount) as mch_amounts')
             ->where($condition)->find();
         $count = $this->refill_stat($condition,$time_cond);
+
+        $merchant_list = Model('')->table('merchant')->limit(1000)->select();
+        foreach ($merchant_list as $key => $value) {
+            $merchants[$value['mchid']] = $value;
+        }
         foreach ($order_list as $order_id => $order_info) {
             $order_list[$order_id]['card_type_text'] = $this->scard_type($order_info['card_type']);
             $order_list[$order_id]['mch_name'] = $merchants[$order_info['mchid']]['company_name'];

+ 26 - 1
admin/templates/default/provider.group.set.php

@@ -24,6 +24,9 @@
                 <th>
                 <a href="JavaScript:void(0);" class="btn" id="emptyBtn"><span>清空</span></a>
                 </th>
+                <th class="w50 align-center">
+                    全选
+                </th>
                 <?php foreach ($output['amounts'] as $amount){?>
                 <th class="w50 align-center"><?php echo $amount;?></th>
                 <?php }?>
@@ -34,9 +37,12 @@
                     <?php foreach ($output['providers'] as $provider){?>
                         <tr class="trFlex">
                             <td class="w180"><?php echo $provider['name'];?></td>
+                            <td class="w50 align-center">
+                                <input type="checkbox" class="w50 checkAll">
+                            </td>
                             <?php foreach ($output['amounts'] as $amount){?>
                             <td class="w50 align-center">
-                                <input type="checkbox" class="w50" name="info[]" style="vertical-align: middle;"
+                                <input type="checkbox" class="w50 input" name="info[]" style="vertical-align: middle;"
                                        value="<?php echo "{$_GET['quality']}-{$provider['provider_name']}-{$provider['card_type']}-{$amount}-{$provider['provider_id']}";?>"
                                        <?php if(in_array("{$_GET['quality']}-{$provider['provider_name']}-{$provider['card_type']}-{$amount}-{$provider['provider_id']}", $output['sel_data'])){ echo 'checked';}?>
                                 />
@@ -84,5 +90,24 @@
                 }
             })
         })
+        // 全选
+        $('.checkAll').click(function () {
+            let hang = $(this).parent().parent().prevAll().length + 1
+            if ($(this).is(':checked')) {
+                $('.input').each(function () {
+                    let inputH = $(this).parent().parent().prevAll().length + 1
+                    if (hang == inputH) {
+                        $(this).attr("checked",true)
+                    }
+                })
+            } else {
+                $('.input').each(function () {
+                    let inputH = $(this).parent().parent().prevAll().length + 1
+                    if (hang == inputH) {
+                        $(this).attr("checked",false)
+                    }
+                })
+            }
+        })
     });
 </script>

+ 1 - 0
admin/templates/default/refill.order.index.php

@@ -378,6 +378,7 @@
             $('input[name="export"]').val('1');
             $('input[name="op"]').val('refill_order');
             $('#formSearch').submit();
+            $('input[name="export"]').val('');
         })
         // 日期选择器
         laydate.render({

+ 2 - 2
data/config/dev/base.ini.php

@@ -45,8 +45,8 @@ $config['gip'] 		= 0;
 $config['dbdriver'] = 'mysqli';
 $config['tablepre']	= 'lrlz_';
 
-define('SSH_TUNEL_PROD','local');
-//define('SSH_TUNEL_PROD','xyz');
+//define('SSH_TUNEL_PROD','local');
+define('SSH_TUNEL_PROD','xyz');
 //define('SSH_TUNEL_PROD','lingzh');
 
 if(SSH_TUNEL_PROD ==='local') {

+ 15 - 1
data/config/dev/refill.ini.php

@@ -351,4 +351,18 @@ $phone_providers = [
     ['name' => 'weiyi', 'cfg' => $weiyi_phone],
     ['name' => 'tonglu', 'cfg' => $tonglu_phone],
 ];
-$config['phone_providers'] = $phone_providers;
+$config['phone_providers'] = $phone_providers;
+
+
+$config['refill_third_specs'] = [100];
+
+$sctongqian = ['name' => 'tonglu', 'store_id' => 34,'qualitys' => '4',
+    'amount' => [
+        100 => [['goods_id' => 6426, 'price' => 99, 'quality' => 4, 'card_type' => 'chinamobile,chinaunicom,chinatelecom']],
+    ],
+    'official_sn' => true, 'refill_type' => 'api'];
+
+$third_providers = [
+    ['name' => 'sctongqian', 'cfg' => $sctongqian]
+];
+$config['third_providers'] = $third_providers;

+ 13 - 0
data/model/thrid_refill.model.php

@@ -0,0 +1,13 @@
+<?php
+
+declare(strict_types=0);
+
+defined('InShopNC') or exit('Access Invalid!');
+
+class thrid_refillModel extends Model
+{
+    public function getProviderProduct($store_id,$goods_id,$system_code)
+    {
+        return $this->table('third_proprice')->where(['store_id' => $store_id,'goods_id' => $goods_id,'system_code' => $system_code])->field('*')->find();
+    }
+}

+ 7 - 1
docker/conf/nginx/nginx-win-http.conf

@@ -29,7 +29,7 @@ http
     {
     	listen       80;
         set  $folder_name /var/www/html;
-        server_name 192.168.1.195;
+        server_name 192.168.1.195 www.xyxy.com;
         root $folder_name;
         index index.html index.php; 
     	client_max_body_size 100m;
@@ -83,4 +83,10 @@ http
             include        fastcgi_params;
         }
     }
+
+    server {
+        listen       80;
+        server_name xyxyxy.com;
+        return 301 http://www.xyxy.com;
+    }
 }

+ 6 - 147
docker/conf/nginx/nginx-xyz-https.conf

@@ -131,150 +131,9 @@ http
         }
     }
 
-    server
-        {
-            listen       443 ssl;
-            set  $folder_name /var/www/html;
-            server_name xyzshops.cn;
-            root $folder_name;
-
-            ssl_certificate      cert/www.xyzshops.cn.pem;
-            ssl_certificate_key  cert/www.xyzshops.cn.key;
-
-            ssl_session_cache    shared:SSL:1m;
-            ssl_session_timeout  5m;
-
-            ssl_ciphers ECDHE-RSA-AES128-GCM-SHA256:ECDHE:ECDH:AES:HIGH:!NULL:!aNULL:!MD5:!ADH:!RC4;  #使用此加密套件。
-            ssl_protocols TLSv1 TLSv1.1 TLSv1.2;   #使用该协议进行配置。
-            ssl_prefer_server_ciphers on;
-
-            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 /plot {
-                root $folder_name;
-                proxy_pass         http://172.26.105.127:5000;
-                  proxy_redirect     off;
-
-                proxy_set_header   Host                 $host;
-                proxy_set_header   X-Real-IP            $remote_addr;
-                proxy_set_header   X-Forwarded-For      $proxy_add_x_forwarded_for;
-                proxy_set_header   X-Forwarded-Proto    $scheme;
-            }
-
-            location /merchant {
-                root $folder_name;
-                autoindex on;
-                index  index.html index.htm index.php;
-                try_files $uri $uri/ /merchant/index.html;
-            }
-            location ~ /mobile/[/\w]+\.php$ {
-                root           $folder_name;
-                fastcgi_pass   docker.hostip:9100;
-                fastcgi_index  index.php;
-                fastcgi_param  SCRIPT_FILENAME  $folder_name$fastcgi_script_name;
-                fastcgi_param  SIGN $http_sign;
-                include fastcgi_params;
-            }
-
-            location ~ /mobile/[/\w]+\.html$ {
-                try_files $uri $uri/ /mobile/index.html;
-            }
-
-            location ~ /racc/[/\w]+\.php$ {
-                root           $folder_name;
-                fastcgi_pass   docker.hostip:9101;
-                fastcgi_index  index.php;
-                fastcgi_param  SCRIPT_FILENAME  $folder_name$fastcgi_script_name;
-                fastcgi_param  SIGN $http_sign;
-                include fastcgi_params;
-            }
-
-            location ~ /mchsrv/[/\w]+\.php$ {
-                root           $folder_name;
-                fastcgi_pass   docker.hostip:9102;
-                fastcgi_index  index.php;
-                fastcgi_param  SCRIPT_FILENAME  $folder_name$fastcgi_script_name;
-                fastcgi_param SIGN $http_sign;
-                include fastcgi_params;
-            }
-
-            location ~ \.php$ {
-                add_header Cache-Control no-store;
-                root           $folder_name;
-                fastcgi_pass   docker.hostip:9000;
-                fastcgi_index  index.php;
-                fastcgi_param  SCRIPT_FILENAME  $folder_name$fastcgi_script_name;
-                include        fastcgi_params;
-            }
-        }
-
-    server
-        {
-            listen       80;
-            set  $folder_name /var/www/html;
-            server_name 121.89.223.81 www.xyzshops.cn xyzshops.cn;
-            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 ~ \.php$ {
-                add_header Cache-Control no-store;
-                root           $folder_name;
-                fastcgi_pass   docker.hostip:9000;
-                fastcgi_index  index.php;
-                fastcgi_param  SCRIPT_FILENAME  $folder_name$fastcgi_script_name;
-                include        fastcgi_params;
-            }
-        }
-}
+    server {
+        listen       443 ssl;
+        server_name xyzshops.cn;
+        return 301 https://www.xyzshops.cn;
+    }
+}

+ 2 - 0
helper/mtopcard/mtopcard.php

@@ -15,6 +15,8 @@ const ChinaMobileCard  = 4;        //手机卡
 const ChinaUnicomCard  = 5;        //手机卡
 const ChinaTelecomCard = 6;        //手机卡
 
+const ThirdRefillCard  = 7;        //三方账号充值
+
 
 #卡的状态
 const CardNormal = 1;

+ 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)
+    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("没有协商商品购买价格.");

+ 2 - 2
helper/refill/IRefill.php

@@ -128,7 +128,7 @@ abstract class IRefill
         return $this->mAmountTypes;
     }
 
-    public function goods($quality,int $amount,int $card_type)
+    public function goods($quality,int $amount,int $card_type,$other)
     {
         $maps = $this->mAmountTypes[$quality] ?? [];
         $key = "{$amount}-{$card_type}";
@@ -137,7 +137,7 @@ abstract class IRefill
             return [$params['goods_id'], round($params['price'],2)];
         }
         else {
-            return [];
+            return [0,0];
         }
     }
 

+ 6 - 6
helper/refill/RefillBase.php

@@ -235,9 +235,9 @@ 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)
+                        $order_time, $commit_times, $last_orderid = 0, $card_type = 0, $regin_no = 0, $quantity = 1, $third_params = [])
     {
-        if($card_type == 0) {
+        if($card_type == 0 && $card_type != mtopcard\ThirdRefillCard ) {
             $card_type = mtopcard\card_type($card_no,$regin_no);
         }
         [$providers, $overload] = $this->mPolicy->find_providers($mchid,$amount, $card_type, $quality, $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) {
@@ -281,13 +281,13 @@ class RefillBase
             Log::record("select channel name = {$channel_name}",Log::DEBUG);
 
             //通道价格大于客户价格,换通道.
-            [$goods_id, $price] = $provider->goods($quality,$amount,$card_type);
-            if ($price > $mch_amount) continue;
+            [$goods_id, $price] = $provider->goods($quality,$amount,$card_type,$third_params);
+            if ($price > $mch_amount || $goods_id <= 0) continue;
 
             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'] ?? '';

+ 18 - 0
helper/refill/api/lingzh/sctongqian/RefillPhone.php

@@ -14,6 +14,23 @@ class RefillPhone extends refill\IRefillPhone
         parent::__construct($cfgs);
     }
 
+    public function goods($quality,int $amount,int $card_type,$other)
+    {
+        [$goods_id, $price] = parent::goods($quality,$amount,$card_type,$other);
+        if($goods_id <= 0) return [0,0];
+
+        $store_id = $this->mStoreID;
+        $pcode = $other['product_code'];
+        $thrid_refill = Model('thrid_refill');
+        $product = $thrid_refill->getProviderProduct($store_id,$goods_id,$pcode);
+        if(empty($product)) {
+            Log::record("cannot find provider's produce where name={$this->mName}, goods_id = {$goods_id} pcode={$pcode}",Log::ERR);
+            return [0,0];
+        } else {
+            return [$goods_id,ncPriceFormat($product['channel_amount'])];
+        }
+    }
+
     private function req_params(string $order_sn, string $product_code)
     {
         $params['AppKey'] = config::APP_KEY;
@@ -156,4 +173,5 @@ class RefillPhone extends refill\IRefillPhone
         $content .= $params['ProductCode'] . $params['TimesTamp'] . $params['Version'] . config::App_Secret;
         return strtoupper(md5($content));
     }
+
 }

+ 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;
     }
-
 }
 
 //通道控制

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

@@ -72,6 +72,9 @@ class policy extends ProviderManager implements IPolicy
                 if (empty($ret)) {
                     return [[],false];
                 }
+                else {
+                    $names = $ret;
+                }
             }
         }
 
@@ -102,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);
     }

+ 12 - 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",
@@ -218,6 +220,16 @@ class util
         }
     }
 
+    public static function push_addthird($params)
+    {
+        try {
+            queue\DispatcherClient::instance()->push('addthird', $params);
+            return true;
+        } catch (Exception $ex) {
+            return false;
+        }
+    }
+
     public static function push_notify($chname, $params)
     {
         try {

+ 102 - 0
racc/control/lzrefill.php

@@ -108,6 +108,108 @@ class lzrefillControl extends lzbaseControl
         }
     }
 
+    private function check_third($params)
+    {
+        if(empty($params['product_code'])) {
+            return -9;
+        }
+        if(empty($params['quantity'])) {
+            return -9;
+        }
+
+        $card_no = $params['card_no'];
+        if(empty($card_no)) {
+            return -9;
+        }
+
+        $third_card_type = $params['card_type'];
+        if(empty($third_card_type)) {
+            return -9;
+        }
+
+        if(empty($params['notifyurl'])) {
+            return -9;
+        }
+
+        if(empty($params['ord'])) {
+            return -9;
+        }
+
+        if(empty($params['tim'])) {
+            return -9;
+        }
+
+        $tim = strtotime($params['tim']);
+        if($tim === false) {
+            return -9;
+        }
+
+        $cur = time();
+        $start = strtotime(date('Y-m-d',$cur - 1800));
+        if($tim < $start || $tim > $cur + 1800) {
+            return -9;
+        }
+
+        return true;
+    }
+
+    private function check_pcode()
+    {
+        //todo
+    }
+
+    public function add_thirdOp()
+    {
+        $code = $this->check_third($_GET);
+        if($code !== true) {
+            return self::outerr($code,$this->merchant_available);
+        }
+
+        $amount = refill\util::ThirdRefillAmount;
+        $mch_order = $_GET['ord'];
+        $notify_url = $_GET['notifyurl'];
+
+        //三方充值没有质量
+        $quality = 1;
+        $card_type = mtopcard\ThirdRefillCard;
+
+        $product_code = $_GET['product_code'];
+        $card_no = $_GET['mob'];
+        $quantity = $_GET['quantity'];
+        $third_card_type = $_GET['card_type'];
+
+        //此处判断是对的
+        if($this->member_available <= 0) {
+            return self::outerr(4,$this->merchant_available);
+        }
+
+        if(!$this->check_mchorder($this->mchid(),$mch_order)) {
+            return self::outerr(11,$this->merchant_available);
+        }
+
+        $params = [ 'mchid' => $this->mchid(),
+            'buyer_id' => $this->adminid(),
+            'amount' => $amount,
+            '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
+        ];
+
+        $ret = refill\util::push_addthird($params);
+        if($ret) {
+            return self::outsuccess($this->merchant_available);
+        }
+        else {
+            return self::outerr(-6,$this->merchant_available);
+        }
+    }
+
     private function can_refill($cardno)
     {
         $card_info = refill\util::read_card($cardno);

+ 3 - 0
rdispatcher/processor.php

@@ -56,6 +56,9 @@ class processor extends queue\ILooper
                         $order_id = intval($params['order_id']);
                         $this->mProxy->manual_cancel($order_id);
                     }
+                    if ($method == 'addthird') {
+                        $this->mProxy->addthird($params);
+                    }
                     else {
                         Log::record("Error Method={$method}", Log::DEBUG);
                     }

+ 81 - 2
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;
 
@@ -141,8 +142,86 @@ class proxy
     public function manual_success($order_id)
     {
         refill\RefillFactory::instance()->manual_success($order_id);
-    }    public function manual_cancel($order_id)
+    }
+    public function manual_cancel($order_id)
     {
         refill\RefillFactory::instance()->manual_cancel($order_id);
     }
+
+    public function addthird($params)
+    {
+        $refill_order = Model('refill_order');
+
+        $mchid = $params['mchid'];
+        $buyer_id = $params['buyer_id'];
+        $amount = intval($params['amount']);
+
+        $card_no = $params['card_no'];
+        $mch_order = $params['mch_order'];
+        $notify_url = $params['notify_url'];
+        $idcard = $params['idcard'] ?? '';
+        $card_name = $params['card_name'] ?? '';
+
+        $order_time = $params['order_time'] ?? time();
+        $commit_times = $params['commit_times'] ?? 0;
+        $last_order_id = $params['order_id'] ?? 0;
+
+        $org_quality = intval($params['org_quality']) ?? 0;
+        $card_type   = intval($params['card_type']);
+        $regin_no   = 0;
+
+        $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, $org_quality,$org_quality,
+            $order_time, $commit_times, $last_order_id,$card_type,$regin_no,$third_params);
+
+        if($errcode !== true)
+        {
+            $fNotify = true;
+            if(($errcode === refill\errcode::MERCHANT_REFILL_ERROR && $neterr) || $errcode == refill\errcode::PROVIDER_OVERLOAD || $errcode == errcode::MERCHANT_PRICE_UNSETTING)
+            {
+                [$org_quality,$quality] = refill\RefillFactory::instance()->find_quality($mchid,$amount,$card_type,$org_quality,$commit_times,time() - $order_time);
+                if ($quality > 0) {
+                    $fNotify = false;
+                    $params['order_id'] = $order_id;
+                    if($order_id > 0) {
+                        $refill_order->edit($order_id, ['is_retrying' => 1]);
+                    }
+                    if(defined('USE_COROUTINE') && USE_COROUTINE && $errcode == refill\errcode::PROVIDER_OVERLOAD) {
+                        \Swoole\Coroutine::sleep(1);
+                    }
+                    refill\util::push_add($params);
+                }
+            }
+
+            if($fNotify)
+            {
+                if ($order_id === 0)
+                {
+                    $order_info = $this->latest_order($refill_order, $mchid, $mch_order);
+                    if (empty($order_info)) {
+                        $order_id = refill\RefillFactory::instance()->zero_order($mchid, $buyer_id, $amount, $card_no,
+                            $mch_order, $idcard, $card_name, $notify_url, $quality, $org_quality, $order_time, $commit_times, $errmsg);
+                        refill\util::pop_queue($mchid,$mch_order);
+                    } else {
+                        $order_id = $order_info['order_id'];
+                    }
+                }
+                else {
+                    $refill_order->edit($order_id, ['notify_time' => time(), 'notify_state' => 1,'is_retrying' => 0]);
+                }
+
+                QueueClient::push("NotifyMerchantComplete", ['order_id' => $order_id,'manual' => false]);
+            }
+        }
+    }
 }

+ 30 - 0
test/TestThirdRefill.php

@@ -0,0 +1,30 @@
+<?php
+
+
+use PHPUnit\Framework\TestCase;
+
+define('APP_ID', 'test');
+define('BASE_ROOT_PATH', str_replace('/test', '', dirname(__FILE__)));
+
+require_once(BASE_ROOT_PATH . '/global.php');
+require_once(BASE_CORE_PATH . '/lrlz.php');
+require_once(BASE_ROOT_PATH . '/fooder.php');
+
+require_once(BASE_CORE_PATH . '/framework/function/http.php');
+require_once(BASE_HELPER_PATH . '/refill/RefillFactory.php');
+require_once(BASE_HELPER_PATH . '/mtopcard/mtopcard.php');
+
+class TestThirdRefill extends TestCase
+{
+    public static function setUpBeforeClass() : void
+    {
+        Base::run_util();
+    }
+
+    public function testProviderPrice()
+    {
+        $thrid_refill = Model('thrid_refill');
+        $info = $thrid_refill->getProviderProduct(34,1000,'LZPLM100591');
+
+    }
+}