diff --git a/app/common/model/store/order/StoreOrder.php b/app/common/model/store/order/StoreOrder.php index c57dd5b3..a4ab9694 100644 --- a/app/common/model/store/order/StoreOrder.php +++ b/app/common/model/store/order/StoreOrder.php @@ -28,6 +28,7 @@ class StoreOrder extends BaseModel const STATUS_WAIT_CONFIRM = 12; //待确认 const STATUS_WAIT_PAY = 0; //待支付 + const STATUS_WAIT_COMMENT = 2; //待评价 public static function tablePk(): ?string { diff --git a/app/common/repositories/store/order/StoreOrderRepository.php b/app/common/repositories/store/order/StoreOrderRepository.php index 4db2258b..cdb2453f 100644 --- a/app/common/repositories/store/order/StoreOrderRepository.php +++ b/app/common/repositories/store/order/StoreOrderRepository.php @@ -15,6 +15,7 @@ use app\common\dao\store\order\StoreOrderDao; use app\common\model\store\order\StoreGroupOrder; use app\common\model\store\order\StoreOrder; use app\common\model\store\order\StoreOrderInterest; +use app\common\model\store\product\PurchaseRecord; use app\common\model\user\User; use app\common\repositories\BaseRepository; use app\common\repositories\delivery\DeliveryOrderRepository; @@ -2539,4 +2540,32 @@ class StoreOrderRepository extends BaseRepository } + /** + * 采购订单列表 + * @param $merId + * @param $page + * @param $limit + * @return \think\Collection + * @throws DataNotFoundException + * @throws DbException + * @throws ModelNotFoundException + */ + public function purchaseOrder($merId, $page, $limit) + { + $orders = StoreOrder::where('mer_id', $merId) + ->where('pay_type', StoreGroupOrder::PAY_TYPE_CREDIT_BUY) + ->where('status', StoreOrder::STATUS_WAIT_COMMENT) + ->page($page, $limit) + ->select(); + foreach ($orders as $order) { + $products = $order->orderProduct; + foreach ($products as &$product) { + $purchaseRecord = PurchaseRecord::where(['order_id' => $product['order_id'], 'order_product_id' => $product['product_id'], 'order_unique' => $product['product_sku']])->field('sales_volume')->find(); + $product['sales_volume'] = empty($purchaseRecord) ? 0 : $purchaseRecord->sales_volume; + unset($product['cart_info']); + } + } + return $orders; + } + } diff --git a/app/common/repositories/store/product/ProductRepository.php b/app/common/repositories/store/product/ProductRepository.php index 91db6fdc..c41f002a 100644 --- a/app/common/repositories/store/product/ProductRepository.php +++ b/app/common/repositories/store/product/ProductRepository.php @@ -2251,6 +2251,9 @@ class ProductRepository extends BaseRepository ]; } } + foreach ($data['attrValue'] as $k => $item) { + $data['attrValue'][$k]['stock'] = 0; + } app()->make(ProductLabelRepository::class)->checkHas($merId,$data['mer_labels']); $count = app()->make(StoreCategoryRepository::class)->getWhereCount(['store_category_id' => $data['cate_id'],'is_show' => 1]); if (!$count) throw new ValidateException('平台分类不存在或不可用'); diff --git a/app/controller/api/server/StoreOrder.php b/app/controller/api/server/StoreOrder.php index 0f8404b0..b127ab04 100644 --- a/app/controller/api/server/StoreOrder.php +++ b/app/controller/api/server/StoreOrder.php @@ -338,4 +338,19 @@ class StoreOrder extends BaseController return app('json')->success('订单核销成功'); } + /** + * 采购订单列表 + * @param $merId + * @param StoreOrderRepository $orderRepository + * @return \think\Collection + * @throws \think\db\exception\DataNotFoundException + * @throws \think\db\exception\DbException + * @throws \think\db\exception\ModelNotFoundException + */ + public function purchaseOrder($merId, StoreOrderRepository $orderRepository) + { + [$page, $limit] = $this->getPage(); + return $orderRepository->purchaseOrder($merId, $page, $limit); + } + } diff --git a/route/api.php b/route/api.php index 8fd17dc7..c10547c6 100644 --- a/route/api.php +++ b/route/api.php @@ -310,6 +310,7 @@ Route::group('api/', function () { Route::get('/dump_temp', '/getFormData'); Route::get('/delivery_config', '/getDeliveryConfig'); Route::get('/delivery_options', '/getDeliveryOptions'); + Route::get('/purchaseOrder', '/purchaseOrder'); })->prefix('api.server.StoreOrder')->middleware(\app\common\middleware\MerchantServerMiddleware::class,0);