PaymentBehavior.php 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146
  1. <?php
  2. /**
  3. *
  4. * @author: xaboy<365615158@qq.com>
  5. * @day: 2017/12/26
  6. */
  7. namespace behavior\wechat;
  8. use app\admin\model\wechat\WechatMessage;
  9. use app\ebapi\model\store\StoreOrder as StoreOrderRoutineModel;
  10. use app\wap\model\store\StoreOrder as StoreOrderWapModel;
  11. use app\wap\model\user\UserRecharge;
  12. use service\HookService;
  13. use app\core\util\WechatService;
  14. use app\core\util\MiniProgramService;
  15. class PaymentBehavior
  16. {
  17. /**
  18. * 公众号下单成功之后
  19. * @param $order
  20. * @param $prepay_id
  21. */
  22. public static function wechatPaymentPrepare($order, $prepay_id)
  23. {
  24. }
  25. /**
  26. * 小程序下单成功之后
  27. * @param $order
  28. * @param $prepay_id
  29. */
  30. public static function wechatPaymentPrepareProgram($order, $prepay_id)
  31. {
  32. }
  33. /**
  34. * 支付成功后
  35. * @param $notify
  36. * @return bool|mixed
  37. */
  38. public static function wechatPaySuccess($notify)
  39. {
  40. if(isset($notify->attach) && $notify->attach){
  41. return HookService::listen('wechat_pay_success_'.strtolower($notify->attach),$notify->out_trade_no,$notify,true,self::class);
  42. }
  43. return false;
  44. }
  45. /**
  46. * 商品订单支付成功后 微信公众号
  47. * @param $orderId
  48. * @param $notify
  49. * @return bool
  50. */
  51. public static function wechatPaySuccessProduct($orderId, $notify)
  52. {
  53. try{
  54. if(StoreOrderWapModel::be(['order_id'=>$orderId,'paid'=>1])) return true;
  55. return StoreOrderWapModel::paySuccess($orderId);
  56. }catch (\Exception $e){
  57. return false;
  58. }
  59. }
  60. /**
  61. * 商品订单支付成功后 小程序
  62. *
  63. * @param $orderId
  64. * @param $notify
  65. * @return bool
  66. */
  67. public static function wechatPaySuccessProductr($orderId, $notify)
  68. {
  69. try{
  70. if(StoreOrderRoutineModel::be(['order_id'=>$orderId,'paid'=>1])) return true;
  71. return StoreOrderRoutineModel::paySuccess($orderId);
  72. }catch (\Exception $e){
  73. return false;
  74. }
  75. }
  76. /**
  77. * 用户充值成功后
  78. * @param $orderId
  79. * @param $notify
  80. * @return bool
  81. */
  82. public static function wechatPaySuccessUserRecharge($orderId, $notify)
  83. {
  84. try{
  85. if(UserRecharge::be(['order_id'=>$orderId,'paid'=>1])) return true;
  86. return UserRecharge::rechargeSuccess($orderId);
  87. }catch (\Exception $e){
  88. return false;
  89. }
  90. }
  91. /**
  92. * 使用余额支付订单时
  93. * @param $userInfo
  94. * @param $orderInfo
  95. */
  96. public static function yuePayProduct($userInfo, $orderInfo)
  97. {
  98. }
  99. /**
  100. * 微信支付订单退款
  101. * @param $orderNo
  102. * @param array $opt
  103. */
  104. public static function wechatPayOrderRefund($orderNo, array $opt)
  105. {
  106. WechatService::payOrderRefund($orderNo,$opt);
  107. }
  108. /**
  109. * 小程序支付订单退款
  110. * @param $orderNo
  111. * @param array $opt
  112. */
  113. public static function routinePayOrderRefund($orderNo, array $opt)
  114. {
  115. return MiniProgramService::payOrderRefund($orderNo,$opt);//2.5.36
  116. }
  117. /**
  118. * 微信支付充值退款
  119. * @param $orderNo
  120. * @param array $opt
  121. */
  122. public static function userRechargeRefund($orderNo, array $opt)
  123. {
  124. WechatService::payOrderRefund($orderNo,$opt);
  125. }
  126. }