payUtil.php 3.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  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. //扫码付款
  46. ScanPayClass::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. case dict::getDict('capitalType', 'customRechargeToGhs', 'id'):
  61. //客户向供货商充值销账
  62. CustomRechargeClass::thirdPay($payWay, $orderSn, $totalFee, $attach, $transactionId);
  63. break;
  64. default:
  65. }
  66. }
  67. }