StoreCouponIssue.php 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  1. <?php
  2. /**
  3. * @author: xaboy<365615158@qq.com>
  4. * @day: 2018/01/17
  5. */
  6. namespace app\admin\model\ump;
  7. use crmeb\basic\BaseModel;
  8. use crmeb\traits\ModelTrait;
  9. class StoreCouponIssue extends BaseModel
  10. {
  11. /**
  12. * 数据表主键
  13. * @var string
  14. */
  15. protected $pk = 'id';
  16. /**
  17. * 模型名称
  18. * @var string
  19. */
  20. protected $name = 'store_coupon_issue';
  21. use ModelTrait;
  22. protected $insert = ['add_time'];
  23. public static function stsypage($where)
  24. {
  25. $model = self::alias('A')
  26. ->field('A.*,B.title,B.type')
  27. ->join('store_coupon B', 'A.cid = B.id')
  28. ->where('A.is_del', 0)
  29. ->order('A.id DESC');
  30. if (isset($where['status']) && $where['status'] != '') {
  31. $model = $model->where('A.status', $where['status']);
  32. }
  33. if (isset($where['type']) && $where['type'] != '') {
  34. $model = $model->where('B.type', $where['type']);
  35. }
  36. if (isset($where['coupon_title']) && $where['coupon_title'] != '') {
  37. $model = $model->where('B.title', 'LIKE', "%$where[coupon_title]%");
  38. }
  39. return self::page($model);
  40. }
  41. protected function setAddTimeAttr()
  42. {
  43. return time();
  44. }
  45. /**
  46. * 发布优惠券
  47. * @param $cid
  48. * @param int $total_count
  49. * @param int $start_time
  50. * @param int $end_time
  51. * @param int $remain_count
  52. * @param int $status
  53. * @param int $is_permanent
  54. * @param int $full_reduction
  55. * @param int $is_give_subscribe
  56. * @param int $is_full_give
  57. * @return StoreCouponIssue|\think\Model
  58. */
  59. public static function setIssue($cid, $total_count = 0, $start_time = 0, $end_time = 0, $remain_count = 0, $status = 0, $is_permanent = 0, $full_reduction = 0, $is_give_subscribe = 0, $is_full_give = 0)
  60. {
  61. return self::create(compact('cid', 'start_time', 'end_time', 'total_count', 'remain_count', 'status', 'is_permanent', 'full_reduction', 'is_give_subscribe', 'is_full_give'));
  62. }
  63. }