diff --git a/mallinkAdmin/src/main/java/com/iformall/controller/basic/TtGoodsCategoryController.java b/mallinkAdmin/src/main/java/com/iformall/controller/basic/TtGoodsCategoryController.java index ff36d188f..7e4e49ff9 100644 --- a/mallinkAdmin/src/main/java/com/iformall/controller/basic/TtGoodsCategoryController.java +++ b/mallinkAdmin/src/main/java/com/iformall/controller/basic/TtGoodsCategoryController.java @@ -38,12 +38,25 @@ public class TtGoodsCategoryController extends BaseController { return new ResultData(ttGoodsCategoryService.findTreeList()); } + @TenantIgnore + @ApiOperation("查询类目") + @GetMapping("get") + @ApiImplicitParams({}) + @SystemControllerLog(description = "列表") + public ResultData categoryGet(Integer categoryId) { + logger.debug("[" + getIpAddr() + "] TtMerchantPoiController::categoryGet"); + if(categoryId == null){ + categoryId = 0; + } + return new ResultData(ttGoodsCategoryService.categoryGet(categoryId)); + } + @TenantIgnore @ApiOperation("查询抖音类目") @GetMapping("syncGet/{token}") @ApiImplicitParams({}) @SystemControllerLog(description = "列表") - public ResultData get(@PathVariable String token) { + public ResultData syncGet(@PathVariable String token) { logger.debug("[" + getIpAddr() + "] TtMerchantPoiController::get"); if(StringUtils.isBlank(token)){ return new ResultData(ErrorCode.SYS_PARAMETER_NOT_NULL); diff --git a/mallinkAdmin/src/main/java/com/iformall/controller/basic/TtPoiPlanController.java b/mallinkAdmin/src/main/java/com/iformall/controller/basic/TtPoiPlanController.java index 5e106d0fc..48b0ab30f 100644 --- a/mallinkAdmin/src/main/java/com/iformall/controller/basic/TtPoiPlanController.java +++ b/mallinkAdmin/src/main/java/com/iformall/controller/basic/TtPoiPlanController.java @@ -142,45 +142,44 @@ public class TtPoiPlanController extends BaseController { @SystemControllerLog(description = "更新") public ResultData saveOrientedPlan(@RequestBody TtPoiTakeRate record) { logger.debug("[" + getIpAddr() + "] TtMerchantPoiController::saveOrientedPlan"); - if(record.getId() == null){ - if(StringUtils.isBlank(record.getName())){//不可修改 - return new ResultData(ErrorCode.SYS_PARAMETER_NOT_NULL.getCode(),"计划名称为空"); - } - if(StringUtils.isBlank(record.getMerchantPhone())){ - return new ResultData(ErrorCode.SYS_PARAMETER_NOT_NULL.getCode(),"计划联系人为空"); - } - if(record.getDouyinIdList() == null || record.getDouyinIdList().isEmpty()){ - return new ResultData(ErrorCode.SYS_PARAMETER_NOT_NULL.getCode(),"定向达人抖音号为空"); - } - if(record.getCouponId() == null){ - return new ResultData(ErrorCode.SYS_PARAMETER_NOT_NULL.getCode(),"商品Id为空"); - } - if(record.getContentType() == null){ - return new ResultData(ErrorCode.SYS_PARAMETER_NOT_NULL.getCode(),"带货场景为空"); - } - EnumCpsPlanContentType planType = EnumCpsPlanContentType.getEnum(record.getContentType()); - if(planType == null || (!planType.equals(EnumCpsPlanContentType.VIDEO) && !planType.equals(EnumCpsPlanContentType.LIVE))){ - return new ResultData(ErrorCode.SYS_PARAMETER_ERROR.getCode(),"带货场景错误"); - } - if(planType.equals(EnumCpsPlanContentType.VIDEO)){ - if(record.getStartTime() == null){ - return new ResultData(ErrorCode.SYS_PARAMETER_NOT_NULL.getCode(),"计划开始时间为空"); - } - if(record.getEndTime() == null){ - return new ResultData(ErrorCode.SYS_PARAMETER_NOT_NULL.getCode(),"计划结束时间为空"); - } - if(record.getCommissionDuration() == null){ - return new ResultData(ErrorCode.SYS_PARAMETER_NOT_NULL.getCode(),"佣金有效期为空"); - } + if(StringUtils.isBlank(record.getName())){//不可修改 + return new ResultData(ErrorCode.SYS_PARAMETER_NOT_NULL.getCode(),"计划名称为空"); + } + if(StringUtils.isBlank(record.getMerchantPhone())){ + return new ResultData(ErrorCode.SYS_PARAMETER_NOT_NULL.getCode(),"计划联系人为空"); + } + if(record.getDouyinIdList() == null || record.getDouyinIdList().isEmpty()){ + return new ResultData(ErrorCode.SYS_PARAMETER_NOT_NULL.getCode(),"定向达人抖音号为空"); + } + //达人去重 + List collect = record.getDouyinIdList().stream().collect(Collectors.toList()); + record.setDouyinIdList(collect); + + if(record.getCouponId() == null){ + return new ResultData(ErrorCode.SYS_PARAMETER_NOT_NULL.getCode(),"商品Id为空"); + } + if(record.getContentType() == null){ + return new ResultData(ErrorCode.SYS_PARAMETER_NOT_NULL.getCode(),"带货场景为空"); + } + EnumCpsPlanContentType planType = EnumCpsPlanContentType.getEnum(record.getContentType()); + if(planType == null || (!planType.equals(EnumCpsPlanContentType.VIDEO) && !planType.equals(EnumCpsPlanContentType.LIVE))){ + return new ResultData(ErrorCode.SYS_PARAMETER_ERROR.getCode(),"带货场景错误"); + } + if(planType.equals(EnumCpsPlanContentType.VIDEO)){ + if(record.getStartTime() == null){ + return new ResultData(ErrorCode.SYS_PARAMETER_NOT_NULL.getCode(),"计划开始时间为空"); } - if(record.getTakeRate() == null){ - return new ResultData(ErrorCode.SYS_PARAMETER_NOT_NULL.getCode(),"商品的抽佣率为空"); + if(record.getEndTime() == null){ + return new ResultData(ErrorCode.SYS_PARAMETER_NOT_NULL.getCode(),"计划结束时间为空"); } - if(record.getTakeRate() <= 0 || record.getTakeRate() > 2900){ - + if(record.getCommissionDuration() == null){ + return new ResultData(ErrorCode.SYS_PARAMETER_NOT_NULL.getCode(),"佣金有效期为空"); } } - if(record.getTakeRate() != null && (record.getTakeRate() <= 0 || record.getTakeRate() > 2900)){ + if(record.getTakeRate() == null){ + return new ResultData(ErrorCode.SYS_PARAMETER_NOT_NULL.getCode(),"商品的抽佣率为空"); + } + if(record.getTakeRate() <= 0 || record.getTakeRate() > 2900){ return new ResultData(ErrorCode.SYS_PARAMETER_NOT_NULL.getCode(),"商品的抽佣率需在万分位0-2900之间"); } diff --git a/mallinkService/src/main/java/com/iformall/domain/po/TtPoiTakeRate.java b/mallinkService/src/main/java/com/iformall/domain/po/TtPoiTakeRate.java index 8793ab707..3ac4b28bf 100644 --- a/mallinkService/src/main/java/com/iformall/domain/po/TtPoiTakeRate.java +++ b/mallinkService/src/main/java/com/iformall/domain/po/TtPoiTakeRate.java @@ -47,7 +47,7 @@ public class TtPoiTakeRate extends TenantEntity { private Date startTime; private Date endTime; - @io.swagger.annotations.ApiModelProperty(value="佣金有效期,单位是秒",name="commissionDuration") + @io.swagger.annotations.ApiModelProperty(value="佣金有效期,单位是天",name="commissionDuration") private Long commissionDuration; @io.swagger.annotations.ApiModelProperty(value="创建时间",name="createDate") diff --git a/mallinkService/src/main/java/com/iformall/service/TtGoodsCategoryService.java b/mallinkService/src/main/java/com/iformall/service/TtGoodsCategoryService.java index 2ad17d8cc..01e5466eb 100644 --- a/mallinkService/src/main/java/com/iformall/service/TtGoodsCategoryService.java +++ b/mallinkService/src/main/java/com/iformall/service/TtGoodsCategoryService.java @@ -1,7 +1,9 @@ package com.iformall.service; +import com.iformall.common.ErrorCode; import com.iformall.domain.po.TtGoodsCategory; import com.iformall.domain.po.WxCoupon; +import com.iformall.douyin.web.bean.GoodsCategory; import com.iformall.douyin.web.bean.GoodsTemplateGet; import java.util.List; @@ -38,4 +40,7 @@ public interface TtGoodsCategoryService { * 同步抖音类目 */ void syncGet(); + + + List categoryGet(Integer categoryId); } diff --git a/mallinkService/src/main/java/com/iformall/service/impl/TtCouponGoodsServiceImpl.java b/mallinkService/src/main/java/com/iformall/service/impl/TtCouponGoodsServiceImpl.java index 54cbbb20f..6ece3651f 100644 --- a/mallinkService/src/main/java/com/iformall/service/impl/TtCouponGoodsServiceImpl.java +++ b/mallinkService/src/main/java/com/iformall/service/impl/TtCouponGoodsServiceImpl.java @@ -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 addDouyinIdList = new ArrayList<>(); + addDouyinIdList.addAll(record.getDouyinIdList()); + List oldDouyinIdList = JSONObject.parseArray(oldTakeRate.getDouyinId(), String.class); + addDouyinIdList.remove(oldDouyinIdList); + if(!addDouyinIdList.isEmpty()){//有新增的达人 + poiPlan.setDouyinIdList(addDouyinIdList); + Map 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 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 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 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 oldDouyinIdList = JSONObject.parseArray(oldTakeRate.getDouyinId(), String.class); - List newDouyinIdList = takeRate.getDouyinIdList(); - - List addDouyinIdList = new ArrayList<>(); - for (String douyinId:newDouyinIdList) { - if(!oldDouyinIdList.contains(douyinId)){ - addDouyinIdList.add(douyinId); - } - } - List 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 oldDouyinIdList = JSONObject.parseArray(oldTakeRate.getDouyinId(), String.class); +// List newDouyinIdList = takeRate.getDouyinIdList(); +// +// List addDouyinIdList = new ArrayList<>(); +// for (String douyinId:newDouyinIdList) { +// if(!oldDouyinIdList.contains(douyinId)){ +// addDouyinIdList.add(douyinId); +// } +// } +// List 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) { 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 e51c59c51..594e7e48b 100644 --- a/mallinkService/src/main/java/com/iformall/service/impl/TtGoodsCategoryServiceImpl.java +++ b/mallinkService/src/main/java/com/iformall/service/impl/TtGoodsCategoryServiceImpl.java @@ -11,6 +11,7 @@ import com.iformall.douyin.web.bean.GoodsTemplateGet; import com.iformall.enums.EnumCouponValidType; import com.iformall.enums.EnumGoodsCategoryRate; import com.iformall.enums.EnumYesOrNo; +import com.iformall.exception.MallinkException; import com.iformall.mapper.TtGoodsCategoryMapper; import com.iformall.service.TtGoodsCategoryService; import com.iformall.service.TtMerchantPoiService; @@ -475,6 +476,18 @@ public class TtGoodsCategoryServiceImpl implements TtGoodsCategoryService { handSyncCategory(ttWebService,0,null,new Date()); } + @Override + public List categoryGet(Integer categoryId) { + TtWebService ttWebService = ttMerchantPoiService.getTtWebService(null); + try { + List goodsCategories = ttWebService.getGoodsService().categoryGet(categoryId, null); + return goodsCategories; + } catch (WxErrorException e) { + e.printStackTrace(); + throw new MallinkException(e.getError().getErrorCode(),e.getError().getErrorMsg()); + } + } + /** * 循环同步类目 * @param ttWebService