PaymentRepositories.php 2.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192
  1. <?php
  2. namespace crmeb\repositories;
  3. use app\models\store\StoreOrder;
  4. use app\models\user\UserMobileRecharge;
  5. use app\models\user\UserRecharge;
  6. /**
  7. * Class PaymentRepositories
  8. * @package crmeb\repositories
  9. */
  10. class PaymentRepositories
  11. {
  12. /**
  13. * 公众号下单成功之后
  14. * @param $order
  15. * @param $prepay_id
  16. */
  17. public static function wechatPaymentPrepare($order, $prepay_id)
  18. {
  19. }
  20. /**
  21. * 小程序下单成功之后
  22. * @param $order
  23. * @param $prepay_id
  24. */
  25. public static function wechatPaymentPrepareProgram($order, $prepay_id)
  26. {
  27. }
  28. /**
  29. * 使用余额支付订单时
  30. * @param $userInfo
  31. * @param $orderInfo
  32. */
  33. public static function yuePayProduct($userInfo, $orderInfo)
  34. {
  35. }
  36. /**
  37. * 订单支付成功之后
  38. * @param string|null $order_id 订单id
  39. * @return bool
  40. */
  41. public static function wechatProduct(string $order_id = null)
  42. {
  43. try {
  44. if (StoreOrder::be(['order_id' => $order_id, 'paid' => 1])) return true;
  45. $order = StoreOrder::where('order_id', $order_id)->find();
  46. return StoreOrder::paySuccess($order_id, $order['pay_type']);
  47. } catch (\Exception $e) {
  48. return false;
  49. }
  50. }
  51. /**
  52. * 订单支付成功之后
  53. * @param string|null $order_id 订单id
  54. * @return bool
  55. */
  56. public static function wechatMobileRecharge(string $order_id = null)
  57. {
  58. try {
  59. if (UserMobileRecharge::be(['order_id' => $order_id, 'paid' => 1])) return true;
  60. return UserMobileRecharge::rechargeSuccess($order_id);
  61. } catch (\Exception $e) {
  62. return false;
  63. }
  64. }
  65. /**
  66. * 充值成功后
  67. * @param string|null $order_id 订单id
  68. * @return bool
  69. */
  70. public static function wechatUserRecharge(string $order_id = null)
  71. {
  72. try {
  73. if (UserRecharge::be(['order_id' => $order_id, 'paid' => 1])) return true;
  74. return UserRecharge::rechargeSuccess($order_id);
  75. } catch (\Exception $e) {
  76. return false;
  77. }
  78. }
  79. }