Browse Source

Merge branch 'rperform' into rtest

stanley-king 3 years ago
parent
commit
7deb00cc47
61 changed files with 3154 additions and 1676 deletions
  1. 84 6
      admin/control/ordersendlist.php
  2. 20 1
      admin/control/orderstats.php
  3. 3 3
      admin/control/provider_group.php
  4. 16 4
      admin/control/refill_order.php
  5. 3 3
      admin/control/refill_order_manual.php
  6. 79 5
      admin/control/refill_refund.php
  7. 10 3
      admin/templates/default/provider.group.set.php
  8. 13 0
      admin/templates/default/refill.order.index.php
  9. 1 0
      admin/templates/default/refill.order.neterr.index.php
  10. 328 0
      admin/templates/default/refill.order.notify.err.index.php
  11. 11 5
      admin/templates/default/refill.order.send.index.php
  12. 19 0
      admin/templates/default/refill.refund.php
  13. 6 0
      core/framework/cache/cache.redis.php
  14. 25 0
      core/framework/function/http.php
  15. 0 1
      core/framework/libraries/model.php
  16. 14 1089
      data/config/dev/refill.ini.php
  17. 1 1
      data/config/xyz/base.ini.php
  18. 7 4
      data/config/xyztest/base.ini.php
  19. 19 239
      data/config/xyztest/refill.ini.php
  20. 46 34
      data/logic/buy_virtual.logic.php
  21. 70 45
      data/logic/vr_order.logic.php
  22. 11 9
      data/model/predeposit.model.php
  23. 51 51
      data/model/refill_order.model.php
  24. 4 0
      docker/compose/lz-acc/restart.sh
  25. 5 1
      docker/compose/lz-worker/docker-compose.yml
  26. 3 0
      docker/compose/lz-worker/restart.sh
  27. 5 1
      docker/compose/xyz-worker/docker-compose.yml
  28. 2 0
      docker/compose/xyz-worker/restart.sh
  29. 43 17
      docker/compose/xyzt-acc/docker-compose.yml
  30. 17 23
      docker/compose/xyzt-worker/docker-compose.yml
  31. 21 1
      docker/conf/nginx/nginx-acc-45-http.conf
  32. 1 1
      docker/conf/php/xyzt-45-php.ini
  33. 1944 0
      docker/conf/php/xyzt-php-swoole.ini
  34. 2 0
      global.php
  35. 9 0
      heart.html
  36. 2 2
      helper/model/member_info.php
  37. 13 13
      helper/queue/iqueue.php
  38. 2 2
      helper/queue/rdispatcher.php
  39. 91 67
      helper/refill/RefillBase.php
  40. 8 7
      helper/refill/api/test/baidu/RefillPhone.php
  41. 2 0
      helper/refill/api/xyz/moxj/RefillPhone.php
  42. 3 0
      helper/refill/api/xyz/moxj_fs/RefillPhone.php
  43. 3 0
      helper/refill/api/xyz/moxj_yd/RefillPhone.php
  44. 2 0
      helper/refill/api/xyz/weiyi/RefillPhone.php
  45. 2 0
      helper/refill/api/xyz/weiyiman/RefillPhone.php
  46. 2 0
      helper/refill/api/xyz/weiyiwt/RefillPhone.php
  47. 3 1
      helper/refill/api/xyz/yinteng/RefillPhone.php
  48. 7 7
      helper/refill/api/xyz/yinteng/接口地址.txt
  49. 2 0
      helper/refill/api/xyz/yunling/RefillPhone.php
  50. 2 0
      helper/refill/api/xyz/yunlingds/RefillPhone.php
  51. 2 0
      helper/refill/api/xyz/yunlingfs/RefillPhone.php
  52. 2 0
      helper/refill/api/xyz/yunsuoyao/RefillPhone.php
  53. 1 1
      helper/refill/policy/xyz/policy.php
  54. 8 1
      helper/refill/util.php
  55. 1 9
      mobile/control/refill.php
  56. 3 5
      rdispatcher/codispatcher.php
  57. 3 3
      rdispatcher/processor.php
  58. 7 2
      rdispatcher/proxy.php
  59. 29 0
      test/TestHttp.php
  60. 7 6
      test/TestRefill.php
  61. 54 3
      test/TestRefillThird.php

+ 84 - 6
admin/control/ordersendlist.php

@@ -40,19 +40,25 @@ class ordersendlistControl extends SystemControl
             return $condition;
         };
         if ($_GET['time'] == 3) {
-            $condition = $time_out_order(300, $condition);
-            $time_cond[] = ['lt', (time() - 300)];
+            $condition = $time_out_order(180, $condition);
+            $time_cond[] = ['lt', (time() - 180)];
             $_GET['card_type'] = 'phone';
         }
         if ($_GET['time'] == 4) {
-            $condition = $time_out_order(900, $condition);
-            $time_cond[] = ['lt', (time() - 900)];
+            $condition = $time_out_order(300, $condition);
+            $time_cond[] = ['lt', (time() - 300)];
+            $_GET['card_type'] = 'phone';
         }
         if ($_GET['time'] == 5) {
             $condition = $time_out_order(600, $condition);
             $time_cond[] = ['lt', (time() - 600)];
+        }
+        if ($_GET['time'] == 6) {
+            $condition = $time_out_order(900, $condition);
+            $time_cond[] = ['lt', (time() - 900)];
             $_GET['card_type'] = 'phone';
         }
+
         if (!empty($_GET['card_type'])) {
             if (in_array($_GET['card_type'], ['1', '2', '4', '5', '6', '7'])) {
                 $condition['refill_order.card_type'] = $_GET['card_type'];
@@ -150,11 +156,83 @@ class ordersendlistControl extends SystemControl
         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'];
-            $order_list[$order_id]['diff_time_text'] = $this->elapse_time(time() - $order_info['order_time']);
-            $order_list[$order_id]['diff_time'] = time() - $order_info['order_time'];
+            if ($order_info['notify_time'] > 0) {
+                $diff_time = $order_info['notify_time'] - $order_info['order_time'];
+            } else {
+                $diff_time = time() - $order_info['order_time'];
+            }
+
+            $order_list[$order_id]['diff_time'] = $diff_time;
+            $order_list[$order_id]['diff_time_text'] = $this->elapse_time($diff_time);
+
             $order_list[$order_id]['quality_text'] = $this->quality_format($order_info['quality'],$order_info['card_type']);
         }
 
         return $order_list;
     }
+
+    public function notify_err_orderOp()
+    {
+        $model_refill_order = Model('refill_order');
+
+        $order_state_cancel = ORDER_STATE_CANCEL;
+        $order_state_success = ORDER_STATE_SUCCESS;
+        $condition['refill_order.inner_status'] = 0;
+        $condition['vr_order.order_state'] = ['in',"{$order_state_cancel},{$order_state_success}"];
+        $condition['refill_order.mch_notify_state'] = 0;
+        if(empty($_GET['time'])) {
+            $_GET['time'] = 1;
+        }
+        if(empty($_GET['notify_time'])) {
+            $_GET['notify_time'] = 180;
+        }
+        $time = $_GET['time'] * 3600;
+        $condition['refill_order.order_time'] = ['gt', (time() - $time)];
+
+        $notify_time = $_GET['notify_time'];
+        $condition['refill_order.notify_time'] = ['lt', (time() - $notify_time)];
+
+
+        $order_list = $model_refill_order->getMerchantOrderList($condition, '', 'refill_order.*,vr_order.order_state', 'refill_order.notify_time asc', 1000);
+        $merchant_list = Model('')->table('merchant')->limit(1000)->order('name asc')->select();
+        $order_list = $this->orderFormat($order_list,$merchant_list);
+
+        $provider_list = Model('')->table('refill_provider,store')
+            ->field('refill_provider.*,store.store_name')
+            ->join('inner')
+            ->on('store.store_id=refill_provider.store_id')
+            ->order('name asc')
+            ->limit(1000)
+            ->select();
+        Tpl::output('provider_list', $provider_list);
+        Tpl::output('order_list', $order_list);
+        Tpl::output('show_page', $model_refill_order->showpage());
+        Tpl::showpage('refill.order.notify.err.index');
+    }
+
+    public function notifyerr_all_notifyOp()
+    {
+        if(empty($_GET['time']) || empty($_GET['notify_time'])) {
+            showMessage('日期条件错误');
+        }
+        $model_refill_order = Model('refill_order');
+
+        $order_state_cancel = ORDER_STATE_CANCEL;
+        $order_state_success = ORDER_STATE_SUCCESS;
+        $condition['refill_order.inner_status'] = 0;
+        $condition['vr_order.order_state'] = ['in',"{$order_state_cancel},{$order_state_success}"];
+        $condition['refill_order.mch_notify_state'] = 0;
+
+        $time = $_GET['time'] * 3600;
+        $condition['refill_order.order_time'] = ['gt', (time() - $time)];
+        $notify_time = $_GET['notify_time'];
+        $condition['refill_order.notify_time'] = ['lt', (time() - $notify_time)];
+
+        $order_list = $model_refill_order->getMerchantOrderList($condition, '', 'refill_order.*,vr_order.order_state', 'refill_order.notify_time asc', 1000);
+
+        foreach ($order_list as $order) {
+            QueueClient::push("NotifyMerchantComplete", ['order_id' => $order['order_id'], 'manual' => true]);
+        }
+        showMessage('操作成功');
+    }
 }

+ 20 - 1
admin/control/orderstats.php

@@ -69,7 +69,7 @@ class orderstatsControl extends SystemControl
         } elseif ($end_unixtime > 0) {
             $condition['time_stamp'] = ['lt', $end_unixtime];
         }
-        $stats_list = $model_refill_order->getOrderStatsList($condition,'','*','time_stamp asc');
+        $stats_list = $this->all_orderstats_data($condition);
 
         $total_stats = $this->stats($stats_list);
         $stats = $total_stats[$_GET['order_time_type']];
@@ -105,4 +105,23 @@ class orderstatsControl extends SystemControl
         }
         return $total_stats;
     }
+
+    private function all_orderstats_data($condition): array
+    {
+        $i = 0;
+        $result = [];
+        while (true) {
+            $start = $i * 1000;
+            $list = Model('')->table('refill_stats')->field('*')
+                ->where($condition)->order('time_stamp desc')->limit("{$start},1000")->select();
+            if (empty($list)) {
+                break;
+            }
+            $i++;
+            foreach ($list as $value) {
+                $result[] = $value;
+            }
+        }
+        return $result;
+    }
 }

+ 3 - 3
admin/control/provider_group.php

@@ -196,10 +196,10 @@ class provider_groupControl extends SystemControl
             $quality = $_GET['quality'] ?? 1;
 
             $providers = Model('')->table('refill_provider,store')
-                ->field('refill_provider.provider_id,refill_provider.name,store.store_name')
+                ->field('refill_provider.provider_id,refill_provider.name,store.store_name,opened')
                 ->join('inner')
                 ->on('store.store_id=refill_provider.store_id')
-                ->where(['type' => $type, 'opened' => 1, 'qualitys' => ['like', '%' . $quality . '%']])
+                ->where(['type' => $type, 'qualitys' => ['like', '%' . $quality . '%']])
                 ->limit(1000)
                 ->order('opened asc , provider_id desc')
                 ->select();
@@ -212,13 +212,13 @@ class provider_groupControl extends SystemControl
                 foreach ($providers as $key => $provider) {
                     $data['provider_id'] = $provider['provider_id'];
                     $data['provider_name'] = $provider['name'];
+                    $data['opened'] = $provider['opened'];
                     $data['card_type'] = $opr;
                     $card_type = $this->scard_type($opr);
                     $data['name'] = "{$card_type}-{$provider['store_name']}";
                     $results[] = $data;
                 }
             }
-
             $mod = Model('provider_group');
             $condition['group_id'] = $_GET['group_id'];
             $condition['quality']  = $quality;

+ 16 - 4
admin/control/refill_order.php

@@ -143,6 +143,8 @@ class refill_orderControl extends SystemControl
             Tpl::output('stat', $stat);
         }
 
+        $dispatcher_queue_length = refill\util::dispatcher_queue_length();
+        Tpl::output('dispatcher_queue_length', $dispatcher_queue_length);
         Tpl::output('admin_info', $this->getAdminInfo());
         Tpl::output('ftoday', $fToday);
         Tpl::output('order_list', $order_list);
@@ -329,17 +331,27 @@ class refill_orderControl extends SystemControl
         foreach ($order_list as $order_id => $order_info) {
             $order_list[$order_id]['order_state_text'] = orderState($order_info);
             $order_list[$order_id]['notify_time_text'] = '/';
+            $order_list[$order_id]['commit_time_text'] = date("Y-m-d H:i:s", $order_info['commit_time']);
             if ($order_info['notify_time'] > 0) {
                 $diff_time = $order_info['notify_time'] - $order_info['commit_time'];
                 $order_list[$order_id]['notify_time_text'] = date("Y-m-d H:i:s", $order_info['notify_time']);
             } else {
-                $diff_time = time() - $order_info['commit_time'];
-                if($order_info['order_state'] != ORDER_STATE_SEND) {
+                if($order_info['commit_time'] == 0) {
+                    $diff_time = 0;
                     $order_list[$order_id]['order_state_text'] = '提交失败';
+                    $order_list[$order_id]['commit_time_text'] = '/';
+                } else {
+                    $diff_time = time() - $order_info['commit_time'];
+                    if($order_info['order_state'] != ORDER_STATE_SEND) {
+                        $order_list[$order_id]['order_state_text'] = '提交失败';
+                    }
                 }
             }
-            $order_list[$order_id]['commit_time_text'] = date("Y-m-d H:i:s", $order_info['commit_time']);
-            $order_list[$order_id]['diff_time_text'] = $this->elapse_time($diff_time);
+            if($diff_time != 0) {
+                $order_list[$order_id]['diff_time_text'] = $this->elapse_time($diff_time);
+            } else {
+                $order_list[$order_id]['diff_time_text'] = '/';
+            }
             $order_list[$order_id]['diff_time'] = $diff_time;
         }
         $res = ['state' => 1, 'data' => $order_list, 'count' => count($order_list)];

+ 3 - 3
admin/control/refill_order_manual.php

@@ -23,7 +23,7 @@ class refill_order_manualControl extends SystemControl
                 $merchants[$value['mchid']] = $value;
             }
 
-            $order_list = $model_refill_order->getMerchantOrderList($condition, 50, 'refill_order.*,vr_order.order_state', 'refill_order.order_time desc');
+            $order_list = $model_refill_order->getMerchantOrderList($condition, 50, 'refill_order.*,vr_order.order_state', 'refill_order.order_time desc','',true);
             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'];
@@ -59,9 +59,9 @@ class refill_order_manualControl extends SystemControl
         $refill_info = Model('refill_order')->getOrderInfo(['order_id' => $order_id]);
 
         if ($type == 'success') {
-            $logic_vr_order->changeOrderStateSuccess($order_id);
+            $logic_vr_order->changeOrderStateSuccess($order_id,true);
         } elseif ($type == 'cancel') {
-            $logic_vr_order->changeOrderStateCancel($order_info, '', "充值失败");
+            $logic_vr_order->changeOrderStateCancel($order_info, '', "充值失败", true, true);
         } else {
             showMessage('手动操作类型错误', 'index.php?act=refill_order&op=index');
         }

+ 79 - 5
admin/control/refill_refund.php

@@ -40,7 +40,21 @@ class refill_refundControl extends SystemControl
             $merchants[$value['mchid']] = $value;
         }
 
-        $refund_list = $mod->getRefillRefundList($condition,50);
+        if($_GET['export'] == 1) {
+            $this->RefillRefundExport($condition,$providers,$merchants);
+        }else{
+            $refund_list = $mod->getRefillRefundList($condition,50);
+            $refund_list = $this->DataFormat($refund_list,$providers,$merchants);
+        }
+
+        Tpl::output('provider_list', $providers);
+        Tpl::output('merchants', $merchants);
+        Tpl::output('info_list', $refund_list);
+        Tpl::showpage('refill.refund');
+    }
+
+    private function DataFormat($refund_list,$providers,$merchants)
+    {
         foreach ($refund_list as $key => $value) {
             $refund_list[$key]['provider_name'] = $providers[$value['provider_id']]['name'];
             $refund_list[$key]['store_name'] = $providers[$value['provider_id']]['store_name'];
@@ -50,10 +64,70 @@ class refill_refundControl extends SystemControl
 
             $refund_list[$key]['card_type_text'] = $this->scard_type($value['card_type']);
         }
-        Tpl::output('provider_list', $providers);
-        Tpl::output('merchants', $merchants);
-        Tpl::output('info_list', $refund_list);
-        Tpl::showpage('refill.refund');
+        return $refund_list;
+    }
+
+    private function RefillRefundExport($condition,$providers,$merchants)
+    {
+        $i = 0;
+        $result = [];
+        while (true) {
+            $start = $i * 1000;
+            $list = Model('')->table('refill_refund')->where($condition)->order('refund_time desc')->limit("{$start},1000")->select();
+
+            if (empty($list)) {
+                break;
+            }
+            $i++;
+            foreach ($list as $value) {
+                $result[] = $value;
+            }
+        }
+        $result = $this->DataFormat($result,$providers,$merchants);
+        $this->createExcel($result);
+    }
+
+    private function createExcel($data = array())
+    {
+        Language::read('export');
+        import('libraries.excel');
+        $excel_obj = new Excel();
+        $excel_data = array();
+        //设置样式
+        $excel_obj->setStyle(array('id' => 's_title', 'Font' => array('FontName' => '宋体', 'Size' => '12', 'Bold' => '1')));
+        //header
+        $excel_data[0][] = array('styleid' => 's_title', 'data' => '通道名称');
+        $excel_data[0][] = array('styleid' => 's_title', 'data' => '通道退款金额');
+        $excel_data[0][] = array('styleid' => 's_title', 'data' => '机构编码');
+        $excel_data[0][] = array('styleid' => 's_title', 'data' => '机构名称');
+        $excel_data[0][] = array('styleid' => 's_title', 'data' => '机构退款金额');
+        $excel_data[0][] = array('styleid' => 's_title', 'data' => '退款卡号');
+        $excel_data[0][] = array('styleid' => 's_title', 'data' => '退款卡类型');
+        $excel_data[0][] = array('styleid' => 's_title', 'data' => '退款面值');
+        $excel_data[0][] = array('styleid' => 's_title', 'data' => '退款日期');
+        $excel_data[0][] = array('styleid' => 's_title', 'data' => '备注');
+        //data
+        foreach ((array)$data as $v) {
+            $mch_name = $v['company_name'] ?? $v['name'];
+            $tmp = array();
+            $tmp[] = array('data' => "{$v['provider_name']}({$v['store_name']})");
+            $tmp[] = array('data' => $v['channel_amount']);
+            $tmp[] = array('data' => $v['mchid']);
+            $tmp[] = array('data' => $mch_name);
+            $tmp[] = array('data' => $v['mch_amount']);
+            $tmp[] = array('data' => $v['card_no']);
+            $tmp[] = array('data' => $v['card_type_text']);
+            $tmp[] = array('data' => $v['refill_amount']);
+            $tmp[] = array('data' => date('Y-m-d H:i:s', $v['refund_time']));
+            $tmp[] = array('data' => $v['bz']);
+
+            $excel_data[] = $tmp;
+        }
+        $excel_data = $excel_obj->charset($excel_data, CHARSET);
+        $excel_obj->addArray($excel_data);
+        $excel_obj->addWorksheet($excel_obj->charset(L('exp_od_order'), CHARSET));
+        $excel_obj->generateXML($excel_obj->charset(L('exp_od_order'), CHARSET) . date('Y-m-d-H', time()));
+        exit;
     }
 
     public function addOp()

+ 10 - 3
admin/templates/default/provider.group.set.php

@@ -37,7 +37,7 @@
                 <?php if(!empty($output['providers'])){?>
                     <?php foreach ($output['providers'] as $provider){?>
                     <tr class="trFlex" data-color="<?php echo $provider['card_type'];?>">
-                            <td class="w180"><?php echo $provider['name'];?></td>
+                            <td class="w180"><span data-color="<?php echo $provider['opened']?>" class="textColor"><?php echo $provider['name'];?></span></td>
                             <td class="w50 align-center">
                                 <input type="checkbox" class="w50 checkAll">
                             </td>
@@ -80,8 +80,15 @@
         $('#submitBtn').click(function () {
             $("#merchant_name_form").submit();
         });
-   
-        
+
+        $('.textColor').each(function () {
+            let color = $(this).attr('data-color')
+            if (color == '1') {
+                $(this).css('color', 'green')
+            } else {
+                $(this).css('color', 'red')
+            }
+        })
 
 
         // 表格hover时背景

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

@@ -307,6 +307,19 @@
             </tbody>
         </table>
     </form>
+    <table class="table tb-type2" style="min-width:1400px">
+        <tbody>
+        <tr>
+            <td>
+                <ul>
+                    <li>
+                        队列任务个数: <?php echo $output['dispatcher_queue_length'] ?? 0;?>
+                    </li>
+                </ul>
+            </td>
+        </tr>
+        </tbody>
+    </table>
     <?php if($_GET['fShowStat'] == 1){?>
         <table class="table tb-type2" id="prompt" style="min-width:1400px">
             <tbody>

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

@@ -57,6 +57,7 @@
             <ul class="tab-base">
                 <li><a href="index.php?act=ordersendlist&op=index"><span>超时订单监控</span></a></li>
                 <li><a href="JavaScript:void(0);" class="current"><span>网络错误订单监控</span></a></li>
+                <li><a href="index.php?act=ordersendlist&op=notify_err_order"><span>未回调订单监控</span></a></li>
             </ul>
         </div>
     </div>

+ 328 - 0
admin/templates/default/refill.order.notify.err.index.php

@@ -0,0 +1,328 @@
+<style>
+    th label {
+        display: inline-block;
+        width: 60px;
+    }
+
+    .lineLi {
+        display: inline-block;
+        min-width: 150px;
+        font-size: 14px;
+    }
+    .page .fixed-bar .item-title h3 {
+        margin-top:18px !important;
+        margin-bottom:10px !important;
+        font-weight:700 !important;
+    }
+    .tab-base li span {
+        font-size:12px !important;
+    }
+    .layui-form-select .layui-input {
+        height:23px;
+        padding-left: 11px;
+        padding-right: 0!important;
+    }
+    input::placeholder{ 
+        color:#333; 
+    }
+    .layui-form-selected dl {
+    display: flex!important;
+    flex-wrap: wrap!important;
+    }
+    .layui-form-select dl {
+      
+        top: 29px !important;
+        left: 4px!important;
+        min-width: 802%!important;
+        max-height: 280px!important;
+        padding: 14px 0!important;
+    }
+    .layui-form-select dl dd.layui-this{
+        display: none;
+    }
+    .layui-form-select dl dd {
+    cursor: pointer;
+    width: 130px;
+    }
+    .lefto {
+        margin-left: 6px;
+    }
+</style>
+
+<?php defined('InShopNC') or exit('Access Invalid!'); ?>
+<div class="page">
+    <div class="fixed-bar">
+        <div class="item-title">
+            <h3>问题订单监控</h3>
+            <ul class="tab-base">
+                <li><a href="index.php?act=ordersendlist&op=index"><span>超时订单监控</span></a></li>
+                <li><a href="index.php?act=ordersendlist&op=neterr_order"><span>网络错误订单监控</span></a></li>
+                <li><a href="JavaScript:void(0);" class="current"><span>未回调订单监控</span></a></li>
+            </ul>
+        </div>
+    </div>
+    <div class="fixed-empty"></div>
+    <form method="get" action="index.php" name="formSearch" id="formSearch">
+        <input type="hidden" name="act" value="OrderSendList"/>
+        <input type="hidden" name="op" value="notify_err_order"/>
+        <table class="tb-type1 noborder search">
+            <tr>
+                <th><label class="lefto">近期时间(小时内)</label></th>
+                <td  class="layui-form">
+                    <select name="time" class="querySelect" id="time_id"  lay-verify="" lay-search lay-filter="time_id">
+                        <option value=""><?php echo $lang['nc_please_choose']; ?></option>
+                        <?php for ($i = 1; $i<=12; $i++) { ?>
+                            <option value="<?php echo $i; ?>" <?php if ($_GET['time'] == $i){ ?>selected<?php } ?>><?php echo $i;?>小时
+                            </option>
+                        <?php } ?>
+                    </select>
+                </td>
+                <th>回调时间</th>
+                <td>
+                    <select name="notify_time" class="querySelect" id="arrangeClass">
+                        <option value=""><?php echo $lang['nc_please_choose']; ?></option>
+                        <option value="1"
+                                <?php if ($_GET['notify_time'] == '1'){ ?>selected<?php } ?>>1秒</option>
+                        <option value="15"
+                                <?php if ($_GET['notify_time'] == '15'){ ?>selected<?php } ?>>15秒</option>
+                        <?php for ($i = 1; $i <= 5; $i++){?>
+                        <option value="<?php echo $i*60;?>"
+                                <?php if ($_GET['notify_time'] == $i*60){ ?>selected<?php } ?>><?php echo $i;?>分钟</option>
+                        <?php }?>
+                        <option value="600"
+                                <?php if ($_GET['notify_time'] == '600'){ ?>selected<?php } ?>>10分钟</option>
+                        <option value="900"
+                                <?php if ($_GET['notify_time'] == '900'){ ?>selected<?php } ?>>15分钟</option>
+                    </select>
+                </td>
+                <td>
+                    <a href="javascript:void(0);" id="ncsubmit" class="btn-search "
+                       title="<?php echo $lang['nc_query']; ?>">&nbsp;
+                    </a>
+                </td>
+            </tr>
+        </table>
+        <table class="tb-type1 noborder search">
+            <tr>
+                <td>
+                    <a href="#" class="btns" onclick="hCopyChannel(event)">
+                        <span><i class="icon-edit"></i>拷贝订单号</span>
+                    </a>
+                    <a href="#" class="btns" onclick="hCopyCardNo(event)">
+                        <span><i class="icon-edit"></i>拷贝充值卡号</span>
+                    </a>
+                    <a href="#" id="btn_time" class="btns">
+                        <span><i class="icon-edit"></i>批量回调</span>
+                    </a>
+                </td>
+            </tr>
+        </table>
+    </form>
+    <table class="table tb-type2 nobdb">
+        <thead>
+        <tr class="thead">
+            <th class="align-center">编号</th>
+            <th class="align-center">订单号</th>
+            <th class="align-center">机构编号</th>
+            <th class="align-center">机构名称</th>
+            <th class="align-center">充值卡号</th>
+            <th class="align-center">充值卡类型</th>
+            <th class="align-center">充值额度</th>
+            <th class="align-right">下单日期</th>
+            <th class="align-right">耗时</th>
+            <th class="align-center">订单状态</th>
+            <th class="align-center">通道质量</th>
+            <th class="align-center">失败原因</th>
+            <th class="align-center">商家单号</th>
+            <th class="align-center">扣款金额</th>
+            <th class="align-center">渠道单号</th>
+            <th class="align-center">渠道名称</th>
+            <th class="align-center">回调状态</th>
+            <th class="align-center">回调次数</th>
+        </tr>
+        </thead>
+        <tbody id="tbody">
+        <?php if (count($output['order_list']) > 0) { ?>
+            <?php
+            foreach ($output['order_list'] as $key => $order) { ?>
+                <tr class="hover trFlex">
+                    <td class="align-center"><?php echo $key + 1; ?></td>
+                    <td class="align-left"><?php echo $order['order_sn']; ?></td>
+                    <td class="align-center"><?php echo $order['mchid']; ?></td>
+                    <td class="align-center"><?php echo $order['mch_name']; ?></td>
+                    <td class="align-left"><?php echo $order['card_no']; ?></td>
+                    <td class="align-center"><?php echo $order['card_type_text']; ?></td>
+                    <td class="align-center"><?php echo $order['refill_amount']; ?></td>
+                    <td class="align-right"><?php echo date('Y-m-d H:i:s', $order['order_time']); ?></td>
+                    <td class="align-right">
+                        <?php if (empty($order['notify_time'])) {
+                            if ($order['diff_time'] >= 1800 && $order['diff_time'] <= 3600) {
+                                ?>
+                                <span style="color: #fd9d0e"><?php echo $order['diff_time_text'] ?></span>
+                            <?php } elseif ($order['diff_time'] > 3600) { ?>
+                                <span style="color: #f30707"><?php echo $order['diff_time_text'] ?></span>
+                            <?php } else {
+                                ?>
+                                <?php echo $order['diff_time_text'] ?>
+                            <?php } ?>
+                        <?php } else { ?>
+                            <?php echo $order['diff_time_text'] ?>
+                        <?php } ?>
+                    </td>
+                    <td class="align-center"><?php echo orderState($order); ?></td>
+                    <td class="align-left"><?php echo $order['quality_text']; ?></td>
+                    <td class="align-left"><?php echo $order['err_msg']; ?></td>
+                    <td class="align-left"><?php echo $order['mch_order']; ?></td>
+                    <td class="align-center"><?php echo $order['mch_amount']; ?></td>
+                    <td class="align-left" class="ch_trade_no"><?php echo $order['ch_trade_no']; ?></td>
+                    <td class="align-center"><?php echo $order['channel_name']; ?></td>
+                    <td class="align-center">
+                        <?php if($order['mch_notify_state'] == 0){?>
+                            回调未确认
+                        <?php }elseif($order['mch_notify_state'] == 1){?>
+                            回调已确认
+                        <?php }elseif($order['mch_notify_state'] == 2){?>
+                            已停止回调
+                        <?php }?>
+                    </td>
+                    <td class="align-center"><?php echo $order['mch_notify_times']; ?></td>
+                </tr>
+            <?php } ?>
+        <?php } else { ?>
+            <tr class="no_data">
+                <td colspan="15"><?php echo $lang['nc_no_record']; ?></td>
+            </tr>
+        <?php } ?>
+        </tbody>
+        <tfoot>
+        <tr class="tfoot">
+            <td colspan="15" id="dataFuncs">
+                <div class="pagination"> <?php echo $output['show_page']; ?> </div>
+            </td>
+        </tr>
+        </tfoot>
+    </table>
+    <!-- 预警提示 -->
+    <audio id="auto" src="<?php echo RESOURCE_SITE_URL; ?>/warning.mp3"></audio>
+</div>
+<script type="text/javascript" src="<?php echo RESOURCE_SITE_URL; ?>/laydate/laydate.js"></script>
+<script type="text/javascript" src="<?php echo RESOURCE_SITE_URL; ?>/js/jquery-ui/jquery.ui.js"></script>
+<script type="text/javascript" src="<?php echo RESOURCE_SITE_URL; ?>/js/jquery-ui/i18n/zh-CN.js"
+        charset="utf-8"></script>
+<script type="text/javascript" src="<?php echo RESOURCE_SITE_URL;?>/refill/layer.js"></script>
+<script type="text/javascript" src="<?php echo ADMIN_TEMPLATES_URL;?>/layui/layui.js"></script>
+<link rel="stylesheet" type="text/css" href="<?php echo ADMIN_TEMPLATES_URL; ?>/layui/css/layui.css"/>
+<link rel="stylesheet" type="text/css"
+      href="<?php echo RESOURCE_SITE_URL; ?>/js/jquery-ui/themes/ui-lightness/jquery.ui.css"/>
+<script type="text/javascript">
+    $(function () {
+        $('#ncsubmit').click(function () {
+            $('#formSearch').submit();
+        });
+        $('#query_start_time').datepicker({dateFormat: 'yy-mm-dd'});
+        $('#query_end_time').datepicker({dateFormat: 'yy-mm-dd'});
+        // 日期选择器
+        laydate.render({
+            elem: '#startTime',
+            type: 'datetime'
+        });
+        laydate.render({
+            elem: '#endTime',
+            type: 'datetime'
+        });
+     
+        //批量回调
+        $('#btn_time').click(() => {
+            let time1 = $("#time_id option:selected").val()
+            let time2 = $("#arrangeClass option:selected").val()
+          console.log(time1, time2);
+          window.location.href =`index.php?act=OrderSendList&op=notifyerr_all_notify&time= ${time1 ? time1 : ''} &notify_time= ${time2 ? time2 : ''}`
+         
+        })
+        layui.use(['form'], function(){
+            var form = layui.form;
+            form.on('select(time_id)', function (data) {
+                const time3 = data.value;
+                console.log(time3);
+                form.render('select')
+
+                $("select[name='notify_time']").blur(function(){
+                const time4 = $(this).val()
+				console.log(time4)
+                $('#btn_time').click(() =>{
+                console.log(time3, time4);
+                window.location.href = `index.php?act=OrderSendList&op=notifyerr_all_notify&time= ${time3} &notify_time= ${time4}`
+
+
+                })
+			});
+            })
+        })
+    
+      
+        let isWring = '<?php echo $output['count'][1];?>';
+        // console.log('isWring', Number(isWring));
+        let setTimer
+        let num
+        if (Number(isWring) > 0) {
+            window.clearTimeout(setTimer)
+            setTimer = setTimeout(function () {
+                $("#auto")[0].play();
+                // $("#auto").attr("src", '<?php echo RESOURCE_SITE_URL; ?>/warning.mp3');
+            }, 1000);
+            window.clearTimeout(num)
+            num = setTimeout(function () {
+                window.location.reload();
+            }, 60000);
+        }
+        // 表格hover时背景
+        $('.trFlex').each(function () {
+            $(this).hover(function () {
+                $(this)[0].style.backgroundColor = '#cbe9f3'
+            }, function () {
+                $(this)[0].style.backgroundColor = '#fff'
+            })
+        })
+        // 供方名称颜色
+        $('.textColor').each(function () {
+            let color = $(this).attr('data-color')
+            if (color == '1') {
+                $(this).css('color', 'green')
+            } else {
+                $(this).css('color', 'red')
+            }
+        })
+    });
+
+    function hCopyChannel(e) {
+        let str = ''
+        $('#tbody tr').each(function () {
+            let res = $(this).find('td').eq(1).text()
+            str += res + '\n'
+        })
+        let oInput = document.createElement("textarea");
+        oInput.style.border = "0 none";
+        oInput.style.color = "transparent";
+        oInput.value = str;
+        document.body.appendChild(oInput);
+        oInput.select(); // 选择对象
+        document.execCommand("Copy"); // 执行浏览器复制命令
+        oInput.parentNode.removeChild(oInput)
+    }
+
+    function hCopyCardNo(e) {
+        let str = ''
+        $('#tbody tr').each(function () {
+            let res = $(this).find('td').eq(4).text()
+            str += res + '\n'
+        })
+        let oInput = document.createElement("textarea");
+        oInput.style.border = "0 none";
+        oInput.style.color = "transparent";
+        oInput.value = str;
+        document.body.appendChild(oInput);
+        oInput.select(); // 选择对象
+        document.execCommand("Copy"); // 执行浏览器复制命令
+        oInput.parentNode.removeChild(oInput)
+    }
+</script> 

+ 11 - 5
admin/templates/default/refill.order.send.index.php

@@ -66,6 +66,7 @@
             <ul class="tab-base">
                 <li><a href="JavaScript:void(0);" class="current"><span>超时订单监控</span></a></li>
                 <li><a href="index.php?act=ordersendlist&op=neterr_order"><span>网络错误订单监控</span></a></li>
+                <li><a href="index.php?act=ordersendlist&op=notify_err_order"><span>未回调订单监控</span></a></li>
             </ul>
         </div>
     </div>
@@ -169,13 +170,16 @@
                                 <?php if ($_GET['time'] == '2'){ ?>selected<?php } ?>>耗时一小时订单
                         </option>
                         <option value="3"
-                                <?php if ($_GET['time'] == '3'){ ?>selected<?php } ?>>特定耗时5分钟订单
+                                <?php if ($_GET['time'] == '3'){ ?>selected<?php } ?>>特定耗时3分钟订单
+                        </option>
+                        <option value="4"
+                                <?php if ($_GET['time'] == '4'){ ?>selected<?php } ?>>特定耗时5分钟订单
                         </option>
                         <option value="5"
                                 <?php if ($_GET['time'] == '5'){ ?>selected<?php } ?>>特定耗时10分钟订单
                         </option>
-                        <option value="4"
-                                <?php if ($_GET['time'] == '4'){ ?>selected<?php } ?>>特定耗时15分钟订单
+                        <option value="6"
+                                <?php if ($_GET['time'] == '6'){ ?>selected<?php } ?>>特定耗时15分钟订单
                         </option>
                     </select>
                 </td>
@@ -219,11 +223,13 @@
                     <li class="lineLi" style="color:#000;">超过30分钟订单数量:<?php echo $output['count'][0] ?? 0 ?></li>
                     <li class="lineLi" style="color:#000;">超过1小时订单数量:<?php echo $output['count'][1] ?? 0 ?></li>
                     <?php if ($_GET['time'] == 3) { ?>
-                        <li class="lineLi" style="color:#000;">超过5分钟订单数量:<?php echo $output['count'][2] ?? 0 ?></li>
+                        <li class="lineLi" style="color:#000;">超过3分钟订单数量:<?php echo $output['count'][2] ?? 0 ?></li>
                     <?php } elseif ($_GET['time'] == 4) { ?>
-                        <li class="lineLi" style="color:#000;">超过15分钟订单数量:<?php echo $output['count'][2] ?? 0 ?></li>
+                        <li class="lineLi" style="color:#000;">超过5分钟订单数量:<?php echo $output['count'][2] ?? 0 ?></li>
                     <?php } elseif ($_GET['time'] == 5) { ?>
                         <li class="lineLi" style="color:#000;">超过10分钟订单数量:<?php echo $output['count'][2] ?? 0 ?></li>
+                    <?php } elseif ($_GET['time'] == 6) { ?>
+                    <li class="lineLi" style="color:#000;">超过15分钟订单数量:<?php echo $output['count'][2] ?? 0 ?></li>
                     <?php } ?>
                 </ul>
             </td>

+ 19 - 0
admin/templates/default/refill.refund.php

@@ -29,6 +29,7 @@
     <form method="get" name="formSearch" id="formSearch" class="layui-form">
         <input type="hidden" value="refill_refund" name="act">
         <input type="hidden" value="index" name="op">
+        <input type="hidden" name="export" value=""/>
         <table class="tb-type1 noborder search">
             <tbody>
             <tr>
@@ -66,6 +67,11 @@
                 </td>
                 <td><a href="javascript:void(0);" id="ncsubmit" class="btn-search "
                        title="<?php echo $lang['nc_query']; ?>">&nbsp;</a>
+                <td>
+                    <a href="javascript:void(0);" id="ncexport" class="btns" >
+                        <span><i class="icon-edit"></i>搜索导出</span>
+                    </a>
+                </td>
             </tr>
             </tbody>
         </table>
@@ -157,5 +163,18 @@
                 $(this)[0].style.backgroundColor = '#fff'
             })
         })
+        // 导出
+        $('#ncexport').click(function () {
+
+            $('input[name="export"]').val('1');
+            $('input[name="op"]').val('index');
+
+            $('#formSearch').submit();
+            $('input[name="export"]').val('');
+            var ii = layer.load();
+            setTimeout(function(){
+                layer.close(ii);
+            }, 800);
+        })
     });
 </script>

+ 6 - 0
core/framework/cache/cache.redis.php

@@ -257,4 +257,10 @@ class CacheRedis extends Cache
         if (!$this->enable) return false;
         return $this->handler->del($key);
     }
+
+    public function lLen($key) {
+        $this->init_master();
+        if (!$this->enable) return false;
+        return $this->handler->lLen($key);
+    }
 }

+ 25 - 0
core/framework/function/http.php

@@ -24,6 +24,7 @@ function http_request($url, $params = array(), $method = 'GET', $multi = false,
     curl_setopt($ci, CURLOPT_HEADER, false);
     curl_setopt($ci, CURLOPT_CONNECTTIMEOUT, 60);
     curl_setopt($ci, CURLOPT_IPRESOLVE, CURL_IPRESOLVE_V4);
+    curl_setopt($ci, CURLOPT_FOLLOWLOCATION, true);
 
     $headers = (array) $extheaders;
     switch ($method)
@@ -67,6 +68,13 @@ function http_request($url, $params = array(), $method = 'GET', $multi = false,
         $net_errno  = curl_errno($ci);
         Log::record("netmodule http_request errno={$net_errno} err={$err} url={$url}",Log::ERR);
     }
+    else
+    {
+        $code = curl_getinfo($ci,CURLINFO_HTTP_CODE);
+        if($code != 200) {
+            Log::record("netmodule http_request http errno={$code} url={$url}",Log::ERR);
+        }
+    }
 
     curl_close($ci);
 
@@ -90,6 +98,7 @@ function http_post_data($url, $body, $headers = array(),&$net_errno = 0)
     curl_setopt($ci, CURLOPT_URL, $url);
     curl_setopt($ci, CURLOPT_CONNECTTIMEOUT, 60);
     curl_setopt($ci, CURLOPT_POST, TRUE);
+    curl_setopt($ci, CURLOPT_FOLLOWLOCATION, true);
 
     if (!empty($headers)) {
         curl_setopt($ci, CURLOPT_HTTPHEADER, $headers);
@@ -101,6 +110,13 @@ function http_post_data($url, $body, $headers = array(),&$net_errno = 0)
         $net_errno  = curl_errno($ci);
         Log::record("netmodule http_post_data errno={$net_errno} err={$err}  url={$url}",Log::ERR);
     }
+    else
+    {
+        $code = curl_getinfo($ci,CURLINFO_HTTP_CODE);
+        if($code != 200) {
+            Log::record("netmodule http_request http errno={$code} url={$url}",Log::ERR);
+        }
+    }
     curl_close($ci);
 
     return $response;
@@ -120,6 +136,8 @@ function https_request($url, $params = array(), $method = 'GET', $multi = false,
     curl_setopt($ci, CURLOPT_SSL_VERIFYHOST, 2);
     curl_setopt($ci, CURLOPT_CONNECTTIMEOUT, 60);
     curl_setopt($ci, CURLOPT_HEADER, false);
+    curl_setopt($ci, CURLOPT_FOLLOWLOCATION, true);
+
     $headers = (array) $extheaders;
     switch ($method)
     {
@@ -162,6 +180,13 @@ function https_request($url, $params = array(), $method = 'GET', $multi = false,
         $net_errno  = curl_errno($ci);
         Log::record("netmodule https_request errno={$net_errno} err={$err} url={$url}",Log::ERR);
     }
+    else
+    {
+        $code = curl_getinfo($ci,CURLINFO_HTTP_CODE);
+        if($code != 200) {
+            Log::record("netmodule http_request http errno={$code} url={$url}",Log::ERR);
+        }
+    }
     curl_close($ci);
 
     return $response;

+ 0 - 1
core/framework/libraries/model.php

@@ -37,7 +37,6 @@ class trans_wapper
     public function commit()
     {
         $this->mState |= 0x0010;
-        $this->mStart = microtime(true);
         if($this->mMod == null) {
             Db::commit();
         } else {

File diff suppressed because it is too large
+ 14 - 1089
data/config/dev/refill.ini.php


+ 1 - 1
data/config/xyz/base.ini.php

@@ -75,7 +75,7 @@ $config['redis']['slave']['host']     	= SLAVE_REDISHOST;
 $config['redis']['slave']['port']     	= 6379;
 $config['redis']['slave']['pconnect'] 	= 0;
 
-$config['coroutine']['redis_host'] = '172.26.105.125';
+$config['coroutine']['redis_host'] = COROUTINE_REDISHOST;
 $config['coroutine']['redis_port'] = 6379;
 
 

+ 7 - 4
data/config/xyztest/base.ini.php

@@ -48,15 +48,15 @@ $config['tablepre']	= 'lrlz_';
 $config['db'][1]['dbhost']       = MASTER_DBHOST;
 $config['db'][1]['dbport']       = '3306';
 $config['db'][1]['dbuser']       = 'root';
-$config['db'][1]['dbpwd']        = 'XTZ@shop@951688';
-$config['db'][1]['dbname']       = 'shop_test';
+$config['db'][1]['dbpwd']        = 'yezi131419';
+$config['db'][1]['dbname']       = 'xyztest';
 $config['db'][1]['dbcharset']    = 'UTF-8';
 
 $config['db']['slave'][0]['dbhost']     = SLAVE_DBHOST;
 $config['db']['slave'][0]['dbport']     = '3306';
 $config['db']['slave'][0]['dbuser']     = 'root';
-$config['db']['slave'][0]['dbpwd']      = 'XTZ@shop@951688';
-$config['db']['slave'][0]['dbname']     = 'shop_test';
+$config['db']['slave'][0]['dbpwd']      = 'yezi131419';
+$config['db']['slave'][0]['dbname']     = 'xyztest';
 $config['db']['slave'][0]['dbcharset']  = 'UTF-8';
 
 $config['session_expire'] 	= 3600;
@@ -74,6 +74,9 @@ $config['redis']['slave']['host']     	= SLAVE_REDISHOST;
 $config['redis']['slave']['port']     	= 6379;
 $config['redis']['slave']['pconnect'] 	= 0;
 
+$config['coroutine']['redis_host'] = COROUTINE_REDISHOST;
+$config['coroutine']['redis_port'] = 6379;
+
 
 //$config['fullindexer']['open']      = false;
 //$config['fullindexer']['appname']   = '33hao';

+ 19 - 239
data/config/xyztest/refill.ini.php

@@ -7,256 +7,36 @@ $config['refill_phone_specs'] = [10, 20, 30, 50, 100, 200, 300, 500];
 
 //充值额度基本表
 $config['refill_specs'] = [
-    'petrochina'  => $config['refill_oil_specs'],
-    'sinopec'     => $config['refill_oil_specs'],
+    'petrochina' => $config['refill_oil_specs'],
+    'sinopec' => $config['refill_oil_specs'],
     'chinamobile' => $config['refill_phone_specs'],
     'chinaunicom' => $config['refill_phone_specs'],
     'chinatelecom' => $config['refill_phone_specs']
 ];
 
-//充值渠道配置表
-//速汇充京东加油通道
-$tianjt_oil = ['name' => 'tianjt', 'store_id' => 7,
-    'amount' => [
-        100 => [['goods_id' => 6290, 'price' => 97.0, 'quality' => 1, 'card_type' => 'sinopec']],
-        200 => [['goods_id' => 6291, 'price' => 194, 'quality' => 1, 'card_type' => 'sinopec']],
-        500 => [['goods_id' => 6292, 'price' => 485, 'quality' => 1, 'card_type' => 'sinopec']],
-        1000 => [['goods_id' => 6293, 'price' => 970, 'quality' => 1, 'card_type' => 'sinopec']]
-    ],
-    'period' => ['start' => '8:30', 'end' => '22:20'], 'refill_type' => 'api'];
-
-//速汇充天猫加油通道
-$suhctm_oil = ['name' => 'suhctm', 'store_id' => 7,
-    'amount' => [
-        100 => [['goods_id' => 6290, 'price' => 96.8, 'quality' => 1, 'card_type' => 'sinopec']],
-        200 => [['goods_id' => 6291, 'price' => 193.6, 'quality' => 1, 'card_type' => 'sinopec']],
-        500 => [['goods_id' => 6292, 'price' => 484, 'quality' => 1, 'card_type' => 'sinopec']],
-        1000 => [['goods_id' => 6293, 'price' => 968, 'quality' => 1, 'card_type' => 'sinopec']]
-    ],
-    'period' => ['start' => '8:30', 'end' => '22:20'], 'refill_type' => 'api'];
-
-$suhcpdd_oil = ['name' => 'suhcpdd', 'store_id' => 7,
-    'amount' => [
-        100 => [['goods_id' => 6290, 'price' => 96.8, 'quality' => 1, 'card_type' => 'sinopec']],
-        200 => [['goods_id' => 6291, 'price' => 193.6, 'quality' => 1, 'card_type' => 'sinopec']],
-        500 => [['goods_id' => 6292, 'price' => 484, 'quality' => 1, 'card_type' => 'sinopec']],
-        1000 => [['goods_id' => 6293, 'price' => 968, 'quality' => 1, 'card_type' => 'sinopec']]
-    ],
-    'period' => ['start' => '8:30', 'end' => '22:20'], 'refill_type' => 'api'];
-
-//赵梓暄提供的加油通道
-$zzx_oil = ['name' => 'zzx', 'store_id' => 13,
-    'amount' => [
-        100 => [['goods_id' => 6307, 'price' => 97.8, 'quality' => 1, 'card_type' => 'petrochina,sinopec']],
-        200 => [['goods_id' => 6308, 'price' => 195.6, 'quality' => 1, 'card_type' => 'petrochina,sinopec']],
-        500 => [['goods_id' => 6309, 'price' => 489, 'quality' => 1, 'card_type' => 'petrochina,sinopec']],
-        1000 => [['goods_id' => 6310, 'price' => 978, 'quality' => 1, 'card_type' => 'petrochina,sinopec']]
-    ],
-    'refill_type' => 'api'];
-
-//赵梓暄提供的加油通道
-$lx_oil = ['name' => 'lx', 'store_id' => 14,
-    'amount' => [
-        500 => [['goods_id' => 6322, 'price' => 479, 'quality' => 1, 'card_type' => 'sinopec']],
-        1000 => [['goods_id' => 6311, 'price' => 958, 'quality' => 1, 'card_type' => 'sinopec']] //,
-//        2000 => ['goods_id' => 6322, 'price' => 1916]
-    ],
-    'period' => ['start' => '14:00', 'end' => '19:00'], 'official_sn' => true, 'refill_type' => 'inner_store'];
-
-//赛虎
-$saihu_oil = ['name' => 'saihu', 'store_id' => 15,
-    'amount' => [
-        100 => [['goods_id' => 6313, 'price' => 97, 'quality' => 1, 'card_type' => 'sinopec']],
-        200 => [['goods_id' => 6314, 'price' => 194, 'quality' => 1, 'card_type' => 'sinopec']],
-        500 => [['goods_id' => 6315, 'price' => 485, 'quality' => 1, 'card_type' => 'sinopec']],
-        1000 => [['goods_id' => 6316, 'price' => 970, 'quality' => 1, 'card_type' => 'sinopec']],
-        2000 => [['goods_id' => 6317, 'price' => 1940, 'quality' => 1, 'card_type' => 'sinopec']]
-    ],
-    'refill_type' => 'api'];
 
-#官方中石油通道
-$gftd_oil = ['name' => 'gftd', 'store_id' => 19,
-    'amount' => [
-        100 => [['goods_id' => 6339, 'price' => 95, 'quality' => 1, 'card_type' => 'petrochina']],
-        200 => [['goods_id' => 6340, 'price' => 190, 'quality' => 1, 'card_type' => 'petrochina']],
-        500 => [['goods_id' => 6341, 'price' => 475, 'quality' => 1, 'card_type' => 'petrochina']],
-        1000 => [['goods_id' => 6342, 'price' => 950, 'quality' => 1, 'card_type' => 'petrochina']]
-    ],
-    'period' => [], 'refill_type' => 'api'];
-
-#官方中石化通道
-$gftdsinop_oil = ['name' => 'gftdsinop', 'store_id' => 20,
-    'amount' => [
-        100 => [['goods_id' => 6343, 'price' => 95, 'quality' => 1, 'card_type' => 'sinopec']],
-        200 => [['goods_id' => 6344, 'price' => 190, 'quality' => 1, 'card_type' => 'sinopec']],
-        500 => [['goods_id' => 6345, 'price' => 475, 'quality' => 1, 'card_type' => 'sinopec']],
-        1000 => [['goods_id' => 6346, 'price' => 950, 'quality' => 1, 'card_type' => 'sinopec']]
-    ],
-    'period' => [], 'refill_type' => 'api'];
-
-$oil_providers = [
-    ['name' => 'tianjt', 'cfg' => $tianjt_oil],
-    ['name' => 'suhctm', 'cfg' => $suhctm_oil],
-    ['name' => 'suhcpdd', 'cfg' => $suhcpdd_oil],
-    ['name' => 'zzx', 'cfg' => $zzx_oil],
-    ['name' => 'lx', 'cfg' => $lx_oil],
-    ['name' => 'saihu', 'cfg' => $saihu_oil],
-    ['name' => 'gftd', 'cfg' => $gftd_oil],
-    ['name' => 'gftdsinop', 'cfg' => $gftdsinop_oil]
-];
+//充值渠道配置表
+$oil_providers = [];
 $config['oil_providers'] = $oil_providers;
 
-$beixt_phone = ['name' => 'beixt', 'store_id' => 8,
-    'amount' => [
-        50 => [['goods_id' => 6295, 'price' => 48.75, 'quality' => 1, 'card_type' => 'chinamobile,chinaunicom,chinatelecom']],
-        100 => [['goods_id' => 6296, 'price' => 97.5, 'quality' => 1, 'card_type' => 'chinamobile,chinaunicom,chinatelecom']],
-        200 => [['goods_id' => 6297, 'price' => 195,  'quality' => 1, 'card_type' => 'chinamobile,chinaunicom,chinatelecom']]
-    ],
-    'refill_type' => 'api'];
-
-$bxtwt_phone = ['name' => 'bxtwt', 'store_id' => 10,
-    'amount' => [
-        50 => [['goods_id' => 6298, 'price' => 48,   'quality' => 1, 'card_type' => 'chinamobile,chinaunicom,chinatelecom']],
-        100 => [['goods_id' => 6299, 'price' => 96,  'quality' => 1, 'card_type' => 'chinamobile,chinaunicom,chinatelecom']],
-        200 => [['goods_id' => 6300, 'price' => 192, 'quality' => 1, 'card_type' => 'chinamobile,chinaunicom,chinatelecom']]
-    ],
-    'refill_type' => 'api'];
-
-$bjb_phone = ['name' => 'bjb', 'store_id' => 12,
-    'amount' => [
-        10 => [['goods_id' => 6305, 'price' => 9.51,  'quality' => 1, 'card_type' => 'chinaunicom,chinatelecom']],
-        20 => [['goods_id' => 6306, 'price' => 19.02, 'quality' => 1, 'card_type' => 'chinaunicom,chinatelecom']],
-        30 => [['goods_id' => 6301, 'price' => 28.53, 'quality' => 1, 'card_type' => 'chinaunicom,chinatelecom']],
-        50 => [['goods_id' => 6302, 'price' => 47.55, 'quality' => 1, 'card_type' => 'chinaunicom,chinatelecom']],
-        100 => [['goods_id' => 6303, 'price' => 95.1, 'quality' => 1, 'card_type' => 'chinaunicom,chinatelecom']],
-        200 => [['goods_id' => 6304, 'price' => 190.20, 'quality' => 1, 'card_type' => 'chinaunicom,chinatelecom']],
-        300 => [['goods_id' => 6327, 'price' => 285.30, 'quality' => 1, 'card_type' => 'chinaunicom,chinatelecom']],
-        500 => [['goods_id' => 6328, 'price' => 475.50, 'quality' => 1, 'card_type' => 'chinaunicom,chinatelecom']]
-        ],
-    'official_sn' => true, 'refill_type' => 'api'];
-$lingzh_phone = ['name' => 'lingzh', 'store_id' => 28,
-    'amount' => [
-        10 => [['goods_id' => 6389, 'price' => 9.53, 'quality' => 1, 'card_type' => 'chinamobile']],
-        20 => [['goods_id' => 6390, 'price' => 19.06, 'quality' => 1, 'card_type' => 'chinamobile']],
-        30 => [['goods_id' => 6391, 'price' => 28.59, 'quality' => 1, 'card_type' => 'chinamobile']],
-        50 => [['goods_id' => 6392, 'price' => 47.65, 'quality' => 1, 'card_type' => 'chinamobile']],
-        100 => [['goods_id' => 6393, 'price' => 95.3, 'quality' => 1, 'card_type' => 'chinamobile']],
-        200 => [['goods_id' => 6394, 'price' => 190.60, 'quality' => 1, 'card_type' => 'chinamobile']],
-        300 => [['goods_id' => 6395, 'price' => 285.90, 'quality' => 1, 'card_type' => 'chinamobile']],
-        500 => [['goods_id' => 6396, 'price' => 476.50, 'quality' => 1, 'card_type' => 'chinamobile']]
-    ],
-    'official_sn' => true, 'refill_type' => 'api'];
-
-$lingzhdl_phone = ['name' => 'lingzhdl', 'store_id' => 29, 'card_type' => ['chinaunicom', 'chinatelecom'],
+$baidu_phone = ['name' => 'baidu', 'store_id' => 71,'qualitys' => '1',
     'amount' => [
-        10 => [['goods_id' => 6397, 'price' => 9.51, 'quality' => 1, 'card_type' => 'chinaunicom,chinatelecom']],
-        20 => [['goods_id' => 6398, 'price' => 19.02, 'quality' => 1, 'card_type' => 'chinaunicom,chinatelecom']],
-        30 => [['goods_id' => 6399, 'price' => 28.53, 'quality' => 1, 'card_type' => 'chinaunicom,chinatelecom']],
-        50 => [['goods_id' => 6400, 'price' => 47.55, 'quality' => 1, 'card_type' => 'chinaunicom,chinatelecom']],
-        100 => [['goods_id' => 6401, 'price' => 95.1, 'quality' => 1, 'card_type' => 'chinaunicom,chinatelecom']],
-        200 => [['goods_id' => 6402, 'price' => 190.20, 'quality' => 1, 'card_type' => 'chinaunicom,chinatelecom']],
-        300 => [['goods_id' => 6403, 'price' => 285.30, 'quality' => 1, 'card_type' => 'chinaunicom,chinatelecom']],
-        500 => [['goods_id' => 6404, 'price' => 475.50, 'quality' => 1, 'card_type' => 'chinaunicom,chinatelecom']]
+        10 =>  [['goods_id' => 6692, 'price' => 9, 'quality' => 1, 'card_type' => 'chinamobile,chinaunicom,chinatelecom']],
+        20 =>  [['goods_id' => 6693, 'price' => 18, 'quality' => 1, 'card_type' => 'chinamobile,chinaunicom,chinatelecom']],
+        30 =>  [['goods_id' => 6694, 'price' => 27, 'quality' => 1, 'card_type' => 'chinamobile,chinaunicom,chinatelecom']],
+        50 =>  [['goods_id' => 6695, 'price' => 45, 'quality' => 1, 'card_type' => 'chinamobile,chinaunicom,chinatelecom']],
+        100 => [['goods_id' => 6696, 'price' => 90, 'quality' => 1, 'card_type' => 'chinamobile,chinaunicom,chinatelecom']],
+        200 => [['goods_id' => 6697, 'price' => 180, 'quality' => 1, 'card_type' => 'chinamobile,chinaunicom,chinatelecom']],
+        500 => [['goods_id' => 6698, 'price' => 450, 'quality' => 1, 'card_type' => 'chinamobile,chinaunicom,chinatelecom']]
     ],
     'official_sn' => true, 'refill_type' => 'api'];
-
-$bjbyd_phone = ['name' => 'bjbyd', 'store_id' => 24,
-    'amount' => [
-        30 => [['goods_id' => 6367, 'price' => 28.53, 'quality' => 1, 'card_type' => 'chinamobile']],
-        50 => [['goods_id' => 6368, 'price' => 47.55, 'quality' => 1, 'card_type' => 'chinamobile']],
-        100 => [['goods_id' => 6369, 'price' => 95.1, 'quality' => 1, 'card_type' => 'chinamobile']],
-        200 => [['goods_id' => 6370, 'price' => 190.2, 'quality' => 1, 'card_type' => 'chinamobile']]
-    ],
-    'official_sn' => true, 'refill_type' => 'api'];
-
-$afandnew_phone = ['name' => 'afandnew', 'store_id' => 25,
-    'amount' => [
-        30 => [['goods_id' => 6386, 'price' => 28.5, 'quality' => 1, 'card_type' => 'chinamobile']],
-        50 => [['goods_id' => 6371, 'price' => 47.5, 'quality' => 1, 'card_type' => 'chinamobile']],
-        100 => [['goods_id' => 6372, 'price' => 95, 'quality' => 1, 'card_type' => 'chinamobile']],
-        200 => [['goods_id' => 6373, 'price' => 190, 'quality' => 1, 'card_type' => 'chinamobile']],
-        300 => [['goods_id' => 6387, 'price' => 285, 'quality' => 1, 'card_type' => 'chinamobile']],
-        500 => [['goods_id' => 6388, 'price' => 475, 'quality' => 1, 'card_type' => 'chinamobile']]
-    ],
-    'refill_type' => 'api'];
-
-$tianx_phone = ['name' => 'tianx', 'store_id' => 25,
-    'amount' => [
-        50 => [['goods_id' => 6371, 'price' => 46.5, 'quality' => 1, 'card_type' => 'chinamobile,chinaunicom,chinatelecom']],
-        100 => [['goods_id' => 6372, 'price' => 93,  'quality' => 1, 'card_type' => 'chinamobile,chinaunicom,chinatelecom']],
-        200 => [['goods_id' => 6373, 'price' => 186, 'quality' => 1, 'card_type' => 'chinamobile,chinaunicom,chinatelecom']]
-    ],
-    'refill_type' => 'api'];
-
-$yifa_phone = ['name' => 'yifa', 'store_id' => 16,
-    'amount' => [
-        30 => [['goods_id' => 6318, 'price' => 28.65, 'quality' => 1, 'card_type' => 'chinamobile']],
-        50 => [['goods_id' => 6319, 'price' => 47.75, 'quality' => 1, 'card_type' => 'chinamobile']],
-        100 => [['goods_id' => 6320, 'price' => 95.5, 'quality' => 1, 'card_type' => 'chinamobile']],
-        200 => [['goods_id' => 6321, 'price' => 191,  'quality' => 1, 'card_type' => 'chinamobile']]
-    ],
-    'refill_type' => 'api'];
-
-$jiec_phone = ['name' => 'jiec', 'store_id' => 17,
-    'amount' => [
-        30 => [['goods_id' => 6323, 'price' => 28.65, 'quality' => 1, 'card_type' => 'chinamobile,chinaunicom,chinatelecom']],
-        50 => [['goods_id' => 6324, 'price' => 47.75, 'quality' => 1, 'card_type' => 'chinamobile,chinaunicom,chinatelecom']],
-        100 => [['goods_id' => 6325, 'price' => 95.5, 'quality' => 1, 'card_type' => 'chinamobile,chinaunicom,chinatelecom']],
-        200 => [['goods_id' => 6326, 'price' => 191, 'quality' => 1, 'card_type' => 'chinamobile,chinaunicom,chinatelecom']],
-        300 => [['goods_id' => 6329, 'price' => 286.5, 'quality' => 1, 'card_type' => 'chinamobile,chinaunicom,chinatelecom']],
-        500 => [['goods_id' => 6330, 'price' => 477.5, 'quality' => 1, 'card_type' => 'chinamobile,chinaunicom,chinatelecom']]
-    ],
-    'official_sn' => true, 'refill_type' => 'api'];
-
-$weit_phone = ['name' => 'weit', 'store_id' => 18,
-    'amount' => [
-        10 => [['goods_id' => 6337, 'price' => 9.5, 'quality' => 1, 'card_type' => 'chinaunicom,chinatelecom']],
-        20 => [['goods_id' => 6338, 'price' => 19, 'quality' => 1, 'card_type' => 'chinaunicom,chinatelecom']],
-        30 => [['goods_id' => 6331, 'price' => 28.5, 'quality' => 1, 'card_type' => 'chinaunicom,chinatelecom']],
-        50 => [['goods_id' => 6332, 'price' => 47.5, 'quality' => 1, 'card_type' => 'chinaunicom,chinatelecom']],
-        100 => [['goods_id' => 6333, 'price' => 95, 'quality' => 1, 'card_type' => 'chinaunicom,chinatelecom']],
-        200 => [['goods_id' => 6334, 'price' => 190, 'quality' => 1, 'card_type' => 'chinaunicom,chinatelecom']],
-        300 => [['goods_id' => 6335, 'price' => 285, 'quality' => 1, 'card_type' => 'chinaunicom,chinatelecom']],
-        500 => [['goods_id' => 6336, 'price' => 475, 'quality' => 1, 'card_type' => 'chinaunicom,chinatelecom']]
-    ],
-    'official_sn' => true, 'refill_type' => 'api'];
-
-$afand_phone = ['name' => 'afand', 'store_id' => 26,
-    'amount' => [
-        30 => [['goods_id' => 6374, 'price' => 28.5, 'quality' => 1, 'card_type' => 'chinaunicom,chinatelecom']],
-        50 => [['goods_id' => 6375, 'price' => 47.5, 'quality' => 1, 'card_type' => 'chinaunicom,chinatelecom']],
-        100 => [['goods_id' => 6376, 'price' => 95, 'quality' => 1, 'card_type' => 'chinaunicom,chinatelecom']],
-        200 => [['goods_id' => 6377, 'price' => 190, 'quality' => 1, 'card_type' => 'chinaunicom,chinatelecom']],
-        300 => [['goods_id' => 6378, 'price' => 285, 'quality' => 1, 'card_type' => 'chinaunicom,chinatelecom']],
-        500 => [['goods_id' => 6379, 'price' => 475, 'quality' => 1, 'card_type' => 'chinaunicom,chinatelecom']]
-    ],
-    'official_sn' => true, 'refill_type' => 'api'];
-
-$afandeng_phone = ['name' => 'afandeng', 'store_id' => 27,
-    'amount' => [
-        30 => [['goods_id' => 6380, 'price' => 28.5, 'quality' => 1, 'card_type' => 'chinamobile']],
-        50 => [['goods_id' => 6381, 'price' => 47.5, 'quality' => 1, 'card_type' => 'chinamobile']],
-        100 => [['goods_id' => 6382, 'price' => 95, 'quality' => 1, 'card_type' => 'chinamobile']],
-        200 => [['goods_id' => 6383, 'price' => 190, 'quality' => 1, 'card_type' => 'chinamobile']],
-        300 => [['goods_id' => 6384, 'price' => 285, 'quality' => 1, 'card_type' => 'chinamobile']],
-        500 => [['goods_id' => 6385, 'price' => 475, 'quality' => 1, 'card_type' => 'chinamobile']]
-    ],
-    'official_sn' => true, 'refill_type' => 'api'];
-
 $phone_providers = [
-//    ['name' => 'beixt', 'cfg' => $beixt_phone],
-//    ['name' => 'bxtwt', 'cfg' => $bxtwt_phone],
-    ['name' => 'bjb', 'cfg' => $bjb_phone],
-    ['name' => 'bjbyd', 'cfg' => $bjbyd_phone],
+    ['name' => 'baidu', 'cfg' => $baidu_phone, 'opened' => true, 'sort' => 1]];
+$config['phone_providers'] = $phone_providers;
 
-//    ['name' => 'yifa', 'cfg' => $yifa_phone],
-//    ['name' => 'jiec', 'cfg' => $jiec_phone],
-//    ['name' => 'weit', 'cfg' => $weit_phone],
 
-    ['name' => 'afand', 'cfg' => $afand_phone],
-    ['name' => 'afandeng', 'cfg' => $afandeng_phone],
-    ['name' => 'afandnew', 'cfg' => $afandnew_phone],
-    ['name' => 'lingzh', 'cfg' => $lingzh_phone],
-    ['name' => 'lingzhdl', 'cfg' => $lingzhdl_phone]
-];
-$config['phone_providers'] = $phone_providers;
+//以下为三方通道
+$third_providers = [];
+$config['third_providers'] = $third_providers;
+
+$config['auto_find_channels'] = true;

+ 46 - 34
data/logic/buy_virtual.logic.php

@@ -39,7 +39,7 @@ class buy_virtualLogic
      * @param int $member_id 会员ID
      * @return array
      */
-    public function getBuyStepData($goods_id, $quantity, $member_id)
+    public function getBuyStepData($goods_id, $quantity, $member_id,$fRefill = false)
     {
         $goods_info = Model('goods')->getVirtualGoodsOnlineInfoByID($goods_id);
         if (empty($goods_info)) {
@@ -54,8 +54,10 @@ class buy_virtualLogic
             $goods_info['virtual_limit'] = $goods_info['goods_storage'];
         }
 
-        //取得抢购信息
-        $goods_info = $this->_getGroupbuyInfo($goods_info);
+        if(!$fRefill) {
+            //取得抢购信息
+            $goods_info = $this->_getGroupbuyInfo($goods_info);
+        }
 
         $quantity = abs(intval($quantity));
         $quantity = $quantity == 0 ? 1 : $quantity;
@@ -65,19 +67,16 @@ class buy_virtualLogic
         }
         $goods_info['quantity'] = $quantity;
         $goods_info['goods_total'] = ncPriceFormat($goods_info['goods_price'] * $goods_info['quantity']);
-        $goods_info['goods_image_url'] = cthumb($goods_info['goods_image'], 240, $goods_info['store_id']);
+
+        if(!$fRefill) {
+            $goods_info['goods_image_url'] = cthumb($goods_info['goods_image'], 240, $goods_info['store_id']);
+        }
 
         $return = [];
         $return['goods_info'] = $goods_info;
         $return['store_info'] = Model('store')->getStoreOnlineInfoByID($goods_info['store_id']);
         $return['member_info'] = Model('member')->getMemberInfoByID($member_id);
 
-//        $model_payment = Model('payment');
-//        $pd_payment_info = Model('payment')->getPaymentOpenInfo(array('payment_code'=>'predeposit'));
-//        if (empty($pd_payment_info)) {
-//            $return['member_info']['available_predeposit'] = 0;
-//            $return['member_info']['available_rc_balance'] = 0;
-//        }
         return callback(true,'',$return);
     }
 
@@ -87,9 +86,10 @@ class buy_virtualLogic
      * @param int $member_id
      * @return array
      */
-    public function buyStep3($post, $member_id,$calc_vorder_amount = null,$merchant = false)
+    public function buyStep3($post, $member_id,$calc_vorder_amount = null,$merchant = false,$use_trans = true)
     {
-        $result = $this->getBuyStepData($post['goods_id'], $post['quantity'], $member_id);
+        $fRefill = $merchant;
+        $result = $this->getBuyStepData($post['goods_id'], $post['quantity'], $member_id, $fRefill);
         if (!$result['state']) return $result;
         
         $goods_info  = $result['data']['goods_info'];
@@ -116,12 +116,16 @@ class buy_virtualLogic
         {
             $model_goods = Model('goods');
             //开始事务
-            $trans = new trans_wapper($model_goods,__METHOD__);
+            if($use_trans) {
+                $trans = new trans_wapper($model_goods,__METHOD__);
+            }
+
             $member_info = Model('member')->getMemberInfo(['member_id' => $member_id]);
-            $order_info = $this->_createOrder($input,$goods_info,$member_info);
+            $order_info = $this->_createOrder($input,$goods_info,$member_info,$fRefill);
             if (!empty($post['password']))
             {
-                if ($member_info['member_paypwd'] != '' && $member_info['member_paypwd'] == md5($post['password'])) {
+                if ($member_info['member_paypwd'] != '' && $member_info['member_paypwd'] == md5($post['password']))
+                {
                     //充值卡支付
                     if (!empty($post['rcb_pay'])) {
                         $order_info = $this->_rcbPay($order_info, $post, $member_info);
@@ -129,7 +133,7 @@ class buy_virtualLogic
 
                     //预存款支付
                     if (!empty($post['pd_pay'])) {
-                        $this->_pdPay($order_info, $post, $member_info);
+                        $this->_pdPay($order_info, $post, $member_info,$fRefill);
                     }                    
                 }
             }
@@ -137,30 +141,35 @@ class buy_virtualLogic
             {
                 //预存款支付
                 if (!empty($post['pd_pay'])) {
-                    $this->_pdPay($order_info, $post, $member_info);
+                    $this->_pdPay($order_info, $post, $member_info,$fRefill);
                 }
             }
             else {
                 Log::record('',Log::DEBUG);
             }
-            //提交事务
-            $trans->commit();
+            if($use_trans) {
+                $trans->commit();
+            }
         }
         catch (Exception $e)
         {
-            $trans->rollback();
+            if($use_trans) {
+                $trans->rollback();
+            }
+            
             return callback(false, $e->getMessage());
         }
 
-        //变更库存和销量
-        QueueClient::push('createOrderUpdateStorage', [$goods_info['goods_id'] => $goods_info['quantity']]);
-
-        //更新抢购信息
-        $this->_updateGroupBuy($goods_info);
-
-        //发送兑换码到手机
-        $param = ['order_id'=>$order_info['order_id'],'buyer_id'=>$member_id,'buyer_phone'=>$order_info['buyer_phone']];
-        QueueClient::push('sendVrCode', $param);
+        if(!$fRefill)
+        {
+            //变更库存和销量
+            QueueClient::push('createOrderUpdateStorage', [$goods_info['goods_id'] => $goods_info['quantity']]);
+            //更新抢购信息
+            $this->_updateGroupBuy($goods_info);
+            //发送兑换码到手机
+            $param = ['order_id'=>$order_info['order_id'],'buyer_id'=>$member_id,'buyer_phone'=>$order_info['buyer_phone']];
+            QueueClient::push('sendVrCode', $param);
+        }
 
         return callback(true,'', ['order_id' => $order_info['order_id'],'order_sn' => $order_info['order_sn']]);
     }
@@ -173,7 +182,7 @@ class buy_virtualLogic
      * @throws Exception
      * @return array
      */
-    private function _createOrder($input, $goods_info, $member_info)
+    private function _createOrder($input, $goods_info, $member_info,$fRefill)
     {
         extract($input);
         $model_vr_order = Model('vr_order');
@@ -212,6 +221,7 @@ class buy_virtualLogic
         }
         $order['order_id'] = $order_id;
 
+        if ($fRefill) return $order;
         // 提醒[库存报警]
         if ($goods_info['goods_storage_alarm'] >= ($goods_info['goods_storage'] - $input['quantity'])) {
             $param = [];
@@ -315,7 +325,7 @@ class buy_virtualLogic
      * 预存款支付
      * 如果预存款足够就单独支付了该订单,如果不足就暂时冻结,等API支付成功了再彻底扣除
      */
-    private function _pdPay($order_info, $input, $buyer_info)
+    private function _pdPay($order_info, $input, $buyer_info,$fRefill=false)
     {
         if ($order_info['order_state'] == ORDER_STATE_PAY) return false;
 
@@ -334,7 +344,7 @@ class buy_virtualLogic
 
         if ($available_pd_amount >= $order_amount) {
             //预存款立即支付,订单支付完成
-            $model_pd->changePd('order_pay',$data_pd);
+            $model_pd->changePd('order_pay',$data_pd,$fRefill);
 
             //下单,支付被冻结的充值卡
             $pd_amount = floatval($order_info['rcb_amount']);
@@ -359,12 +369,14 @@ class buy_virtualLogic
             }
 
             //发放兑换码
-            $model_vr_order->addOrderCode($order_info);
+            if(!$fRefill) {
+                $model_vr_order->addOrderCode($order_info);
+            }
         }
         else {
             //暂冻结预存款,后面还需要API彻底完成支付
             $data_pd['amount'] = $available_pd_amount;
-            $model_pd->changePd('order_freeze',$data_pd);
+            $model_pd->changePd('order_freeze',$data_pd,$fRefill);
             //预存款支付金额保存到订单
             $data_order = [];
             $data_order['pd_amount'] = $available_pd_amount;

+ 70 - 45
data/logic/vr_order.logic.php

@@ -18,22 +18,24 @@ class vr_orderLogic
      * @param boolean $if_queue 是否使用队列
      * @return array
      */
-    public function changeOrderStateCancel($order_info, $role, $msg, $if_queue = true)
+    public function changeOrderStateCancel($order_info, $role, $msg, $if_queue = true,$fRefill = false)
     {
 
         try {
             $model_vr_order = Model('vr_order');
             $trans = new trans_wapper($model_vr_order, __METHOD__);
 
-            //库存、销量变更
-            if ($if_queue) {
-                QueueClient::push('cancelOrderUpdateStorage', [$order_info['goods_id'] => $order_info['goods_num']]);
-            } else {
-                Logic('queue')->cancelOrderUpdateStorage([$order_info['goods_id'] => $order_info['goods_num']]);
+            if(!$fRefill)
+            {
+                //库存、销量变更
+                if ($if_queue) {
+                    QueueClient::push('cancelOrderUpdateStorage', [$order_info['goods_id'] => $order_info['goods_num']]);
+                } else {
+                    Logic('queue')->cancelOrderUpdateStorage([$order_info['goods_id'] => $order_info['goods_num']]);
+                }
             }
 
             $model_pd = Model('predeposit');
-
             //解冻充值卡
             $pd_amount = floatval($order_info['rcb_amount']);
             if ($pd_amount > 0) {
@@ -53,7 +55,7 @@ class vr_orderLogic
                 $data_pd['member_name'] = $order_info['buyer_name'];
                 $data_pd['amount'] = $pd_amount;
                 $data_pd['order_sn'] = $order_info['order_sn'];
-                $model_pd->changePd('order_cancel', $data_pd);
+                $model_pd->changePd('order_cancel', $data_pd,$fRefill);
             }
 
             //更新订单信息
@@ -66,8 +68,10 @@ class vr_orderLogic
             $update = $model_vr_order->editOrder($update_order, ['order_id' => $order_info['order_id']]);
             if (!$update) {
                 throw new Exception('保存失败');
-            } else {
+            } elseif(!$fRefill) {
                 QueueClient::push('OnVrOrderCancel', ['order_sn' => $order_info['order_sn']]);
+            } else {
+
             }
 
             $trans->commit();
@@ -157,19 +161,30 @@ class vr_orderLogic
         }
     }
 
-    public function changeOrderStateSend($order_id)
+    public function changeOrderStateSend($order_id,$fRefill = false)
     {
         $model_vr_order = Model('vr_order');
-        $condition = [];
-        $condition['vr_state'] = 0;
-        $condition['refund_lock'] = ['in', [0, 1]];
-        $condition['order_id'] = $order_id;
-        $condition['vr_indate'] = ['gt', time()];
-        $order_code_info = $model_vr_order->getOrderCodeInfo($condition, '*', true);
-        if (!empty($order_code_info)) {
+
+        if($fRefill)
+        {
             $update = $model_vr_order->editOrder(['order_state' => ORDER_STATE_SEND], ['order_id' => $order_id]);
             if (!$update) {
-                callback(false, '更新失败');
+                return callback(false, '更新失败');
+            }
+        }
+        else
+        {
+            $condition = [];
+            $condition['vr_state'] = 0;
+            $condition['refund_lock'] = ['in', [0, 1]];
+            $condition['order_id'] = $order_id;
+            $condition['vr_indate'] = ['gt', time()];
+            $order_code_info = $model_vr_order->getOrderCodeInfo($condition, '*', true);
+            if (!empty($order_code_info)) {
+                $update = $model_vr_order->editOrder(['order_state' => ORDER_STATE_SEND], ['order_id' => $order_id]);
+                if (!$update) {
+                    callback(false, '更新失败');
+                }
             }
         }
 
@@ -181,41 +196,51 @@ class vr_orderLogic
      * @param int $order_id
      * @return array
      */
-    public function changeOrderStateSuccess($order_id)
+    public function changeOrderStateSuccess($order_id,$fRefill = false)
     {
         $model_vr_order = Model('vr_order');
-        $condition = [];
-        $condition['vr_state'] = 0;
-        $condition['refund_lock'] = ['in', [0, 1]];
-        $condition['order_id'] = $order_id;
-        $condition['vr_indate'] = ['gt', time()];
-        $order_code_info = $model_vr_order->getOrderCodeInfo($condition, '*', true);
-        if (!empty($order_code_info)) {
+        if($fRefill)
+        {
             $update = $model_vr_order->editOrder(['order_state' => ORDER_STATE_SUCCESS, 'finnshed_time' => time()], ['order_id' => $order_id]);
             if (!$update) {
-                callback(false, '更新失败');
+                return callback(false, '更新失败');
             }
         }
+        else
+        {
+            $condition = [];
+            $condition['vr_state'] = 0;
+            $condition['refund_lock'] = ['in', [0, 1]];
+            $condition['order_id'] = $order_id;
+            $condition['vr_indate'] = ['gt', time()];
+            $order_code_info = $model_vr_order->getOrderCodeInfo($condition, '*', true);
+            if (!empty($order_code_info)) {
+                $update = $model_vr_order->editOrder(['order_state' => ORDER_STATE_SUCCESS, 'finnshed_time' => time()], ['order_id' => $order_id]);
+                if (!$update) {
+                    callback(false, '更新失败');
+                }
+            }
 
-        $order_info = $model_vr_order->getOrderInfo(['order_id' => $order_id]);
-        QueueClient::push('OnVrOrderComplete',['order_sn' => $order_info['order_sn']]);
-        //添加会员积分
-        if (C('points_isuse') == 1) {
-            Model('points')->savePointsLog('order',
-                ['pl_memberid' => $order_info['buyer_id'],
-                 'pl_membername' => $order_info['buyer_name'],
-                 'orderprice' => $order_info['order_amount'],
-                 'order_sn' => $order_info['order_sn'],
-                 'order_id' => $order_info['order_id']], true);
-        }
+            $order_info = $model_vr_order->getOrderInfo(['order_id' => $order_id]);
+            QueueClient::push('OnVrOrderComplete',['order_sn' => $order_info['order_sn']]);
+            //添加会员积分
+            if (C('points_isuse') == 1) {
+                Model('points')->savePointsLog('order',
+                    ['pl_memberid' => $order_info['buyer_id'],
+                        'pl_membername' => $order_info['buyer_name'],
+                        'orderprice' => $order_info['order_amount'],
+                        'order_sn' => $order_info['order_sn'],
+                        'order_id' => $order_info['order_id']], true);
+            }
 
-        //添加会员经验值
-        Model('exppoints')->saveExppointsLog('order',
-            ['exp_memberid' => $order_info['buyer_id'],
-                'exp_membername' => $order_info['buyer_name'],
-                'orderprice' => $order_info['order_amount'],
-                'order_sn' => $order_info['order_sn'],
-                'order_id' => $order_info['order_id']]);
+            //添加会员经验值
+            Model('exppoints')->saveExppointsLog('order',
+                ['exp_memberid' => $order_info['buyer_id'],
+                    'exp_membername' => $order_info['buyer_name'],
+                    'orderprice' => $order_info['order_amount'],
+                    'order_sn' => $order_info['order_sn'],
+                    'order_id' => $order_info['order_id']]);
+        }
 
         return callback(true, '更新成功');
     }

+ 11 - 9
data/model/predeposit.model.php

@@ -243,7 +243,7 @@ class predepositModel extends Model {
      * @throws Exception
      * @return int
      */
-    public function changePd($change_type,$data = []) {
+    public function changePd($change_type,$data = [],$fRefill = false) {
         $data_log = [];
         $data_pd = [];
         $data_msg = [];
@@ -418,14 +418,16 @@ class predepositModel extends Model {
             throw new Exception('操作失败');
         }
 
-        // 支付成功发送买家消息
-        $param = [];
-        $param['code'] = 'predeposit_change';
-        $param['member_id'] = $data['member_id'];
-        $data_msg['av_amount'] = ncPriceFormat($data_msg['av_amount']);
-        $data_msg['freeze_amount'] = ncPriceFormat($data_msg['freeze_amount']);
-        $param['param'] = $data_msg;
-        QueueClient::push('sendMemberMsg', $param);
+        if(!$fRefill) {
+            // 支付成功发送买家消息
+            $param = [];
+            $param['code'] = 'predeposit_change';
+            $param['member_id'] = $data['member_id'];
+            $data_msg['av_amount'] = ncPriceFormat($data_msg['av_amount']);
+            $data_msg['freeze_amount'] = ncPriceFormat($data_msg['freeze_amount']);
+            $param['param'] = $data_msg;
+            QueueClient::push('sendMemberMsg', $param);
+        }
         return $insert;
     }
 

+ 51 - 51
data/model/refill_order.model.php

@@ -1,51 +1,51 @@
-<?php
-
-use const mtopcard\PetroChinaCard;
-use const mtopcard\PhoneCard;
-use const mtopcard\SinopecCard;
-
-defined('InShopNC') or exit('Access Invalid!');
-
-
-class refill_orderModel extends Model
-{
-    public function getOrderInfo($condition = [], $fields = '*', $master = false, $lock = false)
-    {
-        $order_info = $this->table('refill_order')->field($fields)->where($condition)->order('')->master($master)->lock($lock)->find();
-        if (empty($order_info)) {
-            return [];
-        }
-        return $order_info;
-    }
-
-    public function add_refill($params)
-    {
-        return $this->table('refill_order')->insert($params);
-    }
-
-    public function edit($order_id,$data)
-    {
-        return $this->table('refill_order')->where(['order_id' => $order_id])->update($data);
-    }
-
-    public function getMerchantOrderList($condition, $pagesize = '', $field = '*', $order = 'refill_order.order_id desc', $limit = '')
-    {
-        $list = $this->table('refill_order,vr_order')->field($field)
-            ->where($condition)->join('inner')->on('refill_order.order_id=vr_order.order_id')->page($pagesize)->order($order)->limit($limit)->select();
-        if (empty($list)) return [];
-        return $list;
-    }
-
-    public function getOrderStatsList($condition, $pagesize = '', $field = '*', $order = 'time_stamp desc', $limit = '')
-    {
-        $list = $this->table('refill_stats')->field($field)
-            ->where($condition)->page($pagesize)->order($order)->limit($limit)->select();
-        if (empty($list)) return [];
-        return $list;
-    }
-
-    public function first_item()
-    {
-        return $this->table('refill_order')->field('order_time')->where(['order_id' => ['gt',0]])->order('order_id asc')->find();
-    }
-}
+<?php
+
+use const mtopcard\PetroChinaCard;
+use const mtopcard\PhoneCard;
+use const mtopcard\SinopecCard;
+
+defined('InShopNC') or exit('Access Invalid!');
+
+
+class refill_orderModel extends Model
+{
+    public function getOrderInfo($condition = [], $fields = '*', $master = false, $lock = false)
+    {
+        $order_info = $this->table('refill_order')->field($fields)->where($condition)->order('')->master($master)->lock($lock)->find();
+        if (empty($order_info)) {
+            return [];
+        }
+        return $order_info;
+    }
+
+    public function add_refill($params)
+    {
+        return $this->table('refill_order')->insert($params);
+    }
+
+    public function edit($order_id,$data)
+    {
+        return $this->table('refill_order')->where(['order_id' => $order_id])->update($data);
+    }
+
+    public function getMerchantOrderList($condition, $pagesize = '', $field = '*', $order = 'refill_order.order_id desc', $limit = '', $master = false)
+    {
+        $list = $this->table('refill_order,vr_order')->field($field)
+            ->where($condition)->join('inner')->on('refill_order.order_id=vr_order.order_id')->page($pagesize)->order($order)->limit($limit)->master($master)->select();
+        if (empty($list)) return [];
+        return $list;
+    }
+
+    public function getOrderStatsList($condition, $pagesize = '', $field = '*', $order = 'time_stamp desc', $limit = '')
+    {
+        $list = $this->table('refill_stats')->field($field)
+            ->where($condition)->page($pagesize)->order($order)->limit($limit)->select();
+        if (empty($list)) return [];
+        return $list;
+    }
+
+    public function first_item()
+    {
+        return $this->table('refill_order')->field('order_time')->where(['order_id' => ['gt',0]])->order('order_id asc')->find();
+    }
+}

+ 4 - 0
docker/compose/lz-acc/restart.sh

@@ -0,0 +1,4 @@
+docker-compose stop -t 1200 mobilesrv raccsrv mchsrv websrv crontabsrv cronsec
+docker-compose up -d
+docker-compose up -d
+docker-compose ps

+ 5 - 1
docker/compose/lz-worker/docker-compose.yml

@@ -21,7 +21,11 @@ services:
       - /mnt/shoplog:/var/www/html/data/log
       - ../../conf/php/lz-php-swoole.ini:/usr/local/etc/php/php.ini
     container_name: "panda-codispatcher"
-    command: [php,"/var/www/html/rdispatcher/codispatcher.php","8"]
+    command: [php,"/var/www/html/rdispatcher/codispatcher.php","16"]
+    deploy:
+      resources:
+        limits:
+          cpus: '8'
 
   queuesrv:
     image: php-zts-debug:7.3.18

+ 3 - 0
docker/compose/lz-worker/restart.sh

@@ -0,0 +1,3 @@
+docker-compose stop -t 1200 cordsrv
+docker-compose down
+docker-compose up -d

+ 5 - 1
docker/compose/xyz-worker/docker-compose.yml

@@ -10,7 +10,11 @@ services:
       - /mnt/shoplog:/var/www/html/data/log
       - ../../conf/php/xyz-php-swoole.ini:/usr/local/etc/php/php.ini
     container_name: "panda-codispatcher"
-    command: [php,"/var/www/html/rdispatcher/codispatcher.php","32"]
+    command: [php,"/var/www/html/rdispatcher/codispatcher.php","16"]
+    deploy:
+      resources:
+        limits:
+          cpus: '8'
 
   queuesrv:
     image: php-zts-debug:7.3.18

+ 2 - 0
docker/compose/xyz-worker/restart.sh

@@ -0,0 +1,2 @@
+docker-compose stop -t 1200 cordsrv
+docker-compose up -d

+ 43 - 17
docker/compose/xyzt-acc/docker-compose.yml

@@ -4,19 +4,18 @@ services:
   nginxsrv:
     image: nginx:alpine
     ports:
-      - "80:80"
+      - "8080:80"
     volumes:
       - ../../../:/var/www/html
       - ../../conf/etc/localtime:/etc/localtime:ro
       - /nfs/upload:/var/www/html/data/upload
       - /nfs/tmerchant:/var/www/html/merchant
-      - ../../conf/nginx/nginx-acc-45-http.conf:/etc/nginx/nginx.conf:ro
+      - ../../conf/nginx/nginx-xyztest-http.conf:/etc/nginx/nginx.conf:ro
     container_name: "panda-nginx"
     command: [nginx,'-g','daemon off;']
     extra_hosts:
       - "docker.hostip:172.17.0.1"
-      - "eth.hostip:172.26.105.126"
-
+      - "eth.hostip:172.26.105.127"
 
   redisrv:
     image: redis:alpine
@@ -30,37 +29,53 @@ services:
     command: [redis-server,"/etc/redis/redis.conf"]
 
   mobilesrv:
-    image: php-zts-debug:7.3.18
+    image: php-zts:7.3.18
     ports:
       - "9100:9100"
     volumes:
       - ../../conf/etc/localtime:/etc/localtime:ro
       - ../../../:/var/www/html
-      - ../../conf/php/xyzt-45-php.ini:/usr/local/etc/php/php.ini
+      - ../../conf/php/xyzt-175-php.ini:/usr/local/etc/php/php.ini
       - /nfs/upload:/var/www/html/data/upload
-      - /mnt/shoplog:/var/www/html/data/log
-      - ../../conf/php/lz-mobile-spwan-start:/usr/local/bin/docker-spwan-start
+      - /mnt/testlog:/var/www/html/data/log
+      - ../../conf/php/mobile-spwan-start:/usr/local/bin/docker-spwan-start
     container_name: "panda-mobile"
     command: ['docker-spwan-start']
     depends_on:
       - "redisrv"
 
   raccsrv:
-    image: php-zts-debug:7.3.18
+    image: php-zts:7.3.18
     ports:
       - "9101:9101"
     volumes:
       - ../../conf/etc/localtime:/etc/localtime:ro
       - ../../../:/var/www/html
-      - ../../conf/php/xyzt-45-php.ini:/usr/local/etc/php/php.ini
+      - ../../conf/php/xyzt-175-php.ini:/usr/local/etc/php/php.ini
       - /nfs/upload:/var/www/html/data/upload
-      - /mnt/shoplog:/var/www/html/data/log
+      - /mnt/testlog:/var/www/html/data/log
       - ../../conf/php/racc-spwan-start-lz:/usr/local/bin/docker-spwan-start
     container_name: "panda-racc"
     command: [docker-spwan-start]
     depends_on:
       - "redisrv"
 
+  mchsrv:
+    image: php-zts:7.3.18
+    ports:
+      - "9102:9102"
+    volumes:
+      - ../../conf/etc/localtime:/etc/localtime:ro
+      - ../../../:/var/www/html
+      - ../../conf/php/xyzt-175-php.ini:/usr/local/etc/php/php.ini
+      - /nfs/upload:/var/www/html/data/upload
+      - /mnt/testlog:/var/www/html/data/log
+      - ../../conf/php/mch-spwan-start-lz:/usr/local/bin/docker-spwan-start
+    container_name: "panda-merchant"
+    command: [docker-spwan-start]
+    depends_on:
+       - "redisrv"
+
   websrv:
     image: php-fpm:alpine
     ports:
@@ -69,8 +84,8 @@ services:
       - ../../conf/etc/localtime:/etc/localtime:ro
       - ../../../:/var/www/html
       - /nfs/upload:/var/www/html/data/upload
-      - /mnt/shoplog:/var/www/html/data/log
-      - ../../conf/php/xyzt-45-php.ini:/usr/local/etc/php/php.ini
+      - /mnt/testlog:/var/www/html/data/log
+      - ../../conf/php/xyzt-175-php.ini:/usr/local/etc/php/php.ini
       - ../../conf/php-fpm/php-fpm.conf:/usr/local/etc/php-fpm.conf
     container_name: "panda-web"
     command: [php-fpm]
@@ -83,22 +98,33 @@ services:
       - ../../conf/etc/localtime:/etc/localtime:ro
       - ../../../:/var/www/html
       - /nfs/upload:/var/www/html/data/upload
-      - /mnt/shoplog:/var/www/html/data/log
-      - ../../conf/php/xyzt-45-php.ini:/usr/local/etc/php/php.ini
+      - /mnt/testlog:/var/www/html/data/log
+      - ../../conf/php/xyzt-175-php.ini:/usr/local/etc/php/php.ini
       - ../../conf/crontab/root:/var/spool/cron/crontabs/root
     container_name: "panda-crontab"
     command: [crond,"-f"]
     depends_on:
       - "redisrv"
 
+  cronsec:
+    image: php-zts-debug:7.3.18
+    volumes:
+      - ../../conf/etc/localtime:/etc/localtime:ro
+      - ../../../:/var/www/html
+      - /nfs/upload:/var/www/html/data/upload
+      - /mnt/testlog:/var/www/html/data/log
+      - ../../conf/php/xyzt-175-php.ini:/usr/local/etc/php/php.ini
+    container_name: "panda-cronsec"
+    command: [php,"/var/www/html/crontab/index.php",'minutes','second_queue']
+
   phpcli:
     image: php-zts-debug:7.3.18
     volumes:
       - ../../conf/etc/localtime:/etc/localtime:ro
-      - ../../conf/php/xyzt-45-php.ini:/usr/local/etc/php/php.ini
+      - ../../conf/php/xyzt-175-php.ini:/usr/local/etc/php/php.ini
       - ../../../:/var/www/html
       - /nfs/upload:/var/www/html/data/upload
-      - /mnt/shoplog:/var/www/html/data/log
+      - /mnt/testlog:/var/www/html/data/log
     container_name: "panda-php"
     depends_on:
       - "redisrv"

+ 17 - 23
docker/compose/xyzt-worker/docker-compose.yml

@@ -1,16 +1,20 @@
 version: "3.7"
 
 services:
-  rdsrv:
-    image: php-zts-debug:7.3.18
+  cordsrv:
+    image: php-swool-redis:latest
     volumes:
       - ../../conf/etc/localtime:/etc/localtime:ro
       - ../../../:/var/www/html
       - /nfs/upload:/var/www/html/data/upload
-      - /mnt/shoplog:/var/www/html/data/log
-      - ../../conf/php/xyzt-45-php.ini:/usr/local/etc/php/php.ini
-    container_name: "panda-dispatcher"
-    command: [php,"/var/www/html/rdispatcher/dispatcher.php","1"]
+      - /mnt/testlog:/var/www/html/data/log
+      - ../../conf/php/xyzt-php-swoole.ini:/usr/local/etc/php/php.ini
+    container_name: "worker-codispatcher"
+    command: [php,"/var/www/html/rdispatcher/codispatcher.php","16"]
+    deploy:
+      resources:
+        limits:
+          cpus: '8'
 
   queuesrv:
     image: php-zts-debug:7.3.18
@@ -18,9 +22,9 @@ services:
       - ../../conf/etc/localtime:/etc/localtime:ro
       - ../../../:/var/www/html
       - /nfs/upload:/var/www/html/data/upload
-      - /mnt/shoplog:/var/www/html/data/log
-      - ../../conf/php/xyzt-45-php.ini:/usr/local/etc/php/php.ini
-    container_name: "panda-queue"
+      - /mnt/testlog:/var/www/html/data/log
+      - ../../conf/php/xyzt-175-php.ini:/usr/local/etc/php/php.ini
+    container_name: "worker-queue"
     command: [php,"/var/www/html/queue/index.php", "queue", "index"]
 
   searcher:
@@ -29,17 +33,7 @@ services:
       - ../../conf/etc/localtime:/etc/localtime:ro
       - ../../../:/var/www/html
       - /nfs/upload:/var/www/html/data/upload
-      - /mnt/shoplog:/var/www/html/data/log
-      - ../../conf/php/xyzt-45-php.ini:/usr/local/etc/php/php.ini
-    container_name: "panda-searcher"
-    command: [php, "/var/www/html/searcher.php"]
-
-#  phpcli:
-#    image: php-zts-debug:7.3.18
-#    volumes:
-#      - ../../conf/etc/localtime:/etc/localtime:ro
-#      - ../../conf/php/xyzt-45-php.ini:/usr/local/etc/php/php.ini
-#      - ../../../:/var/www/html
-#      - /nfs/upload:/var/www/html/data/upload
-#      - /mnt/shoplog:/var/www/html/data/log
-#    container_name: "panda-php"
+      - /mnt/testlog:/var/www/html/data/log
+      - ../../conf/php/xyzt-175-php.ini:/usr/local/etc/php/php.ini
+    container_name: "worker-searcher"
+    command: [php, "/var/www/html/searcher.php"]

+ 21 - 1
docker/conf/nginx/nginx-acc-45-http.conf

@@ -30,7 +30,7 @@ http
     {
     	listen       80;
         set  $folder_name /var/www/html;
-        server_name 121.89.196.45;
+        server_name test.xyzshops.cn;
         root $folder_name;
         index index.html index.php; 
     	client_max_body_size 100m;
@@ -63,6 +63,17 @@ http
 	        try_files $uri $uri/ /mshop/index.html;
         }
 
+        location /plot {
+            root $folder_name;
+            proxy_pass         http://docker.hostip: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;
@@ -92,6 +103,15 @@ http
             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;

+ 1 - 1
docker/conf/php/xyzt-45-php.ini

@@ -1325,7 +1325,7 @@ bcmath.scale = 0
 ; http://php.net/session.save-handler
 ;session.save_handler = file
 session.save_handler = redis
-session.save_path = tcp://172.26.105.126:6379
+session.save_path = tcp://172.26.105.127:6379
 
 ; Argument passed to save_handler.  In the case of files, this is the path
 ; where data files are stored. Note: Windows users have to change this

File diff suppressed because it is too large
+ 1944 - 0
docker/conf/php/xyzt-php-swoole.ini


+ 2 - 0
global.php

@@ -122,6 +122,8 @@ define('ORDER_STATE_SUCCESS', 40);
 
 define('ORDER_STATE_QUEUE', 50);
 
+define('ORDER_STATE_NOEXIST', 60);
+
 //未付款订单,自动取消的分钟
 define('VRORDER_AUTO_CANCEL_MINUTE', 10); //
 //未付款订单,自动取消的天数

+ 9 - 0
heart.html

@@ -0,0 +1,9 @@
+<!DOCTYPE html>
+<html lang="en">
+<head>
+    <meta charset="UTF-8">
+    <title>HeartBeat</title>
+</head>
+<body>
+</body>
+</html>

+ 2 - 2
helper/model/member_info.php

@@ -68,14 +68,14 @@ class member_info
     public function mobile()
     {
         if($this->binded_mobile()) {
-            return $this->member_info['member_mobile'];
+            return $this->member_info['member_mobile'] ?? '';
         }
         else {
             return "";
         }
     }
     public function truename() {
-        return $this->member_info['member_truename'];
+        return $this->member_info['member_truename'] ?? '';
     }
     public function sex()
     {

+ 13 - 13
helper/queue/iqueue.php

@@ -13,18 +13,16 @@ class IQueueDB
 {
     private $_redis;
 
-    private $_tb_prefix;
+    private $_queue_name;
     //存定义存储表的数量,系统会随机分配存储
 
-    private $_tb_num = 3;
     private $_comode;
-
     public function __construct($queue_name,$comode = false)
     {
         if ( !extension_loaded('redis') ) {
             throw_exception('redis failed to load');
         }
-        $this->_tb_prefix = $queue_name;
+        $this->_queue_name = $queue_name;
         $this->_comode = $comode;
 
         if ($this->_comode) {
@@ -72,27 +70,26 @@ class IQueueDB
     public function rpush($value)
     {
         try {
-            return $this->_redis->rPush($this->_tb_prefix . rand(1, $this->_tb_num), $value);
+            return $this->_redis->rPush($this->_queue_name, $value);
         } catch(Exception $e) {
-            throw_exception($e->getMessage());
+            Log::record("IQueueDB::rpush " . $e->getMessage(),Log::ERR);
+            return false;
         }
     }
 
     public function lpush($value)
     {
         try {
-            return $this->_redis->lPush($this->_tb_prefix.rand(1,$this->_tb_num),$value);
+            return $this->_redis->lPush($this->_queue_name,$value);
         } catch(Exception $e) {
-            throw_exception($e->getMessage());
+            Log::record("IQueueDB::lpush " . $e->getMessage(),Log::ERR);
+            return false;
         }
     }
 
     public function scan()
     {
-        $list_key = [];
-        for ($i = 1; $i <= $this->_tb_num; $i++) {
-            $list_key[] = $this->_tb_prefix . $i;
-        }
+        $list_key[] = $this->_queue_name;
         return $list_key;
     }
 
@@ -119,7 +116,6 @@ class IQueueDB
         $this->_redis->flushAll();
     }
 }
-
 /**
  * 队列处理
  *
@@ -239,6 +235,10 @@ abstract class ILooper
                         $content = $this->mServer->pop($queues,1);
                         if(empty($content)) continue;
 
+                        $msg = json_encode($content);
+                        Log::record("queuemessage:{$msg}",Log::DEBUG);
+
+
                         if($this->_stop)
                         {
                             foreach ($content as $key => $params) {

+ 2 - 2
helper/queue/rdispatcher.php

@@ -29,7 +29,7 @@ class DispatcherDB extends IQueueDB
 {
     public function __construct()
     {
-        parent::__construct('QUEUE_DISPATCHER_');
+        parent::__construct('QUEUE_DISPATCHER_CO');
     }
 }
 
@@ -45,7 +45,7 @@ class CoDispatcherDB extends IQueueDB
 {
     public function __construct()
     {
-        parent::__construct('QUEUE_DISPATCHER_',true);
+        parent::__construct('QUEUE_DISPATCHER_CO',true);
     }
 }
 

+ 91 - 67
helper/refill/RefillBase.php

@@ -19,7 +19,6 @@ use QueueClient;
 use member_info;
 use Exception;
 use trans_wapper;
-use Cache;
 
 class RefillBase
 {
@@ -91,7 +90,6 @@ class RefillBase
         try
         {
             $tran = new trans_wapper($mod_order,'notify change order state trans');
-
             $order_info = $mod_order->getOrderInfo(['order_id' => $order_id],'*',true,true);
             $order_state = intval($order_info['order_state']);
 
@@ -109,6 +107,10 @@ class RefillBase
             }
 
             $refill_info = $mod_refill->getOrderInfo(['order_id' => $order_id,'inner_status' => 0]);
+            if(empty($refill_info)) {
+                $tran->commit();
+                return false;
+            }
 
             $quality = intval($refill_info['quality']);
             $card_type = intval($refill_info['card_type']);
@@ -120,24 +122,21 @@ class RefillBase
             if ($success) {
                 util::incr_notify($chname, $card_type, $spec, $quality, true);
                 util::incr_user_success($mchid,$card_type, $spec,$org_quality);
-                $logic_vr_order->changeOrderStateSuccess($order_id);
+                $logic_vr_order->changeOrderStateSuccess($order_id,true);
             }
             elseif ($can_try)
             {
-                if(!empty($refill_info))
+                util::add_exclude_channel($mchid,$mch_order,$card_type,$chname);
+                util::incr_notify($chname, $card_type, $spec, $quality, false);
+                util::incr_amount_lock($mchid,$card_type,$spec);
+
+                $logic_vr_order->changeOrderStateCancel($order_info, '', "{$chname}接口回调通知失败,正在重试",true,true);
+                [$can_retry,$params] = $this->retry($refill_info, $order_info);
+                if ($can_retry)
                 {
-                    util::add_exclude_channel($mchid,$mch_order,$card_type,$chname);
-                    util::incr_notify($chname, $card_type, $spec, $quality, false);
-                    util::incr_amount_lock($mchid,$card_type,$spec);
-
-                    $logic_vr_order->changeOrderStateCancel($order_info, '', "{$chname}接口回调通知失败,正在重试");
-
-                    [$can_retry,$params] = $this->retry($refill_info, $order_info);
-                    if ($can_retry)
-                    {
-                        $mod_refill->edit($order_id, ['is_retrying' => 1,'notify_time' => time()]);
-                        $tran->commit();
-                        util::push_add($params);
+                    $mod_refill->edit($order_id, ['is_retrying' => 1,'notify_time' => time()]);
+                    $tran->commit();
+                    if(util::push_add($params)) {
                         return true;
                     }
                 }
@@ -145,8 +144,7 @@ class RefillBase
             else {
                 util::incr_notify($chname, $card_type, $spec, $quality, false);
                 util::incr_amount_lock($mchid,$card_type,$spec);
-
-                $logic_vr_order->changeOrderStateCancel($order_info, '', "{$chname}接口回调通知失败,不可重试.");
+                $logic_vr_order->changeOrderStateCancel($order_info, '', "{$chname}接口回调通知失败,不可重试.",true,true);
             }
             $tran->commit();
         }
@@ -155,7 +153,7 @@ class RefillBase
             Log::record("Error:" . $ex->getMessage(), Log::ERR);
         }
 
-        $mod_refill->edit($order_id, ['notify_time' => time(), 'notify_state' => 1]);
+        $mod_refill->edit($order_id, ['notify_time' => time(), 'is_retrying' => 0,'notify_state' => 1]);
         util::pop_queue_order($mchid,$mch_order);
         QueueClient::push("NotifyMerchantComplete", ['order_id' => $order_id,'manual' => false]);
         util::del_exclude_channel($mchid,$mch_order,$card_type);
@@ -232,7 +230,7 @@ class RefillBase
 
             $logic_vr_order = Logic("vr_order");
             $order_info = Model('vr_order')->getOrderInfo(['order_id' => $order_id]);
-            $logic_vr_order->changeOrderStateCancel($order_info, '', '无法下单创建0元订单');
+            $logic_vr_order->changeOrderStateCancel($order_info, '', '无法下单创建0元订单',true,true);
 
             if (empty($mch_order)) {
                 $mch_order = $order_sn;
@@ -332,8 +330,7 @@ class RefillBase
             //通道价格大于客户价格,换通道.
             [$goods_id, $price] = $provider->goods($quality,$amount,$card_type,$third_params);
             if ($goods_id <= 0) continue;
-            if($org_quality != 15 && $price > $mch_price) continue;
-//            if($org_quality != Quality::SlowSixNormal && $price > $mch_price) continue;
+            if($org_quality != Quality::SlowSixNormal && $price > $mch_price) continue;
             Log::record("start create order",Log::DEBUG);
 
             $input['goods_id'] = $goods_id;
@@ -344,37 +341,41 @@ class RefillBase
             $input['order_from']  = 1;
             $input['pd_pay'] = true;
 
-            $start = microtime(true);
             $logic_buy_virtual = Logic('buy_virtual');
-            $result = $logic_buy_virtual->buyStep3($input, $buyer_id, [$calc, 'calc_vorder_amount'], true);
-            Log::record(sprintf("buyStep3 request time=%.6f", microtime(true) - $start), Log::DEBUG);
-
             $mod_refill = Model('refill_order');
-            if ($result['state'] === true)
-            {
-                $order_sn = $result['data']['order_sn'];
-                $order_id = $result['data']['order_id'];
 
-                if($last_orderid > 0) {
-                    $mod_refill->edit($last_orderid, ['inner_status' => 1]);
+            try
+            {
+                $fTrans = false;
+                if($fTrans) {
+                    $trans = new trans_wapper($mod_refill,__METHOD__);
+                } else {
+                    $start = microtime(true);
                 }
-                $last_orderid = $order_id;
 
-                if (empty($mch_order)) {
-                    $mch_order = $order_sn;
-                }
+                $result = $logic_buy_virtual->buyStep3($input, $buyer_id, [$calc, 'calc_vorder_amount'], true,false);
+                if ($result['state'] === true)
+                {
+                    $order_sn = $result['data']['order_sn'];
+                    $order_id = $result['data']['order_id'];
 
-                $thrid_refill = Model('thrid_refill');
-                if($card_type == mtopcard\ThirdRefillCard) {
-                    $product = $thrid_refill->getProduct(['system_code' => $third_params['product_code']]);
-                    $refill_amount = $product['refill_amount'];
-                } else {
-                    $refill_amount = $amount;
-                }
+                    if($last_orderid > 0) {
+                        $mod_refill->edit($last_orderid, ['inner_status' => 1]);
+                    }
+                    $last_orderid = $order_id;
+
+                    if (empty($mch_order)) {
+                        $mch_order = $order_sn;
+                    }
+
+                    $thrid_refill = Model('thrid_refill');
+                    if($card_type == mtopcard\ThirdRefillCard) {
+                        $product = $thrid_refill->getProduct(['system_code' => $third_params['product_code']]);
+                        $refill_amount = $product['refill_amount'];
+                    } else {
+                        $refill_amount = $amount;
+                    }
 
-                $start = microtime(true);
-                try {
-                    $trans = new trans_wapper($mod_refill, __METHOD__);
                     //虚拟订单表信息扩展
                     $orderext = ['order_id' => $order_id, 'order_sn' => $order_sn, 'mchid' => $mchid,
                         'refill_amount' => $refill_amount, 'mch_order' => $mch_order,
@@ -387,7 +388,6 @@ class RefillBase
                     $mod_refill->add_refill($orderext);
 
                     if($card_type == mtopcard\ThirdRefillCard) {
-
                         $ext = ['order_id' => $order_id,
                             'order_sn' => $order_sn,
                             'account_type' => $third_params['third_card_type'],
@@ -397,23 +397,35 @@ class RefillBase
                         ];
                         $thrid_refill->addExt($ext);
                     }
+
+                    if(!$this->pay_completed($order_sn)) {
+                        $logic_vr_order = Logic("vr_order");
+                        $order_info = Model('vr_order')->getOrderInfo(['order_id' => $order_id]);
+                        $logic_vr_order->changeOrderStateCancel($order_info, '', "预存款不足以支付该订单",true,true);
+                        if($fTrans) {
+                            $trans->commit();
+                        }
+                        break;
+                    }
+                    elseif($fTrans) {
+                        $trans->commit();
+                    }
+                    else {
+                        Log::record(sprintf(__METHOD__ . "request time=%.6f", microtime(true) - $start), Log::DEBUG);
+                    }
+                }
+                else {
                     $trans->commit();
+                    Log::record("{$result['msg']}",Log::ERR);
+                    continue;
                 }
-                catch (Exception $ex) {
-                    Log::record($ex->getMessage(),Log::ERR);
+            }
+            catch (Exception $ex)
+            {
+                Log::record($ex->getMessage(), Log::ERR);
+                if($fTrans) {
                     $trans->rollback();
                 }
-                Log::record(sprintf("insert:refill_order request time=%.6f", microtime(true) - $start), Log::DEBUG);
-
-                if(!$this->pay_completed($order_sn)) {
-                    $logic_vr_order = Logic("vr_order");
-                    $order_info = Model('vr_order')->getOrderInfo(['order_id' => $order_id]);
-                    $logic_vr_order->changeOrderStateCancel($order_info, '', "预存款不足以支付该订单");
-                    break;
-                }
-            }
-            else {
-                Log::record("{$result['msg']}",Log::ERR);
                 continue;
             }
 
@@ -445,7 +457,7 @@ class RefillBase
                 $trade_no = $errmsg;
                 if ($provider->refill_type() == 'api') {
                     $logic_vr_order = Logic("vr_order");
-                    $logic_vr_order->changeOrderStateSend($order_id);
+                    $logic_vr_order->changeOrderStateSend($order_id,true);
                 }
 
                 $data = ['commit_time' => time(), 'ch_trade_no' => $trade_no];
@@ -462,7 +474,7 @@ class RefillBase
             else
             {
                 if($neterr && util::need_check($net_errno)) {
-                    $mod_refill->edit($order_id, ['neterr' => 1,'err_msg' => "neterr={$net_errno}"]);
+                    $mod_refill->edit($order_id, ['commit_time' => time(),'neterr' => 1,'err_msg' => "neterr={$net_errno}"]);
                     break;
                 }
 
@@ -475,7 +487,7 @@ class RefillBase
                 Log::record("channel:{$channel_name} err:{$errmsg}");
                 $logic_vr_order = Logic("vr_order");
                 $order_info = Model('vr_order')->getOrderInfo(['order_id' => $order_id]);
-                $logic_vr_order->changeOrderStateCancel($order_info, '', "调用{$channel_name}接口失败");
+                $logic_vr_order->changeOrderStateCancel($order_info, '', "调用{$channel_name}接口失败",true,true);
                 $mod_refill->edit($order_id, ['commit_time' => time()]);
             }
         }
@@ -494,7 +506,7 @@ class RefillBase
     private function pay_completed($order_sn)
     {
         $logic_payment = Logic('payment');
-        $order = $logic_payment->getVrOrderInfo($order_sn);
+        $order = $logic_payment->getVrOrderInfo($order_sn,'',true);
         $api_pay_amount = $order['data']['api_pay_amount'];
 
         return ($api_pay_amount == ncPriceFormat(0.00));
@@ -624,6 +636,9 @@ class RefillBase
         $mod_refill = Model('refill_order');
         $refill_info = $mod_refill->getOrderInfo(['order_id' => $order_id,'inner_status' => 0]);
         $chname = $refill_info['channel_name'];
+        $mchid = $refill_info['mchid'];
+        $mch_order = $refill_info['mch_order'];
+        $card_type = intval($refill_info['card_type']);
 
         try
         {
@@ -657,12 +672,21 @@ class RefillBase
             elseif($order_state == ORDER_STATE_SUCCESS || $order_state == ORDER_STATE_CANCEL)
             {
                 $logic_vr_order = Logic("vr_order");
-                $logic_vr_order->changeOrderStateSend($order_id);
+                $logic_vr_order->changeOrderStateSend($order_id,true);
 
                 $data = ['commit_time' => time()];
                 $mod_refill->edit($order_id, $data);
                 QueueClient::async_push("QueryRefillState",['order_id' => $order_id],1);
             }
+            elseif ($order_state == ORDER_STATE_NOEXIST) {
+                $logic_vr_order = Logic("vr_order");
+                $logic_vr_order->changeOrderStateCancel($order_info, '', "{$chname}查询订单不存在.",true,true);
+
+                $mod_refill->edit($order_id, ['notify_time' => time(), 'notify_state' => 1]);
+                util::pop_queue_order($mchid,$mch_order);
+                QueueClient::push("NotifyMerchantComplete", ['order_id' => $order_id,'manual' => false]);
+                util::del_exclude_channel($mchid,$mch_order,$card_type);
+            }
             else {
                 QueueClient::async_push("QueryOrderNeterr",['order_id' => $order_id],5);
             }
@@ -685,7 +709,7 @@ class RefillBase
                 $tran->commit();
 
                 $logic_vr_order = Logic("vr_order");
-                $logic_vr_order->changeOrderStateSuccess($order_id);
+                $logic_vr_order->changeOrderStateSuccess($order_id,true);
                 $refill_order = Model('refill_order');
                 $refill_order->edit($order_id, ['notify_time' => time(), 'notify_state' => 1,'is_retrying' => 0]);
                 mtopcard\cards_helper::assign($order_id);
@@ -721,7 +745,7 @@ class RefillBase
                 $tran->commit();
 
                 $logic_vr_order = Logic("vr_order");
-                $logic_vr_order->changeOrderStateCancel($order_info, '', "后台手动回调通知失败");
+                $logic_vr_order->changeOrderStateCancel($order_info, '', "后台手动回调通知失败",true,true);
                 $refill_order = Model('refill_order');
                 $refill_order->edit($order_id, ['notify_time' => time(), 'notify_state' => 1,'is_retrying' => 0]);
                 mtopcard\cards_helper::reuse($order_id);

+ 8 - 7
helper/refill/api/test/baidu/RefillPhone.php

@@ -5,7 +5,6 @@ namespace refill\baidu;
 require_once(BASE_HELPER_RAPI_PATH . '/baidu/config.php');
 
 use refill;
-use mtopcard;
 use Log;
 
 class RefillPhone extends refill\IRefillPhone
@@ -39,12 +38,14 @@ class RefillPhone extends refill\IRefillPhone
         Log::record("start request",Log::DEBUG);
         $resp = http_request(config::ORDER_URL, $params , 'POST' , false , [] , $net_errno);
         Log::record("recv length = " . strlen($resp),Log::DEBUG);
-        if ($resp === false) {
-            return [false, '系统错误',true];
-        } else {
-            $rand = mt_rand(0,1);
-            return [$rand , '',false];
-        }
+
+        return [true , '',false];
+//        if ($resp === false) {
+//            return [false, '系统错误',true];
+//        } else {
+//            $rand = mt_rand(0,1);
+//            return [$rand , '',false];
+//        }
     }
 
     public function query($refill_info)

+ 2 - 0
helper/refill/api/xyz/moxj/RefillPhone.php

@@ -80,6 +80,8 @@ class RefillPhone extends refill\IRefillPhone
                     $order_state = ORDER_STATE_CANCEL;
                 } elseif ($data['status'] == '充值中') {
                     $order_state = ORDER_STATE_SEND;
+                } elseif ($resp['msg'] == -8) {
+                    $order_state = ORDER_STATE_NOEXIST;
                 } else {
                     return [false, $resp['msg']];
                 }

+ 3 - 0
helper/refill/api/xyz/moxj_fs/RefillPhone.php

@@ -88,6 +88,9 @@ class RefillPhone extends refill\IRefillPhone
 
                 return [true, $order_state];
             }
+            elseif($resp['code'] == 106) {
+                return [true, ORDER_STATE_NOEXIST];
+            }
             else {
                 return [false, $resp['msg']];
             }

+ 3 - 0
helper/refill/api/xyz/moxj_yd/RefillPhone.php

@@ -87,6 +87,9 @@ class RefillPhone extends refill\IRefillPhone
                 }
                 return [true, $order_state];
             }
+            elseif($resp['code'] == 5) {
+                return [true, ORDER_STATE_NOEXIST];
+            }
             else {
                 return [false, $resp['message']];
             }

+ 2 - 0
helper/refill/api/xyz/weiyi/RefillPhone.php

@@ -81,6 +81,8 @@ class RefillPhone extends refill\IRefillPhone
                 $order_state = ORDER_STATE_CANCEL;
             } elseif ($resp['code'] === '0002' || $resp['code'] === '0003') {
                 $order_state = ORDER_STATE_SEND;
+            } elseif ($resp['code'] === '0005') {
+                $order_state = ORDER_STATE_NOEXIST;
             } else {
                 return [false, $resp['desc']];
             }

+ 2 - 0
helper/refill/api/xyz/weiyiman/RefillPhone.php

@@ -80,6 +80,8 @@ class RefillPhone extends refill\IRefillPhone
                 $order_state = ORDER_STATE_CANCEL;
             } elseif ($resp['code'] === '0002' || $resp['code'] === '0003') {
                 $order_state = ORDER_STATE_SEND;
+            } elseif ($resp['code'] === '0005') {
+                $order_state = ORDER_STATE_NOEXIST;
             } else {
                 return [false, $resp['desc']];
             }

+ 2 - 0
helper/refill/api/xyz/weiyiwt/RefillPhone.php

@@ -84,6 +84,8 @@ class RefillPhone extends refill\IRefillPhone
                 $order_state = ORDER_STATE_CANCEL;
             } elseif (in_array($status, [5011,5019])) {
                 $order_state = ORDER_STATE_SEND;
+            } elseif ($status === 5005) {
+                $order_state = ORDER_STATE_NOEXIST;
             } else {
                 return [false, $status];
             }

+ 3 - 1
helper/refill/api/xyz/yinteng/RefillPhone.php

@@ -82,8 +82,10 @@ class RefillPhone extends refill\IRefillPhone
                 $order_state = ORDER_STATE_SUCCESS;
             } elseif ($status === 5013) {
                 $order_state = ORDER_STATE_CANCEL;
-            } elseif (in_array($status, [5011,5019])) {
+            } elseif (in_array($status, [5011, 5019])) {
                 $order_state = ORDER_STATE_SEND;
+            } elseif (in_array($status, [5005])) {
+                $order_state = ORDER_STATE_NOEXIST;
             } else {
                 return [false, $status];
             }

+ 7 - 7
helper/refill/api/xyz/yinteng/接口地址.txt

@@ -1,9 +1,9 @@
-正式环境:
-话费下单地址:http://121.41.208.107:10186/plat/api/old/submitorder
-查询地址:http://121.41.208.107:10186/plat/api/old/queryorder
-查询余额地址:http://121.41.208.107:10186/plat/api/old/queryBalance
+锟斤拷式锟斤拷锟斤拷锟斤拷
+锟斤拷锟斤拷锟铰碉拷锟斤拷址锟斤拷http://121.41.208.107:10186/plat/api/old/submitorder
+锟斤拷询锟斤拷址锟斤拷http://121.41.208.107:10186/plat/api/old/queryorder
+锟斤拷询锟斤拷锟斤拷址锟斤拷http://121.41.208.107:10186/plat/api/old/queryBalance
 
-测试ID:200000
-钥:2a7533687d974571a2051ad555bfd2f5
+锟斤拷锟斤拷ID:200000
+锟斤拷钥:2a7533687d974571a2051ad555bfd2f5
 
-对接文档地址:https://docs.qq.com/doc/DWkV1VkxQVk13eEtQ
+锟皆斤拷锟侥碉拷锟斤拷址锟斤拷https://docs.qq.com/doc/DWkV1VkxQVk13eEtQ

+ 2 - 0
helper/refill/api/xyz/yunling/RefillPhone.php

@@ -85,6 +85,8 @@ class RefillPhone extends refill\IRefillPhone
                 $order_state = ORDER_STATE_CANCEL;
             } elseif (in_array($resultno, [0,2])) {
                 $order_state = ORDER_STATE_SEND;
+            } elseif ($resultno === 5007) {
+                $order_state = ORDER_STATE_NOEXIST;
             } else {
                 return [false, $resp['message']];
             }

+ 2 - 0
helper/refill/api/xyz/yunlingds/RefillPhone.php

@@ -85,6 +85,8 @@ class RefillPhone extends refill\IRefillPhone
                 $order_state = ORDER_STATE_CANCEL;
             } elseif (in_array($resultno, [0,2])) {
                 $order_state = ORDER_STATE_SEND;
+            } elseif ($resultno === 5007) {
+                $order_state = ORDER_STATE_NOEXIST;
             } else {
                 return [false, $resp['message']];
             }

+ 2 - 0
helper/refill/api/xyz/yunlingfs/RefillPhone.php

@@ -83,6 +83,8 @@ class RefillPhone extends refill\IRefillPhone
                 $order_state = ORDER_STATE_CANCEL;
             } elseif (in_array($resultno, [0,2])) {
                 $order_state = ORDER_STATE_SEND;
+            } elseif ($resultno === 5007) {
+                $order_state = ORDER_STATE_NOEXIST;
             } else {
                 return [false, $resp['message']];
             }

+ 2 - 0
helper/refill/api/xyz/yunsuoyao/RefillPhone.php

@@ -86,6 +86,8 @@ class RefillPhone extends refill\IRefillPhone
                     $order_state = ORDER_STATE_CANCEL;
                 } elseif (in_array($resultno, [0,2])) {
                     $order_state = ORDER_STATE_SEND;
+                } elseif ($resultno === 5007) {
+                    $order_state = ORDER_STATE_NOEXIST;
                 } else {
                     return [false, $resultno];
                 }

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

@@ -248,7 +248,7 @@ class policy extends ProviderManager implements IPolicy
             $resp = RBridgeFactory::instance()->notify($notify_url, $params);
         }
 
-        return $resp == "SUCCESS";
+        return $resp == "SUCCESS" || $resp == 'FAILED';
     }
 
     private function body($state, $refill_info, $mch_info)

+ 8 - 1
helper/refill/util.php

@@ -300,6 +300,12 @@ class util
         }
     }
 
+    public static function dispatcher_queue_length()
+    {
+        $ins = Cache::getInstance('cacheredis');
+        return $ins->lLen('QUEUE_DISPATCHER_CO');
+    }
+
     //统计提交订单数据
     public static function incr_commit_pre($chname, $card_type, $spec, $quality)
     {
@@ -487,6 +493,7 @@ class util
     ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
     public static function push_queue_order($mchid,$mch_order,$order_state)
     {
+        if(empty($mch_order)) return;
         $ins = Cache::getInstance('cacheredis');
 
         $name = 'merchant_order_query';
@@ -500,7 +507,7 @@ class util
 
         $name = 'merchant_order_query';
         $key = "{$mchid}-{$mch_order}";
-        $ins->hdel($name, '', $key);
+        $ret = $ins->hdel($name, '', $key);
     }
 
     public static function query_queue_order($mchid,$mch_order)

+ 1 - 9
mobile/control/refill.php

@@ -269,13 +269,7 @@ class refillControl extends merchantControl
         $result['order_time'] = $refill_info['order_time'];
         $result['success_time'] = $refill_info['notify_time'];
         $result['official_sn'] = $refill_info['official_sn'] ?? "";
-
-        if($refill_info['is_retrying']) {
-            $result['order_state'] = ORDER_STATE_NEW;
-        }
-        else {
-            $result['order_state'] = $order_info['order_state'];
-        }
+        $result['order_state'] = $order_info['order_state'];
 
         return $result;
     }
@@ -295,8 +289,6 @@ class refillControl extends merchantControl
             $result['mchid'] = $mchid;
             $result['order_sn'] = $order_sn;
             $result['order_state'] = $order_state;
-
-            $this->query_request($mchid,$order_sn);
             return self::outsuccess($result);
         }
         else

+ 3 - 5
rdispatcher/codispatcher.php

@@ -54,7 +54,6 @@ function subscribe_message(&$quit, &$redis, $channels)
             Log::record("subscribe_message start quit=" . strbool($quit),Log::DEBUG);
             if(!$redis->connected) {
                 $ret = $redis->connect(C('coroutine.redis_host'), C('coroutine.redis_port'));
-                Log::record("subscribe_message redis connected = {$redis->connected}",Log::DEBUG);
             }
             else {
                 $ret = true;
@@ -76,11 +75,11 @@ function subscribe_message(&$quit, &$redis, $channels)
                     if($quit) break;
 
                     if($type == 'channel' || $type == 'merchant') {
-                        Log::record("subscribe_message recv mgs:{$sub_type}-{$channel}-{$type}",Log::DEBUG);
+//                        Log::record("subscribe_message recv mgs:{$sub_type}-{$channel}-{$type}",Log::DEBUG);
                         refill\RefillFactory::instance()->load();
                     }
                     elseif($type == 'ratio') {
-                        Log::record("subscribe_message recv mgs:{$sub_type}-{$channel}-{$type}",Log::DEBUG);
+//                        Log::record("subscribe_message recv mgs:{$sub_type}-{$channel}-{$type}",Log::DEBUG);
 
                         $start = microtime(true);
                         $ins = Cache::getInstance('cacheredis');
@@ -98,10 +97,9 @@ function subscribe_message(&$quit, &$redis, $channels)
                         Log::record($msg,Log::DEBUG);
                     }
                     else {
-                        Log::record("subscribe_message recv mgs:{$sub_type}-{$channel}-{$type}",Log::DEBUG);
+//                        Log::record("subscribe_message recv mgs:{$sub_type}-{$channel}-{$type}",Log::DEBUG);
                     }
                 }
-                Log::record("subscribe_message redis recv timeout",Log::DEBUG);
             }
             else {
                 Log::record("subscribe_message subscribe error",Log::ERR);

+ 3 - 3
rdispatcher/processor.php

@@ -33,7 +33,6 @@ class processor extends queue\ILooper
                 } elseif ($method == 'notify') {
                     $channel = $params['channel'];
                     $input = $params['params'];
-
                     if (empty($channel) || empty($params))
                         continue;
                     $this->mProxy->notify($channel, $input);
@@ -58,8 +57,9 @@ class processor extends queue\ILooper
                 } else {
                     Log::record("Error Method={$method}", Log::DEBUG);
                 }
-            } catch (Exception $x) {
-                Log::record($x->getMessage(), Log::ERR);
+            }
+            catch (Exception $x) {
+                Log::record("processor::handle ". $x->getMessage(), Log::ERR);
             }
         }
 

+ 7 - 2
rdispatcher/proxy.php

@@ -89,13 +89,17 @@ class proxy
             elseif(($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,'',$regin_no);
-                if ($quality > 0) {
+                if ($quality > 0)
+                {
                     $fNotify = false;
                     $params['order_id'] = $order_id;
                     if($order_id > 0) {
                         $refill_order->edit($order_id, ['is_retrying' => 1]);
                     }
-                    refill\util::push_add($params);
+
+                    if(!refill\util::push_add($params)) {
+                        $fNotify = true;
+                    }
                 }
             }
 
@@ -109,6 +113,7 @@ class proxy
                             $mch_order, $idcard, $card_name, $notify_url, $quality, $org_quality, $order_time, $commit_times, $errmsg);
                     } else {
                         $order_id = $order_info['order_id'];
+                        $refill_order->edit($order_id, ['notify_time' => time(), 'notify_state' => 1,'is_retrying' => 0]);
                     }
                 }
                 else {

+ 29 - 0
test/TestHttp.php

@@ -0,0 +1,29 @@
+<?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');
+
+class TestHttp extends TestCase
+{
+    public static function setUpBeforeClass(): void
+    {
+        Base::run_util();
+    }
+
+    public function testRequest()
+    {
+        Log::record(__METHOD__,Log::DEBUG);
+        for ($i = 0; $i < 10000; $i++) {
+            $rsp = http_request("http://test.xyzshops.cn");
+        }
+    }
+}

+ 7 - 6
test/TestRefill.php

@@ -1281,12 +1281,13 @@ class TestRefill extends TestCase
     public function testcreateSign()
     {
         $params['act'] = 'refill';
-        $params['amount'] = '100';
-        $params['cardno'] = '11100';
-        $params['mchid'] = '10152';
-        $params['notifyurl'] = 'http://122.114.168.35/gateway/api.notify/call?s_order=D20210623163820797539530&s_type=1';
+        $params['amount'] = '30';
+        $params['cardno'] = '18500972879';
+        $params['mchid'] = '10175';
+        $params['notifyurl'] = 'https://su.emgot.com/union/coco/rechargeNotify';
         $params['op'] = 'add';
-        $params['order_sn'] = 'D20210623163820797539530';
+        $params['order_sn'] = '20210706125001412243513';
+        $params['quality'] = 7;
         $sign = $this->md5_sign($params);
     }
 
@@ -1340,7 +1341,7 @@ class TestRefill extends TestCase
             }
         }
 
-        $body .= "&key=NNLUOn14tNBeG7JJRGoPDKEO6Ocdt89G";
+        $body .= "&key=BcuXVAbW3KstGRWh6EdMMoFIfq9XKUW0";
 
         return md5($body);
     }

+ 54 - 3
test/TestRefillThird.php

@@ -64,16 +64,67 @@ class TestRefillThird extends TestCase
 
     public function testPushPhone()
     {
-        $params = [ 'mchid' => 9618,
-            'buyer_id' => 6,
+        $params = [ 'mchid' => 1092,
+            'buyer_id' => 60221,
             'amount' => 30,
             'mch_order' => $this->make_sn(),
-            'org_quality' => 15,
+            'org_quality' => 1,
             'card_no' => '13911129867'
         ];
 
         $ret = refill\util::push_add($params);
+        Log::record("push message",Log::DEBUG);
     }
+    //docker-compose run phpcli php /var/www/html/phpunit-9.2.5.phar --filter "/(TestRefillThird::testPushPhone)( .*)?$/" --test-suffix TestRefillThird.php /var/www/html/test
+
+    public function testPushPhones()
+    {
+        $time = time();
+        for ($i = 0; $i < 1000000; $i++)
+        {
+            $params = [ 'mchid' => 1092,
+                'buyer_id' => 60221,
+                'amount' => 30,
+                'mch_order' => "{$time}" . sprintf("%'010d",$i),
+                'org_quality' => 1,
+                'card_no' => '13911129867'
+            ];
+
+            $ret = refill\util::push_add($params);
+            Log::record("push message",Log::DEBUG);
+        }
+        //docker-compose run phpcli php /var/www/html/phpunit-9.2.5.phar --filter "/(TestRefillThird::testPushPhones)( .*)?$/" --test-suffix TestRefillThird.php /var/www/html/test
+    }
+
+    private function push_order($mchid,$member_id,$time,$index)
+    {
+        $params = [ 'mchid' => $mchid,
+            'buyer_id' => $member_id,
+            'amount' => 30,
+            'mch_order' => "{$time}" . sprintf("%'010d",$index),
+            'org_quality' => 1,
+            'card_no' => '13911129867'
+        ];
+        $ret = refill\util::push_add($params);
+    }
+
+    public function testPushOtherPhones()
+    {
+        $time = time();
+        Log::record("push message start:{$time}",Log::DEBUG);
+
+        for ($i = 0; $i < 100000; $i++)
+        {
+            $this->push_order(1092,60221,$time,$i);
+//            $this->push_order(1093,65771,$time,$i);
+//            $this->push_order(1094,65772,$time,$i);
+//            $this->push_order(1095,65773,$time,$i);
+//            $this->push_order(1096,65774,$time,$i);
+        }
+        Log::record("push message end",Log::DEBUG);
+        //docker-compose run phpcli php /var/www/html/phpunit-9.2.5.phar --filter "/(TestRefillThird::testPushOtherPhones)( .*)?$/" --test-suffix TestRefillThird.php /var/www/html/test
+    }
+
 
     public function testPushLzThird()
     {