From 940dd1b292db4c5cc2df2f137fa46c37f2159898 Mon Sep 17 00:00:00 2001 From: Pu Zhibing <393733352@qq.com> Date: 星期四, 05 十二月 2024 18:06:01 +0800 Subject: [PATCH] Merge remote-tracking branch 'origin/master' --- ruoyi-service/ruoyi-account/src/main/java/com/ruoyi/account/service/impl/UserPointServiceImpl.java | 96 ++++++++++- ruoyi-service/ruoyi-account/src/main/java/com/ruoyi/account/controller/VipCenter.java | 85 ++++++++++ ruoyi-service/ruoyi-other/src/main/java/com/ruoyi/other/controller/VipSettingController.java | 5 ruoyi-service/ruoyi-account/src/main/java/com/ruoyi/account/service/UserPointService.java | 2 ruoyi-service/ruoyi-other/src/main/java/com/ruoyi/other/controller/ShareController.java | 22 ++ ruoyi-service/ruoyi-account/src/main/java/com/ruoyi/account/vo/vip/VipLevel.java | 20 ++ ruoyi-service/ruoyi-account/src/main/java/com/ruoyi/account/service/PointSettingService.java | 8 + ruoyi-api/ruoyi-api-other/src/main/java/com/ruoyi/other/api/feignClient/RemoteVipSettingClient.java | 5 ruoyi-api/ruoyi-api-other/src/main/java/com/ruoyi/other/api/factory/RemoteVipSettingFallbackFactory.java | 7 ruoyi-api/ruoyi-api-other/src/main/java/com/ruoyi/other/api/domain/PointSetting.java | 4 ruoyi-service/ruoyi-other/src/main/java/com/ruoyi/other/vo/TechnicianSubscribeVO.java | 6 ruoyi-service/ruoyi-other/src/main/java/com/ruoyi/other/controller/GoodsEvaluateController.java | 29 +++ ruoyi-api/ruoyi-api-other/src/main/java/com/ruoyi/other/api/domain/GoodsEvaluate.java | 10 + ruoyi-common/ruoyi-common-core/src/main/java/com/ruoyi/common/core/utils/PhoneNumberValidator.java | 28 +++ ruoyi-api/ruoyi-api-account/src/main/java/com/ruoyi/account/api/factory/AppUserClientFallbackFactory.java | 1 ruoyi-api/ruoyi-api-other/src/main/java/com/ruoyi/other/api/domain/Share.java | 2 ruoyi-service/ruoyi-order/src/main/java/com/ruoyi/order/controller/OrderController.java | 9 ruoyi-service/ruoyi-account/src/main/java/com/ruoyi/account/service/impl/PointSettingServiceImpl.java | 29 +++ ruoyi-service/ruoyi-account/src/main/java/com/ruoyi/account/controller/UserPointController.java | 16 - ruoyi-service/ruoyi-account/src/main/java/com/ruoyi/account/vo/vip/Level.java | 60 +++++++ ruoyi-service/ruoyi-account/src/main/java/com/ruoyi/account/controller/AppUserController.java | 19 + ruoyi-service/ruoyi-other/src/main/resources/mapper/other/TechnicianSubscribeMapper.xml | 2 ruoyi-service/ruoyi-order/src/main/java/com/ruoyi/order/mapper/OrderMapper.java | 5 ruoyi-service/ruoyi-order/src/main/resources/mapper/order/OrderMapper.xml | 6 24 files changed, 422 insertions(+), 54 deletions(-) diff --git a/ruoyi-api/ruoyi-api-account/src/main/java/com/ruoyi/account/api/factory/AppUserClientFallbackFactory.java b/ruoyi-api/ruoyi-api-account/src/main/java/com/ruoyi/account/api/factory/AppUserClientFallbackFactory.java index c2da01a..eaae6be 100644 --- a/ruoyi-api/ruoyi-api-account/src/main/java/com/ruoyi/account/api/factory/AppUserClientFallbackFactory.java +++ b/ruoyi-api/ruoyi-api-account/src/main/java/com/ruoyi/account/api/factory/AppUserClientFallbackFactory.java @@ -23,7 +23,6 @@ public AppUserClient create(Throwable cause) { return new AppUserClient() { - @PostMapping("/appUser/getAppUserById") @Override public AppUser getAppUserById(Long id) { log.error("根据id获取用户失败:{}", cause.getMessage()); diff --git a/ruoyi-api/ruoyi-api-other/src/main/java/com/ruoyi/other/api/domain/GoodsEvaluate.java b/ruoyi-api/ruoyi-api-other/src/main/java/com/ruoyi/other/api/domain/GoodsEvaluate.java index 745cad0..2de0d6f 100644 --- a/ruoyi-api/ruoyi-api-other/src/main/java/com/ruoyi/other/api/domain/GoodsEvaluate.java +++ b/ruoyi-api/ruoyi-api-other/src/main/java/com/ruoyi/other/api/domain/GoodsEvaluate.java @@ -70,4 +70,14 @@ private LocalDateTime createTime; + @ApiModelProperty(value = "头像") + @TableField(exist = false) + private String avatar; + + + @ApiModelProperty(value = "名字") + @TableField(exist = false) + private String userName; + + } diff --git a/ruoyi-api/ruoyi-api-other/src/main/java/com/ruoyi/other/api/domain/PointSetting.java b/ruoyi-api/ruoyi-api-other/src/main/java/com/ruoyi/other/api/domain/PointSetting.java index c6bb0be..15a7069 100644 --- a/ruoyi-api/ruoyi-api-other/src/main/java/com/ruoyi/other/api/domain/PointSetting.java +++ b/ruoyi-api/ruoyi-api-other/src/main/java/com/ruoyi/other/api/domain/PointSetting.java @@ -105,7 +105,7 @@ @ApiModelProperty(value = "门店业绩积分") @TableField("shop_point") - private BigDecimal shopPoint; + private Integer shopPoint; @ApiModelProperty(value = "门店业绩积分 1开0关") @TableField("shop_point_open") @@ -129,7 +129,7 @@ @ApiModelProperty(value = "拉新人积分") @TableField("get_new_point") - private BigDecimal getNewPoint; + private Integer getNewPoint; @ApiModelProperty(value = "拉新人积分 1开0关") @TableField("get_new_point_open") diff --git a/ruoyi-api/ruoyi-api-other/src/main/java/com/ruoyi/other/api/domain/Share.java b/ruoyi-api/ruoyi-api-other/src/main/java/com/ruoyi/other/api/domain/Share.java index 75a5bd4..2fb7181 100644 --- a/ruoyi-api/ruoyi-api-other/src/main/java/com/ruoyi/other/api/domain/Share.java +++ b/ruoyi-api/ruoyi-api-other/src/main/java/com/ruoyi/other/api/domain/Share.java @@ -76,7 +76,7 @@ @ApiModelProperty(value = "对象id") @TableField("object_id") - private Integer objectId; + private String objectId; } diff --git a/ruoyi-api/ruoyi-api-other/src/main/java/com/ruoyi/other/api/factory/RemoteVipSettingFallbackFactory.java b/ruoyi-api/ruoyi-api-other/src/main/java/com/ruoyi/other/api/factory/RemoteVipSettingFallbackFactory.java index 6bd559c..1fd7d1f 100644 --- a/ruoyi-api/ruoyi-api-other/src/main/java/com/ruoyi/other/api/factory/RemoteVipSettingFallbackFactory.java +++ b/ruoyi-api/ruoyi-api-other/src/main/java/com/ruoyi/other/api/factory/RemoteVipSettingFallbackFactory.java @@ -7,6 +7,8 @@ import lombok.extern.slf4j.Slf4j; import org.springframework.cloud.openfeign.FallbackFactory; +import java.util.List; + @Slf4j public class RemoteVipSettingFallbackFactory implements FallbackFactory<RemoteVipSettingClient> { @Override @@ -17,6 +19,11 @@ log.error("获取会员设置信息失败:{}", cause.getMessage()); throw new ServiceException("获取会员设置信息失败"); } + + @Override + public R<List<VipSetting>> list() { + return R.fail("获取会员设置信息失败"); + } }; } } diff --git a/ruoyi-api/ruoyi-api-other/src/main/java/com/ruoyi/other/api/feignClient/RemoteVipSettingClient.java b/ruoyi-api/ruoyi-api-other/src/main/java/com/ruoyi/other/api/feignClient/RemoteVipSettingClient.java index d99075a..647e84e 100644 --- a/ruoyi-api/ruoyi-api-other/src/main/java/com/ruoyi/other/api/feignClient/RemoteVipSettingClient.java +++ b/ruoyi-api/ruoyi-api-other/src/main/java/com/ruoyi/other/api/feignClient/RemoteVipSettingClient.java @@ -8,9 +8,14 @@ import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.RequestParam; +import java.util.List; + @FeignClient(contextId = "RemoteVipSettingClient", value = ServiceNameConstants.OTHER_SERVICE, fallbackFactory = RemoteVipSettingFallbackFactory.class) public interface RemoteVipSettingClient { @GetMapping("/vip-setting/getVipSettingById") R<VipSetting> getVipSettingById(@RequestParam(value = "id",required = true) Integer id); + + @GetMapping("/vip-setting/list") + R<List<VipSetting>> list(); } diff --git a/ruoyi-common/ruoyi-common-core/src/main/java/com/ruoyi/common/core/utils/PhoneNumberValidator.java b/ruoyi-common/ruoyi-common-core/src/main/java/com/ruoyi/common/core/utils/PhoneNumberValidator.java new file mode 100644 index 0000000..2ba287d --- /dev/null +++ b/ruoyi-common/ruoyi-common-core/src/main/java/com/ruoyi/common/core/utils/PhoneNumberValidator.java @@ -0,0 +1,28 @@ +package com.ruoyi.common.core.utils; + +public class PhoneNumberValidator { + + // 定义一个匹配中国手机号的正则表达式 + private static final String CHINA_PHONE_REGEX = "^1[3-9]\\d{9}$"; + + /** + * 验证给定的字符串是否符合中国手机号的格式. + * + * @param phoneNumber 要验证的手机号 + * @return 如果手机号格式正确返回true,否则返回false + */ + public static boolean isValidChinaPhoneNumber(String phoneNumber) { + if (phoneNumber == null || phoneNumber.isEmpty()) { + return false; + } + return phoneNumber.matches(CHINA_PHONE_REGEX); + } + + public static void main(String[] args) { + // 测试几个号码 + String[] phoneNumbers = {"13800138000", "15912345678", "18612345678", "110", "12345678901", "19912345678"}; + for (String phoneNumber : phoneNumbers) { + System.out.println("Phone number: " + phoneNumber + " is valid: " + isValidChinaPhoneNumber(phoneNumber)); + } + } +} diff --git a/ruoyi-service/ruoyi-account/src/main/java/com/ruoyi/account/controller/AppUserController.java b/ruoyi-service/ruoyi-account/src/main/java/com/ruoyi/account/controller/AppUserController.java index e3c1045..6ee0ca6 100644 --- a/ruoyi-service/ruoyi-account/src/main/java/com/ruoyi/account/controller/AppUserController.java +++ b/ruoyi-service/ruoyi-account/src/main/java/com/ruoyi/account/controller/AppUserController.java @@ -12,12 +12,11 @@ import com.ruoyi.common.security.service.TokenService; import com.ruoyi.other.api.domain.Shop; import com.ruoyi.other.api.feignClient.StoreClient; +import io.swagger.annotations.*; import org.springframework.web.bind.annotation.PostMapping; import org.springframework.web.bind.annotation.RequestBody; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RestController; -import io.swagger.annotations.Api; -import io.swagger.annotations.ApiOperation; import javax.annotation.Resource; import java.util.List; @@ -25,8 +24,6 @@ import com.ruoyi.account.vo.*; import com.ruoyi.common.core.web.controller.BaseController; import com.ruoyi.common.core.web.page.TableDataInfo; -import io.swagger.annotations.ApiImplicitParam; -import io.swagger.annotations.ApiImplicitParams; import org.springframework.web.bind.annotation.*; /** @@ -178,7 +175,7 @@ @ResponseBody - @PostMapping("/recommend") + @GetMapping("/recommend") @ApiOperation(value = "推广中心", tags = {"小程序-推广中心"}) public R<AppUser> recommend(){ Long userId = tokenService.getLoginUserApplet().getUserid(); @@ -221,6 +218,18 @@ return R.ok(user); } + @ResponseBody + @GetMapping("/change") + @ApiOperation(value = "推广中心", tags = {"小程序-推广中心"}) + public R<AppUser> change(@ApiParam("换绑用户id") Long userId){ + Long userId1 = tokenService.getLoginUserApplet().getUserid(); + //获取绑定门店 + AppUser user = appUserService.getById(userId1); + user.setInviteUserId(userId); + appUserService.updateById(user); + return R.ok(); + } + @GetMapping("/index") diff --git a/ruoyi-service/ruoyi-account/src/main/java/com/ruoyi/account/controller/UserPointController.java b/ruoyi-service/ruoyi-account/src/main/java/com/ruoyi/account/controller/UserPointController.java index 75fef0e..7ab6d0a 100644 --- a/ruoyi-service/ruoyi-account/src/main/java/com/ruoyi/account/controller/UserPointController.java +++ b/ruoyi-service/ruoyi-account/src/main/java/com/ruoyi/account/controller/UserPointController.java @@ -1,10 +1,7 @@ package com.ruoyi.account.controller; -import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; -import com.ruoyi.account.api.model.AppUser; import com.ruoyi.account.api.model.UserPoint; -import com.ruoyi.account.service.AppUserService; import com.ruoyi.account.service.UserPointService; import com.ruoyi.account.vo.UserPointDetailVO; import com.ruoyi.account.vo.UserPointVO; @@ -40,8 +37,6 @@ public class UserPointController extends BaseController { @Resource private UserPointService userPointService; - @Resource - private AppUserService appUserService; /** @@ -86,15 +81,8 @@ */ @PostMapping("/transferPoint") @ApiOperation("转赠积分") - public R<Void> transferPoint(@ApiParam("积分") BigDecimal point, @ApiParam("手机号") Long phone) { - AppUser appUser = appUserService.getOne(new LambdaQueryWrapper<AppUser>() - .eq(AppUser::getPhone, phone)); - - - - if (null == appUser) { - return R.fail("用户不存在"); - } + public R<Void> transferPoint(@ApiParam("积分") @RequestParam BigDecimal point, @ApiParam("手机号") @RequestParam String phone) { + userPointService.transferPoint(point, phone); return R.ok(); } diff --git a/ruoyi-service/ruoyi-account/src/main/java/com/ruoyi/account/controller/VipCenter.java b/ruoyi-service/ruoyi-account/src/main/java/com/ruoyi/account/controller/VipCenter.java new file mode 100644 index 0000000..d964ef6 --- /dev/null +++ b/ruoyi-service/ruoyi-account/src/main/java/com/ruoyi/account/controller/VipCenter.java @@ -0,0 +1,85 @@ +package com.ruoyi.account.controller; + +import com.ruoyi.account.service.VipSettingService; +import com.ruoyi.account.vo.vip.Level; +import com.ruoyi.account.vo.vip.VipLevel; +import com.ruoyi.common.core.domain.R; +import com.ruoyi.common.security.service.TokenService; +import com.ruoyi.other.api.domain.BaseSetting; +import com.ruoyi.other.api.domain.VipSetting; +import com.ruoyi.other.api.feignClient.BaseSettingClient; +import com.ruoyi.other.api.feignClient.RemoteVipSettingClient; +import io.swagger.annotations.Api; +import io.swagger.annotations.ApiOperation; +import lombok.extern.log4j.Log4j2; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RestController; + +import javax.annotation.Resource; +import java.util.ArrayList; +import java.util.List; + +@RestController +@RequestMapping("/vipCenter") +@Api(tags = "小程序-会员中心") +@Log4j2 +public class VipCenter { + @Resource + private RemoteVipSettingClient remoteVipSettingClient; + @Resource + private BaseSettingClient baseSettingClient; + @Resource + private VipSettingService vipSettingService; + @Resource + private TokenService tokenService; + + + @GetMapping("getVipLevelList") + @ApiOperation(value = "会员等级列表", tags = {"会员中心-小程序"}) + public R<VipLevel> vipLevelList() { + R<List<VipSetting>> r = remoteVipSettingClient.list(); + if (!R.isSuccess(r)){ + return R.fail("会员等级获取失败"); + } + List<VipSetting> vipSettingList = r.getData(); + if (vipSettingList == null || vipSettingList.isEmpty()){ + return R.fail("会员等级获取失败"); + } + R<BaseSetting> baseSettingR = baseSettingClient.getBaseSetting(3); + if (!R.isSuccess(baseSettingR)){ + log.error("【会员设置说明】获取失败"); + return R.fail("会员等级获取失败"); + } + BaseSetting baseSetting = baseSettingR.getData(); + if (baseSetting == null){ + log.error("【会员设置说明】未设置"); + return R.fail("会员等级获取失败"); + } + Long userid = tokenService.getLoginUserApplet().getUserid(); + VipSetting loginUserVipSetting = vipSettingService.getVipSettingByUserId(userid); + + VipLevel vipLevel = new VipLevel(); + List<Level> levelList = new ArrayList<>(); + vipSettingList.forEach(vipSetting -> { + Level level = new Level(); + level.setId(vipSetting.getId()); + level.setName(vipSetting.getVipName()); + level.setVipInfo(vipSetting.getVipInfo()); + level.setVipDesc(baseSetting.getContent()); + level.setVipLevelUpShop(vipSetting.getVipLevelUpShop()); + level.setVipLevelUpShare(vipSetting.getVipLevelUpShare()); + level.setKeepBuyDay(vipSetting.getKeepBuyDay()); + level.setKeepBuyPoint(vipSetting.getKeepBuyPoint()); + level.setKeepShareDay(vipSetting.getKeepShareDay()); + level.setKeepSharePoint(vipSetting.getKeepSharePoint()); + level.setKeepShopDay(vipSetting.getKeepShopDay()); + level.setKeepShopPoint(vipSetting.getKeepShopPoint()); + levelList.add(level); + }); + vipLevel.setLevelList(levelList); + vipLevel.setCurrentLevel(loginUserVipSetting.getId()); + return R.ok(vipLevel); + } + +} diff --git a/ruoyi-service/ruoyi-account/src/main/java/com/ruoyi/account/service/PointSettingService.java b/ruoyi-service/ruoyi-account/src/main/java/com/ruoyi/account/service/PointSettingService.java new file mode 100644 index 0000000..064686f --- /dev/null +++ b/ruoyi-service/ruoyi-account/src/main/java/com/ruoyi/account/service/PointSettingService.java @@ -0,0 +1,8 @@ +package com.ruoyi.account.service; + +import com.ruoyi.other.api.domain.PointSetting; + +public interface PointSettingService { + + PointSetting getPointSettingByAppUserId(Long appUserId); +} diff --git a/ruoyi-service/ruoyi-account/src/main/java/com/ruoyi/account/service/UserPointService.java b/ruoyi-service/ruoyi-account/src/main/java/com/ruoyi/account/service/UserPointService.java index 3057915..a274f27 100644 --- a/ruoyi-service/ruoyi-account/src/main/java/com/ruoyi/account/service/UserPointService.java +++ b/ruoyi-service/ruoyi-account/src/main/java/com/ruoyi/account/service/UserPointService.java @@ -24,5 +24,5 @@ List<UserPointDetailVO> getUserPointDetail(Long userId, LocalDateTime startTime, LocalDateTime endTime, Integer type); - void transferPoint(BigDecimal point, Long phone); + void transferPoint(BigDecimal point, String phone); } diff --git a/ruoyi-service/ruoyi-account/src/main/java/com/ruoyi/account/service/impl/PointSettingServiceImpl.java b/ruoyi-service/ruoyi-account/src/main/java/com/ruoyi/account/service/impl/PointSettingServiceImpl.java new file mode 100644 index 0000000..50fdd69 --- /dev/null +++ b/ruoyi-service/ruoyi-account/src/main/java/com/ruoyi/account/service/impl/PointSettingServiceImpl.java @@ -0,0 +1,29 @@ +package com.ruoyi.account.service.impl; + +import com.ruoyi.account.api.model.AppUser; +import com.ruoyi.account.service.AppUserService; +import com.ruoyi.account.service.PointSettingService; +import com.ruoyi.common.core.domain.R; +import com.ruoyi.other.api.domain.PointSetting; +import com.ruoyi.other.api.feignClient.PointSettingClient; +import org.springframework.stereotype.Service; + +import javax.annotation.Resource; + +@Service +public class PointSettingServiceImpl implements PointSettingService { + @Resource + private PointSettingClient pointSettingClient; + @Resource + private AppUserService appUserService; + + @Override + public PointSetting getPointSettingByAppUserId(Long appUserId) { + AppUser appUser = appUserService.getById(appUserId); + R<PointSetting> r = pointSettingClient.getPointSetting(appUser.getVipId()); + if (!R.isSuccess(r)){ + throw new RuntimeException("获取积分设置失败"); + } + return r.getData(); + } +} diff --git a/ruoyi-service/ruoyi-account/src/main/java/com/ruoyi/account/service/impl/UserPointServiceImpl.java b/ruoyi-service/ruoyi-account/src/main/java/com/ruoyi/account/service/impl/UserPointServiceImpl.java index cca1a66..3775d83 100644 --- a/ruoyi-service/ruoyi-account/src/main/java/com/ruoyi/account/service/impl/UserPointServiceImpl.java +++ b/ruoyi-service/ruoyi-account/src/main/java/com/ruoyi/account/service/impl/UserPointServiceImpl.java @@ -3,19 +3,25 @@ import cn.hutool.core.collection.CollectionUtil; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; -import com.ruoyi.account.api.feignClient.AppUserClient; import com.ruoyi.account.api.model.AppUser; -import com.ruoyi.account.api.model.BalanceChangeRecord; import com.ruoyi.account.api.model.UserPoint; import com.ruoyi.account.enums.PointChangeType; import com.ruoyi.account.mapper.UserPointMapper; +import com.ruoyi.account.service.AppUserService; +import com.ruoyi.account.service.PointSettingService; import com.ruoyi.account.service.UserPointService; +import com.ruoyi.account.service.VipSettingService; import com.ruoyi.account.vo.UserPointDetailVO; import com.ruoyi.account.vo.UserPointVO; -import com.ruoyi.common.core.domain.R; +import com.ruoyi.common.core.exception.ServiceException; +import com.ruoyi.common.core.utils.PhoneNumberValidator; +import com.ruoyi.common.security.service.TokenService; +import com.ruoyi.other.api.domain.PointSetting; import com.ruoyi.other.api.domain.VipSetting; -import com.ruoyi.other.api.feignClient.RemoteVipSettingClient; +import com.ruoyi.system.api.model.LoginUser; +import lombok.extern.slf4j.Slf4j; import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; import javax.annotation.Resource; import java.math.BigDecimal; @@ -23,6 +29,7 @@ import java.util.Collections; import java.util.List; import java.util.Map; +import java.util.Optional; import java.util.stream.Collectors; /** @@ -34,25 +41,26 @@ * @since 2024-11-21 */ @Service +@Slf4j public class UserPointServiceImpl extends ServiceImpl<UserPointMapper, UserPoint> implements UserPointService { @Resource - private AppUserClient appUserClient; + private AppUserService appUserService; @Resource - private RemoteVipSettingClient remoteVipSettingClient; + private TokenService tokenService; + @Resource + private VipSettingService vipSettingService; + @Resource + private PointSettingService pointSettingService; @Override public UserPointVO getUserPoint(Long userId) { - AppUser appUser = appUserClient.getAppUserById(userId); + AppUser appUser = appUserService.getById(userId); List<UserPoint> userPointList = list(new LambdaQueryWrapper<UserPoint>() .eq(UserPoint::getAppUserId, userId)); Map<Integer, Integer> userBalanceMap = userPointList.stream() .collect(Collectors.toMap(UserPoint::getType, UserPoint::getBalance)); - - R<VipSetting> r = remoteVipSettingClient.getVipSettingById(appUser.getVipId()); - if (!R.isSuccess(r)){ - throw new RuntimeException("会员等级获取失败"); - } + VipSetting vipSetting = vipSettingService.getVipSettingByUserId(userId); Integer lavePoint = appUser.getLavePoint(); UserPointVO userPointVO = new UserPointVO(); @@ -63,7 +71,7 @@ userPointVO.setPullNewPoint(userBalanceMap.get(PointChangeType.NEW_USER_REFERRAL.getCode())); userPointVO.setShopAchievementPoint(userBalanceMap.get(PointChangeType.STORE_PERFORMANCE.getCode())); userPointVO.setShopSharePoint(userBalanceMap.get(PointChangeType.STORE_COMMISSION_RETURN.getCode())); - userPointVO.setGiftPoint(r.getData().getVipGiftRole()); + userPointVO.setGiftPoint(vipSetting.getVipGiftRole()); return userPointVO; } @@ -87,8 +95,66 @@ @Override - public void transferPoint(BigDecimal point, Long phone) { - AppUser appUser = appUserService.getOne(new LambdaQueryWrapper<AppUser>() + @Transactional + public void transferPoint(BigDecimal point, String phone) { + if (!PhoneNumberValidator.isValidChinaPhoneNumber(phone)) { + throw new ServiceException("无效的电话号码"); + } + + LoginUser loginUserApplet = tokenService.getLoginUserApplet(); + Long userid = loginUserApplet.getUserid(); + + VipSetting vipSetting = vipSettingService.getVipSettingByUserId(userid); + if (vipSetting == null) { + throw new ServiceException("VIP 设置未找到"); + } + if (vipSetting.getVipGiftRole() == 0) { + throw new ServiceException("转赠积分权限未开启"); + } + + AppUser appUser = appUserService.getById(userid); + if (appUser == null) { + throw new ServiceException("用户未找到"); + } + Integer totalPoint = appUser.getLavePoint(); + + PointSetting pointSetting = pointSettingService.getPointSettingByAppUserId(userid); + if (pointSetting == null) { + throw new ServiceException("积分设置未找到"); + } + Integer buyPointOpen = pointSetting.getBuyPointOpen(); + + List<UserPoint> userPointList = list(new LambdaQueryWrapper<UserPoint>() + .eq(UserPoint::getAppUserId, userid)); + Map<Integer, Integer> userBalanceMap = userPointList.stream() + .collect(Collectors.toMap(UserPoint::getType, UserPoint::getBalance)); + + totalPoint -= getAdjustedPoint(userBalanceMap, PointChangeType.CONSUME.getCode(), buyPointOpen == 0); + totalPoint -= getAdjustedPoint(userBalanceMap, PointChangeType.COMMISSION_RETURN.getCode(), pointSetting.getSharePointOpen() == 0); + totalPoint -= getAdjustedPoint(userBalanceMap, PointChangeType.STORE_COMMISSION_RETURN.getCode(), pointSetting.getShopSharePointOpen() == 0); + totalPoint -= getAdjustedPoint(userBalanceMap, PointChangeType.STORE_PERFORMANCE.getCode(), pointSetting.getShopPointOpen() == 0); + totalPoint -= getAdjustedPoint(userBalanceMap, PointChangeType.TECHNICIAN_PERFORMANCE.getCode(), pointSetting.getPersonPointOpen() == 0); + totalPoint -= getAdjustedPoint(userBalanceMap, PointChangeType.NEW_USER_REFERRAL.getCode(), pointSetting.getGetNewPointOpen() == 0); + totalPoint -= getAdjustedPoint(userBalanceMap, PointChangeType.REGISTRATION.getCode(), pointSetting.getGetRegisPointOpen() == 0); + totalPoint -= getAdjustedPoint(userBalanceMap, PointChangeType.WORK_PERFORMANCE.getCode(), pointSetting.getWorkPointOpen() == 0); + + if (point.compareTo(new BigDecimal(totalPoint)) > 0) { + throw new ServiceException("转赠积分不足"); + } + + AppUser appUserForPhoe = appUserService.getOne(new LambdaQueryWrapper<AppUser>() .eq(AppUser::getPhone, phone)); + if (appUserForPhoe == null) { + throw new ServiceException("目标用户未找到"); + } + + appUserForPhoe.setLavePoint(appUserForPhoe.getLavePoint() + point.intValue()); + appUserService.updateById(appUserForPhoe); + + log.info("积分转赠完成,用户ID: {}, 新积分: {}", appUserForPhoe.getId(), appUserForPhoe.getLavePoint()); + } + + private int getAdjustedPoint(Map<Integer, Integer> userBalanceMap, int pointTypeCode, boolean isOpen) { + return isOpen ? 0 : Optional.ofNullable(userBalanceMap.get(pointTypeCode)).orElse(0); } } diff --git a/ruoyi-service/ruoyi-account/src/main/java/com/ruoyi/account/vo/vip/Level.java b/ruoyi-service/ruoyi-account/src/main/java/com/ruoyi/account/vo/vip/Level.java new file mode 100644 index 0000000..855de5c --- /dev/null +++ b/ruoyi-service/ruoyi-account/src/main/java/com/ruoyi/account/vo/vip/Level.java @@ -0,0 +1,60 @@ +package com.ruoyi.account.vo.vip; + +import io.swagger.annotations.Api; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; + +import java.math.BigDecimal; +import java.util.List; + +@Data +public class Level { + + @ApiModelProperty(value = "会员等级id") + private Integer id; + + /** + * 会员名称 + */ + @ApiModelProperty(value = "会员名称") + private String name; + + @ApiModelProperty(value = "会员专属权益") + private String vipInfo; + + @ApiModelProperty(value = "会员说明") + private String vipDesc; + + @ApiModelProperty(value = "消费达到积分 后升级") + private BigDecimal vipLevelUpShop; + + @ApiModelProperty(value = "返佣达到积分 后升级") + private BigDecimal vipLevelUpShare; + + @ApiModelProperty(value = "升级会员的直推用户人数要求") + private Integer vipDirectNum; + @ApiModelProperty(value = "升级会员的团队数要求") + private Integer vipTeamNum; + + @ApiModelProperty(value = "保级:消费x天") + private Integer keepBuyDay; + + @ApiModelProperty(value = "保级:消费x分") + private BigDecimal keepBuyPoint; + + @ApiModelProperty(value = "保级:返佣x天") + private Integer keepShareDay; + + @ApiModelProperty(value = "保级:返佣x分") + private BigDecimal keepSharePoint; + + @ApiModelProperty(value = "保级:门店x天") + private Integer keepShopDay; + + @ApiModelProperty(value = "保级:门店x分") + private BigDecimal keepShopPoint; + + + + +} diff --git a/ruoyi-service/ruoyi-account/src/main/java/com/ruoyi/account/vo/vip/VipLevel.java b/ruoyi-service/ruoyi-account/src/main/java/com/ruoyi/account/vo/vip/VipLevel.java new file mode 100644 index 0000000..a1282ea --- /dev/null +++ b/ruoyi-service/ruoyi-account/src/main/java/com/ruoyi/account/vo/vip/VipLevel.java @@ -0,0 +1,20 @@ +package com.ruoyi.account.vo.vip; + +import io.swagger.annotations.Api; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; + +import java.util.List; + +@Api(tags = "会员等级") +@Data +public class VipLevel { + /** + * 当前等级 + */ + @ApiModelProperty(value = "当前等级") + private Integer currentLevel; + + @ApiModelProperty(value = "会员等级列表") + private List<Level> levelList; +} diff --git a/ruoyi-service/ruoyi-order/src/main/java/com/ruoyi/order/controller/OrderController.java b/ruoyi-service/ruoyi-order/src/main/java/com/ruoyi/order/controller/OrderController.java index 924e14b..5c9cab3 100644 --- a/ruoyi-service/ruoyi-order/src/main/java/com/ruoyi/order/controller/OrderController.java +++ b/ruoyi-service/ruoyi-order/src/main/java/com/ruoyi/order/controller/OrderController.java @@ -7,13 +7,10 @@ import com.ruoyi.common.core.web.page.TableDataInfo; import com.ruoyi.common.security.service.TokenService; import com.ruoyi.order.service.OrderService; +import io.swagger.annotations.*; import org.springframework.web.bind.annotation.*; import com.ruoyi.order.vo.OrderDetailVO; import com.ruoyi.system.api.model.LoginUser; -import io.swagger.annotations.Api; -import io.swagger.annotations.ApiImplicitParam; -import io.swagger.annotations.ApiImplicitParams; -import io.swagger.annotations.ApiOperation; import com.ruoyi.order.model.Order; import javax.annotation.Resource; @@ -44,8 +41,8 @@ @ApiImplicitParams({ @ApiImplicitParam(value = "订单状态", name = "status", required = true, dataType = "int"), }) - @GetMapping("/getMyOrderList/{status}") - public TableDataInfo getMyOrderList(@PathVariable("status") Integer status){ + @GetMapping("/getMyOrderList") + public TableDataInfo getMyOrderList(@ApiParam("订单状态") Integer status){ startPage(); LoginUser loginUserApplet = tokenService.getLoginUserApplet(); return getDataTable(orderService.selectOrderListByUserId(status, loginUserApplet.getUserid())); diff --git a/ruoyi-service/ruoyi-order/src/main/java/com/ruoyi/order/mapper/OrderMapper.java b/ruoyi-service/ruoyi-order/src/main/java/com/ruoyi/order/mapper/OrderMapper.java index 6fa0cb8..eae8c99 100644 --- a/ruoyi-service/ruoyi-order/src/main/java/com/ruoyi/order/mapper/OrderMapper.java +++ b/ruoyi-service/ruoyi-order/src/main/java/com/ruoyi/order/mapper/OrderMapper.java @@ -3,12 +3,13 @@ import com.baomidou.mybatisplus.core.mapper.BaseMapper; import com.ruoyi.order.vo.OrderVO; import com.ruoyi.order.model.Order; +import org.apache.ibatis.annotations.Param; import java.util.List; /** * <p> - * Mapper 接口 + * Mapper 接口 * </p> * * @author luodangjia @@ -18,5 +19,5 @@ /** * 查询用户id */ - List<OrderVO> selectOrderListByUserId(Integer status, Long userId); + List<OrderVO> selectOrderListByUserId(@Param("status") Integer status, @Param("userId") Long userId); } diff --git a/ruoyi-service/ruoyi-order/src/main/resources/mapper/order/OrderMapper.xml b/ruoyi-service/ruoyi-order/src/main/resources/mapper/order/OrderMapper.xml index 54acfa5..c5188f0 100644 --- a/ruoyi-service/ruoyi-order/src/main/resources/mapper/order/OrderMapper.xml +++ b/ruoyi-service/ruoyi-order/src/main/resources/mapper/order/OrderMapper.xml @@ -28,9 +28,11 @@ o.id, o.order_number, o.order_status, + o.good_name, + o.good_pics, + o.num, o.point, - o.payment_amount, - o.create_time + o.payment_amount ORDER BY o.create_time DESC </select> diff --git a/ruoyi-service/ruoyi-other/src/main/java/com/ruoyi/other/controller/GoodsEvaluateController.java b/ruoyi-service/ruoyi-other/src/main/java/com/ruoyi/other/controller/GoodsEvaluateController.java index 2b55eaf..0f3f1b2 100644 --- a/ruoyi-service/ruoyi-other/src/main/java/com/ruoyi/other/controller/GoodsEvaluateController.java +++ b/ruoyi-service/ruoyi-other/src/main/java/com/ruoyi/other/controller/GoodsEvaluateController.java @@ -1,8 +1,21 @@ package com.ruoyi.other.controller; +import com.ruoyi.account.api.feignClient.AppUserClient; +import com.ruoyi.account.api.model.AppUser; +import com.ruoyi.common.core.domain.R; +import com.ruoyi.common.core.web.page.TableDataInfo; +import com.ruoyi.other.api.domain.Goods; +import com.ruoyi.other.api.domain.GoodsEvaluate; +import com.ruoyi.other.service.GoodsEvaluateService; +import io.swagger.annotations.ApiOperation; +import io.swagger.annotations.ApiParam; +import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RestController; + +import javax.annotation.Resource; +import java.util.List; /** * <p> @@ -15,6 +28,22 @@ @RestController @RequestMapping("/goods-evaluate") public class GoodsEvaluateController { + @Resource + private GoodsEvaluateService goodsEvaluateService; + @Resource + private AppUserClient appUserClient; + + @GetMapping("/goodsList") + @ApiOperation(value = "商品评价", tags = {"小程序-商品评价"}) + public R<List<GoodsEvaluate>> goodsList(@ApiParam("商品id") Integer goodsId){ + List<GoodsEvaluate> list = goodsEvaluateService.lambdaQuery().eq(GoodsEvaluate::getGoodsId, goodsId).list(); + for (GoodsEvaluate goodsEvaluate : list) { + AppUser appUserById = appUserClient.getAppUserById(goodsEvaluate.getAppUserId()); + goodsEvaluate.setUserName(appUserById.getName()); + goodsEvaluate.setAvatar(appUserById.getAvatar()); + } + return R.ok(list); + } } diff --git a/ruoyi-service/ruoyi-other/src/main/java/com/ruoyi/other/controller/ShareController.java b/ruoyi-service/ruoyi-other/src/main/java/com/ruoyi/other/controller/ShareController.java index db05155..783f4e0 100644 --- a/ruoyi-service/ruoyi-other/src/main/java/com/ruoyi/other/controller/ShareController.java +++ b/ruoyi-service/ruoyi-other/src/main/java/com/ruoyi/other/controller/ShareController.java @@ -4,6 +4,7 @@ import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.ruoyi.common.core.domain.R; import com.ruoyi.common.core.web.controller.BaseController; +import com.ruoyi.common.security.service.TokenService; import com.ruoyi.other.api.domain.Share; import com.ruoyi.other.enums.ShareAddType; import com.ruoyi.other.enums.ShareAuditStatus; @@ -31,6 +32,8 @@ public class ShareController extends BaseController { @Resource private ShareService shareService; + @Resource + private TokenService tokenService; /** * 分享列表 @@ -46,14 +49,29 @@ } + @ApiOperation(value = "分享页列表", tags = {"小程序-推广中心"}) + @GetMapping("/recommand/list") + public R<List<Share>> recommandlist(){ + Long userid = tokenService.getLoginUserApplet().getUserid(); + return R.ok(shareService.list(new LambdaQueryWrapper<Share>().eq(Share::getAddType,2) + .eq(Share::getObjectId, userid))); + } + + + /** * 分享添加 */ @ApiOperation(value = "分享添加", tags = {"小程序-个人中心-门店管理-分享添加"}) @PostMapping public R<Void> add(@RequestBody Share share){ - share.setAddType(ShareAddType.STORE.getCode()); - share.setAuditStatus(ShareAuditStatus.WAIT.getCode()); + Long userid = tokenService.getLoginUserApplet().getUserid(); + if (share.getAddType()==1) { + share.setAuditStatus(ShareAuditStatus.WAIT.getCode()); + }else if (share.getAddType()==2){ + share.setAuditStatus(ShareAuditStatus.WAIT.getCode()); + share.setObjectId(userid.toString()); + } share.setDelFlag(0); share.setAppletShare(1); shareService.save(share); diff --git a/ruoyi-service/ruoyi-other/src/main/java/com/ruoyi/other/controller/VipSettingController.java b/ruoyi-service/ruoyi-other/src/main/java/com/ruoyi/other/controller/VipSettingController.java index 4af566f..8f73394 100644 --- a/ruoyi-service/ruoyi-other/src/main/java/com/ruoyi/other/controller/VipSettingController.java +++ b/ruoyi-service/ruoyi-other/src/main/java/com/ruoyi/other/controller/VipSettingController.java @@ -36,9 +36,8 @@ @Resource private VipGoodService vipGoodService; - @GetMapping("/info") - @ApiOperation(value = "获取各级会员信息", tags = {"小程序-个人中心首页", "小程序-会员中心"}) - public R<List<VipSetting>> info() { + @GetMapping("/list") + public R<List<VipSetting>> list() { List<VipSetting> list = vipSettingService.list(); return R.ok(list); } diff --git a/ruoyi-service/ruoyi-other/src/main/java/com/ruoyi/other/vo/TechnicianSubscribeVO.java b/ruoyi-service/ruoyi-other/src/main/java/com/ruoyi/other/vo/TechnicianSubscribeVO.java index 416c846..42ccb7e 100644 --- a/ruoyi-service/ruoyi-other/src/main/java/com/ruoyi/other/vo/TechnicianSubscribeVO.java +++ b/ruoyi-service/ruoyi-other/src/main/java/com/ruoyi/other/vo/TechnicianSubscribeVO.java @@ -54,4 +54,10 @@ */ @ApiModelProperty(value = "预约状态:0=待服务,1=已服务,2=已取消 4 已到期") private Integer status; + + @ApiModelProperty(value = "经度") + private String longitude; + + @ApiModelProperty(value = "纬度") + private String latitude; } diff --git a/ruoyi-service/ruoyi-other/src/main/resources/mapper/other/TechnicianSubscribeMapper.xml b/ruoyi-service/ruoyi-other/src/main/resources/mapper/other/TechnicianSubscribeMapper.xml index 891f3be..d47604c 100644 --- a/ruoyi-service/ruoyi-other/src/main/resources/mapper/other/TechnicianSubscribeMapper.xml +++ b/ruoyi-service/ruoyi-other/src/main/resources/mapper/other/TechnicianSubscribeMapper.xml @@ -31,6 +31,8 @@ ts.`name` shopName, ts.address shopAddress, tt.name technicianName, + ts.longitude, + ts.latitude, tts.subscribe_time, tts.service_mode, CASE -- Gitblit v1.7.1