|
|
@@ -184,10 +184,47 @@ class ProductController extends BaseController
|
|
|
$id = $get['id'] ?? 0;
|
|
|
$info = ProductClass::getById($id, true);
|
|
|
ProductClass::check($info, $this->mainId);
|
|
|
- $info->reachNum = 0;
|
|
|
- $info->reachNumDiscount = 0;
|
|
|
- $info->save();
|
|
|
- util::complete('取消成功');
|
|
|
+
|
|
|
+ $db = Yii::$app->db;
|
|
|
+ $transaction = $db->beginTransaction();
|
|
|
+ try {
|
|
|
+ $info->reachNum = 0;
|
|
|
+ $info->reachNumDiscount = 0;
|
|
|
+ $info->save();
|
|
|
+
|
|
|
+ // 如果当前在总店,则直营分店要同步取消
|
|
|
+ $currentShop = $this->shop;
|
|
|
+ if (isset($currentShop->default) && $currentShop->default == 1) {
|
|
|
+ $sjId = $currentShop->sjId ?? 0;
|
|
|
+ $ptItemId = $info->itemId ?? 0;
|
|
|
+ $chainShopList = ShopClass::getAllByCondition(['sjId' => $sjId], null, '*', null, true);
|
|
|
+ if (!empty($chainShopList)) {
|
|
|
+ foreach ($chainShopList as $chainShop) {
|
|
|
+ $chainShopId = $chainShop->id ?? 0;
|
|
|
+ if ($chainShopId == $this->shopId) {
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ $isDefault = $chainShop->default ?? 0;
|
|
|
+ $isJoin = $chainShop->join ?? 0;
|
|
|
+ if ($isDefault == 0 && $isJoin == 0) {
|
|
|
+ $chainMainId = $chainShop->mainId ?? 0;
|
|
|
+ $chainProduct = ProductClass::getByCondition(['mainId' => $chainMainId, 'itemId' => $ptItemId], true);
|
|
|
+ if (!empty($chainProduct)) {
|
|
|
+ $chainProduct->reachNum = 0;
|
|
|
+ $chainProduct->reachNumDiscount = 0;
|
|
|
+ $chainProduct->save();
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ $transaction->commit();
|
|
|
+ util::complete('取消成功');
|
|
|
+ } catch (\Exception $e) {
|
|
|
+ $transaction->rollBack();
|
|
|
+ util::fail('取消失败:' . $e->getMessage());
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
//取消特价 ssh 20220901
|
|
|
@@ -197,11 +234,49 @@ class ProductController extends BaseController
|
|
|
$id = $get['id'] ?? 0;
|
|
|
$info = ProductClass::getById($id, true);
|
|
|
ProductClass::check($info, $this->mainId);
|
|
|
- $info->discountPrice = 0;
|
|
|
- $info->skDiscountPrice = 0;
|
|
|
- $info->hjDiscountPrice = 0;
|
|
|
- $info->save();
|
|
|
- util::complete('取消成功');
|
|
|
+
|
|
|
+ $db = Yii::$app->db;
|
|
|
+ $transaction = $db->beginTransaction();
|
|
|
+ try {
|
|
|
+ $info->discountPrice = 0;
|
|
|
+ $info->skDiscountPrice = 0;
|
|
|
+ $info->hjDiscountPrice = 0;
|
|
|
+ $info->save();
|
|
|
+
|
|
|
+ // 如果当前在总店,则直营分店要同步取消特价
|
|
|
+ $currentShop = $this->shop;
|
|
|
+ if (isset($currentShop->default) && $currentShop->default == 1) {
|
|
|
+ $sjId = $currentShop->sjId ?? 0;
|
|
|
+ $ptItemId = $info->itemId ?? 0;
|
|
|
+ $chainShopList = ShopClass::getAllByCondition(['sjId' => $sjId], null, '*', null, true);
|
|
|
+ if (!empty($chainShopList)) {
|
|
|
+ foreach ($chainShopList as $chainShop) {
|
|
|
+ $chainShopId = $chainShop->id ?? 0;
|
|
|
+ if ($chainShopId == $this->shopId) {
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ $isDefault = $chainShop->default ?? 0;
|
|
|
+ $isJoin = $chainShop->join ?? 0;
|
|
|
+ if ($isDefault == 0 && $isJoin == 0) {
|
|
|
+ $chainMainId = $chainShop->mainId ?? 0;
|
|
|
+ $chainProduct = ProductClass::getByCondition(['mainId' => $chainMainId, 'itemId' => $ptItemId], true);
|
|
|
+ if (!empty($chainProduct)) {
|
|
|
+ $chainProduct->discountPrice = 0;
|
|
|
+ $chainProduct->skDiscountPrice = 0;
|
|
|
+ $chainProduct->hjDiscountPrice = 0;
|
|
|
+ $chainProduct->save();
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ $transaction->commit();
|
|
|
+ util::complete('取消成功');
|
|
|
+ } catch (\Exception $e) {
|
|
|
+ $transaction->rollBack();
|
|
|
+ util::fail('取消失败:' . $e->getMessage());
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
//打印花材的标签 ssh 20220602
|