UserMonthService.php 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. <?php
  2. /**
  3. * Created by PhpStorm.
  4. * User: z-yang
  5. * Date: 2019/7/27
  6. * Time: 18:01
  7. */
  8. namespace App\Modules\User\Services;
  9. use App\Modules\User\Models\UserMonthOrder;
  10. use App\Modules\User\Models\UserMonthSign;
  11. class UserMonthService
  12. {
  13. public static function createSign(int $uid, int $plan_id, string $change_type)
  14. {
  15. $model = new UserMonthSign();
  16. $info = $model->where('uid', $uid)->where('plan_id', $plan_id)->first();
  17. if ($info) {
  18. $info->change_type = $change_type;
  19. $info->save();
  20. } else {
  21. $model->uid = $uid;
  22. $model->plan_id = $plan_id;
  23. $model->change_type = $change_type;
  24. $model->save();
  25. }
  26. return;
  27. }
  28. public static function createLOrder(int $uid, int $plan_id, int $total_fee, string $trade_no,string $out_trade_no)
  29. {
  30. $model = new UserMonthOrder();
  31. $model->uid = $uid;
  32. $model->plan_id = $plan_id;
  33. $model->total_fee = $total_fee;
  34. $model->trade_no = $trade_no;
  35. $model->out_trade_no = $out_trade_no;
  36. $model->save();
  37. return;
  38. }
  39. public static function getOrderByOrder($trade_no,$out_trade_no){
  40. $model = new UserMonthOrder();
  41. $info = $model->where('trade_no',$trade_no)->orWhere('out_trade_no',$out_trade_no)->first();
  42. return $info;
  43. }
  44. }