Parcourir la source

Merge branch 'relectric' into raccount

xiaoyu il y a 2 ans
Parent
commit
37ce95fdea

+ 4 - 4
admin/control/control.php

@@ -383,9 +383,9 @@ class SystemControl
         return array_column($res, 'order_id');
     }
 
-    protected function merchants($condition = [])
+    protected function merchants($condition = [], $order= 'company_name asc')
     {
-        $items = Model('')->table('merchant')->where($condition)->limit(1000)->order('company_name asc')->select();
+        $items = Model('')->table('merchant')->where($condition)->limit(1000)->order($order)->select();
         foreach ($items as &$item) {
             $item['pinyin'] = Pinyin::getPinyin(strtolower($item['company_name']));
             $item['alpha'] = substr($item['pinyin'],0,1);
@@ -410,14 +410,14 @@ class SystemControl
         return $items;
     }
 
-    protected function providers($condition = [])
+    protected function providers($condition = [], $order = 'opened asc, name asc')
     {
         $items = Model('')->table('refill_provider,store')
             ->field('refill_provider.*,store.store_name')
             ->join('inner')
             ->on('store.store_id=refill_provider.store_id')
             ->where($condition)
-            ->order('opened asc, name asc')
+            ->order($order)
             ->limit(1000)
             ->select();
 

+ 39 - 0
admin/control/refill_merchant_channel_cfg.php

@@ -0,0 +1,39 @@
+<?php
+
+class refill_merchant_channel_cfgControl extends SystemControl
+{
+    public function __construct()
+    {
+        parent::__construct();
+    }
+
+    public function indexOp()
+    {
+        $type = $_GET['type'] ?? $_POST['type'];
+        if(empty($type)) $type = mtopcard\PhoneCardPaper;
+        $quality = $_GET['quality'] ?? $_POST['quality'];
+        if(empty($quality)) $quality = refill\Quality::Normal;
+        $cache_field = "{$type}-{$quality}";
+
+        $merchants = $this->merchants(['merchant_state' => 1], 'merchant_state asc, company_name asc');
+        $providers = $this->providers(['type' => $type, 'qualitys' => ['like', '%' . $quality . '%'], 'oper_time' => ['gt', time()-86400*7]]);
+
+        if(chksubmit())
+        {
+            $sel = $_POST['sel'] ?? [];
+            wcache('refill_merchant_channel-cfg', [$cache_field => serialize($sel)], 'refill-');
+            showMessage('编辑成功');
+        }
+        else
+        {
+            $data = rcache('refill_merchant_channel-cfg', 'refill-', $cache_field);
+            $val = $data[$cache_field] ?? serialize([]);
+            $merchant_channel_cfg = unserialize($val);
+
+            Tpl::output('merchant_channel_cfg', $merchant_channel_cfg);
+            Tpl::output('merchant_list', $merchants);
+            Tpl::output('provider_list', $providers);
+            Tpl::showpage('refill.merchant.channel.cfg');
+        }
+    }
+}

+ 7 - 0
admin/control/refill_order_manual.php

@@ -535,6 +535,13 @@ class refill_order_manualControl extends SystemControl
             elseif ($type === 'canceled_order_retry_next') {
                 [$succ,$err] = refill\util::retry_canceled_order($order_id,true);
                 $this->log("预回调订单失败补快充,订单号:{$order['order_sn']},商家单号:{$mch_order},机构编码:{$mchid} err:{$err}");
+            }
+            elseif ($type === 'buybacked') {
+                $this->log("预回调订单返销操作,订单号:{$order['order_sn']},商家单号:{$mch_order},机构编码:{$mchid} err:{$err}");
+            }
+            elseif ($type === 'manual_recharged') {
+                $manual_recharge_amount = $_GET['manual_recharge_amount'] ?? 0;
+                $this->log("预回调订单手动补充录入,订单号:{$order['order_sn']},商家单号:{$mch_order},机构编码:{$mchid} err:{$err}");
             } else {
                 continue;
             }

+ 1 - 0
admin/include/limit.php

@@ -35,6 +35,7 @@ $_limit =  array(
         array('name'=> '订单列表', 'op'=>null, 'act'=>'refill_order'),
         array('name'=> '通道列表', 'op'=>null, 'act'=>'provider'),
         array('name'=> '通道控制', 'op'=>null, 'act'=>'provider_ctl'),
+        array('name'=> '机构通道配置', 'op'=>null, 'act'=>'refill_merchant_channel_cfg'),
         array('name'=> '通道组管理', 'op'=> null, 'act'=>'provider_group'),
         array('name'=> '订单监控', 'op'=>null, 'act'=>'ordersendlist'),
         array('name'=> '对账管理', 'op'=>null, 'act'=>'orderstats'),

+ 1 - 0
admin/include/menu.php

@@ -98,6 +98,7 @@ $arr = array(
 					array('args'=>'index,refill_order,merchant',			'text'=>'订单列表'),
 					array('args'=>'index,provider,merchant',				'text'=>'通道列表'),
 					array('args'=>'index,provider_ctl,merchant',			'text'=>'通道控制'),
+					array('args'=>'index,refill_merchant_channel_cfg,merchant',			'text'=>'机构通道配置'),
 					array('args'=>'index,provider_group,merchant',			'text'=>'通道组管理'),
 					array('args'=>'index,ordersendlist,merchant',			'text'=>'订单监控'),
 					array('args'=>'index,orderstats,merchant',				'text'=>'对账管理'),

+ 433 - 0
admin/templates/default/refill.merchant.channel.cfg.php

@@ -0,0 +1,433 @@
+<link href="<?php echo ADMIN_TEMPLATES_URL; ?>/css/recharge.css?<?php echo rand(1, 10); ?>" rel="stylesheet" type="text/css" id="cssfile2" />
+<style>
+    .batch {
+        vertical-align: middle;
+        display: inline-block;
+        *display: inline
+            /*IE7*/
+        ;
+        margin-left: 4px;
+        position: relative;
+        z-index: 1;
+        *zoom: 1
+            /*IE7*/
+        ;
+    }
+
+    .batch i {
+        cursor: pointer;
+    }
+
+    .batch-input {
+        background-color: #FFF;
+        white-space: nowrap;
+        padding: 4px 9px;
+        border: solid 1px #BCE8F1;
+        position: absolute;
+        z-index: 1;
+        bottom: -75px;
+        left: -88px;
+        box-shadow: 3px 3px 0 rgba(153, 153, 153, 0.25);
+    }
+
+    .batch-input h6 {
+        font-size: 12px;
+        color: #555;
+    }
+
+    .batch-input .text {
+        vertical-align: middle;
+        clear: both;
+        padding: 0 4px;
+        vertical-align: middle;
+        margin-right: 4px;
+    }
+
+    .batch-input .arrow {
+        background: url(<?php echo SHOP_SITE_URL; ?>/templates/default/images/seller/ncsc_bg_img.png) no-repeat -240px -20px;
+        display: block;
+        width: 10px;
+        height: 5px;
+        margin-left: 1px;
+        top: -5px;
+        left: 50%;
+        position: absolute;
+        z-index: 2;
+        transform: rotate(180deg);
+    }
+
+    .batch-input a.close {
+        font-size: 11px;
+        line-height: 12px;
+        color: #BCE8F1;
+        text-decoration: none;
+        background-color: #FFF;
+        text-align: center;
+        display: block;
+        width: 12px;
+        height: 12px;
+        border-radius: 7px;
+        border: solid 1px #BCE8F1;
+        top: -7px;
+        right: -7px;
+        position: absolute;
+        z-index: 2;
+    }
+
+    .text.price {
+        width: 40px;
+    }
+
+    .text.pricee {
+        width: 40px;
+    }
+
+    .fixed-bar {
+        width: 100%;
+    }
+
+    #price_table {
+        table-layout: fixed;
+        width: 100%;
+        height: calc(100vh - 220px);
+        overflow: auto;
+        display: block;
+        margin-top: 80px;
+    }
+
+    #price_table tr th:first-child {
+        position: sticky;
+        top: 0;
+        left: 0;
+        background: #fff;
+        box-shadow: 2px 0 2px rgb(0 0 0 / 10%);
+        z-index: 11;
+    }
+
+    #price_table tr:first-child {
+        position: sticky;
+        top: 0;
+        z-index: 11;
+        background: #fff;
+    }
+
+    /* #price_table tr:nth-child(2) {
+        position: sticky;
+        top: 41px;
+        z-index: 11;
+        background: #fff;
+    } */
+
+    #price_table tr td:first-child {
+        display: block;
+        position: sticky;
+        left: 0;
+        box-shadow: 2px 0 2px rgb(0 0 0 / 10%);
+        z-index: 10;
+    }
+
+    #price_table tbody tr:hover .batch-td {
+        background: #cbe9f3 !important;
+    }
+
+    .provider_amount_control .batch-td {
+        min-width: 40px !important;
+        padding: 0 !important;
+    }
+
+    .tb-type2 th {
+        transform: scale(0.9);
+        line-height: 1.2 !important;
+    }
+
+    .table th,
+    .table td {
+        padding: 2px !important;
+    }
+</style>
+<?php defined('InShopNC') or exit('Access Invalid!'); ?>
+<div class="page provider_amount_control">
+    <div class="fixed-bar">
+        <div class="item-title">
+            <h3>机构通道配置</h3>
+            <ul class="tab-base">
+                <li><a href="index.php?act=refill_merchant_channel_cfg&op=index&type=2&quality=<?php echo refill\Quality::Normal; ?>" class="classA" data-type="2-<?php echo refill\Quality::Normal; ?>"><span>普充话费通道控制</span></a></li>
+                <li><a href="index.php?act=refill_merchant_channel_cfg&op=index&type=2&quality=<?php echo refill\Quality::Quick; ?>" class="classA" data-type="2-<?php echo refill\Quality::Quick; ?>"><span>快充话费通道控制</span></a></li>
+                <li><a href="index.php?act=refill_merchant_channel_cfg&op=index&type=2&quality=<?php echo refill\Quality::CardKey; ?>" class="classA" data-type="2-<?php echo refill\Quality::CardKey; ?>"><span>卡密话费通道控制</span></a></li>
+                <li><a href="index.php?act=refill_merchant_channel_cfg&op=index&type=2&quality=<?php echo refill\Quality::ThirdShop; ?>" class="classA" data-type="2-<?php echo refill\Quality::ThirdShop; ?>"><span>三方话费通道控制</span></a></li>
+                <li><a href="index.php?act=refill_merchant_channel_cfg&op=index&type=2&quality=<?php echo refill\Quality::SlowTwentyFour; ?>" class="classA" data-type="2-<?php echo refill\Quality::SlowTwentyFour; ?>"><span>慢24话费通道控制</span></a></li>
+                <li><a href="index.php?act=refill_merchant_channel_cfg&op=index&type=2&quality=<?php echo refill\Quality::SlowSix; ?>" class="classA" data-type="2-<?php echo refill\Quality::SlowSix; ?>"><span>慢6话费通道控制</span></a></li>
+                <li><a href="index.php?act=refill_merchant_channel_cfg&op=index&type=2&quality=<?php echo refill\Quality::SlowTwo; ?>" class="classA" data-type="2-<?php echo refill\Quality::SlowTwo; ?>"><span>慢2话费通道控制</span></a></li>
+                <li><a href="index.php?act=refill_merchant_channel_cfg&op=index&type=2&quality=<?php echo refill\Quality::SlowFortyEight; ?>" class="classA" data-type="2-<?php echo refill\Quality::SlowFortyEight; ?>"><span>慢48话费通道控制</span></a></li>
+                <li><a href="index.php?act=refill_merchant_channel_cfg&op=index&type=2&quality=<?php echo refill\Quality::SlowSeventyTwo; ?>" class="classA" data-type="2-<?php echo refill\Quality::SlowSeventyTwo; ?>"><span>慢72话费通道控制</span></a></li>
+                <li><a href="index.php?act=refill_merchant_channel_cfg&op=index&type=2&quality=<?php echo refill\Quality::Fastest; ?>" class="classA" data-type="2-<?php echo refill\Quality::Fastest; ?>"><span>速充话费通道控制</span></a></li>
+
+                <li><a href="index.php?act=refill_merchant_channel_cfg&op=index&type=1&quality=<?php echo refill\Quality::Normal; ?>" class="classA" data-type="1-<?php echo refill\Quality::Normal; ?>"><span>无流水油卡通道控制</span></a></li>
+                <li><a href="index.php?act=refill_merchant_channel_cfg&op=index&type=1&quality=<?php echo refill\Quality::SlowTwentyFour; ?>" class="classA" data-type="1-<?php echo refill\Quality::SlowTwentyFour; ?>"><span>有流水油卡通道控制</span></a></li>
+                <li><a href="index.php?act=refill_merchant_channel_cfg&op=index&type=1&quality=<?php echo refill\Quality::CardKey; ?>" class="classA" data-type="1-<?php echo refill\Quality::CardKey; ?>"><span>卡密油卡通道控制</span></a></li>
+                <li><a href="index.php?act=refill_merchant_channel_cfg&op=index&type=1&quality=<?php echo refill\Quality::Quick; ?>" class="classA" data-type="1-<?php echo refill\Quality::Quick; ?>"><span>快充油卡通道控制</span></a></li>
+            </ul>
+        </div>
+    </div>
+    <div class="fixed-empty"></div>
+    <form id="price_form" enctype="multipart/form-data" method="post">
+        <input type="hidden" name="form_submit" value="ok" />
+        <table class="table tb-type2 tableFixed">
+            <tbody class="tbody">
+                <tr>
+                    <td colspan="2" class="required"><label>机构通道设置:</label></td>
+                </tr>
+                <tr class="noborder">
+                    <table class="table tb-type2" id="price_table">
+                        <tbody class="tbody tableContent">
+                            <tr>
+                                <th class="align-center w130 mw130" style="transform: scale(1);">机构名称</th>
+                                <?php foreach ($output['provider_list'] as $k => $provider) { ?>
+                                    <th class="align-center" style="vertical-align: top;">
+                                        <div><input type="checkbox" name="chbox" value="" class="checkAllCol" data-index="<?php echo $k ?>"></div>
+                                            <?php if ($provider['opened'] == 1) { ?>
+                                                <span style="color: #0bb20c">
+                                            <?php } ?><?php if ($provider['opened'] == 2) { ?>
+                                                <span style="color: #f30707">
+                                            <?php } ?>
+
+                                            <?php echo $provider['store_name'] ?></span>
+
+                                    </th>
+                                <?php } ?>
+                            </tr>
+                            <!-- <tr>
+                                <th class="align-center w120 mw120" style="height:16px">
+                                    </td>
+                                    <?php foreach ($output['provider_list'] as $k => $provider) { ?>
+                                <th class="batch-td">
+                                    
+                                </th>
+                            <?php } ?>
+
+                            </tr> -->
+                            <?php foreach ($output['merchant_list'] as $k => $merchant) { ?>
+                                <tr class="w500 trFlex">
+                                    <td style="width: 130px;min-width:130px;white-space: nowrap;display: flex;align-items: center;" class="tbFlex">
+                                        <input type="checkbox" class="checkAllRow" />
+                                        <?php if ($merchant['merchant_state'] == 1) { ?>
+                                        <span style="color: #0bb20c">
+                                            <?php } ?><?php if ($merchant['merchant_state'] == 2) { ?>
+                                                <span style="color: #f30707">
+                                            <?php } ?>
+
+                                            <?php echo $merchant['company_name'] ?? $merchant['name']; ?></span>
+                                    </td>
+                                    <?php foreach ($output['provider_list'] as $provider) { ?>
+                                        <td class="batch-td">
+                                            <input type="checkbox" class="cellCheckBox cellCheckBox-<?php echo $k ?>" id="checkBoxList" name="sel[<?php echo $merchant['mchid'] ?>][]" value="<?php echo $provider['provider_id']; ?>" <?php
+                                                                                                                                                                                                                                        if (!empty($output['merchant_channel_cfg']) && array_key_exists($merchant['mchid'], $output['merchant_channel_cfg']) && in_array($provider['provider_id'], $output['merchant_channel_cfg'][$merchant['mchid']])) {
+                                                                                                                                                                                                                                            echo 'checked';
+                                                                                                                                                                                                                                        }
+                                                                                                                                                                                                                                        ?>>
+                                        </td>
+                                    <?php } ?>
+                                </tr>
+                            <?php } ?>
+                        </tbody>
+                    </table>
+                </tr>
+            </tbody>
+            <tfoot>
+                <tr class="tfoot">
+                    <td colspan="15"><a href="JavaScript:void(0);" class="btn" style="margin-top: 15px" id="submitBtn"><span><?php echo $lang['nc_submit']; ?></span></a></td>
+                </tr>
+            </tfoot>
+        </table>
+    </form>
+</div>
+<script type="text/javascript" src="<?php echo RESOURCE_SITE_URL; ?>/js/dialog/dialog.js" id="dialog_js" charset="utf-8"></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/ajaxfileupload/ajaxfileupload.js"></script>
+<script type="text/javascript" src="<?php echo RESOURCE_SITE_URL; ?>/js/jquery.Jcrop/jquery.Jcrop.js"></script>
+<script type="text/javascript" src="<?php echo RESOURCE_SITE_URL; ?>/refill/layer.js"></script>
+<link href="<?php echo RESOURCE_SITE_URL; ?>/js/jquery.Jcrop/jquery.Jcrop.min.css" rel="stylesheet" type="text/css" id="cssfile2" />
+<script type="text/javascript">
+    $(function() {
+        let isSubmit = true
+        $('.input-one').blur(function() {
+            let value = $(this)[0].value
+            if (value >= -1) {
+                isSubmit = true;
+                $(this)[0].style['borderColor'] = ''
+            } else {
+                isSubmit = false
+                $(this)[0].style['borderColor'] = '#e64444'
+            }
+        })
+        $('.input-tow').blur(function() {
+            let value = $(this)[0].value
+            if (value >= 1 && value <= 100) {
+                isSubmit = true;
+                $(this)[0].style['borderColor'] = ''
+            } else {
+                isSubmit = false
+                $(this)[0].style['borderColor'] = '#e64444'
+            }
+        })
+        $('.input-three').blur(function() {
+            let value = $(this)[0].value
+            if (value == 0 || value == 1) {
+                isSubmit = true
+                $(this)[0].style['borderColor'] = ''
+            } else {
+                isSubmit = false
+                $(this)[0].style['borderColor'] = '#e64444'
+            }
+        })
+
+        // 开始获取当前地址
+        let type = '<?php echo $_GET['type'] ?? mtopcard\PhoneCardPaper; ?>';
+        let quality = '<?php echo $_GET['quality'] ?? refill\Quality::Normal; ?>';
+        $(".classA").each(function() {
+            if (type + '-' + quality === $(this).attr("data-type")) {
+                $(this).addClass('current')
+                $(this).attr('href', 'JavaScript:void(0);')
+            }
+        })
+
+        // 提交
+        $("#submitBtn").click(function() {
+            console.log('isSubmit', isSubmit);
+            if (isSubmit) {
+                $("#price_form").submit();
+            }
+        })
+
+        // tab样式
+        $(".tab-base a").click(function() {
+            $(this).addClass('current')
+            $(this).siblings().removeClass('current')
+        })
+        // 表格hover时背景
+        $('#price_table td').each(function() {
+            let colorIndex = $(this).attr('data-color')
+            const colorArr = ['#fff', '#f1dde6', '#c8c6f3', '#fff', '#f1dde6', '#c8c6f3', '#f2f3c6', '#fff'];
+            if (colorArr[colorIndex]) {
+                $(this).css('background', colorArr[colorIndex]);
+            } else {
+                $(this).css('background', '#fff');
+            }
+
+            // if (color == 4 || color == 1) {
+            //     $(this).css('background', '#f1dde6')
+            // } else if (color == 5 || color == 2) {
+            //     $(this).css('background', '#c8c6f3')
+            // } else if (color == 6) {
+            //     $(this).css('background', '#f2f3c6')
+            // } else {
+            //     $(this).css('background', '#fff')
+            // }
+        })
+
+        // $('#price_table .tableContent tr').hover(function() {
+        //         $(this)[0].style.backgroundColor = '#cbe9f3'
+        //     }, function() {
+        //         if (color == 4 || color == 1) {
+        //             $(this).css('background', '#f1dde6')
+        //         } else if (color == 5 || color == 2) {
+        //             $(this).css('background', '#c8c6f3')
+
+        //         } else if (color == 6) {
+        //             $(this).css('background', '#f2f3c6')
+
+        //         } else {
+        //             $(this).css('background', '#fff')
+
+        //         }
+        //     })
+
+        // 批量设置开关
+        $('.batch > .icon-edit').click(function() {
+            $('.batch > .batch-input').hide();
+            $(this).next().show();
+        });
+        $('.batch-input > .close').click(function() {
+            $(this).parent().hide();
+        });
+        $('.price').change(function() {
+            let val = $(this).val()
+            if (val != '1' && val != '0') {
+                layer.msg('开关只能设置0或1');
+            }
+        })
+        // 点击设置
+        $('.ncsc-btn-mini').click(function() {
+            let price = $(this).siblings('.price').val()
+            if (price != '1' && price != '0') {
+                layer.msg('开关只能设置0或1');
+                return
+            }
+            var lie = $(this).parents('.batch-td').prevAll().length
+            $('.input-three').each(function() {
+                let tdCon = $(this).parents('td').prevAll().length / 2
+                let readOnly = $(this).attr('readOnly')
+                if (lie == tdCon && !readOnly) {
+                    $(this).val(price)
+                }
+            })
+
+        })
+        // 单量设置开关
+        $('.batch > .icon-edit').click(function() {
+            $('.batch > .batch-input').hide();
+            $(this).next().show();
+        });
+        $('.batch-input > .close').click(function() {
+            $(this).parent().hide();
+        });
+        $('.pricee').change(function() {
+            let val = $(this).val()
+            if (val <= -2) {
+                layer.msg('单量只能设置大于-1');
+            }
+        })
+        // 点击设置
+        $('.ncsc-btn-quantity').click(function() {
+            let quantity = $(this).siblings('.quantity').val()
+            if (quantity <= -2) {
+                layer.msg('单量只能设置大于-1');
+                return
+            }
+            let lie = $(this).parents('.batch-td').prevAll().length;
+            $('.input-one').each(function(index, item) {
+                let tdCon = $(this).parents('td').prevAll().length / 2
+                let readOnly = $(this).attr('readOnly')
+                if (lie == tdCon && !readOnly) {
+                    $(this).val(quantity)
+                }
+            })
+        })
+
+        $('.checkAllCol').click(function() {
+            const index = $(this).attr('data-index');
+            const batchTd = $('.trFlex').find('.batch-td');
+
+            console.log('checkAllCol', $('.trFlex'));
+            if ($(this).is(':checked')) {
+                for (let i = 0; i < $('.trFlex').length; i++) {
+                    $('.trFlex').eq(i).find('.batch-td').eq(index).find('input').attr('checked', true)
+                }
+            } else {
+                for (let i = 0; i < $('.trFlex').length; i++) {
+                    $('.trFlex').eq(i).find('.batch-td').eq(index).find('input').attr('checked', false)
+                }
+            }
+
+        })
+
+        $('.checkAllRow').click(function() {
+            if ($(this).is(':checked')) {
+                $(this).parent().siblings('td').find('.cellCheckBox').attr('checked', true)
+            } else {
+                $(this).parent().siblings('td').find('.cellCheckBox').attr('checked', false);
+            }
+
+        })
+    });
+</script>

+ 12 - 20
admin/templates/default/transfer.order.php

@@ -117,9 +117,10 @@
                 <td class="layui-form">
                     <select name="mchid" class="querySelect" lay-verify="" lay-search>
                         <option value=""><?php echo $lang['nc_please_choose']; ?></option>
+                        <?php if(!empty($output['merchant_list'])){?>
                         <?php foreach ($output['merchant_list'] as $merchant) { ?>
                             <option value="<?php echo $merchant['mchid'] ?>"<?php if ($_GET['mchid'] == $merchant['mchid']){ ?>selected<?php } ?>><?php echo $merchant['company_name'] == '' ? $merchant['name'] : $merchant['company_name']; ?></option>
-                        <?php } ?>
+                        <?php }} ?>
                     </select>
                 </td>
                 <th><label class="query_ors">充值卡号(多行查询)</label></th>
@@ -175,7 +176,7 @@
             </tr>
         </thead>
         <tbody id="tbody">
-            <?php if (count($output['list']) > 0) { ?>
+            <?php if (!empty($output['list']) && count($output['list']) > 0) { ?>
                 <?php
                 foreach ($output['list'] as $key => $order) { ?>
                     <tr class="hover trFlex">
@@ -207,8 +208,7 @@
                         <td class="align-center"><?php echo $order['quality_text']; ?></td>
                         <td class="align-center"><?php echo orderState($order); ?></td>
                         <td class="align-center">
-                            <input type="hidden" value="<?php echo $order['can_cancel']; ?>">
-                            <a href="index.php?act=refill_order_manual&op=transfer_order_dispose&type=set_next_order&order_ids=<?php echo $order['order_id']; ?>" id="hdFail">
+                            <a href="index.php?act=refill_order_manual&op=transfer_order_dispose&type=set_next_order&order_ids=<?php echo $order['order_id']; ?>">
                                 拦截转快充</a>
                         </td>
                     </tr>
@@ -237,10 +237,10 @@
 <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() {
-        $('#hCopyCardNo').click(function() {
+        function copy_some(col) {
             let str = ''
-            $('#tbody tr').each(function () {
-                let res = $(this).find('td').eq(5).text()
+            $('#tbody tr').each(function() {
+                let res = $(this).find('td').eq(col).text()
                 str += res + '\n'
             })
             let oInput = document.createElement("textarea");
@@ -251,22 +251,14 @@
             oInput.select(); // 选择对象
             document.execCommand("Copy"); // 执行浏览器复制命令
             oInput.parentNode.removeChild(oInput)
+        }
+
+        $('#hCopyCardNo').click(function() {
+            copy_some(5)
         });
 
         $('#hCopyMchOrderNo').click(function() {
-            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)
+            copy_some(4)
         });
 
         $('#ncsubmit').click(function() {

+ 101 - 61
admin/templates/default/transfer.order.recharge.php

@@ -117,9 +117,11 @@
                 <td class="layui-form">
                     <select name="mchid" class="querySelect" lay-verify="" lay-search>
                         <option value=""><?php echo $lang['nc_please_choose']; ?></option>
+                        <?php if(!empty($output['merchant_list'])){?>
+
                         <?php foreach ($output['merchant_list'] as $merchant) { ?>
                             <option value="<?php echo $merchant['mchid'] ?>"<?php if ($_GET['mchid'] == $merchant['mchid']){ ?>selected<?php } ?>><?php echo $merchant['company_name'] == '' ? $merchant['name'] : $merchant['company_name']; ?></option>
-                        <?php } ?>
+                        <?php }} ?>
                     </select>
                 </td>
                 <th><label class="query_ors">充值卡号(多行查询)</label></th>
@@ -157,6 +159,13 @@
                     </a>
                 </td>
             </tr>
+            <tr>
+                <td>
+                    <a href="#" class="btns" id="buybacked">
+                        <span><i class="icon-edit"></i>批量返销处理</span>
+                    </a>
+                </td>
+            </tr>
         </table>
     </form>
     <table class="table tb-type2 nobdb">
@@ -167,7 +176,7 @@
             </th>
             <th class="align-center">编号</th>
             <th class="align-center">机构编号</th>
-            <th class="align-center">机构名称</th>
+            <th class="align-left">机构名称</th>
             <th class="align-center">商家单号</th>
             <th class="align-center">充值卡号</th>
             <th class="align-center">充值面值</th>
@@ -176,20 +185,21 @@
             <th class="align-left">供方名称</th>
             <th class="align-center">当前质量</th>
             <th class="align-center">订单状态</th>
+            <th class="align-center">返销/补充</th>
             <th class="align-center"><?php echo $lang['nc_handle']; ?></th>
         </tr>
         </thead>
         <tbody id="tbody">
-        <?php if (count($output['list']) > 0) { ?>
+        <?php if (!empty($output['list']) && count($output['list']) > 0) { ?>
             <?php
             foreach ($output['list'] as $key => $order) { ?>
                 <tr class="hover trFlex">
                     <td class="align-center">
                         <input type="checkbox" id="checkBoxList" name="checkbox" value="<?php echo $order['order_id']; ?>">
                     </td>
-                    <td class="align-center"><?php echo $key + 1; ?></td>
+                    <td class="align-center"><?php echo $order['order_id']; ?></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['mch_name']; ?></td>
                     <td class="align-center"><?php echo $order['mch_order']; ?></td>
                     <td class="align-center"><?php echo $order['card_no']; ?></td>
                     <td class="align-center"><?php echo $order['refill_amount']; ?></td>
@@ -217,11 +227,15 @@
                     <td class="align-center"><?php echo $order['quality_text']; ?></td>
                     <td class="align-center"><?php echo orderState($order); ?></td>
                     <td class="align-center">
-                        <input type="hidden" value="<?php echo $order['can_cancel']; ?>">
-                        <a href="index.php?act=refill_order_manual&op=transfer_order_dispose&type=canceled_order_retry&order_ids=<?php echo $order['order_id']; ?>" id="hdFail">
+                        <a href="index.php?act=refill_order_manual&op=transfer_order_dispose&type=buybacked&order_ids=<?php echo $order['order_id']; ?>">返销</a>
+                        |
+                        <a href="#" data-order_id="<?php echo $order['order_id']; ?>" id="manual_recharged">已手动补充</a>
+                    </td>
+                    <td class="align-center">
+                        <a href="index.php?act=refill_order_manual&op=transfer_order_dispose&type=canceled_order_retry&order_ids=<?php echo $order['order_id']; ?>">
                             补充</a>
                         |
-                        <a href="index.php?act=refill_order_manual&op=transfer_order_dispose&type=canceled_order_retry_next&order_ids=<?php echo $order['order_id']; ?>" id="hdFail">
+                        <a href="index.php?act=refill_order_manual&op=transfer_order_dispose&type=canceled_order_retry_next&order_ids=<?php echo $order['order_id']; ?>">
                             补快充</a>
                     </td>
                 </tr>
@@ -250,10 +264,10 @@
 <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() {
-        $('#hCopyCardNo').click(function() {
+        function copy_some(col) {
             let str = ''
             $('#tbody tr').each(function () {
-                let res = $(this).find('td').eq(5).text()
+                let res = $(this).find('td').eq(col).text()
                 str += res + '\n'
             })
             let oInput = document.createElement("textarea");
@@ -264,25 +278,17 @@
             oInput.select(); // 选择对象
             document.execCommand("Copy"); // 执行浏览器复制命令
             oInput.parentNode.removeChild(oInput)
+        }
+
+        $('#hCopyCardNo').click(function () {
+            copy_some(5)
         });
 
-        $('#hCopyMchOrderNo').click(function() {
-            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)
+        $('#hCopyMchOrderNo').click(function () {
+            copy_some(4)
         });
 
-        $('#ncsubmit').click(function() {
+        $('#ncsubmit').click(function () {
             $('#formSearch').submit();
         });
         $('#query_start_time').datepicker({
@@ -303,80 +309,114 @@
         });
 
         //全选
-        $('#selectAll').click(function() {
+        $('#selectAll').click(function () {
             if ($("input[name='chbox']").is(':checked')) {
-                $("input[name='checkbox']").each(function() {
+                $("input[name='checkbox']").each(function () {
                     this.checked = true;
                 })
             } else {
-                $("input[name='checkbox']").each(function() {
+                $("input[name='checkbox']").each(function () {
                     this.checked = false;
                 })
             }
         })
 
         //过滤
-        $("#mch_orders").blur(function() {
+        $("#mch_orders").blur(function () {
             let test_mch = $("#mch_orders").val();
             let result = test_mch.replace(/[\  \r\n\,]+/g, ",");
             $(this).val(result)
         })
 
         //过滤
-        $("#card_nos").blur(function() {
+        $("#card_nos").blur(function () {
             let test_mch = $("#card_nos").val();
             let result = test_mch.replace(/[\  \r\n\,]+/g, ",");
             $(this).val(result)
         })
 
+        $('#manual_recharged').on('click', function() {
+            let order_id = $(this).attr('data-order_id');
+            layui.use(['layer'], function() {
+                const manual_amountHTML = '<label class="createTaskDate"><span>手动补充金额:</span><input type="text" class="layui-input" id="manual_amount"></label>'
+                layer.confirm(manual_amountHTML, {
+                    title: '输入手动补充金额'
+                }, function(index) {
+                    console.log('确认')
+                    let manual_recharge_amount = $('#manual_amount').val();
+                    if (!manual_recharge_amount) {
+                        layer.msg('请输入手动补充金额');
+                        return;
+                    }
+                    console.log(manual_recharge_amount)
+                    console.log(order_id)
+                    index = layer.load();
+                    window.location.href = `index.php?act=refill_order_manual&op=transfer_order_dispose&type=manual_recharged&order_ids=${order_id}&manual_recharge_amount=${manual_recharge_amount}`
+                    layer.close(index);
+                }, function() {
+                    console.log('取消')
+                });
+            })
+        })
+
         //批量
-        $('#canceled_order_retry').click(function() {
+        $('#canceled_order_retry').click(function () {
             layer.confirm('您确定要批量补充吗', {
                 btn: ['确定', '取消'],
                 title: '批量补充'
-            }, function() {
-                let arr = [];
-                $("input:checkbox:checked").each(function(i) {
-                    arr[i] = $(this).val();
-                })
-                let str = arr.join(",");
-                let strr = str.substring(0, 1);
-                let number = Number(strr);
-                if (isNaN(number)) {
-                    let strrr = str.substring(1, str.length);
-                    window.location.href = `index.php?act=refill_order_manual&op=transfer_order_dispose&type=canceled_order_retry&order_ids= ${strrr ? strrr : ''}`
-                } else if (!isNaN(number) && str !== '') {
-                    window.location.href = `index.php?act=refill_order_manual&op=transfer_order_dispose&type=canceled_order_retry&order_ids= ${str ? str : ''}`
+            }, function () {
+                let order_ids = formatParams();
+                console.log(order_ids);
+                if (order_ids !== '') {
+                    window.location.href = `index.php?act=refill_order_manual&op=transfer_order_dispose&type=canceled_order_retry&order_ids= ${order_ids}`
                 } else {
-                    layer.msg('请还没有任何操作,请先选择');
+                    layer.msg('还没有任何操作,请先选择');
                 }
-            }, function() {});
+            }, function () {
+            });
         })
 
         //批量
-        $('#canceled_order_retry_next').click(function() {
+        $('#canceled_order_retry_next').click(function () {
             layer.confirm('您确定要批量补快充吗', {
                 btn: ['确定', '取消'],
                 title: '批量补快充'
-            }, function() {
-                let arr = [];
-                $("input:checkbox:checked").each(function(i) {
-                    arr[i] = $(this).val();
-                })
-                let str = arr.join(",");
-                let strr = str.substring(0, 1);
-                let number = Number(strr);
-                if (isNaN(number)) {
-                    let strrr = str.substring(1, str.length);
-                    window.location.href = `index.php?act=refill_order_manual&op=transfer_order_dispose&type=canceled_order_retry_next&order_ids= ${strrr ? strrr : ''}`
-                } else if (!isNaN(number) && str !== '') {
-                    window.location.href = `index.php?act=refill_order_manual&op=transfer_order_dispose&type=canceled_order_retry_next&order_ids= ${str ? str : ''}`
+            }, function () {
+                let order_ids = formatParams();
+                if (order_ids !== '') {
+                    window.location.href = `index.php?act=refill_order_manual&op=transfer_order_dispose&type=canceled_order_retry_next&order_ids= ${order_ids}`
+                } else {
+                    layer.msg('还没有任何操作,请先选择');
+                }
+            }, function () {
+            });
+        })
+
+        //批量
+        $('#buybacked').click(function () {
+            layer.confirm('您确定要批量返销处理吗', {
+                btn: ['确定', '取消'],
+                title: '批量补快充'
+            }, function () {
+                let order_ids = formatParams();
+                if (order_ids !== '') {
+                    window.location.href = `index.php?act=refill_order_manual&op=transfer_order_dispose&type=buybacked&order_ids= ${order_ids}`
                 } else {
                     layer.msg('请还没有任何操作,请先选择');
                 }
-            }, function() {});
+            }, function () {
+            });
         })
 
+        function formatParams()
+        {
+            let arr = [];
+            $("input[name='checkbox']:checked").each(function (i) {
+                arr[i] = $(this).val();
+            })
+            return arr.join(",");
+        }
+
         //双击
         $('.doubleclick').dblclick(function() {
             let order_sn = $(this).attr('data-order')

+ 60 - 0
crontab/control/vendor.php

@@ -0,0 +1,60 @@
+<?php
+
+defined('InShopNC') or exit('Access Invalid!');
+
+require_once (BASE_ROOT_PATH . '/helper/message/publisher.php');
+require_once(BASE_HELPER_PATH . '/refill/util.php');
+require_once(BASE_HELPER_PATH . '/refill/divert_account.php');
+require_once(BASE_HELPER_PATH . '/refill/RefillFactory.php');
+require_once(BASE_CORE_PATH . '/framework/function/http.php');
+require_once(BASE_HELPER_PATH . '/PHPExcel/PHPExcel.php');
+
+
+class vendorControl
+{
+    public function __construct(){
+        Log::short_name('vendor');
+    }
+
+    //中石化电子券token获取
+    public function token_refreshOp()
+    {
+        Log::record(__METHOD__,Log::DEBUG);
+        require_once(BASE_HELPER_RAPI_PATH . "/gdsinopec/config.php");
+
+        $worker = function (&$period) : bool
+        {
+            $token_req = new refill\gdsinopec\config();
+            [$state, $result] = $token_req->get_access_token();
+            if ($state === false) {
+                Log::record("get token fail msg:$result", Log::ERR);
+                return false;
+            } else {
+                $period = $result;
+                return true;
+            }
+        };
+
+        $next_time = 0;
+        $period = 7000;
+
+        while (true)
+        {
+            try
+            {
+                if($next_time > time()) {
+                    sleep(1);
+                }
+                elseif($worker($period)) {
+                    $next_time = time() + $period;
+                }
+                else {
+                    Log::record("token_refresh",Log::ERR);
+                }
+            }
+            catch (Exception $ex) {
+                Log::record($ex->getMessage(),Log::ERR);
+            }
+        }
+    }
+}

+ 13 - 0
docker/compose/stanley/vendor/docker-compose.yml

@@ -0,0 +1,13 @@
+version: "3.7"
+
+services:
+  token_refresh:
+    image: php-zts-debug:7.3.18
+    volumes:
+      - ../../../../:/var/www/html
+      - ../conf/etc/localtime:/etc/localtime:ro
+      - ../conf/php/php-debug.ini:/usr/local/etc/php/php.ini
+      - /Volumes/Transcend/upload:/var/www/html/data/upload
+      - /Users/stanley-king/work/PHPProject/shoplog:/var/www/html/data/log
+    container_name: "panda-token-refresh"
+    command: [php,"/var/www/html/crontab/index.php",'vendor','token_refresh']

+ 17 - 0
docker/compose/xyz/yzvendor/docker-compose.yml

@@ -0,0 +1,17 @@
+version: "3.7"
+
+services:
+  token_refresh:
+    image: php-swool-redis:latest
+    volumes:
+      - ../../../../:/var/www/html
+      - ../conf/etc/localtime:/etc/localtime:ro
+      - ../conf/php/php-swoole.ini:/usr/local/etc/php/php.ini
+      - /nfs/upload:/var/www/html/data/upload
+      - /mnt/shoplog:/var/www/html/data/log
+    container_name: "panda-token-refresh"
+    command: [php,"/var/www/html/crontab/index.php",'vendor','token_refresh']
+    deploy:
+      resources:
+        limits:
+          cpus: '8'

+ 40 - 29
helper/refill/api/xyz/gdsinopec/RefillOil.php

@@ -9,34 +9,11 @@ use Log;
 
 class RefillOil extends refill\IRefillOil
 {
-    private $access_token = '039957e4b8224ecba34def77cefde8f7';
-
     public function __construct($cfgs)
     {
         parent::__construct($cfgs);
     }
 
-    public function get_access_token()
-    {
-        $params['appid'] = config::APP_ID;
-        $params['secret'] = config::APP_SECRET;
-
-        $resp = http_request(config::TOKEN_URL, $params, 'GET', false, config::ExtHeaders, $net_errno);
-        if (empty($resp)) {
-            return [false, '网络错误'];
-        } else {
-            Log::record($resp, Log::DEBUG);
-            $resp = json_decode($resp, true);
-            if (empty($resp)) {
-                return [false, '网络错误'];
-            } elseif ($resp['state'] === 'ok') {
-                return [true, $resp['data']['access_token']];
-            } else {
-                return [false, $resp['info']];
-            }
-        }
-    }
-
     public function get_supplier($access_token)
     {
         $params['access_token'] = $access_token;
@@ -59,7 +36,12 @@ class RefillOil extends refill\IRefillOil
 
     public function find_list($supplier_origin)
     {
-        $params['access_token'] = $this->access_token;
+        $access_token = config::token();
+        if($access_token === false) {
+            return [false, 'token获取失败'];
+        }
+
+        $params['access_token'] = $access_token;
         $params['page_number'] = 1;
         $params['page_size'] = config::PAGE_SIZE;
         $params['supplier_origin'] = $supplier_origin;
@@ -94,7 +76,27 @@ class RefillOil extends refill\IRefillOil
 
     public function add($card_no, $card_type, $amount, $params,&$net_errno = 0)
     {
-        $access_token = $this->access_token;
+        $tokener = function ()
+        {
+            $times = 10;
+            do
+            {
+                $token = config::token();
+                if($token === false) {
+                    Swoole\Coroutine::sleep(10);
+                } else {
+                    return $token;
+                }
+            } while($times-- > 0);
+
+            return false;
+        };
+
+        $access_token = $tokener();
+        if($access_token === false) {
+            return [false, 'token获取失败', false];
+        }
+
         $order_sn = $params['order_sn'];
         $supplier_origin = $params['supplier_origin'];
         $product_id = $params['product_id'];
@@ -123,9 +125,13 @@ class RefillOil extends refill\IRefillOil
 
     public function query($refill_info)
     {
-        $params['access_token'] = $this->access_token;
-        $params['customer_order_id'] = $refill_info['order_sn'];
+        $access_token = config::token();
+        if($access_token === false) {
+            return [false, 'token获取失败'];
+        }
 
+        $params['access_token'] = $access_token;
+        $params['customer_order_id'] = $refill_info['order_sn'];
         $resp = http_request(config::QUERY_URL, $params, 'POST', false, config::ExtHeaders);
 
         if (empty($resp)) {
@@ -151,12 +157,17 @@ class RefillOil extends refill\IRefillOil
                 } else {
                     return [false, $status];
                 }
+
                 return [true, $order_state];
             }
-            else
-            {
+            else {
                 return [false, $resp['info']];
             }
         }
     }
+
+    public function callback()
+    {
+        return false;
+    }
 }

+ 48 - 0
helper/refill/api/xyz/gdsinopec/config.php

@@ -2,6 +2,8 @@
 
 namespace refill\gdsinopec;
 
+use Log;
+
 class config
 {
     const TOKEN_URL = 'http://dev.tetong.9aijoy.com/open/api/token'; //获取AccessToken
@@ -15,4 +17,50 @@ class config
     const NOTIFY_URL = BASE_SITE_URL . "/mobile/callback/refill_sinopec.php";
     const ExtHeaders = ['Content-Type:application/x-www-form-urlencoded;charset=utf-8'];
     const PAGE_SIZE = 200;
+
+
+    public function get_access_token()
+    {
+        $params['appid'] = config::APP_ID;
+        $params['secret'] = config::APP_SECRET;
+
+        $resp = http_request(config::TOKEN_URL, $params, 'GET', false, config::ExtHeaders, $net_errno);
+        if (empty($resp)) {
+            return [false, '网络错误'];
+        }
+        else
+        {
+            Log::record($resp, Log::DEBUG);
+            $resp = json_decode($resp, true);
+            if (empty($resp)) {
+                return [false, '网络错误'];
+            } elseif ($resp['state'] === 'ok') {
+                $result = $resp['data'];
+                $access_token = $result['access_token'];
+                $expires_in = intval($result['expires_in']);
+                wcache('vendor-cfgs', ['gdsinopec-token' => $access_token,'gdsinopec-time' => time() + $expires_in],'refill-');
+
+                return [true, $expires_in];
+            } else {
+                return [false, $resp['info']];
+            }
+        }
+    }
+
+    public static function token()
+    {
+        $result = rcache('vendor-cfgs','refill-','gdsinopec-token,gdsinopec-time');
+        if(empty($result)) {
+            return false;
+        }
+
+        $expires_time = $result['gdsinopec-time'];
+        $token = $result['gdsinopec-token'];
+
+        if ($expires_time > $token) {
+            return $token;
+        } else {
+            return false;
+        }
+    }
 }

+ 9 - 0
test/TestRefillStats.php

@@ -12,6 +12,8 @@ require_once(BASE_ROOT_PATH . '/fooder.php');
 
 require_once(BASE_HELPER_PATH . '/stat_helper.php');
 
+use refill\gdsinopec;
+
 class TestRefillStats extends TestCase
 {
     public static function setUpBeforeClass(): void
@@ -42,6 +44,13 @@ class TestRefillStats extends TestCase
             $refill->provider_stat($time_stamp, $cid, $order_time_type);
         }
     }
+
+    public function  testToken()
+    {
+        require_once(BASE_HELPER_RAPI_PATH . "/gdsinopec/config.php");
+        $token_req = refill\gdsinopec\config::token();
+
+    }
 }
 
 //docker-compose run phpcli php /var/www/html/phpunit-9.2.5.phar --filter "/(TestRefillStats::testLatestDay)( .*)?$/" --test-suffix TestRefillStats.php /var/www/html/test