feat : order list
This commit is contained in:
@@ -19,6 +19,7 @@ use Hyperf\DbConnection\Model\Model;
|
|||||||
* @property string $extra
|
* @property string $extra
|
||||||
* @property int $total_stock
|
* @property int $total_stock
|
||||||
* @property int $surplus_stock
|
* @property int $surplus_stock
|
||||||
|
* @property int $chef_id
|
||||||
* @property int $sales_num
|
* @property int $sales_num
|
||||||
* @property int $order_num
|
* @property int $order_num
|
||||||
* @property int $cancel_num
|
* @property int $cancel_num
|
||||||
@@ -52,6 +53,7 @@ class Sku extends Model
|
|||||||
protected array $casts = [
|
protected array $casts = [
|
||||||
'id' => 'integer',
|
'id' => 'integer',
|
||||||
'spu_id' => 'integer',
|
'spu_id' => 'integer',
|
||||||
|
'chef_id' => 'integer',
|
||||||
'total_stock' => 'integer',
|
'total_stock' => 'integer',
|
||||||
'surplus_stock' => 'integer',
|
'surplus_stock' => 'integer',
|
||||||
'sales_num' => 'integer',
|
'sales_num' => 'integer',
|
||||||
|
|||||||
@@ -93,6 +93,7 @@ class SkuService extends BaseService
|
|||||||
$insertModel->spu_id = $spuId;
|
$insertModel->spu_id = $spuId;
|
||||||
$insertModel->title = $spuInfo->title.$this->request->input('title');
|
$insertModel->title = $spuInfo->title.$this->request->input('title');
|
||||||
$insertModel->price = $this->request->input('price');
|
$insertModel->price = $this->request->input('price');
|
||||||
|
$insertModel->chef_id = $this->request->input('chef_id');
|
||||||
$insertModel->image_ids = $imageIds;
|
$insertModel->image_ids = $imageIds;
|
||||||
$insertModel->param = $this->request->input('param','');
|
$insertModel->param = $this->request->input('param','');
|
||||||
$insertModel->extra = $this->request->input('extra','');
|
$insertModel->extra = $this->request->input('extra','');
|
||||||
@@ -161,7 +162,7 @@ class SkuService extends BaseService
|
|||||||
if (!empty($updateOssIds) || !empty($delOssIds)) {
|
if (!empty($updateOssIds) || !empty($delOssIds)) {
|
||||||
$skuInfo->image_ids = $requestOssIds;
|
$skuInfo->image_ids = $requestOssIds;
|
||||||
}
|
}
|
||||||
|
$skuInfo->chef_id = $this->request->input('chef_id');
|
||||||
$skuInfo->param = $this->request->input('param','');
|
$skuInfo->param = $this->request->input('param','');
|
||||||
$skuInfo->extra = $this->request->input('extra','');
|
$skuInfo->extra = $this->request->input('extra','');
|
||||||
$skuInfo->total_stock = $this->request->input('stock');
|
$skuInfo->total_stock = $this->request->input('stock');
|
||||||
|
|||||||
@@ -97,9 +97,9 @@ class ChefService
|
|||||||
$orderGoods = $orderGoods->toArray();
|
$orderGoods = $orderGoods->toArray();
|
||||||
|
|
||||||
$skuIds = array_unique(array_column($orderGoods, 'sku_id'));
|
$skuIds = array_unique(array_column($orderGoods, 'sku_id'));
|
||||||
$skuInfo = $this->skuModel->whereIn('id',$skuIds)->pluck('spu_id','id')->toArray();
|
$chefList = $this->skuModel->whereIn('id',$skuIds)->pluck('chef_id','id')->toArray();
|
||||||
if (empty($skuInfo)) throw new Exception('skuInfoError:dataNull');
|
if (empty($chefList)) throw new Exception('chefInfoError:dataNull');
|
||||||
$spuInfo = $this->spuModel->whereIn('id',array_unique(array_values($skuInfo)))->pluck('chef_id','id')->toArray();
|
|
||||||
|
|
||||||
$currentDate = date('Y-m-d H:i:s');
|
$currentDate = date('Y-m-d H:i:s');
|
||||||
|
|
||||||
@@ -108,7 +108,7 @@ class ChefService
|
|||||||
if (empty($insertData[$orderGood['sku_id']])) {
|
if (empty($insertData[$orderGood['sku_id']])) {
|
||||||
$insertData[$orderGood['sku_id']] = [
|
$insertData[$orderGood['sku_id']] = [
|
||||||
'date' => $cycle->dates,
|
'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'],
|
'sku_id' => $orderGood['sku_id'],
|
||||||
'cycle_id' => $this->cycleId,
|
'cycle_id' => $this->cycleId,
|
||||||
'kitchen_id' => $this->kitchenId,
|
'kitchen_id' => $this->kitchenId,
|
||||||
|
|||||||
@@ -114,11 +114,7 @@ class OrderInfoService extends BaseService
|
|||||||
$skuList = array_column($skuList, null,'id');
|
$skuList = array_column($skuList, null,'id');
|
||||||
$imageList = $this->getOssObjects(array_column($skuList,'image_ids'));
|
$imageList = $this->getOssObjects(array_column($skuList,'image_ids'));
|
||||||
|
|
||||||
$spuIds = array_unique(array_column($skuList,'spu_id'));
|
$chefId = array_unique(array_column($skuList,'chef_id'));
|
||||||
$spuList = $this->spuModel->getDataArrByIds($spuIds);
|
|
||||||
$spuList = array_column($spuList, null,'id');
|
|
||||||
|
|
||||||
$chefId = array_unique(array_column($spuList,'chef_id'));
|
|
||||||
$chefList = $this->adminUserModel->getDataArrByIds($chefId);
|
$chefList = $this->adminUserModel->getDataArrByIds($chefId);
|
||||||
$chefList = array_column($chefList, null,'id');
|
$chefList = array_column($chefList, null,'id');
|
||||||
|
|
||||||
@@ -169,7 +165,7 @@ class OrderInfoService extends BaseService
|
|||||||
'unit_price' => $item['unit_price'],
|
'unit_price' => $item['unit_price'],
|
||||||
'quantity' => $item['quantity'],
|
'quantity' => $item['quantity'],
|
||||||
'price' => bcmul((string)$item['unit_price'], (string)$item['quantity'], 2),
|
'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_price'] = bcadd((string)$oneCopiesInfo['total_price'], bcmul((string)$item['unit_price'],(string)$item['quantity'],2), 2);
|
||||||
$oneCopiesInfo['total_quantity'] += $item['quantity'];
|
$oneCopiesInfo['total_quantity'] += $item['quantity'];
|
||||||
|
|||||||
@@ -24,7 +24,16 @@ use Psr\Container\NotFoundExceptionInterface;
|
|||||||
|
|
||||||
class OrderListService extends BaseService
|
class OrderListService extends BaseService
|
||||||
{
|
{
|
||||||
|
|
||||||
use OssTrait;
|
use OssTrait;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @var int 当前订单/历史订单
|
||||||
|
*/
|
||||||
|
CONST CURRENT_ORDER = 1;
|
||||||
|
|
||||||
|
CONST HISTORY_ORDER = 2;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @var Order
|
* @var Order
|
||||||
*/
|
*/
|
||||||
@@ -58,11 +67,19 @@ class OrderListService extends BaseService
|
|||||||
{
|
{
|
||||||
$limit = (int)$this->request->input('limit', 20);
|
$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
|
$orderList = $this->orderModel
|
||||||
->where('user_id', $this->userId)
|
->where('user_id', $this->userId)
|
||||||
->when($this->request->input('status'), function ($query) {
|
->whereIn('status', $status)
|
||||||
$query->where('status', $this->request->input('status'));
|
// ->when($this->request->input('status'), function ($query) {
|
||||||
})
|
// $query->where('status', $this->request->input('status'));
|
||||||
|
// })
|
||||||
->select([
|
->select([
|
||||||
'id',
|
'id',
|
||||||
'order_sno',
|
'order_sno',
|
||||||
|
|||||||
Reference in New Issue
Block a user