PaymentBehavior.php 6.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224
  1. <?php
  2. // +----------------------------------------------------------------------
  3. // | CRMEB [ CRMEB赋能开发者,助力企业发展 ]
  4. // +----------------------------------------------------------------------
  5. // | Copyright (c) 2016~2022 https://www.crmeb.com All rights reserved.
  6. // +----------------------------------------------------------------------
  7. // | Licensed CRMEB并不是自由软件,未经许可不能去掉CRMEB相关版权
  8. // +----------------------------------------------------------------------
  9. // | Author: CRMEB Team <admin@crmeb.com>
  10. // +----------------------------------------------------------------------
  11. namespace behavior\wechat;
  12. use app\wap\model\store\StoreOrder as StoreOrderRoutineModel;
  13. use app\wap\model\store\StoreOrder as StoreOrderWapModel;
  14. use app\wap\model\user\UserRecharge;
  15. use service\HookService;
  16. use service\WechatService;
  17. use app\wap\model\activity\EventSignUp;
  18. use app\wap\model\topic\TestPaperOrder;
  19. use app\wap\model\material\DataDownloadOrder;
  20. class PaymentBehavior
  21. {
  22. /**
  23. * 下单成功之后
  24. * @param $order
  25. * @param $prepay_id
  26. */
  27. public static function wechatPaymentPrepare($order, $prepay_id)
  28. {
  29. }
  30. /**
  31. * 支付成功后
  32. * @param $notify
  33. * @return bool|mixed
  34. */
  35. public static function wechatPaySuccess($notify)
  36. {
  37. if (isset($notify->attach) && $notify->attach) {
  38. return HookService::listen('wechat_pay_success_' . strtolower($notify->attach), $notify->out_trade_no, $notify, true, self::class);
  39. }
  40. return false;
  41. }
  42. /**
  43. * 商品订单支付成功后 微信公众号
  44. * @param $orderId
  45. * @param $notify
  46. * @return bool
  47. */
  48. public static function wechatPaySuccessGoods($orderId, $notify)
  49. {
  50. try {
  51. if (StoreOrderWapModel::be(['order_id' => $orderId, 'paid' => 1, 'type' => 2])) return true;
  52. return StoreOrderWapModel::payGoodsSuccess($orderId);
  53. } catch (\Exception $e) {
  54. return false;
  55. }
  56. }
  57. /**
  58. * 专题订单支付成功后 微信公众号 支付宝
  59. * @param $orderId
  60. * @param $notify
  61. * @return bool
  62. */
  63. public static function wechatPaySuccessSpecial($orderId, $notify)
  64. {
  65. try {
  66. if (StoreOrderWapModel::be(['order_id' => $orderId, 'paid' => 1])) return true;
  67. return StoreOrderWapModel::paySuccess($orderId);
  68. } catch (\Exception $e) {
  69. return false;
  70. }
  71. }
  72. /**
  73. * 学习计划订单支付成功后 微信公众号 支付宝
  74. * @param $orderId
  75. * @param $notify
  76. * @return bool
  77. */
  78. public static function wechatPaySuccessPlan($orderId, $notify)
  79. {
  80. try {
  81. if (StoreOrderWapModel::be(['order_id' => $orderId, 'paid' => 1])) return true;
  82. return StoreOrderWapModel::payPlanSuccess($orderId);
  83. } catch (\Exception $e) {
  84. return false;
  85. }
  86. }
  87. /**
  88. * 会员订单支付成功后 微信公众号 支付宝
  89. * @param $orderId
  90. * @param $notify
  91. * @return bool
  92. */
  93. public static function wechatPaySuccessMember($orderId, $notify)
  94. {
  95. try {
  96. if (StoreOrderWapModel::be(['order_id' => $orderId, 'paid' => 1])) return true;
  97. return StoreOrderWapModel::payMeSuccess($orderId);
  98. } catch (\Exception $e) {
  99. return false;
  100. }
  101. }
  102. /**
  103. * 活动报名订单支付成功后 微信公众号 支付宝
  104. * @param $orderId
  105. * @param $notify
  106. * @return bool
  107. */
  108. public static function wechatPaySuccessSignup($orderId, $notify)
  109. {
  110. try {
  111. if (EventSignUp::be(['order_id' => $orderId, 'paid' => 1])) return true;
  112. return EventSignUp::paySuccess($orderId);
  113. } catch (\Exception $e) {
  114. return false;
  115. }
  116. }
  117. /**
  118. * 试卷订单支付成功后 微信公众号 支付宝
  119. * @param $orderId
  120. * @param $notify
  121. * @return bool
  122. */
  123. public static function wechatPaySuccessTestpaper($orderId, $notify)
  124. {
  125. try {
  126. if (TestPaperOrder::be(['order_id' => $orderId, 'paid' => 1])) return true;
  127. return TestPaperOrder::payTestPaperSuccess($orderId);
  128. } catch (\Exception $e) {
  129. return false;
  130. }
  131. }
  132. /**
  133. * 资料订单支付成功后 微信公众号 支付宝
  134. * @param $orderId
  135. * @param $notify
  136. * @return bool
  137. */
  138. public static function wechatPaySuccessDatadownload($orderId, $notify)
  139. {
  140. try {
  141. if (DataDownloadOrder::be(['order_id' => $orderId, 'paid' => 1])) return true;
  142. return DataDownloadOrder::payDataDownloadSuccess($orderId);
  143. } catch (\Exception $e) {
  144. return false;
  145. }
  146. }
  147. /**
  148. * 商品订单支付成功后 小程序
  149. * @param $orderId
  150. * @param $notify
  151. * @return bool
  152. */
  153. public static function wechatPaySuccessProductr($orderId, $notify)
  154. {
  155. try {
  156. if (StoreOrderRoutineModel::be(['order_id' => $orderId, 'paid' => 1])) return true;
  157. return StoreOrderRoutineModel::paySuccess($orderId);
  158. } catch (\Exception $e) {
  159. return false;
  160. }
  161. }
  162. /**
  163. * 用户充值成功后
  164. * @param $orderId
  165. * @param $notify
  166. * @return bool
  167. */
  168. public static function wechatPaySuccessRecharge($orderId, $notify)
  169. {
  170. try {
  171. if (UserRecharge::be(['order_id' => $orderId, 'paid' => 1])) return true;
  172. return UserRecharge::rechargeSuccess($orderId);
  173. } catch (\Exception $e) {
  174. return false;
  175. }
  176. }
  177. /**
  178. * 使用余额支付订单时
  179. * @param $userInfo
  180. * @param $orderInfo
  181. */
  182. public static function yuePayProduct($userInfo, $orderInfo)
  183. {
  184. }
  185. /**
  186. * 微信支付订单退款
  187. * @param $orderNo
  188. * @param array $opt
  189. */
  190. public static function wechatPayOrderRefund($orderNo, array $opt)
  191. {
  192. WechatService::payOrderRefund($orderNo, $opt);
  193. }
  194. /**
  195. * 微信支付充值退款
  196. * @param $orderNo
  197. * @param array $opt
  198. */
  199. public static function userRechargeRefund($orderNo, array $opt)
  200. {
  201. WechatService::payOrderRefund($orderNo, $opt);
  202. }
  203. }