Merge pull request 'fix(app): 修复订单退款和库存处理相关问题' (#493) from dev into main
Reviewed-on: #493
This commit is contained in:
commit
8658df0d79
@ -284,8 +284,8 @@ class PayNotifyLogic extends BaseLogic
|
|||||||
// self::dealProductLog($order);
|
// self::dealProductLog($order);
|
||||||
|
|
||||||
if ($order->pay_type == 7) {
|
if ($order->pay_type == 7) {
|
||||||
$openid=UserAuth::where('user_id',$order['uid'])->value('openid');
|
$openid = UserAuth::where('user_id', $order['uid'])->value('openid');
|
||||||
if($openid){
|
if ($openid) {
|
||||||
Redis::send('push-delivery', ['order_id' => $order['order_id'], 'openid' => $openid, 'logistics_type' => 4]);
|
Redis::send('push-delivery', ['order_id' => $order['order_id'], 'openid' => $openid, 'logistics_type' => 4]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -326,8 +326,8 @@ class PayNotifyLogic extends BaseLogic
|
|||||||
UserSignLogic::RefundRecharge($orderRe);
|
UserSignLogic::RefundRecharge($orderRe);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
$refund=bcdiv($extra['amount']['refund'], 100, 2);
|
$refund = bcdiv($extra['amount']['refund'], 100, 2);
|
||||||
if($refund==$order['pay_price']){
|
if ($refund == $order['pay_price']) {
|
||||||
$order->status = OrderEnum::REFUND_PAY;
|
$order->status = OrderEnum::REFUND_PAY;
|
||||||
$order->refund_status = OrderEnum::REFUND_STATUS_FINISH;
|
$order->refund_status = OrderEnum::REFUND_STATUS_FINISH;
|
||||||
$order->refund_price = $refund;
|
$order->refund_price = $refund;
|
||||||
@ -351,7 +351,7 @@ class PayNotifyLogic extends BaseLogic
|
|||||||
// $user = User::where('id', $order['uid'])->findOrEmpty();
|
// $user = User::where('id', $order['uid'])->findOrEmpty();
|
||||||
// $capitalFlowDao = new CapitalFlowLogic($user);
|
// $capitalFlowDao = new CapitalFlowLogic($user);
|
||||||
// $capitalFlowDao->userIncome('user_order_refund', 'system_back', $order['id'], $order['pay_price'], '', 1);
|
// $capitalFlowDao->userIncome('user_order_refund', 'system_back', $order['id'], $order['pay_price'], '', 1);
|
||||||
self::addStock($order['id'],$order);
|
self::addStock($order['id'], $order);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -374,7 +374,7 @@ class PayNotifyLogic extends BaseLogic
|
|||||||
}
|
}
|
||||||
$user->save();
|
$user->save();
|
||||||
//增加数量
|
//增加数量
|
||||||
self::addStock($order['id'],$order);
|
self::addStock($order['id'], $order);
|
||||||
}
|
}
|
||||||
if ($order['pay_type'] == PayEnum::PURCHASE_FUNDS) { //采购款支付
|
if ($order['pay_type'] == PayEnum::PURCHASE_FUNDS) { //采购款支付
|
||||||
$user = User::where('id', $order['uid'])->findOrEmpty();
|
$user = User::where('id', $order['uid'])->findOrEmpty();
|
||||||
@ -389,7 +389,7 @@ class PayNotifyLogic extends BaseLogic
|
|||||||
}
|
}
|
||||||
$user->save();
|
$user->save();
|
||||||
//增加数量
|
//增加数量
|
||||||
self::addStock($order['id'],$order);
|
self::addStock($order['id'], $order);
|
||||||
}
|
}
|
||||||
UserSignLogic::RefundOrder($order);
|
UserSignLogic::RefundOrder($order);
|
||||||
|
|
||||||
@ -427,7 +427,7 @@ class PayNotifyLogic extends BaseLogic
|
|||||||
$model->status = YesNoEnum::YES;
|
$model->status = YesNoEnum::YES;
|
||||||
$model->save();
|
$model->save();
|
||||||
//增加数量
|
//增加数量
|
||||||
self::addStock($order['id'],$order);
|
self::addStock($order['id'], $order);
|
||||||
StoreOrderCartInfo::where('oid', $order['id'])->update(['status' => OrderEnum::REFUND_STATUS_FINISH]);
|
StoreOrderCartInfo::where('oid', $order['id'])->update(['status' => OrderEnum::REFUND_STATUS_FINISH]);
|
||||||
(new StoreFinanceFlowLogic())->store_finance_back($orderSn, $order['store_id']);
|
(new StoreFinanceFlowLogic())->store_finance_back($orderSn, $order['store_id']);
|
||||||
|
|
||||||
@ -502,7 +502,7 @@ class PayNotifyLogic extends BaseLogic
|
|||||||
$uid = $order['other_uid'];
|
$uid = $order['other_uid'];
|
||||||
}
|
}
|
||||||
$cashFlowLogic = new CashFlowLogic();
|
$cashFlowLogic = new CashFlowLogic();
|
||||||
$cashFlowLogic->insert($order['store_id'], $order['price'],$orderSn);
|
$cashFlowLogic->insert($order['store_id'], $order['price'], $orderSn);
|
||||||
|
|
||||||
PushService::push('wechat_mmp_' . $uid, $uid, ['type' => 'INDUSTRYMEMBERS', 'msg' => '订单支付成功', 'data' => ['id' => $order['id'], 'paid' => 1]]);
|
PushService::push('wechat_mmp_' . $uid, $uid, ['type' => 'INDUSTRYMEMBERS', 'msg' => '订单支付成功', 'data' => ['id' => $order['id'], 'paid' => 1]]);
|
||||||
PushService::push('store_merchant_' . $order['store_id'], $order['store_id'], ['type' => 'INDUSTRYMEMBERS', 'msg' => '订单支付成功', 'data' => ['id' => $order['id'], 'paid' => 1]]);
|
PushService::push('store_merchant_' . $order['store_id'], $order['store_id'], ['type' => 'INDUSTRYMEMBERS', 'msg' => '订单支付成功', 'data' => ['id' => $order['id'], 'paid' => 1]]);
|
||||||
@ -624,25 +624,27 @@ class PayNotifyLogic extends BaseLogic
|
|||||||
'total_price' => bcmul($stock, $storeProduct['purchase'], 2),
|
'total_price' => bcmul($stock, $storeProduct['purchase'], 2),
|
||||||
'sales' => bcadd($storeProduct['sales'], $v['cart_num'], 2)
|
'sales' => bcadd($storeProduct['sales'], $v['cart_num'], 2)
|
||||||
], ['id' => $v['product_id']]);
|
], ['id' => $v['product_id']]);
|
||||||
if($storeProduct['product_type']==5){
|
if ($storeProduct['product_type'] == 5) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if ($branchProduct) {
|
if ($order['source'] != OrderEnum::SOURCE_20) {
|
||||||
$stock = bcsub($branchProduct['stock'], $v['cart_num'], 2);
|
if ($branchProduct) {
|
||||||
StoreBranchProduct::update([
|
$stock = bcsub($branchProduct['stock'], $v['cart_num'], 2);
|
||||||
'stock' => $stock,
|
StoreBranchProduct::update([
|
||||||
'total_price' => bcmul($stock, $branchProduct['purchase'], 2),
|
'stock' => $stock,
|
||||||
'sales' => bcadd($branchProduct['sales'], $v['cart_num'], 2)
|
'total_price' => bcmul($stock, $branchProduct['purchase'], 2),
|
||||||
], ['id' => $branchProduct['id']]);
|
'sales' => bcadd($branchProduct['sales'], $v['cart_num'], 2)
|
||||||
SqlChannelLog('StoreBranchProduct',$branchProduct['id'], $v['cart_num'], -1, Request()->url());
|
], ['id' => $branchProduct['id']]);
|
||||||
} else {
|
SqlChannelLog('StoreBranchProduct', $branchProduct['id'], $v['cart_num'], -1, Request()->url());
|
||||||
StoreProductLogic::ordinary(['id' => $v['product_id']], $v['store_id'], 0, $storeProduct);
|
} else {
|
||||||
StoreBranchProduct::update([
|
StoreProductLogic::ordinary(['id' => $v['product_id']], $v['store_id'], 0, $storeProduct);
|
||||||
'stock' => -$v['cart_num'],
|
StoreBranchProduct::update([
|
||||||
'sales' => $v['cart_num']
|
'stock' => -$v['cart_num'],
|
||||||
], ['product_id' => $v['product_id'],'store_id'=>$v['store_id']]);
|
'sales' => $v['cart_num']
|
||||||
SqlChannelLog('StoreBranchProduct',$branchProduct['id'], $v['cart_num'], -1, Request()->url());
|
], ['product_id' => $v['product_id'], 'store_id' => $v['store_id']]);
|
||||||
|
SqlChannelLog('StoreBranchProduct', $branchProduct['id'], $v['cart_num'], -1, Request()->url());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} catch (\Throwable $e) {
|
} catch (\Throwable $e) {
|
||||||
@ -660,8 +662,8 @@ class PayNotifyLogic extends BaseLogic
|
|||||||
if ($order['uid'] != 1) {
|
if ($order['uid'] != 1) {
|
||||||
Redis::send('order_wetcha_push_send', ['order' => $order]);
|
Redis::send('order_wetcha_push_send', ['order' => $order]);
|
||||||
}
|
}
|
||||||
$xprinter=DictData::where('type_value','xprinter')->where('name','xprinter_'.$order['store_id'])->where('status',1)->find();
|
$xprinter = DictData::where('type_value', 'xprinter')->where('name', 'xprinter_' . $order['store_id'])->where('status', 1)->find();
|
||||||
if($xprinter){
|
if ($xprinter) {
|
||||||
Redis::send('order_xprinter_push_send', ['order' => $order]);
|
Redis::send('order_xprinter_push_send', ['order' => $order]);
|
||||||
}
|
}
|
||||||
} catch (\Exception $e) {
|
} catch (\Exception $e) {
|
||||||
@ -866,9 +868,9 @@ class PayNotifyLogic extends BaseLogic
|
|||||||
* @throws \think\db\exception\DbException
|
* @throws \think\db\exception\DbException
|
||||||
* @throws \think\db\exception\ModelNotFoundException
|
* @throws \think\db\exception\ModelNotFoundException
|
||||||
*/
|
*/
|
||||||
public static function addStock($oid,$order)
|
public static function addStock($oid, $order)
|
||||||
{
|
{
|
||||||
if($order && $order['source']==OrderEnum::SOURCE_20){
|
if ($order && $order['source'] == OrderEnum::SOURCE_20) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
$updateData = [];
|
$updateData = [];
|
||||||
@ -884,14 +886,14 @@ class PayNotifyLogic extends BaseLogic
|
|||||||
$updateData[] = [
|
$updateData[] = [
|
||||||
'id' => $StoreBranchProduct['id'],
|
'id' => $StoreBranchProduct['id'],
|
||||||
'stock' => $StoreBranchProduct['stock'] + $v['cart_num'],
|
'stock' => $StoreBranchProduct['stock'] + $v['cart_num'],
|
||||||
'sales' => ['dec', $v['cart_num']]
|
'sales' => ['dec', $v['cart_num']]
|
||||||
// 'sales' => ['inc', $v['cart_num']]
|
// 'sales' => ['inc', $v['cart_num']]
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
(new StoreBranchProduct())->saveAll($updateData);
|
(new StoreBranchProduct())->saveAll($updateData);
|
||||||
SqlChannelLog('StoreBranchProduct',0,0,1,Request()->url());
|
SqlChannelLog('StoreBranchProduct', 0, 0, 1, Request()->url());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user