|
@@ -53,24 +53,24 @@ class StoreOrderDao extends BaseDao
|
|
|
$fieldKey = $fieldKey == 'all' ? '' : $fieldKey;
|
|
|
return parent::search($where)->when($isDel, function ($query) use ($where) {
|
|
|
$query->where('is_del', $where['is_del']);
|
|
|
- })->when(isset($where['plat_type']) && in_array($where['plat_type'], [-1, 0, 1, 2]), function ($query) use($where) {
|
|
|
- switch ($where['plat_type']) {
|
|
|
- case -1://所有
|
|
|
- break;
|
|
|
- case 0://平台
|
|
|
- $query->where('store_id', 0)->where('supplier_id', 0);
|
|
|
- break;
|
|
|
- case 1://门店
|
|
|
- $query->where('store_id', '>', 0);
|
|
|
- break;
|
|
|
- case 2://供应商
|
|
|
- $query->where('supplier_id', '>', 0);
|
|
|
- break;
|
|
|
- }
|
|
|
+ })->when(isset($where['plat_type']) && in_array($where['plat_type'], [-1, 0, 1, 2]), function ($query) use ($where) {
|
|
|
+ switch ($where['plat_type']) {
|
|
|
+ case -1://所有
|
|
|
+ break;
|
|
|
+ case 0://平台
|
|
|
+ $query->where('store_id', 0)->where('supplier_id', 0);
|
|
|
+ break;
|
|
|
+ case 1://门店
|
|
|
+ $query->where('store_id', '>', 0);
|
|
|
+ break;
|
|
|
+ case 2://供应商
|
|
|
+ $query->where('supplier_id', '>', 0);
|
|
|
+ break;
|
|
|
+ }
|
|
|
})->when(isset($where['is_system_del']), function ($query) {
|
|
|
$query->where('is_system_del', 0);
|
|
|
})->when(isset($where['is_coupon']), function ($query) {
|
|
|
- $query->where('coupon_id','>', 0);
|
|
|
+ $query->where('coupon_id', '>', 0);
|
|
|
})->when(isset($where['staff_id']) && $where['staff_id'], function ($query) use ($where) {
|
|
|
$query->where('staff_id', $where['staff_id']);
|
|
|
})->when(isset($where['status']) && $where['status'] !== '', function ($query) use ($where) {
|
|
@@ -146,8 +146,8 @@ class StoreOrderDao extends BaseDao
|
|
|
break;
|
|
|
case 8://预售
|
|
|
$query->where('type', 6);
|
|
|
- break;
|
|
|
- case 9://新人专享
|
|
|
+ break;
|
|
|
+ case 9://新人专享
|
|
|
$query->where('type', 7);
|
|
|
break;
|
|
|
case 10://抽奖
|
|
@@ -161,18 +161,18 @@ class StoreOrderDao extends BaseDao
|
|
|
break;
|
|
|
}
|
|
|
})->when(isset($where['order_type']) && $where['order_type'] !== '', function ($query) use ($where) {
|
|
|
- switch ($where['order_type']) {
|
|
|
- case 5://核销订单
|
|
|
- $query->where('shipping_type', 2);
|
|
|
- break;
|
|
|
- case 6://收银台订单
|
|
|
- $query->where('shipping_type', 4);
|
|
|
- break;
|
|
|
- case 7://配送订单
|
|
|
- $query->whereIn('shipping_type', [1, 3]);
|
|
|
- break;
|
|
|
- }
|
|
|
- })->when(isset($where['pay_type']), function ($query) use ($where) {
|
|
|
+ switch ($where['order_type']) {
|
|
|
+ case 5://核销订单
|
|
|
+ $query->where('shipping_type', 2);
|
|
|
+ break;
|
|
|
+ case 6://收银台订单
|
|
|
+ $query->where('shipping_type', 4);
|
|
|
+ break;
|
|
|
+ case 7://配送订单
|
|
|
+ $query->whereIn('shipping_type', [1, 3]);
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ })->when(isset($where['pay_type']), function ($query) use ($where) {
|
|
|
switch ($where['pay_type']) {
|
|
|
case 1:
|
|
|
$query->where('pay_type', 'weixin');
|
|
@@ -200,21 +200,21 @@ class StoreOrderDao extends BaseDao
|
|
|
})->when($realName && !$fieldKey, function ($query) use ($where) {
|
|
|
$query->where(function ($que) use ($where) {
|
|
|
$que->whereLike('order_id|real_name|user_phone|verify_code', '%' . $where['real_name'] . '%')
|
|
|
- ->whereOr('uid', 'in', function ($q) use ($where) {
|
|
|
- $q->name('user')->whereLike('nickname|uid|phone', '%' . $where['real_name'] . '%')->field(['uid'])->select();
|
|
|
- })->whereOr('uid', 'in', function ($q) use ($where) {
|
|
|
- $q->name('user_address')->whereLike('real_name|uid|phone', '%' . $where['real_name'] . '%')->field(['uid'])->select();
|
|
|
- })->whereOr('id', 'in', function ($que) use ($where) {
|
|
|
- $que->name('store_order_cart_info')->whereIn('product_id', function ($q) use ($where) {
|
|
|
- $q->name('store_product')->whereLike('store_name|keyword', '%' . $where['real_name'] . '%')->field(['id'])->select();
|
|
|
- })->field(['oid'])->select();
|
|
|
- })->whereOr('activity_id', 'in', function ($que) use ($where) {
|
|
|
- $que->name('store_seckill')->whereLike('title|info', '%' . $where['real_name'] . '%')->field(['id'])->select();
|
|
|
- })->whereOr('activity_id', 'in', function ($que) use ($where) {
|
|
|
- $que->name('store_bargain')->whereLike('title|info', '%' . $where['real_name'] . '%')->field(['id'])->select();
|
|
|
- })->whereOr('activity_id', 'in', function ($que) use ($where) {
|
|
|
- $que->name('store_combination')->whereLike('title|info', '%' . $where['real_name'] . '%')->field(['id'])->select();
|
|
|
- });
|
|
|
+ ->whereOr('uid', 'in', function ($q) use ($where) {
|
|
|
+ $q->name('user')->whereLike('nickname|uid|phone', '%' . $where['real_name'] . '%')->field(['uid'])->select();
|
|
|
+ })->whereOr('uid', 'in', function ($q) use ($where) {
|
|
|
+ $q->name('user_address')->whereLike('real_name|uid|phone', '%' . $where['real_name'] . '%')->field(['uid'])->select();
|
|
|
+ })->whereOr('id', 'in', function ($que) use ($where) {
|
|
|
+ $que->name('store_order_cart_info')->whereIn('product_id', function ($q) use ($where) {
|
|
|
+ $q->name('store_product')->whereLike('store_name|keyword', '%' . $where['real_name'] . '%')->field(['id'])->select();
|
|
|
+ })->field(['oid'])->select();
|
|
|
+ })->whereOr('activity_id', 'in', function ($que) use ($where) {
|
|
|
+ $que->name('store_seckill')->whereLike('title|info', '%' . $where['real_name'] . '%')->field(['id'])->select();
|
|
|
+ })->whereOr('activity_id', 'in', function ($que) use ($where) {
|
|
|
+ $que->name('store_bargain')->whereLike('title|info', '%' . $where['real_name'] . '%')->field(['id'])->select();
|
|
|
+ })->whereOr('activity_id', 'in', function ($que) use ($where) {
|
|
|
+ $que->name('store_combination')->whereLike('title|info', '%' . $where['real_name'] . '%')->field(['id'])->select();
|
|
|
+ });
|
|
|
});
|
|
|
})->when(isset($where['unique']), function ($query) use ($where) {
|
|
|
$query->where('unique', $where['unique']);
|
|
@@ -241,6 +241,18 @@ class StoreOrderDao extends BaseDao
|
|
|
} else {
|
|
|
$query->where('refund_status', 0);
|
|
|
}
|
|
|
+ })->when(isset($where['area']) && !empty($where['area']), function ($query) use ($where) {
|
|
|
+ if (is_array($where['area'])) {
|
|
|
+ if (($where['area']['order_province'] ?? '') != '') {
|
|
|
+ $query->where('order_province', $where['area']['order_province']);
|
|
|
+ if (($where['area']['order_city'] ?? '') != '') {
|
|
|
+ $query->where('order_city', $where['area']['order_city']);
|
|
|
+ if (($where['area']['order_district'] ?? '') != '') {
|
|
|
+ $query->where('order_district', $where['area']['order_district']);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
});
|
|
|
}
|
|
|
|
|
@@ -665,9 +677,11 @@ class StoreOrderDao extends BaseDao
|
|
|
* @param $timeType
|
|
|
* @param $field
|
|
|
* @param $str
|
|
|
+ * @param string $orderStatus
|
|
|
+ * @param null $area
|
|
|
* @return mixed
|
|
|
*/
|
|
|
- public function getProductTrend($time, $timeType, $field, $str, $orderStatus = '')
|
|
|
+ public function getProductTrend($time, $timeType, $field, $str, $orderStatus = '', $area = null)
|
|
|
{
|
|
|
return $this->getModel()->where(function ($query) use ($field, $orderStatus) {
|
|
|
if ($field == 'pay_time') {
|
|
@@ -690,6 +704,18 @@ class StoreOrderDao extends BaseDao
|
|
|
$time[1] = date('Y/m/d', strtotime($time[1]) + 86400);
|
|
|
$query->whereTime($field, 'between', $time);
|
|
|
}
|
|
|
+ })->where(function ($query) use ($area) {
|
|
|
+ if (is_array($area)) {
|
|
|
+ if (($area['order_province'] ?? '') != '') {
|
|
|
+ $query->where('order_province', $area['order_province']);
|
|
|
+ if (($area['order_city'] ?? '') != '') {
|
|
|
+ $query->where('order_city', $area['order_city']);
|
|
|
+ if (($area['order_district'] ?? '') != '') {
|
|
|
+ $query->where('order_district', $area['order_district']);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
})->field("FROM_UNIXTIME($field,'$timeType') as days,$str as num")->group('days')->select()->toArray();
|
|
|
}
|
|
|
|
|
@@ -746,7 +772,7 @@ class StoreOrderDao extends BaseDao
|
|
|
} elseif ($where['timeKey']['days'] > 30 && $where['timeKey']['days'] < 365) {
|
|
|
$timeUinx = "%Y-%m";
|
|
|
} else {
|
|
|
- $timeUinx = "%Y-%m";
|
|
|
+ $timeUinx = "%Y-%m";
|
|
|
}
|
|
|
$query->field("sum($sumField) as number,FROM_UNIXTIME($group, '$timeUinx') as time");
|
|
|
$query->group("FROM_UNIXTIME($group, '$timeUinx')");
|
|
@@ -776,7 +802,7 @@ class StoreOrderDao extends BaseDao
|
|
|
} elseif ($where['timeKey']['days'] > 30 && $where['timeKey']['days'] < 365) {
|
|
|
$timeUinx = "%Y-%m";
|
|
|
} else {
|
|
|
- $timeUinx = "%Y-%m";
|
|
|
+ $timeUinx = "%Y-%m";
|
|
|
}
|
|
|
$query->field("count($sumField) as number,FROM_UNIXTIME(pay_time, '$timeUinx') as time");
|
|
|
$query->group("FROM_UNIXTIME(pay_time, '$timeUinx')");
|
|
@@ -821,7 +847,7 @@ class StoreOrderDao extends BaseDao
|
|
|
} elseif ($where['timeKey']['days'] > 30 && $where['timeKey']['days'] < 365) {
|
|
|
$timeUinx = "%Y-%m";
|
|
|
} else {
|
|
|
- $timeUinx = "%Y-%m";
|
|
|
+ $timeUinx = "%Y-%m";
|
|
|
}
|
|
|
$query->field("count(distinct uid) as number,FROM_UNIXTIME(pay_time, '$timeUinx') as time");
|
|
|
$query->group("FROM_UNIXTIME(pay_time, '$timeUinx')");
|
|
@@ -987,38 +1013,38 @@ class StoreOrderDao extends BaseDao
|
|
|
$query->whereTime($field, 'between', $time);
|
|
|
}
|
|
|
})->where('is_del', 0)->where('is_system_del', 0)
|
|
|
- ->field("FROM_UNIXTIME($field,'$timeType') as days,$str as num")->group('days')->select()->toArray();
|
|
|
+ ->field("FROM_UNIXTIME($field,'$timeType') as days,$str as num")->group('days')->select()->toArray();
|
|
|
}
|
|
|
|
|
|
- /**
|
|
|
- * 获取活动订单列表:
|
|
|
- * @param int $id
|
|
|
- * @param int $type 0:普通、1:秒杀、2:砍价、3:拼团、4:积分、5:套餐、6:预售、7:新人礼
|
|
|
- * @param array $where
|
|
|
- * @param int $page
|
|
|
- * @param int $limit
|
|
|
- * @return array
|
|
|
- * @throws \think\db\exception\DataNotFoundException
|
|
|
- * @throws \think\db\exception\DbException
|
|
|
- * @throws \think\db\exception\ModelNotFoundException
|
|
|
- */
|
|
|
- public function activityStatisticsOrder(int $id, int $type = 1,array $where = [], int $page = 0, int $limit = 0)
|
|
|
- {
|
|
|
- return $this->search($where)->where('pid', 'in', [0, -1])->where('paid', 1)->where('type', $type)->where('activity_id', $id)
|
|
|
- ->when($page && $limit, function ($query) use ($page, $limit) {
|
|
|
- $query->page($page, $limit);
|
|
|
- })->field(['order_id', 'real_name', 'status', 'pay_price', 'total_num', 'add_time', 'pay_time', 'paid', 'shipping_type', 'refund_status', 'is_del', 'is_system_del'])->select()->toArray();
|
|
|
- }
|
|
|
+ /**
|
|
|
+ * 获取活动订单列表:
|
|
|
+ * @param int $id
|
|
|
+ * @param int $type 0:普通、1:秒杀、2:砍价、3:拼团、4:积分、5:套餐、6:预售、7:新人礼
|
|
|
+ * @param array $where
|
|
|
+ * @param int $page
|
|
|
+ * @param int $limit
|
|
|
+ * @return array
|
|
|
+ * @throws \think\db\exception\DataNotFoundException
|
|
|
+ * @throws \think\db\exception\DbException
|
|
|
+ * @throws \think\db\exception\ModelNotFoundException
|
|
|
+ */
|
|
|
+ public function activityStatisticsOrder(int $id, int $type = 1, array $where = [], int $page = 0, int $limit = 0)
|
|
|
+ {
|
|
|
+ return $this->search($where)->where('pid', 'in', [0, -1])->where('paid', 1)->where('type', $type)->where('activity_id', $id)
|
|
|
+ ->when($page && $limit, function ($query) use ($page, $limit) {
|
|
|
+ $query->page($page, $limit);
|
|
|
+ })->field(['order_id', 'real_name', 'status', 'pay_price', 'total_num', 'add_time', 'pay_time', 'paid', 'shipping_type', 'refund_status', 'is_del', 'is_system_del'])->select()->toArray();
|
|
|
+ }
|
|
|
|
|
|
|
|
|
- /**
|
|
|
- * 秒杀参与人统计
|
|
|
- * @param int $id
|
|
|
- * @param string $keyword
|
|
|
- * @param int $page
|
|
|
- * @param int $limit
|
|
|
- * @return mixed
|
|
|
- */
|
|
|
+ /**
|
|
|
+ * 秒杀参与人统计
|
|
|
+ * @param int $id
|
|
|
+ * @param string $keyword
|
|
|
+ * @param int $page
|
|
|
+ * @param int $limit
|
|
|
+ * @return mixed
|
|
|
+ */
|
|
|
public function seckillPeople(int $id, string $keyword, int $page = 0, int $limit = 0)
|
|
|
{
|
|
|
return $this->getModel()
|
|
@@ -1038,38 +1064,38 @@ class StoreOrderDao extends BaseDao
|
|
|
})->select()->toArray();
|
|
|
}
|
|
|
|
|
|
- /**
|
|
|
- * @param int $pid
|
|
|
- * @return array
|
|
|
- * @throws \think\db\exception\DataNotFoundException
|
|
|
- * @throws \think\db\exception\DbException
|
|
|
- * @throws \think\db\exception\ModelNotFoundException
|
|
|
- */
|
|
|
- public function getSubOrderNotSendList(int $pid)
|
|
|
- {
|
|
|
- return $this->getModel()->where('pid', $pid)->where('status', 1)->select()->toArray();
|
|
|
- }
|
|
|
+ /**
|
|
|
+ * @param int $pid
|
|
|
+ * @return array
|
|
|
+ * @throws \think\db\exception\DataNotFoundException
|
|
|
+ * @throws \think\db\exception\DbException
|
|
|
+ * @throws \think\db\exception\ModelNotFoundException
|
|
|
+ */
|
|
|
+ public function getSubOrderNotSendList(int $pid)
|
|
|
+ {
|
|
|
+ return $this->getModel()->where('pid', $pid)->where('status', 1)->select()->toArray();
|
|
|
+ }
|
|
|
|
|
|
- /**
|
|
|
- * @param int $pid
|
|
|
- * @param int $order_id
|
|
|
- * @return int
|
|
|
- * @throws \think\db\exception\DbException
|
|
|
- */
|
|
|
- public function getSubOrderNotSend(int $pid, int $order_id)
|
|
|
- {
|
|
|
- return $this->getModel()->where('pid', $pid)->where('status', 0)->where('id', '<>', $order_id)->count();
|
|
|
- }
|
|
|
+ /**
|
|
|
+ * @param int $pid
|
|
|
+ * @param int $order_id
|
|
|
+ * @return int
|
|
|
+ * @throws \think\db\exception\DbException
|
|
|
+ */
|
|
|
+ public function getSubOrderNotSend(int $pid, int $order_id)
|
|
|
+ {
|
|
|
+ return $this->getModel()->where('pid', $pid)->where('status', 0)->where('id', '<>', $order_id)->count();
|
|
|
+ }
|
|
|
|
|
|
- /**
|
|
|
- * @param int $pid
|
|
|
- * @param int $order_id
|
|
|
- * @return int
|
|
|
- * @throws \think\db\exception\DbException
|
|
|
- */
|
|
|
- public function getSubOrderNotTake(int $pid, int $order_id)
|
|
|
- {
|
|
|
- return $this->getModel()->where('pid', $pid)->where('status', 1)->where('id', '<>', $order_id)->count();
|
|
|
- }
|
|
|
+ /**
|
|
|
+ * @param int $pid
|
|
|
+ * @param int $order_id
|
|
|
+ * @return int
|
|
|
+ * @throws \think\db\exception\DbException
|
|
|
+ */
|
|
|
+ public function getSubOrderNotTake(int $pid, int $order_id)
|
|
|
+ {
|
|
|
+ return $this->getModel()->where('pid', $pid)->where('status', 1)->where('id', '<>', $order_id)->count();
|
|
|
+ }
|
|
|
|
|
|
}
|