PaymentRepositories.php 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  1. <?php
  2. namespace crmeb\repositories;
  3. use app\models\store\StoreOrder;
  4. use app\models\user\UserRecharge;
  5. /**
  6. * Class PaymentRepositories
  7. * @package crmeb\repositories
  8. */
  9. class PaymentRepositories
  10. {
  11. /**
  12. * 公众号下单成功之后
  13. * @param $order
  14. * @param $prepay_id
  15. */
  16. public static function wechatPaymentPrepare($order, $prepay_id)
  17. {
  18. }
  19. /**
  20. * 小程序下单成功之后
  21. * @param $order
  22. * @param $prepay_id
  23. */
  24. public static function wechatPaymentPrepareProgram($order, $prepay_id)
  25. {
  26. }
  27. /**
  28. * 使用余额支付订单时
  29. * @param $userInfo
  30. * @param $orderInfo
  31. */
  32. public static function yuePayProduct($userInfo, $orderInfo)
  33. {
  34. }
  35. /**
  36. * 订单支付成功之后
  37. * @param string|null $order_id 订单id
  38. * @return bool
  39. */
  40. public static function wechatProduct(string $order_id = null)
  41. {
  42. try {
  43. if (StoreOrder::where('add_time', '<=',strtotime('2022-8-5'))->where('order_id', $order_id)->find()) return true;
  44. if (StoreOrder::be(['re_order_id' => $order_id])) 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. }