Browse Source

admin update

haru haru 2 years ago
parent
commit
28ebfd4e3e

+ 74 - 0
admin/control/orderstats.php

@@ -271,4 +271,78 @@ class orderstatsControl extends SystemControl
         $balance_ids = $_GET['balance_ids'];
         showMessage('操作成功!');
     }
+
+    public function refill_balance_stat_cfgOp()
+    {
+        $type = $_POST['type'];
+        $items = $result = [];
+        $key = $cache = '';
+        if ($type === 'provider') {
+            $items = $this->providers();
+            $key = 'store_id';
+            $cache = 'provider_balance-stat_cfg';
+        } elseif ($type === 'merchant') {
+            $items = $this->merchants();
+            $key = 'mchid';
+            $cache = 'merchant_balance-stat_cfg';
+        } else {
+            showMessage('类型错误!');
+        }
+        $statType = $_POST['statType'];
+        if(empty($statType)) {
+            showMessage('操作成功!');
+        }
+        foreach ($items as $item) {
+            $cid = $item[$key];
+            if (!empty($statType[$cid]) && array_key_exists($cid, $statType)) {
+                foreach ($statType[$cid] as $value) {
+                    $result[$cid][] = $value;
+                }
+            }
+        }
+        wcache($cache, ['data' => serialize($result)], 'refill-');
+        showMessage('操作成功!');
+    }
+
+    public function balance_cfg_dataOp()
+    {
+        $type = $_GET['type'];
+        $result = [];
+        if ($type === 'provider') {
+            $items = $this->providers();
+            $cache = $this->balance_cfg_cache('provider_balance-stat_cfg');
+            foreach ($items as $item) {
+                $data['name'] = $item['store_name'] ?? $item['name'];
+                $data['value'] = $item['store_id'];
+                if(!empty($cache[$item['store_id']]) && array_key_exists($item['store_id'], $cache)) {
+                    $data['order_time_type'] = $cache[$item['store_id']];
+                }else{
+                    $data['order_time_type'] = [];
+                }
+                $result[] = $data;
+            }
+        } elseif ($type === 'merchant') {
+            $items = $this->merchants();
+            $cache = $this->balance_cfg_cache('merchant_balance-stat_cfg');
+            foreach ($items as $item) {
+                $data['name'] = $item['company_name'] ?? $item['name'];
+                $data['value'] = $item['mchid'];
+                if (!empty($cache[$item['mchid']]) && array_key_exists($item['mchid'], $cache)) {
+                    $data['order_time_type'] = $cache[$item['mchid']];
+                } else {
+                    $data['order_time_type'] = [];
+                }
+                $result[] = $data;
+            }
+        } else {
+            echo json_encode([]);
+        }
+        echo json_encode($result);
+    }
+
+    private function balance_cfg_cache($cache)
+    {
+        $mch_cache = rcache($cache, 'refill-');
+        return empty($mch_cache['data']) ? [] : unserialize($mch_cache['data']);
+    }
 }

+ 6 - 7
admin/templates/default/merchant.refill.balance.php

@@ -565,26 +565,25 @@
 
 
         $('#editStatType').click(function() {
-            $.get('index.php?act=refill_order&op=merchant_data', function(res) {
+            $.get('index.php?act=OrderStats&op=balance_cfg_data&type=merchant', function(res) {
                 console.log('provider_data', JSON.parse(res));
 
                 if (res) {
                     const datas = JSON.parse(res);
-                    let tableHTML = `<form id="editStatTypeForm">
+                    let tableHTML = `<form id="editStatTypeForm" method="post" action="index.php?act=OrderStats&op=refill_balance_stat_cfg">
                     <div style="width:500px;">
                     <table class="editStatTypeTable">
+                        <input type="hidden" value="merchant" name="type">
                     <thead>
                         <th>主体名称</th>
                         <th style="width:100px;">回调时间</th>
                         <th style="width:100px;">下单时间</th>
-                        <th style="width:100px;">无</th>
                     </thead>`;
                     datas.map((item, index) => {
                         tableHTML += `<tr>
                             <td>${item.name}</td>
-                            <td style="width:100px;"><label><input type="radio" name="statType-${index}" /></label></td>
-                            <td style="width:100px;"><label><input type="radio" name="statType-${index}" /></label></td>
-                            <td style="width:100px;"><label><input type="radio" name="statType-${index}" /></label></td>
+                            <td style="width:100px;"><label><input type="checkbox" name="statType[${item.value}][]" value="order_time" /></label></td>
+                            <td style="width:100px;"><label><input type="checkbox" name="statType[${item.value}][]" value="notify_time"/></label></td>
                         </tr>`
                     })
 
@@ -595,7 +594,7 @@
                         layer.open({
                             btn: ['确定', '取消'],
                             yes: function() {
-                                alert('确定提交');
+                                $('#editStatTypeForm').submit();
                             },
                             btn2: function() {
                                 console.log('取消');

+ 5 - 5
admin/templates/default/provider.refill.balance.php

@@ -552,14 +552,15 @@
 
 
         $('#editStatType').click(function() {
-            $.get('index.php?act=refill_order&op=provider_data', function(res) {
+            $.get('index.php?act=OrderStats&op=balance_cfg_data&type=provider', function(res) {
                 console.log('provider_data', JSON.parse(res));
 
                 if (res) {
                     const datas = JSON.parse(res);
-                    let tableHTML = `<form id="editStatTypeForm" method="post" action="/">
+                    let tableHTML = `<form id="editStatTypeForm" method="post" action="index.php?act=OrderStats&op=refill_balance_stat_cfg">
                     <div style="width:500px;">
                     <table class="editStatTypeTable">
+                        <input type="hidden" value="provider" name="type">
                     <thead>
                         <th>主体名称</th>
                         <th style="width:100px;">回调时间</th>
@@ -568,8 +569,8 @@
                     datas.map((item, index) => {
                         tableHTML += `<tr>
                             <td>${item.name}</td>
-                            <td style="width:100px;"><label><input type="checkbox" name="statType-${item.value}[]" value="order_time"/></label></td>
-                            <td style="width:100px;"><label><input type="checkbox" name="statType-${item.value}[]" value="notify_time"/></label></td>
+                            <td style="width:100px;"><label><input type="checkbox" name="statType[${item.value}][]" value="order_time"/></label></td>
+                            <td style="width:100px;"><label><input type="checkbox" name="statType[${item.value}][]" value="notify_time"/></label></td>
                         </tr>`
                     })
 
@@ -580,7 +581,6 @@
                         layer.open({
                             btn: ['确定', '取消'],
                             yes: function() {
-                                alert('确定提交');
                                 $('#editStatTypeForm').submit();
                             },
                             btn2: function() {