diff --git a/eladmin-common/src/main/java/cn/ysk/cashier/utils/PageUtil.java b/eladmin-common/src/main/java/cn/ysk/cashier/utils/PageUtil.java index a3a22399..e4d5593c 100644 --- a/eladmin-common/src/main/java/cn/ysk/cashier/utils/PageUtil.java +++ b/eladmin-common/src/main/java/cn/ysk/cashier/utils/PageUtil.java @@ -15,6 +15,7 @@ */ package cn.ysk.cashier.utils; +import org.apache.poi.ss.formula.functions.T; import org.springframework.data.domain.Page; import java.util.*; @@ -49,8 +50,12 @@ public class PageUtil extends cn.hutool.core.util.PageUtil { map.put("totalElements",page.getTotalElements()); return map; } - - + public static Map toPlusPage(List list, Integer total) { + Map map = new LinkedHashMap<>(2); + map.put("content",list); + map.put("totalElements",total); + return map; + } /** * 自定义分页 */ diff --git a/eladmin-system/pom.xml b/eladmin-system/pom.xml index 8a176362..85a1471a 100644 --- a/eladmin-system/pom.xml +++ b/eladmin-system/pom.xml @@ -98,10 +98,20 @@ 2.1.4 + + + + + com.baomidou - mybatis-plus-extension - 3.3.2 + mybatis-plus-generator + 3.5.3.1 + + + com.baomidou + mybatis-plus-boot-starter + 3.5.3.1 diff --git a/eladmin-system/src/main/java/cn/ysk/cashier/config/MybatisPlusConfig.java b/eladmin-system/src/main/java/cn/ysk/cashier/config/MybatisPlusConfig.java new file mode 100644 index 00000000..f9e6df14 --- /dev/null +++ b/eladmin-system/src/main/java/cn/ysk/cashier/config/MybatisPlusConfig.java @@ -0,0 +1,36 @@ +package me.zhengjie.config; + +import com.baomidou.mybatisplus.annotation.DbType; +import com.baomidou.mybatisplus.extension.plugins.*; +import com.baomidou.mybatisplus.extension.plugins.inner.PaginationInnerInterceptor; +import org.mybatis.spring.annotation.MapperScan; +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.Configuration; +import org.springframework.transaction.annotation.EnableTransactionManagement; + +import java.util.Collections; + + +@Configuration +@MapperScan("me.zhengjie.mybatis.mapper") +@EnableTransactionManagement +public class MybatisPlusConfig { + + + @Bean + public PaginationInnerInterceptor paginationInnerInterceptor() { + PaginationInnerInterceptor paginationInterceptor = new PaginationInnerInterceptor(); + // 设置最大单页限制数量,默认 500 条,-1 不受限制 + paginationInterceptor.setMaxLimit(-1L); + paginationInterceptor.setDbType(DbType.MYSQL); + // 开启 count 的 join 优化,只针对部分 left join + paginationInterceptor.setOptimizeJoin(true); + return paginationInterceptor; + } + @Bean + public MybatisPlusInterceptor mybatisPlusInterceptor(){ + MybatisPlusInterceptor mybatisPlusInterceptor = new MybatisPlusInterceptor(); + mybatisPlusInterceptor.setInterceptors(Collections.singletonList(paginationInnerInterceptor())); + return mybatisPlusInterceptor; + } +} diff --git a/eladmin-system/src/main/java/cn/ysk/cashier/mybatis/entity/StorageVo.java b/eladmin-system/src/main/java/cn/ysk/cashier/mybatis/entity/StorageVo.java new file mode 100644 index 00000000..98a9d4ef --- /dev/null +++ b/eladmin-system/src/main/java/cn/ysk/cashier/mybatis/entity/StorageVo.java @@ -0,0 +1,13 @@ +package me.zhengjie.mybatis.entity; + +import lombok.Data; + +@Data +public class StorageVo { + private Integer id; + private String productName; + private String img; + private String account; + private String unit; + private Integer num; +} diff --git a/eladmin-system/src/main/java/cn/ysk/cashier/mybatis/entity/TbUserStorage.java b/eladmin-system/src/main/java/cn/ysk/cashier/mybatis/entity/TbUserStorage.java new file mode 100644 index 00000000..a4821d70 --- /dev/null +++ b/eladmin-system/src/main/java/cn/ysk/cashier/mybatis/entity/TbUserStorage.java @@ -0,0 +1,33 @@ +package me.zhengjie.mybatis.entity; + +import com.baomidou.mybatisplus.annotation.IdType; +import com.baomidou.mybatisplus.annotation.TableField; +import com.baomidou.mybatisplus.annotation.TableId; +import com.baomidou.mybatisplus.annotation.TableName; +import com.baomidou.mybatisplus.extension.activerecord.Model; +import lombok.Data; +import lombok.EqualsAndHashCode; + +import java.util.Date; + +@Data +@EqualsAndHashCode(callSuper = true) +@TableName("tb_user_storage") +public class TbUserStorage extends Model { + private static final long serialVersionUID = 1L; + @TableId(type = IdType.ASSIGN_UUID) + private String id; // 记录ID + private Integer userId; // 用户ID + private String shopId; // 用户ID + private Integer productId; + private Integer num; + private Integer outNum; + private Integer inNum; + private Date createTime; + private String account; + private String unit; + private String productName; + private Integer skuId; + private String skuName; + private String imgUrl; +} \ No newline at end of file diff --git a/eladmin-system/src/main/java/cn/ysk/cashier/mybatis/mapper/TbMerchantAccountMapper.java b/eladmin-system/src/main/java/cn/ysk/cashier/mybatis/mapper/TbMerchantAccountMapper.java new file mode 100644 index 00000000..97fa7574 --- /dev/null +++ b/eladmin-system/src/main/java/cn/ysk/cashier/mybatis/mapper/TbMerchantAccountMapper.java @@ -0,0 +1,30 @@ +/* +* Copyright 2019-2020 Zheng Jie +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ +package me.zhengjie.mybatis.mapper; + +import com.baomidou.mybatisplus.core.mapper.BaseMapper; +import me.zhengjie.modules.shopInfo.merchantAccount.domain.TbMerchantAccount; +import me.zhengjie.mybatis.entity.TbUserStorage; +import org.springframework.data.jpa.repository.JpaRepository; +import org.springframework.data.jpa.repository.JpaSpecificationExecutor; + +/** +* @website https://eladmin.vip +* @author lyf +* @date 2024-02-08 +**/ +public interface TbMerchantAccountMapper extends BaseMapper { +} \ No newline at end of file diff --git a/eladmin-system/src/main/java/cn/ysk/cashier/mybatis/mapper/TbProducSkutMapper.java b/eladmin-system/src/main/java/cn/ysk/cashier/mybatis/mapper/TbProducSkutMapper.java new file mode 100644 index 00000000..ba8e0856 --- /dev/null +++ b/eladmin-system/src/main/java/cn/ysk/cashier/mybatis/mapper/TbProducSkutMapper.java @@ -0,0 +1,10 @@ +package me.zhengjie.mybatis.mapper; + +import com.baomidou.mybatisplus.core.mapper.BaseMapper; +import me.zhengjie.modules.productInfo.product.domain.TbProduct; +import me.zhengjie.modules.productInfo.productSku.domain.TbProductSku; + +public interface TbProducSkutMapper extends BaseMapper { + + +} \ No newline at end of file diff --git a/eladmin-system/src/main/java/cn/ysk/cashier/mybatis/mapper/TbProductMapper.java b/eladmin-system/src/main/java/cn/ysk/cashier/mybatis/mapper/TbProductMapper.java new file mode 100644 index 00000000..0e9c1915 --- /dev/null +++ b/eladmin-system/src/main/java/cn/ysk/cashier/mybatis/mapper/TbProductMapper.java @@ -0,0 +1,10 @@ +package me.zhengjie.mybatis.mapper; + +import com.baomidou.mybatisplus.core.mapper.BaseMapper; +import me.zhengjie.modules.productInfo.product.domain.TbProduct; +import me.zhengjie.mybatis.entity.TbUserStorage; + +public interface TbProductMapper extends BaseMapper { + + +} \ No newline at end of file diff --git a/eladmin-system/src/main/java/cn/ysk/cashier/mybatis/mapper/TbUserStorageMapper.java b/eladmin-system/src/main/java/cn/ysk/cashier/mybatis/mapper/TbUserStorageMapper.java new file mode 100644 index 00000000..efa2e1b2 --- /dev/null +++ b/eladmin-system/src/main/java/cn/ysk/cashier/mybatis/mapper/TbUserStorageMapper.java @@ -0,0 +1,9 @@ +package me.zhengjie.mybatis.mapper; + +import com.baomidou.mybatisplus.core.mapper.BaseMapper; +import me.zhengjie.mybatis.entity.TbUserStorage; + +public interface TbUserStorageMapper extends BaseMapper { + + +} \ No newline at end of file diff --git a/eladmin-system/src/main/java/cn/ysk/cashier/mybatis/rest/StorageController.java b/eladmin-system/src/main/java/cn/ysk/cashier/mybatis/rest/StorageController.java new file mode 100644 index 00000000..f0f7d3e1 --- /dev/null +++ b/eladmin-system/src/main/java/cn/ysk/cashier/mybatis/rest/StorageController.java @@ -0,0 +1,40 @@ +package me.zhengjie.mybatis.rest; + +import io.swagger.annotations.Api; +import lombok.RequiredArgsConstructor; +import me.zhengjie.annotation.Log; +import me.zhengjie.mybatis.entity.StorageVo; +import me.zhengjie.mybatis.service.ShopService; +import me.zhengjie.utils.SecurityUtils; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.data.domain.Pageable; +import org.springframework.http.HttpStatus; +import org.springframework.http.ResponseEntity; +import org.springframework.web.bind.annotation.*; + +@RestController +@RequiredArgsConstructor +@Api(tags = "/shop/storage") +@RequestMapping("/api/storage") +public class StorageController { + @Autowired + private ShopService shopService; + @PostMapping("/findStorage") + public ResponseEntity findStorage(@RequestParam Integer shopId,String account,Pageable pageable){ + return new ResponseEntity<>(shopService.findStorage(shopId,account,pageable), HttpStatus.OK); + } + @PostMapping("/outStorage") + @Log("商品出库") + public ResponseEntity outStorage(@RequestParam Integer id,@RequestParam Integer num){ + String userName = SecurityUtils.getCurrentUsername(); + shopService.outStorage(id,userName,num); + return new ResponseEntity<>( HttpStatus.OK); + } + @PostMapping("/inStorage") + @Log("商品入库") + public ResponseEntity inStorage(@RequestBody StorageVo storageVo){ + String userName = SecurityUtils.getCurrentUsername(); + shopService.inStorage(storageVo,userName); + return new ResponseEntity<>(HttpStatus.OK); + } +} diff --git a/eladmin-system/src/main/java/cn/ysk/cashier/mybatis/service/ShopService.java b/eladmin-system/src/main/java/cn/ysk/cashier/mybatis/service/ShopService.java new file mode 100644 index 00000000..9607cf52 --- /dev/null +++ b/eladmin-system/src/main/java/cn/ysk/cashier/mybatis/service/ShopService.java @@ -0,0 +1,34 @@ +/* +* Copyright 2019-2020 Zheng Jie +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ +package me.zhengjie.mybatis.service; + +import me.zhengjie.mybatis.entity.StorageVo; +import org.springframework.data.domain.Pageable; + +/** +* @website https://eladmin.vip +* @description 服务接口 +* @author admin +* @date 2023-10-30 +**/ +public interface ShopService { + Object findStorage(Integer shopId, String account, Pageable pageable); + + void outStorage(Integer id, String userName, Integer num); + + + void inStorage(StorageVo storageVo, String userName); +} \ No newline at end of file diff --git a/eladmin-system/src/main/java/cn/ysk/cashier/mybatis/service/impl/ShopServiceImpl.java b/eladmin-system/src/main/java/cn/ysk/cashier/mybatis/service/impl/ShopServiceImpl.java new file mode 100644 index 00000000..4f0dd66d --- /dev/null +++ b/eladmin-system/src/main/java/cn/ysk/cashier/mybatis/service/impl/ShopServiceImpl.java @@ -0,0 +1,123 @@ +/* + * Copyright 2019-2020 Zheng Jie + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package me.zhengjie.mybatis.service.impl; + +import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; +import com.baomidou.mybatisplus.core.metadata.IPage; +import com.baomidou.mybatisplus.extension.plugins.pagination.Page; +import me.zhengjie.exception.NewBadRequestException; +import me.zhengjie.modules.productInfo.productSku.domain.TbProductSku; +import me.zhengjie.modules.shopInfo.merchantAccount.domain.TbMerchantAccount; +import me.zhengjie.mybatis.entity.StorageVo; +import me.zhengjie.mybatis.entity.TbUserStorage; +import me.zhengjie.mybatis.mapper.TbMerchantAccountMapper; +import me.zhengjie.mybatis.mapper.TbProducSkutMapper; +import me.zhengjie.mybatis.mapper.TbProductMapper; +import me.zhengjie.mybatis.mapper.TbUserStorageMapper; +import me.zhengjie.mybatis.service.ShopService; +import me.zhengjie.utils.*; +import org.apache.commons.lang3.StringUtils; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.data.domain.Pageable; +import org.springframework.stereotype.Service; + +import java.util.*; + +/** + * @author admin + * @website https://eladmin.vip + * @description 服务实现 + * @date 2023-10-30 + **/ +@Service +public class ShopServiceImpl implements ShopService { + + @Autowired + private TbUserStorageMapper userStorageMapper; + @Autowired + private TbMerchantAccountMapper tbMerchantAccountMapper; + @Autowired + private TbProducSkutMapper producSkutMapper; + @Autowired + private TbProductMapper productMapper; + @Override + public Object findStorage(Integer shopId, String account, Pageable pageable) { + QueryWrapper queryWrapper = new QueryWrapper<>(); + queryWrapper.eq("shop_id", shopId); + if (StringUtils.isNotEmpty(account)) { + queryWrapper.eq("account", account); + } + IPage iPage = userStorageMapper.selectPage(new Page<>(pageable.getPageNumber(), pageable.getPageSize()), queryWrapper); + return PageUtil.toPage(iPage.getRecords(), iPage.getTotal()); + } + + @Override + public void outStorage(Integer id, String userName, Integer num) { + if (Objects.isNull(num) || num < 0) { + throw new NewBadRequestException("请输入出库数量"); + } + QueryWrapper wrapper = new QueryWrapper<>(); + wrapper.eq("account", userName); + TbMerchantAccount merchantAccount = tbMerchantAccountMapper.selectOne(wrapper); + + QueryWrapper queryWrapper = new QueryWrapper<>(); + queryWrapper.eq("id", id); + queryWrapper.eq("shop_id", merchantAccount.getShopId()); + TbUserStorage userStorage = userStorageMapper.selectOne(queryWrapper); + if (Objects.isNull(userStorage)) { + throw new NewBadRequestException("存储商品在该店铺不存在"); + } + if (userStorage.getNum() < num) { + throw new NewBadRequestException("库存不足"); + } + userStorage.setNum(userStorage.getNum() - num); + userStorage.setOutNum(userStorage.getOutNum() + num); + userStorageMapper.updateById(userStorage); + } + + @Override + public void inStorage(StorageVo storageVo, String userName) { + if (Objects.isNull(storageVo.getNum()) || storageVo.getNum() < 0) { + throw new NewBadRequestException("请输入出库数量"); + } + QueryWrapper wrapper = new QueryWrapper<>(); + wrapper.eq("account", userName); + TbMerchantAccount merchantAccount = tbMerchantAccountMapper.selectOne(wrapper); + + QueryWrapper queryWrapper = new QueryWrapper<>(); + queryWrapper.eq("product_name", storageVo.getProductName()); + queryWrapper.eq("account", storageVo.getAccount()); + queryWrapper.eq("shop_id", merchantAccount.getShopId()); + TbUserStorage userStorage = userStorageMapper.selectOne(queryWrapper); + if (Objects.nonNull(userStorage)) { + userStorage.setNum(userStorage.getNum() + storageVo.getNum()); + userStorage.setInNum(userStorage.getInNum() + storageVo.getNum()); + userStorageMapper.updateById(userStorage); + }else { + userStorage = new TbUserStorage(); + userStorage.setAccount(storageVo.getAccount()); + userStorage.setCreateTime(new Date()); + userStorage.setShopId(merchantAccount.getShopId()); + userStorage.setNum(storageVo.getNum()); + userStorage.setOutNum(0); + userStorage.setInNum(storageVo.getNum()); + userStorage.setImgUrl(storageVo.getImg()); + userStorage.setProductName(storageVo.getImg()); + userStorage.setUnit(storageVo.getUnit()); + userStorageMapper.insert(userStorage); + } + } +} \ No newline at end of file diff --git a/eladmin-system/src/main/java/cn/ysk/cashier/pojo/product/TbProduct.java b/eladmin-system/src/main/java/cn/ysk/cashier/pojo/product/TbProduct.java index fb4c4fe8..3714d634 100644 --- a/eladmin-system/src/main/java/cn/ysk/cashier/pojo/product/TbProduct.java +++ b/eladmin-system/src/main/java/cn/ysk/cashier/pojo/product/TbProduct.java @@ -15,6 +15,9 @@ */ package cn.ysk.cashier.pojo.product; +import com.baomidou.mybatisplus.annotation.IdType; +import com.baomidou.mybatisplus.annotation.TableId; +import com.baomidou.mybatisplus.annotation.TableName; import lombok.Data; import cn.hutool.core.bean.BeanUtil; import io.swagger.annotations.ApiModelProperty; @@ -34,12 +37,14 @@ import java.io.Serializable; @Entity @Data @Table(name="tb_product") +@TableName("tb_product") public class TbProduct implements Serializable { @Id @Column(name = "`id`") @GeneratedValue(strategy = GenerationType.IDENTITY) @ApiModelProperty(value = "id") + @TableId(type = IdType.AUTO) private Integer id; @Column(name = "`source_path`") diff --git a/eladmin-system/src/main/java/cn/ysk/cashier/pojo/product/TbProductSku.java b/eladmin-system/src/main/java/cn/ysk/cashier/pojo/product/TbProductSku.java index 816ed2c2..9e2a7ce6 100644 --- a/eladmin-system/src/main/java/cn/ysk/cashier/pojo/product/TbProductSku.java +++ b/eladmin-system/src/main/java/cn/ysk/cashier/pojo/product/TbProductSku.java @@ -13,8 +13,13 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package cn.ysk.cashier.pojo.product; +package me.zhengjie.modules.productInfo.productSku.domain; +import cn.hutool.json.JSON; +import com.baomidou.mybatisplus.annotation.IdType; +import com.baomidou.mybatisplus.annotation.TableField; +import com.baomidou.mybatisplus.annotation.TableId; +import com.baomidou.mybatisplus.annotation.TableName; import lombok.Data; import cn.hutool.core.bean.BeanUtil; import io.swagger.annotations.ApiModelProperty; @@ -33,12 +38,14 @@ import java.io.Serializable; @Entity @Data @Table(name="tb_product_sku") +@TableName("tb_product_sku") public class TbProductSku implements Serializable { @Id @GeneratedValue(strategy = GenerationType.IDENTITY) @Column(name = "`id`") @ApiModelProperty(value = "自增id") + @TableId(type = IdType.AUTO) private Integer id; @Column(name = "`shop_id`") @@ -56,11 +63,11 @@ public class TbProductSku implements Serializable { @Column(name = "`origin_price`") @ApiModelProperty(value = "原价") - private BigDecimal originPrice; + private BigDecimal originPrice = new BigDecimal("0.00"); @Column(name = "`cost_price`") @ApiModelProperty(value = "成本价") - private BigDecimal costPrice; + private BigDecimal costPrice = new BigDecimal("0.00"); @Column(name = "`member_price`") @ApiModelProperty(value = "会员价") @@ -68,11 +75,11 @@ public class TbProductSku implements Serializable { @Column(name = "`meal_price`") @ApiModelProperty(value = "mealPrice") - private BigDecimal mealPrice; + private BigDecimal mealPrice = new BigDecimal("0.00"); @Column(name = "`sale_price`") @ApiModelProperty(value = "售价") - private BigDecimal salePrice; + private BigDecimal salePrice = new BigDecimal("0.00"); @Column(name = "`guide_price`") @ApiModelProperty(value = "进货参考价") @@ -84,7 +91,7 @@ public class TbProductSku implements Serializable { @Column(name = "`stock_number`") @ApiModelProperty(value = "库存数量") - private Double stockNumber; + private Double stockNumber = 0.00; @Column(name = "`spec_snap`") @ApiModelProperty(value = "标签镜像") @@ -108,7 +115,7 @@ public class TbProductSku implements Serializable { @Column(name = "`real_sales_number`") @ApiModelProperty(value = "销量") - private Double realSalesNumber; + private Double realSalesNumber = 0.00; @Column(name = "`first_shared`") @ApiModelProperty(value = "一级分销金额") diff --git a/eladmin-system/src/main/java/cn/ysk/cashier/pojo/shop/TbMerchantAccount.java b/eladmin-system/src/main/java/cn/ysk/cashier/pojo/shop/TbMerchantAccount.java index 55556084..f2518932 100644 --- a/eladmin-system/src/main/java/cn/ysk/cashier/pojo/shop/TbMerchantAccount.java +++ b/eladmin-system/src/main/java/cn/ysk/cashier/pojo/shop/TbMerchantAccount.java @@ -15,6 +15,9 @@ */ package cn.ysk.cashier.pojo.shop; +import com.baomidou.mybatisplus.annotation.IdType; +import com.baomidou.mybatisplus.annotation.TableId; +import com.baomidou.mybatisplus.annotation.TableName; import lombok.Data; import cn.hutool.core.bean.BeanUtil; import io.swagger.annotations.ApiModelProperty; @@ -31,6 +34,7 @@ import java.io.Serializable; **/ @Entity @Data +@TableName("tb_merchant_account") @Table(name="tb_merchant_account") public class TbMerchantAccount implements Serializable { @@ -38,6 +42,7 @@ public class TbMerchantAccount implements Serializable { @GeneratedValue(strategy = GenerationType.IDENTITY) @Column(name = "`id`") @ApiModelProperty(value = "自增id") + @TableId(type = IdType.AUTO) private Integer id; @Column(name = "`account`",nullable = false) diff --git a/eladmin-system/src/main/java/cn/ysk/cashier/service/impl/shopimpl/TbMerchantRegisterServiceImpl.java b/eladmin-system/src/main/java/cn/ysk/cashier/service/impl/shopimpl/TbMerchantRegisterServiceImpl.java index 6bc5a17a..a3d860b0 100644 --- a/eladmin-system/src/main/java/cn/ysk/cashier/service/impl/shopimpl/TbMerchantRegisterServiceImpl.java +++ b/eladmin-system/src/main/java/cn/ysk/cashier/service/impl/shopimpl/TbMerchantRegisterServiceImpl.java @@ -13,26 +13,26 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package cn.ysk.cashier.service.impl.shopimpl; +package me.zhengjie.modules.shopInfo.shopRegister.service.impl; -import cn.ysk.cashier.exception.BadRequestException; -import cn.ysk.cashier.pojo.shop.TbMerchantRegister; -import cn.ysk.cashier.utils.ValidationUtil; -import cn.ysk.cashier.utils.FileUtil; +import me.zhengjie.exception.BadRequestException; +import me.zhengjie.modules.shopInfo.shopRegister.domain.TbMerchantRegister; +import me.zhengjie.utils.ValidationUtil; +import me.zhengjie.utils.FileUtil; import lombok.RequiredArgsConstructor; -import cn.ysk.cashier.repository.shop.TbMerchantRegisterRepository; -import cn.ysk.cashier.service.shop.TbMerchantRegisterService; -import cn.ysk.cashier.dto.shop.TbMerchantRegisterDto; -import cn.ysk.cashier.dto.shop.TbMerchantRegisterQueryCriteria; -import cn.ysk.cashier.mapper.shop.TbMerchantRegisterMapper; +import me.zhengjie.modules.shopInfo.shopRegister.repository.TbMerchantRegisterRepository; +import me.zhengjie.modules.shopInfo.shopRegister.service.TbMerchantRegisterService; +import me.zhengjie.modules.shopInfo.shopRegister.service.dto.TbMerchantRegisterDto; +import me.zhengjie.modules.shopInfo.shopRegister.service.dto.TbMerchantRegisterQueryCriteria; +import me.zhengjie.modules.shopInfo.shopRegister.service.mapstruct.TbMerchantRegisterMapper; import org.springframework.data.domain.PageRequest; import org.springframework.data.domain.Sort; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; import org.springframework.data.domain.Page; import org.springframework.data.domain.Pageable; -import cn.ysk.cashier.utils.PageUtil; -import cn.ysk.cashier.utils.QueryHelp; +import me.zhengjie.utils.PageUtil; +import me.zhengjie.utils.QueryHelp; import java.time.Instant; import java.util.*; @@ -88,9 +88,6 @@ 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("-", ""));