StoreOrderIncrement.php 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. <?php
  2. /**
  3. *
  4. * @author: xaboy<365615158@qq.com>
  5. * @day: 2018/01/22
  6. */
  7. namespace app\models\store;
  8. use crmeb\basic\BaseModel;
  9. use crmeb\traits\ModelTrait;
  10. /**
  11. * TODO 优惠券Model
  12. * Class StoreCoupon
  13. * @package app\models\store
  14. */
  15. class StoreOrderIncrement extends BaseModel
  16. {
  17. /**
  18. * 数据表主键
  19. * @var string
  20. */
  21. protected $pk = 'id';
  22. /**
  23. * 模型名称
  24. * @var string
  25. */
  26. protected $name = 'store_order_increment';
  27. use ModelTrait;
  28. public static function list($where)
  29. {
  30. $model = self::alias('a')
  31. ->leftJoin('user b', 'a.increment_uid = b.uid')
  32. ->leftJoin('user c', 'a.uid = c.uid')
  33. ->field('a.*,b.nickname,c.nickname as c_nickname')
  34. ->order('a.id DESC');
  35. if ($where['name'])$model->where('b.nickname|b.uid' , 'like', '%'.$where['name'],'%');
  36. if ($where['order'])$model->where('order' , '=', $where['name']);
  37. if (trim($where['data']) != '') $model = self::getModelTime($where, $model, 'a.add_time');
  38. $data['count'] = $model->count();
  39. if ($where['page'] && $where['limit']){
  40. $model->page($where['page'], $where['limit']);
  41. }else{
  42. $model->page(20, 1);
  43. }
  44. $list = $model->select()->toArray();
  45. foreach ($list as &$item){
  46. $item['add_time'] = date('Y-m-d H:i:s',$item['add_time']);
  47. }
  48. $data['data'] = $list;
  49. return $data;
  50. }
  51. }