订单统计数字错误问题处理

This commit is contained in:
evoxwht 2023-04-17 12:06:40 +08:00
parent ef5655723a
commit 6d685a636c
3 changed files with 8 additions and 5 deletions

View File

@ -605,6 +605,7 @@ class StoreOrderController
* 订单统计数据
* @param Request $request
* @return mixed
* @throws \ReflectionException
*/
public function data(Request $request)
{

View File

@ -50,17 +50,19 @@ class StoreOrderDao extends BaseDao
$realName = $where['real_name'] ?? '';
$fieldKey = $where['field_key'] ?? '';
$fieldKey = $fieldKey == 'all' ? '' : $fieldKey;
$status = $where['status'] ?? '';
unset($where['status']);
return parent::search($where, $search)->when($isDel, function ($query) use ($where) {
$query->where('is_del', $where['is_del']);
})->when(isset($where['is_system_del']), function ($query) {
$query->where('is_system_del', 0);
})->when(isset($where['status']) && $where['status'] !== '', function ($query) use ($where) {
switch ((int)$where['status']) {
})->when($status !== '', function ($query) use ($where, $status) {
switch ((int)$status) {
case 0://未支付
$query->where('paid', 0)->where('status', 0)->where('refund_status', 0)->where('is_del', 0);
break;
case 1://已支付 未发货
$query->where('paid', 1)->whereIn('status', [0, 4])->whereIn('refund_status', [0, 3])->when(isset($where['shipping_type']), function ($query) {
$query->where('paid', 1)->where('status', 0)->whereIn('refund_status', [0, 3])->when(isset($where['shipping_type']), function ($query) {
$query->where('shipping_type', 1);
})->where('is_del', 0);
break;
@ -95,7 +97,7 @@ class StoreOrderDao extends BaseDao
$query->where('is_del', 1);
break;
case 9://全部用户未删除的订单
$query->where('is_del', 0);
$query->whereIn('refund_status', [0, 3])->where('is_del', 0);
break;
}
})->when(isset($where['paid']) && $where['paid'] !== '', function ($query) use ($where) {

View File

@ -93,7 +93,7 @@ class StoreOrderServices extends BaseServices
{
[$page, $limit] = $this->getPageValue();
$data = $this->dao->getOrderList($where, $field, $page, $limit, $with);
$count = $this->dao->count($where);
$count = $this->dao->count($where, false);
$data = $this->tidyOrderList($data);
foreach ($data as &$item) {
$refund_num = array_sum(array_column($item['refund'], 'refund_num'));