PaymentRepositories.php 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182
  1. <?php
  2. namespace crmeb\repositories;
  3. use app\models\store\StoreOrder;
  4. use app\models\store\StoreOrderBatch;
  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. $first4 = mb_substr($order_id, 0, 4);
  45. if ($first4 == 'wxcn') {
  46. return StoreOrderBatch::paySuccessBatch($order_id);
  47. } else {
  48. // single version commented
  49. if (StoreOrder::be(['order_id' => $order_id, 'paid' => 1])) return true;
  50. return StoreOrder::paySuccess($order_id);
  51. }
  52. } catch (\Exception $e) {
  53. return false;
  54. }
  55. }
  56. /**
  57. * 充值成功后
  58. * @param string|null $order_id 订单id
  59. * @return bool
  60. */
  61. public static function wechatUserRecharge(string $order_id = null)
  62. {
  63. try {
  64. if (UserRecharge::be(['order_id' => $order_id, 'paid' => 1])) return true;
  65. return UserRecharge::rechargeSuccess($order_id);
  66. } catch (\Exception $e) {
  67. return false;
  68. }
  69. }
  70. }