添加商家利润比例字段
This commit is contained in:
parent
38bc60b721
commit
305e3b1bc4
@ -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) . '%';
|
||||
}
|
||||
}
|
||||
@ -8,11 +8,13 @@ class SubsidyValidate extends Validate
|
||||
{
|
||||
|
||||
protected $rule = [
|
||||
'profit' => 'require',
|
||||
'discount' => 'require',
|
||||
'subsidy' => 'require',
|
||||
];
|
||||
|
||||
protected $message = [
|
||||
'profit.require' => '商家利润比例参数不能为空',
|
||||
'discount.require' => '商品让利比例参数不能为空',
|
||||
'subsidy.require' => '商品全返比例参数不能为空',
|
||||
];
|
||||
|
||||
@ -10,6 +10,16 @@
|
||||
}
|
||||
</style>
|
||||
<div class="layui-form" lay-filter="layui-form" id="layui-form" style="padding: 20px 30px 20px 0;">
|
||||
<div class="layui-form-item">
|
||||
<label class="layui-form-label"><font color="red">*</font>商家利润比例</label>
|
||||
<div class="layui-input-inline">
|
||||
<div class="flex">
|
||||
<input type="text" name="profit" lay-verify="required" lay-verType="tips" placeholder="请输入商家利润比例" autocomplete="off" class="layui-input">
|
||||
<p style="margin-left: 10px">%</p>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="layui-form-item">
|
||||
<label class="layui-form-label"><font color="red">*</font>商品让利比例</label>
|
||||
<div class="layui-input-inline">
|
||||
|
||||
@ -12,6 +12,16 @@
|
||||
<div class="layui-form" lay-filter="layui-form" id="layui-form" style="padding: 20px 30px 20px 0;">
|
||||
<input type="hidden" value="{$detail.id}" name="id">
|
||||
|
||||
<div class="layui-form-item">
|
||||
<label class="layui-form-label"><font color="red">*</font>商家利润比例</label>
|
||||
<div class="layui-input-inline">
|
||||
<div class="flex">
|
||||
<input type="text" name="profit" value="{$detail.profit}" lay-verify="required" lay-verType="tips" placeholder="请输入商家利润比例" autocomplete="off" class="layui-input">
|
||||
<p style="margin-left: 10px">%</p>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="layui-form-item">
|
||||
<label class="layui-form-label"><font color="red">*</font>商品让利比例</label>
|
||||
<div class="layui-input-inline">
|
||||
|
||||
@ -77,9 +77,9 @@
|
||||
</div>
|
||||
</div>
|
||||
<div class="layui-form-item" style="display: flex">
|
||||
<lable class="layui-form-label">分销推广会员无极公司佣金:</lable>
|
||||
<lable class="layui-form-label">分销推广会员无级公司佣金:</lable>
|
||||
<div class="info">
|
||||
<input value="{$config.distribution_electrodeless}" type="text" name="distribution_electrodeless" id="distribution_electrodeless" placeholder="分销推广会员无极公司佣金" autocomplete="off" class="layui-input">
|
||||
<input value="{$config.distribution_electrodeless}" type="text" name="distribution_electrodeless" id="distribution_electrodeless" placeholder="分销推广会员无级公司佣金" autocomplete="off" class="layui-input">
|
||||
<p style="margin-left: 10px">%</p>
|
||||
</div>
|
||||
</div>
|
||||
@ -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'}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user