Goods.php 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. <?php
  2. namespace app\agent\controller\order;
  3. use app\common\controller\AgentController;
  4. use app\http\IResponse;
  5. use Lettered\Support\Auth as IAuth;
  6. use think\App;
  7. class Goods extends AgentController
  8. {
  9. protected $model;
  10. public function __construct(App $app = null, IAuth $auth)
  11. {
  12. parent::__construct($app, $auth);
  13. $this->model = new \app\agent\model\order\Goods();
  14. }
  15. public function index()
  16. {
  17. $user = $this->auth->user();
  18. $where[] = ['area_id', 'eq', $user['area_id']];
  19. //组合搜索
  20. !empty(input('name')) && $where[]
  21. = ['name', 'like', '%' . input('name') . '%'];
  22. (!empty(input('pin')) || input('pin') == '0') &&
  23. $where[] = ['is_pin', 'eq', input('pin')];
  24. (!empty(input('status')) || input('status') == '0') &&
  25. $where[] = ['status', 'eq', input('status')];
  26. !empty(input('area')) && $where[]
  27. = ['area_id', 'eq', input('area')];
  28. !empty(input('keywords')) && $where[]
  29. = ['user_id|order_no', 'like', '%' . input('keywords') . '%'];
  30. // 时间处理
  31. if (!empty(input('created_at'))){
  32. list($start, $end) = str2arr(input('created_at'),'-');
  33. $where[] = ['created_at', 'between', [strtotime($start), strtotime($end)]];
  34. }
  35. return IResponse::paginate($this->model->where($where)->with(['user','seller','addr'])
  36. ->order(['created_at' => 'desc'])
  37. ->paginate(input('limit'),false));
  38. }
  39. }