payUtil.php 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  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 bizHd\order\classes\OrderClass;
  7. use bizHd\purchase\classes\PurchaseClearClass;
  8. use bizHd\purchase\services\PurchaseService;
  9. use bizHd\px\services\PxApplyService;
  10. use Yii;
  11. class payUtil
  12. {
  13. public static function thirdPay($payWay, $capitalType, $orderSn, $totalFee, $attach, $transactionId = '')
  14. {
  15. //4秒内不允许第三方重复通知
  16. $cacheKey = 'third_pay_' . $orderSn;
  17. $has = Yii::$app->redis->executeCommand('GET', [$cacheKey]);
  18. if (!empty($has)) {
  19. Yii::info("支付回调短时间内出现重复通知,流水类型:{$capitalType} orderSn:{$orderSn}");
  20. return false;
  21. }
  22. Yii::$app->redis->executeCommand('SETEX', [$cacheKey, 4, 'has']);
  23. //流水类型列表
  24. switch ($capitalType) {
  25. case dict::getDict('capitalType', 'xhRecharge', 'id'):
  26. //商家充值
  27. $currentRecharge = RechargeClass::thirdPay($payWay, $orderSn, $totalFee, $attach);
  28. //有发红包的通知供货商
  29. WxMessageClass::customRechargeInformGhs($currentRecharge);
  30. $customName = $currentRecharge->customName ?? '';
  31. $rechargeAmount = $currentRecharge->amount ?? 0;
  32. $rechargeAmount = floatval($rechargeAmount);
  33. noticeUtil::push("客户 {$customName} 充值{$rechargeAmount}元", '15280215347');
  34. break;
  35. case dict::getDict('capitalType', 'xhPurchase', 'id'):
  36. //零售采购
  37. PurchaseService::thirdPay($payWay, $orderSn, $totalFee, $attach, $transactionId);
  38. break;
  39. case dict::getDict('capitalType', 'hdPurchaseClear', 'id'):
  40. //零售结帐
  41. PurchaseClearClass::thirdPay($payWay, $orderSn, $totalFee, $attach,$transactionId);
  42. break;
  43. case dict::getDict('capitalType', 'xhOrder', 'id'):
  44. //散客下单
  45. OrderClass::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. default:
  56. }
  57. }
  58. }