|
|
|
@@ -624,9 +624,39 @@ public class TtCouponGoodsServiceImpl implements TtCouponGoodsService { |
|
|
|
poiPlan.setPlanId(record.getId()); |
|
|
|
//不能修改达人 |
|
|
|
// this.poiOrientedPlanDeleteTalent(ttWebService,record); |
|
|
|
//修改只能添加达人 |
|
|
|
TtPoiTakeRate oldTakeRate = ttPoiTakeRateMapper.selectById(record.getId(), record.getTenantId()); |
|
|
|
if(oldTakeRate == null || StringUtils.isBlank(oldTakeRate.getDouyinId())){ |
|
|
|
throw new MallinkException(ErrorCode.SYS_PARAMETER_ERROR); |
|
|
|
} |
|
|
|
List<String> addDouyinIdList = new ArrayList<>(); |
|
|
|
addDouyinIdList.addAll(record.getDouyinIdList()); |
|
|
|
List<String> oldDouyinIdList = JSONObject.parseArray(oldTakeRate.getDouyinId(), String.class); |
|
|
|
addDouyinIdList.remove(oldDouyinIdList); |
|
|
|
if(!addDouyinIdList.isEmpty()){//有新增的达人 |
|
|
|
poiPlan.setDouyinIdList(addDouyinIdList); |
|
|
|
Map<String, Integer> douyinMap = JSONObject.parseObject(oldTakeRate.getDouyinIdStatus(), Map.class); |
|
|
|
for (String douyin:addDouyinIdList) { |
|
|
|
douyinMap.put(douyin,EnumCpsPlanStatus.ING.getCode()); |
|
|
|
} |
|
|
|
record.setDouyinId(JSON.toJSONString(record.getDouyinIdList())); |
|
|
|
record.setDouyinIdStatus(JSON.toJSONString(douyinMap)); |
|
|
|
}else{//没有新增的达人 |
|
|
|
record.setDouyinId(null); |
|
|
|
record.setDouyinIdStatus(null); |
|
|
|
} |
|
|
|
record.setName(null);//名称不能修改 |
|
|
|
record.setCommissionDuration(null);//佣金有效期不能修改 |
|
|
|
}else{ |
|
|
|
poiPlan.setDouyinIdList(record.getDouyinIdList()); |
|
|
|
poiPlan.setPlanName(record.getName()); |
|
|
|
poiPlan.setDouyinIdList(record.getDouyinIdList()); |
|
|
|
|
|
|
|
Map<String, Integer> douyinMap = new HashMap<>(); |
|
|
|
for (String douyin: record.getDouyinIdList()) { |
|
|
|
douyinMap.put(douyin,EnumCpsPlanStatus.ING.getCode()); |
|
|
|
} |
|
|
|
record.setDouyinId(JSON.toJSONString(record.getDouyinIdList())); |
|
|
|
record.setDouyinIdStatus(JSON.toJSONString(douyinMap)); |
|
|
|
} |
|
|
|
poiPlan.setMerchantPhone(record.getMerchantPhone()); |
|
|
|
List<PoiOrientedPlan.ProductRate> productList = new ArrayList<>(); |
|
|
|
@@ -651,17 +681,6 @@ public class TtCouponGoodsServiceImpl implements TtCouponGoodsService { |
|
|
|
if(returnPlanId != null){ |
|
|
|
if(record.getId() == null){ |
|
|
|
record.setId(returnPlanId); |
|
|
|
record.setDouyinId(JSON.toJSONString(record.getDouyinIdList())); |
|
|
|
Map<String, Integer> douyinMap = new HashMap<>(); |
|
|
|
for (String douyin: record.getDouyinIdList()) { |
|
|
|
douyinMap.put(douyin,EnumCpsPlanStatus.ING.getCode()); |
|
|
|
} |
|
|
|
record.setDouyinIdStatus(JSON.toJSONString(douyinMap)); |
|
|
|
}else{ |
|
|
|
record.setName(null); |
|
|
|
record.setDouyinId(null); |
|
|
|
record.setDouyinIdStatus(null); |
|
|
|
record.setCommissionDuration(null); |
|
|
|
} |
|
|
|
record.setType(EnumCpsPlanType.DIRECTIONAL.getCode()); |
|
|
|
this.saveorupdate(record); |
|
|
|
@@ -756,54 +775,54 @@ public class TtCouponGoodsServiceImpl implements TtCouponGoodsService { |
|
|
|
* @param takeRate |
|
|
|
* @return |
|
|
|
*/ |
|
|
|
private void poiOrientedPlanDeleteTalent(TtWebService ttWebService,TtPoiTakeRate takeRate){ |
|
|
|
if(takeRate == null || takeRate.getId() == null |
|
|
|
|| takeRate.getDouyinIdList() == null || takeRate.getDouyinIdList().isEmpty()){ |
|
|
|
throw new MallinkException(ErrorCode.SYS_PARAMETER_ERROR); |
|
|
|
} |
|
|
|
TtPoiTakeRate oldTakeRate = ttPoiTakeRateMapper.selectById(takeRate.getId(), takeRate.getTenantId()); |
|
|
|
if(oldTakeRate == null || StringUtils.isBlank(oldTakeRate.getDouyinId())){ |
|
|
|
throw new MallinkException(ErrorCode.SYS_PARAMETER_ERROR); |
|
|
|
} |
|
|
|
List<String> oldDouyinIdList = JSONObject.parseArray(oldTakeRate.getDouyinId(), String.class); |
|
|
|
List<String> newDouyinIdList = takeRate.getDouyinIdList(); |
|
|
|
|
|
|
|
List<String> addDouyinIdList = new ArrayList<>(); |
|
|
|
for (String douyinId:newDouyinIdList) { |
|
|
|
if(!oldDouyinIdList.contains(douyinId)){ |
|
|
|
addDouyinIdList.add(douyinId); |
|
|
|
} |
|
|
|
} |
|
|
|
List<String> delDouyinIdList = new ArrayList<>(); |
|
|
|
for (String douyinId:oldDouyinIdList) { |
|
|
|
if(!newDouyinIdList.contains(douyinId)){ |
|
|
|
try { |
|
|
|
boolean b = ttWebService.getPoiPlanService().poiOrientedPlanDeleteTalent(oldTakeRate.getId(), douyinId); |
|
|
|
delDouyinIdList.add(douyinId); |
|
|
|
} catch (WxErrorException e) { |
|
|
|
e.printStackTrace(); |
|
|
|
logger.error("定向计划删除达人失败{}"+e.getMessage()); |
|
|
|
logger.error("定向计划删除达人失败"+oldTakeRate.getId()+"del--"+douyinId); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
if(!delDouyinIdList.isEmpty()){ |
|
|
|
oldDouyinIdList.removeAll(delDouyinIdList); |
|
|
|
} |
|
|
|
TtPoiTakeRate updTakeRate = new TtPoiTakeRate(); |
|
|
|
updTakeRate.updateTenantInfo(oldTakeRate); |
|
|
|
updTakeRate.setId(oldTakeRate.getId()); |
|
|
|
updTakeRate.setDouyinId(JSON.toJSONString(oldDouyinIdList)); |
|
|
|
ttPoiTakeRateMapper.updateById(updTakeRate); |
|
|
|
|
|
|
|
if(!addDouyinIdList.isEmpty()){ |
|
|
|
oldDouyinIdList.addAll(addDouyinIdList); |
|
|
|
takeRate.setDouyinId(JSON.toJSONString(oldDouyinIdList)); |
|
|
|
takeRate.setDouyinIdList(addDouyinIdList); |
|
|
|
}else{ |
|
|
|
takeRate.setDouyinIdList(null); |
|
|
|
} |
|
|
|
} |
|
|
|
// private void poiOrientedPlanDeleteTalent(TtWebService ttWebService,TtPoiTakeRate takeRate){ |
|
|
|
// if(takeRate == null || takeRate.getId() == null |
|
|
|
// || takeRate.getDouyinIdList() == null || takeRate.getDouyinIdList().isEmpty()){ |
|
|
|
// throw new MallinkException(ErrorCode.SYS_PARAMETER_ERROR); |
|
|
|
// } |
|
|
|
// TtPoiTakeRate oldTakeRate = ttPoiTakeRateMapper.selectById(takeRate.getId(), takeRate.getTenantId()); |
|
|
|
// if(oldTakeRate == null || StringUtils.isBlank(oldTakeRate.getDouyinId())){ |
|
|
|
// throw new MallinkException(ErrorCode.SYS_PARAMETER_ERROR); |
|
|
|
// } |
|
|
|
// List<String> oldDouyinIdList = JSONObject.parseArray(oldTakeRate.getDouyinId(), String.class); |
|
|
|
// List<String> newDouyinIdList = takeRate.getDouyinIdList(); |
|
|
|
// |
|
|
|
// List<String> addDouyinIdList = new ArrayList<>(); |
|
|
|
// for (String douyinId:newDouyinIdList) { |
|
|
|
// if(!oldDouyinIdList.contains(douyinId)){ |
|
|
|
// addDouyinIdList.add(douyinId); |
|
|
|
// } |
|
|
|
// } |
|
|
|
// List<String> delDouyinIdList = new ArrayList<>(); |
|
|
|
// for (String douyinId:oldDouyinIdList) { |
|
|
|
// if(!newDouyinIdList.contains(douyinId)){ |
|
|
|
// try { |
|
|
|
// boolean b = ttWebService.getPoiPlanService().poiOrientedPlanDeleteTalent(oldTakeRate.getId(), douyinId); |
|
|
|
// delDouyinIdList.add(douyinId); |
|
|
|
// } catch (WxErrorException e) { |
|
|
|
// e.printStackTrace(); |
|
|
|
// logger.error("定向计划删除达人失败{}"+e.getMessage()); |
|
|
|
// logger.error("定向计划删除达人失败"+oldTakeRate.getId()+"del--"+douyinId); |
|
|
|
// } |
|
|
|
// } |
|
|
|
// } |
|
|
|
// if(!delDouyinIdList.isEmpty()){ |
|
|
|
// oldDouyinIdList.removeAll(delDouyinIdList); |
|
|
|
// } |
|
|
|
// TtPoiTakeRate updTakeRate = new TtPoiTakeRate(); |
|
|
|
// updTakeRate.updateTenantInfo(oldTakeRate); |
|
|
|
// updTakeRate.setId(oldTakeRate.getId()); |
|
|
|
// updTakeRate.setDouyinId(JSON.toJSONString(oldDouyinIdList)); |
|
|
|
// ttPoiTakeRateMapper.updateById(updTakeRate); |
|
|
|
// |
|
|
|
// if(!addDouyinIdList.isEmpty()){ |
|
|
|
// oldDouyinIdList.addAll(addDouyinIdList); |
|
|
|
// takeRate.setDouyinId(JSON.toJSONString(oldDouyinIdList)); |
|
|
|
// takeRate.setDouyinIdList(addDouyinIdList); |
|
|
|
// }else{ |
|
|
|
// takeRate.setDouyinIdList(null); |
|
|
|
// } |
|
|
|
// } |
|
|
|
|
|
|
|
@Override |
|
|
|
public ResultData poiPlanUpdateStatus(TtPoiTakeRate record) { |
|
|
|
|