| @@ -38,12 +38,25 @@ public class TtGoodsCategoryController extends BaseController { | |||||
| return new ResultData(ttGoodsCategoryService.findTreeList()); | 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 | @TenantIgnore | ||||
| @ApiOperation("查询抖音类目") | @ApiOperation("查询抖音类目") | ||||
| @GetMapping("syncGet/{token}") | @GetMapping("syncGet/{token}") | ||||
| @ApiImplicitParams({}) | @ApiImplicitParams({}) | ||||
| @SystemControllerLog(description = "列表") | @SystemControllerLog(description = "列表") | ||||
| public ResultData get(@PathVariable String token) { | |||||
| public ResultData syncGet(@PathVariable String token) { | |||||
| logger.debug("[" + getIpAddr() + "] TtMerchantPoiController::get"); | logger.debug("[" + getIpAddr() + "] TtMerchantPoiController::get"); | ||||
| if(StringUtils.isBlank(token)){ | if(StringUtils.isBlank(token)){ | ||||
| return new ResultData(ErrorCode.SYS_PARAMETER_NOT_NULL); | return new ResultData(ErrorCode.SYS_PARAMETER_NOT_NULL); | ||||
| @@ -142,45 +142,44 @@ public class TtPoiPlanController extends BaseController { | |||||
| @SystemControllerLog(description = "更新") | @SystemControllerLog(description = "更新") | ||||
| public ResultData saveOrientedPlan(@RequestBody TtPoiTakeRate record) { | public ResultData saveOrientedPlan(@RequestBody TtPoiTakeRate record) { | ||||
| logger.debug("[" + getIpAddr() + "] TtMerchantPoiController::saveOrientedPlan"); | 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<String> 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之间"); | return new ResultData(ErrorCode.SYS_PARAMETER_NOT_NULL.getCode(),"商品的抽佣率需在万分位0-2900之间"); | ||||
| } | } | ||||
| @@ -47,7 +47,7 @@ public class TtPoiTakeRate extends TenantEntity { | |||||
| private Date startTime; | private Date startTime; | ||||
| private Date endTime; | private Date endTime; | ||||
| @io.swagger.annotations.ApiModelProperty(value="佣金有效期,单位是秒",name="commissionDuration") | |||||
| @io.swagger.annotations.ApiModelProperty(value="佣金有效期,单位是天",name="commissionDuration") | |||||
| private Long commissionDuration; | private Long commissionDuration; | ||||
| @io.swagger.annotations.ApiModelProperty(value="创建时间",name="createDate") | @io.swagger.annotations.ApiModelProperty(value="创建时间",name="createDate") | ||||
| @@ -1,7 +1,9 @@ | |||||
| package com.iformall.service; | package com.iformall.service; | ||||
| import com.iformall.common.ErrorCode; | |||||
| import com.iformall.domain.po.TtGoodsCategory; | import com.iformall.domain.po.TtGoodsCategory; | ||||
| import com.iformall.domain.po.WxCoupon; | import com.iformall.domain.po.WxCoupon; | ||||
| import com.iformall.douyin.web.bean.GoodsCategory; | |||||
| import com.iformall.douyin.web.bean.GoodsTemplateGet; | import com.iformall.douyin.web.bean.GoodsTemplateGet; | ||||
| import java.util.List; | import java.util.List; | ||||
| @@ -38,4 +40,7 @@ public interface TtGoodsCategoryService { | |||||
| * 同步抖音类目 | * 同步抖音类目 | ||||
| */ | */ | ||||
| void syncGet(); | void syncGet(); | ||||
| List<GoodsCategory> categoryGet(Integer categoryId); | |||||
| } | } | ||||
| @@ -624,9 +624,39 @@ public class TtCouponGoodsServiceImpl implements TtCouponGoodsService { | |||||
| poiPlan.setPlanId(record.getId()); | poiPlan.setPlanId(record.getId()); | ||||
| //不能修改达人 | //不能修改达人 | ||||
| // this.poiOrientedPlanDeleteTalent(ttWebService,record); | // 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{ | }else{ | ||||
| poiPlan.setDouyinIdList(record.getDouyinIdList()); | |||||
| poiPlan.setPlanName(record.getName()); | 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()); | poiPlan.setMerchantPhone(record.getMerchantPhone()); | ||||
| List<PoiOrientedPlan.ProductRate> productList = new ArrayList<>(); | List<PoiOrientedPlan.ProductRate> productList = new ArrayList<>(); | ||||
| @@ -651,17 +681,6 @@ public class TtCouponGoodsServiceImpl implements TtCouponGoodsService { | |||||
| if(returnPlanId != null){ | if(returnPlanId != null){ | ||||
| if(record.getId() == null){ | if(record.getId() == null){ | ||||
| record.setId(returnPlanId); | 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()); | record.setType(EnumCpsPlanType.DIRECTIONAL.getCode()); | ||||
| this.saveorupdate(record); | this.saveorupdate(record); | ||||
| @@ -756,54 +775,54 @@ public class TtCouponGoodsServiceImpl implements TtCouponGoodsService { | |||||
| * @param takeRate | * @param takeRate | ||||
| * @return | * @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 | @Override | ||||
| public ResultData poiPlanUpdateStatus(TtPoiTakeRate record) { | public ResultData poiPlanUpdateStatus(TtPoiTakeRate record) { | ||||
| @@ -11,6 +11,7 @@ import com.iformall.douyin.web.bean.GoodsTemplateGet; | |||||
| import com.iformall.enums.EnumCouponValidType; | import com.iformall.enums.EnumCouponValidType; | ||||
| import com.iformall.enums.EnumGoodsCategoryRate; | import com.iformall.enums.EnumGoodsCategoryRate; | ||||
| import com.iformall.enums.EnumYesOrNo; | import com.iformall.enums.EnumYesOrNo; | ||||
| import com.iformall.exception.MallinkException; | |||||
| import com.iformall.mapper.TtGoodsCategoryMapper; | import com.iformall.mapper.TtGoodsCategoryMapper; | ||||
| import com.iformall.service.TtGoodsCategoryService; | import com.iformall.service.TtGoodsCategoryService; | ||||
| import com.iformall.service.TtMerchantPoiService; | import com.iformall.service.TtMerchantPoiService; | ||||
| @@ -475,6 +476,18 @@ public class TtGoodsCategoryServiceImpl implements TtGoodsCategoryService { | |||||
| handSyncCategory(ttWebService,0,null,new Date()); | handSyncCategory(ttWebService,0,null,new Date()); | ||||
| } | } | ||||
| @Override | |||||
| public List<GoodsCategory> categoryGet(Integer categoryId) { | |||||
| TtWebService ttWebService = ttMerchantPoiService.getTtWebService(null); | |||||
| try { | |||||
| List<GoodsCategory> goodsCategories = ttWebService.getGoodsService().categoryGet(categoryId, null); | |||||
| return goodsCategories; | |||||
| } catch (WxErrorException e) { | |||||
| e.printStackTrace(); | |||||
| throw new MallinkException(e.getError().getErrorCode(),e.getError().getErrorMsg()); | |||||
| } | |||||
| } | |||||
| /** | /** | ||||
| * 循环同步类目 | * 循环同步类目 | ||||
| * @param ttWebService | * @param ttWebService | ||||