diff --git a/app/admin/logic/goods/SubsidyLogic.php b/app/admin/logic/goods/SubsidyLogic.php index 3ad76e5f..70f03b3d 100755 --- a/app/admin/logic/goods/SubsidyLogic.php +++ b/app/admin/logic/goods/SubsidyLogic.php @@ -20,27 +20,18 @@ class SubsidyLogic extends Logic public static function lists($get) { $lists = GoodsSubsidy::where('is_delete', 0) - ->withAttr('discount', function ($value) { - $arr = explode('.', $value); - if ($arr[1] > 0) { - return $value . '%'; - } - - return intval($value) . '%'; - }) - ->withAttr('subsidy', function ($value) { - $arr = explode('.', $value); - if ($arr[1] > 0) { - return $value . '%'; - } - - return intval($value) . '%'; - }) + ->order('id desc') ->paginate([ 'list_rows'=> $get['limit'], 'page'=> $get['page'], ]); + foreach ($lists as &$v) { + $v['profit'] = self::formatStr($v['profit']); + $v['discount'] = self::formatStr($v['discount']); + $v['subsidy'] = self::formatStr($v['subsidy']); + } + return ['count' => $lists->total(), 'lists' => $lists->getCollection()]; } @@ -51,6 +42,7 @@ class SubsidyLogic extends Logic try { Db::startTrans(); GoodsSubsidy::create([ + 'profit' => str_replace('%', '', $post['profit']), 'discount' => str_replace('%', '', $post['discount']), 'subsidy' => str_replace('%', '', $post['subsidy']), ]); @@ -75,6 +67,7 @@ class SubsidyLogic extends Logic try { Db::startTrans(); GoodsSubsidy::update([ + 'profit' => str_replace('%', '', $post['profit']), 'discount' => str_replace('%', '', $post['discount']), 'subsidy' => str_replace('%', '', $post['subsidy']), ], ['id' => $post['id']]); @@ -132,4 +125,10 @@ class SubsidyLogic extends Logic return false; } } + + private static function formatStr($str) + { + $s = explode('.', $str); + return $s[1] > 0 ? $s . '%' : intval($str) . '%'; + } } \ No newline at end of file diff --git a/app/admin/validate/goods/SubsidyValidate.php b/app/admin/validate/goods/SubsidyValidate.php index bf4641d9..07c44f29 100755 --- a/app/admin/validate/goods/SubsidyValidate.php +++ b/app/admin/validate/goods/SubsidyValidate.php @@ -8,11 +8,13 @@ class SubsidyValidate extends Validate { protected $rule = [ + 'profit' => 'require', 'discount' => 'require', 'subsidy' => 'require', ]; protected $message = [ + 'profit.require' => '商家利润比例参数不能为空', 'discount.require' => '商品让利比例参数不能为空', 'subsidy.require' => '商品全返比例参数不能为空', ]; diff --git a/app/admin/view/goods/subsidy/add.html b/app/admin/view/goods/subsidy/add.html index b6781de0..ce77313e 100755 --- a/app/admin/view/goods/subsidy/add.html +++ b/app/admin/view/goods/subsidy/add.html @@ -10,6 +10,16 @@ }
+
+ +
+
+ +

%

+
+
+
+
diff --git a/app/admin/view/goods/subsidy/edit.html b/app/admin/view/goods/subsidy/edit.html index 7a1b2f1f..52995b5f 100755 --- a/app/admin/view/goods/subsidy/edit.html +++ b/app/admin/view/goods/subsidy/edit.html @@ -12,6 +12,16 @@
+
+ +
+
+ +

%

+
+
+
+
diff --git a/app/admin/view/goods/subsidy/lists.html b/app/admin/view/goods/subsidy/lists.html index 308ab4eb..76045e7b 100755 --- a/app/admin/view/goods/subsidy/lists.html +++ b/app/admin/view/goods/subsidy/lists.html @@ -77,9 +77,9 @@
- 分销推广会员无极公司佣金: + 分销推广会员无级公司佣金:
- +

%

@@ -254,6 +254,7 @@ //列表 like.tableLists('#like-table-lists', '{:url("goods.subsidy/lists")}', [ {field: 'id', width: 60, title: 'ID', sort: true} + , {field: 'profit', title: '商家利润比例', align: "center"} , {field: 'discount', title: '商品让利比例', align: "center"} , {field: 'subsidy', title: '商品全返比例', align: "center"} , {fixed: 'right', title: '操作', align: 'center', width: 300, toolbar: '#subsidy-operation'}