payUtil.php 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  1. <?php
  2. namespace common\components;
  3. use biz\renew\classes\RenewClass;
  4. use biz\wx\classes\WxMessageClass;
  5. use bizGhs\custom\classes\CustomRechargeClass;
  6. use bizHd\ljh\classes\LjhApplyClass;
  7. use bizHd\order\classes\OrderClass;
  8. use bizHd\order\classes\ScanPayClass;
  9. use bizHd\purchase\classes\PurchaseClearClass;
  10. use bizHd\purchase\services\PurchaseService;
  11. use bizHd\px\services\PxApplyService;
  12. use bizHd\recharge\classes\RechargeClass;
  13. use bizHd\shop\classes\MainWalletRechargeClass;
  14. use Yii;
  15. class payUtil
  16. {
  17. public static function thirdPay($payWay, $capitalType, $orderSn, $totalFee, $attach, $transactionId = '')
  18. {
  19. // 同一 orderSn 短时重复通知直接跳过(NoticeController 仍会回 SUCCESS,避免渠道反复重试)
  20. $cacheKey = 'third_pay_' . $orderSn;
  21. $has = Yii::$app->redis->executeCommand('GET', [$cacheKey]);
  22. if (!empty($has)) {
  23. Yii::info("支付回调短时间内出现重复通知,流水类型:{$capitalType} orderSn:{$orderSn}");
  24. return false;
  25. }
  26. Yii::$app->redis->executeCommand('SETEX', [$cacheKey, 10, 'has']);
  27. //流水类型列表
  28. switch ($capitalType) {
  29. case dict::getDict('capitalType', 'xhRecharge', 'id'):
  30. //散客向花店充值
  31. RechargeClass::thirdPay($payWay, $orderSn, $totalFee, $attach, $transactionId);
  32. break;
  33. case dict::getDict('capitalType', 'xhPurchase', 'id'):
  34. //零售采购
  35. PurchaseService::thirdPay($payWay, $orderSn, $totalFee, $attach, $transactionId);
  36. break;
  37. case dict::getDict('capitalType', 'hdPurchaseClear', 'id'):
  38. //零售结帐
  39. PurchaseClearClass::thirdPay($payWay, $orderSn, $totalFee, $attach, $transactionId);
  40. break;
  41. case dict::getDict('capitalType', 'xhOrder', 'id'):
  42. //散客下单
  43. OrderClass::thirdPay($payWay, $orderSn, $totalFee, $attach, $transactionId);
  44. break;
  45. case dict::getDict('capitalType', 'scanPay', 'id'):
  46. //扫码付款
  47. ScanPayClass::thirdPay($payWay, $orderSn, $totalFee, $attach, $transactionId);
  48. break;
  49. case dict::getDict('capitalType', 'xhRenew', 'id'):
  50. //商家续期、购买套餐和设备
  51. RenewClass::thirdPay($payWay, $orderSn, $totalFee, $attach, $transactionId);
  52. break;
  53. case dict::getDict('capitalType', 'pxApply', 'id'):
  54. //培训报名
  55. PxApplyService::thirdPay($payWay, $orderSn, $totalFee, $attach);
  56. break;
  57. case dict::getDict('capitalType', 'ljhApply', 'id'):
  58. //零交会报名
  59. LjhApplyClass::thirdPay($payWay, $orderSn, $totalFee, $attach, $transactionId);
  60. break;
  61. case dict::getDict('capitalType', 'customRechargeToGhs', 'id'):
  62. //客户向供货商充值销账
  63. CustomRechargeClass::thirdPay($payWay, $orderSn, $totalFee, $attach, $transactionId);
  64. break;
  65. case dict::getDict('capitalType', 'mainWalletRecharge', 'id'):
  66. // 中央钱包微信充值
  67. MainWalletRechargeClass::thirdPay($payWay, $orderSn, $totalFee, $attach, $transactionId);
  68. break;
  69. default:
  70. }
  71. }
  72. }