店铺签约
This commit is contained in:
@@ -1,54 +0,0 @@
|
||||
package com.czg.controller.admin;
|
||||
|
||||
import com.czg.account.dto.PageDTO;
|
||||
import com.czg.account.dto.register.MerchantRegisterDTO;
|
||||
import com.czg.account.entity.MerchantRegister;
|
||||
import com.czg.account.service.MerchantRegisterService;
|
||||
import com.czg.annotation.SaAdminCheckPermission;
|
||||
import com.czg.annotation.SaAdminCheckRole;
|
||||
import com.czg.resp.CzgResult;
|
||||
import com.mybatisflex.core.paginate.Page;
|
||||
import jakarta.annotation.Resource;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
/**
|
||||
* 激活码管理
|
||||
* @author Administrator
|
||||
*/
|
||||
@RestController
|
||||
@RequestMapping("/admin/merchantRegister")
|
||||
public class MerchantRegisterController {
|
||||
@Resource
|
||||
private MerchantRegisterService merchantRegisterService;
|
||||
|
||||
|
||||
/**
|
||||
* 激活码列表
|
||||
* 权限标识: merchantRegister:list
|
||||
* @param pageDTO 分页参数
|
||||
* @param state 状态 0未激活 1已激活
|
||||
* @param startTime 开始时间
|
||||
* @param endTime 结束时间
|
||||
* @return 激活码列表
|
||||
*/
|
||||
@SaAdminCheckRole("管理员")
|
||||
@SaAdminCheckPermission(parentName = "激活码", value = "merchantRegister:list", name = "激活码列表")
|
||||
@GetMapping
|
||||
public CzgResult<Page<MerchantRegister>> get(PageDTO pageDTO, Integer state, String startTime, String endTime) {
|
||||
return CzgResult.success(merchantRegisterService.get(pageDTO, state, startTime, endTime));
|
||||
}
|
||||
|
||||
/**
|
||||
* 生成激活码
|
||||
* 权限标识: merchantRegister:add
|
||||
* @param merchantRegisterDTO 激活码信息
|
||||
* @return 是否成功
|
||||
*/
|
||||
@SaAdminCheckRole("管理员")
|
||||
@SaAdminCheckPermission(parentName = "激活码", value = "merchantRegister:add", name = "生成激活码")
|
||||
@PostMapping
|
||||
public CzgResult<Boolean> add(@RequestBody @Validated MerchantRegisterDTO merchantRegisterDTO) {
|
||||
return CzgResult.success(merchantRegisterService.add(merchantRegisterDTO));
|
||||
}
|
||||
}
|
||||
@@ -5,8 +5,10 @@ import com.czg.account.dto.shopinfo.ShopBranchSelectDTO;
|
||||
import com.czg.account.dto.shopinfo.ShopDetailDTO;
|
||||
import com.czg.account.dto.shopinfo.ShopInfoAddDTO;
|
||||
import com.czg.account.dto.shopinfo.ShopInfoEditDTO;
|
||||
import com.czg.account.entity.ShopRegister;
|
||||
import com.czg.account.entity.ShopInfo;
|
||||
import com.czg.account.service.AuthorizationService;
|
||||
import com.czg.account.service.ShopRegisterService;
|
||||
import com.czg.account.service.ShopInfoService;
|
||||
import com.czg.annotation.SaAdminCheckPermission;
|
||||
import com.czg.annotation.SaAdminCheckRole;
|
||||
@@ -32,6 +34,8 @@ public class ShopInfoController {
|
||||
private ShopInfoService shopInfoService;
|
||||
@Resource
|
||||
private AuthorizationService authorizationService;
|
||||
@Resource
|
||||
private ShopRegisterService shopRegisterService;
|
||||
|
||||
/**
|
||||
* 店铺列表, 只允许管理员调用
|
||||
@@ -118,4 +122,17 @@ public class ShopInfoController {
|
||||
return CzgResult.success();
|
||||
}
|
||||
|
||||
/**
|
||||
* 续期记录
|
||||
*
|
||||
* @param pageDTO 分页参数
|
||||
* @return 续期记录列表
|
||||
*/
|
||||
@SaAdminCheckRole("管理员")
|
||||
@GetMapping("/registerRecord")
|
||||
public CzgResult<Page<ShopRegister>> get(PageDTO pageDTO, Long shopId) {
|
||||
Page<ShopRegister> page = shopRegisterService.page(new Page<>(pageDTO.page(), pageDTO.size()),
|
||||
new QueryWrapper().eq(ShopRegister::getShopId, shopId).orderBy(ShopRegister::getCreateTime, false));
|
||||
return CzgResult.success(page);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,16 +0,0 @@
|
||||
package com.czg.account.dto.register;
|
||||
|
||||
import jakarta.validation.constraints.Max;
|
||||
import jakarta.validation.constraints.Min;
|
||||
import jakarta.validation.constraints.NotNull;
|
||||
|
||||
public record MerchantRegisterDTO(
|
||||
@NotNull(message = "激活时长不能为空")
|
||||
@Min(1)
|
||||
Integer periodMonth,
|
||||
@NotNull(message = "数量不为空")
|
||||
@Min(1)
|
||||
@Max(10)
|
||||
Integer num
|
||||
) {
|
||||
}
|
||||
@@ -4,6 +4,8 @@ import jakarta.validation.constraints.NotEmpty;
|
||||
import jakarta.validation.constraints.NotNull;
|
||||
import lombok.Data;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
|
||||
/**
|
||||
* @author Administrator
|
||||
*/
|
||||
@@ -20,8 +22,14 @@ public class ShopInfoAddDTO {
|
||||
private String frontImg;
|
||||
@NotEmpty(message = "试用/正式不为空")
|
||||
private String profiles;
|
||||
// @NotEmpty(message = "激活码不为空")
|
||||
private String activateCode;
|
||||
/**
|
||||
* 激活时长
|
||||
*/
|
||||
private Integer activateDuration;
|
||||
/**
|
||||
* 激活费用
|
||||
*/
|
||||
private BigDecimal activateAmount;
|
||||
@NotEmpty(message = "登录账号不为空")
|
||||
private String accountName;
|
||||
@NotEmpty(message = "登录密码不为空")
|
||||
|
||||
@@ -249,9 +249,13 @@ public class ShopInfoEditDTO {
|
||||
private String taxAmount;
|
||||
|
||||
/**
|
||||
* 店铺激活码
|
||||
* 激活时长
|
||||
*/
|
||||
private String activateCode;
|
||||
private Integer activateDuration;
|
||||
/**
|
||||
* 激活费用
|
||||
*/
|
||||
private BigDecimal activateAmount;
|
||||
/**
|
||||
* 是否为主店 1-是 0-否
|
||||
*/
|
||||
|
||||
@@ -14,7 +14,7 @@ import java.math.BigDecimal;
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
/**
|
||||
* 激活码 实体类。
|
||||
* 店铺签约 实体类。
|
||||
*
|
||||
* @author Administrator
|
||||
* @since 2025-02-11
|
||||
@@ -23,8 +23,8 @@ import java.time.LocalDateTime;
|
||||
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
@Table("tb_merchant_register")
|
||||
public class MerchantRegister implements Serializable {
|
||||
@Table("tb_shop_register")
|
||||
public class ShopRegister implements Serializable {
|
||||
|
||||
@Serial
|
||||
private static final long serialVersionUID = 1L;
|
||||
@@ -32,18 +32,13 @@ public class MerchantRegister implements Serializable {
|
||||
@Id(keyType = KeyType.Auto)
|
||||
private Integer id;
|
||||
|
||||
/**
|
||||
* 激活码
|
||||
*/
|
||||
private String registerCode;
|
||||
|
||||
/**
|
||||
* 店铺id
|
||||
*/
|
||||
private Long shopId;
|
||||
|
||||
/**
|
||||
* 激活码金额
|
||||
* 店铺签约金额
|
||||
*/
|
||||
private BigDecimal amount;
|
||||
|
||||
@@ -52,11 +47,6 @@ public class MerchantRegister implements Serializable {
|
||||
*/
|
||||
private Integer periodMonth;
|
||||
|
||||
/**
|
||||
* 状态0未使用1已使用
|
||||
*/
|
||||
private Integer status;
|
||||
|
||||
/**
|
||||
* 创建时间
|
||||
*/
|
||||
@@ -1,20 +0,0 @@
|
||||
package com.czg.account.service;
|
||||
|
||||
import com.czg.account.dto.PageDTO;
|
||||
import com.czg.account.dto.register.MerchantRegisterDTO;
|
||||
import com.czg.account.entity.MerchantRegister;
|
||||
import com.mybatisflex.core.paginate.Page;
|
||||
import com.mybatisflex.core.service.IService;
|
||||
|
||||
/**
|
||||
* 激活码 服务层。
|
||||
*
|
||||
* @author Administrator
|
||||
* @since 2025-02-11
|
||||
*/
|
||||
public interface MerchantRegisterService extends IService<MerchantRegister> {
|
||||
|
||||
Page<MerchantRegister> get(PageDTO pageDTO, Integer state, String startTime, String endTime);
|
||||
|
||||
Boolean add(MerchantRegisterDTO merchantRegisterDTO);
|
||||
}
|
||||
@@ -0,0 +1,14 @@
|
||||
package com.czg.account.service;
|
||||
|
||||
import com.czg.account.entity.ShopRegister;
|
||||
import com.mybatisflex.core.service.IService;
|
||||
|
||||
/**
|
||||
* 店铺签约 服务层。
|
||||
*
|
||||
* @author Administrator
|
||||
* @since 2025-02-11
|
||||
*/
|
||||
public interface ShopRegisterService extends IService<ShopRegister> {
|
||||
|
||||
}
|
||||
@@ -1,6 +1,6 @@
|
||||
package com.czg.account.vo;
|
||||
|
||||
import com.czg.account.entity.MerchantRegister;
|
||||
import com.czg.account.entity.ShopRegister;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
|
||||
@@ -11,7 +11,7 @@ import java.time.LocalDateTime;
|
||||
*/
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@Data
|
||||
public class MerchantRegisterVO extends MerchantRegister {
|
||||
public class ShopRegisterVO extends ShopRegister {
|
||||
private String shopName;
|
||||
private String phone;
|
||||
private String registerType;
|
||||
@@ -1,19 +0,0 @@
|
||||
package com.czg.service.account.mapper;
|
||||
|
||||
import com.czg.account.entity.MerchantRegister;
|
||||
import com.czg.account.vo.MerchantRegisterVO;
|
||||
import com.mybatisflex.core.BaseMapper;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 激活码 映射层。
|
||||
*
|
||||
* @author Administrator
|
||||
* @since 2025-02-11
|
||||
*/
|
||||
public interface MerchantRegisterMapper extends BaseMapper<MerchantRegister> {
|
||||
|
||||
List<MerchantRegisterVO> pageInfo(@Param("state") Integer state, @Param("startTime") String startTime, @Param("endTime") String endTime);
|
||||
}
|
||||
@@ -0,0 +1,14 @@
|
||||
package com.czg.service.account.mapper;
|
||||
|
||||
import com.czg.account.entity.ShopRegister;
|
||||
import com.mybatisflex.core.BaseMapper;
|
||||
|
||||
/**
|
||||
* 店铺签约 映射层。
|
||||
*
|
||||
* @author Administrator
|
||||
* @since 2025-02-11
|
||||
*/
|
||||
public interface ShopRegisterMapper extends BaseMapper<ShopRegister> {
|
||||
|
||||
}
|
||||
@@ -1,47 +0,0 @@
|
||||
package com.czg.service.account.service.impl;
|
||||
|
||||
import cn.hutool.core.util.IdUtil;
|
||||
import com.czg.account.dto.PageDTO;
|
||||
import com.czg.account.dto.register.MerchantRegisterDTO;
|
||||
import com.czg.account.entity.MerchantRegister;
|
||||
import com.czg.account.service.MerchantRegisterService;
|
||||
import com.czg.service.account.mapper.MerchantRegisterMapper;
|
||||
import com.czg.utils.PageUtil;
|
||||
import com.github.pagehelper.PageHelper;
|
||||
import com.github.pagehelper.PageInfo;
|
||||
import com.mybatisflex.core.paginate.Page;
|
||||
import com.mybatisflex.spring.service.impl.ServiceImpl;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
/**
|
||||
* 激活码 服务层实现。
|
||||
*
|
||||
* @author Administrator
|
||||
* @since 2025-02-11
|
||||
*/
|
||||
@Service
|
||||
public class MerchantRegisterServiceImpl extends ServiceImpl<MerchantRegisterMapper, MerchantRegister> implements MerchantRegisterService {
|
||||
|
||||
@Override
|
||||
public Page<MerchantRegister> get(PageDTO pageDTO, Integer state, String startTime, String endTime) {
|
||||
Page<Object> page = PageUtil.buildPage();
|
||||
PageHelper.startPage(Math.toIntExact(page.getPageNumber()), Math.toIntExact(page.getPageSize()));
|
||||
return PageUtil.convert(new PageInfo<>(mapper.pageInfo(state, startTime, endTime)));
|
||||
}
|
||||
|
||||
@Override
|
||||
public Boolean add(MerchantRegisterDTO merchantRegisterDTO) {
|
||||
ArrayList<MerchantRegister> registers = new ArrayList<>();
|
||||
for (int i = 0; i < merchantRegisterDTO.num(); i++) {
|
||||
MerchantRegister tbMerchantRegister = new MerchantRegister();
|
||||
tbMerchantRegister.setRegisterCode(IdUtil.simpleUUID());
|
||||
tbMerchantRegister.setStatus(0);
|
||||
tbMerchantRegister.setPeriodMonth(merchantRegisterDTO.periodMonth());
|
||||
registers.add(tbMerchantRegister);
|
||||
}
|
||||
int i = mapper.insertBatchSelective(registers, 50);
|
||||
return i > 0;
|
||||
}
|
||||
}
|
||||
@@ -63,7 +63,7 @@ public class ShopInfoServiceImpl extends ServiceImpl<ShopInfoMapper, ShopInfo> i
|
||||
@Resource
|
||||
private SysUserService sysUserService;
|
||||
@Resource
|
||||
private MerchantRegisterService merchantRegisterService;
|
||||
private ShopRegisterService shopRegisterService;
|
||||
@Resource
|
||||
private ShopTableService shopTableService;
|
||||
@Resource
|
||||
@@ -147,22 +147,23 @@ public class ShopInfoServiceImpl extends ServiceImpl<ShopInfoMapper, ShopInfo> i
|
||||
return page;
|
||||
}
|
||||
|
||||
private void activateShop(ShopInfo shopInfo, String activateCode) {
|
||||
MerchantRegister merchantRegister = merchantRegisterService.queryChain().eq(MerchantRegister::getRegisterCode, activateCode).one();
|
||||
AssertUtil.isNull(merchantRegister, "激活码不存在");
|
||||
if (merchantRegister.getStatus() == 1) {
|
||||
throw new CzgException("激活码已使用");
|
||||
}
|
||||
|
||||
// 续期
|
||||
/**
|
||||
* 签约店铺
|
||||
* @param activateDuration 签约时长
|
||||
* @param amount 续期费用
|
||||
*/
|
||||
private void activateShop(ShopInfo shopInfo, Integer activateDuration, BigDecimal amount) {
|
||||
// 签约/续期
|
||||
if (shopInfo.getExpireTime() != null && shopInfo.getExpireTime().isAfter(LocalDateTime.now())) {
|
||||
shopInfo.setExpireTime(DateUtil.offsetMonth(DateUtil.date(shopInfo.getExpireTime()), merchantRegister.getPeriodMonth()).toLocalDateTime());
|
||||
shopInfo.setExpireTime(DateUtil.offsetMonth(DateUtil.date(shopInfo.getExpireTime()), activateDuration).toLocalDateTime());
|
||||
} else {
|
||||
shopInfo.setExpireTime(DateUtil.offsetMonth(DateUtil.date(), merchantRegister.getPeriodMonth()).toLocalDateTime());
|
||||
shopInfo.setExpireTime(DateUtil.offsetMonth(DateUtil.date(), activateDuration).toLocalDateTime());
|
||||
}
|
||||
merchantRegister.setStatus(1);
|
||||
merchantRegister.setShopId(shopInfo.getId());
|
||||
merchantRegisterService.updateById(merchantRegister);
|
||||
ShopRegister register = new ShopRegister();
|
||||
register.setShopId(shopInfo.getId());
|
||||
register.setPeriodMonth(activateDuration);
|
||||
register.setAmount(amount);
|
||||
shopRegisterService.save(register);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -207,10 +208,9 @@ public class ShopInfoServiceImpl extends ServiceImpl<ShopInfoMapper, ShopInfo> i
|
||||
shopInfo.setProfiles("release");
|
||||
}
|
||||
save(shopInfo);
|
||||
if (StrUtil.isNotBlank(shopInfoAddDTO.getActivateCode())) {
|
||||
activateShop(shopInfo, shopInfoAddDTO.getActivateCode());
|
||||
if (shopInfoAddDTO.getActivateDuration() != null) {
|
||||
activateShop(shopInfo, shopInfoAddDTO.getActivateDuration(),shopInfoAddDTO.getActivateAmount());
|
||||
}
|
||||
|
||||
// 增加支付方式
|
||||
shopPayTypeService.addInfo(shopInfo.getId());
|
||||
// 初始化积分霸王餐设置
|
||||
@@ -264,6 +264,7 @@ public class ShopInfoServiceImpl extends ServiceImpl<ShopInfoMapper, ShopInfo> i
|
||||
|
||||
@Override
|
||||
@CacheEvict(key = "#shopInfoEditDTO.id")
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public Boolean edit(ShopInfoEditDTO shopInfoEditDTO) {
|
||||
shopInfoEditDTO.setIsMemberPrice(null);
|
||||
ShopInfo shopInfo;
|
||||
@@ -298,8 +299,8 @@ public class ShopInfoServiceImpl extends ServiceImpl<ShopInfoMapper, ShopInfo> i
|
||||
} else {
|
||||
throw new CzgException("禁止连锁店/加盟店修改为单店");
|
||||
}
|
||||
if (shopInfoEditDTO.getActivateCode() != null) {
|
||||
activateShop(shopInfo, shopInfoEditDTO.getActivateCode());
|
||||
if (shopInfoEditDTO.getActivateDuration() != null) {
|
||||
activateShop(shopInfo, shopInfoEditDTO.getActivateDuration(),shopInfoEditDTO.getActivateAmount());
|
||||
}
|
||||
BeanUtil.copyProperties(shopInfoEditDTO, shopInfo);
|
||||
if (shopInfoEditDTO.getOperationPwd() != null) {
|
||||
|
||||
@@ -0,0 +1,18 @@
|
||||
package com.czg.service.account.service.impl;
|
||||
|
||||
import com.czg.account.entity.ShopRegister;
|
||||
import com.czg.account.service.ShopRegisterService;
|
||||
import com.czg.service.account.mapper.ShopRegisterMapper;
|
||||
import com.mybatisflex.spring.service.impl.ServiceImpl;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
/**
|
||||
* 店铺签约 服务层实现。
|
||||
*
|
||||
* @author Administrator
|
||||
* @since 2025-02-11
|
||||
*/
|
||||
@Service
|
||||
public class ShopRegisterServiceImpl extends ServiceImpl<ShopRegisterMapper, ShopRegister> implements ShopRegisterService {
|
||||
|
||||
}
|
||||
@@ -1,25 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE mapper
|
||||
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||
<mapper namespace="com.czg.service.account.mapper.MerchantRegisterMapper">
|
||||
|
||||
<select id="pageInfo" resultType="com.czg.account.vo.MerchantRegisterVO">
|
||||
select a.*, b.shop_name, b.phone, b.register_type, b.expire_time
|
||||
from tb_merchant_register as a
|
||||
left join tb_shop_info as b on a.shop_id = b.id
|
||||
<where>
|
||||
<if test="state != null">
|
||||
a.status=#{state}
|
||||
</if>
|
||||
<if test="startTime != null and startTime != ''">
|
||||
a.create_time >= #{startTime}
|
||||
</if>
|
||||
|
||||
<if test="endTime != null and endTime != ''">
|
||||
a.create_time <= #{endTime}
|
||||
</if>
|
||||
</where>
|
||||
order by a.create_time desc
|
||||
</select>
|
||||
</mapper>
|
||||
@@ -0,0 +1,7 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE mapper
|
||||
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||
<mapper namespace="com.czg.service.account.mapper.ShopRegisterMapper">
|
||||
|
||||
</mapper>
|
||||
Reference in New Issue
Block a user