xhxu 3 лет назад
Родитель
Сommit
fd4b0e5bf3
6 измененных файлов: 146 добавлений и 97 удалений
  1. +14
    -1
      mallinkAdmin/src/main/java/com/iformall/controller/basic/TtGoodsCategoryController.java
  2. +34
    -35
      mallinkAdmin/src/main/java/com/iformall/controller/basic/TtPoiPlanController.java
  3. +1
    -1
      mallinkService/src/main/java/com/iformall/domain/po/TtPoiTakeRate.java
  4. +5
    -0
      mallinkService/src/main/java/com/iformall/service/TtGoodsCategoryService.java
  5. +79
    -60
      mallinkService/src/main/java/com/iformall/service/impl/TtCouponGoodsServiceImpl.java
  6. +13
    -0
      mallinkService/src/main/java/com/iformall/service/impl/TtGoodsCategoryServiceImpl.java

+ 14
- 1
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);


+ 34
- 35
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<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之间");
}



+ 1
- 1
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")


+ 5
- 0
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<GoodsCategory> categoryGet(Integer categoryId);
}

+ 79
- 60
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<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) {


+ 13
- 0
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<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


Загрузка…
Отмена
Сохранить