payUtil.php 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  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 bizGhs\custom\classes\CustomRechargeClass;
  7. use bizHd\ljh\classes\LjhApplyClass;
  8. use bizHd\order\classes\OrderClass;
  9. use bizHd\purchase\classes\PurchaseClearClass;
  10. use bizHd\purchase\services\PurchaseService;
  11. use bizHd\px\services\PxApplyService;
  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. $currentRecharge = RechargeClass::thirdPay($payWay, $orderSn, $totalFee, $attach);
  30. //有发红包的通知供货商
  31. WxMessageClass::customRechargeInformGhs($currentRecharge);
  32. $customName = $currentRecharge->customName ?? '';
  33. $rechargeAmount = $currentRecharge->amount ?? 0;
  34. $rechargeAmount = floatval($rechargeAmount);
  35. noticeUtil::push("客户 {$customName} 充值{$rechargeAmount}元", '15280215347');
  36. break;
  37. case dict::getDict('capitalType', 'xhPurchase', 'id'):
  38. //零售采购
  39. PurchaseService::thirdPay($payWay, $orderSn, $totalFee, $attach, $transactionId);
  40. break;
  41. case dict::getDict('capitalType', 'hdPurchaseClear', 'id'):
  42. //零售结帐
  43. PurchaseClearClass::thirdPay($payWay, $orderSn, $totalFee, $attach, $transactionId);
  44. break;
  45. case dict::getDict('capitalType', 'xhOrder', 'id'):
  46. //散客下单
  47. OrderClass::thirdPay($payWay, $orderSn, $totalFee, $attach, $transactionId);
  48. break;
  49. case dict::getDict('capitalType', 'xhRenew', 'id'):
  50. //商家续期
  51. RenewClass::thirdPay($payWay, $orderSn, $totalFee, $attach);
  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. default:
  66. }
  67. }
  68. }