فهرست منبع

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

stanley-king 3 سال پیش
والد
کامیت
a41fdabd09

+ 11 - 18
admin/control/orderstats.php

@@ -4,16 +4,9 @@
 class orderstatsControl extends SystemControl
 {
     private $task_type = [
-        'order_export' => '订单导出'
-    ];
-    private $type = [
-        'merchant' => '机构',
-        'provider' => '通道'
-    ];
-    private $order_time_type = [
-        'notify_time' => '回调时间',
-        'order_time' => '下单时间'
+        'refill_order_export' => '订单导出'
     ];
+
     private $task_state = [
         1   => '待处理',
         2   => '处理中',
@@ -141,33 +134,33 @@ class orderstatsControl extends SystemControl
     }
     public function refill_taskOp()
     {
-        $model = Model('refill_task');
-        $condition['is_del'] = 0;
+        $model = Model('task');
+        $condition['is_show'] = 1;
         if(!empty($_GET['type'])) {
             $condition['type'] = $_GET['type'];
         }
-        if(!empty($_GET['cid'])) {
-            $condition['cid'] = $_GET['cid'];
+        if(!empty($_GET['task_id'])) {
+            $condition['task_id'] = $_GET['task_id'];
+        }
+        if(!empty($_GET['state'])) {
+            $condition['state'] = $_GET['state'];
         }
         $task_list = $model->getList($condition, 50);
         foreach ($task_list as $key => $value) {
             $task_list[$key]['condition'] = unserialize($value['task_params']);
+            $task_list[$key]['result'] = unserialize($value['result']);
         }
 
         Tpl::output('list', $task_list);
-        Tpl::output('provider_list', $this->providers());
-        Tpl::output('merchant_list', $this->merchants());
         Tpl::output('task_type', $this->task_type);
-        Tpl::output('type', $this->type);
         Tpl::output('task_state', $this->task_state);
-        Tpl::output('order_time_type', $this->order_time_type);
         Tpl::showpage('refill.task');
     }
 
     public function task_delOp()
     {
         $task_id = $_GET['task_id'];
-        $model = Model('refill_task');
+        $model = Model('task');
         $resp = $model->Del($task_id);
         if($resp) {
             showMessage('删除成功', 'index.php?act=OrderStats&&op=refill_task');

+ 24 - 11
admin/control/refill_order.php

@@ -130,16 +130,20 @@ class refill_orderControl extends SystemControl
         }
 
         if (!empty($_GET['export']) || !empty($_GET['export_stats'])) {
-            $this->RefillOrderExport($cond);
-            exit;
+            if (empty($_GET['query_end_time'])) {
+                showMessage('订单导出条件必须含有结束日期.');
+            } else {
+                $this->RefillOrderExport($cond);
+            }
+            return;
         }
         if (!empty($_GET['mch_notify'])) {
             $this->mch_notify($cond);
-            exit;
+            return;
         }
         if (!empty($_GET['order_query'])) {
             $this->updateOrderSend($cond);
-            exit;
+            return;
         }
         $merchants = [];
         $merchant_list = $this->merchants();
@@ -190,17 +194,26 @@ class refill_orderControl extends SystemControl
         Tpl::showpage('refill.order.index');
     }
 
-    private function RefillOrderExport($condition)
+    private function RefillOrderExport($cond)
     {
         if(!empty($_GET['export_stats'])) {
-            if(!empty($condition['refill_order.order_time'])) {
-                $condition['refill_order.notify_time'] = $condition['refill_order.order_time'];
-                unset($condition['refill_order.order_time']);
-                unset($condition['vr_order.add_time']);
+            if(!empty($cond['refill_order.order_time'])) {
+                $cond['refill_order.notify_time'] = $cond['refill_order.order_time'];
+                unset($cond['refill_order.order_time']);
+                unset($cond['vr_order.add_time']);
             }
         }
-        $result = Model('refill_order')->getAllOrders($condition);
-        $this->createExcel($result);
+        $manager = new task\manager();
+        $task = $manager->add_task('refill_order_export',$cond,1);
+        if ($task->completed() && $task->success()) {
+            $file_name = $task->result();
+            $file_path = UPLOAD_SITE_URL . '/' . ATTACH_TASK . DS . $file_name;
+            header("Content-Disposition: attachment; filename={$file_name}");
+            readfile($file_path);
+        } else {
+            $task_id = $task->task_id();
+            showMessage("录入成功,任务ID:{$task_id},请稍后以相同条件再次导出,或在任务列表直接下载。","index.php?act=orderstats&op=refill_task&task_id={$task_id}");
+        }
     }
 
     private function createExcel($data = array())

+ 9 - 2
admin/templates/default/refill.order.index.php

@@ -595,6 +595,9 @@
 <link rel="stylesheet" type="text/css" href="<?php echo ADMIN_TEMPLATES_URL; ?>/layui/css/layui.css"/>
 <script type="text/javascript">
     $(function () {
+        let EntTime = localStorage.getItem('Endtime')
+        $('#endTime').val(EntTime)
+        localStorage.clear();
         //查看
     $('#examine').click(function () {
       let order_id = $(this).attr('data-order')
@@ -796,8 +799,8 @@
         data: datas
     })
 
-    $('#query_start_time').datepicker({dateFormat: 'yy-mm-dd'});
-    $('#query_end_time').datepicker({dateFormat: 'yy-mm-dd'});
+    // $('#query_start_time').datepicker({dateFormat: 'yy-mm-dd'});
+    // $('#query_end_time').datepicker({dateFormat: 'yy-mm-dd'});
     $('#ncsubmit').click(function () {
         let index = layer.load(0, {shade: false}); 
         $('input[name="op"]').val('index');
@@ -832,6 +835,8 @@
         $('input[name="no_mchid"]').val(selectStr);
         $('#formSearch').submit();
         $('input[name="export"]').val('');
+        let Endtime = $('#endTime').val()
+        localStorage.setItem('Endtime',Endtime)
         let ii = layer.load();
         setTimeout(function(){
             layer.close(ii);
@@ -856,6 +861,8 @@
         $('input[name="no_mchid"]').val(selectStr);
         $('#formSearch').submit();
         $('input[name="export_stats"]').val('');
+        let Endtime = $('#endTime').val()
+        localStorage.setItem('Endtime',Endtime)
         })
 
     //搜索+统计 

+ 22 - 127
admin/templates/default/refill.task.php

@@ -124,22 +124,18 @@
     <form method="get" action="index.php" name="formSearch" id="formSearch">
         <input type="hidden" name="act" value="orderstats"/>
         <input type="hidden" name="op" value="refill_task"/>
-        <input type="hidden" name="cid_type" value=""/>
-        <input type="hidden" name="default_cid_type" value="<?php echo $_GET['cid_type']; ?>"/>
         <table class="tb-type1 noborder search">
             <tr>
-                <th><label>主体类型</label></th>
-                <td class="layui-form type">
-                    <select name="type" id="type" lay-filter="type">
-                        <option value="">请选择</option>
-                        <?php foreach ($output['type'] as $key => $value){?>
-                            <option value="<?php echo $key;?>" <?php if($_GET['type'] === $key) { echo 'selected'; }?>><?php echo $value;?></option>
-                        <?php }?>
-                    </select>
-                </td>
-                <th><label>主体选择</label></th>
-                <td class="layui-form selection">
-                    <select name="cid" id="cid" lay-filter="cid" lay-search></select>
+                <th><label>处理状态</label></th>
+                <td>
+                    <label>
+                        <select name="state">
+                            <option value=""><?php echo $lang['nc_please_choose']; ?></option>
+                            <?php foreach($output['task_state'] as $key => $value){?>
+                                <option value="<?php echo $key;?>" <?php if ($_GET['state'] == $key){ ?>selected<?php } ?>><?php echo $value;?></option>
+                            <?php }?>
+                        </select>
+                    </label>
                 </td>
                 <td>
                     <a href="javascript:void(0);" id="ncsubmit" class="btn-search "
@@ -156,7 +152,7 @@
             <th class="align-center">编号</th>
             <th class="align-center">任务ID</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>
@@ -172,8 +168,8 @@
                 <tr class="hover trFlex">
                     <td class="align-center"><?php echo $key + 1; ?></td>
                     <td class="align-center"><?php echo $value['task_id']; ?></td>
-                    <td class="align-center"><?php echo $output['task_type'][$value['task_type']]; ?></td>
-                    <td class="align-center">
+                    <td class="align-center"><?php echo $output['task_type'][$value['type']]; ?></td>
+<!--                    <td class="align-center">-->
 <!--                        --><?php //if(!empty($value['condition']['refill_order.order_time'])) { ?>
 <!--                        <p>统计日期范围:-->
 <!--                            --><?php //echo date("Y-m-d H:i:s", $value['condition']['refill_order.order_time'][0][1]) ?? '/';?>
@@ -188,14 +184,18 @@
 //                            }
 //                            ?>
 <!--                        </p>-->
-                    </td>
-                    <td class="align-center"><?php echo $output['task_state'][$value['task_state']]; ?></td>
+<!--                    </td>-->
+                    <td class="align-center"><?php echo $output['task_state'][$value['state']]; ?></td>
                     <td class="align-center"><?php echo $value['add_time'] ? date('Y-m-d H:i:s', $value['add_time']) : '/'; ?></td>
-                    <td class="align-center"><?php echo $value['dispose_time'] ? date('Y-m-d H:i:s', $value['dispose_time']) : '/'; ?></td>
+                    <td class="align-center"><?php echo $value['act_time'] ? date('Y-m-d H:i:s', $value['act_time']) : '/'; ?></td>
                     <td class="align-center"><?php echo $value['finish_time'] ? date('Y-m-d H:i:s', $value['finish_time']) : '/'; ?></td>
                     <td class="align-center">
-                        <?php if($value['task_state'] == 3 && !empty($value['task_result'])){?>
-                            <a target="_blank" href="<?php echo UPLOAD_SITE_URL . '/' . ATTACH_TASK . DS . $value['task_result']; ?>">下载</a>
+                        <?php if($value['state'] == 3 && !empty($value['result'])){?>
+                                <?php if($value['result_state'] == 1){ ?>
+                            <a target="_blank" href="<?php echo UPLOAD_SITE_URL . '/' . ATTACH_TASK . DS . $value['result']; ?>">下载</a>
+                                    <?php }else{
+                                    echo $value['result'];
+                            }?>
                         <?php }?>
                     </td>
                     <td class="align-center">
@@ -229,16 +229,8 @@
 <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">
-    let selectValue = ''
-    let Interface
-    let default_type = '<?php echo $_GET['type'];?>';
-    // console.log(default_type, 'type');
-    let default_cid_m = '<?php echo $_GET['cid'];?>';
-    // console.log(default_cid_m);
-
     $(function () {
         $('#ncsubmit').click(function () {
-            $('input[name="cid_type"]').val(selectValue);
             $('#formSearch').submit();
         });
         $('#query_start_time').datepicker({dateFormat: 'yy-mm-dd'});
@@ -270,102 +262,5 @@
                 $(this).css('color', 'red')
             }
         })
-
-
-
-
-
-        //主体选择
-        layui.use(['form'], function () {
-            let form = layui.form;
-            let default_type = $('select[name="type"]').val();
-            if (default_type === 'merchant') {
-                $.get('index.php?act=refill_order&op=merchant_data', function(res) {
-                    res = JSON.parse(res)
-                    let html = '';
-                    res.forEach(item => {
-                        html += `<option value="${item.value}">${item.name}</option>`;
-                    })
-                    let select_type = `<select>${html}</select>`
-                    $('#cid').html(select_type);
-                    form.render('select')
-                })
-            } else if (default_type === 'provider'){
-                $.get('index.php?act=refill_order&op=provider_data', function(res) {
-                    selectRes = JSON.parse(res)
-                        let html = '';
-                        selectRes.forEach(item => {
-                            html += `<option value="${item.value}">${item.name}</option>`;
-                        })
-                        let select_type = `<select>${html}</select>`
-                        $('#cid').html(select_type);
-                        let default_cid_type = $('input[name="default_cid_type"]').val()
-                        console.log(default_cid_type, '隐藏');
-                        if (default_cid_type) {
-                            for (let i = 0; i < selectRes.length; i++) {
-                                // let html = '';
-                                 if(selectRes[i].value == default_cid_type) {
-                                    console.log(selectRes[i].value, '接口的valie');
-                                    selectRes[i].selected = true
-                                // html = `<option value="${selectRes[i].value }">${selectRes[i].name }</option>`;
-                                // let select_type = `<select>${html}</select>`
-                                // electRes[i].selected = true
-                                // var select = 'dd[lay-value=' + selectRes[i].value + ']';// 设置value
-                                // $("#cid").find("option[value="+selectRes[i].value+"]").prop("selected",true);
-                                // let as = $('#cid').siblings("div.layui-form-select").find('dl').find(select).click()
-                                form.render('select')
-                        }
-                    }
-                }
-                        form.render('select')
-                })
-                 form.on('select(cid)', function (data) {
-                        let form_type = data.value;
-                        selectValue = data.value
-                        form.render('select')
-
-                    })
-            } else {
-                $('#cid').html('');
-                form.render('select')
-            }
-            form.on('select(type)', function (data) {
-                let form_type = data.value;
-                form.render('select')
-                if (form_type === 'merchant') {
-                    $.get('index.php?act=refill_order&op=merchant_data', function(res) {
-                        res = JSON.parse(res)
-                        let html = '';
-                        res.forEach(item => {
-                            html += `<option value="${item.value}">${item.name}</option>`;
-                        })
-                        let select_type = `<select>${html}</select>`
-                        $('#cid').html(select_type);
-                        form.render('select')
-
-                    })
-                } else if (form_type === 'provider'){
-                    $.get('index.php?act=refill_order&op=provider_data', function(res) {
-                        res = JSON.parse(res)
-                        let html = '';
-                        res.forEach(item => {
-                            html += `<option value="${item.value}">${item.name}</option>`;
-                        })
-                        let select_type = `<select>${html}</select>`
-                        $('#cid').html(select_type);
-                        form.render('select')
-                    })
-                    form.on('select(cid)', function (data) {
-                        let form_type = data.value;
-                        selectValue = data.value
-                        form.render('select')
-
-                    })
-                } else {
-                    $('#cid').html('');
-                    form.render('select')
-                }
-            })
-        })
     });
 </script> 

+ 1 - 1
admin/templates/default/system.order.stats.php

@@ -18,7 +18,7 @@
                 <li><a href="index.php?act=OrderStats&op=index&type=provider"><span>上游对账记录</span></a></li>
                 <li><a href="index.php?act=OrderStats&op=index&type=merchant"><span>下游对账记录</span></a></li>
 
-<!--                <li><a href="index.php?act=OrderStats&op=refill_task"><span>任务列表</span></a></li>-->
+                <li><a href="index.php?act=OrderStats&op=refill_task"><span>任务列表</span></a></li>
 <!--                <li><a href="index.php?act=OrderStats&op=task_add"><span>任务录入</span></a></li>-->
             </ul>
         </div>

+ 1 - 3
data/model/task.model.php

@@ -66,8 +66,6 @@ class taskModel extends Model
     public function Del($task_id)
     {
         $condition['task_id'] = $task_id;
-        return $this->where($condition)->update(
-            ['is_del' => 1]
-        );
+        return $this->where($condition)->delete();
     }
 }

BIN
helper/refill/api/xyz/guochuang/20211129广东移动调价函.png


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

@@ -72,7 +72,7 @@ class config
         "4-10-13" => 10.22, "4-20-13" => 19.94, "4-30-13" => 30.27, "4-50-13" => 50.3, "4-100-13" => 100.4, "4-200-13" => 200.6, "4-300-13" => 300.9, "4-500-13" => 501.5,//福建 13
         "4-10-5" => 10.02, "4-20-5" => 20.04, "4-30-5" => 30.06, "4-50-5" => 50.1, "4-100-5" => 100.2, "4-200-5" => 200.4, "4-300-5" => 300.6, "4-500-5" => 501,//内蒙古 5
         "4-30-18" => 29.835, "4-50-18" => 49.725, "4-100-18" => 99.45, "4-200-18" => 198.3,//湖南 18
-        "4-10-19" => 9.955, "4-20-19" => 19.91, "4-30-19" => 29.865, "4-50-19" => 49.775, "4-100-19" => 99.55, "4-200-19" => 199.1, "4-300-19" => 298.65, "4-500-19" => 497.75,//广东 19
+        "4-10-19" => 9.959, "4-20-19" => 19.918, "4-30-19" => 29.877, "4-50-19" => 49.795, "4-100-19" => 99.59, "4-200-19" => 199.18, "4-300-19" => 298.77, "4-500-19" => 497.95,//广东 19
         "4-10-7" => 9.885, "4-20-7" => 19.77, "4-30-7" => 29.655, "4-50-7" => 49.425, "4-100-7" => 98.85, "4-200-7" => 197.7, "4-300-7" => 296.55, "4-500-7" => 494.25,//吉林 7
         "4-10-1" => 10.31, "4-20-1" => 20.32, "4-30-1" => 30.33, "4-50-1" => 50.35, "4-100-1" => 100.4, "4-200-1" => 200.3, "4-300-1" => 300.45, "4-500-1" => 500.75,//北京 1
         "4-10-22" => 10.015, "4-20-22" => 20.03, "4-30-22" => 30.045, "4-50-22" => 50.075, "4-100-22" => 100.15, "4-200-22" => 200.3, "4-300-22" => 300.45, "4-500-22" => 500.75,//重庆 22

+ 68 - 2
helper/task/handler.php

@@ -1,9 +1,10 @@
 <?php
-
-
 namespace task;
 
 use Exception;
+use mtopcard;
+use PHPExcel;
+use PHPExcel_IOFactory;
 
 class handler
 {
@@ -53,4 +54,69 @@ class handler
     {
         return md5("refill_order_stat-".serialize($condition));
     }
+
+    public function refill_order_export($condition)
+    {
+        $orders = Model('refill_order')->getAllOrders($condition);
+        if (empty($orders)) {
+            return [false, '统计数据为空'];
+        }
+
+        $merchants = [];
+        $column_values = ['商户号', '商户名称', '商户订单号','平台单号', '面额', '充值卡号', '充值卡类型', '下单日期', '完成日期', '官方流水号', '订单状态', '扣款金额(下游)', '上游名称','上游订单号', '折扣金额(上游)'];
+        $data_keys = ['mchid', 'mch_name', 'mch_order', 'order_sn', 'refill_amount', 'card_no', 'card_type_text', 'order_time_text', 'notify_time_text', 'official_sn', 'order_state_text', 'mch_amount', 'channel_name', 'ch_trade_no', 'channel_amount'];
+        $merchant_list = Model('')->table('merchant')->limit(1000)->order('company_name asc')->select();
+        foreach ($merchant_list as $value) {
+            $merchants[$value['mchid']] = $value;
+        }
+        $column_key = 'A';
+        for($index=0;$index<count($column_values);$index++){
+            $column_keys[] = $column_key;
+            $column_key++;
+        }
+
+        $objPHPExcel = new PHPExcel();
+        $objPHPExcel->setActiveSheetIndex(0);
+        $objPHPExcel->getDefaultStyle()->getFont()->setName('Arial')->setSize(10);
+        foreach ($column_keys as $key => $column_key) {
+            $objPHPExcel->getActiveSheet()->getColumnDimension($column_key)->setWidth(15);
+            $cell_value = $column_key . 1;
+            $objPHPExcel->getActiveSheet()->setCellValue($cell_value, $column_values[$key]);
+        }
+
+        $card_type_texts = [mtopcard\PetroChinaCard => '中石油', mtopcard\SinopecCard => '中石化', mtopcard\ChinaMobileCard => '中国移动', mtopcard\ChinaUnicomCard => '中国联通', mtopcard\ChinaTelecomCard => '中国电信'];
+        foreach ($orders as $k => $order) {
+            if(!empty($merchants)) {
+                $order['mch_name'] = $merchants[$order['mchid']]['company_name'];
+            }
+            $order['card_type_text'] = $card_type_texts[$order['card_type']];
+            $order['order_time_text'] = $order['order_time'] ? date('Y-m-d H:i:s', $order['order_time']) : '';
+            $order['notify_time_text'] = $order['notify_time'] ? date('Y-m-d H:i:s', $order['notify_time']) : '';
+            $order['order_state_text'] = orderState($order);
+            foreach ($column_keys as $key => $column_key) {
+                $field = $column_key . ($k + 2);
+                $objPHPExcel->getActiveSheet()->setCellValueExplicit($field, $order[$data_keys[$key]]);
+            }
+        }
+        try {
+            $path = BASE_ROOT_PATH . "/data/upload/task/";
+            if (!is_dir($path)) {
+                mkdir($path, 0755);
+            }
+            $filename = date('YmdHis', time()) . "-订单导出.xlsx";
+
+            $file_path = $path . $filename;
+            $objWriter = PHPExcel_IOFactory::createWriter($objPHPExcel, 'Excel2007');
+
+            $objWriter->save($file_path);
+            return [true, $filename];
+        } catch (Exception $e) {
+            return [false, false];
+        }
+    }
+
+    public function refill_order_export_title($condition)
+    {
+        return md5("refill_order_export-".serialize($condition));
+    }
 }

+ 5 - 0
helper/task/task_wrapper.php

@@ -26,6 +26,11 @@ class task_wrapper
         return $this->mRecord['result_state'] == 1;
     }
 
+    public function task_id()
+    {
+        return $this->mRecord['task_id'];
+    }
+
     public function result()
     {
         if($this->success()) {