Merge branch 'prod' into test

This commit is contained in:
张松
2025-11-11 09:30:19 +08:00
21 changed files with 227 additions and 59 deletions

View File

@@ -1,10 +1,7 @@
package com.czg.controller.admin; package com.czg.controller.admin;
import cn.hutool.core.util.StrUtil; import cn.hutool.core.util.StrUtil;
import com.czg.account.dto.table.ShopTableAddDTO; import com.czg.account.dto.table.*;
import com.czg.account.dto.table.ShopTableBindDTO;
import com.czg.account.dto.table.ShopTableClearDTO;
import com.czg.account.dto.table.ShopTableDTO;
import com.czg.account.entity.ShopTable; import com.czg.account.entity.ShopTable;
import com.czg.account.service.ShopTableService; import com.czg.account.service.ShopTableService;
import com.czg.account.vo.ShopTableVO; import com.czg.account.vo.ShopTableVO;
@@ -15,6 +12,7 @@ import com.czg.resp.CzgResult;
import com.czg.sa.StpKit; import com.czg.sa.StpKit;
import com.mybatisflex.core.paginate.Page; import com.mybatisflex.core.paginate.Page;
import com.mybatisflex.core.query.QueryWrapper; import com.mybatisflex.core.query.QueryWrapper;
import com.mybatisflex.core.update.UpdateChain;
import jakarta.annotation.Resource; import jakarta.annotation.Resource;
import jakarta.servlet.http.HttpServletRequest; import jakarta.servlet.http.HttpServletRequest;
import jakarta.servlet.http.HttpServletResponse; import jakarta.servlet.http.HttpServletResponse;
@@ -93,6 +91,24 @@ public class ShopTableController {
return CzgResult.success(shopTableService.updateInfo(StpKit.USER.getLoginIdAsLong(), shopTableDTO)); return CzgResult.success(shopTableService.updateInfo(StpKit.USER.getLoginIdAsLong(), shopTableDTO));
} }
/**
* 批量台桌配置
* 权限标识: shopTable:edit
* @return 是否成功
*/
@PutMapping
public CzgResult<Boolean> editBatch(@RequestBody @Validated ShopTableEditBatchDTO shopTableDTO) {
UpdateChain<ShopTable> query = shopTableService.updateChain().eq(ShopTable::getShopId, StpKit.USER.getShopId());
if (shopTableDTO.getClearTime() != null) {
query.eq(ShopTable::getClearTime, shopTableDTO.getClearTime());
}
if (shopTableDTO.getAutoClear() != null) {
query.eq(ShopTable::getAutoClear, shopTableDTO.getAutoClear());
}
return CzgResult.success(query.update());
}
/** /**
* 台桌清台 * 台桌清台
* 权限标识: shopTable:clear * 权限标识: shopTable:clear

View File

@@ -36,7 +36,7 @@ public class UMemberPointsController {
*/ */
@GetMapping("pointsBasicSetting") @GetMapping("pointsBasicSetting")
public CzgResult<PointsBasicSettingDTO> getPointsBasicSetting() { public CzgResult<PointsBasicSettingDTO> getPointsBasicSetting() {
Long shopId = StpKit.USER.getShopId(0L); Long shopId = StpKit.USER.getShopId();
PointsBasicSetting entity = pointsBasicSettingService.getById(shopId); PointsBasicSetting entity = pointsBasicSettingService.getById(shopId);
PointsBasicSettingDTO data = BeanUtil.copyProperties(entity, PointsBasicSettingDTO.class); PointsBasicSettingDTO data = BeanUtil.copyProperties(entity, PointsBasicSettingDTO.class);
return CzgResult.success(data); return CzgResult.success(data);

View File

@@ -16,8 +16,8 @@ public class MybatisFlexConfig {
//设置 SQL 审计收集器 //设置 SQL 审计收集器
AuditManager.setMessageCollector(auditMessage -> AuditManager.setMessageCollector(auditMessage ->
log.info("{},{}ms", auditMessage.getFullSql() log.info("[sql] time: {}, size: {},\n sql:{}",
, auditMessage.getElapsedTime()) auditMessage.getQueryTime(), auditMessage.getQueryCount(), auditMessage.getFullSql())
); );
} }

View File

@@ -15,7 +15,6 @@ import java.lang.annotation.Target;
* @author click33 * @author click33
* *
*/ */
@SaCheckPermission(type = "admin")
//@SaCheckPermission(type = "user") //@SaCheckPermission(type = "user")
@Retention(RetentionPolicy.RUNTIME) @Retention(RetentionPolicy.RUNTIME)
@Target({ ElementType.METHOD, ElementType.TYPE}) @Target({ ElementType.METHOD, ElementType.TYPE})
@@ -25,7 +24,6 @@ public @interface SaAdminCheckPermission {
* 需要校验的权限码 * 需要校验的权限码
* @return 需要校验的权限码 * @return 需要校验的权限码
*/ */
@AliasFor(annotation = SaCheckPermission.class)
String [] value() default {}; String [] value() default {};
String name() default ""; String name() default "";
@@ -34,7 +32,6 @@ public @interface SaAdminCheckPermission {
* 验证模式AND | OR默认AND * 验证模式AND | OR默认AND
* @return 验证模式 * @return 验证模式
*/ */
@AliasFor(annotation = SaCheckPermission.class)
SaMode mode() default SaMode.AND; SaMode mode() default SaMode.AND;
/** /**
@@ -52,7 +49,6 @@ public @interface SaAdminCheckPermission {
* *
* @return / * @return /
*/ */
@AliasFor(annotation = SaCheckPermission.class)
String[] orRole() default {}; String[] orRole() default {};
} }

View File

@@ -16,7 +16,7 @@ import java.lang.annotation.Target;
* *
*/ */
//@SaCheckRole(type = "user") //@SaCheckRole(type = "user")
@SaCheckRole(type = "admin") //@SaCheckRole(type = "admin")
@Retention(RetentionPolicy.RUNTIME) @Retention(RetentionPolicy.RUNTIME)
@Target({ ElementType.METHOD, ElementType.TYPE}) @Target({ ElementType.METHOD, ElementType.TYPE})
public @interface SaAdminCheckRole { public @interface SaAdminCheckRole {
@@ -25,14 +25,12 @@ public @interface SaAdminCheckRole {
* 需要校验的角色标识 * 需要校验的角色标识
* @return 需要校验的角色标识 * @return 需要校验的角色标识
*/ */
@AliasFor(annotation = SaCheckRole.class)
String [] value() default {}; String [] value() default {};
/** /**
* 验证模式AND | OR默认AND * 验证模式AND | OR默认AND
* @return 验证模式 * @return 验证模式
*/ */
@AliasFor(annotation = SaCheckRole.class)
SaMode mode() default SaMode.AND; SaMode mode() default SaMode.AND;
} }

View File

@@ -0,0 +1,47 @@
package com.czg.handler;
import cn.dev33.satoken.annotation.handler.SaAnnotationHandlerInterface;
import com.czg.annotation.SaAdminCheckPermission;
import com.czg.sa.StpKit;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component;
import java.lang.reflect.Method;
import cn.dev33.satoken.annotation.SaMode;
/**
* 员工权限校验
* @author Administrator
*/
@Component
@Slf4j
public class SaAdminCheckPermissionHandler implements SaAnnotationHandlerInterface<SaAdminCheckPermission> {
@Override
public Class<SaAdminCheckPermission> getHandlerAnnotationClass() {
return SaAdminCheckPermission.class;
}
@Override
public void checkMethod(SaAdminCheckPermission annotation, Method method) {
// 2⃣ 如果是管理员,直接放行
if (StpKit.USER.isAdmin()) {
log.debug("[SaAdminCheckPermissionHandler] 管理员免校验权限: userId={}", StpKit.USER.getLoginId());
return;
}
// 3⃣ 非管理员执行权限校验
String[] permissions = annotation.value();
SaMode mode = annotation.mode();
if (permissions != null && permissions.length > 0) {
if (mode == SaMode.AND) {
StpKit.USER.checkPermissionAnd(permissions);
} else {
StpKit.USER.checkPermissionOr(permissions);
}
}
log.debug("[SaAdminCheckPermissionHandler] 非管理员执行权限校验: userId={}", StpKit.USER.getLoginId());
}
}

View File

@@ -0,0 +1,62 @@
package com.czg.handler;
import cn.dev33.satoken.annotation.handler.SaAnnotationHandlerInterface;
import cn.hutool.core.util.StrUtil;
import com.czg.annotation.SaAdminCheckRole;
import com.czg.annotation.SaStaffCheckPermission;
import com.czg.sa.StpKit;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component;
import java.lang.reflect.Method;
/**
* 员工权限校验
* @author Administrator
*/
import cn.dev33.satoken.stp.StpUtil;
import cn.dev33.satoken.annotation.SaMode;
import cn.dev33.satoken.annotation.SaCheckRole;
import cn.dev33.satoken.annotation.SaCheckLogin;
import org.springframework.stereotype.Component;
import lombok.extern.slf4j.Slf4j;
import java.lang.reflect.Method;
@Component
@Slf4j
public class SaAdminCheckRoleHandler implements SaAnnotationHandlerInterface<SaAdminCheckRole> {
@Override
public Class<SaAdminCheckRole> getHandlerAnnotationClass() {
return SaAdminCheckRole.class;
}
@Override
public void checkMethod(SaAdminCheckRole annotation, Method method) {
if (StpKit.USER.isAdmin()) {
log.debug("[SaAdminCheckRoleHandler] 管理员免校验: userId={}", StpKit.USER.getLoginId());
return;
}
// 3⃣ 非管理员,执行原本注解校验逻辑
String[] roles = annotation.value();
SaMode mode = annotation.mode();
if (roles != null && roles.length > 0) {
if (mode == SaMode.AND) {
StpKit.USER.checkRoleAnd(roles);
} else {
// 有一个角色即可
StpKit.USER.checkRoleOr(roles);
}
} else {
// 如果注解没有指定角色,默认使用注解上 type 的值
// 你 @SaCheckRole(type = "admin") 默认角色
String typeRole = "admin";
StpKit.USER.checkRole(typeRole);
}
}
}

View File

@@ -0,0 +1,36 @@
package com.czg.account.dto.table;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import java.io.Serial;
import java.io.Serializable;
import java.math.BigDecimal;
/**
* 台桌配置 实体类。
*
* @author zs
* @since 2025-02-13
*/
@Data
@NoArgsConstructor
@AllArgsConstructor
public class ShopTableEditBatchDTO implements Serializable {
@Serial
private static final long serialVersionUID = 1L;
/**
* 自动清台 0手动 1自动
*/
private Integer autoClear;
/**
* 自动清台时间 单位分钟 默认10
*/
private Integer clearTime;
}

View File

@@ -126,6 +126,8 @@ public class ShopTable implements Serializable {
*/ */
private Integer useNum; private Integer useNum;
private Integer autoClear;
public boolean canUseByStatus() { public boolean canUseByStatus() {
return !ShopTableStatusEnum.UNBOUND.equalsVal(status) return !ShopTableStatusEnum.UNBOUND.equalsVal(status)
&& !ShopTableStatusEnum.SETTLED.equalsVal(status) && !ShopTableStatusEnum.SETTLED.equalsVal(status)

View File

@@ -197,6 +197,7 @@ public class AShopUserServiceImpl implements AShopUserService {
shopUserDTO.setNextExperience(config.getExperienceValue() - (shopUser.getExperience() == null ? 0 : shopUser.getExperience())); shopUserDTO.setNextExperience(config.getExperienceValue() - (shopUser.getExperience() == null ? 0 : shopUser.getExperience()));
shopUserDTO.setNextExperience(shopUserDTO.getNextExperience() < 0 ? 0: shopUserDTO.getNextExperience()); shopUserDTO.setNextExperience(shopUserDTO.getNextExperience() < 0 ? 0: shopUserDTO.getNextExperience());
shopUserDTO.setNextMemberLevelName(config.getName()); shopUserDTO.setNextMemberLevelName(config.getName());
shopUserDTO.setDiscount(config.getDiscount());
} }
return shopUserDTO; return shopUserDTO;
} }

View File

@@ -97,7 +97,7 @@ public class MemberPointsServiceImpl extends ServiceImpl<MemberPointsMapper, Mem
@Override @Override
public OrderDeductionPointsDTO getMemberUsablePoints(Long shopUserId, BigDecimal orderAmount) { public OrderDeductionPointsDTO getMemberUsablePoints(Long shopUserId, BigDecimal orderAmount) {
MemberPoints entity = initMemberPoints(shopUserId); MemberPoints entity = initMemberPoints(shopUserId);
Long shopId = entity.getSourceShopId(); Long shopId = entity.getMainShopId();
Integer accountPoints = entity.getAccountPoints(); Integer accountPoints = entity.getAccountPoints();
OrderDeductionPointsDTO dto = new OrderDeductionPointsDTO(); OrderDeductionPointsDTO dto = new OrderDeductionPointsDTO();
dto.setAccountPoints(accountPoints); dto.setAccountPoints(accountPoints);

View File

@@ -2,6 +2,7 @@ package com.czg.service.account.service.impl;
import com.czg.account.dto.ShopConfigDTO; import com.czg.account.dto.ShopConfigDTO;
import com.czg.account.entity.ShopConfig; import com.czg.account.entity.ShopConfig;
import com.czg.account.entity.ShopInfo;
import com.czg.account.service.ShopConfigService; import com.czg.account.service.ShopConfigService;
import com.czg.sa.StpKit; import com.czg.sa.StpKit;
import com.czg.service.RedisService; import com.czg.service.RedisService;
@@ -20,6 +21,8 @@ import org.springframework.stereotype.Service;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
import java.util.Set;
import java.util.stream.Collectors;
/** /**
* 店铺配置扩展 * 店铺配置扩展
@@ -59,31 +62,28 @@ public class ShopConfigServiceImpl extends ServiceImpl<ShopConfigMapper, ShopCon
shopIdList = new ArrayList<>(); shopIdList = new ArrayList<>();
} }
// 防止报错 // 防止报错
shopIdList.add(-9999L); Set<Long> childShopIdList = shopInfoMapper.selectListByQuery(new QueryWrapper().eq(ShopInfo::getMainId, mainShopId)
List<Long> extistList; .select(ShopInfo::getId)).stream().map(ShopInfo::getId).collect(Collectors.toSet());
if (!shopIdList.isEmpty()) { childShopIdList.add(mainShopId);
extistList = list(new QueryWrapper().in(ShopConfig::getId, shopIdList).select(ShopConfig::getId)).stream().map(ShopConfig::getId).toList(); List<Long> extistList = new ArrayList<>(list(new QueryWrapper().in(ShopConfig::getId, childShopIdList)).stream().map(ShopConfig::getId).toList());
shopIdList.stream().filter(id -> !extistList.contains(id)).forEach(id -> { extistList.add(mainShopId);
save(new ShopConfig().setId(id).setMainId(mainShopId).setIsEnableDiscount(0).setIsProductSuggest(0)); childShopIdList.stream().filter(id -> !extistList.contains(id)).forEach(id -> {
}); save(new ShopConfig().setId(id).setMainId(id.equals(mainShopId) ? null : mainShopId).setIsEnableDiscount(0).setIsProductSuggest(0));
} else { });
extistList = new ArrayList<>();
}
if (isEnable == 0 && !onyUpValid) { if (isEnable == 0 && !onyUpValid) {
List<Long> finalShopIdList = shopIdList;
updateChain().or(or -> { updateChain().or(or -> {
or.eq(ShopConfig::getId, mainShopId); or.eq(ShopConfig::getId, mainShopId);
}).or(or -> { }).or(or -> {
or.in(ShopConfig::getId, finalShopIdList); or.in(ShopConfig::getId, childShopIdList);
}).set(property, 0).update(); }).set(property, 0).update();
}else { }else {
if ("all".equals(useShopType)) { if ("all".equals(useShopType)) {
List<Long> finalShopIdList1 = shopIdList;
updateChain().or(or -> { updateChain().or(or -> {
or.eq(ShopConfig::getId, mainShopId); or.eq(ShopConfig::getId, mainShopId);
}).or(or -> { }).or(or -> {
or.in(ShopConfig::getId, finalShopIdList1); or.in(ShopConfig::getId, childShopIdList);
}).set(property, 1).update(); }).set(property, 1).update();
}else { }else {
if (shopIdList.isEmpty()) { if (shopIdList.isEmpty()) {

View File

@@ -20,7 +20,9 @@ import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional; import org.springframework.transaction.annotation.Transactional;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.HashSet;
import java.util.List; import java.util.List;
import java.util.stream.Collectors;
/** /**
* 店铺员工 服务层实现。 * 店铺员工 服务层实现。
@@ -121,7 +123,7 @@ public class ShopStaffServiceImpl extends ServiceImpl<ShopStaffMapper, ShopStaff
} }
private void addPermission(ShopStaff shopStaff, List<Long> shopPermissionIds) { private void addPermission(ShopStaff shopStaff, List<Long> shopPermissionIds) {
long count = shopPermissionService.queryChain().in(ShopPermission::getId, shopPermissionIds).count(); long count = shopPermissionService.queryChain().in(ShopPermission::getId, new HashSet<>(shopPermissionIds)).count();
if (count != shopPermissionIds.size()) { if (count != shopPermissionIds.size()) {
throw new ApiNotPrintException("存在不存在的权限"); throw new ApiNotPrintException("存在不存在的权限");
} }

View File

@@ -71,7 +71,7 @@ public class SysUserServiceImpl extends ServiceImpl<SysUserMapper, SysUser> impl
updateById(sysUser); updateById(sysUser);
// 绑定角色 // 绑定角色
long roleCount = sysRoleMapper.selectCountByQuery(new QueryWrapper().eq(SysRole::getId, roleId).eq(SysRole::getCreateUserId, StpKit.USER.getLoginIdAsLong())); long roleCount = sysRoleMapper.selectCountByQuery(new QueryWrapper().eq(SysRole::getId, roleId).eq(SysRole::getCreateUserId, StpKit.USER.isAdmin() ? null : StpKit.USER.getLoginIdAsLong()));
if (roleCount == 0) { if (roleCount == 0) {
throw new CzgException("角色不存在"); throw new CzgException("角色不存在");
} }

View File

@@ -5,7 +5,6 @@ import cn.hutool.core.collection.CollUtil;
import cn.hutool.core.util.StrUtil; import cn.hutool.core.util.StrUtil;
import com.alibaba.fastjson2.JSONArray; import com.alibaba.fastjson2.JSONArray;
import com.czg.account.dto.shopuser.ShopUserMoneyEditDTO; import com.czg.account.dto.shopuser.ShopUserMoneyEditDTO;
import com.czg.account.entity.ShopConfig;
import com.czg.account.entity.ShopInfo; import com.czg.account.entity.ShopInfo;
import com.czg.account.entity.ShopUser; import com.czg.account.entity.ShopUser;
import com.czg.account.service.ShopConfigService; import com.czg.account.service.ShopConfigService;
@@ -13,21 +12,20 @@ import com.czg.account.service.ShopInfoService;
import com.czg.account.service.ShopUserService; import com.czg.account.service.ShopUserService;
import com.czg.constant.TableValueConstant; import com.czg.constant.TableValueConstant;
import com.czg.enums.ShopUserFlowBizEnum; import com.czg.enums.ShopUserFlowBizEnum;
import com.czg.exception.ApiNotPrintException;
import com.czg.market.dto.MkConsumeCashbackDTO; import com.czg.market.dto.MkConsumeCashbackDTO;
import com.czg.market.dto.MkConsumeDiscountDTO; import com.czg.market.entity.MkConsumeCashback;
import com.czg.market.entity.*; import com.czg.market.entity.MkConsumeCashbackRecord;
import com.czg.market.entity.MkConsumeCashbackStep;
import com.czg.market.service.MkConsumeCashbackRecordService; import com.czg.market.service.MkConsumeCashbackRecordService;
import com.czg.market.service.MkConsumeCashbackService;
import com.czg.market.vo.MkConsumeCashbackVO; import com.czg.market.vo.MkConsumeCashbackVO;
import com.czg.order.entity.OrderInfo; import com.czg.order.entity.OrderInfo;
import com.czg.order.service.OrderInfoService; import com.czg.order.service.OrderInfoService;
import com.czg.service.market.enums.OrderStatusEnums; import com.czg.service.market.enums.OrderStatusEnums;
import com.czg.service.market.mapper.MkConsumeCashbackMapper;
import com.czg.utils.AssertUtil; import com.czg.utils.AssertUtil;
import com.mybatisflex.core.query.QueryWrapper; import com.mybatisflex.core.query.QueryWrapper;
import com.mybatisflex.core.update.UpdateWrapper;
import com.mybatisflex.spring.service.impl.ServiceImpl; import com.mybatisflex.spring.service.impl.ServiceImpl;
import com.czg.market.service.MkConsumeCashbackService;
import com.czg.service.market.mapper.MkConsumeCashbackMapper;
import jakarta.annotation.Resource; import jakarta.annotation.Resource;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.apache.dubbo.config.annotation.DubboReference; import org.apache.dubbo.config.annotation.DubboReference;
@@ -61,6 +59,7 @@ public class MkConsumeCashbackServiceImpl extends ServiceImpl<MkConsumeCashbackM
private OrderInfoService orderInfoService; private OrderInfoService orderInfoService;
@DubboReference @DubboReference
private ShopConfigService shopConfigService; private ShopConfigService shopConfigService;
BigDecimal bili = BigDecimal.valueOf(100);
@Resource @Resource
private MkConsumeCashbackRecordService consumeCashbackRecordService; private MkConsumeCashbackRecordService consumeCashbackRecordService;
@@ -125,9 +124,9 @@ public class MkConsumeCashbackServiceImpl extends ServiceImpl<MkConsumeCashbackM
ShopUser shopUser = shopUserService.getOne(new QueryWrapper().eq(ShopUser::getMainShopId, mainShopId).eq(ShopUser::getUserId, userId)); ShopUser shopUser = shopUserService.getOne(new QueryWrapper().eq(ShopUser::getMainShopId, mainShopId).eq(ShopUser::getUserId, userId));
if (StrUtil.isNotBlank(config.getApplicableUser()) && !"all".equals(config.getApplicableUser())) { if (StrUtil.isNotBlank(config.getApplicableUser()) && !"all".equals(config.getApplicableUser())) {
if ("new".equals(config.getApplicableUser())) { if ("new".equals(config.getApplicableUser())) {
long count = orderInfoService.count(new QueryWrapper().eq(OrderInfo::getUserId, shopUser.getUserId()) boolean exists = orderInfoService.exists(new QueryWrapper().eq(OrderInfo::getUserId, shopUser.getUserId())
.eq(OrderInfo::getShopId, shopUser.getSourceShopId()).eq(OrderInfo::getStatus, OrderStatusEnums.DONE)); .eq(OrderInfo::getShopId, shopId).eq(OrderInfo::getStatus, OrderStatusEnums.DONE.getCode()));
if (count > 0) { if (exists) {
return; return;
} }
} else if ("vip".equals(config.getApplicableUser()) && shopUser.getIsVip() != 1) { } else if ("vip".equals(config.getApplicableUser()) && shopUser.getIsVip() != 1) {
@@ -147,7 +146,7 @@ public class MkConsumeCashbackServiceImpl extends ServiceImpl<MkConsumeCashbackM
if (TableValueConstant.MkConsumeCashback.CashbackType.FIX.getCode().equals(config.getCashbackType())) { if (TableValueConstant.MkConsumeCashback.CashbackType.FIX.getCode().equals(config.getCashbackType())) {
cashbackAmount = cashbackStep.getCashbackAmount(); cashbackAmount = cashbackStep.getCashbackAmount();
} else { } else {
cashbackAmount = amount.multiply(cashbackStep.getCashbackAmount().divide(BigDecimal.valueOf(100), RoundingMode.DOWN)); cashbackAmount = amount.multiply(cashbackStep.getCashbackAmount().divide(bili, 2, RoundingMode.DOWN)).setScale(2, RoundingMode.DOWN);
} }
if (cashbackAmount.compareTo(BigDecimal.ZERO) <= 0) { if (cashbackAmount.compareTo(BigDecimal.ZERO) <= 0) {
return; return;
@@ -166,4 +165,11 @@ public class MkConsumeCashbackServiceImpl extends ServiceImpl<MkConsumeCashbackM
} }
} }
} }
public static void main(String[] args) {
long count = 15L;
if (count > 0) {
System.out.println(1);
}
}
} }

View File

@@ -46,7 +46,7 @@ public class MkDrainageConfigServiceImpl extends ServiceImpl<MkDrainageConfigMap
@Override @Override
public Boolean edit(Long shopId, MkDrainageConfigDTO config) { public Boolean edit(Long shopId, MkDrainageConfigDTO config) {
MkDrainageConfig info = getOne(new QueryWrapper().eq(MkDrainageConfig::getMainShopId, shopId)); MkDrainageConfig info = getOne(new QueryWrapper().eq(MkDrainageConfig::getShopId, shopId));
BeanUtil.copyProperties(config, info); BeanUtil.copyProperties(config, info);
if (config.getUseType() != null) { if (config.getUseType() != null) {
info.setUseType(JSONArray.toJSONString(config.getUseType())); info.setUseType(JSONArray.toJSONString(config.getUseType()));

View File

@@ -70,15 +70,15 @@ public class MkShopConsumeDiscountRecordServiceImpl extends ServiceImpl<MkShopCo
throw new ApiNotPrintException("随机立减配置错误"); throw new ApiNotPrintException("随机立减配置错误");
} }
ShopUser shopUser = shopUserService.getShopUserInfo(shopId, userId); ShopUser shopUser = shopUserService.getShopUserInfo(shopId, userId);
long count = orderInfoService.count(new QueryWrapper().eq(OrderInfo::getUserId, shopUser.getUserId()) boolean exists = orderInfoService.exists(new QueryWrapper().eq(OrderInfo::getUserId, shopUser.getUserId())
.eq(OrderInfo::getShopId, shopUser.getSourceShopId()).eq(OrderInfo::getStatus, OrderStatusEnums.DONE)); .eq(OrderInfo::getShopId, shopUser.getSourceShopId()).eq(OrderInfo::getStatus, OrderStatusEnums.DONE.getCode()));
AssertUtil.isTrue(count > 0, "新客立减仅限新用户使用"); AssertUtil.isTrue(exists, "新客立减仅限新用户使用");
long recordCount = count(new QueryWrapper().eq(MkShopConsumeDiscountRecord::getShopId, shopId).eq(MkShopConsumeDiscountRecord::getShopUserId, shopUser.getId()) boolean exists1 = exists(new QueryWrapper().eq(MkShopConsumeDiscountRecord::getShopId, shopId).eq(MkShopConsumeDiscountRecord::getShopUserId, shopUser.getId())
.eq(MkShopConsumeDiscountRecord::getIsUse, 1)); .eq(MkShopConsumeDiscountRecord::getIsUse, 1));
AssertUtil.isTrue(recordCount > 0, "新客立减已使用"); AssertUtil.isTrue(exists1, "新客立减已使用");
return consumeDiscountVO; return consumeDiscountVO;
} }
@@ -115,9 +115,9 @@ public class MkShopConsumeDiscountRecordServiceImpl extends ServiceImpl<MkShopCo
} }
return discountRecord; return discountRecord;
} }
long count = orderInfoService.count(new QueryWrapper().eq(OrderInfo::getUserId, shopUser.getUserId()) boolean exists = orderInfoService.exists(new QueryWrapper().eq(OrderInfo::getUserId, shopUser.getUserId())
.eq(OrderInfo::getShopId, shopUser.getSourceShopId()).eq(OrderInfo::getStatus, OrderStatusEnums.DONE)); .eq(OrderInfo::getShopId, shopUser.getSourceShopId()).eq(OrderInfo::getStatus, OrderStatusEnums.DONE.getCode()));
if (count > 0) { if (exists) {
// throw new ApiNotPrintException("新客立减仅新用户可用"); // throw new ApiNotPrintException("新客立减仅新用户可用");
log.info("新客立减仅限新用户使用"); log.info("新客立减仅限新用户使用");
return null; return null;

View File

@@ -449,7 +449,8 @@ public class MkShopCouponRecordServiceImpl extends ServiceImpl<MkShopCouponRecor
@Override @Override
public Boolean grant(Long shopId, MkRewardCouponDTO rewardCouponDTO) { public Boolean grant(Long shopId, MkRewardCouponDTO rewardCouponDTO) {
ShopUser shopUser = shopUserService.getOne(new QueryWrapper().eq(ShopUser::getSourceShopId, shopId).eq(ShopUser::getUserId, rewardCouponDTO.getUserId())); Long mainIdByShopId = shopInfoService.getMainIdByShopId(shopId);
ShopUser shopUser = shopUserService.getOne(new QueryWrapper().eq(ShopUser::getMainShopId, mainIdByShopId).eq(ShopUser::getUserId, rewardCouponDTO.getUserId()));
MkShopCouponGiftDTO giftDTO = new MkShopCouponGiftDTO().setCouponId(rewardCouponDTO.getCouponId()) MkShopCouponGiftDTO giftDTO = new MkShopCouponGiftDTO().setCouponId(rewardCouponDTO.getCouponId())
.setShopId(shopId) .setShopId(shopId)
.setSourceId(rewardCouponDTO.getUserId()) .setSourceId(rewardCouponDTO.getUserId())

View File

@@ -139,7 +139,7 @@ public class MkShopRechargeServiceImpl extends ServiceImpl<MkShopRechargeMapper,
shopRechargeDetailService.save(mkShopRechargeDetail); shopRechargeDetailService.save(mkShopRechargeDetail);
}); });
} }
shopConfigService.editStatusByShopIdList(shopId, shopRechargeDTO.getIsEnable(), false, "is_account_ay", shopConfigService.editStatusByShopIdList(shopId, shopRechargeDTO.getIsEnable(), false, "is_account_pay",
shopRechargeDTO.getUseType(), shopRechargeDTO.getShopIdList()); shopRechargeDTO.getUseType(), shopRechargeDTO.getShopIdList());

View File

@@ -112,13 +112,13 @@ public class ShopCouponServiceImpl extends ServiceImpl<ShopCouponMapper, ShopCou
if (!"all".equals(coupon.getGetUserType())) { if (!"all".equals(coupon.getGetUserType())) {
if ("new".equals(coupon.getGetUserType())) { if ("new".equals(coupon.getGetUserType())) {
isNotNewUser = false; isNotNewUser = false;
long count = orderInfoService.count(new QueryWrapper().eq(OrderInfo::getUserId, userId) boolean exists = orderInfoService.exists(new QueryWrapper().eq(OrderInfo::getUserId, userId)
.eq(OrderInfo::getShopId, shopId).eq(OrderInfo::getStatus, OrderStatusEnums.DONE)); .eq(OrderInfo::getShopId, shopId).eq(OrderInfo::getStatus, OrderStatusEnums.DONE.getCode()));
if (count > 0) { if (exists) {
continue; continue;
} }
long count1 = recordService.count(new QueryWrapper().eq(MkShopCouponRecord::getCouponSyncId, coupon.getSyncId())); boolean exists1 = recordService.exists(new QueryWrapper().eq(MkShopCouponRecord::getCouponSyncId, coupon.getSyncId()));
if (count1 > 0) { if (exists1) {
continue; continue;
} }
} else if ("vip".equals(coupon.getGetUserType()) && shopUser.getIsVip() != 1) { } else if ("vip".equals(coupon.getGetUserType()) && shopUser.getIsVip() != 1) {

View File

@@ -363,7 +363,8 @@ public class OrderInfoServiceImpl extends ServiceImpl<OrderInfoMapper, OrderInfo
param.getPointsDiscountAmount().compareTo(BigDecimal.ZERO) > 0); param.getPointsDiscountAmount().compareTo(BigDecimal.ZERO) > 0);
} }
// 积分校验 // 积分校验
PointsBasicSetting pointSetting = pointsBasicService.getById(shopId); Long mainShopId = shopInfoService.getMainIdByShopId(shopId);
PointsBasicSetting pointSetting = pointsBasicService.getById(mainShopId);
boolean usePointsDeduction = param.getPointsNum() > 0 || param.getPointsDiscountAmount().compareTo(BigDecimal.ZERO) > 0; boolean usePointsDeduction = param.getPointsNum() > 0 || param.getPointsDiscountAmount().compareTo(BigDecimal.ZERO) > 0;
if (usePointsDeduction) { if (usePointsDeduction) {
if (pointSetting == null || !pointSetting.getEnableDeduction().equals(1)) { if (pointSetting == null || !pointSetting.getEnableDeduction().equals(1)) {