StoreCouponIssue.php 1.9 KB

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