|
|
@@ -227,8 +227,10 @@ class ProductController extends BaseController
|
|
|
if (empty($data) || empty($type)) {
|
|
|
util::fail("参数错误");
|
|
|
}
|
|
|
- if (in_array($type, ['inTurn', 'addPrice', 'cost', 'weight', 'ratio', 'delStatus', 'ratio'])) {
|
|
|
+ if (in_array($type, ['inTurn', 'addPrice', 'cost', 'weight', 'ratio', 'delStatus', 'ratio','price'])) {
|
|
|
$data = json_decode($data, true);
|
|
|
+ } else {
|
|
|
+ util::fail('不允许的类型');
|
|
|
}
|
|
|
foreach ($data as $v) {
|
|
|
if ($type == 'delStatus') {
|
|
|
@@ -242,12 +244,32 @@ class ProductController extends BaseController
|
|
|
$id = $v['id'];
|
|
|
$val = $v[$type] ?? '';
|
|
|
|
|
|
+ //shish 20210703
|
|
|
if ($type == 'ratio') {
|
|
|
if (preg_match("/^[1-9][0-9]*$/", $val) == false || $val <= 0) {
|
|
|
util::fail('单位比请填写整数,并且要大于0');
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+ //修改售价 shish 20210703
|
|
|
+ if ($type == 'price') {
|
|
|
+ $product = ProductClass::getLockById($id);
|
|
|
+ if (empty($product)) {
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ //留空恢复自动调价
|
|
|
+ if (empty($val)) {
|
|
|
+ $product->priceLabel = ProductClass::PRICE_LABEL_AUTO;
|
|
|
+ $product->price = bcadd($product->cost, $product->addPrice, 2);
|
|
|
+ $product->save();
|
|
|
+ } else {
|
|
|
+ $product->priceLabel = ProductClass::PRICE_LABEL_CHANGE;
|
|
|
+ $product->price = $val;
|
|
|
+ $product->save();
|
|
|
+ }
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+
|
|
|
$where = [];
|
|
|
$where['id'] = $id;
|
|
|
$where['shopId'] = $this->shopId;
|