|
|
|
@@ -556,15 +556,13 @@ public class TtMerchantPoiServiceImpl implements TtMerchantPoiService { |
|
|
|
} |
|
|
|
|
|
|
|
@Override |
|
|
|
public void importOneMem(MallUserInfo user, String importKey, MerchantPoiT poiBase) { |
|
|
|
public void importOneMem(MallUserInfo user, MerchantPoiT poiBase) { |
|
|
|
if (StringUtils.isBlank(poiBase.getMerchantId())) { |
|
|
|
stringRedisTemplate.opsForHash().increment(importKey, "processCount", 1); |
|
|
|
logger.error("服务商POI_ID为空", poiBase.toString()); |
|
|
|
poiBase.setImportRemark("导入失败.服务商POI_ID为空"); |
|
|
|
return; |
|
|
|
} |
|
|
|
if (StringUtils.isBlank(poiBase.getPoiId())) { |
|
|
|
stringRedisTemplate.opsForHash().increment(importKey, "processCount", 1); |
|
|
|
logger.error("已匹配POI_ID为空", poiBase.toString()); |
|
|
|
poiBase.setImportRemark("导入失败.已匹配POI_ID为空"); |
|
|
|
return; |
|
|
|
} |
|
|
|
|
|
|
|
@@ -598,31 +596,27 @@ public class TtMerchantPoiServiceImpl implements TtMerchantPoiService { |
|
|
|
}else{ |
|
|
|
ttMerchantPoiMapper.updateById(merchantPoi); |
|
|
|
} |
|
|
|
poiBase.setImportRemark("导入成功"); |
|
|
|
} catch (Exception e) { |
|
|
|
stringRedisTemplate.opsForHash().increment(importKey, "processCount", 1); |
|
|
|
logger.error(e.getMessage()); |
|
|
|
logger.error("importOneMem error.",e); |
|
|
|
poiBase.setImportRemark("导入失败."+e.getMessage()); |
|
|
|
return; |
|
|
|
} |
|
|
|
|
|
|
|
stringRedisTemplate.opsForHash().increment(importKey,"processCount",1); |
|
|
|
stringRedisTemplate.expire(importKey,10, TimeUnit.SECONDS); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
@Override |
|
|
|
public void importOnePoiNew(MallUserInfo user, String importKey, MerchantPoiTNew poiBase) { |
|
|
|
if (StringUtils.isBlank(poiBase.getMerchantId())) { |
|
|
|
stringRedisTemplate.opsForHash().increment(importKey, "processCount", 1); |
|
|
|
return; |
|
|
|
} |
|
|
|
public void importOnePoiNew(MallUserInfo user, MerchantPoiTNew poiBase){ |
|
|
|
if (StringUtils.isBlank(poiBase.getPoiId())) { |
|
|
|
stringRedisTemplate.opsForHash().increment(importKey, "processCount", 1); |
|
|
|
return; |
|
|
|
poiBase.setImportRemark("导入失败.门店ID为空"); |
|
|
|
return; |
|
|
|
} |
|
|
|
|
|
|
|
try { |
|
|
|
TtMerchantPoi merchantPoi = null; |
|
|
|
if (StringUtils.isNotBlank(poiBase.getMerchantId())) { |
|
|
|
merchantPoi = ttMerchantPoiMapper.selectById(Long.parseLong(poiBase.getMerchantId())); |
|
|
|
} |
|
|
|
Date now = new Date(); |
|
|
|
TtMerchantPoi merchantPoi = ttMerchantPoiMapper.selectById(Long.parseLong(poiBase.getMerchantId())); |
|
|
|
if(merchantPoi == null){ |
|
|
|
merchantPoi = new TtMerchantPoi(); |
|
|
|
} |
|
|
|
@@ -640,6 +634,7 @@ public class TtMerchantPoiServiceImpl implements TtMerchantPoiService { |
|
|
|
merchantPoi.setSyncStatus(EnumSupplierSyncStatus.sync_success.getCode()); |
|
|
|
merchantPoi.setLastSyncStatus(EnumSupplierSyncStatus.sync_success.getCode()); |
|
|
|
merchantPoi.setUpdateDate(now); |
|
|
|
|
|
|
|
if(merchantPoi.getId() == null){ |
|
|
|
merchantPoi.setId(Long.parseLong(poiBase.getMerchantId())); |
|
|
|
merchantPoi.setCreateDate(now); |
|
|
|
@@ -647,57 +642,14 @@ public class TtMerchantPoiServiceImpl implements TtMerchantPoiService { |
|
|
|
}else{ |
|
|
|
ttMerchantPoiMapper.updateById(merchantPoi); |
|
|
|
} |
|
|
|
poiBase.setImportRemark("导入成功"); |
|
|
|
} catch (Exception e) { |
|
|
|
stringRedisTemplate.opsForHash().increment(importKey, "processCount", 1); |
|
|
|
logger.error(e.getMessage()); |
|
|
|
logger.error(e.getMessage(),e); |
|
|
|
poiBase.setImportRemark("导入失败."+e.getMessage()); |
|
|
|
return; |
|
|
|
} |
|
|
|
|
|
|
|
stringRedisTemplate.opsForHash().increment(importKey,"processCount",1); |
|
|
|
stringRedisTemplate.expire(importKey,10, TimeUnit.SECONDS); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
// @Override |
|
|
|
// public ResultData findPoi(TenantEntity tenantInfo, Long couponChannelId) { |
|
|
|
// WxCouponChannel couponChannel = wxCouponChannelMapper.selectById(couponChannelId, tenantInfo.getTenantId()); |
|
|
|
// if(couponChannel == null || !EnumCouponChannelStatus.STATUS_THROW_IN.getCode().equals(couponChannel.getStatus())){ |
|
|
|
// return new ResultData(ErrorCode.SYS_PARAMETER_NOT_NULL.getCode(),"未找到上架卷数据"); |
|
|
|
// } |
|
|
|
// if(!EnumCouponChannelType.COUPON_CHANNEL_ID_DOUYIN_LIST.getCode().equals(couponChannel.getTargetAd())){ |
|
|
|
// return new ResultData(ErrorCode.SYS_PARAMETER_ERROR.getCode(),"只有投放在列表的卷才能进行同步poi"); |
|
|
|
// } |
|
|
|
// WxCoupon coupon = wxCouponMapper.selectById(couponChannel.getCouponId(), tenantInfo.getTenantId()); |
|
|
|
// if(coupon == null || !EnumCouponStatus.COUPON_STATUS_THROW_IN.getCode().equals(coupon.getStatus())){ |
|
|
|
// return new ResultData(ErrorCode.SYS_PARAMETER_ERROR.getCode(),"未找到可投放的卷"); |
|
|
|
// } |
|
|
|
// if(!EnumCouponType.getSpuSyncType().contains(coupon.getType())){ |
|
|
|
// return new ResultData(ErrorCode.SYS_PARAMETER_ERROR.getCode(),"卷类型不支持同步poi"); |
|
|
|
// } |
|
|
|
//// List<TtMerchantPoi> list = new ArrayList<>(); |
|
|
|
//// TtMerchantPoi merchantPoi = ttMerchantPoiMapper.selectById(Long.parseLong(tenantInfo.getTenantId())); |
|
|
|
////// TtMerchantPoi merchantPoi = ttMerchantPoiMapper.selectById(Long.parseLong("1038")); |
|
|
|
//// list.add(merchantPoi); |
|
|
|
// |
|
|
|
// List<Long> merchantIds = wxCouponMerchantMapper.findMerchantIdListByProduct(coupon.getId(), tenantInfo.getTenantId()); |
|
|
|
// if(merchantIds == null || merchantIds.size() == 0 ){ |
|
|
|
// return new ResultData(ErrorCode.SYS_PARAMETER_ERROR.getCode(),"未查询到门店"); |
|
|
|
// } |
|
|
|
// |
|
|
|
// TtMerchantPoi poi = new TtMerchantPoi(); |
|
|
|
// poi.updateTenantInfo(tenantInfo); |
|
|
|
// poi.setIds(merchantIds); |
|
|
|
// poi.setMatchStatus(EnumSupplierMathStatus.match_success.getCode()); |
|
|
|
// poi.setSyncStatus(EnumSupplierSyncStatus.sync_success.getCode()); |
|
|
|
// List<TtMerchantPoi> poiList = ttMerchantPoiMapper.findList(poi); |
|
|
|
// if(poiList != null && merchantIds.size() == poiList.size()){ |
|
|
|
// return new ResultData(poiList); |
|
|
|
// }else{ |
|
|
|
// return new ResultData(ErrorCode.SYS_PARAMETER_ERROR.getCode(),"该商品店铺与poi门店不匹配"); |
|
|
|
// } |
|
|
|
// |
|
|
|
// } |
|
|
|
|
|
|
|
private void updateWebAccessToken(WxAppinfo appinfo, TtBasicService ttbasicService) { |
|
|
|
try { |
|
|
|
String accessToken = ttbasicService.getAccessToken(true); |
|
|
|
@@ -784,395 +736,16 @@ public class TtMerchantPoiServiceImpl implements TtMerchantPoiService { |
|
|
|
for (int i = 0 ; i < poiList.size(); i++) { |
|
|
|
TtMerchantPoi poi = poiList.get(i); |
|
|
|
if (StringUtils.isNotBlank(poi.getPoiId())) { |
|
|
|
poiMerchantIdMap.put(poi.getPoiId(), poi.getId()); |
|
|
|
Long curMId = poiMerchantIdMap.get(poi.getPoiId()); |
|
|
|
if (null == curMId) { |
|
|
|
poiMerchantIdMap.put(poi.getPoiId(), poi.getId()); |
|
|
|
}else { |
|
|
|
poiMerchantIdMap.put(poi.getPoiId(), -1L); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
return poiMerchantIdMap; |
|
|
|
} |
|
|
|
return null; |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
// @Override |
|
|
|
// public ResultData spuSync(TenantEntity tenantInfo, Long couponChannelId, List<Long> merchantIds) { |
|
|
|
// WxCouponChannel couponChannel = wxCouponChannelMapper.selectById(couponChannelId, tenantInfo.getTenantId()); |
|
|
|
// if(couponChannel == null || !EnumCouponChannelStatus.STATUS_THROW_IN.getCode().equals(couponChannel.getStatus())){ |
|
|
|
// return new ResultData(ErrorCode.SYS_PARAMETER_NOT_NULL.getCode(),"未找到上架卷数据"); |
|
|
|
// } |
|
|
|
// if(!EnumCouponChannelType.COUPON_CHANNEL_ID_DOUYIN_LIST.getCode().equals(couponChannel.getTargetAd())){ |
|
|
|
// return new ResultData(ErrorCode.SYS_PARAMETER_ERROR.getCode(),"只有投放在列表的卷才能进行同步poi"); |
|
|
|
// } |
|
|
|
// WxCoupon coupon = wxCouponMapper.selectById(couponChannel.getCouponId(), tenantInfo.getTenantId()); |
|
|
|
// if(coupon == null || !EnumCouponStatus.COUPON_STATUS_THROW_IN.getCode().equals(coupon.getStatus())){ |
|
|
|
// return new ResultData(ErrorCode.SYS_PARAMETER_ERROR.getCode(),"未找到可投放的卷"); |
|
|
|
// } |
|
|
|
// if(!EnumCouponType.getSpuSyncType().contains(coupon.getType())){ |
|
|
|
// return new ResultData(ErrorCode.SYS_PARAMETER_ERROR.getCode(),"卷类型不支持同步poi"); |
|
|
|
// } |
|
|
|
// List<Long> couponMerchantIds = wxCouponMerchantMapper.findMerchantIdListByProduct(coupon.getId(), tenantInfo.getTenantId()); |
|
|
|
// if(couponMerchantIds == null || couponMerchantIds.size() == 0 ){ |
|
|
|
// return new ResultData(ErrorCode.SYS_PARAMETER_ERROR.getCode(),"未查询到门店"); |
|
|
|
// } |
|
|
|
// |
|
|
|
// TtMerchantPoi poi = new TtMerchantPoi(); |
|
|
|
// poi.updateTenantInfo(tenantInfo); |
|
|
|
// poi.setIds(couponMerchantIds); |
|
|
|
// poi.setMatchStatus(EnumSupplierMathStatus.match_success.getCode()); |
|
|
|
// poi.setSyncStatus(EnumSupplierSyncStatus.sync_success.getCode()); |
|
|
|
// List<TtMerchantPoi> poiList = ttMerchantPoiMapper.findList(poi); |
|
|
|
// if(poiList == null || poiList.isEmpty()){ |
|
|
|
// return new ResultData(ErrorCode.SYS_PARAMETER_ERROR.getCode(),"未查询到匹配的poi"); |
|
|
|
// } |
|
|
|
//// List<Long> collect = poiList.stream().map(p -> p.getId()).collect(Collectors.toList()); |
|
|
|
// |
|
|
|
// String spuId = spuSync(coupon,couponChannel,couponMerchantIds); |
|
|
|
// if(StringUtils.isBlank(spuId)){ |
|
|
|
// return new ResultData(ErrorCode.SYS_PARAMETER_ERROR.getCode(),"同步失败"); |
|
|
|
// } |
|
|
|
// WxCouponChannel ccUpd = new WxCouponChannel(); |
|
|
|
// ccUpd.setId(couponChannel.getId()); |
|
|
|
// ccUpd.updateTenantInfo(couponChannel); |
|
|
|
// ccUpd.setTtSpuId(spuId); |
|
|
|
// ccUpd.setUpdateDate(new Date()); |
|
|
|
// wxCouponChannelMapper.updateById(ccUpd); |
|
|
|
// |
|
|
|
// syncCouponChannelPoi(ccUpd); |
|
|
|
// return new ResultData(); |
|
|
|
// } |
|
|
|
|
|
|
|
// private void syncCouponChannelPoi(WxCouponChannel ccUpd){ |
|
|
|
// TtCouponChannelPoi ttCouponChannelPoi = ttCouponChannelPoiMapper.selectById(ccUpd.getTenantId(),ccUpd.getId()); |
|
|
|
// if(ttCouponChannelPoi != null){ |
|
|
|
// ttCouponChannelPoi.setLastStatus(EnumSpuSyncStatus.sync_auditing.getCode()); |
|
|
|
// ttCouponChannelPoi.setLastStatusDesc(""); |
|
|
|
// ttCouponChannelPoi.setUpdateDate(ccUpd.getUpdateDate()); |
|
|
|
// ttCouponChannelPoiMapper.updateById(ttCouponChannelPoi); |
|
|
|
// }else{ |
|
|
|
// ttCouponChannelPoi = new TtCouponChannelPoi(); |
|
|
|
// ttCouponChannelPoi.setId(ccUpd.getId()); |
|
|
|
// ttCouponChannelPoi.updateTenantInfo(ccUpd); |
|
|
|
// ttCouponChannelPoi.setSpuId(ccUpd.getTtSpuId()); |
|
|
|
// ttCouponChannelPoi.setStatus(EnumSpuSyncStatus.sync_auditing.getCode()); |
|
|
|
// ttCouponChannelPoi.setLastStatus(EnumSpuSyncStatus.sync_auditing.getCode()); |
|
|
|
// ttCouponChannelPoi.setCreateDate(ccUpd.getUpdateDate()); |
|
|
|
// ttCouponChannelPoi.setUpdateDate(ccUpd.getUpdateDate()); |
|
|
|
// ttCouponChannelPoiMapper.insert(ttCouponChannelPoi); |
|
|
|
// } |
|
|
|
// } |
|
|
|
|
|
|
|
// private String spuSync(WxCoupon coupon,WxCouponChannel couponChannel, List<Long> merchantIds){ |
|
|
|
// TtSpuSync spuSync = new TtSpuSync(); |
|
|
|
// spuSync.setEntryInfo(getEntryInfo(couponChannel)); |
|
|
|
//// spuSync.setFrontCategoryTag();//前台品类标签 |
|
|
|
//// spuSync.setRecommendWord();//推荐语,5~20个字 |
|
|
|
//// spuSync.setSortWeight();//排序权重,按降序排列 |
|
|
|
// List<String> collect = merchantIds.stream().map(merchantId -> merchantId.toString()).collect(Collectors.toList()); |
|
|
|
// spuSync.setSupplierExtIdList(collect); |
|
|
|
// spuSync.setPrice(coupon.getSalePrice()); |
|
|
|
// spuSync.setSpuExtId(couponChannel.getId().toString()); |
|
|
|
// spuSync.setImageList(JSONArray.parseArray(coupon.getCoverPicture(),String.class)); |
|
|
|
//// spuSync.setMpSettletype();//小程序结算类型 1-包销 2-代销 |
|
|
|
// spuSync.setOriginPrice(coupon.getPrice()); |
|
|
|
//// spuSync.setTakeRate();//商品的抽佣率,万分数 |
|
|
|
// spuSync.setAttribute(getAttribute(coupon,couponChannel)); |
|
|
|
//// spuSync.setHighlights(getHighlights(coupon)); |
|
|
|
// spuSync.setName(coupon.getTitle()); |
|
|
|
//// spuSync.setOrderDependsOnDate(false);//下单是否依赖日期 |
|
|
|
// spuSync.setSpuType(91);//spu类型号,1-日历房,30-酒店民宿预售券,90-门票,91-团购券 |
|
|
|
// if(EnumCouponChannelStatus.STATUS_THROW_IN.getCode().equals(couponChannel.getStatus())){ |
|
|
|
// spuSync.setStatus(1); |
|
|
|
// }else{ |
|
|
|
// spuSync.setStatus(2); |
|
|
|
// } |
|
|
|
// spuSync.setStock(coupon.getRemainInventory()); |
|
|
|
// |
|
|
|
// String spuId = null; |
|
|
|
// try { |
|
|
|
// spuId = getTtWebService(coupon).getProductService().spuSync(spuSync); |
|
|
|
// } catch (WxErrorException e) { |
|
|
|
// logger.error("发起商品同步error"+e.getMessage()); |
|
|
|
// throw new MallinkException(ErrorCode.MSG_METHOD_REQUEST_ERROR.getCode(),e.getMessage()); |
|
|
|
// } |
|
|
|
// return spuId; |
|
|
|
// } |
|
|
|
|
|
|
|
//__________________________________商品同步_______________________________________________ |
|
|
|
//获取入口信息 |
|
|
|
// private JsonObject getEntryInfo(WxCouponChannel couponChannel){ |
|
|
|
// JsonObject object = new JsonObject(); |
|
|
|
// object.addProperty("entry_type",2);//入口类型(1:H5,2:抖音小程序,3:抖音链接) |
|
|
|
// JsonObject miniApp = new JsonObject(); |
|
|
|
// miniApp.addProperty("params",couponChannel.getTtparams()); |
|
|
|
// miniApp.addProperty("path",couponChannel.getTtPath()); |
|
|
|
// WxAppinfo appInfo = wxAppinfoService.getCAppInfo(couponChannel, EnumAppPlat.TOUTIAO); |
|
|
|
// miniApp.addProperty("app_id",appInfo.getAppId()); |
|
|
|
// object.add("entry_miniApp",miniApp); |
|
|
|
// return object; |
|
|
|
// } |
|
|
|
// |
|
|
|
// //获取SPU属性字段 |
|
|
|
// private JsonObject getAttribute(WxCoupon coupon,WxCouponChannel couponChannel){ |
|
|
|
//// JsonObject object = new JsonObject(); |
|
|
|
// JsonObject productObjuct = new JsonObject(); |
|
|
|
// SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); |
|
|
|
// productObjuct.addProperty("groupon_valid_start",dateFormat.format(couponChannel.getShowBeginTime()));//团购售卖时间开始 |
|
|
|
// // todo 要求必传, 可能为空 |
|
|
|
// productObjuct.addProperty("groupon_valid_end",dateFormat.format(coupon.getValidEndDate()));//******* |
|
|
|
// |
|
|
|
// productObjuct.addProperty("order_limit",coupon.getUseLimitQuantity());//单个用户购买数量限制 |
|
|
|
// if(EnumCouponValidType.BETWEEN_TWO_TIME.getCode().equals(coupon.getValidType())){ |
|
|
|
// productObjuct.addProperty("order_valid_start",dateFormat.format(coupon.getValidStartDate())); |
|
|
|
// productObjuct.addProperty("order_valid_end",dateFormat.format(coupon.getValidEndDate())); |
|
|
|
// }else if(EnumCouponValidType.DAYS_AFTER_RECEIVING.getCode().equals(coupon.getValidType())){ |
|
|
|
// productObjuct.addProperty("post_purchase_day",coupon.getValidDays()); |
|
|
|
// } |
|
|
|
// //todo 商家客服电话 目前传的广场的客服电话 联系人广场名称 |
|
|
|
// WxMall mall = wxMallMapper.getByTenantId(coupon.getTenantId()); |
|
|
|
// JsonArray phoneArray = new JsonArray(); |
|
|
|
// phoneArray.add(mall.getServicePhone()); |
|
|
|
// productObjuct.add("service_phone",phoneArray); |
|
|
|
// productObjuct.addProperty("contact_name",mall.getName()); |
|
|
|
// |
|
|
|
// //todo 团购须知 要求格式 标题加类容 是否二选一 待测试 |
|
|
|
// JsonArray notificationArray = new JsonArray(); |
|
|
|
//// for ( : ) { |
|
|
|
// JsonObject contentObject = new JsonObject(); |
|
|
|
// contentObject.addProperty("title","");//标题 |
|
|
|
// contentObject.addProperty("content",coupon.getRemark());//内容 |
|
|
|
// notificationArray.add(contentObject); |
|
|
|
//// } |
|
|
|
// productObjuct.add("notification",notificationArray); |
|
|
|
// if(EnumCouponContentType.HTML.getCode().equals(coupon.getContentType())){ |
|
|
|
// productObjuct.addProperty("notification_rich_text",coupon.getHtml()); |
|
|
|
// } |
|
|
|
// productObjuct.addProperty("sub_title",coupon.getSubTitle()); |
|
|
|
// |
|
|
|
// //todo 团购详情 要求必传, 待测试 |
|
|
|
// if(StringUtils.isNotBlank(coupon.getItemGroup())){ |
|
|
|
// JsonArray groupArray = new JsonParser().parse(coupon.getItemGroup()).getAsJsonArray(); |
|
|
|
// productObjuct.add("pay_item_groups",groupArray); |
|
|
|
// } |
|
|
|
//// JsonArray groupArray = new JsonArray(); |
|
|
|
//// for ( : ) { |
|
|
|
//// JsonObject groupObject = new JsonObject(); |
|
|
|
//// groupObject.addProperty("group_name","标题");//标题 |
|
|
|
//// JsonArray itemArray = new JsonArray(); //菜品 |
|
|
|
//// for (:) { |
|
|
|
//// JsonObject itemObject = new JsonObject(); |
|
|
|
//// itemObject.addProperty("name","菜名"); |
|
|
|
//// itemObject.addProperty("count","数量"); |
|
|
|
//// itemObject.addProperty("price","价格"); |
|
|
|
//// itemArray.add(itemObject); |
|
|
|
//// } |
|
|
|
//// groupObject.add("item_list",itemArray); |
|
|
|
//// groupArray.add(groupObject); |
|
|
|
//// } |
|
|
|
//// productObjuct.add("pay_item_groups",groupArray); |
|
|
|
// |
|
|
|
// //使用日期规则 |
|
|
|
//// JsonObject dateRuleObject = new JsonObject(); |
|
|
|
//// JsonObject unDateObject = new JsonObject();//不可用日期 |
|
|
|
//// JsonArray dateArray = new JsonArray();//日期列表,格式yyyy-mm-dd,最多传100个 |
|
|
|
//// JsonArray weekDayArray = new JsonArray();//星期列表,1-7代表周一到周天,[1,2]代表周一周二不可用 |
|
|
|
//// unDateObject.add("date_list",dateArray); |
|
|
|
//// unDateObject.add("weekday_list",weekDayArray); |
|
|
|
//// dateRuleObject.add("unavailable_date",unDateObject); |
|
|
|
//// productObjuct.add("date_rule",dateRuleObject); |
|
|
|
// |
|
|
|
// return productObjuct; |
|
|
|
// } |
|
|
|
// |
|
|
|
// //商品亮点标签 |
|
|
|
// private JsonArray getHighlights(WxCoupon coupon){ |
|
|
|
// JsonArray array = new JsonArray(); |
|
|
|
//// for (:) { |
|
|
|
//// JsonObject object = new JsonObject(); |
|
|
|
//// object.addProperty("content",);//介绍,字符串长度<=5 |
|
|
|
//// object.addProperty("priority",);//优先级,数字越小优先级越高 |
|
|
|
//// array.add(object); |
|
|
|
//// } |
|
|
|
// return array; |
|
|
|
// } |
|
|
|
|
|
|
|
//_________________________________________________________________________________ |
|
|
|
|
|
|
|
// @Override |
|
|
|
// public ResultData spuGet(TenantEntity tenantInfo, Long couponChannelId) { |
|
|
|
// WxCouponChannel couponChannel = wxCouponChannelMapper.selectById(couponChannelId, tenantInfo.getTenantId()); |
|
|
|
// if(couponChannel == null){ |
|
|
|
// return new ResultData(ErrorCode.SYS_PARAMETER_NOT_NULL.getCode(),"未找到卷数据"); |
|
|
|
// } |
|
|
|
// if(StringUtils.isBlank(couponChannel.getTtSpuId())){ |
|
|
|
// return new ResultData(ErrorCode.SYS_PARAMETER_ERROR.getCode(),"该券未同步poi"); |
|
|
|
// } |
|
|
|
// TtSpuGet spuGet = new TtSpuGet(); |
|
|
|
// spuGet.setSpuExtId(couponChannel.getId().toString()); |
|
|
|
// spuGet.setNeedSpuDraft(true); |
|
|
|
// spuGet.setSpuDraftcount(3); |
|
|
|
// try { |
|
|
|
// TtSpuGetResult spuGetResult = getTtWebService(tenantInfo).getProductService().spuGet(spuGet); |
|
|
|
// handSyncCouponChannelPoi(tenantInfo,spuGetResult); |
|
|
|
// //处理一下数据 |
|
|
|
// Map<String,Object> map = new HashMap<>(); |
|
|
|
// if(spuGetResult.getSpuDetail() != null){//线上数据 |
|
|
|
// TtSpuSync spuDetail = spuGetResult.getSpuDetail(); |
|
|
|
// map.put("spuDetail",handSpuSync(spuDetail)); |
|
|
|
// } |
|
|
|
// if(spuGetResult.getSpuDraft() != null && spuGetResult.getSpuDraft().size() > 0){//最近一次审核数据 |
|
|
|
// TtSpuSync spuDraft = spuGetResult.getSpuDraft().get(0); |
|
|
|
// map.put("spuDraft",handSpuSync(spuDraft)); |
|
|
|
// } |
|
|
|
// return new ResultData(map); |
|
|
|
// } catch (WxErrorException e) { |
|
|
|
// logger.error("couponChannelId:"+couponChannelId +" 多门店SPU信息查询error "+e.getMessage()); |
|
|
|
// return new ResultData(ErrorCode.MSG_METHOD_REQUEST_ERROR.getCode(),e.getMessage()); |
|
|
|
// } |
|
|
|
// } |
|
|
|
// |
|
|
|
// private void handSyncCouponChannelPoi(TenantEntity tenantInfo,TtSpuGetResult spuGetResult){ |
|
|
|
// Date now = new Date(); |
|
|
|
// TtSpuSync spuDetail = spuGetResult.getSpuDetail(); |
|
|
|
// if(spuDetail != null && StringUtils.isNotBlank(spuDetail.getSpuId()) && StringUtils.isNotBlank(spuDetail.getSpuExtId()) |
|
|
|
// && spuDetail.getStatus() != null){ |
|
|
|
// TtCouponChannelPoi ttCouponChannelPoi = ttCouponChannelPoiMapper.selectById(tenantInfo.getTenantId(),Long.parseLong(spuDetail.getSpuExtId())); |
|
|
|
// if(ttCouponChannelPoi != null && !spuDetail.getStatus().equals(ttCouponChannelPoi.getStatus())){ |
|
|
|
// TtCouponChannelPoi ccPoi = new TtCouponChannelPoi(); |
|
|
|
// ccPoi.setId(ttCouponChannelPoi.getId()); |
|
|
|
// ccPoi.setStatus(spuDetail.getStatus()); |
|
|
|
// ccPoi.setStatusDesc(spuDetail.getStatusDesc()); |
|
|
|
// ccPoi.setUpdateDate(now); |
|
|
|
// ttCouponChannelPoiMapper.updateById(ccPoi); |
|
|
|
// }else if(ttCouponChannelPoi == null){ |
|
|
|
// ttCouponChannelPoi = new TtCouponChannelPoi(); |
|
|
|
// ttCouponChannelPoi.setId(Long.parseLong(spuDetail.getSpuExtId())); |
|
|
|
// ttCouponChannelPoi.updateTenantInfo(tenantInfo); |
|
|
|
// ttCouponChannelPoi.setSpuId(spuDetail.getSpuId()); |
|
|
|
// ttCouponChannelPoi.setStatus(spuDetail.getStatus()); |
|
|
|
// ttCouponChannelPoi.setStatusDesc(spuDetail.getStatusDesc()); |
|
|
|
// ttCouponChannelPoi.setCreateDate(now); |
|
|
|
// ttCouponChannelPoi.setUpdateDate(now); |
|
|
|
// ttCouponChannelPoiMapper.insert(ttCouponChannelPoi); |
|
|
|
// } |
|
|
|
// } |
|
|
|
// List<TtSpuSync> spuDraftList = spuGetResult.getSpuDraft(); |
|
|
|
// if(spuDraftList != null && spuDraftList.size() > 0){ |
|
|
|
// TtSpuSync spuDraft = spuDraftList.get(0); |
|
|
|
// if(spuDraft != null && StringUtils.isNotBlank(spuDraft.getSpuId()) && StringUtils.isNotBlank(spuDraft.getSpuExtId()) |
|
|
|
// && spuDraft.getStatus() != null){ |
|
|
|
// TtCouponChannelPoi ttCouponChannelPoi = ttCouponChannelPoiMapper.selectById(tenantInfo.getTenantId(),Long.parseLong(spuDraft.getSpuExtId())); |
|
|
|
// if(ttCouponChannelPoi != null && !spuDraft.getStatus().equals(ttCouponChannelPoi.getStatus())){ |
|
|
|
// TtCouponChannelPoi ccPoi = new TtCouponChannelPoi(); |
|
|
|
// ccPoi.setId(ttCouponChannelPoi.getId()); |
|
|
|
// ccPoi.setLastStatus(spuDraft.getStatus()); |
|
|
|
// ccPoi.setLastStatusDesc(spuDraft.getStatusDesc()); |
|
|
|
// ccPoi.setUpdateDate(now); |
|
|
|
// ttCouponChannelPoiMapper.updateById(ccPoi); |
|
|
|
// }else if(ttCouponChannelPoi == null){ |
|
|
|
// ttCouponChannelPoi = new TtCouponChannelPoi(); |
|
|
|
// ttCouponChannelPoi.setId(Long.parseLong(spuDraft.getSpuExtId())); |
|
|
|
// ttCouponChannelPoi.updateTenantInfo(tenantInfo); |
|
|
|
// ttCouponChannelPoi.setSpuId(spuDraft.getSpuId()); |
|
|
|
// ttCouponChannelPoi.setStatus(EnumSpuSyncStatus.sync_auditing.getCode()); |
|
|
|
// ttCouponChannelPoi.setLastStatus(spuDraft.getStatus()); |
|
|
|
// ttCouponChannelPoi.setLastStatusDesc(spuDraft.getStatusDesc()); |
|
|
|
// ttCouponChannelPoi.setCreateDate(now); |
|
|
|
// ttCouponChannelPoi.setUpdateDate(now); |
|
|
|
// ttCouponChannelPoiMapper.insert(ttCouponChannelPoi); |
|
|
|
// } |
|
|
|
// } |
|
|
|
// } |
|
|
|
// } |
|
|
|
// |
|
|
|
// private Map<String,Object> handSpuSync(TtSpuSync spuSync){ |
|
|
|
// Map<String,Object> map = new HashMap<>(); |
|
|
|
// map.put("id",spuSync.getSpuExtId()); |
|
|
|
// map.put("spu_id",spuSync.getSpuId()); |
|
|
|
// map.put("image_list",spuSync.getImageList()); |
|
|
|
// map.put("name",spuSync.getName()); |
|
|
|
// if(spuSync.getAttribute() != null){ |
|
|
|
// JsonObject attribute = spuSync.getAttribute(); |
|
|
|
// JsonArray pay_item_groups = attribute.getAsJsonArray("pay_item_groups"); |
|
|
|
// map.put("pay_item_groups",pay_item_groups.toString()); |
|
|
|
// JsonArray notification = attribute.getAsJsonArray("notification"); |
|
|
|
// map.put("notification",notification.toString()); |
|
|
|
// map.put("order_limit", GsonHelper.getString(attribute, "order_limit")); |
|
|
|
// //售卖有效期 |
|
|
|
// map.put("groupon_valid_start", GsonHelper.getString(attribute, "groupon_valid_start")); |
|
|
|
// map.put("groupon_valid_end", GsonHelper.getString(attribute, "groupon_valid_end")); |
|
|
|
// //卷有效期 |
|
|
|
// map.put("order_valid_start", GsonHelper.getString(attribute, "order_valid_start")); |
|
|
|
// map.put("order_valid_end", GsonHelper.getString(attribute, "order_valid_end")); |
|
|
|
// |
|
|
|
// } |
|
|
|
// |
|
|
|
// map.put("price",spuSync.getPrice()); |
|
|
|
// map.put("origin_price",spuSync.getOriginPrice()); |
|
|
|
// map.put("stock",spuSync.getStock()); |
|
|
|
// map.put("status",spuSync.getStatus()); |
|
|
|
// map.put("status_desc",spuSync.getStatusDesc()); |
|
|
|
// return map; |
|
|
|
// } |
|
|
|
|
|
|
|
// @Override |
|
|
|
// public ResultData spuStatusSync(TenantEntity tenantInfo, Long couponChannelId) { |
|
|
|
// WxCouponChannel couponChannel = wxCouponChannelMapper.selectById(couponChannelId, tenantInfo.getTenantId()); |
|
|
|
// if(couponChannel == null){ |
|
|
|
// return new ResultData(ErrorCode.SYS_PARAMETER_NOT_NULL.getCode(),"未找到卷数据"); |
|
|
|
// } |
|
|
|
// if(StringUtils.isBlank(couponChannel.getTtSpuId())){ |
|
|
|
// return new ResultData(ErrorCode.SYS_PARAMETER_ERROR.getCode(),"该券未同步poi"); |
|
|
|
// } |
|
|
|
// TtSpuStatusSync statusSync = new TtSpuStatusSync(); |
|
|
|
// List<String> ids = new ArrayList<>(); |
|
|
|
// ids.add(couponChannel.getId().toString()); |
|
|
|
// statusSync.setSpuExtIdList(ids); |
|
|
|
// if(EnumCouponChannelStatus.STATUS_THROW_IN.getCode().equals(couponChannel.getStatus())){ |
|
|
|
// statusSync.setStatus(1); |
|
|
|
// }else{ |
|
|
|
// statusSync.setStatus(2); |
|
|
|
// } |
|
|
|
// try { |
|
|
|
// TtSpuStatusSync statusSyncResult = getTtWebService(tenantInfo).getProductService().spuStatusSync(statusSync); |
|
|
|
// if(statusSyncResult.getSpuExtIdList() != null && statusSyncResult.getSpuExtIdList().containsAll(ids)){ |
|
|
|
// return new ResultData(); |
|
|
|
// } |
|
|
|
// } catch (WxErrorException e) { |
|
|
|
// logger.error("couponChannelId:"+couponChannelId +" 多门店SPU状态同步error "+e.getMessage()); |
|
|
|
// throw new MallinkException(ErrorCode.MSG_METHOD_REQUEST_ERROR.getCode(),e.getMessage()); |
|
|
|
//// return new ResultData(ErrorCode.MSG_METHOD_REQUEST_ERROR.getCode(),e.getMessage()); |
|
|
|
// } |
|
|
|
// throw new MallinkException(ErrorCode.SYS_SERVER_ERROR.getCode(),"同步失败"); |
|
|
|
//// return new ResultData(ErrorCode.SYS_SERVER_ERROR.getCode(),"同步失败"); |
|
|
|
// } |
|
|
|
|
|
|
|
// @Override |
|
|
|
// public ResultData spuStockSync(TenantEntity tenantInfo, Long couponChannelId) { |
|
|
|
// WxCouponChannel couponChannel = wxCouponChannelMapper.selectById(couponChannelId, tenantInfo.getTenantId()); |
|
|
|
// if(couponChannel == null){ |
|
|
|
// return new ResultData(ErrorCode.SYS_PARAMETER_NOT_NULL.getCode(),"未找到卷数据"); |
|
|
|
// } |
|
|
|
// if(StringUtils.isBlank(couponChannel.getTtSpuId())){ |
|
|
|
// return new ResultData(ErrorCode.SYS_PARAMETER_ERROR.getCode(),"该券未同步poi"); |
|
|
|
// } |
|
|
|
// WxCoupon coupon = wxCouponMapper.selectById(couponChannel.getCouponId(), tenantInfo.getTenantId()); |
|
|
|
// if(coupon == null){ |
|
|
|
// return new ResultData(ErrorCode.SYS_PARAMETER_ERROR.getCode(),"未找到卷数据"); |
|
|
|
// } |
|
|
|
// TtSpuStockSync stockSync = new TtSpuStockSync(); |
|
|
|
// stockSync.setSpuExtId(couponChannel.getId().toString()); |
|
|
|
// stockSync.setStock(coupon.getRemainInventory()); |
|
|
|
// try { |
|
|
|
// boolean syncResult = getTtWebService(tenantInfo).getProductService().spuStockUpdate(stockSync); |
|
|
|
// if(syncResult){ |
|
|
|
// return new ResultData(); |
|
|
|
// } |
|
|
|
// } catch (WxErrorException e) { |
|
|
|
// logger.error("couponChannelId:"+couponChannelId +" 多门店SPU状态同步error "+e.getMessage()); |
|
|
|
// throw new MallinkException(ErrorCode.MSG_METHOD_REQUEST_ERROR.getCode(),e.getMessage()); |
|
|
|
//// return new ResultData(ErrorCode.MSG_METHOD_REQUEST_ERROR.getCode(),e.getMessage()); |
|
|
|
// } |
|
|
|
// throw new MallinkException(ErrorCode.SYS_SERVER_ERROR.getCode(),"同步失败"); |
|
|
|
//// return new ResultData(ErrorCode.SYS_SERVER_ERROR.getCode(),"同步失败"); |
|
|
|
// } |
|
|
|
|
|
|
|
} |