|
@@ -153,40 +153,47 @@ class stat_refill
|
|
{
|
|
{
|
|
$cond = [
|
|
$cond = [
|
|
'refill_order.inner_status' => 0,
|
|
'refill_order.inner_status' => 0,
|
|
- 'vr_order.order_state' => ORDER_STATE_SUCCESS,
|
|
|
|
"refill_order.{$order_time_type}&refill_order.{$order_time_type}" => ['_multi' => true, ['egt', $day_time], ['lt', $day_time + stat_refill::DaySecs]],
|
|
"refill_order.{$order_time_type}&refill_order.{$order_time_type}" => ['_multi' => true, ['egt', $day_time], ['lt', $day_time + stat_refill::DaySecs]],
|
|
];
|
|
];
|
|
|
|
|
|
- $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')
|
|
|
|
- ->join('inner')
|
|
|
|
- ->on('refill_order.order_id=vr_order.order_id')
|
|
|
|
- ->where($cond)
|
|
|
|
- ->group('mchid')
|
|
|
|
- ->select();
|
|
|
|
-
|
|
|
|
- foreach ($items as $item)
|
|
|
|
|
|
+ foreach ($this->mMerchantNames as $mchid => $cname)
|
|
{
|
|
{
|
|
|
|
+ $mchid = intval($mchid);
|
|
|
|
+ if($mchid <= 0) continue;
|
|
|
|
+ if($cur_mchid != 0 && $cur_mchid != $mchid) continue;
|
|
|
|
+ $cond['refill_order.mchid'] = $mchid;
|
|
|
|
+ $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')
|
|
|
|
+ ->join('inner')
|
|
|
|
+ ->on('refill_order.order_id=vr_order.order_id')
|
|
|
|
+ ->where($cond)
|
|
|
|
+ ->group('order_state')
|
|
|
|
+ ->select();
|
|
|
|
+ if(empty($items)) continue;
|
|
|
|
+
|
|
$params = [];
|
|
$params = [];
|
|
|
|
+
|
|
$params['time_text'] = date("Y-m-d" , $day_time);
|
|
$params['time_text'] = date("Y-m-d" , $day_time);
|
|
$params['time_stamp'] = $day_time;
|
|
$params['time_stamp'] = $day_time;
|
|
$params['type'] = 'merchant';
|
|
$params['type'] = 'merchant';
|
|
$params['order_time_type'] = $order_time_type;
|
|
$params['order_time_type'] = $order_time_type;
|
|
-
|
|
|
|
- $mchid = intval($item['mchid']);
|
|
|
|
- if($mchid <= 0) continue;
|
|
|
|
- if($cur_mchid != 0 && $cur_mchid != $mchid) continue;
|
|
|
|
-
|
|
|
|
$params['cid'] = $mchid;
|
|
$params['cid'] = $mchid;
|
|
- if(!array_key_exists($mchid,$this->mMerchantNames)) continue;
|
|
|
|
- $params['cname'] = $this->mMerchantNames[$mchid];
|
|
|
|
-
|
|
|
|
- $params['success_count'] = $item['order_count'];
|
|
|
|
- $params['success_refill_amounts'] = $item['refill_amounts'];
|
|
|
|
- $params['success_channel_amounts'] = $item['channel_amounts'];
|
|
|
|
- $params['success_mch_amounts'] = $item['mch_amounts'];
|
|
|
|
- $params['profit_amounts'] = $item['mch_amounts'] - $item['channel_amounts'];
|
|
|
|
-
|
|
|
|
|
|
+ $params['cname'] = $cname;
|
|
|
|
+ foreach ($items as $item)
|
|
|
|
+ {
|
|
|
|
+ $order_state = $item['order_state'];
|
|
|
|
+ if ($order_state == ORDER_STATE_SUCCESS) {
|
|
|
|
+ $params['success_count'] = $item['order_count'];
|
|
|
|
+ $params['success_refill_amounts'] = $item['refill_amounts'];
|
|
|
|
+ $params['success_channel_amounts'] = $item['channel_amounts'];
|
|
|
|
+ $params['success_mch_amounts'] = $item['mch_amounts'];
|
|
|
|
+ $params['profit_amounts'] = $item['mch_amounts'] - $item['channel_amounts'];
|
|
|
|
+ } elseif ($order_state == ORDER_STATE_CANCEL) {
|
|
|
|
+ $params['cancel_count'] = $item['order_count'];
|
|
|
|
+ } else {
|
|
|
|
+ $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{
|
|
}else{
|
|
@@ -199,41 +206,48 @@ class stat_refill
|
|
{
|
|
{
|
|
$cond = [
|
|
$cond = [
|
|
'refill_order.inner_status' => 0,
|
|
'refill_order.inner_status' => 0,
|
|
- 'vr_order.order_state' => ORDER_STATE_SUCCESS,
|
|
|
|
"refill_order.{$order_time_type}&refill_order.{$order_time_type}" => ['_multi' => true, ['egt', $day_time], ['lt', $day_time + stat_refill::DaySecs]],
|
|
"refill_order.{$order_time_type}&refill_order.{$order_time_type}" => ['_multi' => true, ['egt', $day_time], ['lt', $day_time + stat_refill::DaySecs]],
|
|
];
|
|
];
|
|
|
|
|
|
- $items = Model('')->table('refill_order,vr_order')
|
|
|
|
- ->field('vr_order.store_id, count(*) as order_count, sum(refill_amount) as refill_amounts, sum(channel_amount) as channel_amounts, sum(mch_amount) as mch_amounts')
|
|
|
|
- ->join('inner')
|
|
|
|
- ->on('refill_order.order_id=vr_order.order_id')
|
|
|
|
- ->where($cond)
|
|
|
|
- ->group('vr_order.store_id')
|
|
|
|
- ->select();
|
|
|
|
-
|
|
|
|
- foreach ($items as $item)
|
|
|
|
|
|
+ foreach ($this->mProviderNames as $store_id => $cname)
|
|
{
|
|
{
|
|
|
|
+ $store_id = intval($store_id);
|
|
|
|
+ if($store_id <= 0) continue;
|
|
|
|
+ if($cur_storeid != 0 && $cur_storeid != $store_id) continue;
|
|
|
|
+
|
|
|
|
+ $cond['vr_order.store_id'] = $store_id;
|
|
|
|
+ $items = Model('')->table('refill_order,vr_order')
|
|
|
|
+ ->field('vr_order.store_id, count(*) as order_count, sum(refill_amount) as refill_amounts, sum(channel_amount) as channel_amounts, sum(mch_amount) as mch_amounts, order_state')
|
|
|
|
+ ->join('inner')
|
|
|
|
+ ->on('refill_order.order_id=vr_order.order_id')
|
|
|
|
+ ->where($cond)
|
|
|
|
+ ->group('order_state')
|
|
|
|
+ ->select();
|
|
|
|
+ if(empty($items)) continue;
|
|
|
|
+
|
|
$params = [];
|
|
$params = [];
|
|
$params['time_text'] = date("Y-m-d" , $day_time);
|
|
$params['time_text'] = date("Y-m-d" , $day_time);
|
|
$params['time_stamp'] = $day_time;
|
|
$params['time_stamp'] = $day_time;
|
|
$params['type'] = 'provider';
|
|
$params['type'] = 'provider';
|
|
$params['order_time_type'] = $order_time_type;
|
|
$params['order_time_type'] = $order_time_type;
|
|
-
|
|
|
|
- $store_id = intval($item['store_id']);
|
|
|
|
- if($store_id <= 0) continue;
|
|
|
|
- if($cur_storeid != 0 && $cur_storeid != $store_id) continue;
|
|
|
|
-
|
|
|
|
$params['cid'] = $store_id;
|
|
$params['cid'] = $store_id;
|
|
- if(!array_key_exists($store_id,$this->mProviderNames)) continue;
|
|
|
|
- $params['cname'] = $this->mProviderNames[$store_id];
|
|
|
|
-
|
|
|
|
-
|
|
|
|
- $params['success_count'] = $item['order_count'];
|
|
|
|
- $params['success_refill_amounts'] = $item['refill_amounts'];
|
|
|
|
- $params['success_channel_amounts'] = $item['channel_amounts'];
|
|
|
|
- $params['success_mch_amounts'] = $item['mch_amounts'];
|
|
|
|
- $params['profit_amounts'] = $item['mch_amounts'] - $item['channel_amounts'];
|
|
|
|
-
|
|
|
|
|
|
+ $params['cname'] = $cname;
|
|
|
|
+
|
|
|
|
+ foreach ($items as $item)
|
|
|
|
+ {
|
|
|
|
+ $order_state = $item['order_state'];
|
|
|
|
+ if ($order_state == ORDER_STATE_SUCCESS) {
|
|
|
|
+ $params['success_count'] = $item['order_count'];
|
|
|
|
+ $params['success_refill_amounts'] = $item['refill_amounts'];
|
|
|
|
+ $params['success_channel_amounts'] = $item['channel_amounts'];
|
|
|
|
+ $params['success_mch_amounts'] = $item['mch_amounts'];
|
|
|
|
+ $params['profit_amounts'] = $item['mch_amounts'] - $item['channel_amounts'];
|
|
|
|
+ } elseif ($order_state == ORDER_STATE_CANCEL) {
|
|
|
|
+ $params['cancel_count'] = $item['order_count'];
|
|
|
|
+ } else {
|
|
|
|
+ $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{
|
|
}else{
|