瀏覽代碼

Merge branch 'inner_oil' into iOIL

stanley-king 4 年之前
父節點
當前提交
4de10e1729

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

@@ -107,4 +107,5 @@ $config['area_version'] = 5;
 $config['appjump_prefix'] = 'xyzshop://www.xyzshops.com';
 
 $config['client_setting'] = ['running' => 174,'home' => 0];
-$config['wsd_bradge_port'] = 60987;
+$config['wsd_bradge_port'] = 60987;
+$config['card_key_stores'] = [6];

+ 35 - 26
data/config/dev/refill.ini.php

@@ -1,38 +1,47 @@
 <?php
 
 
-$suhc_oil = ['name' => 'suhc','store_id' => 8,'card_type' => ['sinopec'],
-    'amount' => [100 => ['goods_id' => 6226,'price' => 96.8],
-        200 => ['goods_id' => 6227,'price' => 193.6],
-        500 => ['goods_id' => 6228,'price' => 484],
-        1000=> ['goods_id' => 6229,'price' => 968],
-        2000=> ['goods_id' => 6230,'price' => 1976]],
-    'period' => ['start' => '8:30','end' => '22:30'],'refill_type' => 'api'];
-
-$suhctm_oil = ['name' => 'suhctm','store_id' => 8,'card_type' => ['sinopec'],
-    'amount' => [100 => ['goods_id' => 6226,'price' => 96.8],
-        200 => ['goods_id' => 6227,'price' => 193.6],
-        500 => ['goods_id' => 6228,'price' => 484],
-        1000=> ['goods_id' => 6229,'price' => 968],
-        2000=> ['goods_id' => 6230,'price' => 1976]],
-    'period' => ['start' => '8:30','end' => '22:30'],'refill_type' => 'api'];
-
-$oil_providers = ['suhc' => $suhc_oil,'suhctm' => $suhctm_oil];
+$suhc_oil = ['name' => 'suhc', 'store_id' => 8, 'card_type' => ['sinopec'],
+    'amount' => [100 => ['goods_id' => 6226, 'price' => 96.8],
+        200 => ['goods_id' => 6227, 'price' => 193.6],
+        500 => ['goods_id' => 6228, 'price' => 484],
+        1000 => ['goods_id' => 6229, 'price' => 968],
+        2000 => ['goods_id' => 6230, 'price' => 1976]],
+    'period' => ['start' => '8:30', 'end' => '22:30'], 'refill_type' => 'api'];
+
+$suhctm_oil = ['name' => 'suhctm', 'store_id' => 8, 'card_type' => ['sinopec'],
+    'amount' => [100 => ['goods_id' => 6226, 'price' => 96.8],
+        200 => ['goods_id' => 6227, 'price' => 193.6],
+        500 => ['goods_id' => 6228, 'price' => 484],
+        1000 => ['goods_id' => 6229, 'price' => 968],
+        2000 => ['goods_id' => 6230, 'price' => 1976]],
+    'period' => ['start' => '8:30', 'end' => '22:30'], 'refill_type' => 'api'];
+
+$lx_oil = ['name' => 'lx', 'store_id' => 10, 'card_type' => ['sinopec'],
+    'amount' => [100 => ['goods_id' => 6234, 'price' => 95.5],
+        200 => ['goods_id' => 6235, 'price' => 191],
+        500 => ['goods_id' => 6236, 'price' => 477.5],
+        1000 => ['goods_id' => 6237, 'price' => 955],
+        2000 => ['goods_id' => 6238, 'price' => 1910]],
+    'period' => ['start' => '8:30', 'end' => '22:30'], 'refill_type' => 'inner_store'];
+
+//$oil_providers = ['suhc' => $suhc_oil, 'suhctm' => $suhctm_oil,'lx' => $lx_oil];
+$oil_providers = ['lx' => $lx_oil];
 $config['oil_providers'] = $oil_providers;
 
 
-$beixt_phone = ['name' => 'beixt','store_id' => 9,'card_type' => ['chinamobile','chinaunicom','chinatelecom'],
-    'amount' => [50 => ['goods_id' => 6231,'price' => 48.75],
-        100 => ['goods_id' => 6232,'price' => 97.5],
-        200 => ['goods_id' => 6233,'price' => 195]],
+$beixt_phone = ['name' => 'beixt', 'store_id' => 9, 'card_type' => ['chinamobile', 'chinaunicom', 'chinatelecom'],
+    'amount' => [50 => ['goods_id' => 6231, 'price' => 48.75],
+        100 => ['goods_id' => 6232, 'price' => 97.5],
+        200 => ['goods_id' => 6233, 'price' => 195]],
     'refill_type' => 'api'];
 
-$bxtwt_phone = ['name' => 'bxtwt','store_id' => 10,'card_type' => ['chinamobile','chinaunicom','chinatelecom'],
-    'amount' => [50 => ['goods_id' => 6298,'price' => 48],
-        100 => ['goods_id' => 6299,'price' => 96],
-        200 => ['goods_id' => 6300,'price' => 192]],
+$bxtwt_phone = ['name' => 'bxtwt', 'store_id' => 10, 'card_type' => ['chinamobile', 'chinaunicom', 'chinatelecom'],
+    'amount' => [50 => ['goods_id' => 6298, 'price' => 48],
+        100 => ['goods_id' => 6299, 'price' => 96],
+        200 => ['goods_id' => 6300, 'price' => 192]],
     'refill_type' => 'api'];
 
-$phone_providers = ['beixt' => $beixt_phone , 'bxtwt' => $bxtwt_phone];
+$phone_providers = ['beixt' => $beixt_phone, 'bxtwt' => $bxtwt_phone];
 //$phone_providers = ['beixt' => $beixt_phone];
 $config['phone_providers'] = $phone_providers;

+ 1 - 1
helper/fcgi_server.php

@@ -29,7 +29,7 @@ class fcgi_server
             'cmbpay_notify.php','cmbpay_sign.php','wxauthor.php','api/wxLogin/index.php','api/wxLogin/callback.php',
             'signature.php',
             'refill_suhc.php','refill_suhctm.php','refill_beixt.php','refill_bxtwt.php','refill_bjb.php','refill_xyz.php',
-            'refill_zzx.php',
+            'refill_zzx.php','refill_inner.php',
             'bridge_shr.php'
         ];
         $path = BASE_ROOT_PATH . '/mobile/';

+ 24 - 9
helper/refill/RefillFactory.php

@@ -37,6 +37,10 @@ require_once(BASE_HELPER_PATH . '/refill/zzx/RefillOil.php');
 require_once(BASE_HELPER_PATH . '/refill/zzx/RefillPhone.php');
 require_once(BASE_HELPER_PATH . '/refill/zzx/RefillCallBack.php');
 
+require_once(BASE_HELPER_PATH . '/refill/lx/RefillOil.php');
+require_once(BASE_HELPER_PATH . '/refill/lx/RefillPhone.php');
+require_once(BASE_HELPER_PATH . '/refill/lx/RefillCallBack.php');
+
 use Log;
 use mtopcard;
 use QueueClient;
@@ -282,7 +286,7 @@ class RefillFactory
 //            }
 
             $period = time() - $refill['order_time'];
-            if($period >= 15 * 60) {
+            if($period >= 10 * 60) {
                 return false;
             }
 
@@ -303,12 +307,15 @@ class RefillFactory
         $commit_times = $refill_info['commit_times'] + 1;
         $order_time = $refill_info['order_time'];
 
-        [$success,$err] = $this->add($mchid,$buyer_id,$amount,$card_no,$mch_order,$notify_url,$order_time,$commit_times);
+        $idcard = $refill_info['idcard'] ?? '';
+        $card_name = $refill_info['card_name'] ?? '';
+
+        [$success, $err] = $this->add($mchid, $buyer_id, $amount, $card_no, $mch_order, $idcard, $card_name, $notify_url, $order_time, $commit_times);
 
         return ($success === true);
     }
 
-    public function add($mchid, $buyer_id, $amount, $card_no, $mch_order, $notify_url, $order_time = 0, $commit_times = 0)
+    public function add($mchid, $buyer_id, $amount, $card_no, $mch_order, $idcard, $card_name, $notify_url, $order_time = 0, $commit_times = 0)
     {
         $card_type = mtopcard\card_type($card_no);
         $providers = $this->find_providers($amount, $card_type);
@@ -342,7 +349,8 @@ class RefillFactory
         usort($providers, $ascending);
 
         $refill_state = false;
-        foreach ($providers as $provider) {
+        foreach ($providers as $provider)
+        {
             $channel_name = $provider->name();
             [$goods_id, $price] = $provider->goods($amount);
 
@@ -362,7 +370,8 @@ class RefillFactory
             $result = $logic_buy_virtual->buyStep3($input, $buyer_id, [$calc, 'calc_vorder_amount'], true);
 
             $mod_refill = Model('refill_order');
-            if ($result['state'] === true) {
+            if ($result['state'] === true)
+            {
                 $order_sn = $result['data']['order_sn'];
                 $order_id = $result['data']['order_id'];
 
@@ -372,6 +381,7 @@ class RefillFactory
                 //虚拟订单表信息扩展
                 $orderext = ['order_id' => $order_id, 'order_sn' => $order_sn, 'mchid' => $mchid,
                     'refill_amount' => $amount, 'mch_order' => $mch_order,
+                    'idcard' => $idcard, 'card_name' => $card_name,
                     'notify_url' => $notify_url, 'channel_name' => $channel_name,
                     'mch_amount' => $mch_amount, 'channel_amount' => $price,
                     'order_time' => $order_time, 'commit_times' => $commit_times,
@@ -381,14 +391,19 @@ class RefillFactory
                 continue;
             }
 
-            $params = ['order_sn' => $order_sn];
+            $params = ['order_sn' => $order_sn, 'idcard' => $idcard, 'card_name' => $card_name];
             [$state, $err] = $provider->add($card_no, $card_type, $amount, $params);
-            if ($state) {
+            if ($state)
+            {
                 $trade_no = $err;
-                $logic_vr_order = Logic("vr_order");
-                $logic_vr_order->changeOrderStateSend($order_id);
+                if($provider->refill_type() == 'api') {
+                    $logic_vr_order = Logic("vr_order");
+                    $logic_vr_order->changeOrderStateSend($order_id);
+                }
+
                 $data = ['commit_time' => time(), 'ch_trade_no' => $trade_no];
                 $mod_refill->edit($order_id, $data);
+
                 $refill_state = true;
                 break;
             } else {

+ 29 - 0
helper/refill/lx/RefillCallBack.php

@@ -0,0 +1,29 @@
+<?php
+
+
+namespace refill\lx;
+
+use refill;
+
+class RefillCallBack implements refill\IRefillCallBack
+{
+    public function verify($params): bool
+    {
+        return true;
+    }
+
+    //        $params = ['state_type' => 'order_cancel','order_id' => 313,'channel_name' => 'lx'];
+    public function notify($params)
+    {
+        $state = $params['state_type'];
+        $order_id = $params['order_id'];
+
+        if ($state == 'order_success') {
+            return [$order_id, true, false, true];
+        } elseif ($state == 'order_cancel') {
+            return [$order_id, false, false, true];
+        } else {
+            return [$order_id, false, false, false];
+        }
+    }
+}

+ 55 - 0
helper/refill/lx/RefillOil.php

@@ -0,0 +1,55 @@
+<?php
+
+
+namespace refill\lx;
+
+require_once(BASE_HELPER_PATH . '/refill/lx/config.php');
+
+
+use refill;
+use mtopcard;
+use Log;
+
+class RefillOil extends refill\IRefillOil
+{
+    public function __construct($cfgs)
+    {
+        parent::__construct($cfgs);
+    }
+
+    public function add($card_no, $card_type, $amount, $input)
+    {
+        //lx 加油需要身份证姓名
+        if (empty($input['card_name'])) {
+            return [false, '参数没有包含身份证姓名:card_name'];
+        }
+        else {
+            return [true, $input['order_sn']];
+        }
+    }
+
+    public function query($refill_info)
+    {
+        return [true,''];
+
+//        $params['batchid'] = $refill_info['ch_trade_no'];
+//        $params['orgid'] = config::ORGID;
+//        $params['cardno'] = $refill_info['card_no'];
+//        $params['onlystr'] = $refill_info['order_sn'];
+//        $sign = $this->sign($params);
+//        $params['sign'] = $sign;
+//
+//        $resp = http_request(config::ORDER_QUERY_URL, $params, 'POST', false, config::ExtHeaders);
+//        if ($resp === false) {
+//            return [false, '系统错误'];
+//        } else {
+//            Log::record($resp, Log::DEBUG);
+//            $resp = json_decode($resp, true);
+//            if ($resp['state'] == 0) {
+//                return [true, $resp['data']];
+//            } else {
+//                return [false, $resp['msg']];
+//            }
+//        }
+    }
+}

+ 24 - 0
helper/refill/lx/RefillPhone.php

@@ -0,0 +1,24 @@
+<?php
+
+
+namespace refill\lx;
+
+
+use refill\IRefillPhone;
+
+class RefillPhone extends IRefillPhone
+{
+    public function __construct($cfgs)
+    {
+        parent::__construct($cfgs);
+    }
+
+    public function add($card_no,$card_type,$amount,$input)
+    {
+        return [false,'No Implement'];
+    }
+    public function query($refill_info)
+    {
+        return [false,'No Implement'];
+    }
+}

+ 10 - 0
helper/refill/lx/config.php

@@ -0,0 +1,10 @@
+<?php
+
+
+namespace refill\lx;
+
+
+class config
+{
+
+}

+ 32 - 1
helper/vrorder_helper.php

@@ -8,9 +8,40 @@ class vrorder_helper
     //提供给商家管理后台.
     public static function extend_order_info($order)
     {
+        $order_id = $order['order_id'];
+        $refill_order = Model('refill_order');
+        $refill_info = $refill_order->getOrderInfo(['order_id' => $order_id]);
+
+        if(empty($refill_info)) {
+            return self::card_key_info($order);
+        } else {
+            return self::refill_info($refill_info);
+        }
+    }
+
+    private static function refill_info($refill_info)
+    {
+
+        if(empty($refill_info)) {
+            return [];
+        }
+        else {
+            $ret['接收卡'] = $refill_info['card_no'];
+            $ret['卡类别'] = mtopcard\scard_type($refill_info['card_type']);
+            $ret['身份证号码'] = $refill_info['idcard'];
+            $ret['身份证姓名'] = $refill_info['card_name'];
+//            $ret['卡号'] = $item['card_no'];
+//            $ret['卡密'] = $item['card_key'];
+
+            return $ret;
+
+        }
+    }
+
+    private static function card_key_info($order)
+    {
         global $config;
         $handlers = $config['vgoods_handlers'];
-
         $goods_id = $order['goods_id'];
         if(array_key_exists($goods_id,$handlers))
         {

+ 5 - 1
mobile/control/merchant_refill.php

@@ -88,6 +88,10 @@ class merchant_refillControl extends mbMerchantControl
         if(empty($card_no)){
             return self::outerr(errcode::ErrParamter, "卡号格式错误或未上传");
         }
+
+        $idcard = $params['idcard'] ?? '';
+        $card_name = $params['card_name'] ?? '';
+
         //成功个数、失败个数
         $success_no = $error_no = 0;
         $data = [];
@@ -104,7 +108,7 @@ class merchant_refillControl extends mbMerchantControl
             }
             else
             {
-                [$state,$err] = refill\RefillFactory::instance()->add($mchid,$merchant_info['admin_id'],$amount,$no,'','');
+                [$state, $err] = refill\RefillFactory::instance()->add($mchid, $merchant_info['admin_id'], $amount, $no, '', $idcard, $card_name, '');
                 $arr['state'] = $state;
                 $arr['err'] = $err;
                 if($state === true) {

+ 3 - 1
mobile/control/refill.php

@@ -82,8 +82,10 @@ class refillControl extends merchantControl
         $card_no = $_GET['cardno'];
         $notify_url = $_GET['notifyurl'];
         $mch_order = $_GET['order_sn']; //对方的order编号
+        $idcard = $_GET['idcard'] ?? '';
+        $card_name = $_GET['card_name'] ?? '';
 
-        [$state,$err] = refill\RefillFactory::instance()->add($this->mchid(),$this->adminid(),$amount,$card_no,$mch_order,$notify_url);
+        [$state, $err] = refill\RefillFactory::instance()->add($this->mchid(), $this->adminid(), $amount, $card_no, $mch_order, $idcard, $card_name, $notify_url);
         if($state === true) {
             return self::outsuccess(['state' => true]);
         }

+ 10 - 0
mobile/refill_inner.php

@@ -0,0 +1,10 @@
+<?php
+
+require_once(BASE_HELPER_PATH . '/refill/RefillFactory.php');
+
+$channel_name = $_POST['channel_name'];
+
+refill\RefillFactory::instance()->notify($channel_name,$_POST);
+
+echo ('success');
+

+ 51 - 13
shop/control/store_vr_order.php

@@ -9,6 +9,8 @@
 
 defined('InShopNC') or exit('Access Invalid!');
 require_once(BASE_HELPER_PATH . '/vrorder_helper.php');
+require_once(BASE_CORE_PATH . '/framework/function/http.php');
+
 
 class store_vr_orderControl extends BaseSellerControl
 {
@@ -72,7 +74,8 @@ class store_vr_orderControl extends BaseSellerControl
 	 * 卖家订单详情
 	 *
 	 */
-	public function show_orderOp() {
+	public function show_orderOp()
+    {
 	    $order_id = intval($_GET['order_id']);
 	    if ($order_id <= 0) {
 	        showMessage(Language::get('wrong_argument'),'','html','error');
@@ -106,6 +109,7 @@ class store_vr_orderControl extends BaseSellerControl
         }
 
         Tpl::output('order_info',$order_info);
+        Tpl::output('order_info',$order_info);
 		Tpl::showpage('store_vr_order.show');
 	}
 
@@ -122,23 +126,57 @@ class store_vr_orderControl extends BaseSellerControl
         $extra_info = vrorder_helper::extend_order_info($order_info);
         $order_info['extend_order_info'] = $extra_info;
 
-	    if ($_GET['state_type'] == 'order_cancel') {
-	        $result = $this->_order_cancel($order_info,$_POST);
-	    }
-        elseif ($_GET['state_type'] == 'order_send') {
-            $result = $this->_order_send($order_info,$_POST);
+        $order_id = $order_info['order_id'];
+        $refill_order = Model('refill_order');
+        $refill_info = $refill_order->getOrderInfo(['order_id' => $order_id]);
+
+        $isRefill = empty($refill_info) ? false : true;
+
+        if($isRefill)
+        {
+            $state_type = $_GET['state_type'];
+            if($state_type == 'order_send') {
+                $result = $this->_order_send($order_info,$_POST);
+                if(!$result['state']) {
+                    showDialog($result['msg'],'','error');
+                } else {
+                    showDialog($result['msg'],'reload','js');
+                }
+            }
+            else {
+                $order_id = $order_info['order_id'];
+                $params = ['state_type' => $state_type,'order_id' => $order_id,'channel_name' => $refill_info['channel_name']];
+                $resp = http_request(BASE_SITE_URL . '/mobile/refill_inner.php',$params,'POST');
+                if($resp !== 'success') {
+                    showDialog("失败",'','error');
+                } else {
+                    showDialog("成功",'reload','js');
+                }
+            }
         }
-        elseif ($_GET['state_type'] == 'order_success') {
-            $result = $this->_order_success($order_info,$_POST);
+        else
+        {
+            if ($_GET['state_type'] == 'order_cancel') {
+                $result = $this->_order_cancel($order_info,$_POST);
+            }
+            elseif ($_GET['state_type'] == 'order_send') {
+                $result = $this->_order_send($order_info,$_POST);
+            }
+            elseif ($_GET['state_type'] == 'order_success') {
+                $result = $this->_order_success($order_info,$_POST);
+            }
+
+            if(!$result['state']) {
+                showDialog($result['msg'],'','error');
+            } else {
+                showDialog($result['msg'],'reload','js');
+            }
         }
 
-	    if(!$result['state']) {
-	        showDialog($result['msg'],'','error');
-	    } else {
-	        showDialog($result['msg'],'reload','js');
-	    }
+
 	}
 
+
 	/**
 	 * 取消订单
 	 * @param arrty $order_info

+ 11 - 2
shop/templates/default/seller/store_vr_order.show.php

@@ -48,6 +48,8 @@
                 $uri = '';
             }
 
+            $cancel_uri = "index.php?act=store_vr_order&op=change_state&state_type=order_cancel&order_id={$order_id}&order_sn={$order_sn}";
+
             if(!empty($output['order_info']['extend_order_info'])) { ?>
               <dl class="line">
                   <dt>附加信息:</dt>
@@ -66,7 +68,7 @@
                  dialog_title="已经处理尚未到账订单"
                  dialog_id="buyer_order_send_order"
                  uri=<?php echo($uri) ?>
-                 id="order_action_success">订单已经处理了</a>
+                 id="order_action_success">开始处理订单</a>
               </dd>
              <?php } elseif ($output['order_info']['order_state'] == ORDER_STATE_SEND){ ?>
                  <a href="javascript:void(0)" class="ncsc-btn-mini" nc_type="dialog" dialog_width="480"
@@ -75,9 +77,16 @@
                     uri=<?php echo($uri) ?>
                     id="order_action_success">订单处理完成了</a>
                  </dd>
+                 <dd>
+                     <a href="javascript:void(0)" class="ncsc-btn-mini" nc_type="dialog" dialog_width="480"
+                        dialog_title="已经处理尚未到账订单"
+                        dialog_id="buyer_order_send_order"
+                        uri=<?php echo($cancel_uri) ?>
+                        id="order_action_success">取消订单</a>
+                 </dd>
              <?php }?>
-          </dl>
 
+          </dl>
           <?php } ?>
       </div>
     </div>

+ 1 - 0
test/TestRBridge.php

@@ -142,4 +142,5 @@ class TestRBridge extends TestCase
 
         return $sign;
     }
+
 }

+ 28 - 5
test/TestRefill.php

@@ -17,13 +17,13 @@ require_once(BASE_HELPER_PATH . '/mtopcard/mtopcard.php');
 const LocalTest = 1;
 const NetTest = 2;
 
-const CurrentTest = NetTest;
+const CurrentTest = LocalTest;
 
 class TestRefill extends TestCase
 {
-    private $mReqHost = '';
-    private $mKey = '';
-    private $mMchid = 0;
+    private $mReqHost;
+    private $mKey;
+    private $mMchid;
 
     public function __construct(?string $name = null, array $data = [], $dataName = '')
     {
@@ -382,7 +382,6 @@ class TestRefill extends TestCase
     {
         $body = $this->body($params);
         $body .= "&key={$this->mKey}";
-//        $body .= "&key=ZhongFKJZhongFKJZhongFKJ";
         $params['sign'] = md5($body);
 
         $resp = http_request($url, $params, 'POST');
@@ -467,4 +466,28 @@ class TestRefill extends TestCase
         $ipwhitelist = unserialize($merchant_info['ip_white_list']);
         $res = json_encode($ipwhitelist);
     }
+
+    //测试向内部店提交订单,可先屏蔽其它充值通道
+    public function testAddoilToInnerStore()
+    {
+        $url = $this->mReqHost . "/mobile/index.php";
+        $notifyurl = BASE_SITE_URL . '/mobile/signature.php';
+        $params = ['mchid' => 1,
+            'cardno' => '1000111100020445281',
+            'amount' => "1000",
+            "act" => "refill",
+            "op" => "add",
+            'card_name' => '江海苗',
+            'order_sn' => $this->make_sn(),
+            'notifyurl' => $notifyurl];
+
+        $resp = $this->send_md5($url, $params);
+        Log::record($resp, Log::DEBUG);
+    }
+
+    public function testRefillInnerCB()
+    {
+        $params = ['state_type' => 'order_cancel','order_id' => 311,'channel_name' => 'lx'];
+        $resp = http_request(BASE_SITE_URL . '/mobile/refill_inner.php',$params,'POST');
+    }
 }