payUtil.php 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  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 Yii;
  14. class payUtil
  15. {
  16. public static function thirdPay($payWay, $capitalType, $orderSn, $totalFee, $attach, $transactionId = '')
  17. {
  18. //4秒内不允许第三方重复通知
  19. $cacheKey = 'third_pay_' . $orderSn;
  20. $has = Yii::$app->redis->executeCommand('GET', [$cacheKey]);
  21. if (!empty($has)) {
  22. Yii::info("支付回调短时间内出现重复通知,流水类型:{$capitalType} orderSn:{$orderSn}");
  23. return false;
  24. }
  25. Yii::$app->redis->executeCommand('SETEX', [$cacheKey, 4, 'has']);
  26. //流水类型列表
  27. switch ($capitalType) {
  28. case dict::getDict('capitalType', 'xhRecharge', 'id'):
  29. //散客向花店充值
  30. RechargeClass::thirdPay($payWay, $orderSn, $totalFee, $attach);
  31. break;
  32. case dict::getDict('capitalType', 'xhPurchase', 'id'):
  33. //零售采购
  34. PurchaseService::thirdPay($payWay, $orderSn, $totalFee, $attach, $transactionId);
  35. break;
  36. case dict::getDict('capitalType', 'hdPurchaseClear', 'id'):
  37. //零售结帐
  38. PurchaseClearClass::thirdPay($payWay, $orderSn, $totalFee, $attach, $transactionId);
  39. break;
  40. case dict::getDict('capitalType', 'xhOrder', 'id'):
  41. //散客下单
  42. OrderClass::thirdPay($payWay, $orderSn, $totalFee, $attach, $transactionId);
  43. break;
  44. case dict::getDict('capitalType', 'scanPay', 'id'):
  45. ScanPayClass::thirdPay($payWay, $orderSn, $totalFee, $attach, $transactionId);
  46. break;
  47. case dict::getDict('capitalType', 'xhRenew', 'id'):
  48. //商家续期
  49. RenewClass::thirdPay($payWay, $orderSn, $totalFee, $attach);
  50. break;
  51. case dict::getDict('capitalType', 'pxApply', 'id'):
  52. //培训报名
  53. PxApplyService::thirdPay($payWay, $orderSn, $totalFee, $attach);
  54. break;
  55. case dict::getDict('capitalType', 'ljhApply', 'id'):
  56. //零交会报名
  57. LjhApplyClass::thirdPay($payWay, $orderSn, $totalFee, $attach, $transactionId);
  58. break;
  59. case dict::getDict('capitalType', 'customRechargeToGhs', 'id'):
  60. //客户向供货商充值销账
  61. CustomRechargeClass::thirdPay($payWay, $orderSn, $totalFee, $attach, $transactionId);
  62. break;
  63. default:
  64. }
  65. }
  66. }