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