UserMonthService.php 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  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,string $openid)
  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->openid = $openid;
  25. $model->save();
  26. }
  27. return;
  28. }
  29. public static function isSignMonth($openid){
  30. $model = new UserMonthSign();
  31. return $model->where('openid',$openid)->where('change_type','ADD')->select('id')->first();
  32. }
  33. public static function getLastOrder(int $uid){
  34. $model = new UserMonthOrder();
  35. return $model->where('uid',$uid)->orderBy('id','desc')->first();
  36. }
  37. public static function createLOrder(int $uid, int $plan_id, int $total_fee, string $trade_no,string $out_trade_no)
  38. {
  39. $model = new UserMonthOrder();
  40. $model->uid = $uid;
  41. $model->plan_id = $plan_id;
  42. $model->total_fee = $total_fee;
  43. $model->trade_no = $trade_no;
  44. $model->out_trade_no = $out_trade_no;
  45. $model->save();
  46. return;
  47. }
  48. public static function getOrderByOrder($trade_no,$out_trade_no){
  49. $model = new UserMonthOrder();
  50. $info = $model->where('trade_no',$trade_no)->first();
  51. return $info;
  52. }
  53. }