|
|
@@ -179,4 +179,33 @@ class ProductController extends BaseController
|
|
|
ProductClass::updateProduct($post);
|
|
|
util::complete();
|
|
|
}
|
|
|
+
|
|
|
+ //批量修改product 排序,成本价,加价
|
|
|
+ public function actionBatchUpdate()
|
|
|
+ {
|
|
|
+ $data = Yii::$app->request->post('data', ''); //data = [{id:1,inTurn:10,addPrice:2,cost:10}]
|
|
|
+ $type = Yii::$app->request->post('type', '');
|
|
|
+ if (empty($data) || empty($type)) {
|
|
|
+ util::fail("参数错误");
|
|
|
+ }
|
|
|
+ if (in_array($type, ['inTurn', 'addPrice', 'cost', 'weight', 'ratio']))
|
|
|
+ $data = json_decode($data, true);
|
|
|
+ foreach ($data as $v) {
|
|
|
+ $id = $v['id'];
|
|
|
+ $val = $v[$type] ?? '';
|
|
|
+ $where = [];
|
|
|
+ $where['id'] = $id;
|
|
|
+ $where['shopId'] = $this->shopId;
|
|
|
+ $where['sjId'] = $this->sjId;
|
|
|
+ if (empty($val)) {
|
|
|
+ util::fail("参数错误1");
|
|
|
+ }
|
|
|
+ $data = [
|
|
|
+ $type => $val
|
|
|
+ ];
|
|
|
+ ProductClass::updateByCondition($where, $data);
|
|
|
+ ProductClass::autoPriceById($id);
|
|
|
+ }
|
|
|
+ util::complete();
|
|
|
+ }
|
|
|
}
|