退款退积分相关逻辑新增,减库存兼容核销
This commit is contained in:
parent
8c9608f5da
commit
a40041e2df
@ -92,9 +92,9 @@ class PayNotifyLogic extends BaseLogic
|
|||||||
$capitalFlowDao = new CapitalFlowLogic($user);
|
$capitalFlowDao = new CapitalFlowLogic($user);
|
||||||
$capitalFlowDao->userExpense('user_order_balance_pay', 'order', $order['id'], $order['pay_price'], '', 0, $order['store_id']);
|
$capitalFlowDao->userExpense('user_order_balance_pay', 'order', $order['id'], $order['pay_price'], '', 0, $order['store_id']);
|
||||||
self::dealProductLog($order);
|
self::dealProductLog($order);
|
||||||
if ($order['shipping_type'] == 3) {
|
// if ($order['shipping_type'] == 3) {
|
||||||
self::descStock($order['id']);
|
// self::descStock($order['id']);
|
||||||
}
|
// }
|
||||||
self::afterPay($order);
|
self::afterPay($order);
|
||||||
if ($extra && $extra['store_id']) {
|
if ($extra && $extra['store_id']) {
|
||||||
$params = [
|
$params = [
|
||||||
@ -289,7 +289,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);
|
||||||
$deal_money = bcdiv($extra['amount']['refund'], 100, 2);
|
$deal_money = bcdiv($extra['amount']['refund'], 100, 2);
|
||||||
|
$check_user_sing = UserSign::where('order_id',$order['order_id'])->count();
|
||||||
if (in_array($order['pay_type'], [PayEnum::BALANCE_PAY, PayEnum::PURCHASE_FUNDS])) {
|
if (in_array($order['pay_type'], [PayEnum::BALANCE_PAY, PayEnum::PURCHASE_FUNDS])) {
|
||||||
if ($order['pay_type'] == PayEnum::BALANCE_PAY) { //用户余额
|
if ($order['pay_type'] == PayEnum::BALANCE_PAY) { //用户余额
|
||||||
$user->now_money = bcadd($user->now_money, $deal_money, 2);
|
$user->now_money = bcadd($user->now_money, $deal_money, 2);
|
||||||
@ -299,7 +299,6 @@ class PayNotifyLogic extends BaseLogic
|
|||||||
//退款
|
//退款
|
||||||
$capitalFlowDao->userIncome('system_balance_back', 'system_back', $order['id'], $deal_money);
|
$capitalFlowDao->userIncome('system_balance_back', 'system_back', $order['id'], $deal_money);
|
||||||
}
|
}
|
||||||
if ($order['pay_type'] == PayEnum::PURCHASE_FUNDS) { //采购款
|
|
||||||
if ($order['pay_type'] == PayEnum::PURCHASE_FUNDS) { //采购款
|
if ($order['pay_type'] == PayEnum::PURCHASE_FUNDS) { //采购款
|
||||||
$user->purchase_funds = bcadd($user->purchase_funds, $deal_money, 2);
|
$user->purchase_funds = bcadd($user->purchase_funds, $deal_money, 2);
|
||||||
$user->save();
|
$user->save();
|
||||||
@ -308,6 +307,14 @@ class PayNotifyLogic extends BaseLogic
|
|||||||
//退款
|
//退款
|
||||||
$capitalFlowDao->userIncome('system_purchase_back', 'system_back', $order['id'], $deal_money);
|
$capitalFlowDao->userIncome('system_purchase_back', 'system_back', $order['id'], $deal_money);
|
||||||
}
|
}
|
||||||
|
if($check_user_sing){
|
||||||
|
self::descUserSing($order);
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
//积分
|
||||||
|
if($check_user_sing){
|
||||||
|
self::descUserSing($order);
|
||||||
}
|
}
|
||||||
//微信日志 user_order_refund
|
//微信日志 user_order_refund
|
||||||
$capitalFlowDao->userIncome('user_order_refund', 'system_back', $order['id'], $deal_money, '', 1);
|
$capitalFlowDao->userIncome('user_order_refund', 'system_back', $order['id'], $deal_money, '', 1);
|
||||||
@ -317,9 +324,38 @@ class PayNotifyLogic extends BaseLogic
|
|||||||
return true;
|
return true;
|
||||||
// self::afterPay($order,$extra['transaction_id']);
|
// self::afterPay($order,$extra['transaction_id']);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//退积分
|
||||||
|
public static function descUserSing($order)
|
||||||
|
{
|
||||||
|
$user_sing = new UserSign();
|
||||||
|
if ($order['uid'] > 0 ) {
|
||||||
|
$user_number = bcmul($order['refund_price'], '0.10', 2);
|
||||||
|
$sing = [
|
||||||
|
'uid' => $order['uid'],
|
||||||
|
'order_id' => $order['order_id'],
|
||||||
|
'title' => '退款扣除兑换券',
|
||||||
|
'financial_pm' => 0,
|
||||||
|
'store_id' => $order['store_id'],
|
||||||
|
'number' => $user_number,
|
||||||
|
];
|
||||||
|
$user_sing->save($sing);
|
||||||
|
$now_int = User::where('id',$order['uid'])->find();
|
||||||
|
if($now_int){
|
||||||
|
if($now_int['integral'] > $user_number){
|
||||||
|
User::where('id',$order['uid'])->dec('integral',$user_number)->update();
|
||||||
|
}else{
|
||||||
|
User::where('id',$order['uid'])->dec('integral',$now_int['integral'])->update();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 财务退还金额相关
|
* 财务退还金额相关
|
||||||
* @param $orderSn
|
* @param $orderSn
|
||||||
@ -407,6 +443,7 @@ class PayNotifyLogic extends BaseLogic
|
|||||||
'uid' => $order['uid'],
|
'uid' => $order['uid'],
|
||||||
'order_id' => $order['order_id'],
|
'order_id' => $order['order_id'],
|
||||||
'title' => '购买商品获得兑换券',
|
'title' => '购买商品获得兑换券',
|
||||||
|
'financial_pm' => 1,
|
||||||
'store_id' => $order['store_id'],
|
'store_id' => $order['store_id'],
|
||||||
'number' => $user_number,
|
'number' => $user_number,
|
||||||
];
|
];
|
||||||
@ -557,6 +594,7 @@ class PayNotifyLogic extends BaseLogic
|
|||||||
'uid' => $order['uid'],
|
'uid' => $order['uid'],
|
||||||
'order_id' => $order['order_id'],
|
'order_id' => $order['order_id'],
|
||||||
'title' => '购买商品获得兑换券',
|
'title' => '购买商品获得兑换券',
|
||||||
|
'financial_pm' => 1,
|
||||||
'store_id' => $order['store_id'],
|
'store_id' => $order['store_id'],
|
||||||
'number' => $user_number,
|
'number' => $user_number,
|
||||||
];
|
];
|
||||||
@ -592,6 +630,7 @@ class PayNotifyLogic extends BaseLogic
|
|||||||
'uid' => $order['uid'],
|
'uid' => $order['uid'],
|
||||||
'order_id' => $order['order_id'],
|
'order_id' => $order['order_id'],
|
||||||
'title' => '购买商品获得兑换券',
|
'title' => '购买商品获得兑换券',
|
||||||
|
'financial_pm' => 1,
|
||||||
'store_id' => $order['store_id'],
|
'store_id' => $order['store_id'],
|
||||||
'number' => $user_number,
|
'number' => $user_number,
|
||||||
'status' => 0,
|
'status' => 0,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user