更新支付回调
This commit is contained in:
parent
fc59ecf522
commit
a4d178a0d6
@ -7,6 +7,7 @@ use app\admin\validate\operation\OpurchaseclassValidate;
|
||||
use app\api\logic\order\OrderLogic;
|
||||
use app\api\controller\BaseApiController;
|
||||
use app\api\lists\operation\OpurchaseclassLists;
|
||||
use app\common\logic\PayNotifyLogic;
|
||||
use app\common\model\goods\Goods;
|
||||
use app\common\model\opurchase\Opurchaseinfo;
|
||||
use Webman\RedisQueue\Redis;
|
||||
@ -94,6 +95,7 @@ class OpurchaseOrderController extends BaseApiController
|
||||
if($order==false){
|
||||
return $this->fail(OrderLogic::getError());
|
||||
}else{
|
||||
PayNotifyLogic::handle('opurchaseclass', $order['number']);
|
||||
//推送队列
|
||||
Redis::send('push-supplier-products', ['order_id'=>$order['id']]);
|
||||
return $this->success('支付成功');
|
||||
|
@ -11,10 +11,14 @@ class OrderEnum
|
||||
* @USER_ORDER_PAY 用户订单支付
|
||||
* @MERCHANT_ORDER_OBTAINS 商户订单获得
|
||||
* @ORDER_HANDLING_FEES 订单手续费
|
||||
* @MERCHANT_ORDER_PAY 商户订单支付
|
||||
* @PLATFORM_ORDER_OBTAINS 平台订单获得
|
||||
*/
|
||||
const USER_ORDER_PAY = 1;
|
||||
const MERCHANT_ORDER_OBTAINS = 2;
|
||||
const ORDER_HANDLING_FEES = 3;
|
||||
const MERCHANT_ORDER_PAY = 4;
|
||||
const PLATFORM_ORDER_OBTAINS = 5;
|
||||
|
||||
/**
|
||||
* 收入支出类型
|
||||
|
@ -2,9 +2,12 @@
|
||||
|
||||
namespace app\common\logic;
|
||||
|
||||
use app\common\enum\OrderEnum;
|
||||
use app\common\enum\PayEnum;
|
||||
use app\common\enum\user\AccountLogEnum;
|
||||
use app\common\model\operation\Opurchaseclass;
|
||||
use app\common\model\order\Cart;
|
||||
use app\common\model\order\FinancialRecord;
|
||||
use app\common\model\recharge\RechargeOrder;
|
||||
use app\common\model\retail\Cashierclass;
|
||||
use app\common\model\user\User;
|
||||
@ -73,10 +76,81 @@ class PayNotifyLogic extends BaseLogic
|
||||
Cart::whereIn('cart_id', $order['cart_id'])->update(['is_pay' => 1]);
|
||||
}
|
||||
}
|
||||
PushService::push('cash_register_' . $order['user_id'], $order['user_id'], '您有一笔订单已支付');
|
||||
if ($order->pay_type != 9) {
|
||||
//用户支出流水
|
||||
$record[] = [
|
||||
'financial_record_sn' => $extra['transaction_id'],
|
||||
'order_id' => $order['id'],
|
||||
'number_sn' => $order['number'],
|
||||
'user_id' => $order['uid'],
|
||||
'financial_type' => OrderEnum::USER_ORDER_PAY,
|
||||
'financial_pm' => OrderEnum::EXPENDITURE,
|
||||
'number' => $order['actual'],
|
||||
'status' => 1,
|
||||
'type' => OrderEnum::USER,
|
||||
'mer_id' => $order['merchant'],
|
||||
];
|
||||
//商户获得流水
|
||||
$record[] = [
|
||||
'financial_record_sn' => $extra['transaction_id'],
|
||||
'order_id' => $order['id'],
|
||||
'number_sn' => $order['number'],
|
||||
'user_id' => $order['uid'],
|
||||
'financial_type' => OrderEnum::MERCHANT_ORDER_OBTAINS,
|
||||
'financial_pm' => OrderEnum::INCOME,
|
||||
'number' => $order['actual'],
|
||||
'status' => 0,
|
||||
'type' => OrderEnum::MERCHANT,
|
||||
'mer_id' => $order['merchant'],
|
||||
];
|
||||
(new FinancialRecord())->saveAll($record);
|
||||
}
|
||||
|
||||
if ($order->pay_type == 9) {
|
||||
PushService::push('cash_register_' . $order['user_id'], $order['user_id'], '您有一笔订单已支付');
|
||||
} else {
|
||||
PushService::push('store_merchant_' . $order['merchant'], $order['merchant'], '您有一笔新的订单');
|
||||
}
|
||||
if (!empty($extra['payer']['openid']) && $order->pay_type != 9) {
|
||||
Redis::send('push-delivery',['order_id'=>$orderSn,'openid'=>$extra['payer']['openid']],5);
|
||||
Redis::send('push-delivery', ['order_id' => $orderSn, 'openid' => $extra['payer']['openid']], 5);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
/**
|
||||
* 采购订单支付成功
|
||||
*/
|
||||
public static function opurchaseclass($orderSn, $extra = [])
|
||||
{
|
||||
$order = Opurchaseclass::where('number', $orderSn)->findOrEmpty();
|
||||
$order_arr=explode(',',$order['order_arr']);
|
||||
(new FinancialRecord())->where('order_id','in',$order_arr)->update(['status' => 1]);
|
||||
$time=time();
|
||||
//商户支出流水
|
||||
$record[] = [
|
||||
'financial_record_sn' => $time,
|
||||
'order_id' => $order['id'],
|
||||
'number_sn' => $order['number'],
|
||||
'user_id' => $order['uid'],
|
||||
'financial_type' => OrderEnum::MERCHANT_ORDER_PAY,
|
||||
'financial_pm' => OrderEnum::EXPENDITURE,
|
||||
'number' => $order['actual'],
|
||||
'status' => 1,
|
||||
'type' => OrderEnum::MERCHANT,
|
||||
'mer_id' => $order['merchant'],
|
||||
];
|
||||
//平台获得流水
|
||||
$record[] = [
|
||||
'financial_record_sn' => $time,
|
||||
'order_id' => $order['id'],
|
||||
'number_sn' => $order['number'],
|
||||
'user_id' => $order['uid'],
|
||||
'financial_type' => OrderEnum::PLATFORM_ORDER_OBTAINS,
|
||||
'financial_pm' => OrderEnum::INCOME,
|
||||
'number' => $order['actual'],
|
||||
'status' => 1,
|
||||
'type' => OrderEnum::PLATFORM,
|
||||
'mer_id' => $order['merchant'],
|
||||
];
|
||||
(new FinancialRecord())->saveAll($record);
|
||||
}
|
||||
}
|
||||
|
@ -39,33 +39,6 @@ class RetailOrderLogic extends BaseLogic
|
||||
try {
|
||||
$user->user_money = bcsub($user->user_money, $order['actual'], 2);
|
||||
$user->save();
|
||||
//用户支出流水
|
||||
$record[] = [
|
||||
'financial_record_sn' => time(),
|
||||
'order_id' => $order['id'],
|
||||
'number_sn' => $order['number'],
|
||||
'user_id' => $order['uid'],
|
||||
'financial_type' => OrderEnum::USER_ORDER_PAY,
|
||||
'financial_pm' => OrderEnum::EXPENDITURE,
|
||||
'number' => $order['actual'],
|
||||
'status' => 1,
|
||||
'type' => OrderEnum::USER,
|
||||
'mer_id' => $order['merchant'],
|
||||
];
|
||||
//商户获得流水
|
||||
$record[] = [
|
||||
'financial_record_sn' => time(),
|
||||
'order_id' => $order['id'],
|
||||
'number_sn' => $order['number'],
|
||||
'user_id' => $order['uid'],
|
||||
'financial_type' => OrderEnum::MERCHANT_ORDER_OBTAINS,
|
||||
'financial_pm' => OrderEnum::INCOME,
|
||||
'number' => $order['actual'],
|
||||
'status' => 0,
|
||||
'type' => OrderEnum::MERCHANT,
|
||||
'mer_id' => $order['merchant'],
|
||||
];
|
||||
(new FinancialRecord())->saveAll($record);
|
||||
Db::commit();
|
||||
return true;
|
||||
} catch (Exception $e) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user