feat(transaction): 新增查询未创建分账规则的商品分类接口
This commit is contained in:
parent
296c852bdd
commit
3a973e9fe3
@ -3,6 +3,7 @@ package com.wzj.soopin.transaction.controller;
|
||||
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.wzj.soopin.goods.domain.vo.ProductCategoryVO;
|
||||
import com.wzj.soopin.transaction.convert.DivideRuleConvert;
|
||||
import com.wzj.soopin.transaction.domain.bo.DivideRuleBO;
|
||||
import com.wzj.soopin.transaction.domain.po.DivideRule;
|
||||
@ -16,6 +17,8 @@ import org.dromara.common.log.annotation.Log;
|
||||
import org.dromara.common.log.enums.BusinessType;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 用户封禁
|
||||
*/
|
||||
@ -75,4 +78,11 @@ public class DivideRuleController {
|
||||
public R<Boolean> remove(@PathVariable Long id) {
|
||||
return R.ok(service.removeById(id));
|
||||
}
|
||||
|
||||
|
||||
@Operation(summary = "获取还未创建规则的商品分类")
|
||||
@GetMapping("/productCategoryWithNoRule")
|
||||
public R<List<ProductCategoryVO>> productCategoryWithNoRule() {
|
||||
return R.ok(service.productCategoryWithNoRule());
|
||||
}
|
||||
}
|
||||
|
@ -2,6 +2,7 @@ package com.wzj.soopin.transaction.mapper;
|
||||
|
||||
import com.wzj.soopin.transaction.domain.po.DivideRuleDetail;
|
||||
import com.wzj.soopin.transaction.domain.vo.DivideRuleDetailVO;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
import org.dromara.common.mybatis.core.mapper.BaseMapperPlus;
|
||||
|
||||
/**
|
||||
@ -9,6 +10,7 @@ import org.dromara.common.mybatis.core.mapper.BaseMapperPlus;
|
||||
*
|
||||
* @author zcc
|
||||
*/
|
||||
@Mapper
|
||||
public interface DivideRuleDetailMapper extends BaseMapperPlus<DivideRuleDetail, DivideRuleDetailVO> {
|
||||
|
||||
}
|
||||
|
@ -1,6 +1,7 @@
|
||||
package com.wzj.soopin.transaction.service;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
import com.wzj.soopin.goods.domain.vo.ProductCategoryVO;
|
||||
import com.wzj.soopin.transaction.domain.bo.DivideRuleBO;
|
||||
import com.wzj.soopin.transaction.domain.po.DivideRule;
|
||||
import com.wzj.soopin.transaction.domain.po.DivideRuleDetail;
|
||||
@ -22,5 +23,11 @@ public interface IDivideRuleService extends IService<DivideRule> {
|
||||
|
||||
void checkRule(List<DivideRuleDetail> details);
|
||||
|
||||
/**
|
||||
* 查询还未创建分账规则的商品分类
|
||||
* @return
|
||||
*/
|
||||
List<ProductCategoryVO> productCategoryWithNoRule();
|
||||
|
||||
|
||||
}
|
||||
|
@ -1,9 +1,13 @@
|
||||
package com.wzj.soopin.transaction.service.impl;
|
||||
|
||||
import cn.hutool.core.bean.BeanUtil;
|
||||
import cn.hutool.core.collection.CollUtil;
|
||||
import cn.hutool.core.lang.Assert;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.wzj.soopin.goods.domain.entity.ProductCategory;
|
||||
import com.wzj.soopin.goods.domain.vo.ProductCategoryVO;
|
||||
import com.wzj.soopin.goods.service.ProductCategoryService;
|
||||
import com.wzj.soopin.transaction.convert.DivideRuleConvert;
|
||||
import com.wzj.soopin.transaction.convert.DivideRuleDetailConvert;
|
||||
import com.wzj.soopin.transaction.domain.bo.DivideRuleBO;
|
||||
@ -43,6 +47,8 @@ public class DivideRuleServiceImpl extends ServiceImpl<DivideRuleMapper, DivideR
|
||||
|
||||
private final DivideRuleConvert convert;
|
||||
|
||||
private final ProductCategoryService productCategoryService;
|
||||
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
@Override
|
||||
public boolean save(DivideRuleBO bo) {
|
||||
@ -152,4 +158,14 @@ public class DivideRuleServiceImpl extends ServiceImpl<DivideRuleMapper, DivideR
|
||||
Assert.isTrue(totalMoneyRatio == 100L, () -> new ServiceException("金额分账比例之和未等于100%"));
|
||||
Assert.isTrue(totalFeeRatio == 100L, () -> new ServiceException("手续费分账比例之和未等于100%"));
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<ProductCategoryVO> productCategoryWithNoRule() {
|
||||
List<DivideRule> existRule = this.list();
|
||||
List<ProductCategory> allProductCategories = productCategoryService.list();
|
||||
List<Integer> existTypes = existRule.stream().map(item -> item.getType()).toList();
|
||||
return allProductCategories.stream().filter(item -> item.getParentId() != 0)
|
||||
.filter(item -> !CollUtil.contains(existTypes, item.getId()))
|
||||
.map(item -> BeanUtil.copyProperties(item, ProductCategoryVO.class)).toList();
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user