|
|
@@ -380,14 +380,39 @@ class ProductController extends BaseController
|
|
|
// $data = [$type => $val];
|
|
|
// ProductClass::updateByCondition($where, $data);
|
|
|
|
|
|
+ $data = [$type => $val];
|
|
|
+
|
|
|
$currentProduct = ProductClass::getById($id, true);
|
|
|
if ($currentProduct->shopId != $this->shopId) {
|
|
|
util::fail('非常操作');
|
|
|
}
|
|
|
$currentProduct->$type = $val;
|
|
|
- $currentProduct->save();
|
|
|
- $data = [$type => $val];
|
|
|
+ if ($type == 'addPrice') {
|
|
|
+
|
|
|
+ $anotherAddPrice = $val > 2 ? $val - 1 : 1;
|
|
|
|
|
|
+ $qtAddPrice = $currentProduct->qtAddPrice;
|
|
|
+ if ($qtAddPrice <= 0) {
|
|
|
+ $currentProduct->qtAddPrice = $anotherAddPrice;
|
|
|
+ $data['qtAddPrice'] = $anotherAddPrice;
|
|
|
+ }
|
|
|
+ $byAddPrice = $currentProduct->byAddPrice;
|
|
|
+ if ($byAddPrice <= 0) {
|
|
|
+ $currentProduct->byAddPrice = $anotherAddPrice;
|
|
|
+ $data['byAddPrice'] = $anotherAddPrice;
|
|
|
+ }
|
|
|
+ $hjAddPrice = $currentProduct->hjAddPrice;
|
|
|
+ if ($hjAddPrice <= 0) {
|
|
|
+ $currentProduct->hjAddPrice = $anotherAddPrice;
|
|
|
+ $data['hjAddPrice'] = $anotherAddPrice;
|
|
|
+ }
|
|
|
+ $zsAddPrice = $currentProduct->zsAddPrice;
|
|
|
+ if ($zsAddPrice <= 0) {
|
|
|
+ $currentProduct->zsAddPrice = $anotherAddPrice;
|
|
|
+ $data['zsAddPrice'] = $anotherAddPrice;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ $currentProduct->save();
|
|
|
|
|
|
//2021.7.6 linqh 如果是首店,则更新全部分店
|
|
|
ProductClass::updateSyncProduct($id, $this->shopId, $data);
|