|
@@ -15,7 +15,7 @@ class merchant_infoControl extends mbMerchantControl
|
|
$merchant_info = $model_merchant->getMerchantInfo(['mchid' => $mchid], 'mchid,admin_id,name,alarm_amount,ip_white_list,use_key');
|
|
$merchant_info = $model_merchant->getMerchantInfo(['mchid' => $mchid], 'mchid,admin_id,name,alarm_amount,ip_white_list,use_key');
|
|
$model_member = Model('member');
|
|
$model_member = Model('member');
|
|
$member_info = $model_member->getMemberInfo(['member_id' => $merchant_info['admin_id']], 'available_predeposit');
|
|
$member_info = $model_member->getMemberInfo(['member_id' => $merchant_info['admin_id']], 'available_predeposit');
|
|
- if(empty($member_info)){
|
|
|
|
|
|
+ if (empty($member_info)) {
|
|
$member_info['available_predeposit'] = 0;
|
|
$member_info['available_predeposit'] = 0;
|
|
}
|
|
}
|
|
$merchant_info['member'] = $member_info;
|
|
$merchant_info['member'] = $member_info;
|
|
@@ -35,28 +35,79 @@ class merchant_infoControl extends mbMerchantControl
|
|
$merchant_info = $model_merchant->getMerchantInfo(['mchid' => $mchid], 'mchid,admin_id,name');
|
|
$merchant_info = $model_merchant->getMerchantInfo(['mchid' => $mchid], 'mchid,admin_id,name');
|
|
$model_member = Model('member');
|
|
$model_member = Model('member');
|
|
$member_info = $model_member->getMemberInfo(['member_id' => $merchant_info['admin_id']], 'available_predeposit');
|
|
$member_info = $model_member->getMemberInfo(['member_id' => $merchant_info['admin_id']], 'available_predeposit');
|
|
- if(empty($member_info)){
|
|
|
|
|
|
+ if (empty($member_info)) {
|
|
$merchant_info['available_predeposit'] = 0;
|
|
$merchant_info['available_predeposit'] = 0;
|
|
- }else{
|
|
|
|
|
|
+ } else {
|
|
$merchant_info['available_predeposit'] = $member_info['available_predeposit'];
|
|
$merchant_info['available_predeposit'] = $member_info['available_predeposit'];
|
|
}
|
|
}
|
|
|
|
|
|
- $cond['mchid'] = $mchid;
|
|
|
|
- $cond['inner_status'] = 0;
|
|
|
|
- $beginToday = mktime(0, 0, 0, date('m'), date('d'), date('Y'));
|
|
|
|
- $endToday = mktime(0, 0, 0, date('m'), date('d') + 1, date('Y')) - 1;
|
|
|
|
- $cond['refill_order.order_time'] = ['between', [$beginToday, $endToday]];
|
|
|
|
- $todayStatistics = $this->MerchantOrderStatistics($cond);
|
|
|
|
- $beginThisWeek = mktime(0, 0, 0, date('m'), date('d') - date('w') + 1, date('y'));
|
|
|
|
- $endThisWeek = time();
|
|
|
|
- $cond['refill_order.order_time'] = ['between', [$beginThisWeek, $endThisWeek]];
|
|
|
|
- $weeksStatistics = $this->WeeksMerchantOrderStatistics($cond);
|
|
|
|
|
|
+ $statistics = $this->statistics();
|
|
|
|
+
|
|
$result['merchant_info'] = $merchant_info;
|
|
$result['merchant_info'] = $merchant_info;
|
|
- $result['todayStatistics'] = $todayStatistics;
|
|
|
|
- $result['weeksStatistics'] = $weeksStatistics;
|
|
|
|
|
|
+ $result['todayStatistics'] = $statistics[0];
|
|
|
|
+ $result['weeksStatistics'] = $statistics;
|
|
return self::outsuccess($result);
|
|
return self::outsuccess($result);
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ private function statistics()
|
|
|
|
+ {
|
|
|
|
+ $cond['mchid'] = $this->mchid();
|
|
|
|
+ $cond['inner_status'] = 0;
|
|
|
|
+ $begin_time = $this->date_time();
|
|
|
|
+ $cond['order_time'] = ['egt', $begin_time];
|
|
|
|
+
|
|
|
|
+ $result = [];
|
|
|
|
+ for ($ftime = $begin_time, $i = 0; $ftime < time(); $ftime += 86400, $i += 1) {
|
|
|
|
+ $result[$i] = ['count' => 0, 'successCount' => 0, 'errorCount' => 0, 'otherCount' => 0, 'amountCount' => 0];
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ $model_refill_order = Model('refill_order');
|
|
|
|
+
|
|
|
|
+ $i = 0;
|
|
|
|
+ while (true)
|
|
|
|
+ {
|
|
|
|
+ $start = $i * 1000;
|
|
|
|
+ $orders = $model_refill_order->getMerchantOrderList($cond,'','*', 'refill_order.order_id desc',"{$start},1000");
|
|
|
|
+
|
|
|
|
+ if (empty($orders)) {
|
|
|
|
+ break;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ $days_calc = function ($order_time) use ($begin_time) {
|
|
|
|
+ $period = $order_time - $begin_time;
|
|
|
|
+ $days = intval($period / 86400) + ($period % 86400 > 0 ? 1 : 0);
|
|
|
|
+ return $days;
|
|
|
|
+ };
|
|
|
|
+
|
|
|
|
+ foreach ($orders as $order)
|
|
|
|
+ {
|
|
|
|
+ $order_day = $days_calc($order['order_time']);
|
|
|
|
+
|
|
|
|
+ $result[$order_day]['count'] += 1;
|
|
|
|
+ if ($order['order_state'] == ORDER_STATE_CANCEL) {
|
|
|
|
+ $result[$order_day]['errorCount'] += 1;
|
|
|
|
+ } elseif ($order['order_state'] == ORDER_STATE_SUCCESS) {
|
|
|
|
+ $result[$order_day]['successCount'] += 1;
|
|
|
|
+ $result[$order_day]['amountCount'] += $order['mch_amount'];;
|
|
|
|
+ } else {
|
|
|
|
+ $result[$order_day]['otherCount'] += 1;
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ return $result;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ private function date_time($days = 6)
|
|
|
|
+ {
|
|
|
|
+ $date = date('Y-m-d', time());
|
|
|
|
+ $day_start = strtotime("{$date}");
|
|
|
|
+ $begin = $day_start - $days * 86400;
|
|
|
|
+ return $begin;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+
|
|
public function addipOp()
|
|
public function addipOp()
|
|
{
|
|
{
|
|
$mchid = $this->mchid();
|
|
$mchid = $this->mchid();
|
|
@@ -160,7 +211,7 @@ class merchant_infoControl extends mbMerchantControl
|
|
return self::outerr(errcode::ErrMemberNotExist, "用户不存在.");
|
|
return self::outerr(errcode::ErrMemberNotExist, "用户不存在.");
|
|
}
|
|
}
|
|
$model_pd = Model('merchant');
|
|
$model_pd = Model('merchant');
|
|
- if(empty($merchant_info['admin_id'])){
|
|
|
|
|
|
+ if (empty($merchant_info['admin_id'])) {
|
|
$result['data'] = [];
|
|
$result['data'] = [];
|
|
$result['total'] = 0;
|
|
$result['total'] = 0;
|
|
return self::outsuccess($result);
|
|
return self::outsuccess($result);
|
|
@@ -216,50 +267,4 @@ class merchant_infoControl extends mbMerchantControl
|
|
}
|
|
}
|
|
return $data;
|
|
return $data;
|
|
}
|
|
}
|
|
-
|
|
|
|
- private function WeeksMerchantOrderStatistics($cond)
|
|
|
|
- {
|
|
|
|
- $data = [];
|
|
|
|
- $begin = mktime(0, 0, 0, date('m'), date('d') - 7, date('Y'));
|
|
|
|
- $end = mktime(0, 0, 0, date('m'), date('d') + 1, date('Y')) - 1;
|
|
|
|
- $cond['refill_order.order_time'] = ['between', [$begin, $end]];
|
|
|
|
- $WeeksOrderStatistics = $this->MerchantOrderStatistics($cond);
|
|
|
|
-
|
|
|
|
- for ($i = 0; $i < 7; $i++) {
|
|
|
|
- $begin = mktime(0, 0, 0, date('m'), date('d') - $i, date('Y'));
|
|
|
|
- $end = mktime(0, 0, 0, date('m'), date('d') - $i + 1, date('Y')) - 1;
|
|
|
|
- $cond['refill_order.order_time'] = ['between', [$begin, $end]];
|
|
|
|
- $OrderStatistics = $this->MerchantOrderStatistics($cond);
|
|
|
|
- $data[] = $OrderStatistics;
|
|
|
|
- }
|
|
|
|
- return $data;
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- private function MerchantOrderStatistics($cond)
|
|
|
|
- {
|
|
|
|
- $model_refill_order = Model('refill_order');
|
|
|
|
- $orders = $model_refill_order->getMerchantOrderList($cond);
|
|
|
|
- if (empty($orders)) {
|
|
|
|
- $data['count'] = $data['successCount'] = $data['errorCount'] = $data['otherCount'] = $data['amountCount'] = 0;
|
|
|
|
- return $data;
|
|
|
|
- }
|
|
|
|
- $count = count($orders);
|
|
|
|
- $successCount = $errorCount = $otherCount = $amountCount = 0;
|
|
|
|
- foreach ($orders as $order) {
|
|
|
|
- if ($order['order_state'] == ORDER_STATE_CANCEL) {
|
|
|
|
- $errorCount++;
|
|
|
|
- } elseif ($order['order_state'] == ORDER_STATE_SUCCESS) {
|
|
|
|
- $successCount++;
|
|
|
|
- $amountCount += $order['mch_amount'];
|
|
|
|
- } else {
|
|
|
|
- $otherCount++;
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
- $data['count'] = $count;
|
|
|
|
- $data['successCount'] = $successCount;
|
|
|
|
- $data['errorCount'] = $errorCount;
|
|
|
|
- $data['otherCount'] = $otherCount;
|
|
|
|
- $data['amountCount'] = $amountCount;
|
|
|
|
- return $data;
|
|
|
|
- }
|
|
|
|
}
|
|
}
|