diff --git a/app/common/lists/StoreStaffLists.php b/app/common/lists/StoreStaffLists.php index dcc4c066..7d9a53ea 100644 --- a/app/common/lists/StoreStaffLists.php +++ b/app/common/lists/StoreStaffLists.php @@ -33,7 +33,7 @@ class StoreStaffLists extends BaseAdminDataLists implements ListsSearchInterface */ public function lists(): array { - return SystemStoreStaff::field('id,staff_name,avatar,account,phone,is_admin,is_manager') + return SystemStoreStaff::field('id,staff_name,avatar,account,phone,is_admin,is_manager,status') ->when(!empty($this->request->adminInfo['store_id']), function ($query) { $query->where('store_id', '=', $this->request->adminInfo['store_id']); }) diff --git a/app/common/logic/DeliveryServiceLogic.php b/app/common/logic/DeliveryServiceLogic.php index 36b3428e..ffa01778 100644 --- a/app/common/logic/DeliveryServiceLogic.php +++ b/app/common/logic/DeliveryServiceLogic.php @@ -2,9 +2,9 @@ namespace app\common\logic; +use app\common\logic\store_order\StoreOrderLogic; use app\common\model\system_store\DeliveryService; use app\common\service\FileService; -use Webman\Config; class DeliveryServiceLogic extends BaseLogic { @@ -58,7 +58,37 @@ class DeliveryServiceLogic extends BaseLogic if (empty($model)) { throw new \Exception('数据不存在'); } - return $model->toArray(); + $data = $model->toArray(); + $orderLogic = new StoreOrderLogic(); + $data['wait'] = $orderLogic->storeOrderCountByWhere([ + 'store_id' => $data['store_id'], + 'delivery_id' => $data['phone'], + 'status' => 0, + 'paid' => 1, + 'shipping_type' => 1, + ]); + $data['finish'] = $orderLogic->storeOrderCountByWhere([ + 'store_id' => $data['store_id'], + 'delivery_id' => $data['phone'], + 'status' => [1, 2], + 'paid' => 1, + 'shipping_type' => 1, + ]); + $data['wait_amount'] = $orderLogic->storeOrderSumByWhere([ + 'store_id' => $data['store_id'], + 'delivery_id' => $data['phone'], + 'status' => 0, + 'paid' => 1, + 'shipping_type' => 1, + ]); + $data['finish_amount'] = $orderLogic->storeOrderSumByWhere([ + 'store_id' => $data['store_id'], + 'delivery_id' => $data['phone'], + 'status' => [1, 2], + 'paid' => 1, + 'shipping_type' => 1, + ]); + return $data; } public function status($id) diff --git a/app/common/logic/SystemStoreStaffLogic.php b/app/common/logic/SystemStoreStaffLogic.php index 4e25dc41..dcb3d938 100644 --- a/app/common/logic/SystemStoreStaffLogic.php +++ b/app/common/logic/SystemStoreStaffLogic.php @@ -2,6 +2,7 @@ namespace app\common\logic; +use app\common\logic\store_order\StoreOrderLogic; use app\common\model\system_store\SystemStoreStaff; use app\common\service\FileService; use Webman\Config; @@ -69,7 +70,30 @@ class SystemStoreStaffLogic extends BaseLogic if (empty($model)) { throw new \Exception('数据不存在'); } - return $model->toArray(); + $data = $model->toArray(); + $orderLogic = new StoreOrderLogic(); + $data['cashier_order'] = $orderLogic->storeOrderCountByWhere([ + 'store_id' => $data['store_id'], + 'staff_id' => $data['id'], + 'status' => [0, 1, 2], + 'paid' => 1, + 'shipping_type' => 3, + ]); + $data['verify_order'] = $orderLogic->storeOrderCountByWhere([ + 'store_id' => $data['store_id'], + 'delivery_id' => $data['phone'], + 'status' => [1, 2], + 'paid' => 1, + 'shipping_type' => 2, + ]); + $data['delivery_order'] = $orderLogic->storeOrderSumByWhere([ + 'store_id' => $data['store_id'], + 'delivery_id' => $data['phone'], + 'status' => 0, + 'paid' => 1, + 'shipping_type' => 1, + ]); + return $data; } public function status($id) diff --git a/app/common/logic/store_order/StoreOrderLogic.php b/app/common/logic/store_order/StoreOrderLogic.php index 04ebccbd..f262db51 100644 --- a/app/common/logic/store_order/StoreOrderLogic.php +++ b/app/common/logic/store_order/StoreOrderLogic.php @@ -143,4 +143,26 @@ class StoreOrderLogic extends BaseLogic return StoreOrder::where(['store_id' => $storeId, 'status' => $status])->count(); } + /** + * 订单统计 + * @param $where + * @return int|\think\db\Query + * @throws \think\db\exception\DbException + */ + public function storeOrderCountByWhere($where) + { + return StoreOrder::where($where)->count(); + } + + /** + * 订单统计 + * @param $where + * @return int|\think\db\Query + * @throws \think\db\exception\DbException + */ + public function storeOrderSumByWhere($where) + { + return StoreOrder::where($where)->sum('pay_price'); + } + }