jyy
2021-04-06 f9bb41486c8c9b89c762d5ccff850e4c23a2caa8
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,65 @@
    }
    /**
     * 根据固定等级规则新增用户积分
     */
    @Transactional(rollbackFor = Exception.class)
    public void addScoreByParamSetting(Long vipId, Long oprationUserId, Long shopId, Integer firstScore, Long businessId, int type, String remark, BusParameterSettings parameterSetting) {
        SysVipInfo vipInfo = sysVipInfoDao.selectById(vipId);
        //添加自己的积分
        if (firstScore > 0) {
            addScore(
                    vipInfo.getId(),
                    oprationUserId,
                    shopId,
                    firstScore,
                    businessId,
                    type,
                    remark
            );
        }
        if (StringUtils.isNotBlank(parameterSetting.getParamValue())
                && vipInfo.getRecommendId() != null) {
            //推荐注册老带新积分奖励
            SysVipInfo referrerVip = sysVipInfoDao.selectById(vipInfo.getRecommendId());
            Integer secondScore = new Integer(parameterSetting.getParamValue());
            if (secondScore > 0) {
                addScore(
                        referrerVip.getId(),
                        oprationUserId,
                        shopId,
                        secondScore,
                        businessId,
                        type,
                        remark
                );
            }
            //推荐注册二级带新积分奖励
            if (StringUtils.isNotBlank(parameterSetting.getParamValue1())
                    && referrerVip.getRecommendId() != null) {
                Integer threeScore = new Integer(parameterSetting.getParamValue());
                if (threeScore > 0) {
                    addScore(
                            referrerVip.getRecommendId(),
                            oprationUserId,
                            shopId,
                            threeScore,
                            businessId,
                            type,
                            remark
                    );
                }
            }
        }
    }
    /**
     * 退积分
     */
    public void refundScore(Long vipId, Integer score, Long oldBusinessId, int type){