StoreCoupon.php 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  1. <?php
  2. /**
  3. *
  4. * @author: xaboy<365615158@qq.com>
  5. * @day: 2017/11/11
  6. */
  7. namespace app\admin\model\ump;
  8. use traits\ModelTrait;
  9. use basic\ModelBasic;
  10. /**
  11. * Class StoreCategory
  12. * @package app\admin\model\store
  13. */
  14. class StoreCoupon extends ModelBasic
  15. {
  16. use ModelTrait;
  17. /**
  18. * @param $where
  19. * @return array
  20. */
  21. public static function systemPage($where){
  22. $model = new self;
  23. if($where['status'] != '') $model = $model->where('status',$where['status']);
  24. if($where['title'] != '') $model = $model->where('title','LIKE',"%$where[title]%");
  25. // if($where['is_del'] != '') $model = $model->where('is_del',$where['is_del']);
  26. $model = $model->where('is_del',0);
  27. $model = $model->order('sort desc,id desc');
  28. return self::page($model,$where);
  29. }
  30. /**
  31. * @param $where
  32. * @return array
  33. */
  34. public static function systemPageCoupon($where){
  35. $model = new self;
  36. if($where['status'] != '') $model = $model->where('status',$where['status']);
  37. if($where['title'] != '') $model = $model->where('title','LIKE',"%$where[title]%");
  38. // if($where['is_del'] != '') $model = $model->where('is_del',$where['is_del']);
  39. $model = $model->where('is_del',0);
  40. $model = $model->where('status',1);
  41. $model = $model->order('sort desc,id desc');
  42. return self::page($model,$where);
  43. }
  44. public static function editIsDel($id){
  45. $data['status'] = 0;
  46. self::beginTrans();
  47. $res1 = self::edit($data,$id);
  48. $res2 = false !== StoreCouponUser::where('cid',$id)->setField('is_fail',1);
  49. $res3 = false !== StoreCouponIssue::where('cid',$id)->setField('status',-1);
  50. $res = $res1 && $res2 && $res3;
  51. self::checkTrans($res);
  52. return $res;
  53. }
  54. }