StoreCoupon.php 2.0 KB

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