ruoyi-api/ruoyi-api-account/src/main/java/com/ruoyi/account/api/model/AppUser.java
@@ -81,10 +81,20 @@ @ApiModelProperty(value = "推广人id") @TableField("invite_user_id") private Long inviteUserId; @ApiModelProperty(value = "推广人姓名") @TableField(exist = false) private String inviteUserName; @ApiModelProperty(value = "当前用户顶级的推广人id") @TableField("top_invite_id") private Long topInviteId; @ApiModelProperty(value = "绑定门店id") @TableField("shop_id") private Long shopId; @ApiModelProperty(value = "绑定门店名称") @TableField(exist = false) private String shopName; @ApiModelProperty(value = "合伙人积分数") @TableField("part_point") @@ -130,4 +140,25 @@ @TableField("total_distribution_amount") private BigDecimal total_distribution_amount; @ApiModelProperty("等级1会员数") private Long count1; @ApiModelProperty("等级2会员数") private Long count2; @ApiModelProperty("等级3会员数") private Long count3; @ApiModelProperty("等级4会员数") private Long count4; @ApiModelProperty("等级5会员数") private Long count5; @ApiModelProperty("等级6会员数") private Long count6; @ApiModelProperty("等级7会员数") private Long count7; } ruoyi-api/ruoyi-api-other/src/main/java/com/ruoyi/other/api/factory/StoreFallbackFactory.java
New file @@ -0,0 +1,35 @@ package com.ruoyi.other.api.factory; import com.ruoyi.common.core.domain.R; import com.ruoyi.other.api.domain.Shop; import com.ruoyi.other.api.feignClient.OrderClient; import com.ruoyi.other.api.feignClient.StoreClient; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.cloud.openfeign.FallbackFactory; import org.springframework.stereotype.Component; /** * 充电订单服务降级处理 * * @author ruoyi */ @Component public class StoreFallbackFactory implements FallbackFactory<StoreClient> { private static final Logger log = LoggerFactory.getLogger(StoreFallbackFactory.class); @Override public StoreClient create(Throwable cause) { log.error("商品订单调用失败:{}", cause.getMessage()); return new StoreClient() { @Override public R<Shop> getStoreById(Long id) { return R.fail("根据门店id查询详情:" + cause.getMessage()); } }; } } ruoyi-api/ruoyi-api-other/src/main/java/com/ruoyi/other/api/feignClient/StoreClient.java
New file @@ -0,0 +1,24 @@ package com.ruoyi.other.api.feignClient; import com.ruoyi.common.core.constant.ServiceNameConstants; import com.ruoyi.common.core.domain.R; import com.ruoyi.other.api.domain.Shop; import com.ruoyi.other.api.factory.OrderFallbackFactory; import com.ruoyi.other.api.factory.StoreFallbackFactory; import org.springframework.cloud.openfeign.FeignClient; import org.springframework.web.bind.annotation.PostMapping; import org.springframework.web.bind.annotation.RequestParam; import java.util.List; /** * 后台订单服务 * @author ruoyi */ @FeignClient(contextId = "StoreClient", value = ServiceNameConstants.OTHER_SERVICE, fallbackFactory = StoreFallbackFactory.class) public interface StoreClient { @PostMapping(value = "/shop/getDetailById") public R<Shop> getStoreById(@RequestParam("id") Long id); } ruoyi-service/ruoyi-account/src/main/java/com/ruoyi/account/controller/AppUserController.java
@@ -1,10 +1,15 @@ package com.ruoyi.account.controller; import java.time.LocalDateTime; import com.ruoyi.account.api.model.AppUser; import com.ruoyi.account.api.model.UserCancellationLog; import com.ruoyi.account.service.AppUserService; import com.ruoyi.account.service.UserCancellationLogService; import com.ruoyi.common.core.domain.R; import com.ruoyi.common.security.service.TokenService; import com.ruoyi.other.api.domain.Shop; import com.ruoyi.other.api.feignClient.StoreClient; import org.junit.Test; import org.springframework.web.bind.annotation.PostMapping; import org.springframework.web.bind.annotation.RequestBody; @@ -37,6 +42,12 @@ @Resource private TokenService tokenService; @Resource private AppUserService appUserService; @Resource private StoreClient storeClient; @@ -99,26 +110,74 @@ return AjaxResult.success(); } @Resource private TokenService tokenService; @Resource private AppUserService appUserService; @ResponseBody @PostMapping("/info") @ApiOperation(value = "我的资料", tags = {"小程序-个人中心首页-我的资料"}) public R<AppUser> info(){ Long userId = tokenService.getLoginUserApplet().getUserId(); AppUser user = appUserService.getById(userId); return R.ok(user); } @Resource private UserCancellationLogService userCancellationLogService; @ResponseBody @PostMapping("/unregis") @ApiOperation(value = "注销", tags = {"小程序-个人中心首页-我的资料"}) public R unregis(){ Long userId = tokenService.getLoginUserApplet().getUserId(); AppUser user = appUserService.getById(userId); //添加注销记录 UserCancellationLog userCancellationLog = new UserCancellationLog(); userCancellationLog.setAppUserId(user.getId()); userCancellationLog.setVipId(user.getVipId()); userCancellationLogService.save(userCancellationLog); return R.ok(); } @PostMapping("/index") @ApiOperation(value = "个人中心首页", tags = {"小程序-个人中心首页"}) @Test public void index(){ public R<AppUser> index(){ System.err.println("=-===="); // Long userId = tokenService.getLoginUserApplet().getUserId(); } public void test(Long userId,Integer count){ List<AppUser> list = appUserService.lambdaQuery().eq(AppUser::getInviteUserId, userId).list(); count = count + list.size(); for (AppUser appUser : list) { test(appUser.getId(),count); } Long userId = tokenService.getLoginUserApplet().getUserId(); //当前用户信息 AppUser user = appUserService.getById(userId); //当前用户的推荐人信息 if (user.getInviteUserId()!=null){ AppUser inviteUser = appUserService.getById(user.getInviteUserId()); user.setInviteUserName(inviteUser.getName()); } //当前绑定门店的店铺信息 if (user.getShopId()!=null){ R<Shop> storeById = storeClient.getStoreById(user.getShopId()); if (storeById.getData()!=null){ user.setShopName(storeById.getData().getName()); } } Long count1 = appUserService.lambdaQuery().eq(AppUser::getVipId, 1).eq(AppUser::getTopInviteId, userId).count(); Long count2 = appUserService.lambdaQuery().eq(AppUser::getVipId, 2).eq(AppUser::getTopInviteId, userId).count(); Long count3 = appUserService.lambdaQuery().eq(AppUser::getVipId, 3).eq(AppUser::getTopInviteId, userId).count(); Long count4 = appUserService.lambdaQuery().eq(AppUser::getVipId, 4).eq(AppUser::getTopInviteId, userId).count(); Long count5 = appUserService.lambdaQuery().eq(AppUser::getVipId, 5).eq(AppUser::getTopInviteId, userId).count(); Long count6 = appUserService.lambdaQuery().eq(AppUser::getVipId, 6).eq(AppUser::getTopInviteId, userId).count(); Long count7 = appUserService.lambdaQuery().eq(AppUser::getVipId, 7).eq(AppUser::getTopInviteId, userId).count(); user.setCount1(count1); user.setCount2(count2); user.setCount3(count3); user.setCount4(count4); user.setCount5(count5); user.setCount6(count6); user.setCount7(count7); return R.ok(user); } } } ruoyi-service/ruoyi-account/src/main/java/com/ruoyi/account/controller/UserAddressController.java
@@ -1,8 +1,16 @@ package com.ruoyi.account.controller; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RestController; import com.ruoyi.account.api.model.AppUser; import com.ruoyi.account.api.model.UserAddress; import com.ruoyi.account.service.UserAddressService; import com.ruoyi.common.core.domain.R; import com.ruoyi.common.security.service.TokenService; import io.swagger.annotations.ApiOperation; import org.springframework.web.bind.annotation.*; import javax.annotation.Resource; import java.util.List; /** * <p> @@ -16,5 +24,50 @@ @RequestMapping("/user-address") public class UserAddressController { @Resource private TokenService tokenService; @Resource private UserAddressService userAddressService; @ResponseBody @PostMapping("/add") @ApiOperation(value = "添加", tags = {"小程序-个人中心首页-我的地址"}) public R add(@RequestBody UserAddress userAddress){ Long userId = tokenService.getLoginUserApplet().getUserId(); userAddress.setAppUserId(userId); userAddressService.save(userAddress); return R.ok(); } @ResponseBody @PostMapping("/edit") @ApiOperation(value = "编辑", tags = {"小程序-个人中心首页-我的地址"}) public R edit(@RequestBody UserAddress userAddress){ userAddressService.updateById(userAddress); return R.ok(); } @ResponseBody @PostMapping("/delete") @ApiOperation(value = "删除", tags = {"小程序-个人中心首页-我的地址"}) public R edit(@RequestParam Integer id){ userAddressService.removeById(id); return R.ok(); } @ResponseBody @PostMapping("/set") @ApiOperation(value = "设为默认", tags = {"小程序-个人中心首页-我的地址"}) public R set(@RequestParam Integer id){ Long userId = tokenService.getLoginUserApplet().getUserId(); List<UserAddress> list = userAddressService.lambdaQuery().eq(UserAddress::getAppUserId, userId).list(); for (UserAddress userAddress : list) { userAddress.setIsDefault(0); } userAddressService.updateBatchById(list); UserAddress byId = userAddressService.getById(id); byId.setIsDefault(1); userAddressService.updateById(byId); return R.ok(); } } ruoyi-service/ruoyi-other/src/main/java/com/ruoyi/other/controller/ShopController.java
@@ -4,6 +4,7 @@ import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; 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.controller.BaseController; import com.ruoyi.common.core.web.domain.AjaxResult; import com.ruoyi.common.security.utils.SecurityUtils; @@ -15,10 +16,7 @@ import io.swagger.annotations.Api; 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.RequestParam; import org.springframework.web.bind.annotation.RestController; import org.springframework.web.bind.annotation.*; import javax.annotation.Resource; import java.util.List; @@ -42,6 +40,14 @@ @Resource private AppUserClient appUserClient; @PostMapping("/getDetailById") public R<Shop> getDetailById(@RequestParam("id") Long id){ Shop byId = shopService.getById(id); return R.ok(byId); } /** * 附近门店列表 */ ruoyi-service/ruoyi-other/src/main/java/com/ruoyi/other/controller/TechnicianSubscribeController.java
@@ -52,7 +52,7 @@ * 取消服务 */ @GetMapping("/cancel") @ApiOperation(value = "取消服务", notes = "取消服务", tags = {"小程序-个人中心-门店管理-预约列表-取消服务"}) @ApiOperation(value = "取消服务", notes = "取消服务", tags = {"小程序-个人中心-门店管理-预约列表-取消服务","小程序-个人中心-我的预约"}) public AjaxResult cancel(@ApiParam(value = "预约id") @RequestParam Long id){ TechnicianSubscribe subscribe = technicianSubscribeService.getOne(new LambdaQueryWrapper<TechnicianSubscribe>() @@ -66,5 +66,16 @@ return success(); } @GetMapping("/home/list") @ApiOperation(value = "列表", notes = "列表", tags = {"小程序-个人中心-我的预约"}) public TableDataInfo homelist(@ApiParam(value = "状态 0=待服务,1=已服务,2=已取消 4 已到期") @RequestParam Integer status){ startPage(); List<TechnicianSubscribeVO> list = technicianSubscribeService .getTechnicianSubscribeByUser(SecurityUtils.getUserId(),status); return getDataTable(list); } } ruoyi-service/ruoyi-other/src/main/java/com/ruoyi/other/controller/VipSettingController.java
@@ -1,8 +1,17 @@ package com.ruoyi.other.controller; import com.ruoyi.account.api.model.AppUser; import com.ruoyi.common.core.domain.R; import com.ruoyi.other.api.domain.VipSetting; import com.ruoyi.other.service.VipSettingService; import io.swagger.annotations.ApiOperation; import org.springframework.web.bind.annotation.PostMapping; 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 +24,13 @@ @RestController @RequestMapping("/vip-setting") public class VipSettingController { @Resource private VipSettingService vipSettingService; @PostMapping("/info") @ApiOperation(value = "获取各级会员信息", tags = {"小程序-个人中心首页"}) public R<List<VipSetting>> info(){ List<VipSetting> list = vipSettingService.list(); return R.ok(list); } } ruoyi-service/ruoyi-other/src/main/java/com/ruoyi/other/mapper/TechnicianSubscribeMapper.java
@@ -24,4 +24,6 @@ */ public List<TechnicianSubscribeVO> getTechnicianSubscribeByUserAndShop(@Param("userId") Long userId, @Param("shopId") Long shopId); public List<TechnicianSubscribeVO> getTechnicianSubscribeByUser(@Param("userId") Long userId, @Param("status") Integer status); } ruoyi-service/ruoyi-other/src/main/java/com/ruoyi/other/service/TechnicianSubscribeService.java
@@ -20,5 +20,6 @@ * 查询用于指定门店的相关预约记录 */ List<TechnicianSubscribeVO> getTechnicianSubscribeByUserAndShop(Long userId, Long shopId); List<TechnicianSubscribeVO> getTechnicianSubscribeByUser(Long userId, Integer status); } ruoyi-service/ruoyi-other/src/main/java/com/ruoyi/other/service/impl/TechnicianSubscribeServiceImpl.java
@@ -28,4 +28,8 @@ public List<TechnicianSubscribeVO> getTechnicianSubscribeByUserAndShop(Long userId, Long shopId) { return technicianSubscribeMapper.getTechnicianSubscribeByUserAndShop(userId, shopId); } @Override public List<TechnicianSubscribeVO> getTechnicianSubscribeByUser(Long userId, Integer status) { return technicianSubscribeMapper.getTechnicianSubscribeByUser(userId, status); } } ruoyi-service/ruoyi-other/src/main/java/com/ruoyi/other/vo/TechnicianSubscribeVO.java
@@ -49,6 +49,6 @@ /** * 预约状态:0=待服务,1=已服务,2=已取消 */ @ApiModelProperty(value = "预约状态:0=待服务,1=已服务,2=已取消") @ApiModelProperty(value = "预约状态:0=待服务,1=已服务,2=已取消 4 已到期") private Integer status; } ruoyi-service/ruoyi-other/src/main/resources/mapper/other/TechnicianSubscribeMapper.xml
@@ -24,4 +24,35 @@ AND tts.del_flag = 0 ORDER BY tts.create_time DESC </select> <select id="getTechnicianSubscribeByUser" resultType="com.ruoyi.other.vo.TechnicianSubscribeVO"> SELECT * from ( SELECT tts.user_address, ts.`name` shopName, ts.address shopAddress, tt.name technicianName, tts.subscribe_time, tts.service_mode, CASE WHEN tts.subscribe_time lt; NOW() THEN 4 ELSE tts.status END AS status FROM t_technician_subscribe tts LEFT JOIN t_technician tt ON tts.technician_id = tt.id AND tt.del_flag = 0 LEFT JOIN t_shop ts ON tt.shop_id = ts.id AND ts.del_flag = 0 WHERE tts.app_user_id = #{userId} AND tts.del_flag = 0 ORDER BY tts.create_time DESC ) o <where> <if test="status !=null"> o.status = #{status} </if> </where> </select> </mapper>