feat(PayNotifyLogic): 修改支付通知逻辑,增加活动价结算功能
This commit is contained in:
parent
17697bf361
commit
49ee6b0c1c
@ -7,6 +7,7 @@ use app\common\enum\OrderEnum;
|
||||
use app\common\enum\PayEnum;
|
||||
use app\common\enum\user\UserShipEnum;
|
||||
use app\common\enum\YesNoEnum;
|
||||
use app\common\model\Config;
|
||||
use app\common\model\dict\DictType;
|
||||
use app\common\model\finance\CapitalFlow;
|
||||
use app\common\model\finance\PayNotifyLog;
|
||||
@ -260,9 +261,9 @@ class PayNotifyLogic extends BaseLogic
|
||||
$order = StoreOrder::where('order_id', $orderSn)->findOrEmpty();
|
||||
if ($order->isEmpty() || $order->status == OrderEnum::REFUND_PAY) {
|
||||
//充值
|
||||
$orderRe = UserRecharge::where('order_id',$orderSn)->findOrEmpty();
|
||||
if($orderRe->isEmpty() || $orderRe->status == -1){
|
||||
return true;
|
||||
$orderRe = UserRecharge::where('order_id', $orderSn)->findOrEmpty();
|
||||
if ($orderRe->isEmpty() || $orderRe->status == -1) {
|
||||
return true;
|
||||
}
|
||||
$orderRe->status = -1;
|
||||
$orderRe->refund_price = $orderRe->price;
|
||||
@ -283,8 +284,8 @@ class PayNotifyLogic extends BaseLogic
|
||||
$user = User::where('id', $order['uid'])->findOrEmpty();
|
||||
$capitalFlowDao = new CapitalFlowLogic($user);
|
||||
$deal_money = bcdiv($extra['amount']['refund'], 100, 2);
|
||||
if (in_array($order['pay_type'],[PayEnum::BALANCE_PAY,PayEnum::PURCHASE_FUNDS])){
|
||||
if($order['pay_type'] == PayEnum::BALANCE_PAY){//用户余额
|
||||
if (in_array($order['pay_type'], [PayEnum::BALANCE_PAY, PayEnum::PURCHASE_FUNDS])) {
|
||||
if ($order['pay_type'] == PayEnum::BALANCE_PAY) { //用户余额
|
||||
$user->now_money = bcadd($user->now_money, $deal_money, 2);
|
||||
$user->save();
|
||||
//增加数量
|
||||
@ -292,7 +293,7 @@ class PayNotifyLogic extends BaseLogic
|
||||
//退款
|
||||
$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) { //采购款
|
||||
$user->purchase_funds = bcadd($user->purchase_funds, $deal_money, 2);
|
||||
$user->save();
|
||||
//增加数量
|
||||
@ -300,13 +301,12 @@ class PayNotifyLogic extends BaseLogic
|
||||
//退款
|
||||
$capitalFlowDao->userIncome('system_purchase_back', 'system_back', $order['id'], $deal_money);
|
||||
}
|
||||
|
||||
}
|
||||
//微信日志 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);
|
||||
//处理财务流水退还
|
||||
self::store_finance_back($orderSn);
|
||||
self::addStock($order['id']);//微信
|
||||
self::addStock($order['id']); //微信
|
||||
return true;
|
||||
// self::afterPay($order,$extra['transaction_id']);
|
||||
}
|
||||
@ -322,18 +322,17 @@ class PayNotifyLogic extends BaseLogic
|
||||
*/
|
||||
public static function store_finance_back($orderSn)
|
||||
{
|
||||
$data = StoreFinanceFlow::where('order_sn',$orderSn)
|
||||
->where(['financial_pm'=>1])
|
||||
$data = StoreFinanceFlow::where('order_sn', $orderSn)
|
||||
->where(['financial_pm' => 1])
|
||||
->select()->toArray();
|
||||
foreach ($data as &$value){
|
||||
foreach ($data as &$value) {
|
||||
unset($value['id']);
|
||||
$value['financial_record_sn']=(new StoreFinanceFlowLogic)->getSn();
|
||||
$value['financial_pm']=0;
|
||||
$value['financial_type']= OrderEnum::PAY_BACK;
|
||||
$value['create_time']=time();
|
||||
$value['financial_record_sn'] = (new StoreFinanceFlowLogic)->getSn();
|
||||
$value['financial_pm'] = 0;
|
||||
$value['financial_type'] = OrderEnum::PAY_BACK;
|
||||
$value['create_time'] = time();
|
||||
}
|
||||
(new StoreFinanceFlow)->saveAll($data);
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
@ -358,7 +357,7 @@ class PayNotifyLogic extends BaseLogic
|
||||
$order->save();
|
||||
//日志记录
|
||||
$model = new StoreCashFinanceFlow();
|
||||
$model->store_id = $order['store_id']??0;
|
||||
$model->store_id = $order['store_id'] ?? 0;
|
||||
$model->cash_price = $order->pay_price;
|
||||
$model->receivable = $order->pay_price;
|
||||
$model->remark = '退款';
|
||||
@ -376,9 +375,9 @@ class PayNotifyLogic extends BaseLogic
|
||||
* @param $extra
|
||||
* @return true
|
||||
*/
|
||||
public static function recharge_cash_refund($orderId,$extra = [])
|
||||
public static function recharge_cash_refund($orderId, $extra = [])
|
||||
{
|
||||
$order = UserRecharge::where('id',$orderId)->findOrEmpty();
|
||||
$order = UserRecharge::where('id', $orderId)->findOrEmpty();
|
||||
if ($order->isEmpty() || $order->status == -1) {
|
||||
return true;
|
||||
}
|
||||
@ -515,6 +514,27 @@ class PayNotifyLogic extends BaseLogic
|
||||
{
|
||||
$financeLogic = new StoreFinanceFlowLogic();
|
||||
$user_sing = new UserSign();
|
||||
$off_activity = Config::where('name', 'off_activity')->value('value');
|
||||
if ($off_activity == 1) {
|
||||
//-----活动价结算更改
|
||||
$financeLogic->order = $order;
|
||||
$financeLogic->user = ['uid' => $order['uid']];
|
||||
$financeLogic->in($transaction_id, $order['pay_price'], OrderEnum::USER_ORDER_PAY, $order['store_id'], $order['staff_id'], 0, $order['pay_type']); //用户订单支付
|
||||
$financeLogic->in($transaction_id, $order['pay_price'], OrderEnum::SUPPLIER_ORDER_OBTAINS, $order['store_id'], 0, 0, $order['pay_type']);
|
||||
$financeLogic->out($transaction_id, $order['pay_price'], OrderEnum::SUPPLIER_ORDER_OBTAINS, $order['store_id'], $order['staff_id'], 0, $order['pay_type']);
|
||||
if ($order['uid'] > 0) {
|
||||
$user_number = bcmul($order['pay_price'], '0.10', 2);
|
||||
$sing = [
|
||||
'uid' => $order['uid'],
|
||||
'order_id' => $order['order_id'],
|
||||
'title' => '购买商品获得兑换券',
|
||||
'store_id' => $order['store_id'],
|
||||
'number' => $user_number,
|
||||
];
|
||||
$user_sing->save($sing);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
$vipFen = 0;
|
||||
if ($order['uid'] > 0) {
|
||||
// 结算金额 要支付的钱减去冻结得钱去走后面得逻辑 发得兑换券也要去减去
|
||||
@ -896,7 +916,7 @@ class PayNotifyLogic extends BaseLogic
|
||||
$updateData[] = [
|
||||
'id' => $StoreBranchProduct['id'],
|
||||
'stock' => $StoreBranchProduct['stock'] + $v['cart_num'],
|
||||
// 'sales' => ['inc', $v['cart_num']]
|
||||
// 'sales' => ['inc', $v['cart_num']]
|
||||
];
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user