|
@@ -25,6 +25,31 @@ class merchant_infoControl extends mbMerchantControl
|
|
|
return self::outsuccess($merchant_info);
|
|
|
}
|
|
|
|
|
|
+ public function homeOp()
|
|
|
+ {
|
|
|
+ $mchid = $this->mchid();
|
|
|
+ $model_merchant = Model('merchant');
|
|
|
+ $merchant_info = $model_merchant->getMerchantInfo(['mchid' => $mchid], 'mchid,admin_id,name');
|
|
|
+ $model_member = Model('member');
|
|
|
+ $member_info = $model_member->getMemberInfo(['member_id' => $merchant_info['admin_id']], '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);
|
|
|
+ $result['merchant_info'] = $merchant_info;
|
|
|
+ $result['todayStatistics'] = $todayStatistics;
|
|
|
+ $result['weeksStatistics'] = $weeksStatistics;
|
|
|
+ return self::outsuccess($result);
|
|
|
+ }
|
|
|
+
|
|
|
public function addipOp()
|
|
|
{
|
|
|
$mchid = $this->mchid();
|
|
@@ -149,7 +174,7 @@ class merchant_infoControl extends mbMerchantControl
|
|
|
if (isset($value['lg_add_time'])) {
|
|
|
$value['lg_add_time'] = date('Y-m-d H:i:s', $value['lg_add_time']);
|
|
|
}
|
|
|
- switch ($value['lg_type']){
|
|
|
+ switch ($value['lg_type']) {
|
|
|
case 'order_pay':
|
|
|
$value['lg_type_text'] = '下单减款';
|
|
|
break;
|
|
@@ -179,4 +204,45 @@ class merchant_infoControl extends mbMerchantControl
|
|
|
}
|
|
|
return $data;
|
|
|
}
|
|
|
+
|
|
|
+ private function WeeksMerchantOrderStatistics($cond)
|
|
|
+ {
|
|
|
+ $data = [];
|
|
|
+ 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;
|
|
|
+ }
|
|
|
}
|