55 changed files with 3495 additions and 908 deletions
@ -1,7 +1,7 @@ |
|||
package com.elink.esua.epdc.modules.async; |
|||
package com.elink.esua.epdc.async; |
|||
|
|||
import com.elink.esua.epdc.dto.epdc.form.EpdcInformationFormDTO; |
|||
import com.elink.esua.epdc.modules.feign.NewsFeignClient; |
|||
import com.elink.esua.epdc.feign.NewsFeignClient; |
|||
import org.springframework.beans.factory.annotation.Autowired; |
|||
import org.springframework.scheduling.annotation.Async; |
|||
import org.springframework.stereotype.Component; |
@ -0,0 +1,70 @@ |
|||
package com.elink.esua.epdc.controller; |
|||
|
|||
import com.elink.esua.epdc.commons.tools.constant.Constant; |
|||
import com.elink.esua.epdc.commons.tools.utils.Result; |
|||
import com.elink.esua.epdc.dto.form.EpdcAppPointsRankingFormDTO; |
|||
import com.elink.esua.epdc.dto.form.EpdcAppPointsRecordFormDTO; |
|||
import com.elink.esua.epdc.dto.result.EpdcAppPointsRankingResultDTO; |
|||
import com.elink.esua.epdc.dto.result.EpdcAppPointsRecordResultDTO; |
|||
import com.elink.esua.epdc.dto.result.PointsRuleResultDTO; |
|||
import com.elink.esua.epdc.service.PointsLogsService; |
|||
import com.elink.esua.epdc.service.PointsRuleService; |
|||
import org.springframework.beans.factory.annotation.Autowired; |
|||
import org.springframework.web.bind.annotation.*; |
|||
|
|||
import java.util.List; |
|||
|
|||
/** |
|||
* 积分管理模块APP接口 |
|||
* |
|||
* @author: zhangyong |
|||
* @Date: 2020-04-30 |
|||
*/ |
|||
@RestController |
|||
@RequestMapping(Constant.EPDC_APP + "points") |
|||
public class EpdcAppPointsController { |
|||
|
|||
@Autowired |
|||
private PointsLogsService pointsLogsService; |
|||
@Autowired |
|||
private PointsRuleService pointsRuleService; |
|||
|
|||
/** |
|||
* @Description: 当前登录用户 积分记录接口 |
|||
* @Param: [dto] |
|||
* @return: com.elink.esua.epdc.commons.tools.utils.Result<java.util.List<com.elink.esua.epdc.dto.result.EpdcAppPointsRecordResultDTO>> |
|||
* @Author: zy |
|||
* @Date: 2020-04-29 |
|||
*/ |
|||
@GetMapping("/pointsRecord/list") |
|||
public Result<List<EpdcAppPointsRecordResultDTO>> listPointsRecord(@RequestBody EpdcAppPointsRecordFormDTO formDto) { |
|||
List<EpdcAppPointsRecordResultDTO> list = pointsLogsService.listPointsRecord(formDto); |
|||
return new Result<List<EpdcAppPointsRecordResultDTO>>().ok(list); |
|||
} |
|||
|
|||
/** |
|||
* @Description: 积分排行接口(0 周排行、1 月排行) |
|||
* @Param: [formDto] |
|||
* @return: com.elink.esua.epdc.commons.tools.utils.Result<com.elink.esua.epdc.dto.result.EpdcAppPointsRankingResultDTO> |
|||
* @Author: zy |
|||
* @Date: 2020-04-30 |
|||
*/ |
|||
@GetMapping("pointsRanking/list") |
|||
public Result<EpdcAppPointsRankingResultDTO> listPointsRanking(@RequestBody EpdcAppPointsRankingFormDTO formDto) { |
|||
EpdcAppPointsRankingResultDTO list = pointsLogsService.listPointsRanking(formDto); |
|||
return new Result<EpdcAppPointsRankingResultDTO>().ok(list); |
|||
} |
|||
|
|||
/** |
|||
* @Description 根据动作编码获取积分规则 |
|||
* @Author songyunpeng |
|||
* @Date 2020/7/21 |
|||
* @Param [behaviorCode] |
|||
* @return com.elink.esua.epdc.commons.tools.utils.Result<com.elink.esua.epdc.dto.result.PointsRuleResultDTO> |
|||
**/ |
|||
@GetMapping("getPointsRuleByBehaviorCode/{behaviorCode}") |
|||
public Result<PointsRuleResultDTO> getPointsRuleByBehaviorCode (@PathVariable("behaviorCode") String behaviorCode){ |
|||
PointsRuleResultDTO pointsRuleByBehaviorCode = pointsRuleService.getPointsRuleByBehaviorCode(behaviorCode); |
|||
return new Result<PointsRuleResultDTO>().ok(pointsRuleByBehaviorCode); |
|||
} |
|||
} |
@ -0,0 +1,115 @@ |
|||
/** |
|||
* Copyright 2018 人人开源 https://www.renren.io
|
|||
* <p> |
|||
* This program is free software: you can redistribute it and/or modify |
|||
* it under the terms of the GNU General Public License as published by |
|||
* the Free Software Foundation, either version 3 of the License, or |
|||
* (at your option) any later version. |
|||
* <p> |
|||
* This program is distributed in the hope that it will be useful, |
|||
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
|||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|||
* GNU General Public License for more details. |
|||
* <p> |
|||
* You should have received a copy of the GNU General Public License |
|||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|||
*/ |
|||
|
|||
package com.elink.esua.epdc.controller; |
|||
|
|||
import com.elink.esua.epdc.commons.tools.page.PageData; |
|||
import com.elink.esua.epdc.commons.tools.utils.ExcelUtils; |
|||
import com.elink.esua.epdc.commons.tools.utils.Result; |
|||
import com.elink.esua.epdc.commons.tools.validator.AssertUtils; |
|||
import com.elink.esua.epdc.commons.tools.validator.ValidatorUtils; |
|||
import com.elink.esua.epdc.commons.tools.validator.group.AddGroup; |
|||
import com.elink.esua.epdc.commons.tools.validator.group.UpdateGroup; |
|||
import com.elink.esua.epdc.commons.tools.validator.group.DefaultGroup; |
|||
import com.elink.esua.epdc.dto.PointsBehaviorDTO; |
|||
import com.elink.esua.epdc.excel.PointsBehaviorExcel; |
|||
import com.elink.esua.epdc.service.PointsBehaviorService; |
|||
import org.springframework.beans.factory.annotation.Autowired; |
|||
import org.springframework.web.bind.annotation.*; |
|||
|
|||
import javax.servlet.http.HttpServletResponse; |
|||
import java.util.List; |
|||
import java.util.Map; |
|||
|
|||
|
|||
/** |
|||
* 积分动作管理表 积分动作管理表 |
|||
* |
|||
* @author zhangyong |
|||
* @since v1.0.0 2020-04-28 |
|||
*/ |
|||
@RestController |
|||
@RequestMapping("pointsbehavior") |
|||
public class PointsBehaviorController { |
|||
|
|||
@Autowired |
|||
private PointsBehaviorService pointsBehaviorService; |
|||
|
|||
@GetMapping("page") |
|||
public Result<PageData<PointsBehaviorDTO>> page(@RequestParam Map<String, Object> params){ |
|||
PageData<PointsBehaviorDTO> page = pointsBehaviorService.page(params); |
|||
return new Result<PageData<PointsBehaviorDTO>>().ok(page); |
|||
} |
|||
|
|||
@GetMapping("{id}") |
|||
public Result<PointsBehaviorDTO> get(@PathVariable("id") String id){ |
|||
PointsBehaviorDTO data = pointsBehaviorService.get(id); |
|||
return new Result<PointsBehaviorDTO>().ok(data); |
|||
} |
|||
|
|||
@PostMapping |
|||
public Result save(@RequestBody PointsBehaviorDTO dto){ |
|||
//效验数据
|
|||
ValidatorUtils.validateEntity(dto, AddGroup.class, DefaultGroup.class); |
|||
return pointsBehaviorService.save(dto); |
|||
} |
|||
|
|||
@PutMapping |
|||
public Result update(@RequestBody PointsBehaviorDTO dto){ |
|||
//效验数据
|
|||
ValidatorUtils.validateEntity(dto, UpdateGroup.class, DefaultGroup.class); |
|||
return pointsBehaviorService.update(dto); |
|||
} |
|||
|
|||
@DeleteMapping |
|||
public Result delete(@RequestBody String[] ids){ |
|||
//效验数据
|
|||
AssertUtils.isArrayEmpty(ids, "id"); |
|||
return pointsBehaviorService.delete(ids); |
|||
} |
|||
|
|||
@GetMapping("export") |
|||
public void export(@RequestParam Map<String, Object> params, HttpServletResponse response) throws Exception { |
|||
List<PointsBehaviorDTO> list = pointsBehaviorService.list(params); |
|||
ExcelUtils.exportExcelToTarget(response, null, list, PointsBehaviorExcel.class); |
|||
} |
|||
|
|||
/** |
|||
* @Description: 获取全部的动作编码 |
|||
* @Param: [] |
|||
* @return: com.elink.esua.epdc.commons.tools.utils.Result<java.util.List<com.elink.esua.epdc.dto.PointsBehaviorDTO>> |
|||
* @Author: zy |
|||
* @Date: 2020-04-29 |
|||
*/ |
|||
@GetMapping("getBehaviorDesc") |
|||
public Result<List<PointsBehaviorDTO>> getBehaviorDesc(){ |
|||
List<PointsBehaviorDTO> data = pointsBehaviorService.listBehaviorDesc(); |
|||
return new Result<List<PointsBehaviorDTO>>().ok(data); |
|||
} |
|||
/** |
|||
* @Description 志愿者服务使用- 获取全部动作编码 |
|||
* @Author songyunpeng |
|||
* @Date 2020/5/12 |
|||
* @Param [] |
|||
* @return com.elink.esua.epdc.commons.tools.utils.Result<java.util.List<com.elink.esua.epdc.dto.PointsBehaviorDTO>> |
|||
**/ |
|||
@GetMapping("getAllBehaviorDesc") |
|||
public Result<List<PointsBehaviorDTO>> getAllBehaviorDesc(){ |
|||
List<PointsBehaviorDTO> data = pointsBehaviorService.selectAllListBehaviorDesc(); |
|||
return new Result<List<PointsBehaviorDTO>>().ok(data); |
|||
} |
|||
} |
@ -0,0 +1,94 @@ |
|||
/** |
|||
* Copyright 2018 人人开源 https://www.renren.io
|
|||
* <p> |
|||
* This program is free software: you can redistribute it and/or modify |
|||
* it under the terms of the GNU General Public License as published by |
|||
* the Free Software Foundation, either version 3 of the License, or |
|||
* (at your option) any later version. |
|||
* <p> |
|||
* This program is distributed in the hope that it will be useful, |
|||
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
|||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|||
* GNU General Public License for more details. |
|||
* <p> |
|||
* You should have received a copy of the GNU General Public License |
|||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|||
*/ |
|||
|
|||
package com.elink.esua.epdc.controller; |
|||
|
|||
import com.elink.esua.epdc.commons.tools.page.PageData; |
|||
import com.elink.esua.epdc.commons.tools.utils.ExcelUtils; |
|||
import com.elink.esua.epdc.commons.tools.utils.Result; |
|||
import com.elink.esua.epdc.commons.tools.validator.AssertUtils; |
|||
import com.elink.esua.epdc.commons.tools.validator.ValidatorUtils; |
|||
import com.elink.esua.epdc.commons.tools.validator.group.AddGroup; |
|||
import com.elink.esua.epdc.commons.tools.validator.group.UpdateGroup; |
|||
import com.elink.esua.epdc.commons.tools.validator.group.DefaultGroup; |
|||
import com.elink.esua.epdc.dto.PointsBehaviorRuleDTO; |
|||
import com.elink.esua.epdc.excel.PointsBehaviorRuleExcel; |
|||
import com.elink.esua.epdc.service.PointsBehaviorRuleService; |
|||
import org.springframework.beans.factory.annotation.Autowired; |
|||
import org.springframework.web.bind.annotation.*; |
|||
|
|||
import javax.servlet.http.HttpServletResponse; |
|||
import java.util.List; |
|||
import java.util.Map; |
|||
|
|||
|
|||
/** |
|||
* 积分动作规则关系表 |
|||
* |
|||
* @author elink elink@elink-cn.com |
|||
* @since v1.0.0 2020-05-11 |
|||
*/ |
|||
@RestController |
|||
@RequestMapping("pointsbehaviorrule") |
|||
public class PointsBehaviorRuleController { |
|||
|
|||
@Autowired |
|||
private PointsBehaviorRuleService pointsBehaviorRuleService; |
|||
|
|||
@GetMapping("page") |
|||
public Result<PageData<PointsBehaviorRuleDTO>> page(@RequestParam Map<String, Object> params){ |
|||
PageData<PointsBehaviorRuleDTO> page = pointsBehaviorRuleService.page(params); |
|||
return new Result<PageData<PointsBehaviorRuleDTO>>().ok(page); |
|||
} |
|||
|
|||
@GetMapping("{id}") |
|||
public Result<PointsBehaviorRuleDTO> get(@PathVariable("id") String id){ |
|||
PointsBehaviorRuleDTO data = pointsBehaviorRuleService.get(id); |
|||
return new Result<PointsBehaviorRuleDTO>().ok(data); |
|||
} |
|||
|
|||
@PostMapping |
|||
public Result save(@RequestBody PointsBehaviorRuleDTO dto){ |
|||
//效验数据
|
|||
ValidatorUtils.validateEntity(dto, AddGroup.class, DefaultGroup.class); |
|||
pointsBehaviorRuleService.save(dto); |
|||
return new Result(); |
|||
} |
|||
|
|||
@PutMapping |
|||
public Result update(@RequestBody PointsBehaviorRuleDTO dto){ |
|||
//效验数据
|
|||
ValidatorUtils.validateEntity(dto, UpdateGroup.class, DefaultGroup.class); |
|||
pointsBehaviorRuleService.update(dto); |
|||
return new Result(); |
|||
} |
|||
|
|||
@DeleteMapping |
|||
public Result delete(@RequestBody String[] ids){ |
|||
//效验数据
|
|||
AssertUtils.isArrayEmpty(ids, "id"); |
|||
pointsBehaviorRuleService.delete(ids); |
|||
return new Result(); |
|||
} |
|||
|
|||
@GetMapping("export") |
|||
public void export(@RequestParam Map<String, Object> params, HttpServletResponse response) throws Exception { |
|||
List<PointsBehaviorRuleDTO> list = pointsBehaviorRuleService.list(params); |
|||
ExcelUtils.exportExcelToTarget(response, null, list, PointsBehaviorRuleExcel.class); |
|||
} |
|||
|
|||
} |
@ -0,0 +1,45 @@ |
|||
package com.elink.esua.epdc.controller; |
|||
|
|||
import com.elink.esua.epdc.commons.tools.utils.ConvertUtils; |
|||
import com.elink.esua.epdc.commons.tools.utils.Result; |
|||
import com.elink.esua.epdc.commons.tools.validator.ValidatorUtils; |
|||
import com.elink.esua.epdc.dto.PointsLogsDTO; |
|||
import com.elink.esua.epdc.dto.form.PointsLogsAddFormDTO; |
|||
import com.elink.esua.epdc.dto.form.PointsLogsFormDTO; |
|||
import com.elink.esua.epdc.dto.result.BehaviorResultDto; |
|||
import com.elink.esua.epdc.dto.result.PointsLogsResultDTO; |
|||
import com.elink.esua.epdc.dto.result.PointsLogsSumResultDTO; |
|||
import com.elink.esua.epdc.dto.result.PointsRuleResultDTO; |
|||
import com.elink.esua.epdc.entity.PointsLogsEntity; |
|||
import com.elink.esua.epdc.service.PointsBehaviorService; |
|||
import com.elink.esua.epdc.service.PointsLogsService; |
|||
import com.elink.esua.epdc.service.PointsRuleService; |
|||
import org.springframework.beans.factory.annotation.Autowired; |
|||
import org.springframework.web.bind.annotation.*; |
|||
|
|||
/** |
|||
* @author songyunpeng |
|||
* @Description 提供外部接口Controller |
|||
* @create 2020-04-28 |
|||
*/ |
|||
@RestController |
|||
@RequestMapping("points") |
|||
public class PointsController { |
|||
|
|||
|
|||
@Autowired |
|||
private PointsBehaviorService pointsBehaviorService; |
|||
|
|||
/** |
|||
* @return com.elink.esua.epdc.dto.result.BehaviorResultDto |
|||
* @Description 根据动作编码获取动作信息 |
|||
* @Author songyunpeng |
|||
* @Date 2020/4/28 |
|||
* @Param [behaviorCode] |
|||
**/ |
|||
@PostMapping("getBehaviorCodeInfo/{behaviorCode}") |
|||
public Result<BehaviorResultDto> getBehaviorCodeInfo(@PathVariable String behaviorCode) { |
|||
return pointsBehaviorService.getBehaviorCodeInfoByBehaviorCode(behaviorCode); |
|||
} |
|||
|
|||
} |
@ -0,0 +1,117 @@ |
|||
/** |
|||
* Copyright 2018 人人开源 https://www.renren.io
|
|||
* <p> |
|||
* This program is free software: you can redistribute it and/or modify |
|||
* it under the terms of the GNU General Public License as published by |
|||
* the Free Software Foundation, either version 3 of the License, or |
|||
* (at your option) any later version. |
|||
* <p> |
|||
* This program is distributed in the hope that it will be useful, |
|||
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
|||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|||
* GNU General Public License for more details. |
|||
* <p> |
|||
* You should have received a copy of the GNU General Public License |
|||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|||
*/ |
|||
|
|||
package com.elink.esua.epdc.controller; |
|||
|
|||
import com.elink.esua.epdc.commons.tools.page.PageData; |
|||
import com.elink.esua.epdc.commons.tools.utils.ExcelUtils; |
|||
import com.elink.esua.epdc.commons.tools.utils.Result; |
|||
import com.elink.esua.epdc.commons.tools.validator.AssertUtils; |
|||
import com.elink.esua.epdc.commons.tools.validator.ValidatorUtils; |
|||
import com.elink.esua.epdc.commons.tools.validator.group.AddGroup; |
|||
import com.elink.esua.epdc.commons.tools.validator.group.UpdateGroup; |
|||
import com.elink.esua.epdc.commons.tools.validator.group.DefaultGroup; |
|||
import com.elink.esua.epdc.dto.PointsRuleDTO; |
|||
import com.elink.esua.epdc.excel.PointsRuleExcel; |
|||
import com.elink.esua.epdc.service.PointsRuleService; |
|||
import org.springframework.beans.factory.annotation.Autowired; |
|||
import org.springframework.web.bind.annotation.*; |
|||
|
|||
import javax.servlet.http.HttpServletResponse; |
|||
import java.util.HashMap; |
|||
import java.util.List; |
|||
import java.util.Map; |
|||
|
|||
|
|||
/** |
|||
* 积分规则管理表 积分规则管理表 |
|||
* |
|||
* @author zhangyong |
|||
* @since v1.0.0 2020-04-28 |
|||
*/ |
|||
@RestController |
|||
@RequestMapping("pointsrule") |
|||
public class PointsRuleController { |
|||
|
|||
@Autowired |
|||
private PointsRuleService pointsRuleService; |
|||
|
|||
@GetMapping("page") |
|||
public Result<PageData<PointsRuleDTO>> page(@RequestParam Map<String, Object> params){ |
|||
PageData<PointsRuleDTO> page = pointsRuleService.page(params); |
|||
return new Result<PageData<PointsRuleDTO>>().ok(page); |
|||
} |
|||
|
|||
@GetMapping("{id}") |
|||
public Result<PointsRuleDTO> get(@PathVariable("id") String id){ |
|||
PointsRuleDTO data = pointsRuleService.get(id); |
|||
return new Result<PointsRuleDTO>().ok(data); |
|||
} |
|||
|
|||
@PostMapping |
|||
public Result save(@RequestBody PointsRuleDTO dto){ |
|||
//效验数据
|
|||
ValidatorUtils.validateEntity(dto, AddGroup.class, DefaultGroup.class); |
|||
return pointsRuleService.save(dto); |
|||
} |
|||
|
|||
@PutMapping |
|||
public Result update(@RequestBody PointsRuleDTO dto){ |
|||
//效验数据
|
|||
ValidatorUtils.validateEntity(dto, UpdateGroup.class, DefaultGroup.class); |
|||
return pointsRuleService.update(dto); |
|||
} |
|||
|
|||
@DeleteMapping |
|||
public Result delete(@RequestBody String[] ids){ |
|||
//效验数据
|
|||
AssertUtils.isArrayEmpty(ids, "id"); |
|||
pointsRuleService.delete(ids); |
|||
return new Result(); |
|||
} |
|||
|
|||
@GetMapping("export") |
|||
public void export(@RequestParam Map<String, Object> params, HttpServletResponse response) throws Exception { |
|||
List<PointsRuleDTO> list = pointsRuleService.list(params); |
|||
ExcelUtils.exportExcelToTarget(response, null, list, PointsRuleExcel.class); |
|||
} |
|||
|
|||
/** |
|||
* @param ruleCode |
|||
* @return com.elink.esua.epdc.commons.tools.utils.Result<com.elink.esua.epdc.dto.rule.PointsRuleDTO> |
|||
* @Author yinzuomei |
|||
* @Description 根据规则编码查询规则信息 |
|||
* @Date 2019/12/12 16:29 |
|||
**/ |
|||
@GetMapping("getPointRule/{ruleCode}") |
|||
public Result<PointsRuleDTO> getPointRule(@PathVariable("ruleCode") String ruleCode) { |
|||
return pointsRuleService.getPointRule(ruleCode); |
|||
} |
|||
|
|||
/*** |
|||
* 规则列表 |
|||
* @param |
|||
* @return com.elink.esua.epdc.commons.tools.utils.Result<com.elink.esua.epdc.commons.tools.page.PageData<com.elink.esua.epdc.dto.PointsRuleDTO>> |
|||
* @author qushutong |
|||
* @date 2020/7/20 17:28 |
|||
*/ |
|||
@GetMapping("ruleList") |
|||
public Result<List<PointsRuleDTO>> getRuleList() { |
|||
List<PointsRuleDTO> list = pointsRuleService.list(new HashMap<>()); |
|||
return new Result<List<PointsRuleDTO>>().ok(list); |
|||
} |
|||
} |
@ -0,0 +1,96 @@ |
|||
/** |
|||
* Copyright 2018 人人开源 https://www.renren.io
|
|||
* <p> |
|||
* This program is free software: you can redistribute it and/or modify |
|||
* it under the terms of the GNU General Public License as published by |
|||
* the Free Software Foundation, either version 3 of the License, or |
|||
* (at your option) any later version. |
|||
* <p> |
|||
* This program is distributed in the hope that it will be useful, |
|||
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
|||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|||
* GNU General Public License for more details. |
|||
* <p> |
|||
* You should have received a copy of the GNU General Public License |
|||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|||
*/ |
|||
|
|||
package com.elink.esua.epdc.dao; |
|||
|
|||
import com.elink.esua.epdc.commons.mybatis.dao.BaseDao; |
|||
import com.elink.esua.epdc.dto.PointsBehaviorDTO; |
|||
import com.elink.esua.epdc.dto.result.BehaviorResultDto; |
|||
import com.elink.esua.epdc.entity.PointsBehaviorEntity; |
|||
import org.apache.ibatis.annotations.Mapper; |
|||
|
|||
import java.util.List; |
|||
import java.util.Map; |
|||
|
|||
/** |
|||
* 积分动作管理表 积分动作管理表 |
|||
* |
|||
* @author zhangyong |
|||
* @since v1.0.0 2020-04-28 |
|||
*/ |
|||
@Mapper |
|||
public interface PointsBehaviorDao extends BaseDao<PointsBehaviorEntity> { |
|||
|
|||
/** |
|||
* 动作管理 列表查询 |
|||
* |
|||
* @param params |
|||
* param behaviorCode 可选 动作编码 |
|||
* param behaviorDesc 可选 动作描述 |
|||
* param pageIndex 必选 页码 |
|||
* param pageSize 必选 页容量 |
|||
* @return: java.util.List<com.elink.esua.epdc.dto.PointsBehaviorDTO> |
|||
* @Author: zy |
|||
* @Date: 2020-04-28 |
|||
*/ |
|||
List<PointsBehaviorDTO> selectListPointsBehavior(Map<String, Object> params); |
|||
|
|||
/** |
|||
* @return com.elink.esua.epdc.dto.result.BehaviorResultDto |
|||
* @Description 根据动作编码获取动作信息 |
|||
* @Author songyunpeng |
|||
* @Date 2020/4/28 |
|||
* @Param [] |
|||
**/ |
|||
BehaviorResultDto getBehaviorCodeInfoByBehaviorCode(String behaviorCode); |
|||
/** |
|||
* @Description 志愿者服务使用- 获取全部动作编码 |
|||
* @Author songyunpeng |
|||
* @Date 2020/5/12 |
|||
* @Param [] |
|||
* @return java.util.List<com.elink.esua.epdc.dto.PointsBehaviorDTO> |
|||
**/ |
|||
List<PointsBehaviorDTO> selectAllListBehaviorDesc(); |
|||
|
|||
/** |
|||
* 获取全部的动作编码 |
|||
* |
|||
* @Param: [] |
|||
* @return: com.elink.esua.epdc.commons.tools.utils.Result<java.util.List<com.elink.esua.epdc.dto.PointsBehaviorDTO>> |
|||
* @Author: zy |
|||
* @Date: 2020-04-29 |
|||
*/ |
|||
List<PointsBehaviorDTO> selectListBehaviorDesc(); |
|||
|
|||
/** |
|||
* 查询积分动作管理表 动作描述是否存在 |
|||
* @param behaviorDesc 动作描述 |
|||
* @return int |
|||
* @Author zhangyong |
|||
* @Date 17:33 2020-05-08 |
|||
**/ |
|||
int selectBehaviorDescItExist(String behaviorDesc); |
|||
|
|||
/** |
|||
* 查询积分规则表 动作编码是否存在 |
|||
* @param behaviorCode 动作编码 |
|||
* @return int |
|||
* @Author zhangyong |
|||
* @Date 15:48 2020-05-08 |
|||
**/ |
|||
int selectBehaviorCodeDoestItExist(String behaviorCode); |
|||
} |
@ -0,0 +1,146 @@ |
|||
/** |
|||
* Copyright 2018 人人开源 https://www.renren.io
|
|||
* <p> |
|||
* This program is free software: you can redistribute it and/or modify |
|||
* it under the terms of the GNU General Public License as published by |
|||
* the Free Software Foundation, either version 3 of the License, or |
|||
* (at your option) any later version. |
|||
* <p> |
|||
* This program is distributed in the hope that it will be useful, |
|||
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
|||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|||
* GNU General Public License for more details. |
|||
* <p> |
|||
* You should have received a copy of the GNU General Public License |
|||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|||
*/ |
|||
|
|||
package com.elink.esua.epdc.dao; |
|||
|
|||
import com.elink.esua.epdc.commons.mybatis.dao.BaseDao; |
|||
import com.elink.esua.epdc.dto.PointsLogsDTO; |
|||
import com.elink.esua.epdc.dto.form.PointsLogsFormDTO; |
|||
import com.elink.esua.epdc.dto.result.*; |
|||
import com.elink.esua.epdc.dto.form.EpdcAppPointsRankingFormDTO; |
|||
import com.elink.esua.epdc.dto.form.EpdcAppPointsRecordFormDTO; |
|||
import com.elink.esua.epdc.entity.PointsLogsEntity; |
|||
import org.apache.ibatis.annotations.Mapper; |
|||
|
|||
import java.util.List; |
|||
import java.util.Map; |
|||
|
|||
/** |
|||
* 积分记录表 积分记录表 |
|||
* |
|||
* @author elink elink@elink-cn.com |
|||
* @since v1.0.0 2020-04-29 |
|||
*/ |
|||
@Mapper |
|||
public interface PointsLogsDao extends BaseDao<PointsLogsEntity> { |
|||
/** |
|||
* @return com.elink.esua.epdc.dto.result.PointsLogsResultDTO |
|||
* @Description 根据用户,业务ID,行为编码获取日志记录 |
|||
* @Author songyunpeng |
|||
* @Date 2020/4/29 |
|||
* @Param [pointsLogsFormDTO] |
|||
**/ |
|||
List<PointsLogsResultDTO> selecOneLogsByBehaviorCodeAndUserIdAndReferenceId(PointsLogsFormDTO pointsLogsFormDTO); |
|||
|
|||
/** |
|||
* @return java.lang.Integer |
|||
* @Description 根据行为编码和用户ID获取积分 该动作积分总和 |
|||
* @Author songyunpeng |
|||
* @Date 2020/4/29 |
|||
* @Param [pointsLogsFormDTO] |
|||
**/ |
|||
Integer getPointsSumByBehaviorCodeAndUserId(PointsLogsFormDTO pointsLogsFormDTO); |
|||
|
|||
/** |
|||
* @return com.elink.esua.epdc.dto.result.PointsLogsResultDTO |
|||
* @Description 获取指定人指定动作的最新一条工作日志 |
|||
* @Author songyunpeng |
|||
* @Date 2020/4/29 |
|||
* @Param [pointsLogsFormDTO] |
|||
**/ |
|||
PointsLogsResultDTO getLastPointLogs(PointsLogsFormDTO pointsLogsFormDTO); |
|||
|
|||
/** |
|||
* 当前登录用户 积分记录接口 |
|||
* |
|||
* @param formDto |
|||
* param pageIndex 必选 页码 |
|||
* param pageSize 必选 页容量 |
|||
* param userId 必选 用户ID |
|||
* @return: java.util.List<com.elink.esua.epdc.dto.result.EpdcAppPointsRecordResultDTO> |
|||
* @Author: zy |
|||
* @Date: 2020-04-29 |
|||
*/ |
|||
List<EpdcAppPointsRecordResultDTO> selectListPointsRecord(EpdcAppPointsRecordFormDTO formDto); |
|||
|
|||
/** |
|||
* 积分排行接口(0 周排行、1 月排行) |
|||
* |
|||
* @param formDto |
|||
* param pageIndex 必选 页码 |
|||
* param pageSize 必选 页容量 |
|||
* param rankingType 必选 排名方式:0-周,1-月 |
|||
* @return: java.util.List <com.elink.esua.epdc.dto.result.EpdcAppPointsRankingTopTenDTO> |
|||
* @Author: zy |
|||
* @Date: 2020-04-30 |
|||
*/ |
|||
List<EpdcAppPointsRankingTopTenDTO> selectListPointsRanking(EpdcAppPointsRankingFormDTO formDto); |
|||
|
|||
/** |
|||
* 志愿者管理 积分记录页面分页查询 |
|||
* @param params |
|||
* param userId 必选 用户ID |
|||
* @return java.util.List<com.elink.esua.epdc.dto.PointsLogsDTO> |
|||
* @Author zhangyong |
|||
* @Date 15:31 2020-05-12 |
|||
**/ |
|||
List<PointsLogsDTO> selectListVolunteerPointsLog(Map<String, Object> params); |
|||
|
|||
/** |
|||
* 积分排行接口(0 周排行、1 月排行) - 查询用户个人排名名次 及 积分 |
|||
* |
|||
* @param formDto |
|||
* param pageIndex 必选 页码 |
|||
* param pageSize 必选 页容量 |
|||
* param rankingType 必选 排名方式:0-周,1-月 |
|||
* @return: com.elink.esua.epdc.dto.result.EpdcAppPointsRankingUserDTO |
|||
* @Author: zy |
|||
* @Date: 2020-05-13 |
|||
*/ |
|||
EpdcAppPointsRankingUserDTO selectUserPointsRanking(EpdcAppPointsRankingFormDTO formDto); |
|||
|
|||
/** |
|||
* 积分排行接口(0 周排行、1 月排行) - 产生积分记录的总人数,相同积分做去重处理 |
|||
* |
|||
* @param formDto |
|||
* param pageIndex 必选 页码 |
|||
* param pageSize 必选 页容量 |
|||
* param rankingType 必选 排名方式:0-周,1-月 |
|||
* @return: int |
|||
* @Author: zy |
|||
* @Date: 2020-05-13 |
|||
*/ |
|||
int selectCountPointsRanking(EpdcAppPointsRankingFormDTO formDto); |
|||
|
|||
/*** |
|||
* 积分分类统计 |
|||
* @param params |
|||
* @return java.util.List<com.elink.esua.epdc.dto.result.PointsStatisticsListResultDTO> |
|||
* @author qushutong |
|||
* @date 2020/7/21 10:37 |
|||
*/ |
|||
List<PointsStatisticsListResultDTO> selectPointsList(Map<String, Object> params); |
|||
|
|||
/*** |
|||
* 积分总览 |
|||
* @param params |
|||
* @return com.elink.esua.epdc.dto.result.PointsStatisticsListResultDTO |
|||
* @author qushutong |
|||
* @date 2020/7/21 10:37 |
|||
*/ |
|||
PointsStatisticsListResultDTO selectPointsOverview(Map<String, Object> params); |
|||
} |
@ -0,0 +1,72 @@ |
|||
/** |
|||
* Copyright 2018 人人开源 https://www.renren.io
|
|||
* <p> |
|||
* This program is free software: you can redistribute it and/or modify |
|||
* it under the terms of the GNU General Public License as published by |
|||
* the Free Software Foundation, either version 3 of the License, or |
|||
* (at your option) any later version. |
|||
* <p> |
|||
* This program is distributed in the hope that it will be useful, |
|||
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
|||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|||
* GNU General Public License for more details. |
|||
* <p> |
|||
* You should have received a copy of the GNU General Public License |
|||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|||
*/ |
|||
|
|||
package com.elink.esua.epdc.dao; |
|||
|
|||
import com.elink.esua.epdc.commons.mybatis.dao.BaseDao; |
|||
import com.elink.esua.epdc.dto.PointsRuleDTO; |
|||
import com.elink.esua.epdc.dto.result.PointsRuleResultDTO; |
|||
import com.elink.esua.epdc.entity.PointsRuleEntity; |
|||
import org.apache.ibatis.annotations.Mapper; |
|||
|
|||
import java.util.List; |
|||
import java.util.Map; |
|||
|
|||
/** |
|||
* 积分规则管理表 积分规则管理表 |
|||
* |
|||
* @author zhangyong |
|||
* @since v1.0.0 2020-04-28 |
|||
*/ |
|||
@Mapper |
|||
public interface PointsRuleDao extends BaseDao<PointsRuleEntity> { |
|||
|
|||
/** |
|||
* @return com.elink.esua.epdc.dto.result.PointsRuleResultDTO |
|||
* @Description 根据动作编码获取积分规则 |
|||
* @Author songyunpeng |
|||
* @Date 2020/4/29 |
|||
* @Param [behaviorCode] |
|||
**/ |
|||
PointsRuleResultDTO selecOnePointsRuleByBehaviorCode(String behaviorCode); |
|||
|
|||
/** |
|||
* 积分规则配置 列表查询 |
|||
* |
|||
* @param params |
|||
* param ruleCode 可选 积分规则编码 |
|||
* param ruleDesc 可选 积分规则描述 |
|||
* param operationType 可选 规则操作类型 0-减积分,1-加积分 |
|||
* param enableFlag 可选 启用标识 0-否,1-是 |
|||
* param pageIndex 必选 页码 |
|||
* param pageSize 必选 页容量 |
|||
* @return: java.util.List<com.elink.esua.epdc.dao.PointsRuleDao> |
|||
* @Author: zy |
|||
* @Date: 2020-04-29 |
|||
*/ |
|||
List<PointsRuleDTO> selectListPointsRule(Map<String, Object> params); |
|||
|
|||
/** |
|||
* 根据积分规则管理表ID,查询相关联的动作编码 |
|||
* |
|||
* @param pointsRuldId 积分规则管理表ID |
|||
* @return java.util.List<java.lang.String> |
|||
* @Author zhangyong |
|||
* @Date 10:22 2020-05-11 |
|||
**/ |
|||
List<String> selectListBehaviorCode(String pointsRuldId); |
|||
} |
@ -0,0 +1,61 @@ |
|||
/** |
|||
* Copyright 2018 人人开源 https://www.renren.io
|
|||
* <p> |
|||
* This program is free software: you can redistribute it and/or modify |
|||
* it under the terms of the GNU General Public License as published by |
|||
* the Free Software Foundation, either version 3 of the License, or |
|||
* (at your option) any later version. |
|||
* <p> |
|||
* This program is distributed in the hope that it will be useful, |
|||
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
|||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|||
* GNU General Public License for more details. |
|||
* <p> |
|||
* You should have received a copy of the GNU General Public License |
|||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|||
*/ |
|||
|
|||
package com.elink.esua.epdc.entity; |
|||
|
|||
import com.baomidou.mybatisplus.annotation.TableName; |
|||
|
|||
import com.elink.esua.epdc.commons.mybatis.entity.BaseEpdcEntity; |
|||
import lombok.Data; |
|||
import lombok.EqualsAndHashCode; |
|||
|
|||
import java.util.Date; |
|||
|
|||
/** |
|||
* 积分动作管理表 积分动作管理表 |
|||
* |
|||
* @author zhangyong |
|||
* @since v1.0.0 2020-04-28 |
|||
*/ |
|||
@Data |
|||
@EqualsAndHashCode(callSuper=false) |
|||
@TableName("epdc_points_behavior") |
|||
public class PointsBehaviorEntity extends BaseEpdcEntity { |
|||
|
|||
private static final long serialVersionUID = 1L; |
|||
|
|||
/** |
|||
* 动作编码 |
|||
*/ |
|||
private String behaviorCode; |
|||
|
|||
/** |
|||
* 动作描述 |
|||
*/ |
|||
private String behaviorDesc; |
|||
|
|||
/** |
|||
* 动作记录时机 0-方法执行前,1-方法执行后 |
|||
*/ |
|||
private String behaviorRecordingTime; |
|||
|
|||
/** |
|||
* 备注 |
|||
*/ |
|||
private String remark; |
|||
|
|||
} |
@ -0,0 +1,51 @@ |
|||
/** |
|||
* Copyright 2018 人人开源 https://www.renren.io
|
|||
* <p> |
|||
* This program is free software: you can redistribute it and/or modify |
|||
* it under the terms of the GNU General Public License as published by |
|||
* the Free Software Foundation, either version 3 of the License, or |
|||
* (at your option) any later version. |
|||
* <p> |
|||
* This program is distributed in the hope that it will be useful, |
|||
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
|||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|||
* GNU General Public License for more details. |
|||
* <p> |
|||
* You should have received a copy of the GNU General Public License |
|||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|||
*/ |
|||
|
|||
package com.elink.esua.epdc.entity; |
|||
|
|||
import com.baomidou.mybatisplus.annotation.TableName; |
|||
|
|||
import com.elink.esua.epdc.commons.mybatis.entity.BaseEpdcEntity; |
|||
import lombok.Data; |
|||
import lombok.EqualsAndHashCode; |
|||
|
|||
import java.util.Date; |
|||
|
|||
/** |
|||
* 积分动作规则关系表 |
|||
* |
|||
* @author elink elink@elink-cn.com |
|||
* @since v1.0.0 2020-05-11 |
|||
*/ |
|||
@Data |
|||
@EqualsAndHashCode(callSuper=false) |
|||
@TableName("epdc_points_behavior_rule") |
|||
public class PointsBehaviorRuleEntity extends BaseEpdcEntity { |
|||
|
|||
private static final long serialVersionUID = 1L; |
|||
|
|||
/** |
|||
* 动作ID |
|||
*/ |
|||
private String behaviorId; |
|||
|
|||
/** |
|||
* 规则ID |
|||
*/ |
|||
private String ruleId; |
|||
|
|||
} |
@ -0,0 +1,68 @@ |
|||
/** |
|||
* Copyright 2018 人人开源 https://www.renren.io
|
|||
* <p> |
|||
* This program is free software: you can redistribute it and/or modify |
|||
* it under the terms of the GNU General Public License as published by |
|||
* the Free Software Foundation, either version 3 of the License, or |
|||
* (at your option) any later version. |
|||
* <p> |
|||
* This program is distributed in the hope that it will be useful, |
|||
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
|||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|||
* GNU General Public License for more details. |
|||
* <p> |
|||
* You should have received a copy of the GNU General Public License |
|||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|||
*/ |
|||
|
|||
package com.elink.esua.epdc.excel; |
|||
|
|||
import cn.afterturn.easypoi.excel.annotation.Excel; |
|||
import lombok.Data; |
|||
|
|||
import java.util.Date; |
|||
|
|||
/** |
|||
* 积分动作管理表 积分动作管理表 |
|||
* |
|||
* @author zhangyong |
|||
* @since v1.0.0 2020-04-28 |
|||
*/ |
|||
@Data |
|||
public class PointsBehaviorExcel { |
|||
|
|||
@Excel(name = "ID") |
|||
private String id; |
|||
|
|||
@Excel(name = "动作编码") |
|||
private String behaviorCode; |
|||
|
|||
@Excel(name = "动作描述") |
|||
private String behaviorDesc; |
|||
|
|||
@Excel(name = "动作记录时机 0-方法执行前,1-方法执行后") |
|||
private String behaviorRecordingTime; |
|||
|
|||
@Excel(name = "备注") |
|||
private String remark; |
|||
|
|||
@Excel(name = "乐观锁") |
|||
private Integer revision; |
|||
|
|||
@Excel(name = "删除标识 0-否,1-是") |
|||
private String delFlag; |
|||
|
|||
@Excel(name = "创建人") |
|||
private String createdBy; |
|||
|
|||
@Excel(name = "创建时间") |
|||
private Date createdTime; |
|||
|
|||
@Excel(name = "更新人") |
|||
private String updatedBy; |
|||
|
|||
@Excel(name = "更新时间") |
|||
private Date updatedTime; |
|||
|
|||
|
|||
} |
@ -0,0 +1,62 @@ |
|||
/** |
|||
* Copyright 2018 人人开源 https://www.renren.io
|
|||
* <p> |
|||
* This program is free software: you can redistribute it and/or modify |
|||
* it under the terms of the GNU General Public License as published by |
|||
* the Free Software Foundation, either version 3 of the License, or |
|||
* (at your option) any later version. |
|||
* <p> |
|||
* This program is distributed in the hope that it will be useful, |
|||
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
|||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|||
* GNU General Public License for more details. |
|||
* <p> |
|||
* You should have received a copy of the GNU General Public License |
|||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|||
*/ |
|||
|
|||
package com.elink.esua.epdc.excel; |
|||
|
|||
import cn.afterturn.easypoi.excel.annotation.Excel; |
|||
import lombok.Data; |
|||
|
|||
import java.util.Date; |
|||
|
|||
/** |
|||
* 积分动作规则关系表 |
|||
* |
|||
* @author elink elink@elink-cn.com |
|||
* @since v1.0.0 2020-05-11 |
|||
*/ |
|||
@Data |
|||
public class PointsBehaviorRuleExcel { |
|||
|
|||
@Excel(name = "ID") |
|||
private String id; |
|||
|
|||
@Excel(name = "动作ID") |
|||
private String behaviorId; |
|||
|
|||
@Excel(name = "规则ID") |
|||
private String ruleId; |
|||
|
|||
@Excel(name = "乐观锁") |
|||
private Integer revision; |
|||
|
|||
@Excel(name = "删除标识 0-否,1-是") |
|||
private String delFlag; |
|||
|
|||
@Excel(name = "创建人") |
|||
private String createdBy; |
|||
|
|||
@Excel(name = "创建时间") |
|||
private Date createdTime; |
|||
|
|||
@Excel(name = "更新人") |
|||
private String updatedBy; |
|||
|
|||
@Excel(name = "更新时间") |
|||
private Date updatedTime; |
|||
|
|||
|
|||
} |
@ -1,9 +1,9 @@ |
|||
package com.elink.esua.epdc.modules.feign; |
|||
package com.elink.esua.epdc.feign; |
|||
|
|||
import com.elink.esua.epdc.commons.tools.constant.ServiceConstant; |
|||
import com.elink.esua.epdc.commons.tools.utils.Result; |
|||
import com.elink.esua.epdc.dto.epdc.form.EpdcInformationFormDTO; |
|||
import com.elink.esua.epdc.modules.feign.fallback.NewsFeignClientFallback; |
|||
import com.elink.esua.epdc.feign.fallback.NewsFeignClientFallback; |
|||
import org.springframework.cloud.openfeign.FeignClient; |
|||
import org.springframework.http.MediaType; |
|||
import org.springframework.web.bind.annotation.PostMapping; |
@ -0,0 +1,61 @@ |
|||
package com.elink.esua.epdc.feign; |
|||
|
|||
import com.elink.esua.epdc.commons.tools.constant.ServiceConstant; |
|||
import com.elink.esua.epdc.commons.tools.utils.Result; |
|||
import com.elink.esua.epdc.dto.UserDTO; |
|||
import com.elink.esua.epdc.dto.UserGridRelationDTO; |
|||
import com.elink.esua.epdc.dto.epdc.form.EpdcUserPointsFormDTO; |
|||
import com.elink.esua.epdc.feign.fallback.UsersFeignClientFallback; |
|||
import org.springframework.cloud.openfeign.FeignClient; |
|||
import org.springframework.http.MediaType; |
|||
import org.springframework.web.bind.annotation.*; |
|||
|
|||
|
|||
/** |
|||
* @author songyunpeng |
|||
* @date 2020/04/28 |
|||
*/ |
|||
@FeignClient(name = ServiceConstant.EPDC_USER_SERVER, fallback = UsersFeignClientFallback.class) |
|||
public interface UsersFeignClient { |
|||
|
|||
/** |
|||
* @return com.elink.esua.epdc.commons.tools.utils.Result<com.elink.esua.epdc.pointcommons.tools.dto.BehaviorResultDto> |
|||
* @Description 获取用户信息 |
|||
* @Author songyunpeng |
|||
* @Date 2020/4/29 |
|||
* @Param [id] |
|||
**/ |
|||
@GetMapping(value = "app-user/user/{id}", consumes = MediaType.APPLICATION_JSON_VALUE) |
|||
Result<UserDTO> getUserById(@PathVariable String id); |
|||
|
|||
/** |
|||
* @return com.elink.esua.epdc.commons.tools.utils.Result<com.elink.esua.epdc.pointcommons.tools.dto.BehaviorResultDto> |
|||
* @Description 更新用户信息 |
|||
* @Author songyunpeng |
|||
* @Date 2020/4/29 |
|||
* @Param [dto] |
|||
**/ |
|||
@PutMapping(value = "app-user/user", consumes = MediaType.APPLICATION_JSON_VALUE) |
|||
Result updateUser(@RequestBody UserDTO dto); |
|||
|
|||
/** |
|||
* @param formDTO |
|||
* @return com.elink.esua.epdc.dto.UserDTO |
|||
* @Author yinzuomei |
|||
* @Description 根据操作类型更新用户积分 |
|||
* @Date 2019/12/13 15:12 |
|||
**/ |
|||
@PostMapping(value = "app-user/user/handleUserPoints", consumes = MediaType.APPLICATION_JSON_VALUE) |
|||
Result<UserDTO> handleUserPoints(EpdcUserPointsFormDTO formDTO); |
|||
|
|||
/** |
|||
* @return com.elink.esua.epdc.commons.tools.utils.Result<com.elink.esua.epdc.dto.UserGridRelationDTO> |
|||
* @Description 获取用户最后一次切换网格信息 |
|||
* @Author songyunpeng |
|||
* @Date 2020/5/14 |
|||
* @Param [userId] |
|||
**/ |
|||
@GetMapping(value = "app-user/usergrid/getUserLastSwitchGird/{userId}", consumes = MediaType.APPLICATION_JSON_VALUE) |
|||
Result<UserGridRelationDTO> getUserLastSwitchGird(@PathVariable("userId") String userId); |
|||
} |
|||
|
@ -1,10 +1,10 @@ |
|||
package com.elink.esua.epdc.modules.feign.fallback; |
|||
package com.elink.esua.epdc.feign.fallback; |
|||
|
|||
import com.elink.esua.epdc.commons.tools.constant.ServiceConstant; |
|||
import com.elink.esua.epdc.commons.tools.utils.ModuleUtils; |
|||
import com.elink.esua.epdc.commons.tools.utils.Result; |
|||
import com.elink.esua.epdc.dto.epdc.form.EpdcInformationFormDTO; |
|||
import com.elink.esua.epdc.modules.feign.NewsFeignClient; |
|||
import com.elink.esua.epdc.feign.NewsFeignClient; |
|||
import org.springframework.stereotype.Component; |
|||
|
|||
/** |
@ -0,0 +1,38 @@ |
|||
package com.elink.esua.epdc.feign.fallback; |
|||
|
|||
import com.elink.esua.epdc.commons.tools.constant.ServiceConstant; |
|||
import com.elink.esua.epdc.commons.tools.utils.ModuleUtils; |
|||
import com.elink.esua.epdc.commons.tools.utils.Result; |
|||
import com.elink.esua.epdc.dto.UserDTO; |
|||
import com.elink.esua.epdc.dto.UserGridRelationDTO; |
|||
import com.elink.esua.epdc.dto.epdc.form.EpdcUserPointsFormDTO; |
|||
import com.elink.esua.epdc.feign.UsersFeignClient; |
|||
import org.springframework.stereotype.Component; |
|||
|
|||
/** |
|||
* @author songyunpeng |
|||
* @date 2020/4/28 9:30 |
|||
*/ |
|||
@Component |
|||
public class UsersFeignClientFallback implements UsersFeignClient { |
|||
|
|||
@Override |
|||
public Result<UserDTO> getUserById(String id) { |
|||
return ModuleUtils.feignConError(ServiceConstant.EPDC_USER_SERVER, "get", id); |
|||
} |
|||
|
|||
@Override |
|||
public Result updateUser(UserDTO dto) { |
|||
return ModuleUtils.feignConError(ServiceConstant.EPDC_USER_SERVER, "update", dto); |
|||
} |
|||
|
|||
@Override |
|||
public Result<UserDTO> handleUserPoints(EpdcUserPointsFormDTO formDTO) { |
|||
return ModuleUtils.feignConError(ServiceConstant.EPDC_USER_SERVER, "handleUserPoints", formDTO); |
|||
} |
|||
|
|||
@Override |
|||
public Result<UserGridRelationDTO> getUserLastSwitchGird(String userId) { |
|||
return ModuleUtils.feignConError(ServiceConstant.EPDC_USER_SERVER, "getUserLastSwitchGird", userId); |
|||
} |
|||
} |
@ -0,0 +1,41 @@ |
|||
/** |
|||
* Copyright (c) 2018 人人开源 All rights reserved. |
|||
* |
|||
* https://www.renren.io
|
|||
* |
|||
* 版权所有,侵权必究! |
|||
*/ |
|||
|
|||
package com.elink.esua.epdc.jwt; |
|||
|
|||
import org.springframework.boot.context.properties.ConfigurationProperties; |
|||
import org.springframework.context.annotation.Configuration; |
|||
|
|||
/** |
|||
* Jwt |
|||
* |
|||
* @author Mark sunlightcs@gmail.com |
|||
* @since 1.0.0 |
|||
*/ |
|||
@Configuration |
|||
@ConfigurationProperties(prefix = "jwt.token") |
|||
public class JwtTokenProperties { |
|||
private String secret; |
|||
private int expire; |
|||
|
|||
public String getSecret() { |
|||
return secret; |
|||
} |
|||
|
|||
public void setSecret(String secret) { |
|||
this.secret = secret; |
|||
} |
|||
|
|||
public int getExpire() { |
|||
return expire; |
|||
} |
|||
|
|||
public void setExpire(int expire) { |
|||
this.expire = expire; |
|||
} |
|||
} |
@ -0,0 +1,68 @@ |
|||
/** |
|||
* Copyright (c) 2018 人人开源 All rights reserved. |
|||
* <p> |
|||
* https://www.renren.io
|
|||
* <p> |
|||
* 版权所有,侵权必究! |
|||
*/ |
|||
|
|||
package com.elink.esua.epdc.jwt; |
|||
|
|||
import io.jsonwebtoken.Claims; |
|||
import io.jsonwebtoken.Jwts; |
|||
import io.jsonwebtoken.SignatureAlgorithm; |
|||
import org.joda.time.DateTime; |
|||
import org.slf4j.Logger; |
|||
import org.slf4j.LoggerFactory; |
|||
import org.springframework.beans.factory.annotation.Autowired; |
|||
import org.springframework.stereotype.Component; |
|||
|
|||
import java.util.Date; |
|||
|
|||
/** |
|||
* Jwt工具类 |
|||
* |
|||
* @author Mark sunlightcs@gmail.com |
|||
* @since 1.0.0 |
|||
*/ |
|||
@Component |
|||
public class JwtTokenUtils { |
|||
private static final Logger logger = LoggerFactory.getLogger(JwtTokenUtils.class); |
|||
|
|||
@Autowired |
|||
private JwtTokenProperties jwtProperties; |
|||
|
|||
/** |
|||
* 生成jwt token |
|||
*/ |
|||
public String generateToken(String userId) { |
|||
return Jwts.builder() |
|||
.setHeaderParam("typ", "JWT") |
|||
.setSubject(userId) |
|||
.setIssuedAt(new Date()) |
|||
.setExpiration(DateTime.now().plusSeconds(jwtProperties.getExpire()).toDate()) |
|||
.signWith(SignatureAlgorithm.HS512, jwtProperties.getSecret()) |
|||
.compact(); |
|||
} |
|||
|
|||
public Claims getClaimByToken(String token) { |
|||
try { |
|||
return Jwts.parser() |
|||
.setSigningKey(jwtProperties.getSecret()) |
|||
.parseClaimsJws(token) |
|||
.getBody(); |
|||
} catch (Exception e) { |
|||
logger.debug("validate is token error, token = " + token, e); |
|||
return null; |
|||
} |
|||
} |
|||
|
|||
/** |
|||
* token是否过期 |
|||
* |
|||
* @return true:过期 |
|||
*/ |
|||
public boolean isTokenExpired(Date expiration) { |
|||
return expiration.before(new Date()); |
|||
} |
|||
} |
@ -1,42 +0,0 @@ |
|||
package com.elink.esua.epdc.modules.feign; |
|||
|
|||
import com.elink.esua.epdc.commons.tools.constant.ServiceConstant; |
|||
import com.elink.esua.epdc.commons.tools.utils.Result; |
|||
import com.elink.esua.epdc.dto.UserDTO; |
|||
import com.elink.esua.epdc.dto.epdc.form.EpdcUserPointsFormDTO; |
|||
import com.elink.esua.epdc.modules.feign.fallback.UserFeignClientFallback; |
|||
import org.springframework.cloud.openfeign.FeignClient; |
|||
import org.springframework.http.MediaType; |
|||
import org.springframework.web.bind.annotation.GetMapping; |
|||
import org.springframework.web.bind.annotation.PathVariable; |
|||
import org.springframework.web.bind.annotation.PostMapping; |
|||
|
|||
/** |
|||
* @Description 用户模块 |
|||
* @Author yinzuomei |
|||
* @Date 2019/12/13 10:00 |
|||
*/ |
|||
@FeignClient(name = ServiceConstant.EPDC_USER_SERVER, fallback = UserFeignClientFallback.class) |
|||
public interface UserFeignClient { |
|||
|
|||
/** |
|||
* @param formDTO |
|||
* @return com.elink.esua.epdc.dto.UserDTO |
|||
* @Author yinzuomei |
|||
* @Description 根据操作类型更新用户积分 |
|||
* @Date 2019/12/13 15:12 |
|||
**/ |
|||
@PostMapping(value = "app-user/user/handleUserPoints", consumes = MediaType.APPLICATION_JSON_VALUE) |
|||
Result<UserDTO> handleUserPoints(EpdcUserPointsFormDTO formDTO); |
|||
|
|||
/** |
|||
* 查询用户基础信息 |
|||
* |
|||
* @param userId |
|||
* @return com.elink.esua.epdc.commons.tools.utils.Result<com.elink.esua.epdc.dto.UserDTO> |
|||
* @author work@yujt.net.cn |
|||
* @date 2019/10/26 15:16 |
|||
*/ |
|||
@GetMapping("app-user/epdc-app/user/getById/{userId}") |
|||
Result<UserDTO> getUserInfoById(@PathVariable("userId") String userId); |
|||
} |
@ -1,28 +0,0 @@ |
|||
package com.elink.esua.epdc.modules.feign.fallback; |
|||
|
|||
import com.elink.esua.epdc.commons.tools.constant.ServiceConstant; |
|||
import com.elink.esua.epdc.commons.tools.utils.ModuleUtils; |
|||
import com.elink.esua.epdc.commons.tools.utils.Result; |
|||
import com.elink.esua.epdc.dto.UserDTO; |
|||
import com.elink.esua.epdc.dto.epdc.form.EpdcUserPointsFormDTO; |
|||
import com.elink.esua.epdc.modules.feign.UserFeignClient; |
|||
import org.springframework.stereotype.Component; |
|||
|
|||
/** |
|||
* @Description |
|||
* @Author yinzuomei |
|||
* @Date 2019/12/13 10:00 |
|||
*/ |
|||
@Component |
|||
public class UserFeignClientFallback implements UserFeignClient { |
|||
|
|||
@Override |
|||
public Result<UserDTO> handleUserPoints(EpdcUserPointsFormDTO formDTO) { |
|||
return ModuleUtils.feignConError(ServiceConstant.EPDC_USER_SERVER, "handleUserPoints", formDTO); |
|||
} |
|||
|
|||
@Override |
|||
public Result<UserDTO> getUserInfoById(String userId) { |
|||
return ModuleUtils.feignConError(ServiceConstant.EPDC_USER_SERVER, "getUserInfoById", userId); |
|||
} |
|||
} |
@ -1,192 +0,0 @@ |
|||
/** |
|||
* Copyright 2018 人人开源 https://www.renren.io
|
|||
* <p> |
|||
* This program is free software: you can redistribute it and/or modify |
|||
* it under the terms of the GNU General Public License as published by |
|||
* the Free Software Foundation, either version 3 of the License, or |
|||
* (at your option) any later version. |
|||
* <p> |
|||
* This program is distributed in the hope that it will be useful, |
|||
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
|||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|||
* GNU General Public License for more details. |
|||
* <p> |
|||
* You should have received a copy of the GNU General Public License |
|||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|||
*/ |
|||
|
|||
package com.elink.esua.epdc.modules.logs.service.impl; |
|||
|
|||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
|||
import com.baomidou.mybatisplus.core.metadata.IPage; |
|||
import com.elink.esua.epdc.commons.mybatis.service.impl.BaseServiceImpl; |
|||
import com.elink.esua.epdc.commons.tools.constant.FieldConstant; |
|||
import com.elink.esua.epdc.commons.tools.constant.NumConstant; |
|||
import com.elink.esua.epdc.commons.tools.constant.PointsConstant; |
|||
import com.elink.esua.epdc.commons.tools.enums.YesOrNoEnum; |
|||
import com.elink.esua.epdc.commons.tools.enums.pointsenum.PointsOperationEnum; |
|||
import com.elink.esua.epdc.commons.tools.enums.pointsenum.PointsOperationModeEnum; |
|||
import com.elink.esua.epdc.commons.tools.page.PageData; |
|||
import com.elink.esua.epdc.commons.tools.utils.ConvertUtils; |
|||
import com.elink.esua.epdc.commons.tools.utils.Result; |
|||
import com.elink.esua.epdc.constant.PointsNoticeConstant; |
|||
import com.elink.esua.epdc.dto.UserDTO; |
|||
import com.elink.esua.epdc.dto.epdc.form.EpdcInformationFormDTO; |
|||
import com.elink.esua.epdc.dto.epdc.form.EpdcUserPointsFormDTO; |
|||
import com.elink.esua.epdc.dto.epdc.result.EpdcAdjustVolunteerPointsDTO; |
|||
import com.elink.esua.epdc.dto.logs.PointsLogsDTO; |
|||
import com.elink.esua.epdc.modules.async.NewsTask; |
|||
import com.elink.esua.epdc.modules.feign.UserFeignClient; |
|||
import com.elink.esua.epdc.modules.logs.dao.PointsLogsDao; |
|||
import com.elink.esua.epdc.modules.logs.entity.PointsLogsEntity; |
|||
import com.elink.esua.epdc.modules.logs.redis.PointsLogsRedis; |
|||
import com.elink.esua.epdc.modules.logs.service.PointsLogsService; |
|||
import org.apache.commons.lang3.StringUtils; |
|||
import org.springframework.beans.factory.annotation.Autowired; |
|||
import org.springframework.stereotype.Service; |
|||
import org.springframework.transaction.annotation.Transactional; |
|||
|
|||
import java.util.Arrays; |
|||
import java.util.Date; |
|||
import java.util.List; |
|||
import java.util.Map; |
|||
|
|||
/** |
|||
* 积分日志表 |
|||
* |
|||
* @author qu qu@elink-cn.com |
|||
* @since v1.0.0 2019-12-13 |
|||
*/ |
|||
@Service |
|||
public class PointsLogsServiceImpl extends BaseServiceImpl<PointsLogsDao, PointsLogsEntity> implements PointsLogsService { |
|||
|
|||
@Autowired |
|||
private PointsLogsRedis pointsLogsRedis; |
|||
|
|||
@Autowired |
|||
private UserFeignClient userFeignClient; |
|||
|
|||
@Autowired |
|||
private NewsTask newsTask; |
|||
|
|||
@Override |
|||
public PageData<PointsLogsDTO> page(Map<String, Object> params) { |
|||
IPage<PointsLogsDTO> page = getPage(params); |
|||
List<PointsLogsDTO> list = baseDao.selectListVolunteerPointsLog(params); |
|||
return new PageData<>(list, page.getTotal()); |
|||
} |
|||
|
|||
@Override |
|||
public List<PointsLogsDTO> list(Map<String, Object> params) { |
|||
List<PointsLogsEntity> entityList = baseDao.selectList(getWrapper(params)); |
|||
|
|||
return ConvertUtils.sourceToTarget(entityList, PointsLogsDTO.class); |
|||
} |
|||
|
|||
private QueryWrapper<PointsLogsEntity> getWrapper(Map<String, Object> params) { |
|||
String id = (String) params.get(FieldConstant.ID_HUMP); |
|||
|
|||
QueryWrapper<PointsLogsEntity> wrapper = new QueryWrapper<>(); |
|||
wrapper.eq(StringUtils.isNotBlank(id), FieldConstant.ID, id); |
|||
|
|||
return wrapper; |
|||
} |
|||
|
|||
@Override |
|||
public PointsLogsDTO get(String id) { |
|||
PointsLogsEntity entity = baseDao.selectById(id); |
|||
return ConvertUtils.sourceToTarget(entity, PointsLogsDTO.class); |
|||
} |
|||
|
|||
@Override |
|||
@Transactional(rollbackFor = Exception.class) |
|||
public Result save(PointsLogsDTO dto) { |
|||
PointsLogsEntity entity = ConvertUtils.sourceToTarget(dto, PointsLogsEntity.class); |
|||
insert(entity); |
|||
return new Result(); |
|||
} |
|||
|
|||
@Override |
|||
@Transactional(rollbackFor = Exception.class) |
|||
public void update(PointsLogsDTO dto) { |
|||
PointsLogsEntity entity = ConvertUtils.sourceToTarget(dto, PointsLogsEntity.class); |
|||
updateById(entity); |
|||
} |
|||
|
|||
@Override |
|||
@Transactional(rollbackFor = Exception.class) |
|||
public void delete(String[] ids) { |
|||
// 逻辑删除(@TableLogic 注解)
|
|||
baseDao.deleteBatchIds(Arrays.asList(ids)); |
|||
} |
|||
|
|||
/** |
|||
* @param formDto |
|||
* @return com.elink.esua.epdc.commons.tools.utils.Result |
|||
* @Author yinzuomei |
|||
* @Description 确定调整用户积分 |
|||
* @Date 2019/12/16 18:56 |
|||
**/ |
|||
@Override |
|||
@Transactional(rollbackFor = Exception.class) |
|||
public Result confirmAdjustPoint(EpdcAdjustVolunteerPointsDTO formDto) { |
|||
if (formDto.getOperatePoints() == NumConstant.ZERO) { |
|||
return new Result().error("操作积分不能为0"); |
|||
} |
|||
PointsLogsEntity pointsLogsEntity = new PointsLogsEntity(); |
|||
pointsLogsEntity.setVolunteerId(formDto.getId()); |
|||
pointsLogsEntity.setUserId(formDto.getUserId()); |
|||
pointsLogsEntity.setOperationTime(new Date()); |
|||
pointsLogsEntity.setOperationMode(PointsOperationModeEnum.OPERATION_MODE_ADMIN.getOperationMode());//操作方式(user-用户操作,admin-管理员操作,sys-系统操作)
|
|||
pointsLogsEntity.setStatus(YesOrNoEnum.YES.value()); |
|||
pointsLogsEntity.setFailureReason(""); |
|||
pointsLogsEntity.setRuleCode(PointsConstant.ruleCode); |
|||
pointsLogsEntity.setOperationDesc(formDto.getAdjustReason());//操作描述
|
|||
pointsLogsEntity.setPoints(formDto.getOperatePoints()); |
|||
pointsLogsEntity.setOperationType(formDto.getOperationType());//积分操作类型(0-减积分,1-加积分)
|
|||
EpdcUserPointsFormDTO userPointsFormDTO = new EpdcUserPointsFormDTO(); |
|||
userPointsFormDTO.setUserId(formDto.getUserId()); |
|||
userPointsFormDTO.setPoints(formDto.getOperatePoints()); |
|||
userPointsFormDTO.setOperationType(formDto.getOperationType()); |
|||
Result<UserDTO> result = userFeignClient.handleUserPoints(userPointsFormDTO); |
|||
if (!result.success()) { |
|||
return new Result().error("调整用户积分失败"); |
|||
} |
|||
//剩余积分
|
|||
pointsLogsEntity.setLavePoints(result.getData().getPoints()); |
|||
pointsLogsEntity.setBehaviorCode(formDto.getBehaviorCode()); |
|||
this.insert(pointsLogsEntity); |
|||
//给用户发送消息通知
|
|||
this.issueSmsNotification(pointsLogsEntity); |
|||
return new Result(); |
|||
} |
|||
|
|||
/** |
|||
* @param pointsLogsEntity |
|||
* @return void |
|||
* @Author yinzuomei |
|||
* @Description 调整积分完成后-给用户发送消息通知 |
|||
* @Date 2020/2/7 22:12 |
|||
**/ |
|||
private void issueSmsNotification(PointsLogsEntity pointsLogsEntity) { |
|||
EpdcInformationFormDTO informationFormDTO = new EpdcInformationFormDTO(); |
|||
informationFormDTO.setUserId(pointsLogsEntity.getUserId()); |
|||
String content = ""; |
|||
//积分操作类型(0-减积分,1-加积分)
|
|||
if (PointsOperationEnum.OPERATION_TYPE_ADD.getOperationType().equals(pointsLogsEntity.getOperationType())) { |
|||
informationFormDTO.setTitle(PointsNoticeConstant.ADD_POINTS_NOTICE); |
|||
content = PointsNoticeConstant.ADD_POINTS + pointsLogsEntity.getPoints() + PointsNoticeConstant.REASON + pointsLogsEntity.getOperationDesc(); |
|||
|
|||
} else if (PointsOperationEnum.OPERATION_TYPE_SUBSTRACT.getOperationType().equals(pointsLogsEntity.getOperationType())) { |
|||
informationFormDTO.setTitle(PointsNoticeConstant.SUBTRACT_POINTS_NOTICE); |
|||
content = PointsNoticeConstant.SUBTRACT_POINTS + pointsLogsEntity.getPoints() + PointsNoticeConstant.REASON + pointsLogsEntity.getOperationDesc(); |
|||
} |
|||
informationFormDTO.setContent(content); |
|||
informationFormDTO.setType(PointsNoticeConstant.NOTICE_TYPE_INTERACTIVE_NOTICE); |
|||
informationFormDTO.setBusinessType(PointsNoticeConstant.NOTICE__BUSINESS_TYPE_ACTIVITY); |
|||
informationFormDTO.setBusinessId(pointsLogsEntity.getId()); |
|||
informationFormDTO.setRelBusinessContent(""); |
|||
// 发送消息
|
|||
newsTask.insertUserInformation(informationFormDTO); |
|||
} |
|||
} |
@ -1,103 +0,0 @@ |
|||
/** |
|||
* Copyright 2018 人人开源 https://www.renren.io
|
|||
* <p> |
|||
* This program is free software: you can redistribute it and/or modify |
|||
* it under the terms of the GNU General Public License as published by |
|||
* the Free Software Foundation, either version 3 of the License, or |
|||
* (at your option) any later version. |
|||
* <p> |
|||
* This program is distributed in the hope that it will be useful, |
|||
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
|||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|||
* GNU General Public License for more details. |
|||
* <p> |
|||
* You should have received a copy of the GNU General Public License |
|||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|||
*/ |
|||
|
|||
package com.elink.esua.epdc.modules.rule.controller; |
|||
|
|||
import com.elink.esua.epdc.commons.tools.page.PageData; |
|||
import com.elink.esua.epdc.commons.tools.utils.ExcelUtils; |
|||
import com.elink.esua.epdc.commons.tools.utils.Result; |
|||
import com.elink.esua.epdc.commons.tools.validator.AssertUtils; |
|||
import com.elink.esua.epdc.commons.tools.validator.ValidatorUtils; |
|||
import com.elink.esua.epdc.commons.tools.validator.group.AddGroup; |
|||
import com.elink.esua.epdc.commons.tools.validator.group.UpdateGroup; |
|||
import com.elink.esua.epdc.commons.tools.validator.group.DefaultGroup; |
|||
import com.elink.esua.epdc.dto.rule.PointsRuleDTO; |
|||
import com.elink.esua.epdc.modules.rule.excel.PointsRuleExcel; |
|||
import com.elink.esua.epdc.modules.rule.service.PointsRuleService; |
|||
import org.springframework.beans.factory.annotation.Autowired; |
|||
import org.springframework.web.bind.annotation.*; |
|||
|
|||
import javax.servlet.http.HttpServletResponse; |
|||
import java.util.List; |
|||
import java.util.Map; |
|||
|
|||
|
|||
/** |
|||
* 积分规则表 |
|||
* |
|||
* @author qu qu@elink-cn.com |
|||
* @since v1.0.0 2019-12-11 |
|||
*/ |
|||
@RestController |
|||
@RequestMapping("pointsrule") |
|||
public class PointsRuleController { |
|||
|
|||
@Autowired |
|||
private PointsRuleService pointsRuleService; |
|||
|
|||
@GetMapping("page") |
|||
public Result<PageData<PointsRuleDTO>> page(@RequestParam Map<String, Object> params) { |
|||
PageData<PointsRuleDTO> page = pointsRuleService.page(params); |
|||
return new Result<PageData<PointsRuleDTO>>().ok(page); |
|||
} |
|||
|
|||
@GetMapping("{id}") |
|||
public Result<PointsRuleDTO> get(@PathVariable("id") String id) { |
|||
PointsRuleDTO data = pointsRuleService.get(id); |
|||
return new Result<PointsRuleDTO>().ok(data); |
|||
} |
|||
|
|||
@PostMapping |
|||
public Result save(@RequestBody PointsRuleDTO dto) { |
|||
//效验数据
|
|||
ValidatorUtils.validateEntity(dto, AddGroup.class, DefaultGroup.class); |
|||
return pointsRuleService.save(dto); |
|||
} |
|||
|
|||
@PutMapping |
|||
public Result update(@RequestBody PointsRuleDTO dto) { |
|||
//效验数据
|
|||
ValidatorUtils.validateEntity(dto, UpdateGroup.class, DefaultGroup.class); |
|||
return pointsRuleService.update(dto); |
|||
} |
|||
|
|||
@DeleteMapping |
|||
public Result delete(@RequestBody String[] ids) { |
|||
//效验数据
|
|||
AssertUtils.isArrayEmpty(ids, "id"); |
|||
pointsRuleService.delete(ids); |
|||
return new Result(); |
|||
} |
|||
|
|||
@GetMapping("export") |
|||
public void export(@RequestParam Map<String, Object> params, HttpServletResponse response) throws Exception { |
|||
List<PointsRuleDTO> list = pointsRuleService.list(params); |
|||
ExcelUtils.exportExcelToTarget(response, null, list, PointsRuleExcel.class); |
|||
} |
|||
|
|||
/** |
|||
* @param ruleCode |
|||
* @return com.elink.esua.epdc.commons.tools.utils.Result<com.elink.esua.epdc.dto.rule.PointsRuleDTO> |
|||
* @Author yinzuomei |
|||
* @Description 根据规则编码查询规则信息 |
|||
* @Date 2019/12/12 16:29 |
|||
**/ |
|||
@GetMapping("getPointRule/{ruleCode}") |
|||
public Result<PointsRuleDTO> getPointRule(@PathVariable("ruleCode") String ruleCode) { |
|||
return pointsRuleService.getPointRule(ruleCode); |
|||
} |
|||
} |
@ -1,235 +0,0 @@ |
|||
/** |
|||
* Copyright 2018 人人开源 https://www.renren.io
|
|||
* <p> |
|||
* This program is free software: you can redistribute it and/or modify |
|||
* it under the terms of the GNU General Public License as published by |
|||
* the Free Software Foundation, either version 3 of the License, or |
|||
* (at your option) any later version. |
|||
* <p> |
|||
* This program is distributed in the hope that it will be useful, |
|||
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
|||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|||
* GNU General Public License for more details. |
|||
* <p> |
|||
* You should have received a copy of the GNU General Public License |
|||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|||
*/ |
|||
|
|||
package com.elink.esua.epdc.modules.rule.service.impl; |
|||
|
|||
import cn.hutool.core.collection.CollUtil; |
|||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
|||
import com.baomidou.mybatisplus.core.metadata.IPage; |
|||
import com.elink.esua.epdc.commons.mybatis.service.impl.BaseServiceImpl; |
|||
import com.elink.esua.epdc.commons.tools.constant.FieldConstant; |
|||
import com.elink.esua.epdc.commons.tools.enums.pointsenum.PointsLimitTimeEnum; |
|||
import com.elink.esua.epdc.commons.tools.enums.pointsenum.PointsRuleAvailableEnum; |
|||
import com.elink.esua.epdc.commons.tools.enums.pointsenum.PointsUpperLimitEnum; |
|||
import com.elink.esua.epdc.commons.tools.page.PageData; |
|||
import com.elink.esua.epdc.commons.tools.redis.RedisKeys; |
|||
import com.elink.esua.epdc.commons.tools.redis.RedisUtils; |
|||
import com.elink.esua.epdc.commons.tools.utils.ConvertUtils; |
|||
import com.elink.esua.epdc.commons.tools.utils.Result; |
|||
import com.elink.esua.epdc.dto.rule.PointsRuleDTO; |
|||
import com.elink.esua.epdc.modules.rule.dao.PointsRuleDao; |
|||
import com.elink.esua.epdc.modules.rule.entity.PointsRuleEntity; |
|||
import com.elink.esua.epdc.modules.rule.redis.PointsRuleRedis; |
|||
import com.elink.esua.epdc.modules.rule.service.PointsRuleService; |
|||
import org.apache.commons.lang3.StringUtils; |
|||
import org.springframework.beans.factory.annotation.Autowired; |
|||
import org.springframework.stereotype.Service; |
|||
import org.springframework.transaction.annotation.Transactional; |
|||
|
|||
import java.util.Arrays; |
|||
import java.util.List; |
|||
import java.util.Map; |
|||
|
|||
/** |
|||
* 积分规则表 |
|||
* |
|||
* @author qu qu@elink-cn.com |
|||
* @since v1.0.0 2019-12-11 |
|||
*/ |
|||
@Service |
|||
public class PointsRuleServiceImpl extends BaseServiceImpl<PointsRuleDao, PointsRuleEntity> implements PointsRuleService { |
|||
|
|||
@Autowired |
|||
private PointsRuleRedis pointsRuleRedis; |
|||
|
|||
@Autowired |
|||
private RedisUtils redisUtils; |
|||
|
|||
@Override |
|||
public PageData<PointsRuleDTO> page(Map<String, Object> params) { |
|||
String ruleDesc = (String) params.get("ruleDesc"); |
|||
String behaviorCode = (String) params.get("behaviorCode"); |
|||
String behaviorDesc = (String) params.get("behaviorDesc"); |
|||
String ruleCode = (String) params.get("ruleCode"); |
|||
String operationType = (String) params.get("operationType"); |
|||
String available = (String) params.get("available"); |
|||
String upperLimitFlag = (String) params.get("upperLimitFlag"); |
|||
String startTime = (String) params.get("startTime"); |
|||
String endTime = (String) params.get("endTime"); |
|||
QueryWrapper<PointsRuleEntity> wrapper = new QueryWrapper<>(); |
|||
wrapper.like(StringUtils.isNotBlank(ruleDesc), "RULE_DESC", ruleDesc.trim()) |
|||
.like(StringUtils.isNotBlank(behaviorDesc), "BEHAVIOR_DESC", behaviorDesc.trim()) |
|||
.like(StringUtils.isNotBlank(ruleCode), "RULE_CODE", ruleCode.trim()) |
|||
.eq(StringUtils.isNotBlank(operationType), "OPERATION_TYPE", operationType) |
|||
.eq(StringUtils.isNotBlank(available), "AVAILABLE", available) |
|||
.eq(StringUtils.isNotBlank(upperLimitFlag), "UPPER_LIMIT_FLAG", upperLimitFlag) |
|||
.eq(StringUtils.isNotBlank(behaviorCode), "BEHAVIOR_CODE", behaviorCode) |
|||
.between(StringUtils.isNotBlank(startTime) && StringUtils.isNotBlank(endTime), |
|||
"DATE_FORMAT(CREATED_TIME, '%Y-%m-%d' )", |
|||
startTime, |
|||
endTime); |
|||
IPage<PointsRuleEntity> page = baseDao.selectPage( |
|||
getPage(params, FieldConstant.CREATED_TIME, false), |
|||
wrapper |
|||
); |
|||
return getPageData(page, PointsRuleDTO.class); |
|||
} |
|||
|
|||
@Override |
|||
public List<PointsRuleDTO> list(Map<String, Object> params) { |
|||
List<PointsRuleEntity> entityList = baseDao.selectList(getWrapper(params)); |
|||
|
|||
return ConvertUtils.sourceToTarget(entityList, PointsRuleDTO.class); |
|||
} |
|||
|
|||
private QueryWrapper<PointsRuleEntity> getWrapper(Map<String, Object> params) { |
|||
String id = (String) params.get(FieldConstant.ID_HUMP); |
|||
|
|||
QueryWrapper<PointsRuleEntity> wrapper = new QueryWrapper<>(); |
|||
wrapper.eq(StringUtils.isNotBlank(id), FieldConstant.ID, id); |
|||
|
|||
return wrapper; |
|||
} |
|||
|
|||
@Override |
|||
public PointsRuleDTO get(String id) { |
|||
PointsRuleEntity entity = baseDao.selectById(id); |
|||
return ConvertUtils.sourceToTarget(entity, PointsRuleDTO.class); |
|||
} |
|||
|
|||
@Override |
|||
@Transactional(rollbackFor = Exception.class) |
|||
public Result save(PointsRuleDTO dto) { |
|||
Result checkResult = checkPointsRuleDTO(dto); |
|||
if (!checkResult.success()) { |
|||
return checkResult; |
|||
} |
|||
if(StringUtils.isBlank(dto.getLimitTimeType())){ |
|||
dto.setLimitTimeType(PointsLimitTimeEnum.LIMIT_TIME_MINUTE.value()); |
|||
} |
|||
dto.setAvailable(PointsRuleAvailableEnum.AVAILABLE_TRUE.value());//可用标记(0-不可用,1-可用) 新增时默认可用
|
|||
PointsRuleEntity entity = ConvertUtils.sourceToTarget(dto, PointsRuleEntity.class); |
|||
insert(entity); |
|||
String pointsRuleKey = RedisKeys.getPointsRuleKey(dto.getRuleCode()); |
|||
redisUtils.set(pointsRuleKey, entity); |
|||
return new Result(); |
|||
} |
|||
|
|||
@Override |
|||
@Transactional(rollbackFor = Exception.class) |
|||
public Result update(PointsRuleDTO dto) { |
|||
Result checkResult = checkPointsRuleDTO(dto); |
|||
if (!checkResult.success()) { |
|||
return checkResult; |
|||
} |
|||
if(StringUtils.isBlank(dto.getLimitTimeType())){ |
|||
dto.setLimitTimeType(PointsLimitTimeEnum.LIMIT_TIME_MINUTE.value()); |
|||
} |
|||
PointsRuleEntity entity = ConvertUtils.sourceToTarget(dto, PointsRuleEntity.class); |
|||
updateById(entity); |
|||
String pointsRuleKey = RedisKeys.getPointsRuleKey(dto.getRuleCode()); |
|||
redisUtils.set(pointsRuleKey, entity); |
|||
return new Result(); |
|||
} |
|||
|
|||
@Override |
|||
@Transactional(rollbackFor = Exception.class) |
|||
public void delete(String[] ids) { |
|||
// 逻辑删除(@TableLogic 注解)
|
|||
QueryWrapper<PointsRuleEntity> wrapper = new QueryWrapper<>(); |
|||
wrapper.in(FieldConstant.ID, ids); |
|||
List<PointsRuleEntity> pointsRuleEntityList = baseDao.selectList(wrapper); |
|||
for (PointsRuleEntity pointsRuleEntity : pointsRuleEntityList) { |
|||
String pointsRuleKey = RedisKeys.getPointsRuleKey(pointsRuleEntity.getRuleCode()); |
|||
redisUtils.delete(pointsRuleKey); |
|||
} |
|||
baseDao.deleteBatchIds(Arrays.asList(ids)); |
|||
} |
|||
|
|||
/** |
|||
* @param |
|||
* @return com.elink.esua.epdc.commons.tools.utils.Result |
|||
* @Author yinzuomei |
|||
* @Description 项目启动初始化积分规则到redis |
|||
* @Date 2019/12/12 16:26 |
|||
**/ |
|||
@Override |
|||
public Result initPointsRuleRedis() { |
|||
QueryWrapper<PointsRuleEntity> wrapper = new QueryWrapper<>(); |
|||
wrapper.eq("AVAILABLE", PointsRuleAvailableEnum.AVAILABLE_TRUE.value()); |
|||
List<PointsRuleEntity> pointsRuleEntityList = baseDao.selectList(wrapper); |
|||
for (PointsRuleEntity pointsRuleEntity : pointsRuleEntityList) { |
|||
String pointsRuleKey = RedisKeys.getPointsRuleKey(pointsRuleEntity.getRuleCode()); |
|||
redisUtils.set(pointsRuleKey, pointsRuleEntity); |
|||
} |
|||
return new Result(); |
|||
} |
|||
|
|||
/** |
|||
* @param ruleCode |
|||
* @return com.elink.esua.epdc.dto.rule.PointsRuleDTO |
|||
* @Author yinzuomei |
|||
* @Description 根据规则编码查询规则信息 |
|||
* @Date 2019/12/12 16:30 |
|||
**/ |
|||
@Override |
|||
public Result<PointsRuleDTO> getPointRule(String ruleCode) { |
|||
if (StringUtils.isBlank(ruleCode)) { |
|||
return new Result<PointsRuleDTO>().error("规则编码不能为空"); |
|||
} |
|||
String pointsRuleKey = RedisKeys.getPointsRuleKey(ruleCode); |
|||
Object obj = redisUtils.get(pointsRuleKey); |
|||
if (null == obj) { |
|||
QueryWrapper<PointsRuleEntity> wrapper = new QueryWrapper<>(); |
|||
wrapper.eq("RULE_CODE", ruleCode); |
|||
List<PointsRuleEntity> pointsRuleEntityList = baseDao.selectList(wrapper); |
|||
if (CollUtil.isEmpty(pointsRuleEntityList)) { |
|||
return new Result<PointsRuleDTO>().error("没有找到有效记录"); |
|||
} else if (pointsRuleEntityList.size() > 1) { |
|||
return new Result<PointsRuleDTO>().error("规则编码不唯一"); |
|||
} |
|||
redisUtils.set(pointsRuleKey, pointsRuleEntityList.get(0)); |
|||
obj = redisUtils.get(pointsRuleKey); |
|||
} |
|||
PointsRuleDTO pointsRuleDTO = ConvertUtils.sourceToTarget(obj, PointsRuleDTO.class); |
|||
return new Result<PointsRuleDTO>().ok(pointsRuleDTO); |
|||
} |
|||
|
|||
/** |
|||
* @param dto |
|||
* @return com.elink.esua.epdc.commons.tools.utils.Result |
|||
* @Author yinzuomei |
|||
* @Description 校验界面提交数据 |
|||
* @Date 2019/12/11 17:56 |
|||
**/ |
|||
public Result checkPointsRuleDTO(PointsRuleDTO dto) { |
|||
//规则有上限值:积分值不能大于上限值
|
|||
if (PointsUpperLimitEnum.YES.value().equals(dto.getUpperLimitFlag()) |
|||
&& dto.getPoints() > dto.getUpperLimitVal()) { |
|||
return new Result().error("积分值不能大于上限值"); |
|||
} |
|||
//校验规则编码是否唯一
|
|||
QueryWrapper<PointsRuleEntity> wrapper = new QueryWrapper<>(); |
|||
wrapper.eq("RULE_CODE", dto.getRuleCode()) |
|||
.ne(StringUtils.isNotBlank(dto.getId()), FieldConstant.ID, dto.getId()); |
|||
List<PointsRuleEntity> list = baseDao.selectList(wrapper); |
|||
if (CollUtil.isNotEmpty(list)) { |
|||
return new Result().error("规则编码已存在"); |
|||
} |
|||
return new Result(); |
|||
} |
|||
} |
@ -0,0 +1,197 @@ |
|||
package com.elink.esua.epdc.mq; |
|||
|
|||
import com.alibaba.fastjson.JSONObject; |
|||
import com.elink.esua.epdc.common.token.dto.TokenDto; |
|||
import com.elink.esua.epdc.common.token.util.CpUserDetailRedis; |
|||
import com.elink.esua.epdc.commons.tools.constant.RocketMqConstant; |
|||
import com.elink.esua.epdc.commons.tools.utils.ConvertUtils; |
|||
import com.elink.esua.epdc.commons.tools.utils.Result; |
|||
import com.elink.esua.epdc.dto.UserDTO; |
|||
import com.elink.esua.epdc.dto.UserGridRelationDTO; |
|||
import com.elink.esua.epdc.dto.form.PointsLogsAddFormDTO; |
|||
import com.elink.esua.epdc.dto.form.PointsLogsFormDTO; |
|||
import com.elink.esua.epdc.dto.result.PointsLogsResultDTO; |
|||
import com.elink.esua.epdc.dto.result.PointsRuleResultDTO; |
|||
import com.elink.esua.epdc.entity.PointsLogsEntity; |
|||
import com.elink.esua.epdc.feign.UsersFeignClient; |
|||
import com.elink.esua.epdc.jwt.JwtTokenProperties; |
|||
import com.elink.esua.epdc.mq.dto.BehaviorDto; |
|||
import com.elink.esua.epdc.service.PointsLogsService; |
|||
import com.elink.esua.epdc.service.PointsRuleService; |
|||
import lombok.extern.slf4j.Slf4j; |
|||
import org.apache.commons.lang3.StringUtils; |
|||
import org.apache.rocketmq.common.message.MessageExt; |
|||
import org.apache.rocketmq.spring.annotation.MessageModel; |
|||
import org.apache.rocketmq.spring.annotation.RocketMQMessageListener; |
|||
import org.apache.rocketmq.spring.core.RocketMQListener; |
|||
import org.springframework.beans.factory.annotation.Autowired; |
|||
import org.springframework.stereotype.Component; |
|||
|
|||
import java.util.List; |
|||
|
|||
/** |
|||
* 积分埋点-监听MQ消息 |
|||
* |
|||
* @Author:songyunpeng |
|||
* @Date:2020/4/28 13:44 |
|||
*/ |
|||
@Slf4j |
|||
@Component |
|||
@RocketMQMessageListener(topic = RocketMqConstant.MQ_TOPIC_POINTS, consumerGroup = "${rocketmq.consumer.points-group}", messageModel = MessageModel.BROADCASTING) |
|||
public class PointsModifyConsumer implements RocketMQListener<MessageExt> { |
|||
|
|||
@Autowired |
|||
private PointsLogsService pointsLogsService; |
|||
@Autowired |
|||
private PointsRuleService pointsRuleService; |
|||
|
|||
@Autowired |
|||
private UsersFeignClient usersFeignClient; |
|||
@Autowired |
|||
private CpUserDetailRedis cpUserDetailRedis; |
|||
@Autowired |
|||
private JwtTokenProperties jwtTokenProperties; |
|||
|
|||
|
|||
/** |
|||
* 操作类型 加分 |
|||
*/ |
|||
private static final String OPERATION_TYPE_ADD = "1"; |
|||
/** |
|||
* 操作类型 减分 |
|||
*/ |
|||
private static final String OPERATION_TYPE_SUB = "0"; |
|||
/** |
|||
* 动作限制次数 无限次 |
|||
*/ |
|||
private static final String OPERATION_LIMIT_NUM = "0"; |
|||
/** |
|||
* 成功 |
|||
*/ |
|||
private static final String SUCCESS_CODE = "success"; |
|||
|
|||
/** |
|||
* 处理逻辑:(1)根据业务ID和动作编码去日志里查看是够已经有这个记录,如果有根据规则判断是否进行积分加减 |
|||
* (2)进行用户的积分的加和减。然后更新redis里用户的积分的值,更新数据库里用户积分的值 |
|||
* (3)将用户操作记录存入日志表 |
|||
**/ |
|||
@Override |
|||
public void onMessage(MessageExt messageExt) { |
|||
log.info("EPDC-POINTS-SERVER消费消息START:{topic:{}, msgId:{}}", RocketMqConstant.MQ_TOPIC_ORGANIZATION, messageExt.getMsgId()); |
|||
try { |
|||
String charset = "UTF-8"; |
|||
String body = new String(messageExt.getBody(), charset); |
|||
BehaviorDto dto = JSONObject.parseObject(body, BehaviorDto.class); |
|||
String info = this.handlePoints(dto); |
|||
log.info("EPDC-POINTS-SERVER消费消息END:{topic:{}, msgId:{}, body:{}, info:{}}", RocketMqConstant.MQ_TOPIC_ORGANIZATION, messageExt.getMsgId(), body,info); |
|||
} catch (Exception e) { |
|||
log.info("EPDC-POINTS-SERVER消费消息失败:msgId:{}", messageExt.getMsgId()); |
|||
e.printStackTrace(); |
|||
} |
|||
} |
|||
|
|||
|
|||
/** |
|||
* 处理新闻浏览积分 同一新闻算一次 |
|||
* <p> |
|||
* 根据动作编码获取积分规则信息, |
|||
* 根据动作编码和用户ID获取此动作在一定时限内的总分,然后根据上线统计指标判断是否到达上限值,未到达加分或减分,达到则不进行操作 |
|||
*/ |
|||
private String handlePoints(BehaviorDto dto) { |
|||
//解析参数
|
|||
if (StringUtils.isBlank(dto.getReferenceId()) || StringUtils.isBlank(dto.getUserId()) || StringUtils.isBlank(dto.getBehavior())) { |
|||
return "mq参数传递出错:业务ID,用户ID或者行为为空"; |
|||
} |
|||
//计算是否超过该动作的积分上限 -- 开始
|
|||
//1.根据行为编码获取积分规则
|
|||
PointsLogsFormDTO pointsLogsFormDTO = new PointsLogsFormDTO(); |
|||
pointsLogsFormDTO.setBehaviorCode(dto.getBehavior()); |
|||
pointsLogsFormDTO.setUserId(dto.getUserId()); |
|||
pointsLogsFormDTO.setReferenceId(dto.getReferenceId()); |
|||
PointsRuleResultDTO pointsRuleResultDTO = pointsRuleService.getPointsRuleByBehaviorCode(dto.getBehavior()); |
|||
if (pointsRuleResultDTO == null) { |
|||
return "获取积分规则失败"; |
|||
} |
|||
if(pointsRuleResultDTO.getUpperLimitVal() == 0){ |
|||
return "积分限值为0,无法加分"; |
|||
} |
|||
pointsLogsFormDTO.setRuleCode(pointsRuleResultDTO.getRuleCode()); |
|||
//1.1如果规则里动作次数上限不为0则需要判断该动作是否超过次数上限
|
|||
if (!OPERATION_LIMIT_NUM.equals(pointsRuleResultDTO.getLimitNum())) { |
|||
//此处通过规则编码获取日志信息
|
|||
// (用于针对 同一个项目(同一个是关键:意思就是这里的业务ID必须是一样的,否则即使一个记分配置多个动作,也不生效)表态多次 只记录一次分数)
|
|||
List<PointsLogsResultDTO> pointsLogsResultDTs = pointsLogsService.getLogsByBehaviorCodeAndUserIdAndReferenceId(pointsLogsFormDTO); |
|||
//如果大于或者等于上限 代表不能再进行操作
|
|||
if (pointsLogsResultDTs != null && pointsLogsResultDTs.size() >= Integer.parseInt(pointsRuleResultDTO.getLimitNum())) { |
|||
return "同一项目积分已达到上限值,无法继续加分"; |
|||
} |
|||
} |
|||
//2.赋值积分规则的上限期限(小时,年。。。。)
|
|||
pointsLogsFormDTO.setOperationFlag(pointsRuleResultDTO.getLimitType()); |
|||
//3.获取前一分钟的总分
|
|||
Integer total = pointsLogsService.getPointsSumByBehaviorCodeAndUserId(pointsLogsFormDTO); |
|||
//判断总分是否超过上限
|
|||
if (total != null) { |
|||
if (Math.abs(total + pointsRuleResultDTO.getPoints()) > Math.abs(pointsRuleResultDTO.getUpperLimitVal())) { |
|||
return "该动作积分已达到上限值,无法继续加分"; |
|||
} |
|||
} |
|||
//计算是否超过该动作的积分上限 -- 结束
|
|||
//更新用户的积分 -- 开始
|
|||
//1.获取用户信息
|
|||
Result<UserDTO> userById = usersFeignClient.getUserById(dto.getUserId()); |
|||
if (!SUCCESS_CODE.equals(userById.getMsg())) { |
|||
return "通过Feign获取用户信息失败"; |
|||
} |
|||
UserDTO userDTO = userById.getData(); |
|||
if (userDTO == null) { |
|||
return "无法获取到用户信息"; |
|||
} |
|||
//判断用户是否完善信息
|
|||
Long gridId = 0L; |
|||
//获取网格人员关系表
|
|||
Result<UserGridRelationDTO> userLastSwitchGird = usersFeignClient.getUserLastSwitchGird(userDTO.getId()); |
|||
if(!userLastSwitchGird.success() || userLastSwitchGird.getData()==null){ |
|||
return "无法获取到网格人员关系信息"; |
|||
} |
|||
gridId = userLastSwitchGird.getData().getGridId(); |
|||
//2.更新用户积分分数
|
|||
if (OPERATION_TYPE_ADD.equals(pointsRuleResultDTO.getOperationType())) { |
|||
userDTO.setPoints(userDTO.getPoints() + pointsRuleResultDTO.getPoints()); |
|||
userDTO.setPointsTotle(userDTO.getPointsTotle() == null ? 0 : userDTO.getPointsTotle() + pointsRuleResultDTO.getPoints()); |
|||
} else if (OPERATION_TYPE_SUB.equals(pointsRuleResultDTO.getOperationType())) { |
|||
userDTO.setPoints(userDTO.getPoints() - pointsRuleResultDTO.getPoints()); |
|||
} |
|||
//3.更新数据库用户积分
|
|||
usersFeignClient.updateUser(userDTO); |
|||
//4.更新redis用户积分情况
|
|||
TokenDto tokenDto = ConvertUtils.sourceToTarget(userDTO, TokenDto.class); |
|||
tokenDto.setUserId(userDTO.getId()); |
|||
tokenDto.setGridId(gridId); |
|||
int expire = jwtTokenProperties.getExpire(); |
|||
cpUserDetailRedis.set(tokenDto, expire); |
|||
//更新用户的积分 -- 结束
|
|||
//添加操作日志 -- 开始
|
|||
addRuleLog(pointsRuleResultDTO, dto, userDTO); |
|||
//添加操作日志 -- 结束
|
|||
return "积分操作成功!动作描述:"+pointsRuleResultDTO.getBehaviorDesc() +" 积分描述:"+pointsRuleResultDTO.getRuleDesc() +" 分数统计:" +pointsRuleResultDTO.getPoints(); |
|||
} |
|||
|
|||
private void addRuleLog(PointsRuleResultDTO pointsRuleResultDTO, BehaviorDto dto, UserDTO userDTO) { |
|||
PointsLogsAddFormDTO pointsLogsAddFormDTO = new PointsLogsAddFormDTO(); |
|||
pointsLogsAddFormDTO.setUserId(dto.getUserId()); |
|||
pointsLogsAddFormDTO.setNickname(userDTO.getNickname()); |
|||
pointsLogsAddFormDTO.setFaceImg(userDTO.getFaceImg()); |
|||
pointsLogsAddFormDTO.setReferenceId(dto.getReferenceId()); |
|||
pointsLogsAddFormDTO.setRuleCode(pointsRuleResultDTO.getRuleCode()); |
|||
pointsLogsAddFormDTO.setBehaviorCode(pointsRuleResultDTO.getBehaviorCode()); |
|||
pointsLogsAddFormDTO.setOperationType(pointsRuleResultDTO.getOperationType()); |
|||
pointsLogsAddFormDTO.setPoints(pointsRuleResultDTO.getPoints()); |
|||
pointsLogsAddFormDTO.setOperationDesc(pointsRuleResultDTO.getRuleDesc()); |
|||
pointsLogsAddFormDTO.setOperationTime(dto.getOperationTime()); |
|||
pointsLogsAddFormDTO.setOperationMode("user"); |
|||
pointsLogsAddFormDTO.setLavePoints(userDTO.getPoints()); |
|||
PointsLogsEntity pointsLogsEntity = ConvertUtils.sourceToTarget(pointsLogsAddFormDTO, PointsLogsEntity.class); |
|||
pointsLogsService.insert(pointsLogsEntity); |
|||
} |
|||
} |
@ -0,0 +1,51 @@ |
|||
package com.elink.esua.epdc.mq.dto; |
|||
|
|||
import lombok.Data; |
|||
import org.springframework.expression.Operation; |
|||
|
|||
import java.io.Serializable; |
|||
import java.util.Date; |
|||
|
|||
/** |
|||
* 用户行为DTO |
|||
* |
|||
* @author songyunpeng |
|||
* @Date 20-04-28 |
|||
*/ |
|||
@Data |
|||
public class BehaviorDto implements Serializable { |
|||
|
|||
private static final long serialVersionUID = 5458618984429715932L; |
|||
|
|||
/** |
|||
* 用户行为 |
|||
*/ |
|||
private String behavior; |
|||
|
|||
/** |
|||
* 业务ID |
|||
*/ |
|||
private String referenceId; |
|||
|
|||
/** |
|||
* 其他业务ID |
|||
*/ |
|||
private String otherReferenceId; |
|||
|
|||
/** |
|||
* 用户ID |
|||
*/ |
|||
private String userId; |
|||
|
|||
/** |
|||
* 其他标识 |
|||
*/ |
|||
private String ortherFlag; |
|||
|
|||
/** |
|||
* 操作时间 |
|||
*/ |
|||
private Date operationTime; |
|||
|
|||
|
|||
} |
@ -0,0 +1,47 @@ |
|||
/** |
|||
* Copyright 2018 人人开源 https://www.renren.io
|
|||
* <p> |
|||
* This program is free software: you can redistribute it and/or modify |
|||
* it under the terms of the GNU General Public License as published by |
|||
* the Free Software Foundation, either version 3 of the License, or |
|||
* (at your option) any later version. |
|||
* <p> |
|||
* This program is distributed in the hope that it will be useful, |
|||
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
|||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|||
* GNU General Public License for more details. |
|||
* <p> |
|||
* You should have received a copy of the GNU General Public License |
|||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|||
*/ |
|||
|
|||
package com.elink.esua.epdc.redis; |
|||
|
|||
import com.elink.esua.epdc.commons.tools.redis.RedisUtils; |
|||
import org.springframework.beans.factory.annotation.Autowired; |
|||
import org.springframework.stereotype.Component; |
|||
|
|||
/** |
|||
* 积分动作规则关系表 |
|||
* |
|||
* @author elink elink@elink-cn.com |
|||
* @since v1.0.0 2020-05-11 |
|||
*/ |
|||
@Component |
|||
public class PointsBehaviorRuleRedis { |
|||
@Autowired |
|||
private RedisUtils redisUtils; |
|||
|
|||
public void delete(Object[] ids) { |
|||
|
|||
} |
|||
|
|||
public void set(){ |
|||
|
|||
} |
|||
|
|||
public String get(String id){ |
|||
return null; |
|||
} |
|||
|
|||
} |
@ -0,0 +1,126 @@ |
|||
/** |
|||
* Copyright 2018 人人开源 https://www.renren.io
|
|||
* <p> |
|||
* This program is free software: you can redistribute it and/or modify |
|||
* it under the terms of the GNU General Public License as published by |
|||
* the Free Software Foundation, either version 3 of the License, or |
|||
* (at your option) any later version. |
|||
* <p> |
|||
* This program is distributed in the hope that it will be useful, |
|||
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
|||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|||
* GNU General Public License for more details. |
|||
* <p> |
|||
* You should have received a copy of the GNU General Public License |
|||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|||
*/ |
|||
|
|||
package com.elink.esua.epdc.service; |
|||
|
|||
import com.elink.esua.epdc.commons.mybatis.service.BaseService; |
|||
import com.elink.esua.epdc.commons.tools.page.PageData; |
|||
import com.elink.esua.epdc.commons.tools.utils.Result; |
|||
import com.elink.esua.epdc.dto.PointsBehaviorDTO; |
|||
import com.elink.esua.epdc.dto.result.BehaviorResultDto; |
|||
import com.elink.esua.epdc.entity.PointsBehaviorEntity; |
|||
|
|||
import java.util.List; |
|||
import java.util.Map; |
|||
|
|||
/** |
|||
* 积分动作管理表 积分动作管理表 |
|||
* |
|||
* @author zhangyong |
|||
* @since v1.0.0 2020-04-28 |
|||
*/ |
|||
public interface PointsBehaviorService extends BaseService<PointsBehaviorEntity> { |
|||
|
|||
/** |
|||
* 默认分页 |
|||
* |
|||
* @param params |
|||
* @return PageData<PointsBehaviorDTO> |
|||
* @author generator |
|||
* @date 2020-04-28 |
|||
*/ |
|||
PageData<PointsBehaviorDTO> page(Map<String, Object> params); |
|||
|
|||
/** |
|||
* 默认查询 |
|||
* |
|||
* @param params |
|||
* @return java.util.List<PointsBehaviorDTO> |
|||
* @author generator |
|||
* @date 2020-04-28 |
|||
*/ |
|||
List<PointsBehaviorDTO> list(Map<String, Object> params); |
|||
|
|||
/** |
|||
* 单条查询 |
|||
* |
|||
* @param id |
|||
* @return PointsBehaviorDTO |
|||
* @author generator |
|||
* @date 2020-04-28 |
|||
*/ |
|||
PointsBehaviorDTO get(String id); |
|||
|
|||
/** |
|||
* 默认保存 |
|||
* |
|||
* @param dto |
|||
* @return Result |
|||
* @author generator |
|||
* @date 2020-04-28 |
|||
*/ |
|||
Result save(PointsBehaviorDTO dto); |
|||
|
|||
/** |
|||
* 默认更新 |
|||
* |
|||
* @param dto |
|||
* @return Result |
|||
* @author generator |
|||
* @date 2020-04-28 |
|||
*/ |
|||
Result update(PointsBehaviorDTO dto); |
|||
|
|||
/** |
|||
* 批量删除 |
|||
* |
|||
* @param ids |
|||
* @return Result |
|||
* @author generator |
|||
* @date 2020-04-28 |
|||
*/ |
|||
Result delete(String[] ids); |
|||
|
|||
/** |
|||
* @return com.elink.esua.epdc.dto.result.BehaviorResultDto |
|||
* @Description 根据动作编码获取动作信息 |
|||
* @Author songyunpeng |
|||
* @Date 2020/4/28 |
|||
* @Param [behaviorCode] |
|||
**/ |
|||
Result<BehaviorResultDto> getBehaviorCodeInfoByBehaviorCode(String behaviorCode); |
|||
|
|||
|
|||
/** |
|||
* 获取全部的动作编码 |
|||
* |
|||
* @Param: [] |
|||
* @return: com.elink.esua.epdc.commons.tools.utils.Result<java.util.List < com.elink.esua.epdc.dto.PointsBehaviorDTO>> |
|||
* @Author: zy |
|||
* @Date: 2020-04-29 |
|||
*/ |
|||
List<PointsBehaviorDTO> listBehaviorDesc(); |
|||
|
|||
/** |
|||
* @Description 志愿者服务使用- 获取全部动作编码 |
|||
* @Author songyunpeng |
|||
* @Date 2020/5/12 |
|||
* @Param [] |
|||
* @return java.util.List<com.elink.esua.epdc.dto.PointsBehaviorDTO> |
|||
**/ |
|||
List<PointsBehaviorDTO> selectAllListBehaviorDesc(); |
|||
} |
@ -0,0 +1,193 @@ |
|||
/** |
|||
* Copyright 2018 人人开源 https://www.renren.io
|
|||
* <p> |
|||
* This program is free software: you can redistribute it and/or modify |
|||
* it under the terms of the GNU General Public License as published by |
|||
* the Free Software Foundation, either version 3 of the License, or |
|||
* (at your option) any later version. |
|||
* <p> |
|||
* This program is distributed in the hope that it will be useful, |
|||
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
|||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|||
* GNU General Public License for more details. |
|||
* <p> |
|||
* You should have received a copy of the GNU General Public License |
|||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|||
*/ |
|||
|
|||
package com.elink.esua.epdc.service; |
|||
|
|||
import com.elink.esua.epdc.commons.mybatis.service.BaseService; |
|||
import com.elink.esua.epdc.commons.tools.page.PageData; |
|||
import com.elink.esua.epdc.commons.tools.utils.Result; |
|||
import com.elink.esua.epdc.dto.EpdcAdjustUserPointsDTO; |
|||
import com.elink.esua.epdc.dto.PointsLogsDTO; |
|||
import com.elink.esua.epdc.dto.epdc.result.EpdcAdjustVolunteerPointsDTO; |
|||
import com.elink.esua.epdc.dto.form.EpdcAppPointsRankingFormDTO; |
|||
import com.elink.esua.epdc.dto.form.EpdcAppPointsRecordFormDTO; |
|||
import com.elink.esua.epdc.dto.form.PointsLogsFormDTO; |
|||
import com.elink.esua.epdc.dto.result.EpdcAppPointsRankingResultDTO; |
|||
import com.elink.esua.epdc.dto.result.EpdcAppPointsRecordResultDTO; |
|||
import com.elink.esua.epdc.dto.result.PointsLogsResultDTO; |
|||
import com.elink.esua.epdc.dto.result.PointsStatisticsListResultDTO; |
|||
import com.elink.esua.epdc.entity.PointsLogsEntity; |
|||
|
|||
import java.util.List; |
|||
import java.util.Map; |
|||
|
|||
/** |
|||
* 积分记录表 积分记录表 |
|||
* |
|||
* @author elink elink@elink-cn.com |
|||
* @since v1.0.0 2020-04-29 |
|||
*/ |
|||
public interface PointsLogsService extends BaseService<PointsLogsEntity> { |
|||
|
|||
/** |
|||
* 默认分页 |
|||
* |
|||
* @param params |
|||
* @return PageData<PointsLogsDTO> |
|||
* @author generator |
|||
* @date 2020-04-29 |
|||
*/ |
|||
PageData<PointsLogsDTO> page(Map<String, Object> params); |
|||
|
|||
/** |
|||
* 默认查询 |
|||
* |
|||
* @param params |
|||
* @return java.util.List<PointsLogsDTO> |
|||
* @author generator |
|||
* @date 2020-04-29 |
|||
*/ |
|||
List<PointsLogsDTO> list(Map<String, Object> params); |
|||
|
|||
/** |
|||
* 单条查询 |
|||
* |
|||
* @param id |
|||
* @return PointsLogsDTO |
|||
* @author generator |
|||
* @date 2020-04-29 |
|||
*/ |
|||
PointsLogsDTO get(String id); |
|||
|
|||
/** |
|||
* 默认保存 |
|||
* |
|||
* @param dto |
|||
* @return void |
|||
* @author generator |
|||
* @date 2020-04-29 |
|||
*/ |
|||
Result save(PointsLogsDTO dto); |
|||
|
|||
/** |
|||
* 默认更新 |
|||
* |
|||
* @param dto |
|||
* @return void |
|||
* @author generator |
|||
* @date 2020-04-29 |
|||
*/ |
|||
void update(PointsLogsDTO dto); |
|||
|
|||
/** |
|||
* 批量删除 |
|||
* |
|||
* @param ids |
|||
* @return void |
|||
* @author generator |
|||
* @date 2020-04-29 |
|||
*/ |
|||
void delete(String[] ids); |
|||
|
|||
/** |
|||
* 当前登录用户 积分记录接口 |
|||
* |
|||
* @param formDto |
|||
* param pageIndex 必选 页码 |
|||
* param pageSize 必选 页容量 |
|||
* param userId 必选 用户ID |
|||
* @return: java.util.List<com.elink.esua.epdc.dto.result.EpdcAppPointsRecordResultDTO> |
|||
* @Author: zy |
|||
* @Date: 2020-04-29 |
|||
*/ |
|||
List<EpdcAppPointsRecordResultDTO> listPointsRecord(EpdcAppPointsRecordFormDTO formDto); |
|||
|
|||
/** |
|||
* @return com.elink.esua.epdc.commons.tools.utils.Result<com.elink.esua.epdc.dto.result.PointsLogsResultDTO> |
|||
* @Description 根据用户,业务ID,行为编码获取日志记录嘻嘻 |
|||
* @Author songyunpeng |
|||
* @Date 2020/4/29 |
|||
* @Param [pointsLogsFormDTO] |
|||
**/ |
|||
List<PointsLogsResultDTO> getLogsByBehaviorCodeAndUserIdAndReferenceId(PointsLogsFormDTO pointsLogsFormDTO); |
|||
|
|||
/** |
|||
* @return java.lang.Integer |
|||
* @Description 根据行为编码和用户ID获取积分 该动作积分总和 |
|||
* @Author songyunpeng |
|||
* @Date 2020/4/29 |
|||
* @Param [pointsLogsFormDTO] |
|||
**/ |
|||
Integer getPointsSumByBehaviorCodeAndUserId(PointsLogsFormDTO pointsLogsFormDTO); |
|||
|
|||
/** |
|||
* @return com.elink.esua.epdc.commons.tools.utils.Result<com.elink.esua.epdc.dto.result.PointsLogsResultDTO> |
|||
* @Description 获取指定人指定动作的最新一条工作日志 |
|||
* @Author songyunpeng |
|||
* @Date 2020/4/29 |
|||
* @Param [pointsLogsFormDTO] |
|||
**/ |
|||
PointsLogsResultDTO getLastPointLogs(PointsLogsFormDTO pointsLogsFormDTO); |
|||
|
|||
/** |
|||
* @param formDto |
|||
* @return com.elink.esua.epdc.commons.tools.utils.Result |
|||
* @Author yinzuomei |
|||
* @Description 确定调整用户积分 |
|||
* @Date 2019/12/16 18:56 |
|||
**/ |
|||
Result confirmAdjustPoint(EpdcAdjustVolunteerPointsDTO formDto); |
|||
|
|||
/** |
|||
* 积分排行接口(0 周排行、1 月排行) |
|||
* |
|||
* @param formDto |
|||
* param pageIndex 必选 页码 |
|||
* param pageSize 必选 页容量 |
|||
* param rankingType 必选 排名方式:0-周,1-月 |
|||
* @return: com.elink.esua.epdc.dto.result.EpdcAppPointsRankingResultDTO> |
|||
* @Author: zy |
|||
* @Date: 2020-04-30 |
|||
*/ |
|||
EpdcAppPointsRankingResultDTO listPointsRanking(EpdcAppPointsRankingFormDTO formDto); |
|||
/** |
|||
* @Description 积分管理-积分统计 -统计调整积分 |
|||
* @Author songyunpeng |
|||
* @Date 2020/6/9 |
|||
* @Param [formDto] |
|||
* @return com.elink.esua.epdc.commons.tools.utils.Result |
|||
**/ |
|||
Result confirmUserAdjustPoint(EpdcAdjustUserPointsDTO formDto); |
|||
|
|||
/*** |
|||
* 积分分类统计 |
|||
* @param params |
|||
* @return com.elink.esua.epdc.commons.tools.page.PageData<com.elink.esua.epdc.dto.result.PointsStatisticsListResultDTO> |
|||
* @author qushutong |
|||
* @date 2020/7/21 10:36 |
|||
*/ |
|||
PageData<PointsStatisticsListResultDTO> listPagePoint(Map<String, Object> params); |
|||
|
|||
/*** |
|||
* 积分总览 |
|||
* @param params |
|||
* @return com.elink.esua.epdc.dto.result.PointsStatisticsListResultDTO |
|||
* @author qushutong |
|||
* @date 2020/7/21 10:36 |
|||
*/ |
|||
PointsStatisticsListResultDTO getPointsOverview(Map<String, Object> params); |
|||
} |
@ -0,0 +1,104 @@ |
|||
/** |
|||
* Copyright 2018 人人开源 https://www.renren.io
|
|||
* <p> |
|||
* This program is free software: you can redistribute it and/or modify |
|||
* it under the terms of the GNU General Public License as published by |
|||
* the Free Software Foundation, either version 3 of the License, or |
|||
* (at your option) any later version. |
|||
* <p> |
|||
* This program is distributed in the hope that it will be useful, |
|||
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
|||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|||
* GNU General Public License for more details. |
|||
* <p> |
|||
* You should have received a copy of the GNU General Public License |
|||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|||
*/ |
|||
|
|||
package com.elink.esua.epdc.service.impl; |
|||
|
|||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
|||
import com.baomidou.mybatisplus.core.metadata.IPage; |
|||
import com.elink.esua.epdc.commons.mybatis.service.impl.BaseServiceImpl; |
|||
import com.elink.esua.epdc.commons.tools.page.PageData; |
|||
import com.elink.esua.epdc.commons.tools.utils.ConvertUtils; |
|||
import com.elink.esua.epdc.commons.tools.constant.FieldConstant; |
|||
import com.elink.esua.epdc.dao.PointsBehaviorRuleDao; |
|||
import com.elink.esua.epdc.dto.PointsBehaviorRuleDTO; |
|||
import com.elink.esua.epdc.entity.PointsBehaviorRuleEntity; |
|||
import com.elink.esua.epdc.redis.PointsBehaviorRuleRedis; |
|||
import com.elink.esua.epdc.service.PointsBehaviorRuleService; |
|||
import org.apache.commons.lang3.StringUtils; |
|||
import org.springframework.beans.factory.annotation.Autowired; |
|||
import org.springframework.stereotype.Service; |
|||
import org.springframework.transaction.annotation.Transactional; |
|||
|
|||
import java.util.Arrays; |
|||
import java.util.List; |
|||
import java.util.Map; |
|||
|
|||
/** |
|||
* 积分动作规则关系表 |
|||
* |
|||
* @author elink elink@elink-cn.com |
|||
* @since v1.0.0 2020-05-11 |
|||
*/ |
|||
@Service |
|||
public class PointsBehaviorRuleServiceImpl extends BaseServiceImpl<PointsBehaviorRuleDao, PointsBehaviorRuleEntity> implements PointsBehaviorRuleService { |
|||
|
|||
@Autowired |
|||
private PointsBehaviorRuleRedis pointsBehaviorRuleRedis; |
|||
|
|||
@Override |
|||
public PageData<PointsBehaviorRuleDTO> page(Map<String, Object> params) { |
|||
IPage<PointsBehaviorRuleEntity> page = baseDao.selectPage( |
|||
getPage(params, FieldConstant.CREATED_TIME, false), |
|||
getWrapper(params) |
|||
); |
|||
return getPageData(page, PointsBehaviorRuleDTO.class); |
|||
} |
|||
|
|||
@Override |
|||
public List<PointsBehaviorRuleDTO> list(Map<String, Object> params) { |
|||
List<PointsBehaviorRuleEntity> entityList = baseDao.selectList(getWrapper(params)); |
|||
|
|||
return ConvertUtils.sourceToTarget(entityList, PointsBehaviorRuleDTO.class); |
|||
} |
|||
|
|||
private QueryWrapper<PointsBehaviorRuleEntity> getWrapper(Map<String, Object> params){ |
|||
String id = (String)params.get(FieldConstant.ID_HUMP); |
|||
|
|||
QueryWrapper<PointsBehaviorRuleEntity> wrapper = new QueryWrapper<>(); |
|||
wrapper.eq(StringUtils.isNotBlank(id), FieldConstant.ID, id); |
|||
|
|||
return wrapper; |
|||
} |
|||
|
|||
@Override |
|||
public PointsBehaviorRuleDTO get(String id) { |
|||
PointsBehaviorRuleEntity entity = baseDao.selectById(id); |
|||
return ConvertUtils.sourceToTarget(entity, PointsBehaviorRuleDTO.class); |
|||
} |
|||
|
|||
@Override |
|||
@Transactional(rollbackFor = Exception.class) |
|||
public void save(PointsBehaviorRuleDTO dto) { |
|||
PointsBehaviorRuleEntity entity = ConvertUtils.sourceToTarget(dto, PointsBehaviorRuleEntity.class); |
|||
insert(entity); |
|||
} |
|||
|
|||
@Override |
|||
@Transactional(rollbackFor = Exception.class) |
|||
public void update(PointsBehaviorRuleDTO dto) { |
|||
PointsBehaviorRuleEntity entity = ConvertUtils.sourceToTarget(dto, PointsBehaviorRuleEntity.class); |
|||
updateById(entity); |
|||
} |
|||
|
|||
@Override |
|||
@Transactional(rollbackFor = Exception.class) |
|||
public void delete(String[] ids) { |
|||
// 逻辑删除(@TableLogic 注解)
|
|||
baseDao.deleteBatchIds(Arrays.asList(ids)); |
|||
} |
|||
|
|||
} |
@ -0,0 +1,207 @@ |
|||
/** |
|||
* Copyright 2018 人人开源 https://www.renren.io
|
|||
* <p> |
|||
* This program is free software: you can redistribute it and/or modify |
|||
* it under the terms of the GNU General Public License as published by |
|||
* the Free Software Foundation, either version 3 of the License, or |
|||
* (at your option) any later version. |
|||
* <p> |
|||
* This program is distributed in the hope that it will be useful, |
|||
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
|||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|||
* GNU General Public License for more details. |
|||
* <p> |
|||
* You should have received a copy of the GNU General Public License |
|||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|||
*/ |
|||
|
|||
package com.elink.esua.epdc.service.impl; |
|||
|
|||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
|||
import com.baomidou.mybatisplus.core.metadata.IPage; |
|||
import com.elink.esua.epdc.commons.mybatis.service.impl.BaseServiceImpl; |
|||
import com.elink.esua.epdc.commons.tools.constant.NumConstant; |
|||
import com.elink.esua.epdc.commons.tools.exception.ErrorCode; |
|||
import com.elink.esua.epdc.commons.tools.page.PageData; |
|||
import com.elink.esua.epdc.commons.tools.redis.RedisKeys; |
|||
import com.elink.esua.epdc.commons.tools.redis.RedisUtils; |
|||
import com.elink.esua.epdc.commons.tools.utils.ConvertUtils; |
|||
import com.elink.esua.epdc.commons.tools.constant.FieldConstant; |
|||
import com.elink.esua.epdc.commons.tools.utils.Result; |
|||
import com.elink.esua.epdc.dao.PointsBehaviorDao; |
|||
import com.elink.esua.epdc.dto.PointsBehaviorDTO; |
|||
import com.elink.esua.epdc.dto.result.BehaviorResultDto; |
|||
import com.elink.esua.epdc.entity.PointsBehaviorEntity; |
|||
import com.elink.esua.epdc.redis.PointsBehaviorRedis; |
|||
import com.elink.esua.epdc.service.PointsBehaviorService; |
|||
import org.apache.commons.lang3.StringUtils; |
|||
import org.springframework.beans.factory.annotation.Autowired; |
|||
import org.springframework.stereotype.Service; |
|||
import org.springframework.transaction.annotation.Transactional; |
|||
|
|||
import java.util.Arrays; |
|||
import java.util.List; |
|||
import java.util.Map; |
|||
|
|||
/** |
|||
* 积分动作管理表 积分动作管理表 |
|||
* |
|||
* @author zhangyong |
|||
* @since v1.0.0 2020-04-28 |
|||
*/ |
|||
@Service |
|||
public class PointsBehaviorServiceImpl extends BaseServiceImpl<PointsBehaviorDao, PointsBehaviorEntity> implements PointsBehaviorService { |
|||
|
|||
@Autowired |
|||
private PointsBehaviorRedis pointsBehaviorRedis; |
|||
|
|||
@Autowired |
|||
private RedisUtils redisUtils; |
|||
|
|||
@Override |
|||
public PageData<PointsBehaviorDTO> page(Map<String, Object> params) { |
|||
IPage<PointsBehaviorDTO> page = getPage(params); |
|||
List<PointsBehaviorDTO> list = baseDao.selectListPointsBehavior(params); |
|||
return new PageData<>(list, page.getTotal()); |
|||
} |
|||
|
|||
@Override |
|||
public List<PointsBehaviorDTO> list(Map<String, Object> params) { |
|||
List<PointsBehaviorEntity> entityList = baseDao.selectList(getWrapper(params)); |
|||
|
|||
return ConvertUtils.sourceToTarget(entityList, PointsBehaviorDTO.class); |
|||
} |
|||
|
|||
private QueryWrapper<PointsBehaviorEntity> getWrapper(Map<String, Object> params) { |
|||
String id = (String) params.get(FieldConstant.ID_HUMP); |
|||
|
|||
QueryWrapper<PointsBehaviorEntity> wrapper = new QueryWrapper<>(); |
|||
wrapper.eq(StringUtils.isNotBlank(id), FieldConstant.ID, id); |
|||
|
|||
return wrapper; |
|||
} |
|||
|
|||
@Override |
|||
public PointsBehaviorDTO get(String id) { |
|||
PointsBehaviorEntity entity = baseDao.selectById(id); |
|||
return ConvertUtils.sourceToTarget(entity, PointsBehaviorDTO.class); |
|||
} |
|||
|
|||
@Override |
|||
@Transactional(rollbackFor = Exception.class) |
|||
public Result save(PointsBehaviorDTO dto) { |
|||
// 判断动作编码是否重复
|
|||
Result checkBehaviorCode = this.checkBehaviorCodeIsExist(dto.getBehaviorCode()); |
|||
if (checkBehaviorCode.getCode() == ErrorCode.INTERNAL_SERVER_ERROR) { |
|||
return checkBehaviorCode; |
|||
} |
|||
// 判断动作描述是否重复
|
|||
Result checkBehaviorDesc = this.checkBehaviorDescIsExist(dto.getBehaviorDesc()); |
|||
if (checkBehaviorDesc.getCode() == ErrorCode.INTERNAL_SERVER_ERROR) { |
|||
return checkBehaviorDesc; |
|||
} |
|||
|
|||
PointsBehaviorEntity entity = ConvertUtils.sourceToTarget(dto, PointsBehaviorEntity.class); |
|||
insert(entity); |
|||
// 存入redis
|
|||
redisUtils.set(RedisKeys.getAllRuleCodeKey(entity.getBehaviorCode()), entity, RedisUtils.NOT_EXPIRE); |
|||
return new Result(); |
|||
} |
|||
|
|||
/** |
|||
* @Description: 查询动作编码是否存在 |
|||
* @Param: [behaviorCode] |
|||
* @return: com.elink.esua.epdc.commons.tools.utils.Result |
|||
* @Author: zy |
|||
* @Date: 2020-04-28 |
|||
*/ |
|||
private Result checkBehaviorCodeIsExist(String behaviorCode) { |
|||
Object bhc = redisUtils.get(RedisKeys.getAllRuleCodeKey(behaviorCode)); |
|||
if (bhc != null) { |
|||
return new Result().error("动作编码已存在,请重新设置"); |
|||
} |
|||
return new Result(); |
|||
} |
|||
|
|||
@Override |
|||
@Transactional(rollbackFor = Exception.class) |
|||
public Result update(PointsBehaviorDTO dto) { |
|||
// 查询之前的动作编码
|
|||
PointsBehaviorEntity queryEntity = baseDao.selectById(dto.getId()); |
|||
// 判断本次修改操作是否修改了动作编码, 如果改动了,查询新的动作编码是否已存在
|
|||
if (!(queryEntity.getBehaviorCode().equals(dto.getBehaviorCode()))) { |
|||
Result checkBehaviorCode = this.checkBehaviorCodeIsExist(dto.getBehaviorCode()); |
|||
if (checkBehaviorCode.getCode() == ErrorCode.INTERNAL_SERVER_ERROR) { |
|||
return checkBehaviorCode; |
|||
} |
|||
} |
|||
// 判断本次修改操作是否修改了动作描述, 如果改动了,查询新的动作描述是否在表中已存在
|
|||
if (!(queryEntity.getBehaviorDesc().equals(dto.getBehaviorDesc()))) { |
|||
Result checkBehaviorDesc = this.checkBehaviorDescIsExist(dto.getBehaviorDesc()); |
|||
if (checkBehaviorDesc.getCode() == ErrorCode.INTERNAL_SERVER_ERROR) { |
|||
return checkBehaviorDesc; |
|||
} |
|||
} |
|||
|
|||
PointsBehaviorEntity entity = ConvertUtils.sourceToTarget(dto, PointsBehaviorEntity.class); |
|||
updateById(entity); |
|||
// 删除redis中的存储信息
|
|||
redisUtils.delete(RedisKeys.getAllRuleCodeKey(queryEntity.getBehaviorCode())); |
|||
// 新增redis信息
|
|||
redisUtils.set(RedisKeys.getAllRuleCodeKey(entity.getBehaviorCode()), entity, RedisUtils.NOT_EXPIRE); |
|||
return new Result(); |
|||
} |
|||
|
|||
@Override |
|||
@Transactional(rollbackFor = Exception.class) |
|||
public Result delete(String[] ids) { |
|||
PointsBehaviorEntity entity = baseDao.selectById(ids[0]); |
|||
// 动作有对应的积分规则不让删,提示:
|
|||
int behaviorCodeNum = baseDao.selectBehaviorCodeDoestItExist(entity.getBehaviorCode()); |
|||
if (behaviorCodeNum > NumConstant.ZERO) { |
|||
return new Result().error("该动作已绑定积分规则不能删除"); |
|||
} |
|||
|
|||
// 逻辑删除(@TableLogic 注解)
|
|||
baseDao.deleteBatchIds(Arrays.asList(ids)); |
|||
// 删除redis中的存储信息
|
|||
redisUtils.delete(RedisKeys.getAllRuleCodeKey(entity.getBehaviorCode())); |
|||
return new Result(); |
|||
} |
|||
|
|||
@Override |
|||
public Result<BehaviorResultDto> getBehaviorCodeInfoByBehaviorCode(String behaviorCode) { |
|||
if (StringUtils.isBlank(behaviorCode)) { |
|||
return new Result<BehaviorResultDto>().error("行为编码为空"); |
|||
} |
|||
BehaviorResultDto behaviorResultDto = baseDao.getBehaviorCodeInfoByBehaviorCode(behaviorCode); |
|||
Result<BehaviorResultDto> resultDtoResult = new Result<>(); |
|||
resultDtoResult.setData(behaviorResultDto); |
|||
return resultDtoResult; |
|||
} |
|||
|
|||
@Override |
|||
public List<PointsBehaviorDTO> listBehaviorDesc() { |
|||
return baseDao.selectListBehaviorDesc(); |
|||
} |
|||
|
|||
@Override |
|||
public List<PointsBehaviorDTO> selectAllListBehaviorDesc() { |
|||
return baseDao.selectAllListBehaviorDesc(); |
|||
} |
|||
|
|||
/** |
|||
* 查询积分动作管理表 动作描述是否存在 |
|||
* @param behaviorDesc 动作描述 |
|||
* @return com.elink.esua.epdc.commons.tools.utils.Result |
|||
* @Author zhangyong |
|||
* @Date 17:33 2020-05-08 |
|||
**/ |
|||
private Result checkBehaviorDescIsExist(String behaviorDesc) { |
|||
int behaviorDescNum = baseDao.selectBehaviorDescItExist(behaviorDesc); |
|||
if (behaviorDescNum > NumConstant.ZERO) { |
|||
return new Result().error("动作描述已存在,请重新命名"); |
|||
} |
|||
return new Result(); |
|||
} |
|||
} |
@ -0,0 +1,342 @@ |
|||
/** |
|||
* Copyright 2018 人人开源 https://www.renren.io
|
|||
* <p> |
|||
* This program is free software: you can redistribute it and/or modify |
|||
* it under the terms of the GNU General Public License as published by |
|||
* the Free Software Foundation, either version 3 of the License, or |
|||
* (at your option) any later version. |
|||
* <p> |
|||
* This program is distributed in the hope that it will be useful, |
|||
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
|||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|||
* GNU General Public License for more details. |
|||
* <p> |
|||
* You should have received a copy of the GNU General Public License |
|||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|||
*/ |
|||
|
|||
package com.elink.esua.epdc.service.impl; |
|||
|
|||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
|||
import com.baomidou.mybatisplus.core.metadata.IPage; |
|||
import com.elink.esua.epdc.async.NewsTask; |
|||
import com.elink.esua.epdc.commons.mybatis.service.impl.BaseServiceImpl; |
|||
import com.elink.esua.epdc.commons.tools.constant.FieldConstant; |
|||
import com.elink.esua.epdc.commons.tools.constant.NumConstant; |
|||
import com.elink.esua.epdc.commons.tools.constant.PointsConstant; |
|||
import com.elink.esua.epdc.commons.tools.enums.pointsenum.PointsOperationEnum; |
|||
import com.elink.esua.epdc.commons.tools.enums.pointsenum.PointsOperationModeEnum; |
|||
import com.elink.esua.epdc.commons.tools.exception.RenException; |
|||
import com.elink.esua.epdc.commons.tools.page.PageData; |
|||
import com.elink.esua.epdc.commons.tools.utils.ConvertUtils; |
|||
import com.elink.esua.epdc.commons.tools.utils.Result; |
|||
import com.elink.esua.epdc.dao.PointsLogsDao; |
|||
import com.elink.esua.epdc.dto.EpdcAdjustUserPointsDTO; |
|||
import com.elink.esua.epdc.dto.PointsLogsDTO; |
|||
import com.elink.esua.epdc.dto.UserDTO; |
|||
import com.elink.esua.epdc.dto.constant.PointsNoticeConstant; |
|||
import com.elink.esua.epdc.dto.epdc.form.EpdcInformationFormDTO; |
|||
import com.elink.esua.epdc.dto.epdc.form.EpdcUserPointsFormDTO; |
|||
import com.elink.esua.epdc.dto.epdc.result.EpdcAdjustVolunteerPointsDTO; |
|||
import com.elink.esua.epdc.dto.form.EpdcAppPointsRankingFormDTO; |
|||
import com.elink.esua.epdc.dto.form.EpdcAppPointsRecordFormDTO; |
|||
import com.elink.esua.epdc.dto.form.PointsLogsFormDTO; |
|||
import com.elink.esua.epdc.dto.result.*; |
|||
import com.elink.esua.epdc.entity.PointsLogsEntity; |
|||
import com.elink.esua.epdc.feign.UsersFeignClient; |
|||
import com.elink.esua.epdc.redis.PointsLogsRedis; |
|||
import com.elink.esua.epdc.service.PointsBehaviorService; |
|||
import com.elink.esua.epdc.service.PointsLogsService; |
|||
import org.apache.commons.lang3.StringUtils; |
|||
import org.springframework.beans.factory.annotation.Autowired; |
|||
import org.springframework.stereotype.Service; |
|||
import org.springframework.transaction.annotation.Transactional; |
|||
|
|||
import java.util.*; |
|||
|
|||
/** |
|||
* 积分记录表 积分记录表 |
|||
* |
|||
* @author elink elink@elink-cn.com |
|||
* @since v1.0.0 2020-04-29 |
|||
*/ |
|||
@Service |
|||
public class PointsLogsServiceImpl extends BaseServiceImpl<PointsLogsDao, PointsLogsEntity> implements PointsLogsService { |
|||
|
|||
@Autowired |
|||
private PointsLogsRedis pointsLogsRedis; |
|||
|
|||
@Autowired |
|||
private UsersFeignClient usersFeignClient; |
|||
|
|||
@Autowired |
|||
private PointsBehaviorService pointsBehaviorService; |
|||
|
|||
@Autowired |
|||
private NewsTask newsTask; |
|||
|
|||
@Override |
|||
public PageData<PointsLogsDTO> page(Map<String, Object> params) { |
|||
IPage<PointsLogsDTO> page = getPage(params); |
|||
List<PointsLogsDTO> list = baseDao.selectListVolunteerPointsLog(params); |
|||
return new PageData<>(list, page.getTotal()); |
|||
} |
|||
|
|||
@Override |
|||
public List<PointsLogsDTO> list(Map<String, Object> params) { |
|||
List<PointsLogsEntity> entityList = baseDao.selectList(getWrapper(params)); |
|||
|
|||
return ConvertUtils.sourceToTarget(entityList, PointsLogsDTO.class); |
|||
} |
|||
|
|||
private QueryWrapper<PointsLogsEntity> getWrapper(Map<String, Object> params) { |
|||
String id = (String) params.get(FieldConstant.ID_HUMP); |
|||
|
|||
QueryWrapper<PointsLogsEntity> wrapper = new QueryWrapper<>(); |
|||
wrapper.eq(StringUtils.isNotBlank(id), FieldConstant.ID, id); |
|||
|
|||
return wrapper; |
|||
} |
|||
|
|||
@Override |
|||
public PointsLogsDTO get(String id) { |
|||
PointsLogsEntity entity = baseDao.selectById(id); |
|||
return ConvertUtils.sourceToTarget(entity, PointsLogsDTO.class); |
|||
} |
|||
|
|||
@Override |
|||
@Transactional(rollbackFor = Exception.class) |
|||
public Result save(PointsLogsDTO dto) { |
|||
PointsLogsEntity entity = ConvertUtils.sourceToTarget(dto, PointsLogsEntity.class); |
|||
insert(entity); |
|||
|
|||
return new Result(); |
|||
} |
|||
|
|||
@Override |
|||
@Transactional(rollbackFor = Exception.class) |
|||
public void update(PointsLogsDTO dto) { |
|||
PointsLogsEntity entity = ConvertUtils.sourceToTarget(dto, PointsLogsEntity.class); |
|||
updateById(entity); |
|||
} |
|||
|
|||
@Override |
|||
@Transactional(rollbackFor = Exception.class) |
|||
public void delete(String[] ids) { |
|||
// 逻辑删除(@TableLogic 注解)
|
|||
baseDao.deleteBatchIds(Arrays.asList(ids)); |
|||
} |
|||
|
|||
@Override |
|||
public List<PointsLogsResultDTO> getLogsByBehaviorCodeAndUserIdAndReferenceId(PointsLogsFormDTO pointsLogsFormDTO) { |
|||
List<PointsLogsResultDTO> pointsLogsResultDTO = baseDao.selecOneLogsByBehaviorCodeAndUserIdAndReferenceId(pointsLogsFormDTO); |
|||
return pointsLogsResultDTO; |
|||
} |
|||
|
|||
@Override |
|||
public Integer getPointsSumByBehaviorCodeAndUserId(PointsLogsFormDTO pointsLogsFormDTO) { |
|||
return baseDao.getPointsSumByBehaviorCodeAndUserId(pointsLogsFormDTO); |
|||
} |
|||
|
|||
@Override |
|||
public PointsLogsResultDTO getLastPointLogs(PointsLogsFormDTO pointsLogsFormDTO) { |
|||
PointsLogsResultDTO pointsLogsResultDTO = baseDao.getLastPointLogs(pointsLogsFormDTO); |
|||
return pointsLogsResultDTO; |
|||
} |
|||
|
|||
@Override |
|||
public List<EpdcAppPointsRecordResultDTO> listPointsRecord(EpdcAppPointsRecordFormDTO formDto) { |
|||
int pageIndex = (formDto.getPageIndex() - NumConstant.ONE) * formDto.getPageSize(); |
|||
formDto.setPageIndex(pageIndex); |
|||
return baseDao.selectListPointsRecord(formDto); |
|||
} |
|||
|
|||
/** |
|||
* @param formDto |
|||
* @return com.elink.esua.epdc.commons.tools.utils.Result |
|||
* @Author yinzuomei |
|||
* @Description 确定调整用户积分 |
|||
* @Date 2019/12/16 18:56 |
|||
**/ |
|||
@Override |
|||
@Transactional(rollbackFor = Exception.class) |
|||
public Result confirmAdjustPoint(EpdcAdjustVolunteerPointsDTO formDto) { |
|||
if (formDto.getOperatePoints() == NumConstant.ZERO) { |
|||
return new Result().error("操作积分不能为0"); |
|||
} |
|||
//根据动作编码获取动作信息
|
|||
Result<BehaviorResultDto> behaviorCodeInfoByBehaviorCode = pointsBehaviorService.getBehaviorCodeInfoByBehaviorCode(formDto.getBehaviorCode()); |
|||
if (!behaviorCodeInfoByBehaviorCode.success() || behaviorCodeInfoByBehaviorCode.getData() == null) { |
|||
throw new RenException("获取动作编码信息异常或无此动作编码"); |
|||
} |
|||
PointsLogsEntity pointsLogsEntity = new PointsLogsEntity(); |
|||
pointsLogsEntity.setVolunteerId(formDto.getId()); |
|||
pointsLogsEntity.setUserId(formDto.getUserId()); |
|||
pointsLogsEntity.setNickname(formDto.getNickname()); |
|||
pointsLogsEntity.setFaceImg(formDto.getFaceImg()); |
|||
pointsLogsEntity.setOperationTime(new Date()); |
|||
pointsLogsEntity.setOperationMode(PointsOperationModeEnum.OPERATION_MODE_ADMIN.getOperationMode());//操作方式(user-用户操作,admin-管理员操作,sys-系统操作)
|
|||
pointsLogsEntity.setRuleCode(PointsConstant.ruleCode); |
|||
pointsLogsEntity.setBehaviorCode(formDto.getBehaviorCode()); |
|||
pointsLogsEntity.setOperationDesc(behaviorCodeInfoByBehaviorCode.getData().getBehaviorDesc());//操作描述
|
|||
pointsLogsEntity.setPoints(formDto.getOperatePoints()); |
|||
pointsLogsEntity.setOperationType(formDto.getOperationType());//积分操作类型(0-减积分,1-加积分)
|
|||
pointsLogsEntity.setReferenceId(formDto.getId());//积分操作类型(0-减积分,1-加积分)
|
|||
EpdcUserPointsFormDTO userPointsFormDTO = new EpdcUserPointsFormDTO(); |
|||
userPointsFormDTO.setUserId(formDto.getUserId()); |
|||
userPointsFormDTO.setPoints(formDto.getOperatePoints()); |
|||
userPointsFormDTO.setOperationType(formDto.getOperationType()); |
|||
Result<UserDTO> result = usersFeignClient.handleUserPoints(userPointsFormDTO); |
|||
if (!result.success()) { |
|||
return new Result().error("调整用户积分失败"); |
|||
} |
|||
//剩余积分
|
|||
pointsLogsEntity.setLavePoints(result.getData().getPoints()); |
|||
pointsLogsEntity.setBehaviorCode(formDto.getBehaviorCode()); |
|||
this.insert(pointsLogsEntity); |
|||
//给用户发送消息通知
|
|||
this.issueSmsNotification(pointsLogsEntity, formDto); |
|||
return new Result(); |
|||
} |
|||
|
|||
/** |
|||
* @param pointsLogsEntity |
|||
* @param formDto |
|||
* @return void |
|||
* @Author yinzuomei |
|||
* @Description 调整积分完成后-给用户发送消息通知 |
|||
* @Date 2020/2/7 22:12 |
|||
**/ |
|||
private void issueSmsNotification(PointsLogsEntity pointsLogsEntity, EpdcAdjustVolunteerPointsDTO formDto) { |
|||
EpdcInformationFormDTO informationFormDTO = new EpdcInformationFormDTO(); |
|||
informationFormDTO.setUserId(pointsLogsEntity.getUserId()); |
|||
String content = ""; |
|||
//积分操作类型(0-减积分,1-加积分)
|
|||
if (PointsOperationEnum.OPERATION_TYPE_ADD.getOperationType().equals(pointsLogsEntity.getOperationType())) { |
|||
informationFormDTO.setTitle(PointsNoticeConstant.ADD_POINTS_NOTICE); |
|||
content = PointsNoticeConstant.ADD_POINTS + pointsLogsEntity.getPoints() + PointsNoticeConstant.REASON + formDto.getAdjustReason(); |
|||
|
|||
} else if (PointsOperationEnum.OPERATION_TYPE_SUBSTRACT.getOperationType().equals(pointsLogsEntity.getOperationType())) { |
|||
informationFormDTO.setTitle(PointsNoticeConstant.SUBTRACT_POINTS_NOTICE); |
|||
content = PointsNoticeConstant.SUBTRACT_POINTS + pointsLogsEntity.getPoints() + PointsNoticeConstant.REASON + formDto.getAdjustReason(); |
|||
} |
|||
informationFormDTO.setContent(content); |
|||
informationFormDTO.setType(PointsNoticeConstant.NOTICE_TYPE_INTERACTIVE_NOTICE); |
|||
informationFormDTO.setBusinessType(PointsNoticeConstant.NOTICE__BUSINESS_TYPE_ACTIVITY); |
|||
informationFormDTO.setBusinessId(pointsLogsEntity.getId()); |
|||
informationFormDTO.setRelBusinessContent(""); |
|||
// 发送消息
|
|||
newsTask.insertUserInformation(informationFormDTO); |
|||
} |
|||
|
|||
@Override |
|||
public EpdcAppPointsRankingResultDTO listPointsRanking(EpdcAppPointsRankingFormDTO formDto) { |
|||
int pageIndex = (formDto.getPageIndex() - NumConstant.ONE) * formDto.getPageSize(); |
|||
formDto.setPageIndex(pageIndex); |
|||
// 积分相同,排名相同
|
|||
EpdcAppPointsRankingResultDTO rangking = new EpdcAppPointsRankingResultDTO(); |
|||
// 获取排好序的 排行榜数据数据
|
|||
rangking.setRank(this.sortListPointsRank(formDto)); |
|||
|
|||
// 判断当前用户是否产生过积分记录
|
|||
EpdcAppPointsRankingUserDTO userRang = baseDao.selectUserPointsRanking(formDto); |
|||
// 用户产生过积分记录,返回积分排名
|
|||
if (userRang != null) { |
|||
userRang.setUserId(formDto.getUserId()); |
|||
userRang.setNickName(formDto.getNickName()); |
|||
rangking.setCurrentUser(userRang); |
|||
} else { |
|||
// 未产生过积分排名 总排名+1
|
|||
rangking.setCurrentUser(this.noPointsRecordIsUserRanking(formDto)); |
|||
} |
|||
return rangking; |
|||
} |
|||
|
|||
@Override |
|||
public Result confirmUserAdjustPoint(EpdcAdjustUserPointsDTO formDto) { |
|||
if (formDto.getOperatePoints() == NumConstant.ZERO) { |
|||
return new Result().error("操作积分不能为0"); |
|||
} |
|||
PointsLogsEntity pointsLogsEntity = new PointsLogsEntity(); |
|||
pointsLogsEntity.setUserId(formDto.getId()); |
|||
pointsLogsEntity.setNickname(formDto.getNickname()); |
|||
pointsLogsEntity.setFaceImg(formDto.getFaceImg()); |
|||
pointsLogsEntity.setOperationTime(new Date()); |
|||
pointsLogsEntity.setOperationMode(PointsOperationModeEnum.OPERATION_MODE_ADMIN.getOperationMode());//操作方式(user-用户操作,admin-管理员操作,sys-系统操作)
|
|||
pointsLogsEntity.setRuleCode(PointsConstant.ruleCode); |
|||
pointsLogsEntity.setBehaviorCode(PointsConstant.behaviorCodeCode); |
|||
pointsLogsEntity.setOperationDesc(formDto.getAdjustReason());//操作描述
|
|||
pointsLogsEntity.setPoints(formDto.getOperatePoints()); |
|||
pointsLogsEntity.setOperationType(formDto.getOperationType());//积分操作类型(0-减积分,1-加积分)
|
|||
pointsLogsEntity.setReferenceId(formDto.getId());//积分操作类型(0-减积分,1-加积分)
|
|||
EpdcUserPointsFormDTO userPointsFormDTO = new EpdcUserPointsFormDTO(); |
|||
userPointsFormDTO.setUserId(formDto.getId()); |
|||
userPointsFormDTO.setPoints(formDto.getOperatePoints()); |
|||
userPointsFormDTO.setOperationType(formDto.getOperationType()); |
|||
Result<UserDTO> result = usersFeignClient.handleUserPoints(userPointsFormDTO); |
|||
if (!result.success()) { |
|||
return new Result().error("调整用户积分失败"); |
|||
} |
|||
//剩余积分
|
|||
pointsLogsEntity.setLavePoints(result.getData().getPoints()); |
|||
this.insert(pointsLogsEntity); |
|||
return new Result(); |
|||
} |
|||
|
|||
|
|||
/** |
|||
* 获取【排好序】的排行榜数据 |
|||
* |
|||
* @param formDto |
|||
* @return java.util.List<com.elink.esua.epdc.dto.result.EpdcAppPointsRankingTopTenDTO> |
|||
* @Author zhangyong |
|||
* @Date 16:09 2020-05-13 |
|||
**/ |
|||
private List<EpdcAppPointsRankingTopTenDTO> sortListPointsRank(EpdcAppPointsRankingFormDTO formDto) { |
|||
List<EpdcAppPointsRankingTopTenDTO> listPointsRank = new ArrayList<>(); |
|||
listPointsRank = baseDao.selectListPointsRanking(formDto); |
|||
int sortNumber = 1; |
|||
if (listPointsRank != null) { |
|||
for (int i = 1; i < listPointsRank.size(); i++) { |
|||
listPointsRank.get(0).setRank(NumConstant.ONE); |
|||
if (listPointsRank.get(i - NumConstant.ONE).getPoints().intValue() == listPointsRank.get(i).getPoints().intValue()) { |
|||
listPointsRank.get(i).setRank(sortNumber); |
|||
} else { |
|||
sortNumber = sortNumber + NumConstant.ONE; |
|||
listPointsRank.get(i).setRank(sortNumber); |
|||
} |
|||
} |
|||
} |
|||
return listPointsRank; |
|||
} |
|||
|
|||
/** |
|||
* 查询积分排行接口(0 周排行、1 月排行)如果没有当前登录用户的积分记录,返回 处理(总排名+1) 过的排名信息 |
|||
* |
|||
* @param formDto |
|||
* @return com.elink.esua.epdc.dto.result.EpdcAppPointsRankingUserDTO |
|||
* @Author zhangyong |
|||
* @Date 13:35 2020-05-13 |
|||
**/ |
|||
private EpdcAppPointsRankingUserDTO noPointsRecordIsUserRanking(EpdcAppPointsRankingFormDTO formDto) { |
|||
EpdcAppPointsRankingUserDTO userRang = new EpdcAppPointsRankingUserDTO(); |
|||
int pointCountRaning = baseDao.selectCountPointsRanking(formDto); |
|||
userRang.setUserId(formDto.getUserId()); |
|||
userRang.setNickName(formDto.getNickName()); |
|||
userRang.setPoints(NumConstant.ZERO); |
|||
userRang.setRank(pointCountRaning + NumConstant.ONE); |
|||
return userRang; |
|||
} |
|||
|
|||
@Override |
|||
public PageData<PointsStatisticsListResultDTO> listPagePoint(Map<String, Object> params) { |
|||
IPage<PointsStatisticsListResultDTO> page = getPage(params); |
|||
List<PointsStatisticsListResultDTO> list = baseDao.selectPointsList(params); |
|||
return new PageData(list, page.getTotal()); |
|||
} |
|||
|
|||
@Override |
|||
public PointsStatisticsListResultDTO getPointsOverview(Map<String, Object> params) { |
|||
return baseDao.selectPointsOverview(params); |
|||
} |
|||
} |
@ -0,0 +1,250 @@ |
|||
/** |
|||
* Copyright 2018 人人开源 https://www.renren.io
|
|||
* <p> |
|||
* This program is free software: you can redistribute it and/or modify |
|||
* it under the terms of the GNU General Public License as published by |
|||
* the Free Software Foundation, either version 3 of the License, or |
|||
* (at your option) any later version. |
|||
* <p> |
|||
* This program is distributed in the hope that it will be useful, |
|||
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
|||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|||
* GNU General Public License for more details. |
|||
* <p> |
|||
* You should have received a copy of the GNU General Public License |
|||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|||
*/ |
|||
|
|||
package com.elink.esua.epdc.service.impl; |
|||
|
|||
import cn.hutool.core.collection.CollUtil; |
|||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
|||
import com.baomidou.mybatisplus.core.metadata.IPage; |
|||
import com.elink.esua.epdc.commons.mybatis.service.impl.BaseServiceImpl; |
|||
import com.elink.esua.epdc.commons.tools.constant.FieldConstant; |
|||
import com.elink.esua.epdc.commons.tools.enums.pointsenum.PointsRuleAvailableEnum; |
|||
import com.elink.esua.epdc.commons.tools.exception.ErrorCode; |
|||
import com.elink.esua.epdc.commons.tools.page.PageData; |
|||
import com.elink.esua.epdc.commons.tools.redis.RedisKeys; |
|||
import com.elink.esua.epdc.commons.tools.redis.RedisUtils; |
|||
import com.elink.esua.epdc.commons.tools.utils.ConvertUtils; |
|||
import com.elink.esua.epdc.commons.tools.utils.Result; |
|||
import com.elink.esua.epdc.dao.PointsBehaviorDao; |
|||
import com.elink.esua.epdc.dao.PointsBehaviorRuleDao; |
|||
import com.elink.esua.epdc.dao.PointsRuleDao; |
|||
import com.elink.esua.epdc.dto.PointsBehaviorDTO; |
|||
import com.elink.esua.epdc.dto.PointsBehaviorRuleDTO; |
|||
import com.elink.esua.epdc.dto.PointsRuleDTO; |
|||
import com.elink.esua.epdc.dto.result.BehaviorResultDto; |
|||
import com.elink.esua.epdc.dto.result.PointsRuleResultDTO; |
|||
import com.elink.esua.epdc.entity.PointsBehaviorRuleEntity; |
|||
import com.elink.esua.epdc.entity.PointsRuleEntity; |
|||
import com.elink.esua.epdc.redis.PointsRuleRedis; |
|||
import com.elink.esua.epdc.service.PointsRuleService; |
|||
import org.apache.commons.lang3.StringUtils; |
|||
import org.springframework.beans.factory.annotation.Autowired; |
|||
import org.springframework.stereotype.Service; |
|||
import org.springframework.transaction.annotation.Transactional; |
|||
|
|||
import java.util.Arrays; |
|||
import java.util.List; |
|||
import java.util.Map; |
|||
|
|||
/** |
|||
* 积分规则管理表 积分规则管理表 |
|||
* |
|||
* @author zhangyong |
|||
* @since v1.0.0 2020-04-28 |
|||
*/ |
|||
@Service |
|||
public class PointsRuleServiceImpl extends BaseServiceImpl<PointsRuleDao, PointsRuleEntity> implements PointsRuleService { |
|||
|
|||
@Autowired |
|||
private PointsRuleRedis pointsRuleRedis; |
|||
|
|||
@Autowired |
|||
private RedisUtils redisUtils; |
|||
|
|||
@Autowired |
|||
private PointsBehaviorRuleDao pointsBehaviorRuleDao; |
|||
|
|||
@Autowired |
|||
private PointsBehaviorDao pointsBehaviorDao; |
|||
|
|||
@Override |
|||
public PageData<PointsRuleDTO> page(Map<String, Object> params) { |
|||
IPage<PointsRuleDTO> page = getPage(params); |
|||
List<PointsRuleDTO> list = baseDao.selectListPointsRule(params); |
|||
return new PageData<>(list, page.getTotal()); |
|||
} |
|||
|
|||
@Override |
|||
public List<PointsRuleDTO> list(Map<String, Object> params) { |
|||
List<PointsRuleEntity> entityList = baseDao.selectList(getWrapper(params)); |
|||
|
|||
return ConvertUtils.sourceToTarget(entityList, PointsRuleDTO.class); |
|||
} |
|||
|
|||
private QueryWrapper<PointsRuleEntity> getWrapper(Map<String, Object> params) { |
|||
String id = (String) params.get(FieldConstant.ID_HUMP); |
|||
|
|||
QueryWrapper<PointsRuleEntity> wrapper = new QueryWrapper<>(); |
|||
wrapper.eq(StringUtils.isNotBlank(id), FieldConstant.ID, id); |
|||
|
|||
return wrapper; |
|||
} |
|||
|
|||
@Override |
|||
public PointsRuleDTO get(String id) { |
|||
PointsRuleEntity entity = baseDao.selectById(id); |
|||
PointsRuleDTO dto = ConvertUtils.sourceToTarget(entity, PointsRuleDTO.class); |
|||
dto.setBehaviorCodeArray(baseDao.selectListBehaviorCode(dto.getId())); |
|||
return dto; |
|||
} |
|||
|
|||
@Override |
|||
@Transactional(rollbackFor = Exception.class) |
|||
public Result save(PointsRuleDTO dto) { |
|||
// 判断积分规则编码是否重复
|
|||
Result checkRuleCode = this.checkRuleCodeIsExist(dto.getRuleCode()); |
|||
if (checkRuleCode.getCode() == ErrorCode.INTERNAL_SERVER_ERROR) { |
|||
return checkRuleCode; |
|||
} |
|||
|
|||
// 积分规则管理表
|
|||
PointsRuleEntity entity = ConvertUtils.sourceToTarget(dto, PointsRuleEntity.class); |
|||
insert(entity); |
|||
// 存入积分动作规则关系表
|
|||
this.insertPointsBehaviorRule(dto, entity.getId()); |
|||
|
|||
// 存入redis
|
|||
redisUtils.set(RedisKeys.getAllPointsRuleCodeKey(entity.getRuleCode()), entity, RedisUtils.NOT_EXPIRE); |
|||
return new Result(); |
|||
} |
|||
|
|||
/** |
|||
* @Description: 查询积分规则编码是否存在 |
|||
* @Param: [behaviorCode] |
|||
* @return: com.elink.esua.epdc.commons.tools.utils.Result |
|||
* @Author: zy |
|||
* @Date: 2020-04-28 |
|||
*/ |
|||
private Result checkRuleCodeIsExist(String ruleCode) { |
|||
Object bhc = redisUtils.get(RedisKeys.getAllPointsRuleCodeKey(ruleCode)); |
|||
if (bhc != null) { |
|||
return new Result().error("积分规则编码已存在,请重新设置"); |
|||
} |
|||
return new Result(); |
|||
} |
|||
|
|||
@Override |
|||
@Transactional(rollbackFor = Exception.class) |
|||
public Result update(PointsRuleDTO dto) { |
|||
// 查询之前的积分规则编码、动作编码
|
|||
PointsRuleEntity queryEntity = baseDao.selectById(dto.getId()); |
|||
// 判断本次修改操作是否修改了积分规则编码, 如果改动了,查询新的积分规则编码是否已存在
|
|||
if (!(queryEntity.getRuleCode().equals(dto.getRuleCode()))) { |
|||
Result checkRuleCode = this.checkRuleCodeIsExist(dto.getRuleCode()); |
|||
if (checkRuleCode.getCode() == ErrorCode.INTERNAL_SERVER_ERROR) { |
|||
return checkRuleCode; |
|||
} |
|||
} |
|||
// 修改积分规则管理表
|
|||
PointsRuleEntity entity = ConvertUtils.sourceToTarget(dto, PointsRuleEntity.class); |
|||
updateById(entity); |
|||
// 删除积分动作规则关系表
|
|||
pointsBehaviorRuleDao.deletePointsBehaviorRule(dto.getId()); |
|||
// 存入积分动作规则关系表
|
|||
this.insertPointsBehaviorRule(dto, dto.getId()); |
|||
// 删除redis中的存储信息
|
|||
redisUtils.delete(RedisKeys.getAllPointsRuleCodeKey(queryEntity.getRuleCode())); |
|||
// 新增redis信息
|
|||
redisUtils.set(RedisKeys.getAllPointsRuleCodeKey(entity.getRuleCode()), entity, RedisUtils.NOT_EXPIRE); |
|||
return new Result(); |
|||
} |
|||
|
|||
@Override |
|||
@Transactional(rollbackFor = Exception.class) |
|||
public void delete(String[] ids) { |
|||
PointsRuleEntity entity = baseDao.selectById(ids[0]); |
|||
// 逻辑删除(@TableLogic 注解)
|
|||
baseDao.deleteBatchIds(Arrays.asList(ids)); |
|||
// 删除redis中的存储信息
|
|||
redisUtils.delete(RedisKeys.getAllPointsRuleCodeKey(entity.getRuleCode())); |
|||
} |
|||
|
|||
@Override |
|||
public PointsRuleResultDTO getPointsRuleByBehaviorCode(String behaviorCode) { |
|||
return baseDao.selecOnePointsRuleByBehaviorCode(behaviorCode); |
|||
} |
|||
|
|||
/** |
|||
* @param ruleCode |
|||
* @return com.elink.esua.epdc.dto.rule.PointsRuleDTO |
|||
* @Author yinzuomei |
|||
* @Description 根据规则编码查询规则信息 |
|||
* @Date 2019/12/12 16:30 |
|||
**/ |
|||
@Override |
|||
public Result<PointsRuleDTO> getPointRule(String ruleCode) { |
|||
if (StringUtils.isBlank(ruleCode)) { |
|||
return new Result<PointsRuleDTO>().error("规则编码不能为空"); |
|||
} |
|||
String pointsRuleKey = RedisKeys.getPointsRuleKey(ruleCode); |
|||
Object obj = redisUtils.get(pointsRuleKey); |
|||
if (null == obj) { |
|||
QueryWrapper<PointsRuleEntity> wrapper = new QueryWrapper<>(); |
|||
wrapper.eq("RULE_CODE", ruleCode); |
|||
List<PointsRuleEntity> pointsRuleEntityList = baseDao.selectList(wrapper); |
|||
if (CollUtil.isEmpty(pointsRuleEntityList)) { |
|||
return new Result<PointsRuleDTO>().error("没有找到有效记录"); |
|||
} else if (pointsRuleEntityList.size() > 1) { |
|||
return new Result<PointsRuleDTO>().error("规则编码不唯一"); |
|||
} |
|||
redisUtils.set(pointsRuleKey, pointsRuleEntityList.get(0)); |
|||
obj = redisUtils.get(pointsRuleKey); |
|||
} |
|||
PointsRuleDTO pointsRuleDTO = ConvertUtils.sourceToTarget(obj, PointsRuleDTO.class); |
|||
return new Result<PointsRuleDTO>().ok(pointsRuleDTO); |
|||
} |
|||
|
|||
/** |
|||
* @param |
|||
* @return com.elink.esua.epdc.commons.tools.utils.Result |
|||
* @Author yinzuomei |
|||
* @Description 项目启动初始化积分规则到redis |
|||
* @Date 2019/12/12 16:26 |
|||
**/ |
|||
@Override |
|||
public Result initPointsRuleRedis() { |
|||
QueryWrapper<PointsRuleEntity> wrapper = new QueryWrapper<>(); |
|||
wrapper.eq("ENABLE_FLAG", PointsRuleAvailableEnum.AVAILABLE_TRUE.value()); |
|||
List<PointsRuleEntity> pointsRuleEntityList = baseDao.selectList(wrapper); |
|||
for (PointsRuleEntity pointsRuleEntity : pointsRuleEntityList) { |
|||
String pointsRuleKey = RedisKeys.getPointsRuleKey(pointsRuleEntity.getRuleCode()); |
|||
redisUtils.set(pointsRuleKey, pointsRuleEntity); |
|||
} |
|||
return new Result(); |
|||
} |
|||
|
|||
/** |
|||
* 存入积分动作规则关系表 |
|||
* @param pointsRuleDTO |
|||
* @param pointsRuldId 积分规则表主键ID |
|||
* @return void |
|||
* @Author zhangyong |
|||
* @Date 10:37 2020-05-11 |
|||
**/ |
|||
private void insertPointsBehaviorRule(PointsRuleDTO pointsRuleDTO, String pointsRuldId) { |
|||
for (String behaviorCode : pointsRuleDTO.getBehaviorCodeArray()){ |
|||
PointsBehaviorRuleDTO dto = new PointsBehaviorRuleDTO(); |
|||
// 根据动作编码查询动作ID
|
|||
BehaviorResultDto pointsBehavior = pointsBehaviorDao.getBehaviorCodeInfoByBehaviorCode(behaviorCode); |
|||
dto.setBehaviorId(pointsBehavior.getId()); |
|||
dto.setRuleId(pointsRuldId); |
|||
PointsBehaviorRuleEntity entity = ConvertUtils.sourceToTarget(dto, PointsBehaviorRuleEntity.class); |
|||
pointsBehaviorRuleDao.insert(entity); |
|||
} |
|||
|
|||
} |
|||
} |
@ -0,0 +1,93 @@ |
|||
<?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.elink.esua.epdc.dao.PointsBehaviorDao"> |
|||
|
|||
<resultMap type="com.elink.esua.epdc.entity.PointsBehaviorEntity" id="pointsBehaviorMap"> |
|||
<result property="id" column="ID"/> |
|||
<result property="behaviorCode" column="BEHAVIOR_CODE"/> |
|||
<result property="behaviorDesc" column="BEHAVIOR_DESC"/> |
|||
<result property="behaviorRecordingTime" column="BEHAVIOR_RECORDING_TIME"/> |
|||
<result property="remark" column="REMARK"/> |
|||
<result property="revision" column="REVISION"/> |
|||
<result property="delFlag" column="DEL_FLAG"/> |
|||
<result property="createdBy" column="CREATED_BY"/> |
|||
<result property="createdTime" column="CREATED_TIME"/> |
|||
<result property="updatedBy" column="UPDATED_BY"/> |
|||
<result property="updatedTime" column="UPDATED_TIME"/> |
|||
</resultMap> |
|||
|
|||
<select id="selectListPointsBehavior" resultType="com.elink.esua.epdc.dto.PointsBehaviorDTO"> |
|||
SELECT |
|||
(@i:=@i+1) as orderNumber, |
|||
b.ID id, |
|||
b.BEHAVIOR_CODE behaviorCode, |
|||
b.BEHAVIOR_DESC behaviorDesc, |
|||
b.BEHAVIOR_RECORDING_TIME behaviorRecordingTime, |
|||
b.REMARK remark |
|||
FROM |
|||
`epdc_points_behavior` b, (select @i:=0) as it |
|||
WHERE b.DEL_FLAG = 0 |
|||
<if test="behaviorCode != null and behaviorCode.trim() != ''"> |
|||
AND instr(b.BEHAVIOR_CODE , trim(#{behaviorCode}) ) > 0 |
|||
</if> |
|||
<if test="behaviorDesc != null and behaviorDesc.trim() != ''"> |
|||
AND instr(b.BEHAVIOR_DESC , trim(#{behaviorDesc}) ) > 0 |
|||
</if> |
|||
ORDER BY |
|||
b.CREATED_TIME |
|||
</select> |
|||
|
|||
|
|||
<select id="getBehaviorCodeInfoByBehaviorCode" resultType="com.elink.esua.epdc.dto.result.BehaviorResultDto"> |
|||
select ID,BEHAVIOR_CODE,BEHAVIOR_DESC,BEHAVIOR_RECORDING_TIME,REMARK,REVISION,DEL_FLAG,CREATED_BY |
|||
,CREATED_TIME,UPDATED_BY,UPDATED_TIME |
|||
from epdc_points_behavior where BEHAVIOR_CODE = #{behaviorCode} and DEL_FLAG ='0' limit 1; |
|||
|
|||
</select> |
|||
<select id="selectAllListBehaviorDesc" resultType="com.elink.esua.epdc.dto.PointsBehaviorDTO"> |
|||
SELECT |
|||
b.BEHAVIOR_CODE behaviorCode, |
|||
b.BEHAVIOR_DESC behaviorDesc |
|||
FROM |
|||
`epdc_points_behavior` b |
|||
WHERE |
|||
b.DEL_FLAG = 0 |
|||
</select> |
|||
|
|||
<select id="selectListBehaviorDesc" resultType="com.elink.esua.epdc.dto.PointsBehaviorDTO"> |
|||
SELECT |
|||
b.BEHAVIOR_CODE behaviorCode, |
|||
b.BEHAVIOR_DESC behaviorDesc, |
|||
case when br.ID IS NULL |
|||
then false |
|||
else true |
|||
end disabled |
|||
FROM |
|||
`epdc_points_behavior` b |
|||
LEFT JOIN epdc_points_behavior_rule br ON b.id = br.BEHAVIOR_ID AND br.DEL_FLAG = 0 |
|||
WHERE |
|||
b.DEL_FLAG = 0 |
|||
GROUP BY b.id |
|||
</select> |
|||
|
|||
<select id="selectBehaviorDescItExist" resultType="int"> |
|||
SELECT |
|||
count(1) |
|||
FROM |
|||
epdc_points_behavior b |
|||
WHERE |
|||
b.DEL_FLAG = 0 |
|||
AND b.BEHAVIOR_DESC = #{behaviorDesc} |
|||
</select> |
|||
|
|||
<select id="selectBehaviorCodeDoestItExist" resultType="int"> |
|||
SELECT |
|||
count(1) |
|||
FROM |
|||
epdc_points_behavior_rule br LEFT JOIN epdc_points_behavior b ON br.BEHAVIOR_ID = b.ID |
|||
WHERE |
|||
br.DEL_FLAG = 0 |
|||
AND b.BEHAVIOR_CODE = #{behaviorCode} |
|||
</select> |
|||
</mapper> |
@ -0,0 +1,23 @@ |
|||
<?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.elink.esua.epdc.dao.PointsBehaviorRuleDao"> |
|||
|
|||
<resultMap type="com.elink.esua.epdc.entity.PointsBehaviorRuleEntity" id="pointsBehaviorRuleMap"> |
|||
<result property="id" column="ID"/> |
|||
<result property="behaviorId" column="BEHAVIOR_ID"/> |
|||
<result property="ruleId" column="RULE_ID"/> |
|||
<result property="revision" column="REVISION"/> |
|||
<result property="delFlag" column="DEL_FLAG"/> |
|||
<result property="createdBy" column="CREATED_BY"/> |
|||
<result property="createdTime" column="CREATED_TIME"/> |
|||
<result property="updatedBy" column="UPDATED_BY"/> |
|||
<result property="updatedTime" column="UPDATED_TIME"/> |
|||
</resultMap> |
|||
|
|||
<delete id="deletePointsBehaviorRule"> |
|||
update epdc_points_behavior_rule |
|||
set DEL_FLAG = '1' |
|||
where DEL_FLAG='0' and RULE_ID =#{ruleId} |
|||
</delete> |
|||
</mapper> |
@ -0,0 +1,226 @@ |
|||
<?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.elink.esua.epdc.dao.PointsLogsDao"> |
|||
|
|||
<resultMap type="com.elink.esua.epdc.entity.PointsLogsEntity" id="pointsLogsMap"> |
|||
<result property="id" column="ID"/> |
|||
<result property="userId" column="USER_ID"/> |
|||
<result property="referenceId" column="REFERENCE_ID"/> |
|||
<result property="ruleCode" column="RULE_CODE"/> |
|||
<result property="behaviorCode" column="BEHAVIOR_CODE"/> |
|||
<result property="operationType" column="OPERATION_TYPE"/> |
|||
<result property="points" column="POINTS"/> |
|||
<result property="operationDesc" column="OPERATION_DESC"/> |
|||
<result property="operationTime" column="OPERATION_TIME"/> |
|||
<result property="operationMode" column="OPERATION_MODE"/> |
|||
<result property="lavePoints" column="LAVE_POINTS"/> |
|||
<result property="revision" column="REVISION"/> |
|||
<result property="delFlag" column="DEL_FLAG"/> |
|||
<result property="createdBy" column="CREATED_BY"/> |
|||
<result property="createdTime" column="CREATED_TIME"/> |
|||
<result property="updatedBy" column="UPDATED_BY"/> |
|||
<result property="updatedTime" column="UPDATED_TIME"/> |
|||
</resultMap> |
|||
|
|||
<select id="selectListPointsRecord" resultType="com.elink.esua.epdc.dto.result.EpdcAppPointsRecordResultDTO"> |
|||
SELECT |
|||
l.ID id, |
|||
l.OPERATION_DESC ruleDesc, |
|||
l.OPERATION_TYPE operationType, |
|||
l.POINTS points, |
|||
l.OPERATION_TIME operationTime |
|||
FROM |
|||
epdc_points_logs l |
|||
WHERE l.DEL_FLAG = 0 |
|||
AND l.USER_ID = #{userId} |
|||
ORDER BY |
|||
l.OPERATION_TIME DESC |
|||
LIMIT #{pageIndex}, #{pageSize} |
|||
</select> |
|||
<select id="selecOneLogsByBehaviorCodeAndUserIdAndReferenceId" |
|||
resultType="com.elink.esua.epdc.dto.result.PointsLogsResultDTO"> |
|||
select ID,USER_ID,REFERENCE_ID,RULE_CODE,BEHAVIOR_CODE,POINTS,OPERATION_DESC,OPERATION_TIME,OPERATION_MODE |
|||
,LAVE_POINTS,REVISION,DEL_FLAG,CREATED_BY,CREATED_TIME,UPDATED_BY,UPDATED_TIME |
|||
from epdc_points_logs where DEL_FLAG ='0' and USER_ID = #{userId} and REFERENCE_ID = #{referenceId} |
|||
and RULE_CODE = #{ruleCode} |
|||
</select> |
|||
|
|||
<select id="getPointsSumByBehaviorCodeAndUserId" resultType="integer"> |
|||
select sum(z) - sum(f) as total from( |
|||
select |
|||
case when OPERATION_TYPE =0 then sum(POINTS) else 0 end as f, |
|||
case when OPERATION_TYPE =1 then sum(POINTS) else 0 end as z, |
|||
BEHAVIOR_CODE |
|||
from epdc_points_logs where USER_ID = #{userId} and BEHAVIOR_CODE = #{behaviorCode} |
|||
<if test="operationFlag == 0"> |
|||
and OPERATION_TIME between date_add(now() , interval -1 minute ) and now() |
|||
</if> |
|||
<if test="operationFlag == 1"> |
|||
and OPERATION_TIME between date_add(now() , interval -1 hour ) and now() |
|||
</if> |
|||
<if test="operationFlag == 2"> |
|||
and date_format(OPERATION_TIME,'%d') = date_format(now(),'%d') |
|||
</if> |
|||
<if test="operationFlag == 3"> |
|||
and date_format(OPERATION_TIME,'%m') = date_format(now(),'%m') |
|||
</if> |
|||
<if test="operationFlag == 4"> |
|||
and date_format(OPERATION_TIME,'%Y') = date_format(now(),'%Y') |
|||
</if> |
|||
group by OPERATION_TYPE)a group by a.BEHAVIOR_CODE; |
|||
</select> |
|||
|
|||
<select id="getLastPointLogs" resultType="com.elink.esua.epdc.dto.result.PointsLogsResultDTO"> |
|||
select ID,USER_ID,REFERENCE_ID,RULE_CODE,BEHAVIOR_CODE,POINTS,OPERATION_DESC,OPERATION_TIME,OPERATION_MODE |
|||
,LAVE_POINTS,REVISION,DEL_FLAG,CREATED_BY,CREATED_TIME,UPDATED_BY,UPDATED_TIME |
|||
from epdc_points_logs where DEL_FLAG ='0' and USER_ID = #{userId} |
|||
and BEHAVIOR_CODE = #{behaviorCode} order by OPERATION_TIME desc limit 1 |
|||
</select> |
|||
|
|||
<select id="selectListPointsRanking" resultType="com.elink.esua.epdc.dto.result.EpdcAppPointsRankingTopTenDTO"> |
|||
SELECT |
|||
tab.USER_ID userId, |
|||
( |
|||
SELECT NICKNAME |
|||
FROM epdc_points_logs |
|||
WHERE tab.USER_ID = USER_ID |
|||
ORDER BY CREATED_TIME DESC |
|||
limit 0,1 |
|||
) nickName, |
|||
(tab.totalPointsAdd - tab.totalPointsDeducted) points |
|||
FROM( |
|||
SELECT |
|||
USER_ID, |
|||
SUM(case when OPERATION_TYPE = 0 then IFNULL(points,0) else 0 end) totalPointsDeducted, |
|||
SUM(case when OPERATION_TYPE = 1 then IFNULL(points,0) else 0 end) totalPointsAdd |
|||
FROM epdc_points_logs |
|||
WHERE DEL_FLAG = 0 |
|||
<if test="rankingType != null and rankingType == 0"> |
|||
AND YEARWEEK(date_format(OPERATION_TIME,'%Y-%m-%d')) = YEARWEEK(now()) |
|||
</if> |
|||
<if test="rankingType != null and rankingType == 1"> |
|||
AND DATE_FORMAT( OPERATION_TIME, '%Y%m' ) = DATE_FORMAT( CURDATE() , '%Y%m' ) |
|||
</if> |
|||
GROUP BY USER_ID |
|||
) tab ORDER BY (tab.totalPointsAdd - tab.totalPointsDeducted) DESC |
|||
LIMIT #{pageIndex}, #{pageSize} |
|||
</select> |
|||
|
|||
<select id="selectListVolunteerPointsLog" resultType="com.elink.esua.epdc.dto.PointsLogsDTO"> |
|||
SELECT |
|||
l.OPERATION_DESC operationDesc, |
|||
b.BEHAVIOR_DESC behaviorCode, |
|||
l.OPERATION_TIME operationTime, |
|||
l.POINTS points, |
|||
l.OPERATION_TYPE operationType, |
|||
l.LAVE_POINTS lavePoints |
|||
FROM |
|||
epdc_points_logs l |
|||
LEFT JOIN epdc_points_behavior b ON l.BEHAVIOR_CODE = b.BEHAVIOR_CODE AND b.DEL_FLAG = 0 |
|||
WHERE |
|||
l.DEL_FLAG = 0 |
|||
AND l.USER_ID = #{userId} |
|||
<if test="behaviorCode != null and behaviorCode != ''"> |
|||
AND l.BEHAVIOR_CODE = #{behaviorCode} |
|||
</if> |
|||
ORDER BY |
|||
l.CREATED_TIME DESC |
|||
</select> |
|||
|
|||
<select id="selectUserPointsRanking" resultType="com.elink.esua.epdc.dto.result.EpdcAppPointsRankingUserDTO"> |
|||
SELECT |
|||
userRanking.rank, |
|||
userRanking.points |
|||
FROM( |
|||
SELECT |
|||
(@i:=@i+1) rank, |
|||
tab.USER_ID userId, |
|||
GROUP_CONCAT(tab.USER_ID SEPARATOR ',') pdtj, |
|||
tab.points |
|||
FROM( |
|||
SELECT |
|||
USER_ID, |
|||
(SUM(case when OPERATION_TYPE = 1 then IFNULL(points,0) else 0 end) - SUM(case when OPERATION_TYPE = 0 then IFNULL(points,0) else 0 end)) points |
|||
FROM epdc_points_logs |
|||
WHERE DEL_FLAG = 0 |
|||
<if test="rankingType != null and rankingType == 0"> |
|||
AND YEARWEEK(date_format(OPERATION_TIME,'%Y-%m-%d')) = YEARWEEK(now()) |
|||
</if> |
|||
<if test="rankingType != null and rankingType == 1"> |
|||
AND DATE_FORMAT( OPERATION_TIME, '%Y%m' ) = DATE_FORMAT( CURDATE() , '%Y%m' ) |
|||
</if> |
|||
GROUP BY USER_ID |
|||
) tab ,(select @i:=0) t1 |
|||
GROUP BY tab.points |
|||
ORDER BY tab.points DESC |
|||
) userRanking |
|||
WHERE instr(userRanking.pdtj , #{userId} ) > 0 |
|||
</select> |
|||
|
|||
<select id="selectCountPointsRanking" resultType="int"> |
|||
SELECT |
|||
COUNT(1) |
|||
FROM( |
|||
SELECT |
|||
p.points |
|||
FROM( |
|||
SELECT |
|||
USER_ID, |
|||
(SUM(case when OPERATION_TYPE = 1 then IFNULL(points,0) else 0 end) - SUM(case when OPERATION_TYPE = 0 then IFNULL(points,0) else 0 end)) points |
|||
FROM epdc_points_logs |
|||
WHERE DEL_FLAG = 0 |
|||
<if test="rankingType != null and rankingType == 0"> |
|||
AND YEARWEEK(date_format(OPERATION_TIME,'%Y-%m-%d')) = YEARWEEK(now()) |
|||
</if> |
|||
<if test="rankingType != null and rankingType == 1"> |
|||
AND DATE_FORMAT( OPERATION_TIME, '%Y%m' ) = DATE_FORMAT( CURDATE() , '%Y%m' ) |
|||
</if> |
|||
GROUP BY USER_ID |
|||
) p GROUP BY p.points |
|||
) tab |
|||
</select> |
|||
|
|||
<select id="selectPointsList" resultType="com.elink.esua.epdc.dto.result.PointsStatisticsListResultDTO"> |
|||
SELECT |
|||
SUM( |
|||
IF( lg.OPERATION_TYPE = '1', lg.POINTS, 0 ) |
|||
) allPoints, |
|||
SUM( |
|||
IF( lg.OPERATION_TYPE = '0', lg.POINTS, 0 ) |
|||
) residuePoints, |
|||
lg.OPERATION_DESC |
|||
FROM |
|||
epdc_points_logs lg |
|||
WHERE |
|||
lg.DEL_FLAG = '0' |
|||
<if test="ruleCode!= null and ruleCode !=''"> |
|||
and lg.RULE_CODE = #{ruleCode} |
|||
</if> |
|||
<if test="startTime!= null and startTime !=''"> |
|||
and lg.OPERATION_TIME between #{startTime} AND #{endTime} |
|||
</if> |
|||
|
|||
GROUP BY |
|||
lg.RULE_CODE |
|||
ORDER BY allPoints DESC |
|||
</select> |
|||
|
|||
<select id="selectPointsOverview" resultType="com.elink.esua.epdc.dto.result.PointsStatisticsListResultDTO"> |
|||
SELECT |
|||
SUM( |
|||
IF( lg.OPERATION_TYPE = '1', lg.POINTS, 0 ) |
|||
) allPoints, |
|||
SUM( |
|||
IF( lg.OPERATION_TYPE = '0', lg.POINTS, 0 ) |
|||
) residuePoints |
|||
FROM |
|||
epdc_points_logs lg |
|||
WHERE |
|||
lg.DEL_FLAG = '0' |
|||
<if test="startTime!= null and startTime !=''"> |
|||
and lg.OPERATION_TIME between #{startTime} AND #{endTime} |
|||
</if> |
|||
ORDER BY lg.OPERATION_TYPE DESC |
|||
</select> |
|||
</mapper> |
@ -0,0 +1,98 @@ |
|||
<?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.elink.esua.epdc.dao.PointsRuleDao"> |
|||
|
|||
<resultMap type="com.elink.esua.epdc.entity.PointsRuleEntity" id="pointsRuleMap"> |
|||
<result property="id" column="ID"/> |
|||
<result property="ruleCode" column="RULE_CODE"/> |
|||
<result property="ruleDesc" column="RULE_DESC"/> |
|||
<result property="operationType" column="OPERATION_TYPE"/> |
|||
<result property="points" column="POINTS"/> |
|||
<result property="limitType" column="LIMIT_TYPE"/> |
|||
<result property="upperLimitVal" column="UPPER_LIMIT_VAL"/> |
|||
<result property="limitNum" column="LIMIT_NUM"/> |
|||
<result property="enableFlag" column="ENABLE_FLAG"/> |
|||
<result property="addedVal" column="ADDED_VAL"/> |
|||
<result property="remark" column="REMARK"/> |
|||
<result property="revision" column="REVISION"/> |
|||
<result property="delFlag" column="DEL_FLAG"/> |
|||
<result property="createdBy" column="CREATED_BY"/> |
|||
<result property="createdTime" column="CREATED_TIME"/> |
|||
<result property="updatedBy" column="UPDATED_BY"/> |
|||
<result property="updatedTime" column="UPDATED_TIME"/> |
|||
</resultMap> |
|||
|
|||
<select id="selecOnePointsRuleByBehaviorCode" resultType="com.elink.esua.epdc.dto.result.PointsRuleResultDTO"> |
|||
select epr.RULE_CODE,epb.BEHAVIOR_CODE,epr.RULE_DESC,epr.OPERATION_TYPE,epr.POINTS,epr.LIMIT_TYPE,epr.UPPER_LIMIT_VAL |
|||
,epr.ENABLE_FLAG,epr.ADDED_VAL,epr.LIMIT_NUM,epb.BEHAVIOR_DESC |
|||
from epdc_points_behavior_rule epbr |
|||
left join epdc_points_behavior epb on epb.ID = epbr.BEHAVIOR_ID |
|||
left join epdc_points_rule epr on epr.ID = epbr.RULE_ID |
|||
where epbr.DEL_FLAG='0' and epb.DEL_FLAG='0' and epr.DEL_FLAG='0' and epr.ENABLE_FLAG = '1' and epb.BEHAVIOR_CODE = #{behaviorCode} |
|||
order by epbr.CREATED_TIME desc |
|||
limit 1; |
|||
</select> |
|||
|
|||
<select id="selectListPointsRule" resultType="com.elink.esua.epdc.dto.PointsRuleDTO"> |
|||
SELECT |
|||
(@i:=@i+1) as orderNumber, |
|||
r.id, |
|||
r.ruleCode, |
|||
r.ruleDesc, |
|||
r.operationType, |
|||
r.points, |
|||
r.limitType, |
|||
r.upperLimitVal, |
|||
r.limitNum, |
|||
r.enableFlag, |
|||
r.addedVal, |
|||
r.remark, |
|||
r.behaviorCode |
|||
FROM( |
|||
SELECT |
|||
r.ID id, |
|||
r.RULE_CODE ruleCode, |
|||
r.RULE_DESC ruleDesc, |
|||
r.OPERATION_TYPE operationType, |
|||
r.POINTS points, |
|||
r.LIMIT_TYPE limitType, |
|||
r.UPPER_LIMIT_VAL upperLimitVal, |
|||
r.LIMIT_NUM limitNum, |
|||
r.ENABLE_FLAG enableFlag, |
|||
r.ADDED_VAL addedVal, |
|||
r.REMARK remark, |
|||
GROUP_CONCAT(b.BEHAVIOR_CODE) as behaviorCode, |
|||
r.CREATED_TIME |
|||
FROM |
|||
epdc_points_rule r |
|||
LEFT JOIN epdc_points_behavior_rule br ON r.id = br.RULE_ID AND br.DEL_FLAG = 0 |
|||
LEFT JOIN epdc_points_behavior b ON br.BEHAVIOR_ID = b.ID AND b.DEL_FLAG = 0 |
|||
WHERE r.DEL_FLAG = 0 |
|||
<if test="ruleCode != null and ruleCode.trim() != ''"> |
|||
AND instr(r.RULE_CODE , trim(#{ruleCode}) ) > 0 |
|||
</if> |
|||
<if test="ruleDesc != null and ruleDesc.trim() != ''"> |
|||
AND instr(r.RULE_DESC , trim(#{ruleDesc}) ) > 0 |
|||
</if> |
|||
<if test="operationType != null and operationType != ''"> |
|||
AND r.OPERATION_TYPE = #{operationType} |
|||
</if> |
|||
<if test="enableFlag != null and enableFlag != ''"> |
|||
AND r.ENABLE_FLAG = #{enableFlag} |
|||
</if> |
|||
GROUP BY r.ID |
|||
) r, (select @i:=0) as it |
|||
ORDER BY r.CREATED_TIME DESC |
|||
</select> |
|||
|
|||
<select id="selectListBehaviorCode" resultType="String"> |
|||
SELECT |
|||
b.BEHAVIOR_CODE behaviorCodeArray |
|||
FROM |
|||
epdc_points_rule r |
|||
LEFT JOIN epdc_points_behavior_rule br ON r.id = br.RULE_ID AND br.DEL_FLAG = 0 |
|||
LEFT JOIN epdc_points_behavior b ON br.BEHAVIOR_ID = b.ID AND b.DEL_FLAG = 0 |
|||
WHERE r.DEL_FLAG = 0 AND r.id = #{pointsRuldId} |
|||
</select> |
|||
</mapper> |
@ -1,49 +0,0 @@ |
|||
<?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.elink.esua.epdc.modules.logs.dao.PointsLogsDao"> |
|||
|
|||
<resultMap type="com.elink.esua.epdc.modules.logs.entity.PointsLogsEntity" id="pointsLogsMap"> |
|||
<result property="id" column="ID"/> |
|||
<result property="volunteerId" column="VOLUNTEER_ID"/> |
|||
<result property="userId" column="USER_ID"/> |
|||
<result property="operationType" column="OPERATION_TYPE"/> |
|||
<result property="points" column="POINTS"/> |
|||
<result property="operationDesc" column="OPERATION_DESC"/> |
|||
<result property="operationTime" column="OPERATION_TIME"/> |
|||
<result property="operationMode" column="OPERATION_MODE"/> |
|||
<result property="ruleCode" column="RULE_CODE"/> |
|||
<result property="status" column="STATUS"/> |
|||
<result property="failureReason" column="FAILURE_REASON"/> |
|||
<result property="delFlag" column="DEL_FLAG"/> |
|||
<result property="revision" column="REVISION"/> |
|||
<result property="createdBy" column="CREATED_BY"/> |
|||
<result property="createdTime" column="CREATED_TIME"/> |
|||
<result property="updatedBy" column="UPDATED_BY"/> |
|||
<result property="updatedTime" column="UPDATED_TIME"/> |
|||
<result property="lavePoints" column="LAVE_POINTS"></result> |
|||
<result property="behaviorCode" column="BEHAVIOR_CODE"/> |
|||
</resultMap> |
|||
|
|||
<select id="selectListVolunteerPointsLog" resultType="com.elink.esua.epdc.dto.logs.PointsLogsDTO"> |
|||
SELECT |
|||
l.OPERATION_DESC operationDesc, |
|||
b.BEHAVIOR_DESC behaviorCode, |
|||
l.OPERATION_TIME operationTime, |
|||
l.POINTS points, |
|||
l.OPERATION_TYPE operationType, |
|||
l.LAVE_POINTS lavePoints |
|||
FROM |
|||
epdc_points_logs l |
|||
LEFT JOIN epdc_points_behavior b ON l.BEHAVIOR_CODE = b.BEHAVIOR_CODE |
|||
AND b.DEL_FLAG = 0 |
|||
WHERE |
|||
l.DEL_FLAG = 0 |
|||
AND l.USER_ID = #{userId} |
|||
<if test="behaviorCode !='' and behaviorCode != null"> |
|||
and l.BEHAVIOR_CODE = #{behaviorCode} |
|||
</if> |
|||
ORDER BY |
|||
l.CREATED_TIME DESC |
|||
</select> |
|||
</mapper> |
@ -1,27 +0,0 @@ |
|||
<?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.elink.esua.epdc.modules.rule.dao.PointsRuleDao"> |
|||
|
|||
<resultMap type="com.elink.esua.epdc.modules.rule.entity.PointsRuleEntity" id="pointsRuleMap"> |
|||
<result property="id" column="ID"/> |
|||
<result property="ruleCode" column="RULE_CODE"/> |
|||
<result property="ruleDesc" column="RULE_DESC"/> |
|||
<result property="points" column="POINTS"/> |
|||
<result property="operationType" column="OPERATION_TYPE"/> |
|||
<result property="available" column="AVAILABLE"/> |
|||
<result property="behaviorCode" column="BEHAVIOR_CODE"/> |
|||
<result property="behaviorDesc" column="BEHAVIOR_DESC"/> |
|||
<result property="upperLimitFlag" column="UPPER_LIMIT_FLAG"/> |
|||
<result property="limitTimeType" column="LIMIT_TIME_TYPE"/> |
|||
<result property="upperLimitVal" column="UPPER_LIMIT_VAL"/> |
|||
<result property="delFlag" column="DEL_FLAG"/> |
|||
<result property="revision" column="REVISION"/> |
|||
<result property="createdBy" column="CREATED_BY"/> |
|||
<result property="createdTime" column="CREATED_TIME"/> |
|||
<result property="updatedBy" column="UPDATED_BY"/> |
|||
<result property="updatedTime" column="UPDATED_TIME"/> |
|||
</resultMap> |
|||
|
|||
|
|||
</mapper> |
Loading…
Reference in new issue