|
@@ -67,10 +67,10 @@ class stat_refill
|
|
$end_tm = $this->end_day();
|
|
$end_tm = $this->end_day();
|
|
for($start_tm = $this->lastest_day(); $start_tm < $end_tm; $start_tm += stat_refill::DaySecs)
|
|
for($start_tm = $this->lastest_day(); $start_tm < $end_tm; $start_tm += stat_refill::DaySecs)
|
|
{
|
|
{
|
|
- $order_count = $this->system_stat($start_tm);
|
|
|
|
|
|
+ $order_count = $this->system_stat($start_tm,'notify_time');
|
|
if ($order_count > 0) {
|
|
if ($order_count > 0) {
|
|
- $this->merchant_stat($start_tm);
|
|
|
|
- $this->provider_stat($start_tm);
|
|
|
|
|
|
+ $this->merchant_stat($start_tm,'notify_time');
|
|
|
|
+ $this->provider_stat($start_tm,'notify_time');
|
|
}
|
|
}
|
|
|
|
|
|
$order_count = $this->system_stat($start_tm,'order_time');
|
|
$order_count = $this->system_stat($start_tm,'order_time');
|
|
@@ -83,11 +83,21 @@ class stat_refill
|
|
|
|
|
|
private function system_stat($day_time, $order_time_type='notify_time')
|
|
private function system_stat($day_time, $order_time_type='notify_time')
|
|
{
|
|
{
|
|
|
|
+ $end_time = $day_time + stat_refill::DaySecs;
|
|
$cond = [
|
|
$cond = [
|
|
'refill_order.inner_status' => 0,
|
|
'refill_order.inner_status' => 0,
|
|
- "refill_order.{$order_time_type}&refill_order.{$order_time_type}" => ['_multi' => true, ['egt', $day_time], ['lt', $day_time + stat_refill::DaySecs]]
|
|
|
|
];
|
|
];
|
|
|
|
|
|
|
|
+ if($order_time_type == 'notify_time') {
|
|
|
|
+ $cond["refill_order.notify_time&refill_order.notify_time"] = ['_multi' => true, ['egt', $day_time], ['lt', $end_time]];
|
|
|
|
+ $cond["refill_order.order_time&refill_order.order_time"] = ['_multi' => true, ['egt', $day_time - 3 * stat_refill::DaySecs], ['lt', $end_time]];
|
|
|
|
+ $cond["vr_order.add_time&vr_order.add_time"] = ['_multi' => true, ['egt', $day_time - 3 * stat_refill::DaySecs], ['lt', $end_time]];
|
|
|
|
+ }
|
|
|
|
+ else {
|
|
|
|
+ $cond["refill_order.order_time&refill_order.order_time"] = ['_multi' => true, ['egt', $day_time], ['lt', $end_time]];
|
|
|
|
+ $cond["vr_order.add_time&vr_order.add_time"] = ['_multi' => true, ['egt', $day_time], ['lt', time()]];
|
|
|
|
+ }
|
|
|
|
+
|
|
$items = Model('')->table('refill_order,vr_order')
|
|
$items = Model('')->table('refill_order,vr_order')
|
|
->field('order_state, count(*) as order_count, sum(refill_amount) as refill_amounts, sum(channel_amount) as channel_amounts, sum(mch_amount) as mch_amounts')
|
|
->field('order_state, count(*) as order_count, sum(refill_amount) as refill_amounts, sum(channel_amount) as channel_amounts, sum(mch_amount) as mch_amounts')
|
|
->join('inner')
|
|
->join('inner')
|
|
@@ -151,16 +161,27 @@ class stat_refill
|
|
|
|
|
|
public function merchant_stat($day_time,$cur_mchid = 0,$order_time_type='notify_time')
|
|
public function merchant_stat($day_time,$cur_mchid = 0,$order_time_type='notify_time')
|
|
{
|
|
{
|
|
|
|
+ $end_time = $day_time + stat_refill::DaySecs;
|
|
$cond = [
|
|
$cond = [
|
|
'refill_order.inner_status' => 0,
|
|
'refill_order.inner_status' => 0,
|
|
- "refill_order.{$order_time_type}&refill_order.{$order_time_type}" => ['_multi' => true, ['egt', $day_time], ['lt', $day_time + stat_refill::DaySecs]],
|
|
|
|
];
|
|
];
|
|
|
|
|
|
|
|
+ if($order_time_type == 'notify_time') {
|
|
|
|
+ $cond["refill_order.notify_time&refill_order.notify_time"] = ['_multi' => true, ['egt', $day_time], ['lt', $end_time]];
|
|
|
|
+ $cond["refill_order.order_time&refill_order.order_time"] = ['_multi' => true, ['egt', $day_time - 3 * stat_refill::DaySecs], ['lt', $end_time]];
|
|
|
|
+ $cond["vr_order.add_time&vr_order.add_time"] = ['_multi' => true, ['egt', $day_time - 3 * stat_refill::DaySecs], ['lt', $end_time]];
|
|
|
|
+ }
|
|
|
|
+ else {
|
|
|
|
+ $cond["refill_order.order_time&refill_order.order_time"] = ['_multi' => true, ['egt', $day_time], ['lt', $end_time]];
|
|
|
|
+ $cond["vr_order.add_time&vr_order.add_time"] = ['_multi' => true, ['egt', $day_time], ['lt', time()]];
|
|
|
|
+ }
|
|
|
|
+
|
|
foreach ($this->mMerchantNames as $mchid => $cname)
|
|
foreach ($this->mMerchantNames as $mchid => $cname)
|
|
{
|
|
{
|
|
$mchid = intval($mchid);
|
|
$mchid = intval($mchid);
|
|
if($mchid <= 0) continue;
|
|
if($mchid <= 0) continue;
|
|
if($cur_mchid != 0 && $cur_mchid != $mchid) continue;
|
|
if($cur_mchid != 0 && $cur_mchid != $mchid) continue;
|
|
|
|
+
|
|
$cond['refill_order.mchid'] = $mchid;
|
|
$cond['refill_order.mchid'] = $mchid;
|
|
$items = Model('')->table('refill_order,vr_order')
|
|
$items = Model('')->table('refill_order,vr_order')
|
|
->field('mchid, count(*) as order_count, sum(refill_amount) as refill_amounts, sum(channel_amount) as channel_amounts, sum(mch_amount) as mch_amounts, order_state')
|
|
->field('mchid, count(*) as order_count, sum(refill_amount) as refill_amounts, sum(channel_amount) as channel_amounts, sum(mch_amount) as mch_amounts, order_state')
|
|
@@ -194,23 +215,33 @@ class stat_refill
|
|
$params['send_count'] = $item['order_count'];
|
|
$params['send_count'] = $item['order_count'];
|
|
}
|
|
}
|
|
}
|
|
}
|
|
- if($cur_mchid != 0 && $cur_mchid == $mchid) {
|
|
|
|
|
|
+ if ($cur_mchid != 0 && $cur_mchid == $mchid) {
|
|
Model('')->table('refill_stats')->where(['time_stamp' => $day_time, 'cid' => $cur_mchid, 'type' => 'merchant', 'order_time_type' => $order_time_type])->update($params);
|
|
Model('')->table('refill_stats')->where(['time_stamp' => $day_time, 'cid' => $cur_mchid, 'type' => 'merchant', 'order_time_type' => $order_time_type])->update($params);
|
|
- }else{
|
|
|
|
- if(!empty($params['success_count'])) {
|
|
|
|
- Model('')->table('refill_stats')->insert($params);
|
|
|
|
- }
|
|
|
|
|
|
+ } elseif (!empty($params['success_count'])) {
|
|
|
|
+ Model('')->table('refill_stats')->insert($params);
|
|
|
|
+ } else {
|
|
|
|
+
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
public function provider_stat($day_time,$cur_storeid = 0,$order_time_type='notify_time')
|
|
public function provider_stat($day_time,$cur_storeid = 0,$order_time_type='notify_time')
|
|
{
|
|
{
|
|
|
|
+ $end_time = $day_time + stat_refill::DaySecs;
|
|
$cond = [
|
|
$cond = [
|
|
'refill_order.inner_status' => 0,
|
|
'refill_order.inner_status' => 0,
|
|
- "refill_order.{$order_time_type}&refill_order.{$order_time_type}" => ['_multi' => true, ['egt', $day_time], ['lt', $day_time + stat_refill::DaySecs]],
|
|
|
|
];
|
|
];
|
|
|
|
|
|
|
|
+ if($order_time_type == 'notify_time') {
|
|
|
|
+ $cond["refill_order.notify_time&refill_order.notify_time"] = ['_multi' => true, ['egt', $day_time], ['lt', $end_time]];
|
|
|
|
+ $cond["refill_order.order_time&refill_order.order_time"] = ['_multi' => true, ['egt', $day_time - 3 * stat_refill::DaySecs], ['lt', $end_time]];
|
|
|
|
+ $cond["vr_order.add_time&vr_order.add_time"] = ['_multi' => true, ['egt', $day_time - 3 * stat_refill::DaySecs], ['lt', $end_time]];
|
|
|
|
+ }
|
|
|
|
+ else {
|
|
|
|
+ $cond["refill_order.order_time&refill_order.order_time"] = ['_multi' => true, ['egt', $day_time], ['lt', $end_time]];
|
|
|
|
+ $cond["vr_order.add_time&vr_order.add_time"] = ['_multi' => true, ['egt', $day_time], ['lt', time()]];
|
|
|
|
+ }
|
|
|
|
+
|
|
foreach ($this->mProviderNames as $store_id => $cname)
|
|
foreach ($this->mProviderNames as $store_id => $cname)
|
|
{
|
|
{
|
|
$store_id = intval($store_id);
|
|
$store_id = intval($store_id);
|
|
@@ -250,12 +281,12 @@ class stat_refill
|
|
$params['send_count'] = $item['order_count'];
|
|
$params['send_count'] = $item['order_count'];
|
|
}
|
|
}
|
|
}
|
|
}
|
|
- if($cur_storeid != 0 && $cur_storeid == $store_id) {
|
|
|
|
|
|
+ if ($cur_storeid != 0 && $cur_storeid == $store_id) {
|
|
Model('')->table('refill_stats')->where(['time_stamp' => $day_time, 'cid' => $cur_storeid, 'type' => 'provider', 'order_time_type' => $order_time_type])->update($params);
|
|
Model('')->table('refill_stats')->where(['time_stamp' => $day_time, 'cid' => $cur_storeid, 'type' => 'provider', 'order_time_type' => $order_time_type])->update($params);
|
|
- }else{
|
|
|
|
- if(!empty($params['success_count'])) {
|
|
|
|
- Model('')->table('refill_stats')->insert($params);
|
|
|
|
- }
|
|
|
|
|
|
+ } elseif (!empty($params['success_count'])) {
|
|
|
|
+ Model('')->table('refill_stats')->insert($params);
|
|
|
|
+ } else {
|
|
|
|
+
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|