|
@@ -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']);
|
|
|
+ }
|
|
|
}
|