This commit is contained in:
luofei 2024-03-22 15:20:54 +08:00
commit 2338f133a1
64 changed files with 91 additions and 76 deletions

View File

@ -897,7 +897,7 @@ class StoreOrderCreateRepository extends StoreOrderRepository
return $data; return $data;
} }
public function v2CreateOrder($key, int $pay_type, $user, array $cartId, array $extend, array $mark, array $receipt_data, array $takes = null, array $useCoupon = null, bool $useIntegral = false, int $addressId = null, array $post) public function v2CreateOrder($key, int $pay_type, $user, array $cartId, array $extend, array $mark, array $receipt_data, array $takes = null, array $useCoupon = null, bool $useIntegral = false, int $addressId = null, array $post,$remarkMoney)
{ {
$uid = $user->uid; $uid = $user->uid;
// $orderInfo = $this->v2CartIdByOrderInfo($user, $cartId, $takes, $useCoupon, $useIntegral, $addressId, true); // $orderInfo = $this->v2CartIdByOrderInfo($user, $cartId, $takes, $useCoupon, $useIntegral, $addressId, true);
@ -1134,6 +1134,14 @@ class StoreOrderCreateRepository extends StoreOrderRepository
$totalCost = bcadd($totalCost, $cost, 2); $totalCost = bcadd($totalCost, $cost, 2);
$totalNum += $merchantCart['order']['total_num']; $totalNum += $merchantCart['order']['total_num'];
} }
//当$remarkMoney不为0得时候就是输入金额匹配去处理得
$pay_price = $orderInfo['order_price'];
$coupon_price = bcadd($orderInfo['total_platform_coupon_price'], $orderInfo['order_coupon_price'], 2);
if($remarkMoney){
$pay_price = $remarkMoney;//输入得金额
$coupon_price = $orderInfo['order_price'] -$pay_price;
}
$groupOrder = [ $groupOrder = [
'uid' => $uid, 'uid' => $uid,
'group_order_sn' => count($orderList) === 1 ? $orderList[0]['order_sn'] : ($this->getNewOrderId(StoreOrderRepository::TYPE_SN_ORDER) . '0'), 'group_order_sn' => count($orderList) === 1 ? $orderList[0]['order_sn'] : ($this->getNewOrderId(StoreOrderRepository::TYPE_SN_ORDER) . '0'),
@ -1143,8 +1151,8 @@ class StoreOrderCreateRepository extends StoreOrderRepository
'real_name' => $address['real_name'] ?? '', 'real_name' => $address['real_name'] ?? '',
'user_phone' => $address['phone'] ?? '', 'user_phone' => $address['phone'] ?? '',
'user_address' => $user_address, 'user_address' => $user_address,
'pay_price' => $orderInfo['order_price'], 'pay_price' => $pay_price,
'coupon_price' => bcadd($orderInfo['total_platform_coupon_price'], $orderInfo['order_coupon_price'], 2), 'coupon_price' => $coupon_price,
'pay_postage' => $totalPostage, 'pay_postage' => $totalPostage,
'cost' => $totalCost, 'cost' => $totalCost,
'coupon_id' => $orderInfo['usePlatformCouponId'] > 0 ? $orderInfo['usePlatformCouponId'] : '', 'coupon_id' => $orderInfo['usePlatformCouponId'] > 0 ? $orderInfo['usePlatformCouponId'] : '',
@ -1157,7 +1165,7 @@ class StoreOrderCreateRepository extends StoreOrderRepository
'sale_type' => $saleType, 'sale_type' => $saleType,
]; ];
event('order.create.before', compact('groupOrder', 'orderList')); event('order.create.before', compact('groupOrder', 'orderList'));
$group = Db::transaction(function () use ($ex, $user, $topUid, $spreadUid, $uid, $receipt_data, $cartIds, $allUseCoupon, $groupOrder, $orderList, $orderInfo, $useCoupon) { $group = Db::transaction(function () use ($ex, $user, $topUid, $spreadUid, $uid, $receipt_data, $cartIds, $allUseCoupon, $groupOrder, $orderList, $orderInfo, $useCoupon,$pay_type) {
$storeGroupOrderRepository = app()->make(StoreGroupOrderRepository::class); $storeGroupOrderRepository = app()->make(StoreGroupOrderRepository::class);
$storeCartRepository = app()->make(StoreCartRepository::class); $storeCartRepository = app()->make(StoreCartRepository::class);
$attrValueRepository = app()->make(ProductAttrValueRepository::class); $attrValueRepository = app()->make(ProductAttrValueRepository::class);
@ -1169,7 +1177,9 @@ class StoreOrderCreateRepository extends StoreOrderRepository
$userMerchantRepository = app()->make(UserMerchantRepository::class); $userMerchantRepository = app()->make(UserMerchantRepository::class);
$storeCouponUserDao = new StoreCouponUserDao(); $storeCouponUserDao = new StoreCouponUserDao();
//减库存 //减库存 ---不为对公转账
if ($pay_type != Enum::public) {
foreach ($orderList as $order) { foreach ($orderList as $order) {
foreach ($order['cartInfo']['list'] as $cart) { foreach ($order['cartInfo']['list'] as $cart) {
if (!isset($uniqueList[$cart['productAttr']['product_id'] . $cart['productAttr']['unique']])) if (!isset($uniqueList[$cart['productAttr']['product_id'] . $cart['productAttr']['unique']]))
@ -1212,6 +1222,7 @@ class StoreOrderCreateRepository extends StoreOrderRepository
} }
} }
} }
}
if ($orderInfo['order_type'] == 10 && !app()->make(StoreDiscountRepository::class)->decStock($orderList[0]['cartInfo']['list'][0]['source_id'])) { if ($orderInfo['order_type'] == 10 && !app()->make(StoreDiscountRepository::class)->decStock($orderList[0]['cartInfo']['list'][0]['source_id'])) {
throw new ValidateException('套餐库不足'); throw new ValidateException('套餐库不足');

View File

@ -83,7 +83,7 @@ class StoreOrder extends BaseController
$payType = $this->request->param('pay_type'); $payType = $this->request->param('pay_type');
$key = (string)$this->request->param('key'); $key = (string)$this->request->param('key');
$post = (array)$this->request->param('post'); $post = (array)$this->request->param('post');
$remarkMoney = $this->request->param('money')??0;//匹配金额
if(!$key){ if(!$key){
return app('json')->fail('订单操作超时,请刷新页面'); return app('json')->fail('订单操作超时,请刷新页面');
} }
@ -108,9 +108,9 @@ class StoreOrder extends BaseController
// if (!$addressId) // if (!$addressId)
// return app('json')->fail('请选择地址'); // return app('json')->fail('请选择地址');
$groupOrder = app()->make(LockService::class)->exec('order.create', function () use ($key, $orderCreateRepository, $receipt_data, $mark, $extend, $cartId, $payType, $takes, $couponIds, $useIntegral, $addressId, $post) { $groupOrder = app()->make(LockService::class)->exec('order.create', function () use ($key, $orderCreateRepository, $receipt_data, $mark, $extend, $cartId, $payType, $takes, $couponIds, $useIntegral, $addressId, $post,$remarkMoney) {
$orderCreateRepository->isScanOrder = (int)$this->request->param('source') == 999; $orderCreateRepository->isScanOrder = (int)$this->request->param('source') == 999;
return $orderCreateRepository->v2CreateOrder($key, array_search($payType, StoreOrderRepository::PAY_TYPE), $this->request->userInfo(), $cartId, $extend, $mark, $receipt_data, $takes, $couponIds, $useIntegral, $addressId, $post); return $orderCreateRepository->v2CreateOrder($key, array_search($payType, StoreOrderRepository::PAY_TYPE), $this->request->userInfo(), $cartId, $extend, $mark, $receipt_data, $takes, $couponIds, $useIntegral, $addressId, $post,$remarkMoney);
}); });
if ($isPc) { if ($isPc) {

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long