Просмотр исходного кода

//goodsc

release_toaliyun_real
xhxu 3 лет назад
Родитель
Сommit
e780757ad0
7 измененных файлов: 105 добавлений и 26 удалений
  1. +36
    -10
      mallinkAdmin/src/main/java/com/iformall/controller/basic/TtGoodsCategoryController.java
  2. +4
    -0
      mallinkAdmin/src/main/resources/db/migration/V2023022000001__add_tt_goods_category.sql
  3. +3
    -0
      mallinkService/src/main/java/com/iformall/domain/po/TtGoodsCategory.java
  4. +2
    -0
      mallinkService/src/main/java/com/iformall/mapper/TtGoodsCategoryMapper.java
  5. +2
    -0
      mallinkService/src/main/java/com/iformall/service/TtGoodsCategoryService.java
  6. +46
    -15
      mallinkService/src/main/java/com/iformall/service/impl/TtGoodsCategoryServiceImpl.java
  7. +12
    -1
      mallinkService/src/main/resources/mapper/TtGoodsCategoryMapper.xml

+ 36
- 10
mallinkAdmin/src/main/java/com/iformall/controller/basic/TtGoodsCategoryController.java Просмотреть файл

@@ -6,6 +6,7 @@ import com.iformall.annotation.TenantIgnore;
import com.iformall.common.ErrorCode; import com.iformall.common.ErrorCode;
import com.iformall.common.ResultData; import com.iformall.common.ResultData;
import com.iformall.controller.base.BaseController; import com.iformall.controller.base.BaseController;
import com.iformall.domain.po.TtGoodsCategory;
import com.iformall.service.TtGoodsCategoryService; import com.iformall.service.TtGoodsCategoryService;
import com.iformall.utils.DateUtils; import com.iformall.utils.DateUtils;
import io.swagger.annotations.ApiImplicitParams; import io.swagger.annotations.ApiImplicitParams;
@@ -52,20 +53,45 @@ public class TtGoodsCategoryController extends BaseController {
} }


@TenantIgnore @TenantIgnore
@ApiOperation("查询抖音类目")
@GetMapping("syncGet/{token}")
@ApiOperation("同步抖音类目")
@GetMapping("syncGetTt")
@ApiImplicitParams({}) @ApiImplicitParams({})
@SystemControllerLog(description = "列表")
public ResultData syncGet(@PathVariable String token) {
logger.debug("[" + getIpAddr() + "] TtMerchantPoiController::get");
if(StringUtils.isBlank(token)){
@SystemControllerLog(description = "同步")
public ResultData syncGetTt() {
logger.debug("[" + getIpAddr() + "] TtMerchantPoiController::syncGetTt");
ttGoodsCategoryService.syncGet();
return new ResultData();
}

@TenantIgnore
@ApiOperation("设置抖音软件服务费率")
@PostMapping("setServiceFee")
@ApiImplicitParams({})
@SystemControllerLog(description = "修改")
public ResultData setServiceFee(@RequestBody TtGoodsCategory record) {
logger.debug("[" + getIpAddr() + "] TtMerchantPoiController::setServiceFee");
if(record.getId() == null || record.getServiceFee() == null){
return new ResultData(ErrorCode.SYS_PARAMETER_NOT_NULL); return new ResultData(ErrorCode.SYS_PARAMETER_NOT_NULL);
} }
String systemTime = DateUtils.getSystemTime("MMdd")+"syncgc";
if(!systemTime.equals(token)){
return new ResultData(ErrorCode.SYS_SERVER_ERROR);
record.setSoftwareFee(null);

ttGoodsCategoryService.updateFee(record);
return new ResultData();
}

@TenantIgnore
@ApiOperation("设置软件服务费")
@PostMapping("setSoftwareFee")
@ApiImplicitParams({})
@SystemControllerLog(description = "修改")
public ResultData setSoftwareFee(@RequestBody TtGoodsCategory record) {
logger.debug("[" + getIpAddr() + "] TtMerchantPoiController::setSoftwareFee");
if(record.getId() == null || record.getSoftwareFee() == null){
return new ResultData(ErrorCode.SYS_PARAMETER_NOT_NULL);
} }
ttGoodsCategoryService.syncGet();
record.setServiceFee(null);

ttGoodsCategoryService.updateFee(record);
return new ResultData(); return new ResultData();
} }




+ 4
- 0
mallinkAdmin/src/main/resources/db/migration/V2023022000001__add_tt_goods_category.sql Просмотреть файл

@@ -0,0 +1,4 @@
ALTER TABLE `mallink`.`tt_goods_category`
MODIFY COLUMN `service_fee` int(11) DEFAULT NULL COMMENT ''抖音软件服务费率(万分之)'' AFTER `is_leaf`,
ADD COLUMN `software_fee` int(11) COMMENT ''软件服务费率(万分位)'' AFTER `service_fee`;


+ 3
- 0
mallinkService/src/main/java/com/iformall/domain/po/TtGoodsCategory.java Просмотреть файл

@@ -34,6 +34,9 @@ public class TtGoodsCategory extends BaseEntity {
@io.swagger.annotations.ApiModelProperty(value="",name="serviceFee") @io.swagger.annotations.ApiModelProperty(value="",name="serviceFee")
private Integer serviceFee; private Integer serviceFee;


@io.swagger.annotations.ApiModelProperty(value="",name="softwareFee")
private Integer softwareFee;

@io.swagger.annotations.ApiModelProperty(value="创建时间",name="createDate") @io.swagger.annotations.ApiModelProperty(value="创建时间",name="createDate")
private Date createDate; private Date createDate;
@io.swagger.annotations.ApiModelProperty(value="更新时间",name="updateDate") @io.swagger.annotations.ApiModelProperty(value="更新时间",name="updateDate")


+ 2
- 0
mallinkService/src/main/java/com/iformall/mapper/TtGoodsCategoryMapper.java Просмотреть файл

@@ -13,4 +13,6 @@ public interface TtGoodsCategoryMapper extends CommonMapper<TtGoodsCategory, Str
List<Integer> findIdAll(TtGoodsCategory record); List<Integer> findIdAll(TtGoodsCategory record);


int updDelByIds(TtGoodsCategory record); int updDelByIds(TtGoodsCategory record);

int updateByFreeIds(TtGoodsCategory updgc);
} }

+ 2
- 0
mallinkService/src/main/java/com/iformall/service/TtGoodsCategoryService.java Просмотреть файл

@@ -1,6 +1,7 @@
package com.iformall.service; package com.iformall.service;


import com.iformall.common.ErrorCode; import com.iformall.common.ErrorCode;
import com.iformall.common.ResultData;
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.GoodsCategory;
@@ -44,4 +45,5 @@ public interface TtGoodsCategoryService {


List<GoodsCategory> categoryGet(Integer categoryId); List<GoodsCategory> categoryGet(Integer categoryId);


void updateFee(TtGoodsCategory record);
} }

+ 46
- 15
mallinkService/src/main/java/com/iformall/service/impl/TtGoodsCategoryServiceImpl.java Просмотреть файл

@@ -3,6 +3,8 @@ package com.iformall.service.impl;
import com.alibaba.fastjson.JSONArray; import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject; import com.alibaba.fastjson.JSONObject;
import com.github.binarywang.wxpay.bean.bank.BankingResult; import com.github.binarywang.wxpay.bean.bank.BankingResult;
import com.iformall.common.ErrorCode;
import com.iformall.common.ResultData;
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.domain.po.base.BaseEntity; import com.iformall.domain.po.base.BaseEntity;
@@ -477,11 +479,11 @@ public class TtGoodsCategoryServiceImpl implements TtGoodsCategoryService {
} }
} }


@Async
// @Async
@Override @Override
public void syncGet() { public void syncGet() {
TtWebService ttWebService = ttMerchantPoiService.getTtWebService(null); TtWebService ttWebService = ttMerchantPoiService.getTtWebService(null);
handSyncCategory(ttWebService,0,null,new Date());
handSyncCategory(ttWebService,0,new Date());
} }


@Override @Override
@@ -504,13 +506,24 @@ public class TtGoodsCategoryServiceImpl implements TtGoodsCategoryService {
} }
} }


@Override
public void updateFee(TtGoodsCategory record) {
List<Integer> ids = new ArrayList<>();
if(record.getId() != null){
ids.add(record.getId());
}
if(!ids.isEmpty()){
updateFeeByIds(ids,record.getServiceFee(),record.getSoftwareFee(),new Date());
}
}

/** /**
* 循环同步类目 * 循环同步类目
* @param ttWebService * @param ttWebService
* @param category_id * @param category_id
* @param now * @param now
*/ */
private void handSyncCategory(TtWebService ttWebService,Integer category_id,EnumGoodsCategoryRate categoryRate,Date now){
private void handSyncCategory(TtWebService ttWebService,Integer category_id,Date now){
try { try {
List<GoodsCategory> goodsCategories = ttWebService.getGoodsService().categoryGet(category_id, null); List<GoodsCategory> goodsCategories = ttWebService.getGoodsService().categoryGet(category_id, null);
if(goodsCategories != null){ if(goodsCategories != null){
@@ -518,12 +531,6 @@ public class TtGoodsCategoryServiceImpl implements TtGoodsCategoryService {
record.setParentId(category_id); record.setParentId(category_id);
List<Integer> listAll = ttGoodsCategoryMapper.findIdAll(record); List<Integer> listAll = ttGoodsCategoryMapper.findIdAll(record);
for (GoodsCategory gc:goodsCategories) { for (GoodsCategory gc:goodsCategories) {
if(category_id.intValue() == 0){
categoryRate = EnumGoodsCategoryRate.getEnum(gc.getCategoryId());
if(categoryRate == null){
categoryRate = EnumGoodsCategoryRate.OTHER;
}
}


TtGoodsCategory updgc = new TtGoodsCategory(); TtGoodsCategory updgc = new TtGoodsCategory();
updgc.setId(gc.getCategoryId()); updgc.setId(gc.getCategoryId());
@@ -532,7 +539,6 @@ public class TtGoodsCategoryServiceImpl implements TtGoodsCategoryService {
updgc.setParentId(gc.getParentId()); updgc.setParentId(gc.getParentId());
updgc.setEnable(gc.getEnable()?EnumYesOrNo.YES.getCode():EnumYesOrNo.NO.getCode()); updgc.setEnable(gc.getEnable()?EnumYesOrNo.YES.getCode():EnumYesOrNo.NO.getCode());
updgc.setIsLeaf(gc.getEnable()?EnumYesOrNo.YES.getCode():EnumYesOrNo.NO.getCode()); updgc.setIsLeaf(gc.getEnable()?EnumYesOrNo.YES.getCode():EnumYesOrNo.NO.getCode());
updgc.setServiceFee(categoryRate.getRate());
updgc.setIsDel(EnumYesOrNo.NO.getCode()); updgc.setIsDel(EnumYesOrNo.NO.getCode());
updgc.setUpdateDate(now); updgc.setUpdateDate(now);
if(listAll.contains(gc.getCategoryId())){ if(listAll.contains(gc.getCategoryId())){
@@ -543,7 +549,7 @@ public class TtGoodsCategoryServiceImpl implements TtGoodsCategoryService {
ttGoodsCategoryMapper.insert(updgc); ttGoodsCategoryMapper.insert(updgc);
} }
if(!gc.getIsLeaf()){ if(!gc.getIsLeaf()){
handSyncCategory(ttWebService,gc.getCategoryId(),categoryRate,now);
handSyncCategory(ttWebService,gc.getCategoryId(),now);
} }
} }
updateDelByIds(listAll,now); updateDelByIds(listAll,now);
@@ -551,10 +557,12 @@ public class TtGoodsCategoryServiceImpl implements TtGoodsCategoryService {
} catch (WxErrorException e) { } catch (WxErrorException e) {
e.printStackTrace(); e.printStackTrace();
logger.error("同步商品类目失败"+e.getMessage()); logger.error("同步商品类目失败"+e.getMessage());
throw new MallinkException(ErrorCode.SYS_SERVER_ERROR);
} }
catch (Exception e) { catch (Exception e) {
e.printStackTrace(); e.printStackTrace();
logger.error("同步商品类目失败"+e.getMessage()); logger.error("同步商品类目失败"+e.getMessage());
throw new MallinkException(ErrorCode.SYS_SERVER_ERROR);
} }


} }
@@ -573,10 +581,33 @@ public class TtGoodsCategoryServiceImpl implements TtGoodsCategoryService {
delgc.setIsDel(EnumYesOrNo.YES.getCode()); delgc.setIsDel(EnumYesOrNo.YES.getCode());
delgc.setUpdateDate(now); delgc.setUpdateDate(now);
int i = ttGoodsCategoryMapper.updDelByIds(delgc); int i = ttGoodsCategoryMapper.updDelByIds(delgc);
TtGoodsCategory gcq = new TtGoodsCategory();
gcq.setParentIds(ids);
List<Integer> idAll = ttGoodsCategoryMapper.findIdAll(gcq);
updateDelByIds(idAll,now);
if(i > 0){
TtGoodsCategory gcq = new TtGoodsCategory();
gcq.setParentIds(ids);
List<Integer> idAll = ttGoodsCategoryMapper.findIdAll(gcq);
updateDelByIds(idAll,now);
}
}

/**
* 循环修改费率
*/
private void updateFeeByIds(List<Integer> ids,Integer serviceFee,Integer softwareFee,Date now){
if(ids == null || ids.size() <= 0){
return;
}
TtGoodsCategory updgc = new TtGoodsCategory();
updgc.setCategoryIds(ids);
updgc.setServiceFee(serviceFee);
updgc.setSoftwareFee(softwareFee);
updgc.setUpdateDate(now);
int i = ttGoodsCategoryMapper.updateByFreeIds(updgc);
if(i > 0){
TtGoodsCategory gcq = new TtGoodsCategory();
gcq.setParentIds(ids);
List<Integer> idAll = ttGoodsCategoryMapper.findIdAll(gcq);
updateFeeByIds(idAll,serviceFee,softwareFee,now);
}
} }


} }

+ 12
- 1
mallinkService/src/main/resources/mapper/TtGoodsCategoryMapper.xml Просмотреть файл

@@ -9,10 +9,11 @@
<result column="enable" jdbcType="INTEGER" property="enable" /> <result column="enable" jdbcType="INTEGER" property="enable" />
<result column="is_leaf" jdbcType="INTEGER" property="isLeaf" /> <result column="is_leaf" jdbcType="INTEGER" property="isLeaf" />
<result column="service_fee" jdbcType="INTEGER" property="serviceFee" /> <result column="service_fee" jdbcType="INTEGER" property="serviceFee" />
<result column="software_fee" jdbcType="INTEGER" property="softwareFee" />
</resultMap> </resultMap>
<sql id="allColumns"> <sql id="allColumns">
`id`,`level`,`name`,`parent_id`,`enable`,`is_leaf`,`service_fee`
`id`,`level`,`name`,`parent_id`,`enable`,`is_leaf`,`service_fee`,`software_fee`
</sql> </sql>


<sql id="dynamicWhereConditions"> <sql id="dynamicWhereConditions">
@@ -80,4 +81,14 @@
</foreach> </foreach>
</update> </update>


<update id="updateByFreeIds" parameterType="com.iformall.domain.po.TtGoodsCategory">
update tt_goods_category set update_date = #{updateDate}
<if test=" null != serviceFee ">,`service_fee` = #{serviceFee}</if>
<if test=" null != softwareFee ">,`software_fee` = #{softwareFee}</if>
where id in
<foreach collection="categoryIds" index="index" item="idItem" open="(" separator="," close=")">
#{idItem}
</foreach>
</update>

</mapper> </mapper>

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