优化预订单系统逻辑和数据处理
- 在生成预订单时增加订单类型的判断,避免生成支付订单 - 优化预订单列表展示,增加出库单ID字段 - 完善从商城订单转换为预订单的逻辑,防止重复转换 - 修复了一些潜在的逻辑错误和数据一致性问题
This commit is contained in:
parent
e3d3e94a08
commit
9103d26df9
@ -43,7 +43,7 @@ class BeforehandOrderLists extends BaseAdminDataLists implements ListsSearchInte
|
||||
public function lists(): array
|
||||
{
|
||||
return BeforehandOrder::where($this->searchWhere)
|
||||
->field(['id','order_id', 'uid','order_type','total_num','total_price','admin_id', 'pay_price', 'deduction_price','create_time', 'status', 'mark'])
|
||||
->field(['id','order_id', 'uid','order_type','total_num','total_price','outbound_id','admin_id', 'pay_price', 'deduction_price','create_time', 'status', 'mark'])
|
||||
->limit($this->limitOffset, $this->limitLength)
|
||||
->order(['id' => 'desc'])
|
||||
->select()->each(function ($item){
|
||||
|
@ -92,9 +92,12 @@ class BeforehandOrderLogic extends BaseLogic
|
||||
*/
|
||||
public static function generateOrder(array $params): bool
|
||||
{
|
||||
$order = BeforehandOrder::where('id', $params['id'])->find();
|
||||
if ($order['order_type']==4) {
|
||||
throw new BusinessException('该订单类型不能生成支付订单');
|
||||
}
|
||||
Db::startTrans();
|
||||
try {
|
||||
$order = BeforehandOrder::where('id', $params['id'])->find();
|
||||
$cart_info = BeforehandOrderCartInfo::where('bhoid', $params['id'])->select()->toArray();
|
||||
|
||||
$cart_select = [];
|
||||
@ -225,7 +228,6 @@ class BeforehandOrderLogic extends BaseLogic
|
||||
return true;
|
||||
} catch (\Throwable $e) {
|
||||
Db::rollback();
|
||||
d($e);
|
||||
throw new BusinessException($e->getMessage());
|
||||
}
|
||||
}
|
||||
@ -345,6 +347,10 @@ class BeforehandOrderLogic extends BaseLogic
|
||||
$datas = [];
|
||||
|
||||
$order = StoreOrder::where('id', $params['id'])->find();
|
||||
$find=BeforehandOrder::where('order_sn',$order['order_id'])->find();
|
||||
if($find){
|
||||
throw new BusinessException('该订单已转成预定单,请勿重新转');
|
||||
}
|
||||
$info = StoreOrderCartInfo::where('oid', $params['id'])->select();
|
||||
$total_num = $order['total_num'];
|
||||
$total_price = $order['total_price'];
|
||||
@ -369,6 +375,7 @@ class BeforehandOrderLogic extends BaseLogic
|
||||
'total_price' => $total_price,
|
||||
'pay_price' => 0,
|
||||
'pay_type' => 0,
|
||||
'order_type' => 4,
|
||||
'deduction_price' => 0,
|
||||
'paid' => 0,
|
||||
'mark' => $params['mark'] ?? ''
|
||||
|
Loading…
x
Reference in New Issue
Block a user