新增规格逻辑修改,新增激活码到期时间,激活码时间校验
This commit is contained in:
@@ -77,7 +77,7 @@ public class TbProductQueryCriteria{
|
||||
|
||||
/** 精确 */
|
||||
@Query
|
||||
private Integer status;
|
||||
private Integer status =1;
|
||||
|
||||
/** 精确 */
|
||||
@Query
|
||||
|
||||
@@ -32,4 +32,7 @@ public interface TbProductRepository extends JpaRepository<TbProduct, Integer>,
|
||||
|
||||
@Query("SELECT product from TbProduct product where product.id in :productIds")
|
||||
List<TbProduct> findByIds(List<Integer> productIds);
|
||||
|
||||
@Query(value = "update tb_product set status = -1 where id in :productIds",nativeQuery = true)
|
||||
Integer updateByStatus(List<Integer> productIds);
|
||||
}
|
||||
@@ -311,16 +311,12 @@ public class TbProductServiceImpl implements TbProductService {
|
||||
tbProductSkuRepository.saveAll(skuList);
|
||||
|
||||
}
|
||||
// ValidationUtil.isNull( tbProduct.getId(),"TbProduct","id",resources.getId());
|
||||
// tbProduct.copy(resources);
|
||||
// tbProductRepository.save(tbProduct);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void deleteAll(Integer[] ids) {
|
||||
for (Integer id : ids) {
|
||||
tbProductRepository.deleteById(id);
|
||||
}
|
||||
List<Integer> list = Arrays.asList(ids);
|
||||
tbProductRepository.updateByStatus(list);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -110,9 +110,8 @@ public class TbShopCategoryServiceImpl implements TbShopCategoryService {
|
||||
public TbShopCategory create(TbShopCategory resources) {
|
||||
resources.setCreatedAt(Instant.now().toEpochMilli());
|
||||
resources.setUpdatedAt(Instant.now().toEpochMilli());
|
||||
|
||||
TbShopCategoryDto dto = tbShopCategoryMapper.toDto(tbShopCategoryRepository.save(resources));
|
||||
if (resources.getName() != null){
|
||||
TbShopCategory byName = tbShopCategoryRepository.findByName(resources.getName(), resources.getShopId());
|
||||
if (byName.getName() != null){
|
||||
throw new BadRequestException("分类名称重复");
|
||||
}
|
||||
if (resources.getPid() == null || "".equals(resources.getPid())){
|
||||
@@ -121,8 +120,7 @@ public class TbShopCategoryServiceImpl implements TbShopCategoryService {
|
||||
resources.setTree(Integer.valueOf(resources.getPid().trim()));
|
||||
}
|
||||
|
||||
ValidationUtil.isNull(dto.getId(),"TbShopCategory","id",resources.getId());
|
||||
tbShopCategoryRepository.save(resources);
|
||||
ValidationUtil.isNull(resources.getId(),"TbShopCategory","id",resources.getId());
|
||||
return tbShopCategoryRepository.save(resources);
|
||||
}
|
||||
|
||||
|
||||
@@ -88,6 +88,9 @@ public class TbMerchantRegisterServiceImpl implements TbMerchantRegisterService
|
||||
if (resources.getNumber()>10){
|
||||
throw new BadRequestException("每次最多生成10条激活码");
|
||||
}
|
||||
if (resources.getPeriodYear() <= 0){
|
||||
throw new BadRequestException("激活码时长有误");
|
||||
}
|
||||
for (int i = 0; i < resources.getNumber(); i++) {
|
||||
TbMerchantRegister tbMerchantRegister = new TbMerchantRegister();
|
||||
tbMerchantRegister.setRegisterCode(UUID.randomUUID().toString().replaceAll("-", ""));
|
||||
|
||||
@@ -75,6 +75,8 @@ public class TbShopInfoServiceImpl implements TbShopInfoService {
|
||||
|
||||
private final TbPlussShopStaffRepository shopStaffRepository;
|
||||
|
||||
private final RedisUtils redisUtils;
|
||||
|
||||
@Override
|
||||
public Map<String,Object> queryAll(TbShopInfoQueryCriteria criteria){
|
||||
Sort sort = Sort.by(Sort.Direction.DESC, "id");
|
||||
@@ -130,8 +132,31 @@ public class TbShopInfoServiceImpl implements TbShopInfoService {
|
||||
BeanUtils.copyProperties(resources,tbShopInfo);
|
||||
tbShopInfo.setCreatedAt(Instant.now().toEpochMilli());
|
||||
tbShopInfo.setUpdatedAt(Instant.now().toEpochMilli());
|
||||
//激活码
|
||||
TbMerchantRegister tbMerchantRegister = new TbMerchantRegister();
|
||||
if (resources.getRegisterCode() != null){
|
||||
tbMerchantRegister = merchantRegisterRepository.findByRegisterCode(resources.getRegisterCode());
|
||||
if(tbMerchantRegister == null){
|
||||
throw new BadRequestException("激活码有误");
|
||||
}
|
||||
if (tbMerchantRegister.getStatus() == 1){
|
||||
throw new BadRequestException("激活码已激活,不能重复绑定");
|
||||
}
|
||||
tbShopInfo.setExpireAt(DateUtil.addMonthsAndGetTimestamp(tbMerchantRegister.getPeriodYear()));
|
||||
//向redis中存入key
|
||||
redisUtils.set(CacheKey.ACT_CODE,resources.getAccount(),tbShopInfo.getExpireAt()-Instant.now().toEpochMilli());
|
||||
}
|
||||
//增加商户详情
|
||||
TbShopInfo save = tbShopInfoRepository.save(tbShopInfo);
|
||||
if (resources.getRegisterCode() != null) {
|
||||
//激活码绑定
|
||||
tbMerchantRegister.setStatus(1);
|
||||
tbMerchantRegister.setShopId(String.valueOf(save.getId()));
|
||||
tbMerchantRegister.setName(save.getShopName());
|
||||
merchantRegisterRepository.save(tbMerchantRegister);
|
||||
|
||||
|
||||
}
|
||||
//增加商户登录账号
|
||||
TbMerchantAccount tbMerchantAccount = new TbMerchantAccount();
|
||||
tbMerchantAccount.setAccount(resources.getAccount());
|
||||
@@ -183,22 +208,7 @@ public class TbShopInfoServiceImpl implements TbShopInfoService {
|
||||
tbPlussShopStaff.setCode(save.getPhone());
|
||||
shopStaffRepository.save(tbPlussShopStaff);
|
||||
|
||||
if (resources.getRegisterCode() != null){
|
||||
//激活码绑定
|
||||
TbMerchantRegister tbMerchantRegister = merchantRegisterRepository.findByRegisterCode(resources.getRegisterCode());
|
||||
if(tbMerchantRegister == null){
|
||||
throw new BadRequestException("激活码有误");
|
||||
}
|
||||
if (tbMerchantRegister.getStatus() == 1){
|
||||
throw new BadRequestException("激活码已激活,不能重复绑定");
|
||||
}
|
||||
tbMerchantRegister.setStatus(1);
|
||||
tbMerchantAccount.setShopId(String.valueOf(save.getId()));
|
||||
tbMerchantAccount.setName(save.getShopName());
|
||||
merchantRegisterRepository.save(tbMerchantRegister);
|
||||
//向redis中存入key
|
||||
// redisUtils.set
|
||||
}
|
||||
|
||||
|
||||
return tbShopInfoMapper.toDto(new TbShopInfo());
|
||||
}
|
||||
|
||||
@@ -26,7 +26,7 @@ spring:
|
||||
properties:
|
||||
hibernate:
|
||||
dialect: org.hibernate.dialect.MySQL5InnoDBDialect
|
||||
show_sql: true
|
||||
show_sql: false
|
||||
|
||||
redis:
|
||||
#数据库索引
|
||||
|
||||
Reference in New Issue
Block a user