## 商品列表添加批量上下架功能,按商品分类查询功能
This commit is contained in:
		
							parent
							
								
									e4843067c3
								
							
						
					
					
						commit
						a4e8ead1ab
					
				|  | @ -2,6 +2,7 @@ package com.hzs.sale.wares.controller.manage; | ||||||
| 
 | 
 | ||||||
| import cn.hutool.core.bean.BeanUtil; | import cn.hutool.core.bean.BeanUtil; | ||||||
| import cn.hutool.core.collection.CollectionUtil; | import cn.hutool.core.collection.CollectionUtil; | ||||||
|  | import com.alibaba.nacos.client.naming.utils.CollectionUtils; | ||||||
| import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; | import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; | ||||||
| import com.baomidou.mybatisplus.core.toolkit.Wrappers; | import com.baomidou.mybatisplus.core.toolkit.Wrappers; | ||||||
| import com.hzs.common.core.annotation.AccessPermissions; | import com.hzs.common.core.annotation.AccessPermissions; | ||||||
|  | @ -79,8 +80,6 @@ public class BdWaresController extends BaseController { | ||||||
|     @Autowired |     @Autowired | ||||||
|     private IBdWaresLabelService waresLabelService; |     private IBdWaresLabelService waresLabelService; | ||||||
|     @Autowired |     @Autowired | ||||||
|     private IBdWaresExtendService waresExtendService; |  | ||||||
|     @Autowired |  | ||||||
|     private IBdWaresDetailService waresDetailService; |     private IBdWaresDetailService waresDetailService; | ||||||
|     @Autowired |     @Autowired | ||||||
|     private IBdWaresSpecsSkuService waresSpecsSkuService; |     private IBdWaresSpecsSkuService waresSpecsSkuService; | ||||||
|  | @ -94,6 +93,8 @@ public class BdWaresController extends BaseController { | ||||||
|     private IBdAreaClassifyService areaClassifyService; |     private IBdAreaClassifyService areaClassifyService; | ||||||
|     @Autowired |     @Autowired | ||||||
|     private UserTokenService userTokenService; |     private UserTokenService userTokenService; | ||||||
|  |     @Autowired | ||||||
|  |     private IBdWaresExtendService iBdWaresExtendService; | ||||||
| 
 | 
 | ||||||
|     /** |     /** | ||||||
|      * 查询列表 |      * 查询列表 | ||||||
|  | @ -561,7 +562,7 @@ public class BdWaresController extends BaseController { | ||||||
|         BdWares wares = iBdWaresService.getById(pkId); |         BdWares wares = iBdWaresService.getById(pkId); | ||||||
|         LambdaQueryWrapper<BdWaresExtend> queryWrapper = new LambdaQueryWrapper<>(); |         LambdaQueryWrapper<BdWaresExtend> queryWrapper = new LambdaQueryWrapper<>(); | ||||||
|         queryWrapper.eq(BdWaresExtend::getPkWares, pkId); |         queryWrapper.eq(BdWaresExtend::getPkWares, pkId); | ||||||
|         BdWaresExtend waresExtend = waresExtendService.getOne(queryWrapper); |         BdWaresExtend waresExtend = iBdWaresExtendService.getOne(queryWrapper); | ||||||
|         WaresParams waresParams = new WaresParams(); |         WaresParams waresParams = new WaresParams(); | ||||||
|         waresParams.setWaresId(wares.getPkId()); |         waresParams.setWaresId(wares.getPkId()); | ||||||
|         waresParams.setIsPreSale(wares.getIsPreSale()); |         waresParams.setIsPreSale(wares.getIsPreSale()); | ||||||
|  | @ -1119,4 +1120,32 @@ public class BdWaresController extends BaseController { | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
| 
 | 
 | ||||||
|  |     /** | ||||||
|  |      * 商品批量上架 | ||||||
|  |      */ | ||||||
|  |     @Log(module = EOperationModule.PUT_ON_LIST, business = EOperationBusiness.PUT_ON_LIST, method = EOperationMethod.RENEW, remark = "商品批量上架") | ||||||
|  |     @PostMapping("/putOnList") | ||||||
|  |     public AjaxResult putOnList(@RequestBody WaresPutOnIdsParams waresPutOnIdsParams) { | ||||||
|  |         if (CollectionUtils.isEmpty(waresPutOnIdsParams.getPkWares())) { | ||||||
|  |             return AjaxResult.error("商品ID不能为空"); | ||||||
|  |         } | ||||||
|  |         iBdWaresExtendService.putOnList(waresPutOnIdsParams); | ||||||
|  |         return AjaxResult.success(); | ||||||
|  |     } | ||||||
|  | 
 | ||||||
|  | 
 | ||||||
|  |     /** | ||||||
|  |      * 商品批量下架 | ||||||
|  |      */ | ||||||
|  |     @Log(module = EOperationModule.PUT_OFF_LIST, business = EOperationBusiness.PUT_OFF_LIST, method = EOperationMethod.RENEW, remark = "商品批量下架") | ||||||
|  |     @PostMapping("/putOffList") | ||||||
|  |     public AjaxResult putOffList(@RequestBody WaresPutOnIdsParams waresPutOnIdsParams) { | ||||||
|  |         if (CollectionUtils.isEmpty(waresPutOnIdsParams.getPkWares())) { | ||||||
|  |             return AjaxResult.error("商品ID不能为空"); | ||||||
|  |         } | ||||||
|  |         iBdWaresExtendService.putOffList(waresPutOnIdsParams); | ||||||
|  |         return AjaxResult.success(); | ||||||
|  |     } | ||||||
|  | 
 | ||||||
|  | 
 | ||||||
| } | } | ||||||
|  |  | ||||||
|  | @ -49,4 +49,11 @@ public interface BdWaresExtendMapper extends BaseMapper<BdWaresExtend> { | ||||||
|      */ |      */ | ||||||
|     int batchUpdateInventoryUse(@Param("limitList") List<BdWaresMemberLimit> limitList); |     int batchUpdateInventoryUse(@Param("limitList") List<BdWaresMemberLimit> limitList); | ||||||
| 
 | 
 | ||||||
|  |     void putOnList(@Param("pkWares") List<Integer> pkWares); | ||||||
|  | 
 | ||||||
|  |     void putOffList(@Param("pkWares") List<Integer> pkWares); | ||||||
|  | 
 | ||||||
|  |     void updatePutOnTimeByPkWares(@Param("pkWares") List<Integer> pkWares); | ||||||
|  | 
 | ||||||
|  |     void updatePutOffTimeByPkWares(@Param("pkWares") List<Integer> pkWares); | ||||||
| } | } | ||||||
|  |  | ||||||
|  | @ -0,0 +1,17 @@ | ||||||
|  | package com.hzs.sale.wares.param; | ||||||
|  | 
 | ||||||
|  | import lombok.AllArgsConstructor; | ||||||
|  | import lombok.Data; | ||||||
|  | import lombok.NoArgsConstructor; | ||||||
|  | 
 | ||||||
|  | import java.util.List; | ||||||
|  | 
 | ||||||
|  | @Data | ||||||
|  | @AllArgsConstructor | ||||||
|  | @NoArgsConstructor | ||||||
|  | public class WaresPutOnIdsParams { | ||||||
|  |     /** | ||||||
|  |      * 商品主键信息 | ||||||
|  |      */ | ||||||
|  |     private List<Integer> pkWares; | ||||||
|  | } | ||||||
|  | @ -5,6 +5,7 @@ import com.hzs.common.domain.sale.wares.BdWaresExtend; | ||||||
| import com.hzs.common.domain.sale.wares.BdWaresMemberLimit; | import com.hzs.common.domain.sale.wares.BdWaresMemberLimit; | ||||||
| import com.hzs.sale.order.param.WaresNumberParam; | import com.hzs.sale.order.param.WaresNumberParam; | ||||||
| import com.hzs.sale.order.vo.WaresPreSaleVo; | import com.hzs.sale.order.vo.WaresPreSaleVo; | ||||||
|  | import com.hzs.sale.wares.param.WaresPutOnIdsParams; | ||||||
| 
 | 
 | ||||||
| import java.util.Collection; | import java.util.Collection; | ||||||
| import java.util.Date; | import java.util.Date; | ||||||
|  | @ -56,4 +57,7 @@ public interface IBdWaresExtendService extends IService<BdWaresExtend> { | ||||||
|      */ |      */ | ||||||
|     int batchUpdateInventoryUse(List<BdWaresMemberLimit> limitList); |     int batchUpdateInventoryUse(List<BdWaresMemberLimit> limitList); | ||||||
| 
 | 
 | ||||||
|  |     void putOnList(WaresPutOnIdsParams waresPutOnIdsParams); | ||||||
|  | 
 | ||||||
|  |     void putOffList(WaresPutOnIdsParams waresPutOnIdsParams); | ||||||
| } | } | ||||||
|  |  | ||||||
|  | @ -1,6 +1,7 @@ | ||||||
| package com.hzs.sale.wares.service.impl; | package com.hzs.sale.wares.service.impl; | ||||||
| 
 | 
 | ||||||
| import cn.hutool.core.collection.CollectionUtil; | import cn.hutool.core.collection.CollectionUtil; | ||||||
|  | import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; | ||||||
| import com.baomidou.mybatisplus.core.toolkit.Wrappers; | import com.baomidou.mybatisplus.core.toolkit.Wrappers; | ||||||
| import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; | import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; | ||||||
| import com.hzs.common.domain.sale.wares.BdWaresExtend; | import com.hzs.common.domain.sale.wares.BdWaresExtend; | ||||||
|  | @ -8,18 +9,23 @@ import com.hzs.common.domain.sale.wares.BdWaresMemberLimit; | ||||||
| import com.hzs.sale.order.param.WaresNumberParam; | import com.hzs.sale.order.param.WaresNumberParam; | ||||||
| import com.hzs.sale.order.vo.WaresPreSaleVo; | import com.hzs.sale.order.vo.WaresPreSaleVo; | ||||||
| import com.hzs.sale.wares.mapper.BdWaresExtendMapper; | import com.hzs.sale.wares.mapper.BdWaresExtendMapper; | ||||||
|  | import com.hzs.sale.wares.param.WaresPutOnIdsParams; | ||||||
| import com.hzs.sale.wares.service.IBdWaresExtendService; | import com.hzs.sale.wares.service.IBdWaresExtendService; | ||||||
|  | import lombok.extern.slf4j.Slf4j; | ||||||
| import org.springframework.stereotype.Service; | import org.springframework.stereotype.Service; | ||||||
|  | import org.springframework.transaction.annotation.Transactional; | ||||||
| 
 | 
 | ||||||
| import java.util.Collection; | import java.util.Collection; | ||||||
| import java.util.Collections; | import java.util.Collections; | ||||||
| import java.util.Date; | import java.util.Date; | ||||||
| import java.util.List; | import java.util.List; | ||||||
|  | import java.util.stream.Collectors; | ||||||
| 
 | 
 | ||||||
| /** | /** | ||||||
|  * 商品发布扩展表 服务实现类 |  * 商品发布扩展表 服务实现类 | ||||||
|  */ |  */ | ||||||
| @Service | @Service | ||||||
|  | @Slf4j | ||||||
| public class BdWaresExtendServiceImpl extends ServiceImpl<BdWaresExtendMapper, BdWaresExtend> implements IBdWaresExtendService { | public class BdWaresExtendServiceImpl extends ServiceImpl<BdWaresExtendMapper, BdWaresExtend> implements IBdWaresExtendService { | ||||||
| 
 | 
 | ||||||
|     @Override |     @Override | ||||||
|  | @ -62,4 +68,36 @@ public class BdWaresExtendServiceImpl extends ServiceImpl<BdWaresExtendMapper, B | ||||||
|         return baseMapper.batchUpdateInventoryUse(limitList); |         return baseMapper.batchUpdateInventoryUse(limitList); | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|  |     @Override | ||||||
|  |     @Transactional(rollbackFor = Exception.class) | ||||||
|  |     public void putOnList(WaresPutOnIdsParams waresPutOnIdsParams) { | ||||||
|  |         log.info("上架商品主键列表{}",waresPutOnIdsParams.getPkWares()); | ||||||
|  |         List<BdWaresExtend> bdWaresExtends = baseMapper.selectList(new LambdaQueryWrapper<BdWaresExtend>() | ||||||
|  |                 .in(BdWaresExtend::getPkWares, waresPutOnIdsParams.getPkWares()) | ||||||
|  |                 .eq(BdWaresExtend::getIsPutOn, 1)); | ||||||
|  |         List<Integer> list = bdWaresExtends.stream().map(BdWaresExtend::getPkWares).collect(Collectors.toList()); | ||||||
|  |         log.info("当前未上架商品主键列表{}",list); | ||||||
|  |         if (CollectionUtil.isEmpty(list)) { | ||||||
|  |             return; | ||||||
|  |         } | ||||||
|  |         baseMapper.putOnList(list); | ||||||
|  |         baseMapper.updatePutOnTimeByPkWares(list); | ||||||
|  |     } | ||||||
|  | 
 | ||||||
|  |     @Override | ||||||
|  |     @Transactional(rollbackFor = Exception.class) | ||||||
|  |     public void putOffList(WaresPutOnIdsParams waresPutOnIdsParams) { | ||||||
|  |         log.info("下架商品主键列表{}",waresPutOnIdsParams.getPkWares()); | ||||||
|  |         List<BdWaresExtend> bdWaresExtends = baseMapper.selectList(new LambdaQueryWrapper<BdWaresExtend>() | ||||||
|  |                 .in(BdWaresExtend::getPkWares, waresPutOnIdsParams.getPkWares()) | ||||||
|  |                 .eq(BdWaresExtend::getIsPutOn, 0)); | ||||||
|  |         List<Integer> list = bdWaresExtends.stream().map(BdWaresExtend::getPkWares).collect(Collectors.toList()); | ||||||
|  |         log.info("当前未下架商品主键列表{}",list); | ||||||
|  |         if (CollectionUtil.isEmpty(list)) { | ||||||
|  |             return; | ||||||
|  |         } | ||||||
|  |         baseMapper.putOffList(list); | ||||||
|  |         baseMapper.updatePutOffTimeByPkWares(list); | ||||||
|  |     } | ||||||
|  | 
 | ||||||
| } | } | ||||||
|  |  | ||||||
|  | @ -100,5 +100,37 @@ | ||||||
|         when matched then |         when matched then | ||||||
|         update set bwe.inventory_use = bwe.inventory_use + tmp.quantity |         update set bwe.inventory_use = bwe.inventory_use + tmp.quantity | ||||||
|     </update> |     </update> | ||||||
|  |     <update id="putOnList"> | ||||||
|  |         update BD_WARES_EXTEND | ||||||
|  |         SET IS_PUT_ON = 0 | ||||||
|  |         WHERE PK_WARES IN | ||||||
|  |         <foreach collection="pkWares" item="id" open="(" separator="," close=")"> | ||||||
|  |             #{id} | ||||||
|  |         </foreach> | ||||||
|  |     </update> | ||||||
|  |     <update id="putOffList"> | ||||||
|  |         update BD_WARES_EXTEND | ||||||
|  |         SET IS_PUT_ON = 1 | ||||||
|  |         WHERE PK_WARES IN | ||||||
|  |         <foreach collection="pkWares" item="id" open="(" separator="," close=")"> | ||||||
|  |             #{id} | ||||||
|  |         </foreach> | ||||||
|  |     </update> | ||||||
|  |     <update id="updatePutOnTimeByPkWares"> | ||||||
|  |         update BD_WARES | ||||||
|  |         SET LISTING_TIME = SYSDATE | ||||||
|  |         WHERE PK_ID IN | ||||||
|  |         <foreach collection="pkWares" item="id" open="(" separator="," close=")"> | ||||||
|  |             #{id} | ||||||
|  |         </foreach> | ||||||
|  |     </update> | ||||||
|  |     <update id="updatePutOffTimeByPkWares"> | ||||||
|  |         update BD_WARES | ||||||
|  |         SET REMOVAL_TIME = SYSDATE | ||||||
|  |         WHERE PK_ID IN | ||||||
|  |         <foreach collection="pkWares" item="id" open="(" separator="," close=")"> | ||||||
|  |             #{id} | ||||||
|  |         </foreach> | ||||||
|  |     </update> | ||||||
| 
 | 
 | ||||||
| </mapper> | </mapper> | ||||||
|  |  | ||||||
|  | @ -263,6 +263,9 @@ | ||||||
|         <if test="waresStatus != null"> |         <if test="waresStatus != null"> | ||||||
|             and bw.WARES_STATUS <= #{waresStatus} |             and bw.WARES_STATUS <= #{waresStatus} | ||||||
|         </if> |         </if> | ||||||
|  |         <if test="isMakerGift != null"> | ||||||
|  |             and we.IS_MAKER_GIFT = #{isMakerGift} | ||||||
|  |         </if> | ||||||
|         order by bw.sort desc, bw.CREATION_TIME desc |         order by bw.sort desc, bw.CREATION_TIME desc | ||||||
|     </select> |     </select> | ||||||
| 
 | 
 | ||||||
|  |  | ||||||
|  | @ -110,6 +110,10 @@ public enum EOperationBusiness { | ||||||
| 
 | 
 | ||||||
|     WARES_LIST("商品列表"), |     WARES_LIST("商品列表"), | ||||||
| 
 | 
 | ||||||
|  |     PUT_ON_LIST("商品批量上架"), | ||||||
|  | 
 | ||||||
|  |     PUT_OFF_LIST("商品批量下架"), | ||||||
|  | 
 | ||||||
|     AREA_CLASSIFY("商品分类"), |     AREA_CLASSIFY("商品分类"), | ||||||
| 
 | 
 | ||||||
|     PRODUCT_CLASSIFY("产品分类"), |     PRODUCT_CLASSIFY("产品分类"), | ||||||
|  |  | ||||||
|  | @ -72,6 +72,10 @@ public enum EOperationModule { | ||||||
| 
 | 
 | ||||||
|     WARES_LIST("商品列表"), |     WARES_LIST("商品列表"), | ||||||
| 
 | 
 | ||||||
|  |     PUT_ON_LIST("商品批量上架"), | ||||||
|  | 
 | ||||||
|  |     PUT_OFF_LIST("商品批量下架"), | ||||||
|  | 
 | ||||||
|     AREA_CLASSIFY("商品分类"), |     AREA_CLASSIFY("商品分类"), | ||||||
| 
 | 
 | ||||||
|     SPECIFICATIONS_CONFIG("规格配置"), |     SPECIFICATIONS_CONFIG("规格配置"), | ||||||
|  |  | ||||||
		Loading…
	
		Reference in New Issue