Search in sources :

Example 1 with WriterPointRule

use of com.bc.pmpheep.back.po.WriterPointRule in project pmph by BCSquad.

the class WriterPointRuleServiceTest method getlistWriterPointRulePoint.

@SuppressWarnings({ "unused", "rawtypes", "unchecked" })
@Test
@Rollback(Const.ISROLLBACK)
public void getlistWriterPointRulePoint() {
    WriterPointRule writerPointRule = this.addWriterPointRulePoint();
    PageParameter pageParameter = new PageParameter<>();
    PageResult pageResult = new PageResult<>();
    WriterPointRuleVO writerPointRuleVO = new WriterPointRuleVO();
    pageParameter.setParameter(writerPointRuleVO);
    pageParameter.setPageSize(10);
    pageResult = writerPointRuleService.getlistWriterPointRulePoint(pageParameter);
    Assert.assertNotNull("分页数据失败", pageResult);
}
Also used : WriterPointRuleVO(com.bc.pmpheep.back.vo.WriterPointRuleVO) PageParameter(com.bc.pmpheep.back.plugin.PageParameter) WriterPointRule(com.bc.pmpheep.back.po.WriterPointRule) PageResult(com.bc.pmpheep.back.plugin.PageResult) Test(org.junit.Test) BaseTest(com.bc.pmpheep.test.BaseTest) Rollback(org.springframework.test.annotation.Rollback)

Example 2 with WriterPointRule

use of com.bc.pmpheep.back.po.WriterPointRule in project pmph by BCSquad.

the class WriterPointLogServiceImpl method addWriterPointLogByRuleName.

@Override
public void addWriterPointLogByRuleName(String ruleName, Long userId) throws CheckedServiceException {
    if (StringUtil.isEmpty(ruleName)) {
        throw new CheckedServiceException(CheckedExceptionBusiness.WRITER_POINT_MANAGEMENT, CheckedExceptionResult.NULL_PARAM, "规则名称为空");
    }
    if (ObjectUtil.isNull(userId)) {
        throw new CheckedServiceException(CheckedExceptionBusiness.WRITER_POINT_MANAGEMENT, CheckedExceptionResult.NULL_PARAM, "作者Id为空");
    }
    // 获取积分规则
    WriterPointRule writerPointRuleVOs = writerPointRuleService.getWriterPointRuleByName(ruleName);
    if (null != writerPointRuleVOs) {
        if (writerPointRuleVOs.getIsDisabled() == false) {
            // 查询用户之前的积分值
            List<WriterPointLog> writerPointLog2 = this.getWriterPointLogByUserId(userId);
            WriterPointLog writerPointLog = new WriterPointLog();
            // 现在的规则的积分值+以前的积分
            // 获取的总积分
            Integer temp = 0;
            if (!writerPointLog2.isEmpty()) {
                // 以前的总积分
                Integer newTemp = 0;
                // 遍历以前获取的积分
                for (WriterPointLog writerPointLogNew : writerPointLog2) {
                    newTemp += writerPointLogNew.getPoint();
                }
                temp = writerPointRuleVOs.getPoint() + newTemp;
            } else {
                temp = writerPointRuleVOs.getPoint();
            }
            writerPointLog.setPoint(writerPointRuleVOs.getPoint());
            // 积分规则id
            writerPointLog.setRuleId(writerPointRuleVOs.getId());
            writerPointLog.setUserId(userId);
            // 增加积分记录
            this.add(writerPointLog);
            // 查询用户积分
            WriterPoint point = writerPointService.getWriterPointByUserId(userId);
            if (ObjectUtil.notNull(point)) {
                writerPointService.updateWriterPoint(new WriterPoint(point.getId(), userId, temp + point.getLoss(), temp, point.getLoss()));
            } else {
                writerPointService.addWriterPoint(new WriterPoint(userId, temp, temp, 0));
            }
        }
    }
}
Also used : CheckedServiceException(com.bc.pmpheep.service.exception.CheckedServiceException) WriterPointRule(com.bc.pmpheep.back.po.WriterPointRule) WriterPointLog(com.bc.pmpheep.back.po.WriterPointLog) WriterPoint(com.bc.pmpheep.back.po.WriterPoint)

Example 3 with WriterPointRule

use of com.bc.pmpheep.back.po.WriterPointRule in project pmph by BCSquad.

the class MigrationPlus method point.

// 积分规则迁移
protected void point() {
    WriterPointRule writerPointRule1 = new WriterPointRule("连续登录", "logins", 1, false, null, null, "连续登录每天增加1分", true);
    writerPointRuleService.addWriterPointRule(writerPointRule1);
    WriterPointRule writerPointRule2 = new WriterPointRule("连续最大积分", "max_login_integral", 5, false, null, null, "到第5天增加5分后,每天给5分,中间有一天不来,重新开始积分", true);
    writerPointRuleService.addWriterPointRule(writerPointRule2);
    WriterPointRule writerPointRule3 = new WriterPointRule("登录", "login", 1, false, null, null, "每天登录一次给1分,一天仅一次", true);
    writerPointRuleService.addWriterPointRule(writerPointRule3);
    /*WriterPointRule writerPointRule4=new WriterPointRule("回复话题", "reply_topic", 1, false, null, null, "回复话题给1分", true);
		 writerPointRuleService.addWriterPointRule(writerPointRule4);
		 WriterPointRule writerPointRule5=new WriterPointRule("创建话题", "create_topic", 1, false, null, null, "创建话题给1分", true);
		 writerPointRuleService.addWriterPointRule(writerPointRule5);*/
    WriterPointRule writerPointRule9 = new WriterPointRule("图书评论", "book_comment", 1, false, null, null, "图书评论给1分", true);
    writerPointRuleService.addWriterPointRule(writerPointRule9);
    WriterPointRule writerPointRule10 = new WriterPointRule("图书纠错", "book_correction", 1, false, null, null, "图书纠错给1分", true);
    writerPointRuleService.addWriterPointRule(writerPointRule10);
    WriterPointRule writerPointRule11 = new WriterPointRule("发表文章", "cms_content", 1, false, null, null, "发表文章给1分", true);
    writerPointRuleService.addWriterPointRule(writerPointRule11);
    WriterPointRule writerPointRule12 = new WriterPointRule("问卷调查", "survey", 1, false, null, null, "问卷调查给1分", true);
    writerPointRuleService.addWriterPointRule(writerPointRule12);
    WriterPointRule writerPointRule6 = new WriterPointRule("平台a", "sys_a", 50, true, "2", 2, "本平台50积分=商城2积分", true);
    writerPointRuleService.addWriterPointRule(writerPointRule6);
    WriterPointRule writerPointRule7 = new WriterPointRule("平台b", "sys_b", 200, true, "0", 10, "本平台200积分=平台b10积分", true);
    writerPointRuleService.addWriterPointRule(writerPointRule7);
    WriterPointRule writerPointRule8 = new WriterPointRule("智慧商城", "buss", 100, true, "1", 1, "本平台100积分=智慧商城1积分", true);
    writerPointRuleService.addWriterPointRule(writerPointRule8);
}
Also used : WriterPointRule(com.bc.pmpheep.back.po.WriterPointRule)

Example 4 with WriterPointRule

use of com.bc.pmpheep.back.po.WriterPointRule in project pmph by BCSquad.

the class WriterPointRuleServiceTest method point.

@Test
@Rollback(Const.ISROLLBACK)
public void point() {
    WriterPointRule writerPointRule1 = new WriterPointRule("连续登录", "logins", 1, false, null, null, "连续登录每天增加1分", true);
    writerPointRuleService.addWriterPointRule(writerPointRule1);
    WriterPointRule writerPointRule2 = new WriterPointRule("连续最大积分", "max_login_integral", 5, false, null, null, "到第5天增加5分后,每天给5分,中间有一天不来,重新开始积分", true);
    writerPointRuleService.addWriterPointRule(writerPointRule2);
    WriterPointRule writerPointRule3 = new WriterPointRule("登录", "login", 1, false, null, null, "每天登录一次给1分,一天仅一次", true);
    writerPointRuleService.addWriterPointRule(writerPointRule3);
    WriterPointRule writerPointRule4 = new WriterPointRule("回复话题", "reply_topic", 1, false, null, null, "回复话题给1分", true);
    writerPointRuleService.addWriterPointRule(writerPointRule4);
    WriterPointRule writerPointRule5 = new WriterPointRule("创建话题", "create_topic", 1, false, null, null, "创建话题给1分", true);
    writerPointRuleService.addWriterPointRule(writerPointRule5);
    WriterPointRule writerPointRule9 = new WriterPointRule("图书评论", "book_comment", 1, false, null, null, "图书评论给1分", true);
    writerPointRuleService.addWriterPointRule(writerPointRule9);
    WriterPointRule writerPointRule10 = new WriterPointRule("图书纠错", "book_correction", 1, false, null, null, "图书纠错给1分", true);
    writerPointRuleService.addWriterPointRule(writerPointRule10);
    WriterPointRule writerPointRule11 = new WriterPointRule("发表文章", "cms_content", 1, false, null, null, "发表文章给1分", true);
    writerPointRuleService.addWriterPointRule(writerPointRule11);
    WriterPointRule writerPointRule12 = new WriterPointRule("问卷调查", "survey", 1, false, null, null, "问卷调查给1分", true);
    writerPointRuleService.addWriterPointRule(writerPointRule12);
    WriterPointRule writerPointRule6 = new WriterPointRule("平台a", "sys_a", 50, true, "2", 2, "本平台50积分=商城2积分", true);
    writerPointRuleService.addWriterPointRule(writerPointRule6);
    WriterPointRule writerPointRule7 = new WriterPointRule("平台b", "sys_b", 200, true, "0", 10, "本平台200积分=平台b10积分", true);
    writerPointRuleService.addWriterPointRule(writerPointRule7);
    WriterPointRule writerPointRule8 = new WriterPointRule("智慧商城", "buss", 100, true, "1", 1, "本平台100积分=智慧商城1积分", true);
    writerPointRuleService.addWriterPointRule(writerPointRule8);
}
Also used : WriterPointRule(com.bc.pmpheep.back.po.WriterPointRule) Test(org.junit.Test) BaseTest(com.bc.pmpheep.test.BaseTest) Rollback(org.springframework.test.annotation.Rollback)

Example 5 with WriterPointRule

use of com.bc.pmpheep.back.po.WriterPointRule in project pmph by BCSquad.

the class WriterPointRuleServiceTest method getListWriterPointRule.

@SuppressWarnings({ "unused", "rawtypes", "unchecked" })
@Test
@Rollback(Const.ISROLLBACK)
public void getListWriterPointRule() {
    WriterPointRule writerPointRule = this.addWriterPointRules();
    PageParameter pageParameter = new PageParameter<>();
    PageResult pageResult = new PageResult<>();
    WriterPointRuleVO writerPointRuleVO = new WriterPointRuleVO();
    pageParameter.setParameter(writerPointRuleVO);
    pageParameter.setPageSize(10);
    pageResult = writerPointRuleService.getListWriterPointRule(pageParameter);
    Assert.assertNotNull("分页数据失败", pageResult);
}
Also used : WriterPointRuleVO(com.bc.pmpheep.back.vo.WriterPointRuleVO) PageParameter(com.bc.pmpheep.back.plugin.PageParameter) WriterPointRule(com.bc.pmpheep.back.po.WriterPointRule) PageResult(com.bc.pmpheep.back.plugin.PageResult) Test(org.junit.Test) BaseTest(com.bc.pmpheep.test.BaseTest) Rollback(org.springframework.test.annotation.Rollback)

Aggregations

WriterPointRule (com.bc.pmpheep.back.po.WriterPointRule)5 BaseTest (com.bc.pmpheep.test.BaseTest)3 Test (org.junit.Test)3 Rollback (org.springframework.test.annotation.Rollback)3 PageParameter (com.bc.pmpheep.back.plugin.PageParameter)2 PageResult (com.bc.pmpheep.back.plugin.PageResult)2 WriterPointRuleVO (com.bc.pmpheep.back.vo.WriterPointRuleVO)2 WriterPoint (com.bc.pmpheep.back.po.WriterPoint)1 WriterPointLog (com.bc.pmpheep.back.po.WriterPointLog)1 CheckedServiceException (com.bc.pmpheep.service.exception.CheckedServiceException)1