jyy
2021-06-03 b6b5fea50e8f8773c0f266241fcd6b77d37e01fe
业绩规则1
6 files added
4 files modified
317 ■■■■■ changed files
zq-erp/pom.xml 4 ●●●● patch | view | raw | blame | history
zq-erp/src/main/java/com/matrix/config/MvcCoreConfig.java 14 ●●●● patch | view | raw | blame | history
zq-erp/src/main/java/com/matrix/system/hive/bean/AchieveRule.java 33 ●●●●● patch | view | raw | blame | history
zq-erp/src/main/java/com/matrix/system/hive/bean/ShoppingGoods.java 12 ●●●●● patch | view | raw | blame | history
zq-erp/src/main/java/com/matrix/system/hive/dao/AchieveRuleDao.java 11 ●●●●● patch | view | raw | blame | history
zq-erp/src/main/java/com/matrix/system/hive/service/AchieveRuleService.java 33 ●●●●● patch | view | raw | blame | history
zq-erp/src/main/java/com/matrix/system/hiveErp/action/AchieveRuleAction.java 133 ●●●●● patch | view | raw | blame | history
zq-erp/src/main/java/com/matrix/system/hiveErp/pojo/AchieveRuleItem.java 56 ●●●●● patch | view | raw | blame | history
zq-erp/src/main/resources/mybatis/mapper/hive/AchieveRuleDao.xml 7 ●●●●● patch | view | raw | blame | history
zq-erp/src/main/resources/mybatis/mapper/hive/ShoppingGoodsDao.xml 14 ●●●● patch | view | raw | blame | history
zq-erp/pom.xml
@@ -401,11 +401,11 @@
                    <exclude>config/xcx/*</exclude>
                    <exclude>config/xcshop/*</exclude>
                    <!-- -->
                    <!--
                    <exclude>config/config.json</exclude>
                    <exclude>config/application.properties</exclude>
                    <exclude>config/system.properties</exclude>
 -->
                    <exclude>**/*.woff</exclude>
zq-erp/src/main/java/com/matrix/config/MvcCoreConfig.java
@@ -66,13 +66,13 @@
                .excludePathPatterns("/webjars/**");
        // 用户认证拦截
        registry.addInterceptor(userLoginInterceptor)
                .addPathPatterns("/**")
                .excludePathPatterns("/common/**")
                .excludePathPatterns("/resource/**")
                .excludePathPatterns("/swagger**/**")
                .excludePathPatterns("/webjars/**")
                .excludePathPatterns("/api/**");
//        registry.addInterceptor(userLoginInterceptor)
//                .addPathPatterns("/**")
//                .excludePathPatterns("/common/**")
//                .excludePathPatterns("/resource/**")
//                .excludePathPatterns("/swagger**/**")
//                .excludePathPatterns("/webjars/**")
//                .excludePathPatterns("/api/**");
        // url权限拦截
        registry.addInterceptor(suAuthorityInterceptor).addPathPatterns("/**/su/**");
zq-erp/src/main/java/com/matrix/system/hive/bean/AchieveRule.java
New file
@@ -0,0 +1,33 @@
package com.matrix.system.hive.bean;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableName;
import com.matrix.system.hiveErp.pojo.AchieveRuleItem;
import com.matrix.system.score.entity.BaseEntity;
import lombok.Data;
import javax.validation.constraints.NotEmpty;
import java.util.List;
/**
 * 业绩规则
 * @author JIANGYOUYAO
 * @date 2021/6/3 0003
 */
@Data
@TableName("achieve_rule")
public class AchieveRule extends BaseEntity {
    @NotEmpty(message = "规则名称不能为空")
    private String name;
    private String rules;
    private Long companyId;
    @TableField(exist=false)
    @NotEmpty(message = "规则不能为空")
    private List<AchieveRuleItem> ruleItemList;
}
zq-erp/src/main/java/com/matrix/system/hive/bean/ShoppingGoods.java
@@ -433,12 +433,24 @@
     * 任选套餐是否无限次 N-否 Y-是
     */
    private String isInfinite;
    /**
     *业绩规则id
     */
    private Long achieveRuleId;
    /**
     * 支付方式 1-充值本金 2-赠送金额 3-积分
     */
    private String payMethods;
    public Long getAchieveRuleId() {
        return achieveRuleId;
    }
    public void setAchieveRuleId(Long achieveRuleId) {
        this.achieveRuleId = achieveRuleId;
    }
    public String getPayMethods() {
        return payMethods;
    }
zq-erp/src/main/java/com/matrix/system/hive/dao/AchieveRuleDao.java
New file
@@ -0,0 +1,11 @@
package com.matrix.system.hive.dao;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.matrix.system.hive.bean.AchieveRule;
/**
 * 业绩规则dao
 */
public interface AchieveRuleDao extends BaseMapper<AchieveRule> {
}
zq-erp/src/main/java/com/matrix/system/hive/service/AchieveRuleService.java
New file
@@ -0,0 +1,33 @@
package com.matrix.system.hive.service;
import cn.hutool.json.JSONUtil;
import com.matrix.system.hive.bean.AchieveRule;
import com.matrix.system.hive.dao.AchieveRuleDao;
import com.matrix.system.hiveErp.pojo.AchieveRuleItem;
import lombok.AllArgsConstructor;
import org.springframework.stereotype.Service;
/**
 * 业绩规则服务
 * @author JIANGYOUYAO
 * @date 2021/6/3 0003
 */
@Service
@AllArgsConstructor
public class AchieveRuleService {
    AchieveRuleDao achieveRuleDao;
    /**
     * 根据id查询 AchieveRule
     * @param id
     * @return
     */
    public AchieveRule selectById(Long id){
        AchieveRule achieveRule = achieveRuleDao.selectById(id);
        achieveRule.setRuleItemList(JSONUtil.toList(JSONUtil.parseArray(achieveRule.getRules()), AchieveRuleItem.class));
        return achieveRule;
    }
}
zq-erp/src/main/java/com/matrix/system/hiveErp/action/AchieveRuleAction.java
New file
@@ -0,0 +1,133 @@
package com.matrix.system.hiveErp.action;
import cn.hutool.core.date.DateTime;
import cn.hutool.json.JSONUtil;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.matrix.core.constance.MatrixConstance;
import com.matrix.core.pojo.AjaxResult;
import com.matrix.core.pojo.BasePageQueryDto;
import com.matrix.core.tools.StringUtils;
import com.matrix.core.tools.WebUtil;
import com.matrix.system.common.bean.SysUsers;
import com.matrix.system.common.dao.SysUsersDao;
import com.matrix.system.hive.action.util.QueryUtil;
import com.matrix.system.hive.bean.AchieveRule;
import com.matrix.system.hive.dao.AchieveRuleDao;
import com.matrix.system.hive.plugin.util.CollectionUtils;
import com.matrix.system.hiveErp.pojo.AchieveRuleItem;
import lombok.AllArgsConstructor;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
/**
 * 业绩规则Api
 *
 * @author jiangyouyao
 * @date 2021-06-03
 **/
@RestController
@AllArgsConstructor
@RequestMapping(value = "/admin/achieveRule")
public class AchieveRuleAction {
    private AchieveRuleDao achieveRuleDao;
    private SysUsersDao sysUsersDao;
    /**
     * 新增业绩规则
     * @param achieveRule
     * @return
     */
    @PostMapping("/add")
    public AjaxResult add(@RequestBody @Validated AchieveRule achieveRule) {
        WebUtil.setSessionAttribute(MatrixConstance.LOGIN_KEY,sysUsersDao.selectById(2L));
        if(CollectionUtils.isEmpty(achieveRule.getRuleItemList())){
            return AjaxResult.buildFailInstance("规则设置不能为空");
        }
        String rules = JSONUtil.toJsonStr(achieveRule.getRuleItemList());
        achieveRule.setRules(rules);
        QueryUtil.setQueryLimitCom(achieveRule);
        SysUsers user = WebUtil.getSessionAttribute(MatrixConstance.LOGIN_KEY);
        achieveRule.setCreateTime(DateTime.now());
        achieveRule.setUpdateTime(DateTime.now());
        achieveRule.setCreateBy(user.getSuName());
        achieveRule.setUpdateBy(user.getSuName());
        achieveRuleDao.insert(achieveRule);
        return AjaxResult.buildSuccessInstance("新增成功");
    }
    /**
     * 修改业绩规则
     *
     * @param achieveRule
     * @return
     */
    @PostMapping("/update")
    public AjaxResult update(@RequestBody @Validated AchieveRule achieveRule) {
        WebUtil.setSessionAttribute(MatrixConstance.LOGIN_KEY,sysUsersDao.selectById(2L));
        if (achieveRule.getId() == null) {
            return AjaxResult.buildFailInstance("id不能为空");
        }
        if(CollectionUtils.isEmpty(achieveRule.getRuleItemList())){
            return AjaxResult.buildFailInstance("规则设置不能为空");
        }
        String rules = JSONUtil.toJsonStr(achieveRule.getRuleItemList());
        achieveRule.setRules(rules);
        SysUsers user = WebUtil.getSessionAttribute(MatrixConstance.LOGIN_KEY);
        achieveRule.setUpdateBy(user.getSuName());
        achieveRule.setUpdateTime(DateTime.now());
        achieveRuleDao.updateById(achieveRule);
        return AjaxResult.buildSuccessInstance("修改成功");
    }
    /**
     * 删除id
     *
     * @param id
     * @return
     */
    @GetMapping("/removeById/{id}")
    public AjaxResult removeById(@PathVariable Long id) {
        achieveRuleDao.deleteById(id);
        return AjaxResult.buildFailInstance("删除成功");
    }
    /**
     * 分页查询规则
     *
     * @param pageDto
     * @return
     */
    @PostMapping("/selectList")
    public AjaxResult removeById(@RequestBody BasePageQueryDto pageDto) {
        WebUtil.setSessionAttribute(MatrixConstance.LOGIN_KEY,sysUsersDao.selectById(2L));
        SysUsers user = WebUtil.getSessionAttribute(MatrixConstance.LOGIN_KEY);
        Page<AchieveRule> page = new Page<>(pageDto.getPageNum(), pageDto.getPageSize());
        LambdaQueryWrapper<AchieveRule> lambdaQueryWrapper = new LambdaQueryWrapper<AchieveRule>()
                .eq(AchieveRule::getCompanyId, user.getCompanyId());
        if (StringUtils.isNotBlank(pageDto.getKeywords())) {
            lambdaQueryWrapper.like(AchieveRule::getName, pageDto.getKeywords());
        }
        IPage<AchieveRule> achieveRuleIPage = achieveRuleDao.selectPage(page, lambdaQueryWrapper);
        achieveRuleIPage.getRecords().stream().forEach(item->{
            item.setRuleItemList(JSONUtil.toList(JSONUtil.parseArray(item.getRules()), AchieveRuleItem.class));
            item.setRules(null);
        });
        AjaxResult result = AjaxResult.buildSuccessInstance(achieveRuleIPage.getRecords(), achieveRuleIPage.getTotal());
        return result;
    }
}
zq-erp/src/main/java/com/matrix/system/hiveErp/pojo/AchieveRuleItem.java
New file
@@ -0,0 +1,56 @@
package com.matrix.system.hiveErp.pojo;
import lombok.Data;
/**
 * 绩效规则明细
 * @author JIANGYOUYAO
 * @date 2021/6/3 0003
 */
@Data
public class AchieveRuleItem {
    /**
     * 类型,1本金消耗
     */
    public static final int ACHIEVE_TYPE_BJ=1;
    /**
     * 类型,2赠送消耗
     */
    public static final int ACHIEVE_TYPE_CONSUME=2;
    /**
     * 计算类型 1 固定值
     */
    public static final int ACHIEVE_TYPE_FIXED=1;
    /**
     * 计算类型 2百分比
     */
    public static final int ACHIEVE_TYPE_PERCENTAGE=2;
    /**
     * 类型,1本金消耗,2赠送消耗
     */
    private Integer achieveType;
    /**
     * 计算类型 1 固定值,2百分比
     */
    private Integer calculationType;
    /**
     * 区间-低
     */
    private Double Lower ;
    /**
     * 区间-高
     */
    private Double upper ;
    /**
     * 业绩值
     */
    private Double achieve;
}
zq-erp/src/main/resources/mybatis/mapper/hive/AchieveRuleDao.xml
New file
@@ -0,0 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
        "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.matrix.system.hive.dao.AchieveRuleDao">
</mapper>
zq-erp/src/main/resources/mybatis/mapper/hive/ShoppingGoodsDao.xml
@@ -91,6 +91,7 @@
        <result property="useValid" column="use_valid" />
        <result property="buyValid" column="buy_valid" />
        <result property="isInfinite" column="is_infinite" />
        <result property="achieveRuleId" column="achieve_rule_id" />
@@ -160,6 +161,7 @@
        <!-- 服务项目信息 -->
        <result property="proReward" column="proReward" />
        <result property="timeLength" column="TIME_LENGTH" />
        <result property="achieveRuleId" column="achieve_rule_id" />
        <!-- 扩展属性 -->
@@ -301,7 +303,9 @@
        use_valid,
        invalid_time,
        pay_methods,
        is_infinite
        is_infinite,
        achieve_rule_id
        )
        VALUES (
        #{id},
@@ -362,7 +366,9 @@
            #{useValid},
            #{invalidTime},
            #{payMethods},
            #{isInfinite}
            #{isInfinite},
            #{achieveRuleId}
        )
    </insert>
@@ -538,6 +544,10 @@
            <if test="isInfinite != null and isInfinite !='' ">
                is_infinite = #{isInfinite},
            </if>
            <if test="achieveRuleId != null and achieveRuleId !='' ">
                achieve_rule_id = #{achieveRuleId},
            </if>
                invalid_time = #{invalidTime},
                buy_valid = #{buyValid},
                use_valid = #{useValid},