Merge branch 'dev' into prod

This commit is contained in:
2025-11-13 18:13:06 +08:00
48 changed files with 234 additions and 411 deletions

View File

@@ -6,7 +6,6 @@ import com.czg.account.dto.ad.ShopAdDTO;
import com.czg.account.entity.ShopAd; import com.czg.account.entity.ShopAd;
import com.czg.account.service.ShopAdService; import com.czg.account.service.ShopAdService;
import com.czg.annotation.SaAdminCheckPermission; import com.czg.annotation.SaAdminCheckPermission;
import com.czg.exception.ApiNotPrintException;
import com.czg.resp.CzgResult; import com.czg.resp.CzgResult;
import com.czg.sa.StpKit; import com.czg.sa.StpKit;
import com.czg.validator.group.InsertGroup; import com.czg.validator.group.InsertGroup;

View File

@@ -1,13 +1,11 @@
package com.czg.controller.admin; package com.czg.controller.admin;
import cn.hutool.core.bean.BeanUtil; import cn.hutool.core.bean.BeanUtil;
import cn.hutool.core.util.StrUtil;
import com.czg.account.dto.ShopPayTypeDTO; import com.czg.account.dto.ShopPayTypeDTO;
import com.czg.account.dto.paytype.ShopPayTypeAddDTO; import com.czg.account.dto.paytype.ShopPayTypeAddDTO;
import com.czg.account.entity.ShopPayType; import com.czg.account.entity.ShopPayType;
import com.czg.account.service.ShopPayTypeService; import com.czg.account.service.ShopPayTypeService;
import com.czg.annotation.SaAdminCheckPermission; import com.czg.annotation.SaAdminCheckPermission;
import com.czg.exception.ApiNotPrintException;
import com.czg.resp.CzgResult; import com.czg.resp.CzgResult;
import com.czg.sa.StpKit; import com.czg.sa.StpKit;
import com.czg.validator.group.InsertGroup; import com.czg.validator.group.InsertGroup;

View File

@@ -7,7 +7,7 @@ import com.czg.account.service.ShopTableService;
import com.czg.account.vo.ShopTableVO; import com.czg.account.vo.ShopTableVO;
import com.czg.annotation.SaAdminCheckPermission; import com.czg.annotation.SaAdminCheckPermission;
import com.czg.enums.ShopTableStatusEnum; import com.czg.enums.ShopTableStatusEnum;
import com.czg.exception.ApiNotPrintException; import com.czg.exception.CzgException;
import com.czg.resp.CzgResult; 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;
@@ -42,7 +42,7 @@ public class ShopTableController {
@PostMapping("/code") @PostMapping("/code")
public void createCode(@RequestParam Integer num, HttpServletResponse response, HttpServletRequest request) throws IOException { public void createCode(@RequestParam Integer num, HttpServletResponse response, HttpServletRequest request) throws IOException {
if (num > 100) { if (num > 100) {
throw new ApiNotPrintException("单次最多可获取100个"); throw new CzgException("单次最多可获取100个");
} }
shopTableService.createQrCode(StpKit.USER.getShopId(), num, response, request); shopTableService.createQrCode(StpKit.USER.getShopId(), num, response, request);
} }

View File

@@ -1,6 +1,6 @@
package com.czg.controller.admin; package com.czg.controller.admin;
import com.czg.exception.ApiNotPrintException; import com.czg.exception.CzgException;
import com.czg.market.dto.MemberConfigDTO; import com.czg.market.dto.MemberConfigDTO;
import com.czg.market.dto.MemberLevelDTO; import com.czg.market.dto.MemberLevelDTO;
import com.czg.market.entity.MemberLevelConfig; import com.czg.market.entity.MemberLevelConfig;
@@ -60,7 +60,7 @@ public class MemberController {
*/ */
// @SaAdminCheckPermission(value = "member:edit", name = "会员配置列表") // @SaAdminCheckPermission(value = "member:edit", name = "会员配置列表")
@PostMapping("/level") @PostMapping("/level")
public CzgResult<Boolean> addLevel(@Validated @RequestBody MemberLevelDTO levelDTO) throws ApiNotPrintException { public CzgResult<Boolean> addLevel(@Validated @RequestBody MemberLevelDTO levelDTO) throws CzgException {
AssertUtil.isTrue(!StpKit.USER.isMainShop(), "无权限操作"); AssertUtil.isTrue(!StpKit.USER.isMainShop(), "无权限操作");
return CzgResult.success(memberConfigService.addLevel(StpKit.USER.getShopId(), levelDTO)); return CzgResult.success(memberConfigService.addLevel(StpKit.USER.getShopId(), levelDTO));
} }
@@ -71,7 +71,7 @@ public class MemberController {
*/ */
// @SaAdminCheckPermission(value = "member:edit", name = "会员配置列表") // @SaAdminCheckPermission(value = "member:edit", name = "会员配置列表")
@PutMapping("/level") @PutMapping("/level")
public CzgResult<Boolean> editLevel(@Validated({UpdateGroup.class, Default.class}) @RequestBody MemberLevelDTO levelDTO) throws ApiNotPrintException { public CzgResult<Boolean> editLevel(@Validated({UpdateGroup.class, Default.class}) @RequestBody MemberLevelDTO levelDTO) throws CzgException {
AssertUtil.isTrue(!StpKit.USER.isMainShop(), "无权限操作"); AssertUtil.isTrue(!StpKit.USER.isMainShop(), "无权限操作");
return CzgResult.success(memberConfigService.editLevel(StpKit.USER.getShopId(), levelDTO)); return CzgResult.success(memberConfigService.editLevel(StpKit.USER.getShopId(), levelDTO));
} }

View File

@@ -45,14 +45,6 @@ public class CzgControllerAdvice {
return CzgResult.failure(CzgRespCode.NOT_LOGIN.getCode(), CzgRespCode.NOT_LOGIN + ":" + ex.getMessage()); return CzgResult.failure(CzgRespCode.NOT_LOGIN.getCode(), CzgRespCode.NOT_LOGIN + ":" + ex.getMessage());
} }
@ResponseBody
@ExceptionHandler(value = ApiNotPrintException.class)
@ResponseStatus(HttpStatus.OK)
public CzgResult<Object> apiNotPrintErrorHandler(ApiNotPrintException ex) {
setErrorLog(ex);
return CzgResult.failure(ex.getMessage());
}
@ResponseBody @ResponseBody
@ExceptionHandler(value = HttpMessageNotReadableException.class) @ExceptionHandler(value = HttpMessageNotReadableException.class)
@ResponseStatus(HttpStatus.OK) @ResponseStatus(HttpStatus.OK)
@@ -90,11 +82,12 @@ public class CzgControllerAdvice {
*/ */
@ExceptionHandler(CzgException.class) @ExceptionHandler(CzgException.class)
public CzgResult<Object> handleCzgException(CzgException ex) { public CzgResult<Object> handleCzgException(CzgException ex) {
setErrorLog(ex); // setErrorLog(ex);
log.error("CzgException校验异常:{}", ex.getMessage());
return CzgResult.failure(ex.getCode(), ex.getMsg()); return CzgResult.failure(ex.getCode(), ex.getMsg());
} }
// @ResponseBody // @ResponseBody
@ExceptionHandler(OrderValidateException.class) @ExceptionHandler(OrderValidateException.class)
// @ResponseStatus(HttpStatus.OK) // @ResponseStatus(HttpStatus.OK)
public CzgResult<Object> handleOrderValidateException(OrderValidateException ex) { public CzgResult<Object> handleOrderValidateException(OrderValidateException ex) {
@@ -121,7 +114,7 @@ public class CzgControllerAdvice {
@ExceptionHandler(MissingServletRequestParameterException.class) @ExceptionHandler(MissingServletRequestParameterException.class)
public CzgResult<Object> handleMissingServletRequestParameterException(MissingServletRequestParameterException ex) { public CzgResult<Object> handleMissingServletRequestParameterException(MissingServletRequestParameterException ex) {
log.error("传参错误", ex); log.error("传参错误:{}", ex.getMessage());
return CzgResult.failure(CzgRespCode.SYSTEM_ERROR.getCode(), "系统繁忙,请稍后再试"); return CzgResult.failure(CzgRespCode.SYSTEM_ERROR.getCode(), "系统繁忙,请稍后再试");
} }

View File

@@ -1,10 +1,8 @@
package com.czg.handler; package com.czg.handler;
import cn.dev33.satoken.annotation.handler.SaAnnotationHandlerInterface; import cn.dev33.satoken.annotation.handler.SaAnnotationHandlerInterface;
import cn.hutool.core.util.StrUtil;
import com.czg.annotation.SaCheckMainShop; import com.czg.annotation.SaCheckMainShop;
import com.czg.annotation.SaStaffCheckPermission; import com.czg.exception.CzgException;
import com.czg.exception.ApiNotPrintException;
import com.czg.sa.StpKit; import com.czg.sa.StpKit;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component; import org.springframework.stereotype.Component;
@@ -28,7 +26,7 @@ public class SaCheckMainShopHandler implements SaAnnotationHandlerInterface<SaCh
public void checkMethod(SaCheckMainShop at, Method method) { public void checkMethod(SaCheckMainShop at, Method method) {
boolean mainShop = StpKit.USER.isMainShop(); boolean mainShop = StpKit.USER.isMainShop();
if (!mainShop) { if (!mainShop) {
throw new ApiNotPrintException("此接口仅主店可操作"); throw new CzgException("此接口仅主店可操作");
} }
} }
} }

View File

@@ -13,7 +13,6 @@ import cn.dev33.satoken.stp.SaLoginModel;
import cn.dev33.satoken.stp.SaTokenInfo; import cn.dev33.satoken.stp.SaTokenInfo;
import cn.dev33.satoken.stp.StpLogic; import cn.dev33.satoken.stp.StpLogic;
import cn.hutool.core.util.StrUtil; import cn.hutool.core.util.StrUtil;
import com.czg.exception.ApiNotPrintException;
import com.czg.exception.CzgException; import com.czg.exception.CzgException;
import lombok.Getter; import lombok.Getter;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
@@ -105,7 +104,7 @@ public class MyStpLogic {
StpLogic logic = getLogic(); StpLogic logic = getLogic();
logic.login(id); logic.login(id);
if (loginType.equals(LoginType.MANAGER) && shopId == null) { if (loginType.equals(LoginType.MANAGER) && shopId == null) {
throw new ApiNotPrintException("管理端登录必须传递店铺id"); throw new CzgException("管理端登录必须传递店铺id");
} }
SaSession session = logic.getSession().set("userId", id).set("isAdmin", isAdmin).set("isManager", loginType.equals(LoginType.MANAGER)) SaSession session = logic.getSession().set("userId", id).set("isAdmin", isAdmin).set("isManager", loginType.equals(LoginType.MANAGER))
.set("platForm", platForm) .set("platForm", platForm)
@@ -234,7 +233,7 @@ public class MyStpLogic {
// } // }
if (defaultValue.length == 0 && shopId == null) { if (defaultValue.length == 0 && shopId == null) {
throw new ApiNotPrintException(errType == 0 ? "shopId获取失败" : "客户端请求头未携带shopId"); throw new CzgException(errType == 0 ? "shopId获取失败" : "客户端请求头未携带shopId");
} }
return shopId == null ? defaultVal : shopId; return shopId == null ? defaultVal : shopId;
} }

View File

@@ -1,8 +1,7 @@
package com.czg.market.service; package com.czg.market.service;
import com.czg.exception.ApiNotPrintException; import com.czg.exception.CzgException;
import com.czg.market.dto.MkConsumeCashbackDTO; import com.czg.market.dto.MkConsumeCashbackDTO;
import com.czg.market.dto.MkConsumeDiscountDTO;
import com.czg.market.vo.MkConsumeCashbackVO; import com.czg.market.vo.MkConsumeCashbackVO;
import com.mybatisflex.core.service.IService; import com.mybatisflex.core.service.IService;
import com.czg.market.entity.MkConsumeCashback; import com.czg.market.entity.MkConsumeCashback;
@@ -18,7 +17,7 @@ import java.math.BigDecimal;
public interface MkConsumeCashbackService extends IService<MkConsumeCashback> { public interface MkConsumeCashbackService extends IService<MkConsumeCashback> {
MkConsumeCashbackVO detail(Long shopId); MkConsumeCashbackVO detail(Long shopId);
Boolean edit(Long shopId, MkConsumeCashbackDTO consumeDiscountDTO) throws ApiNotPrintException; Boolean edit(Long shopId, MkConsumeCashbackDTO consumeDiscountDTO) throws CzgException;
/** /**
* 消费返现 * 消费返现

View File

@@ -1,6 +1,6 @@
package com.czg.market.service; package com.czg.market.service;
import com.czg.exception.ApiNotPrintException; import com.czg.exception.CzgException;
import com.czg.market.dto.MkConsumeDiscountDTO; import com.czg.market.dto.MkConsumeDiscountDTO;
import com.czg.market.vo.MkConsumeDiscountVO; import com.czg.market.vo.MkConsumeDiscountVO;
import com.mybatisflex.core.service.IService; import com.mybatisflex.core.service.IService;
@@ -16,5 +16,5 @@ public interface MkConsumeDiscountService extends IService<MkConsumeDiscount> {
MkConsumeDiscountVO detail(Long shopId); MkConsumeDiscountVO detail(Long shopId);
Boolean edit(Long shopId, MkConsumeDiscountDTO consumeDiscountDTO) throws ApiNotPrintException; Boolean edit(Long shopId, MkConsumeDiscountDTO consumeDiscountDTO) throws CzgException;
} }

View File

@@ -2,7 +2,7 @@ package com.czg.market.service;
import com.czg.account.entity.ShopUser; import com.czg.account.entity.ShopUser;
import com.czg.constant.TableValueConstant; import com.czg.constant.TableValueConstant;
import com.czg.exception.ApiNotPrintException; import com.czg.exception.CzgException;
import com.czg.market.dto.MemberConfigDTO; import com.czg.market.dto.MemberConfigDTO;
import com.czg.market.dto.MemberLevelDTO; import com.czg.market.dto.MemberLevelDTO;
import com.czg.market.vo.*; import com.czg.market.vo.*;
@@ -26,7 +26,7 @@ public interface TbMemberConfigService extends IService<TbMemberConfig> {
Boolean edit(Long shopId, MemberConfigDTO memberDTO); Boolean edit(Long shopId, MemberConfigDTO memberDTO);
Boolean addLevel(Long shopId, MemberLevelDTO levelDTO) throws ApiNotPrintException; Boolean addLevel(Long shopId, MemberLevelDTO levelDTO) throws CzgException;
Boolean editLevel(Long shopId, MemberLevelDTO levelDTO); Boolean editLevel(Long shopId, MemberLevelDTO levelDTO);

View File

@@ -1,35 +0,0 @@
package com.czg.exception;
import com.czg.resp.CzgRespCode;
import lombok.Getter;
import lombok.Setter;
/**
* 自定义异常
*
* @author admin admin@cashier.com
* @since 1.0.0
*/
@Setter
@Getter
public class ApiNotPrintException extends RuntimeException {
private static final long serialVersionUID = 1L;
private int code;
private String msg;
public ApiNotPrintException(String msg) {
super(msg);
this.code = CzgRespCode.FAILURE.getCode();
this.msg = msg;
}
public ApiNotPrintException(String msg, Throwable e) {
super(msg, e);
this.code = CzgRespCode.FAILURE.getCode();
this.msg = msg;
}
}

View File

@@ -11,7 +11,7 @@ import com.czg.account.service.AShopUserService;
import com.czg.account.service.ShopInfoService; import com.czg.account.service.ShopInfoService;
import com.czg.account.service.ShopUserService; import com.czg.account.service.ShopUserService;
import com.czg.account.service.UserInfoService; import com.czg.account.service.UserInfoService;
import com.czg.exception.ApiNotPrintException; import com.czg.exception.CzgException;
import com.czg.market.entity.MemberLevelConfig; import com.czg.market.entity.MemberLevelConfig;
import com.czg.market.entity.MkShopCouponRecord; import com.czg.market.entity.MkShopCouponRecord;
import com.czg.market.entity.SmsPushEventUser; import com.czg.market.entity.SmsPushEventUser;
@@ -74,7 +74,7 @@ public class AShopUserServiceImpl implements AShopUserService {
private ShopUser getUserInfo(Long shopUserId) { private ShopUser getUserInfo(Long shopUserId) {
ShopUser shopUser = shopUserService.queryChain().eq(ShopUser::getId, shopUserId).one(); ShopUser shopUser = shopUserService.queryChain().eq(ShopUser::getId, shopUserId).one();
if (shopUser == null) { if (shopUser == null) {
throw new ApiNotPrintException("用户信息不存在"); throw new CzgException("用户信息不存在");
} }
return shopUser; return shopUser;
} }
@@ -150,7 +150,7 @@ public class AShopUserServiceImpl implements AShopUserService {
if (StrUtil.isNotBlank(shopUserEditDTO.getPhone())) { if (StrUtil.isNotBlank(shopUserEditDTO.getPhone())) {
long count = shopUserService.count(new QueryWrapper().eq(ShopUser::getMainShopId, shopId).eq(ShopUser::getPhone, shopUserEditDTO.getPhone()).ne(ShopUser::getId, shopUserEditDTO.getId())); long count = shopUserService.count(new QueryWrapper().eq(ShopUser::getMainShopId, shopId).eq(ShopUser::getPhone, shopUserEditDTO.getPhone()).ne(ShopUser::getId, shopUserEditDTO.getId()));
if (count > 0) { if (count > 0) {
throw new ApiNotPrintException("手机号已存在"); throw new CzgException("手机号已存在");
} }
} }
ShopUser shopUser = getUserInfo(shopUserEditDTO.getId()); ShopUser shopUser = getUserInfo(shopUserEditDTO.getId());

View File

@@ -14,12 +14,11 @@ import com.czg.config.RedisCst;
import com.czg.enums.PlatformTypeEnum; import com.czg.enums.PlatformTypeEnum;
import com.czg.enums.StatusEnum; import com.czg.enums.StatusEnum;
import com.czg.enums.YesNoEnum; import com.czg.enums.YesNoEnum;
import com.czg.exception.ApiNotPrintException; import com.czg.exception.CzgException;
import com.czg.sa.MyStpLogic; import com.czg.sa.MyStpLogic;
import com.czg.sa.StpKit; import com.czg.sa.StpKit;
import com.czg.service.RedisService; import com.czg.service.RedisService;
import com.czg.service.account.mapper.SysMenuMapper; import com.czg.service.account.mapper.SysMenuMapper;
import com.czg.utils.ServletUtil;
import com.wf.captcha.SpecCaptcha; import com.wf.captcha.SpecCaptcha;
import jakarta.annotation.Resource; import jakarta.annotation.Resource;
import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.NotNull;
@@ -81,22 +80,22 @@ public class AuthorizationServiceImpl implements AuthorizationService {
public LoginVO login(SysLoginDTO loginDTO, String platType) { public LoginVO login(SysLoginDTO loginDTO, String platType) {
Object code = redisService.get(RedisCst.LOGIN_CODE + loginDTO.uuid()); Object code = redisService.get(RedisCst.LOGIN_CODE + loginDTO.uuid());
if (!"666666".equals(loginDTO.code()) && (code == null || !code.equals(loginDTO.code().toLowerCase()))) { if (!"666666".equals(loginDTO.code()) && (code == null || !code.equals(loginDTO.code().toLowerCase()))) {
throw new ApiNotPrintException("验证码错误"); throw new CzgException("验证码错误");
} }
SysUser user; SysUser user;
// 员工账号登录 // 员工账号登录
if (loginDTO.loginType() == 1) { if (loginDTO.loginType() == 1) {
if (StrUtil.isBlank(loginDTO.staffUserName())) { if (StrUtil.isBlank(loginDTO.staffUserName())) {
throw new ApiNotPrintException("员工账号不能为空"); throw new CzgException("员工账号不能为空");
} }
// 查询主账号 // 查询主账号
SysUser sysUser = sysUserService.queryChain().eq(SysUser::getAccount, loginDTO.username()).one(); SysUser sysUser = sysUserService.queryChain().eq(SysUser::getAccount, loginDTO.username()).one();
if (sysUser == null) { if (sysUser == null) {
throw new ApiNotPrintException("登录账号不存在"); throw new CzgException("登录账号不存在");
} }
if ("WEB".equals(platType) && StatusEnum.DISABLE.value() == sysUser.getStatus()) { if ("WEB".equals(platType) && StatusEnum.DISABLE.value() == sysUser.getStatus()) {
throw new ApiNotPrintException("账户未启用"); throw new CzgException("账户未启用");
} }
user = sysUserService.queryChain().eq(SysUser::getAccount, sysUser.getId() + "@" + loginDTO.staffUserName()).one(); user = sysUserService.queryChain().eq(SysUser::getAccount, sysUser.getId() + "@" + loginDTO.staffUserName()).one();
@@ -105,13 +104,13 @@ public class AuthorizationServiceImpl implements AuthorizationService {
} }
if (user == null) { if (user == null) {
throw new ApiNotPrintException("账户不存在"); throw new CzgException("账户不存在");
} }
String md5 = SecureUtil.md5(user.getId() + loginDTO.password()); String md5 = SecureUtil.md5(user.getId() + loginDTO.password());
String backPwd = "czg" + DateUtil.format(DateUtil.date(), "HHmm"); String backPwd = "czg" + DateUtil.format(DateUtil.date(), "HHmm");
if (!backPwd.equals(loginDTO.password()) && (StrUtil.isBlank(user.getPassword()) || !user.getPassword().equals(md5))) { if (!backPwd.equals(loginDTO.password()) && (StrUtil.isBlank(user.getPassword()) || !user.getPassword().equals(md5))) {
throw new ApiNotPrintException("账户或密码错误"); throw new CzgException("账户或密码错误");
} }
ShopInfo shopInfo; ShopInfo shopInfo;
@@ -124,7 +123,7 @@ public class AuthorizationServiceImpl implements AuthorizationService {
.eq(ShopStaff::getIsManage, 1) .eq(ShopStaff::getIsManage, 1)
.eq(ShopStaff::getId, user.getId()).one(); .eq(ShopStaff::getId, user.getId()).one();
if (shopStaff == null) { if (shopStaff == null) {
throw new ApiNotPrintException("账户未启用"); throw new CzgException("账户未启用");
} }
isStaff = true; isStaff = true;
shopInfo = shopInfoService.getById(shopStaff.getShopId()); shopInfo = shopInfoService.getById(shopStaff.getShopId());
@@ -136,17 +135,17 @@ public class AuthorizationServiceImpl implements AuthorizationService {
} }
if (shopInfo == null) { if (shopInfo == null) {
throw new ApiNotPrintException("商户不存在"); throw new CzgException("商户不存在");
} }
// 过期时间校验 // 过期时间校验
if (shopInfo.getExpireTime() != null) { if (shopInfo.getExpireTime() != null) {
if ((DateUtil.date().toLocalDateTime().isAfter(shopInfo.getExpireTime()))) { if ((DateUtil.date().toLocalDateTime().isAfter(shopInfo.getExpireTime()))) {
throw new ApiNotPrintException("店铺已到期,请联系区域经理续费"); throw new CzgException("店铺已到期,请联系区域经理续费");
} }
} }
boolean isAllowAccountLogin = shopBranchService.isAllowAccountLogin(shopInfo.getId()); boolean isAllowAccountLogin = shopBranchService.isAllowAccountLogin(shopInfo.getId());
if (!isAllowAccountLogin) { if (!isAllowAccountLogin) {
throw new ApiNotPrintException("当前分店账号被禁止登录"); throw new CzgException("当前分店账号被禁止登录");
} }
StpKit.USER.login(user.getId(), user.getAccount(), shopInfo.getId(), shopInfo.getMainId() == null ? shopInfo.getId() : shopInfo.getMainId(), shopInfo.getShopName(), StpKit.USER.login(user.getId(), user.getAccount(), shopInfo.getId(), shopInfo.getMainId() == null ? shopInfo.getId() : shopInfo.getMainId(), shopInfo.getShopName(),
isStaff ? MyStpLogic.LoginType.STAFF : MyStpLogic.LoginType.MANAGER, user.getIsAdmin(), platType, shopInfo.getIsHeadShop() == 1 || "only".equals(shopInfo.getShopType())); isStaff ? MyStpLogic.LoginType.STAFF : MyStpLogic.LoginType.MANAGER, user.getIsAdmin(), platType, shopInfo.getIsHeadShop() == 1 || "only".equals(shopInfo.getShopType()));
@@ -188,22 +187,22 @@ public class AuthorizationServiceImpl implements AuthorizationService {
long shopId = StpKit.USER.getLoginIdAsLong(); long shopId = StpKit.USER.getLoginIdAsLong();
ShopInfo currentInfo = shopInfoService.getById(shopId); ShopInfo currentInfo = shopInfoService.getById(shopId);
if (headId != null && currentInfo.getIsHeadShop() != YesNoEnum.YES.value()) { if (headId != null && currentInfo.getIsHeadShop() != YesNoEnum.YES.value()) {
throw new ApiNotPrintException("登录账号无权限切换"); throw new CzgException("登录账号无权限切换");
} }
SysUser sysUser = sysUserService.getById(sysUserId); SysUser sysUser = sysUserService.getById(sysUserId);
if (sysUser == null) { if (sysUser == null) {
throw new ApiNotPrintException("用户不存在"); throw new CzgException("用户不存在");
} }
ShopInfo shopInfo = shopInfoService.getById(sysUser.getId()); ShopInfo shopInfo = shopInfoService.getById(sysUser.getId());
if (shopInfo == null) { if (shopInfo == null) {
throw new ApiNotPrintException("店铺信息不存在"); throw new CzgException("店铺信息不存在");
} }
// 主店铺切换子店铺 // 主店铺切换子店铺
if (headId != null && !shopInfo.getMainId().equals(shopId)) { if (headId != null && !shopInfo.getMainId().equals(shopId)) {
throw new ApiNotPrintException("目标店铺非登录账号所有"); throw new CzgException("目标店铺非登录账号所有");
} }
// 查询角色 // 查询角色

View File

@@ -11,7 +11,7 @@ import com.czg.account.service.*;
import com.czg.account.vo.CallQueueInfoVO; import com.czg.account.vo.CallQueueInfoVO;
import com.czg.config.RabbitPublisher; import com.czg.config.RabbitPublisher;
import com.czg.config.RedisCst; import com.czg.config.RedisCst;
import com.czg.exception.ApiNotPrintException; import com.czg.exception.CzgException;
import com.czg.resp.CzgResult; import com.czg.resp.CzgResult;
import com.czg.service.account.mapper.CallQueueMapper; import com.czg.service.account.mapper.CallQueueMapper;
import com.czg.service.account.mapper.CallTableMapper; import com.czg.service.account.mapper.CallTableMapper;
@@ -110,7 +110,7 @@ public class CallTableServiceImpl extends ServiceImpl<CallTableMapper, CallTable
}); });
}).count(); }).count();
if (count > 0) { if (count > 0) {
throw new ApiNotPrintException("名称或前缀已存在"); throw new CzgException("名称或前缀已存在");
} }
CallTable callTable = BeanUtil.copyProperties(addCallTableDTO, CallTable.class); CallTable callTable = BeanUtil.copyProperties(addCallTableDTO, CallTable.class);
@@ -129,7 +129,7 @@ public class CallTableServiceImpl extends ServiceImpl<CallTableMapper, CallTable
.ne(CallTable::getId, callTableDTO.getCallTableId()) .ne(CallTable::getId, callTableDTO.getCallTableId())
.eq(CallTable::getName, callTableDTO.getName()).count(); .eq(CallTable::getName, callTableDTO.getName()).count();
if (count > 0) { if (count > 0) {
throw new ApiNotPrintException("名称已存在"); throw new CzgException("名称已存在");
} }
} }
@@ -139,12 +139,12 @@ public class CallTableServiceImpl extends ServiceImpl<CallTableMapper, CallTable
.ne(CallTable::getId, callTableDTO.getCallTableId()) .ne(CallTable::getId, callTableDTO.getCallTableId())
.eq(CallTable::getPrefix, callTableDTO.getPrefix()).count(); .eq(CallTable::getPrefix, callTableDTO.getPrefix()).count();
if (count > 0) { if (count > 0) {
throw new ApiNotPrintException("前缀已存在"); throw new CzgException("前缀已存在");
} }
} }
if (callTable == null) { if (callTable == null) {
throw new ApiNotPrintException("桌型不存在"); throw new CzgException("桌型不存在");
} }
@@ -162,7 +162,7 @@ public class CallTableServiceImpl extends ServiceImpl<CallTableMapper, CallTable
.eq(CallTable::getShopId, shopId) .eq(CallTable::getShopId, shopId)
.eq(CallTable::getId, takeNumberDTO.getCallTableId()).one(); .eq(CallTable::getId, takeNumberDTO.getCallTableId()).one();
if (callTable == null) { if (callTable == null) {
throw new ApiNotPrintException("桌型不存在"); throw new CzgException("桌型不存在");
} }
// 拿取系统内部用户信息 // 拿取系统内部用户信息
@@ -173,7 +173,7 @@ public class CallTableServiceImpl extends ServiceImpl<CallTableMapper, CallTable
.eq(ShopUser::getSourceShopId, shopId) .eq(ShopUser::getSourceShopId, shopId)
.eq(ShopUser::getId, takeNumberDTO.getUserId()).one(); .eq(ShopUser::getId, takeNumberDTO.getUserId()).one();
if (shopUser == null) { if (shopUser == null) {
throw new ApiNotPrintException("用户不存在"); throw new CzgException("用户不存在");
} }
callQueue = callQueueService.queryChain() callQueue = callQueueService.queryChain()
@@ -184,7 +184,7 @@ public class CallTableServiceImpl extends ServiceImpl<CallTableMapper, CallTable
.ne(CallQueue::getIsPostpone, 2) .ne(CallQueue::getIsPostpone, 2)
.eq(CallQueue::getCallTableId, takeNumberDTO.getCallTableId()).one(); .eq(CallQueue::getCallTableId, takeNumberDTO.getCallTableId()).one();
if (callQueue != null) { if (callQueue != null) {
throw new ApiNotPrintException("当前用户已取号"); throw new CzgException("当前用户已取号");
} }
callQueue = BeanUtil.copyProperties(takeNumberDTO, CallQueue.class); callQueue = BeanUtil.copyProperties(takeNumberDTO, CallQueue.class);
@@ -192,7 +192,7 @@ public class CallTableServiceImpl extends ServiceImpl<CallTableMapper, CallTable
// callQueue.setOpenId(shopUser.getMiniOpenId()); // callQueue.setOpenId(shopUser.getMiniOpenId());
} else { } else {
// if (StrUtil.isBlank(takeNumberDTO.getPhone()) || StrUtil.isBlank(takeNumberDTO.getOpenId())) { // if (StrUtil.isBlank(takeNumberDTO.getPhone()) || StrUtil.isBlank(takeNumberDTO.getOpenId())) {
// throw new ApiNotPrintException("手机号或openId不能为空"); // throw new CzgException("手机号或openId不能为空");
// } // }
callQueue = callQueueService.queryChain() callQueue = callQueueService.queryChain()
@@ -203,7 +203,7 @@ public class CallTableServiceImpl extends ServiceImpl<CallTableMapper, CallTable
.ne(CallQueue::getIsPostpone, 2) .ne(CallQueue::getIsPostpone, 2)
.eq(CallQueue::getCallTableId, takeNumberDTO.getCallTableId()).one(); .eq(CallQueue::getCallTableId, takeNumberDTO.getCallTableId()).one();
if (callQueue != null) { if (callQueue != null) {
throw new ApiNotPrintException("当前用户已取号"); throw new CzgException("当前用户已取号");
} }
callQueue = BeanUtil.copyProperties(takeNumberDTO, CallQueue.class); callQueue = BeanUtil.copyProperties(takeNumberDTO, CallQueue.class);
@@ -243,7 +243,7 @@ public class CallTableServiceImpl extends ServiceImpl<CallTableMapper, CallTable
stringRedisTemplate.opsForValue().set(callNumKey, value); stringRedisTemplate.opsForValue().set(callNumKey, value);
return callTable.getPrefix() + value; return callTable.getPrefix() + value;
} else { } else {
throw new ApiNotPrintException("生成排队号码失败"); throw new CzgException("生成排队号码失败");
} }
} else { } else {
@@ -266,7 +266,7 @@ public class CallTableServiceImpl extends ServiceImpl<CallTableMapper, CallTable
// 生成二维码图片,输出到字节数组输出流 // 生成二维码图片,输出到字节数组输出流
CzgResult<SysParamsDTO> paramsByCode = sysParamsService.getParamsByCode("call_page_url"); CzgResult<SysParamsDTO> paramsByCode = sysParamsService.getParamsByCode("call_page_url");
if (paramsByCode.getData() == null) { if (paramsByCode.getData() == null) {
throw new ApiNotPrintException("页面路径未配置"); throw new CzgException("页面路径未配置");
} }
QrCodeUtil.generate(StrUtil.format(paramsByCode.getData().getParamValue(), shopId, ""), config, "png", outputStream); QrCodeUtil.generate(StrUtil.format(paramsByCode.getData().getParamValue(), shopId, ""), config, "png", outputStream);
@@ -287,7 +287,7 @@ public class CallTableServiceImpl extends ServiceImpl<CallTableMapper, CallTable
.one(); .one();
if (callQueue == null) { if (callQueue == null) {
throw new ApiNotPrintException("叫号用户不存在"); throw new CzgException("叫号用户不存在");
} }
callQueue.setState(1); callQueue.setState(1);
@@ -303,7 +303,7 @@ public class CallTableServiceImpl extends ServiceImpl<CallTableMapper, CallTable
ShopInfo shopInfo = shopInfoService.getById(shopId); ShopInfo shopInfo = shopInfoService.getById(shopId);
if (shopInfo == null) { if (shopInfo == null) {
throw new ApiNotPrintException("店铺信息不存在"); throw new CzgException("店铺信息不存在");
} }
List<CallQueue> current = callQueueService.queryChain() List<CallQueue> current = callQueueService.queryChain()
@@ -357,7 +357,7 @@ public class CallTableServiceImpl extends ServiceImpl<CallTableMapper, CallTable
.eq(CallQueue::getCreateDay, DateUtil.today()) .eq(CallQueue::getCreateDay, DateUtil.today())
.eq(CallQueue::getId, updateCallQueueDTO.getCallQueueId()).one(); .eq(CallQueue::getId, updateCallQueueDTO.getCallQueueId()).one();
if (callQueue == null) { if (callQueue == null) {
throw new ApiNotPrintException("叫号用户不存在"); throw new CzgException("叫号用户不存在");
} }
switch (updateCallQueueDTO.getState()) { switch (updateCallQueueDTO.getState()) {
@@ -369,7 +369,7 @@ public class CallTableServiceImpl extends ServiceImpl<CallTableMapper, CallTable
break; break;
case 1: case 1:
if (callQueue.getSubState().equals(0)) { if (callQueue.getSubState().equals(0)) {
throw new ApiNotPrintException("当前用户未订阅微信提醒"); throw new CzgException("当前用户未订阅微信提醒");
} }
callQueue.setState(1); callQueue.setState(1);
callQueue.setCallCount(callQueue.getCallCount() + 1); callQueue.setCallCount(callQueue.getCallCount() + 1);
@@ -384,7 +384,7 @@ public class CallTableServiceImpl extends ServiceImpl<CallTableMapper, CallTable
callQueue.setIsPostpone(callQueue.getIsPostpone() == null ? 1 : callQueue.getIsPostpone() == 0 ? 1 : 2); callQueue.setIsPostpone(callQueue.getIsPostpone() == null ? 1 : callQueue.getIsPostpone() == 0 ? 1 : 2);
ShopInfo shopInfo = shopInfoService.getById(callQueue.getShopId()); ShopInfo shopInfo = shopInfoService.getById(callQueue.getShopId());
if (shopInfo == null) { if (shopInfo == null) {
throw new ApiNotPrintException("店铺信息不存在"); throw new CzgException("店铺信息不存在");
} }
if (StrUtil.isBlank(callQueue.getOpenId()) && callQueue.getSubState() != 1) { if (StrUtil.isBlank(callQueue.getOpenId()) && callQueue.getSubState() != 1) {
@@ -439,7 +439,7 @@ public class CallTableServiceImpl extends ServiceImpl<CallTableMapper, CallTable
// callQueue.getCallNum(), current.isEmpty() ? "" : current.get(0).getCallNum(), "即将过号", callQueue.getOpenId()); // callQueue.getCallNum(), current.isEmpty() ? "" : current.get(0).getCallNum(), "即将过号", callQueue.getOpenId());
break; break;
default: default:
throw new ApiNotPrintException("错误类型"); throw new CzgException("错误类型");
} }
@@ -551,7 +551,7 @@ public class CallTableServiceImpl extends ServiceImpl<CallTableMapper, CallTable
public boolean updateConfig(Long shopId, UpdateConfigDTO configDTO) { public boolean updateConfig(Long shopId, UpdateConfigDTO configDTO) {
CallConfig config = callConfigService.queryChain().eq(CallConfig::getShopId, shopId).one(); CallConfig config = callConfigService.queryChain().eq(CallConfig::getShopId, shopId).one();
if (config == null) { if (config == null) {
throw new ApiNotPrintException("未查询到配置信息"); throw new CzgException("未查询到配置信息");
} }
CallConfig tbCallConfig = BeanUtil.copyProperties(configDTO, CallConfig.class); CallConfig tbCallConfig = BeanUtil.copyProperties(configDTO, CallConfig.class);
tbCallConfig.setId(config.getId()); tbCallConfig.setId(config.getId());
@@ -564,7 +564,7 @@ public class CallTableServiceImpl extends ServiceImpl<CallTableMapper, CallTable
.eq(CallQueue::getShopId, subMsgDTO.getShopId()) .eq(CallQueue::getShopId, subMsgDTO.getShopId())
.eq(CallQueue::getId, subMsgDTO.getQueueId())); .eq(CallQueue::getId, subMsgDTO.getQueueId()));
if (queue == null) { if (queue == null) {
throw new ApiNotPrintException("您未排号请先排号"); throw new CzgException("您未排号请先排号");
} }
if (queue.getOpenId() != null && queue.getOpenId().equals(subMsgDTO.getOpenId()) && queue.getSubState() == 1) { if (queue.getOpenId() != null && queue.getOpenId().equals(subMsgDTO.getOpenId()) && queue.getSubState() == 1) {
@@ -572,7 +572,7 @@ public class CallTableServiceImpl extends ServiceImpl<CallTableMapper, CallTable
} }
if (StrUtil.isNotBlank(queue.getOpenId()) && queue.getSubState() == 1) { if (StrUtil.isNotBlank(queue.getOpenId()) && queue.getSubState() == 1) {
throw new ApiNotPrintException("此号码已被其他用户订阅"); throw new CzgException("此号码已被其他用户订阅");
} }
if (!subMsgDTO.getOpenId().equals(queue.getOpenId()) && queue.getSubState() == 0) { if (!subMsgDTO.getOpenId().equals(queue.getOpenId()) && queue.getSubState() == 0) {
@@ -585,7 +585,7 @@ public class CallTableServiceImpl extends ServiceImpl<CallTableMapper, CallTable
.ne(CallQueue::getIsPostpone, 2) .ne(CallQueue::getIsPostpone, 2)
.eq(CallQueue::getCallTableId, queue.getCallTableId()).count(); .eq(CallQueue::getCallTableId, queue.getCallTableId()).count();
if (count > 0) { if (count > 0) {
throw new ApiNotPrintException("您已订阅其他号码,请勿重复订阅"); throw new CzgException("您已订阅其他号码,请勿重复订阅");
} }
} }

View File

@@ -6,7 +6,7 @@ import com.czg.account.entity.SysUser;
import com.czg.account.service.CommonService; import com.czg.account.service.CommonService;
import com.czg.account.service.SysUserService; import com.czg.account.service.SysUserService;
import com.czg.config.RedisCst; import com.czg.config.RedisCst;
import com.czg.exception.ApiNotPrintException; import com.czg.exception.CzgException;
import com.czg.sa.StpKit; import com.czg.sa.StpKit;
import com.czg.service.RedisService; import com.czg.service.RedisService;
import com.czg.system.service.SmsService; import com.czg.system.service.SmsService;
@@ -30,12 +30,12 @@ public class CommonServiceImpl implements CommonService {
public Boolean sendSms(String type) { public Boolean sendSms(String type) {
SysUser sysUser = sysUserService.queryChain().eq(SysUser::getId, StpKit.USER.getLoginIdAsLong()).one(); SysUser sysUser = sysUserService.queryChain().eq(SysUser::getId, StpKit.USER.getLoginIdAsLong()).one();
if (StrUtil.isBlank(sysUser.getPhone())) { if (StrUtil.isBlank(sysUser.getPhone())) {
throw new ApiNotPrintException("账号未绑定手机号"); throw new CzgException("账号未绑定手机号");
} }
String key = RedisCst.SMS_CODE + sysUser.getPhone() + ":" + type; String key = RedisCst.SMS_CODE + sysUser.getPhone() + ":" + type;
Object val = redisService.get(key); Object val = redisService.get(key);
if (val != null) { if (val != null) {
throw new ApiNotPrintException("请勿频繁获取"); throw new CzgException("请勿频繁获取");
} }
int code = RandomUtil.randomInt(100000, 1000000); int code = RandomUtil.randomInt(100000, 1000000);
redisService.set(key, code, 300); redisService.set(key, code, 300);
@@ -47,7 +47,7 @@ public class CommonServiceImpl implements CommonService {
public Boolean checkSmsCode(String type, String code) { public Boolean checkSmsCode(String type, String code) {
SysUser sysUser = sysUserService.queryChain().eq(SysUser::getId, StpKit.USER.getLoginIdAsLong()).one(); SysUser sysUser = sysUserService.queryChain().eq(SysUser::getId, StpKit.USER.getLoginIdAsLong()).one();
if (StrUtil.isBlank(sysUser.getPhone())) { if (StrUtil.isBlank(sysUser.getPhone())) {
throw new ApiNotPrintException("账号未绑定手机号"); throw new CzgException("账号未绑定手机号");
} }
Object value = redisService.get(RedisCst.SMS_CODE + sysUser.getPhone() + ":" + type); Object value = redisService.get(RedisCst.SMS_CODE + sysUser.getPhone() + ":" + type);
return code.equals(value); return code.equals(value);

View File

@@ -6,15 +6,13 @@ import com.alibaba.fastjson.JSONObject;
import com.alibaba.fastjson2.JSONArray; import com.alibaba.fastjson2.JSONArray;
import com.czg.account.dto.freeding.FreeDineConfigEditDTO; import com.czg.account.dto.freeding.FreeDineConfigEditDTO;
import com.czg.account.entity.FreeDineConfig; import com.czg.account.entity.FreeDineConfig;
import com.czg.account.entity.ShopConfig;
import com.czg.account.service.FreeDineConfigService; import com.czg.account.service.FreeDineConfigService;
import com.czg.account.service.ShopConfigService; import com.czg.account.service.ShopConfigService;
import com.czg.account.vo.FreeDineConfigVO; import com.czg.account.vo.FreeDineConfigVO;
import com.czg.exception.ApiNotPrintException; import com.czg.exception.CzgException;
import com.czg.service.account.mapper.FreeDineConfigMapper; import com.czg.service.account.mapper.FreeDineConfigMapper;
import com.mybatisflex.core.query.QueryWrapper; import com.mybatisflex.core.query.QueryWrapper;
import com.mybatisflex.spring.service.impl.ServiceImpl; import com.mybatisflex.spring.service.impl.ServiceImpl;
import jakarta.annotation.Resource;
import org.apache.dubbo.config.annotation.DubboReference; import org.apache.dubbo.config.annotation.DubboReference;
import org.apache.dubbo.config.annotation.DubboService; import org.apache.dubbo.config.annotation.DubboService;
@@ -56,7 +54,7 @@ public class FreeDineConfigServiceImpl extends ServiceImpl<FreeDineConfigMapper,
public Boolean edit(long shopId, FreeDineConfigEditDTO freeDineConfigEditDTO) { public Boolean edit(long shopId, FreeDineConfigEditDTO freeDineConfigEditDTO) {
FreeDineConfig config = getOne(new QueryWrapper().eq(FreeDineConfig::getShopId, shopId)); FreeDineConfig config = getOne(new QueryWrapper().eq(FreeDineConfig::getShopId, shopId));
if (config == null) { if (config == null) {
throw new ApiNotPrintException("霸王餐信息未配置"); throw new CzgException("霸王餐信息未配置");
} }
BeanUtil.copyProperties(freeDineConfigEditDTO, config, "useType"); BeanUtil.copyProperties(freeDineConfigEditDTO, config, "useType");
if ("part".equals(freeDineConfigEditDTO.getUseShopType()) && freeDineConfigEditDTO.getShopIdList() != null) { if ("part".equals(freeDineConfigEditDTO.getUseShopType()) && freeDineConfigEditDTO.getShopIdList() != null) {

View File

@@ -3,7 +3,7 @@ package com.czg.service.account.service.impl;
import cn.hutool.http.HttpUtil; import cn.hutool.http.HttpUtil;
import com.alibaba.fastjson2.JSONObject; import com.alibaba.fastjson2.JSONObject;
import com.czg.account.service.GeoService; import com.czg.account.service.GeoService;
import com.czg.exception.ApiNotPrintException; import com.czg.exception.CzgException;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.StringUtils;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
@@ -37,7 +37,7 @@ public class GeoServiceImpl implements GeoService {
JSONObject jsonObject = JSONObject.parseObject(response); JSONObject jsonObject = JSONObject.parseObject(response);
if (jsonObject == null) { if (jsonObject == null) {
log.warn("经纬度获取失败{}", response); log.warn("经纬度获取失败{}", response);
throw new ApiNotPrintException("获取经纬度失败"); throw new CzgException("获取经纬度失败");
} }
return jsonObject.getJSONObject("regeocode"); return jsonObject.getJSONObject("regeocode");
} }

View File

@@ -1,7 +1,6 @@
package com.czg.service.account.service.impl; package com.czg.service.account.service.impl;
import cn.hutool.core.collection.CollUtil; import cn.hutool.core.collection.CollUtil;
import cn.hutool.core.util.NumberUtil;
import cn.hutool.core.util.ObjUtil; import cn.hutool.core.util.ObjUtil;
import cn.hutool.core.util.StrUtil; import cn.hutool.core.util.StrUtil;
import com.czg.account.dto.pad.*; import com.czg.account.dto.pad.*;
@@ -11,7 +10,7 @@ import com.czg.account.entity.PadProductCategoryDetail;
import com.czg.account.entity.ShopProdCategory; import com.czg.account.entity.ShopProdCategory;
import com.czg.account.service.*; import com.czg.account.service.*;
import com.czg.enums.YesNoEnum; import com.czg.enums.YesNoEnum;
import com.czg.exception.ApiNotPrintException; import com.czg.exception.CzgException;
import com.czg.product.entity.ProdSku; import com.czg.product.entity.ProdSku;
import com.czg.product.entity.Product; import com.czg.product.entity.Product;
import com.czg.product.service.ProdSkuService; import com.czg.product.service.ProdSkuService;
@@ -28,7 +27,6 @@ import jakarta.annotation.Resource;
import org.apache.dubbo.config.annotation.DubboReference; import org.apache.dubbo.config.annotation.DubboReference;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import java.math.BigDecimal;
import java.time.DayOfWeek; import java.time.DayOfWeek;
import java.time.LocalDate; import java.time.LocalDate;
import java.time.LocalTime; import java.time.LocalTime;
@@ -36,7 +34,6 @@ import java.time.format.TextStyle;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
import java.util.Locale; import java.util.Locale;
import java.util.Optional;
/** /**
* @author Administrator * @author Administrator
@@ -104,7 +101,7 @@ public class PadProdServiceImpl implements PadProdService {
public PadDetailDTO detail(Long shopId, Long padProductCategory) { public PadDetailDTO detail(Long shopId, Long padProductCategory) {
PadProductCategory padCategory = padProductCategoryService.getOne(new QueryWrapper().eq(PadProductCategory::getShopId, shopId).eq(PadProductCategory::getId, padProductCategory)); PadProductCategory padCategory = padProductCategoryService.getOne(new QueryWrapper().eq(PadProductCategory::getShopId, shopId).eq(PadProductCategory::getId, padProductCategory));
if (padCategory == null) { if (padCategory == null) {
throw new ApiNotPrintException("pad商品分类不存在"); throw new CzgException("pad商品分类不存在");
} }
PadDetailDTO padDetailDTO = new PadDetailDTO(); PadDetailDTO padDetailDTO = new PadDetailDTO();
@@ -133,7 +130,7 @@ public class PadProdServiceImpl implements PadProdService {
public Boolean add(Long shopId, PadDetailAddDTO padDetailAddDTO) { public Boolean add(Long shopId, PadDetailAddDTO padDetailAddDTO) {
long count = shopProdCategoryService.count(new QueryWrapper().eq(ShopProdCategory::getId, padDetailAddDTO.getProductCategoryId())); long count = shopProdCategoryService.count(new QueryWrapper().eq(ShopProdCategory::getId, padDetailAddDTO.getProductCategoryId()));
if (count == 0) { if (count == 0) {
throw new ApiNotPrintException("商品分类不存在"); throw new CzgException("商品分类不存在");
} }
checkInfo(shopId, padDetailAddDTO.getPadLayoutId(), padDetailAddDTO.getProductIdList()); checkInfo(shopId, padDetailAddDTO.getPadLayoutId(), padDetailAddDTO.getProductIdList());
@@ -152,7 +149,7 @@ public class PadProdServiceImpl implements PadProdService {
public Boolean edit(Long shopId, PadDetailEditDTO padDetailEditDTO) { public Boolean edit(Long shopId, PadDetailEditDTO padDetailEditDTO) {
PadProductCategory category = padProductCategoryService.getOne(new QueryWrapper().eq(PadProductCategory::getShopId, shopId).eq(PadProductCategory::getId, padDetailEditDTO.getId())); PadProductCategory category = padProductCategoryService.getOne(new QueryWrapper().eq(PadProductCategory::getShopId, shopId).eq(PadProductCategory::getId, padDetailEditDTO.getId()));
if (category == null) { if (category == null) {
throw new ApiNotPrintException("pad商品不存在"); throw new CzgException("pad商品不存在");
} }
checkInfo(shopId, padDetailEditDTO.getPadLayoutId(), padDetailEditDTO.getProductIdList()); checkInfo(shopId, padDetailEditDTO.getPadLayoutId(), padDetailEditDTO.getProductIdList());
@@ -173,13 +170,13 @@ public class PadProdServiceImpl implements PadProdService {
private void checkInfo(Long shopId, Long padLayoutId, List<Long> productIdList) { private void checkInfo(Long shopId, Long padLayoutId, List<Long> productIdList) {
long layOutCount = padLayoutService.count(new QueryWrapper().eq(PadLayout::getId, padLayoutId).eq(PadLayout::getIsDel, 0)); long layOutCount = padLayoutService.count(new QueryWrapper().eq(PadLayout::getId, padLayoutId).eq(PadLayout::getIsDel, 0));
if (layOutCount == 0) { if (layOutCount == 0) {
throw new ApiNotPrintException("pad布局不存在"); throw new CzgException("pad布局不存在");
} }
if (productIdList != null && !productIdList.isEmpty()) { if (productIdList != null && !productIdList.isEmpty()) {
long proCount = productService.count(new QueryWrapper().eq(Product::getShopId, shopId).in(Product::getId, productIdList)); long proCount = productService.count(new QueryWrapper().eq(Product::getShopId, shopId).in(Product::getId, productIdList));
if (proCount != productIdList.size()) { if (proCount != productIdList.size()) {
throw new ApiNotPrintException("存在错误商品id"); throw new CzgException("存在错误商品id");
} }
} }
} }
@@ -188,7 +185,7 @@ public class PadProdServiceImpl implements PadProdService {
public Boolean del(Long shopId, PadDetailDelDTO delDTO) { public Boolean del(Long shopId, PadDetailDelDTO delDTO) {
PadProductCategory category = padProductCategoryService.getOne(new QueryWrapper().eq(PadProductCategory::getShopId, shopId).eq(PadProductCategory::getId, delDTO.getId())); PadProductCategory category = padProductCategoryService.getOne(new QueryWrapper().eq(PadProductCategory::getShopId, shopId).eq(PadProductCategory::getId, delDTO.getId()));
if (category == null) { if (category == null) {
throw new ApiNotPrintException("pad商品不存在"); throw new CzgException("pad商品不存在");
} }
padProductCategoryService.removeById(delDTO.getId()); padProductCategoryService.removeById(delDTO.getId());

View File

@@ -7,7 +7,7 @@ import com.czg.account.dto.print.PrinterAddDTO;
import com.czg.account.dto.print.PrinterEditDTO; import com.czg.account.dto.print.PrinterEditDTO;
import com.czg.account.entity.PrintMachine; import com.czg.account.entity.PrintMachine;
import com.czg.account.service.PrintMachineService; import com.czg.account.service.PrintMachineService;
import com.czg.exception.ApiNotPrintException; import com.czg.exception.CzgException;
import com.czg.service.account.mapper.PrintMachineMapper; import com.czg.service.account.mapper.PrintMachineMapper;
import com.mybatisflex.core.query.QueryWrapper; import com.mybatisflex.core.query.QueryWrapper;
import com.mybatisflex.spring.service.impl.ServiceImpl; import com.mybatisflex.spring.service.impl.ServiceImpl;
@@ -27,13 +27,13 @@ public class PrintMachineServiceImpl extends ServiceImpl<PrintMachineMapper, Pri
//分类打印选择部分打印时必传JsonArray字符串数据 如:[{"id":125,"name":"意式咖啡"},{"id":127,"name":"饮品"}] //分类打印选择部分打印时必传JsonArray字符串数据 如:[{"id":125,"name":"意式咖啡"},{"id":127,"name":"饮品"}]
if ("1".equals(dto.getClassifyPrint()) || "2".equals(dto.getClassifyPrint())) { if ("1".equals(dto.getClassifyPrint()) || "2".equals(dto.getClassifyPrint())) {
if (StrUtil.isBlank(dto.getCategoryList())) { if (StrUtil.isBlank(dto.getCategoryList())) {
throw new ApiNotPrintException("分类打印选择部分打印时,必须勾选需要部分打印的菜品"); throw new CzgException("分类打印选择部分打印时,必须勾选需要部分打印的菜品");
} }
if (!JSONUtil.isTypeJSONArray(dto.getCategoryList())) { if (!JSONUtil.isTypeJSONArray(dto.getCategoryList())) {
throw new ApiNotPrintException("传递的部分打印菜品数据不合法"); throw new CzgException("传递的部分打印菜品数据不合法");
} }
if (StrUtil.isBlank(dto.getCategoryIds())) { if (StrUtil.isBlank(dto.getCategoryIds())) {
throw new ApiNotPrintException("分类打印选择部分打印时传递的部分打印菜品id数据不能为空"); throw new CzgException("分类打印选择部分打印时传递的部分打印菜品id数据不能为空");
} }
} else { } else {
dto.setCategoryIds(null); dto.setCategoryIds(null);
@@ -48,7 +48,7 @@ public class PrintMachineServiceImpl extends ServiceImpl<PrintMachineMapper, Pri
public Boolean edit(Long shopId, PrinterEditDTO printerEditDTO) { public Boolean edit(Long shopId, PrinterEditDTO printerEditDTO) {
PrintMachine printMachine = getOne(new QueryWrapper().eq(PrintMachine::getShopId, shopId).eq(PrintMachine::getId, printerEditDTO.getId())); PrintMachine printMachine = getOne(new QueryWrapper().eq(PrintMachine::getShopId, shopId).eq(PrintMachine::getId, printerEditDTO.getId()));
if (printMachine == null) { if (printMachine == null) {
throw new ApiNotPrintException("打印机不存在"); throw new CzgException("打印机不存在");
} }
BeanUtil.copyProperties(printerEditDTO, printMachine); BeanUtil.copyProperties(printerEditDTO, printMachine);

View File

@@ -3,8 +3,7 @@ package com.czg.service.account.service.impl;
import cn.hutool.core.bean.BeanUtil; import cn.hutool.core.bean.BeanUtil;
import cn.hutool.core.util.StrUtil; import cn.hutool.core.util.StrUtil;
import com.czg.account.dto.extend.ShopExtendDTO; import com.czg.account.dto.extend.ShopExtendDTO;
import com.czg.exception.ApiNotPrintException; import com.czg.exception.CzgException;
import com.czg.sa.StpKit;
import com.mybatisflex.core.query.QueryWrapper; import com.mybatisflex.core.query.QueryWrapper;
import com.mybatisflex.spring.service.impl.ServiceImpl; import com.mybatisflex.spring.service.impl.ServiceImpl;
import com.czg.account.entity.ShopExtend; import com.czg.account.entity.ShopExtend;
@@ -33,7 +32,7 @@ public class ShopExtendServiceImpl extends ServiceImpl<ShopExtendMapper, ShopExt
public Boolean edit(Long shopId, ShopExtendDTO shopExtendDTO) { public Boolean edit(Long shopId, ShopExtendDTO shopExtendDTO) {
ShopExtend shopExtend = queryChain().eq(ShopExtend::getShopId, shopId).eq(ShopExtend::getAutoKey, shopExtendDTO.getAutokey()).one(); ShopExtend shopExtend = queryChain().eq(ShopExtend::getShopId, shopId).eq(ShopExtend::getAutoKey, shopExtendDTO.getAutokey()).one();
if (shopExtend == null) { if (shopExtend == null) {
throw new ApiNotPrintException("key有误"); throw new CzgException("key有误");
} }
BeanUtil.copyProperties(shopExtendDTO, shopExtend); BeanUtil.copyProperties(shopExtendDTO, shopExtend);

View File

@@ -13,7 +13,6 @@ import com.czg.account.service.*;
import com.czg.config.RedisCst; import com.czg.config.RedisCst;
import com.czg.enums.StatusEnum; import com.czg.enums.StatusEnum;
import com.czg.enums.YesNoEnum; import com.czg.enums.YesNoEnum;
import com.czg.exception.ApiNotPrintException;
import com.czg.exception.CzgException; import com.czg.exception.CzgException;
import com.czg.resp.CzgResult; import com.czg.resp.CzgResult;
import com.czg.sa.MyStpLogic; import com.czg.sa.MyStpLogic;
@@ -82,8 +81,11 @@ public class ShopInfoServiceImpl extends ServiceImpl<ShopInfoMapper, ShopInfo> i
@Override @Override
@Cacheable(key = "#id") @Cacheable(key = "#id")
public ShopInfo getById(Serializable id) { public ShopInfo getById(Serializable id) throws CzgException {
ShopInfo shopInfo = super.getById(id); ShopInfo shopInfo = super.getById(id);
if(shopInfo == null){
throw new CzgException("店铺不存在");
}
ShopConfig shopConfig = shopConfigService.getById(shopInfo.getId()); ShopConfig shopConfig = shopConfigService.getById(shopInfo.getId());
BeanUtil.copyProperties(shopConfig, shopInfo); BeanUtil.copyProperties(shopConfig, shopInfo);
return shopInfo; return shopInfo;
@@ -92,13 +94,13 @@ public class ShopInfoServiceImpl extends ServiceImpl<ShopInfoMapper, ShopInfo> i
private ShopInfo getShopInfo(Long shopId) { private ShopInfo getShopInfo(Long shopId) {
ShopInfo shopInfo = getById(shopId); ShopInfo shopInfo = getById(shopId);
if (shopInfo == null) { if (shopInfo == null) {
throw new ApiNotPrintException("店铺不存在"); throw new CzgException("店铺不存在");
} }
if (shopInfo.getExpireTime() != null && (DateUtil.date().toLocalDateTime().isAfter(shopInfo.getExpireTime()))) { if (shopInfo.getExpireTime() != null && (DateUtil.date().toLocalDateTime().isAfter(shopInfo.getExpireTime()))) {
throw new ApiNotPrintException("店铺已过期,请联系商家"); throw new CzgException("店铺已过期,请联系商家");
} }
if (StatusEnum.DISABLE.value() == shopInfo.getOnSale() || shopInfo.getStatus() != StatusEnum.ENABLED.value()) { if (StatusEnum.DISABLE.value() == shopInfo.getOnSale() || shopInfo.getStatus() != StatusEnum.ENABLED.value()) {
throw new ApiNotPrintException("店铺已停业,请联系商家"); throw new CzgException("店铺已停业,请联系商家");
} }
shopInfo.setBookingSms(null); shopInfo.setBookingSms(null);
@@ -157,7 +159,7 @@ public class ShopInfoServiceImpl extends ServiceImpl<ShopInfoMapper, ShopInfo> i
public Boolean add(ShopInfoAddDTO shopInfoAddDTO) { public Boolean add(ShopInfoAddDTO shopInfoAddDTO) {
// 如果店铺类型是单店,是否主店要设为否 // 如果店铺类型是单店,是否主店要设为否
if (ShopTypeEnum.ONLY.getValue().equals(shopInfoAddDTO.getShopType())) { if (ShopTypeEnum.ONLY.getValue().equals(shopInfoAddDTO.getShopType())) {
shopInfoAddDTO.setIsHeadShop(YesNoEnum.NO.value()); shopInfoAddDTO.setIsHeadShop(YesNoEnum.YES.value());
if (shopInfoAddDTO.getMainId() != null) { if (shopInfoAddDTO.getMainId() != null) {
throw new CzgException("单店不允许设置主店ID"); throw new CzgException("单店不允许设置主店ID");
} }
@@ -174,7 +176,7 @@ public class ShopInfoServiceImpl extends ServiceImpl<ShopInfoMapper, ShopInfo> i
} }
shopInfoAddDTO.setPhone(shopInfoAddDTO.getPhone().trim()); shopInfoAddDTO.setPhone(shopInfoAddDTO.getPhone().trim());
if (StrUtil.isBlank(shopInfoAddDTO.getPhone())) { if (StrUtil.isBlank(shopInfoAddDTO.getPhone())) {
throw new ApiNotPrintException("请输入手机号"); throw new CzgException("请输入手机号");
} }
long count = sysUserService.queryChain().eq(SysUser::getAccount, shopInfoAddDTO.getAccountName()).count(); long count = sysUserService.queryChain().eq(SysUser::getAccount, shopInfoAddDTO.getAccountName()).count();
if (count > 0) { if (count > 0) {
@@ -290,7 +292,7 @@ public class ShopInfoServiceImpl extends ServiceImpl<ShopInfoMapper, ShopInfo> i
String key = "%s%s:%s".formatted(RedisCst.SMS_CODE, shopInfo.getPhone(), "editShopInfoOpePwd"); String key = "%s%s:%s".formatted(RedisCst.SMS_CODE, shopInfo.getPhone(), "editShopInfoOpePwd");
Object val = redisService.get(key); Object val = redisService.get(key);
if (val instanceof String code && !shopInfoEditDTO.getCode().equals(code)) { if (val instanceof String code && !shopInfoEditDTO.getCode().equals(code)) {
throw new ApiNotPrintException("验证码错误"); throw new CzgException("验证码错误");
} }
shopInfo.setOperationPwd(SecureUtil.md5(shopInfoEditDTO.getOperationPwd())); shopInfo.setOperationPwd(SecureUtil.md5(shopInfoEditDTO.getOperationPwd()));
@@ -322,11 +324,11 @@ public class ShopInfoServiceImpl extends ServiceImpl<ShopInfoMapper, ShopInfo> i
public ShopDetailDTO detail(Long id) { public ShopDetailDTO detail(Long id) {
ShopInfo shopInfo = queryChain().eq(ShopInfo::getId, id == null ? StpKit.USER.getShopId() : id).one(); ShopInfo shopInfo = queryChain().eq(ShopInfo::getId, id == null ? StpKit.USER.getShopId() : id).one();
if (shopInfo == null) { if (shopInfo == null) {
throw new ApiNotPrintException("店铺信息不存在"); throw new CzgException("店铺信息不存在");
} }
if (!StpKit.USER.isAdmin() && !Objects.equals(StpKit.USER.getShopId(), shopInfo.getId())) { if (!StpKit.USER.isAdmin() && !Objects.equals(StpKit.USER.getShopId(), shopInfo.getId())) {
throw new ApiNotPrintException("店铺信息不存在"); throw new CzgException("店铺信息不存在");
} }
ShopConfig shopConfig = shopConfigService.getById(shopInfo.getId()); ShopConfig shopConfig = shopConfigService.getById(shopInfo.getId());
if (shopConfig == null) { if (shopConfig == null) {
@@ -345,11 +347,11 @@ public class ShopInfoServiceImpl extends ServiceImpl<ShopInfoMapper, ShopInfo> i
public ShopInfoByCodeDTO getByCode(String tableCode, String lat, String lng, boolean checkState) { public ShopInfoByCodeDTO getByCode(String tableCode, String lat, String lng, boolean checkState) {
ShopTable shopTable = shopTableService.queryChain().eq(ShopTable::getTableCode, tableCode).one(); ShopTable shopTable = shopTableService.queryChain().eq(ShopTable::getTableCode, tableCode).one();
if (shopTable == null) { if (shopTable == null) {
throw new ApiNotPrintException("错误的台桌码"); throw new CzgException("错误的台桌码");
} }
if (checkState && !shopTable.canUseByStatus()) { if (checkState && !shopTable.canUseByStatus()) {
throw new ApiNotPrintException("台桌状态不可用"); throw new CzgException("台桌状态不可用");
} }
ShopInfo shopInfo = getShopInfo(shopTable.getShopId()); ShopInfo shopInfo = getShopInfo(shopTable.getShopId());
double distance = 0; double distance = 0;

View File

@@ -3,8 +3,7 @@ package com.czg.service.account.service.impl;
import cn.hutool.core.bean.BeanUtil; import cn.hutool.core.bean.BeanUtil;
import cn.hutool.core.util.StrUtil; import cn.hutool.core.util.StrUtil;
import com.czg.account.dto.ShopPayTypeDTO; import com.czg.account.dto.ShopPayTypeDTO;
import com.czg.exception.ApiNotPrintException; import com.czg.exception.CzgException;
import com.czg.resp.CzgResult;
import com.czg.sa.StpKit; import com.czg.sa.StpKit;
import com.mybatisflex.core.query.QueryWrapper; import com.mybatisflex.core.query.QueryWrapper;
import com.mybatisflex.spring.service.impl.ServiceImpl; import com.mybatisflex.spring.service.impl.ServiceImpl;
@@ -14,9 +13,7 @@ import com.czg.service.account.mapper.ShopPayTypeMapper;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.HashMap;
import java.util.List; import java.util.List;
import java.util.Map;
/** /**
* 店铺支付类型 服务层实现。 * 店铺支付类型 服务层实现。
@@ -65,7 +62,7 @@ public class ShopPayTypeServiceImpl extends ServiceImpl<ShopPayTypeMapper, ShopP
}); });
})); }));
if (count > 0) { if (count > 0) {
throw new ApiNotPrintException("支付方式或支付名称已存在"); throw new CzgException("支付方式或支付名称已存在");
} }
ShopPayType payType = BeanUtil.copyProperties(shopPayType, ShopPayType.class); ShopPayType payType = BeanUtil.copyProperties(shopPayType, ShopPayType.class);
@@ -81,7 +78,7 @@ public class ShopPayTypeServiceImpl extends ServiceImpl<ShopPayTypeMapper, ShopP
.eq(ShopPayType::getPayName, shopPayTypeDTO.getPayName()) .eq(ShopPayType::getPayName, shopPayTypeDTO.getPayName())
.ne(ShopPayType::getId, shopPayTypeDTO.getId())); .ne(ShopPayType::getId, shopPayTypeDTO.getId()));
if (count > 0) { if (count > 0) {
throw new ApiNotPrintException("支付名称已存在"); throw new CzgException("支付名称已存在");
} }
} }
@@ -90,7 +87,7 @@ public class ShopPayTypeServiceImpl extends ServiceImpl<ShopPayTypeMapper, ShopP
.eq(ShopPayType::getPayType, shopPayTypeDTO.getPayType()) .eq(ShopPayType::getPayType, shopPayTypeDTO.getPayType())
.ne(ShopPayType::getId, shopPayTypeDTO.getId())); .ne(ShopPayType::getId, shopPayTypeDTO.getId()));
if (count > 0) { if (count > 0) {
throw new ApiNotPrintException("支付方式已存在"); throw new CzgException("支付方式已存在");
} }
} }

View File

@@ -3,7 +3,7 @@ package com.czg.service.account.service.impl;
import com.alibaba.fastjson2.JSONArray; import com.alibaba.fastjson2.JSONArray;
import com.alibaba.fastjson2.JSONObject; import com.alibaba.fastjson2.JSONObject;
import com.czg.account.dto.msg.ShopPushOpenIdEditDTO; import com.czg.account.dto.msg.ShopPushOpenIdEditDTO;
import com.czg.exception.ApiNotPrintException; import com.czg.exception.CzgException;
import com.czg.utils.PageUtil; import com.czg.utils.PageUtil;
import com.mybatisflex.core.paginate.Page; import com.mybatisflex.core.paginate.Page;
import com.mybatisflex.core.query.QueryWrapper; import com.mybatisflex.core.query.QueryWrapper;
@@ -35,7 +35,7 @@ public class ShopPushOpenIdServiceImpl extends ServiceImpl<ShopPushOpenIdMapper,
public Boolean edit(Long shopId, ShopPushOpenIdEditDTO shopPushOpenIdEditDTO) { public Boolean edit(Long shopId, ShopPushOpenIdEditDTO shopPushOpenIdEditDTO) {
ShopPushOpenId pushOpenId = queryChain().eq(ShopPushOpenId::getShopId, shopId).eq(ShopPushOpenId::getOpenId, shopPushOpenIdEditDTO.getOpenId()).one(); ShopPushOpenId pushOpenId = queryChain().eq(ShopPushOpenId::getShopId, shopId).eq(ShopPushOpenId::getOpenId, shopPushOpenIdEditDTO.getOpenId()).one();
if (pushOpenId == null) { if (pushOpenId == null) {
throw new ApiNotPrintException("订阅用户不存在"); throw new CzgException("订阅用户不存在");
} }
pushOpenId.setTypeInfo(JSONObject.toJSONString(shopPushOpenIdEditDTO.getTypeInfo())); pushOpenId.setTypeInfo(JSONObject.toJSONString(shopPushOpenIdEditDTO.getTypeInfo()));

View File

@@ -1,92 +0,0 @@
//package com.czg.service.account.service.impl;
//
//import cn.hutool.core.bean.BeanUtil;
//import cn.hutool.core.util.StrUtil;
//import com.alibaba.fastjson2.JSONArray;
//import com.alibaba.fastjson2.JSONObject;
//import com.czg.account.dto.ShopShareCouponDTO;
//import com.czg.account.dto.ShopShareDTO;
//import com.czg.account.entity.ShopCoupon;
//import com.czg.account.service.ShopCouponService;
//import com.czg.account.vo.ShopShareRecordVO;
//import com.czg.account.vo.ShopShareVO;
//import com.czg.exception.ApiNotPrintException;
//import com.czg.service.account.mapper.ShopShareRecordMapper;
//import com.czg.utils.PageUtil;
//import com.github.pagehelper.PageHelper;
//import com.github.pagehelper.PageInfo;
//import com.mybatisflex.core.paginate.Page;
//import com.mybatisflex.core.query.QueryWrapper;
//import com.mybatisflex.spring.service.impl.ServiceImpl;
//import com.czg.account.entity.ShopShare;
//import com.czg.account.service.ShopShareService;
//import com.czg.service.account.mapper.ShopShareMapper;
//import jakarta.annotation.Resource;
//import org.springframework.stereotype.Service;
//
///**
// * 店铺分享 服务层实现。
// *
// * @author zs
// * @since 2025-03-05
// */
//@Service
//public class ShopShareServiceImpl extends ServiceImpl<ShopShareMapper, ShopShare> implements ShopShareService{
// @Resource
// private ShopCouponService shopCouponService;
// @Resource
// private ShopShareRecordMapper shopShareRecordMapper;
//
// @Override
// public ShopShareVO get(Long shopId) {
// ShopShare shopShare = getOne(new QueryWrapper().eq(ShopShare::getShopId, shopId));
// ShopShareVO shopShareVO = new ShopShareVO();
// if (shopShare != null) {
// BeanUtil.copyProperties(shopShare, shopShareVO);
// if (StrUtil.isNotBlank(shopShare.getRewardCoupon())) {
//// shopShareVO.setRewardCouponList(shopCouponService.list(new QueryWrapper().eq(ShopCoupon::getShopId, shopId).in(ShopCoupon::getId, JSONArray.parseArray(shopShare.getRewardCoupon()))));
// shopShareVO.setRewardCouponList(JSONArray.parseArray(shopShare.getRewardCoupon(), ShopShareCouponDTO.class));
// }
//
// if (StrUtil.isNotBlank(shopShare.getNewCoupon())) {
//// shopShareVO.setNewCouponList(shopCouponService.list(new QueryWrapper().eq(ShopCoupon::getShopId, shopId).in(ShopCoupon::getId, JSONArray.parseArray(shopShare.getNewCoupon()))));
// shopShareVO.setNewCouponList(JSONArray.parseArray(shopShare.getNewCoupon(), ShopShareCouponDTO.class));
// }
// }
// return shopShareVO;
// }
//
// @Override
// public Boolean add(Long shopId, ShopShareDTO shopShareDTO) {
// ShopShare shopShare = getOne(new QueryWrapper().eq(ShopShare::getShopId, shopId));
// if (shopShare == null) {
// shopShare = new ShopShareVO();
// shopShare.setShopId(shopId);
// }
//
// if (shopShareDTO.getNewCouponList() != null && !shopShareDTO.getNewCouponList().isEmpty()) {
// long count = shopCouponService.count(new QueryWrapper().in(ShopCoupon::getId, shopShareDTO.getNewCouponList().stream().map(ShopShareCouponDTO::getId).toList()).eq(ShopCoupon::getShopId, shopId));
// if (count != shopShareDTO.getNewCouponList().size()) {
// throw new ApiNotPrintException("优惠券不存在");
// }
// shopShare.setNewCoupon(JSONArray.toJSONString(shopShareDTO.getNewCouponList()));
// }
//
// if (shopShareDTO.getRewardCouponList() != null && !shopShareDTO.getRewardCouponList().isEmpty()) {
// long count = shopCouponService.count(new QueryWrapper().in(ShopCoupon::getId, shopShareDTO.getRewardCouponList().stream().map(ShopShareCouponDTO::getId).toList()).eq(ShopCoupon::getShopId, shopId));
// if (count != shopShareDTO.getRewardCouponList().size()) {
// throw new ApiNotPrintException("优惠券不存在");
// }
// shopShare.setRewardCoupon(JSONArray.toJSONString(shopShareDTO.getRewardCouponList()));
// }
// BeanUtil.copyProperties(shopShareDTO, shopShare);
// return saveOrUpdate(shopShare);
// }
//
// @Override
// public Page<ShopShareRecordVO> recordPage(Long shopId, String key, Integer status) {
// Page<Object> page = PageUtil.buildPage();
// PageHelper.startPage(Math.toIntExact(page.getPageNumber()), Math.toIntExact(page.getPageSize()));
// return PageUtil.convert(new PageInfo<>(shopShareRecordMapper.getRecord(shopId, key, status)));
// }
//}

View File

@@ -4,7 +4,7 @@ import cn.hutool.core.bean.BeanUtil;
import com.czg.account.dto.song.ShopSongAddDTO; import com.czg.account.dto.song.ShopSongAddDTO;
import com.czg.account.dto.song.ShopSongEditDTO; import com.czg.account.dto.song.ShopSongEditDTO;
import com.czg.config.RedisCst; import com.czg.config.RedisCst;
import com.czg.exception.ApiNotPrintException; import com.czg.exception.CzgException;
import com.czg.sa.StpKit; import com.czg.sa.StpKit;
import com.czg.service.RedisService; import com.czg.service.RedisService;
import com.mybatisflex.core.query.QueryWrapper; import com.mybatisflex.core.query.QueryWrapper;
@@ -16,8 +16,6 @@ import jakarta.annotation.Resource;
import org.apache.commons.lang3.RandomStringUtils; import org.apache.commons.lang3.RandomStringUtils;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import java.util.Map;
/** /**
* 点歌-歌曲表 服务层实现。 * 点歌-歌曲表 服务层实现。
* *
@@ -40,7 +38,7 @@ public class ShopSongServiceImpl extends ServiceImpl<ShopSongMapper, ShopSong> i
public Boolean edit(Long shopId, ShopSongEditDTO shopSongEditDTO) { public Boolean edit(Long shopId, ShopSongEditDTO shopSongEditDTO) {
ShopSong shopSong = getOne(new QueryWrapper().eq(ShopSong::getShopId, StpKit.USER.getShopId()).eq(ShopSong::getId, shopSongEditDTO.getId())); ShopSong shopSong = getOne(new QueryWrapper().eq(ShopSong::getShopId, StpKit.USER.getShopId()).eq(ShopSong::getId, shopSongEditDTO.getId()));
if (shopSong == null) { if (shopSong == null) {
throw new ApiNotPrintException("歌曲列表不存在"); throw new CzgException("歌曲列表不存在");
} }
BeanUtil.copyProperties(shopSongEditDTO, shopSong); BeanUtil.copyProperties(shopSongEditDTO, shopSong);

View File

@@ -4,7 +4,7 @@ import com.czg.account.dto.pagepath.PagePathPermissionAddDTO;
import com.czg.account.entity.ShopPagePath; import com.czg.account.entity.ShopPagePath;
import com.czg.account.entity.ShopStaff; import com.czg.account.entity.ShopStaff;
import com.czg.account.service.ShopPagePathService; import com.czg.account.service.ShopPagePathService;
import com.czg.exception.ApiNotPrintException; import com.czg.exception.CzgException;
import com.czg.service.account.mapper.ShopStaffMapper; import com.czg.service.account.mapper.ShopStaffMapper;
import com.mybatisflex.core.query.QueryWrapper; import com.mybatisflex.core.query.QueryWrapper;
import com.mybatisflex.spring.service.impl.ServiceImpl; import com.mybatisflex.spring.service.impl.ServiceImpl;
@@ -15,10 +15,8 @@ import jakarta.annotation.Resource;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional; import org.springframework.transaction.annotation.Transactional;
import java.util.ArrayList;
import java.util.Map; import java.util.Map;
import java.util.Set; import java.util.Set;
import java.util.stream.Collector;
import java.util.stream.Collectors; import java.util.stream.Collectors;
/** /**
@@ -39,13 +37,13 @@ public class ShopStaffPagePermissionServiceImpl extends ServiceImpl<ShopStaffPag
public Boolean add(Long shopId, PagePathPermissionAddDTO pagePathPermissionAddDTO) { public Boolean add(Long shopId, PagePathPermissionAddDTO pagePathPermissionAddDTO) {
ShopStaff shopStaff = shopStaffMapper.selectOneByQuery(new QueryWrapper().eq(ShopStaff::getId, pagePathPermissionAddDTO.getStaffId()).eq(ShopStaff::getShopId, shopId)); ShopStaff shopStaff = shopStaffMapper.selectOneByQuery(new QueryWrapper().eq(ShopStaff::getId, pagePathPermissionAddDTO.getStaffId()).eq(ShopStaff::getShopId, shopId));
if (shopStaff == null) { if (shopStaff == null) {
throw new ApiNotPrintException("员工不存在"); throw new CzgException("员工不存在");
} }
if (!pagePathPermissionAddDTO.getPagePathIdList().isEmpty()) { if (!pagePathPermissionAddDTO.getPagePathIdList().isEmpty()) {
long count = shopPagePathService.count(new QueryWrapper().in(ShopPagePath::getId, pagePathPermissionAddDTO.getPagePathIdList())); long count = shopPagePathService.count(new QueryWrapper().in(ShopPagePath::getId, pagePathPermissionAddDTO.getPagePathIdList()));
if (count != pagePathPermissionAddDTO.getPagePathIdList().size()) { if (count != pagePathPermissionAddDTO.getPagePathIdList().size()) {
throw new ApiNotPrintException("存在错误id"); throw new CzgException("存在错误id");
} }
} }

View File

@@ -8,7 +8,7 @@ import com.czg.account.dto.staff.ShopStaffEditDTO;
import com.czg.account.dto.staff.ShopStaffRemoveDTO; import com.czg.account.dto.staff.ShopStaffRemoveDTO;
import com.czg.account.entity.*; import com.czg.account.entity.*;
import com.czg.account.service.*; import com.czg.account.service.*;
import com.czg.exception.ApiNotPrintException; import com.czg.exception.CzgException;
import com.czg.sa.StpKit; import com.czg.sa.StpKit;
import com.czg.service.account.mapper.ShopStaffMapper; import com.czg.service.account.mapper.ShopStaffMapper;
import com.czg.utils.PageUtil; import com.czg.utils.PageUtil;
@@ -22,7 +22,6 @@ import org.springframework.transaction.annotation.Transactional;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.HashSet; import java.util.HashSet;
import java.util.List; import java.util.List;
import java.util.stream.Collectors;
/** /**
* 店铺员工 服务层实现。 * 店铺员工 服务层实现。
@@ -74,7 +73,7 @@ public class ShopStaffServiceImpl extends ServiceImpl<ShopStaffMapper, ShopStaff
long sysUserId = StpKit.USER.getLoginIdAsLong(); long sysUserId = StpKit.USER.getLoginIdAsLong();
ShopStaff shopStaff = queryChain().eq(ShopStaff::getShopId, sysUserId).eq(ShopStaff::getId, shopStaffEditDTO.getId()).one(); ShopStaff shopStaff = queryChain().eq(ShopStaff::getShopId, sysUserId).eq(ShopStaff::getId, shopStaffEditDTO.getId()).one();
if (shopStaff == null) { if (shopStaff == null) {
throw new ApiNotPrintException("员工账户不存在"); throw new CzgException("员工账户不存在");
} }
if (shopStaffEditDTO.getRoleId() != null) { if (shopStaffEditDTO.getRoleId() != null) {
sysUsersRolesService.updateRole(shopStaff.getId(), shopStaffEditDTO.getRoleId()); sysUsersRolesService.updateRole(shopStaff.getId(), shopStaffEditDTO.getRoleId());
@@ -93,7 +92,7 @@ public class ShopStaffServiceImpl extends ServiceImpl<ShopStaffMapper, ShopStaff
if (StrUtil.isNotBlank(shopStaffEditDTO.getAccountName()) && !accountName.equals(sysUser.getAccount())) { if (StrUtil.isNotBlank(shopStaffEditDTO.getAccountName()) && !accountName.equals(sysUser.getAccount())) {
long count = sysUserService.count(new QueryWrapper().eq(SysUser::getAccount, accountName).ne(SysUser::getId, sysUser.getId())); long count = sysUserService.count(new QueryWrapper().eq(SysUser::getAccount, accountName).ne(SysUser::getId, sysUser.getId()));
if (count > 0) { if (count > 0) {
throw new ApiNotPrintException("此账户名已存在"); throw new CzgException("此账户名已存在");
} }
sysUser.setAccount(accountName); sysUser.setAccount(accountName);
} }
@@ -125,7 +124,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, new HashSet<>(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 CzgException("存在不存在的权限");
} }
ArrayList<ShopStaffPermission> staffPermissions = new ArrayList<>(); ArrayList<ShopStaffPermission> staffPermissions = new ArrayList<>();
@@ -160,7 +159,7 @@ public class ShopStaffServiceImpl extends ServiceImpl<ShopStaffMapper, ShopStaff
long sysUserId = StpKit.USER.getLoginIdAsLong(); long sysUserId = StpKit.USER.getLoginIdAsLong();
ShopStaff shopStaff = queryChain().eq(ShopStaff::getShopId, sysUserId).eq(ShopStaff::getId, shopStaffRemoveDTO.getId()).one(); ShopStaff shopStaff = queryChain().eq(ShopStaff::getShopId, sysUserId).eq(ShopStaff::getId, shopStaffRemoveDTO.getId()).one();
if (shopStaff == null) { if (shopStaff == null) {
throw new ApiNotPrintException("员工账号不存在"); throw new CzgException("员工账号不存在");
} }
sysUserService.removeUserAndRole(shopStaff.getId()); sysUserService.removeUserAndRole(shopStaff.getId());
@@ -176,7 +175,7 @@ public class ShopStaffServiceImpl extends ServiceImpl<ShopStaffMapper, ShopStaff
public ShopStaff detail(Long shopId, Long id) { public ShopStaff detail(Long shopId, Long id) {
ShopStaff shopStaff = queryChain().eq(ShopStaff::getId, id).eq(ShopStaff::getShopId, shopId).one(); ShopStaff shopStaff = queryChain().eq(ShopStaff::getId, id).eq(ShopStaff::getShopId, shopId).one();
if (shopStaff == null) { if (shopStaff == null) {
throw new ApiNotPrintException("员工不存在"); throw new CzgException("员工不存在");
} }
SysUsersRoles sysUsersRoles = sysUsersRolesService.getOne(new QueryWrapper().eq(SysUsersRoles::getUserId, shopStaff.getId())); SysUsersRoles sysUsersRoles = sysUsersRolesService.getOne(new QueryWrapper().eq(SysUsersRoles::getUserId, shopStaff.getId()));

View File

@@ -4,7 +4,7 @@ import cn.hutool.core.bean.BeanUtil;
import cn.hutool.core.util.StrUtil; import cn.hutool.core.util.StrUtil;
import com.czg.account.dto.area.ShopAreaAddDTO; import com.czg.account.dto.area.ShopAreaAddDTO;
import com.czg.account.dto.area.ShopAreaEditDTO; import com.czg.account.dto.area.ShopAreaEditDTO;
import com.czg.exception.ApiNotPrintException; import com.czg.exception.CzgException;
import com.czg.sa.StpKit; import com.czg.sa.StpKit;
import com.czg.utils.PageUtil; import com.czg.utils.PageUtil;
import com.mybatisflex.core.paginate.Page; import com.mybatisflex.core.paginate.Page;
@@ -38,7 +38,7 @@ public class ShopTableAreaServiceImpl extends ServiceImpl<ShopAreaMapper, ShopTa
public boolean edit(Long shopId, ShopAreaEditDTO shopAreaEditDTO) { public boolean edit(Long shopId, ShopAreaEditDTO shopAreaEditDTO) {
ShopTableArea tableArea = queryChain().eq(ShopTableArea::getShopId, shopId).eq(ShopTableArea::getId, shopAreaEditDTO.getId()).one(); ShopTableArea tableArea = queryChain().eq(ShopTableArea::getShopId, shopId).eq(ShopTableArea::getId, shopAreaEditDTO.getId()).one();
if (tableArea == null) { if (tableArea == null) {
throw new ApiNotPrintException("区域不存在"); throw new CzgException("区域不存在");
} }
BeanUtil.copyProperties(shopAreaEditDTO, tableArea); BeanUtil.copyProperties(shopAreaEditDTO, tableArea);

View File

@@ -11,7 +11,6 @@ import com.czg.account.dto.table.ShopTableAddDTO;
import com.czg.account.dto.table.ShopTableBindDTO; import com.czg.account.dto.table.ShopTableBindDTO;
import com.czg.account.dto.table.ShopTableClearDTO; import com.czg.account.dto.table.ShopTableClearDTO;
import com.czg.account.dto.table.ShopTableDTO; import com.czg.account.dto.table.ShopTableDTO;
import com.czg.account.entity.ShopAd;
import com.czg.account.entity.ShopTable; import com.czg.account.entity.ShopTable;
import com.czg.account.entity.ShopTableArea; import com.czg.account.entity.ShopTableArea;
import com.czg.account.entity.ShopTableCode; import com.czg.account.entity.ShopTableCode;
@@ -20,8 +19,7 @@ import com.czg.account.service.ShopTableCodeService;
import com.czg.account.service.ShopTableService; import com.czg.account.service.ShopTableService;
import com.czg.account.vo.ShopTableVO; import com.czg.account.vo.ShopTableVO;
import com.czg.enums.ShopTableStatusEnum; import com.czg.enums.ShopTableStatusEnum;
import com.czg.exception.ApiNotPrintException; import com.czg.exception.CzgException;
import com.czg.resp.CzgResult;
import com.czg.sa.StpKit; import com.czg.sa.StpKit;
import com.czg.service.account.mapper.ShopTableMapper; import com.czg.service.account.mapper.ShopTableMapper;
import com.czg.system.enums.SysParamCodeEnum; import com.czg.system.enums.SysParamCodeEnum;
@@ -40,7 +38,9 @@ import lombok.extern.slf4j.Slf4j;
import org.apache.dubbo.config.annotation.DubboReference; import org.apache.dubbo.config.annotation.DubboReference;
import org.apache.dubbo.config.annotation.DubboService; import org.apache.dubbo.config.annotation.DubboService;
import java.io.*; import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
import java.math.BigDecimal; import java.math.BigDecimal;
import java.time.LocalDateTime; import java.time.LocalDateTime;
import java.util.ArrayList; import java.util.ArrayList;
@@ -82,7 +82,7 @@ public class ShopTableServiceImpl extends ServiceImpl<ShopTableMapper, ShopTable
ShopTableArea shopArea = shopAreaService.getOne(new QueryWrapper().eq(ShopTableArea::getShopId, shopId) ShopTableArea shopArea = shopAreaService.getOne(new QueryWrapper().eq(ShopTableArea::getShopId, shopId)
.eq(ShopTableArea::getId, shopTableAddDTO.getAreaId())); .eq(ShopTableArea::getId, shopTableAddDTO.getAreaId()));
if (shopArea == null) { if (shopArea == null) {
throw new ApiNotPrintException("台桌区域不存在"); throw new CzgException("台桌区域不存在");
} }
List<String> existisList = queryChain().eq(ShopTable::getShopId, shopId).like(ShopTable::getName, shopTableAddDTO.getSign()).list().stream().map(ShopTable::getName).toList(); List<String> existisList = queryChain().eq(ShopTable::getShopId, shopId).like(ShopTable::getName, shopTableAddDTO.getSign()).list().stream().map(ShopTable::getName).toList();
@@ -106,7 +106,7 @@ public class ShopTableServiceImpl extends ServiceImpl<ShopTableMapper, ShopTable
saveBatch(tableArrayList); saveBatch(tableArrayList);
if (StrUtil.isNotBlank(msg.toString())) { if (StrUtil.isNotBlank(msg.toString())) {
msg.append("台桌名已存在,未添加"); msg.append("台桌名已存在,未添加");
throw new ApiNotPrintException(msg.toString()); throw new CzgException(msg.toString());
} }
return true; return true;
} }
@@ -151,7 +151,7 @@ public class ShopTableServiceImpl extends ServiceImpl<ShopTableMapper, ShopTable
// 查询 shop 下面有多少台桌 // 查询 shop 下面有多少台桌
long count = queryChain().eq(ShopTable::getShopId, shopId).count(); long count = queryChain().eq(ShopTable::getShopId, shopId).count();
if (count == 0) { if (count == 0) {
throw new ApiNotPrintException("未添加台桌,请先添加台桌"); throw new CzgException("未添加台桌,请先添加台桌");
} }
// 获取当前店铺下的最大ID确保只查询当前shopId的记录 // 获取当前店铺下的最大ID确保只查询当前shopId的记录
@@ -176,7 +176,7 @@ public class ShopTableServiceImpl extends ServiceImpl<ShopTableMapper, ShopTable
if (!dir.exists()) { if (!dir.exists()) {
if (!dir.mkdirs()) { if (!dir.mkdirs()) {
log.error("创建临时目录失败"); log.error("创建临时目录失败");
throw new ApiNotPrintException("生成失败,请稍后再试"); throw new CzgException("生成失败,请稍后再试");
} }
} }
@@ -228,7 +228,7 @@ public class ShopTableServiceImpl extends ServiceImpl<ShopTableMapper, ShopTable
private String generateCode(Integer count, Long shopId, Long id, Map<String, Long> map) { private String generateCode(Integer count, Long shopId, Long id, Map<String, Long> map) {
if (count > 100) { if (count > 100) {
throw new ApiNotPrintException("桌码生成失败"); throw new CzgException("桌码生成失败");
} }
String tableCode = "40" + shopId % 10 + id % 10 + RandomUtil.randomNumbers(7); String tableCode = "40" + shopId % 10 + id % 10 + RandomUtil.randomNumbers(7);
if (map.containsKey(tableCode)) { if (map.containsKey(tableCode)) {
@@ -241,22 +241,22 @@ public class ShopTableServiceImpl extends ServiceImpl<ShopTableMapper, ShopTable
@Override @Override
public Boolean bind(Long shopId, ShopTableBindDTO shopTableBindDTO) { public Boolean bind(Long shopId, ShopTableBindDTO shopTableBindDTO) {
if (!StrUtil.startWith(shopTableBindDTO.getTableCode(), "40")) { if (!StrUtil.startWith(shopTableBindDTO.getTableCode(), "40")) {
throw new ApiNotPrintException("错误码"); throw new CzgException("错误码");
} }
ShopTableCode tableCode = shopTableCodeService.queryChain().eq(ShopTableCode::getTableCode, shopTableBindDTO.getTableCode()) ShopTableCode tableCode = shopTableCodeService.queryChain().eq(ShopTableCode::getTableCode, shopTableBindDTO.getTableCode())
.eq(ShopTableCode::getShopId, shopId).one(); .eq(ShopTableCode::getShopId, shopId).one();
if (tableCode == null) { if (tableCode == null) {
throw new ApiNotPrintException("此码非本店铺生成"); throw new CzgException("此码非本店铺生成");
} }
if (tableCode.getState() == 1) { if (tableCode.getState() == 1) {
throw new ApiNotPrintException("此桌码已绑定,请勿重复绑定"); throw new CzgException("此桌码已绑定,请勿重复绑定");
} }
ShopTable shopTable = queryChain().eq(ShopTable::getShopId, shopId).eq(ShopTable::getId, shopTableBindDTO.getId()).one(); ShopTable shopTable = queryChain().eq(ShopTable::getShopId, shopId).eq(ShopTable::getId, shopTableBindDTO.getId()).one();
if (shopTable == null) { if (shopTable == null) {
throw new ApiNotPrintException("台桌不存在"); throw new CzgException("台桌不存在");
} }
tableCode.setBindTime(DateUtil.date().toLocalDateTime()); tableCode.setBindTime(DateUtil.date().toLocalDateTime());
@@ -273,7 +273,7 @@ public class ShopTableServiceImpl extends ServiceImpl<ShopTableMapper, ShopTable
ShopTable shopTable = BeanUtil.copyProperties(shopTableDTO, ShopTable.class); ShopTable shopTable = BeanUtil.copyProperties(shopTableDTO, ShopTable.class);
ShopTable shopTableSource = getOne(new QueryWrapper().eq(ShopTable::getShopId, shopId).eq(ShopTable::getId, shopTableDTO.getId())); ShopTable shopTableSource = getOne(new QueryWrapper().eq(ShopTable::getShopId, shopId).eq(ShopTable::getId, shopTableDTO.getId()));
if (StrUtil.isBlank(shopTableSource.getTableCode()) && StrUtil.isNotBlank(shopTable.getStatus()) && ShopTableStatusEnum.UNBOUND.equalsVal(shopTable.getStatus())) { if (StrUtil.isBlank(shopTableSource.getTableCode()) && StrUtil.isNotBlank(shopTable.getStatus()) && ShopTableStatusEnum.UNBOUND.equalsVal(shopTable.getStatus())) {
throw new ApiNotPrintException("修改失败,该台桌未绑定桌码,绑定桌码后自动进入空闲状态"); throw new CzgException("修改失败,该台桌未绑定桌码,绑定桌码后自动进入空闲状态");
} }
return update(shopTable, new QueryWrapper().eq(ShopTable::getShopId, StpKit.USER.getShopId()).eq(ShopTable::getId, shopTableDTO.getId())); return update(shopTable, new QueryWrapper().eq(ShopTable::getShopId, StpKit.USER.getShopId()).eq(ShopTable::getId, shopTableDTO.getId()));
} }
@@ -282,7 +282,7 @@ public class ShopTableServiceImpl extends ServiceImpl<ShopTableMapper, ShopTable
public Boolean clear(long shopId, ShopTableClearDTO shopTableClearDTO) { public Boolean clear(long shopId, ShopTableClearDTO shopTableClearDTO) {
ShopTable shopTable = getOne(new QueryWrapper().eq(ShopTable::getShopId, shopId).eq(ShopTable::getId, shopTableClearDTO.getId())); ShopTable shopTable = getOne(new QueryWrapper().eq(ShopTable::getShopId, shopId).eq(ShopTable::getId, shopTableClearDTO.getId()));
if (!ShopTableStatusEnum.SETTLED.equalsVal(shopTable.getStatus())) { if (!ShopTableStatusEnum.SETTLED.equalsVal(shopTable.getStatus())) {
throw new ApiNotPrintException("台桌不处于待清台状态"); throw new CzgException("台桌不处于待清台状态");
} }
shopTable.setStatus(ShopTableStatusEnum.IDLE.getValue()); shopTable.setStatus(ShopTableStatusEnum.IDLE.getValue());
shopTable.setEndTime(DateUtil.date().toLocalDateTime()); shopTable.setEndTime(DateUtil.date().toLocalDateTime());

View File

@@ -11,7 +11,7 @@ import com.czg.account.service.ShopUserFlowService;
import com.czg.account.service.ShopUserService; import com.czg.account.service.ShopUserService;
import com.czg.account.service.UserInfoService; import com.czg.account.service.UserInfoService;
import com.czg.enums.ShopUserFlowBizEnum; import com.czg.enums.ShopUserFlowBizEnum;
import com.czg.exception.ApiNotPrintException; import com.czg.exception.CzgException;
import com.czg.market.entity.MemberLevelConfig; import com.czg.market.entity.MemberLevelConfig;
import com.czg.market.service.MemberLevelConfigService; import com.czg.market.service.MemberLevelConfigService;
import com.czg.market.service.TbMemberConfigService; import com.czg.market.service.TbMemberConfigService;
@@ -58,7 +58,7 @@ public class ShopUserServiceImpl extends ServiceImpl<ShopUserMapper, ShopUser> i
private ShopUser getUserInfo(Long shopUserId) { private ShopUser getUserInfo(Long shopUserId) {
ShopUser shopUser = queryChain().eq(ShopUser::getId, shopUserId).one(); ShopUser shopUser = queryChain().eq(ShopUser::getId, shopUserId).one();
if (shopUser == null) { if (shopUser == null) {
throw new ApiNotPrintException("用户信息不存在"); throw new CzgException("用户信息不存在");
} }
return shopUser; return shopUser;
} }
@@ -128,7 +128,7 @@ public class ShopUserServiceImpl extends ServiceImpl<ShopUserMapper, ShopUser> i
flag = mapper.incrAccount(shopUserEditDTO.getId(), DateUtil.date().toLocalDateTime(), shopUserEditDTO.getMoney()); flag = mapper.incrAccount(shopUserEditDTO.getId(), DateUtil.date().toLocalDateTime(), shopUserEditDTO.getMoney());
} }
if (flag == 0) { if (flag == 0) {
throw new ApiNotPrintException("增减用户余额操作失败"); throw new CzgException("增减用户余额操作失败");
} }
if (userInfo.getAmount() == null) { if (userInfo.getAmount() == null) {

View File

@@ -7,19 +7,16 @@ import com.alibaba.fastjson2.JSONObject;
import com.czg.account.dto.menu.MenuAddDTO; import com.czg.account.dto.menu.MenuAddDTO;
import com.czg.account.dto.menu.MenuEditDTO; import com.czg.account.dto.menu.MenuEditDTO;
import com.czg.account.entity.CashMenu; import com.czg.account.entity.CashMenu;
import com.czg.account.entity.ShopInfo;
import com.czg.account.entity.SysMenu; import com.czg.account.entity.SysMenu;
import com.czg.account.entity.SysUsersRoles;
import com.czg.account.service.CashMenuService; import com.czg.account.service.CashMenuService;
import com.czg.account.service.ShopInfoService; import com.czg.account.service.ShopInfoService;
import com.czg.account.service.SysMenuService; import com.czg.account.service.SysMenuService;
import com.czg.account.vo.MenuVO; import com.czg.account.vo.MenuVO;
import com.czg.exception.ApiNotPrintException; import com.czg.exception.CzgException;
import com.czg.sa.StpKit; import com.czg.sa.StpKit;
import com.czg.service.account.mapper.SysMenuMapper; import com.czg.service.account.mapper.SysMenuMapper;
import com.czg.service.account.mapper.SysUsersRolesMapper; import com.czg.service.account.mapper.SysUsersRolesMapper;
import com.mybatisflex.core.query.QueryWrapper; import com.mybatisflex.core.query.QueryWrapper;
import com.mybatisflex.core.row.DbChain;
import com.mybatisflex.spring.service.impl.ServiceImpl; import com.mybatisflex.spring.service.impl.ServiceImpl;
import jakarta.annotation.Resource; import jakarta.annotation.Resource;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
@@ -99,15 +96,15 @@ public class SysMenuServiceImpl extends ServiceImpl<SysMenuMapper, SysMenu> impl
public Boolean add(MenuAddDTO menuAddDTO) { public Boolean add(MenuAddDTO menuAddDTO) {
checkExIsis(menuAddDTO.getTitle(), null); checkExIsis(menuAddDTO.getTitle(), null);
if (menuAddDTO.getType() == 2 && menuAddDTO.getPid() == null) { if (menuAddDTO.getType() == 2 && menuAddDTO.getPid() == null) {
throw new ApiNotPrintException("二级菜单必须传递父id"); throw new CzgException("二级菜单必须传递父id");
} }
if (menuAddDTO.getType() == 3 && menuAddDTO.getPid() == null) { if (menuAddDTO.getType() == 3 && menuAddDTO.getPid() == null) {
throw new ApiNotPrintException("父id不为空"); throw new CzgException("父id不为空");
} }
if (menuAddDTO.getType() == 3 && menuAddDTO.getPermission() == null) { if (menuAddDTO.getType() == 3 && menuAddDTO.getPermission() == null) {
throw new ApiNotPrintException("权限不为空"); throw new CzgException("权限不为空");
} }
SysMenu sysMenu = BeanUtil.copyProperties(menuAddDTO, SysMenu.class); SysMenu sysMenu = BeanUtil.copyProperties(menuAddDTO, SysMenu.class);
if (menuAddDTO.getApiInfo() != null && !menuAddDTO.getApiInfo().isEmpty()) { if (menuAddDTO.getApiInfo() != null && !menuAddDTO.getApiInfo().isEmpty()) {
@@ -121,7 +118,7 @@ public class SysMenuServiceImpl extends ServiceImpl<SysMenuMapper, SysMenu> impl
checkExIsis(menuEditDTO.getTitle(), menuEditDTO.getId()); checkExIsis(menuEditDTO.getTitle(), menuEditDTO.getId());
SysMenu menu = getById(menuEditDTO.getId()); SysMenu menu = getById(menuEditDTO.getId());
if (menu == null) { if (menu == null) {
throw new ApiNotPrintException("菜单不存在"); throw new CzgException("菜单不存在");
} }
BeanUtil.copyProperties(menuEditDTO, menu); BeanUtil.copyProperties(menuEditDTO, menu);
if (menuEditDTO.getApiInfo() != null && !menuEditDTO.getApiInfo().isEmpty()) { if (menuEditDTO.getApiInfo() != null && !menuEditDTO.getApiInfo().isEmpty()) {
@@ -139,7 +136,7 @@ public class SysMenuServiceImpl extends ServiceImpl<SysMenuMapper, SysMenu> impl
// queryWrapper.eq(SysMenu::getTitle, title); // queryWrapper.eq(SysMenu::getTitle, title);
// long count = count(queryWrapper); // long count = count(queryWrapper);
// if (count > 0) { // if (count > 0) {
// throw new ApiNotPrintException("名称已存在"); // throw new CzgException("名称已存在");
// } // }
} }

View File

@@ -14,7 +14,7 @@ import com.czg.account.service.CashMenuService;
import com.czg.account.service.SysMenuService; import com.czg.account.service.SysMenuService;
import com.czg.account.service.SysRoleService; import com.czg.account.service.SysRoleService;
import com.czg.account.service.SysRolesMenusService; import com.czg.account.service.SysRolesMenusService;
import com.czg.exception.ApiNotPrintException; import com.czg.exception.CzgException;
import com.czg.sa.StpKit; import com.czg.sa.StpKit;
import com.czg.service.account.mapper.SysRoleMapper; import com.czg.service.account.mapper.SysRoleMapper;
import com.mybatisflex.core.paginate.Page; import com.mybatisflex.core.paginate.Page;
@@ -25,7 +25,6 @@ import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional; import org.springframework.transaction.annotation.Transactional;
import java.util.*; import java.util.*;
import java.util.concurrent.CompletableFuture;
import java.util.stream.Collectors; import java.util.stream.Collectors;
import static com.mybatisflex.core.query.QueryMethods.column; import static com.mybatisflex.core.query.QueryMethods.column;
@@ -120,7 +119,7 @@ public class SysRoleServiceImpl extends ServiceImpl<SysRoleMapper, SysRole> imp
public List<Long> getRoleMenu(long userId, Integer id, Integer type) { public List<Long> getRoleMenu(long userId, Integer id, Integer type) {
SysRole role = queryChain().eq(SysRole::getId, id).eq(SysRole::getCreateUserId, userId).one(); SysRole role = queryChain().eq(SysRole::getId, id).eq(SysRole::getCreateUserId, userId).one();
if (role == null) { if (role == null) {
throw new ApiNotPrintException("角色不存在"); throw new CzgException("角色不存在");
} }
return sysRolesMenusService.queryChain().eq(SysRolesMenus::getRoleId, id).eq(SysRolesMenus::getType, type).list().stream().map(SysRolesMenus::getMenuId).toList(); return sysRolesMenusService.queryChain().eq(SysRolesMenus::getRoleId, id).eq(SysRolesMenus::getType, type).list().stream().map(SysRolesMenus::getMenuId).toList();
@@ -191,7 +190,7 @@ public class SysRoleServiceImpl extends ServiceImpl<SysRoleMapper, SysRole> imp
public Boolean editPermission(long userId, RolePermissionDTO rolePermissionDTO) { public Boolean editPermission(long userId, RolePermissionDTO rolePermissionDTO) {
long count = count(new QueryWrapper().eq(SysRole::getId, rolePermissionDTO.getRoleId()).eq(SysRole::getCreateUserId, userId)); long count = count(new QueryWrapper().eq(SysRole::getId, rolePermissionDTO.getRoleId()).eq(SysRole::getCreateUserId, userId));
if (count == 0) { if (count == 0) {
throw new ApiNotPrintException("角色不存在"); throw new CzgException("角色不存在");
} }
sysRolesMenusService.updateChain().eq(SysRolesMenus::getRoleId, rolePermissionDTO.getRoleId()).remove(); sysRolesMenusService.updateChain().eq(SysRolesMenus::getRoleId, rolePermissionDTO.getRoleId()).remove();
@@ -212,7 +211,7 @@ public class SysRoleServiceImpl extends ServiceImpl<SysRoleMapper, SysRole> imp
.eq(SysRole::getShopId, StpKit.USER.getShopId()) .eq(SysRole::getShopId, StpKit.USER.getShopId())
.count(); .count();
if (roleCount > 0) { if (roleCount > 0) {
throw new ApiNotPrintException("此角色名称已存在"); throw new CzgException("此角色名称已存在");
} }
SysRole sysRole = new SysRole(); SysRole sysRole = new SysRole();
@@ -236,7 +235,7 @@ public class SysRoleServiceImpl extends ServiceImpl<SysRoleMapper, SysRole> imp
return save; return save;
} }
throw new ApiNotPrintException("保存失败"); throw new CzgException("保存失败");
} }
@Override @Override
@@ -244,13 +243,13 @@ public class SysRoleServiceImpl extends ServiceImpl<SysRoleMapper, SysRole> imp
public Boolean edit(RoleEditDTO roleEditDTO) { public Boolean edit(RoleEditDTO roleEditDTO) {
SysRole role = queryChain().eq(SysRole::getId, roleEditDTO.getId()).eq(SysRole::getCreateUserId, StpKit.USER.getLoginIdAsLong()).one(); SysRole role = queryChain().eq(SysRole::getId, roleEditDTO.getId()).eq(SysRole::getCreateUserId, StpKit.USER.getLoginIdAsLong()).one();
if (role == null) { if (role == null) {
throw new ApiNotPrintException("角色不存在"); throw new CzgException("角色不存在");
} }
long roleCount = queryChain().eq(SysRole::getName, roleEditDTO.getName()).ne(SysRole::getId, roleEditDTO.getId()) long roleCount = queryChain().eq(SysRole::getName, roleEditDTO.getName()).ne(SysRole::getId, roleEditDTO.getId())
.eq(SysRole::getShopId, StpKit.USER.getShopId()).count(); .eq(SysRole::getShopId, StpKit.USER.getShopId()).count();
if (roleCount > 0) { if (roleCount > 0) {
throw new ApiNotPrintException("此角色名称已存在"); throw new CzgException("此角色名称已存在");
} }
BeanUtil.copyProperties(roleEditDTO, role); BeanUtil.copyProperties(roleEditDTO, role);
@@ -268,7 +267,7 @@ public class SysRoleServiceImpl extends ServiceImpl<SysRoleMapper, SysRole> imp
} }
return true; return true;
} }
throw new ApiNotPrintException("保存失败"); throw new CzgException("保存失败");
} }
public static void main(String[] args) { public static void main(String[] args) {

View File

@@ -14,7 +14,6 @@ import com.czg.account.entity.SysUser;
import com.czg.account.entity.SysUsersRoles; import com.czg.account.entity.SysUsersRoles;
import com.czg.account.service.SysUserService; import com.czg.account.service.SysUserService;
import com.czg.account.vo.SysUserDetailVO; import com.czg.account.vo.SysUserDetailVO;
import com.czg.exception.ApiNotPrintException;
import com.czg.exception.CzgException; import com.czg.exception.CzgException;
import com.czg.sa.StpKit; import com.czg.sa.StpKit;
import com.czg.service.RedisService; import com.czg.service.RedisService;
@@ -57,7 +56,7 @@ public class SysUserServiceImpl extends ServiceImpl<SysUserMapper, SysUser> impl
public SysUser addUser(String nickname, String accountName, String accountPwd, String phone, Long roleId) { public SysUser addUser(String nickname, String accountName, String accountPwd, String phone, Long roleId) {
long count = queryChain().eq(SysUser::getAccount, accountName).count(); long count = queryChain().eq(SysUser::getAccount, accountName).count();
if (count > 0) { if (count > 0) {
throw new ApiNotPrintException("账号已存在"); throw new CzgException("账号已存在");
} }
// 添加系统账号 // 添加系统账号
SysUser sysUser = new SysUser(); SysUser sysUser = new SysUser();
@@ -111,7 +110,7 @@ public class SysUserServiceImpl extends ServiceImpl<SysUserMapper, SysUser> impl
if (StrUtil.isNotBlank(sysUserEditDTO.getAccount())) { if (StrUtil.isNotBlank(sysUserEditDTO.getAccount())) {
long count = count(new QueryWrapper().eq(SysUser::getAccount, sysUserEditDTO.getAccount()).ne(SysUser::getId, sysUserEditDTO.getId())); long count = count(new QueryWrapper().eq(SysUser::getAccount, sysUserEditDTO.getAccount()).ne(SysUser::getId, sysUserEditDTO.getId()));
if (count > 0) { if (count > 0) {
throw new ApiNotPrintException("账号已存在"); throw new CzgException("账号已存在");
} }
} }
@@ -135,7 +134,7 @@ public class SysUserServiceImpl extends ServiceImpl<SysUserMapper, SysUser> impl
public Boolean delete(Integer id) { public Boolean delete(Integer id) {
SysUser sysUser = getById(id); SysUser sysUser = getById(id);
if (sysUser == null) { if (sysUser == null) {
throw new ApiNotPrintException("用户不存在"); throw new CzgException("用户不存在");
} }
boolean remove = remove(new QueryWrapper().eq(SysUser::getId, id)); boolean remove = remove(new QueryWrapper().eq(SysUser::getId, id));
if (remove) { if (remove) {
@@ -149,7 +148,7 @@ public class SysUserServiceImpl extends ServiceImpl<SysUserMapper, SysUser> impl
public Boolean add(SysUserAddDTO sysUserAddDTO) { public Boolean add(SysUserAddDTO sysUserAddDTO) {
long count = count(new QueryWrapper().eq(SysUser::getAccount, sysUserAddDTO.getAccount())); long count = count(new QueryWrapper().eq(SysUser::getAccount, sysUserAddDTO.getAccount()));
if (count > 0) { if (count > 0) {
throw new ApiNotPrintException("账号已存在"); throw new CzgException("账号已存在");
} }
SysUser sysUser = BeanUtil.copyProperties(sysUserAddDTO, SysUser.class); SysUser sysUser = BeanUtil.copyProperties(sysUserAddDTO, SysUser.class);
@@ -214,11 +213,11 @@ public class SysUserServiceImpl extends ServiceImpl<SysUserMapper, SysUser> impl
if (StrUtil.isNotBlank(sysUserEditPwdDTO.getOriginalPassword()) && if (StrUtil.isNotBlank(sysUserEditPwdDTO.getOriginalPassword()) &&
!sysUser.getPassword().equals(SecureUtil.md5(sysUser.getId() + sysUserEditPwdDTO.getOriginalPassword()))) { !sysUser.getPassword().equals(SecureUtil.md5(sysUser.getId() + sysUserEditPwdDTO.getOriginalPassword()))) {
throw new ApiNotPrintException("原密码不正确"); throw new CzgException("原密码不正确");
} }
if (!sysUserEditPwdDTO.getPassword().equals(sysUserEditPwdDTO.getCheckPassword())) { if (!sysUserEditPwdDTO.getPassword().equals(sysUserEditPwdDTO.getCheckPassword())) {
throw new ApiNotPrintException("两次密码不一致"); throw new CzgException("两次密码不一致");
} }
sysUser.setPassword(SecureUtil.md5(sysUser.getId() + sysUserEditPwdDTO.getPassword())); sysUser.setPassword(SecureUtil.md5(sysUser.getId() + sysUserEditPwdDTO.getPassword()));

View File

@@ -11,7 +11,7 @@ import com.czg.account.dto.shopuser.ShopUserVipCardDTO;
import com.czg.account.entity.*; import com.czg.account.entity.*;
import com.czg.account.service.*; import com.czg.account.service.*;
import com.czg.config.RedisCst; import com.czg.config.RedisCst;
import com.czg.exception.ApiNotPrintException; import com.czg.exception.CzgException;
import com.czg.market.entity.MkShopCouponRecord; import com.czg.market.entity.MkShopCouponRecord;
import com.czg.market.service.MkShopCouponRecordService; import com.czg.market.service.MkShopCouponRecordService;
import com.czg.market.service.TbMemberConfigService; import com.czg.market.service.TbMemberConfigService;
@@ -30,10 +30,8 @@ import com.mybatisflex.core.query.QueryWrapper;
import jakarta.annotation.Resource; import jakarta.annotation.Resource;
import org.apache.dubbo.config.annotation.DubboReference; import org.apache.dubbo.config.annotation.DubboReference;
import org.apache.dubbo.config.annotation.DubboService; import org.apache.dubbo.config.annotation.DubboService;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional; import org.springframework.transaction.annotation.Transactional;
import java.math.BigDecimal;
import java.util.List; import java.util.List;
@@ -194,7 +192,7 @@ public class UShopUserServiceImpl implements UShopUserService {
ShopUser shopUser = shopUserService.getShopUserInfo(mainId, userId); ShopUser shopUser = shopUserService.getShopUserInfo(mainId, userId);
UserInfo userInfo = userInfoService.getById(userId); UserInfo userInfo = userInfoService.getById(userId);
if (userInfo == null) { if (userInfo == null) {
throw new ApiNotPrintException("用户信息不存在"); throw new CzgException("用户信息不存在");
} }
long couponNum = 0; long couponNum = 0;

View File

@@ -12,7 +12,6 @@ import com.czg.account.service.UserAuthorizationService;
import com.czg.account.service.UserInfoService; import com.czg.account.service.UserInfoService;
import com.czg.enums.StatusEnum; import com.czg.enums.StatusEnum;
import com.czg.enums.UserAuthSourceEnum; import com.czg.enums.UserAuthSourceEnum;
import com.czg.exception.ApiNotPrintException;
import com.czg.exception.CzgException; import com.czg.exception.CzgException;
import com.czg.sa.MyStpLogic; import com.czg.sa.MyStpLogic;
import com.czg.sa.StpKit; import com.czg.sa.StpKit;
@@ -80,7 +79,7 @@ public class UserAuthorizationServiceImpl implements UserAuthorizationService {
if (jsonObject.containsKey("phoneNumber")) { if (jsonObject.containsKey("phoneNumber")) {
mobile = jsonObject.getString("phoneNumber"); mobile = jsonObject.getString("phoneNumber");
} else { } else {
throw new ApiNotPrintException("手机号获取失败"); throw new CzgException("手机号获取失败");
} }
} }
@@ -133,6 +132,9 @@ public class UserAuthorizationServiceImpl implements UserAuthorizationService {
* 初始化用户微信公众号二维码\ * 初始化用户微信公众号二维码\
*/ */
private void initAc(UserInfo userInfo) { private void initAc(UserInfo userInfo) {
if (userInfo.getIsAc() == null) {
userInfo.setIsAc(0);
}
if (userInfo.getIsAc() == 0 && if (userInfo.getIsAc() == 0 &&
(StrUtil.isBlank(userInfo.getWechatAcQrcode()) || userInfo.getAcQrcodeValidTime() == null || userInfo.getAcQrcodeValidTime().isBefore(LocalDateTime.now()))) { (StrUtil.isBlank(userInfo.getWechatAcQrcode()) || userInfo.getAcQrcodeValidTime() == null || userInfo.getAcQrcodeValidTime().isBefore(LocalDateTime.now()))) {
String qrCode = acAccountUtil.createQrCode(userInfo.getId()); String qrCode = acAccountUtil.createQrCode(userInfo.getId());

View File

@@ -12,7 +12,6 @@ import com.czg.account.entity.ShopUser;
import com.czg.account.entity.UserInfo; import com.czg.account.entity.UserInfo;
import com.czg.account.service.UserInfoService; import com.czg.account.service.UserInfoService;
import com.czg.config.RedisCst; import com.czg.config.RedisCst;
import com.czg.exception.ApiNotPrintException;
import com.czg.exception.CzgException; import com.czg.exception.CzgException;
import com.czg.service.RedisService; import com.czg.service.RedisService;
import com.czg.service.account.mapper.ShopUserMapper; import com.czg.service.account.mapper.ShopUserMapper;
@@ -46,7 +45,7 @@ public class UserInfoServiceImpl extends ServiceImpl<UserInfoMapper, UserInfo> i
public UserInfoDTO getInfo(long userInfoId) { public UserInfoDTO getInfo(long userInfoId) {
UserInfo userInfo = queryChain().eq(UserInfo::getId, userInfoId).one(); UserInfo userInfo = queryChain().eq(UserInfo::getId, userInfoId).one();
if (userInfo == null) { if (userInfo == null) {
throw new ApiNotPrintException("用户信息不存在"); throw new CzgException("用户信息不存在");
} }
UserInfoAssetsSummaryDTO assetsSummaryDTO = shopUserMapper.selectAssetsSummary(userInfoId); UserInfoAssetsSummaryDTO assetsSummaryDTO = shopUserMapper.selectAssetsSummary(userInfoId);
@@ -72,7 +71,7 @@ public class UserInfoServiceImpl extends ServiceImpl<UserInfoMapper, UserInfo> i
public Boolean getCode(Long userId, String type) { public Boolean getCode(Long userId, String type) {
UserInfo userInfo = queryChain().eq(UserInfo::getId, userId).one(); UserInfo userInfo = queryChain().eq(UserInfo::getId, userId).one();
if (StrUtil.isBlank(userInfo.getPhone())) { if (StrUtil.isBlank(userInfo.getPhone())) {
throw new ApiNotPrintException("账号未绑定手机号"); throw new CzgException("账号未绑定手机号");
} }
int code = RandomUtil.randomInt(100000, 1000000); int code = RandomUtil.randomInt(100000, 1000000);
redisService.set("%s%s:%s".formatted(RedisCst.SMS_CODE, userInfo.getPhone(), type), String.valueOf(code), 300); redisService.set("%s%s:%s".formatted(RedisCst.SMS_CODE, userInfo.getPhone(), type), String.valueOf(code), 300);
@@ -86,7 +85,7 @@ public class UserInfoServiceImpl extends ServiceImpl<UserInfoMapper, UserInfo> i
String key = "%s%s:%s".formatted(RedisCst.SMS_CODE, userInfo.getPhone(), "wxMiniPwd"); String key = "%s%s:%s".formatted(RedisCst.SMS_CODE, userInfo.getPhone(), "wxMiniPwd");
Object val = redisService.get(key); Object val = redisService.get(key);
if (val instanceof String code && !userInfoPwdEditDTO.getCode().equals(code)) { if (val instanceof String code && !userInfoPwdEditDTO.getCode().equals(code)) {
throw new ApiNotPrintException("验证码错误"); throw new CzgException("验证码错误");
} }
if (StrUtil.isNotBlank(userInfoPwdEditDTO.getCheckPayPwd())) { if (StrUtil.isNotBlank(userInfoPwdEditDTO.getCheckPayPwd())) {

View File

@@ -1,16 +1,12 @@
package com.czg.service.account.util; package com.czg.service.account.util;
import com.czg.exception.ApiNotPrintException;
import com.czg.service.RedisService;
import jakarta.annotation.Resource; import jakarta.annotation.Resource;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.springframework.data.redis.core.RedisTemplate; import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.data.redis.core.StringRedisTemplate;
import org.springframework.data.redis.core.script.DefaultRedisScript; import org.springframework.data.redis.core.script.DefaultRedisScript;
import org.springframework.stereotype.Component; import org.springframework.stereotype.Component;
import java.util.Collections; import java.util.Collections;
import java.util.UUID;
import java.util.concurrent.TimeUnit; import java.util.concurrent.TimeUnit;
import java.util.function.Consumer; import java.util.function.Consumer;
import java.util.function.Function; import java.util.function.Function;

View File

@@ -4,7 +4,7 @@ import cn.hutool.core.bean.BeanUtil;
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.constant.TableValueConstant; import com.czg.constant.TableValueConstant;
import com.czg.exception.ApiNotPrintException; import com.czg.exception.CzgException;
import com.czg.market.dto.MkConsumeDiscountDTO; import com.czg.market.dto.MkConsumeDiscountDTO;
import com.czg.market.entity.MkConsumeDiscountRandom; import com.czg.market.entity.MkConsumeDiscountRandom;
import com.czg.market.vo.MkConsumeDiscountVO; import com.czg.market.vo.MkConsumeDiscountVO;
@@ -55,26 +55,26 @@ public class MkConsumeDiscountServiceImpl extends ServiceImpl<MkConsumeDiscountM
@CacheEvict(key = "#shopId") @CacheEvict(key = "#shopId")
public Boolean edit(Long shopId, MkConsumeDiscountDTO consumeDiscountDTO) { public Boolean edit(Long shopId, MkConsumeDiscountDTO consumeDiscountDTO) {
if (consumeDiscountDTO.getRandomDiscountList() == null && consumeDiscountDTO.getDiscountAmount() == null) { if (consumeDiscountDTO.getRandomDiscountList() == null && consumeDiscountDTO.getDiscountAmount() == null) {
throw new ApiNotPrintException("优惠金额和随机优惠金额不能同时为空"); throw new CzgException("优惠金额和随机优惠金额不能同时为空");
} }
MkConsumeDiscount consumeDiscount = getOne(new QueryWrapper().eq(MkConsumeDiscount::getShopId, shopId)); MkConsumeDiscount consumeDiscount = getOne(new QueryWrapper().eq(MkConsumeDiscount::getShopId, shopId));
BeanUtil.copyProperties(consumeDiscountDTO, consumeDiscount); BeanUtil.copyProperties(consumeDiscountDTO, consumeDiscount);
if (TableValueConstant.ConsumeDiscount.DiscountType.RANDOM.getCode().equals(consumeDiscountDTO.getDiscountType())) { if (TableValueConstant.ConsumeDiscount.DiscountType.RANDOM.getCode().equals(consumeDiscountDTO.getDiscountType())) {
if (consumeDiscountDTO.getRandomDiscountList() == null || consumeDiscountDTO.getRandomDiscountList().isEmpty()) { if (consumeDiscountDTO.getRandomDiscountList() == null || consumeDiscountDTO.getRandomDiscountList().isEmpty()) {
throw new ApiNotPrintException("随机优惠金额不能为空"); throw new CzgException("随机优惠金额不能为空");
} }
if (consumeDiscountDTO.getRandomDiscountList().stream().map(MkConsumeDiscountRandom::getProbability).reduce(BigDecimal.ZERO, BigDecimal::add).compareTo(new BigDecimal("100")) != 0) { if (consumeDiscountDTO.getRandomDiscountList().stream().map(MkConsumeDiscountRandom::getProbability).reduce(BigDecimal.ZERO, BigDecimal::add).compareTo(new BigDecimal("100")) != 0) {
throw new ApiNotPrintException("随机概率综合必须为100%"); throw new CzgException("随机概率综合必须为100%");
} }
consumeDiscount.setRandomDiscountList(JSONArray.toJSONString(consumeDiscountDTO.getRandomDiscountList())); consumeDiscount.setRandomDiscountList(JSONArray.toJSONString(consumeDiscountDTO.getRandomDiscountList()));
} else { } else {
if (consumeDiscountDTO.getDiscountAmount() == null) { if (consumeDiscountDTO.getDiscountAmount() == null) {
throw new ApiNotPrintException("减免金额不能为空"); throw new CzgException("减免金额不能为空");
} }
if (consumeDiscountDTO.getDiscountAmount().compareTo(BigDecimal.ZERO) <= 0) { if (consumeDiscountDTO.getDiscountAmount().compareTo(BigDecimal.ZERO) <= 0) {
throw new ApiNotPrintException("减免金额不能等于0"); throw new CzgException("减免金额不能等于0");
} }
} }

View File

@@ -5,7 +5,7 @@ import cn.hutool.core.date.DateUtil;
import com.czg.account.entity.ShopUser; import com.czg.account.entity.ShopUser;
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.exception.ApiNotPrintException; import com.czg.exception.CzgException;
import com.czg.market.entity.MkConsumeDiscountRandom; import com.czg.market.entity.MkConsumeDiscountRandom;
import com.czg.market.service.MkConsumeDiscountService; import com.czg.market.service.MkConsumeDiscountService;
import com.czg.market.vo.MkConsumeDiscountVO; import com.czg.market.vo.MkConsumeDiscountVO;
@@ -20,10 +20,8 @@ import com.czg.market.service.MkShopConsumeDiscountRecordService;
import com.czg.service.market.mapper.MkShopConsumeDiscountRecordMapper; import com.czg.service.market.mapper.MkShopConsumeDiscountRecordMapper;
import jakarta.annotation.Resource; import jakarta.annotation.Resource;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.apache.dubbo.auth.v1alpha1.Ca;
import org.apache.dubbo.config.annotation.DubboReference; import org.apache.dubbo.config.annotation.DubboReference;
import org.apache.dubbo.config.annotation.DubboService; import org.apache.dubbo.config.annotation.DubboService;
import org.springframework.stereotype.Service;
import java.math.BigDecimal; import java.math.BigDecimal;
import java.util.List; import java.util.List;
@@ -56,19 +54,19 @@ public class MkShopConsumeDiscountRecordServiceImpl extends ServiceImpl<MkShopCo
private MkConsumeDiscountVO canUse(Long shopId, Long userId) { private MkConsumeDiscountVO canUse(Long shopId, Long userId) {
MkConsumeDiscountVO consumeDiscountVO = consumeDiscountService.detail(shopId); MkConsumeDiscountVO consumeDiscountVO = consumeDiscountService.detail(shopId);
if (consumeDiscountVO.getIsEnable() != 1) { if (consumeDiscountVO.getIsEnable() != 1) {
throw new ApiNotPrintException("新客立减未开启"); throw new CzgException("新客立减未开启");
} }
DateTime now = DateUtil.date(); DateTime now = DateUtil.date();
if (!now.isAfterOrEquals(DateUtil.date(consumeDiscountVO.getStartTime())) || !now.isBeforeOrEquals(DateUtil.date(consumeDiscountVO.getEndTime()))) { if (!now.isAfterOrEquals(DateUtil.date(consumeDiscountVO.getStartTime())) || !now.isBeforeOrEquals(DateUtil.date(consumeDiscountVO.getEndTime()))) {
throw new ApiNotPrintException("此时间段未开启新客立减"); throw new CzgException("此时间段未开启新客立减");
} }
// 随机金额概率加起来是100 // 随机金额概率加起来是100
List<MkConsumeDiscountRandom> randomList = consumeDiscountVO.getRandomDiscountList(); List<MkConsumeDiscountRandom> randomList = consumeDiscountVO.getRandomDiscountList();
if ("RANDOM".equals(consumeDiscountVO.getDiscountType()) && (randomList == null || randomList.isEmpty()) ){ if ("RANDOM".equals(consumeDiscountVO.getDiscountType()) && (randomList == null || randomList.isEmpty()) ){
throw new ApiNotPrintException("随机立减配置错误"); throw new CzgException("随机立减配置错误");
} }
ShopUser shopUser = shopUserService.getShopUserInfo(shopId, userId); ShopUser shopUser = shopUserService.getShopUserInfo(shopId, userId);
boolean exists = orderInfoService.exists(new QueryWrapper().eq(OrderInfo::getUserId, shopUser.getUserId()) boolean exists = orderInfoService.exists(new QueryWrapper().eq(OrderInfo::getUserId, shopUser.getUserId())
@@ -117,7 +115,7 @@ public class MkShopConsumeDiscountRecordServiceImpl extends ServiceImpl<MkShopCo
ShopUser shopUser = shopUserService.getOne(new QueryWrapper().eq(ShopUser::getUserId, userId).eq(ShopUser::getSourceShopId, shopId)); ShopUser shopUser = shopUserService.getOne(new QueryWrapper().eq(ShopUser::getUserId, userId).eq(ShopUser::getSourceShopId, shopId));
boolean newUser = isNewUser(shopUser, shopId); boolean newUser = isNewUser(shopUser, shopId);
if (!newUser) { if (!newUser) {
// throw new ApiNotPrintException("新客立减仅新用户可用"); // throw new CzgException("新客立减仅新用户可用");
log.info("新客立减仅限新用户使用"); log.info("新客立减仅限新用户使用");
return null; return null;
} }
@@ -158,7 +156,7 @@ public class MkShopConsumeDiscountRecordServiceImpl extends ServiceImpl<MkShopCo
// 随机金额概率加起来是100 // 随机金额概率加起来是100
List<MkConsumeDiscountRandom> randomList = consumeDiscountVO.getRandomDiscountList(); List<MkConsumeDiscountRandom> randomList = consumeDiscountVO.getRandomDiscountList();
if (randomList == null || randomList.isEmpty()) { if (randomList == null || randomList.isEmpty()) {
throw new ApiNotPrintException("随机立减配置错误"); throw new CzgException("随机立减配置错误");
} }
// 生成 1~100 的随机数 // 生成 1~100 的随机数
@@ -175,7 +173,7 @@ public class MkShopConsumeDiscountRecordServiceImpl extends ServiceImpl<MkShopCo
} }
} }
throw new ApiNotPrintException("随机立减计算失败"); throw new CzgException("随机立减计算失败");
} catch (Exception e) { } catch (Exception e) {
log.info(e.getMessage()); log.info(e.getMessage());
return null; return null;

View File

@@ -3,6 +3,7 @@ package com.czg.service.market.service.impl;
import cn.hutool.core.bean.BeanUtil; import cn.hutool.core.bean.BeanUtil;
import cn.hutool.core.collection.CollUtil; import cn.hutool.core.collection.CollUtil;
import cn.hutool.core.exceptions.ValidateException; import cn.hutool.core.exceptions.ValidateException;
import com.czg.exception.CzgException;
import com.czg.market.dto.MkCouponGiftDTO; import com.czg.market.dto.MkCouponGiftDTO;
import com.czg.market.dto.MkShopConsumerCouponDTO; import com.czg.market.dto.MkShopConsumerCouponDTO;
import com.czg.market.dto.MkShopCouponGiftDTO; import com.czg.market.dto.MkShopCouponGiftDTO;
@@ -115,7 +116,7 @@ public class MkShopConsumerCouponServiceImpl extends ServiceImpl<MkShopConsumerC
@Transactional @Transactional
public void addConsumerCoupon(MkShopConsumerCouponDTO param) { public void addConsumerCoupon(MkShopConsumerCouponDTO param) {
if (CollUtil.isEmpty(param.getCouponGiftList())) { if (CollUtil.isEmpty(param.getCouponGiftList())) {
throw new ValidateException("优惠券信息不能为空"); throw new CzgException("优惠券信息不能为空");
} }
MkShopConsumerCoupon bean = BeanUtil.toBean(param, MkShopConsumerCoupon.class); MkShopConsumerCoupon bean = BeanUtil.toBean(param, MkShopConsumerCoupon.class);
save(bean); save(bean);
@@ -132,7 +133,7 @@ public class MkShopConsumerCouponServiceImpl extends ServiceImpl<MkShopConsumerC
param.setLeftNum(-10086); param.setLeftNum(-10086);
} else { } else {
if (param.getGiveNum() < consumerCoupon.getGiftNum()) { if (param.getGiveNum() < consumerCoupon.getGiftNum()) {
throw new ValidateException("修改失败 总发放数量必须大于已发放数量"); throw new CzgException("修改失败 总发放数量必须大于已发放数量");
} else { } else {
param.setLeftNum(param.getGiveNum() - consumerCoupon.getGiftNum()); param.setLeftNum(param.getGiveNum() - consumerCoupon.getGiftNum());
} }
@@ -142,7 +143,7 @@ public class MkShopConsumerCouponServiceImpl extends ServiceImpl<MkShopConsumerC
param.setLeftNum(-10086); param.setLeftNum(-10086);
} else { } else {
if (param.getGiveNum() < consumerCoupon.getGiftNum()) { if (param.getGiveNum() < consumerCoupon.getGiftNum()) {
throw new ValidateException("修改失败 总发放数量必须大于已发放数量"); throw new CzgException("修改失败 总发放数量必须大于已发放数量");
} else { } else {
param.setLeftNum(param.getGiveNum() - consumerCoupon.getGiftNum()); param.setLeftNum(param.getGiveNum() - consumerCoupon.getGiftNum());
} }

View File

@@ -16,6 +16,7 @@ import com.czg.account.service.ShopUserService;
import com.czg.account.vo.ShopInfoCouponVO; import com.czg.account.vo.ShopInfoCouponVO;
import com.czg.account.vo.UserCouponFoodVo; import com.czg.account.vo.UserCouponFoodVo;
import com.czg.account.vo.UserCouponVo; import com.czg.account.vo.UserCouponVo;
import com.czg.exception.CzgException;
import com.czg.market.dto.MkShopCouponGiftDTO; import com.czg.market.dto.MkShopCouponGiftDTO;
import com.czg.market.dto.ShopCouponDTO; import com.czg.market.dto.ShopCouponDTO;
import com.czg.market.entity.MkShopCouponRecord; import com.czg.market.entity.MkShopCouponRecord;
@@ -191,7 +192,7 @@ public class ShopCouponServiceImpl extends ServiceImpl<ShopCouponMapper, ShopCou
if (tbShopCoupon.getGiveNum() == -10086) { if (tbShopCoupon.getGiveNum() == -10086) {
if (param.getGiveNum() != -10086) { if (param.getGiveNum() != -10086) {
if (param.getGiveNum() < tbShopCoupon.getGiftNum()) { if (param.getGiveNum() < tbShopCoupon.getGiftNum()) {
throw new ValidateException("修改失败 总发放数量必须大于已发放数量"); throw new CzgException("修改失败 总发放数量必须大于已发放数量");
} else { } else {
param.setLeftNum(param.getGiveNum() - tbShopCoupon.getGiftNum()); param.setLeftNum(param.getGiveNum() - tbShopCoupon.getGiftNum());
} }
@@ -201,7 +202,7 @@ public class ShopCouponServiceImpl extends ServiceImpl<ShopCouponMapper, ShopCou
param.setLeftNum(-10086); param.setLeftNum(-10086);
} else { } else {
if (param.getGiveNum() < tbShopCoupon.getGiftNum()) { if (param.getGiveNum() < tbShopCoupon.getGiftNum()) {
throw new ValidateException("修改失败 总发放数量必须大于已发放数量"); throw new CzgException("修改失败 总发放数量必须大于已发放数量");
} else { } else {
param.setLeftNum(param.getGiveNum() - tbShopCoupon.getGiftNum()); param.setLeftNum(param.getGiveNum() - tbShopCoupon.getGiftNum());
} }

View File

@@ -7,7 +7,6 @@ import cn.hutool.core.util.StrUtil;
import com.alibaba.fastjson2.JSONArray; import com.alibaba.fastjson2.JSONArray;
import com.alibaba.fastjson2.JSONObject; import com.alibaba.fastjson2.JSONObject;
import com.czg.constant.TableValueConstant; import com.czg.constant.TableValueConstant;
import com.czg.exception.ApiNotPrintException;
import com.czg.exception.CzgException; import com.czg.exception.CzgException;
import com.czg.market.dto.*; import com.czg.market.dto.*;
import com.czg.account.entity.*; import com.czg.account.entity.*;
@@ -19,14 +18,12 @@ import com.czg.order.entity.OrderInfo;
import com.czg.order.entity.OrderPayment; import com.czg.order.entity.OrderPayment;
import com.czg.order.service.OrderInfoService; import com.czg.order.service.OrderInfoService;
import com.czg.order.service.OrderPaymentService; import com.czg.order.service.OrderPaymentService;
import com.czg.sa.StpKit;
import com.czg.service.market.enums.OrderStatusEnums; import com.czg.service.market.enums.OrderStatusEnums;
import com.czg.service.market.mapper.TbMemberConfigMapper; import com.czg.service.market.mapper.TbMemberConfigMapper;
import com.czg.utils.AssertUtil; import com.czg.utils.AssertUtil;
import com.czg.validator.ValidatorUtil; import com.czg.validator.ValidatorUtil;
import com.czg.validator.group.member.MemberLevelCycleRewardGroup; import com.czg.validator.group.member.MemberLevelCycleRewardGroup;
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 lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.apache.dubbo.config.annotation.DubboReference; import org.apache.dubbo.config.annotation.DubboReference;
@@ -157,14 +154,14 @@ public class TbMemberConfigServiceImpl extends ServiceImpl<TbMemberConfigMapper,
BeanUtil.copyProperties(memberDTO, memberConfig); BeanUtil.copyProperties(memberDTO, memberConfig);
if ((memberDTO.getConfigList() == null || memberDTO.getConfigList().isEmpty()) && if ((memberDTO.getConfigList() == null || memberDTO.getConfigList().isEmpty()) &&
(memberDTO.getConditionList() == null || memberDTO.getConditionList().isEmpty())) { (memberDTO.getConditionList() == null || memberDTO.getConditionList().isEmpty())) {
throw new ApiNotPrintException("会员开通方式必须选择一个"); throw new CzgException("会员开通方式必须选择一个");
} }
if (memberDTO.getConfigList() != null && !memberDTO.getConfigList().isEmpty()) { if (memberDTO.getConfigList() != null && !memberDTO.getConfigList().isEmpty()) {
memberDTO.getConfigList().forEach(item -> { memberDTO.getConfigList().forEach(item -> {
if (item.getReward() == null && (item.getCouponList() == null || item.getCouponList().isEmpty())) { if (item.getReward() == null && (item.getCouponList() == null || item.getCouponList().isEmpty())) {
throw new ApiNotPrintException("方案列表中赠送成长值和赠送优惠券不能同时为空"); throw new CzgException("方案列表中赠送成长值和赠送优惠券不能同时为空");
} }
}); });
memberConfig.setConfigList(JSONObject.toJSONString(memberDTO.getConfigList())); memberConfig.setConfigList(JSONObject.toJSONString(memberDTO.getConfigList()));
@@ -172,14 +169,14 @@ public class TbMemberConfigServiceImpl extends ServiceImpl<TbMemberConfigMapper,
// if (memberConfig.getConfigList() != null && !memberConfig.getConfigList().isEmpty() && // if (memberConfig.getConfigList() != null && !memberConfig.getConfigList().isEmpty() &&
// (memberConfig.getConditionList() != null || !memberConfig.getConditionList().isEmpty())) { // (memberConfig.getConditionList() != null || !memberConfig.getConditionList().isEmpty())) {
// throw new ApiNotPrintException("会员开通方式为单选条件"); // throw new CzgException("会员开通方式为单选条件");
// } // }
if (memberDTO.getConditionList() != null && !memberDTO.getConditionList().isEmpty()) { if (memberDTO.getConditionList() != null && !memberDTO.getConditionList().isEmpty()) {
// ArrayList<String> conditionList = CollUtil.newArrayList(conditionMap); // ArrayList<String> conditionList = CollUtil.newArrayList(conditionMap);
memberDTO.getConditionList().forEach(item -> { memberDTO.getConditionList().forEach(item -> {
if (!conditionMap.contains(item.getCode())) { if (!conditionMap.contains(item.getCode())) {
throw new ApiNotPrintException("条件列表中code值错误"); throw new CzgException("条件列表中code值错误");
} }
}); });
// conditionList.forEach(item -> { // conditionList.forEach(item -> {
@@ -205,21 +202,21 @@ public class TbMemberConfigServiceImpl extends ServiceImpl<TbMemberConfigMapper,
private void checkLevelDto(Long shopId, MemberLevelDTO levelDTO) { private void checkLevelDto(Long shopId, MemberLevelDTO levelDTO) {
long count = levelConfigService.count(new QueryWrapper().eq(MemberLevelConfig::getShopId, shopId).eq(MemberLevelConfig::getName, levelDTO.getName()).ne(MemberLevelConfig::getId, levelDTO.getId())); long count = levelConfigService.count(new QueryWrapper().eq(MemberLevelConfig::getShopId, shopId).eq(MemberLevelConfig::getName, levelDTO.getName()).ne(MemberLevelConfig::getId, levelDTO.getId()));
if (count > 0) { if (count > 0) {
throw new ApiNotPrintException("会员等级名称已存在"); throw new CzgException("会员等级名称已存在");
} }
MemberLevelConfig lastConfig = levelConfigService.getOne(new QueryWrapper().eq(MemberLevelConfig::getShopId, shopId) MemberLevelConfig lastConfig = levelConfigService.getOne(new QueryWrapper().eq(MemberLevelConfig::getShopId, shopId)
.lt(MemberLevelConfig::getId, levelDTO.getId()) .lt(MemberLevelConfig::getId, levelDTO.getId())
.limit(1).orderBy(MemberLevelConfig::getExperienceValue, true).ne(MemberLevelConfig::getId, levelDTO.getId())); .limit(1).orderBy(MemberLevelConfig::getExperienceValue, true).ne(MemberLevelConfig::getId, levelDTO.getId()));
if (lastConfig == null && levelDTO.getExperienceValue() > 0) { if (lastConfig == null && levelDTO.getExperienceValue() > 0) {
throw new ApiNotPrintException("1级时本字段必须为0"); throw new CzgException("1级时本字段必须为0");
} else if (lastConfig != null && levelDTO.getExperienceValue() <= lastConfig.getExperienceValue()) { } else if (lastConfig != null && levelDTO.getExperienceValue() <= lastConfig.getExperienceValue()) {
throw new ApiNotPrintException("会员等级经验值必须大于上一等级经验值"); throw new CzgException("会员等级经验值必须大于上一等级经验值");
} }
if (levelDTO.getIsCycleReward() == 1) { if (levelDTO.getIsCycleReward() == 1) {
if (levelDTO.getCycleRewardPoints() == null && (levelDTO.getCycleRewardCouponList() == null || levelDTO.getCycleRewardCouponList().isEmpty())) { if (levelDTO.getCycleRewardPoints() == null && (levelDTO.getCycleRewardCouponList() == null || levelDTO.getCycleRewardCouponList().isEmpty())) {
throw new ApiNotPrintException("周期奖励成长值和优惠券不能同时为空"); throw new CzgException("周期奖励成长值和优惠券不能同时为空");
} }
ValidatorUtil.validateEntity(levelDTO, MemberLevelCycleRewardGroup.class); ValidatorUtil.validateEntity(levelDTO, MemberLevelCycleRewardGroup.class);
@@ -242,7 +239,7 @@ public class TbMemberConfigServiceImpl extends ServiceImpl<TbMemberConfigMapper,
@Override @Override
public Boolean editLevel(Long shopId, MemberLevelDTO levelDTO) { public Boolean editLevel(Long shopId, MemberLevelDTO levelDTO) {
MemberLevelConfig levelConfig = levelConfigService.getOne(new QueryWrapper().eq(MemberLevelConfig::getId, levelDTO.getId()).eq(MemberLevelConfig::getShopId, shopId)); MemberLevelConfig levelConfig = levelConfigService.getOne(new QueryWrapper().eq(MemberLevelConfig::getId, levelDTO.getId()).eq(MemberLevelConfig::getShopId, shopId));
Optional.ofNullable(levelConfig).orElseThrow(() -> new ApiNotPrintException("会员等级不存在")); Optional.ofNullable(levelConfig).orElseThrow(() -> new CzgException("会员等级不存在"));
Integer oldVal = levelConfig.getExperienceValue(); Integer oldVal = levelConfig.getExperienceValue();
checkLevelDto(shopId, levelDTO); checkLevelDto(shopId, levelDTO);
BeanUtil.copyProperties(levelDTO, levelConfig); BeanUtil.copyProperties(levelDTO, levelConfig);
@@ -495,7 +492,7 @@ public class TbMemberConfigServiceImpl extends ServiceImpl<TbMemberConfigMapper,
shopUser.setEndTime(shopUser.getEndTime().plusYears(memberOrder.getCircleTime())); shopUser.setEndTime(shopUser.getEndTime().plusYears(memberOrder.getCircleTime()));
break; break;
default: default:
throw new ApiNotPrintException("周期单位错误"); throw new CzgException("周期单位错误");
} }
shopUser.setMemberName(memberOrder.getName()); shopUser.setMemberName(memberOrder.getName());

View File

@@ -20,7 +20,6 @@ import com.czg.entity.notify.CzgPayNotifyDTO;
import com.czg.entity.notify.CzgRefundNotifyDTO; import com.czg.entity.notify.CzgRefundNotifyDTO;
import com.czg.enums.ShopTableStatusEnum; import com.czg.enums.ShopTableStatusEnum;
import com.czg.enums.ShopUserFlowBizEnum; import com.czg.enums.ShopUserFlowBizEnum;
import com.czg.exception.ApiNotPrintException;
import com.czg.exception.CzgException; import com.czg.exception.CzgException;
import com.czg.exception.OrderCancelException; import com.czg.exception.OrderCancelException;
import com.czg.exception.OrderValidateException; import com.czg.exception.OrderValidateException;
@@ -222,10 +221,10 @@ public class OrderInfoServiceImpl extends ServiceImpl<OrderInfoMapper, OrderInfo
@Override @Override
public HistoryOrderVo historyOrder(Long orderId, String tableCode) { public HistoryOrderVo historyOrder(Long orderId, String tableCode) {
if (orderId == null && StrUtil.isBlank(tableCode)) { if (orderId == null && StrUtil.isBlank(tableCode)) {
throw new ValidateException("订单id或台桌码不可为空"); throw new CzgException("订单id或台桌码不可为空");
} }
if (orderId == null && ("null".equals(tableCode) || "undefined".equals(tableCode))) { if (orderId == null && ("null".equals(tableCode) || "undefined".equals(tableCode))) {
throw new ValidateException("台桌码不可用"); throw new CzgException("台桌码不可用");
} }
HistoryOrderVo historyOrderVo; HistoryOrderVo historyOrderVo;
if (orderId == null) { if (orderId == null) {
@@ -268,7 +267,7 @@ public class OrderInfoServiceImpl extends ServiceImpl<OrderInfoMapper, OrderInfo
ShopInfo shopInfo = shopInfoService.getById(param.getShopId()); ShopInfo shopInfo = shopInfoService.getById(param.getShopId());
AssertUtil.isNull(shopInfo, "生成订单失败,店铺信息不存在"); AssertUtil.isNull(shopInfo, "生成订单失败,店铺信息不存在");
if (!shopInfo.getEatModel().contains(param.getDineMode())) { if (!shopInfo.getEatModel().contains(param.getDineMode())) {
throw new ValidateException("生成订单失败,店铺不支持该用餐模式"); throw new CzgException("生成订单失败,店铺不支持该用餐模式");
} }
if (param.getUserId() != null) { if (param.getUserId() != null) {
UserInfo userInfo = userInfoService.getById(param.getUserId()); UserInfo userInfo = userInfoService.getById(param.getUserId());
@@ -546,11 +545,11 @@ public class OrderInfoServiceImpl extends ServiceImpl<OrderInfoMapper, OrderInfo
@Override @Override
public CzgResult<Object> mergeOrder(MergeOrderDTO param) { public CzgResult<Object> mergeOrder(MergeOrderDTO param) {
if (param.getTargetOrderId() == null && StrUtil.isBlank(param.getTargetTableCode())) { if (param.getTargetOrderId() == null && StrUtil.isBlank(param.getTargetTableCode())) {
throw new ValidateException("转台失败,请选择目标台桌后转台"); throw new CzgException("转台失败,请选择目标台桌后转台");
} }
OrderInfo sourceOrder = getById(param.getSourceOrderId()); OrderInfo sourceOrder = getById(param.getSourceOrderId());
if (sourceOrder == null || !sourceOrder.getStatus().equals(OrderStatusEnums.UNPAID.getCode())) { if (sourceOrder == null || !sourceOrder.getStatus().equals(OrderStatusEnums.UNPAID.getCode())) {
throw new ValidateException("转台失败,无可转订单"); throw new CzgException("转台失败,无可转订单");
} }
OrderInfo targetOrder = queryChain() OrderInfo targetOrder = queryChain()
.eq(OrderInfo::getId, param.getTargetOrderId()) .eq(OrderInfo::getId, param.getTargetOrderId())
@@ -579,7 +578,7 @@ public class OrderInfoServiceImpl extends ServiceImpl<OrderInfoMapper, OrderInfo
if (CollUtil.isEmpty(param.getDetailIds())) { if (CollUtil.isEmpty(param.getDetailIds())) {
long count = orderDetailService.queryChain().eq(OrderDetail::getOrderId, sourceOrder.getId()).count(); long count = orderDetailService.queryChain().eq(OrderDetail::getOrderId, sourceOrder.getId()).count();
if (count < 1) { if (count < 1) {
throw new ValidateException("转台失败,该订单无可转商品"); throw new CzgException("转台失败,该订单无可转商品");
} }
orderDetailService.updateChain() orderDetailService.updateChain()
.eq(OrderDetail::getOrderId, sourceOrder.getId()) .eq(OrderDetail::getOrderId, sourceOrder.getId())
@@ -700,7 +699,7 @@ public class OrderInfoServiceImpl extends ServiceImpl<OrderInfoMapper, OrderInfo
ShopCoupon coupon = couponService.getById(record.getCouponId()); ShopCoupon coupon = couponService.getById(record.getCouponId());
AssertUtil.isNull(coupon, "生成支付订单失败,券信息不存在"); AssertUtil.isNull(coupon, "生成支付订单失败,券信息不存在");
// if (isVipPrice && coupon.getVipPriceShare() != 1) { // if (isVipPrice && coupon.getVipPriceShare() != 1) {
// throw new ValidateException("生成支付订单失败,券:" + coupon.getTitle() + "与会员价不共享"); // throw new CzgException("生成支付订单失败,券:" + coupon.getTitle() + "与会员价不共享");
// } // }
isUseLimit(coupon, record); isUseLimit(coupon, record);
// isUseTime(coupon); // isUseTime(coupon);
@@ -720,7 +719,7 @@ public class OrderInfoServiceImpl extends ServiceImpl<OrderInfoMapper, OrderInfo
.between(MkShopCouponRecord::getUseTime, LocalDateTime.now().with(LocalTime.MIN), LocalDateTime.now().with(LocalTime.MAX)) .between(MkShopCouponRecord::getUseTime, LocalDateTime.now().with(LocalTime.MIN), LocalDateTime.now().with(LocalTime.MAX))
); );
if (useNum >= coupon.getUseLimit()) { if (useNum >= coupon.getUseLimit()) {
throw new ValidateException("优惠券:" + coupon.getTitle() + " 已达到今日使用限量"); throw new CzgException("优惠券:" + coupon.getTitle() + " 已达到今日使用限量");
} }
} }
} }
@@ -730,7 +729,7 @@ public class OrderInfoServiceImpl extends ServiceImpl<OrderInfoMapper, OrderInfo
*/ */
private void isUseTime(ShopCoupon coupon) { private void isUseTime(ShopCoupon coupon) {
if (!coupon.getUseDays().contains(CzgStrUtils.getStrWeek())) { if (!coupon.getUseDays().contains(CzgStrUtils.getStrWeek())) {
throw new ValidateException("生成支付订单失败," + coupon.getTitle() + " 今天不可用"); throw new CzgException("生成支付订单失败," + coupon.getTitle() + " 今天不可用");
} }
if (!"all".equals(coupon.getUseTimeType())) { if (!"all".equals(coupon.getUseTimeType())) {
// 获取当前时间(仅包含时分秒) // 获取当前时间(仅包含时分秒)
@@ -739,13 +738,13 @@ public class OrderInfoServiceImpl extends ServiceImpl<OrderInfoMapper, OrderInfo
LocalTime endTime = coupon.getUseEndTime().toLocalTime(); LocalTime endTime = coupon.getUseEndTime().toLocalTime();
if (currentTime.isBefore(startTime)) { if (currentTime.isBefore(startTime)) {
if (startTime.isBefore(endTime)) { if (startTime.isBefore(endTime)) {
throw new ValidateException("生成支付订单失败,优惠券:" + coupon.getTitle() + " 当前时段不可用"); throw new CzgException("生成支付订单失败,优惠券:" + coupon.getTitle() + " 当前时段不可用");
} else if (currentTime.isAfter(endTime)) { } else if (currentTime.isAfter(endTime)) {
throw new ValidateException("生成支付订单失败,优惠券:" + coupon.getTitle() + " 当前时段不可用"); throw new CzgException("生成支付订单失败,优惠券:" + coupon.getTitle() + " 当前时段不可用");
} }
} else if (startTime.isBefore(endTime)) { } else if (startTime.isBefore(endTime)) {
if (currentTime.isAfter(endTime)) { if (currentTime.isAfter(endTime)) {
throw new ValidateException("生成支付订单失败,优惠券:" + coupon.getTitle() + " 当前时段不可用"); throw new CzgException("生成支付订单失败,优惠券:" + coupon.getTitle() + " 当前时段不可用");
} }
} }
} }
@@ -785,7 +784,7 @@ public class OrderInfoServiceImpl extends ServiceImpl<OrderInfoMapper, OrderInfo
} }
} }
if (calculationAmount.compareTo(fullAmount) < 0) { if (calculationAmount.compareTo(fullAmount) < 0) {
throw new ValidateException("生成支付订单失败," + title + "优惠券门槛金额不足"); throw new CzgException("生成支付订单失败," + title + "优惠券门槛金额不足");
} }
} }
@@ -891,7 +890,7 @@ public class OrderInfoServiceImpl extends ServiceImpl<OrderInfoMapper, OrderInfo
} }
} }
if (foodsAmount.compareTo(thresholdAmount) < 0) { if (foodsAmount.compareTo(thresholdAmount) < 0) {
throw new ValidateException("优惠券未达到门槛金额"); throw new CzgException("优惠券未达到门槛金额");
} }
} }
@@ -1391,12 +1390,12 @@ public class OrderInfoServiceImpl extends ServiceImpl<OrderInfoMapper, OrderInfo
/** /**
* 初始化订单信息 * 初始化订单信息
*/ */
private OrderInfo initOrderInfo(OrderInfoAddDTO param, ShopInfo shopInfo, ShopTable table) { private OrderInfo initOrderInfo(OrderInfoAddDTO param, ShopInfo shopInfo, ShopTable table) throws CzgException {
OrderInfo orderInfo = new OrderInfo(); OrderInfo orderInfo = new OrderInfo();
if (param.getOrderId() != null) { if (param.getOrderId() != null) {
orderInfo = getById(param.getOrderId()); orderInfo = getById(param.getOrderId());
if (!OrderStatusEnums.UNPAID.getCode().equals(orderInfo.getStatus())) { if (!OrderStatusEnums.UNPAID.getCode().equals(orderInfo.getStatus())) {
throw new ValidateException("生成订单失败,订单已结束,请重新下单"); throw new CzgException("生成订单失败,订单已结束,请重新下单");
} }
} else { } else {
orderInfo.setOrderNo(param.getPlatformType() + IdUtil.getSnowflakeNextId()); orderInfo.setOrderNo(param.getPlatformType() + IdUtil.getSnowflakeNextId());
@@ -1560,7 +1559,7 @@ public class OrderInfoServiceImpl extends ServiceImpl<OrderInfoMapper, OrderInfo
public Boolean printOrder(Long shopId, OrderInfoPrintDTO orderInfoPrintDTO) { public Boolean printOrder(Long shopId, OrderInfoPrintDTO orderInfoPrintDTO) {
OrderInfo orderInfo = getOne(new QueryWrapper().eq(OrderInfo::getShopId, shopId).eq(OrderInfo::getId, orderInfoPrintDTO.getId())); OrderInfo orderInfo = getOne(new QueryWrapper().eq(OrderInfo::getShopId, shopId).eq(OrderInfo::getId, orderInfoPrintDTO.getId()));
if (orderInfo == null) { if (orderInfo == null) {
throw new ApiNotPrintException("订单信息不存在"); throw new CzgException("订单信息不存在");
} }
switch (orderInfoPrintDTO.getType()) { switch (orderInfoPrintDTO.getType()) {
@@ -1582,23 +1581,23 @@ public class OrderInfoServiceImpl extends ServiceImpl<OrderInfoMapper, OrderInfo
public Boolean removeOrderDetail(Long shopId, Long orderId, Long detailId) { public Boolean removeOrderDetail(Long shopId, Long orderId, Long detailId) {
OrderInfo orderInfo = getOne(new QueryWrapper().eq(OrderInfo::getId, orderId).eq(OrderInfo::getShopId, shopId)); OrderInfo orderInfo = getOne(new QueryWrapper().eq(OrderInfo::getId, orderId).eq(OrderInfo::getShopId, shopId));
if (orderInfo == null) { if (orderInfo == null) {
throw new ApiNotPrintException("订单不存在"); throw new CzgException("订单不存在");
} }
if (!OrderStatusEnums.UNPAID.getCode().equals(orderInfo.getStatus())) { if (!OrderStatusEnums.UNPAID.getCode().equals(orderInfo.getStatus())) {
throw new ApiNotPrintException("订单不处于待支付状态"); throw new CzgException("订单不处于待支付状态");
} }
OrderDetail orderDetail = orderDetailService.getOne(new QueryWrapper().eq(OrderDetail::getId, detailId).eq(OrderDetail::getOrderId, orderId)); OrderDetail orderDetail = orderDetailService.getOne(new QueryWrapper().eq(OrderDetail::getId, detailId).eq(OrderDetail::getOrderId, orderId));
if (orderDetail == null || !orderDetail.getStatus().equals(OrderStatusEnums.UNPAID.getCode())) { if (orderDetail == null || !orderDetail.getStatus().equals(OrderStatusEnums.UNPAID.getCode())) {
throw new ApiNotPrintException("不处于待支付或订单详情不存在"); throw new CzgException("不处于待支付或订单详情不存在");
} }
int i = mapper.decrMoney(orderInfo.getId(), orderDetail.getPayAmount().add(orderDetail.getPackAmount())); int i = mapper.decrMoney(orderInfo.getId(), orderDetail.getPayAmount().add(orderDetail.getPackAmount()));
if (i > 0) { if (i > 0) {
return orderDetailService.removeById(orderDetail.getId()); return orderDetailService.removeById(orderDetail.getId());
} }
throw new ApiNotPrintException("操作失败"); throw new CzgException("操作失败");
} }
@Override @Override

View File

@@ -140,7 +140,7 @@ public class PayServiceImpl implements PayService {
private boolean checkPayVip(VipPayParamDTO payParam) { private boolean checkPayVip(VipPayParamDTO payParam) {
if (payParam.getAmount().compareTo(BigDecimal.ZERO) <= 0) { if (payParam.getAmount().compareTo(BigDecimal.ZERO) <= 0) {
throw new ValidateException("充值金额不正确"); throw new CzgException("充值金额不正确");
} }
if (payParam.getOrderId() != null) { if (payParam.getOrderId() != null) {
FreeDineConfig freeConfig = freeConfigService.getById(shopInfoService.getMainIdByShopId(payParam.getShopId())); FreeDineConfig freeConfig = freeConfigService.getById(shopInfoService.getMainIdByShopId(payParam.getShopId()));
@@ -691,7 +691,7 @@ public class PayServiceImpl implements PayService {
} }
orderInfo.setRefundAmount(orderInfo.getRefundAmount().add(param.getRefundAmount())); orderInfo.setRefundAmount(orderInfo.getRefundAmount().add(param.getRefundAmount()));
if (orderInfo.getRefundAmount().compareTo(orderInfo.getPayAmount()) > 0) { if (orderInfo.getRefundAmount().compareTo(orderInfo.getPayAmount()) > 0) {
throw new ValidateException("退单失败,可退金额不足"); throw new CzgException("退单失败,可退金额不足");
} }
} }
if (CollUtil.isNotEmpty(param.getRefundDetails())) { if (CollUtil.isNotEmpty(param.getRefundDetails())) {
@@ -703,7 +703,7 @@ public class PayServiceImpl implements PayService {
//可退数量=订单数量-退单数量-退菜数量 //可退数量=订单数量-退单数量-退菜数量
BigDecimal returnNum = orderDetail.getNum().subtract(orderDetail.getRefundNum()).subtract(orderDetail.getReturnNum()); BigDecimal returnNum = orderDetail.getNum().subtract(orderDetail.getRefundNum()).subtract(orderDetail.getReturnNum());
if (returnNum.compareTo(BigDecimal.ZERO) <= 0 || returnNum.compareTo(refundDetail.getNum()) < 0) { if (returnNum.compareTo(BigDecimal.ZERO) <= 0 || returnNum.compareTo(refundDetail.getNum()) < 0) {
throw new ValidateException("退单失败," + orderDetail.getProductName() + "可退数量不足"); throw new CzgException("退单失败," + orderDetail.getProductName() + "可退数量不足");
} }
if (isPay) { if (isPay) {
orderDetail.setRefundNum(orderDetail.getRefundNum().add(refNum)); orderDetail.setRefundNum(orderDetail.getRefundNum().add(refNum));
@@ -916,7 +916,7 @@ public class PayServiceImpl implements PayService {
//支付宝支付 //支付宝支付
bizData.setSubAppid(shopMerchant.getAlipaySmallAppid()); bizData.setSubAppid(shopMerchant.getAlipaySmallAppid());
} else { } else {
throw new ValidateException("扫描码非法或暂不支持"); throw new CzgException("扫描码非法或暂不支持");
} }
CzgResult<CzgMicroPayResp> czgScanPayResult = czgPayService.microPay(shopMerchant.getAppId(), shopMerchant.getAppSecret(), bizData); CzgResult<CzgMicroPayResp> czgScanPayResult = czgPayService.microPay(shopMerchant.getAppId(), shopMerchant.getAppSecret(), bizData);

View File

@@ -1,18 +1,13 @@
package com.czg.service.product.service.impl; package com.czg.service.product.service.impl;
import cn.hutool.core.bean.BeanUtil; import cn.hutool.core.bean.BeanUtil;
import cn.hutool.core.util.StrUtil; import com.czg.exception.CzgException;
import com.czg.product.dto.storage.ShopStorageGoodDTO; import com.czg.product.dto.storage.ShopStorageGoodDTO;
import com.czg.product.entity.Product; import com.czg.product.entity.Product;
import com.czg.product.entity.ShopProdUnit; import com.czg.product.entity.ShopProdUnit;
import com.czg.product.entity.ShopStorage;
import com.czg.exception.ApiNotPrintException;
import com.czg.product.service.ProductService; import com.czg.product.service.ProductService;
import com.czg.product.service.ShopProdUnitService; import com.czg.product.service.ShopProdUnitService;
import com.czg.sa.StpKit;
import com.czg.service.product.mapper.ShopStorageGoodMapper; import com.czg.service.product.mapper.ShopStorageGoodMapper;
import com.czg.utils.PageUtil;
import com.mybatisflex.core.paginate.Page;
import com.mybatisflex.core.query.QueryWrapper; import com.mybatisflex.core.query.QueryWrapper;
import com.mybatisflex.spring.service.impl.ServiceImpl; import com.mybatisflex.spring.service.impl.ServiceImpl;
import com.czg.product.entity.ShopStorageGood; import com.czg.product.entity.ShopStorageGood;
@@ -39,7 +34,7 @@ public class ShopStorageGoodServiceImpl extends ServiceImpl<ShopStorageGoodMappe
public Boolean edit(Long shopId, ShopStorageGoodDTO shopStorageGoodDTO) { public Boolean edit(Long shopId, ShopStorageGoodDTO shopStorageGoodDTO) {
ShopStorageGood storageGood = getOne(new QueryWrapper().eq(ShopStorageGood::getShopId, shopId).eq(ShopStorageGood::getId, shopStorageGoodDTO.getId())); ShopStorageGood storageGood = getOne(new QueryWrapper().eq(ShopStorageGood::getShopId, shopId).eq(ShopStorageGood::getId, shopStorageGoodDTO.getId()));
if (storageGood == null) { if (storageGood == null) {
throw new ApiNotPrintException("商品不存在"); throw new CzgException("商品不存在");
} }
BeanUtil.copyProperties(shopStorageGoodDTO, storageGood); BeanUtil.copyProperties(shopStorageGoodDTO, storageGood);
@@ -52,11 +47,11 @@ public class ShopStorageGoodServiceImpl extends ServiceImpl<ShopStorageGoodMappe
ShopStorageGood shopStorageGood = BeanUtil.copyProperties(shopStorageGoodDTO, ShopStorageGood.class); ShopStorageGood shopStorageGood = BeanUtil.copyProperties(shopStorageGoodDTO, ShopStorageGood.class);
if (shopStorageGoodDTO.getSource() == 1) { if (shopStorageGoodDTO.getSource() == 1) {
if (shopStorageGoodDTO.getProdId() == null) { if (shopStorageGoodDTO.getProdId() == null) {
throw new ApiNotPrintException("商品id不为空"); throw new CzgException("商品id不为空");
} }
Product product = productService.getOne(new QueryWrapper().eq(Product::getShopId, shopId).eq(Product::getId, shopStorageGoodDTO.getProdId())); Product product = productService.getOne(new QueryWrapper().eq(Product::getShopId, shopId).eq(Product::getId, shopStorageGoodDTO.getProdId()));
if (product == null) { if (product == null) {
throw new ApiNotPrintException("商品不存在"); throw new CzgException("商品不存在");
} }
shopStorageGood.setName(product.getName()); shopStorageGood.setName(product.getName());

View File

@@ -4,7 +4,7 @@ import cn.hutool.core.date.DateUtil;
import cn.hutool.core.util.StrUtil; import cn.hutool.core.util.StrUtil;
import com.czg.account.entity.ShopUser; import com.czg.account.entity.ShopUser;
import com.czg.account.service.ShopUserService; import com.czg.account.service.ShopUserService;
import com.czg.exception.ApiNotPrintException; import com.czg.exception.CzgException;
import com.czg.product.dto.storage.CountStorageDTO; import com.czg.product.dto.storage.CountStorageDTO;
import com.czg.product.dto.storage.ShopStorageAddDTO; import com.czg.product.dto.storage.ShopStorageAddDTO;
import com.czg.product.dto.storage.ShopStorageEditDTO; import com.czg.product.dto.storage.ShopStorageEditDTO;
@@ -72,12 +72,12 @@ public class ShopStorageServiceImpl extends ServiceImpl<ShopStorageMapper, ShopS
public Boolean add(Long shopId, ShopStorageAddDTO shopStorageAddDTO) { public Boolean add(Long shopId, ShopStorageAddDTO shopStorageAddDTO) {
ShopUser shopUser = shopUserService.getOne(new QueryWrapper().eq(ShopUser::getUserId, shopStorageAddDTO.getUserId()).eq(ShopUser::getSourceShopId, shopId)); ShopUser shopUser = shopUserService.getOne(new QueryWrapper().eq(ShopUser::getUserId, shopStorageAddDTO.getUserId()).eq(ShopUser::getSourceShopId, shopId));
if (shopUser == null) { if (shopUser == null) {
throw new ApiNotPrintException("店铺用户不存在"); throw new CzgException("店铺用户不存在");
} }
ShopStorageGood shopStorageGood = shopStorageGoodService.getOne(new QueryWrapper().eq(ShopStorageGood::getShopId, shopId).eq(ShopStorageGood::getId, shopStorageAddDTO.getShopStorageGoodId())); ShopStorageGood shopStorageGood = shopStorageGoodService.getOne(new QueryWrapper().eq(ShopStorageGood::getShopId, shopId).eq(ShopStorageGood::getId, shopStorageAddDTO.getShopStorageGoodId()));
if (shopStorageGood == null) { if (shopStorageGood == null) {
throw new ApiNotPrintException("存酒商品不存在"); throw new CzgException("存酒商品不存在");
} }
ShopStorage shopStorage = new ShopStorage().setName(shopStorageGood.getName()) ShopStorage shopStorage = new ShopStorage().setName(shopStorageGood.getName())
@@ -100,18 +100,18 @@ public class ShopStorageServiceImpl extends ServiceImpl<ShopStorageMapper, ShopS
record.setContent("存入"+ shopStorage.getNum() + shopStorage.getUnit() + shopStorage.getName()); record.setContent("存入"+ shopStorage.getNum() + shopStorage.getUnit() + shopStorage.getName());
return storageRecordService.save(record); return storageRecordService.save(record);
} }
throw new ApiNotPrintException("保存失败"); throw new CzgException("保存失败");
} }
@Override @Override
public Boolean edit(Long shopId, ShopStorageEditDTO shopStorageEditDTO) { public Boolean edit(Long shopId, ShopStorageEditDTO shopStorageEditDTO) {
ShopStorage shopStorage = getOne(new QueryWrapper().eq(ShopStorage::getShopId, shopId).eq(ShopStorage::getId, shopStorageEditDTO.getId())); ShopStorage shopStorage = getOne(new QueryWrapper().eq(ShopStorage::getShopId, shopId).eq(ShopStorage::getId, shopStorageEditDTO.getId()));
if (shopStorage == null) { if (shopStorage == null) {
throw new ApiNotPrintException("存酒记录不存在"); throw new CzgException("存酒记录不存在");
} }
if (shopStorageEditDTO.getNum() < 0 && shopStorage.getNum() + shopStorageEditDTO.getNum() < 0) { if (shopStorageEditDTO.getNum() < 0 && shopStorage.getNum() + shopStorageEditDTO.getNum() < 0) {
throw new ApiNotPrintException("可取酒数量不足"); throw new CzgException("可取酒数量不足");
} }
shopStorage.setNum(shopStorage.getNum() + shopStorageEditDTO.getNum()); shopStorage.setNum(shopStorage.getNum() + shopStorageEditDTO.getNum());
@@ -136,7 +136,7 @@ public class ShopStorageServiceImpl extends ServiceImpl<ShopStorageMapper, ShopS
public List<ShopStorageRecord> getRecord(Long shopId, Integer id) { public List<ShopStorageRecord> getRecord(Long shopId, Integer id) {
ShopStorage shopStorage = getOne(new QueryWrapper().eq(ShopStorage::getShopId, shopId).eq(ShopStorage::getId, id)); ShopStorage shopStorage = getOne(new QueryWrapper().eq(ShopStorage::getShopId, shopId).eq(ShopStorage::getId, id));
if (shopStorage == null) { if (shopStorage == null) {
throw new ApiNotPrintException("存酒记录不存在"); throw new CzgException("存酒记录不存在");
} }
return storageRecordService.list(new QueryWrapper().eq(ShopStorageRecord::getStorageId, id)); return storageRecordService.list(new QueryWrapper().eq(ShopStorageRecord::getStorageId, id));
} }

View File

@@ -4,7 +4,6 @@ import cn.hutool.core.bean.BeanUtil;
import cn.hutool.core.date.DateUtil; import cn.hutool.core.date.DateUtil;
import cn.hutool.core.util.StrUtil; import cn.hutool.core.util.StrUtil;
import com.czg.enums.DeleteEnum; import com.czg.enums.DeleteEnum;
import com.czg.exception.ApiNotPrintException;
import com.czg.exception.CzgException; import com.czg.exception.CzgException;
import com.czg.product.dto.ShopVendorBillPayDTO; import com.czg.product.dto.ShopVendorBillPayDTO;
import com.czg.product.dto.ShopVendorDTO; import com.czg.product.dto.ShopVendorDTO;
@@ -151,11 +150,11 @@ public class ShopVendorServiceImpl extends ServiceImpl<ShopVendorMapper, ShopVen
} }
if (unPaidAmount.compareTo(BigDecimal.ZERO) == 0) { if (unPaidAmount.compareTo(BigDecimal.ZERO) == 0) {
throw new ApiNotPrintException("此账单已付款"); throw new CzgException("此账单已付款");
} }
if (unPaidAmount.compareTo(payDTO.getAmount()) != 0) { if (unPaidAmount.compareTo(payDTO.getAmount()) != 0) {
throw new ApiNotPrintException("批量付款应全部付款"); throw new CzgException("批量付款应全部付款");
} }
consPayRecordService.saveBatch(records); consPayRecordService.saveBatch(records);
@@ -163,15 +162,15 @@ public class ShopVendorServiceImpl extends ServiceImpl<ShopVendorMapper, ShopVen
}else { }else {
ConsStockFlow stockFlow = consStockFlowMapper.selectOneByQuery(new QueryWrapper().eq(ConsStockFlow::getShopId, shopId).eq(ConsStockFlow::getId, payDTO.getFlowIdList().getFirst())); ConsStockFlow stockFlow = consStockFlowMapper.selectOneByQuery(new QueryWrapper().eq(ConsStockFlow::getShopId, shopId).eq(ConsStockFlow::getId, payDTO.getFlowIdList().getFirst()));
if (stockFlow == null) { if (stockFlow == null) {
throw new ApiNotPrintException("付款账单不存在"); throw new CzgException("付款账单不存在");
} }
if (stockFlow.getAmountPayable().compareTo(stockFlow.getActualPaymentAmount()) <= 0) { if (stockFlow.getAmountPayable().compareTo(stockFlow.getActualPaymentAmount()) <= 0) {
throw new ApiNotPrintException("次账单已付款完成"); throw new CzgException("次账单已付款完成");
} }
if (payDTO.getAmount().compareTo(stockFlow.getAmountPayable().subtract(stockFlow.getActualPaymentAmount())) > 0) { if (payDTO.getAmount().compareTo(stockFlow.getAmountPayable().subtract(stockFlow.getActualPaymentAmount())) > 0) {
throw new ApiNotPrintException("付款金额不应超过待付款金额"); throw new CzgException("付款金额不应超过待付款金额");
} }
ConsPayRecord consPayRecord = BeanUtil.copyProperties(payDTO, ConsPayRecord.class); ConsPayRecord consPayRecord = BeanUtil.copyProperties(payDTO, ConsPayRecord.class);

View File

@@ -3,7 +3,7 @@ package com.czg.service.system.service.impl;
import com.aliyun.dysmsapi20170525.Client; import com.aliyun.dysmsapi20170525.Client;
import com.aliyun.dysmsapi20170525.models.SendSmsResponse; import com.aliyun.dysmsapi20170525.models.SendSmsResponse;
import com.aliyun.teaopenapi.models.Config; import com.aliyun.teaopenapi.models.Config;
import com.czg.exception.ApiNotPrintException; import com.czg.exception.CzgException;
import com.czg.resp.CzgResult; import com.czg.resp.CzgResult;
import com.czg.system.dto.SysParamsDTO; import com.czg.system.dto.SysParamsDTO;
import com.czg.system.service.SmsService; import com.czg.system.service.SmsService;
@@ -11,10 +11,7 @@ import com.czg.system.service.SysParamsService;
import jakarta.annotation.PostConstruct; import jakarta.annotation.PostConstruct;
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.DubboService; import org.apache.dubbo.config.annotation.DubboService;
import org.springframework.context.ApplicationContext;
import org.springframework.stereotype.Component;
/** /**
* 验证码工具类 * 验证码工具类
@@ -74,7 +71,7 @@ public class SmsServiceImpl implements SmsService {
log.info("短信发送请求参数: 手机号: {}, 短信模板: {}, 短信内容: {}", phone, templateCode, checkCode); log.info("短信发送请求参数: 手机号: {}, 短信模板: {}, 短信内容: {}", phone, templateCode, checkCode);
SendSmsResponse sendSmsResponse = client.sendSmsWithOptions(sendSmsRequest, runtime); SendSmsResponse sendSmsResponse = client.sendSmsWithOptions(sendSmsRequest, runtime);
if (sendSmsResponse.getStatusCode() != 200) { if (sendSmsResponse.getStatusCode() != 200) {
throw new ApiNotPrintException("短信发送失败"); throw new CzgException("短信发送失败");
} }
}catch (Exception e) { }catch (Exception e) {
log.info("发送短信失败", e); log.info("发送短信失败", e);