payUtil.php 2.7 KB

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