diff --git a/mallinkAdmin/src/main/java/com/iformall/controller/market/WxCouponController.java b/mallinkAdmin/src/main/java/com/iformall/controller/market/WxCouponController.java index c9f320365..125a9496d 100644 --- a/mallinkAdmin/src/main/java/com/iformall/controller/market/WxCouponController.java +++ b/mallinkAdmin/src/main/java/com/iformall/controller/market/WxCouponController.java @@ -230,6 +230,40 @@ public class WxCouponController extends BaseController { return result; } + @ApiOperation("根据id更新接口") + @PostMapping("continueAdd") + @SystemControllerLog(description = "继续添加") + public ResultData continueAdd(@RequestBody WxCoupon wxCoupon) { + logger.debug("[" + getIpAddr() + "] WxCouponController::update"); + if (wxCoupon.getId() == null) { + return new ResultData(ResultData.ERROR, "缺少id"); + } + if(wxCoupon.getProductType() == null || wxCoupon.getCategoryId() == null){ + return new ResultData(ErrorCode.SYS_PARAMETER_NOT_NULL.getCode(), "缺少必要参数"); + } + + wxCoupon.updateTenantInfo(getTenantInfo()); + if(EnumDelFlag.YES.getCode().equals(wxCoupon.getIsDel())){ + WxCouponChannel query = new WxCouponChannel(); + query.updateTenantInfo(wxCoupon); + query.setCouponId(wxCoupon.getId()); + query.setStatus(EnumCouponChannelStatus.STATUS_THROW_IN.getCode()); + if (CollectionUtils.isNotEmpty(wxCouponChannelMapper.findList(query))) { + return new ResultData(ResultData.ERROR, "有活动正在上架,请先下架。"); + } + } + + WxCoupon coupon = wxCouponService.getById(wxCoupon.getId(),wxCoupon.getTenantId()); + if (null == coupon) { + return new ResultData(ResultData.ERROR, "券未查询到。"+wxCoupon.getId()); + } + + ResultData result = wxCouponService.updateTtProduct(wxCoupon); + CouponCacheUtils.removeCouponCache(redisTemplate, wxCoupon.getId()); + CouponCacheUtils.removeCouponMerchantCache(redisTemplate, wxCoupon.getId()); + return result; + } + @ApiOperation("根据id更新库存及有效期接口") @PostMapping("updateStokeAndValidDate") @SystemControllerLog(description = "券投放-库存/有效期更新") @@ -565,9 +599,9 @@ public class WxCouponController extends BaseController { try { GoodsTemplateGet goodsTemplateGet = ttMerchantPoiService.getTtWebService(getTenantInfo()).getGoodsService().templateGet(categoryId, productType); - GoodsTemplateGet admintemp = ttGoodsCategoryService.adminIsShow(goodsTemplateGet); - ttGoodsCategoryService.handTemplate(admintemp,coupon); - return new ResultData(admintemp); + ttGoodsCategoryService.adminIsShow(goodsTemplateGet); + ttGoodsCategoryService.handTemplate(goodsTemplateGet,coupon); + return new ResultData(goodsTemplateGet); } catch (WxErrorException e) { e.printStackTrace(); return new ResultData(ErrorCode.SYS_SERVER_ERROR.getCode(),e.getMessage()); diff --git a/mallinkService/src/main/java/com/iformall/service/TtGoodsCategoryService.java b/mallinkService/src/main/java/com/iformall/service/TtGoodsCategoryService.java index 86252cfc7..de4e0555a 100644 --- a/mallinkService/src/main/java/com/iformall/service/TtGoodsCategoryService.java +++ b/mallinkService/src/main/java/com/iformall/service/TtGoodsCategoryService.java @@ -20,7 +20,7 @@ public interface TtGoodsCategoryService { /** * A端是否显示处理 */ - GoodsTemplateGet adminIsShow(GoodsTemplateGet temp); + void adminIsShow(GoodsTemplateGet temp); /** diff --git a/mallinkService/src/main/java/com/iformall/service/WxCouponService.java b/mallinkService/src/main/java/com/iformall/service/WxCouponService.java index f0a7d0e4e..dd5aa8aa4 100644 --- a/mallinkService/src/main/java/com/iformall/service/WxCouponService.java +++ b/mallinkService/src/main/java/com/iformall/service/WxCouponService.java @@ -85,6 +85,8 @@ public interface WxCouponService { * @param record */ ResultData saveOrUpdate(WxCoupon record); + + ResultData updateTtProduct(WxCoupon wxCoupon); /** * 更新实体 * @@ -269,5 +271,6 @@ public interface WxCouponService { Map getCouponMap(List couponIds, TenantEntity tenantEntity); List getCouponMerchantList(TenantEntity tenantInfo, Long couponId); - + + } diff --git a/mallinkService/src/main/java/com/iformall/service/impl/TtGoodsCategoryServiceImpl.java b/mallinkService/src/main/java/com/iformall/service/impl/TtGoodsCategoryServiceImpl.java index 7192e7065..e9f040257 100644 --- a/mallinkService/src/main/java/com/iformall/service/impl/TtGoodsCategoryServiceImpl.java +++ b/mallinkService/src/main/java/com/iformall/service/impl/TtGoodsCategoryServiceImpl.java @@ -101,23 +101,22 @@ public class TtGoodsCategoryServiceImpl implements TtGoodsCategoryService { * @return */ @Override - public GoodsTemplateGet adminIsShow(GoodsTemplateGet temp) { - GoodsTemplateGet newAttr = new GoodsTemplateGet(); - List productAttrs = new ArrayList<>(); + public void adminIsShow(GoodsTemplateGet temp) { for (GoodsTemplateGet.ProductAttrs attr: temp.getProductAttrs()) { - if(!getProductAdminIsNotShowKey().contains(attr.getKey())){ - productAttrs.add(attr); + if(getProductAdminIsNotShowKey().contains(attr.getKey())){ + attr.setIsShow(false); + }else{ + attr.setIsShow(true); } } - newAttr.setProductAttrs(productAttrs); List skuAttrs = new ArrayList<>(); for (GoodsTemplateGet.ProductAttrs attr: temp.getProductAttrs()) { - if(!getAttrAdminIsNotShowKey().contains(attr.getKey())){ - skuAttrs.add(attr); + if(getAttrAdminIsNotShowKey().contains(attr.getKey())){ + attr.setIsShow(false); + }else{ + attr.setIsShow(true); } } - newAttr.setSkuAttrs(skuAttrs); - return newAttr; } @Override diff --git a/mallinkService/src/main/java/com/iformall/service/impl/WxCouponServiceImpl.java b/mallinkService/src/main/java/com/iformall/service/impl/WxCouponServiceImpl.java index d7d31067c..d6ff57a49 100644 --- a/mallinkService/src/main/java/com/iformall/service/impl/WxCouponServiceImpl.java +++ b/mallinkService/src/main/java/com/iformall/service/impl/WxCouponServiceImpl.java @@ -642,6 +642,22 @@ public class WxCouponServiceImpl implements WxCouponService { return new ResultData(record.getId()); } + @Override + public ResultData updateTtProduct(WxCoupon record) { + WxCoupon coupon = new WxCoupon(); + coupon.setId(record.getId()); + coupon.updateTenantInfo(record); + coupon.setProductType(record.getProductType()); + coupon.setCategoryId(record.getCategoryId()); + coupon.setProductAttrs(record.getProductAttrs()); + coupon.setSkuAttrs(record.getSkuAttrs()); + coupon.setUpdateDate(new Date()); + wxCouponMapper.updateById(coupon); + //清空缓存 + clearCache(record); + return new ResultData(record.getId()); + } + /** * 清除c端首页券列表缓存