店铺签约
This commit is contained in:
@@ -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