diff --git a/cash-common/cash-common-service/src/main/java/com/czg/account/entity/ShopConfig.java b/cash-common/cash-common-service/src/main/java/com/czg/account/entity/ShopConfig.java index f598e1a98..a0f5f49c0 100644 --- a/cash-common/cash-common-service/src/main/java/com/czg/account/entity/ShopConfig.java +++ b/cash-common/cash-common-service/src/main/java/com/czg/account/entity/ShopConfig.java @@ -5,6 +5,7 @@ import com.mybatisflex.annotation.Id; import com.mybatisflex.annotation.KeyType; import com.mybatisflex.annotation.Table; import lombok.Data; +import lombok.experimental.Accessors; import java.io.Serial; import java.io.Serializable; @@ -17,6 +18,7 @@ import java.io.Serializable; */ @Data @Table("tb_shop_config") +@Accessors(chain = true) public class ShopConfig implements Serializable { @Serial @@ -84,7 +86,7 @@ public class ShopConfig implements Serializable { */ private Integer isTableFee; /** - * 是否启用会员价 1-是 0-否 + * 是否启用会员价 1-是 0-否 */ private Integer isMemberPrice; /** @@ -104,4 +106,4 @@ public class ShopConfig implements Serializable { * '自动清台 支付几分钟后 默认10分钟后' */ private Integer tableClearTime; -} \ No newline at end of file +} diff --git a/cash-common/cash-common-service/src/main/java/com/czg/account/service/ShopConfigService.java b/cash-common/cash-common-service/src/main/java/com/czg/account/service/ShopConfigService.java index cea58cb4e..565539b4e 100644 --- a/cash-common/cash-common-service/src/main/java/com/czg/account/service/ShopConfigService.java +++ b/cash-common/cash-common-service/src/main/java/com/czg/account/service/ShopConfigService.java @@ -2,6 +2,9 @@ package com.czg.account.service; import com.czg.account.entity.ShopConfig; import com.mybatisflex.core.service.IService; +import com.mybatisflex.core.util.LambdaGetter; + +import java.util.List; /** * 店铺配置扩展 @@ -11,4 +14,5 @@ import com.mybatisflex.core.service.IService; */ public interface ShopConfigService extends IService { -} \ No newline at end of file + void editStatusByShopIdList(Long mainShopId, Integer isEnable, LambdaGetter property, String useShopType, List shopIdList); +} diff --git a/cash-service/account-service/src/main/java/com/czg/service/account/service/impl/FreeDineConfigServiceImpl.java b/cash-service/account-service/src/main/java/com/czg/service/account/service/impl/FreeDineConfigServiceImpl.java index 8e6f54b40..61a620a78 100644 --- a/cash-service/account-service/src/main/java/com/czg/service/account/service/impl/FreeDineConfigServiceImpl.java +++ b/cash-service/account-service/src/main/java/com/czg/service/account/service/impl/FreeDineConfigServiceImpl.java @@ -6,12 +6,16 @@ import com.alibaba.fastjson.JSONObject; import com.alibaba.fastjson2.JSONArray; import com.czg.account.dto.freeding.FreeDineConfigEditDTO; import com.czg.account.entity.FreeDineConfig; +import com.czg.account.entity.ShopConfig; import com.czg.account.service.FreeDineConfigService; +import com.czg.account.service.ShopConfigService; import com.czg.account.vo.FreeDineConfigVO; import com.czg.exception.ApiNotPrintException; import com.czg.service.account.mapper.FreeDineConfigMapper; import com.mybatisflex.core.query.QueryWrapper; import com.mybatisflex.spring.service.impl.ServiceImpl; +import jakarta.annotation.Resource; +import org.apache.dubbo.config.annotation.DubboReference; import org.apache.dubbo.config.annotation.DubboService; /** @@ -22,6 +26,10 @@ import org.apache.dubbo.config.annotation.DubboService; */ @DubboService public class FreeDineConfigServiceImpl extends ServiceImpl implements FreeDineConfigService{ + + @DubboReference + private ShopConfigService shopConfigService; + @Override public FreeDineConfigVO getConfig(long shopId) { FreeDineConfig freeDineConfig = getOne(new QueryWrapper().eq(FreeDineConfig::getShopId, shopId)); @@ -52,6 +60,8 @@ public class FreeDineConfigServiceImpl extends ServiceImpl void editStatusByShopIdList(Long mainShopId, Integer isEnable, LambdaGetter property, String useShopType, List shopIdList) { + ShopConfig shopConfig = getOne(new QueryWrapper().eq(ShopConfig::getId, mainShopId)); + if (shopConfig == null) { + shopConfig = new ShopConfig(); + shopConfig.setId(mainShopId); + save(shopConfig); + } + + if (!shopIdList.isEmpty()) { + List extistList = list(new QueryWrapper().in(ShopConfig::getId, shopIdList).select(ShopConfig::getId)).stream().map(ShopConfig::getId).toList(); + shopIdList.stream().filter(id -> !extistList.contains(id)).forEach(id -> { + save(new ShopConfig().setId(id).setMainId(mainShopId)); + }); + } + + if (isEnable == 0) { + updateChain().or(or -> { + or.eq(ShopConfig::getMainId, mainShopId); + }).or(or -> { + or.in(ShopConfig::getId, shopIdList); + }).set(property, 0).update(); + }else { + if ("all".equals(useShopType)) { + updateChain().or(or -> { + or.eq(ShopConfig::getMainId, mainShopId); + }).or(or -> { + or.in(ShopConfig::getId, shopIdList); + }).set(property, 1).update(); + }else { + if (shopIdList.isEmpty()) { + updateChain().eq(ShopConfig::getMainId, mainShopId).set(property, 1).update(); + }else { + updateChain().notIn(ShopConfig::getId, shopIdList).set(property, 0).update(); + updateChain().in(ShopConfig::getId, shopIdList).set(property, 1).update(); + } + } + } + + } + +} diff --git a/cash-service/market-service/src/main/java/com/czg/service/market/service/impl/MkConsumeCashbackServiceImpl.java b/cash-service/market-service/src/main/java/com/czg/service/market/service/impl/MkConsumeCashbackServiceImpl.java index 24120e3d7..30299e911 100644 --- a/cash-service/market-service/src/main/java/com/czg/service/market/service/impl/MkConsumeCashbackServiceImpl.java +++ b/cash-service/market-service/src/main/java/com/czg/service/market/service/impl/MkConsumeCashbackServiceImpl.java @@ -5,8 +5,10 @@ import cn.hutool.core.collection.CollUtil; import cn.hutool.core.util.StrUtil; import com.alibaba.fastjson2.JSONArray; import com.czg.account.dto.shopuser.ShopUserMoneyEditDTO; +import com.czg.account.entity.ShopConfig; import com.czg.account.entity.ShopInfo; import com.czg.account.entity.ShopUser; +import com.czg.account.service.ShopConfigService; import com.czg.account.service.ShopInfoService; import com.czg.account.service.ShopUserService; import com.czg.constant.TableValueConstant; @@ -53,6 +55,8 @@ public class MkConsumeCashbackServiceImpl extends ServiceImpl