feat: 修改订单逻辑以处理购物车商品

This commit is contained in:
mkm 2024-06-08 19:56:02 +08:00
parent 5eebccb700
commit 73ff0a9ae8
3 changed files with 8 additions and 4 deletions

View File

@ -72,6 +72,7 @@ class OrderLogic extends BaseLogic
if (isset($check) && $check['status'] == 1) { if (isset($check) && $check['status'] == 1) {
$find['price'] = $productBase['ot_price']; $find['price'] = $productBase['ot_price'];
} }
unset($cart_select[$k]['id']);
//利润 //利润
$onePrice = bcsub($productBase['price'], $productBase['ot_price'], 2); $onePrice = bcsub($productBase['price'], $productBase['ot_price'], 2);
$cart_select[$k]['profit'] = bcmul($v['cart_num'], $onePrice, 2);//利润 $cart_select[$k]['profit'] = bcmul($v['cart_num'], $onePrice, 2);//利润

View File

@ -43,8 +43,10 @@ class StoreOrderLogic extends BaseLogic
if (!$find) { if (!$find) {
continue; continue;
} }
unset($cart_select[$k]['id']);
$cart_select[$k]['total'] = bcmul($v['cart_num'], $find['price'], 2); //钱 $cart_select[$k]['total'] = bcmul($v['cart_num'], $find['price'], 2); //钱
$cart_select[$k]['price'] = $find['price']; $cart_select[$k]['price'] = $find['price'];
$cart_select[$k]['total_price'] = bcmul($v['cart_num'], $find['price'], 2);//钱
$cart_select[$k]['product_id'] = $v['product_id']; $cart_select[$k]['product_id'] = $v['product_id'];
$cart_select[$k]['old_cart_id'] = $v['id']; $cart_select[$k]['old_cart_id'] = $v['id'];
$cart_select[$k]['cart_num'] = $v['cart_num']; $cart_select[$k]['cart_num'] = $v['cart_num'];
@ -130,7 +132,8 @@ class StoreOrderLogic extends BaseLogic
$order = StoreOrder::create($_order); $order = StoreOrder::create($_order);
$goods_list = $orderInfo['cart_list']; $goods_list = $orderInfo['cart_list'];
foreach ($goods_list as $k => $v) { foreach ($goods_list as $k => $v) {
$goods_list[$k]['oid'] = $order->id; $goods_list[$k]['oid'] = 153;
$goods_list[$k]['uid'] = 0;
$goods_list[$k]['cart_id'] = implode(',', $cartId); $goods_list[$k]['cart_id'] = implode(',', $cartId);
$goods_list[$k]['delivery_id'] = $params['store_id']; //商家id $goods_list[$k]['delivery_id'] = $params['store_id']; //商家id
} }

View File

@ -181,15 +181,15 @@ class StoreOrderController extends BaseAdminController
public function pay() public function pay()
{ {
$order_id = (int)$this->request->post('order_id'); $order_id = $this->request->post('order_id');
$pay_type = (int)$this->request->post('pay_type'); $pay_type = $this->request->post('pay_type');
$auth_code = $this->request->post('auth_code'); //微信支付条码 $auth_code = $this->request->post('auth_code'); //微信支付条码
if ($auth_code == '' && $pay_type != PayEnum::CASH_PAY) { if ($auth_code == '' && $pay_type != PayEnum::CASH_PAY) {
return $this->fail('支付条码不能为空'); return $this->fail('支付条码不能为空');
} }
$params = $this->request->post(); $params = $this->request->post();
$where = [ $where = [
'id' => $order_id, 'order_id' => $order_id,
'paid' => 0, 'paid' => 0,
]; ];
$order = StoreOrder::where($where)->find(); $order = StoreOrder::where($where)->find();