payUtil.php 2.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  1. <?php
  2. namespace common\components;
  3. use biz\recharge\classes\RechargeClass;
  4. use biz\renew\classes\RenewClass;
  5. use biz\wx\classes\WxMessageClass;
  6. use bizHd\ljh\classes\LjhApplyClass;
  7. use bizHd\order\classes\OrderClass;
  8. use bizHd\purchase\classes\PurchaseClearClass;
  9. use bizHd\purchase\services\PurchaseService;
  10. use bizHd\px\services\PxApplyService;
  11. use Yii;
  12. class payUtil
  13. {
  14. public static function thirdPay($payWay, $capitalType, $orderSn, $totalFee, $attach, $transactionId = '')
  15. {
  16. //4秒内不允许第三方重复通知
  17. $cacheKey = 'third_pay_' . $orderSn;
  18. $has = Yii::$app->redis->executeCommand('GET', [$cacheKey]);
  19. if (!empty($has)) {
  20. Yii::info("支付回调短时间内出现重复通知,流水类型:{$capitalType} orderSn:{$orderSn}");
  21. return false;
  22. }
  23. Yii::$app->redis->executeCommand('SETEX', [$cacheKey, 4, 'has']);
  24. //流水类型列表
  25. switch ($capitalType) {
  26. case dict::getDict('capitalType', 'xhRecharge', 'id'):
  27. //商家充值
  28. $currentRecharge = RechargeClass::thirdPay($payWay, $orderSn, $totalFee, $attach);
  29. //有发红包的通知供货商
  30. WxMessageClass::customRechargeInformGhs($currentRecharge);
  31. $customName = $currentRecharge->customName ?? '';
  32. $rechargeAmount = $currentRecharge->amount ?? 0;
  33. $rechargeAmount = floatval($rechargeAmount);
  34. noticeUtil::push("客户 {$customName} 充值{$rechargeAmount}元", '15280215347');
  35. break;
  36. case dict::getDict('capitalType', 'xhPurchase', 'id'):
  37. //零售采购
  38. PurchaseService::thirdPay($payWay, $orderSn, $totalFee, $attach, $transactionId);
  39. break;
  40. case dict::getDict('capitalType', 'hdPurchaseClear', 'id'):
  41. //零售结帐
  42. PurchaseClearClass::thirdPay($payWay, $orderSn, $totalFee, $attach, $transactionId);
  43. break;
  44. case dict::getDict('capitalType', 'xhOrder', 'id'):
  45. //散客下单
  46. OrderClass::thirdPay($payWay, $orderSn, $totalFee, $attach, $transactionId);
  47. break;
  48. case dict::getDict('capitalType', 'xhRenew', 'id'):
  49. //商家续期
  50. RenewClass::thirdPay($payWay, $orderSn, $totalFee, $attach);
  51. break;
  52. case dict::getDict('capitalType', 'pxApply', 'id'):
  53. //培训报名
  54. PxApplyService::thirdPay($payWay, $orderSn, $totalFee, $attach);
  55. break;
  56. case dict::getDict('capitalType', 'ljhApply', 'id'):
  57. //零交会报名
  58. LjhApplyClass::thirdPay($payWay, $orderSn, $totalFee, $attach, $transactionId);
  59. break;
  60. default:
  61. }
  62. }
  63. }