@@ -124,6 +124,22 @@ | |||
<artifactId>aliyun-java-sdk-core</artifactId> | |||
<version>4.4.6</version> | |||
</dependency> | |||
<!--mapStruct依赖 高性能对象映射--> | |||
<!--mapstruct核心--> | |||
<dependency> | |||
<groupId>org.mapstruct</groupId> | |||
<artifactId>mapstruct</artifactId> | |||
<version>1.5.3.Final</version> | |||
</dependency> | |||
<!--mapstruct编译--> | |||
<dependency> | |||
<groupId>org.mapstruct</groupId> | |||
<artifactId>mapstruct-processor</artifactId> | |||
<version>1.5.3.Final</version> | |||
</dependency> | |||
</dependencies> | |||
<profiles> |
@@ -1,7 +1,7 @@ | |||
package com.tuoheng.api.controller; | |||
import com.tuoheng.api.entity.request.UserPointsDetailQuery; | |||
import com.tuoheng.api.service.IUserPointsDetailService; | |||
import com.tuoheng.api.service.points.IUserPointsDetailService; | |||
import com.tuoheng.common.utils.JsonResult; | |||
import org.springframework.beans.factory.annotation.Autowired; | |||
import org.springframework.web.bind.annotation.GetMapping; |
@@ -0,0 +1,37 @@ | |||
package com.tuoheng.api.controller; | |||
import com.tuoheng.api.entity.request.ReceivePonitsRequest; | |||
import com.tuoheng.api.service.points.IUserPointsDetailService; | |||
import com.tuoheng.common.utils.JsonResult; | |||
import lombok.RequiredArgsConstructor; | |||
import org.springframework.web.bind.annotation.PostMapping; | |||
import org.springframework.web.bind.annotation.RequestBody; | |||
import org.springframework.web.bind.annotation.RequestMapping; | |||
import org.springframework.web.bind.annotation.RestController; | |||
/** | |||
* 小程序用户 前端控制器 | |||
* | |||
* @author wanjing | |||
* @since 2023-11-23 | |||
*/ | |||
@RestController | |||
@RequiredArgsConstructor | |||
@RequestMapping("/userPoints") | |||
public class UserPointsController { | |||
private final IUserPointsDetailService userPointsDetailService; | |||
/** | |||
* 领取积分 | |||
* | |||
* @param request | |||
* @return | |||
*/ | |||
@PostMapping("/receive") | |||
public JsonResult add(@RequestBody ReceivePonitsRequest request) { | |||
return userPointsDetailService.receive(request); | |||
} | |||
} |
@@ -0,0 +1,38 @@ | |||
package com.tuoheng.api.controller; | |||
import com.tuoheng.api.entity.request.AddWestreamSubmitRequest; | |||
import com.tuoheng.api.entity.request.AddWestreamVolunteerRequest; | |||
import com.tuoheng.api.service.westream.submit.WestreamSubmitService; | |||
import com.tuoheng.common.utils.JsonResult; | |||
import lombok.RequiredArgsConstructor; | |||
import org.springframework.beans.factory.annotation.Autowired; | |||
import org.springframework.web.bind.annotation.PostMapping; | |||
import org.springframework.web.bind.annotation.RequestBody; | |||
import org.springframework.web.bind.annotation.RequestMapping; | |||
import org.springframework.web.bind.annotation.RestController; | |||
/** | |||
* 小程序用户 前端控制器 | |||
* | |||
* @author wanjing | |||
* @since 2023-11-23 | |||
*/ | |||
@RestController | |||
@RequiredArgsConstructor | |||
@RequestMapping("/westreamSubmit") | |||
public class WestreamSubmitController { | |||
private final WestreamSubmitService westreamSubmitService; | |||
/** | |||
* 上报 | |||
* | |||
* @param request | |||
* @return | |||
*/ | |||
@PostMapping("/report") | |||
public JsonResult report(@RequestBody AddWestreamSubmitRequest request){ | |||
return westreamSubmitService.report(request); | |||
} | |||
} |
@@ -0,0 +1,36 @@ | |||
package com.tuoheng.api.controller; | |||
import com.tuoheng.api.entity.request.AddWestreamVolunteerRequest; | |||
import com.tuoheng.api.service.westream.volunteer.WestreamVolunteerService; | |||
import com.tuoheng.common.utils.JsonResult; | |||
import lombok.RequiredArgsConstructor; | |||
import org.springframework.web.bind.annotation.PostMapping; | |||
import org.springframework.web.bind.annotation.RequestBody; | |||
import org.springframework.web.bind.annotation.RequestMapping; | |||
import org.springframework.web.bind.annotation.RestController; | |||
/** | |||
* 小程序用户 前端控制器 | |||
* | |||
* @author wanjing | |||
* @since 2023-11-23 | |||
*/ | |||
@RestController | |||
@RequiredArgsConstructor | |||
@RequestMapping("/westreamVolunteer") | |||
public class WestreamVolunteerController { | |||
private final WestreamVolunteerService westreamVolunteerService; | |||
/** | |||
* 志愿服务提交 | |||
* | |||
* @param request | |||
* @return | |||
*/ | |||
@PostMapping("/add") | |||
public JsonResult add(@RequestBody AddWestreamVolunteerRequest request) { | |||
return westreamVolunteerService.add(request); | |||
} | |||
} |
@@ -0,0 +1,15 @@ | |||
package com.tuoheng.api.conver; | |||
import com.tuoheng.api.entity.domain.WestreamSubmit; | |||
import com.tuoheng.api.entity.request.AddWestreamSubmitRequest; | |||
import org.mapstruct.Mapper; | |||
import org.mapstruct.factory.Mappers; | |||
@Mapper | |||
public interface WestreamSubmitConverMapper { | |||
WestreamSubmitConverMapper INSTANCE = Mappers.getMapper(WestreamSubmitConverMapper.class); | |||
WestreamSubmit addRequestToWestreamSubmit(AddWestreamSubmitRequest request); | |||
} |
@@ -0,0 +1,15 @@ | |||
package com.tuoheng.api.conver; | |||
import com.tuoheng.api.entity.request.AddWestreamVolunteerRequest; | |||
import com.tuoheng.api.entity.domain.WestreamVolunteer; | |||
import org.mapstruct.Mapper; | |||
import org.mapstruct.factory.Mappers; | |||
@Mapper | |||
public interface WestreamVolunteerConverMapper { | |||
WestreamVolunteerConverMapper INSTANCE = Mappers.getMapper(WestreamVolunteerConverMapper.class); | |||
WestreamVolunteer addRequestToWestreamVolunteer(AddWestreamVolunteerRequest request); | |||
} |
@@ -0,0 +1,40 @@ | |||
package com.tuoheng.api.entity.domain; | |||
import com.baomidou.mybatisplus.annotation.TableName; | |||
import com.tuoheng.common.common.BaseEntity; | |||
import lombok.Data; | |||
import lombok.EqualsAndHashCode; | |||
import lombok.experimental.Accessors; | |||
import java.io.Serializable; | |||
/** | |||
* 全民护河知识用户表 | |||
* | |||
* @author wanjing | |||
* @since 2023-11-23 | |||
*/ | |||
@Data | |||
@EqualsAndHashCode(callSuper = false) | |||
@Accessors(chain = true) | |||
@TableName("th_westream_know_user") | |||
public class WestreamKnowUser extends BaseEntity implements Serializable { | |||
private static final long serialVersionUID = 1L; | |||
/** | |||
* 租户ID | |||
*/ | |||
private Integer tenantId; | |||
/** | |||
* openid | |||
*/ | |||
private String openid; | |||
/** | |||
* 全民护河知识表ID | |||
*/ | |||
private Integer knowId; | |||
} |
@@ -0,0 +1,61 @@ | |||
package com.tuoheng.api.entity.domain; | |||
import com.baomidou.mybatisplus.annotation.TableName; | |||
import com.fasterxml.jackson.annotation.JsonFormat; | |||
import com.tuoheng.common.common.BaseEntity; | |||
import lombok.Data; | |||
import lombok.EqualsAndHashCode; | |||
import lombok.experimental.Accessors; | |||
import org.springframework.format.annotation.DateTimeFormat; | |||
import java.io.Serializable; | |||
/** | |||
* 全民护河上报表 | |||
* | |||
* @author wanjing | |||
* @since 2023-11-23 | |||
*/ | |||
@Data | |||
@EqualsAndHashCode(callSuper = false) | |||
@Accessors(chain = true) | |||
@TableName("th_westream_submit") | |||
public class WestreamSubmit extends BaseEntity implements Serializable { | |||
/** | |||
* 租户id | |||
*/ | |||
private Integer tenantId; | |||
/** | |||
* openid | |||
*/ | |||
private String openid; | |||
/** | |||
* 上传照片 | |||
*/ | |||
private String photoUrl; | |||
/** | |||
* 问题描述 | |||
*/ | |||
private String problemDesc; | |||
/** | |||
* 经度 | |||
*/ | |||
private String longitude; | |||
/** | |||
* 纬度 | |||
*/ | |||
private String latitude; | |||
/** | |||
* 审核状态 0待审核 1审核通过 2审核不通过 | |||
*/ | |||
private Integer status; | |||
} |
@@ -0,0 +1,79 @@ | |||
package com.tuoheng.api.entity.domain; | |||
import com.baomidou.mybatisplus.annotation.TableName; | |||
import com.fasterxml.jackson.annotation.JsonFormat; | |||
import com.tuoheng.common.common.BaseEntity; | |||
import lombok.Data; | |||
import lombok.EqualsAndHashCode; | |||
import lombok.experimental.Accessors; | |||
import org.springframework.format.annotation.DateTimeFormat; | |||
import java.io.Serializable; | |||
import java.util.Date; | |||
/** | |||
* 全民护河志愿服务表 | |||
* | |||
* @author wanjing | |||
* @since 2023-11-23 | |||
*/ | |||
@Data | |||
@EqualsAndHashCode(callSuper = false) | |||
@Accessors(chain = true) | |||
@TableName("th_westream_volunteer") | |||
public class WestreamVolunteer extends BaseEntity implements Serializable { | |||
/** | |||
* 租户id | |||
*/ | |||
private Integer tenantId; | |||
/** | |||
* openid | |||
*/ | |||
private String openid; | |||
/** | |||
* 活动人数 | |||
*/ | |||
private Integer activityNum; | |||
/** | |||
* 活动日期 | |||
*/ | |||
@DateTimeFormat(pattern = "yyyy-MM-dd") | |||
@JsonFormat(pattern = "yyyy-MM-dd") | |||
private Date activityDate; | |||
/** | |||
* 活动积分 | |||
*/ | |||
private Integer activityPoints; | |||
/** | |||
* 单位名称 | |||
*/ | |||
private String companyName; | |||
/** | |||
* 联系人 | |||
*/ | |||
private String contactName; | |||
/** | |||
* 电话 | |||
*/ | |||
private String contactPhone; | |||
/** | |||
* 上传照片 | |||
*/ | |||
private String photoUrl; | |||
/** | |||
* 审核状态 0待审核 1审核通过 2审核不通过 | |||
*/ | |||
private Integer status; | |||
} |
@@ -0,0 +1,46 @@ | |||
package com.tuoheng.api.entity.request; | |||
import lombok.Data; | |||
import java.util.List; | |||
/** | |||
* 全民护河上报表 | |||
* | |||
* @author wanjing | |||
* @since 2023-11-23 | |||
*/ | |||
@Data | |||
public class AddWestreamSubmitRequest { | |||
/** | |||
* 租户id | |||
*/ | |||
private Integer tenantId; | |||
/** | |||
* openid | |||
*/ | |||
private String openid; | |||
/** | |||
* 经度 | |||
*/ | |||
private String longitude; | |||
/** | |||
* 纬度 | |||
*/ | |||
private String latitude; | |||
/** | |||
* 问题描述 | |||
*/ | |||
private String problemDesc; | |||
/** | |||
* 上传照片 | |||
*/ | |||
private String photoUrl; | |||
} |
@@ -0,0 +1,67 @@ | |||
package com.tuoheng.api.entity.request; | |||
import com.fasterxml.jackson.annotation.JsonFormat; | |||
import lombok.Data; | |||
import org.springframework.format.annotation.DateTimeFormat; | |||
import java.util.Date; | |||
import java.util.List; | |||
/** | |||
* 全民护河志愿服务表 | |||
* | |||
* @author wanjing | |||
* @since 2023-11-23 | |||
*/ | |||
@Data | |||
public class AddWestreamVolunteerRequest { | |||
/** | |||
* 租户id | |||
*/ | |||
private Integer tenantId; | |||
/** | |||
* openid | |||
*/ | |||
private String openid; | |||
/** | |||
* 活动人数 | |||
*/ | |||
private Integer activityNum; | |||
/** | |||
* 活动日期 | |||
*/ | |||
@DateTimeFormat(pattern = "yyyy-MM-dd") | |||
@JsonFormat(pattern = "yyyy-MM-dd") | |||
private Date activityDate; | |||
/** | |||
* 活动积分 | |||
*/ | |||
private Integer activityPoints; | |||
/** | |||
* 单位名称 | |||
*/ | |||
private String companyName; | |||
/** | |||
* 联系人 | |||
*/ | |||
private String contactName; | |||
/** | |||
* 电话 | |||
*/ | |||
private String contactPhone; | |||
/** | |||
* 上传照片 | |||
*/ | |||
private String photoUrl; | |||
} |
@@ -0,0 +1,35 @@ | |||
package com.tuoheng.api.entity.request; | |||
import com.fasterxml.jackson.annotation.JsonFormat; | |||
import lombok.Data; | |||
import org.springframework.format.annotation.DateTimeFormat; | |||
import java.util.Date; | |||
import java.util.List; | |||
/** | |||
* 全民护河志愿服务表 | |||
* | |||
* @author wanjing | |||
* @since 2023-11-23 | |||
*/ | |||
@Data | |||
public class ReceivePonitsRequest { | |||
/** | |||
* 租户id | |||
*/ | |||
private Integer tenantId; | |||
/** | |||
* openid | |||
*/ | |||
private String openid; | |||
/** | |||
* 知识ID | |||
*/ | |||
private Integer knowId; | |||
} |
@@ -0,0 +1,30 @@ | |||
package com.tuoheng.api.enums; | |||
import lombok.Getter; | |||
/** | |||
* @Author xiaoying | |||
* @Date 2023/7/10 9:27 | |||
*/ | |||
public enum DictDataEnum { | |||
VOLUNTEER_ACTIVITY("volunteer_activity", "志愿者活动"), | |||
TIKTOK("tiktok", "关注抖音"), | |||
VIDEO("video", "学习视频"), | |||
WESTREAM_KNOW("westream_know", "阅读知识"), | |||
DAILY_LIMIT_WESTREAM_KNOW("daily_limit_westream_know", "阅读知识每日最大限额"), | |||
WESTREAM_SUBMIT("westream_submit", "我要上"), | |||
DAILY_LIMIT_WESTREAM_SUBMIT("daily_limit_westream_submit", "我要上报每日最大限额"),; | |||
DictDataEnum(String code, String description) { | |||
this.code = code; | |||
this.description = description; | |||
} | |||
@Getter | |||
private String code; | |||
@Getter | |||
private String description; | |||
} |
@@ -6,13 +6,14 @@ import lombok.Getter; | |||
* @Author xiaoying | |||
* @Date 2023/7/10 9:27 | |||
*/ | |||
public enum DictDateEnum { | |||
public enum DictEnum { | |||
VOLUNTEER_ACTIVITY("volunteer_activity", "志愿者活动"), | |||
TIKTOK("tiktok", "关注抖音"), | |||
VIDEO("video", "学习视频"); | |||
SCREEN("screen", "大屏信息展示"), | |||
TASK_STATUS("task_status", "任务状态"), | |||
POINTS_RULE("points_rule", "积分规则"), | |||
MSG_RULE("msg_rule", "短信规则"); | |||
DictDateEnum(String code, String description) { | |||
DictEnum(String code, String description) { | |||
this.code = code; | |||
this.description = description; | |||
} |
@@ -0,0 +1,25 @@ | |||
package com.tuoheng.api.enums; | |||
import lombok.Getter; | |||
/** | |||
* 逻辑删除标记类型 | |||
* @author chenyukun | |||
*/ | |||
public enum MarkEnum { | |||
VALID(1,"有效"), | |||
NOTVALID(0,"失效"); | |||
MarkEnum(int code, String description){ | |||
this.code = code; | |||
this.description = description; | |||
} | |||
@Getter | |||
private int code; | |||
@Getter | |||
private String description; | |||
} |
@@ -2,6 +2,9 @@ package com.tuoheng.api.mapper; | |||
import com.baomidou.mybatisplus.core.mapper.BaseMapper; | |||
import com.tuoheng.api.entity.domain.UserPointsDetail; | |||
import org.apache.ibatis.annotations.Param; | |||
import java.util.Date; | |||
/** | |||
* 用户积分明细表 Mapper 接口 | |||
@@ -10,4 +13,7 @@ import com.tuoheng.api.entity.domain.UserPointsDetail; | |||
* @since 2023-05-06 | |||
*/ | |||
public interface UserPointsDetailMapper extends BaseMapper<UserPointsDetail> { | |||
Integer selectTotalPointsByToDay(@Param("openid") String openid, @Param("pointsTime") String pointsTime, @Param("changeName") String changeName); | |||
} |
@@ -0,0 +1,15 @@ | |||
package com.tuoheng.api.mapper; | |||
import com.baomidou.mybatisplus.core.mapper.BaseMapper; | |||
import com.tuoheng.api.entity.domain.WestreamKnow; | |||
import com.tuoheng.api.entity.domain.WestreamKnowUser; | |||
/** | |||
* 全民护河知识用户表 Mapper 接口 | |||
* | |||
* @author wanjing | |||
* @since 2023-11-23 | |||
*/ | |||
public interface WestreamKnowUserMapper extends BaseMapper<WestreamKnowUser> { | |||
} |
@@ -0,0 +1,14 @@ | |||
package com.tuoheng.api.mapper; | |||
import com.baomidou.mybatisplus.core.mapper.BaseMapper; | |||
import com.tuoheng.api.entity.domain.WestreamSubmit; | |||
/** | |||
* 全民护河上报表 Mapper 接口 | |||
* | |||
* @author wanjing | |||
* @since 2023-11-23 | |||
*/ | |||
public interface WestreamSubmitMapper extends BaseMapper<WestreamSubmit> { | |||
} |
@@ -0,0 +1,14 @@ | |||
package com.tuoheng.api.mapper; | |||
import com.baomidou.mybatisplus.core.mapper.BaseMapper; | |||
import com.tuoheng.api.entity.domain.WestreamVolunteer; | |||
/** | |||
* 全民护河志愿服务表 Mapper 接口 | |||
* | |||
* @author wanjing | |||
* @since 2023-11-23 | |||
*/ | |||
public interface WestreamVolunteerMapper extends BaseMapper<WestreamVolunteer> { | |||
} |
@@ -8,12 +8,11 @@ import com.tuoheng.api.constants.DictConstants; | |||
import com.tuoheng.api.entity.domain.*; | |||
import com.tuoheng.api.entity.request.OnlineNumQuery; | |||
import com.tuoheng.api.entity.request.WestreamUserQuery; | |||
import com.tuoheng.api.enums.DictDateEnum; | |||
import com.tuoheng.api.enums.DictDataEnum; | |||
import com.tuoheng.api.mapper.*; | |||
import com.tuoheng.api.service.IWestreamUserService; | |||
import com.tuoheng.api.utils.PointsTitleConstants; | |||
import com.tuoheng.common.common.BaseServiceImpl; | |||
import com.tuoheng.common.config.CommonConfig; | |||
import com.tuoheng.common.utils.CommonUtils; | |||
import com.tuoheng.common.utils.JsonResult; | |||
import com.tuoheng.common.utils.StringUtils; | |||
@@ -184,9 +183,9 @@ public class WestreamUserServiceImpl extends BaseServiceImpl<WestreamUserMapper, | |||
ThDictData param1 = new ThDictData(); | |||
ThDictData param2 = new ThDictData(); | |||
ThDictData param3 = new ThDictData(); | |||
param1.setName(DictDateEnum.TIKTOK.getDescription()); | |||
param2.setName(DictDateEnum.VIDEO.getDescription()); | |||
param3.setName(DictDateEnum.VOLUNTEER_ACTIVITY.getDescription()); | |||
param1.setName(DictDataEnum.TIKTOK.getDescription()); | |||
param2.setName(DictDataEnum.VIDEO.getDescription()); | |||
param3.setName(DictDataEnum.VOLUNTEER_ACTIVITY.getDescription()); | |||
thDictData.add(param1); | |||
thDictData.add(param2); | |||
thDictData.add(param3); | |||
@@ -198,14 +197,14 @@ public class WestreamUserServiceImpl extends BaseServiceImpl<WestreamUserMapper, | |||
.eq(ThDictData::getDictId, thDict.getId()) | |||
.eq(ThDictData::getMark, 1)); | |||
for (ThDictData thDictDatum : thDictData) { | |||
if (DictDateEnum.TIKTOK.getCode().equals(thDictDatum.getName())) { | |||
thDictDatum.setNote(DictDateEnum.TIKTOK.getDescription()); | |||
if (DictDataEnum.TIKTOK.getCode().equals(thDictDatum.getName())) { | |||
thDictDatum.setNote(DictDataEnum.TIKTOK.getDescription()); | |||
} | |||
if (DictDateEnum.VIDEO.getCode().equals(thDictDatum.getName())) { | |||
thDictDatum.setNote(DictDateEnum.VIDEO.getDescription()); | |||
if (DictDataEnum.VIDEO.getCode().equals(thDictDatum.getName())) { | |||
thDictDatum.setNote(DictDataEnum.VIDEO.getDescription()); | |||
} | |||
if (DictDateEnum.VOLUNTEER_ACTIVITY.getCode().equals(thDictDatum.getName())) { | |||
thDictDatum.setNote(DictDateEnum.VOLUNTEER_ACTIVITY.getDescription()); | |||
if (DictDataEnum.VOLUNTEER_ACTIVITY.getCode().equals(thDictDatum.getName())) { | |||
thDictDatum.setNote(DictDataEnum.VOLUNTEER_ACTIVITY.getDescription()); | |||
} | |||
} | |||
thDictData = thDictData.stream().filter(t -> StringUtils.isNotEmpty(t.getNote())).collect(Collectors.toList()); |
@@ -1,6 +1,7 @@ | |||
package com.tuoheng.api.service; | |||
package com.tuoheng.api.service.points; | |||
import com.tuoheng.api.entity.domain.UserPointsDetail; | |||
import com.tuoheng.api.entity.request.ReceivePonitsRequest; | |||
import com.tuoheng.api.entity.request.UserPointsDetailQuery; | |||
import com.tuoheng.common.common.IBaseService; | |||
import com.tuoheng.common.utils.JsonResult; | |||
@@ -15,4 +16,6 @@ public interface IUserPointsDetailService extends IBaseService<UserPointsDetail> | |||
JsonResult exchange(UserPointsDetailQuery userPointsDetailQuery); | |||
JsonResult pointsDetail(UserPointsDetailQuery userPointsDetailQuery); | |||
JsonResult receive(ReceivePonitsRequest request); | |||
} |
@@ -1,4 +1,4 @@ | |||
package com.tuoheng.api.service.impl; | |||
package com.tuoheng.api.service.points; | |||
import cn.hutool.core.util.ObjectUtil; | |||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; | |||
@@ -7,11 +7,12 @@ import com.baomidou.mybatisplus.extension.plugins.pagination.Page; | |||
import com.tuoheng.api.entity.domain.Goods; | |||
import com.tuoheng.api.entity.domain.Merchant; | |||
import com.tuoheng.api.entity.domain.UserPointsDetail; | |||
import com.tuoheng.api.entity.request.ReceivePonitsRequest; | |||
import com.tuoheng.api.entity.request.UserPointsDetailQuery; | |||
import com.tuoheng.api.mapper.GoodsMapper; | |||
import com.tuoheng.api.mapper.MerchantMapper; | |||
import com.tuoheng.api.mapper.UserPointsDetailMapper; | |||
import com.tuoheng.api.service.IUserPointsDetailService; | |||
import com.tuoheng.api.service.points.receive.ReceivePonitsService; | |||
import com.tuoheng.common.common.BaseServiceImpl; | |||
import com.tuoheng.common.utils.CommonUtils; | |||
import com.tuoheng.common.utils.JsonResult; | |||
@@ -19,9 +20,6 @@ import com.tuoheng.common.utils.StringUtils; | |||
import org.springframework.beans.factory.annotation.Autowired; | |||
import org.springframework.stereotype.Service; | |||
import java.util.ArrayList; | |||
import java.util.List; | |||
/** | |||
* 全民护河公告表 服务实现类 | |||
* | |||
@@ -40,6 +38,9 @@ public class UserPointsDetailServiceImpl extends BaseServiceImpl<UserPointsDetai | |||
@Autowired | |||
GoodsMapper goodsMapper; | |||
@Autowired | |||
private ReceivePonitsService receivePonitsService; | |||
@Override | |||
public JsonResult exchange(UserPointsDetailQuery query) { | |||
if (null == query.getPage() || null == query.getLimit()) { | |||
@@ -125,4 +126,9 @@ public class UserPointsDetailServiceImpl extends BaseServiceImpl<UserPointsDetai | |||
// } | |||
return JsonResult.success(userPointsDetailList); | |||
} | |||
@Override | |||
public JsonResult receive(ReceivePonitsRequest request) { | |||
return receivePonitsService.receive(request); | |||
} | |||
} |
@@ -0,0 +1,172 @@ | |||
package com.tuoheng.api.service.points.receive; | |||
import cn.hutool.core.util.ObjectUtil; | |||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; | |||
import com.tuoheng.api.entity.domain.*; | |||
import com.tuoheng.api.entity.request.ReceivePonitsRequest; | |||
import com.tuoheng.api.enums.DictDataEnum; | |||
import com.tuoheng.api.enums.DictEnum; | |||
import com.tuoheng.api.enums.MarkEnum; | |||
import com.tuoheng.api.mapper.*; | |||
import com.tuoheng.common.exception.ServiceException; | |||
import com.tuoheng.common.utils.DateUtils; | |||
import com.tuoheng.common.utils.JsonResult; | |||
import com.tuoheng.common.utils.StringUtils; | |||
import lombok.RequiredArgsConstructor; | |||
import lombok.extern.slf4j.Slf4j; | |||
import org.springframework.stereotype.Service; | |||
import org.springframework.transaction.annotation.Transactional; | |||
import java.util.Date; | |||
/** | |||
* 全民护河领取积分 业务类 | |||
* | |||
* @author wanjing | |||
* @since 2023-11-23 | |||
*/ | |||
@Slf4j | |||
@Service | |||
@RequiredArgsConstructor | |||
public class ReceivePonitsService { | |||
private final WestreamKnowUserMapper westreamKnowUserMapper; | |||
private final UserPointsDetailMapper userPointsDetailMapper; | |||
private final WestreamUserMapper westreamUserMapper; | |||
private final ThDictMapper dictMapper; | |||
private final ThDictDataMapper dictDataMapper; | |||
@Transactional | |||
public JsonResult receive(ReceivePonitsRequest request) { | |||
JsonResult result = this.check(request); | |||
if (0 != result.getCode()) { | |||
log.info("全民护河领取积分:校验失败:{}", result.getMsg()); | |||
return result; | |||
} | |||
ThDict dict = dictMapper.selectOne(new LambdaQueryWrapper<ThDict>() | |||
.eq(ThDict::getTenantId, request.getTenantId()) | |||
.eq(ThDict::getCode, DictEnum.POINTS_RULE.getCode()) | |||
.eq(ThDict::getMark, MarkEnum.VALID.getCode())); | |||
if (ObjectUtil.isEmpty(dict)) { | |||
log.info("领取积分,该字典类型不存在,tenantId:{}, dictCode:{}", request.getTenantId(), DictEnum.POINTS_RULE.getCode()); | |||
return JsonResult.error("积分规则未设置"); | |||
} | |||
ThDictData dictData = dictDataMapper.selectOne(new LambdaQueryWrapper<ThDictData>() | |||
.eq(ThDictData::getTenantId, request.getTenantId()) | |||
.eq(ThDictData::getDictId, dict.getId()) | |||
.eq(ThDictData::getName, DictDataEnum.WESTREAM_KNOW.getCode()) | |||
.eq(ThDictData::getMark, MarkEnum.VALID.getCode())); | |||
if (ObjectUtil.isEmpty(dictData)) { | |||
log.info("领取积分,该字典项不存在,tenantId:{}, dictDataName:{}", request.getTenantId(), DictDataEnum.WESTREAM_KNOW.getCode()); | |||
return JsonResult.error("积分规则未设置"); | |||
} | |||
ThDictData dailyLimitWestreamSubmitDictData = dictDataMapper.selectOne(new LambdaQueryWrapper<ThDictData>() | |||
.eq(ThDictData::getTenantId, request.getTenantId()) | |||
.eq(ThDictData::getDictId, dict.getId()) | |||
.eq(ThDictData::getName, DictDataEnum.DAILY_LIMIT_WESTREAM_SUBMIT.getCode()) | |||
.eq(ThDictData::getMark, MarkEnum.VALID.getCode())); | |||
if (ObjectUtil.isEmpty(dailyLimitWestreamSubmitDictData)) { | |||
log.info("领取积分,每日上报最大限额字典项不存在,tenantId:{}, dictDataName:{}", request.getTenantId(), DictDataEnum.DAILY_LIMIT_WESTREAM_SUBMIT.getCode()); | |||
return JsonResult.error("积分规则未设置"); | |||
} | |||
Integer dailyLimitWestreamSubmit = 0; | |||
if (ObjectUtil.isNotEmpty(dailyLimitWestreamSubmitDictData)) { | |||
dailyLimitWestreamSubmit = Integer.parseInt(dailyLimitWestreamSubmitDictData.getValue()); | |||
} | |||
String pointsTime = DateUtils.getDate(); | |||
String changeName = "阅读知识"; | |||
Integer totalPointsByToDay = userPointsDetailMapper.selectTotalPointsByToDay(request.getOpenid(), pointsTime, changeName); | |||
if (ObjectUtil.isNotEmpty(totalPointsByToDay)) { | |||
if (totalPointsByToDay >= dailyLimitWestreamSubmit) { | |||
log.info("领取积分,已超过每日积分上限,totalPointsByToDay:{}, dailyLimitWestreamSubmit:{}", totalPointsByToDay, dailyLimitWestreamSubmit); | |||
return JsonResult.error("已超过每日积分上限"); | |||
} | |||
} | |||
WestreamUser westreamUser = westreamUserMapper.selectOne(new LambdaQueryWrapper<WestreamUser>() | |||
.eq(WestreamUser::getTenantId, request.getTenantId()) | |||
.eq(WestreamUser::getOpenid, request.getOpenid()) | |||
.eq(WestreamUser::getMark, MarkEnum.VALID.getCode())); | |||
if (ObjectUtil.isEmpty(westreamUser)) { | |||
log.info("领取积分,该用户不存在,tenantId:{}, openid:{}", request.getTenantId(), request.getOpenid()); | |||
return JsonResult.error("该用户不存在"); | |||
} | |||
WestreamKnowUser westreamKnowUser = westreamKnowUserMapper.selectOne(new LambdaQueryWrapper<WestreamKnowUser>() | |||
.eq(WestreamKnowUser::getTenantId, request.getTenantId()) | |||
.eq(WestreamKnowUser::getOpenid, request.getOpenid()) | |||
.eq(WestreamKnowUser::getKnowId, request.getKnowId()) | |||
.eq(WestreamKnowUser::getMark, MarkEnum.VALID.getCode())); | |||
if (ObjectUtil.isNotEmpty(westreamKnowUser)) { | |||
return JsonResult.error("您已获得过积分了,仅能获取一次积分。"); | |||
} else { | |||
westreamKnowUser = new WestreamKnowUser(); | |||
westreamKnowUser.setTenantId(request.getTenantId()); | |||
westreamKnowUser.setOpenid(request.getOpenid()); | |||
westreamKnowUser.setKnowId(request.getKnowId()); | |||
westreamKnowUser.setCreateUser(0); | |||
westreamKnowUser.setCreateTime(DateUtils.now()); | |||
westreamKnowUserMapper.insert(westreamKnowUser); | |||
} | |||
UserPointsDetail userPointsDetail = new UserPointsDetail(); | |||
userPointsDetail.setTenantId(request.getTenantId()); | |||
userPointsDetail.setOpenid(request.getOpenid()); | |||
userPointsDetail.setNickname(westreamUser.getNickname()); | |||
userPointsDetail.setChangeName("阅读知识"); | |||
userPointsDetail.setType(1); | |||
userPointsDetail.setCreateTime(DateUtils.now()); | |||
Integer points = 0; | |||
if (ObjectUtil.isNotEmpty(dictData)) { | |||
points = Integer.parseInt(dictData.getValue()); | |||
userPointsDetail.setPointsChange(points); | |||
} | |||
userPointsDetail.setPointsTime(DateUtils.now()); | |||
Integer row = userPointsDetailMapper.insert(userPointsDetail); | |||
if (row <= 0) { | |||
return JsonResult.error("领取积分,失败"); | |||
} | |||
if (ObjectUtil.isEmpty(westreamUser.getMallPoints())) { | |||
westreamUser.setMallPoints(points); | |||
} else { | |||
westreamUser.setMallPoints(westreamUser.getMallPoints() + points); | |||
} | |||
row = westreamUserMapper.updateById(westreamUser); | |||
if (row <= 0) { | |||
return JsonResult.error("领取积分,修改用户总积分失败"); | |||
} | |||
return JsonResult.success(); | |||
} | |||
/** | |||
* 检查参数 | |||
* | |||
* @param request | |||
* @return | |||
*/ | |||
private JsonResult check(ReceivePonitsRequest request) { | |||
if (ObjectUtil.isEmpty(request.getTenantId()) || 0 == request.getTenantId()) { | |||
throw new ServiceException("租户Id为空"); | |||
} | |||
if (StringUtils.isEmpty(request.getOpenid())) { | |||
throw new ServiceException("OpenId为空"); | |||
} | |||
if (ObjectUtil.isEmpty(request.getKnowId()) || 0 == request.getKnowId()) { | |||
throw new ServiceException("知识ID为空"); | |||
} | |||
return JsonResult.success(); | |||
} | |||
} |
@@ -0,0 +1,21 @@ | |||
package com.tuoheng.api.service.westream.submit; | |||
import com.tuoheng.api.entity.request.AddWestreamSubmitRequest; | |||
import com.tuoheng.common.utils.JsonResult; | |||
/** | |||
* 全民护河上报 服务类 | |||
* | |||
* @author wanjing | |||
* @since 2023-11-23 | |||
*/ | |||
public interface WestreamSubmitService { | |||
/** | |||
* 上报 | |||
* | |||
* @return | |||
*/ | |||
JsonResult report(AddWestreamSubmitRequest request); | |||
} |
@@ -0,0 +1,21 @@ | |||
package com.tuoheng.api.service.westream.submit; | |||
import com.tuoheng.api.entity.request.AddWestreamSubmitRequest; | |||
import com.tuoheng.api.service.westream.submit.report.ReportWestreamSubmitService; | |||
import com.tuoheng.common.utils.JsonResult; | |||
import lombok.RequiredArgsConstructor; | |||
import lombok.extern.slf4j.Slf4j; | |||
import org.springframework.stereotype.Service; | |||
@Slf4j | |||
@Service | |||
@RequiredArgsConstructor | |||
public class WestreamSubmitServiceImpl implements WestreamSubmitService { | |||
private final ReportWestreamSubmitService reportWestreamSubmitService; | |||
@Override | |||
public JsonResult report(AddWestreamSubmitRequest request) { | |||
return reportWestreamSubmitService.report(request); | |||
} | |||
} |
@@ -0,0 +1,74 @@ | |||
package com.tuoheng.api.service.westream.submit.report; | |||
import cn.hutool.core.util.ObjectUtil; | |||
import com.tuoheng.api.conver.WestreamSubmitConverMapper; | |||
import com.tuoheng.api.entity.domain.WestreamSubmit; | |||
import com.tuoheng.api.entity.request.AddWestreamSubmitRequest; | |||
import com.tuoheng.api.mapper.WestreamSubmitMapper; | |||
import com.tuoheng.common.exception.ServiceException; | |||
import com.tuoheng.common.utils.DateUtils; | |||
import com.tuoheng.common.utils.JsonResult; | |||
import com.tuoheng.common.utils.StringUtils; | |||
import lombok.RequiredArgsConstructor; | |||
import lombok.extern.slf4j.Slf4j; | |||
import org.springframework.stereotype.Service; | |||
/** | |||
* 全民护河上报 业务类 | |||
* | |||
* @author wanjing | |||
* @since 2023-11-23 | |||
*/ | |||
@Slf4j | |||
@Service | |||
@RequiredArgsConstructor | |||
public class ReportWestreamSubmitService { | |||
private final WestreamSubmitMapper westreamSubmitMapper; | |||
public JsonResult report(AddWestreamSubmitRequest request) { | |||
JsonResult result = this.check(request); | |||
if (0 != result.getCode()) { | |||
log.info("全民护河我要上报:校验失败:{}", result.getMsg()); | |||
return result; | |||
} | |||
WestreamSubmit westreamSubmit = WestreamSubmitConverMapper.INSTANCE.addRequestToWestreamSubmit(request); | |||
westreamSubmit.setCreateUser(0); | |||
westreamSubmit.setCreateTime(DateUtils.now()); | |||
Integer rowId = westreamSubmitMapper.insert(westreamSubmit); | |||
if (rowId <= 0) { | |||
log.info("全民护河我要上报:添加失败:{}", result.getMsg()); | |||
return JsonResult.error("全民护河我要上报失败"); | |||
} | |||
return JsonResult.success(); | |||
} | |||
/** | |||
* 检查参数 | |||
* | |||
* @param request | |||
* @return | |||
*/ | |||
private JsonResult check(AddWestreamSubmitRequest request) { | |||
if (ObjectUtil.isEmpty(request.getTenantId()) || 0 == request.getTenantId()) { | |||
throw new ServiceException("租户Id为空"); | |||
} | |||
if (StringUtils.isEmpty(request.getOpenid())) { | |||
throw new ServiceException("OpenId为空"); | |||
} | |||
if (StringUtils.isEmpty(request.getLongitude())) { | |||
throw new ServiceException("经度为空"); | |||
} | |||
if (StringUtils.isEmpty(request.getLatitude())) { | |||
throw new ServiceException("纬度为空"); | |||
} | |||
if (StringUtils.isEmpty(request.getProblemDesc())) { | |||
throw new ServiceException("问题描述为空"); | |||
} | |||
if (StringUtils.isEmpty(request.getPhotoUrl())) { | |||
throw new ServiceException("图片为空"); | |||
} | |||
return JsonResult.success(); | |||
} | |||
} |
@@ -0,0 +1,21 @@ | |||
package com.tuoheng.api.service.westream.volunteer; | |||
import com.tuoheng.api.entity.request.AddWestreamVolunteerRequest; | |||
import com.tuoheng.common.utils.JsonResult; | |||
/** | |||
* 全民护河志愿服务 服务类 | |||
* | |||
* @author wanjing | |||
* @since 2023-11-23 | |||
*/ | |||
public interface WestreamVolunteerService { | |||
/** | |||
* 上报 | |||
* | |||
* @return | |||
*/ | |||
JsonResult add(AddWestreamVolunteerRequest request); | |||
} |
@@ -0,0 +1,27 @@ | |||
package com.tuoheng.api.service.westream.volunteer; | |||
import com.tuoheng.api.entity.request.AddWestreamVolunteerRequest; | |||
import com.tuoheng.api.service.westream.volunteer.add.AddWestreamVolunteerService; | |||
import com.tuoheng.common.utils.JsonResult; | |||
import lombok.RequiredArgsConstructor; | |||
import lombok.extern.slf4j.Slf4j; | |||
import org.springframework.stereotype.Service; | |||
/** | |||
* 全民护河志愿服务 服务类 | |||
* | |||
* @author wanjing | |||
* @since 2023-11-23 | |||
*/ | |||
@Slf4j | |||
@Service | |||
@RequiredArgsConstructor | |||
public class WestreamVolunteerServiceImpl implements WestreamVolunteerService { | |||
private final AddWestreamVolunteerService addWestreamVolunteerService; | |||
@Override | |||
public JsonResult add(AddWestreamVolunteerRequest request) { | |||
return addWestreamVolunteerService.add(request); | |||
} | |||
} |
@@ -0,0 +1,85 @@ | |||
package com.tuoheng.api.service.westream.volunteer.add; | |||
import cn.hutool.core.collection.CollectionUtil; | |||
import cn.hutool.core.util.ObjectUtil; | |||
import com.tuoheng.api.conver.WestreamVolunteerConverMapper; | |||
import com.tuoheng.api.entity.request.AddWestreamVolunteerRequest; | |||
import com.tuoheng.api.entity.domain.WestreamVolunteer; | |||
import com.tuoheng.api.mapper.WestreamVolunteerMapper; | |||
import com.tuoheng.common.exception.ServiceException; | |||
import com.tuoheng.common.utils.DateUtils; | |||
import com.tuoheng.common.utils.JsonResult; | |||
import com.tuoheng.common.utils.StringUtils; | |||
import lombok.RequiredArgsConstructor; | |||
import lombok.extern.slf4j.Slf4j; | |||
import org.springframework.stereotype.Service; | |||
/** | |||
* 全民护河志愿服务 业务类 | |||
* | |||
* @author wanjing | |||
* @since 2023-11-23 | |||
*/ | |||
@Slf4j | |||
@Service | |||
@RequiredArgsConstructor | |||
public class AddWestreamVolunteerService { | |||
private final WestreamVolunteerMapper westreamVolunteerMapper; | |||
public JsonResult add(AddWestreamVolunteerRequest request) { | |||
JsonResult result = this.check(request); | |||
if (0 != result.getCode()) { | |||
log.info("全民护河志愿服务申请:校验失败:{}", result.getMsg()); | |||
return result; | |||
} | |||
WestreamVolunteer westreamVolunteer = WestreamVolunteerConverMapper.INSTANCE.addRequestToWestreamVolunteer(request); | |||
westreamVolunteer.setCreateUser(0); | |||
westreamVolunteer.setCreateTime(DateUtils.now()); | |||
Integer rowId = westreamVolunteerMapper.insert(westreamVolunteer); | |||
if (rowId <= 0) { | |||
log.info("全民护河志愿服务:添加失败:{}", result.getMsg()); | |||
return JsonResult.error("全民护河志愿服务申请失败"); | |||
} | |||
return JsonResult.success(); | |||
} | |||
/** | |||
* 检查参数 | |||
* | |||
* @param request | |||
* | |||
* @return | |||
*/ | |||
private JsonResult check(AddWestreamVolunteerRequest request) { | |||
if (ObjectUtil.isEmpty(request.getTenantId()) || 0 == request.getTenantId()) { | |||
throw new ServiceException("租户Id为空"); | |||
} | |||
if (StringUtils.isEmpty(request.getOpenid())) { | |||
throw new ServiceException("OpenId为空"); | |||
} | |||
if (ObjectUtil.isEmpty(request.getActivityNum()) || 0 == request.getActivityNum()) { | |||
throw new ServiceException("活动人数为空"); | |||
} | |||
if (ObjectUtil.isEmpty(request.getActivityDate())) { | |||
throw new ServiceException("活动日期为空"); | |||
} | |||
if (ObjectUtil.isEmpty(request.getActivityPoints())) { | |||
throw new ServiceException("获取积分为空"); | |||
} | |||
if (StringUtils.isEmpty(request.getCompanyName())) { | |||
throw new ServiceException("单位名称为空"); | |||
} | |||
if (StringUtils.isEmpty(request.getContactName())) { | |||
throw new ServiceException("联系人为空"); | |||
} | |||
if (StringUtils.isEmpty(request.getContactPhone())) { | |||
throw new ServiceException("电话为空"); | |||
} | |||
if (StringUtils.isEmpty(request.getPhotoUrl())) { | |||
throw new ServiceException("图片为空"); | |||
} | |||
return JsonResult.success(); | |||
} | |||
} |
@@ -15,6 +15,8 @@ tuoheng: | |||
video-url: http://vod.play.t-aaron.com/ | |||
# 高德Key | |||
gaodeKey: 5a1f63e7563cba471a9d0773e218144a | |||
# DSP服务域名 | |||
dsp-domain-url: http://192.168.11.11:7011/ | |||
#阿里云 | |||
aliyuncsVod: |
@@ -0,0 +1,45 @@ | |||
<?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.tuoheng.api.mapper.UserPointsDetailMapper"> | |||
<resultMap id="BaseResultMap" type="com.tuoheng.api.entity.domain.UserPointsDetail"> | |||
<id property="id" column="id" /> | |||
<result property="tenantId" column="tenant_id"/> | |||
<result property="openid" column="openid" /> | |||
<result property="nickname" column="nickname" /> | |||
<result property="pointsChange" column="points_change" /> | |||
<result property="pointsTime" column="points_time"/> | |||
<result property="type" column="type" /> | |||
<result property="operatorId" column="operator_id" /> | |||
<result property="operatorName" column="operator_name" /> | |||
<result property="changeName" column="change_name" /> | |||
<result property="exchangeFlag" column="exchange_flag"/> | |||
<result property="goodsId" column="goods_id" /> | |||
<result property="goodsPoints" column="goods_points" /> | |||
<result property="goodsCount" column="goods_count" /> | |||
<result property="createUser" column="create_user" /> | |||
<result property="createTime" column="create_time" /> | |||
<result property="updateUser" column="update_user" /> | |||
<result property="updateTime" column="update_time" /> | |||
<result property="mark" column="mark" /> | |||
</resultMap> | |||
<sql id="Base_Column_List"> | |||
id, tenant_id, openid, nickname, | |||
points_change, points_time, type, operator_id, operator_name, change_name, exchange_flag, goods_id, goods_points, goods_count, | |||
create_user, create_time, update_user, update_time, mark | |||
</sql> | |||
<select id="selectTotalPointsByToDay" resultType="java.lang.Integer"> | |||
select sum(points_change) | |||
from th_user_points_detail | |||
<where> | |||
<if test="1 == 1"> and mark = 1 and type = 1 </if> | |||
<if test="openid != null and openid != ''"> and openid = #{openid} </if> | |||
<if test="pointsTime != null and pointsTime != '' "> and points_time = #{pointsTime} </if> | |||
<if test="changeName != null and changeName != ''"> and change_name = #{changeName} </if> | |||
</where> | |||
</select> | |||
</mapper> |
@@ -1,5 +1,6 @@ | |||
package com.tuoheng.common.exception; | |||
import com.tuoheng.common.common.ExceptionInterface; | |||
import com.tuoheng.common.utils.JsonResult; | |||
/** | |||
* 业务异常类(业务处理时手动抛出异常) | |||
@@ -42,5 +43,15 @@ public class ServiceException extends RuntimeException { | |||
this.code = code; | |||
} | |||
/** | |||
* 构造器 | |||
* | |||
* @param msg | |||
*/ | |||
public ServiceException(String msg) { | |||
super(msg); | |||
this.msg = msg; | |||
this.code = JsonResult.ERROR; | |||
} | |||
} | |||
@@ -22,7 +22,7 @@ public class JsonResult<T> implements Serializable { | |||
/** | |||
* 失败 | |||
*/ | |||
public static final int error = CommonConstants.FAIL; | |||
public static final int ERROR = CommonConstants.FAIL; | |||
private int code; | |||
@@ -43,19 +43,19 @@ public class JsonResult<T> implements Serializable { | |||
} | |||
public static <T> JsonResult<T> error() { | |||
return jsonResult(null, error, "操作失败"); | |||
return jsonResult(null, ERROR, "操作失败"); | |||
} | |||
public static <T> JsonResult<T> error(String msg) { | |||
return jsonResult(null, error, msg); | |||
return jsonResult(null, ERROR, msg); | |||
} | |||
public static <T> JsonResult<T> error(T data) { | |||
return jsonResult(data, error, "操作失败"); | |||
return jsonResult(data, ERROR, "操作失败"); | |||
} | |||
public static <T> JsonResult<T> error(T data, String msg) { | |||
return jsonResult(data, error, msg); | |||
return jsonResult(data, ERROR, msg); | |||
} | |||
public static <T> JsonResult<T> error(int code, String msg) { |