feat: 修改订单创建逻辑,优化了支付类型判断和订单生成过程,并调整了部分代码结构。

This commit is contained in:
mkm 2024-06-13 16:11:14 +08:00
parent a1b54043d2
commit 3f90482d70
3 changed files with 9 additions and 15 deletions

View File

@ -182,14 +182,9 @@ class OrderController extends BaseApiController
return $this->fail('购物车商品不能超过100个');
}
// if ($pay_type == 9 || $pay_type == 17 ||$pay_type==13) {
// if (empty($this->request->userInfo['merchant'])) {
// return $this->fail('请先绑定商户');
// }
// $mer_id = $this->request->userInfo['merchant']['mer_id'];
// $params['mer_id'] = $mer_id;
// }
$order = OrderLogic::createOrder($cartId, $addressId, null, $params);
$user=User::where('id',$this->userId)->find();
$order = OrderLogic::createOrder($cartId, $addressId, $user, $params);
if ($order != false) {
switch ($pay_type) {
case PayEnum::BALANCE_PAY:

View File

@ -61,7 +61,7 @@ class OrderLogic extends BaseLogic
self::setError('购物车为空');
return false;
}
// try {
try {
self::$total_price = 0;
self::$pay_price = 0;
self::$cost = 0; //成本
@ -141,10 +141,10 @@ class OrderLogic extends BaseLogic
if ($params['store_id']) {
$order['default_delivery'] = SystemStore::where('id', $params['store_id'])->value('is_send');
}
// } catch (\Exception $e) {
// self::setError($e->getMessage());
// return false;
// }
} catch (\Exception $e) {
self::setError($e->getMessage());
return false;
}
return ['order' => $order, 'cart_list' => $cart_select];
}

View File

@ -46,7 +46,6 @@ class StoreOrderLogic extends BaseLogic
self::$activity_price = 0; //活动减少
/** 计算价格 */
$check = DictType::where('type', 'activities')->find();
foreach ($cart_select as $k => $v) {
$find = StoreBranchProduct::where(['product_id' => $v['product_id'],'store_id'=>$params['store_id']])->field('id branch_product_id,store_name,image,unit,cost price,cost,product_id')->find();
if (!$find) {
@ -107,7 +106,7 @@ class StoreOrderLogic extends BaseLogic
'shipping_type' =>3,//配送方式 1=快递 2=门店自提
'activity' =>'减免',
'activity_price' =>self::$activity_price,
'activities'=>$check['status'],
'activities' => self::$activity_price>0?1:0,
'default_delivery'=>1,
'original_price'=>self::$total_price,
'deduction_price' => self::$activity_price