订单信息
This commit is contained in:
@@ -22,10 +22,11 @@ use Modules\Common\Http\Controllers\BaseController;
|
||||
class StoreOrderController extends BaseController
|
||||
{
|
||||
/** 状态中文名(通知文案用) */
|
||||
private const STATUS_NAMES = [
|
||||
StoreOrderModel::STATUS_PENDING => '待汇总',
|
||||
StoreOrderModel::STATUS_SUMMARIZED => '已汇总',
|
||||
StoreOrderModel::STATUS_DELIVERING => '配送中',
|
||||
private const array STATUS_NAMES = [
|
||||
StoreOrderModel::STATUS_PENDING => '待接单',
|
||||
StoreOrderModel::STATUS_SUMMARIZED => '已接单',
|
||||
StoreOrderModel::STATUS_DELIVERING => '采购中',
|
||||
StoreOrderModel::STATUS_DISTRIBUTION => '配送中',
|
||||
StoreOrderModel::STATUS_COMPLETED => '已完成',
|
||||
StoreOrderModel::STATUS_CANCELLED => '已取消',
|
||||
];
|
||||
@@ -43,11 +44,30 @@ class StoreOrderController extends BaseController
|
||||
{
|
||||
$params = $request->all();
|
||||
$pageSize = $params['pageSize'] ?? 10;
|
||||
$data = $this->buildSearch($params, StoreOrderModel::query()->with('store:id,name'))
|
||||
$query = StoreOrderModel::query()->with([
|
||||
'store:id,name,address,contact,phone',
|
||||
'items:id,order_id,product_id,product_name,product_spec,price,quantity,amount',
|
||||
'items.product'
|
||||
]);
|
||||
$data = $this->buildSearch($params, $query)
|
||||
->orderBy('order_date', 'desc')
|
||||
->orderBy('id', 'desc')
|
||||
->paginate($pageSize)
|
||||
->toArray();
|
||||
$box_amount = site_config('services.box_amount');
|
||||
$tray_amount = site_config('services.tray_amount');
|
||||
foreach ($data['data'] as &$item) {
|
||||
$item['box_amount'] = number_format($box_amount * $item['box_num'], 2);
|
||||
$item['tray_amount'] = number_format($tray_amount * $item['tray_num'], 2);
|
||||
if(count($item['items']) > 0) {
|
||||
foreach ($item['items'] as &$product) {
|
||||
if($product['product'] && $product['product']['images_arr'] > 0) {
|
||||
$product['image'] = $product['product']['images_arr'][0]['preview_url'] ?? '';
|
||||
unset($product['product']);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return $this->success($data);
|
||||
}
|
||||
|
||||
|
||||
@@ -34,7 +34,7 @@ class StoreOrderItemModel extends Model
|
||||
'store_id' => 'integer',
|
||||
'product_id' => 'integer',
|
||||
'price' => 'decimal:2',
|
||||
'quantity' => 'decimal:2',
|
||||
'quantity' => 'integer',
|
||||
'weight' => 'decimal:3',
|
||||
'amount' => 'decimal:2',
|
||||
];
|
||||
|
||||
@@ -14,16 +14,18 @@ class StoreOrderModel extends Model
|
||||
{
|
||||
use HasFactory;
|
||||
|
||||
/** 状态:待汇总(可被采购单生成归集、可取消) */
|
||||
public const STATUS_PENDING = 0;
|
||||
/** 状态:已汇总(已生成采购单) */
|
||||
public const STATUS_SUMMARIZED = 1;
|
||||
/** 状态:待接单(可被采购单生成归集、可取消) */
|
||||
public const int STATUS_PENDING = 0;
|
||||
/** 状态:已接单(已生成采购单) */
|
||||
public const int STATUS_SUMMARIZED = 1;
|
||||
/** 状态:采购中 */
|
||||
public const int STATUS_DELIVERING = 2;
|
||||
/** 状态:配送中 */
|
||||
public const STATUS_DELIVERING = 2;
|
||||
public const int STATUS_DISTRIBUTION = 3;
|
||||
/** 状态:已完成 */
|
||||
public const STATUS_COMPLETED = 3;
|
||||
public const int STATUS_COMPLETED = 4;
|
||||
/** 状态:已取消 */
|
||||
public const STATUS_CANCELLED = 9;
|
||||
public const int STATUS_CANCELLED = 9;
|
||||
|
||||
protected $table = 'store_order';
|
||||
protected $primaryKey = 'id';
|
||||
@@ -35,17 +37,28 @@ class StoreOrderModel extends Model
|
||||
'total_quantity',
|
||||
'total_weight',
|
||||
'total_amount',
|
||||
'product_amount',
|
||||
'added_amount',
|
||||
'box_num',
|
||||
'tray_num',
|
||||
'status',
|
||||
'remark',
|
||||
];
|
||||
|
||||
protected $casts = [
|
||||
'store_id' => 'integer',
|
||||
'purchase_id' => 'integer',
|
||||
'statement_id' => 'integer',
|
||||
'order_date' => 'date:Y-m-d',
|
||||
'total_quantity' => 'decimal:2',
|
||||
'total_quantity' => 'integer',
|
||||
'total_weight' => 'decimal:3',
|
||||
'total_amount' => 'decimal:2',
|
||||
'product_amount' => 'decimal:2',
|
||||
'added_amount' => 'decimal:2',
|
||||
'box_num' => 'integer',
|
||||
'tray_num' => 'integer',
|
||||
'status' => 'integer',
|
||||
'created_at' => 'datetime:Y-m-d H:i:s',
|
||||
];
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user