| @@ -2,3 +2,14 @@ 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`; | |||
| DROP TABLE IF EXISTS `tt_mall_goods_category`; | |||
| CREATE TABLE `tt_mall_goods_category` ( | |||
| `goods_category_id` int(11) NOT NULL, | |||
| `tenant_id` varchar(5) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL COMMENT '租户ID', | |||
| `parent_tenant_id` varchar(5) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT '父租户ID', | |||
| `software_fee` int(11) DEFAULT NULL COMMENT '软件服务费率(万分位)', | |||
| `create_date` datetime(0) DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间', | |||
| `update_date` datetime(0) DEFAULT CURRENT_TIMESTAMP COMMENT '更新时间', | |||
| `is_del` tinyint(1) NOT NULL DEFAULT 0 COMMENT '是否删除1是0否', | |||
| UNIQUE INDEX `goods_category_id`(`goods_category_id`, `tenant_id`) USING BTREE | |||
| ) ENGINE = InnoDB CHARACTER SET = utf8mb4 COLLATE = utf8mb4_unicode_ci ROW_FORMAT = Dynamic; | |||
| @@ -12,6 +12,12 @@ public interface TtMallGoodsCategoryMapper extends CommonMapper<TtMallGoodsCateg | |||
| List<TtMallGoodsCategoryVo> findAllTreeList(TtMallGoodsCategoryVo recordVo); | |||
| TtMallGoodsCategory selectByTenantAndCategoryId(TtMallGoodsCategory mallGoodsCategory); | |||
| int updateByTenantAndCategoryId(TtMallGoodsCategory old); | |||
| int insertList(List<TtMallGoodsCategory> childList); | |||
| List<TtMallGoodsCategory> findList(TtMallGoodsCategory record); | |||
| @@ -22,4 +28,5 @@ public interface TtMallGoodsCategoryMapper extends CommonMapper<TtMallGoodsCateg | |||
| int updateFeeByIds(TtMallGoodsCategory record); | |||
| } | |||
| @@ -31,6 +31,7 @@ import org.springframework.beans.factory.annotation.Qualifier; | |||
| import org.springframework.data.redis.core.RedisTemplate; | |||
| import org.springframework.scheduling.annotation.Async; | |||
| import org.springframework.stereotype.Service; | |||
| import org.springframework.transaction.annotation.Transactional; | |||
| import java.util.ArrayList; | |||
| import java.util.Date; | |||
| @@ -512,6 +513,7 @@ public class TtGoodsCategoryServiceImpl implements TtGoodsCategoryService { | |||
| } | |||
| // @Async | |||
| @Transactional(rollbackFor = {Exception.class}) | |||
| @Override | |||
| public void syncGet() { | |||
| TtWebService ttWebService = ttMerchantPoiService.getTtWebService(null); | |||
| @@ -538,6 +540,7 @@ public class TtGoodsCategoryServiceImpl implements TtGoodsCategoryService { | |||
| } | |||
| } | |||
| @Transactional(rollbackFor = {Exception.class}) | |||
| @Override | |||
| public void updateFee(TtGoodsCategory record) { | |||
| List<Integer> ids = new ArrayList<>(); | |||
| @@ -17,8 +17,10 @@ import org.springframework.beans.factory.annotation.Autowired; | |||
| import org.springframework.beans.factory.annotation.Qualifier; | |||
| import org.springframework.data.redis.core.RedisTemplate; | |||
| import org.springframework.stereotype.Service; | |||
| import org.springframework.transaction.annotation.Transactional; | |||
| import java.util.ArrayList; | |||
| import java.util.Date; | |||
| import java.util.List; | |||
| import java.util.stream.Collectors; | |||
| @@ -29,6 +31,9 @@ public class TtMallGoodsCategoryServiceImpl implements TtMallGoodsCategoryServic | |||
| @Autowired | |||
| TtMallGoodsCategoryMapper ttMallGoodsCategoryMapper; | |||
| @Autowired | |||
| TtGoodsCategoryMapper ttGoodsCategoryMapper; | |||
| @Autowired | |||
| @Qualifier("objectCommonRedisTemplate") | |||
| RedisTemplate<String, Object> categoryRedisTemplate; | |||
| @@ -74,13 +79,65 @@ public class TtMallGoodsCategoryServiceImpl implements TtMallGoodsCategoryServic | |||
| return childList; | |||
| } | |||
| @Transactional(rollbackFor = {Exception.class}) | |||
| @Override | |||
| public void updateFee(TtMallGoodsCategoryVo record) { | |||
| TtMallGoodsCategory mgcUpd = new TtMallGoodsCategory(); | |||
| mgcUpd.setGoodsCategoryId(record.getCategoryId()); | |||
| mgcUpd.updateTenantInfo(record); | |||
| // ttMallGoodsCategoryMapper.selectByTenantAnd(); | |||
| updateFeeByIds(record,record.getCategoryId(),record.getMallSoftwareFee(),new Date()); | |||
| } | |||
| /** | |||
| * 循环修改费率 | |||
| */ | |||
| private void updateFeeByIds(TenantEntity tenantEntity,Integer categoryId,Integer softwareFee,Date now){ | |||
| if(categoryId == null){ | |||
| return; | |||
| } | |||
| TtMallGoodsCategory mallGoodsCategory = new TtMallGoodsCategory(); | |||
| mallGoodsCategory.setGoodsCategoryId(categoryId); | |||
| mallGoodsCategory.updateTenantInfo(tenantEntity); | |||
| TtMallGoodsCategory old = ttMallGoodsCategoryMapper.selectByTenantAndCategoryId(mallGoodsCategory); | |||
| TtGoodsCategory gcq = new TtGoodsCategory(); | |||
| gcq.setParentId(categoryId); | |||
| List<Integer> childIds = ttGoodsCategoryMapper.findIdAll(gcq); | |||
| if(old != null){ | |||
| if(!softwareFee.equals(old.getSoftwareFee())){ | |||
| old.setSoftwareFee(softwareFee); | |||
| old.setUpdateDate(now); | |||
| ttMallGoodsCategoryMapper.updateByTenantAndCategoryId(old); | |||
| } | |||
| if(childIds != null && !childIds.isEmpty()){ | |||
| old.setGoodsCategoryId(null); | |||
| old.setCategoryIds(childIds); | |||
| ttMallGoodsCategoryMapper.updateByTenantAndCategoryId(old); | |||
| } | |||
| }else{ | |||
| old = new TtMallGoodsCategory(); | |||
| old.setGoodsCategoryId(categoryId); | |||
| old.updateTenantInfo(tenantEntity); | |||
| old.setSoftwareFee(softwareFee); | |||
| old.setCreateDate(now); | |||
| old.setUpdateDate(now); | |||
| ttMallGoodsCategoryMapper.insert(old); | |||
| if(childIds != null && !childIds.isEmpty()){ | |||
| List<TtMallGoodsCategory> childList = new ArrayList<>(); | |||
| for (Integer childId:childIds) { | |||
| TtMallGoodsCategory child = new TtMallGoodsCategory(); | |||
| old.setGoodsCategoryId(childId); | |||
| old.updateTenantInfo(tenantEntity); | |||
| old.setSoftwareFee(softwareFee); | |||
| old.setCreateDate(now); | |||
| old.setUpdateDate(now); | |||
| childList.add(child); | |||
| } | |||
| ttMallGoodsCategoryMapper.insertList(childList); | |||
| } | |||
| } | |||
| if(childIds != null && !childIds.isEmpty()){ | |||
| for (Integer childId:childIds) { | |||
| updateFeeByIds(tenantEntity,childId,softwareFee,now); | |||
| } | |||
| } | |||
| } | |||
| } | |||
| @@ -44,6 +44,25 @@ | |||
| <include refid="dynamicWhereConditions" /> | |||
| </select> | |||
| <select id="selectByTenantAndCategoryId" parameterType="com.iformall.domain.po.TtMallGoodsCategory" resultMap="BaseResultMap"> | |||
| select <include refid="allColumns" /> from tt_mall_goods_category | |||
| where `tenant_id` = #{tenantId} and `goods_category_id` = #{goodsCategoryId} | |||
| </select> | |||
| <update id="updateByTenantAndCategoryId" parameterType="com.iformall.domain.po.TtMallGoodsCategory"> | |||
| update tt_mall_goods_category set `software_fee` = #{softwareFee}, update_date = #{updateDate} | |||
| where `tenant_id` = #{tenantId} | |||
| <if test=" null != goodsCategoryId "> | |||
| and `goods_category_id` = #{goodsCategoryId} | |||
| </if> | |||
| <if test=" null != categoryIds "> | |||
| and goods_category_id in | |||
| <foreach collection="categoryIds" index="index" item="idItem" open="(" separator="," close=")"> | |||
| #{idItem} | |||
| </foreach> | |||
| </if> | |||
| </update> | |||
| <select id="findIdAll" parameterType="com.iformall.domain.po.TtMallGoodsCategory" resultType="Integer"> | |||
| select id from tt_mall_goods_category | |||
| <include refid="dynamicWhereConditions" /> | |||
| @@ -68,6 +87,8 @@ | |||
| <resultMap id="BaseResultMapVo" type="com.iformall.domain.vo.TtMallGoodsCategoryVo"> | |||
| <result column="id" jdbcType="INTEGER" property="goodsCategoryId" /> | |||
| <result column="level" jdbcType="INTEGER" property="level" /> | |||