|
|
@@ -545,17 +545,54 @@ class ProductClass extends BaseClass
|
|
|
//修改价格 linqh 2021.1.28
|
|
|
public static function changePrice($product, $price, $priceLabel)
|
|
|
{
|
|
|
- $id = $product->id ?? 0;
|
|
|
$shopId = $product->shopId ?? 0;
|
|
|
|
|
|
- //改价后取消特价 shish 20210902
|
|
|
- $product->discountPrice = 0;
|
|
|
- $product->save();
|
|
|
+ $shopInfo = ShopClass::getById($shopId, true);
|
|
|
+ $itemId = $product->itemId ?? 0;
|
|
|
|
|
|
- //2021.7.6 linqh 首店改价,同步到各个分店
|
|
|
- $res = ProductClass::updateByCondition(['id' => $id], ['price' => $price, 'priceLabel' => $priceLabel]);
|
|
|
- self::updateSyncProduct($id, $shopId, ['price' => $price, 'priceLabel' => $priceLabel]);
|
|
|
- return $res;
|
|
|
+ $sjId = $shopInfo->sjId ?? 0;
|
|
|
+ $shopAll = ShopClass::getAllShop($sjId);
|
|
|
+ if ($shopAll) {
|
|
|
+ foreach ($shopAll as $shop) {
|
|
|
+ $currentId = $shop['id'] ?? 0;
|
|
|
+ $currentInfo = ProductClass::getByCondition(['itemId' => $itemId, 'shopId' => $currentId], true);
|
|
|
+ if (empty($currentInfo)) {
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+
|
|
|
+ //改价后取消特价
|
|
|
+ $currentInfo->discountPrice = 0;
|
|
|
+ $currentInfo->price = $price;
|
|
|
+ $currentInfo->priceLabel = $priceLabel;
|
|
|
+ //会员价同步变化
|
|
|
+ $addPrice = $currentInfo->addPrice ?? 0;
|
|
|
+ $qtAddPrice = $currentInfo->qtAddPrice ?? 0;
|
|
|
+ $qt = bcsub($addPrice, $qtAddPrice, 2);
|
|
|
+ if ($qt > 0) {
|
|
|
+ $currentInfo->qtPrice = bcsub($price, $qt, 2);
|
|
|
+ }
|
|
|
+ $byAddPrice = $currentInfo->byAddPrice ?? 0;
|
|
|
+ $by = bcsub($addPrice, $byAddPrice, 2);
|
|
|
+ if ($by > 0) {
|
|
|
+ $currentInfo->byPrice = bcsub($price, $by, 2);
|
|
|
+ }
|
|
|
+ $hjAddPrice = $currentInfo->hjAddPrice ?? 0;
|
|
|
+ $hj = bcsub($addPrice, $hjAddPrice, 2);
|
|
|
+ if ($hj > 0) {
|
|
|
+ $currentInfo->hjPrice = bcsub($price, $hj, 2);
|
|
|
+ }
|
|
|
+ $zsAddPrice = $currentInfo->zsAddPrice ?? 0;
|
|
|
+ $zs = bcsub($addPrice, $zsAddPrice, 2);
|
|
|
+ if ($zs > 0) {
|
|
|
+ $currentInfo->zsPrice = bcsub($price, $zs, 2);
|
|
|
+ }
|
|
|
+ $currentInfo->save();
|
|
|
+
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ return true;
|
|
|
}
|
|
|
|
|
|
//2021.7.6 修改花材同步其他分店
|
|
|
@@ -565,7 +602,6 @@ class ProductClass extends BaseClass
|
|
|
$productData = ProductClass::getById($productId);
|
|
|
$itemId = $productData['itemId'];
|
|
|
if ($shopInfo['default'] == 1) {
|
|
|
- //首店
|
|
|
$sjId = $shopInfo['sjId'];
|
|
|
$shopAll = ShopClass::getAllShop($sjId);
|
|
|
if ($shopAll) {
|