|
|
|
@@ -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<WxMerchantVo> couponMerchantList = getCouponMerchantList(coupon, coupon.getId()); |
|
|
|
List<Product.PoiStruct> 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<WxCouponChannel> 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<WxMerchantVo> couponMerchantList = getCouponMerchantList(coupon, coupon.getId()); |
|
|
|
List<WxMerchantVo> 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<Product.PoiStruct> 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){ |
|
|
|
|