| @@ -142,46 +142,83 @@ public class TtPoiPlanController extends BaseController { | |||
| @SystemControllerLog(description = "更新") | |||
| public ResultData saveOrientedPlan(@RequestBody TtPoiTakeRate record) { | |||
| logger.debug("[" + getIpAddr() + "] TtMerchantPoiController::saveOrientedPlan"); | |||
| 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.getId() == null){ | |||
| if(StringUtils.isBlank(record.getName())){//不可修改 | |||
| return new ResultData(ErrorCode.SYS_PARAMETER_NOT_NULL.getCode(),"计划名称为空"); | |||
| } | |||
| if(record.getEndTime() == null){ | |||
| 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.getCommissionDuration() == null){ | |||
| 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(record.getTakeRate() == null){ | |||
| return new ResultData(ErrorCode.SYS_PARAMETER_NOT_NULL.getCode(),"商品的抽佣率为空"); | |||
| } | |||
| if(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){ | |||
| if(record.getTakeRate() != null && (record.getTakeRate() <= 0 || record.getTakeRate() > 2900)){ | |||
| return new ResultData(ErrorCode.SYS_PARAMETER_NOT_NULL.getCode(),"商品的抽佣率需在万分位0-2900之间"); | |||
| } | |||
| record.updateTenantInfo(getTenantInfo()); | |||
| return ttCouponGoodsService.saveOrientedPlan(record); | |||
| } | |||
| @ApiOperation("新增定向佣金达人合作") | |||
| @PostMapping("addOrientedPlanDouyin") | |||
| @SystemControllerLog(description = "更新") | |||
| public ResultData addOrientedPlanDouyin(@RequestBody TtPoiTakeRate record) { | |||
| logger.debug("[" + getIpAddr() + "] TtMerchantPoiController::addOrientedPlanDouyin"); | |||
| if(record.getId() == null){ | |||
| return new ResultData(ErrorCode.SYS_PARAMETER_NOT_NULL.getCode(),"Id为空"); | |||
| } | |||
| if(record.getDouyinIdList() == null || record.getDouyinIdList().isEmpty()){ | |||
| return new ResultData(ErrorCode.SYS_PARAMETER_NOT_NULL.getCode(),"添加定向达人抖音号为空"); | |||
| } | |||
| record.updateTenantInfo(getTenantInfo()); | |||
| return ttCouponGoodsService.addOrientedPlanDouyin(record); | |||
| } | |||
| @ApiOperation("取消定向佣金达人合作") | |||
| @PostMapping("cancelOrientedPlanDouyin") | |||
| @SystemControllerLog(description = "更新") | |||
| public ResultData cancelOrientedPlanDouyin(@RequestBody TtPoiTakeRate record) { | |||
| logger.debug("[" + getIpAddr() + "] TtMerchantPoiController::cancelOrientedPlanDouyin"); | |||
| if(record.getId() == null){ | |||
| return new ResultData(ErrorCode.SYS_PARAMETER_NOT_NULL.getCode(),"Id为空"); | |||
| } | |||
| if(StringUtils.isBlank(record.getDouyinId())){ | |||
| return new ResultData(ErrorCode.SYS_PARAMETER_NOT_NULL.getCode(),"取消定向达人抖音号为空"); | |||
| } | |||
| record.updateTenantInfo(getTenantInfo()); | |||
| return ttCouponGoodsService.cancelOrientedPlanDouyin(record); | |||
| } | |||
| @ApiOperation("修改通用佣金计划状态") | |||
| @PostMapping("updateStatus") | |||
| @SystemControllerLog(description = "更新") | |||
| @@ -10,6 +10,8 @@ import com.iformall.domain.vo.TtCouponChannelVo; | |||
| import com.iformall.domain.vo.TtCouponVo; | |||
| import com.iformall.enums.EnumCpsPlanType; | |||
| import java.util.List; | |||
| public interface TtCouponGoodsService { | |||
| ResultData couponList(TtCouponVo ttCouponVo, Integer pageNum, Integer pageSize); | |||
| @@ -45,6 +47,10 @@ public interface TtCouponGoodsService { | |||
| ResultData saveOrientedPlan(TtPoiTakeRate record); | |||
| ResultData addOrientedPlanDouyin(TtPoiTakeRate record); | |||
| ResultData cancelOrientedPlanDouyin(TtPoiTakeRate record); | |||
| ResultData poiPlanUpdateStatus(TtPoiTakeRate record); | |||
| ResultData poiOrientedPlanUpdateStatus(TtPoiTakeRate record); | |||
| @@ -56,4 +62,5 @@ public interface TtCouponGoodsService { | |||
| ResultData getAll(TenantEntity tenantInfo, Long couponId); | |||
| ResultData getRateScope(TenantEntity tenantInfo, Long couponId); | |||
| } | |||
| @@ -620,16 +620,15 @@ public class TtCouponGoodsServiceImpl implements TtCouponGoodsService { | |||
| Long returnPlanId = null; | |||
| PoiOrientedPlan poiPlan = new PoiOrientedPlan(); | |||
| if(record.getId() != null){ | |||
| //修改 | |||
| poiPlan.setPlanId(record.getId()); | |||
| this.poiOrientedPlanDeleteTalent(ttWebService,record); | |||
| //不能修改达人 | |||
| // this.poiOrientedPlanDeleteTalent(ttWebService,record); | |||
| }else{ | |||
| record.setDouyinId(JSON.toJSONString(record.getDouyinIdList())); | |||
| poiPlan.setDouyinIdList(record.getDouyinIdList()); | |||
| poiPlan.setPlanName(record.getName()); | |||
| } | |||
| poiPlan.setMerchantPhone(record.getMerchantPhone()); | |||
| if(record.getDouyinIdList() != null && !record.getDouyinIdList().isEmpty()){ | |||
| poiPlan.setDouyinIdList(record.getDouyinIdList()); | |||
| } | |||
| List<PoiOrientedPlan.ProductRate> productList = new ArrayList<>(); | |||
| PoiOrientedPlan.ProductRate product = new PoiOrientedPlan.ProductRate(); | |||
| product.setProductId(spu_id); | |||
| @@ -652,8 +651,16 @@ 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()); | |||
| @@ -669,6 +676,79 @@ public class TtCouponGoodsServiceImpl implements TtCouponGoodsService { | |||
| } | |||
| } | |||
| @Override | |||
| public ResultData addOrientedPlanDouyin(TtPoiTakeRate record) { | |||
| TtPoiTakeRate takeRate = ttPoiTakeRateMapper.selectById(record.getId(), record.getTenantId()); | |||
| if(takeRate == null){ | |||
| return new ResultData(ErrorCode.SYS_PARAMETER_ERROR.getCode(),"未获取到计划"); | |||
| } | |||
| if(EnumCpsPlanContentType.LIVE.getCode().equals(takeRate.getContentType()) | |||
| || EnumCpsPlanContentType.VIDEO.getCode().equals(record.getContentType())){ | |||
| return new ResultData(ErrorCode.SYS_PARAMETER_ERROR.getCode(),"带货场景不支持"); | |||
| } | |||
| List<String> douyinIdList = JSONObject.parseArray(takeRate.getDouyinId(), String.class); | |||
| douyinIdList.removeAll(record.getDouyinIdList()); | |||
| douyinIdList.addAll(record.getDouyinIdList()); | |||
| Map<String, Integer> douyinMap = JSONObject.parseObject(takeRate.getDouyinIdStatus(), Map.class); | |||
| for (String douyin: record.getDouyinIdList()) { | |||
| douyinMap.put(douyin,EnumCpsPlanStatus.ING.getCode()); | |||
| } | |||
| try { | |||
| TtWebService ttWebService = ttMerchantPoiService.getTtWebService(record); | |||
| PoiOrientedPlan poiPlan = new PoiOrientedPlan(); | |||
| poiPlan.setPlanId(record.getId()); | |||
| poiPlan.setDouyinIdList(record.getDouyinIdList()); | |||
| Long returnPlanId = null; | |||
| if(EnumCpsPlanContentType.LIVE.getCode().equals(record.getContentType())){ | |||
| returnPlanId = ttWebService.getPoiPlanService().poiOrientedPlanLiveSave(poiPlan); | |||
| }else if(EnumCpsPlanContentType.VIDEO.getCode().equals(record.getContentType())){ | |||
| returnPlanId = ttWebService.getPoiPlanService().poiOrientedPlanVideoSave(poiPlan); | |||
| } | |||
| TtPoiTakeRate updTakeRate = new TtPoiTakeRate(); | |||
| updTakeRate.setId(record.getId()); | |||
| updTakeRate.updateTenantInfo(record); | |||
| updTakeRate.setDouyinId(JSON.toJSONString(douyinIdList)); | |||
| updTakeRate.setDouyinIdStatus(JSON.toJSONString(douyinMap)); | |||
| updTakeRate.setUpdateDate(new Date()); | |||
| ttPoiTakeRateMapper.updateById(updTakeRate); | |||
| return new ResultData(); | |||
| }catch (WxErrorException e) { | |||
| e.printStackTrace(); | |||
| return new ResultData(ErrorCode.SYS_SERVER_ERROR.getCode(),e.getMessage()); | |||
| } | |||
| } | |||
| @Override | |||
| public ResultData cancelOrientedPlanDouyin(TtPoiTakeRate record) { | |||
| TtPoiTakeRate takeRate = ttPoiTakeRateMapper.selectById(record.getId(), record.getTenantId()); | |||
| if(takeRate == null){ | |||
| return new ResultData(ErrorCode.SYS_PARAMETER_ERROR.getCode(),"未获取到计划"); | |||
| } | |||
| if(EnumCpsPlanContentType.LIVE.getCode().equals(takeRate.getContentType()) | |||
| || EnumCpsPlanContentType.VIDEO.getCode().equals(record.getContentType())){ | |||
| return new ResultData(ErrorCode.SYS_PARAMETER_ERROR.getCode(),"带货场景不支持"); | |||
| } | |||
| Map<String, Integer> douyinMap = JSONObject.parseObject(takeRate.getDouyinIdStatus(), Map.class); | |||
| douyinMap.put(record.getDouyinId(),EnumCpsPlanStatus.OFF.getCode()); | |||
| try { | |||
| TtWebService ttWebService = ttMerchantPoiService.getTtWebService(record); | |||
| boolean b = ttWebService.getPoiPlanService().poiOrientedPlanDeleteTalent(record.getId(), record.getDouyinId()); | |||
| TtPoiTakeRate updTakeRate = new TtPoiTakeRate(); | |||
| updTakeRate.setId(record.getId()); | |||
| updTakeRate.updateTenantInfo(record); | |||
| updTakeRate.setDouyinIdStatus(JSON.toJSONString(douyinMap)); | |||
| updTakeRate.setUpdateDate(new Date()); | |||
| ttPoiTakeRateMapper.updateById(updTakeRate); | |||
| return new ResultData(); | |||
| }catch (WxErrorException e) { | |||
| e.printStackTrace(); | |||
| return new ResultData(ErrorCode.SYS_SERVER_ERROR.getCode(),e.getMessage()); | |||
| } | |||
| } | |||
| /** | |||
| * 删除定向计划里的达人,并处理达人数据 | |||
| * 只能一个个删除,有可能删除失败 | |||
| @@ -749,6 +829,8 @@ public class TtCouponGoodsServiceImpl implements TtCouponGoodsService { | |||
| @Override | |||
| public ResultData poiOrientedPlanUpdateStatus(TtPoiTakeRate record) { | |||
| try { | |||
| //仅支持传3,将计划修改为已取消 | |||
| //仅支持修改直播间定向佣金计划,不支持修改短视频定向佣金计划 | |||
| boolean b = ttMerchantPoiService.getTtWebService(record).getPoiPlanService().poiOrientedPlanUpdateStatus(record.getId(), record.getStatus()); | |||
| if(b){ | |||
| TtPoiTakeRate updTakeRate = new TtPoiTakeRate(); | |||