## 商品列表添加批量上下架功能,按商品分类查询功能
This commit is contained in:
		
							parent
							
								
									5affb18304
								
							
						
					
					
						commit
						602a9a7fb6
					
				|  | @ -2,6 +2,7 @@ package com.hzs.sale.wares.controller.manage; | |||
| 
 | ||||
| import cn.hutool.core.bean.BeanUtil; | ||||
| 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.toolkit.Wrappers; | ||||
| import com.hzs.common.core.annotation.AccessPermissions; | ||||
|  | @ -79,8 +80,6 @@ public class BdWaresController extends BaseController { | |||
|     @Autowired | ||||
|     private IBdWaresLabelService waresLabelService; | ||||
|     @Autowired | ||||
|     private IBdWaresExtendService waresExtendService; | ||||
|     @Autowired | ||||
|     private IBdWaresDetailService waresDetailService; | ||||
|     @Autowired | ||||
|     private IBdWaresSpecsSkuService waresSpecsSkuService; | ||||
|  | @ -94,6 +93,8 @@ public class BdWaresController extends BaseController { | |||
|     private IBdAreaClassifyService areaClassifyService; | ||||
|     @Autowired | ||||
|     private UserTokenService userTokenService; | ||||
|     @Autowired | ||||
|     private IBdWaresExtendService iBdWaresExtendService; | ||||
| 
 | ||||
|     /** | ||||
|      * 查询列表 | ||||
|  | @ -561,7 +562,7 @@ public class BdWaresController extends BaseController { | |||
|         BdWares wares = iBdWaresService.getById(pkId); | ||||
|         LambdaQueryWrapper<BdWaresExtend> queryWrapper = new LambdaQueryWrapper<>(); | ||||
|         queryWrapper.eq(BdWaresExtend::getPkWares, pkId); | ||||
|         BdWaresExtend waresExtend = waresExtendService.getOne(queryWrapper); | ||||
|         BdWaresExtend waresExtend = iBdWaresExtendService.getOne(queryWrapper); | ||||
|         WaresParams waresParams = new WaresParams(); | ||||
|         waresParams.setWaresId(wares.getPkId()); | ||||
|         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); | ||||
| 
 | ||||
|     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.sale.order.param.WaresNumberParam; | ||||
| import com.hzs.sale.order.vo.WaresPreSaleVo; | ||||
| import com.hzs.sale.wares.param.WaresPutOnIdsParams; | ||||
| 
 | ||||
| import java.util.Collection; | ||||
| import java.util.Date; | ||||
|  | @ -56,4 +57,7 @@ public interface IBdWaresExtendService extends IService<BdWaresExtend> { | |||
|      */ | ||||
|     int batchUpdateInventoryUse(List<BdWaresMemberLimit> limitList); | ||||
| 
 | ||||
|     void putOnList(WaresPutOnIdsParams waresPutOnIdsParams); | ||||
| 
 | ||||
|     void putOffList(WaresPutOnIdsParams waresPutOnIdsParams); | ||||
| } | ||||
|  |  | |||
|  | @ -1,6 +1,7 @@ | |||
| package com.hzs.sale.wares.service.impl; | ||||
| 
 | ||||
| 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.extension.service.impl.ServiceImpl; | ||||
| 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.vo.WaresPreSaleVo; | ||||
| import com.hzs.sale.wares.mapper.BdWaresExtendMapper; | ||||
| import com.hzs.sale.wares.param.WaresPutOnIdsParams; | ||||
| import com.hzs.sale.wares.service.IBdWaresExtendService; | ||||
| import lombok.extern.slf4j.Slf4j; | ||||
| import org.springframework.stereotype.Service; | ||||
| import org.springframework.transaction.annotation.Transactional; | ||||
| 
 | ||||
| import java.util.Collection; | ||||
| import java.util.Collections; | ||||
| import java.util.Date; | ||||
| import java.util.List; | ||||
| import java.util.stream.Collectors; | ||||
| 
 | ||||
| /** | ||||
|  * 商品发布扩展表 服务实现类 | ||||
|  */ | ||||
| @Service | ||||
| @Slf4j | ||||
| public class BdWaresExtendServiceImpl extends ServiceImpl<BdWaresExtendMapper, BdWaresExtend> implements IBdWaresExtendService { | ||||
| 
 | ||||
|     @Override | ||||
|  | @ -62,4 +68,36 @@ public class BdWaresExtendServiceImpl extends ServiceImpl<BdWaresExtendMapper, B | |||
|         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 | ||||
|         update set bwe.inventory_use = bwe.inventory_use + tmp.quantity | ||||
|     </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> | ||||
|  |  | |||
|  | @ -263,6 +263,9 @@ | |||
|         <if test="waresStatus != null"> | ||||
|             and bw.WARES_STATUS <= #{waresStatus} | ||||
|         </if> | ||||
|         <if test="isMakerGift != null"> | ||||
|             and we.IS_MAKER_GIFT = #{isMakerGift} | ||||
|         </if> | ||||
|         order by bw.sort desc, bw.CREATION_TIME desc | ||||
|     </select> | ||||
| 
 | ||||
|  |  | |||
|  | @ -110,6 +110,10 @@ public enum EOperationBusiness { | |||
| 
 | ||||
|     WARES_LIST("商品列表"), | ||||
| 
 | ||||
|     PUT_ON_LIST("商品批量上架"), | ||||
| 
 | ||||
|     PUT_OFF_LIST("商品批量下架"), | ||||
| 
 | ||||
|     AREA_CLASSIFY("商品分类"), | ||||
| 
 | ||||
|     PRODUCT_CLASSIFY("产品分类"), | ||||
|  |  | |||
|  | @ -72,6 +72,10 @@ public enum EOperationModule { | |||
| 
 | ||||
|     WARES_LIST("商品列表"), | ||||
| 
 | ||||
|     PUT_ON_LIST("商品批量上架"), | ||||
| 
 | ||||
|     PUT_OFF_LIST("商品批量下架"), | ||||
| 
 | ||||
|     AREA_CLASSIFY("商品分类"), | ||||
| 
 | ||||
|     SPECIFICATIONS_CONFIG("规格配置"), | ||||
|  |  | |||
		Loading…
	
		Reference in New Issue