diff --git a/mallinkAdmin/src/main/java/com/iformall/controller/market/WxCouponChannelController.java b/mallinkAdmin/src/main/java/com/iformall/controller/market/WxCouponChannelController.java index 22c79f62f..4f2fbbae5 100644 --- a/mallinkAdmin/src/main/java/com/iformall/controller/market/WxCouponChannelController.java +++ b/mallinkAdmin/src/main/java/com/iformall/controller/market/WxCouponChannelController.java @@ -52,6 +52,7 @@ public class WxCouponChannelController extends BaseController { @Autowired @Qualifier("objectCommonRedisTemplate") RedisTemplate redisTemplate; + @ApiOperation("分页列表接口") @GetMapping("list") diff --git a/mallinkService/src/main/java/com/iformall/domain/po/WxMerchant.java b/mallinkService/src/main/java/com/iformall/domain/po/WxMerchant.java index 413c1d7f6..c4fa93c1f 100644 --- a/mallinkService/src/main/java/com/iformall/domain/po/WxMerchant.java +++ b/mallinkService/src/main/java/com/iformall/domain/po/WxMerchant.java @@ -346,6 +346,10 @@ public class WxMerchant extends TenantEntity { @TableField(exist = false) private String addr; + @io.swagger.annotations.ApiModelProperty(value=" supplierExtId",name="supplierExtId") + @TableField(exist = false) + private String supplierExtId; + @io.swagger.annotations.ApiModelProperty(value="ttPoi",name="ttPoi") @TableField(exist = false) private String ttPoi; diff --git a/mallinkService/src/main/java/com/iformall/domain/vo/WxMerchantVo.java b/mallinkService/src/main/java/com/iformall/domain/vo/WxMerchantVo.java index 9d62e49f4..fbd2c1ed0 100644 --- a/mallinkService/src/main/java/com/iformall/domain/vo/WxMerchantVo.java +++ b/mallinkService/src/main/java/com/iformall/domain/vo/WxMerchantVo.java @@ -101,6 +101,10 @@ public class WxMerchantVo extends TenantEntity { @io.swagger.annotations.ApiModelProperty(value = "置顶时间", name = "topTime") private Date topTime; + @io.swagger.annotations.ApiModelProperty(value=" supplierExtId",name="supplierExtId") + @TableField(exist = false) + private String supplierExtId; + @io.swagger.annotations.ApiModelProperty(value="ttPoi",name="ttPoi") @TableField(exist = false) private String ttPoi; @@ -132,6 +136,7 @@ public class WxMerchantVo extends TenantEntity { this.linkLinePhone = m.getLinkLinePhone(); this.topTime = m.getTopTime(); this.addr = m.getAddr(); + this.supplierExtId = m.getSupplierExtId(); this.ttPoi = m.getTtPoi(); this.longitude = m.getLongitude(); this.latitude = m.getLatitude(); diff --git a/mallinkService/src/main/java/com/iformall/enums/EnumCouponChannelStatus.java b/mallinkService/src/main/java/com/iformall/enums/EnumCouponChannelStatus.java index 3cf00a521..e8283dceb 100644 --- a/mallinkService/src/main/java/com/iformall/enums/EnumCouponChannelStatus.java +++ b/mallinkService/src/main/java/com/iformall/enums/EnumCouponChannelStatus.java @@ -7,8 +7,12 @@ public enum EnumCouponChannelStatus { // 0-草稿/待生效;1-已生效/已发布/已投放;2-已下架; + STATUS_BEFORE(-1, "预上线"),//审核用 + STATUS_THROW_IN(0, "已上架"), STATUS_TAKE_OFFF(1, "已下架"), + + STATUS_AFTER(2, "作废"), ; public static EnumCouponChannelStatus getEnum(Integer code) { 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 15bd7e296..03da4cf59 100644 --- a/mallinkService/src/main/java/com/iformall/service/impl/WxCouponServiceImpl.java +++ b/mallinkService/src/main/java/com/iformall/service/impl/WxCouponServiceImpl.java @@ -1250,14 +1250,59 @@ public class WxCouponServiceImpl implements WxCouponService { || ttattrs.getSkuAttrKeyValueMap().isEmpty()){ return new ResultData(ErrorCode.SYS_PARAMETER_NOT_NULL.getCode(),"该券缺少必要属性"); } - //添加到审核渠道 - WxCouponChannelAddVo wxCouponChannelAddVo = wxCouponChannelService.addCouponChannel(coupon.getId(), EnumCouponChannelType.COUPON_CHANNEL_ID_DOUYIN_SAVE_LIST.getCode(), - coupon, null, null, null, null, null); + if(coupon.getStatus() != EnumCouponStatus.COUPON_STATUS_THROW_IN.getCode()) { + return new ResultData(ErrorCode.COUPON_ORDER_IS_INVALID); + } + + //获取门店 + List couponMerchantList = getCouponMerchantList(coupon, coupon.getId()); + List poiList = new ArrayList(); + for (WxMerchantVo mvo:couponMerchantList){ + if(StringUtils.isNotBlank(mvo.getSupplierExtId())){ + Product.PoiStruct poiStruct = new Product.PoiStruct(); + poiStruct.setSupplierExtId(mvo.getTtPoi()); + poiList.add(poiStruct); + } + } + if(poiList.isEmpty()){ + return new ResultData(ErrorCode.MERCHANT_INFO_NOT_FOUND.getCode(),"未找到poi门店"); + } + + //查询是否有上架的 + WxCouponChannel wxCouponChannelQuery = new WxCouponChannel(); + wxCouponChannelQuery.updateTenantInfo(coupon); + wxCouponChannelQuery.setCouponId(coupon.getId()); + wxCouponChannelQuery.setTargetAd(EnumCouponChannelType.COUPON_CHANNEL_ID_DOUYIN_LIST.getCode()); + wxCouponChannelQuery.setStatus(EnumCouponChannelStatus.STATUS_THROW_IN.getCode()); + List wxCouponChannels = wxCouponChannelMapper.findList(wxCouponChannelQuery); + if(wxCouponChannels.size() > 0){ + return new ResultData(ErrorCode.COUPON_CHANNEL_IS_EXISTED); + } + //预审核的作废掉 重新投放 + wxCouponChannelQuery.setStatus(EnumCouponChannelStatus.STATUS_BEFORE.getCode()); + WxCouponChannel updCouponChannel = new WxCouponChannel(); + updCouponChannel.setStatus(EnumCouponChannelStatus.STATUS_AFTER.getCode()); + updCouponChannel.setUpdateDate(new Date()); + wxCouponChannelMapper.update(updCouponChannel,new QueryWrapper<>(wxCouponChannelQuery)); + //投放预审核 + WxCouponChannel wxCouponChannel = new WxCouponChannel(); + final IdWorker idWorker = IdWorker.get(); + wxCouponChannel.setId(idWorker.nextId()); + wxCouponChannel.updateTenantInfo(coupon); + wxCouponChannel.setShowBeginTime(new Date()); + wxCouponChannel.setBeginTime(new Date()); + wxCouponChannel.setEndTime(coupon.getValidEndDate()); + wxCouponChannel.setStatus(EnumCouponChannelStatus.STATUS_AFTER.getCode()); + wxCouponChannel.setCouponId(coupon.getId()); + wxCouponChannel.setType(coupon.getType()); + wxCouponChannel.setTargetAd(EnumCouponChannelType.COUPON_CHANNEL_ID_DOUYIN_LIST.getCode()); + wxCouponChannel.setBusiness(coupon.getBusiness()); + wxCouponChannel.setSubBusiness(coupon.getSubBusiness()); + wxCouponChannel.setTitle(coupon.getTitle()); + wxCouponChannelMapper.insert(wxCouponChannel); //提交审核 try { - List couponMerchantList = getCouponMerchantList(coupon, coupon.getId()); - List merchantList = couponMerchantList.stream().sorted(Comparator.comparing(m -> m.getTtPoi(), Comparator.nullsLast(String::compareTo))).collect(toList()); TtWebService ttWebService = ttMerchantPoiService.getTtWebService(coupon); Product product = new Product(); @@ -1267,16 +1312,11 @@ public class WxCouponServiceImpl implements WxCouponService { prostruct.setCategoryId(ttattrs.getCategoryId()); prostruct.setProductType(ttattrs.getProductType()); prostruct.setBizLine(5);//默认小程序 - prostruct.setAccountName(merchantList.get(0).getMerchantName()); + prostruct.setAccountName(couponMerchantList.get(0).getMerchantName()); // prostruct.setSoldStartTime(); // prostruct.setSoldEndTime(); - prostruct.setOutUrl(getGoodsEntrySchema(coupon,wxCouponChannelAddVo.getId())); - List poiList = new ArrayList(); - for (WxMerchantVo mvo:merchantList){ - Product.PoiStruct poiStruct = new Product.PoiStruct(); - poiStruct.setSupplierExtId(mvo.getId().toString()); - poiList.add(poiStruct); - } + prostruct.setOutUrl(getGoodsEntrySchema(coupon,wxCouponChannel.getId())); + prostruct.setPoiList(poiList); prostruct.setAttrKeyValueMap(ttattrs.getProductAttrKeyValueMap()); product.setProduct(prostruct); @@ -1294,11 +1334,11 @@ public class WxCouponServiceImpl implements WxCouponService { product.setSku(skuStruct); String productId = ttWebService.getGoodsService().productSave(product); - syncCouponChannelPoi(coupon,wxCouponChannelAddVo.getId(),productId); + syncCouponChannelPoi(coupon,wxCouponChannel.getId(),productId); return new ResultData(); } catch (WxErrorException e) { - throw new Exception(e); + throw new Exception(e.getMessage()); // logger.error(e.getMessage()); // return new ResultData(ErrorCode.SYS_SERVER_ERROR.getCode(),e.getMessage()); } catch (Exception e){ diff --git a/mallinkService/src/main/java/com/iformall/service/impl/WxMerchantServiceImpl.java b/mallinkService/src/main/java/com/iformall/service/impl/WxMerchantServiceImpl.java index a16db4d29..7d0d3c061 100644 --- a/mallinkService/src/main/java/com/iformall/service/impl/WxMerchantServiceImpl.java +++ b/mallinkService/src/main/java/com/iformall/service/impl/WxMerchantServiceImpl.java @@ -1331,6 +1331,7 @@ public class WxMerchantServiceImpl implements WxMerchantService { TtMerchantPoi poi = poiMap.get(m.getId()); if(null != poi){ m.setAddr(poi.getAddress()); + m.setSupplierExtId(poi.getSupplierExtId()); m.setTtPoi(poi.getPoiId()); m.setLongitude(poi.getLongitude()); m.setLatitude(poi.getLatitude()); @@ -1399,6 +1400,7 @@ public class WxMerchantServiceImpl implements WxMerchantService { vo.setShopVoList(merchantShopVoList.get(vo.getId())); } vo.setAddr(m.getAddr()); + vo.setSupplierExtId(m.getSupplierExtId()); vo.setTtPoi(m.getTtPoi()); vo.setLongitude(m.getLongitude()); vo.setLatitude(m.getLatitude());