|
@@ -4,8 +4,12 @@ import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
|
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
|
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
|
|
|
|
+import com.fuint.common.dto.CommissionRuleDto;
|
|
|
+import com.fuint.common.dto.CommissionRuleItemDto;
|
|
|
import com.fuint.common.param.CommissionRuleItemParam;
|
|
|
import com.fuint.common.param.CommissionRuleParam;
|
|
|
+import com.fuint.common.service.GoodsService;
|
|
|
+import com.fuint.common.service.SettingService;
|
|
|
import com.fuint.framework.annoation.OperationServiceLog;
|
|
|
import com.fuint.framework.exception.BusinessCheckException;
|
|
|
import com.fuint.framework.pagination.PaginationRequest;
|
|
@@ -17,6 +21,7 @@ import com.fuint.common.enums.StatusEnum;
|
|
|
|
|
|
import com.fuint.repository.model.MtCommissionRule;
|
|
|
import com.fuint.repository.model.MtCommissionRuleItem;
|
|
|
+import com.fuint.repository.model.MtGoods;
|
|
|
import com.fuint.utils.StringUtil;
|
|
|
import com.github.pagehelper.PageHelper;
|
|
|
import lombok.AllArgsConstructor;
|
|
@@ -47,6 +52,16 @@ public class CommissionRuleServiceImpl extends ServiceImpl<MtCommissionRuleMappe
|
|
|
|
|
|
private MtCommissionRuleItemMapper mtCommissionRuleItemMapper;
|
|
|
|
|
|
+ /**
|
|
|
+ * 商品服务接口
|
|
|
+ * */
|
|
|
+ private GoodsService goodsService;
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 系统设置服务接口
|
|
|
+ * */
|
|
|
+ private SettingService settingService;
|
|
|
+
|
|
|
/**
|
|
|
* 分页查询规则列表
|
|
|
*
|
|
@@ -114,10 +129,11 @@ public class CommissionRuleServiceImpl extends ServiceImpl<MtCommissionRuleMappe
|
|
|
mtCommissionRule.setCreateTime(date);
|
|
|
mtCommissionRule.setUpdateTime(date);
|
|
|
mtCommissionRule.setMerchantId(mtCommissionRule.getMerchantId()== null ? 0 : mtCommissionRule.getMerchantId());
|
|
|
+ String storeIds = StringUtil.join(commissionRule.getStoreIdList().toArray(), ",");
|
|
|
+ mtCommissionRule.setStoreIds(storeIds);
|
|
|
boolean result = save(mtCommissionRule);
|
|
|
if (result) {
|
|
|
if (commissionRule.getDetailList() != null && commissionRule.getDetailList().size() > 0) {
|
|
|
- String storeIds = StringUtil.join(commissionRule.getStoreIdList().toArray(), ",");
|
|
|
for (CommissionRuleItemParam itemParam : commissionRule.getDetailList()) {
|
|
|
MtCommissionRuleItem mtCommissionRuleItem = new MtCommissionRuleItem();
|
|
|
mtCommissionRuleItem.setRuleId(mtCommissionRule.getId());
|
|
@@ -149,10 +165,54 @@ public class CommissionRuleServiceImpl extends ServiceImpl<MtCommissionRuleMappe
|
|
|
* 根据ID获取规则信息
|
|
|
*
|
|
|
* @param id
|
|
|
+ * @return
|
|
|
*/
|
|
|
@Override
|
|
|
- public MtCommissionRule queryCommissionRuleById(Integer id) {
|
|
|
- return mtCommissionRuleMapper.selectById(id);
|
|
|
+ public CommissionRuleDto queryCommissionRuleById(Integer id) throws BusinessCheckException {
|
|
|
+ MtCommissionRule mtCommissionRule = mtCommissionRuleMapper.selectById(id);
|
|
|
+ if (mtCommissionRule == null) {
|
|
|
+ return null;
|
|
|
+ }
|
|
|
+ CommissionRuleDto commissionRuleDto = new CommissionRuleDto();
|
|
|
+ BeanUtils.copyProperties(mtCommissionRule, commissionRuleDto);
|
|
|
+
|
|
|
+ Map<String, Object> param = new HashMap();
|
|
|
+ param.put("RULE_ID", id);
|
|
|
+ param.put("STATUS", StatusEnum.ENABLED.getKey());
|
|
|
+ List<MtCommissionRuleItem> mtCommissionRuleItem = mtCommissionRuleItemMapper.selectByMap(param);
|
|
|
+ List<CommissionRuleItemDto> detailList = new ArrayList<>();
|
|
|
+ String basePath = settingService.getUploadBasePath();
|
|
|
+ if (mtCommissionRuleItem != null && mtCommissionRuleItem.size() > 0) {
|
|
|
+ for (MtCommissionRuleItem item : mtCommissionRuleItem) {
|
|
|
+ CommissionRuleItemDto commissionRuleItemDto = new CommissionRuleItemDto();
|
|
|
+ commissionRuleItemDto.setGoodsId(item.getTargetId());
|
|
|
+ MtGoods mtGoods = goodsService.queryGoodsById(item.getTargetId());
|
|
|
+ if (mtGoods != null) {
|
|
|
+ commissionRuleItemDto.setGoodsName(mtGoods.getName());
|
|
|
+ commissionRuleItemDto.setLogo(basePath + mtGoods.getLogo());
|
|
|
+ commissionRuleItemDto.setPrice(mtGoods.getPrice());
|
|
|
+ }
|
|
|
+ commissionRuleItemDto.setType(item.getType());
|
|
|
+ commissionRuleItemDto.setMemberVal(item.getMember());
|
|
|
+ commissionRuleItemDto.setMethod(item.getMethod());
|
|
|
+ commissionRuleItemDto.setVisitorVal(item.getGuest());
|
|
|
+ detailList.add(commissionRuleItemDto);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ commissionRuleDto.setDetailList(detailList);
|
|
|
+
|
|
|
+ List<Integer> storeIds = new ArrayList<>();
|
|
|
+ if (StringUtil.isNotEmpty(mtCommissionRule.getStoreIds())) {
|
|
|
+ List<String> storeIdList = Arrays.asList(mtCommissionRule.getStoreIds().split(","));
|
|
|
+ if (storeIdList != null && storeIdList.size() > 0) {
|
|
|
+ for (String storeId : storeIdList) {
|
|
|
+ storeIds.add(Integer.parseInt(storeId));
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ commissionRuleDto.setStoreIdList(storeIds);
|
|
|
+
|
|
|
+ return commissionRuleDto;
|
|
|
}
|
|
|
|
|
|
/**
|
|
@@ -165,7 +225,7 @@ public class CommissionRuleServiceImpl extends ServiceImpl<MtCommissionRuleMappe
|
|
|
@Transactional(rollbackFor = Exception.class)
|
|
|
@OperationServiceLog(description = "更新分销提成规则")
|
|
|
public MtCommissionRule updateCommissionRule(CommissionRuleParam commissionRule) throws BusinessCheckException {
|
|
|
- MtCommissionRule mtCommissionRule = queryCommissionRuleById(commissionRule.getId());
|
|
|
+ MtCommissionRule mtCommissionRule = mtCommissionRuleMapper.selectById(commissionRule.getId());
|
|
|
if (mtCommissionRule == null) {
|
|
|
logger.error("更新分销提成规则失败...");
|
|
|
throw new BusinessCheckException("该数据状态异常");
|
|
@@ -190,30 +250,4 @@ public class CommissionRuleServiceImpl extends ServiceImpl<MtCommissionRuleMappe
|
|
|
mtCommissionRuleMapper.updateById(mtCommissionRule);
|
|
|
return mtCommissionRule;
|
|
|
}
|
|
|
-
|
|
|
- @Override
|
|
|
- public List<MtCommissionRule> queryCommissionRuleByParams(Map<String, Object> params) {
|
|
|
- String status = params.get("status") == null ? StatusEnum.ENABLED.getKey(): params.get("status").toString();
|
|
|
- String storeId = params.get("storeId") == null ? "" : params.get("storeId").toString();
|
|
|
- String name = params.get("name") == null ? "" : params.get("name").toString();
|
|
|
-
|
|
|
- LambdaQueryWrapper<MtCommissionRule> lambdaQueryWrapper = Wrappers.lambdaQuery();
|
|
|
- if (StringUtils.isNotBlank(name)) {
|
|
|
- lambdaQueryWrapper.like(MtCommissionRule::getName, name);
|
|
|
- }
|
|
|
- if (StringUtils.isNotBlank(status)) {
|
|
|
- lambdaQueryWrapper.eq(MtCommissionRule::getStatus, status);
|
|
|
- }
|
|
|
- if (StringUtils.isNotBlank(storeId)) {
|
|
|
- lambdaQueryWrapper.and(wq -> wq
|
|
|
- .eq(MtCommissionRule::getStoreId, 0)
|
|
|
- .or()
|
|
|
- .eq(MtCommissionRule::getStoreId, storeId));
|
|
|
- }
|
|
|
-
|
|
|
- lambdaQueryWrapper.orderByAsc(MtCommissionRule::getId);
|
|
|
- List<MtCommissionRule> dataList = mtCommissionRuleMapper.selectList(lambdaQueryWrapper);
|
|
|
-
|
|
|
- return dataList;
|
|
|
- }
|
|
|
}
|