新增功能
This commit is contained in:
@ -26,7 +26,7 @@ spring.redis.pool.min-idle=0
|
|||||||
spring.redis.timeout=0
|
spring.redis.timeout=0
|
||||||
|
|
||||||
# 系统名称
|
# 系统名称
|
||||||
system.name = fuint会员营销管理系统
|
system.name = 手工王国
|
||||||
|
|
||||||
# 前端h5地址
|
# 前端h5地址
|
||||||
website.url=https://www.fuint.cn/h5/
|
website.url=https://www.fuint.cn/h5/
|
||||||
|
|||||||
@ -26,7 +26,7 @@ spring.redis.pool.min-idle=0
|
|||||||
spring.redis.timeout=0
|
spring.redis.timeout=0
|
||||||
|
|
||||||
# 系统名称
|
# 系统名称
|
||||||
system.name = fuint会员营销管理系统
|
system.name = 手工王国
|
||||||
|
|
||||||
# 前端h5地址
|
# 前端h5地址
|
||||||
website.url=https://www.fuint.cn/h5/
|
website.url=https://www.fuint.cn/h5/
|
||||||
|
|||||||
@ -34,8 +34,8 @@ public class SwaggerConfig implements WebMvcConfigurer {
|
|||||||
@Bean
|
@Bean
|
||||||
public ApiInfo apiInfo() {
|
public ApiInfo apiInfo() {
|
||||||
return new ApiInfoBuilder()
|
return new ApiInfoBuilder()
|
||||||
.title("fuint会员营销系统接口文档")
|
.title("手工王国接口文档")
|
||||||
.description("fuint会员营销系统接口文档,“/clientApi”目录接口为会员端相关接口,“/backendApi”目录接口为后台管理端相关接口。")
|
.description("手工王国接口文档,“/clientApi”目录接口为会员端相关接口,“/backendApi”目录接口为后台管理端相关接口。")
|
||||||
.termsOfServiceUrl("https://www.fuint.cn/")
|
.termsOfServiceUrl("https://www.fuint.cn/")
|
||||||
.contact(new Contact("海南延禾信息技术有限公司","https://www.fuint.cn/", "fushengqian@qq.com"))
|
.contact(new Contact("海南延禾信息技术有限公司","https://www.fuint.cn/", "fushengqian@qq.com"))
|
||||||
.version("1.0")
|
.version("1.0")
|
||||||
|
|||||||
@ -5,6 +5,7 @@ import io.swagger.annotations.ApiModelProperty;
|
|||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
|
|
||||||
import java.io.Serializable;
|
import java.io.Serializable;
|
||||||
|
import java.math.BigDecimal;
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -42,6 +43,21 @@ public class TaskDto implements Serializable {
|
|||||||
@ApiModelProperty("奖励积分")
|
@ApiModelProperty("奖励积分")
|
||||||
private Integer rewardPoint;
|
private Integer rewardPoint;
|
||||||
|
|
||||||
|
@ApiModelProperty("奖励余额")
|
||||||
|
private BigDecimal rewardBalance;
|
||||||
|
|
||||||
|
@ApiModelProperty("银币阈值(订单使用银币数量)")
|
||||||
|
private Integer pointThreshold;
|
||||||
|
|
||||||
|
@ApiModelProperty("余额阈值(订单使用余额金额)")
|
||||||
|
private BigDecimal balanceThreshold;
|
||||||
|
|
||||||
|
@ApiModelProperty("指定商品ID,多个逗号分隔,空表示全部商品")
|
||||||
|
private String targetGoodsIds;
|
||||||
|
|
||||||
|
@ApiModelProperty("完成阈值(订单金额/点赞数)")
|
||||||
|
private BigDecimal completeThreshold;
|
||||||
|
|
||||||
@ApiModelProperty("每日可领取次数")
|
@ApiModelProperty("每日可领取次数")
|
||||||
private Integer dailyLimit;
|
private Integer dailyLimit;
|
||||||
|
|
||||||
|
|||||||
@ -13,9 +13,9 @@ import java.util.stream.Collectors;
|
|||||||
* CopyRight https://www.fuint.cn
|
* CopyRight https://www.fuint.cn
|
||||||
*/
|
*/
|
||||||
public enum BookStatusEnum {
|
public enum BookStatusEnum {
|
||||||
CREATED("A", "待确认"),
|
CREATED("A", "已预约"),
|
||||||
CONFIRM("B", "待签到"),
|
CONFIRM("B", "进行中"),
|
||||||
FAIL("F", "预约失败"),
|
WAIT_PAY("F", "待付款"),
|
||||||
CANCEL("C", "已取消"),
|
CANCEL("C", "已取消"),
|
||||||
DELETE("D", "已删除"),
|
DELETE("D", "已删除"),
|
||||||
COMPLETE("E", "已完成");
|
COMPLETE("E", "已完成");
|
||||||
|
|||||||
@ -0,0 +1,30 @@
|
|||||||
|
package com.fuint.common.param;
|
||||||
|
|
||||||
|
import io.swagger.annotations.ApiModelProperty;
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
import java.io.Serializable;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 看看作品分页参数
|
||||||
|
*
|
||||||
|
* Created by Codex
|
||||||
|
*/
|
||||||
|
@Data
|
||||||
|
public class LookWorkPage extends PageParam implements Serializable {
|
||||||
|
|
||||||
|
@ApiModelProperty("商户ID")
|
||||||
|
private Integer merchantId;
|
||||||
|
|
||||||
|
@ApiModelProperty("店铺ID")
|
||||||
|
private Integer storeId;
|
||||||
|
|
||||||
|
@ApiModelProperty("用户ID")
|
||||||
|
private Integer userId;
|
||||||
|
|
||||||
|
@ApiModelProperty("标题")
|
||||||
|
private String title;
|
||||||
|
|
||||||
|
@ApiModelProperty("状态")
|
||||||
|
private String status;
|
||||||
|
}
|
||||||
@ -0,0 +1,36 @@
|
|||||||
|
package com.fuint.common.param;
|
||||||
|
|
||||||
|
import io.swagger.annotations.ApiModelProperty;
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
import java.io.Serializable;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 任务完成记录分页请求参数
|
||||||
|
*
|
||||||
|
* Created by Codex
|
||||||
|
*/
|
||||||
|
@Data
|
||||||
|
public class TaskRecordPage extends PageParam implements Serializable {
|
||||||
|
|
||||||
|
@ApiModelProperty("所属商户ID")
|
||||||
|
private Integer merchantId;
|
||||||
|
|
||||||
|
@ApiModelProperty("所属店铺ID")
|
||||||
|
private Integer storeId;
|
||||||
|
|
||||||
|
@ApiModelProperty("任务ID")
|
||||||
|
private Integer taskId;
|
||||||
|
|
||||||
|
@ApiModelProperty("任务名称")
|
||||||
|
private String taskName;
|
||||||
|
|
||||||
|
@ApiModelProperty("任务日期(yyyy-MM-dd)")
|
||||||
|
private String taskDate;
|
||||||
|
|
||||||
|
@ApiModelProperty("会员号")
|
||||||
|
private String userNo;
|
||||||
|
|
||||||
|
@ApiModelProperty("手机号")
|
||||||
|
private String mobile;
|
||||||
|
}
|
||||||
@ -0,0 +1,63 @@
|
|||||||
|
package com.fuint.common.service;
|
||||||
|
|
||||||
|
import com.fuint.common.param.LookWorkPage;
|
||||||
|
import com.fuint.framework.exception.BusinessCheckException;
|
||||||
|
import com.fuint.framework.pagination.PaginationResponse;
|
||||||
|
import com.fuint.repository.model.MtLookWork;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 看看功能业务接口
|
||||||
|
*
|
||||||
|
* Created by Codex
|
||||||
|
*/
|
||||||
|
public interface LookService {
|
||||||
|
|
||||||
|
PaginationResponse<Map<String, Object>> queryWorkListForAdmin(LookWorkPage page) throws BusinessCheckException;
|
||||||
|
|
||||||
|
PaginationResponse<Map<String, Object>> queryWorkListForClient(Integer merchantId,
|
||||||
|
Integer storeId,
|
||||||
|
Integer userId,
|
||||||
|
Integer page,
|
||||||
|
Integer pageSize,
|
||||||
|
boolean onlyMine) throws BusinessCheckException;
|
||||||
|
|
||||||
|
Map<String, Object> getWorkDetail(Integer workId, Integer userId) throws BusinessCheckException;
|
||||||
|
|
||||||
|
Map<String, Object> getWorkDetailForAdmin(Integer workId) throws BusinessCheckException;
|
||||||
|
|
||||||
|
MtLookWork saveWork(Integer merchantId,
|
||||||
|
Integer storeId,
|
||||||
|
Integer userId,
|
||||||
|
String title,
|
||||||
|
String description,
|
||||||
|
List<String> images,
|
||||||
|
String operator) throws BusinessCheckException;
|
||||||
|
|
||||||
|
void removeWork(Integer workId, Integer userId, String operator) throws BusinessCheckException;
|
||||||
|
|
||||||
|
PaginationResponse<Map<String, Object>> queryCommentList(Integer workId,
|
||||||
|
Integer page,
|
||||||
|
Integer pageSize,
|
||||||
|
Integer userId) throws BusinessCheckException;
|
||||||
|
|
||||||
|
Map<String, Object> saveComment(Integer workId,
|
||||||
|
Integer userId,
|
||||||
|
String content,
|
||||||
|
List<String> images,
|
||||||
|
String operator) throws BusinessCheckException;
|
||||||
|
|
||||||
|
Map<String, Object> toggleWorkLike(Integer workId,
|
||||||
|
Integer userId,
|
||||||
|
Integer merchantId,
|
||||||
|
Integer storeId) throws BusinessCheckException;
|
||||||
|
|
||||||
|
Map<String, Object> toggleCommentLike(Integer commentId,
|
||||||
|
Integer userId,
|
||||||
|
Integer merchantId,
|
||||||
|
Integer storeId) throws BusinessCheckException;
|
||||||
|
|
||||||
|
void updateWorkStatus(Integer workId, String status, String operator, Integer merchantId) throws BusinessCheckException;
|
||||||
|
}
|
||||||
@ -3,6 +3,7 @@ package com.fuint.common.service;
|
|||||||
import com.baomidou.mybatisplus.extension.service.IService;
|
import com.baomidou.mybatisplus.extension.service.IService;
|
||||||
import com.fuint.common.dto.TaskDto;
|
import com.fuint.common.dto.TaskDto;
|
||||||
import com.fuint.common.param.TaskPage;
|
import com.fuint.common.param.TaskPage;
|
||||||
|
import com.fuint.common.param.TaskRecordPage;
|
||||||
import com.fuint.framework.exception.BusinessCheckException;
|
import com.fuint.framework.exception.BusinessCheckException;
|
||||||
import com.fuint.framework.pagination.PaginationResponse;
|
import com.fuint.framework.pagination.PaginationResponse;
|
||||||
import com.fuint.repository.model.MtTask;
|
import com.fuint.repository.model.MtTask;
|
||||||
@ -22,6 +23,11 @@ public interface TaskService extends IService<MtTask> {
|
|||||||
*/
|
*/
|
||||||
PaginationResponse<MtTask> queryTaskListByPagination(TaskPage taskPage) throws BusinessCheckException;
|
PaginationResponse<MtTask> queryTaskListByPagination(TaskPage taskPage) throws BusinessCheckException;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 分页查询任务完成记录
|
||||||
|
*/
|
||||||
|
PaginationResponse<Map<String, Object>> queryTaskRecordListByPagination(TaskRecordPage taskRecordPage) throws BusinessCheckException;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 添加任务
|
* 添加任务
|
||||||
*/
|
*/
|
||||||
@ -56,4 +62,9 @@ public interface TaskService extends IService<MtTask> {
|
|||||||
* 领取任务奖励
|
* 领取任务奖励
|
||||||
*/
|
*/
|
||||||
Map<String, Object> claimTask(Integer merchantId, Integer storeId, Integer userId, Integer taskId, String operator) throws BusinessCheckException;
|
Map<String, Object> claimTask(Integer merchantId, Integer storeId, Integer userId, Integer taskId, String operator) throws BusinessCheckException;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 导入公共任务(merchantId=0, storeId=0)到指定商户/店铺
|
||||||
|
*/
|
||||||
|
Map<String, Object> importPublicTask(Integer merchantId, Integer storeId, List<Integer> taskIds, String operator) throws BusinessCheckException;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -156,6 +156,8 @@ public class BookItemServiceImpl extends ServiceImpl<MtBookItemMapper, MtBookIte
|
|||||||
@OperationServiceLog(description = "新增预约订单")
|
@OperationServiceLog(description = "新增预约订单")
|
||||||
public MtBookItem addBookItem(MtBookItem mtBookItem) throws BusinessCheckException, ParseException {
|
public MtBookItem addBookItem(MtBookItem mtBookItem) throws BusinessCheckException, ParseException {
|
||||||
Integer storeId = mtBookItem.getStoreId() == null ? 0 : mtBookItem.getStoreId();
|
Integer storeId = mtBookItem.getStoreId() == null ? 0 : mtBookItem.getStoreId();
|
||||||
|
// 首页“立即签到”场景放开预约校验,允许直接生成预约单
|
||||||
|
boolean quickSign = StringUtil.isNotEmpty(mtBookItem.getRemark()) && mtBookItem.getRemark().contains("快速签到");
|
||||||
if (mtBookItem.getMerchantId() == null || mtBookItem.getMerchantId() <= 0) {
|
if (mtBookItem.getMerchantId() == null || mtBookItem.getMerchantId() <= 0) {
|
||||||
throw new BusinessCheckException("新增预约订单失败:所属商户不能为空!");
|
throw new BusinessCheckException("新增预约订单失败:所属商户不能为空!");
|
||||||
}
|
}
|
||||||
@ -166,6 +168,7 @@ public class BookItemServiceImpl extends ServiceImpl<MtBookItemMapper, MtBookIte
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!quickSign) {
|
||||||
BookableParam param = new BookableParam();
|
BookableParam param = new BookableParam();
|
||||||
param.setBookId(mtBookItem.getBookId());
|
param.setBookId(mtBookItem.getBookId());
|
||||||
param.setDate(mtBookItem.getServiceDate());
|
param.setDate(mtBookItem.getServiceDate());
|
||||||
@ -174,6 +177,7 @@ public class BookItemServiceImpl extends ServiceImpl<MtBookItemMapper, MtBookIte
|
|||||||
if (bookable.size() <= 0) {
|
if (bookable.size() <= 0) {
|
||||||
throw new BusinessCheckException("当前时间段不可预约,请重新选择!");
|
throw new BusinessCheckException("当前时间段不可预约,请重新选择!");
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
LambdaQueryWrapper<MtBookItem> queryWrapper = Wrappers.lambdaQuery();
|
LambdaQueryWrapper<MtBookItem> queryWrapper = Wrappers.lambdaQuery();
|
||||||
queryWrapper.eq(MtBookItem::getMerchantId, mtBookItem.getMerchantId());
|
queryWrapper.eq(MtBookItem::getMerchantId, mtBookItem.getMerchantId());
|
||||||
@ -185,13 +189,13 @@ public class BookItemServiceImpl extends ServiceImpl<MtBookItemMapper, MtBookIte
|
|||||||
if (mtBookItem.getGoodsId() != null && mtBookItem.getGoodsId() > 0) {
|
if (mtBookItem.getGoodsId() != null && mtBookItem.getGoodsId() > 0) {
|
||||||
queryWrapper.eq(MtBookItem::getGoodsId, mtBookItem.getGoodsId());
|
queryWrapper.eq(MtBookItem::getGoodsId, mtBookItem.getGoodsId());
|
||||||
}
|
}
|
||||||
queryWrapper.in(MtBookItem::getStatus, BookStatusEnum.CREATED.getKey(), BookStatusEnum.CONFIRM.getKey());
|
queryWrapper.in(MtBookItem::getStatus, BookStatusEnum.CREATED.getKey(), BookStatusEnum.CONFIRM.getKey(), BookStatusEnum.WAIT_PAY.getKey());
|
||||||
List<MtBookItem> data = mtBookItemMapper.selectList(queryWrapper);
|
List<MtBookItem> data = mtBookItemMapper.selectList(queryWrapper);
|
||||||
if (data != null && data.size() > 0) {
|
if (!quickSign && data != null && data.size() > 0) {
|
||||||
throw new BusinessCheckException("您在该时段已有预约,请勿重复提交!");
|
throw new BusinessCheckException("您在该时段已有预约,请勿重复提交!");
|
||||||
}
|
}
|
||||||
|
|
||||||
mtBookItem.setStatus(BookStatusEnum.CONFIRM.getKey());
|
mtBookItem.setStatus(BookStatusEnum.CREATED.getKey());
|
||||||
mtBookItem.setUpdateTime(new Date());
|
mtBookItem.setUpdateTime(new Date());
|
||||||
mtBookItem.setCreateTime(new Date());
|
mtBookItem.setCreateTime(new Date());
|
||||||
mtBookItem.setVerifyCode(SeqUtil.getRandomNumber(4));
|
mtBookItem.setVerifyCode(SeqUtil.getRandomNumber(4));
|
||||||
|
|||||||
@ -0,0 +1,541 @@
|
|||||||
|
package com.fuint.common.service.impl;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||||
|
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
||||||
|
import com.fuint.common.enums.StatusEnum;
|
||||||
|
import com.fuint.common.param.LookWorkPage;
|
||||||
|
import com.fuint.common.service.LookService;
|
||||||
|
import com.fuint.common.service.MemberService;
|
||||||
|
import com.fuint.common.service.SettingService;
|
||||||
|
import com.fuint.framework.exception.BusinessCheckException;
|
||||||
|
import com.fuint.framework.pagination.PaginationResponse;
|
||||||
|
import com.fuint.repository.mapper.MtLookCommentMapper;
|
||||||
|
import com.fuint.repository.mapper.MtLookLikeMapper;
|
||||||
|
import com.fuint.repository.mapper.MtLookWorkMapper;
|
||||||
|
import com.fuint.repository.model.MtLookComment;
|
||||||
|
import com.fuint.repository.model.MtLookLike;
|
||||||
|
import com.fuint.repository.model.MtLookWork;
|
||||||
|
import com.fuint.repository.model.MtUser;
|
||||||
|
import com.github.pagehelper.Page;
|
||||||
|
import com.github.pagehelper.PageHelper;
|
||||||
|
import lombok.AllArgsConstructor;
|
||||||
|
import org.apache.commons.lang.StringUtils;
|
||||||
|
import org.springframework.context.annotation.Lazy;
|
||||||
|
import org.springframework.data.domain.PageImpl;
|
||||||
|
import org.springframework.data.domain.PageRequest;
|
||||||
|
import org.springframework.stereotype.Service;
|
||||||
|
import org.springframework.transaction.annotation.Transactional;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.Arrays;
|
||||||
|
import java.util.Date;
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 看看功能服务实现
|
||||||
|
*
|
||||||
|
* Created by Codex
|
||||||
|
*/
|
||||||
|
@Service
|
||||||
|
@AllArgsConstructor(onConstructor_ = {@Lazy})
|
||||||
|
public class LookServiceImpl implements LookService {
|
||||||
|
|
||||||
|
private static final String TARGET_TYPE_WORK = "WORK";
|
||||||
|
private static final String TARGET_TYPE_COMMENT = "COMMENT";
|
||||||
|
|
||||||
|
private MtLookWorkMapper mtLookWorkMapper;
|
||||||
|
|
||||||
|
private MtLookCommentMapper mtLookCommentMapper;
|
||||||
|
|
||||||
|
private MtLookLikeMapper mtLookLikeMapper;
|
||||||
|
|
||||||
|
private MemberService memberService;
|
||||||
|
|
||||||
|
private SettingService settingService;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public PaginationResponse<Map<String, Object>> queryWorkListForAdmin(LookWorkPage page) {
|
||||||
|
Page<MtLookWork> pageHelper = PageHelper.startPage(page.getPage(), page.getPageSize());
|
||||||
|
|
||||||
|
LambdaQueryWrapper<MtLookWork> wrapper = Wrappers.lambdaQuery();
|
||||||
|
wrapper.ne(MtLookWork::getStatus, StatusEnum.DISABLE.getKey());
|
||||||
|
|
||||||
|
if (StringUtils.isNotBlank(page.getTitle())) {
|
||||||
|
wrapper.like(MtLookWork::getTitle, page.getTitle());
|
||||||
|
}
|
||||||
|
if (StringUtils.isNotBlank(page.getStatus())) {
|
||||||
|
wrapper.eq(MtLookWork::getStatus, page.getStatus());
|
||||||
|
}
|
||||||
|
if (page.getMerchantId() != null && page.getMerchantId() > 0) {
|
||||||
|
wrapper.eq(MtLookWork::getMerchantId, page.getMerchantId());
|
||||||
|
}
|
||||||
|
if (page.getStoreId() != null && page.getStoreId() > 0) {
|
||||||
|
wrapper.eq(MtLookWork::getStoreId, page.getStoreId());
|
||||||
|
}
|
||||||
|
wrapper.orderByDesc(MtLookWork::getId);
|
||||||
|
|
||||||
|
List<MtLookWork> list = mtLookWorkMapper.selectList(wrapper);
|
||||||
|
List<Map<String, Object>> dataList = toWorkListResult(list, null, true);
|
||||||
|
|
||||||
|
PageRequest pageRequest = PageRequest.of(page.getPage(), page.getPageSize());
|
||||||
|
PageImpl pageImpl = new PageImpl(dataList, pageRequest, pageHelper.getTotal());
|
||||||
|
PaginationResponse<Map<String, Object>> paginationResponse = new PaginationResponse(pageImpl, Map.class);
|
||||||
|
paginationResponse.setTotalPages(pageHelper.getPages());
|
||||||
|
paginationResponse.setTotalElements(pageHelper.getTotal());
|
||||||
|
paginationResponse.setContent(dataList);
|
||||||
|
return paginationResponse;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public PaginationResponse<Map<String, Object>> queryWorkListForClient(Integer merchantId,
|
||||||
|
Integer storeId,
|
||||||
|
Integer userId,
|
||||||
|
Integer page,
|
||||||
|
Integer pageSize,
|
||||||
|
boolean onlyMine) {
|
||||||
|
int currentPage = page == null || page < 1 ? 1 : page;
|
||||||
|
int size = pageSize == null || pageSize < 1 ? 10 : pageSize;
|
||||||
|
|
||||||
|
Page<MtLookWork> pageHelper = PageHelper.startPage(currentPage, size);
|
||||||
|
LambdaQueryWrapper<MtLookWork> wrapper = Wrappers.lambdaQuery();
|
||||||
|
wrapper.eq(MtLookWork::getMerchantId, merchantId)
|
||||||
|
.ne(MtLookWork::getStatus, StatusEnum.DISABLE.getKey());
|
||||||
|
|
||||||
|
if (onlyMine && userId != null && userId > 0) {
|
||||||
|
wrapper.eq(MtLookWork::getUserId, userId)
|
||||||
|
.ne(MtLookWork::getStatus, StatusEnum.DISABLE.getKey());
|
||||||
|
} else {
|
||||||
|
wrapper.eq(MtLookWork::getStatus, StatusEnum.ENABLED.getKey());
|
||||||
|
}
|
||||||
|
|
||||||
|
if (storeId != null && storeId > 0) {
|
||||||
|
wrapper.and(wq -> wq.eq(MtLookWork::getStoreId, 0).or().eq(MtLookWork::getStoreId, storeId));
|
||||||
|
}
|
||||||
|
|
||||||
|
wrapper.orderByDesc(MtLookWork::getId);
|
||||||
|
List<MtLookWork> list = mtLookWorkMapper.selectList(wrapper);
|
||||||
|
List<Map<String, Object>> dataList = toWorkListResult(list, userId, false);
|
||||||
|
|
||||||
|
PageRequest pageRequest = PageRequest.of(currentPage, size);
|
||||||
|
PageImpl pageImpl = new PageImpl(dataList, pageRequest, pageHelper.getTotal());
|
||||||
|
PaginationResponse<Map<String, Object>> paginationResponse = new PaginationResponse(pageImpl, Map.class);
|
||||||
|
paginationResponse.setTotalPages(pageHelper.getPages());
|
||||||
|
paginationResponse.setTotalElements(pageHelper.getTotal());
|
||||||
|
paginationResponse.setContent(dataList);
|
||||||
|
return paginationResponse;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Map<String, Object> getWorkDetail(Integer workId, Integer userId) throws BusinessCheckException {
|
||||||
|
MtLookWork work = mtLookWorkMapper.selectById(workId);
|
||||||
|
if (work == null || StatusEnum.DISABLE.getKey().equals(work.getStatus())) {
|
||||||
|
throw new BusinessCheckException("作品不存在");
|
||||||
|
}
|
||||||
|
if (StatusEnum.ENABLED.getKey().equals(work.getStatus()) || (userId != null && userId.equals(work.getUserId()))) {
|
||||||
|
Map<String, Object> result = toWorkItemResult(work, userId, false);
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
throw new BusinessCheckException("作品已下架");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Map<String, Object> getWorkDetailForAdmin(Integer workId) throws BusinessCheckException {
|
||||||
|
MtLookWork work = mtLookWorkMapper.selectById(workId);
|
||||||
|
if (work == null || StatusEnum.DISABLE.getKey().equals(work.getStatus())) {
|
||||||
|
throw new BusinessCheckException("作品不存在");
|
||||||
|
}
|
||||||
|
return toWorkItemResult(work, null, true);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
@Transactional(rollbackFor = Exception.class)
|
||||||
|
public MtLookWork saveWork(Integer merchantId,
|
||||||
|
Integer storeId,
|
||||||
|
Integer userId,
|
||||||
|
String title,
|
||||||
|
String description,
|
||||||
|
List<String> images,
|
||||||
|
String operator) throws BusinessCheckException {
|
||||||
|
if (merchantId == null || merchantId <= 0) {
|
||||||
|
throw new BusinessCheckException("商户信息异常");
|
||||||
|
}
|
||||||
|
if (userId == null || userId <= 0) {
|
||||||
|
throw new BusinessCheckException("用户信息异常");
|
||||||
|
}
|
||||||
|
if (StringUtils.isBlank(title)) {
|
||||||
|
throw new BusinessCheckException("作品标题不能为空");
|
||||||
|
}
|
||||||
|
if (StringUtils.isBlank(description)) {
|
||||||
|
throw new BusinessCheckException("作品描述不能为空");
|
||||||
|
}
|
||||||
|
if (images == null || images.isEmpty()) {
|
||||||
|
throw new BusinessCheckException("请至少上传1张作品图");
|
||||||
|
}
|
||||||
|
|
||||||
|
MtLookWork work = new MtLookWork();
|
||||||
|
work.setMerchantId(merchantId);
|
||||||
|
work.setStoreId(storeId == null ? 0 : storeId);
|
||||||
|
work.setUserId(userId);
|
||||||
|
work.setTitle(title);
|
||||||
|
work.setDescription(description);
|
||||||
|
work.setImages(joinImages(images));
|
||||||
|
work.setCover(images.get(0));
|
||||||
|
work.setLikeNum(0);
|
||||||
|
work.setCommentNum(0);
|
||||||
|
work.setStatus(StatusEnum.ENABLED.getKey());
|
||||||
|
work.setOperator(StringUtils.isBlank(operator) ? String.valueOf(userId) : operator);
|
||||||
|
work.setCreateTime(new Date());
|
||||||
|
work.setUpdateTime(new Date());
|
||||||
|
|
||||||
|
mtLookWorkMapper.insert(work);
|
||||||
|
return work;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
@Transactional(rollbackFor = Exception.class)
|
||||||
|
public void removeWork(Integer workId, Integer userId, String operator) throws BusinessCheckException {
|
||||||
|
MtLookWork work = mtLookWorkMapper.selectById(workId);
|
||||||
|
if (work == null || StatusEnum.DISABLE.getKey().equals(work.getStatus())) {
|
||||||
|
throw new BusinessCheckException("作品不存在");
|
||||||
|
}
|
||||||
|
if (userId == null || !userId.equals(work.getUserId())) {
|
||||||
|
throw new BusinessCheckException("无权删除该作品");
|
||||||
|
}
|
||||||
|
|
||||||
|
MtLookWork update = new MtLookWork();
|
||||||
|
update.setId(workId);
|
||||||
|
update.setStatus(StatusEnum.DISABLE.getKey());
|
||||||
|
update.setOperator(StringUtils.isBlank(operator) ? String.valueOf(userId) : operator);
|
||||||
|
update.setUpdateTime(new Date());
|
||||||
|
mtLookWorkMapper.updateById(update);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public PaginationResponse<Map<String, Object>> queryCommentList(Integer workId,
|
||||||
|
Integer page,
|
||||||
|
Integer pageSize,
|
||||||
|
Integer userId) throws BusinessCheckException {
|
||||||
|
MtLookWork work = mtLookWorkMapper.selectById(workId);
|
||||||
|
if (work == null || StatusEnum.DISABLE.getKey().equals(work.getStatus())) {
|
||||||
|
throw new BusinessCheckException("作品不存在");
|
||||||
|
}
|
||||||
|
|
||||||
|
int currentPage = page == null || page < 1 ? 1 : page;
|
||||||
|
int size = pageSize == null || pageSize < 1 ? 20 : pageSize;
|
||||||
|
|
||||||
|
Page<MtLookComment> pageHelper = PageHelper.startPage(currentPage, size);
|
||||||
|
LambdaQueryWrapper<MtLookComment> wrapper = Wrappers.lambdaQuery();
|
||||||
|
wrapper.eq(MtLookComment::getWorkId, workId)
|
||||||
|
.eq(MtLookComment::getStatus, StatusEnum.ENABLED.getKey())
|
||||||
|
.orderByDesc(MtLookComment::getId);
|
||||||
|
List<MtLookComment> list = mtLookCommentMapper.selectList(wrapper);
|
||||||
|
List<Map<String, Object>> dataList = toCommentListResult(list, userId);
|
||||||
|
|
||||||
|
PageRequest pageRequest = PageRequest.of(currentPage, size);
|
||||||
|
PageImpl pageImpl = new PageImpl(dataList, pageRequest, pageHelper.getTotal());
|
||||||
|
PaginationResponse<Map<String, Object>> paginationResponse = new PaginationResponse(pageImpl, Map.class);
|
||||||
|
paginationResponse.setTotalPages(pageHelper.getPages());
|
||||||
|
paginationResponse.setTotalElements(pageHelper.getTotal());
|
||||||
|
paginationResponse.setContent(dataList);
|
||||||
|
return paginationResponse;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
@Transactional(rollbackFor = Exception.class)
|
||||||
|
public Map<String, Object> saveComment(Integer workId,
|
||||||
|
Integer userId,
|
||||||
|
String content,
|
||||||
|
List<String> images,
|
||||||
|
String operator) throws BusinessCheckException {
|
||||||
|
MtLookWork work = mtLookWorkMapper.selectById(workId);
|
||||||
|
if (work == null || !StatusEnum.ENABLED.getKey().equals(work.getStatus())) {
|
||||||
|
throw new BusinessCheckException("作品不存在或已下架");
|
||||||
|
}
|
||||||
|
if (StringUtils.isBlank(content) && (images == null || images.isEmpty())) {
|
||||||
|
throw new BusinessCheckException("请输入留言内容或上传图片");
|
||||||
|
}
|
||||||
|
if (userId == null || userId <= 0) {
|
||||||
|
throw new BusinessCheckException("用户信息异常");
|
||||||
|
}
|
||||||
|
|
||||||
|
MtLookComment comment = new MtLookComment();
|
||||||
|
comment.setMerchantId(work.getMerchantId());
|
||||||
|
comment.setStoreId(work.getStoreId());
|
||||||
|
comment.setWorkId(workId);
|
||||||
|
comment.setUserId(userId);
|
||||||
|
comment.setContent(StringUtils.isBlank(content) ? "" : content);
|
||||||
|
comment.setImages(joinImages(images));
|
||||||
|
comment.setLikeNum(0);
|
||||||
|
comment.setStatus(StatusEnum.ENABLED.getKey());
|
||||||
|
comment.setOperator(StringUtils.isBlank(operator) ? String.valueOf(userId) : operator);
|
||||||
|
comment.setCreateTime(new Date());
|
||||||
|
comment.setUpdateTime(new Date());
|
||||||
|
|
||||||
|
mtLookCommentMapper.insert(comment);
|
||||||
|
mtLookWorkMapper.incrCommentNum(workId);
|
||||||
|
return toCommentItemResult(comment, userId);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
@Transactional(rollbackFor = Exception.class)
|
||||||
|
public Map<String, Object> toggleWorkLike(Integer workId,
|
||||||
|
Integer userId,
|
||||||
|
Integer merchantId,
|
||||||
|
Integer storeId) throws BusinessCheckException {
|
||||||
|
if (userId == null || userId <= 0) {
|
||||||
|
throw new BusinessCheckException("请先登录");
|
||||||
|
}
|
||||||
|
MtLookWork work = mtLookWorkMapper.selectById(workId);
|
||||||
|
if (work == null || !StatusEnum.ENABLED.getKey().equals(work.getStatus())) {
|
||||||
|
throw new BusinessCheckException("作品不存在或已下架");
|
||||||
|
}
|
||||||
|
if (merchantId != null && merchantId > 0 && !merchantId.equals(work.getMerchantId())) {
|
||||||
|
throw new BusinessCheckException("作品不存在");
|
||||||
|
}
|
||||||
|
if (storeId != null && storeId > 0 && work.getStoreId() != null && work.getStoreId() > 0 && !storeId.equals(work.getStoreId())) {
|
||||||
|
throw new BusinessCheckException("作品不存在");
|
||||||
|
}
|
||||||
|
|
||||||
|
MtLookLike like = queryLike(userId, TARGET_TYPE_WORK, workId);
|
||||||
|
boolean liked;
|
||||||
|
if (like == null) {
|
||||||
|
like = new MtLookLike();
|
||||||
|
like.setMerchantId(work.getMerchantId());
|
||||||
|
like.setStoreId(work.getStoreId());
|
||||||
|
like.setUserId(userId);
|
||||||
|
like.setTargetType(TARGET_TYPE_WORK);
|
||||||
|
like.setTargetId(workId);
|
||||||
|
like.setStatus(StatusEnum.ENABLED.getKey());
|
||||||
|
like.setCreateTime(new Date());
|
||||||
|
like.setUpdateTime(new Date());
|
||||||
|
mtLookLikeMapper.insert(like);
|
||||||
|
mtLookWorkMapper.incrLikeNum(workId);
|
||||||
|
liked = true;
|
||||||
|
} else if (StatusEnum.ENABLED.getKey().equals(like.getStatus())) {
|
||||||
|
like.setStatus(StatusEnum.FORBIDDEN.getKey());
|
||||||
|
like.setUpdateTime(new Date());
|
||||||
|
mtLookLikeMapper.updateById(like);
|
||||||
|
mtLookWorkMapper.decrLikeNum(workId);
|
||||||
|
liked = false;
|
||||||
|
} else {
|
||||||
|
like.setStatus(StatusEnum.ENABLED.getKey());
|
||||||
|
like.setUpdateTime(new Date());
|
||||||
|
mtLookLikeMapper.updateById(like);
|
||||||
|
mtLookWorkMapper.incrLikeNum(workId);
|
||||||
|
liked = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
MtLookWork latest = mtLookWorkMapper.selectById(workId);
|
||||||
|
Map<String, Object> result = new HashMap<>();
|
||||||
|
result.put("liked", liked);
|
||||||
|
result.put("likeCount", latest.getLikeNum() == null ? 0 : latest.getLikeNum());
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
@Transactional(rollbackFor = Exception.class)
|
||||||
|
public Map<String, Object> toggleCommentLike(Integer commentId,
|
||||||
|
Integer userId,
|
||||||
|
Integer merchantId,
|
||||||
|
Integer storeId) throws BusinessCheckException {
|
||||||
|
if (userId == null || userId <= 0) {
|
||||||
|
throw new BusinessCheckException("请先登录");
|
||||||
|
}
|
||||||
|
MtLookComment comment = mtLookCommentMapper.selectById(commentId);
|
||||||
|
if (comment == null || !StatusEnum.ENABLED.getKey().equals(comment.getStatus())) {
|
||||||
|
throw new BusinessCheckException("评论不存在");
|
||||||
|
}
|
||||||
|
MtLookWork work = mtLookWorkMapper.selectById(comment.getWorkId());
|
||||||
|
if (work == null || !StatusEnum.ENABLED.getKey().equals(work.getStatus())) {
|
||||||
|
throw new BusinessCheckException("作品不存在或已下架");
|
||||||
|
}
|
||||||
|
if (merchantId != null && merchantId > 0 && !merchantId.equals(comment.getMerchantId())) {
|
||||||
|
throw new BusinessCheckException("评论不存在");
|
||||||
|
}
|
||||||
|
if (storeId != null && storeId > 0 && comment.getStoreId() != null && comment.getStoreId() > 0 && !storeId.equals(comment.getStoreId())) {
|
||||||
|
throw new BusinessCheckException("评论不存在");
|
||||||
|
}
|
||||||
|
|
||||||
|
MtLookLike like = queryLike(userId, TARGET_TYPE_COMMENT, commentId);
|
||||||
|
boolean liked;
|
||||||
|
if (like == null) {
|
||||||
|
like = new MtLookLike();
|
||||||
|
like.setMerchantId(comment.getMerchantId());
|
||||||
|
like.setStoreId(comment.getStoreId());
|
||||||
|
like.setUserId(userId);
|
||||||
|
like.setTargetType(TARGET_TYPE_COMMENT);
|
||||||
|
like.setTargetId(commentId);
|
||||||
|
like.setStatus(StatusEnum.ENABLED.getKey());
|
||||||
|
like.setCreateTime(new Date());
|
||||||
|
like.setUpdateTime(new Date());
|
||||||
|
mtLookLikeMapper.insert(like);
|
||||||
|
mtLookCommentMapper.incrLikeNum(commentId);
|
||||||
|
liked = true;
|
||||||
|
} else if (StatusEnum.ENABLED.getKey().equals(like.getStatus())) {
|
||||||
|
like.setStatus(StatusEnum.FORBIDDEN.getKey());
|
||||||
|
like.setUpdateTime(new Date());
|
||||||
|
mtLookLikeMapper.updateById(like);
|
||||||
|
mtLookCommentMapper.decrLikeNum(commentId);
|
||||||
|
liked = false;
|
||||||
|
} else {
|
||||||
|
like.setStatus(StatusEnum.ENABLED.getKey());
|
||||||
|
like.setUpdateTime(new Date());
|
||||||
|
mtLookLikeMapper.updateById(like);
|
||||||
|
mtLookCommentMapper.incrLikeNum(commentId);
|
||||||
|
liked = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
MtLookComment latest = mtLookCommentMapper.selectById(commentId);
|
||||||
|
Map<String, Object> result = new HashMap<>();
|
||||||
|
result.put("liked", liked);
|
||||||
|
result.put("likeCount", latest.getLikeNum() == null ? 0 : latest.getLikeNum());
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
@Transactional(rollbackFor = Exception.class)
|
||||||
|
public void updateWorkStatus(Integer workId, String status, String operator, Integer merchantId) throws BusinessCheckException {
|
||||||
|
MtLookWork work = mtLookWorkMapper.selectById(workId);
|
||||||
|
if (work == null || StatusEnum.DISABLE.getKey().equals(work.getStatus())) {
|
||||||
|
throw new BusinessCheckException("作品不存在");
|
||||||
|
}
|
||||||
|
if (merchantId != null && merchantId > 0 && !merchantId.equals(work.getMerchantId())) {
|
||||||
|
throw new BusinessCheckException("无权操作该作品");
|
||||||
|
}
|
||||||
|
|
||||||
|
MtLookWork update = new MtLookWork();
|
||||||
|
update.setId(workId);
|
||||||
|
update.setStatus(status);
|
||||||
|
update.setOperator(operator);
|
||||||
|
update.setUpdateTime(new Date());
|
||||||
|
mtLookWorkMapper.updateById(update);
|
||||||
|
}
|
||||||
|
|
||||||
|
private MtLookLike queryLike(Integer userId, String targetType, Integer targetId) {
|
||||||
|
LambdaQueryWrapper<MtLookLike> wrapper = Wrappers.lambdaQuery();
|
||||||
|
wrapper.eq(MtLookLike::getUserId, userId)
|
||||||
|
.eq(MtLookLike::getTargetType, targetType)
|
||||||
|
.eq(MtLookLike::getTargetId, targetId)
|
||||||
|
.ne(MtLookLike::getStatus, StatusEnum.DISABLE.getKey())
|
||||||
|
.last("limit 1");
|
||||||
|
return mtLookLikeMapper.selectOne(wrapper);
|
||||||
|
}
|
||||||
|
|
||||||
|
private List<Map<String, Object>> toWorkListResult(List<MtLookWork> list, Integer userId, boolean adminMode) {
|
||||||
|
List<Map<String, Object>> result = new ArrayList<>();
|
||||||
|
for (MtLookWork item : list) {
|
||||||
|
result.add(toWorkItemResult(item, userId, adminMode));
|
||||||
|
}
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
private Map<String, Object> toWorkItemResult(MtLookWork item, Integer userId, boolean adminMode) {
|
||||||
|
Map<String, Object> result = new HashMap<>();
|
||||||
|
result.put("id", item.getId());
|
||||||
|
result.put("merchantId", item.getMerchantId());
|
||||||
|
result.put("storeId", item.getStoreId());
|
||||||
|
result.put("userId", item.getUserId());
|
||||||
|
result.put("title", item.getTitle());
|
||||||
|
result.put("desc", item.getDescription());
|
||||||
|
result.put("description", item.getDescription());
|
||||||
|
result.put("cover", resolveImage(item.getCover()));
|
||||||
|
result.put("images", splitImages(item.getImages()).stream().map(this::resolveImage).collect(Collectors.toList()));
|
||||||
|
result.put("likes", item.getLikeNum() == null ? 0 : item.getLikeNum());
|
||||||
|
result.put("comments", item.getCommentNum() == null ? 0 : item.getCommentNum());
|
||||||
|
result.put("status", item.getStatus());
|
||||||
|
result.put("createTime", item.getCreateTime());
|
||||||
|
result.put("updateTime", item.getUpdateTime());
|
||||||
|
result.put("operator", item.getOperator());
|
||||||
|
|
||||||
|
MtUser user = null;
|
||||||
|
try {
|
||||||
|
user = memberService.queryMemberById(item.getUserId());
|
||||||
|
} catch (BusinessCheckException e) {
|
||||||
|
// ignore
|
||||||
|
}
|
||||||
|
result.put("author", user == null ? "手作玩家" : user.getName());
|
||||||
|
result.put("authorAvatar", user == null ? "" : user.getAvatar());
|
||||||
|
|
||||||
|
if (!adminMode && userId != null && userId > 0) {
|
||||||
|
MtLookLike like = queryLike(userId, TARGET_TYPE_WORK, item.getId());
|
||||||
|
result.put("isLiked", like != null && StatusEnum.ENABLED.getKey().equals(like.getStatus()));
|
||||||
|
} else {
|
||||||
|
result.put("isLiked", false);
|
||||||
|
}
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
private List<Map<String, Object>> toCommentListResult(List<MtLookComment> list, Integer userId) {
|
||||||
|
List<Map<String, Object>> result = new ArrayList<>();
|
||||||
|
for (MtLookComment item : list) {
|
||||||
|
result.add(toCommentItemResult(item, userId));
|
||||||
|
}
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
private Map<String, Object> toCommentItemResult(MtLookComment item, Integer userId) {
|
||||||
|
Map<String, Object> result = new HashMap<>();
|
||||||
|
result.put("id", item.getId());
|
||||||
|
result.put("workId", item.getWorkId());
|
||||||
|
result.put("authorId", item.getUserId());
|
||||||
|
result.put("content", item.getContent());
|
||||||
|
result.put("images", splitImages(item.getImages()).stream().map(this::resolveImage).collect(Collectors.toList()));
|
||||||
|
result.put("likeCount", item.getLikeNum() == null ? 0 : item.getLikeNum());
|
||||||
|
result.put("createTime", item.getCreateTime());
|
||||||
|
|
||||||
|
MtUser user = null;
|
||||||
|
try {
|
||||||
|
user = memberService.queryMemberById(item.getUserId());
|
||||||
|
} catch (BusinessCheckException e) {
|
||||||
|
// ignore
|
||||||
|
}
|
||||||
|
result.put("author", user == null ? "匿名用户" : user.getName());
|
||||||
|
result.put("authorAvatar", user == null ? "" : user.getAvatar());
|
||||||
|
|
||||||
|
if (userId != null && userId > 0) {
|
||||||
|
MtLookLike like = queryLike(userId, TARGET_TYPE_COMMENT, item.getId());
|
||||||
|
result.put("isLiked", like != null && StatusEnum.ENABLED.getKey().equals(like.getStatus()));
|
||||||
|
} else {
|
||||||
|
result.put("isLiked", false);
|
||||||
|
}
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
private String joinImages(List<String> images) {
|
||||||
|
if (images == null || images.isEmpty()) {
|
||||||
|
return "";
|
||||||
|
}
|
||||||
|
List<String> valid = images.stream().filter(StringUtils::isNotBlank).collect(Collectors.toList());
|
||||||
|
return String.join(",", valid);
|
||||||
|
}
|
||||||
|
|
||||||
|
private List<String> splitImages(String images) {
|
||||||
|
if (StringUtils.isBlank(images)) {
|
||||||
|
return new ArrayList<>();
|
||||||
|
}
|
||||||
|
return Arrays.stream(images.split(",")).filter(StringUtils::isNotBlank).collect(Collectors.toList());
|
||||||
|
}
|
||||||
|
|
||||||
|
private String resolveImage(String path) {
|
||||||
|
if (StringUtils.isBlank(path)) {
|
||||||
|
return "";
|
||||||
|
}
|
||||||
|
if (path.startsWith("http://") || path.startsWith("https://")) {
|
||||||
|
return path;
|
||||||
|
}
|
||||||
|
String base = settingService.getUploadBasePath();
|
||||||
|
if (StringUtils.isBlank(base)) {
|
||||||
|
return path;
|
||||||
|
}
|
||||||
|
if (base.endsWith("/") && path.startsWith("/")) {
|
||||||
|
return base + path.substring(1);
|
||||||
|
}
|
||||||
|
if (!base.endsWith("/") && !path.startsWith("/")) {
|
||||||
|
return base + "/" + path;
|
||||||
|
}
|
||||||
|
return base + path;
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -6,6 +6,8 @@ import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|||||||
import com.fuint.common.dto.TaskDto;
|
import com.fuint.common.dto.TaskDto;
|
||||||
import com.fuint.common.enums.StatusEnum;
|
import com.fuint.common.enums.StatusEnum;
|
||||||
import com.fuint.common.param.TaskPage;
|
import com.fuint.common.param.TaskPage;
|
||||||
|
import com.fuint.common.param.TaskRecordPage;
|
||||||
|
import com.fuint.common.service.BalanceService;
|
||||||
import com.fuint.common.service.PointService;
|
import com.fuint.common.service.PointService;
|
||||||
import com.fuint.common.service.StoreService;
|
import com.fuint.common.service.StoreService;
|
||||||
import com.fuint.common.service.TaskService;
|
import com.fuint.common.service.TaskService;
|
||||||
@ -13,13 +15,20 @@ import com.fuint.common.util.DateUtil;
|
|||||||
import com.fuint.framework.annoation.OperationServiceLog;
|
import com.fuint.framework.annoation.OperationServiceLog;
|
||||||
import com.fuint.framework.exception.BusinessCheckException;
|
import com.fuint.framework.exception.BusinessCheckException;
|
||||||
import com.fuint.framework.pagination.PaginationResponse;
|
import com.fuint.framework.pagination.PaginationResponse;
|
||||||
|
import com.fuint.repository.mapper.MtBalanceMapper;
|
||||||
|
import com.fuint.repository.mapper.MtLookWorkMapper;
|
||||||
|
import com.fuint.repository.mapper.MtOrderMapper;
|
||||||
import com.fuint.repository.mapper.MtPointMapper;
|
import com.fuint.repository.mapper.MtPointMapper;
|
||||||
import com.fuint.repository.mapper.MtTaskMapper;
|
import com.fuint.repository.mapper.MtTaskMapper;
|
||||||
import com.fuint.repository.mapper.MtTaskRecordMapper;
|
import com.fuint.repository.mapper.MtTaskRecordMapper;
|
||||||
|
import com.fuint.repository.mapper.MtUserMapper;
|
||||||
|
import com.fuint.repository.model.MtBalance;
|
||||||
|
import com.fuint.repository.model.MtLookWork;
|
||||||
import com.fuint.repository.model.MtPoint;
|
import com.fuint.repository.model.MtPoint;
|
||||||
import com.fuint.repository.model.MtStore;
|
import com.fuint.repository.model.MtStore;
|
||||||
import com.fuint.repository.model.MtTask;
|
import com.fuint.repository.model.MtTask;
|
||||||
import com.fuint.repository.model.MtTaskRecord;
|
import com.fuint.repository.model.MtTaskRecord;
|
||||||
|
import com.fuint.repository.model.MtUser;
|
||||||
import com.github.pagehelper.Page;
|
import com.github.pagehelper.Page;
|
||||||
import com.github.pagehelper.PageHelper;
|
import com.github.pagehelper.PageHelper;
|
||||||
import lombok.AllArgsConstructor;
|
import lombok.AllArgsConstructor;
|
||||||
@ -33,11 +42,16 @@ import org.springframework.data.domain.PageRequest;
|
|||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
import org.springframework.transaction.annotation.Transactional;
|
import org.springframework.transaction.annotation.Transactional;
|
||||||
|
|
||||||
|
import java.math.BigDecimal;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
import java.util.Calendar;
|
||||||
|
import java.util.Collections;
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
|
import java.util.HashSet;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
import java.util.Set;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 任务中心服务实现
|
* 任务中心服务实现
|
||||||
@ -49,15 +63,27 @@ import java.util.Map;
|
|||||||
public class TaskServiceImpl extends ServiceImpl<MtTaskMapper, MtTask> implements TaskService {
|
public class TaskServiceImpl extends ServiceImpl<MtTaskMapper, MtTask> implements TaskService {
|
||||||
|
|
||||||
private static final Logger logger = LoggerFactory.getLogger(TaskServiceImpl.class);
|
private static final Logger logger = LoggerFactory.getLogger(TaskServiceImpl.class);
|
||||||
|
private static final String TASK_CODE_ORDER_COMPLETE_BY_AMOUNT = "ORDER_COMPLETE_BY_AMOUNT";
|
||||||
|
private static final String TASK_CODE_LOOK_PUBLISH_BY_LIKE = "LOOK_PUBLISH_BY_LIKE";
|
||||||
|
|
||||||
private MtTaskMapper mtTaskMapper;
|
private MtTaskMapper mtTaskMapper;
|
||||||
|
|
||||||
private MtTaskRecordMapper mtTaskRecordMapper;
|
private MtTaskRecordMapper mtTaskRecordMapper;
|
||||||
|
|
||||||
|
private MtUserMapper mtUserMapper;
|
||||||
|
|
||||||
private MtPointMapper mtPointMapper;
|
private MtPointMapper mtPointMapper;
|
||||||
|
|
||||||
|
private MtBalanceMapper mtBalanceMapper;
|
||||||
|
|
||||||
|
private MtOrderMapper mtOrderMapper;
|
||||||
|
|
||||||
|
private MtLookWorkMapper mtLookWorkMapper;
|
||||||
|
|
||||||
private PointService pointService;
|
private PointService pointService;
|
||||||
|
|
||||||
|
private BalanceService balanceService;
|
||||||
|
|
||||||
private StoreService storeService;
|
private StoreService storeService;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -94,6 +120,154 @@ public class TaskServiceImpl extends ServiceImpl<MtTaskMapper, MtTask> implement
|
|||||||
return paginationResponse;
|
return paginationResponse;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public PaginationResponse<Map<String, Object>> queryTaskRecordListByPagination(TaskRecordPage taskRecordPage) {
|
||||||
|
List<Integer> matchTaskIds = null;
|
||||||
|
if (StringUtils.isNotBlank(taskRecordPage.getTaskName())) {
|
||||||
|
LambdaQueryWrapper<MtTask> taskWrapper = Wrappers.lambdaQuery();
|
||||||
|
taskWrapper.select(MtTask::getId)
|
||||||
|
.like(MtTask::getTaskName, taskRecordPage.getTaskName())
|
||||||
|
.ne(MtTask::getStatus, StatusEnum.DISABLE.getKey());
|
||||||
|
if (taskRecordPage.getMerchantId() != null) {
|
||||||
|
taskWrapper.eq(MtTask::getMerchantId, taskRecordPage.getMerchantId());
|
||||||
|
}
|
||||||
|
if (taskRecordPage.getStoreId() != null) {
|
||||||
|
taskWrapper.and(wq -> wq.eq(MtTask::getStoreId, 0).or().eq(MtTask::getStoreId, taskRecordPage.getStoreId()));
|
||||||
|
}
|
||||||
|
List<MtTask> taskList = mtTaskMapper.selectList(taskWrapper);
|
||||||
|
matchTaskIds = new ArrayList<>();
|
||||||
|
for (MtTask task : taskList) {
|
||||||
|
matchTaskIds.add(task.getId());
|
||||||
|
}
|
||||||
|
if (matchTaskIds.isEmpty()) {
|
||||||
|
return emptyTaskRecordPage(taskRecordPage);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
List<Integer> matchUserIds = null;
|
||||||
|
if (StringUtils.isNotBlank(taskRecordPage.getUserNo()) || StringUtils.isNotBlank(taskRecordPage.getMobile())) {
|
||||||
|
LambdaQueryWrapper<MtUser> userWrapper = Wrappers.lambdaQuery();
|
||||||
|
userWrapper.select(MtUser::getId)
|
||||||
|
.ne(MtUser::getStatus, StatusEnum.DISABLE.getKey());
|
||||||
|
if (taskRecordPage.getMerchantId() != null) {
|
||||||
|
userWrapper.eq(MtUser::getMerchantId, taskRecordPage.getMerchantId());
|
||||||
|
}
|
||||||
|
if (StringUtils.isNotBlank(taskRecordPage.getUserNo())) {
|
||||||
|
userWrapper.like(MtUser::getUserNo, taskRecordPage.getUserNo());
|
||||||
|
}
|
||||||
|
if (StringUtils.isNotBlank(taskRecordPage.getMobile())) {
|
||||||
|
userWrapper.like(MtUser::getMobile, taskRecordPage.getMobile());
|
||||||
|
}
|
||||||
|
List<MtUser> userList = mtUserMapper.selectList(userWrapper);
|
||||||
|
matchUserIds = new ArrayList<>();
|
||||||
|
for (MtUser user : userList) {
|
||||||
|
matchUserIds.add(user.getId());
|
||||||
|
}
|
||||||
|
if (matchUserIds.isEmpty()) {
|
||||||
|
return emptyTaskRecordPage(taskRecordPage);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Page<MtTaskRecord> pageHelper = PageHelper.startPage(taskRecordPage.getPage(), taskRecordPage.getPageSize());
|
||||||
|
LambdaQueryWrapper<MtTaskRecord> wrapper = Wrappers.lambdaQuery();
|
||||||
|
wrapper.ne(MtTaskRecord::getStatus, StatusEnum.DISABLE.getKey());
|
||||||
|
if (taskRecordPage.getMerchantId() != null) {
|
||||||
|
wrapper.eq(MtTaskRecord::getMerchantId, taskRecordPage.getMerchantId());
|
||||||
|
}
|
||||||
|
if (taskRecordPage.getStoreId() != null) {
|
||||||
|
wrapper.and(wq -> wq.eq(MtTaskRecord::getStoreId, 0).or().eq(MtTaskRecord::getStoreId, taskRecordPage.getStoreId()));
|
||||||
|
}
|
||||||
|
if (taskRecordPage.getTaskId() != null && taskRecordPage.getTaskId() > 0) {
|
||||||
|
wrapper.eq(MtTaskRecord::getTaskId, taskRecordPage.getTaskId());
|
||||||
|
}
|
||||||
|
if (StringUtils.isNotBlank(taskRecordPage.getTaskDate())) {
|
||||||
|
wrapper.eq(MtTaskRecord::getTaskDate, taskRecordPage.getTaskDate());
|
||||||
|
}
|
||||||
|
if (matchTaskIds != null) {
|
||||||
|
wrapper.in(MtTaskRecord::getTaskId, matchTaskIds);
|
||||||
|
}
|
||||||
|
if (matchUserIds != null) {
|
||||||
|
wrapper.in(MtTaskRecord::getUserId, matchUserIds);
|
||||||
|
}
|
||||||
|
|
||||||
|
wrapper.orderByDesc(MtTaskRecord::getTaskDate)
|
||||||
|
.orderByDesc(MtTaskRecord::getLastCompleteTime)
|
||||||
|
.orderByDesc(MtTaskRecord::getId);
|
||||||
|
|
||||||
|
List<MtTaskRecord> recordList = mtTaskRecordMapper.selectList(wrapper);
|
||||||
|
if (recordList == null) {
|
||||||
|
recordList = Collections.emptyList();
|
||||||
|
}
|
||||||
|
|
||||||
|
Set<Integer> taskIdSet = new HashSet<>();
|
||||||
|
Set<Integer> userIdSet = new HashSet<>();
|
||||||
|
for (MtTaskRecord record : recordList) {
|
||||||
|
if (record.getTaskId() != null && record.getTaskId() > 0) {
|
||||||
|
taskIdSet.add(record.getTaskId());
|
||||||
|
}
|
||||||
|
if (record.getUserId() != null && record.getUserId() > 0) {
|
||||||
|
userIdSet.add(record.getUserId());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Map<Integer, MtTask> taskMap = new HashMap<>();
|
||||||
|
if (!taskIdSet.isEmpty()) {
|
||||||
|
LambdaQueryWrapper<MtTask> taskWrapper = Wrappers.lambdaQuery();
|
||||||
|
taskWrapper.in(MtTask::getId, taskIdSet);
|
||||||
|
List<MtTask> taskList = mtTaskMapper.selectList(taskWrapper);
|
||||||
|
for (MtTask task : taskList) {
|
||||||
|
taskMap.put(task.getId(), task);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Map<Integer, MtUser> userMap = new HashMap<>();
|
||||||
|
if (!userIdSet.isEmpty()) {
|
||||||
|
LambdaQueryWrapper<MtUser> userWrapper = Wrappers.lambdaQuery();
|
||||||
|
userWrapper.in(MtUser::getId, userIdSet);
|
||||||
|
List<MtUser> userList = mtUserMapper.selectList(userWrapper);
|
||||||
|
for (MtUser user : userList) {
|
||||||
|
userMap.put(user.getId(), user);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
List<Map<String, Object>> content = new ArrayList<>();
|
||||||
|
for (MtTaskRecord record : recordList) {
|
||||||
|
MtTask task = taskMap.get(record.getTaskId());
|
||||||
|
MtUser user = userMap.get(record.getUserId());
|
||||||
|
|
||||||
|
Map<String, Object> item = new HashMap<>();
|
||||||
|
item.put("id", record.getId());
|
||||||
|
item.put("merchantId", record.getMerchantId());
|
||||||
|
item.put("storeId", record.getStoreId());
|
||||||
|
item.put("taskId", record.getTaskId());
|
||||||
|
item.put("taskCode", task == null ? "" : task.getTaskCode());
|
||||||
|
item.put("taskName", task == null ? "" : task.getTaskName());
|
||||||
|
item.put("taskType", task == null ? "" : task.getTaskType());
|
||||||
|
item.put("userId", record.getUserId());
|
||||||
|
item.put("userNo", user == null ? "" : user.getUserNo());
|
||||||
|
item.put("name", user == null ? "" : user.getName());
|
||||||
|
item.put("mobile", user == null ? "" : user.getMobile());
|
||||||
|
item.put("taskDate", record.getTaskDate());
|
||||||
|
item.put("completeNum", record.getCompleteNum() == null ? 0 : record.getCompleteNum());
|
||||||
|
item.put("claimNum", record.getClaimNum() == null ? 0 : record.getClaimNum());
|
||||||
|
item.put("lastCompleteTime", record.getLastCompleteTime());
|
||||||
|
item.put("lastClaimTime", record.getLastClaimTime());
|
||||||
|
item.put("createTime", record.getCreateTime());
|
||||||
|
item.put("updateTime", record.getUpdateTime());
|
||||||
|
item.put("operator", record.getOperator());
|
||||||
|
item.put("status", record.getStatus());
|
||||||
|
content.add(item);
|
||||||
|
}
|
||||||
|
|
||||||
|
PageRequest pageRequest = PageRequest.of(taskRecordPage.getPage(), taskRecordPage.getPageSize());
|
||||||
|
PageImpl pageImpl = new PageImpl(content, pageRequest, pageHelper.getTotal());
|
||||||
|
PaginationResponse<Map<String, Object>> paginationResponse = new PaginationResponse(pageImpl, Map.class);
|
||||||
|
paginationResponse.setTotalPages(pageHelper.getPages());
|
||||||
|
paginationResponse.setTotalElements(pageHelper.getTotal());
|
||||||
|
paginationResponse.setContent(content);
|
||||||
|
return paginationResponse;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@OperationServiceLog(description = "新增任务")
|
@OperationServiceLog(description = "新增任务")
|
||||||
public MtTask addTask(TaskDto taskDto) throws BusinessCheckException {
|
public MtTask addTask(TaskDto taskDto) throws BusinessCheckException {
|
||||||
@ -128,6 +302,11 @@ public class TaskServiceImpl extends ServiceImpl<MtTaskMapper, MtTask> implement
|
|||||||
|
|
||||||
mtTask.setStoreId(storeId);
|
mtTask.setStoreId(storeId);
|
||||||
mtTask.setRewardPoint(mtTask.getRewardPoint() == null ? 0 : mtTask.getRewardPoint());
|
mtTask.setRewardPoint(mtTask.getRewardPoint() == null ? 0 : mtTask.getRewardPoint());
|
||||||
|
mtTask.setRewardBalance(mtTask.getRewardBalance() == null ? BigDecimal.ZERO : mtTask.getRewardBalance());
|
||||||
|
mtTask.setPointThreshold(mtTask.getPointThreshold() == null ? 0 : mtTask.getPointThreshold());
|
||||||
|
mtTask.setBalanceThreshold(mtTask.getBalanceThreshold() == null ? BigDecimal.ZERO : mtTask.getBalanceThreshold());
|
||||||
|
mtTask.setTargetGoodsIds(normalizeGoodsIds(mtTask.getTargetGoodsIds()));
|
||||||
|
mtTask.setCompleteThreshold(mtTask.getCompleteThreshold() == null ? BigDecimal.ZERO : mtTask.getCompleteThreshold());
|
||||||
mtTask.setDailyLimit(mtTask.getDailyLimit() == null ? 1 : mtTask.getDailyLimit());
|
mtTask.setDailyLimit(mtTask.getDailyLimit() == null ? 1 : mtTask.getDailyLimit());
|
||||||
mtTask.setSort(mtTask.getSort() == null ? 0 : mtTask.getSort());
|
mtTask.setSort(mtTask.getSort() == null ? 0 : mtTask.getSort());
|
||||||
mtTask.setStatus(StringUtils.isBlank(mtTask.getStatus()) ? StatusEnum.ENABLED.getKey() : mtTask.getStatus());
|
mtTask.setStatus(StringUtils.isBlank(mtTask.getStatus()) ? StatusEnum.ENABLED.getKey() : mtTask.getStatus());
|
||||||
@ -187,6 +366,21 @@ public class TaskServiceImpl extends ServiceImpl<MtTaskMapper, MtTask> implement
|
|||||||
if (taskDto.getRewardPoint() != null) {
|
if (taskDto.getRewardPoint() != null) {
|
||||||
mtTask.setRewardPoint(taskDto.getRewardPoint());
|
mtTask.setRewardPoint(taskDto.getRewardPoint());
|
||||||
}
|
}
|
||||||
|
if (taskDto.getRewardBalance() != null) {
|
||||||
|
mtTask.setRewardBalance(taskDto.getRewardBalance());
|
||||||
|
}
|
||||||
|
if (taskDto.getPointThreshold() != null) {
|
||||||
|
mtTask.setPointThreshold(taskDto.getPointThreshold());
|
||||||
|
}
|
||||||
|
if (taskDto.getBalanceThreshold() != null) {
|
||||||
|
mtTask.setBalanceThreshold(taskDto.getBalanceThreshold());
|
||||||
|
}
|
||||||
|
if (taskDto.getTargetGoodsIds() != null) {
|
||||||
|
mtTask.setTargetGoodsIds(normalizeGoodsIds(taskDto.getTargetGoodsIds()));
|
||||||
|
}
|
||||||
|
if (taskDto.getCompleteThreshold() != null) {
|
||||||
|
mtTask.setCompleteThreshold(taskDto.getCompleteThreshold());
|
||||||
|
}
|
||||||
if (taskDto.getDailyLimit() != null) {
|
if (taskDto.getDailyLimit() != null) {
|
||||||
mtTask.setDailyLimit(taskDto.getDailyLimit());
|
mtTask.setDailyLimit(taskDto.getDailyLimit());
|
||||||
}
|
}
|
||||||
@ -258,6 +452,10 @@ public class TaskServiceImpl extends ServiceImpl<MtTaskMapper, MtTask> implement
|
|||||||
int claimNum = record == null || record.getClaimNum() == null ? 0 : record.getClaimNum();
|
int claimNum = record == null || record.getClaimNum() == null ? 0 : record.getClaimNum();
|
||||||
int dailyLimit = task.getDailyLimit() == null ? 1 : task.getDailyLimit();
|
int dailyLimit = task.getDailyLimit() == null ? 1 : task.getDailyLimit();
|
||||||
int rewardPoint = task.getRewardPoint() == null ? 0 : task.getRewardPoint();
|
int rewardPoint = task.getRewardPoint() == null ? 0 : task.getRewardPoint();
|
||||||
|
BigDecimal rewardBalance = task.getRewardBalance() == null ? BigDecimal.ZERO : task.getRewardBalance();
|
||||||
|
BigDecimal completeThreshold = task.getCompleteThreshold() == null ? BigDecimal.ZERO : task.getCompleteThreshold();
|
||||||
|
Integer pointThreshold = task.getPointThreshold() == null ? 0 : task.getPointThreshold();
|
||||||
|
BigDecimal balanceThreshold = task.getBalanceThreshold() == null ? BigDecimal.ZERO : task.getBalanceThreshold();
|
||||||
|
|
||||||
Map<String, Object> item = new HashMap<>();
|
Map<String, Object> item = new HashMap<>();
|
||||||
item.put("id", task.getId());
|
item.put("id", task.getId());
|
||||||
@ -267,6 +465,11 @@ public class TaskServiceImpl extends ServiceImpl<MtTaskMapper, MtTask> implement
|
|||||||
item.put("taskDesc", task.getTaskDesc());
|
item.put("taskDesc", task.getTaskDesc());
|
||||||
item.put("jumpUrl", task.getJumpUrl());
|
item.put("jumpUrl", task.getJumpUrl());
|
||||||
item.put("rewardPoint", rewardPoint);
|
item.put("rewardPoint", rewardPoint);
|
||||||
|
item.put("rewardBalance", rewardBalance);
|
||||||
|
item.put("pointThreshold", pointThreshold);
|
||||||
|
item.put("balanceThreshold", balanceThreshold);
|
||||||
|
item.put("targetGoodsIds", task.getTargetGoodsIds());
|
||||||
|
item.put("completeThreshold", completeThreshold);
|
||||||
item.put("dailyLimit", dailyLimit);
|
item.put("dailyLimit", dailyLimit);
|
||||||
item.put("sort", task.getSort());
|
item.put("sort", task.getSort());
|
||||||
item.put("completeNum", completeNum);
|
item.put("completeNum", completeNum);
|
||||||
@ -290,6 +493,7 @@ public class TaskServiceImpl extends ServiceImpl<MtTaskMapper, MtTask> implement
|
|||||||
String taskDate = DateUtil.getNow(DateUtil.PATTERN_ISO_DATE);
|
String taskDate = DateUtil.getNow(DateUtil.PATTERN_ISO_DATE);
|
||||||
Date nowTime = new Date();
|
Date nowTime = new Date();
|
||||||
MtTaskRecord record = getOrCreateRecord(merchantId, storeId, userId, taskId, taskDate, operator, nowTime);
|
MtTaskRecord record = getOrCreateRecord(merchantId, storeId, userId, taskId, taskDate, operator, nowTime);
|
||||||
|
validateTaskCompleteCondition(taskInfo, merchantId, storeId, userId, record, taskDate);
|
||||||
|
|
||||||
int effect = mtTaskRecordMapper.incrCompleteNum(record.getId(), dailyLimit, nowTime);
|
int effect = mtTaskRecordMapper.incrCompleteNum(record.getId(), dailyLimit, nowTime);
|
||||||
if (effect < 1) {
|
if (effect < 1) {
|
||||||
@ -308,8 +512,9 @@ public class TaskServiceImpl extends ServiceImpl<MtTaskMapper, MtTask> implement
|
|||||||
}
|
}
|
||||||
int dailyLimit = taskInfo.getDailyLimit() == null ? 1 : taskInfo.getDailyLimit();
|
int dailyLimit = taskInfo.getDailyLimit() == null ? 1 : taskInfo.getDailyLimit();
|
||||||
int rewardPoint = taskInfo.getRewardPoint() == null ? 0 : taskInfo.getRewardPoint();
|
int rewardPoint = taskInfo.getRewardPoint() == null ? 0 : taskInfo.getRewardPoint();
|
||||||
if (rewardPoint <= 0) {
|
BigDecimal rewardBalance = taskInfo.getRewardBalance() == null ? BigDecimal.ZERO : taskInfo.getRewardBalance();
|
||||||
throw new BusinessCheckException("该任务未配置奖励积分");
|
if (rewardPoint <= 0 && rewardBalance.compareTo(BigDecimal.ZERO) <= 0) {
|
||||||
|
throw new BusinessCheckException("该任务未配置奖励");
|
||||||
}
|
}
|
||||||
|
|
||||||
String taskDate = DateUtil.getNow(DateUtil.PATTERN_ISO_DATE);
|
String taskDate = DateUtil.getNow(DateUtil.PATTERN_ISO_DATE);
|
||||||
@ -363,13 +568,113 @@ public class TaskServiceImpl extends ServiceImpl<MtTaskMapper, MtTask> implement
|
|||||||
reqPointDto.setAmount(rewardPoint);
|
reqPointDto.setAmount(rewardPoint);
|
||||||
reqPointDto.setDescription("任务奖励:" + taskInfo.getTaskName() + " +" + rewardPoint + "积分");
|
reqPointDto.setDescription("任务奖励:" + taskInfo.getTaskName() + " +" + rewardPoint + "积分");
|
||||||
reqPointDto.setOperator(operator);
|
reqPointDto.setOperator(operator);
|
||||||
|
if (rewardPoint > 0) {
|
||||||
pointService.addPoint(reqPointDto);
|
pointService.addPoint(reqPointDto);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// 幂等发余额:同任务同日期同轮次固定 orderSn,只会发一次
|
||||||
|
if (rewardBalance.compareTo(BigDecimal.ZERO) > 0) {
|
||||||
|
LambdaQueryWrapper<MtBalance> balanceWrapper = Wrappers.lambdaQuery();
|
||||||
|
balanceWrapper.eq(MtBalance::getUserId, userId)
|
||||||
|
.eq(MtBalance::getOrderSn, orderSn)
|
||||||
|
.eq(MtBalance::getStatus, StatusEnum.ENABLED.getKey());
|
||||||
|
MtBalance balanceExisted = mtBalanceMapper.selectOne(balanceWrapper);
|
||||||
|
if (balanceExisted == null) {
|
||||||
|
MtBalance reqBalance = new MtBalance();
|
||||||
|
reqBalance.setUserId(userId);
|
||||||
|
reqBalance.setOrderSn(orderSn);
|
||||||
|
reqBalance.setAmount(rewardBalance);
|
||||||
|
reqBalance.setDescription("任务奖励:" + taskInfo.getTaskName() + " +" + rewardBalance + "余额");
|
||||||
|
reqBalance.setOperator(operator);
|
||||||
|
balanceService.addBalance(reqBalance, true);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
MtTaskRecord latest = mtTaskRecordMapper.selectById(record.getId());
|
MtTaskRecord latest = mtTaskRecordMapper.selectById(record.getId());
|
||||||
return buildTaskProgress(taskInfo, latest);
|
return buildTaskProgress(taskInfo, latest);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
@Transactional(rollbackFor = Exception.class)
|
||||||
|
@OperationServiceLog(description = "导入公共任务")
|
||||||
|
public Map<String, Object> importPublicTask(Integer merchantId, Integer storeId, List<Integer> taskIds, String operator) throws BusinessCheckException {
|
||||||
|
if (merchantId == null || merchantId <= 0) {
|
||||||
|
throw new BusinessCheckException("当前账号未绑定商户,无法导入");
|
||||||
|
}
|
||||||
|
if (taskIds == null || taskIds.isEmpty()) {
|
||||||
|
throw new BusinessCheckException("请选择要导入的任务");
|
||||||
|
}
|
||||||
|
|
||||||
|
Integer targetStoreId = storeId == null ? 0 : storeId;
|
||||||
|
if (targetStoreId > 0) {
|
||||||
|
MtStore mtStore = storeService.queryStoreById(targetStoreId);
|
||||||
|
if (mtStore == null || !merchantId.equals(mtStore.getMerchantId())) {
|
||||||
|
throw new BusinessCheckException("目标店铺不存在或不属于当前商户");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
List<Integer> validTaskIds = new ArrayList<>();
|
||||||
|
Set<Integer> uniqueSet = new HashSet<>();
|
||||||
|
for (Integer taskId : taskIds) {
|
||||||
|
if (taskId == null || taskId <= 0 || uniqueSet.contains(taskId)) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
uniqueSet.add(taskId);
|
||||||
|
validTaskIds.add(taskId);
|
||||||
|
}
|
||||||
|
if (validTaskIds.isEmpty()) {
|
||||||
|
throw new BusinessCheckException("请选择有效的任务");
|
||||||
|
}
|
||||||
|
|
||||||
|
LambdaQueryWrapper<MtTask> sourceWrapper = Wrappers.lambdaQuery();
|
||||||
|
sourceWrapper.eq(MtTask::getMerchantId, 0)
|
||||||
|
.eq(MtTask::getStoreId, 0)
|
||||||
|
.in(MtTask::getId, validTaskIds)
|
||||||
|
.ne(MtTask::getStatus, StatusEnum.DISABLE.getKey());
|
||||||
|
List<MtTask> sourceList = mtTaskMapper.selectList(sourceWrapper);
|
||||||
|
if (sourceList == null || sourceList.isEmpty()) {
|
||||||
|
throw new BusinessCheckException("未找到可导入的公共任务");
|
||||||
|
}
|
||||||
|
Map<Integer, MtTask> sourceMap = new HashMap<>();
|
||||||
|
for (MtTask source : sourceList) {
|
||||||
|
sourceMap.put(source.getId(), source);
|
||||||
|
}
|
||||||
|
|
||||||
|
int importedCount = 0;
|
||||||
|
int skippedCount = 0;
|
||||||
|
List<Integer> importedTaskIds = new ArrayList<>();
|
||||||
|
Date now = new Date();
|
||||||
|
for (Integer taskId : validTaskIds) {
|
||||||
|
MtTask source = sourceMap.get(taskId);
|
||||||
|
if (source == null) {
|
||||||
|
skippedCount++;
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
LambdaQueryWrapper<MtTask> existedWrapper = Wrappers.lambdaQuery();
|
||||||
|
existedWrapper.eq(MtTask::getMerchantId, merchantId)
|
||||||
|
.eq(MtTask::getStoreId, targetStoreId)
|
||||||
|
.eq(MtTask::getTaskCode, source.getTaskCode())
|
||||||
|
.ne(MtTask::getStatus, StatusEnum.DISABLE.getKey());
|
||||||
|
if (mtTaskMapper.selectCount(existedWrapper) > 0) {
|
||||||
|
skippedCount++;
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
MtTask target = copyTaskForImport(source, merchantId, targetStoreId, operator, now);
|
||||||
|
mtTaskMapper.insert(target);
|
||||||
|
importedCount++;
|
||||||
|
importedTaskIds.add(target.getId());
|
||||||
|
}
|
||||||
|
|
||||||
|
Map<String, Object> result = new HashMap<>();
|
||||||
|
result.put("importedCount", importedCount);
|
||||||
|
result.put("skippedCount", skippedCount);
|
||||||
|
result.put("importedTaskIds", importedTaskIds);
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
private MtTask queryTaskByScope(Integer merchantId, Integer storeId, Integer taskId) {
|
private MtTask queryTaskByScope(Integer merchantId, Integer storeId, Integer taskId) {
|
||||||
LambdaQueryWrapper<MtTask> wrapper = Wrappers.lambdaQuery();
|
LambdaQueryWrapper<MtTask> wrapper = Wrappers.lambdaQuery();
|
||||||
wrapper.eq(MtTask::getId, taskId)
|
wrapper.eq(MtTask::getId, taskId)
|
||||||
@ -381,6 +686,17 @@ public class TaskServiceImpl extends ServiceImpl<MtTaskMapper, MtTask> implement
|
|||||||
return mtTaskMapper.selectOne(wrapper);
|
return mtTaskMapper.selectOne(wrapper);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private PaginationResponse<Map<String, Object>> emptyTaskRecordPage(TaskRecordPage taskRecordPage) {
|
||||||
|
List<Map<String, Object>> content = new ArrayList<>();
|
||||||
|
PageRequest pageRequest = PageRequest.of(taskRecordPage.getPage(), taskRecordPage.getPageSize());
|
||||||
|
PageImpl pageImpl = new PageImpl(content, pageRequest, 0);
|
||||||
|
PaginationResponse<Map<String, Object>> paginationResponse = new PaginationResponse(pageImpl, Map.class);
|
||||||
|
paginationResponse.setTotalPages(0);
|
||||||
|
paginationResponse.setTotalElements(0);
|
||||||
|
paginationResponse.setContent(content);
|
||||||
|
return paginationResponse;
|
||||||
|
}
|
||||||
|
|
||||||
private MtTaskRecord getOrCreateRecord(Integer merchantId, Integer storeId, Integer userId, Integer taskId, String taskDate, String operator, Date nowTime) {
|
private MtTaskRecord getOrCreateRecord(Integer merchantId, Integer storeId, Integer userId, Integer taskId, String taskDate, String operator, Date nowTime) {
|
||||||
LambdaQueryWrapper<MtTaskRecord> wrapper = Wrappers.lambdaQuery();
|
LambdaQueryWrapper<MtTaskRecord> wrapper = Wrappers.lambdaQuery();
|
||||||
wrapper.eq(MtTaskRecord::getMerchantId, merchantId)
|
wrapper.eq(MtTaskRecord::getMerchantId, merchantId)
|
||||||
@ -432,4 +748,161 @@ public class TaskServiceImpl extends ServiceImpl<MtTaskMapper, MtTask> implement
|
|||||||
result.put("finished", claimNum >= dailyLimit);
|
result.put("finished", claimNum >= dailyLimit);
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void validateTaskCompleteCondition(MtTask taskInfo,
|
||||||
|
Integer merchantId,
|
||||||
|
Integer storeId,
|
||||||
|
Integer userId,
|
||||||
|
MtTaskRecord record,
|
||||||
|
String taskDate) throws BusinessCheckException {
|
||||||
|
if (taskInfo == null) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
String taskCode = taskInfo.getTaskCode() == null ? "" : taskInfo.getTaskCode();
|
||||||
|
String taskType = taskInfo.getTaskType() == null ? "" : taskInfo.getTaskType();
|
||||||
|
if ("ORDER".equals(taskType) || TASK_CODE_ORDER_COMPLETE_BY_AMOUNT.equals(taskCode)) {
|
||||||
|
validateOrderTask(taskInfo, merchantId, storeId, userId, record, taskDate);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if ("LOOK".equals(taskType) || TASK_CODE_LOOK_PUBLISH_BY_LIKE.equals(taskCode)) {
|
||||||
|
validateLookLikeTask(taskInfo, merchantId, storeId, userId, record, taskDate);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void validateOrderTask(MtTask taskInfo,
|
||||||
|
Integer merchantId,
|
||||||
|
Integer storeId,
|
||||||
|
Integer userId,
|
||||||
|
MtTaskRecord record,
|
||||||
|
String taskDate) throws BusinessCheckException {
|
||||||
|
Integer pointThreshold = taskInfo.getPointThreshold() == null ? 0 : taskInfo.getPointThreshold();
|
||||||
|
BigDecimal balanceThreshold = taskInfo.getBalanceThreshold() == null ? BigDecimal.ZERO : taskInfo.getBalanceThreshold();
|
||||||
|
List<Integer> goodsIdList = parseGoodsIds(taskInfo.getTargetGoodsIds());
|
||||||
|
|
||||||
|
Integer pointThresholdFilter = pointThreshold > 0 ? pointThreshold : null;
|
||||||
|
BigDecimal balanceThresholdFilter = balanceThreshold.compareTo(BigDecimal.ZERO) > 0 ? balanceThreshold : null;
|
||||||
|
Date startTime = getDateStart(taskDate);
|
||||||
|
Date endTime = getDateEnd(taskDate);
|
||||||
|
|
||||||
|
Integer matchNum = mtOrderMapper.countCompleteTaskOrder(merchantId, storeId, userId, startTime, endTime,
|
||||||
|
pointThresholdFilter, balanceThresholdFilter, goodsIdList);
|
||||||
|
int completeNum = record == null || record.getCompleteNum() == null ? 0 : record.getCompleteNum();
|
||||||
|
if (matchNum == null || matchNum <= completeNum) {
|
||||||
|
throw new BusinessCheckException("未达到完成条件:今日订单未满足阈值或指定商品条件");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void validateLookLikeTask(MtTask taskInfo,
|
||||||
|
Integer merchantId,
|
||||||
|
Integer storeId,
|
||||||
|
Integer userId,
|
||||||
|
MtTaskRecord record,
|
||||||
|
String taskDate) throws BusinessCheckException {
|
||||||
|
BigDecimal threshold = taskInfo.getCompleteThreshold() == null ? BigDecimal.ZERO : taskInfo.getCompleteThreshold();
|
||||||
|
if (threshold.compareTo(BigDecimal.ZERO) <= 0) {
|
||||||
|
throw new BusinessCheckException("请先配置作品点赞阈值");
|
||||||
|
}
|
||||||
|
int thresholdLike = threshold.intValue();
|
||||||
|
Date startTime = getDateStart(taskDate);
|
||||||
|
Date endTime = getDateEnd(taskDate);
|
||||||
|
|
||||||
|
LambdaQueryWrapper<MtLookWork> wrapper = Wrappers.lambdaQuery();
|
||||||
|
wrapper.eq(MtLookWork::getMerchantId, merchantId)
|
||||||
|
.eq(MtLookWork::getUserId, userId)
|
||||||
|
.eq(MtLookWork::getStatus, StatusEnum.ENABLED.getKey())
|
||||||
|
.ge(MtLookWork::getCreateTime, startTime)
|
||||||
|
.lt(MtLookWork::getCreateTime, endTime)
|
||||||
|
.ge(MtLookWork::getLikeNum, thresholdLike);
|
||||||
|
if (storeId != null && storeId > 0) {
|
||||||
|
wrapper.and(wq -> wq.eq(MtLookWork::getStoreId, 0).or().eq(MtLookWork::getStoreId, storeId));
|
||||||
|
}
|
||||||
|
Integer matchNum = mtLookWorkMapper.selectCount(wrapper);
|
||||||
|
int completeNum = record == null || record.getCompleteNum() == null ? 0 : record.getCompleteNum();
|
||||||
|
if (matchNum == null || matchNum <= completeNum) {
|
||||||
|
throw new BusinessCheckException("未达到完成条件:今日发布作品点赞数不足");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private Date getDateStart(String taskDate) {
|
||||||
|
Date date;
|
||||||
|
try {
|
||||||
|
date = DateUtil.parseDate(taskDate, DateUtil.PATTERN_ISO_DATE);
|
||||||
|
} catch (Exception e) {
|
||||||
|
date = new Date();
|
||||||
|
}
|
||||||
|
Calendar calendar = Calendar.getInstance();
|
||||||
|
calendar.setTime(date);
|
||||||
|
calendar.set(Calendar.HOUR_OF_DAY, 0);
|
||||||
|
calendar.set(Calendar.MINUTE, 0);
|
||||||
|
calendar.set(Calendar.SECOND, 0);
|
||||||
|
calendar.set(Calendar.MILLISECOND, 0);
|
||||||
|
return calendar.getTime();
|
||||||
|
}
|
||||||
|
|
||||||
|
private Date getDateEnd(String taskDate) {
|
||||||
|
Calendar calendar = Calendar.getInstance();
|
||||||
|
calendar.setTime(getDateStart(taskDate));
|
||||||
|
calendar.add(Calendar.DAY_OF_MONTH, 1);
|
||||||
|
return calendar.getTime();
|
||||||
|
}
|
||||||
|
|
||||||
|
private MtTask copyTaskForImport(MtTask source, Integer merchantId, Integer storeId, String operator, Date now) {
|
||||||
|
MtTask target = new MtTask();
|
||||||
|
target.setMerchantId(merchantId);
|
||||||
|
target.setStoreId(storeId == null ? 0 : storeId);
|
||||||
|
target.setTaskCode(source.getTaskCode());
|
||||||
|
target.setTaskName(source.getTaskName());
|
||||||
|
target.setTaskType(source.getTaskType());
|
||||||
|
target.setTaskDesc(source.getTaskDesc());
|
||||||
|
target.setJumpUrl(source.getJumpUrl());
|
||||||
|
target.setRewardPoint(source.getRewardPoint() == null ? 0 : source.getRewardPoint());
|
||||||
|
target.setRewardBalance(source.getRewardBalance() == null ? BigDecimal.ZERO : source.getRewardBalance());
|
||||||
|
target.setPointThreshold(source.getPointThreshold() == null ? 0 : source.getPointThreshold());
|
||||||
|
target.setBalanceThreshold(source.getBalanceThreshold() == null ? BigDecimal.ZERO : source.getBalanceThreshold());
|
||||||
|
target.setTargetGoodsIds(normalizeGoodsIds(source.getTargetGoodsIds()));
|
||||||
|
target.setCompleteThreshold(source.getCompleteThreshold() == null ? BigDecimal.ZERO : source.getCompleteThreshold());
|
||||||
|
target.setDailyLimit(source.getDailyLimit() == null ? 1 : source.getDailyLimit());
|
||||||
|
target.setSort(source.getSort() == null ? 0 : source.getSort());
|
||||||
|
target.setOperator(operator);
|
||||||
|
target.setStatus(StringUtils.isBlank(source.getStatus()) ? StatusEnum.ENABLED.getKey() : source.getStatus());
|
||||||
|
target.setCreateTime(now);
|
||||||
|
target.setUpdateTime(now);
|
||||||
|
return target;
|
||||||
|
}
|
||||||
|
|
||||||
|
private String normalizeGoodsIds(String goodsIds) {
|
||||||
|
List<Integer> goodsIdList = parseGoodsIds(goodsIds);
|
||||||
|
if (goodsIdList.isEmpty()) {
|
||||||
|
return "";
|
||||||
|
}
|
||||||
|
List<String> result = new ArrayList<>();
|
||||||
|
for (Integer goodsId : goodsIdList) {
|
||||||
|
result.add(String.valueOf(goodsId));
|
||||||
|
}
|
||||||
|
return String.join(",", result);
|
||||||
|
}
|
||||||
|
|
||||||
|
private List<Integer> parseGoodsIds(String goodsIds) {
|
||||||
|
List<Integer> result = new ArrayList<>();
|
||||||
|
if (StringUtils.isBlank(goodsIds)) {
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
String[] parts = goodsIds.split("[,,]");
|
||||||
|
Set<Integer> uniqueSet = new HashSet<>();
|
||||||
|
for (String part : parts) {
|
||||||
|
if (StringUtils.isBlank(part)) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
String value = part.trim();
|
||||||
|
if (!value.matches("\\d+")) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
Integer goodsId = Integer.parseInt(value);
|
||||||
|
if (goodsId > 0 && !uniqueSet.contains(goodsId)) {
|
||||||
|
uniqueSet.add(goodsId);
|
||||||
|
result.add(goodsId);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return result;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -0,0 +1,91 @@
|
|||||||
|
package com.fuint.module.backendApi.controller;
|
||||||
|
|
||||||
|
import com.fuint.common.dto.AccountInfo;
|
||||||
|
import com.fuint.common.param.LookWorkPage;
|
||||||
|
import com.fuint.common.service.LookService;
|
||||||
|
import com.fuint.common.util.TokenUtil;
|
||||||
|
import com.fuint.framework.exception.BusinessCheckException;
|
||||||
|
import com.fuint.framework.pagination.PaginationResponse;
|
||||||
|
import com.fuint.framework.web.BaseController;
|
||||||
|
import com.fuint.framework.web.ResponseObject;
|
||||||
|
import io.swagger.annotations.Api;
|
||||||
|
import io.swagger.annotations.ApiOperation;
|
||||||
|
import lombok.AllArgsConstructor;
|
||||||
|
import org.springframework.security.access.prepost.PreAuthorize;
|
||||||
|
import org.springframework.web.bind.annotation.CrossOrigin;
|
||||||
|
import org.springframework.web.bind.annotation.ModelAttribute;
|
||||||
|
import org.springframework.web.bind.annotation.PathVariable;
|
||||||
|
import org.springframework.web.bind.annotation.RequestBody;
|
||||||
|
import org.springframework.web.bind.annotation.RequestMapping;
|
||||||
|
import org.springframework.web.bind.annotation.RequestMethod;
|
||||||
|
import org.springframework.web.bind.annotation.RestController;
|
||||||
|
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 看看作品管理 controller
|
||||||
|
*
|
||||||
|
* Created by Codex
|
||||||
|
*/
|
||||||
|
@Api(tags = "管理端-看看作品相关接口")
|
||||||
|
@RestController
|
||||||
|
@AllArgsConstructor
|
||||||
|
@RequestMapping(value = "/backendApi/look")
|
||||||
|
public class BackendLookController extends BaseController {
|
||||||
|
|
||||||
|
private LookService lookService;
|
||||||
|
|
||||||
|
@ApiOperation(value = "作品列表查询")
|
||||||
|
@RequestMapping(value = "/list", method = RequestMethod.GET)
|
||||||
|
@CrossOrigin
|
||||||
|
@PreAuthorize("@pms.hasPermission('content:look:index')")
|
||||||
|
public ResponseObject list(@ModelAttribute LookWorkPage page) throws BusinessCheckException {
|
||||||
|
AccountInfo accountInfo = TokenUtil.getAccountInfo();
|
||||||
|
if (accountInfo.getMerchantId() != null && accountInfo.getMerchantId() > 0) {
|
||||||
|
page.setMerchantId(accountInfo.getMerchantId());
|
||||||
|
}
|
||||||
|
if (accountInfo.getStoreId() != null && accountInfo.getStoreId() > 0) {
|
||||||
|
page.setStoreId(accountInfo.getStoreId());
|
||||||
|
}
|
||||||
|
|
||||||
|
PaginationResponse<Map<String, Object>> paginationResponse = lookService.queryWorkListForAdmin(page);
|
||||||
|
Map<String, Object> result = new HashMap<>();
|
||||||
|
result.put("dataList", paginationResponse);
|
||||||
|
return getSuccessResult(result);
|
||||||
|
}
|
||||||
|
|
||||||
|
@ApiOperation(value = "作品详情")
|
||||||
|
@RequestMapping(value = "/info/{id}", method = RequestMethod.GET)
|
||||||
|
@CrossOrigin
|
||||||
|
@PreAuthorize("@pms.hasPermission('content:look:index')")
|
||||||
|
public ResponseObject info(@PathVariable("id") Integer id) throws BusinessCheckException {
|
||||||
|
AccountInfo accountInfo = TokenUtil.getAccountInfo();
|
||||||
|
Map<String, Object> workInfo = lookService.getWorkDetailForAdmin(id);
|
||||||
|
|
||||||
|
Integer merchantId = workInfo.get("merchantId") == null ? 0 : Integer.parseInt(workInfo.get("merchantId").toString());
|
||||||
|
if (accountInfo.getMerchantId() != null && accountInfo.getMerchantId() > 0 && !accountInfo.getMerchantId().equals(merchantId)) {
|
||||||
|
return getFailureResult(1004);
|
||||||
|
}
|
||||||
|
|
||||||
|
Map<String, Object> result = new HashMap<>();
|
||||||
|
result.put("workInfo", workInfo);
|
||||||
|
return getSuccessResult(result);
|
||||||
|
}
|
||||||
|
|
||||||
|
@ApiOperation(value = "更新作品状态")
|
||||||
|
@RequestMapping(value = "/updateStatus", method = RequestMethod.POST)
|
||||||
|
@CrossOrigin
|
||||||
|
@PreAuthorize("@pms.hasPermission('content:look:edit')")
|
||||||
|
public ResponseObject updateStatus(@RequestBody Map<String, Object> params) throws BusinessCheckException {
|
||||||
|
Integer id = params.get("id") == null ? 0 : Integer.parseInt(params.get("id").toString());
|
||||||
|
String status = params.get("status") == null ? "A" : params.get("status").toString();
|
||||||
|
if (id <= 0) {
|
||||||
|
return getFailureResult(201, "作品ID不能为空");
|
||||||
|
}
|
||||||
|
|
||||||
|
AccountInfo accountInfo = TokenUtil.getAccountInfo();
|
||||||
|
lookService.updateWorkStatus(id, status, accountInfo.getAccountName(), accountInfo.getMerchantId());
|
||||||
|
return getSuccessResult(true);
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -4,6 +4,7 @@ import com.fuint.common.dto.AccountInfo;
|
|||||||
import com.fuint.common.dto.TaskDto;
|
import com.fuint.common.dto.TaskDto;
|
||||||
import com.fuint.common.enums.StatusEnum;
|
import com.fuint.common.enums.StatusEnum;
|
||||||
import com.fuint.common.param.TaskPage;
|
import com.fuint.common.param.TaskPage;
|
||||||
|
import com.fuint.common.param.TaskRecordPage;
|
||||||
import com.fuint.common.service.StoreService;
|
import com.fuint.common.service.StoreService;
|
||||||
import com.fuint.common.service.TaskService;
|
import com.fuint.common.service.TaskService;
|
||||||
import com.fuint.common.util.TokenUtil;
|
import com.fuint.common.util.TokenUtil;
|
||||||
@ -20,6 +21,7 @@ import org.springframework.security.access.prepost.PreAuthorize;
|
|||||||
import org.springframework.web.bind.annotation.*;
|
import org.springframework.web.bind.annotation.*;
|
||||||
|
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
@ -61,6 +63,39 @@ public class BackendTaskController extends BaseController {
|
|||||||
return getSuccessResult(result);
|
return getSuccessResult(result);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ApiOperation(value = "公共任务列表查询")
|
||||||
|
@RequestMapping(value = "/publicList", method = RequestMethod.GET)
|
||||||
|
@CrossOrigin
|
||||||
|
@PreAuthorize("@pms.hasPermission('content:task:index')")
|
||||||
|
public ResponseObject publicList(@ModelAttribute TaskPage taskPage) throws BusinessCheckException {
|
||||||
|
taskPage.setMerchantId(0);
|
||||||
|
taskPage.setStoreId(0);
|
||||||
|
PaginationResponse<MtTask> paginationResponse = taskService.queryTaskListByPagination(taskPage);
|
||||||
|
|
||||||
|
Map<String, Object> result = new HashMap<>();
|
||||||
|
result.put("dataList", paginationResponse);
|
||||||
|
return getSuccessResult(result);
|
||||||
|
}
|
||||||
|
|
||||||
|
@ApiOperation(value = "任务完成记录列表查询")
|
||||||
|
@RequestMapping(value = "/recordList", method = RequestMethod.GET)
|
||||||
|
@CrossOrigin
|
||||||
|
@PreAuthorize("@pms.hasPermission('content:task:index')")
|
||||||
|
public ResponseObject recordList(@ModelAttribute TaskRecordPage taskRecordPage) throws BusinessCheckException {
|
||||||
|
AccountInfo accountInfo = TokenUtil.getAccountInfo();
|
||||||
|
if (accountInfo.getMerchantId() != null && accountInfo.getMerchantId() > 0) {
|
||||||
|
taskRecordPage.setMerchantId(accountInfo.getMerchantId());
|
||||||
|
}
|
||||||
|
if (accountInfo.getStoreId() != null && accountInfo.getStoreId() > 0) {
|
||||||
|
taskRecordPage.setStoreId(accountInfo.getStoreId());
|
||||||
|
}
|
||||||
|
|
||||||
|
PaginationResponse<Map<String, Object>> paginationResponse = taskService.queryTaskRecordListByPagination(taskRecordPage);
|
||||||
|
Map<String, Object> result = new HashMap<>();
|
||||||
|
result.put("dataList", paginationResponse);
|
||||||
|
return getSuccessResult(result);
|
||||||
|
}
|
||||||
|
|
||||||
@ApiOperation(value = "获取任务详情")
|
@ApiOperation(value = "获取任务详情")
|
||||||
@RequestMapping(value = "/info/{id}", method = RequestMethod.GET)
|
@RequestMapping(value = "/info/{id}", method = RequestMethod.GET)
|
||||||
@CrossOrigin
|
@CrossOrigin
|
||||||
@ -125,4 +160,36 @@ public class BackendTaskController extends BaseController {
|
|||||||
|
|
||||||
return getSuccessResult(true);
|
return getSuccessResult(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ApiOperation(value = "导入公共任务")
|
||||||
|
@RequestMapping(value = "/importPublic", method = RequestMethod.POST)
|
||||||
|
@CrossOrigin
|
||||||
|
@PreAuthorize("@pms.hasPermission('content:task:add')")
|
||||||
|
public ResponseObject importPublic(@RequestBody Map<String, Object> params) throws BusinessCheckException {
|
||||||
|
AccountInfo accountInfo = TokenUtil.getAccountInfo();
|
||||||
|
Integer merchantId = accountInfo.getMerchantId();
|
||||||
|
if (merchantId == null || merchantId <= 0) {
|
||||||
|
throw new BusinessCheckException("当前账号未绑定商户,无法导入");
|
||||||
|
}
|
||||||
|
|
||||||
|
Integer storeId = accountInfo.getStoreId() == null ? 0 : accountInfo.getStoreId();
|
||||||
|
if (storeId <= 0 && params.get("storeId") != null) {
|
||||||
|
storeId = Integer.parseInt(params.get("storeId").toString());
|
||||||
|
}
|
||||||
|
|
||||||
|
List<Integer> taskIds = new ArrayList<>();
|
||||||
|
Object taskIdsObj = params.get("taskIds");
|
||||||
|
if (taskIdsObj instanceof List) {
|
||||||
|
List<?> sourceList = (List<?>) taskIdsObj;
|
||||||
|
for (Object item : sourceList) {
|
||||||
|
if (item == null) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
taskIds.add(Integer.parseInt(item.toString()));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Map<String, Object> importResult = taskService.importPublicTask(merchantId, storeId, taskIds, accountInfo.getAccountName());
|
||||||
|
return getSuccessResult(importResult);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -201,6 +201,7 @@ public class ClientBookController extends BaseController {
|
|||||||
MtBookItem update = new MtBookItem();
|
MtBookItem update = new MtBookItem();
|
||||||
update.setId(bookItemId);
|
update.setId(bookItemId);
|
||||||
update.setCheckinStartTime(new java.util.Date());
|
update.setCheckinStartTime(new java.util.Date());
|
||||||
|
update.setStatus(BookStatusEnum.CONFIRM.getKey());
|
||||||
update.setOperator(loginInfo.getId().toString());
|
update.setOperator(loginInfo.getId().toString());
|
||||||
|
|
||||||
bookItemService.updateBookItem(update);
|
bookItemService.updateBookItem(update);
|
||||||
@ -239,11 +240,20 @@ public class ClientBookController extends BaseController {
|
|||||||
update.setId(bookItemId);
|
update.setId(bookItemId);
|
||||||
update.setCheckinEndTime(endTime);
|
update.setCheckinEndTime(endTime);
|
||||||
update.setCheckinDurationHours(hours);
|
update.setCheckinDurationHours(hours);
|
||||||
|
boolean isZeroDuration = hours == null || hours.compareTo(BigDecimal.ZERO) <= 0;
|
||||||
|
update.setStatus(isZeroDuration ? BookStatusEnum.COMPLETE.getKey() : BookStatusEnum.WAIT_PAY.getKey());
|
||||||
update.setOperator(loginInfo.getId().toString());
|
update.setOperator(loginInfo.getId().toString());
|
||||||
bookItemService.updateBookItem(update);
|
bookItemService.updateBookItem(update);
|
||||||
|
if (isZeroDuration && bookItem.getOrderId() != null && bookItem.getOrderId() > 0) {
|
||||||
|
OrderDto orderDto = new OrderDto();
|
||||||
|
orderDto.setId(bookItem.getOrderId());
|
||||||
|
orderDto.setStatus(OrderStatusEnum.COMPLETE.getKey());
|
||||||
|
orderService.updateOrder(orderDto);
|
||||||
|
}
|
||||||
Map<String, Object> result = new HashMap<>();
|
Map<String, Object> result = new HashMap<>();
|
||||||
result.put("checkinEndTime", endTime);
|
result.put("checkinEndTime", endTime);
|
||||||
result.put("checkinDurationHours", hours);
|
result.put("checkinDurationHours", hours);
|
||||||
|
result.put("status", update.getStatus());
|
||||||
return getSuccessResult(result);
|
return getSuccessResult(result);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -0,0 +1,235 @@
|
|||||||
|
package com.fuint.module.clientApi.controller;
|
||||||
|
|
||||||
|
import com.fuint.common.dto.UserInfo;
|
||||||
|
import com.fuint.common.service.LookService;
|
||||||
|
import com.fuint.common.service.MerchantService;
|
||||||
|
import com.fuint.common.util.TokenUtil;
|
||||||
|
import com.fuint.framework.exception.BusinessCheckException;
|
||||||
|
import com.fuint.framework.pagination.PaginationResponse;
|
||||||
|
import com.fuint.framework.web.BaseController;
|
||||||
|
import com.fuint.framework.web.ResponseObject;
|
||||||
|
import com.fuint.repository.model.MtLookWork;
|
||||||
|
import com.fuint.utils.StringUtil;
|
||||||
|
import io.swagger.annotations.Api;
|
||||||
|
import io.swagger.annotations.ApiOperation;
|
||||||
|
import lombok.AllArgsConstructor;
|
||||||
|
import org.springframework.web.bind.annotation.CrossOrigin;
|
||||||
|
import org.springframework.web.bind.annotation.RequestBody;
|
||||||
|
import org.springframework.web.bind.annotation.RequestMapping;
|
||||||
|
import org.springframework.web.bind.annotation.RequestMethod;
|
||||||
|
import org.springframework.web.bind.annotation.RestController;
|
||||||
|
|
||||||
|
import javax.servlet.http.HttpServletRequest;
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 看看功能会员端 controller
|
||||||
|
*
|
||||||
|
* Created by Codex
|
||||||
|
*/
|
||||||
|
@Api(tags = "会员端-看看作品相关接口")
|
||||||
|
@RestController
|
||||||
|
@AllArgsConstructor
|
||||||
|
@RequestMapping(value = "/clientApi/look")
|
||||||
|
public class ClientLookController extends BaseController {
|
||||||
|
|
||||||
|
private LookService lookService;
|
||||||
|
|
||||||
|
private MerchantService merchantService;
|
||||||
|
|
||||||
|
@ApiOperation(value = "看看作品列表")
|
||||||
|
@RequestMapping(value = "/list", method = RequestMethod.POST)
|
||||||
|
@CrossOrigin
|
||||||
|
public ResponseObject list(HttpServletRequest request, @RequestBody Map<String, Object> params) throws BusinessCheckException {
|
||||||
|
String merchantNo = request.getHeader("merchantNo") == null ? "" : request.getHeader("merchantNo");
|
||||||
|
Integer storeId = StringUtil.isEmpty(request.getHeader("storeId")) ? 0 : Integer.parseInt(request.getHeader("storeId"));
|
||||||
|
Integer merchantId = merchantService.getMerchantId(merchantNo);
|
||||||
|
if (merchantId <= 0) {
|
||||||
|
return getFailureResult(201, "商户信息异常");
|
||||||
|
}
|
||||||
|
|
||||||
|
Integer page = params.get("page") == null ? 1 : Integer.parseInt(params.get("page").toString());
|
||||||
|
Integer pageSize = params.get("pageSize") == null ? 10 : Integer.parseInt(params.get("pageSize").toString());
|
||||||
|
String mineFlag = params.get("mine") == null ? "0" : params.get("mine").toString();
|
||||||
|
Boolean mine = "1".equals(mineFlag) || "true".equalsIgnoreCase(mineFlag);
|
||||||
|
|
||||||
|
UserInfo loginInfo = TokenUtil.getUserInfo();
|
||||||
|
Integer userId = loginInfo == null ? 0 : loginInfo.getId();
|
||||||
|
if (mine && userId <= 0) {
|
||||||
|
return getFailureResult(1001);
|
||||||
|
}
|
||||||
|
|
||||||
|
PaginationResponse<Map<String, Object>> paginationResponse = lookService.queryWorkListForClient(
|
||||||
|
merchantId,
|
||||||
|
storeId,
|
||||||
|
userId,
|
||||||
|
page,
|
||||||
|
pageSize,
|
||||||
|
mine
|
||||||
|
);
|
||||||
|
|
||||||
|
Map<String, Object> result = new HashMap<>();
|
||||||
|
result.put("content", paginationResponse.getContent());
|
||||||
|
result.put("pageSize", paginationResponse.getPageSize());
|
||||||
|
result.put("pageNumber", paginationResponse.getCurrentPage());
|
||||||
|
result.put("totalRow", paginationResponse.getTotalElements());
|
||||||
|
result.put("totalPage", paginationResponse.getTotalPages());
|
||||||
|
return getSuccessResult(result);
|
||||||
|
}
|
||||||
|
|
||||||
|
@ApiOperation(value = "看看作品详情")
|
||||||
|
@RequestMapping(value = "/detail", method = RequestMethod.POST)
|
||||||
|
@CrossOrigin
|
||||||
|
public ResponseObject detail(@RequestBody Map<String, Object> params) throws BusinessCheckException {
|
||||||
|
Integer workId = params.get("workId") == null ? 0 : Integer.parseInt(params.get("workId").toString());
|
||||||
|
if (workId <= 0) {
|
||||||
|
return getFailureResult(201, "作品ID不能为空");
|
||||||
|
}
|
||||||
|
|
||||||
|
UserInfo loginInfo = TokenUtil.getUserInfo();
|
||||||
|
Integer userId = loginInfo == null ? 0 : loginInfo.getId();
|
||||||
|
Map<String, Object> workInfo = lookService.getWorkDetail(workId, userId);
|
||||||
|
|
||||||
|
Map<String, Object> result = new HashMap<>();
|
||||||
|
result.put("workInfo", workInfo);
|
||||||
|
return getSuccessResult(result);
|
||||||
|
}
|
||||||
|
|
||||||
|
@ApiOperation(value = "发布作品")
|
||||||
|
@RequestMapping(value = "/save", method = RequestMethod.POST)
|
||||||
|
@CrossOrigin
|
||||||
|
public ResponseObject save(HttpServletRequest request, @RequestBody Map<String, Object> params) throws BusinessCheckException {
|
||||||
|
UserInfo loginInfo = TokenUtil.getUserInfo();
|
||||||
|
if (loginInfo == null) {
|
||||||
|
return getFailureResult(1001);
|
||||||
|
}
|
||||||
|
String merchantNo = request.getHeader("merchantNo") == null ? "" : request.getHeader("merchantNo");
|
||||||
|
Integer storeId = StringUtil.isEmpty(request.getHeader("storeId")) ? 0 : Integer.parseInt(request.getHeader("storeId"));
|
||||||
|
Integer merchantId = merchantService.getMerchantId(merchantNo);
|
||||||
|
if (merchantId <= 0) {
|
||||||
|
return getFailureResult(201, "商户信息异常");
|
||||||
|
}
|
||||||
|
|
||||||
|
String title = params.get("title") == null ? "" : params.get("title").toString();
|
||||||
|
String desc = params.get("desc") == null ? "" : params.get("desc").toString();
|
||||||
|
List<String> images = new ArrayList<>();
|
||||||
|
if (params.get("images") instanceof List) {
|
||||||
|
images = (List<String>) params.get("images");
|
||||||
|
}
|
||||||
|
|
||||||
|
MtLookWork work = lookService.saveWork(merchantId, storeId, loginInfo.getId(), title, desc, images, String.valueOf(loginInfo.getId()));
|
||||||
|
Map<String, Object> result = new HashMap<>();
|
||||||
|
result.put("id", work.getId());
|
||||||
|
return getSuccessResult(result);
|
||||||
|
}
|
||||||
|
|
||||||
|
@ApiOperation(value = "删除我的作品")
|
||||||
|
@RequestMapping(value = "/remove", method = RequestMethod.POST)
|
||||||
|
@CrossOrigin
|
||||||
|
public ResponseObject remove(@RequestBody Map<String, Object> params) throws BusinessCheckException {
|
||||||
|
UserInfo loginInfo = TokenUtil.getUserInfo();
|
||||||
|
if (loginInfo == null) {
|
||||||
|
return getFailureResult(1001);
|
||||||
|
}
|
||||||
|
Integer workId = params.get("workId") == null ? 0 : Integer.parseInt(params.get("workId").toString());
|
||||||
|
if (workId <= 0) {
|
||||||
|
return getFailureResult(201, "作品ID不能为空");
|
||||||
|
}
|
||||||
|
lookService.removeWork(workId, loginInfo.getId(), String.valueOf(loginInfo.getId()));
|
||||||
|
return getSuccessResult(true);
|
||||||
|
}
|
||||||
|
|
||||||
|
@ApiOperation(value = "评论列表")
|
||||||
|
@RequestMapping(value = "/commentList", method = RequestMethod.POST)
|
||||||
|
@CrossOrigin
|
||||||
|
public ResponseObject commentList(@RequestBody Map<String, Object> params) throws BusinessCheckException {
|
||||||
|
Integer workId = params.get("workId") == null ? 0 : Integer.parseInt(params.get("workId").toString());
|
||||||
|
Integer page = params.get("page") == null ? 1 : Integer.parseInt(params.get("page").toString());
|
||||||
|
Integer pageSize = params.get("pageSize") == null ? 20 : Integer.parseInt(params.get("pageSize").toString());
|
||||||
|
if (workId <= 0) {
|
||||||
|
return getFailureResult(201, "作品ID不能为空");
|
||||||
|
}
|
||||||
|
|
||||||
|
UserInfo loginInfo = TokenUtil.getUserInfo();
|
||||||
|
Integer userId = loginInfo == null ? 0 : loginInfo.getId();
|
||||||
|
|
||||||
|
PaginationResponse<Map<String, Object>> paginationResponse = lookService.queryCommentList(workId, page, pageSize, userId);
|
||||||
|
Map<String, Object> result = new HashMap<>();
|
||||||
|
result.put("content", paginationResponse.getContent());
|
||||||
|
result.put("pageSize", paginationResponse.getPageSize());
|
||||||
|
result.put("pageNumber", paginationResponse.getCurrentPage());
|
||||||
|
result.put("totalRow", paginationResponse.getTotalElements());
|
||||||
|
result.put("totalPage", paginationResponse.getTotalPages());
|
||||||
|
return getSuccessResult(result);
|
||||||
|
}
|
||||||
|
|
||||||
|
@ApiOperation(value = "发布评论")
|
||||||
|
@RequestMapping(value = "/commentSave", method = RequestMethod.POST)
|
||||||
|
@CrossOrigin
|
||||||
|
public ResponseObject commentSave(@RequestBody Map<String, Object> params) throws BusinessCheckException {
|
||||||
|
UserInfo loginInfo = TokenUtil.getUserInfo();
|
||||||
|
if (loginInfo == null) {
|
||||||
|
return getFailureResult(1001);
|
||||||
|
}
|
||||||
|
|
||||||
|
Integer workId = params.get("workId") == null ? 0 : Integer.parseInt(params.get("workId").toString());
|
||||||
|
String content = params.get("content") == null ? "" : params.get("content").toString();
|
||||||
|
List<String> images = new ArrayList<>();
|
||||||
|
if (params.get("images") instanceof List) {
|
||||||
|
images = (List<String>) params.get("images");
|
||||||
|
}
|
||||||
|
if (workId <= 0) {
|
||||||
|
return getFailureResult(201, "作品ID不能为空");
|
||||||
|
}
|
||||||
|
|
||||||
|
Map<String, Object> commentInfo = lookService.saveComment(workId, loginInfo.getId(), content, images, String.valueOf(loginInfo.getId()));
|
||||||
|
Map<String, Object> result = new HashMap<>();
|
||||||
|
result.put("commentInfo", commentInfo);
|
||||||
|
return getSuccessResult(result);
|
||||||
|
}
|
||||||
|
|
||||||
|
@ApiOperation(value = "作品点赞/取消点赞")
|
||||||
|
@RequestMapping(value = "/toggleLike", method = RequestMethod.POST)
|
||||||
|
@CrossOrigin
|
||||||
|
public ResponseObject toggleLike(HttpServletRequest request, @RequestBody Map<String, Object> params) throws BusinessCheckException {
|
||||||
|
UserInfo loginInfo = TokenUtil.getUserInfo();
|
||||||
|
if (loginInfo == null) {
|
||||||
|
return getFailureResult(1001);
|
||||||
|
}
|
||||||
|
Integer workId = params.get("workId") == null ? 0 : Integer.parseInt(params.get("workId").toString());
|
||||||
|
if (workId <= 0) {
|
||||||
|
return getFailureResult(201, "作品ID不能为空");
|
||||||
|
}
|
||||||
|
|
||||||
|
String merchantNo = request.getHeader("merchantNo") == null ? "" : request.getHeader("merchantNo");
|
||||||
|
Integer storeId = StringUtil.isEmpty(request.getHeader("storeId")) ? 0 : Integer.parseInt(request.getHeader("storeId"));
|
||||||
|
Integer merchantId = merchantService.getMerchantId(merchantNo);
|
||||||
|
|
||||||
|
Map<String, Object> result = lookService.toggleWorkLike(workId, loginInfo.getId(), merchantId, storeId);
|
||||||
|
return getSuccessResult(result);
|
||||||
|
}
|
||||||
|
|
||||||
|
@ApiOperation(value = "评论点赞/取消点赞")
|
||||||
|
@RequestMapping(value = "/toggleCommentLike", method = RequestMethod.POST)
|
||||||
|
@CrossOrigin
|
||||||
|
public ResponseObject toggleCommentLike(HttpServletRequest request, @RequestBody Map<String, Object> params) throws BusinessCheckException {
|
||||||
|
UserInfo loginInfo = TokenUtil.getUserInfo();
|
||||||
|
if (loginInfo == null) {
|
||||||
|
return getFailureResult(1001);
|
||||||
|
}
|
||||||
|
Integer commentId = params.get("commentId") == null ? 0 : Integer.parseInt(params.get("commentId").toString());
|
||||||
|
if (commentId <= 0) {
|
||||||
|
return getFailureResult(201, "评论ID不能为空");
|
||||||
|
}
|
||||||
|
|
||||||
|
String merchantNo = request.getHeader("merchantNo") == null ? "" : request.getHeader("merchantNo");
|
||||||
|
Integer storeId = StringUtil.isEmpty(request.getHeader("storeId")) ? 0 : Integer.parseInt(request.getHeader("storeId"));
|
||||||
|
Integer merchantId = merchantService.getMerchantId(merchantNo);
|
||||||
|
|
||||||
|
Map<String, Object> result = lookService.toggleCommentLike(commentId, loginInfo.getId(), merchantId, storeId);
|
||||||
|
return getSuccessResult(result);
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -18,6 +18,7 @@ import org.springframework.web.bind.annotation.RequestMethod;
|
|||||||
import org.springframework.web.bind.annotation.RestController;
|
import org.springframework.web.bind.annotation.RestController;
|
||||||
|
|
||||||
import javax.servlet.http.HttpServletRequest;
|
import javax.servlet.http.HttpServletRequest;
|
||||||
|
import java.math.BigDecimal;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
@ -53,15 +54,19 @@ public class ClientTaskController extends BaseController {
|
|||||||
|
|
||||||
List<Map<String, Object>> taskList = taskService.queryClientTaskList(merchantId, storeId, userId);
|
List<Map<String, Object>> taskList = taskService.queryClientTaskList(merchantId, storeId, userId);
|
||||||
int totalDailyPoints = 0;
|
int totalDailyPoints = 0;
|
||||||
|
BigDecimal totalDailyBalance = BigDecimal.ZERO;
|
||||||
for (Map<String, Object> task : taskList) {
|
for (Map<String, Object> task : taskList) {
|
||||||
int rewardPoint = task.get("rewardPoint") == null ? 0 : Integer.parseInt(task.get("rewardPoint").toString());
|
int rewardPoint = task.get("rewardPoint") == null ? 0 : Integer.parseInt(task.get("rewardPoint").toString());
|
||||||
|
BigDecimal rewardBalance = task.get("rewardBalance") == null ? BigDecimal.ZERO : new BigDecimal(task.get("rewardBalance").toString());
|
||||||
int dailyLimit = task.get("dailyLimit") == null ? 1 : Integer.parseInt(task.get("dailyLimit").toString());
|
int dailyLimit = task.get("dailyLimit") == null ? 1 : Integer.parseInt(task.get("dailyLimit").toString());
|
||||||
totalDailyPoints += rewardPoint * dailyLimit;
|
totalDailyPoints += rewardPoint * dailyLimit;
|
||||||
|
totalDailyBalance = totalDailyBalance.add(rewardBalance.multiply(new BigDecimal(dailyLimit)));
|
||||||
}
|
}
|
||||||
|
|
||||||
Map<String, Object> outParams = new HashMap<>();
|
Map<String, Object> outParams = new HashMap<>();
|
||||||
outParams.put("taskList", taskList);
|
outParams.put("taskList", taskList);
|
||||||
outParams.put("totalDailyPoints", totalDailyPoints);
|
outParams.put("totalDailyPoints", totalDailyPoints);
|
||||||
|
outParams.put("totalDailyBalance", totalDailyBalance);
|
||||||
return getSuccessResult(outParams);
|
return getSuccessResult(outParams);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -1,7 +1,7 @@
|
|||||||
# \u57FA\u672C\u914D\u7F6E
|
# \u57FA\u672C\u914D\u7F6E
|
||||||
server.port=5918
|
server.port=5918
|
||||||
env.profile=prod
|
env.profile=prod
|
||||||
env.properties.path=/www/wwwroot/configure/
|
env.properties.path=configure/
|
||||||
|
|
||||||
# \u6570\u636E\u5E93\u914D\u7F6E
|
# \u6570\u636E\u5E93\u914D\u7F6E
|
||||||
spring.datasource.type=com.zaxxer.hikari.HikariDataSource
|
spring.datasource.type=com.zaxxer.hikari.HikariDataSource
|
||||||
|
|||||||
@ -0,0 +1,17 @@
|
|||||||
|
package com.fuint.repository.mapper;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||||
|
import com.fuint.repository.model.MtLookComment;
|
||||||
|
import org.apache.ibatis.annotations.Param;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 看看评论 Mapper
|
||||||
|
*
|
||||||
|
* Created by Codex
|
||||||
|
*/
|
||||||
|
public interface MtLookCommentMapper extends BaseMapper<MtLookComment> {
|
||||||
|
|
||||||
|
Integer incrLikeNum(@Param("id") Integer id);
|
||||||
|
|
||||||
|
Integer decrLikeNum(@Param("id") Integer id);
|
||||||
|
}
|
||||||
@ -0,0 +1,12 @@
|
|||||||
|
package com.fuint.repository.mapper;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||||
|
import com.fuint.repository.model.MtLookLike;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 看看点赞 Mapper
|
||||||
|
*
|
||||||
|
* Created by Codex
|
||||||
|
*/
|
||||||
|
public interface MtLookLikeMapper extends BaseMapper<MtLookLike> {
|
||||||
|
}
|
||||||
@ -0,0 +1,21 @@
|
|||||||
|
package com.fuint.repository.mapper;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||||
|
import com.fuint.repository.model.MtLookWork;
|
||||||
|
import org.apache.ibatis.annotations.Param;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 看看作品 Mapper
|
||||||
|
*
|
||||||
|
* Created by Codex
|
||||||
|
*/
|
||||||
|
public interface MtLookWorkMapper extends BaseMapper<MtLookWork> {
|
||||||
|
|
||||||
|
Integer incrLikeNum(@Param("id") Integer id);
|
||||||
|
|
||||||
|
Integer decrLikeNum(@Param("id") Integer id);
|
||||||
|
|
||||||
|
Integer incrCommentNum(@Param("id") Integer id);
|
||||||
|
|
||||||
|
Integer decrCommentNum(@Param("id") Integer id);
|
||||||
|
}
|
||||||
@ -43,4 +43,13 @@ public interface MtOrderMapper extends BaseMapper<MtOrder> {
|
|||||||
|
|
||||||
List<MtOrder> getTobeCommissionOrderList(@Param("dateTime") String dateTime);
|
List<MtOrder> getTobeCommissionOrderList(@Param("dateTime") String dateTime);
|
||||||
|
|
||||||
|
Integer countCompleteTaskOrder(@Param("merchantId") Integer merchantId,
|
||||||
|
@Param("storeId") Integer storeId,
|
||||||
|
@Param("userId") Integer userId,
|
||||||
|
@Param("startTime") Date startTime,
|
||||||
|
@Param("endTime") Date endTime,
|
||||||
|
@Param("pointThreshold") Integer pointThreshold,
|
||||||
|
@Param("balanceThreshold") BigDecimal balanceThreshold,
|
||||||
|
@Param("goodsIdList") List<Integer> goodsIdList);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -0,0 +1,61 @@
|
|||||||
|
package com.fuint.repository.model;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.annotation.IdType;
|
||||||
|
import com.baomidou.mybatisplus.annotation.TableId;
|
||||||
|
import com.baomidou.mybatisplus.annotation.TableName;
|
||||||
|
import io.swagger.annotations.ApiModel;
|
||||||
|
import io.swagger.annotations.ApiModelProperty;
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
import java.io.Serializable;
|
||||||
|
import java.util.Date;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 看看作品评论
|
||||||
|
*
|
||||||
|
* Created by Codex
|
||||||
|
*/
|
||||||
|
@Data
|
||||||
|
@TableName("mt_look_comment")
|
||||||
|
@ApiModel(value = "MtLookComment对象", description = "看看作品评论")
|
||||||
|
public class MtLookComment implements Serializable {
|
||||||
|
|
||||||
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
||||||
|
@ApiModelProperty("自增ID")
|
||||||
|
@TableId(value = "ID", type = IdType.AUTO)
|
||||||
|
private Integer id;
|
||||||
|
|
||||||
|
@ApiModelProperty("商户ID")
|
||||||
|
private Integer merchantId;
|
||||||
|
|
||||||
|
@ApiModelProperty("店铺ID")
|
||||||
|
private Integer storeId;
|
||||||
|
|
||||||
|
@ApiModelProperty("作品ID")
|
||||||
|
private Integer workId;
|
||||||
|
|
||||||
|
@ApiModelProperty("用户ID")
|
||||||
|
private Integer userId;
|
||||||
|
|
||||||
|
@ApiModelProperty("评论内容")
|
||||||
|
private String content;
|
||||||
|
|
||||||
|
@ApiModelProperty("评论图片,逗号分隔")
|
||||||
|
private String images;
|
||||||
|
|
||||||
|
@ApiModelProperty("点赞数")
|
||||||
|
private Integer likeNum;
|
||||||
|
|
||||||
|
@ApiModelProperty("最后操作人")
|
||||||
|
private String operator;
|
||||||
|
|
||||||
|
@ApiModelProperty("创建时间")
|
||||||
|
private Date createTime;
|
||||||
|
|
||||||
|
@ApiModelProperty("更新时间")
|
||||||
|
private Date updateTime;
|
||||||
|
|
||||||
|
@ApiModelProperty("状态(A启用,N禁用,D删除)")
|
||||||
|
private String status;
|
||||||
|
}
|
||||||
@ -0,0 +1,52 @@
|
|||||||
|
package com.fuint.repository.model;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.annotation.IdType;
|
||||||
|
import com.baomidou.mybatisplus.annotation.TableId;
|
||||||
|
import com.baomidou.mybatisplus.annotation.TableName;
|
||||||
|
import io.swagger.annotations.ApiModel;
|
||||||
|
import io.swagger.annotations.ApiModelProperty;
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
import java.io.Serializable;
|
||||||
|
import java.util.Date;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 看看点赞记录
|
||||||
|
*
|
||||||
|
* Created by Codex
|
||||||
|
*/
|
||||||
|
@Data
|
||||||
|
@TableName("mt_look_like")
|
||||||
|
@ApiModel(value = "MtLookLike对象", description = "看看点赞记录")
|
||||||
|
public class MtLookLike implements Serializable {
|
||||||
|
|
||||||
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
||||||
|
@ApiModelProperty("自增ID")
|
||||||
|
@TableId(value = "ID", type = IdType.AUTO)
|
||||||
|
private Integer id;
|
||||||
|
|
||||||
|
@ApiModelProperty("商户ID")
|
||||||
|
private Integer merchantId;
|
||||||
|
|
||||||
|
@ApiModelProperty("店铺ID")
|
||||||
|
private Integer storeId;
|
||||||
|
|
||||||
|
@ApiModelProperty("用户ID")
|
||||||
|
private Integer userId;
|
||||||
|
|
||||||
|
@ApiModelProperty("对象类型(WORK/COMMENT)")
|
||||||
|
private String targetType;
|
||||||
|
|
||||||
|
@ApiModelProperty("对象ID")
|
||||||
|
private Integer targetId;
|
||||||
|
|
||||||
|
@ApiModelProperty("状态(A已赞,N取消,D删除)")
|
||||||
|
private String status;
|
||||||
|
|
||||||
|
@ApiModelProperty("创建时间")
|
||||||
|
private Date createTime;
|
||||||
|
|
||||||
|
@ApiModelProperty("更新时间")
|
||||||
|
private Date updateTime;
|
||||||
|
}
|
||||||
@ -0,0 +1,67 @@
|
|||||||
|
package com.fuint.repository.model;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.annotation.IdType;
|
||||||
|
import com.baomidou.mybatisplus.annotation.TableId;
|
||||||
|
import com.baomidou.mybatisplus.annotation.TableName;
|
||||||
|
import io.swagger.annotations.ApiModel;
|
||||||
|
import io.swagger.annotations.ApiModelProperty;
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
import java.io.Serializable;
|
||||||
|
import java.util.Date;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 看看作品
|
||||||
|
*
|
||||||
|
* Created by Codex
|
||||||
|
*/
|
||||||
|
@Data
|
||||||
|
@TableName("mt_look_work")
|
||||||
|
@ApiModel(value = "MtLookWork对象", description = "看看作品")
|
||||||
|
public class MtLookWork implements Serializable {
|
||||||
|
|
||||||
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
||||||
|
@ApiModelProperty("自增ID")
|
||||||
|
@TableId(value = "ID", type = IdType.AUTO)
|
||||||
|
private Integer id;
|
||||||
|
|
||||||
|
@ApiModelProperty("商户ID")
|
||||||
|
private Integer merchantId;
|
||||||
|
|
||||||
|
@ApiModelProperty("店铺ID")
|
||||||
|
private Integer storeId;
|
||||||
|
|
||||||
|
@ApiModelProperty("用户ID")
|
||||||
|
private Integer userId;
|
||||||
|
|
||||||
|
@ApiModelProperty("标题")
|
||||||
|
private String title;
|
||||||
|
|
||||||
|
@ApiModelProperty("描述")
|
||||||
|
private String description;
|
||||||
|
|
||||||
|
@ApiModelProperty("封面图")
|
||||||
|
private String cover;
|
||||||
|
|
||||||
|
@ApiModelProperty("图片列表,逗号分隔")
|
||||||
|
private String images;
|
||||||
|
|
||||||
|
@ApiModelProperty("点赞数")
|
||||||
|
private Integer likeNum;
|
||||||
|
|
||||||
|
@ApiModelProperty("评论数")
|
||||||
|
private Integer commentNum;
|
||||||
|
|
||||||
|
@ApiModelProperty("最后操作人")
|
||||||
|
private String operator;
|
||||||
|
|
||||||
|
@ApiModelProperty("创建时间")
|
||||||
|
private Date createTime;
|
||||||
|
|
||||||
|
@ApiModelProperty("更新时间")
|
||||||
|
private Date updateTime;
|
||||||
|
|
||||||
|
@ApiModelProperty("状态(A启用,N禁用,D删除)")
|
||||||
|
private String status;
|
||||||
|
}
|
||||||
@ -8,6 +8,7 @@ import io.swagger.annotations.ApiModelProperty;
|
|||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
|
|
||||||
import java.io.Serializable;
|
import java.io.Serializable;
|
||||||
|
import java.math.BigDecimal;
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -50,6 +51,21 @@ public class MtTask implements Serializable {
|
|||||||
@ApiModelProperty("奖励积分")
|
@ApiModelProperty("奖励积分")
|
||||||
private Integer rewardPoint;
|
private Integer rewardPoint;
|
||||||
|
|
||||||
|
@ApiModelProperty("奖励余额")
|
||||||
|
private BigDecimal rewardBalance;
|
||||||
|
|
||||||
|
@ApiModelProperty("银币阈值(订单使用银币数量)")
|
||||||
|
private Integer pointThreshold;
|
||||||
|
|
||||||
|
@ApiModelProperty("余额阈值(订单使用余额金额)")
|
||||||
|
private BigDecimal balanceThreshold;
|
||||||
|
|
||||||
|
@ApiModelProperty("指定商品ID,多个逗号分隔,空表示全部商品")
|
||||||
|
private String targetGoodsIds;
|
||||||
|
|
||||||
|
@ApiModelProperty("完成阈值(订单金额/点赞数)")
|
||||||
|
private BigDecimal completeThreshold;
|
||||||
|
|
||||||
@ApiModelProperty("每日可领取次数")
|
@ApiModelProperty("每日可领取次数")
|
||||||
private Integer dailyLimit;
|
private Integer dailyLimit;
|
||||||
|
|
||||||
|
|||||||
@ -0,0 +1,11 @@
|
|||||||
|
<?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.fuint.repository.mapper.MtLookCommentMapper">
|
||||||
|
<update id="incrLikeNum">
|
||||||
|
update mt_look_comment t set t.LIKE_NUM = IFNULL(t.LIKE_NUM, 0) + 1 where t.ID = #{id}
|
||||||
|
</update>
|
||||||
|
|
||||||
|
<update id="decrLikeNum">
|
||||||
|
update mt_look_comment t set t.LIKE_NUM = if(IFNULL(t.LIKE_NUM, 0) > 0, t.LIKE_NUM - 1, 0) where t.ID = #{id}
|
||||||
|
</update>
|
||||||
|
</mapper>
|
||||||
@ -0,0 +1,19 @@
|
|||||||
|
<?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.fuint.repository.mapper.MtLookWorkMapper">
|
||||||
|
<update id="incrLikeNum">
|
||||||
|
update mt_look_work t set t.LIKE_NUM = IFNULL(t.LIKE_NUM, 0) + 1 where t.ID = #{id}
|
||||||
|
</update>
|
||||||
|
|
||||||
|
<update id="decrLikeNum">
|
||||||
|
update mt_look_work t set t.LIKE_NUM = if(IFNULL(t.LIKE_NUM, 0) > 0, t.LIKE_NUM - 1, 0) where t.ID = #{id}
|
||||||
|
</update>
|
||||||
|
|
||||||
|
<update id="incrCommentNum">
|
||||||
|
update mt_look_work t set t.COMMENT_NUM = IFNULL(t.COMMENT_NUM, 0) + 1 where t.ID = #{id}
|
||||||
|
</update>
|
||||||
|
|
||||||
|
<update id="decrCommentNum">
|
||||||
|
update mt_look_work t set t.COMMENT_NUM = if(IFNULL(t.COMMENT_NUM, 0) > 0, t.COMMENT_NUM - 1, 0) where t.ID = #{id}
|
||||||
|
</update>
|
||||||
|
</mapper>
|
||||||
@ -71,4 +71,34 @@
|
|||||||
<select id="getTobeCommissionOrderList" resultType="com.fuint.repository.model.MtOrder">
|
<select id="getTobeCommissionOrderList" resultType="com.fuint.repository.model.MtOrder">
|
||||||
SELECT t.* FROM `mt_order` t WHERE t.PAY_TIME <= #{dateTime} AND t.STATUS = 'I' AND t.PAY_STATUS = 'B' AND t.COMMISSION_STATUS = 'A' ORDER BY t.ID DESC LIMIT 10
|
SELECT t.* FROM `mt_order` t WHERE t.PAY_TIME <= #{dateTime} AND t.STATUS = 'I' AND t.PAY_STATUS = 'B' AND t.COMMISSION_STATUS = 'A' ORDER BY t.ID DESC LIMIT 10
|
||||||
</select>
|
</select>
|
||||||
|
|
||||||
|
<select id="countCompleteTaskOrder" resultType="java.lang.Integer">
|
||||||
|
SELECT COUNT(DISTINCT o.ID)
|
||||||
|
FROM mt_order o
|
||||||
|
<if test="goodsIdList != null and goodsIdList.size() > 0">
|
||||||
|
INNER JOIN mt_order_goods og ON og.ORDER_ID = o.ID AND og.STATUS = 'A'
|
||||||
|
</if>
|
||||||
|
WHERE o.MERCHANT_ID = #{merchantId}
|
||||||
|
AND o.USER_ID = #{userId}
|
||||||
|
AND o.STATUS = 'I'
|
||||||
|
AND o.PAY_STATUS = 'B'
|
||||||
|
AND o.UPDATE_TIME >= #{startTime}
|
||||||
|
AND o.UPDATE_TIME < #{endTime}
|
||||||
|
<if test="storeId != null and storeId > 0">
|
||||||
|
AND (o.STORE_ID = 0 OR o.STORE_ID = #{storeId})
|
||||||
|
</if>
|
||||||
|
<if test="pointThreshold != null">
|
||||||
|
AND o.USE_POINT >= #{pointThreshold}
|
||||||
|
</if>
|
||||||
|
<if test="balanceThreshold != null">
|
||||||
|
AND o.PAY_TYPE = 'BALANCE'
|
||||||
|
AND o.PAY_AMOUNT >= #{balanceThreshold}
|
||||||
|
</if>
|
||||||
|
<if test="goodsIdList != null and goodsIdList.size() > 0">
|
||||||
|
AND og.GOODS_ID IN
|
||||||
|
<foreach collection="goodsIdList" item="goodsId" open="(" separator="," close=")">
|
||||||
|
#{goodsId}
|
||||||
|
</foreach>
|
||||||
|
</if>
|
||||||
|
</select>
|
||||||
</mapper>
|
</mapper>
|
||||||
|
|||||||
Reference in New Issue
Block a user