payUtil.php 4.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485
  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 bizHd\shop\classes\MainWalletRechargeClass;
  14. use Yii;
  15. class payUtil
  16. {
  17. public static function thirdPay($payWay, $capitalType, $orderSn, $totalFee, $attach, $transactionId = '', $accTradeNo = '')
  18. {
  19. // 同一 orderSn 短时重复通知直接跳过(NoticeController 仍会回 SUCCESS,避免渠道反复重试)
  20. $cacheKey = 'third_pay_' . $orderSn;
  21. $has = Yii::$app->redis->executeCommand('GET', [$cacheKey]);
  22. if (!empty($has)) {
  23. Yii::info("支付回调短时间内出现重复通知,流水类型:{$capitalType} orderSn:{$orderSn}");
  24. // 充值入账可能已完成,短时重复通知仍补录微信虚拟发货
  25. if ($capitalType == dict::getDict('capitalType', 'xhRecharge', 'id')) {
  26. RechargeClass::tryWxVirtualShippingByOrderSn($orderSn, $accTradeNo);
  27. }
  28. if ($capitalType == dict::getDict('capitalType', 'scanPay', 'id')) {
  29. ScanPayClass::tryWxVirtualShippingByOrderSn($orderSn, $accTradeNo);
  30. }
  31. return false;
  32. }
  33. Yii::$app->redis->executeCommand('SETEX', [$cacheKey, 10, 'has']);
  34. //流水类型列表
  35. switch ($capitalType) {
  36. case dict::getDict('capitalType', 'xhRecharge', 'id'):
  37. // 散客向花店充值;acc_trade_no 写入 thirdPayNo,returnCode 仍是拉卡拉 trade_no
  38. RechargeClass::thirdPay($payWay, $orderSn, $totalFee, $attach, $transactionId, $accTradeNo);
  39. break;
  40. case dict::getDict('capitalType', 'xhPurchase', 'id'):
  41. //零售采购
  42. PurchaseService::thirdPay($payWay, $orderSn, $totalFee, $attach, $transactionId);
  43. break;
  44. case dict::getDict('capitalType', 'hdPurchaseClear', 'id'):
  45. //零售结帐
  46. PurchaseClearClass::thirdPay($payWay, $orderSn, $totalFee, $attach, $transactionId);
  47. break;
  48. case dict::getDict('capitalType', 'xhOrder', 'id'):
  49. //散客下单;acc_trade_no 写入 thirdOrderId,供微信发货录入
  50. OrderClass::thirdPay($payWay, $orderSn, $totalFee, $attach, $transactionId, $accTradeNo);
  51. break;
  52. case dict::getDict('capitalType', 'scanPay', 'id'):
  53. //扫码付款;acc_trade_no 写入 thirdPayNo,供微信虚拟发货
  54. ScanPayClass::thirdPay($payWay, $orderSn, $totalFee, $attach, $transactionId, $accTradeNo);
  55. break;
  56. case dict::getDict('capitalType', 'xhRenew', 'id'):
  57. //商家续期、购买套餐和设备
  58. RenewClass::thirdPay($payWay, $orderSn, $totalFee, $attach, $transactionId);
  59. break;
  60. case dict::getDict('capitalType', 'pxApply', 'id'):
  61. //培训报名
  62. PxApplyService::thirdPay($payWay, $orderSn, $totalFee, $attach);
  63. break;
  64. case dict::getDict('capitalType', 'ljhApply', 'id'):
  65. //零交会报名
  66. LjhApplyClass::thirdPay($payWay, $orderSn, $totalFee, $attach, $transactionId);
  67. break;
  68. case dict::getDict('capitalType', 'customRechargeToGhs', 'id'):
  69. //客户向供货商充值销账
  70. CustomRechargeClass::thirdPay($payWay, $orderSn, $totalFee, $attach, $transactionId);
  71. break;
  72. case dict::getDict('capitalType', 'mainWalletRecharge', 'id'):
  73. // 中央钱包微信充值
  74. MainWalletRechargeClass::thirdPay($payWay, $orderSn, $totalFee, $attach, $transactionId);
  75. break;
  76. default:
  77. }
  78. }
  79. }