From 8c3e76d3712fb0497cb3088fe4f4f5c645dee970 Mon Sep 17 00:00:00 2001 From: Administrator <15274802129@163.com> Date: Thu, 15 May 2025 11:14:58 +0800 Subject: [PATCH] feat(mall): 新增新人礼功能 --- src/main/java/cc/mrbird/febs/mall/vo/ApiMemberNewGiftSettingVo.java | 26 +++++++++++++ src/main/java/cc/mrbird/febs/mall/controller/member/ApiMallMemberController.java | 11 +++++ src/main/java/cc/mrbird/febs/common/enumerates/ScoreFlowTypeEnum.java | 2 + src/main/java/cc/mrbird/febs/mall/dto/signActivity/ApiNewGiftSettingDto.java | 4 ++ src/main/java/cc/mrbird/febs/mall/service/IApiMallMemberService.java | 2 + src/main/java/cc/mrbird/febs/mall/service/impl/ApiMallMemberServiceImpl.java | 72 ++++++++++++++++++++++++++++++++++-- 6 files changed, 113 insertions(+), 4 deletions(-) diff --git a/src/main/java/cc/mrbird/febs/common/enumerates/ScoreFlowTypeEnum.java b/src/main/java/cc/mrbird/febs/common/enumerates/ScoreFlowTypeEnum.java index 7f4d4f6..02adc0f 100644 --- a/src/main/java/cc/mrbird/febs/common/enumerates/ScoreFlowTypeEnum.java +++ b/src/main/java/cc/mrbird/febs/common/enumerates/ScoreFlowTypeEnum.java @@ -9,6 +9,8 @@ * */ + MEMBER_INFO_GIFT(10, "完善个人信息,获得{}积分"), + PAY_BALANCE(9, "余额支付{}"), PAY(1, "支付{}积分"), diff --git a/src/main/java/cc/mrbird/febs/mall/controller/member/ApiMallMemberController.java b/src/main/java/cc/mrbird/febs/mall/controller/member/ApiMallMemberController.java index 9047f78..a385178 100644 --- a/src/main/java/cc/mrbird/febs/mall/controller/member/ApiMallMemberController.java +++ b/src/main/java/cc/mrbird/febs/mall/controller/member/ApiMallMemberController.java @@ -293,6 +293,17 @@ } + @ApiOperation(value = "新人礼", notes = "新人礼") + @ApiResponses({ + @ApiResponse(code = 200, message = "success", response = ApiMemberNewGiftSettingVo.class) + }) + @GetMapping(value = "/newGiftEvent") + public FebsResponse newGiftEvent() { + + return memberService.newGiftEvent(); + } + + @ApiOperation(value = "登录事件", notes = "登录事件") @GetMapping(value = "/birthdayEvent") public FebsResponse birthdayEvent() { diff --git a/src/main/java/cc/mrbird/febs/mall/dto/signActivity/ApiNewGiftSettingDto.java b/src/main/java/cc/mrbird/febs/mall/dto/signActivity/ApiNewGiftSettingDto.java index 146c39a..88367e7 100644 --- a/src/main/java/cc/mrbird/febs/mall/dto/signActivity/ApiNewGiftSettingDto.java +++ b/src/main/java/cc/mrbird/febs/mall/dto/signActivity/ApiNewGiftSettingDto.java @@ -1,6 +1,7 @@ package cc.mrbird.febs.mall.dto.signActivity; import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; import lombok.Data; @Data @@ -9,14 +10,17 @@ /** * 是否开启新人礼 */ + @ApiModelProperty(value = "是否开启新人礼 0-关闭 1-开启", example = "丽丽") private int state; /** * 积分 */ + @ApiModelProperty(value = "赠送积分数量", example = "1") private String prizeScore; /** * 优惠券ID */ + @ApiModelProperty(value = "赠送优惠卷", example = "1") private Long couponId; } diff --git a/src/main/java/cc/mrbird/febs/mall/service/IApiMallMemberService.java b/src/main/java/cc/mrbird/febs/mall/service/IApiMallMemberService.java index 8ce9ca0..d7e4a21 100644 --- a/src/main/java/cc/mrbird/febs/mall/service/IApiMallMemberService.java +++ b/src/main/java/cc/mrbird/febs/mall/service/IApiMallMemberService.java @@ -119,4 +119,6 @@ FebsResponse flowList(ApiMoneyFlowDto dto); FebsResponse flowHeader(); + + FebsResponse newGiftEvent(); } diff --git a/src/main/java/cc/mrbird/febs/mall/service/impl/ApiMallMemberServiceImpl.java b/src/main/java/cc/mrbird/febs/mall/service/impl/ApiMallMemberServiceImpl.java index 6b83062..879af4e 100644 --- a/src/main/java/cc/mrbird/febs/mall/service/impl/ApiMallMemberServiceImpl.java +++ b/src/main/java/cc/mrbird/febs/mall/service/impl/ApiMallMemberServiceImpl.java @@ -1,10 +1,7 @@ package cc.mrbird.febs.mall.service.impl; import cc.mrbird.febs.common.entity.FebsResponse; -import cc.mrbird.febs.common.enumerates.DataDictionaryEnum; -import cc.mrbird.febs.common.enumerates.FlowTypeEnum; -import cc.mrbird.febs.common.enumerates.MoneyFlowTypeEnum; -import cc.mrbird.febs.common.enumerates.ScoreFlowTypeEnum; +import cc.mrbird.febs.common.enumerates.*; import cc.mrbird.febs.common.exception.FebsException; import cc.mrbird.febs.common.properties.XcxProperties; import cc.mrbird.febs.common.utils.*; @@ -12,6 +9,7 @@ import cc.mrbird.febs.mall.conversion.MallShopApplyConversion; import cc.mrbird.febs.mall.conversion.MallStoreConversion; import cc.mrbird.febs.mall.dto.*; +import cc.mrbird.febs.mall.dto.signActivity.ApiNewGiftSettingDto; import cc.mrbird.febs.mall.entity.*; import cc.mrbird.febs.mall.mapper.*; import cc.mrbird.febs.mall.service.*; @@ -49,6 +47,7 @@ import java.io.IOException; import java.math.BigDecimal; +import java.math.RoundingMode; import java.util.*; import java.util.stream.Collectors; @@ -761,6 +760,47 @@ mallMember.setSex(1 == apiXcxSaveInfoDto.getGender() ? "女" : "男"); this.baseMapper.updateById(mallMember); + + //完善信息赠送新人礼 + if (StrUtil.isBlank(mallMember.getLevel())) { + DataDictionaryCustom dic = dataDictionaryCustomMapper.selectDicDataByTypeAndCode( + CommonDictionaryEnum.NEW_GIFT_SETTING.getType(), + CommonDictionaryEnum.NEW_GIFT_SETTING.getCode() + ); + ApiNewGiftSettingDto apiNewGiftSettingDto = JSONObject.parseObject(dic.getValue(), ApiNewGiftSettingDto.class); + if (apiNewGiftSettingDto.getState() == 1) { + String prizeScore = apiNewGiftSettingDto.getPrizeScore(); + BigDecimal bigDecimal = new BigDecimal(prizeScore).setScale(0, RoundingMode.HALF_DOWN); + if (bigDecimal.compareTo(BigDecimal.ZERO) > 0) { + walletService.add(bigDecimal, mallMember.getId(), "prizeScore"); + mallMoneyFlowService.addMoneyFlow( + mallMember.getId(), + bigDecimal, + ScoreFlowTypeEnum.MEMBER_INFO_GIFT.getValue(), + MallUtils.getOrderNum(), + FlowTypeEnum.PRIZE_SCORE.getValue(), + StrUtil.format(ScoreFlowTypeEnum.MEMBER_INFO_GIFT.getDesc(),bigDecimal), + 2 + ); + } + if (apiNewGiftSettingDto.getCouponId() != null) { + MallGoodsCoupon mallGoodsCoupon = mallGoodsCouponMapper.selectById(apiNewGiftSettingDto.getCouponId()); + if(ObjectUtil.isNotEmpty(mallGoodsCoupon)){ + MallMemberCoupon memberCoupon = new MallMemberCoupon(); + memberCoupon.setCouponId(mallGoodsCoupon.getId()); + memberCoupon.setCouponName(mallGoodsCoupon.getName()); + memberCoupon.setInviteId(mallMember.getInviteId()); + memberCoupon.setCouponUuid(IdUtil.simpleUUID()); + memberCoupon.setState(1); + memberCoupon.setFromType(3); + memberCoupon.setExpireTime(DateUtil.offsetDay(DateUtil.date(), mallGoodsCoupon.getExpireDay())); + memberCoupon.setMemberId(mallMember.getId()); + mallMemberCouponMapper.insert(memberCoupon); + } + } + + } + } return new FebsResponse().success(); } @@ -1526,6 +1566,30 @@ return new FebsResponse().success().data(apiMoneyFlowHeaderVo); } + @Override + public FebsResponse newGiftEvent() { + DataDictionaryCustom dic = dataDictionaryCustomMapper.selectDicDataByTypeAndCode( + CommonDictionaryEnum.NEW_GIFT_SETTING.getType(), + CommonDictionaryEnum.NEW_GIFT_SETTING.getCode() + ); + ApiNewGiftSettingDto apiNewGiftSettingDto = JSONObject.parseObject(dic.getValue(), ApiNewGiftSettingDto.class); + + ApiMemberNewGiftSettingVo apiMemberNewGiftSettingVo = new ApiMemberNewGiftSettingVo(); + apiMemberNewGiftSettingVo.setState(apiNewGiftSettingDto.getState()); + apiMemberNewGiftSettingVo.setPrizeScore(apiNewGiftSettingDto.getPrizeScore()); + + + LambdaQueryWrapper<MallGoodsCoupon> query = new LambdaQueryWrapper<>(); + query.eq(MallGoodsCoupon::getId, apiNewGiftSettingDto.getCouponId()) + .eq(MallGoodsCoupon::getState, 2); + List<MallGoodsCoupon> coupons = mallGoodsCouponMapper.selectList(query); + if(CollUtil.isNotEmpty(coupons)){ + apiMemberNewGiftSettingVo.setCouponName(coupons.get(0).getName()); + } + + return new FebsResponse().success().data(apiMemberNewGiftSettingVo); + } + // public static void main(String[] args) { // Long userld = 16425L; // String shopAccount = "爱和美医疗"; diff --git a/src/main/java/cc/mrbird/febs/mall/vo/ApiMemberNewGiftSettingVo.java b/src/main/java/cc/mrbird/febs/mall/vo/ApiMemberNewGiftSettingVo.java new file mode 100644 index 0000000..d60cb2b --- /dev/null +++ b/src/main/java/cc/mrbird/febs/mall/vo/ApiMemberNewGiftSettingVo.java @@ -0,0 +1,26 @@ +package cc.mrbird.febs.mall.vo; + +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; + +@Data +@ApiModel(value = "ApiMemberNewGiftSettingVo", description = "参数类") +public class ApiMemberNewGiftSettingVo { + /** + * 是否开启新人礼 + */ + @ApiModelProperty(value = "是否开启新人礼 0-关闭 1-开启", example = "丽丽") + private int state; + + /** + * 积分 + */ + @ApiModelProperty(value = "赠送积分数量", example = "1") + private String prizeScore; + /** + * 优惠券ID + */ + @ApiModelProperty(value = "赠送优惠名称", example = "1") + private String couponName; +} -- Gitblit v1.9.1