diff --git a/app/data/controller/base/Discount.php b/app/data/controller/base/Discount.php index 94c556212..7878cecbf 100644 --- a/app/data/controller/base/Discount.php +++ b/app/data/controller/base/Discount.php @@ -5,6 +5,7 @@ namespace app\data\controller\base; use app\data\model\BaseUserDiscount; use app\data\service\UserUpgradeService; use think\admin\Controller; +use think\admin\helper\QueryHelper; /** * 折扣方案管理 @@ -23,20 +24,12 @@ class Discount extends Controller */ public function index() { - $this->title = '折扣方案管理'; - $query = BaseUserDiscount::mQuery(); - $query->where(['deleted' => 0])->order('sort desc,id desc')->page(); - } - - /** - * 数据列表处理 - * @param array $data - */ - protected function _page_filter(array &$data) - { - foreach ($data as &$vo) { - $vo['items'] = json_decode($vo['items'], true); - } + $this->type = input('get.type', 'index'); + BaseUserDiscount::mQuery()->layTable(function () { + $this->title = '折扣方案管理'; + }, function (QueryHelper $query) { + $query->where(['status' => intval($this->type === 'index'), 'deleted' => 0]); + }); } /** diff --git a/app/data/model/BaseUserDiscount.php b/app/data/model/BaseUserDiscount.php index c2ebfae6b..a2069d4c4 100644 --- a/app/data/model/BaseUserDiscount.php +++ b/app/data/model/BaseUserDiscount.php @@ -11,5 +11,23 @@ use think\admin\Model; */ class BaseUserDiscount extends Model { + /** + * 格式化等级规则 + * @param mixed $value + * @return mixed + */ + public function getItemsAttr($value) + { + return empty($value) ? json_decode($value, true) : $value; + } + /** + * 格式化创建时间 + * @param string $value + * @return string + */ + public function getCreateAtAttr(string $value): string + { + return format_datetime($value); + } } \ No newline at end of file diff --git a/app/data/view/base/discount/form.html b/app/data/view/base/discount/form.html index 92cf14ae3..89e87f203 100644 --- a/app/data/view/base/discount/form.html +++ b/app/data/view/base/discount/form.html @@ -1,4 +1,4 @@ -