diff --git a/cereshop-admin/src/main/java/com/shop/cereshop/admin/service/product/impl/CereShopProductServiceImpl.java b/cereshop-admin/src/main/java/com/shop/cereshop/admin/service/product/impl/CereShopProductServiceImpl.java index 4a0bf89..8b80a44 100644 --- a/cereshop-admin/src/main/java/com/shop/cereshop/admin/service/product/impl/CereShopProductServiceImpl.java +++ b/cereshop-admin/src/main/java/com/shop/cereshop/admin/service/product/impl/CereShopProductServiceImpl.java @@ -187,7 +187,7 @@ public class CereShopProductServiceImpl implements CereShopProductService { String time =TimeUtils.yyMMddHHmmss(); CereShopProduct cereShopProduct=new CereShopProduct(); cereShopProduct.setProductId(param.getProductId()); - cereShopProduct.setShelveState(param.getShelveState()); + cereShopProduct.setPlatShelveState(param.getShelveState()); cereShopProduct.setReject(param.getReject()); cereShopProduct.setUpdateTime(time); String describe=""; @@ -228,13 +228,14 @@ public class CereShopProductServiceImpl implements CereShopProductService { String time =TimeUtils.yyMMddHHmmss(); CereShopProduct cereShopProduct=new CereShopProduct(); cereShopProduct.setProductId(param.getProductId()); - cereShopProduct.setShelveState(IntegerEnum.PRODUCT_SHELVSTATE_FORCED.getCode()); + //cereShopProduct.setShelveState(IntegerEnum.PRODUCT_SHELVSTATE_FORCED.getCode()); + cereShopProduct.setPlatShelveState(IntegerEnum.PRODUCT_SHELVSTATE_FORCED.getCode()); cereShopProduct.setUpdateTime(time); cereShopProductDAO.updateByPrimaryKeySelective(cereShopProduct); //清除缓存 - triggerCacheUpdate(param.getProductId()); + //triggerCacheUpdate(param.getProductId()); //刷新实时信息 - projectInvokeUtil.postRefreshSkuRealInfo(param.getProductId(), RefreshSkuRealInfoSourceEnum.PUT_OFF_SHELVE); + //projectInvokeUtil.postRefreshSkuRealInfo(param.getProductId(), RefreshSkuRealInfoSourceEnum.PUT_OFF_SHELVE); //新增日志 cerePlatformLogService.addLog(user,"商品管理","平台端操作","强制下架",String.valueOf(cereShopProduct.getProductId()),time); } diff --git a/cereshop-admin/src/main/resources/mybatis/mapper/product/CereShopProductDAO.xml b/cereshop-admin/src/main/resources/mybatis/mapper/product/CereShopProductDAO.xml index 8264bab..3a8a31b 100644 --- a/cereshop-admin/src/main/resources/mybatis/mapper/product/CereShopProductDAO.xml +++ b/cereshop-admin/src/main/resources/mybatis/mapper/product/CereShopProductDAO.xml @@ -167,7 +167,10 @@ shelve_state = #{shelveState,jdbcType=BIT}, - + + plat_shelve_state = #{platShelveState,jdbcType=BIT}, + + if_oversold = #{ifOversold,jdbcType=BIT}, diff --git a/cereshop-business/src/main/java/com/shop/cereshop/business/controller/ProductController.java b/cereshop-business/src/main/java/com/shop/cereshop/business/controller/ProductController.java index fc012cb..4c57ba6 100644 --- a/cereshop-business/src/main/java/com/shop/cereshop/business/controller/ProductController.java +++ b/cereshop-business/src/main/java/com/shop/cereshop/business/controller/ProductController.java @@ -163,6 +163,21 @@ public class ProductController { } /** + * 商品上下架 + * @param param + * @return + */ + @PostMapping(value = "platStart") + @NoRepeatSubmit + @ApiOperation(value = "平台上下架") + @NoRepeatWebLog + public Result platStart(@RequestBody ProductUpDownParam param, HttpServletRequest request) throws CoBusinessException{ + //获取当前登录账户 + CerePlatformBusinessUser user = (CerePlatformBusinessUser) request.getAttribute("user"); + cereShopProductService.platStart(param,user); + return new Result(user.getUsername(),"平台上下架", GsonUtil.objectToGson(param)); + } + /** * 修改商品查询 * @param param * @return diff --git a/cereshop-business/src/main/java/com/shop/cereshop/business/page/product/ShopProduct.java b/cereshop-business/src/main/java/com/shop/cereshop/business/page/product/ShopProduct.java index 0adc70f..9ccdd39 100644 --- a/cereshop-business/src/main/java/com/shop/cereshop/business/page/product/ShopProduct.java +++ b/cereshop-business/src/main/java/com/shop/cereshop/business/page/product/ShopProduct.java @@ -235,6 +235,12 @@ public class ShopProduct { private Integer ifLowPrice; /** + * 平台上架商品状态 0-已下架 1-已上架 2-待审核 3-审核失败 + */ + @ApiModelProperty(value = "平台上架商品状态 0-已下架 1-已上架 2-待审核 3-审核失败") + private Integer platShelveState; + + /** * 名称Map */ @ApiModelProperty(value = "名称Map") diff --git a/cereshop-business/src/main/java/com/shop/cereshop/business/param/product/ProductSaveParam.java b/cereshop-business/src/main/java/com/shop/cereshop/business/param/product/ProductSaveParam.java index f507f12..c4771f3 100644 --- a/cereshop-business/src/main/java/com/shop/cereshop/business/param/product/ProductSaveParam.java +++ b/cereshop-business/src/main/java/com/shop/cereshop/business/param/product/ProductSaveParam.java @@ -103,6 +103,13 @@ public class ProductSaveParam { private String shelveState; /** + * 是否平台上架 1-上架 0-不上架 + */ + @ApiModelProperty(value = "是否上架 1-上架 0-不上架") + @NotBlank(message = "没有选择是否上架") + private String platShelveState; + + /** * 是否允许超卖 1-是 0-否 */ @ApiModelProperty(value = "是否允许超卖 1-是 0-否") diff --git a/cereshop-business/src/main/java/com/shop/cereshop/business/param/product/ProductUpdateParam.java b/cereshop-business/src/main/java/com/shop/cereshop/business/param/product/ProductUpdateParam.java index 0945016..5f459ce 100644 --- a/cereshop-business/src/main/java/com/shop/cereshop/business/param/product/ProductUpdateParam.java +++ b/cereshop-business/src/main/java/com/shop/cereshop/business/param/product/ProductUpdateParam.java @@ -97,6 +97,12 @@ public class ProductUpdateParam { private Integer shelveState; /** + * 是否平台上架 1-上架 0-不上架 + */ + @ApiModelProperty(value = "是否平台上架 1-上架 0-不上架") + private Integer platShelveState; + + /** * 是否允许超卖 1-是 0-否 */ @ApiModelProperty(value = "是否允许超卖 1-是 0-否") diff --git a/cereshop-business/src/main/java/com/shop/cereshop/business/service/product/CereShopProductService.java b/cereshop-business/src/main/java/com/shop/cereshop/business/service/product/CereShopProductService.java index 8739f31..7a915d7 100644 --- a/cereshop-business/src/main/java/com/shop/cereshop/business/service/product/CereShopProductService.java +++ b/cereshop-business/src/main/java/com/shop/cereshop/business/service/product/CereShopProductService.java @@ -30,6 +30,8 @@ public interface CereShopProductService { void start(ProductUpDownParam param, CerePlatformBusinessUser user) throws CoBusinessException; + void platStart(ProductUpDownParam param, CerePlatformBusinessUser user) throws CoBusinessException; + Page getAll(ProductGetAllParam param) throws CoBusinessException; diff --git a/cereshop-business/src/main/java/com/shop/cereshop/business/service/product/impl/CereShopProductServiceImpl.java b/cereshop-business/src/main/java/com/shop/cereshop/business/service/product/impl/CereShopProductServiceImpl.java index 9c510d3..02f1225 100644 --- a/cereshop-business/src/main/java/com/shop/cereshop/business/service/product/impl/CereShopProductServiceImpl.java +++ b/cereshop-business/src/main/java/com/shop/cereshop/business/service/product/impl/CereShopProductServiceImpl.java @@ -149,14 +149,15 @@ public class CereShopProductServiceImpl implements CereShopProductService { cereShopProduct.setIfNew(param.getIfNew()); cereShopProduct.setIfFirst(param.getIfFirst()); cereShopProduct.setIfLowPrice(param.getIfLowPrice()); + cereShopProduct.setShelveState(Integer.parseInt(param.getShelveState())); - if(IntegerEnum.PRODUCT_EXAMINE_YES.getCode().equals(Integer.parseInt(param.getShelveState()))){ - //如果是已上架,修改状态为审核中 - cereShopProduct.setShelveState(IntegerEnum.PRODUCT_EXAMINE_STAY.getCode()); + if(IntegerEnum.PRODUCT_EXAMINE_YES.getCode().equals(Integer.parseInt(param.getPlatShelveState())) && IntegerEnum.PRODUCT_EXAMINE_YES.getCode().equals(Integer.parseInt(param.getShelveState()))){ + //如果是平台已上架,修改状态为平台上架审核中。需要满足商品上架状态为上架状态下 + cereShopProduct.setPlatShelveState(IntegerEnum.PRODUCT_EXAMINE_STAY.getCode()); }else { //已下架 - cereShopProduct.setShelveState(Integer.parseInt(param.getShelveState())); + cereShopProduct.setPlatShelveState(Integer.parseInt(param.getPlatShelveState())); } cereShopProduct.setCreateTime(time); cereShopProduct.setUpdateTime(time); @@ -296,6 +297,7 @@ public class CereShopProductServiceImpl implements CereShopProductService { cereShopProduct.setIfNew(param.getIfNew()); cereShopProduct.setIfFirst(param.getIfFirst()); cereShopProduct.setIfLowPrice(param.getIfLowPrice()); + cereShopProduct.setShelveState(param.getShelveState()); boolean isNeedReExam = false; if(!StringUtils.equals(cereShopProduct.getProductName(), dbCereShopProduct.getProductName())){ @@ -317,7 +319,7 @@ public class CereShopProductServiceImpl implements CereShopProductService { isNeedReExam = true; } - if(!isNeedReExam && !Objects.equals(cereShopProduct.getShelveState(), dbCereShopProduct.getShelveState())){ + if(!isNeedReExam && !Objects.equals(param.getPlatShelveState(), dbCereShopProduct.getPlatShelveState())){ isNeedReExam = true; } @@ -330,16 +332,21 @@ public class CereShopProductServiceImpl implements CereShopProductService { } } - if (isNeedReExam && IntegerEnum.PRODUCT_EXAMINE_YES.getCode().equals(param.getShelveState())) { - //如果是已上架,修改状态为审核中 - cereShopProduct.setShelveState(IntegerEnum.PRODUCT_EXAMINE_STAY.getCode()); + if (isNeedReExam && IntegerEnum.PRODUCT_EXAMINE_YES.getCode().equals(param.getPlatShelveState()) && IntegerEnum.PRODUCT_EXAMINE_YES.getCode().equals(param.getShelveState())) { + //如果是已上架,修改状态为审核中。需满足商品上架状态为上架情况下 + cereShopProduct.setPlatShelveState(IntegerEnum.PRODUCT_EXAMINE_STAY.getCode()); } else { //已下架 - cereShopProduct.setShelveState(param.getShelveState()); + cereShopProduct.setPlatShelveState(param.getPlatShelveState()); } //不管是审核中,还是已下架,sku实时信息都要改成下架 - projectInvokeUtil.postRefreshSkuRealInfo(param.getProductId(), null, RefreshSkuRealInfoSourceEnum.PUT_OFF_SHELVE, null); + + if (param.getShelveState() == 0){ + //若为商品下架,sku实时信息都要改成下架。平台端也强制下架 + cereShopProduct.setPlatShelveState(IntegerEnum.PRODUCT_SHELVSTATE_FORCED.getCode()); + projectInvokeUtil.postRefreshSkuRealInfo(param.getProductId(), null, RefreshSkuRealInfoSourceEnum.PUT_OFF_SHELVE, null); + } cereShopProduct.setUpdateTime(time); cereShopProduct.setShopId(param.getShopId()); @@ -587,14 +594,40 @@ public class CereShopProductServiceImpl implements CereShopProductService { String describe=""; if(IntegerEnum.YES.getCode().equals(param.getShelveState())){ describe="上架商品"; - cereShopProduct.setShelveState(IntegerEnum.PRODUCT_EXAMINE_STAY.getCode()); + cereShopProduct.setShelveState(IntegerEnum.PRODUCT_EXAMINE_YES.getCode()); + //更新商品库存缓存 + updateProductStock(cereShopProduct.getProductId()); + //刷新实时信息 + projectInvokeUtil.postRefreshSkuRealInfo(param.getProductId(), RefreshSkuRealInfoSourceEnum.PUT_ON_SHELVE); }else { describe="下架商品"; + cereShopProduct.setPlatShelveState(param.getShelveState()); projectInvokeUtil.postRefreshSkuRealInfo(param.getProductId(), null, RefreshSkuRealInfoSourceEnum.PUT_OFF_SHELVE, null); } cereShopProductDAO.updateByPrimaryKeySelective(cereShopProduct); //清空缓存 - triggerCacheUpdate(param.getProductId()); + //triggerCacheUpdate(param.getProductId()); + //新增日志 + cerePlatformLogService.addLog(user,"商品管理","商户端操作",describe,cereShopProduct.getProductId(),time); + } + + @Override + public void platStart(ProductUpDownParam param, CerePlatformBusinessUser user) throws CoBusinessException { + String time=TimeUtils.yyMMddHHmmss(); + CereShopProduct cereShopProduct=new CereShopProduct(); + cereShopProduct.setProductId(param.getProductId()); + cereShopProduct.setPlatShelveState(param.getShelveState()); + String describe=""; + if(IntegerEnum.YES.getCode().equals(param.getShelveState())){ + describe="平台上架商品"; + cereShopProduct.setPlatShelveState(IntegerEnum.PRODUCT_EXAMINE_STAY.getCode()); + }else { + describe="平台下架商品"; + //projectInvokeUtil.postRefreshSkuRealInfo(param.getProductId(), null, RefreshSkuRealInfoSourceEnum.PUT_OFF_SHELVE, null); + } + cereShopProductDAO.updateByPrimaryKeySelective(cereShopProduct); + //清空缓存 + //triggerCacheUpdate(param.getProductId()); //新增日志 cerePlatformLogService.addLog(user,"商品管理","商户端操作",describe,cereShopProduct.getProductId(),time); } @@ -765,7 +798,8 @@ public class CereShopProductServiceImpl implements CereShopProductService { cereShopProduct.setIfOversold(Integer.parseInt(param.getIfOversold())); if (IntegerEnum.PRODUCT_EXAMINE_YES.getCode().equals(Integer.parseInt(param.getShelveState()))) { //如果是已上架,修改状态为审核中 - cereShopProduct.setShelveState(IntegerEnum.PRODUCT_EXAMINE_STAY.getCode()); + //cereShopProduct.setShelveState(IntegerEnum.PRODUCT_EXAMINE_STAY.getCode()); + cereShopProduct.setShelveState(IntegerEnum.PRODUCT_EXAMINE_YES.getCode()); } else { //已下架 cereShopProduct.setShelveState(Integer.parseInt(param.getShelveState())); @@ -1306,4 +1340,19 @@ public class CereShopProductServiceImpl implements CereShopProductService { cereShopSeckillDetailService.updateBatchSeckillPrice(details); } } + + /** + * 更新商品库存 + * @param productId + */ + private void updateProductStock(Long productId) { + List skuList = cereProductSkuService.findByProductId(productId); + for (Sku sku:skuList) { + String skuStockKey = CacheKeyConstants.SKU_STOCK_PREFIX + sku.getSkuId(); + stringRedisService.set(skuStockKey, sku.getStockNumber()); + + String skuTotalStockKey = CacheKeyConstants.SKU_TOTAL_STOCK_PREFIX + sku.getSkuId(); + stringRedisService.set(skuTotalStockKey, sku.getTotal()); + } + } } diff --git a/cereshop-business/src/main/resources/mybatis/mapper/product/CereShopProductDAO.xml b/cereshop-business/src/main/resources/mybatis/mapper/product/CereShopProductDAO.xml index 6dec175..b01b310 100644 --- a/cereshop-business/src/main/resources/mybatis/mapper/product/CereShopProductDAO.xml +++ b/cereshop-business/src/main/resources/mybatis/mapper/product/CereShopProductDAO.xml @@ -28,7 +28,7 @@ product_id, shop_id, product_name, product_brief, shop_group_id, classify_id, shop_group_business_id, classify_business_id, supplier_id, - supplier_name, if_logistics, shelve_state, if_oversold, fictitious_number, create_time, update_time, product_text, + supplier_name, if_logistics, shelve_state, plat_shelve_state, if_oversold, fictitious_number, create_time, update_time, product_text, reject, if_credit, credit_limit, brand_id @@ -91,6 +91,9 @@ shelve_state = #{shelveState,jdbcType=BIT}, + + plat_shelve_state = #{platShelveState,jdbcType=BIT}, + if_oversold = #{ifOversold,jdbcType=BIT}, @@ -147,7 +150,8 @@ csp.brand_id, csp.if_new, csp.if_first, - csp.if_low_price + csp.if_low_price, + csp.plat_shelve_state FROM cere_shop_product csp INNER JOIN cere_platform_shop cps ON cps.shop_id = csp.shop_id where csp.product_id = #{productId} @@ -168,6 +172,7 @@ csp.if_credit, csp.reject, csp.brand_id, + csp.plat_shelve_state, (SELECT cpi.product_image FROM cere_product_image cpi WHERE cpi.product_id=csp.product_id LIMIT 1) product_image, c.price, c.original_price, diff --git a/cereshop-commons/src/main/java/com/shop/cereshop/commons/domain/product/CereShopProduct.java b/cereshop-commons/src/main/java/com/shop/cereshop/commons/domain/product/CereShopProduct.java index 565efdc..07fd955 100644 --- a/cereshop-commons/src/main/java/com/shop/cereshop/commons/domain/product/CereShopProduct.java +++ b/cereshop-commons/src/main/java/com/shop/cereshop/commons/domain/product/CereShopProduct.java @@ -141,6 +141,12 @@ public class CereShopProduct implements Serializable { @ApiModelProperty("是否低价") private Integer ifLowPrice; + /** + * 平台上架商品状态 0-已下架 1-已上架 2-待审核 3-审核失败 + */ + @ApiModelProperty(value = "平台上架商品状态 0-已下架 1-已上架 2-待审核 3-审核失败") + private Integer platShelveState; + private static final long serialVersionUID = 1L; /** diff --git a/doc/3.0/update.sql b/doc/3.0/update.sql index e8a1009..36d7b7c 100644 --- a/doc/3.0/update.sql +++ b/doc/3.0/update.sql @@ -289,3 +289,5 @@ ALTER TABLE `cere_shop_product` MODIFY COLUMN `classify_id` bigint DEFAULT NULL ALTER TABLE cere_platform_shop ADD shop_type tinyint(1) DEFAULT 1 COMMENT '店铺类型 1国内贸易 2跨境保税 3海外直邮'; ALTER TABLE cere_platform_business ADD pc_domain varchar(128) DEFAULT '' COMMENT 'pc端商城域名'; ALTER TABLE cere_platform_business ADD mobile_domain varchar(128) DEFAULT '' COMMENT '移动端商城域名'; + +ALTER TABLE cere_shop_product ADD plat_shelve_state tinyint(1) DEFAULT 0 COMMENT '平台上架商品状态 0-已下架 1-已上架 2-待审核 3-审核失败';