OrderService.php 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  1. <?php
  2. // +----------------------------------------------------------------------
  3. // | LARAVEL8.0 框架 [ LARAVEL ][ RXThinkCMF ]
  4. // +----------------------------------------------------------------------
  5. // | 版权所有 2017~2021 LARAVEL研发中心
  6. // +----------------------------------------------------------------------
  7. // | 官方网站: http://www.laravel.cn
  8. // +----------------------------------------------------------------------
  9. // | Author: laravel开发员 <laravel.qq.com>
  10. // +----------------------------------------------------------------------
  11. namespace App\Services\Common;
  12. use App\Models\OrderModel;
  13. use App\Services\BaseService;
  14. /**
  15. * 积分商城订单管理-服务类
  16. * @author laravel开发员
  17. * @since 2020/11/11
  18. * Class OrderService
  19. * @package App\Services\Common
  20. */
  21. class OrderService extends BaseService
  22. {
  23. // 静态对象
  24. protected static $instance = null;
  25. /**
  26. * 构造函数
  27. * @author laravel开发员
  28. * @since 2020/11/11
  29. * OrderService constructor.
  30. */
  31. public function __construct()
  32. {
  33. $this->model = new OrderModel();
  34. }
  35. /**
  36. * 静态入口
  37. * @return static|null
  38. */
  39. public static function make()
  40. {
  41. if (!self::$instance) {
  42. self::$instance = (new static());
  43. }
  44. return self::$instance;
  45. }
  46. /**
  47. * 添加或编辑
  48. * @return array
  49. * @since 2020/11/11
  50. * @author laravel开发员
  51. */
  52. public function edit()
  53. {
  54. $data = request()->all();
  55. return parent::edit($data); // TODO: Change the autogenerated stub
  56. }
  57. /**
  58. * 抢拍交易订单数
  59. * @param $userId 用户ID
  60. * @param int $status 状态
  61. * @return mixed
  62. */
  63. public function getNewTradeCount($userId, $status=0)
  64. {
  65. $where = ['user_id'=>$userId,'mark'=>1,'is_read'=>0];
  66. return $this->model->where($where)
  67. ->where(function($query) use($status){
  68. $query->whereIn('status',is_array($status)? $status:[$status]);
  69. })
  70. ->count('id');
  71. }
  72. }