This commit is contained in:
moxiangrong
2024-02-20 19:33:50 +08:00
parent 9c85524e14
commit 477d29d69f
31 changed files with 246 additions and 83 deletions

View File

@ -37,6 +37,7 @@ public interface ErrorCodeConstants {
// ========== 签到记录 ==========
ErrorCode SIGN_IN_RECORD_NOT_EXISTS = new ErrorCode(1004009000, "签到记录不存在");
ErrorCode TODAY_SIGN_IN_RECORD_EXISTS = new ErrorCode(100409001, "今日已签到");
ErrorCode SIGN_IN_CLOSED = new ErrorCode(100409002, "已关闭签到");
// ========== 会员等级配置 ==========
ErrorCode USER_LEVEL_CONFIG_NOT_EXISTS = new ErrorCode(1004011000, "会员等级配置不存在");
// ========== 会员等级权益配置==========

View File

@ -1,16 +1,11 @@
package co.yixiang.yshop.module.member.controller.admin.integralrule.vo;
import lombok.*;
import java.util.*;
import io.swagger.v3.oas.annotations.media.Schema;
import co.yixiang.yshop.framework.common.pojo.PageParam;
import lombok.Data;
import org.springframework.format.annotation.DateTimeFormat;
import java.time.LocalDateTime;
import org.springframework.format.annotation.DateTimeFormat;
import static co.yixiang.yshop.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND;
@Schema(description = "管理后台 - 会员积分规则 Excel 导出 Request VO参数和 IntegralRulePageReqVO 是一致的")
@ -33,4 +28,7 @@ public class IntegralRuleExportReqVO {
@DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)
private LocalDateTime[] createTime;
@Schema(description = "是否开启")
private Boolean enable;
}

View File

@ -1,11 +1,10 @@
package co.yixiang.yshop.module.member.controller.admin.integralrule.vo;
import lombok.*;
import java.util.*;
import io.swagger.v3.oas.annotations.media.Schema;
import co.yixiang.yshop.framework.common.pojo.PageParam;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.ToString;
import org.springframework.format.annotation.DateTimeFormat;
import java.time.LocalDateTime;
@ -34,4 +33,7 @@ public class IntegralRulePageReqVO extends PageParam {
@DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)
private LocalDateTime[] createTime;
@Schema(description = "是否开启")
private Boolean enable;
}

View File

@ -2,6 +2,7 @@ package co.yixiang.yshop.module.member.controller.admin.user;
import co.yixiang.yshop.framework.common.pojo.CommonResult;
import co.yixiang.yshop.framework.common.pojo.PageResult;
import co.yixiang.yshop.framework.desensitize.core.util.DesensitizeUtil;
import co.yixiang.yshop.framework.excel.core.util.ExcelUtils;
import co.yixiang.yshop.framework.operatelog.core.annotations.OperateLog;
import co.yixiang.yshop.module.member.controller.admin.user.vo.*;
@ -112,11 +113,17 @@ public class MemberUserController {
public void exportMaterialExcel(@Valid UserExportReqVO exportReqVO,
HttpServletResponse response) throws IOException {
List<MemberUserDO> list = userService.getUserList(exportReqVO);
// 导出 Excel
List<MemberUserExcelVO> voList = UserConvert.INSTANCE.convertListExcel(list);
desensitize(voList);
// 导出 Excel
ExcelUtils.write(response, "会员用户.xls", "数据", MemberUserExcelVO.class, voList);
}
private void desensitize(List<MemberUserExcelVO> voList) {
DesensitizeUtil.mobileDesensitize(voList, "mobile");
}
@PostMapping("updateTag")
@Operation(summary = "更新用户标签")
@PreAuthorize("@ss.hasPermission('member:user:update')")

View File

@ -58,7 +58,9 @@ public class AppSignInRecordController {
@Operation(summary = "每日任务")
@PreAuthenticated
public CommonResult<List<IntegralRuleRespVO>> integralRule() {
List<IntegralRuleDO> list = integralRuleService.getIntegralRuleList(new IntegralRuleExportReqVO());
IntegralRuleExportReqVO reqVO = new IntegralRuleExportReqVO();
reqVO.setEnable(Boolean.TRUE);
List<IntegralRuleDO> list = integralRuleService.getIntegralRuleList(reqVO);
return CommonResult.success(IntegralRuleConvert.INSTANCE.convertList(list));
}
}

View File

@ -17,8 +17,6 @@ import lombok.*;
@EqualsAndHashCode(callSuper = true)
@ToString(callSuper = true)
@Builder
@NoArgsConstructor
@AllArgsConstructor
public class IntegralRuleDO extends BaseDO {
/**
@ -53,4 +51,25 @@ public class IntegralRuleDO extends BaseDO {
*/
private Boolean enable;
public IntegralRuleDO() {
}
public IntegralRuleDO(Integer integral) {
this.integral = integral;
}
public IntegralRuleDO(Long id, String type, String typeName, Integer integral, String attribute1, String iconUrl, Boolean enable) {
this.id = id;
this.type = type;
this.typeName = typeName;
this.integral = integral;
this.attribute1 = attribute1;
this.iconUrl = iconUrl;
this.enable = enable;
}
public IntegralRuleDO(Integer integral, Boolean enable) {
this.integral = integral;
this.enable = enable;
}
}

View File

@ -25,6 +25,7 @@ public interface IntegralRuleMapper extends BaseMapperX<IntegralRuleDO> {
.likeIfPresent(IntegralRuleDO::getTypeName, reqVO.getTypeName())
.eqIfPresent(IntegralRuleDO::getIntegral, reqVO.getIntegral())
.eqIfPresent(IntegralRuleDO::getAttribute1, reqVO.getAttribute1())
.eqIfPresent(IntegralRuleDO::getEnable, reqVO.getEnable())
.betweenIfPresent(IntegralRuleDO::getCreateTime, reqVO.getCreateTime())
.orderByAsc(IntegralRuleDO::getId));
}
@ -35,6 +36,7 @@ public interface IntegralRuleMapper extends BaseMapperX<IntegralRuleDO> {
.likeIfPresent(IntegralRuleDO::getTypeName, reqVO.getTypeName())
.eqIfPresent(IntegralRuleDO::getIntegral, reqVO.getIntegral())
.eqIfPresent(IntegralRuleDO::getAttribute1, reqVO.getAttribute1())
.eqIfPresent(IntegralRuleDO::getEnable, reqVO.getEnable())
.betweenIfPresent(IntegralRuleDO::getCreateTime, reqVO.getCreateTime())
.orderByAsc(IntegralRuleDO::getId));
}

View File

@ -88,7 +88,7 @@ public class IntegralRuleServiceImpl implements IntegralRuleService {
@Override
public List<IntegralRuleDO> getIntegralRuleByTypes(List<String> typeList) {
return integralRuleMapper.selectList(Wrappers.<IntegralRuleDO>lambdaQuery().in(IntegralRuleDO::getType, typeList));
return integralRuleMapper.selectList(Wrappers.<IntegralRuleDO>lambdaQuery().in(IntegralRuleDO::getType, typeList).eq(IntegralRuleDO::getEnable,Boolean.TRUE));
}
@Override

View File

@ -41,8 +41,7 @@ import java.util.stream.Collectors;
import static co.yixiang.yshop.framework.common.constant.ShopConstants.DAY_FORMAT_STR;
import static co.yixiang.yshop.framework.common.exception.util.ServiceExceptionUtil.exception;
import static co.yixiang.yshop.module.member.enums.ErrorCodeConstants.SIGN_IN_RECORD_NOT_EXISTS;
import static co.yixiang.yshop.module.member.enums.ErrorCodeConstants.TODAY_SIGN_IN_RECORD_EXISTS;
import static co.yixiang.yshop.module.member.enums.ErrorCodeConstants.*;
/**
* 签到记录 Service 实现类
@ -168,7 +167,7 @@ public class SignInRecordServiceImpl implements SignInRecordService {
//查询签到相关积分规则
List<IntegralRuleDO> integralRuleList = integralRuleService.getIntegralRuleByTypes(ListUtil.of(BillDetailEnum.SIGN.getValue()));
//每日签到规则
IntegralRuleDO everydayIntegralRuleDO = integralRuleList.stream().filter(item -> item.getAttribute1().equals("1")).findFirst().get();
IntegralRuleDO everydayIntegralRuleDO = integralRuleList.stream().filter(item -> item.getAttribute1().equals("1")).findFirst().orElse(new IntegralRuleDO(0));
AtomicInteger predictCount = new AtomicInteger(count);
List<DateTime> dateTimes = DateUtil.rangeToList(DateUtils.of(startTime), DateUtils.of(endTime), DateField.DAY_OF_WEEK);
@ -205,6 +204,9 @@ public class SignInRecordServiceImpl implements SignInRecordService {
verifyExistSignInToday(userId);
//获取当前签到规则
IntegralRuleDO currentIntegralRule = getIntegralRule(userId);
if(!currentIntegralRule.getEnable()){
throw exception(SIGN_IN_CLOSED);
}
//领取积分
IntegralRuleDTO rule = new IntegralRuleDTO();
rule.setUserId(userId);
@ -232,7 +234,7 @@ public class SignInRecordServiceImpl implements SignInRecordService {
//查询签到相关积分规则
List<IntegralRuleDO> integralRuleList = integralRuleService.getIntegralRuleByTypes(ListUtil.of(BillDetailEnum.SIGN.getValue()));
//每日签到规则
IntegralRuleDO everydayIntegralRuleDO = integralRuleList.stream().filter(item -> item.getAttribute1().equals("1")).findFirst().get();
IntegralRuleDO everydayIntegralRuleDO = integralRuleList.stream().filter(item -> item.getAttribute1().equals("1")).findFirst().orElse(new IntegralRuleDO(0,Boolean.FALSE));
//当前签到天数
Integer count = countByUserIdThisWeek(userId) + 1;
//获取当前签到规则

View File

@ -1,6 +1,7 @@
package co.yixiang.yshop.module.member.service.userlevelconfig;
import cn.hutool.core.collection.ListUtil;
import cn.hutool.core.thread.ThreadUtil;
import cn.hutool.core.util.NumberUtil;
import cn.hutool.core.util.ObjectUtil;
import co.yixiang.yshop.framework.common.pojo.PageResult;
@ -207,8 +208,10 @@ public class UserLevelConfigServiceImpl implements UserLevelConfigService {
couponEquityOpt.ifPresent(equity -> {
Long couponId = equity.getEquityValue();
if (Objects.nonNull(couponId)) {
couponApi.receiveCoupon(couponId, userId);
log.warn("会员:{},升级:{},发放优惠券:{}", userId, levelId, equity.getEquityValue());
ThreadUtil.execute(() -> {
couponApi.receiveCoupon(couponId, userId);
log.warn("会员:{},升级:{},发放优惠券:{}", userId, levelId, equity.getEquityValue());
});
}
});
}

View File

@ -30,6 +30,9 @@
<if test="param.pm != null">
and t1.pm = #{param.pm}
</if>
<if test="param.createTime != null and param.createTime.length == 2">
and t1.create_time between #{param.createTime[0]} and #{param.createTime[1]}
</if>
<if test="param.nickname != null and param.nickname != ''">
and ( t2.nickname like concat('%',#{param.nickname},'%')
or t2.mobile like concat('%',#{param.nickname},'%')