|
@@ -12,6 +12,8 @@ class refill_balance
|
|
|
private $mProviderNames = [];
|
|
|
private $mStoreidPID = [];
|
|
|
|
|
|
+ private $mTimesTypes = [];
|
|
|
+
|
|
|
public function __construct()
|
|
|
{
|
|
|
$mod_merchant = Model('merchant');
|
|
@@ -31,6 +33,28 @@ class refill_balance
|
|
|
$this->mProviderNames[$store_id] = $item['store_name'];
|
|
|
$this->mStoreidPID[$store_id] = intval($item['provider_id']);
|
|
|
}
|
|
|
+
|
|
|
+ $cfg_reader = function ($name, $field) {
|
|
|
+ $data = rcache($name, 'refill-', $field);
|
|
|
+ $val = $data[$field] ?? serialize([]);
|
|
|
+ return unserialize($val);
|
|
|
+ };
|
|
|
+
|
|
|
+ $this->mTimesTypes['system'] = [0 => ['order_time']];
|
|
|
+ $this->mTimesTypes['merchant'] = $cfg_reader('balance-cfg','merchant');
|
|
|
+ $this->mTimesTypes['provider'] = $cfg_reader('balance-cfg','provider');
|
|
|
+ }
|
|
|
+
|
|
|
+ private function find_timetypes($type,$cid)
|
|
|
+ {
|
|
|
+ if(array_key_exists($type,$this->mTimesTypes))
|
|
|
+ {
|
|
|
+ if(array_key_exists($cid,$this->mTimesTypes[$type])) {
|
|
|
+ return $this->mTimesTypes[$type][$cid];
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ return [];
|
|
|
}
|
|
|
|
|
|
public function stat_all($start, $end)
|
|
@@ -54,7 +78,7 @@ class refill_balance
|
|
|
};
|
|
|
|
|
|
$types = ['system','merchant','provider'];
|
|
|
- $time_types = ['order_time','notify_time'];
|
|
|
+ //time types == 'order_time','notify_time'
|
|
|
foreach ($types as $type)
|
|
|
{
|
|
|
if ($type == 'system') {
|
|
@@ -65,9 +89,10 @@ class refill_balance
|
|
|
$cids = $store_ids();
|
|
|
}
|
|
|
|
|
|
- foreach ($time_types as $time_type)
|
|
|
+ foreach ($cids as $cid)
|
|
|
{
|
|
|
- foreach ($cids as $cid)
|
|
|
+ $time_types = $this->find_timetypes($type,$cid);
|
|
|
+ foreach ($time_types as $time_type)
|
|
|
{
|
|
|
$parent_id = $this->find_parent($type, $cid, $start, $time_type);
|
|
|
$ret = $this->add_balance($type, $cid, $start, $end, $time_type, $parent_id);
|