diff --git a/app/Model/Sku.php b/app/Model/Sku.php index e1b0938..9f0e1ee 100644 --- a/app/Model/Sku.php +++ b/app/Model/Sku.php @@ -18,7 +18,8 @@ use Hyperf\DbConnection\Model\Model; * @property string $param * @property string $extra * @property int $total_stock - * @property int $surplus_stock + * @property int $surplus_stock + * @property int $chef_id * @property int $sales_num * @property int $order_num * @property int $cancel_num @@ -52,6 +53,7 @@ class Sku extends Model protected array $casts = [ 'id' => 'integer', 'spu_id' => 'integer', + 'chef_id' => 'integer', 'total_stock' => 'integer', 'surplus_stock' => 'integer', 'sales_num' => 'integer', diff --git a/app/Service/Admin/Good/SkuService.php b/app/Service/Admin/Good/SkuService.php index 34fb3b7..407d037 100644 --- a/app/Service/Admin/Good/SkuService.php +++ b/app/Service/Admin/Good/SkuService.php @@ -93,6 +93,7 @@ class SkuService extends BaseService $insertModel->spu_id = $spuId; $insertModel->title = $spuInfo->title.$this->request->input('title'); $insertModel->price = $this->request->input('price'); + $insertModel->chef_id = $this->request->input('chef_id'); $insertModel->image_ids = $imageIds; $insertModel->param = $this->request->input('param',''); $insertModel->extra = $this->request->input('extra',''); @@ -161,7 +162,7 @@ class SkuService extends BaseService if (!empty($updateOssIds) || !empty($delOssIds)) { $skuInfo->image_ids = $requestOssIds; } - + $skuInfo->chef_id = $this->request->input('chef_id'); $skuInfo->param = $this->request->input('param',''); $skuInfo->extra = $this->request->input('extra',''); $skuInfo->total_stock = $this->request->input('stock'); diff --git a/app/Service/Amqp/Statement/ChefService.php b/app/Service/Amqp/Statement/ChefService.php index 7c0639e..be675c9 100644 --- a/app/Service/Amqp/Statement/ChefService.php +++ b/app/Service/Amqp/Statement/ChefService.php @@ -97,9 +97,9 @@ class ChefService $orderGoods = $orderGoods->toArray(); $skuIds = array_unique(array_column($orderGoods, 'sku_id')); - $skuInfo = $this->skuModel->whereIn('id',$skuIds)->pluck('spu_id','id')->toArray(); - if (empty($skuInfo)) throw new Exception('skuInfoError:dataNull'); - $spuInfo = $this->spuModel->whereIn('id',array_unique(array_values($skuInfo)))->pluck('chef_id','id')->toArray(); + $chefList = $this->skuModel->whereIn('id',$skuIds)->pluck('chef_id','id')->toArray(); + if (empty($chefList)) throw new Exception('chefInfoError:dataNull'); + $currentDate = date('Y-m-d H:i:s'); @@ -108,7 +108,7 @@ class ChefService if (empty($insertData[$orderGood['sku_id']])) { $insertData[$orderGood['sku_id']] = [ 'date' => $cycle->dates, - 'chef_id' => $spuInfo[$skuInfo[$orderGood['sku_id']]]['chef_id'] ?? 0, + 'chef_id' => $chefList[$orderGood['sku_id']] ?? 0, 'sku_id' => $orderGood['sku_id'], 'cycle_id' => $this->cycleId, 'kitchen_id' => $this->kitchenId, diff --git a/app/Service/Api/Order/OrderInfoService.php b/app/Service/Api/Order/OrderInfoService.php index 7fc56d0..30361ad 100644 --- a/app/Service/Api/Order/OrderInfoService.php +++ b/app/Service/Api/Order/OrderInfoService.php @@ -114,11 +114,7 @@ class OrderInfoService extends BaseService $skuList = array_column($skuList, null,'id'); $imageList = $this->getOssObjects(array_column($skuList,'image_ids')); - $spuIds = array_unique(array_column($skuList,'spu_id')); - $spuList = $this->spuModel->getDataArrByIds($spuIds); - $spuList = array_column($spuList, null,'id'); - - $chefId = array_unique(array_column($spuList,'chef_id')); + $chefId = array_unique(array_column($skuList,'chef_id')); $chefList = $this->adminUserModel->getDataArrByIds($chefId); $chefList = array_column($chefList, null,'id'); @@ -169,7 +165,7 @@ class OrderInfoService extends BaseService 'unit_price' => $item['unit_price'], 'quantity' => $item['quantity'], 'price' => bcmul((string)$item['unit_price'], (string)$item['quantity'], 2), - 'chef_name' => $chefList[$spuList[$skuList[$item['sku_id']]['spu_id']]['chef_id']]['chinese_name'] ?? '', + 'chef_name' => $chefList[$item['sku_id']]['chinese_name'] ?? '', ]; $oneCopiesInfo['total_price'] = bcadd((string)$oneCopiesInfo['total_price'], bcmul((string)$item['unit_price'],(string)$item['quantity'],2), 2); $oneCopiesInfo['total_quantity'] += $item['quantity']; diff --git a/app/Service/Api/Order/OrderListService.php b/app/Service/Api/Order/OrderListService.php index e6f8db7..dd4aa77 100644 --- a/app/Service/Api/Order/OrderListService.php +++ b/app/Service/Api/Order/OrderListService.php @@ -24,7 +24,16 @@ use Psr\Container\NotFoundExceptionInterface; class OrderListService extends BaseService { + use OssTrait; + + /** + * @var int 当前订单/历史订单 + */ + CONST CURRENT_ORDER = 1; + + CONST HISTORY_ORDER = 2; + /** * @var Order */ @@ -58,11 +67,19 @@ class OrderListService extends BaseService { $limit = (int)$this->request->input('limit', 20); + $type = (int)$this->request->input('type',self::CURRENT_ORDER); + + $status = match ($type){ + self::CURRENT_ORDER => [OrderCode::WAIT_PAY,OrderCode::PAYED,OrderCode::PLAN,OrderCode::DEPART], + self::HISTORY_ORDER => [OrderCode::FINISH,OrderCode::CANCEL,OrderCode::FINISH_REFUND,OrderCode::UNCOMPLETED_REFUND] + }; + $orderList = $this->orderModel ->where('user_id', $this->userId) - ->when($this->request->input('status'), function ($query) { - $query->where('status', $this->request->input('status')); - }) + ->whereIn('status', $status) +// ->when($this->request->input('status'), function ($query) { +// $query->where('status', $this->request->input('status')); +// }) ->select([ 'id', 'order_sno',