回调日志

This commit is contained in:
liu 2024-06-08 18:04:40 +08:00
parent f966f07843
commit da297380fc
2 changed files with 29 additions and 18 deletions

View File

@ -31,7 +31,8 @@ class OrderEnum
const CASHIER_ORDER_PAY = 9;
const CASHIER_CASH_ORDER_PAY = 10;
const OWN_GET = 3;
const ORDER_MARGIN = 11;
const ORDER_COMMITION = 12;
/**

View File

@ -10,6 +10,7 @@ use app\common\model\finance\PayNotifyLog;
use app\common\model\pay\PayNotify;
use app\common\model\store_finance_flow\StoreFinanceFlow;
use app\common\model\store_order\StoreOrder;
use app\common\model\system_store\SystemStore;
use app\common\model\user\User;
use app\common\model\user\UserRecharge;
use app\common\model\user\UserShip;
@ -131,15 +132,15 @@ class PayNotifyLogic extends BaseLogic
{
//更新状态
$order = StoreOrder::where('order_id',$orderSn)->findOrEmpty();
// if ($order->isEmpty() || $order->status == OrderEnum::REFUND_PAY) {
// return true;
// }
// $order->status = OrderEnum::REFUND_PAY;
// $order->refund_status = OrderEnum::REFUND_STATUS_FINISH;
// $order->refund_price = bcdiv($extra['amount']['refund'], 100, 2);
// $order->refund_reason_time = time();
// $order->refund_num += 1;
// $order->save();
if ($order->isEmpty() || $order->status == OrderEnum::REFUND_PAY) {
return true;
}
$order->status = OrderEnum::REFUND_PAY;
$order->refund_status = OrderEnum::REFUND_STATUS_FINISH;
$order->refund_price = bcdiv($extra['amount']['refund'], 100, 2);
$order->refund_reason_time = time();
$order->refund_num += 1;
$order->save();
// self::afterPay($order,$extra['transaction_id']);
}
@ -242,16 +243,25 @@ class PayNotifyLogic extends BaseLogic
$financeLogic->order = $order;
$financeLogic->user = ['uid' => $order['uid']];
if ($order->pay_type != 9 || $order->pay_type != 10) {
//手续费
$fees = bcdiv(bcmul($order->pay_price, '0.02', 2), 1, 2);
$financeLogic->in($transaction_id,$order->pay_price, OrderEnum::USER_ORDER_PAY); //用户单入账
$financeLogic->in($transaction_id,$fees, OrderEnum::OWN_GET); //手续费入账
$financeLogic->in($transaction_id, $order['pay_price'], OrderEnum::USER_ORDER_PAY); //用户单入账
//商户应该获得的钱 每个商品的price-ot_price 利润
if($order->profit !== "0.00"){ //要测下写入没
$financeLogic->out($transaction_id,$order->pay_price, OrderEnum::MERCHANT_ORDER_OBTAINS, $order['store_id'], $order['staff_id'], 0);//商户获得的
if ($order->profit !== "0.00") {
//手续费
$fees = bcdiv(bcmul($order['pay_price'], '0.02', 2), 1, 2);
$financeLogic->in($transaction_id, $fees, OrderEnum::ORDER_COMMITION, $order['store_id']); //手续费入账
$financeLogic->out($transaction_id, $order['profit'], OrderEnum::MERCHANT_ORDER_OBTAINS, $order['store_id'], $order['staff_id'], 0);//商户获得的
//冻结金额的
$frozen = bcsub($order->profit, $fees, 2);
//缴纳齐全了就加商户没有就加到平台
$money_limt = SystemStore::where('id', $order['store_id'])->field('paid_deposit,security_deposit')->find();
$deposit = bcsub($money_limt['security_deposit'], $money_limt['paid_deposit'], 2);//剩余额度
if ($deposit > 0 && $frozen > 0) {
$amount = min($deposit, $frozen);
$financeLogic->in($transaction_id, $amount, OrderEnum::ORDER_MARGIN, $order['store_id'], $order['staff_id']);
}
}
// $financeLogic->in($transaction_id,$order['pay_price'], OrderEnum::USER_ORDER_PAY);
// $financeLogic->out($transaction_id,$order['pay_price'], OrderEnum::MERCHANT_ORDER_OBTAINS, $order['store_id'], $order['staff_id'], 0);
$financeLogic->save();
}
}