作者 SHW\戥岁。。

现价基础上打折

... ... @@ -493,9 +493,14 @@ class Litestoregoods extends Backend
$goods_ids = $this->request->get('id');
$goods_ids = explode(',', $goods_ids);
//接收所设置的折扣
$discount = $this->request->get('discount');
$discount = $this->request->get('discount');
$new_discount = $discount / 10;
foreach ($goods_ids as &$v) {
Db::name('litestore_goods_spec')->where('goods_id', $v)->update(['discount' => $discount]);
$spec_goods_ids = Db::name('litestore_goods_spec')->where('goods_id', $v)->field('goods_spec_id,goods_price')->select();
foreach ($spec_goods_ids as &$item) {
$goods_price = round($item['goods_price'] * $new_discount, 1);
Db::name('litestore_goods_spec')->where('goods_spec_id', $item['goods_spec_id'])->update(['discount' => $discount, 'goods_price' => $goods_price]);
}
}
$this->success('设置成功');
}
... ...
... ... @@ -421,7 +421,7 @@ class Classification extends Api
if (empty($goods_spec['discount'])) {
$item['is_discount'] = 'no';
}
$item['discount'] = $goods_spec['discount'];
$item['discount'] = $goods_spec['discount'] . '折';
// 总库存
$item->append(['stock_num']);
... ... @@ -462,6 +462,7 @@ class Classification extends Api
if (empty($spec_value['discount'])) {
$spec_value['is_discount'] = 'no';
}
$spec_value['discount'] = $spec_value['discount'] . '折';
}
$item['goods_sku_list'] = $goods_spec;
$item['goods_sku'] = $array;
... ... @@ -491,7 +492,7 @@ class Classification extends Api
if (empty($goods_spec['discount'])) {
$item['is_discount'] = 'no';
}
$item['discount'] = $goods_spec['discount'];
$item['discount'] = $goods_spec['discount'] . '折';
// 总库存
$item->append(['stock_num']);
... ... @@ -533,6 +534,7 @@ class Classification extends Api
if (empty($spec_value['discount'])) {
$spec_value['is_discount'] = 'no';
}
$spec_value['discount'] = $spec_value['discount'] . '折';
}
$item['goods_sku_list'] = $goods_spec;
$item['goods_sku'] = $array;
... ...
... ... @@ -65,7 +65,7 @@ class Goods extends Api
if (empty($goods_spec['discount'])) {
$goods['is_discount'] = 'no';
}
$goods['discount'] = $goods_spec['discount'];
$goods['discount'] = $goods_spec['discount'].'折';
// 产地
$makerfor_list = ['1' => '国产', '2' => '进口'];
$goods['makefor'] = isset($makerfor_list[$goods['makefor']]) ? $makerfor_list[$goods['makefor']] : '未知';
... ... @@ -164,6 +164,7 @@ class Goods extends Api
if (empty($value['discount'])) {
$value['is_discount'] = 'no';
}
$value['discount'] = $value['discount'].'折';
}
$this->success('商品规格', ['list' => $goods_spec, 'sku' => $array]);
}
... ...
... ... @@ -99,8 +99,8 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'form', 'template', 'litestor
var ids = Table.api.selectedids(table);
layer.prompt({
formType: 0,
value: '8.5折',
title: '请输入折扣',
value: '8.5',
title: '请输入折扣(请勿输入汉字)',
area: ['800px', '350px'] //自定义文本域宽高
},function(value, index, elem){
Fast.api.ajax({
... ...