stanley-king 3 år sedan
förälder
incheckning
edf851d5ad
44 ändrade filer med 2073 tillägg och 1025 borttagningar
  1. 92 0
      admin/control/orderstats.php
  2. 1 4
      admin/templates/default/layout/index_layout.php
  3. 460 260
      admin/templates/default/merchant.refill.balance.php
  4. 7 7
      admin/templates/default/provider.index.php
  5. 81 12
      admin/templates/default/provider.price.set.php
  6. 455 256
      admin/templates/default/provider.refill.balance.php
  7. 33 15
      admin/templates/default/refill.order.index.php
  8. 14 5
      admin/templates/default/system.order.stats.php
  9. 492 209
      admin/templates/default/system.refill.balance.php
  10. 2 1
      data/config/xyz/base.ini.php
  11. 8 8
      data/config/xyz/refill.ini.php
  12. 2 1
      data/config/yl/base.ini.php
  13. 9 9
      data/config/yl/refill.ini.php
  14. 9 0
      data/model/refill_balance.model.php
  15. BIN
      favicon.ico
  16. BIN
      helper/refill/api/xyz/guochuang/20220425黑龙江移动调价函.jpg
  17. 1 1
      helper/refill/api/xyz/guochuang/config.php
  18. 33 17
      helper/refill/api/xyz/yunchonggong_yd/RefillCallBack.php
  19. 70 55
      helper/refill/api/xyz/yunchonggong_yd/RefillPhone.php
  20. 0 12
      helper/refill/api/xyz/yunchonggong_yd/api.txt
  21. 20 14
      helper/refill/api/xyz/yunchonggong_yd/config.php
  22. 24 0
      helper/refill/api/xyz/yunchonggong_yd/开户信息.txt
  23. 1 1
      helper/refill/api/yl/guochuang/config.php
  24. 33 17
      helper/refill/api/yl/yunchonggong_yd/RefillCallBack.php
  25. 70 55
      helper/refill/api/yl/yunchonggong_yd/RefillPhone.php
  26. 0 12
      helper/refill/api/yl/yunchonggong_yd/api.txt
  27. 20 14
      helper/refill/api/yl/yunchonggong_yd/config.php
  28. 24 0
      helper/refill/api/yl/yunchonggong_yd/开户信息.txt
  29. 40 22
      helper/statistics/refill_balance.php
  30. 7 2
      helper/statistics/stat_refill.php
  31. 57 0
      helper/task/handler.php
  32. 2 5
      test/TestRefill.php
  33. 6 0
      test/TestRefillYl.php
  34. 0 1
      vendor/ezyang/htmlpurifier
  35. 0 1
      vendor/maennchen/zipstream-php
  36. 0 1
      vendor/markbaker/complex
  37. 0 1
      vendor/markbaker/matrix
  38. 0 1
      vendor/myclabs/php-enum
  39. 0 1
      vendor/phpoffice/phpspreadsheet
  40. 0 1
      vendor/psr/http-client
  41. 0 1
      vendor/psr/http-factory
  42. 0 1
      vendor/psr/http-message
  43. 0 1
      vendor/psr/simple-cache
  44. 0 1
      vendor/symfony/polyfill-mbstring

+ 92 - 0
admin/control/orderstats.php

@@ -172,4 +172,96 @@ class orderstatsControl extends SystemControl
         Tpl::output('show_page', $mod->showpage());
         Tpl::showpage($page);
     }
+
+    public function refill_balance_stat_allOp()
+    {
+        $end_unixtime = intval(strtotime($_GET['selectEndDate']));
+        if(empty($end_unixtime)) {
+            exit(json_encode(['code' => false, 'msg' => '结束日期不能为空!']));
+        }
+
+        $condition = ['end' => $end_unixtime];
+
+        $manager = new task\manager();
+        $task = $manager->add_task('refill_balance_stat_all',$condition,0);
+        if ($task->completed() && $task->success()) {
+            exit(json_encode(['code' => true, 'msg' => '操作成功,此记录已新建成功。']));
+        } else {
+            exit(json_encode(['code' => true, 'msg' => '操作成功,后台任务已开始新建,请稍后查看新数据']));
+        }
+    }
+
+    public function refill_balance_createOp()
+    {
+        $balance_id = $_GET['balance_id'];
+        $mod = Model('refill_balance');
+        $balance = $mod->getBalance(['balance_id' => $balance_id]);
+        if(empty($balance )) {
+            exit(json_encode(['code' => false, 'msg' => '记录不存在!']));
+        }
+
+        $start_unixtime = intval(strtotime($_GET['selectStartDate']));
+        $end_unixtime = intval(strtotime($_GET['selectEndDate']));
+        if(empty($start_unixtime)) {
+            $start_unixtime = $balance['end_stamp'];
+        }
+        if(empty($end_unixtime)) {
+            exit(json_encode(['code' => false, 'msg' => '结束日期不能为空!']));
+        }
+
+        $condition = [
+            'type' => $balance['type'], 'cid' => $balance['cid'], 'start' => $start_unixtime,
+            'end'  => $end_unixtime, 'time_type' => $balance['time_type'], 'parent_id' => $balance_id
+        ];
+
+        $manager = new task\manager();
+        $task = $manager->add_task('refill_balance_create',$condition,0);
+        if ($task->completed() && $task->success()) {
+            exit(json_encode(['code' => true, 'msg' => '操作成功,此记录已新建成功。']));
+        } else {
+            exit(json_encode(['code' => true, 'msg' => '操作成功,后台任务已开始新建,请稍后查看新数据']));
+        }
+    }
+
+    public function refill_balance_rebuildOp()
+    {
+        $balance_id = $_GET['balance_id'];
+        $mod = Model('refill_balance');
+        $balance = $mod->getBalance(['balance_id' => $balance_id]);
+        if(empty($balance )) {
+            showMessage('记录不存在!');
+        }
+
+        $condition['balance_id'] = $balance_id;
+
+        $manager = new task\manager();
+        $task = $manager->add_task('refill_balance_rebuild',$condition,0);
+        if ($task->completed() && $task->success()) {
+            showMessage('操作成功,此记录已重新生成!');
+        } else {
+            showMessage('操作成功,后台任务已开始重新生成,请稍后查看新数据!');
+        }
+    }
+
+    public function refill_balance_saveOp()
+    {
+        showMessage('操作成功!');
+    }
+
+    public function refill_balance_confirmOp()
+    {
+        $balance_id = $_GET['balance_id'];
+        $mod = Model('refill_balance');
+        $balance = $mod->getBalance(['balance_id' => $balance_id]);
+        if(empty($balance )) {
+            showMessage('记录不存在!');
+        }
+
+        $ret = $mod->BalanceConfirm($balance_id);
+        if ($ret) {
+            showMessage('操作成功!');
+        } else {
+            showMessage('操作失败!');
+        }
+    }
 }

+ 1 - 4
admin/templates/default/layout/index_layout.php

@@ -204,10 +204,7 @@
 
 			// 主题设置
 
-			$.cookie("MyCssSkin", 'skin_0'); // 默认主题
-
-			// $.cookie("MyCssSkin", 'skin_1'); //黑色主题
-
+			$.cookie("MyCssSkin", "<?php global $config; echo $config['admin_layout_skin']; ?>"); // 默认主题
 
 			var $li = $("#skin li");
 			$li.click(function() {

+ 460 - 260
admin/templates/default/merchant.refill.balance.php

@@ -1,27 +1,66 @@
 <?php defined('InShopNC') or exit('Access Invalid!'); ?>
 <style>
     .page .fixed-bar .item-title h3 {
-        margin-top:18px !important;
-        margin-bottom:10px !important;
-        font-weight:700 !important;
+        margin-top: 18px !important;
+        margin-bottom: 10px !important;
+        font-weight: 700 !important;
     }
+
     .tab-base li span {
-        font-size:12px !important;
+        font-size: 12px !important;
     }
+
     .layui-form-select .layui-input {
-        height:26px;
+        height: 26px;
     }
-    input::placeholder{ 
-        color:#333; 
+
+    input::placeholder {
+        color: #333;
     }
+
     .row_q ul li {
         height: 30px;
         line-height: 30px;
     }
+
     .row_w {
         float: left;
         margin-right: 40px;
     }
+
+    #createDate,
+    #createItemStartDate,
+    #createItemEndDate {
+        height: 30px;
+    }
+
+    .createTaskDate {
+        display: flex;
+        align-items: center;
+        margin-bottom: 10px;
+    }
+
+    .createTaskDate span {
+        white-space: nowrap;
+        margin-right: 10px;
+    }
+
+    .table {
+        width: 2500px;
+        table-layout: fixed;
+    }
+
+    .table td:last-child,
+    .table th:last-child {
+        position: sticky;
+        right: 0;
+        background: #fff;
+        box-shadow: -2px 0 2px #cbe9f3;
+        width: 130px;
+        height: 30px;
+        line-height: 30px;
+        display: inline-block;
+    }
 </style>
 <div class="page">
     <div class="fixed-bar">
@@ -42,182 +81,318 @@
         <input type="hidden" value="OrderStats" name="act">
         <input type="hidden" value="refill_balance" name="op">
         <input type="hidden" value="merchant" name="type">
-        <input type="hidden" name="cid" value=""/>
-        <input type="hidden" name="default_no_mch" value="<?php echo $_GET['cid']; ?>"/>
-        
+        <input type="hidden" name="cid" value="" />
+        <input type="hidden" name="default_no_mch" value="<?php echo $_GET['cid']; ?>" />
+
         <table class="tb-type1 noborder search">
             <tbody>
-            <tr>
-                <th><label for="query_start_time">统计时间</label></th>
-                <td>
-                    <input class="txt date" type="text" value="<?php echo $_GET['query_start_time']; ?>"
-                           id="startTime" name="query_start_time" autocomplete="off" style="width:120px" />
-                    <label for="query_start_time">~</label>
-                    <input class="txt date" type="text" value="<?php echo $_GET['query_end_time']; ?>"
-                           id="endTime" name="query_end_time" autocomplete="off" style="width:120px" />
-                </td>
-                <th><label>统计日期类型</label></th>
-                <td>
-                    <select name="order_time_type" id="order_time_type">
-                        <option value="">请选择...</option>
-                        <option value="notify_time" <?php if($_GET['order_time_type'] == 'notify_time'){ echo 'selected';}?>>回调日期</option>
-                        <option value="order_time" <?php if($_GET['order_time_type'] == 'order_time'){ echo 'selected';}?>>下单日期</option>
-                    </select>
-                </td>
-                <th><label>商户名称</label></th>
-                <td>
-                    <!-- <select name="cid" id="cid" class="querySelect" lay-verify="" lay-search>
+                <tr>
+                    <th><label for="query_start_time">统计时间</label></th>
+                    <td>
+                        <input class="txt date" type="text" value="<?php echo $_GET['query_start_time']; ?>" id="startTime" name="query_start_time" autocomplete="off" style="width:120px" />
+                        <label for="query_start_time">~</label>
+                        <input class="txt date" type="text" value="<?php echo $_GET['query_end_time']; ?>" id="endTime" name="query_end_time" autocomplete="off" style="width:120px" />
+                    </td>
+                    <th><label>统计日期类型</label></th>
+                    <td>
+                        <select name="order_time_type" id="order_time_type">
+                            <option value="">请选择...</option>
+                            <option value="notify_time" <?php if ($_GET['order_time_type'] == 'notify_time') {
+                                                            echo 'selected';
+                                                        } ?>>回调日期</option>
+                            <option value="order_time" <?php if ($_GET['order_time_type'] == 'order_time') {
+                                                            echo 'selected';
+                                                        } ?>>下单日期</option>
+                        </select>
+                    </td>
+                    <th><label>商户名称</label></th>
+                    <td>
+                        <!-- <select name="cid" id="cid" class="querySelect" lay-verify="" lay-search>
                         <option value=""><?php echo $lang['nc_please_choose']; ?></option>
-                        <?php foreach($output['merchant_list'] as $merchant){?>
-                            <option value="<?php echo $merchant['mchid']?>"
-                                    <?php if ($_GET['cid'] == $merchant['mchid']){ ?>selected<?php } ?>><?php echo $merchant['company_name'] == '' ? $merchant['name'] : $merchant['company_name'];?>
+                        <?php foreach ($output['merchant_list'] as $merchant) { ?>
+                            <option value="<?php echo $merchant['mchid'] ?>"
+                                    <?php if ($_GET['cid'] == $merchant['mchid']) { ?>selected<?php } ?>><?php echo $merchant['company_name'] == '' ? $merchant['name'] : $merchant['company_name']; ?>
                             </option>
-                        <?php }?>
+                        <?php } ?>
                     </select> -->
-                    <div id="selest_nc"></div>
-                </td>
-                <td><a href="javascript:void(0);" id="ncsubmit" class="btn-search "
-                       title="<?php echo $lang['nc_query']; ?>">&nbsp;</a>
-                    <?php if ($output['mch_name'] != '') { ?>
-                        <a href="index.php?act=OrderStats&op=index" class="btns "
-                           title="<?php echo $lang['nc_cancel_search']; ?>"><span><?php echo $lang['nc_cancel_search']; ?></span></a>
-                    <?php } ?></td>
-<!--                <td>-->
-<!--                    <a href="javascript:void(0);" id="ncexport" class="btn">-->
-<!--                        <span>导出</span>-->
-<!--                    </a>-->
-<!--                </td>-->
-            </tr>
+                        <div id="selest_nc"></div>
+                    </td>
+                    <td><a href="javascript:void(0);" id="ncsubmit" class="btn-search " title="<?php echo $lang['nc_query']; ?>">&nbsp;</a>
+                        <?php if ($output['mch_name'] != '') { ?>
+                            <a href="index.php?act=OrderStats&op=index" class="btns " title="<?php echo $lang['nc_cancel_search']; ?>"><span><?php echo $lang['nc_cancel_search']; ?></span></a>
+                        <?php } ?>
+                    </td>
+                    <!-- <td>
+                        <a href="javascript:void(0);" id="create" class="btn">
+                            <span>新建</span>
+                        </a>
+                    </td> -->
+                </tr>
             </tbody>
         </table>
     </form>
-<!--    <table class="table tb-type2" id="prompt">-->
-<!--        <tbody>-->
-<!--        <tr class="space odd">-->
-<!--            <th colspan="12"><div class="title">-->
-<!--                    <h5>总量统计</h5>-->
-<!--                    <span class="arrow"></span></div></th>-->
-<!--        </tr>-->
-<!--        <tr>-->
-<!--            <td class="row_q">-->
-<!--                <ul class="row_w">-->
-<!--                    <li>回调日期统计</li>-->
-<!--                    <li class="lineLi" style="color:#000;">总计成功订单量: --><?php //echo $output['total_stats']['notify_time']['success_count_total'] ?? 0?><!--</li>-->
-<!--                    <li class="lineLi" style="color:#000;">总计充值中订单量: --><?php //echo $output['total_stats']['notify_time']['send_count_total'] ?? 0?><!--</li>-->
-<!--                    <li class="lineLi" style="color:#000;">总计成功订单金额:--><?php //echo $output['total_stats']['notify_time']['success_refill_amounts_total'] ?? 0?><!--</li>-->
-<!--                    <li class="lineLi" style="color:#000;">总计下游扣款金额:--><?php //echo $output['total_stats']['notify_time']['success_mch_amounts_toatl'] ?? 0?><!--</li>-->
-<!--                    <li class="lineLi" style="color:#000;">总计上游扣款金额:--><?php //echo $output['total_stats']['notify_time']['success_channel_amounts_total'] ?? 0?><!--</li>-->
-<!--                </ul>-->
-<!--                <ul>-->
-<!--                    <li>下单日期统计</li>-->
-<!--                    <li class="lineLi" style="color:#000;">总计成功订单量: --><?php //echo $output['total_stats']['order_time']['success_count_total'] ?? 0?><!--</li>-->
-<!--                    <li class="lineLi" style="color:#000;">总计充值中订单量: --><?php //echo $output['total_stats']['order_time']['send_count_total'] ?? 0?><!--</li>-->
-<!--                    <li class="lineLi" style="color:#000;">总计成功订单金额:--><?php //echo $output['total_stats']['order_time']['success_refill_amounts_total'] ?? 0?><!--</li>-->
-<!--                    <li class="lineLi" style="color:#000;">总计下游扣款金额:--><?php //echo $output['total_stats']['order_time']['success_mch_amounts_toatl'] ?? 0?><!--</li>-->
-<!--                    <li class="lineLi" style="color:#000;">总计上游扣款金额:--><?php //echo $output['total_stats']['order_time']['success_channel_amounts_total'] ?? 0?><!--</li>-->
-<!--                </ul>-->
-<!--            </td>-->
-<!--        </tr>-->
-<!--        </tbody>-->
-<!--    </table>-->
+    <!--    <table class="table tb-type2" id="prompt">-->
+    <!--        <tbody>-->
+    <!--        <tr class="space odd">-->
+    <!--            <th colspan="12"><div class="title">-->
+    <!--                    <h5>总量统计</h5>-->
+    <!--                    <span class="arrow"></span></div></th>-->
+    <!--        </tr>-->
+    <!--        <tr>-->
+    <!--            <td class="row_q">-->
+    <!--                <ul class="row_w">-->
+    <!--                    <li>回调日期统计</li>-->
+    <!--                    <li class="lineLi" style="color:#000;">总计成功订单量: --><?php //echo $output['total_stats']['notify_time']['success_count_total'] ?? 0
+                                                                                ?>
+    <!--</li>-->
+    <!--                    <li class="lineLi" style="color:#000;">总计充值中订单量: --><?php //echo $output['total_stats']['notify_time']['send_count_total'] ?? 0
+                                                                                ?>
+    <!--</li>-->
+    <!--                    <li class="lineLi" style="color:#000;">总计成功订单金额:--><?php //echo $output['total_stats']['notify_time']['success_refill_amounts_total'] ?? 0
+                                                                                ?>
+    <!--</li>-->
+    <!--                    <li class="lineLi" style="color:#000;">总计下游扣款金额:--><?php //echo $output['total_stats']['notify_time']['success_mch_amounts_toatl'] ?? 0
+                                                                                ?>
+    <!--</li>-->
+    <!--                    <li class="lineLi" style="color:#000;">总计上游扣款金额:--><?php //echo $output['total_stats']['notify_time']['success_channel_amounts_total'] ?? 0
+                                                                                ?>
+    <!--</li>-->
+    <!--                </ul>-->
+    <!--                <ul>-->
+    <!--                    <li>下单日期统计</li>-->
+    <!--                    <li class="lineLi" style="color:#000;">总计成功订单量: --><?php //echo $output['total_stats']['order_time']['success_count_total'] ?? 0
+                                                                                ?>
+    <!--</li>-->
+    <!--                    <li class="lineLi" style="color:#000;">总计充值中订单量: --><?php //echo $output['total_stats']['order_time']['send_count_total'] ?? 0
+                                                                                ?>
+    <!--</li>-->
+    <!--                    <li class="lineLi" style="color:#000;">总计成功订单金额:--><?php //echo $output['total_stats']['order_time']['success_refill_amounts_total'] ?? 0
+                                                                                ?>
+    <!--</li>-->
+    <!--                    <li class="lineLi" style="color:#000;">总计下游扣款金额:--><?php //echo $output['total_stats']['order_time']['success_mch_amounts_toatl'] ?? 0
+                                                                                ?>
+    <!--</li>-->
+    <!--                    <li class="lineLi" style="color:#000;">总计上游扣款金额:--><?php //echo $output['total_stats']['order_time']['success_channel_amounts_total'] ?? 0
+                                                                                ?>
+    <!--</li>-->
+    <!--                </ul>-->
+    <!--            </td>-->
+    <!--        </tr>-->
+    <!--        </tbody>-->
+    <!--    </table>-->
     <form method="post" id="merchant_name_form">
-        <input type="hidden" name="form_submit" value="ok"/>
-        <table class="table tb-type2">
-            <thead>
-            <tr class="thead">
-                <th>记录ID</th>
-                <th>父ID</th>
-                <th>主体名称</th>
-                <th>主体ID</th>
-                <th class="align-left">统计开始日期</th>
-                <th class="align-left">统计结束日期</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>
-                <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-left">备注</th>
-<!--                <th class="align-center">操作</th>-->
-            </tr>
-            </thead>
-            <tbody>
-            <?php if (!empty($output['stats_list']) && is_array($output['stats_list'])) { ?>
-                <?php foreach ($output['stats_list'] as $k => $v) { ?>
-                    <tr class="trFlex">
-                        <td><?php echo $v['balance_id']; ?></td>
-                        <td><?php echo $v['parent_id']; ?></td>
-                        <td><?php echo $v['cname']; ?></td>
-                        <td><?php echo $v['cid']; ?></td>
-                        <td class="align-left"><?php echo $v['start_stamp'] ? date('Y-m-d H:i', $v['start_stamp']) : '/'; ?></td>
-                        <td class="align-left"><?php echo $v['end_text']; ?></td>
-                        <td class="align-center"><?php echo $v['success_count']; ?></td>
-                        <td class="align-center"><?php echo $v['refill_amount']; ?></td>
-                        <td class="align-center"><?php echo $v['mch_amount']; ?></td>
-                        <td class="align-center"><?php echo $v['channel_amount']; ?></td>
-                        <td class="align-center"><?php echo $v['profit_amount']; ?></td>
-                        <td class="align-center"><?php echo $v['transfer_in']; ?></td>
-                        <td class="align-center"><?php echo $v['transfer_out']; ?></td>
-                        <td class="align-center"><?php echo $v['refund_amount']; ?></td>
-                        <td class="align-center"><?php echo $v['except_amount']; ?></td>
-                        <td class="align-center"><?php echo $v['accumulate_balance']; ?></td>
-                        <td class="align-center"><?php echo $v['balance']; ?></td>
-                        <td class="align-left"><?php echo date("Y-m-d H:i:s", $v['update_time']); ?></td>
-                        <td class="align-center">
-                            <?php if($v['confirmed'] == 0){?>
-                                <span style="color: #fd9d0e">未确认</span>
-                            <?php }else{?>
-                                <span style="color: #0bb20c">已确认</span>
-                            <?php }?>
+        <input type="hidden" name="form_submit" value="ok" />
+        <div style="width:100%;overflow-x: auto;">
+            <table class="table tb-type2">
+                <thead>
+                    <tr class="thead">
+                        <th>记录ID</th>
+                        <th>父ID</th>
+                        <th>主体名称</th>
+                        <th>主体ID</th>
+                        <th class="align-left">统计开始日期</th>
+                        <th class="align-left">统计结束日期</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>
+                        <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-left">备注</th>
+                        <th class="align-center">操作</th>
+                        <!--                <th class="align-center">操作</th>-->
+                    </tr>
+                </thead>
+                <tbody>
+                    <?php if (!empty($output['stats_list']) && is_array($output['stats_list'])) { ?>
+                        <?php foreach ($output['stats_list'] as $k => $v) { ?>
+                            <tr class="trFlex">
+                                <td><?php echo $v['balance_id']; ?></td>
+                                <td><?php echo $v['parent_id']; ?></td>
+                                <td><?php echo $v['cname']; ?></td>
+                                <td><?php echo $v['cid']; ?></td>
+                                <td class="align-left"><?php echo $v['start_stamp'] ? date('Y-m-d H:i', $v['start_stamp']) : '/'; ?></td>
+                                <td class="align-left"><?php echo $v['end_text']; ?></td>
+                                <td class="align-center"><?php echo $v['success_count']; ?></td>
+                                <td class="align-center"><?php echo $v['refill_amount']; ?></td>
+                                <td class="align-center"><?php echo $v['mch_amount']; ?></td>
+                                <td class="align-center"><?php echo $v['channel_amount']; ?></td>
+                                <td class="align-center"><?php echo $v['profit_amount']; ?></td>
+                                <td class="align-center"><?php echo $v['transfer_in']; ?></td>
+                                <td class="align-center"><?php echo $v['transfer_out']; ?></td>
+                                <td class="align-center"><?php echo $v['refund_amount']; ?></td>
+                                <td class="align-center"><?php echo $v['except_amount']; ?></td>
+                                <td class="align-center"><?php echo $v['accumulate_balance']; ?></td>
+                                <td class="align-center"><?php echo $v['balance']; ?></td>
+                                <td class="align-left"><?php echo date("Y-m-d H:i:s", $v['update_time']); ?></td>
+                                <td class="align-center">
+                                    <?php if ($v['confirmed'] == 0) { ?>
+                                        <span style="color: #fd9d0e">未确认</span>
+                                    <?php } else { ?>
+                                        <span style="color: #0bb20c">已确认</span>
+                                    <?php } ?>
+                                </td>
+                                <td class="align-center"><?php echo $output['order_time_type_text'][$v['time_type']]; ?></td>
+                                <td class="align-left"><?php echo $v['remark']; ?></td>
+                                <td style="text-align: center;color:#0D93BF;">
+                                    <a href="javascript:void(0);" class="item_create_btn" style="color:#0D93BF;">新建</a>
+                                    <span> | </span>
+                                    <a href="javascript:void(0);" style="color:#0D93BF;">编辑</a>
+                                    <span>|</span>
+                                    <a style="margin:0 5px;color:#0D93BF;" href="index.php?act=orderstats&op=refill_balance_rebuild&balance_id=<?php echo $v['balance_id']; ?>" data-index="<?php echo $k ?>" class="rebuildBtn">重新生成</a>
+                                    <?php if ($v['confirmed'] == 0) { ?>
+                                        <span>|</span>
+                                        <a style="color:#0D93BF;" href="index.php?act=orderstats&op=refill_balance_confirm&balance_id=<?php echo $v['balance_id']; ?>" data-index="<?php echo $k ?>" class="checkBtn">确认</a>
+                                    <?php } ?>
+                                </td>
+                                <!--                        <td class="align-center w200">-->
+                                <!--                            <a href="index.php?act=merchant&op=OrderStatsReload&stat_id=--><?php //echo $v['stat_id'];
+                                                                                                                                ?>
+                                <!--">重新统计</a>-->
+                                <!--                            |<a href="index.php?act=merchant&op=OrderStatsCheck&stat_id=--><?php //echo $v['stat_id'] 
+                                                                                                                                ?>
+                                <!--">编辑</a>-->
+                                <!--                        </td>-->
+                            </tr>
+                        <?php } ?>
+                    <?php } else { ?>
+                        <tr class="no_data">
+                            <td colspan="19"><?php echo $lang['nc_no_record']; ?></td>
+                        </tr>
+                    <?php } ?>
+                </tbody>
+                <tfoot>
+                    <tr class="tfoot">
+                        <td></td>
+                        <td colspan="19">
+                            <div class="pagination"><?php echo $output['show_page']; ?></div>
                         </td>
-                        <td class="align-center"><?php echo $output['order_time_type_text'][$v['time_type']]; ?></td>
-                        <td class="align-left"><?php echo $v['remark']; ?></td>
-<!--                        <td class="align-center w200">-->
-<!--                            <a href="index.php?act=merchant&op=OrderStatsReload&stat_id=--><?php //echo $v['stat_id'];?><!--">重新统计</a>-->
-<!--                            |<a href="index.php?act=merchant&op=OrderStatsCheck&stat_id=--><?php //echo $v['stat_id'] ?><!--">编辑</a>-->
-<!--                        </td>-->
                     </tr>
-                <?php } ?>
-            <?php } else { ?>
-                <tr class="no_data">
-                    <td colspan="19"><?php echo $lang['nc_no_record']; ?></td>
-                </tr>
-            <?php } ?>
-            </tbody>
-            <tfoot>
-            <tr class="tfoot">
-                <td></td>
-                <td colspan="19">
-                    <div class="pagination"><?php echo $output['show_page']; ?></div>
-                </td>
-            </tr>
-            </tfoot>
-        </table>
+                </tfoot>
+            </table>
+        </div>
     </form>
 </div>
 <script type="text/javascript" src="<?php echo RESOURCE_SITE_URL; ?>/js/jquery.edit.js" charset="utf-8"></script>
 <script type="text/javascript" src="<?php echo RESOURCE_SITE_URL; ?>/laydate/laydate.js"></script>
-<script type="text/javascript" src="<?php echo ADMIN_TEMPLATES_URL;?>/js/xm-select.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"/>
+<script type="text/javascript" src="<?php echo ADMIN_TEMPLATES_URL; ?>/js/xm-select.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" />
 <script>
-    $(function () {
-        $('#ncsubmit').click(function () {
+    $(function() {
+        $('#create').on('click', function() {
+            var selectEndDate = '';
+            layui.use(['layer', 'laydate'], function() {
+                const selectDateHTML = '<label class="createTaskDate"><span>结束日期:</span><input type="text" class="layui-input" id="createDate"></label>'
+                layer.confirm(selectDateHTML, {
+                    title: '新建'
+                }, function(index) {
+                    console.log('确认')
+                    layer.close(index);
+                }, function() {
+                    console.log('取消')
+                });
+
+
+                laydate.render({
+                    elem: '#createDate',
+                    type: 'datetime',
+                    done: function(value) {
+                        console.log('选中的日期...', value)
+                        selectEndDate = value;
+                    }
+                });
+
+            })
+            // 
+        })
+
+
+        $('.item_create_btn').on('click', function() {
+            var selectStartDate = '';
+            var selectEndDate = '';
+            var balance_id = $(this).attr('data-balance_id');
+            layui.use(['layer', 'laydate'], function() {
+                const selectDateHTML = `<label class="createTaskDate"><span>开始日期:</span><input type="text" class="layui-input" id="createItemStartDate"></label>
+                                        <label class="createTaskDate"><span>结束日期:</span><input type="text" class="layui-input" id="createItemEndDate"></label>`
+                layer.confirm(selectDateHTML, {
+                    title: '新建'
+                }, function(index) {
+                    console.log('确认')
+                    if (!selectStartDate) {
+                        layer.msg('请选择开始日期');
+                        return;
+                    }
+                    if (!selectEndDate) {
+                        layer.msg('请选择结束日期');
+                        return;
+                    }
+                    console.log(balance_id, selectStartDate, selectEndDate)
+                    var index = layer.load();
+                    $.ajax({
+                        url: `index.php?act=orderstats&op=refill_balance_create`,
+                        data: {
+                            balance_id,
+                            selectStartDate,
+                            selectEndDate
+                        },
+                        dataType: 'json',
+                        mothod: 'get',
+                        success: function(res) {
+                            layer.close(index);
+                            console.log('success', res);
+                            if (res.code) {
+                                layer.msg(res.msg)
+                            } else {
+                                layer.alert(res.msg)
+                            }
+                        }
+                    })
+                    layer.close(index);
+                }, function() {
+                    console.log('取消')
+                });
+
+                laydate.render({
+                    elem: '#createItemStartDate',
+                    type: 'datetime',
+                    done: function(value) {
+                        console.log('选中的开始日期...', value)
+                        selectStartDate = value;
+                    }
+                });
+
+                laydate.render({
+                    elem: '#createItemEndDate',
+                    type: 'datetime',
+                    done: function(value) {
+                        console.log('选中的结束日期...', value)
+                        selectEndDate = value;
+                    }
+                });
+
+            })
+        })
+
+
+
+
+
+        $('#ncsubmit').click(function() {
             let selectArr = selest_nc.getValue();
             let selectStr = ''
             for (let i = 0; i < selectArr.length; i++) {
-                selectStr += selectArr[i].value+','
+                selectStr += selectArr[i].value + ','
             }
-            selectStr = selectStr.substr(0, selectStr.length-1)
+            selectStr = selectStr.substr(0, selectStr.length - 1)
             $('input[name="cid"]').val(selectStr);
             console.log("selectStr", selectStr);
             $('#formSearch').submit();
@@ -232,110 +407,111 @@
             type: 'datetime'
         });
         // 表格hover时背景
-        $('.trFlex').each(function () {
-            $(this).hover(function () {
+        $('.trFlex').each(function() {
+            $(this).hover(function() {
                 $(this)[0].style.backgroundColor = '#cbe9f3'
-            },function() {
+            }, function() {
                 $(this)[0].style.backgroundColor = '#fff'
             })
         })
-        function JSONToExcelConvertor(JSONData, FileName, ShowLabel, headData) { 
+
+        function JSONToExcelConvertor(JSONData, FileName, ShowLabel, headData) {
             //先转化json 
-            let arrData = typeof JSONData != 'object' ? JSON.parse(JSONData) : JSONData; 
-            let excel = '<table>';   
+            let arrData = typeof JSONData != 'object' ? JSON.parse(JSONData) : JSONData;
+            let excel = '<table>';
             // 标题
             for (const key in headData) {
                 var head = "<tr>";
-                var td = "<td colspan='12' style='font-size:16px;'>"+ headData[key] + '</td>';
+                var td = "<td colspan='12' style='font-size:16px;'>" + headData[key] + '</td>';
                 excel += td + "</tr>";
             }
             //设置表头 
-            var row = "<tr>"; 
-            for (var i = 0, l = ShowLabel.length; i < l; i++) { 
-                row += "<th style='font-size:14px;'>" + ShowLabel[i].value + '</th>'; 
-            } 
+            var row = "<tr>";
+            for (var i = 0, l = ShowLabel.length; i < l; i++) {
+                row += "<th style='font-size:14px;'>" + ShowLabel[i].value + '</th>';
+            }
             //换行 
-            excel += row + "</tr>"; 
+            excel += row + "</tr>";
             //设置数据 
-            for (var i = 0; i < arrData.length; i++) { 
-                var row = "<tr>"; 
-                let code = i+1
-                row += "<td>" +code+ "</td>"
-                row += '<td style=font-size:14px;'+ 'mso-number-format:"\@"'+ '>' + arrData[i].time_text + '</td>';
-                row += '<td style=font-size:14px;'+ 'mso-number-format:"\@"'+ '>' + arrData[i].cname + '</td>';
-                row += '<td style=font-size:14px;'+ 'mso-number-format:"\@"'+ '>' + arrData[i].cid + '</td>';
-                row += '<td style=font-size:14px;'+ 'mso-number-format:"\@"'+ '>' + arrData[i].success_count + '</td>';
-                row += '<td style=font-size:14px;'+ 'mso-number-format:"\@"'+ '>' + arrData[i].success_refill_amounts + '</td>';
-                row += '<td style=font-size:14px;'+ 'mso-number-format:"\@"'+ '>' + arrData[i].success_mch_amounts + '</td>';
-                row += '<td style=font-size:14px;'+ 'mso-number-format:"\@"'+ '>' + arrData[i].success_channel_amounts + '</td>';
-                row += '<td style=font-size:14px;'+ 'mso-number-format:"\@"'+ '>' + arrData[i].profit_amounts + '</td>';
-                row += '<td style=font-size:14px;'+ 'mso-number-format:"\@"'+ '>' + arrData[i].order_count + '</td>';
-                row += '<td style=font-size:14px;'+ 'mso-number-format:"\@"'+ '>' + arrData[i].cancel_count + '</td>';
-                row += '<td style=font-size:14px;'+ 'mso-number-format:"\@"'+ '>' + arrData[i].success_ratio + '</td>';
-                excel += row + "</tr>"; 
-            } 
-            excel += "</table>"; 
-                var excelFile = "<html xmlns:o='urn:schemas-microsoft-com:office:office' xmlns:x='urn:schemas-microsoft-com:office:excel' xmlns='http://www.w3.org/TR/REC-html40'>"; 
-                excelFile += '<meta http-equiv="content-type" content="application/vnd.ms-excel; charset=UTF-8">'; 
-                excelFile += '<meta http-equiv="content-type" content="application/vnd.ms-excel'; 
-                excelFile += '; charset=UTF-8">'; 
-                excelFile += "<head>"; 
-                excelFile += "<!--[if gte mso 9]>"; 
-                excelFile += "<xml>"; 
-                excelFile += "<x:ExcelWorkbook>"; 
-                excelFile += "<x:ExcelWorksheets>"; 
-                excelFile += "<x:ExcelWorksheet>"; 
-                excelFile += "<x:Name>"; 
-                excelFile += "{worksheet}"; 
-                excelFile += "</x:Name>"; 
-                excelFile += "<x:WorksheetOptions>"; 
-                excelFile += "<x:DisplayGridlines/>"; 
-                excelFile += "</x:WorksheetOptions>"; 
-                excelFile += "</x:ExcelWorksheet>"; 
-                excelFile += "</x:ExcelWorksheets>"; 
-                excelFile += "</x:ExcelWorkbook>"; 
-                excelFile += "</xml>"; 
-                excelFile += "<![endif]-->"; 
-                excelFile += "</head>"; 
-                excelFile += "<body>"; 
-                excelFile += excel; 
-                excelFile += "</body>"; 
-                excelFile += "</html>"; 
-                var uri = 'data:application/vnd.ms-excel;charset=utf-8,' + encodeURIComponent(excelFile); 
-                var link = document.createElement("a");   
-                link.href = uri; 
-                link.style = "visibility:hidden"; 
-                link.download = FileName + ".xls"; 
-                document.body.appendChild(link); 
-                link.click(); 
-                document.body.removeChild(link); 
+            for (var i = 0; i < arrData.length; i++) {
+                var row = "<tr>";
+                let code = i + 1
+                row += "<td>" + code + "</td>"
+                row += '<td style=font-size:14px;' + 'mso-number-format:"\@"' + '>' + arrData[i].time_text + '</td>';
+                row += '<td style=font-size:14px;' + 'mso-number-format:"\@"' + '>' + arrData[i].cname + '</td>';
+                row += '<td style=font-size:14px;' + 'mso-number-format:"\@"' + '>' + arrData[i].cid + '</td>';
+                row += '<td style=font-size:14px;' + 'mso-number-format:"\@"' + '>' + arrData[i].success_count + '</td>';
+                row += '<td style=font-size:14px;' + 'mso-number-format:"\@"' + '>' + arrData[i].success_refill_amounts + '</td>';
+                row += '<td style=font-size:14px;' + 'mso-number-format:"\@"' + '>' + arrData[i].success_mch_amounts + '</td>';
+                row += '<td style=font-size:14px;' + 'mso-number-format:"\@"' + '>' + arrData[i].success_channel_amounts + '</td>';
+                row += '<td style=font-size:14px;' + 'mso-number-format:"\@"' + '>' + arrData[i].profit_amounts + '</td>';
+                row += '<td style=font-size:14px;' + 'mso-number-format:"\@"' + '>' + arrData[i].order_count + '</td>';
+                row += '<td style=font-size:14px;' + 'mso-number-format:"\@"' + '>' + arrData[i].cancel_count + '</td>';
+                row += '<td style=font-size:14px;' + 'mso-number-format:"\@"' + '>' + arrData[i].success_ratio + '</td>';
+                excel += row + "</tr>";
+            }
+            excel += "</table>";
+            var excelFile = "<html xmlns:o='urn:schemas-microsoft-com:office:office' xmlns:x='urn:schemas-microsoft-com:office:excel' xmlns='http://www.w3.org/TR/REC-html40'>";
+            excelFile += '<meta http-equiv="content-type" content="application/vnd.ms-excel; charset=UTF-8">';
+            excelFile += '<meta http-equiv="content-type" content="application/vnd.ms-excel';
+            excelFile += '; charset=UTF-8">';
+            excelFile += "<head>";
+            excelFile += "<!--[if gte mso 9]>";
+            excelFile += "<xml>";
+            excelFile += "<x:ExcelWorkbook>";
+            excelFile += "<x:ExcelWorksheets>";
+            excelFile += "<x:ExcelWorksheet>";
+            excelFile += "<x:Name>";
+            excelFile += "{worksheet}";
+            excelFile += "</x:Name>";
+            excelFile += "<x:WorksheetOptions>";
+            excelFile += "<x:DisplayGridlines/>";
+            excelFile += "</x:WorksheetOptions>";
+            excelFile += "</x:ExcelWorksheet>";
+            excelFile += "</x:ExcelWorksheets>";
+            excelFile += "</x:ExcelWorkbook>";
+            excelFile += "</xml>";
+            excelFile += "<![endif]-->";
+            excelFile += "</head>";
+            excelFile += "<body>";
+            excelFile += excel;
+            excelFile += "</body>";
+            excelFile += "</html>";
+            var uri = 'data:application/vnd.ms-excel;charset=utf-8,' + encodeURIComponent(excelFile);
+            var link = document.createElement("a");
+            link.href = uri;
+            link.style = "visibility:hidden";
+            link.download = FileName + ".xls";
+            document.body.appendChild(link);
+            link.click();
+            document.body.removeChild(link);
         }
-        $('#ncexport').click(function () {
+        $('#ncexport').click(function() {
             let selectArr = selest_nc.getValue();
             let selectStr = ''
             for (let i = 0; i < selectArr.length; i++) {
-                selectStr += selectArr[i].value+','
+                selectStr += selectArr[i].value + ','
             }
-            selectStr = selectStr.substr(0, selectStr.length-1)
+            selectStr = selectStr.substr(0, selectStr.length - 1)
 
-            let starTime = new Date($('input[name="query_start_time"]').val()).getTime()/1000;
-            let endTime = new Date($('input[name="query_end_time"]').val()).getTime()/1000;
+            let starTime = new Date($('input[name="query_start_time"]').val()).getTime() / 1000;
+            let endTime = new Date($('input[name="query_end_time"]').val()).getTime() / 1000;
             let cid = selectStr
             let order_time_type = $('#order_time_type').val()
             $.get('index.php?act=orderstats&op=ExportData&type=merchant', {
                 query_start_time: starTime,
                 query_end_time: endTime,
                 cid: cid,
-                order_time_type:order_time_type
-            }, function (data) {
+                order_time_type: order_time_type
+            }, function(data) {
                 data = JSON.parse(data)
                 if (data && data.data) {
                     let head = ['北京椰子电子商务有限责任公司']
                     let time = ''
                     if (starTime && endTime) {
-                        time = '统计时间:'+$('input[name="query_start_time"]').val()+' - '+$('input[name="query_end_time"]').val()
+                        time = '统计时间:' + $('input[name="query_start_time"]').val() + ' - ' + $('input[name="query_end_time"]').val()
                     } else if (starTime) {
-                        time = '统计时间:'+$('input[name="query_start_time"]').val()
+                        time = '统计时间:' + $('input[name="query_start_time"]').val()
                     }
                     if (time) {
                         head.push(time)
@@ -345,37 +521,61 @@
                     head.push('总计下游扣款金额:' + parseFloat(data.total_stats.success_mch_amounts_toatl))
                     head.push('总计上游扣款金额:' + parseFloat(data.total_stats.success_channel_amounts_total))
                     head.push('总计利润金额:' + parseFloat(data.total_stats.profit_amounts_total))
-                    let title = [{value: "序号"},{value: "统计日期"},{value: "主体名称"},{value: "主体ID"},{value: "成功订单数"},{value: "成功金额"},{value: "下游金额"},{value: "上游金额"},{value: "利润"},{value: "订单总量"}, {value: "失败订单数量"},{value: "成功占比"}]
+                    let title = [{
+                        value: "序号"
+                    }, {
+                        value: "统计日期"
+                    }, {
+                        value: "主体名称"
+                    }, {
+                        value: "主体ID"
+                    }, {
+                        value: "成功订单数"
+                    }, {
+                        value: "成功金额"
+                    }, {
+                        value: "下游金额"
+                    }, {
+                        value: "上游金额"
+                    }, {
+                        value: "利润"
+                    }, {
+                        value: "订单总量"
+                    }, {
+                        value: "失败订单数量"
+                    }, {
+                        value: "成功占比"
+                    }]
                     JSONToExcelConvertor(data.data, '下游对账记录', title, head)
                 }
             })
         })
         //多选
-    let selest_nc
-    let default_no_mch = $('input[name="default_no_mch"]').val().split(',');
-    $.get('index.php?act=refill_order&op=merchant_data', function (data) {
-        data = JSON.parse(data)
-        if (default_no_mch) {
-            for (let index = 0; index < default_no_mch.length; index++) {
-                for (let j = 0; j < data.length; j++) {
-                    if (default_no_mch[index] == data[j].value) {
-                        data[j].selected = true
+        let selest_nc
+        let default_no_mch = $('input[name="default_no_mch"]').val().split(',');
+        $.get('index.php?act=refill_order&op=merchant_data', function(data) {
+            data = JSON.parse(data)
+            if (default_no_mch) {
+                for (let index = 0; index < default_no_mch.length; index++) {
+                    for (let j = 0; j < data.length; j++) {
+                        if (default_no_mch[index] == data[j].value) {
+                            data[j].selected = true
+                        }
                     }
                 }
             }
-        }
-        selest_nc = xmSelect.render({
-            el: '#selest_nc',
-            size: 'mini',
-            filterable: true,
-            style: {
-                minHeight: '27px',
-                lineHeight: '27px',
-                marginLeft: '4px',
-                width: '250px'
-            },
-            data: data
+            selest_nc = xmSelect.render({
+                el: '#selest_nc',
+                size: 'mini',
+                filterable: true,
+                style: {
+                    minHeight: '27px',
+                    lineHeight: '27px',
+                    marginLeft: '4px',
+                    width: '250px'
+                },
+                data: data
+            })
         })
-    })
     });
-</script>
+</script>

+ 7 - 7
admin/templates/default/provider.index.php

@@ -167,16 +167,16 @@
 
                             </td>
                             <td>
-                                <a href="index.php?act=provider&op=provider_price&provider_id=<?php echo $v['provider_id'] ?>">调价</a>
+                                <a style="color:#09C;" href="index.php?act=provider&op=provider_price&provider_id=<?php echo $v['provider_id'] ?>">调价</a>
                             </td>
                             <td>
                                 <?php
-                                    $date = $output['prices']["{$v['name']}-{$v['type']}"];
-                                    if (!empty($date)) {
-                                        echo $date;
-                                    } else {
-                                        echo '/';
-                                    }
+                                $date = $output['prices']["{$v['name']}-{$v['type']}"];
+                                if (!empty($date)) {
+                                    echo $date;
+                                } else {
+                                    echo '/';
+                                }
                                 ?>
 
                             </td>

+ 81 - 12
admin/templates/default/provider.price.set.php

@@ -6,7 +6,7 @@
     }
 
     .spec_table {
-        width: 320px;
+        width: 420px;
         border-right: 1px solid #CBE9F3;
     }
 
@@ -123,14 +123,11 @@
                     <td class="vatop rowform">
                         <select id="selectEffectType">
                             <option value="0">立即生效</option>
-                            <option value="1" <?php if (!empty($output['effect_time'])) {
-                                                    echo 'selected';
-                                                } ?>>延迟生效</option>
+                            <option value="1">延迟生效</option>
                         </select>
                     </td>
                     <td class="vatop rowform">
-                        <!-- <input class="txt date" type="hidden" value="0" name="effect_time" placeholder="" autocomplete="off" style="width:120px" /> -->
-                        <input class="txt date" style="display:none;" type="text" id="startTime" name="effect_time" placeholder="" value="<?php echo date("Y-m-d H:i:s", $output['effect_time']); ?>" autocomplete="off" style="width:120px" />
+                        <input class="txt date" style="display:none;" type="text" id="startTime" name="effect_time" placeholder="" value="<?php echo date("Y-m-d H:i:s", $output['effect_time']);?>" autocomplete="off" style="width:120px" />
                     </td>
                     <td class="vatop tips" style="color: red"></td>
                 </tr>
@@ -145,16 +142,27 @@
                                     <th class="w150 align-center">卡类型</th>
                                     <th class="w150 align-center">面额</th>
                                     <th class="w150 align-center">
-                                        费率
-                                        <div class="batch" style="display: inline-block"><i class="icon-edit" title="批量操作"></i>
+                                        价格
+                                        <div class="batch" style="display: none;"><i class="icon-edit" title="批量操作"></i>
                                             <div class="batch-input" style="display:none;">
                                                 <h6>批量设置费率(百分比):</h6>
                                                 <a href="javascript:void(0)" class="close">X</a>
-                                                <input name="" type="text" class="text price" />
+                                                <input name="" type="text" class="text price" />%
                                                 <a href="javascript:void(0)" class="ncsc-btn-mini" data-type="price">设置</a><span class="arrow"></span>
                                             </div>
                                         </div>
                                     </th>
+                                    <th class="w150 align-center">
+                                        费率(%)
+                                        <div class="batch" style="display: inline-block"><i class="icon-edit" title="批量操作"></i>
+                                            <div class="batch-input" style="display:none;">
+                                                <h6>批量设置费率(百分比):</h6>
+                                                <a href="javascript:void(0)" class="close">X</a>
+                                                <input name="" type="text" class="text price" />%
+                                                <a href="javascript:void(0)" class="ncsc-btn-mini-price" data-type="price">设置</a><span class="arrow"></span>
+                                            </div>
+                                        </div>
+                                    </th>
                                 </tr>
 
                                 <tbody class="tbody">
@@ -169,9 +177,11 @@
                                                 <input type="hidden" class="num" name="specs[]" value="<?php echo $spec; ?>">
                                             </td>
                                             <td class="w150 align-center tdVal">
-                                                <input type="text" name="<?php echo "price-{$card_type}-{$spec}" ?>" class="txt price <?php if ($val['opened'] == 0) echo 'disInput' ?>" <?php if ($val['opened'] == 0) echo 'disabled' ?> data-opened="<?php echo $val['opened']; ?>" value="<?php echo $val['price']; ?>">
+                                                <input type="text" name="<?php echo "price-{$card_type}-{$spec}" ?>" class="txt price changePrice <?php if ($val['opened'] == 0) echo 'disInput' ?>" <?php if ($val['opened'] == 0) echo 'disabled' ?> data-opened="<?php echo $val['opened']; ?>" value="<?php echo $val['price']; ?>">
+                                            </td>
+                                            <td class="w150 align-center">
+                                                <input type="text" style="width:100px;" data-type="rate" min="0" max="200" <?php if ($val['opened'] == 0) echo 'disabled' ?>>
                                             </td>
-
                                         </tr>
                                     <?php } ?>
                                 </tbody>
@@ -196,11 +206,49 @@
 <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() {
+
+        var effect_time = <?php echo json_encode($output['effect_time']) ?> * 1000;
+        var curDate = new Date().getTime();
+        if (effect_time > curDate) {
+            $('#selectEffectType').val('1');
+            $('#startTime').show();
+            var date = new Date(effect_time);
+            var year = date.getFullYear();
+            var month = date.getMonth() + 1;
+            var day = date.getDate();
+            if (month < 10) {
+                month = '0' + month;
+            }
+            if (day < 10) {
+                day = '0' + day;
+            }
+            var nowTime = year + '-' + month + '-' + day + ' ' + '00' + ':' + '00' + ':' + '00';
+            laydate.render({
+                elem: '#startTime',
+                type: 'datetime',
+                value: nowTime,
+                min: new Date().getTime()
+            });
+        }
+
         // laydate.render({
         //     elem: '#startTime',
         //     type: 'datetime'
         // });
 
+        const tdVals = $('.tdVal');
+        for (let i = 0; i < tdVals.length; i++) {
+            let rateInput = tdVals.eq(i).next().find('input');
+            let price = tdVals.eq(i).find('.price').val();
+            let amountPrice = tdVals.eq(i).find('.price').attr('name').split('-')[2];
+            if (tdVals.eq(i).find('input').attr('data-opened') == 1) {
+                rateInput.val(price / amountPrice * 100);
+            } else {
+                rateInput.val('--');
+            }
+        }
+
+
         let maxDecimal = (number) => {
             return String(number).replace(/^(.*\..{4}).*$/, "$1")
         }
@@ -231,7 +279,6 @@
 
                 var nowTime = year + '-' + month + '-' + day + ' ' + '00' + ':' + '00' + ':' + '00';
 
-
                 $(this).attr('name', '')
                 $('#startTime').attr('name', 'effect_time');
                 $('#startTime').show()
@@ -323,8 +370,30 @@
                 }
                 // console.log('_valArr', _valArr)
             }
+            $(this).parents('.setTable').children('.tbody').find('input[data-type="rate"]').val(_value);
+
             $(this).parent().hide();
             $(this).prev().val('');
         });
+
+        $('input[data-type="rate"]').on('input', function() {
+            var val = $(this).val();
+            var changeInputName = $(this).parent('td').prev().find('input').attr('name');
+            var amountPrice = changeInputName.split('-')[2];
+            $(this).parent('td').siblings('.tdVal').find('input').val(maxDecimal(parseInt(amountPrice) * val / 100))
+        })
+
+        $('.changePrice').on('input', function() {
+            const val = $(this).val();
+            const amountPrice = $(this).attr('name').split('-')[2];
+            const rateInput = $(this).parent().next().find('input');
+            rateInput.val(val / amountPrice * 100);
+        })
+
+        $('.ncsc-btn-mini-price').on('click', function() {
+            $(this).parent('th').prev().find('.ncsc-btn-mini').click();
+        })
+
+
     });
 </script>

+ 455 - 256
admin/templates/default/provider.refill.balance.php

@@ -1,27 +1,66 @@
 <?php defined('InShopNC') or exit('Access Invalid!'); ?>
 <style>
     .page .fixed-bar .item-title h3 {
-        margin-top:18px !important;
-        margin-bottom:10px !important;
-        font-weight:700 !important;
+        margin-top: 18px !important;
+        margin-bottom: 10px !important;
+        font-weight: 700 !important;
     }
+
     .tab-base li span {
-        font-size:12px !important;
+        font-size: 12px !important;
     }
+
     .layui-form-select .layui-input {
-        height:26px;
+        height: 26px;
     }
-    input::placeholder{ 
-        color:#333; 
+
+    input::placeholder {
+        color: #333;
     }
+
     .row_q ul li {
         height: 30px;
         line-height: 30px;
     }
+
     .row_w {
         float: left;
         margin-right: 40px;
     }
+
+    #createDate,
+    #createItemStartDate,
+    #createItemEndDate {
+        height: 30px;
+    }
+
+    .createTaskDate {
+        display: flex;
+        align-items: center;
+        margin-bottom: 10px;
+    }
+
+    .createTaskDate span {
+        white-space: nowrap;
+        margin-right: 10px;
+    }
+
+    .table {
+        width: 2500px;
+        table-layout: fixed;
+    }
+
+    .table td:last-child,
+    .table th:last-child {
+        position: sticky;
+        right: 0;
+        background: #fff;
+        box-shadow: -2px 0 2px #cbe9f3;
+        width: 130px;
+        height: 30px;
+        line-height: 30px;
+        display: inline-block;
+    }
 </style>
 <div class="page">
     <div class="fixed-bar">
@@ -42,178 +81,313 @@
         <input type="hidden" value="OrderStats" name="act">
         <input type="hidden" value="refill_balance" name="op">
         <input type="hidden" value="provider" name="type">
-        <input type="hidden" name="cid" value=""/>
-        <input type="hidden" name="default_no_mch" value="<?php echo $_GET['cid']; ?>"/>
+        <input type="hidden" name="cid" value="" />
+        <input type="hidden" name="default_no_mch" value="<?php echo $_GET['cid']; ?>" />
         <table class="tb-type1 noborder search">
             <tbody>
-            <tr>
-                <th><label for="query_start_time">统计时间</label></th>
-                <td>
-                    <input class="txt date" type="text" value="<?php echo $_GET['query_start_time']; ?>"
-                           id="startTime" name="query_start_time" autocomplete="off" style="width:120px" />
-                    <label for="query_start_time">~</label>
-                    <input class="txt date" type="text" value="<?php echo $_GET['query_end_time']; ?>"
-                           id="endTime" name="query_end_time" autocomplete="off" style="width:120px" />
-                </td>
-                <th><label>统计日期类型</label></th>
-                <td>
-                    <select name="order_time_type" id="order_time_type">
-                        <option value="">请选择...</option>
-                        <option value="notify_time" <?php if($_GET['order_time_type'] == 'notify_time'){ echo 'selected';}?>>回调日期</option>
-                        <option value="order_time" <?php if($_GET['order_time_type'] == 'order_time'){ echo 'selected';}?>>下单日期</option>
-                    </select>
-                </td>
-                <th><label>通道名称</label></th>
-                <td>
-                 <div id="selest_nc"></div>
-                </td>
-                <td><a href="javascript:void(0);" id="ncsubmit" class="btn-search "
-                       title="<?php echo $lang['nc_query']; ?>">&nbsp;</a>
-                    <?php if ($output['mch_name'] != '') { ?>
-                        <a href="index.php?act=OrderStats&op=index" class="btns "
-                           title="<?php echo $lang['nc_cancel_search']; ?>"><span><?php echo $lang['nc_cancel_search']; ?></span></a>
-                    <?php } ?></td>
-<!--                <td>-->
-<!--                    <a href="javascript:void(0);" id="ncexport" class="btn">-->
-<!--                        <span>导出</span>-->
-<!--                    </a>-->
-<!--                </td>-->
-            </tr>
+                <tr>
+                    <th><label for="query_start_time">统计时间</label></th>
+                    <td>
+                        <input class="txt date" type="text" value="<?php echo $_GET['query_start_time']; ?>" id="startTime" name="query_start_time" autocomplete="off" style="width:120px" />
+                        <label for="query_start_time">~</label>
+                        <input class="txt date" type="text" value="<?php echo $_GET['query_end_time']; ?>" id="endTime" name="query_end_time" autocomplete="off" style="width:120px" />
+                    </td>
+                    <th><label>统计日期类型</label></th>
+                    <td>
+                        <select name="order_time_type" id="order_time_type">
+                            <option value="">请选择...</option>
+                            <option value="notify_time" <?php if ($_GET['order_time_type'] == 'notify_time') {
+                                                            echo 'selected';
+                                                        } ?>>回调日期</option>
+                            <option value="order_time" <?php if ($_GET['order_time_type'] == 'order_time') {
+                                                            echo 'selected';
+                                                        } ?>>下单日期</option>
+                        </select>
+                    </td>
+                    <th><label>通道名称</label></th>
+                    <td>
+                        <div id="selest_nc"></div>
+                    </td>
+                    <td><a href="javascript:void(0);" id="ncsubmit" class="btn-search " title="<?php echo $lang['nc_query']; ?>">&nbsp;</a>
+                        <?php if ($output['mch_name'] != '') { ?>
+                            <a href="index.php?act=OrderStats&op=index" class="btns " title="<?php echo $lang['nc_cancel_search']; ?>"><span><?php echo $lang['nc_cancel_search']; ?></span></a>
+                        <?php } ?>
+                    </td>
+                    <!-- <td>
+                        <a href="javascript:void(0);" id="create" class="btn">
+                            <span>新建</span>
+                        </a>
+                    </td> -->
+                </tr>
             </tbody>
         </table>
     </form>
-<!--    <table class="table tb-type2" id="prompt">-->
-<!--        <tbody>-->
-<!--        <tr class="space odd">-->
-<!--            <th colspan="12"><div class="title">-->
-<!--                    <h5>总量统计</h5>-->
-<!--                    <span class="arrow"></span></div></th>-->
-<!--        </tr>-->
-<!--        <tr>-->
-<!--            <td class="row_q">-->
-<!--                <ul class="row_w">-->
-<!--                    <li>回调日期统计</li>-->
-<!--                    <li class="lineLi" style="color:#000;">总计成功订单量: --><?php //echo $output['total_stats']['notify_time']['success_count_total'] ?? 0?><!--</li>-->
-<!--                    <li class="lineLi" style="color:#000;">总计充值中订单量: --><?php //echo $output['total_stats']['notify_time']['send_count_total'] ?? 0?><!--</li>-->
-<!--                    <li class="lineLi" style="color:#000;">总计成功订单金额:--><?php //echo $output['total_stats']['notify_time']['success_refill_amounts_total'] ?? 0?><!--</li>-->
-<!--                    <li class="lineLi" style="color:#000;">总计下游扣款金额:--><?php //echo $output['total_stats']['notify_time']['success_mch_amounts_toatl'] ?? 0?><!--</li>-->
-<!--                    <li class="lineLi" style="color:#000;">总计上游扣款金额:--><?php //echo $output['total_stats']['notify_time']['success_channel_amounts_total'] ?? 0?><!--</li>-->
-<!--                </ul>-->
-<!--                <ul>-->
-<!--                    <li>下单日期统计</li>-->
-<!--                    <li class="lineLi" style="color:#000;">总计成功订单量: --><?php //echo $output['total_stats']['order_time']['success_count_total'] ?? 0?><!--</li>-->
-<!--                    <li class="lineLi" style="color:#000;">总计充值中订单量: --><?php //echo $output['total_stats']['order_time']['send_count_total'] ?? 0?><!--</li>-->
-<!--                    <li class="lineLi" style="color:#000;">总计成功订单金额:--><?php //echo $output['total_stats']['order_time']['success_refill_amounts_total'] ?? 0?><!--</li>-->
-<!--                    <li class="lineLi" style="color:#000;">总计下游扣款金额:--><?php //echo $output['total_stats']['order_time']['success_mch_amounts_toatl'] ?? 0?><!--</li>-->
-<!--                    <li class="lineLi" style="color:#000;">总计上游扣款金额:--><?php //echo $output['total_stats']['order_time']['success_channel_amounts_total'] ?? 0?><!--</li>-->
-<!--                </ul>-->
-<!--            </td>-->
-<!--        </tr>-->
-<!--        </tbody>-->
-<!--    </table>-->
+    <!--    <table class="table tb-type2" id="prompt">-->
+    <!--        <tbody>-->
+    <!--        <tr class="space odd">-->
+    <!--            <th colspan="12"><div class="title">-->
+    <!--                    <h5>总量统计</h5>-->
+    <!--                    <span class="arrow"></span></div></th>-->
+    <!--        </tr>-->
+    <!--        <tr>-->
+    <!--            <td class="row_q">-->
+    <!--                <ul class="row_w">-->
+    <!--                    <li>回调日期统计</li>-->
+    <!--                    <li class="lineLi" style="color:#000;">总计成功订单量: --><?php //echo $output['total_stats']['notify_time']['success_count_total'] ?? 0
+                                                                                ?>
+    <!--</li>-->
+    <!--                    <li class="lineLi" style="color:#000;">总计充值中订单量: --><?php //echo $output['total_stats']['notify_time']['send_count_total'] ?? 0
+                                                                                ?>
+    <!--</li>-->
+    <!--                    <li class="lineLi" style="color:#000;">总计成功订单金额:--><?php //echo $output['total_stats']['notify_time']['success_refill_amounts_total'] ?? 0
+                                                                                ?>
+    <!--</li>-->
+    <!--                    <li class="lineLi" style="color:#000;">总计下游扣款金额:--><?php //echo $output['total_stats']['notify_time']['success_mch_amounts_toatl'] ?? 0
+                                                                                ?>
+    <!--</li>-->
+    <!--                    <li class="lineLi" style="color:#000;">总计上游扣款金额:--><?php //echo $output['total_stats']['notify_time']['success_channel_amounts_total'] ?? 0
+                                                                                ?>
+    <!--</li>-->
+    <!--                </ul>-->
+    <!--                <ul>-->
+    <!--                    <li>下单日期统计</li>-->
+    <!--                    <li class="lineLi" style="color:#000;">总计成功订单量: --><?php //echo $output['total_stats']['order_time']['success_count_total'] ?? 0
+                                                                                ?>
+    <!--</li>-->
+    <!--                    <li class="lineLi" style="color:#000;">总计充值中订单量: --><?php //echo $output['total_stats']['order_time']['send_count_total'] ?? 0
+                                                                                ?>
+    <!--</li>-->
+    <!--                    <li class="lineLi" style="color:#000;">总计成功订单金额:--><?php //echo $output['total_stats']['order_time']['success_refill_amounts_total'] ?? 0
+                                                                                ?>
+    <!--</li>-->
+    <!--                    <li class="lineLi" style="color:#000;">总计下游扣款金额:--><?php //echo $output['total_stats']['order_time']['success_mch_amounts_toatl'] ?? 0
+                                                                                ?>
+    <!--</li>-->
+    <!--                    <li class="lineLi" style="color:#000;">总计上游扣款金额:--><?php //echo $output['total_stats']['order_time']['success_channel_amounts_total'] ?? 0
+                                                                                ?>
+    <!--</li>-->
+    <!--                </ul>-->
+    <!--            </td>-->
+    <!--        </tr>-->
+    <!--        </tbody>-->
+    <!--    </table>-->
     <form method="post" id="merchant_name_form">
-        <input type="hidden" name="form_submit" value="ok"/>
-        <table class="table tb-type2">
-            <thead>
-            <tr class="thead">
-                <th>记录ID</th>
-                <th>父ID</th>
-                <th>主体名称</th>
-                <th>主体ID</th>
-                <th class="align-left">统计开始日期</th>
-                <th class="align-left">统计结束日期</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>
-                <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-left">备注</th>
-<!--                <th class="align-center">操作</th>-->
-            </tr>
-            </thead>
-            <tbody>
-            <?php if (!empty($output['stats_list']) && is_array($output['stats_list'])) { ?>
-                <?php foreach ($output['stats_list'] as $k => $v) { ?>
-                    <tr class="trFlex">
-                        <td><?php echo $v['balance_id']; ?></td>
-                        <td><?php echo $v['parent_id']; ?></td>
-                        <td><?php echo $v['cname']; ?></td>
-                        <td><?php echo $v['cid']; ?></td>
-                        <td class="align-left"><?php echo $v['start_stamp'] ? date('Y-m-d H:i', $v['start_stamp']) : '/'; ?></td>
-                        <td class="align-left"><?php echo $v['end_text']; ?></td>
-                        <td class="align-center"><?php echo $v['success_count']; ?></td>
-                        <td class="align-center"><?php echo $v['refill_amount']; ?></td>
-                        <td class="align-center"><?php echo $v['mch_amount']; ?></td>
-                        <td class="align-center"><?php echo $v['channel_amount']; ?></td>
-                        <td class="align-center"><?php echo $v['profit_amount']; ?></td>
-                        <td class="align-center"><?php echo $v['transfer_in']; ?></td>
-                        <td class="align-center"><?php echo $v['transfer_out']; ?></td>
-                        <td class="align-center"><?php echo $v['refund_amount']; ?></td>
-                        <td class="align-center"><?php echo $v['except_amount']; ?></td>
-                        <td class="align-center"><?php echo $v['accumulate_balance']; ?></td>
-                        <td class="align-center"><?php echo $v['balance']; ?></td>
-                        <td class="align-left"><?php echo date("Y-m-d H:i:s", $v['update_time']); ?></td>
-                        <td class="align-center">
-                            <?php if($v['confirmed'] == 0){?>
-                                <span style="color: #fd9d0e">未确认</span>
-                            <?php }else{?>
-                                <span style="color: #0bb20c">已确认</span>
-                            <?php }?>
+        <input type="hidden" name="form_submit" value="ok" />
+        <div style="width:100%;overflow-x: auto;">
+            <table class="table tb-type2">
+                <thead>
+                    <tr class="thead">
+                        <th>记录ID</th>
+                        <th>父ID</th>
+                        <th>主体名称</th>
+                        <th>主体ID</th>
+                        <th class="align-left">统计开始日期</th>
+                        <th class="align-left">统计结束日期</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>
+                        <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-left">备注</th>
+                        <th class="align-center">操作</th>
+                    </tr>
+                </thead>
+                <tbody>
+                    <?php if (!empty($output['stats_list']) && is_array($output['stats_list'])) { ?>
+                        <?php foreach ($output['stats_list'] as $k => $v) { ?>
+                            <tr class="trFlex">
+                                <td><?php echo $v['balance_id']; ?></td>
+                                <td><?php echo $v['parent_id']; ?></td>
+                                <td><?php echo $v['cname']; ?></td>
+                                <td><?php echo $v['cid']; ?></td>
+                                <td class="align-left"><?php echo $v['start_stamp'] ? date('Y-m-d H:i', $v['start_stamp']) : '/'; ?></td>
+                                <td class="align-left"><?php echo $v['end_text']; ?></td>
+                                <td class="align-center"><?php echo $v['success_count']; ?></td>
+                                <td class="align-center"><?php echo $v['refill_amount']; ?></td>
+                                <td class="align-center"><?php echo $v['mch_amount']; ?></td>
+                                <td class="align-center"><?php echo $v['channel_amount']; ?></td>
+                                <td class="align-center"><?php echo $v['profit_amount']; ?></td>
+                                <td class="align-center"><?php echo $v['transfer_in']; ?></td>
+                                <td class="align-center"><?php echo $v['transfer_out']; ?></td>
+                                <td class="align-center"><?php echo $v['refund_amount']; ?></td>
+                                <td class="align-center"><?php echo $v['except_amount']; ?></td>
+                                <td class="align-center"><?php echo $v['accumulate_balance']; ?></td>
+                                <td class="align-center"><?php echo $v['balance']; ?></td>
+                                <td class="align-left"><?php echo date("Y-m-d H:i:s", $v['update_time']); ?></td>
+                                <td class="align-center">
+                                    <?php if ($v['confirmed'] == 0) { ?>
+                                        <span style="color: #fd9d0e">未确认</span>
+                                    <?php } else { ?>
+                                        <span style="color: #0bb20c">已确认</span>
+                                    <?php } ?>
+                                </td>
+                                <td class="align-center"><?php echo $output['order_time_type_text'][$v['time_type']]; ?></td>
+                                <td class="align-left"><?php echo $v['remark']; ?></td>
+                                <td style="text-align: center;color:#0D93BF;">
+                                    <a href="javascript:void(0);" class="item_create_btn" style="color:#0D93BF;">新建</a>
+                                    <span> | </span>
+                                    <a href="javascript:void(0);" style="color:#0D93BF;">编辑</a>
+                                    <span>|</span>
+                                    <a style="margin:0 5px;color:#0D93BF;" href="index.php?act=orderstats&op=refill_balance_rebuild&balance_id=<?php echo $v['balance_id']; ?>" data-index="<?php echo $k ?>" class="rebuildBtn">重新生成</a>
+                                    <?php if ($v['confirmed'] == 0) { ?>
+                                        <span>|</span>
+                                        <a style="color:#0D93BF;" href="index.php?act=orderstats&op=refill_balance_confirm&balance_id=<?php echo $v['balance_id']; ?>" data-index="<?php echo $k ?>" class="checkBtn">确认</a>
+                                    <?php } ?>
+                                </td>
+                                <!--                        <td class="align-center w200">-->
+                                <!--                            <a href="index.php?act=merchant&op=OrderStatsReload&stat_id=--><?php //echo $v['stat_id'];
+                                                                                                                                ?>
+                                <!--">重新统计</a>-->
+                                <!--                            |<a href="index.php?act=merchant&op=OrderStatsCheck&stat_id=--><?php //echo $v['stat_id'] 
+                                                                                                                                ?>
+                                <!--">编辑</a>-->
+                                <!--                        </td>-->
+                            </tr>
+                        <?php } ?>
+                    <?php } else { ?>
+                        <tr class="no_data">
+                            <td colspan="20"><?php echo $lang['nc_no_record']; ?></td>
+                        </tr>
+                    <?php } ?>
+                </tbody>
+                <tfoot>
+                    <tr class="tfoot">
+                        <td></td>
+                        <td colspan="20">
+                            <div class="pagination"><?php echo $output['show_page']; ?></div>
                         </td>
-                        <td class="align-center"><?php echo $output['order_time_type_text'][$v['time_type']]; ?></td>
-                        <td class="align-left"><?php echo $v['remark']; ?></td>
-<!--                        <td class="align-center w200">-->
-<!--                            <a href="index.php?act=merchant&op=OrderStatsReload&stat_id=--><?php //echo $v['stat_id'];?><!--">重新统计</a>-->
-<!--                            |<a href="index.php?act=merchant&op=OrderStatsCheck&stat_id=--><?php //echo $v['stat_id'] ?><!--">编辑</a>-->
-<!--                        </td>-->
                     </tr>
-                <?php } ?>
-            <?php } else { ?>
-                <tr class="no_data">
-                    <td colspan="20"><?php echo $lang['nc_no_record']; ?></td>
-                </tr>
-            <?php } ?>
-            </tbody>
-            <tfoot>
-            <tr class="tfoot">
-                <td></td>
-                <td colspan="20">
-                    <div class="pagination"><?php echo $output['show_page']; ?></div>
-                </td>
-            </tr>
-            </tfoot>
-        </table>
+                </tfoot>
+            </table>
+        </div>
     </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>
-<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" src="<?php echo ADMIN_TEMPLATES_URL;?>/js/xm-select.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" src="<?php echo ADMIN_TEMPLATES_URL; ?>/js/xm-select.js"></script>
 <script type="text/javascript" src="<?php echo RESOURCE_SITE_URL; ?>/js/jquery.edit.js" charset="utf-8"></script>
 <script type="text/javascript" src="<?php echo RESOURCE_SITE_URL; ?>/laydate/laydate.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"/>
+<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" />
 <script>
-    $(function () {
-        $('#ncsubmit').click(function () {
+    $(function() {
+        $('#create').on('click', function() {
+            var selectEndDate = '';
+            layui.use(['layer', 'laydate'], function() {
+                const selectDateHTML = '<label class="createTaskDate"><span>结束日期:</span><input type="text" class="layui-input" id="createDate"></label>'
+                layer.confirm(selectDateHTML, {
+                    title: '新建'
+                }, function(index) {
+                    console.log('确认')
+                    layer.close(index);
+                }, function() {
+                    console.log('取消')
+                });
+
+
+                laydate.render({
+                    elem: '#createDate',
+                    type: 'datetime',
+                    done: function(value) {
+                        console.log('选中的日期...', value)
+                        selectEndDate = value;
+                    }
+                });
+
+            })
+            // 
+        })
+
+
+        $('.item_create_btn').on('click', function() {
+            var selectStartDate = '';
+            var selectEndDate = '';
+            var balance_id = $(this).attr('data-balance_id');
+            layui.use(['layer', 'laydate'], function() {
+                const selectDateHTML = `<label class="createTaskDate"><span>开始日期:</span><input type="text" class="layui-input" id="createItemStartDate"></label>
+                                        <label class="createTaskDate"><span>结束日期:</span><input type="text" class="layui-input" id="createItemEndDate"></label>`
+                layer.confirm(selectDateHTML, {
+                    title: '新建'
+                }, function(index) {
+                    console.log('确认')
+                    if (!selectStartDate) {
+                        layer.msg('请选择开始日期');
+                        return;
+                    }
+                    if (!selectEndDate) {
+                        layer.msg('请选择结束日期');
+                        return;
+                    }
+                    console.log(balance_id, selectStartDate, selectEndDate)
+                    var index = layer.load();
+                    $.ajax({
+                        url: `index.php?act=orderstats&op=refill_balance_create`,
+                        data: {
+                            balance_id,
+                            selectStartDate,
+                            selectEndDate
+                        },
+                        dataType: 'json',
+                        mothod: 'get',
+                        success: function(res) {
+                            layer.close(index);
+                            console.log('success', res);
+                            if (res.code) {
+                                layer.msg(res.msg)
+                            } else {
+                                layer.alert(res.msg)
+                            }
+                        }
+                    })
+                    layer.close(index);
+                }, function() {
+                    console.log('取消')
+                });
+
+                laydate.render({
+                    elem: '#createItemStartDate',
+                    type: 'datetime',
+                    done: function(value) {
+                        console.log('选中的开始日期...', value)
+                        selectStartDate = value;
+                    }
+                });
+
+                laydate.render({
+                    elem: '#createItemEndDate',
+                    type: 'datetime',
+                    done: function(value) {
+                        console.log('选中的结束日期...', value)
+                        selectEndDate = value;
+                    }
+                });
+
+            })
+        })
+
+
+
+
+
+        $('#ncsubmit').click(function() {
             let selectArr = selest_nc.getValue();
             let selectStr = ''
             for (let i = 0; i < selectArr.length; i++) {
-                selectStr += selectArr[i].value+','
+                selectStr += selectArr[i].value + ','
             }
-            selectStr = selectStr.substr(0, selectStr.length-1)
+            selectStr = selectStr.substr(0, selectStr.length - 1)
             $('input[name="cid"]').val(selectStr);
             $('#formSearch').submit();
             $('input[name="cid"]').val('');
@@ -228,109 +402,110 @@
             type: 'datetime'
         });
         // 表格hover时背景
-        $('.trFlex').each(function () {
-            $(this).hover(function () {
+        $('.trFlex').each(function() {
+            $(this).hover(function() {
                 $(this)[0].style.backgroundColor = '#cbe9f3'
-            },function() {
+            }, function() {
                 $(this)[0].style.backgroundColor = '#fff'
             })
         })
-        function JSONToExcelConvertor(JSONData, FileName, ShowLabel, headData) { 
+
+        function JSONToExcelConvertor(JSONData, FileName, ShowLabel, headData) {
             //先转化json 
-            var arrData = typeof JSONData != 'object' ? JSON.parse(JSONData) : JSONData; 
-            var excel = '<table>';   
+            var arrData = typeof JSONData != 'object' ? JSON.parse(JSONData) : JSONData;
+            var excel = '<table>';
             // 标题
             for (const key in headData) {
                 var head = "<tr>";
-                var td = "<td colspan='12' style='font-size:16px;'>"+ headData[key] + '</td>';
+                var td = "<td colspan='12' style='font-size:16px;'>" + headData[key] + '</td>';
                 excel += td + "</tr>";
             }
             //设置表头 
-            var row = "<tr>"; 
-            for (var i = 0, l = ShowLabel.length; i < l; i++) { 
-                row += "<th style='font-size:14px;'>" + ShowLabel[i].value + '</th>'; 
-            } 
+            var row = "<tr>";
+            for (var i = 0, l = ShowLabel.length; i < l; i++) {
+                row += "<th style='font-size:14px;'>" + ShowLabel[i].value + '</th>';
+            }
             //换行 
-            excel += row + "</tr>"; 
+            excel += row + "</tr>";
             //设置数据 
-            for (var i = 0; i < arrData.length; i++) { 
-                var row = "<tr>"; 
-                let code = i+1
-                row += "<td>" +code+ "</td>"
-                row += '<td style=font-size:14px;'+ 'mso-number-format:"\@"'+ '>' + arrData[i].time_text + '</td>';
-                row += '<td style=font-size:14px;'+ 'mso-number-format:"\@"'+ '>' + arrData[i].cname + '</td>';
-                row += '<td style=font-size:14px;'+ 'mso-number-format:"\@"'+ '>' + arrData[i].cid + '</td>';
-                row += '<td style=font-size:14px;'+ 'mso-number-format:"\@"'+ '>' + arrData[i].success_count + '</td>';
-                row += '<td style=font-size:14px;'+ 'mso-number-format:"\@"'+ '>' + arrData[i].success_refill_amounts + '</td>';
-                row += '<td style=font-size:14px;'+ 'mso-number-format:"\@"'+ '>' + arrData[i].success_channel_amounts + '</td>';
-                row += '<td style=font-size:14px;'+ 'mso-number-format:"\@"'+ '>' + arrData[i].success_mch_amounts + '</td>';
-                row += '<td style=font-size:14px;'+ 'mso-number-format:"\@"'+ '>' + arrData[i].profit_amounts + '</td>';
-                row += '<td style=font-size:14px;'+ 'mso-number-format:"\@"'+ '>' + arrData[i].order_count + '</td>';
-                row += '<td style=font-size:14px;'+ 'mso-number-format:"\@"'+ '>' + arrData[i].cancel_count + '</td>';
-                row += '<td style=font-size:14px;'+ 'mso-number-format:"\@"'+ '>' + arrData[i].success_ratio + '</td>';
-                excel += row + "</tr>"; 
-            } 
-                excel += "</table>"; 
-                var excelFile = "<html xmlns:o='urn:schemas-microsoft-com:office:office' xmlns:x='urn:schemas-microsoft-com:office:excel' xmlns='http://www.w3.org/TR/REC-html40'>"; 
-                excelFile += '<meta http-equiv="content-type" content="application/vnd.ms-excel; charset=UTF-8">'; 
-                excelFile += '<meta http-equiv="content-type" content="application/vnd.ms-excel'; 
-                excelFile += '; charset=UTF-8">'; 
-                excelFile += "<head>"; 
-                excelFile += "<!--[if gte mso 9]>"; 
-                excelFile += "<xml>"; 
-                excelFile += "<x:ExcelWorkbook>"; 
-                excelFile += "<x:ExcelWorksheets>"; 
-                excelFile += "<x:ExcelWorksheet>"; 
-                excelFile += "<x:Name>"; 
-                excelFile += "{worksheet}"; 
-                excelFile += "</x:Name>"; 
-                excelFile += "<x:WorksheetOptions>"; 
-                excelFile += "<x:DisplayGridlines/>"; 
-                excelFile += "</x:WorksheetOptions>"; 
-                excelFile += "</x:ExcelWorksheet>"; 
-                excelFile += "</x:ExcelWorksheets>"; 
-                excelFile += "</x:ExcelWorkbook>"; 
-                excelFile += "</xml>"; 
-                excelFile += "<![endif]-->"; 
-                excelFile += "</head>"; 
-                excelFile += "<body>"; 
-                excelFile += excel; 
-                excelFile += "</body>"; 
-                excelFile += "</html>"; 
-                var uri = 'data:application/vnd.ms-excel;charset=utf-8,' + encodeURIComponent(excelFile); 
-                var link = document.createElement("a");   
-                link.href = uri; 
-                link.style = "visibility:hidden"; 
-                link.download = FileName + ".xls"; 
-                document.body.appendChild(link); 
-                link.click(); 
-                document.body.removeChild(link); 
+            for (var i = 0; i < arrData.length; i++) {
+                var row = "<tr>";
+                let code = i + 1
+                row += "<td>" + code + "</td>"
+                row += '<td style=font-size:14px;' + 'mso-number-format:"\@"' + '>' + arrData[i].time_text + '</td>';
+                row += '<td style=font-size:14px;' + 'mso-number-format:"\@"' + '>' + arrData[i].cname + '</td>';
+                row += '<td style=font-size:14px;' + 'mso-number-format:"\@"' + '>' + arrData[i].cid + '</td>';
+                row += '<td style=font-size:14px;' + 'mso-number-format:"\@"' + '>' + arrData[i].success_count + '</td>';
+                row += '<td style=font-size:14px;' + 'mso-number-format:"\@"' + '>' + arrData[i].success_refill_amounts + '</td>';
+                row += '<td style=font-size:14px;' + 'mso-number-format:"\@"' + '>' + arrData[i].success_channel_amounts + '</td>';
+                row += '<td style=font-size:14px;' + 'mso-number-format:"\@"' + '>' + arrData[i].success_mch_amounts + '</td>';
+                row += '<td style=font-size:14px;' + 'mso-number-format:"\@"' + '>' + arrData[i].profit_amounts + '</td>';
+                row += '<td style=font-size:14px;' + 'mso-number-format:"\@"' + '>' + arrData[i].order_count + '</td>';
+                row += '<td style=font-size:14px;' + 'mso-number-format:"\@"' + '>' + arrData[i].cancel_count + '</td>';
+                row += '<td style=font-size:14px;' + 'mso-number-format:"\@"' + '>' + arrData[i].success_ratio + '</td>';
+                excel += row + "</tr>";
+            }
+            excel += "</table>";
+            var excelFile = "<html xmlns:o='urn:schemas-microsoft-com:office:office' xmlns:x='urn:schemas-microsoft-com:office:excel' xmlns='http://www.w3.org/TR/REC-html40'>";
+            excelFile += '<meta http-equiv="content-type" content="application/vnd.ms-excel; charset=UTF-8">';
+            excelFile += '<meta http-equiv="content-type" content="application/vnd.ms-excel';
+            excelFile += '; charset=UTF-8">';
+            excelFile += "<head>";
+            excelFile += "<!--[if gte mso 9]>";
+            excelFile += "<xml>";
+            excelFile += "<x:ExcelWorkbook>";
+            excelFile += "<x:ExcelWorksheets>";
+            excelFile += "<x:ExcelWorksheet>";
+            excelFile += "<x:Name>";
+            excelFile += "{worksheet}";
+            excelFile += "</x:Name>";
+            excelFile += "<x:WorksheetOptions>";
+            excelFile += "<x:DisplayGridlines/>";
+            excelFile += "</x:WorksheetOptions>";
+            excelFile += "</x:ExcelWorksheet>";
+            excelFile += "</x:ExcelWorksheets>";
+            excelFile += "</x:ExcelWorkbook>";
+            excelFile += "</xml>";
+            excelFile += "<![endif]-->";
+            excelFile += "</head>";
+            excelFile += "<body>";
+            excelFile += excel;
+            excelFile += "</body>";
+            excelFile += "</html>";
+            var uri = 'data:application/vnd.ms-excel;charset=utf-8,' + encodeURIComponent(excelFile);
+            var link = document.createElement("a");
+            link.href = uri;
+            link.style = "visibility:hidden";
+            link.download = FileName + ".xls";
+            document.body.appendChild(link);
+            link.click();
+            document.body.removeChild(link);
         }
-        $('#ncexport').click(function () {
+        $('#ncexport').click(function() {
             let selectArr = selest_nc.getValue();
             let selectStr = ''
             for (let i = 0; i < selectArr.length; i++) {
-                selectStr += selectArr[i].value+','
+                selectStr += selectArr[i].value + ','
             }
-            selectStr = selectStr.substr(0, selectStr.length-1)
-            let starTime = new Date($('input[name="query_start_time"]').val()).getTime()/1000;
-            let endTime = new Date($('input[name="query_end_time"]').val()).getTime()/1000;
+            selectStr = selectStr.substr(0, selectStr.length - 1)
+            let starTime = new Date($('input[name="query_start_time"]').val()).getTime() / 1000;
+            let endTime = new Date($('input[name="query_end_time"]').val()).getTime() / 1000;
             let cid = selectStr
             let order_time_type = $('#order_time_type').val()
             $.get('index.php?act=orderstats&op=ExportData&type=provider', {
                 query_start_time: starTime,
                 query_end_time: endTime,
                 cid: cid,
-                order_time_type:order_time_type
-            }, function (data) {
+                order_time_type: order_time_type
+            }, function(data) {
                 data = JSON.parse(data)
                 if (data && data.data) {
                     let head = ['北京椰子电子商务有限责任公司']
                     let time = ''
                     if (starTime && endTime) {
-                        time = '统计时间:'+$('input[name="query_start_time"]').val()+' - '+$('input[name="query_end_time"]').val()
+                        time = '统计时间:' + $('input[name="query_start_time"]').val() + ' - ' + $('input[name="query_end_time"]').val()
                     } else if (starTime) {
-                        time = '统计时间:'+$('input[name="query_start_time"]').val()
+                        time = '统计时间:' + $('input[name="query_start_time"]').val()
                     }
                     if (time) {
                         head.push(time)
@@ -340,38 +515,62 @@
                     head.push('总计下游扣款金额:' + parseFloat(data.total_stats.success_mch_amounts_toatl))
                     head.push('总计上游扣款金额:' + parseFloat(data.total_stats.success_channel_amounts_total))
                     head.push('总计利润金额:' + parseFloat(data.total_stats.profit_amounts_total))
-                    let title = [{value: "序号"},{value: "统计日期"},{value: "主体名称"},{value: "主体ID"},{value: "成功订单数"},{value: "成功金额"},{value: "上游金额"},{value: "下游金额"},{value: "利润"},{value: "订单总量"}, {value: "失败订单数量"},{value: "成功占比"}]
+                    let title = [{
+                        value: "序号"
+                    }, {
+                        value: "统计日期"
+                    }, {
+                        value: "主体名称"
+                    }, {
+                        value: "主体ID"
+                    }, {
+                        value: "成功订单数"
+                    }, {
+                        value: "成功金额"
+                    }, {
+                        value: "上游金额"
+                    }, {
+                        value: "下游金额"
+                    }, {
+                        value: "利润"
+                    }, {
+                        value: "订单总量"
+                    }, {
+                        value: "失败订单数量"
+                    }, {
+                        value: "成功占比"
+                    }]
                     JSONToExcelConvertor(data.data, '上游对账记录', title, head)
                 }
             })
         })
         //多选
-    let selest_nc
-    let default_no_mch = $('input[name="default_no_mch"]').val().split(',');
-    $.get('index.php?act=refill_order&op=provider_data', function (data) {
-        data = JSON.parse(data)
-        if (default_no_mch) {
-            for (let index = 0; index < default_no_mch.length; index++) {
-                for (let j = 0; j < data.length; j++) {
-                    if (default_no_mch[index] == data[j].value) {
-                        data[j].selected = true
+        let selest_nc
+        let default_no_mch = $('input[name="default_no_mch"]').val().split(',');
+        $.get('index.php?act=refill_order&op=provider_data', function(data) {
+            data = JSON.parse(data)
+            if (default_no_mch) {
+                for (let index = 0; index < default_no_mch.length; index++) {
+                    for (let j = 0; j < data.length; j++) {
+                        if (default_no_mch[index] == data[j].value) {
+                            data[j].selected = true
+                        }
                     }
                 }
             }
-        }
-        selest_nc = xmSelect.render({
-            el: '#selest_nc',
-            size: 'mini',
-            filterable: true,
-            style: {
-                minHeight: '27px',
-                lineHeight: '27px',
-                marginLeft: '4px',
-                width: '250px'
-            },
-            language: 'zn',
-            data: data
+            selest_nc = xmSelect.render({
+                el: '#selest_nc',
+                size: 'mini',
+                filterable: true,
+                style: {
+                    minHeight: '27px',
+                    lineHeight: '27px',
+                    marginLeft: '4px',
+                    width: '250px'
+                },
+                language: 'zn',
+                data: data
+            })
         })
-    })
     });
-</script>
+</script>

+ 33 - 15
admin/templates/default/refill.order.index.php

@@ -39,12 +39,12 @@
         padding: 13px 5px;
     }
 
-    .layui-form-selected dl {
+    #mchid_td .layui-form-selected dl {
         display: flex !important;
         flex-wrap: wrap !important;
     }
 
-    .layui-form-select dl {
+    #mchid_td .layui-form-select dl {
         top: 29px !important;
         left: 4px !important;
         min-width: 883% !important;
@@ -52,7 +52,7 @@
         padding: 14px 0 !important;
     }
 
-    .layui-form-select .layui-input {
+    #mchid_td .layui-form-select .layui-input {
         padding-right: 0 !important;
         cursor: pointer;
         width: 124%;
@@ -94,15 +94,16 @@
     }
 
     .layui-form-select dl dd.layui-this {
-        display: none;
+        /* display: none; */
+        background: #099ACF !important;
     }
 
-    .layui-form-select dl dd {
+    #mchid_td .layui-form-select dl dd {
         cursor: pointer;
         width: 130px;
     }
 
-    .layui-form-select .layui-edge {
+    #mchid_td .layui-form-select .layui-edge {
         right: -24px !important;
     }
 
@@ -126,6 +127,15 @@
     .covercolor:active {
         color: #0D93BF;
     }
+
+    #store_id_box .layui-form-select {
+        width: 230px;
+    }
+
+    #store_id_box .layui-form-select dl {
+        left: 3px;
+        top: 28px;
+    }
 </style>
 <?php defined('InShopNC') or exit('Access Invalid!'); ?>
 <div class="page">
@@ -138,7 +148,7 @@
         </div>
     </div>
     <div class="fixed-empty"></div>
-    <form method="get" action="index.php" name="formSearch" id="formSearch">
+    <form method="get" action="index.php" name="formSearch" id="formSearch" lay-filter="userform">
         <input type="hidden" name="act" value="refill_order" />
         <input type="hidden" name="op" value="index" />
         <input type="hidden" name="export" value="" />
@@ -165,7 +175,7 @@
                 </tr>
                 <tr>
                     <th><label>客户名称</label></th>
-                    <td class="layui-form">
+                    <td class="layui-form" id="mchid_td">
                         <select name="mchid" id="mchid" class="querySelect mchid" lay-verify="" lay-search lay-filter="mchid">
                             <option value=""><?php echo $lang['nc_please_choose']; ?></option>
                             <?php foreach ($output['merchant_list'] as $merchant) { ?>
@@ -174,13 +184,15 @@
                         </select>
                     </td>
                     <th><label>供方名称</label></th>
-                    <td class="">
-                        <select name="store_id" class="store_id" lay-search>
-                            <option data-color="<?php echo $provider['opened'] ?>" value=""><?php echo $lang['nc_please_choose']; ?></option>
-                            <?php foreach ($output['provider_list'] as $provider) { ?>
-                                <option value="<?php echo $provider['store_id'] ?>" <?php if ($_GET['store_id'] == $provider['store_id']) { ?>selected<?php } ?> data-color="<?php echo $provider['opened'] ?>" class="textColor"><?php echo $provider['store_name'] ?></option>
-                            <?php } ?>
-                        </select>
+                    <td id="store_id_box">
+                        <div class="layui-form" lay-filter="store_id_select">
+                            <select name="store_id" class="store_id" lay-search style="width:220px;">
+                                <option data-color="<?php echo $provider['opened'] ?>" value=""><?php echo $lang['nc_please_choose']; ?></option>
+                                <?php foreach ($output['provider_list'] as $provider) { ?>
+                                    <option value="<?php echo $provider['store_id'] ?>" <?php if ($_GET['store_id'] == $provider['store_id']) { ?>selected<?php } ?> data-color="<?php echo $provider['opened'] ?>" class="textColor"><?php echo $provider['store_name'] ?></option>
+                                <?php } ?>
+                            </select>
+                        </div>
                     </td>
                     <th><label>不包含客户</label></th>
                     <td>
@@ -568,6 +580,12 @@
 <link rel="stylesheet" type="text/css" href="<?php echo ADMIN_TEMPLATES_URL; ?>/layui/css/layui.css" />
 <script type="text/javascript">
     $(function() {
+
+        layui.use('form', function() {
+            var form = layui.form;
+            form.render('select', 'store_id_select');
+        })
+
         function initialHighlight(id) {
             const $options = $('.mchid_name');
             const attrs = [];

+ 14 - 5
admin/templates/default/system.order.stats.php

@@ -28,6 +28,7 @@
         <input type="hidden" value="OrderStats" name="act">
         <input type="hidden" value="index" name="op">
         <input type="hidden" value="system" name="type">
+        <input type="hidden" name="reload" value=""/>
         <table class="tb-type1 noborder search">
             <tbody>
             <tr>
@@ -47,7 +48,6 @@
                         <option value="order_time" <?php if($_GET['order_time_type'] == 'order_time'){ echo 'selected';}?>>下单日期</option>
                     </select>
                 </td>
-                </td>
                 <td><a href="javascript:void(0);" id="ncsubmit" class="btn-search "
                        title="<?php echo $lang['nc_query']; ?>">&nbsp;</a>
                     <?php if ($output['mch_name'] != '') { ?>
@@ -59,6 +59,11 @@
                         <span>导出</span>
                     </a>
                 </td>
+                <td>
+                    <a href="javascript:void(0);" id="ncreload" class="btn">
+                        <span>批量重新统计</span>
+                    </a>
+                </td>
             </tr>
             </tbody>
         </table>
@@ -111,7 +116,7 @@
                 <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>
@@ -138,9 +143,9 @@
                         <td class="align-center"><?php echo $v['cancel_count']; ?></td>
                         <td class="align-center"><?php echo $v['success_ratio']; ?></td>
                         <td class="align-center"><?php echo $output['order_time_type_text'][$v['order_time_type']]; ?></td>
-<!--                        <td class="align-center w200">-->
-<!--                            <a href="index.php?act=merchant&op=OrderStatsReload&stat_id=--><?php //echo $v['stat_id'];?><!--">重新统计</a>-->
-<!--                        </td>-->
+                        <td class="align-center w200">
+                            <a href="index.php?act=merchant&op=OrderStatsReload&stat_id=<?php echo $v['stat_id'];?>">重新统计</a>
+                        </td>
                     </tr>
                 <?php } ?>
             <?php } else { ?>
@@ -164,6 +169,10 @@
 <script type="text/javascript" src="<?php echo RESOURCE_SITE_URL; ?>/laydate/laydate.js"></script>
 <script>
     $(function () {
+        $("#ncreload").click(function () {
+            $('input[name="reload"]').val('1');
+            $('#formSearch').submit();
+        })
         $('#ncsubmit').click(function () {
             $('input[name="op"]').val('index');
             $('#formSearch').submit();

+ 492 - 209
admin/templates/default/system.refill.balance.php

@@ -4,10 +4,56 @@
         height: 30px;
         line-height: 30px;
     }
+
     .row_w {
         float: left;
         margin-right: 40px;
     }
+
+    #merchant_name_form thead th:last-child,
+    #merchant_name_form tbody td:last-child {
+        position: sticky;
+        right: 0;
+        z-index: 1;
+        background: #fff;
+        box-shadow: -2px 0 2px #cbe9f3;
+        width: 170px;
+        display: inline-block;
+        line-height: 30px;
+        height: 30px;
+        text-align: center;
+    }
+
+    #merchant_name_form table {
+        table-layout: fixed;
+    }
+
+    #createDate,
+    #createItemStartDate,
+    #createItemEndDate {
+        height: 30px;
+    }
+
+    .createTaskDate {
+        display: flex;
+        align-items: center;
+        margin-bottom: 10px;
+    }
+
+    .createTaskDate span {
+        white-space: nowrap;
+        margin-right: 10px;
+    }
+
+    .tab-base li span {
+        font-size: 12px !important;
+    }
+
+    .page .fixed-bar .item-title h3 {
+        margin-top: 18px !important;
+        margin-bottom: 10px !important;
+        font-weight: 700 !important;
+    }
 </style>
 <div class="page">
     <div class="fixed-bar">
@@ -23,6 +69,8 @@
             </ul>
         </div>
     </div>
+
+
     <div class="fixed-empty"></div>
     <form method="get" name="formSearch" id="formSearch">
         <input type="hidden" value="OrderStats" name="act">
@@ -30,153 +78,361 @@
         <input type="hidden" value="system" name="type">
         <table class="tb-type1 noborder search">
             <tbody>
-            <tr>
-                <th><label for="query_start_time">结余统计时间</label></th>
-                <td>
-                    <input class="txt date" type="text" value="<?php echo $_GET['query_start_time']; ?>"
-                           id="startTime" name="query_start_time" autocomplete="off" style="width:120px" />
-                    <label for="query_start_time">~</label>
-                    <input class="txt date" type="text" value="<?php echo $_GET['query_end_time']; ?>"
-                           id="endTime" name="query_end_time" autocomplete="off" style="width:120px" /></td>
-                <td>
-                <th><label>统计日期类型</label></th>
-                <td>
-                    <select name="order_time_type" id="order_time_type">
-                        <option value="">请选择...</option>
-                        <option value="notify_time" <?php if($_GET['order_time_type'] == 'notify_time'){ echo 'selected';}?>>回调日期</option>
-                        <option value="order_time" <?php if($_GET['order_time_type'] == 'order_time'){ echo 'selected';}?>>下单日期</option>
-                    </select>
-                </td>
-                </td>
-                <td><a href="javascript:void(0);" id="ncsubmit" class="btn-search "
-                       title="<?php echo $lang['nc_query']; ?>">&nbsp;</a>
-                    <?php if ($output['mch_name'] != '') { ?>
-                        <a href="index.php?act=OrderStats&op=index" class="btns "
-                           title="<?php echo $lang['nc_cancel_search']; ?>"><span><?php echo $lang['nc_cancel_search']; ?></span></a>
-                    <?php } ?></td>
-<!--                <td>-->
-<!--                    <a href="javascript:void(0);" id="ncexport" class="btn">-->
-<!--                        <span>导出</span>-->
-<!--                    </a>-->
-<!--                </td>-->
-            </tr>
+                <tr>
+                    <th><label for="query_start_time">结余统计时间</label></th>
+                    <td>
+                        <input class="txt date" type="text" value="<?php echo $_GET['query_start_time']; ?>" id="startTime" name="query_start_time" autocomplete="off" style="width:120px" />
+                        <label for="query_start_time">~</label>
+                        <input class="txt date" type="text" value="<?php echo $_GET['query_end_time']; ?>" id="endTime" name="query_end_time" autocomplete="off" style="width:120px" />
+                    </td>
+                    <td>
+                    <th><label>统计日期类型</label></th>
+                    <td>
+                        <select name="order_time_type" id="order_time_type">
+                            <option value="">请选择...</option>
+                            <option value="notify_time" <?php if ($_GET['order_time_type'] == 'notify_time') {
+                                                            echo 'selected';
+                                                        } ?>>回调日期</option>
+                            <option value="order_time" <?php if ($_GET['order_time_type'] == 'order_time') {
+                                                            echo 'selected';
+                                                        } ?>>下单日期</option>
+                        </select>
+                    </td>
+                    </td>
+                    <td><a href="javascript:void(0);" id="ncsubmit" class="btn-search " title="<?php echo $lang['nc_query']; ?>">&nbsp;</a>
+                        <?php if ($output['mch_name'] != '') { ?>
+                            <a href="index.php?act=OrderStats&op=index" class="btns " title="<?php echo $lang['nc_cancel_search']; ?>"><span><?php echo $lang['nc_cancel_search']; ?></span></a>
+                        <?php } ?>
+                    </td>
+                    <td>
+                        <a href="javascript:void(0);" id="create" class="btn">
+                            <span>新建</span>
+                        </a>
+                    </td>
+                </tr>
             </tbody>
         </table>
     </form>
-<!--       <table class="table tb-type2" id="prompt">-->
-<!--        <tbody>-->
-<!--          <tr class="space odd">-->
-<!--            <th colspan="12"><div class="title">-->
-<!--                <h5>总量统计</h5>-->
-<!--                <span class="arrow"></span></div></th>-->
-<!--          </tr>-->
-<!--          <tr>-->
-<!--            <td class="row_q">-->
-<!--                <ul class="row_w">-->
-<!--                    <li>回调日期统计</li>-->
-<!--                    <li class="lineLi" style="color:#000;">总计成功订单量: --><?php //echo $output['total_stats']['notify_time']['success_count_total'] ?? 0?><!--</li>-->
-<!--                    <li class="lineLi" style="color:#000;">总计成功订单金额:--><?php //echo $output['total_stats']['notify_time']['success_refill_amounts_total'] ?? 0?><!--</li>-->
-<!--                    <li class="lineLi" style="color:#000;">总计下游扣款金额:--><?php //echo $output['total_stats']['notify_time']['success_mch_amounts_toatl'] ?? 0?><!--</li>-->
-<!--                    <li class="lineLi" style="color:#000;">总计上游扣款金额:--><?php //echo $output['total_stats']['notify_time']['success_channel_amounts_total'] ?? 0?><!--</li>-->
-<!--                    <li class="lineLi" style="color:#000;">总计利润:--><?php //echo $output['total_stats']['notify_time']['profit_amounts_total'] ?? 0?><!--</li>-->
-<!--                </ul>-->
-<!--                <ul>-->
-<!--                    <li>下单日期统计</li>-->
-<!--                    <li class="lineLi" style="color:#000;">总计成功订单量: --><?php //echo $output['total_stats']['order_time']['success_count_total'] ?? 0?><!--</li>-->
-<!--                    <li class="lineLi" style="color:#000;">总计成功订单金额:--><?php //echo $output['total_stats']['order_time']['success_refill_amounts_total'] ?? 0?><!--</li>-->
-<!--                    <li class="lineLi" style="color:#000;">总计下游扣款金额:--><?php //echo $output['total_stats']['order_time']['success_mch_amounts_toatl'] ?? 0?><!--</li>-->
-<!--                    <li class="lineLi" style="color:#000;">总计上游扣款金额:--><?php //echo $output['total_stats']['order_time']['success_channel_amounts_total'] ?? 0?><!--</li>-->
-<!--                    <li class="lineLi" style="color:#000;">总计利润:--><?php //echo $output['total_stats']['order_time']['profit_amounts_total'] ?? 0?><!--</li>-->
-<!--                </ul>-->
-<!--            </td>-->
-<!--          </tr>-->
-<!--        </tbody>-->
-<!--      </table>-->
-    <form method="post" id="merchant_name_form">
-        <input type="hidden" name="form_submit" value="ok"/>
-        <table class="table tb-type2">
-            <thead>
-            <tr class="thead">
-                <th>记录ID</th>
-                <th>父ID</th>
-                <th>主体名称</th>
-                <th class="align-left">统计开始日期</th>
-                <th class="align-left">统计结束日期</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>
-                <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-left">备注</th>
-                <!--                <th class="align-center">操作</th>-->
-            </tr>
-            </thead>
-            <tbody>
-            <?php if (!empty($output['stats_list']) && is_array($output['stats_list'])) { ?>
-                <?php foreach ($output['stats_list'] as $k => $v) { ?>
-                    <tr class="trFlex">
-                        <td><?php echo $v['balance_id']; ?></td>
-                        <td><?php echo $v['parent_id']; ?></td>
-                        <td><?php echo $v['cname']; ?></td>
-                        <td class="align-left"><?php echo $v['start_stamp'] ? date('Y-m-d H:i', $v['start_stamp']) : '/'; ?></td>
-                        <td class="align-left"><?php echo $v['end_text']; ?></td>
-                        <td class="align-center"><?php echo $v['success_count']; ?></td>
-                        <td class="align-center"><?php echo $v['refill_amount']; ?></td>
-                        <td class="align-center"><?php echo $v['mch_amount']; ?></td>
-                        <td class="align-center"><?php echo $v['channel_amount']; ?></td>
-                        <td class="align-center"><?php echo $v['profit_amount']; ?></td>
-                        <td class="align-center"><?php echo $v['transfer_in']; ?></td>
-                        <td class="align-center"><?php echo $v['transfer_out']; ?></td>
-                        <td class="align-center"><?php echo $v['refund_amount']; ?></td>
-                        <td class="align-center"><?php echo $v['except_amount']; ?></td>
-                        <td class="align-center"><?php echo $v['accumulate_balance']; ?></td>
-                        <td class="align-center"><?php echo $v['balance']; ?></td>
-                        <td class="align-left"><?php echo date("Y-m-d H:i:s", $v['update_time']); ?></td>
-                        <td class="align-center">
-                            <?php if($v['confirmed'] == 0){?>
-                                <span style="color: #fd9d0e">未确认</span>
-                            <?php }else{?>
-                                <span style="color: #0bb20c">已确认</span>
-                            <?php }?>
+    <!--       <table class="table tb-type2" id="prompt">-->
+    <!--        <tbody>-->
+    <!--          <tr class="space odd">-->
+    <!--            <th colspan="12"><div class="title">-->
+    <!--                <h5>总量统计</h5>-->
+    <!--                <span class="arrow"></span></div></th>-->
+    <!--          </tr>-->
+    <!--          <tr>-->
+    <!--            <td class="row_q">-->
+    <!--                <ul class="row_w">-->
+    <!--                    <li>回调日期统计</li>-->
+    <!--                    <li class="lineLi" style="color:#000;">总计成功订单量: --><?php //echo $output['total_stats']['notify_time']['success_count_total'] ?? 0
+                                                                                ?>
+    <!--</li>-->
+    <!--                    <li class="lineLi" style="color:#000;">总计成功订单金额:--><?php //echo $output['total_stats']['notify_time']['success_refill_amounts_total'] ?? 0
+                                                                                ?>
+    <!--</li>-->
+    <!--                    <li class="lineLi" style="color:#000;">总计下游扣款金额:--><?php //echo $output['total_stats']['notify_time']['success_mch_amounts_toatl'] ?? 0
+                                                                                ?>
+    <!--</li>-->
+    <!--                    <li class="lineLi" style="color:#000;">总计上游扣款金额:--><?php //echo $output['total_stats']['notify_time']['success_channel_amounts_total'] ?? 0
+                                                                                ?>
+    <!--</li>-->
+    <!--                    <li class="lineLi" style="color:#000;">总计利润:--><?php //echo $output['total_stats']['notify_time']['profit_amounts_total'] ?? 0
+                                                                            ?>
+    <!--</li>-->
+    <!--                </ul>-->
+    <!--                <ul>-->
+    <!--                    <li>下单日期统计</li>-->
+    <!--                    <li class="lineLi" style="color:#000;">总计成功订单量: --><?php //echo $output['total_stats']['order_time']['success_count_total'] ?? 0
+                                                                                ?>
+    <!--</li>-->
+    <!--                    <li class="lineLi" style="color:#000;">总计成功订单金额:--><?php //echo $output['total_stats']['order_time']['success_refill_amounts_total'] ?? 0
+                                                                                ?>
+    <!--</li>-->
+    <!--                    <li class="lineLi" style="color:#000;">总计下游扣款金额:--><?php //echo $output['total_stats']['order_time']['success_mch_amounts_toatl'] ?? 0
+                                                                                ?>
+    <!--</li>-->
+    <!--                    <li class="lineLi" style="color:#000;">总计上游扣款金额:--><?php //echo $output['total_stats']['order_time']['success_channel_amounts_total'] ?? 0
+                                                                                ?>
+    <!--</li>-->
+    <!--                    <li class="lineLi" style="color:#000;">总计利润:--><?php //echo $output['total_stats']['order_time']['profit_amounts_total'] ?? 0
+                                                                            ?>
+    <!--</li>-->
+    <!--                </ul>-->
+    <!--            </td>-->
+    <!--          </tr>-->
+    <!--        </tbody>-->
+    <!--      </table>-->
+    <div style="width:100%;overflow-x:auto;">
+        <script>
+            var stats_list_data = <?php echo json_encode($output['stats_list'])  ?>
+        </script>
+        <form method="post" id="merchant_name_form">
+            <input type="hidden" name="form_submit" value="ok" />
+            <table class="table tb-type2" style="width:2500px;white-space: nowrap;">
+                <thead>
+                    <tr class="thead">
+                        <th>记录ID</th>
+                        <th>父ID</th>
+                        <th>主体名称</th>
+                        <th class="align-left">统计开始日期</th>
+                        <th class="align-left">统计结束日期</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>
+                        <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-left">备注</th>
+                        <th class="align-center">操作</th>
+                    </tr>
+                </thead>
+                <tbody>
+                    <?php if (!empty($output['stats_list']) && is_array($output['stats_list'])) { ?>
+                        <?php foreach ($output['stats_list'] as $k => $v) { ?>
+                            <tr class="trFlex">
+                                <td><?php echo $v['balance_id']; ?></td>
+                                <td><?php echo $v['parent_id']; ?></td>
+                                <td><?php echo $v['cname']; ?></td>
+                                <td class="align-left"><?php echo $v['start_stamp'] ? date('Y-m-d H:i', $v['start_stamp']) : '/'; ?></td>
+                                <td class="align-left"><?php echo $v['end_text']; ?></td>
+                                <td class="align-center"><?php echo $v['success_count']; ?></td>
+                                <td class="align-center"><?php echo $v['refill_amount']; ?></td>
+                                <td class="align-center"><?php echo $v['mch_amount']; ?></td>
+                                <td class="align-center"><?php echo $v['channel_amount']; ?></td>
+                                <td class="align-center"><?php echo $v['profit_amount']; ?></td>
+                                <td class="align-center"><?php echo $v['transfer_in']; ?></td>
+                                <td class="align-center"><?php echo $v['transfer_out']; ?></td>
+                                <td class="align-center"><?php echo $v['refund_amount']; ?></td>
+                                <td class="align-center"><?php echo $v['except_amount']; ?></td>
+                                <td class="align-center"><?php echo $v['accumulate_balance']; ?></td>
+                                <td class="align-center"><?php echo $v['balance']; ?></td>
+                                <td class="align-left"><?php echo date("Y-m-d H:i:s", $v['update_time']); ?></td>
+                                <td class="align-center">
+                                    <?php if ($v['confirmed'] == 0) { ?>
+                                        <span style="color: #fd9d0e">未确认</span>
+                                    <?php } else { ?>
+                                        <span style="color: #0bb20c">已确认</span>
+                                    <?php } ?>
+                                </td>
+                                <td class="align-center"><?php echo $output['order_time_type_text'][$v['time_type']]; ?></td>
+                                <td class="align-left"><?php echo $v['remark']; ?></td>
+                                <td style="color:#069;">
+                                    <a style="color:#0D93BF;" href="javascript:void(0)" data-index="<?php echo $k ?>" data-balance_id="<?php echo $v['balance_id']; ?>" class="item_create_btn">新建</a>
+                                    <span>|</span>
+                                    <a style="color:#0D93BF;" href="javascript:void(0)" data-index="<?php echo $k ?>" class="handleBtn">编辑</a>
+                                    <span>|</span>
+                                    <a style="margin:0 5px;color:#0D93BF;" href="index.php?act=orderstats&op=refill_balance_rebuild&balance_id=<?php echo $v['balance_id']; ?>" data-index="<?php echo $k ?>" class="rebuildBtn">重新生成</a>
+                                    <?php if ($v['confirmed'] == 0) { ?>
+                                        <span>|</span>
+                                        <a style="color:#0D93BF;" href="index.php?act=orderstats&op=refill_balance_confirm&balance_id=<?php echo $v['balance_id']; ?>" data-index="<?php echo $k ?>" class="checkBtn">确认</a>
+                                    <?php } ?>
+                                </td>
+                                <!--                        <td class="align-center w200">-->
+                                <!--                            <a href="index.php?act=merchant&op=OrderStatsReload&stat_id=--><?php //echo $v['stat_id'];
+                                                                                                                                ?>
+                                <!--">重新统计</a>-->
+                                <!--                        </td>-->
+                            </tr>
+                        <?php } ?>
+                    <?php } else { ?>
+                        <tr class="no_data">
+                            <td colspan="19"><?php echo $lang['nc_no_record']; ?></td>
+                        </tr>
+                    <?php } ?>
+                </tbody>
+                <tfoot>
+                    <tr class="tfoot">
+                        <td></td>
+                        <td colspan="20">
+                            <div class="pagination"><?php echo $output['show_page']; ?></div>
                         </td>
-                        <td class="align-center"><?php echo $output['order_time_type_text'][$v['time_type']]; ?></td>
-                        <td class="align-left"><?php echo $v['remark']; ?></td>
-                        <!--                        <td class="align-center w200">-->
-<!--                            <a href="index.php?act=merchant&op=OrderStatsReload&stat_id=--><?php //echo $v['stat_id'];?><!--">重新统计</a>-->
-<!--                        </td>-->
                     </tr>
-                <?php } ?>
-            <?php } else { ?>
-                <tr class="no_data">
-                    <td colspan="19"><?php echo $lang['nc_no_record']; ?></td>
-                </tr>
-            <?php } ?>
-            </tbody>
-            <tfoot>
-            <tr class="tfoot">
-                <td></td>
-                <td colspan="19">
-                    <div class="pagination"><?php echo $output['show_page']; ?></div>
-                </td>
-            </tr>
-            </tfoot>
-        </table>
-    </form>
+                </tfoot>
+            </table>
+        </form>
+    </div>
 </div>
 <script type="text/javascript" src="<?php echo RESOURCE_SITE_URL; ?>/js/jquery.edit.js" charset="utf-8"></script>
 <script type="text/javascript" src="<?php echo RESOURCE_SITE_URL; ?>/laydate/laydate.js"></script>
+<script type="text/javascript" src="<?php echo ADMIN_TEMPLATES_URL; ?>/layui/layui.js"></script>
+<script type="text/javascript" src="<?php echo RESOURCE_SITE_URL; ?>/refill/layer.js"></script>
+<link rel="stylesheet" type="text/css" href="<?php echo ADMIN_TEMPLATES_URL; ?>/layui/css/layui.css" />
+
 <script>
-    $(function () {
-        $('#ncsubmit').click(function () {
+    $(function() {
+
+        $('#create').on('click', function() {
+            var selectEndDate = '';
+            layui.use(['layer', 'laydate'], function() {
+                const selectDateHTML = '<label class="createTaskDate"><span>结束日期:</span><input type="text" class="layui-input" id="createDate"></label>'
+                layer.confirm(selectDateHTML, {
+                    title: '新建'
+                }, function(index) {
+                    console.log('确认')
+                    if (!selectEndDate) {
+                        layer.msg('请选择结束日期');
+                        return;
+                    }
+                    var index = layer.load();
+                    $.ajax({
+                        url: `index.php?act=orderstats&op=refill_balance_stat_all`,
+                        data: {
+                            selectEndDate
+                        },
+                        dataType: 'json',
+                        mothod: 'get',
+                        success: function(res) {
+                            layer.close(index);
+                            console.log('success', res);
+                            if (res.code) {
+                                layer.msg(res.msg)
+                            } else {
+                                layer.alert(res.msg)
+                            }
+                        }
+                    })
+                    layer.close(index);
+                }, function() {
+                    console.log('取消')
+                });
+
+
+                laydate.render({
+                    elem: '#createDate',
+                    type: 'datetime',
+                    done: function(value) {
+                        console.log('选中的日期...', value)
+                        selectEndDate = value;
+                    }
+                });
+
+            })
+            // 
+        })
+
+
+        $('.item_create_btn').on('click', function() {
+            var selectStartDate = '';
+            var selectEndDate = '';
+            var balance_id = $(this).attr('data-balance_id');
+            layui.use(['layer', 'laydate'], function() {
+                const selectDateHTML = `<label class="createTaskDate"><span>开始日期:</span><input type="text" class="layui-input" id="createItemStartDate"></label>
+                                        <label class="createTaskDate"><span>结束日期:</span><input type="text" class="layui-input" id="createItemEndDate"></label>`
+                layer.confirm(selectDateHTML, {
+                    title: '新建'
+                }, function(index) {
+                    console.log('确认')
+                    if (!selectStartDate) {
+                        layer.msg('请选择开始日期');
+                        return;
+                    }
+                    if (!selectEndDate) {
+                        layer.msg('请选择结束日期');
+                        return;
+                    }
+                    console.log(balance_id, selectStartDate, selectEndDate)
+                    var index = layer.load();
+                    $.ajax({
+                        url: `index.php?act=orderstats&op=refill_balance_create`,
+                        data: {
+                            balance_id,
+                            selectStartDate,
+                            selectEndDate
+                        },
+                        dataType: 'json',
+                        mothod: 'get',
+                        success: function(res) {
+                            layer.close(index);
+                            console.log('success', res);
+                            if (res.code) {
+                                layer.msg(res.msg)
+                            } else {
+                                layer.alert(res.msg)
+                            }
+                        }
+                    })
+                    layer.close(index);
+                }, function() {
+                    console.log('取消')
+                });
+
+                laydate.render({
+                    elem: '#createItemStartDate',
+                    type: 'datetime',
+                    done: function(value) {
+                        console.log('选中的开始日期...', value)
+                        selectStartDate = value;
+                    }
+                });
+
+                laydate.render({
+                    elem: '#createItemEndDate',
+                    type: 'datetime',
+                    done: function(value) {
+                        console.log('选中的结束日期...', value)
+                        selectEndDate = value;
+                    }
+                });
+
+            })
+        })
+
+        $('.handleBtn').on('click', function() {
+            var index = $(this).attr('data-index');
+            var data = stats_list_data[index];
+            layui.use(['form', 'layer'], function() {
+                var layer = layui.layer;
+                var form = layui.form;
+                layer.confirm(`
+                    <div>
+                        <form class="layui-form" action="">
+                            <div class="layui-form-item">
+                                <label class="layui-form-label">记录ID</label>
+                                <div class="layui-input-block">
+                                    <input type="text" value="${data.balance_id}" style="height:38px;" disabled name="title" required  lay-verify="required" placeholder="记录ID" autocomplete="off" class="layui-input">
+                                </div>
+                            </div>
+                            <div class="layui-form-item">
+                                <label class="layui-form-label">父ID</label>
+                                <div class="layui-input-block">
+                                    <input type="text" value="${data.parent_id}" style="height:38px;" disabled name="title" required  lay-verify="required" placeholder="父ID" autocomplete="off" class="layui-input">
+                                </div>
+                            </div>
+                            <div class="layui-form-item">
+                                <label class="layui-form-label">主体名称</label>
+                                <div class="layui-input-block">
+                                    <input type="text" value="${data.cname}" style="height:38px;" disabled name="title" required  lay-verify="required" placeholder="主体名称" autocomplete="off" class="layui-input">
+                                </div>
+                            </div>
+                        
+                        </form>
+                    </div>`, {
+                    area: '500px',
+                    title: '编辑'
+                }, function(index) {
+                    alert('点击了确定')
+                })
+                // layer.open({
+                //     area: '500px',
+                //     type: 1,
+                //     title: '编辑',
+                //     content: 
+                // })
+                form.render();
+
+            })
+        })
+
+
+        $('#ncsubmit').click(function() {
             $('#formSearch').submit();
         });
         // 日期选择器
@@ -189,103 +445,104 @@
             type: 'datetime'
         });
         // 表格hover时背景
-        $('.trFlex').each(function () {
-            $(this).hover(function () {
+        $('.trFlex').each(function() {
+            $(this).hover(function() {
                 $(this)[0].style.backgroundColor = '#cbe9f3'
-            },function() {
+            }, function() {
                 $(this)[0].style.backgroundColor = '#fff'
             })
         })
-        function JSONToExcelConvertor(JSONData, FileName, ShowLabel, headData) { 
+
+        function JSONToExcelConvertor(JSONData, FileName, ShowLabel, headData) {
             //先转化json 
-            let arrData = typeof JSONData != 'object' ? JSON.parse(JSONData) : JSONData; 
-            let excel = '<table>';   
+            let arrData = typeof JSONData != 'object' ? JSON.parse(JSONData) : JSONData;
+            let excel = '<table>';
             // 标题
             for (const key in headData) {
                 var head = "<tr>";
-                var td = "<td colspan='13' style='font-size:16px;'>"+ headData[key] + '</td>';
+                var td = "<td colspan='13' style='font-size:16px;'>" + headData[key] + '</td>';
                 excel += td + "</tr>";
             }
             //设置表头 
-            let row = "<tr>"; 
-            for (var i = 0, l = ShowLabel.length; i < l; i++) { 
-                row += "<th style='font-size:14px;'>" + ShowLabel[i].value + '</th>'; 
+            let row = "<tr>";
+            for (var i = 0, l = ShowLabel.length; i < l; i++) {
+                row += "<th style='font-size:14px;'>" + ShowLabel[i].value + '</th>';
             }
             //换行 
-            excel += row + "</tr>"; 
+            excel += row + "</tr>";
             //设置数据 
-            for (var i = 0; i < arrData.length; i++) { 
+            for (var i = 0; i < arrData.length; i++) {
                 var tr = "<tr>";
-                let code = i+1
-                tr += "<td>" +code+ "</td>"
-                tr += '<td style=font-size:14px;'+ 'mso-number-format:"\@"'+ '>' + arrData[i].time_text + '</td>';
-                tr += '<td style=font-size:14px;'+ 'mso-number-format:"\@"'+ '>' + arrData[i].cname + '</td>';
-                tr += '<td style=font-size:14px;'+ 'mso-number-format:"\@"'+ '>' + arrData[i].cid + '</td>';
-                tr += '<td style=font-size:14px;'+ 'mso-number-format:"\@"'+ '>' + arrData[i].success_count + '</td>';
-                tr += '<td style=font-size:14px;'+ 'mso-number-format:"\@"'+ '>' + arrData[i].success_refill_amounts + '</td>';
-                tr += '<td style=font-size:14px;'+ 'mso-number-format:"\@"'+ '>' + arrData[i].success_mch_amounts + '</td>';
-                tr += '<td style=font-size:14px;'+ 'mso-number-format:"\@"'+ '>' + arrData[i].success_channel_amounts + '</td>';
-                tr += '<td style=font-size:14px;'+ 'mso-number-format:"\@"'+ '>' + arrData[i].profit_amounts + '</td>';
-                tr += '<td style=font-size:14px;'+ 'mso-number-format:"\@"'+ '>' + arrData[i].service_amounts + '</td>';
-                tr += '<td style=font-size:14px;'+ 'mso-number-format:"\@"'+ '>' + arrData[i].order_count + '</td>';
-                tr += '<td style=font-size:14px;'+ 'mso-number-format:"\@"'+ '>' + arrData[i].cancel_count + '</td>';
-                tr += '<td style=font-size:14px;'+ 'mso-number-format:"\@"'+ '>' + arrData[i].success_ratio + '</td>';
+                let code = i + 1
+                tr += "<td>" + code + "</td>"
+                tr += '<td style=font-size:14px;' + 'mso-number-format:"\@"' + '>' + arrData[i].time_text + '</td>';
+                tr += '<td style=font-size:14px;' + 'mso-number-format:"\@"' + '>' + arrData[i].cname + '</td>';
+                tr += '<td style=font-size:14px;' + 'mso-number-format:"\@"' + '>' + arrData[i].cid + '</td>';
+                tr += '<td style=font-size:14px;' + 'mso-number-format:"\@"' + '>' + arrData[i].success_count + '</td>';
+                tr += '<td style=font-size:14px;' + 'mso-number-format:"\@"' + '>' + arrData[i].success_refill_amounts + '</td>';
+                tr += '<td style=font-size:14px;' + 'mso-number-format:"\@"' + '>' + arrData[i].success_mch_amounts + '</td>';
+                tr += '<td style=font-size:14px;' + 'mso-number-format:"\@"' + '>' + arrData[i].success_channel_amounts + '</td>';
+                tr += '<td style=font-size:14px;' + 'mso-number-format:"\@"' + '>' + arrData[i].profit_amounts + '</td>';
+                tr += '<td style=font-size:14px;' + 'mso-number-format:"\@"' + '>' + arrData[i].service_amounts + '</td>';
+                tr += '<td style=font-size:14px;' + 'mso-number-format:"\@"' + '>' + arrData[i].order_count + '</td>';
+                tr += '<td style=font-size:14px;' + 'mso-number-format:"\@"' + '>' + arrData[i].cancel_count + '</td>';
+                tr += '<td style=font-size:14px;' + 'mso-number-format:"\@"' + '>' + arrData[i].success_ratio + '</td>';
                 excel += tr + "</tr>";
-            } 
-                excel += "</table>"; 
-                var excelFile = "<html xmlns:o='urn:schemas-microsoft-com:office:office' xmlns:x='urn:schemas-microsoft-com:office:excel' xmlns='http://www.w3.org/TR/REC-html40'>"; 
-                excelFile += '<meta http-equiv="content-type" content="application/vnd.ms-excel; charset=UTF-8">'; 
-                excelFile += '<meta http-equiv="content-type" content="application/vnd.ms-excel'; 
-                excelFile += '; charset=UTF-8">'; 
-                excelFile += "<head>"; 
-                excelFile += "<!--[if gte mso 9]>";
-                excelFile += "<xml>";
-                excelFile += "<x:ExcelWorkbook>"; 
-                excelFile += "<x:ExcelWorksheets>"; 
-                excelFile += "<x:ExcelWorksheet>"; 
-                excelFile += "<x:Name>"; 
-                excelFile += "{worksheet}"; 
-                excelFile += "</x:Name>"; 
-                excelFile += "<x:WorksheetOptions>"; 
-                excelFile += "<x:DisplayGridlines/>"; 
-                excelFile += "</x:WorksheetOptions>"; 
-                excelFile += "</x:ExcelWorksheet>"; 
-                excelFile += "</x:ExcelWorksheets>"; 
-                excelFile += "</x:ExcelWorkbook>"; 
-                excelFile += "</xml>"; 
-                excelFile += "<![endif]-->"; 
-                excelFile += "</head>"; 
-                excelFile += "<body>"; 
-                excelFile += excel; 
-                excelFile += "</body>"; 
-                excelFile += "</html>"; 
-                var uri = 'data:application/vnd.ms-excel;charset=utf-8,' + encodeURIComponent(excelFile); 
-                var link = document.createElement("a");   
-                link.href = uri; 
-                link.style = "visibility:hidden"; 
-                link.download = FileName + ".xls"; 
-                document.body.appendChild(link); 
-                link.click(); 
-                document.body.removeChild(link); 
+            }
+            excel += "</table>";
+            var excelFile = "<html xmlns:o='urn:schemas-microsoft-com:office:office' xmlns:x='urn:schemas-microsoft-com:office:excel' xmlns='http://www.w3.org/TR/REC-html40'>";
+            excelFile += '<meta http-equiv="content-type" content="application/vnd.ms-excel; charset=UTF-8">';
+            excelFile += '<meta http-equiv="content-type" content="application/vnd.ms-excel';
+            excelFile += '; charset=UTF-8">';
+            excelFile += "<head>";
+            excelFile += "<!--[if gte mso 9]>";
+            excelFile += "<xml>";
+            excelFile += "<x:ExcelWorkbook>";
+            excelFile += "<x:ExcelWorksheets>";
+            excelFile += "<x:ExcelWorksheet>";
+            excelFile += "<x:Name>";
+            excelFile += "{worksheet}";
+            excelFile += "</x:Name>";
+            excelFile += "<x:WorksheetOptions>";
+            excelFile += "<x:DisplayGridlines/>";
+            excelFile += "</x:WorksheetOptions>";
+            excelFile += "</x:ExcelWorksheet>";
+            excelFile += "</x:ExcelWorksheets>";
+            excelFile += "</x:ExcelWorkbook>";
+            excelFile += "</xml>";
+            excelFile += "<![endif]-->";
+            excelFile += "</head>";
+            excelFile += "<body>";
+            excelFile += excel;
+            excelFile += "</body>";
+            excelFile += "</html>";
+            var uri = 'data:application/vnd.ms-excel;charset=utf-8,' + encodeURIComponent(excelFile);
+            var link = document.createElement("a");
+            link.href = uri;
+            link.style = "visibility:hidden";
+            link.download = FileName + ".xls";
+            document.body.appendChild(link);
+            link.click();
+            document.body.removeChild(link);
         }
-        $('#ncexport').click(function () {
-            let starTime = new Date($('input[name="query_start_time"]').val()).getTime()/1000;
-            let endTime = new Date($('input[name="query_end_time"]').val()).getTime()/1000;
+        $('#ncexport').click(function() {
+            let starTime = new Date($('input[name="query_start_time"]').val()).getTime() / 1000;
+            let endTime = new Date($('input[name="query_end_time"]').val()).getTime() / 1000;
             let order_time_type = $('#order_time_type').val();
             $.get('index.php?act=orderstats&op=ExportData', {
                 query_start_time: starTime,
                 query_end_time: endTime,
-                order_time_type:order_time_type
-            }, function (data) {
+                order_time_type: order_time_type
+            }, function(data) {
                 data = JSON.parse(data)
                 if (data && data.data) {
                     let head = ['北京椰子电子商务有限责任公司']
                     let time = ''
                     if (starTime && endTime) {
-                        time = '统计时间:'+$('input[name="query_start_time"]').val()+' - '+$('input[name="query_end_time"]').val()
+                        time = '统计时间:' + $('input[name="query_start_time"]').val() + ' - ' + $('input[name="query_end_time"]').val()
                         head.push(time)
                     } else if (starTime) {
-                        time = '统计时间:'+$('input[name="query_start_time"]').val()
+                        time = '统计时间:' + $('input[name="query_start_time"]').val()
                         head.push(time)
                     }
                     head.push('总计成功订单数量:' + parseInt(data.total_stats.success_count_total))
@@ -293,10 +550,36 @@
                     head.push('总计下游扣款金额:' + parseFloat(data.total_stats.success_mch_amounts_toatl))
                     head.push('总计上游扣款金额:' + parseFloat(data.total_stats.success_channel_amounts_total))
                     head.push('总计利润金额:' + parseFloat(data.total_stats.profit_amounts_total))
-                    let title = [{value: "序号"},{value: "统计日期"},{value: "主体名称"},{value: "主体ID"},{value: "成功订单数"},{value: "成功金额"},{value: "下游金额"},{value: "上游金额"},{value: "利润"},{value: "服务费"},{value: "订单总量"}, {value: "失败订单数量"},{value: "成功占比"}]
+                    let title = [{
+                        value: "序号"
+                    }, {
+                        value: "统计日期"
+                    }, {
+                        value: "主体名称"
+                    }, {
+                        value: "主体ID"
+                    }, {
+                        value: "成功订单数"
+                    }, {
+                        value: "成功金额"
+                    }, {
+                        value: "下游金额"
+                    }, {
+                        value: "上游金额"
+                    }, {
+                        value: "利润"
+                    }, {
+                        value: "服务费"
+                    }, {
+                        value: "订单总量"
+                    }, {
+                        value: "失败订单数量"
+                    }, {
+                        value: "成功占比"
+                    }]
                     JSONToExcelConvertor(data.data, '平台对账记录', title, head)
                 }
             })
         })
     });
-</script>
+</script>

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

@@ -113,4 +113,5 @@ $config['client_setting'] = ['running' => 174,'home' => 0];
 $config['wsd_bradge_port'] = 60987;
 $config['card_key_stores'] = [6];
 
-$config['phone_life_check'] = true;
+$config['phone_life_check'] = true;
+$config['admin_layout_skin'] = 'skin_0';

+ 8 - 8
data/config/xyz/refill.ini.php

@@ -2489,14 +2489,14 @@ $sialan_tax_phone = ['name' => 'sialan_tax', 'store_id' => 119, 'qualitys' => '2
 
 $yunchonggong_yd_phone = ['name' => 'yunchonggong_yd', 'store_id' => 120, 'qualitys' => '1',
     'amount' => [
-        10 => [['goods_id' => 7043, 'price' => 9.54, 'quality' => 1, 'card_type' => 'chinamobile']],
-        20 => [['goods_id' => 7044, 'price' => 19.08, 'quality' => 1, 'card_type' => 'chinamobile']],
-        30 => [['goods_id' => 7045, 'price' => 28.62, 'quality' => 1, 'card_type' => 'chinamobile']],
-        50 => [['goods_id' => 7046, 'price' => 47.7, 'quality' => 1, 'card_type' => 'chinamobile']],
-        100 => [['goods_id' => 7047, 'price' => 95.4, 'quality' => 1, 'card_type' => 'chinamobile']],
-        200 => [['goods_id' => 7048, 'price' => 190.8, 'quality' => 1, 'card_type' => 'chinamobile']],
-        300 => [['goods_id' => 7049, 'price' => 286.2, 'quality' => 1, 'card_type' => 'chinamobile']],
-        500 => [['goods_id' => 7050, 'price' => 477, 'quality' => 1, 'card_type' => 'chinamobile']]
+//        10 => [['goods_id' => 7043, 'price' => 9.55, 'quality' => 1, 'card_type' => 'chinamobile']],
+//        20 => [['goods_id' => 7044, 'price' => 19.1, 'quality' => 1, 'card_type' => 'chinamobile']],
+        30 => [['goods_id' => 7045, 'price' => 28.65, 'quality' => 1, 'card_type' => 'chinamobile']],
+        50 => [['goods_id' => 7046, 'price' => 47.75, 'quality' => 1, 'card_type' => 'chinamobile']],
+        100 => [['goods_id' => 7047, 'price' => 95.5, 'quality' => 1, 'card_type' => 'chinamobile']],
+        200 => [['goods_id' => 7048, 'price' => 191, 'quality' => 1, 'card_type' => 'chinamobile']],
+//        300 => [['goods_id' => 7049, 'price' => 286.5, 'quality' => 1, 'card_type' => 'chinamobile']],
+//        500 => [['goods_id' => 7050, 'price' => 477.5, 'quality' => 1, 'card_type' => 'chinamobile']]
     ],
     'official_sn' => true, 'refill_type' => 'api'];
 

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

@@ -113,4 +113,5 @@ $config['client_setting'] = ['running' => 174,'home' => 0];
 $config['wsd_bradge_port'] = 60987;
 $config['card_key_stores'] = [6];
 
-$config['phone_life_check'] = true;
+$config['phone_life_check'] = true;
+$config['admin_layout_skin'] = 'skin_1';

+ 9 - 9
data/config/yl/refill.ini.php

@@ -2489,14 +2489,14 @@ $sialan_tax_phone = ['name' => 'sialan_tax', 'store_id' => 119, 'qualitys' => '2
 
 $yunchonggong_yd_phone = ['name' => 'yunchonggong_yd', 'store_id' => 120, 'qualitys' => '1',
     'amount' => [
-        10 => [['goods_id' => 7043, 'price' => 9.54, 'quality' => 1, 'card_type' => 'chinamobile']],
-        20 => [['goods_id' => 7044, 'price' => 19.08, 'quality' => 1, 'card_type' => 'chinamobile']],
-        30 => [['goods_id' => 7045, 'price' => 28.62, 'quality' => 1, 'card_type' => 'chinamobile']],
-        50 => [['goods_id' => 7046, 'price' => 47.7, 'quality' => 1, 'card_type' => 'chinamobile']],
-        100 => [['goods_id' => 7047, 'price' => 95.4, 'quality' => 1, 'card_type' => 'chinamobile']],
-        200 => [['goods_id' => 7048, 'price' => 190.8, 'quality' => 1, 'card_type' => 'chinamobile']],
-        300 => [['goods_id' => 7049, 'price' => 286.2, 'quality' => 1, 'card_type' => 'chinamobile']],
-        500 => [['goods_id' => 7050, 'price' => 477, 'quality' => 1, 'card_type' => 'chinamobile']]
+//        10 => [['goods_id' => 7043, 'price' => 9.55, 'quality' => 1, 'card_type' => 'chinamobile']],
+//        20 => [['goods_id' => 7044, 'price' => 19.1, 'quality' => 1, 'card_type' => 'chinamobile']],
+        30 => [['goods_id' => 7045, 'price' => 28.65, 'quality' => 1, 'card_type' => 'chinamobile']],
+        50 => [['goods_id' => 7046, 'price' => 47.75, 'quality' => 1, 'card_type' => 'chinamobile']],
+        100 => [['goods_id' => 7047, 'price' => 95.5, 'quality' => 1, 'card_type' => 'chinamobile']],
+        200 => [['goods_id' => 7048, 'price' => 191, 'quality' => 1, 'card_type' => 'chinamobile']],
+//        300 => [['goods_id' => 7049, 'price' => 286.5, 'quality' => 1, 'card_type' => 'chinamobile']],
+//        500 => [['goods_id' => 7050, 'price' => 477.5, 'quality' => 1, 'card_type' => 'chinamobile']]
     ],
     'official_sn' => true, 'refill_type' => 'api'];
 
@@ -5536,7 +5536,7 @@ $phone_providers = [
     ['name' => 'miaoxt_fs', 'cfg' => $miaoxt_fs_phone],
 //    ['name' => 'xianzhibb', 'cfg' => $xianzhibb_phone],
 //    ['name' => 'yikatong', 'cfg' => $yikatong_phone],
-//    ['name' => 'yunchonggong_yd', 'cfg' => $yunchonggong_yd_phone],
+    ['name' => 'yunchonggong_yd', 'cfg' => $yunchonggong_yd_phone],
     ['name' => 'guochuang_nation', 'cfg' => $guochuang_nation_phone],
 //    ['name' => 'tianyanman', 'cfg' => $tianyanman_phone],
 //    ['name' => 'shimier', 'cfg' => $shimier_phone],

+ 9 - 0
data/model/refill_balance.model.php

@@ -34,4 +34,13 @@ class refill_balanceModel extends Model
         return $this->where($condition)->find();
     }
 
+    public function BalanceConfirm($balance_id)
+    {
+        return $this->where(['balance_id' => $balance_id])->update(['confirmed' => 1]);
+    }
+
+    public function LastConfirm()
+    {
+        return $this->where(['confirmed' => 1, 'type' => 'system'])->order('balance_id desc')->find();
+    }
 }

BIN
favicon.ico


BIN
helper/refill/api/xyz/guochuang/20220425黑龙江移动调价函.jpg


+ 1 - 1
helper/refill/api/xyz/guochuang/config.php

@@ -66,7 +66,7 @@ class config
         "4-10-2" => 10.15, "4-20-2" => 19.92, "4-30-2" => 29.88, "4-50-2" => 49.8, "4-100-2" => 99.6, "4-200-2" => 199.2, "4-300-2" => 298.8, "4-500-2" => 498,//天津 2
         "4-10-6" => 9.75, "4-20-6" => 19.5, "4-30-6" => 29.25, "4-50-6" => 48.75, "4-100-6" => 97.5, "4-200-6" => 195, "4-300-6" => 292.5, "4-500-6" => 487.5,//辽宁 6
         "4-10-9" => 9.94, "4-20-9" => 19.88, "4-30-9" => 29.82, "4-50-9" => 49.7, "4-100-9" => 99.4,//上海 9
-        "4-10-8" => 9.95, "4-20-8" => 19.9, "4-30-8" => 29.85, "4-50-8" => 49.75, "4-100-8" => 99.5, "4-200-8" => 199, "4-300-8" => 298.5, "4-500-8" => 497.5 ,//黑龙江 8
+        "4-10-8" => 9.94, "4-20-8" => 19.88, "4-30-8" => 29.82, "4-50-8" => 49.7, "4-100-8" => 99.4, "4-200-8" => 198.8, "4-300-8" => 298.2, "4-500-8" => 497,//黑龙江 8
         "4-10-29" => 9.76, "4-20-29" => 19.52, "4-30-29" => 29.28, "4-50-29" => 48.8, "4-100-29" => 97.6, "4-200-29" => 195.2, "4-300-29" => 292.8, "4-500-29" => 488,//青海 29
         "4-10-28" => 9.985, "4-20-28" => 19.97, "4-30-28" => 29.955, "4-50-28" => 49.925, "4-100-28" => 99.85, "4-200-28" => 199.7, "4-300-28" => 299.55, "4-500-28" => 499.25,//甘肃 28
         "4-10-13" => 10.22, "4-20-13" => 19.94, "4-30-13" => 29.91, "4-50-13" => 49.85, "4-100-13" => 99.7, "4-200-13" => 199.4, "4-300-13" => 300.9, "4-500-13" => 501.5,//福建 13

+ 33 - 17
helper/refill/api/xyz/yunchonggong_yd/RefillCallBack.php

@@ -8,8 +8,10 @@ class RefillCallBack implements refill\IRefillCallBack
 {
     public function verify($params): bool
     {
-        $sign = $this->sign($params);
-        if ($params['szVerifyString'] == $sign) {
+        $input = $params;
+        unset($input['sign']);
+        $sign = $this->sign($input);
+        if ($params['sign'] == $sign) {
             return true;
         } else {
             return false;
@@ -18,33 +20,47 @@ class RefillCallBack implements refill\IRefillCallBack
 
     private function sign($params)
     {
-        $userid = config::USER_ID;
-        $key = config::KEY;
-        $content = "szAgentId={$userid}&szOrderId={$params['szOrderId']}&szPhoneNum={$params['szPhoneNum']}&nDemo={$params['nDemo']}&fSalePrice={$params['fSalePrice']}";
-        $content .= "&nFlag={$params['nFlag']}&szKey={$key}";
+        $params['appSecret'] = config::APP_SECRET;
+        ksort($params);
+        $content = '';
+        foreach ($params as $key => $value) {
+            if($this->check_empty($value) === false) {
+                $content .= "{$key}={$value}&";
+            }
+        }
+        $content = rtrim($content, '&');
         return md5($content);
     }
 
+    private function check_empty($value)
+    {
+        if (!isset($value))
+            return true;
+        if ($value === null)
+            return true;
+        if (trim($value) === "")
+            return true;
+
+        return false;
+    }
+
     public function notify($params)
     {
-        $status = intval($params['nFlag']);
-        $order_sn = $params['szOrderId'];
+        $status = intval($params['orderStatus']);
+        $order_sn = $params['outOrderId'];
         $order_info = Model('vr_order')->getOrderInfo(['order_sn' => $order_sn]);
         if (empty($order_info)) {
             return [false, false, false,false];
         }
         $order_id = $order_info['order_id'];
-
         if ($status === 2) {
-            $data['official_sn'] = strtolower($params['szRtnMsg']) == 'null' ? '' : $params['szRtnMsg'];
+            $data['official_sn'] = strtolower($params['ext1']) == 'null' ? '' : $params['ext1'];
             Model('refill_order')->edit($order_id, $data);
-            return [$order_id, true, false,true];
-        }
-        elseif ($status === 3) {
-            return [$order_id, false, true,true];
-        }
-        else {
-            return [$order_id, false, false,false];
+            return [$order_id, true, false, true];
+        } elseif ($status === 3) {
+            return [$order_id, false, true, true];
+        } else {
+            return [$order_id, false, false, false];
         }
     }
 }

+ 70 - 55
helper/refill/api/xyz/yunchonggong_yd/RefillPhone.php

@@ -16,15 +16,14 @@ class RefillPhone extends refill\IRefillPhone
 
     private function req_params(int $phone, int $amount, int $card_type, string $order_sn)
     {
-        $params['szAgentId'] = config::USER_ID;
-        $params['szOrderId'] = $order_sn;
-        $params['szPhoneNum'] = $phone;
-        $params['nMoney'] = $amount;
-        $params['nSortType'] = config::operator[$card_type];
-        $params['nProductClass'] = 1;
-        $params['nProductType'] = 1;
-        $params['szTimeStamp'] = date("Y-m-d H:i:s");
-        $params['szNotifyUrl'] = config::NOTIFY_URL;
+        $params['appId'] = config::APP_ID;
+        $params['outOrderId'] = $order_sn;
+        $params['uuid'] = $phone;
+        $params['itemId'] = config::PRODUCT[$card_type][$amount];
+        $params['itemFace'] = $amount;
+        $params['amount'] = 1;
+        $params['callbackUrl'] = config::NOTIFY_URL;
+        $params['timestamp'] = date("YmdHis").$this->get_millisecond();
         return $params;
     }
 
@@ -32,9 +31,11 @@ class RefillPhone extends refill\IRefillPhone
     {
         $order_sn = $params['order_sn'];
         $params = $this->req_params($card_no, $amount, $card_type, $order_sn);
-
+        if(empty($params['itemId'])) {
+            return [false, '商品编号错误', false];
+        }
         $sign = $this->sign($params);
-        $params['szVerifyString'] = $sign;
+        $params['sign'] = $sign;
 
         $resp = http_request(config::ORDER_URL, $params, 'POST', false, config::ExtHeaders, $net_errno);
 
@@ -45,32 +46,28 @@ class RefillPhone extends refill\IRefillPhone
         {
             Log::record($resp, Log::DEBUG);
             $resp = json_decode($resp, true);
-
-            $nRtn = $resp['nRtn'];
             if (empty($resp)) {
                 return [false, '网络错误', true];
-            } elseif ($nRtn === 0) {
-                return [true, '', false];
-            } elseif (in_array($nRtn, config::ERR_NOS, true)) {
-                return [false, $resp['szRtnCode'], false];
-            } elseif (in_array($nRtn, [2050, 999], true)) {
-                $net_errno = "HTTP-{$nRtn}";
-                return [false, $resp['szRtnCode'], true];
+            } elseif ($resp['code'] === '00') {
+                return [true, $resp['orderId'], false];
+            } elseif (in_array($resp['code'], config::ERRCODES, true)) {
+                return [false, $resp['msg'], false];
+            } elseif (in_array($resp['code'], ['-22', '-23', '-99'], true)) {
+                $net_errno = "HTTP-{$resp['code']}";
+                return [false, $resp['msg'], true];
             } else {
-                $err = 998;
-                $net_errno = "HTTP-{$err}";
-                return [false, $resp['szRtnCode'], true];
+                $net_errno = "HTTP-998";
+                return [false, $resp['msg'], true];
             }
         }
     }
 
     public function query($refill_info)
     {
-        $params['szAgentId'] = config::USER_ID;
-        $params['szOrderId'] = $refill_info['order_sn'];
-        $key = config::KEY;
-        $content = "szAgentId={$params['szAgentId']}&szOrderId={$params['szOrderId']}&szKey={$key}";
-        $params['szVerifyString'] = md5($content);
+        $params['appId'] = config::APP_ID;
+        $params['outOrderId'] = $refill_info['order_sn'];
+        $params['timestamp'] = date("YmdHis").$this->get_millisecond();
+        $params['sign'] = $this->sign($params);
 
         $resp = http_request(config::QUERY_URL, $params, 'POST', false, config::ExtHeaders);
 
@@ -84,32 +81,36 @@ class RefillPhone extends refill\IRefillPhone
             if (empty($resp)) {
                 return [false, '网络错误'];
             }
-
-            $status = $resp['nRtn'];
-            if ($status === 5012) {
-                $updata['official_sn'] = $resp['szRtnMsg'];
-                Model('refill_order')->edit($refill_info['order_id'], $updata);
-                $order_state = ORDER_STATE_SUCCESS;
-            } elseif ($status === 5013) {
-                $order_state = ORDER_STATE_CANCEL;
-            } elseif (in_array($status, [5011,5019],true)) {
-                $order_state = ORDER_STATE_SEND;
-            } elseif ($status === 5005 && (time() - $refill_info['commit_time'] >= 300)) {
-                $order_state = ORDER_STATE_NOEXIST;
-            } else {
-                return [false, $resp['szRtnMsg']];
+            elseif ($resp['code'] === '00')
+            {
+                $status = $resp['orderStatus'];
+                if ($status === '2') {
+                    $updata['official_sn'] = $resp['ext1'];
+                    Model('refill_order')->edit($refill_info['order_id'], $updata);
+                    $order_state = ORDER_STATE_SUCCESS;
+                } elseif ($status === '3') {
+                    $order_state = ORDER_STATE_CANCEL;
+                } elseif ($status === '1') {
+                    $order_state = ORDER_STATE_SEND;
+                } elseif ($status === '4' && (time() - $refill_info['commit_time'] >= 600)) {
+                    $order_state = ORDER_STATE_NOEXIST;
+                } else {
+                    return [false, $resp['msg']];
+                }
+                return [true, $order_state];
+            }
+            else
+            {
+                return [false, $resp['msg']];
             }
-
-            return [true, $order_state];
         }
     }
 
     public function balance()
     {
-        $params['szAgentId'] = config::USER_ID;
-        $key = config::KEY;
-        $content = "szAgentId={$params['szAgentId']}&szKey={$key}";
-        $params['szVerifyString'] = md5($content);
+        $params['appId'] = config::APP_ID;
+        $params['timestamp'] = date("YmdHis").$this->get_millisecond();
+        $params['sign'] = $this->sign($params);
 
         $resp = http_request(config::BALANCE_URL, $params, 'POST', false, config::ExtHeaders);
 
@@ -122,20 +123,34 @@ class RefillPhone extends refill\IRefillPhone
             $resp = json_decode($resp, true);
             if (empty($resp)) {
                 return [false, '网络错误'];
-            } elseif ($resp['nRtn'] === 0) {
-                return [true, $resp['fBalance']];
+            } elseif ($resp['code'] === '00') {
+                return [true, $resp['balance']];
             } else {
-                return [false, $resp['szRtnCode']];
+                return [false, $resp['msg']];
             }
         }
     }
 
+    /**
+     * 获取毫秒级别的时间戳
+     */
+    private function get_millisecond()
+    {
+        list($usec, $sec) = explode(" ", microtime());
+        return round($usec*1000);
+    }
+
     private function sign($params)
     {
-        $userid = config::USER_ID;
-        $key = config::KEY;
-        $content = "szAgentId={$userid}&szOrderId={$params['szOrderId']}&szPhoneNum={$params['szPhoneNum']}&nMoney={$params['nMoney']}&nSortType={$params['nSortType']}";
-        $content .= "&nProductClass={$params['nProductClass']}&nProductType={$params['nProductType']}&szTimeStamp={$params['szTimeStamp']}&szKey={$key}";
+        $params['appSecret'] = config::APP_SECRET;
+        ksort($params);
+        $content = '';
+        foreach ($params as $key => $value) {
+            if($this->check_empty($value) === false) {
+                $content .= "{$key}={$value}&";
+            }
+        }
+        $content = rtrim($content, '&');
         return md5($content);
     }
 }

+ 0 - 12
helper/refill/api/xyz/yunchonggong_yd/api.txt

@@ -1,12 +0,0 @@
-正式环境:
-话费下单地址:http://47.98.253.40:10186/plat/api/old/submitorder
-查询地址:http://47.98.253.40:10186/plat/api/old/queryorder
-查询余额地址:http://47.98.253.40:10186/plat/api/old/queryBalance
-
-测试ID:   200043
-秘钥: 028a435cc21f42f39a4bb2d74bba2a34
-账号  gaoye
-密码 123456
-
-对接文档地址:https://docs.qq.com/doc/DWkV1VkxQVk13eEtQ
-客户端地址:http://47.98.253.40:10186/plat/index

+ 20 - 14
helper/refill/api/xyz/yunchonggong_yd/config.php

@@ -6,22 +6,28 @@ namespace refill\yunchonggong_yd;
 use mtopcard;
 class config
 {
-    //954
-    const ORDER_URL = 'http://47.98.253.40:10186/plat/api/old/submitorder';
-    const QUERY_URL= 'http://47.98.253.40:10186/plat/api/old/queryorder';
-    const BALANCE_URL= 'http://47.98.253.40:10186/plat/api/old/queryBalance';
+    const ORDER_URL = 'http://119.23.54.206:8911/api/order/submit';
+    const QUERY_URL = 'http://119.23.54.206:8911/api/order/query';
+    const BALANCE_URL = 'http://119.23.54.206:8911/api/account/balance';
 
-    const USER_ID= '200043';
-    const KEY = '028a435cc21f42f39a4bb2d74bba2a34';
+    const APP_ID = 'kbDyqz9L7X';
+    const APP_SECRET = 'IXxRhCpFVvqEHgNC';
     const NOTIFY_URL = BASE_SITE_URL . "/mobile/callback/refill_yunchonggong_yd.php";
-    const operator = [
-        mtopcard\ChinaMobileCard  => 1,
-        mtopcard\ChinaUnicomCard  => 2,
-        mtopcard\ChinaTelecomCard => 3
-    ];
-    const ExtHeaders = ['Content-Type:application/x-www-form-urlencoded;charset=utf-8'];
 
-    const ERR_NOS = [
-        1000,1001,1003,1004,2001,2002,2003,2020,2021,1006,2030,3003
+    const PRODUCT = [
+        mtopcard\ChinaMobileCard => [
+            30  => 100130,
+            50  => 100131,
+            100 => 100132,
+            200 => 100133
+        ],
+        mtopcard\ChinaUnicomCard => [
+
+        ],
+        mtopcard\ChinaTelecomCard => [
+
+        ],
     ];
+    const ExtHeaders = ['Content-Type:application/x-www-form-urlencoded;charset=utf-8'];
+    const ERRCODES = ['-10', '-12', '-13', '-14', '-15', '-16', '-18', '-21'];
 }

+ 24 - 0
helper/refill/api/xyz/yunchonggong_yd/开户信息.txt

@@ -0,0 +1,24 @@
+后台地址:http://119.23.54.206:8888
+帐号:yezi222
+密码:722763
+二级密码:YSyT6856
+appId:kbDyqz9L7X
+appSecret:IXxRhCpFVvqEHgNC
+后台-商品列表,可查看已配置商品信息
+后台-安全中心,可配置IP白名单
+接口文档:https://www.showdoc.com.cn/1686453783298366/7925312871840290
+话费直充接口:http://119.23.54.206:8911/api/hf/order/submit
+通用直充接口:http://119.23.54.206:8911/api/order/submit
+卡密提取接口:http://119.23.54.206:8911/api/card/get
+查询接口接口:http://119.23.54.206:8911/api/order/query
+余额查询接口:http://119.23.54.206:8911/api/account/balance
+
+
+100130
+云缴费移动30
+100131
+云缴费移动50
+100132
+云缴费移动100
+100133
+云缴费移动200

+ 1 - 1
helper/refill/api/yl/guochuang/config.php

@@ -66,7 +66,7 @@ class config
         "4-10-2" => 10.15, "4-20-2" => 19.92, "4-30-2" => 29.88, "4-50-2" => 49.8, "4-100-2" => 99.6, "4-200-2" => 199.2, "4-300-2" => 298.8, "4-500-2" => 498,//天津 2
         "4-10-6" => 9.75, "4-20-6" => 19.5, "4-30-6" => 29.25, "4-50-6" => 48.75, "4-100-6" => 97.5, "4-200-6" => 195, "4-300-6" => 292.5, "4-500-6" => 487.5,//辽宁 6
         "4-10-9" => 9.94, "4-20-9" => 19.88, "4-30-9" => 29.82, "4-50-9" => 49.7, "4-100-9" => 99.4,//上海 9
-        "4-10-8" => 9.95, "4-20-8" => 19.9, "4-30-8" => 29.85, "4-50-8" => 49.75, "4-100-8" => 99.5, "4-200-8" => 199, "4-300-8" => 298.5, "4-500-8" => 497.5 ,//黑龙江 8
+        "4-10-8" => 9.94, "4-20-8" => 19.88, "4-30-8" => 29.82, "4-50-8" => 49.7, "4-100-8" => 99.4, "4-200-8" => 198.8, "4-300-8" => 298.2, "4-500-8" => 497,//黑龙江 8
         "4-10-29" => 9.76, "4-20-29" => 19.52, "4-30-29" => 29.28, "4-50-29" => 48.8, "4-100-29" => 97.6, "4-200-29" => 195.2, "4-300-29" => 292.8, "4-500-29" => 488,//青海 29
         "4-10-28" => 9.985, "4-20-28" => 19.97, "4-30-28" => 29.955, "4-50-28" => 49.925, "4-100-28" => 99.85, "4-200-28" => 199.7, "4-300-28" => 299.55, "4-500-28" => 499.25,//甘肃 28
         "4-10-13" => 10.22, "4-20-13" => 19.94, "4-30-13" => 29.91, "4-50-13" => 49.85, "4-100-13" => 99.7, "4-200-13" => 199.4, "4-300-13" => 300.9, "4-500-13" => 501.5,//福建 13

+ 33 - 17
helper/refill/api/yl/yunchonggong_yd/RefillCallBack.php

@@ -8,8 +8,10 @@ class RefillCallBack implements refill\IRefillCallBack
 {
     public function verify($params): bool
     {
-        $sign = $this->sign($params);
-        if ($params['szVerifyString'] == $sign) {
+        $input = $params;
+        unset($input['sign']);
+        $sign = $this->sign($input);
+        if ($params['sign'] == $sign) {
             return true;
         } else {
             return false;
@@ -18,33 +20,47 @@ class RefillCallBack implements refill\IRefillCallBack
 
     private function sign($params)
     {
-        $userid = config::USER_ID;
-        $key = config::KEY;
-        $content = "szAgentId={$userid}&szOrderId={$params['szOrderId']}&szPhoneNum={$params['szPhoneNum']}&nDemo={$params['nDemo']}&fSalePrice={$params['fSalePrice']}";
-        $content .= "&nFlag={$params['nFlag']}&szKey={$key}";
+        $params['appSecret'] = config::APP_SECRET;
+        ksort($params);
+        $content = '';
+        foreach ($params as $key => $value) {
+            if($this->check_empty($value) === false) {
+                $content .= "{$key}={$value}&";
+            }
+        }
+        $content = rtrim($content, '&');
         return md5($content);
     }
 
+    private function check_empty($value)
+    {
+        if (!isset($value))
+            return true;
+        if ($value === null)
+            return true;
+        if (trim($value) === "")
+            return true;
+
+        return false;
+    }
+
     public function notify($params)
     {
-        $status = intval($params['nFlag']);
-        $order_sn = $params['szOrderId'];
+        $status = intval($params['orderStatus']);
+        $order_sn = $params['outOrderId'];
         $order_info = Model('vr_order')->getOrderInfo(['order_sn' => $order_sn]);
         if (empty($order_info)) {
             return [false, false, false,false];
         }
         $order_id = $order_info['order_id'];
-
         if ($status === 2) {
-            $data['official_sn'] = strtolower($params['szRtnMsg']) == 'null' ? '' : $params['szRtnMsg'];
+            $data['official_sn'] = strtolower($params['ext1']) == 'null' ? '' : $params['ext1'];
             Model('refill_order')->edit($order_id, $data);
-            return [$order_id, true, false,true];
-        }
-        elseif ($status === 3) {
-            return [$order_id, false, true,true];
-        }
-        else {
-            return [$order_id, false, false,false];
+            return [$order_id, true, false, true];
+        } elseif ($status === 3) {
+            return [$order_id, false, true, true];
+        } else {
+            return [$order_id, false, false, false];
         }
     }
 }

+ 70 - 55
helper/refill/api/yl/yunchonggong_yd/RefillPhone.php

@@ -16,15 +16,14 @@ class RefillPhone extends refill\IRefillPhone
 
     private function req_params(int $phone, int $amount, int $card_type, string $order_sn)
     {
-        $params['szAgentId'] = config::USER_ID;
-        $params['szOrderId'] = $order_sn;
-        $params['szPhoneNum'] = $phone;
-        $params['nMoney'] = $amount;
-        $params['nSortType'] = config::operator[$card_type];
-        $params['nProductClass'] = 1;
-        $params['nProductType'] = 1;
-        $params['szTimeStamp'] = date("Y-m-d H:i:s");
-        $params['szNotifyUrl'] = config::NOTIFY_URL;
+        $params['appId'] = config::APP_ID;
+        $params['outOrderId'] = $order_sn;
+        $params['uuid'] = $phone;
+        $params['itemId'] = config::PRODUCT[$card_type][$amount];
+        $params['itemFace'] = $amount;
+        $params['amount'] = 1;
+        $params['callbackUrl'] = config::NOTIFY_URL;
+        $params['timestamp'] = date("YmdHis").$this->get_millisecond();
         return $params;
     }
 
@@ -32,9 +31,11 @@ class RefillPhone extends refill\IRefillPhone
     {
         $order_sn = $params['order_sn'];
         $params = $this->req_params($card_no, $amount, $card_type, $order_sn);
-
+        if(empty($params['itemId'])) {
+            return [false, '商品编号错误', false];
+        }
         $sign = $this->sign($params);
-        $params['szVerifyString'] = $sign;
+        $params['sign'] = $sign;
 
         $resp = http_request(config::ORDER_URL, $params, 'POST', false, config::ExtHeaders, $net_errno);
 
@@ -45,32 +46,28 @@ class RefillPhone extends refill\IRefillPhone
         {
             Log::record($resp, Log::DEBUG);
             $resp = json_decode($resp, true);
-
-            $nRtn = $resp['nRtn'];
             if (empty($resp)) {
                 return [false, '网络错误', true];
-            } elseif ($nRtn === 0) {
-                return [true, '', false];
-            } elseif (in_array($nRtn, config::ERR_NOS, true)) {
-                return [false, $resp['szRtnCode'], false];
-            } elseif (in_array($nRtn, [2050, 999], true)) {
-                $net_errno = "HTTP-{$nRtn}";
-                return [false, $resp['szRtnCode'], true];
+            } elseif ($resp['code'] === '00') {
+                return [true, $resp['orderId'], false];
+            } elseif (in_array($resp['code'], config::ERRCODES, true)) {
+                return [false, $resp['msg'], false];
+            } elseif (in_array($resp['code'], ['-22', '-23', '-99'], true)) {
+                $net_errno = "HTTP-{$resp['code']}";
+                return [false, $resp['msg'], true];
             } else {
-                $err = 998;
-                $net_errno = "HTTP-{$err}";
-                return [false, $resp['szRtnCode'], true];
+                $net_errno = "HTTP-998";
+                return [false, $resp['msg'], true];
             }
         }
     }
 
     public function query($refill_info)
     {
-        $params['szAgentId'] = config::USER_ID;
-        $params['szOrderId'] = $refill_info['order_sn'];
-        $key = config::KEY;
-        $content = "szAgentId={$params['szAgentId']}&szOrderId={$params['szOrderId']}&szKey={$key}";
-        $params['szVerifyString'] = md5($content);
+        $params['appId'] = config::APP_ID;
+        $params['outOrderId'] = $refill_info['order_sn'];
+        $params['timestamp'] = date("YmdHis").$this->get_millisecond();
+        $params['sign'] = $this->sign($params);
 
         $resp = http_request(config::QUERY_URL, $params, 'POST', false, config::ExtHeaders);
 
@@ -84,32 +81,36 @@ class RefillPhone extends refill\IRefillPhone
             if (empty($resp)) {
                 return [false, '网络错误'];
             }
-
-            $status = $resp['nRtn'];
-            if ($status === 5012) {
-                $updata['official_sn'] = $resp['szRtnMsg'];
-                Model('refill_order')->edit($refill_info['order_id'], $updata);
-                $order_state = ORDER_STATE_SUCCESS;
-            } elseif ($status === 5013) {
-                $order_state = ORDER_STATE_CANCEL;
-            } elseif (in_array($status, [5011,5019],true)) {
-                $order_state = ORDER_STATE_SEND;
-            } elseif ($status === 5005 && (time() - $refill_info['commit_time'] >= 300)) {
-                $order_state = ORDER_STATE_NOEXIST;
-            } else {
-                return [false, $resp['szRtnMsg']];
+            elseif ($resp['code'] === '00')
+            {
+                $status = $resp['orderStatus'];
+                if ($status === '2') {
+                    $updata['official_sn'] = $resp['ext1'];
+                    Model('refill_order')->edit($refill_info['order_id'], $updata);
+                    $order_state = ORDER_STATE_SUCCESS;
+                } elseif ($status === '3') {
+                    $order_state = ORDER_STATE_CANCEL;
+                } elseif ($status === '1') {
+                    $order_state = ORDER_STATE_SEND;
+                } elseif ($status === '4' && (time() - $refill_info['commit_time'] >= 600)) {
+                    $order_state = ORDER_STATE_NOEXIST;
+                } else {
+                    return [false, $resp['msg']];
+                }
+                return [true, $order_state];
+            }
+            else
+            {
+                return [false, $resp['msg']];
             }
-
-            return [true, $order_state];
         }
     }
 
     public function balance()
     {
-        $params['szAgentId'] = config::USER_ID;
-        $key = config::KEY;
-        $content = "szAgentId={$params['szAgentId']}&szKey={$key}";
-        $params['szVerifyString'] = md5($content);
+        $params['appId'] = config::APP_ID;
+        $params['timestamp'] = date("YmdHis").$this->get_millisecond();
+        $params['sign'] = $this->sign($params);
 
         $resp = http_request(config::BALANCE_URL, $params, 'POST', false, config::ExtHeaders);
 
@@ -122,20 +123,34 @@ class RefillPhone extends refill\IRefillPhone
             $resp = json_decode($resp, true);
             if (empty($resp)) {
                 return [false, '网络错误'];
-            } elseif ($resp['nRtn'] === 0) {
-                return [true, $resp['fBalance']];
+            } elseif ($resp['code'] === '00') {
+                return [true, $resp['balance']];
             } else {
-                return [false, $resp['szRtnCode']];
+                return [false, $resp['msg']];
             }
         }
     }
 
+    /**
+     * 获取毫秒级别的时间戳
+     */
+    private function get_millisecond()
+    {
+        list($usec, $sec) = explode(" ", microtime());
+        return round($usec*1000);
+    }
+
     private function sign($params)
     {
-        $userid = config::USER_ID;
-        $key = config::KEY;
-        $content = "szAgentId={$userid}&szOrderId={$params['szOrderId']}&szPhoneNum={$params['szPhoneNum']}&nMoney={$params['nMoney']}&nSortType={$params['nSortType']}";
-        $content .= "&nProductClass={$params['nProductClass']}&nProductType={$params['nProductType']}&szTimeStamp={$params['szTimeStamp']}&szKey={$key}";
+        $params['appSecret'] = config::APP_SECRET;
+        ksort($params);
+        $content = '';
+        foreach ($params as $key => $value) {
+            if($this->check_empty($value) === false) {
+                $content .= "{$key}={$value}&";
+            }
+        }
+        $content = rtrim($content, '&');
         return md5($content);
     }
 }

+ 0 - 12
helper/refill/api/yl/yunchonggong_yd/api.txt

@@ -1,12 +0,0 @@
-正式环境:
-话费下单地址:http://47.98.253.40:10186/plat/api/old/submitorder
-查询地址:http://47.98.253.40:10186/plat/api/old/queryorder
-查询余额地址:http://47.98.253.40:10186/plat/api/old/queryBalance
-
-测试ID:   200043
-秘钥: 028a435cc21f42f39a4bb2d74bba2a34
-账号  gaoye
-密码 123456
-
-对接文档地址:https://docs.qq.com/doc/DWkV1VkxQVk13eEtQ
-客户端地址:http://47.98.253.40:10186/plat/index

+ 20 - 14
helper/refill/api/yl/yunchonggong_yd/config.php

@@ -6,22 +6,28 @@ namespace refill\yunchonggong_yd;
 use mtopcard;
 class config
 {
-    //954
-    const ORDER_URL = 'http://47.98.253.40:10186/plat/api/old/submitorder';
-    const QUERY_URL= 'http://47.98.253.40:10186/plat/api/old/queryorder';
-    const BALANCE_URL= 'http://47.98.253.40:10186/plat/api/old/queryBalance';
+    const ORDER_URL = 'http://119.23.54.206:8911/api/order/submit';
+    const QUERY_URL = 'http://119.23.54.206:8911/api/order/query';
+    const BALANCE_URL = 'http://119.23.54.206:8911/api/account/balance';
 
-    const USER_ID= '200043';
-    const KEY = '028a435cc21f42f39a4bb2d74bba2a34';
+    const APP_ID = 't3iQhtu3sd';
+    const APP_SECRET = 'xaxdWZlzcMsIvzaU';
     const NOTIFY_URL = BASE_SITE_URL . "/mobile/callback/refill_yunchonggong_yd.php";
-    const operator = [
-        mtopcard\ChinaMobileCard  => 1,
-        mtopcard\ChinaUnicomCard  => 2,
-        mtopcard\ChinaTelecomCard => 3
-    ];
-    const ExtHeaders = ['Content-Type:application/x-www-form-urlencoded;charset=utf-8'];
 
-    const ERR_NOS = [
-        1000,1001,1003,1004,2001,2002,2003,2020,2021,1006,2030,3003
+    const PRODUCT = [
+        mtopcard\ChinaMobileCard => [
+            30  => 100130,
+            50  => 100131,
+            100 => 100132,
+            200 => 100133
+        ],
+        mtopcard\ChinaUnicomCard => [
+
+        ],
+        mtopcard\ChinaTelecomCard => [
+
+        ],
     ];
+    const ExtHeaders = ['Content-Type:application/x-www-form-urlencoded;charset=utf-8'];
+    const ERRCODES = ['-10', '-12', '-13', '-14', '-15', '-16', '-18', '-21'];
 }

+ 24 - 0
helper/refill/api/yl/yunchonggong_yd/开户信息.txt

@@ -0,0 +1,24 @@
+后台地址:http://119.23.54.206:8888
+帐号:yelin222
+密码:765514
+二级密码:hauy5488
+appId:t3iQhtu3sd
+appSecret:xaxdWZlzcMsIvzaU
+后台-商品列表,可查看已配置商品信息
+后台-安全中心,可配置IP白名单
+接口文档:https://www.showdoc.com.cn/1686453783298366/7925312871840290
+话费直充接口:http://119.23.54.206:8911/api/hf/order/submit
+通用直充接口:http://119.23.54.206:8911/api/order/submit
+卡密提取接口:http://119.23.54.206:8911/api/card/get
+查询接口接口:http://119.23.54.206:8911/api/order/query
+余额查询接口:http://119.23.54.206:8911/api/account/balance
+
+
+100130
+云缴费移动30
+100131
+云缴费移动50
+100132
+云缴费移动100
+100133
+云缴费移动200

+ 40 - 22
helper/statistics/refill_balance.php

@@ -89,54 +89,47 @@ class refill_balance
         return intval($item['balance_id']);
     }
 
-    //system,provider,merchant
-    //cid=0,mchid,store_id
-    public function add_balance($type, $cid, $start, $end, $time_type, $parent_balance = 0,$remark = '系统自动生成')
+    private function balance_data($type, $cid, $start, $end, $time_type, $parent_balance, $remark)
     {
-        $order_stat = $this->order_stat($type,$cid,$start,$end,$time_type);
+        $order_stat = $this->order_stat($type, $cid, $start, $end, $time_type);
 
-        if($type == 'system') {
-            $in = $this->merchant_evidence_stat(0,$start,$end);
-            $out = $this->provider_amount_stat(0,$start,$end);
+        if ($type == 'system') {
+            $in = $this->merchant_evidence_stat(0, $start, $end);
+            $out = $this->provider_amount_stat(0, $start, $end);
             $cname = 'system';
 
             $balance = ncPriceFormat($in - $out);
-        }
-        elseif($type == 'merchant') {
-            $in = $this->merchant_evidence_stat($cid,$start,$end);
+        } elseif ($type == 'merchant') {
+            $in = $this->merchant_evidence_stat($cid, $start, $end);
             $out = "0.0000";
             $cname = $this->mMerchantNames[$cid];
 
             $balance = ncPriceFormat($in - $order_stat['mch_amounts']);
-        }
-        else {
+        } else {
             $in = "0.0000";
             $pid = $this->mStoreidPID[$cid];
-            $out = $this->provider_amount_stat($pid,$start,$end);
+            $out = $this->provider_amount_stat($pid, $start, $end);
             $cname = $this->mProviderNames[$cid];
 
             $balance = ncPriceFormat($in - $order_stat['channel_amounts']);
         }
 
-        $accumuter = function ($parent_id)
-        {
+        $accumuter = function ($parent_id) {
             if ($parent_id > 0) {
                 $item = Model('refill_balance')->getBalance(['balance_id' => $parent_id]);
-            }
-            else {
+            } else {
                 $item = [];
             }
 
-            if(empty($item)) {
+            if (empty($item)) {
                 return 0.00;
-            }
-            else {
+            } else {
                 return $item['accumulate_balance'] + $item['balance'];
             }
         };
 
-        $data = ['parent_id' => $parent_balance, 'type' => $type, 'cid' => $cid, 'cname' => $cname,
-            'start_stamp' => $start,'end_stamp' => $end,'end_text' => date('Y-m-d H:i:s', $end),
+        return ['parent_id' => $parent_balance, 'type' => $type, 'cid' => $cid, 'cname' => $cname,
+            'start_stamp' => $start, 'end_stamp' => $end, 'end_text' => date('Y-m-d H:i:s', $end),
             'success_count' => intval($order_stat['order_counts']),
             'refill_amount' => ncPriceFormat($order_stat['refill_amounts']),
             'mch_amount' => ncPriceFormat($order_stat['mch_amounts']),
@@ -153,11 +146,35 @@ class refill_balance
             'time_type' => $time_type,
             'remark' => $remark,
         ];
+    }
 
+    //system,provider,merchant
+    //cid=0,mchid,store_id
+    public function add_balance($type, $cid, $start, $end, $time_type, $parent_balance = 0, $remark = '系统自动生成')
+    {
+        $data = $this->balance_data($type, $cid, $start, $end, $time_type, $parent_balance, $remark);
         $ret = Model('refill_balance')->insert($data);
         return $ret != false;
     }
 
+    public function rebuild_balance($balance_id)
+    {
+        $balance = Model('refill_balance')->getBalance(['balance_id' => $balance_id]);
+        if(empty($balance)) return false;
+
+        $type = $balance['type'];
+        $cid = $balance['cid'];
+        $start = $balance['start_stamp'];
+        $end = $balance['end_stamp'];
+        $time_type = $balance['time_type'];
+        $parent_balance = $balance['parent_id'];
+        $remark = '记录重新生成';
+
+        $data = $this->balance_data($type, $cid, $start, $end, $time_type, $parent_balance, $remark);
+        $ret = Model('refill_balance')->where(['balance_id' => $balance_id])->update($data);
+        return $ret != false;
+    }
+
     private function order_stat($type, $cid, $start, $end, $time_type)
     {
         $cond = [
@@ -205,6 +222,7 @@ class refill_balance
     private function merchant_evidence_stat($cid, $start, $end)
     {
         $cond['status'] = $cond['is_operation'] = 2;
+        $cond['add_type'] = ['neq', 4];
         if($cid > 0) {
             $cond['mchid'] = $cid;
         }

+ 7 - 2
helper/statistics/stat_refill.php

@@ -112,7 +112,7 @@ class stat_refill
         }
     }
 
-    private function system_stat($day_time, $order_time_type='notify_time')
+    public function system_stat($day_time, $order_time_type='notify_time', $stat_type='create')
     {
         $end_time = $day_time + stat_refill::DaySecs;
         $cond = [
@@ -145,6 +145,7 @@ class stat_refill
         $params['cname'] = 'system';
         $params['order_time_type'] = $order_time_type;
 
+        $params = $this->init_count($params);
         $order_count = 0;
         foreach ($items as $item)
         {
@@ -184,7 +185,11 @@ class stat_refill
                 $params['service_amounts'] = ncPriceFormat($amounts * 0.0005);
             }
         }
-        Model('')->table('refill_stats')->insert($params);
+        if ($stat_type == 'reload') {
+            Model('')->table('refill_stats')->where(['time_stamp' => $day_time, 'type' => 'system', 'order_time_type' => $order_time_type])->update($params);
+        } elseif ($stat_type == 'create') {
+            Model('')->table('refill_stats')->insert($params);
+        }
 
         return $order_count;
     }

+ 57 - 0
helper/task/handler.php

@@ -2,11 +2,13 @@
 namespace task;
 require_once(BASE_HELPER_PATH . '/stat_helper.php');
 require_once(BASE_HELPER_PATH . '/PHPExcel/PHPExcel.php');
+require_once(BASE_HELPER_PATH . '/statistics/refill_balance.php');
 
 use Exception;
 use mtopcard;
 use PHPExcel;
 use PHPExcel_IOFactory;
+use statistics\refill_balance;
 use statistics\stat_refill;
 
 class handler
@@ -317,6 +319,8 @@ class handler
             $refill->merchant_stat($time_stamp, $cid, $order_time_type);
         } elseif ($type == 'provider') {
             $refill->provider_stat($time_stamp, $cid, $order_time_type);
+        } elseif ($type == 'system') {
+            $refill->system_stat($time_stamp, $order_time_type, 'reload');
         }
         return [true, 'success'];
     }
@@ -325,4 +329,57 @@ class handler
     {
         return md5("order_stat_reload-".serialize($condition));
     }
+
+    public function refill_balance_create($condition)
+    {
+        $type = $condition['type'];
+        $cid = $condition['cid'];
+        $start = $condition['start'];
+        $end = $condition['end'];
+        $time_type = $condition['time_type'];
+        $parent_balance = $condition['parent_id'];
+
+        $refill_balance = new refill_balance();
+        $refill_balance->add_balance($type, $cid, $start, $end, $time_type, $parent_balance);
+        return [true, 'success'];
+    }
+
+    public function refill_balance_create_title($condition)
+    {
+        return md5("refill_balance_create-".serialize($condition));
+    }
+
+    public function refill_balance_rebuild($condition)
+    {
+        $balance_id = $condition['balance_id'];
+
+        $refill_balance = new refill_balance();
+        $refill_balance->rebuild_balance($balance_id);
+        return [true, 'success'];
+    }
+
+    public function refill_balance_rebuild_title($condition)
+    {
+        return md5("refill_balance_rebuild-".serialize($condition));
+    }
+
+    public function refill_balance_stat_all($condition)
+    {
+        $end = $condition['end'];
+        $last_confirm_balance = Model('refill_balance')->LastConfirm();
+        if(empty($last_confirm_balance)) {
+            $start = 0;
+        }else{
+            $start = $last_confirm_balance['end_stamp'];
+        }
+
+        $refill_balance = new refill_balance();
+        $refill_balance->stat_all($start, $end);
+        return [true, 'success'];
+    }
+
+    public function refill_balance_stat_all_title($condition)
+    {
+        return md5("refill_balance_stat_all-".serialize($condition));
+    }
 }

+ 2 - 5
test/TestRefill.php

@@ -934,12 +934,9 @@ class TestRefill extends TestCase
     public function testYunchonggong_yd()
     {
         $provider = $this->getProvider('yunchonggong_yd');
-        for ($i = 1; $i <= 5; $i++) {
-            $resp = $provider->add(13699279618, 4, 50, ['order_sn' => $this->make_sn()]);
-        }
-//        $resp = $provider->query(['order_sn' => '34061631002071526340']);
-
 //        $resp = $provider->balance();
+//        $resp = $provider->add(13699279618, 4, 30, ['order_sn' => $this->make_sn()]);
+//        $resp = $provider->query(['order_sn' => '40181650866044454847']);
 
 //        $body = '{"szOrderId":"34061631002071526340","fSalePrice":"47.7","szAgentId":"200043","nFlag":"3","szVerifyString":"48a7329c13af06b5be1d2fdad706b22e","szPhoneNum":"13699279618","szRtnMsg":"","nDemo":"50"}';
 //        $params = json_decode($body, true);

+ 6 - 0
test/TestRefillYl.php

@@ -682,4 +682,10 @@ class TestRefillYl extends TestCase
         $provider = $this->getProvider('shantong');
         $resp = $provider->balance();
     }
+
+    public function testYunchonggong_yd()
+    {
+        $provider = $this->getProvider('yunchonggong_yd');
+        $resp = $provider->balance();
+    }
 }

+ 0 - 1
vendor/ezyang/htmlpurifier

@@ -1 +0,0 @@
-Subproject commit 1dd3e52365c32a142fb7c9c9f8f038f18e353270

+ 0 - 1
vendor/maennchen/zipstream-php

@@ -1 +0,0 @@
-Subproject commit c4c5803cc1f93df3d2448478ef79394a5981cc58

+ 0 - 1
vendor/markbaker/complex

@@ -1 +0,0 @@
-Subproject commit ab8bc271e404909db09ff2d5ffa1e538085c0f22

+ 0 - 1
vendor/markbaker/matrix

@@ -1 +0,0 @@
-Subproject commit c66aefcafb4f6c269510e9ac46b82619a904c576

+ 0 - 1
vendor/myclabs/php-enum

@@ -1 +0,0 @@
-Subproject commit b942d263c641ddb5190929ff840c68f78713e937

+ 0 - 1
vendor/phpoffice/phpspreadsheet

@@ -1 +0,0 @@
-Subproject commit 4a28fd6eecb11d1f8095ebb99dd2e05e78df2f50

+ 0 - 1
vendor/psr/http-client

@@ -1 +0,0 @@
-Subproject commit 2dfb5f6c5eff0e91e20e913f8c5452ed95b86621

+ 0 - 1
vendor/psr/http-factory

@@ -1 +0,0 @@
-Subproject commit 12ac7fcd07e5b077433f5f2bee95b3a771bf61be

+ 0 - 1
vendor/psr/http-message

@@ -1 +0,0 @@
-Subproject commit f6561bf28d520154e4b0ec72be95418abe6d9363

+ 0 - 1
vendor/psr/simple-cache

@@ -1 +0,0 @@
-Subproject commit 408d5eafb83c57f6365a3ca330ff23aa4a5fa39b

+ 0 - 1
vendor/symfony/polyfill-mbstring

@@ -1 +0,0 @@
-Subproject commit 0abb51d2f102e00a4eefcf46ba7fec406d245825