xiaoyong931011
2021-04-07 382c853bb36bc2521818058c788b6fdf48d7f684
zq-erp/src/main/java/com/matrix/system/score/service/ScoreVipDetailService.java
@@ -6,9 +6,11 @@
import com.matrix.core.constance.MatrixConstance;
import com.matrix.core.exception.GlobleException;
import com.matrix.core.tools.DateUtil;
import com.matrix.core.tools.StringUtils;
import com.matrix.system.common.bean.BusParameterSettings;
import com.matrix.system.common.dao.BusParameterSettingsDao;
import com.matrix.system.common.dao.SysUsersDao;
import com.matrix.system.hive.bean.SysVipInfo;
import com.matrix.system.hive.dao.SysVipInfoDao;
import com.matrix.system.score.constant.ScoreSettingConstant;
import com.matrix.system.score.dao.ScoreUseRecordDao;
@@ -86,8 +88,6 @@
                scoreVipDetailDao.updateById(scoreVipDetail);
                score=Math.abs(surplus);
            }
            //新增扣除记录
@@ -180,6 +180,67 @@
    }
    /**
     * 根据固定等级规则新增用户积分
     */
    @Transactional(rollbackFor = Exception.class)
    public void addScoreByParamSetting(Long vipId, Long oprationUserId, Long shopId, Long businessId, int type, String remark, BusParameterSettings parameterSetting) {
        if (parameterSetting != null) {
            SysVipInfo vipInfo = sysVipInfoDao.selectById(vipId);
            //添加自己的积分
            if (StringUtils.isNotBlank(parameterSetting.getParamValue())) {
                Integer firstScore = new Integer(parameterSetting.getParamValue());
                if (firstScore > 0) {
                    addScore(
                            vipInfo.getId(),
                            oprationUserId,
                            shopId,
                            firstScore,
                            businessId,
                            type,
                            remark
                    );
                }
            }
            if (StringUtils.isNotBlank(parameterSetting.getParamValue1())
                    && vipInfo.getRecommendId() != null) {
                //推荐注册老带新积分奖励
                SysVipInfo referrerVip = sysVipInfoDao.selectById(vipInfo.getRecommendId());
                Integer secondScore = new Integer(parameterSetting.getParamValue1());
                if (secondScore > 0) {
                    addScore(
                            referrerVip.getId(),
                            oprationUserId,
                            shopId,
                            secondScore,
                            businessId,
                            type,
                            remark
                    );
                }
                //推荐注册二级带新积分奖励
                if (StringUtils.isNotBlank(parameterSetting.getParamValue2())
                        && referrerVip.getRecommendId() != null) {
                    Integer threeScore = new Integer(parameterSetting.getParamValue2());
                    if (threeScore > 0) {
                        addScore(
                                referrerVip.getRecommendId(),
                                oprationUserId,
                                shopId,
                                threeScore,
                                businessId,
                                type,
                                remark
                        );
                    }
                }
            }
        }
    }
    /**
     * 退积分
     */
    public void refundScore(Long vipId, Integer score, Long oldBusinessId, int type){