修复支付后库存要销量增加问题

This commit is contained in:
mkm 2024-07-22 15:40:54 +08:00
parent 2e267e2f6a
commit c834e81c28
3 changed files with 7 additions and 1049 deletions

View File

@ -284,11 +284,11 @@ class OrderLogic extends BaseLogic
$_order['pay_type'] = $orderInfo['order']['pay_type'];
$_order['verify_code'] = $verify_code;
$_order['reservation_time'] = null;
$_order['reservation'] = $params['reservation'] ?? 0; //是否需要预约
if (isset($params['reservation_time']) && $params['reservation_time']) {
$_order['reservation_time'] = $params['reservation_time'];
$_order['reservation'] = YesNoEnum::YES;
}
$_order['reservation'] = 0;$params['reservation'] ?? 0; //是否需要预约
// if (isset($params['reservation_time']) && $params['reservation_time']) {
// $_order['reservation_time'] = $params['reservation_time'];
// $_order['reservation'] = YesNoEnum::YES;
// }
if ($addressId > 0 && $uid > 0) {
$address = UserAddress::where(['id' => $addressId, 'uid' => $uid])->find();
if ($address) {

File diff suppressed because it is too large Load Diff

View File

@ -95,9 +95,7 @@ class PayNotifyLogic extends BaseLogic
$capitalFlowDao = new CapitalFlowLogic($user);
$capitalFlowDao->userExpense('user_order_balance_pay', 'order', $order['id'], $order['pay_price'], '', 0, $order['store_id']);
self::dealProductLog($order);
if ($order['shipping_type'] == 3) {
// self::descStock($order['id']);
}
self::afterPay($order);
if ($order['reservation'] == 1 && in_array($order['shipping_type'], [1, 2])) {
$checkArr = [
@ -278,9 +276,7 @@ class PayNotifyLogic extends BaseLogic
self::afterPay($order, $extra['transaction_id']);
// self::addUserSing($order);
self::dealProductLog($order);
if ($order['shipping_type'] == 3) {
self::descStock($order['id']);
}
if (!empty($extra['payer']['openid']) && $order->pay_type == 7) {
Redis::send('push-delivery', ['order_id' => $order['order_id'], 'openid' => $extra['payer']['openid']], 4);
}
@ -499,10 +495,6 @@ class PayNotifyLogic extends BaseLogic
$cashFlowLogic->insert($order['store_id'], $order['pay_price']);
self::dealProductLog($order);
if ($order['shipping_type'] == 3) {
self::descStock($order['id']);
}
if ($order && $order['store_id'] && $order['reservation'] !=1) {
$params = [
'verify_code' => $order['verify_code'],
@ -546,9 +538,6 @@ class PayNotifyLogic extends BaseLogic
UserProductStorageLogic::add($order);
}
self::dealProductLog($order);
if ($order['shipping_type'] == 3) {
self::descStock($order['id']);
}
// if ($order->pay_type == 9) {
// $extra['create_time'] = $order['create_time'];
@ -811,37 +800,6 @@ class PayNotifyLogic extends BaseLogic
}
/**
* 扣库存
* @param $oid
* @return void
* @throws \think\db\exception\DataNotFoundException
* @throws \think\db\exception\DbException
* @throws \think\db\exception\ModelNotFoundException
*/
public static function descStock($oid)
{
$updateData = [];
$goods_list = StoreOrderCartInfo::where('oid', $oid)->select()->toArray();
foreach ($goods_list as $v) {
$StoreBranchProduct = StoreBranchProduct::where(
[
'store_id' => $v['store_id'],
'product_id' => $v['product_id'],
]
)->withTrashed()->find();
if ($StoreBranchProduct) {
$updateData[] = [
'id' => $StoreBranchProduct['id'],
'stock' => $StoreBranchProduct['stock'] - $v['cart_num'],
'sales' => ['inc', $v['cart_num']]
];
}
}
(new StoreBranchProduct())->saveAll($updateData);
}
/**
* 加库存
* @param $oid