PaymentRepositories.php 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990
  1. <?php
  2. namespace crmeb\repositories;
  3. use app\models\store\StoreOrder;
  4. use app\models\user\UserRecharge;
  5. use app\models\user\UserRechargeCard;
  6. /**
  7. * Class WechatPaymentRepositories
  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. return StoreOrder::paySuccess($order_id);
  46. } catch (\Exception $e) {
  47. return false;
  48. }
  49. }
  50. /**
  51. * 充值成功后
  52. * @param string|null $order_id 订单id
  53. * @return bool
  54. */
  55. public static function wechatUserRecharge(string $order_id = null)
  56. {
  57. try {
  58. if (UserRecharge::be(['order_id' => $order_id, 'paid' => 1])) return true;
  59. return UserRecharge::rechargeSuccess($order_id);
  60. } catch (\Exception $e) {
  61. return false;
  62. }
  63. }
  64. /**
  65. * 充值成功后
  66. * @param string|null $order_no 订单编号
  67. * @return bool
  68. */
  69. public static function wechatUserRechargeCard(string $order_no = null)
  70. {
  71. try {
  72. if (UserRechargeCard::be(['order_no' => $order_no, 'paid' => 1])) return true;
  73. return UserRechargeCard::rechargeSuccess($order_no);
  74. } catch (\Exception $e) {
  75. return false;
  76. }
  77. }
  78. }