Merge remote-tracking branch 'origin/master'

This commit is contained in:
Tankaikai 2025-02-12 10:31:11 +08:00
commit 24543f0523
9 changed files with 323 additions and 27 deletions

View File

@ -26,7 +26,7 @@ public class ShopInfoController {
} }
/** /**
* 店铺列表 * 店铺列表, 只允许管理员调用
* 权限标识: shopInfo:list * 权限标识: shopInfo:list
*/ */
@SaAdminCheckRole("管理员") @SaAdminCheckRole("管理员")
@ -37,7 +37,17 @@ public class ShopInfoController {
} }
/** /**
* 店铺添加 * 店铺详情
* 权限标识: shopInfo:detail
*/
@SaAdminCheckPermission("shopInfo:detail")
@GetMapping("/detail")
public CzgResult<ShopInfo> detail() {
return CzgResult.success(shopInfoService.detail());
}
/**
* 店铺添加, 只允许管理员调用
* 权限标识: shopInfo:add * 权限标识: shopInfo:add
*/ */
@SaAdminCheckRole("管理员") @SaAdminCheckRole("管理员")
@ -51,7 +61,6 @@ public class ShopInfoController {
* 店铺编辑 * 店铺编辑
* 权限标识: shopInfo:edit * 权限标识: shopInfo:edit
*/ */
@SaAdminCheckRole("管理员")
@SaAdminCheckPermission("shopInfo:edit") @SaAdminCheckPermission("shopInfo:edit")
@PutMapping @PutMapping
public CzgResult<?> edit(@RequestBody @Validated ShopInfoEditDTO shopInfoEditDTO) { public CzgResult<?> edit(@RequestBody @Validated ShopInfoEditDTO shopInfoEditDTO) {

View File

@ -44,6 +44,14 @@ public class CzgControllerAdvice {
return CzgResult.failure(CzgRespCode.NOT_LOGIN + ":" + ex.getMessage()); return CzgResult.failure(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)

View File

@ -1,8 +1,12 @@
package com.czg.account.dto.shopinfo; package com.czg.account.dto.shopinfo;
import com.mybatisflex.annotation.Column;
import jakarta.validation.constraints.NotNull; import jakarta.validation.constraints.NotNull;
import lombok.Data; import lombok.Data;
import java.math.BigDecimal;
import java.time.LocalDateTime;
/** /**
* @author Administrator * @author Administrator
*/ */
@ -10,19 +14,236 @@ import lombok.Data;
public class ShopInfoEditDTO { public class ShopInfoEditDTO {
@NotNull(message = "id不为空") @NotNull(message = "id不为空")
private Integer id; private Integer id;
/**
* 就餐模式 json形式['dine-in', 'take-out]
*/
private String eatModel;
/**
* 营业时间(周开始)
*/
private String businessStartDay;
/**
* 营业时间(周结束)
*/
private String businessEndDay;
/**
* 营业时间
*/
private String businessTime;
/**
* 是否免除桌位费 0否 1是
*/
private Integer isTableFee;
/**
* 桌位费
*/
private BigDecimal tableFee;
/**
* 是否启用会员价 0否 1是
*/
private Integer isMemberPrice;
/**
* 是否开启会员余额支付
*/
private Integer isAccountPay;
/**
* 台桌预订短信
*/
private String bookingSms;
/**
* 是否开启退款密码 1 启用 0 禁用
*/
private Integer isReturnPwd;
/**
* 是否允许会员自定义金额 1 允许 0 不允许
*/
private Integer isCustomAmount;
/**
* 是否开启会员充值密码 1 启用 0 禁用
*/
private Integer isMemberInPwd;
/**
* 是否开启会员退款密码 1 启用 0 禁用
*/
private Integer isMemberReturnPwd;
/**
* 操作密码
*/
private Integer operationPwd;
/**
* 主店id
*/
private Integer mainId;
/**
* 店铺口号
*/
private String subTitle;
/**
* 店铺名称
*/
private String shopName; private String shopName;
private String shopType;
/**
* 连锁店扩展店名
*/
private String chainName; private String chainName;
private String logo;
/**
* 背景图
*/
private String backImg;
/**
* 门头照
*/
private String frontImg; private String frontImg;
private String profiles;
private String activateCode; /**
private String accountName; * 联系人姓名
private String accountPwd; */
private String lat; private String contactName;
private String lng;
private String detail; /**
private Long roleId; * 联系电话
private String address; */
private String phone; private String phone;
/**
* 店铺logo
*/
private String logo;
/**
* 封面图
*/
private String coverImg;
/**
* 店铺简介
*/
private String detail;
private String registerType;
/**
* 店铺类型 单店--only 连锁店--chain--加盟店join 对应原来 type
*/
private String shopType;
/**
* 管理 0否 1是, 1 为直接管理 可切换店铺 0 不可以切换
*/
private Integer tubeType;
/**
* trial试用版release正式
*/
private String profiles;
/**
* 0停业 1正常营业 2网上售卖
*/
private Integer onSale;
/**
* -1 平台禁用 0-过期1正式营业
*/
private Integer status;
/**
* 商家二维码
*/
private String shopQrcode;
/**
* 商家标签
*/
private String tag;
/**
* 经纬度
*/
private String lat;
/**
* 经纬度
*/
private String lng;
/**
*
*/
private String provinces;
/**
*
*/
private String cities;
/**
* /
*/
private String districts;
/**
* 详细地址
*/
private String address;
/**
* 积分群体 all-所有 vip-仅针对会员
*/
private String consumeColony;
/**
* 小程序码(零点八零首页)
*/
private String smallQrcode;
/**
* 店铺收款码
*/
private String paymentQrcode;
/**
* 开票系统账号
*/
private String bindAccount;
/**
* 项目分类
*/
private String article;
/**
* 数电发票类型
*/
private String sdType;
/**
* 税率
*/
private String taxAmount;
/**
* 店铺激活码
*/
private String activateCode;
} }

View File

@ -209,6 +209,11 @@ public class ShopInfo implements Serializable {
*/ */
private Integer isTableFee; private Integer isTableFee;
/**
* 是否开启会员余额支付
*/
private Integer isAccountPay;
/** /**
* 桌位费 * 桌位费
*/ */

View File

@ -16,4 +16,6 @@ public interface ShopInfoService extends IService<ShopInfo> {
Boolean add(ShopInfoAddDTO shopInfoAddDTO); Boolean add(ShopInfoAddDTO shopInfoAddDTO);
Boolean edit(ShopInfoEditDTO shopInfoEditDTO); Boolean edit(ShopInfoEditDTO shopInfoEditDTO);
ShopInfo detail();
} }

View File

@ -0,0 +1,35 @@
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

@ -9,6 +9,8 @@ import com.czg.account.entity.*;
import com.czg.account.service.*; import com.czg.account.service.*;
import com.czg.account.vo.LoginVO; import com.czg.account.vo.LoginVO;
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.service.account.mapper.SysMenuMapper; import com.czg.service.account.mapper.SysMenuMapper;
@ -61,17 +63,17 @@ public class AuthorizationServiceImpl implements AuthorizationService {
public LoginVO login(SysLoginDTO loginDTO) { public LoginVO login(SysLoginDTO loginDTO) {
// 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())) { // if (!"666666".equals(loginDTO.code()) && code == null || !code.equals(loginDTO.code())) {
// throw new RuntimeException("验证码错误"); // throw new ApiNotPrintException("验证码错误");
// } // }
SysUser user = sysUserService.queryChain().eq(SysUser::getAccount,loginDTO.username()).one(); SysUser user = sysUserService.queryChain().eq(SysUser::getAccount,loginDTO.username()).one();
if (user == null) { if (user == null) {
throw new RuntimeException("账户不存在"); throw new ApiNotPrintException("账户不存在");
} }
String md5 = SecureUtil.md5(user.getId() + loginDTO.password()); String md5 = SecureUtil.md5(user.getId() + loginDTO.password());
if (StrUtil.isBlank(user.getPassword()) || !user.getPassword().equals(md5)) { if (StrUtil.isBlank(user.getPassword()) || !user.getPassword().equals(md5)) {
throw new RuntimeException("账户或密码错误"); throw new ApiNotPrintException("账户或密码错误");
} }
ShopInfo shopInfo; ShopInfo shopInfo;
@ -81,7 +83,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 RuntimeException("账户未启用"); throw new ApiNotPrintException("账户未启用");
} }
shopInfo = shopInfoService.getById(shopStaff.getShopId()); shopInfo = shopInfoService.getById(shopStaff.getShopId());
@ -90,12 +92,12 @@ public class AuthorizationServiceImpl implements AuthorizationService {
} }
if (shopInfo == null) { if (shopInfo == null) {
throw new RuntimeException("商户不存在"); throw new ApiNotPrintException("商户不存在");
} }
// 过期时间校验 // 过期时间校验
if (shopInfo.getExpireTime() != null) { if (shopInfo.getExpireTime() != null) {
if ((DateUtil.date().toLocalDateTime().isAfter(shopInfo.getExpireTime()))) { if ((DateUtil.date().toLocalDateTime().isAfter(shopInfo.getExpireTime()))) {
throw new RuntimeException("店铺已到期,请联系区域经理续费"); throw new ApiNotPrintException("店铺已到期,请联系区域经理续费");
} }
} }

View File

@ -96,7 +96,15 @@ public class ShopInfoServiceImpl extends ServiceImpl<ShopInfoMapper, ShopInfo> i
@Override @Override
public Boolean edit(ShopInfoEditDTO shopInfoEditDTO) { public Boolean edit(ShopInfoEditDTO shopInfoEditDTO) {
ShopInfo shopInfo = getById(StpKit.ADMIN.getLoginIdAsLong()); ShopInfo shopInfo;
if (!StpKit.ADMIN.isAdmin()) {
shopInfo = queryChain().eq(ShopInfo::getId, StpKit.ADMIN.getLoginIdAsLong()).one();
}else {
shopInfo = getById(StpKit.ADMIN.getLoginIdAsLong());
}
if (shopInfo == null) {
throw new CzgException("店铺不存在");
}
BeanUtil.copyProperties(shopInfoEditDTO, shopInfo); BeanUtil.copyProperties(shopInfoEditDTO, shopInfo);
if (shopInfoEditDTO.getActivateCode() != null) { if (shopInfoEditDTO.getActivateCode() != null) {
@ -104,4 +112,9 @@ public class ShopInfoServiceImpl extends ServiceImpl<ShopInfoMapper, ShopInfo> i
} }
return updateById(shopInfo); return updateById(shopInfo);
} }
@Override
public ShopInfo detail() {
return queryChain().eq(ShopInfo::getId, StpKit.ADMIN.getLoginIdAsLong()).one();
}
} }

View File

@ -12,6 +12,7 @@ import com.czg.account.entity.SysRolesMenus;
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.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;
@ -69,7 +70,7 @@ public class SysRoleServiceImpl extends ServiceImpl<SysRoleMapper, SysRole> imp
public boolean addMenu(Long roleId, List<Long> menuIds) { public boolean addMenu(Long roleId, List<Long> menuIds) {
long count = sysMenuService.queryChain().in(SysMenu::getMenuId, menuIds).count(); long count = sysMenuService.queryChain().in(SysMenu::getMenuId, menuIds).count();
if (count != menuIds.size()) { if (count != menuIds.size()) {
throw new RuntimeException("菜单id包含错误id"); throw new ApiNotPrintException("菜单id包含错误id");
} }
ArrayList<SysRolesMenus> rolesMenus = new ArrayList<>(); ArrayList<SysRolesMenus> rolesMenus = new ArrayList<>();
@ -84,7 +85,7 @@ public class SysRoleServiceImpl extends ServiceImpl<SysRoleMapper, SysRole> imp
public Boolean add(RoleAddDTO roleAddDTO) { public Boolean add(RoleAddDTO roleAddDTO) {
long roleCount = queryChain().eq(SysRole::getName, roleAddDTO.name()).count(); long roleCount = queryChain().eq(SysRole::getName, roleAddDTO.name()).count();
if (roleCount > 0) { if (roleCount > 0) {
throw new RuntimeException("此角色名称已存在"); throw new ApiNotPrintException("此角色名称已存在");
} }
SysRole sysRole = new SysRole(); SysRole sysRole = new SysRole();
@ -99,7 +100,7 @@ public class SysRoleServiceImpl extends ServiceImpl<SysRoleMapper, SysRole> imp
return addMenu(sysRole.getId(), roleAddDTO.menuIdList()); return addMenu(sysRole.getId(), roleAddDTO.menuIdList());
} }
throw new RuntimeException("保存失败"); throw new ApiNotPrintException("保存失败");
} }
@Override @Override
@ -107,12 +108,12 @@ 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.ADMIN.getLoginIdAsLong()).one(); SysRole role = queryChain().eq(SysRole::getId, roleEditDTO.getId()).eq(SysRole::getCreateUserId, StpKit.ADMIN.getLoginIdAsLong()).one();
if (role == null) { if (role == null) {
throw new RuntimeException("角色不存在"); throw new ApiNotPrintException("角色不存在");
} }
long roleCount = queryChain().eq(SysRole::getName, roleEditDTO.getName()).count(); long roleCount = queryChain().eq(SysRole::getName, roleEditDTO.getName()).count();
if (roleCount > 0) { if (roleCount > 0) {
throw new RuntimeException("此角色名称已存在"); throw new ApiNotPrintException("此角色名称已存在");
} }
BeanUtil.copyProperties(roleEditDTO, role); BeanUtil.copyProperties(roleEditDTO, role);
@ -121,6 +122,6 @@ public class SysRoleServiceImpl extends ServiceImpl<SysRoleMapper, SysRole> imp
sysRolesMenusService.updateChain().eq(SysRolesMenus::getRoleId, role.getId()).remove(); sysRolesMenusService.updateChain().eq(SysRolesMenus::getRoleId, role.getId()).remove();
return addMenu(role.getId(), roleEditDTO.getMenuIdList()); return addMenu(role.getId(), roleEditDTO.getMenuIdList());
} }
throw new RuntimeException("保存失败"); throw new ApiNotPrintException("保存失败");
} }
} }