| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970 |
- <?php
- namespace common\components;
- use biz\recharge\classes\RechargeClass;
- use biz\renew\classes\RenewClass;
- use bizHd\order\classes\OrderClass;
- use bizHd\purchase\classes\PurchaseClearClass;
- use bizHd\purchase\services\PurchaseService;
- use bizHd\px\services\PxApplyService;
- use Yii;
- class payUtil
- {
- public static function thirdPay($payWay, $capitalType, $orderSn, $totalFee, $attach, $transactionId = '')
- {
- //2秒内不允许第三方重复通知
- $cacheKey = 'third_pay_' . $orderSn;
- $has = Yii::$app->redis->executeCommand('GET', [$cacheKey]);
- if (!empty($has)) {
- Yii::info("第三方2秒内重复通知:{$capitalType} {$orderSn}");
- return false;
- }
- Yii::$app->redis->executeCommand('SETEX', [$cacheKey, 2, 'has']);
- $connection = Yii::$app->db;
- $transaction = $connection->beginTransaction();
- try {
- //流水类型列表
- switch ($capitalType) {
- case dict::getDict('capitalType', 'xhRecharge', 'id'):
- //零售和供应商充值
- RechargeClass::thirdPay($payWay, $orderSn, $totalFee, $attach);
- break;
- case dict::getDict('capitalType', 'xhPurchase', 'id'):
- //零售采购订单
- PurchaseService::thirdPay($payWay, $orderSn, $totalFee, $attach, $transactionId);
- break;
- case dict::getDict('capitalType', 'hdPurchaseClear', 'id'):
- //零售采购订单结清欠款
- PurchaseClearClass::thirdPay($payWay, $orderSn, $totalFee, $attach);
- break;
- case dict::getDict('capitalType', 'xhOrder', 'id'):
- //零售订单
- OrderClass::thirdPay($payWay, $orderSn, $totalFee, $attach);
- break;
- case dict::getDict('capitalType', 'xhRenew', 'id'):
- //零售和供应商续费订单
- RenewClass::thirdPay($payWay, $orderSn, $totalFee, $attach);
- break;
- case dict::getDict('capitalType', 'pxApply', 'id'):
- //培训报名
- PxApplyService::thirdPay($payWay, $orderSn, $totalFee, $attach);
- break;
- default:
- }
- $transaction->commit();
- } catch
- (Exception $exception) {
- $transaction->rollBack();
- util::fail("支付回调处理失败 orderSn:{$orderSn} capitalType:{$capitalType}");
- }
- }
- }
|