ruoyi-api/ruoyi-api-account/src/main/java/com/ruoyi/account/api/factory/AppUserClientFallbackFactory.java
@@ -32,11 +32,18 @@ } @Override public R<Long> getCouponCount(Long userId, Long couponId) { public R<Long> getCouponCount(Long userId, Integer couponId) { log.error("获取优惠券数量失败:{}", cause.getMessage()); throw new RuntimeException("获取优惠券数量失败"); } @Override public R<Long> getVipCount(Long userId, Integer vipId) { log.error("获取直推会员数失败:{}", cause.getMessage()); throw new RuntimeException("获取直推会员数失败"); } }; } } ruoyi-api/ruoyi-api-account/src/main/java/com/ruoyi/account/api/feignClient/AppUserClient.java
@@ -20,15 +20,19 @@ * @param id * @return */ @PostMapping("/appUser/getAppUserById") @PostMapping("/app-user/getAppUserById") AppUser getAppUserById(@RequestParam("id") Long id); /** * 根据id编辑用户 */ @PostMapping("/appUser/editAppUserById") @PostMapping("/app-user/editAppUserById") R<Void> editAppUserById(@RequestParam("appUser") AppUser appUser); @PostMapping("/appUser/getCouponCount") @PostMapping("/app-user/getCouponCount") R<Long> getCouponCount(@RequestParam("userId")Long userId, @RequestParam("couponId") Integer couponId ); @PostMapping("/app-user/getVipCount") R<Long> getVipCount(@RequestParam("userId")Long userId, @RequestParam("vipId") Integer vipId ); } ruoyi-api/ruoyi-api-other/src/main/java/com/ruoyi/other/api/dto/IndexConfigSetDto.java
@@ -11,8 +11,12 @@ private String pic1; @ApiModelProperty("跳转类型1 - 1无2外部链接3商品详情4秒杀商品详情5领卷中心") private Integer direct1; @ApiModelProperty("跳转内容1") private String content1; @ApiModelProperty("宣传图片2") private String pic2; @ApiModelProperty("跳转内容2") private String content2; @ApiModelProperty("跳转类型2 - 1无2外部链接3商品详情4秒杀商品详情5领卷中心") private String direct2; @ApiModelProperty("公司简介") ruoyi-api/ruoyi-api-other/src/main/java/com/ruoyi/other/api/dto/StartPageSetDto.java
New file @@ -0,0 +1,18 @@ package com.ruoyi.other.api.dto; import io.swagger.annotations.ApiModelProperty; import lombok.Data; @Data public class StartPageSetDto { @ApiModelProperty("启动页倒计时") private Integer waitTime; @ApiModelProperty("1图片2视频") private Integer type; @ApiModelProperty("对应文件地址") private String url; } ruoyi-service/ruoyi-account/src/main/java/com/ruoyi/account/controller/AppUserController.java
@@ -4,8 +4,10 @@ import com.ruoyi.account.api.model.AppUser; import com.ruoyi.account.api.model.UserCancellationLog; import com.ruoyi.account.api.model.UserCoupon; import com.ruoyi.account.service.AppUserService; import com.ruoyi.account.service.UserCancellationLogService; import com.ruoyi.account.service.UserCouponService; import com.ruoyi.common.core.domain.R; import com.ruoyi.common.security.service.TokenService; import com.ruoyi.other.api.domain.Shop; @@ -56,7 +58,16 @@ private AppUserService appUserService; @Resource private StoreClient storeClient; @Resource private UserCouponService userCouponService; @ResponseBody @PostMapping("/mobileLogin") @ApiOperation(value = "手机号登录") public AjaxResult<LoginVo> mobileLogin(@RequestBody MobileLogin mobileLogin){ return appUserService.mobileLogin(mobileLogin); } @ResponseBody @@ -68,11 +79,32 @@ @ResponseBody @PostMapping("/mobileLogin") @ApiOperation(value = "手机号登录") public AjaxResult<LoginVo> mobileLogin(@RequestBody MobileLogin mobileLogin){ return appUserService.mobileLogin(mobileLogin); @PostMapping("/getAppUserById") public AppUser getAppUserById(@RequestParam("id") Long id){ return appUserService.getById(id); } @ResponseBody @PostMapping("/editAppUserById") public R<Void> editAppUserById(@RequestParam("appUser") AppUser appUser){ appUserService.updateById(appUser); return R.ok(); } @ResponseBody @PostMapping("/getCouponCount") public R<Long> getCouponCount(@RequestParam("userId")Long userId, @RequestParam("couponId") Integer couponId ){ Long count = userCouponService.lambdaQuery().eq(UserCoupon::getAppUserId, userId).eq(UserCoupon::getCouponId, couponId).count(); return R.ok(count); } @ResponseBody @PostMapping("/getVipCount") public R<Long> getVipCount(@RequestParam("userId")Long userId, @RequestParam("vipId") Integer vipId ){ appUserService.lambdaQuery().eq(AppUser::getInviteUserId, userId).eq(AppUser::getVipId, vipId).count() return R.ok(count); } @@ -147,6 +179,8 @@ } @PostMapping("/index") @ApiOperation(value = "个人中心首页", tags = {"小程序-个人中心首页"}) public R<AppUser> index(){ ruoyi-service/ruoyi-other/src/main/java/com/ruoyi/other/controller/SystemConfigController.java
@@ -6,6 +6,7 @@ import com.ruoyi.common.core.domain.R; import com.ruoyi.other.api.domain.SystemConfig; import com.ruoyi.other.api.dto.IndexConfigSetDto; import com.ruoyi.other.api.dto.StartPageSetDto; import com.ruoyi.other.service.SystemConfigService; import org.springframework.web.bind.annotation.*; import io.swagger.annotations.ApiOperation; @@ -50,5 +51,31 @@ } @PostMapping("/index/start") @ApiOperation(value = "宣传图片-公司简介", tags = {"小程序-启动页"}) public R<StartPageSetDto> indexstart(){ SystemConfig one = systemConfigService.lambdaQuery().eq(SystemConfig::getType, 1).one(); if (one==null){ return R.ok(); } StartPageSetDto indexConfigSetDto = JSONObject.parseObject(one.getContent(), StartPageSetDto.class); return R.ok(indexConfigSetDto); } @PostMapping("/startPage/add") @ApiOperation(value = "添加", tags = {"后台-广告管理-启动页管理"}) public R startPageadd(@RequestBody StartPageSetDto startPageSetDto){ //先删除type=1的数据 List<SystemConfig> list = systemConfigService.lambdaQuery().eq(SystemConfig::getType, 1).list(); systemConfigService.removeBatchByIds(list); SystemConfig systemConfig = new SystemConfig(); systemConfig.setType(1); systemConfig.setContent(JSON.toJSONString(startPageSetDto)); systemConfigService.save(systemConfig); return R.ok(); } } ruoyi-service/ruoyi-other/src/main/java/com/ruoyi/other/controller/TechnicianController.java
@@ -54,61 +54,61 @@ private TechnicianSubscribeService technicianSubscribeService; @Resource private TokenService tokenService; @PostMapping("/shop/list") @ApiOperation(value = "获取门店的技师列表", tags = {"小程序-门店详情-技师预约"}) public R<Page<Technician>> shoplist(@RequestParam Integer shopId,@RequestParam Integer pageNum,@RequestParam Integer pageSize){ //查出技师列表 Page<Technician> page = technicianService.lambdaQuery().eq(Technician::getShopId, shopId).eq(Technician::getStatus, 2).page(Page.of(pageNum, pageSize)); for (Technician technician : page.getRecords()) { //查出技师订单 R<List<Long>> orderIdsByTechId = orderClient.getOrderIdsByTechId(technician.getId()); if (orderIdsByTechId.getData().isEmpty()){ technician.setGrade(new BigDecimal(0)); technician.setServeCount(0); continue; } //查出技师评价 List<GoodsEvaluate> list = goodsEvaluateService.lambdaQuery().in(GoodsEvaluate::getOrderId, orderIdsByTechId.getData()).list(); // @PostMapping("/shop/list") // @ApiOperation(value = "获取门店的技师列表", tags = {"小程序-门店详情-技师预约"}) // public R<Page<Technician>> shoplist(@RequestParam Integer shopId,@RequestParam Integer pageNum,@RequestParam Integer pageSize){ // //查出技师列表 // Page<Technician> page = technicianService.lambdaQuery().eq(Technician::getShopId, shopId).eq(Technician::getStatus, 2).page(Page.of(pageNum, pageSize)); // for (Technician technician : page.getRecords()) { // //查出技师订单 // R<List<Long>> orderIdsByTechId = orderClient.getOrderIdsByTechId(technician.getId()); // if (orderIdsByTechId.getData().isEmpty()){ // technician.setGrade(new BigDecimal(0)); // technician.setServeCount(0); // continue; // } // //查出技师评价 // List<GoodsEvaluate> list = goodsEvaluateService.lambdaQuery().in(GoodsEvaluate::getOrderId, orderIdsByTechId.getData()).list(); // // //算出平均分并保留一位小数 // BigDecimal avg = list.stream().map(GoodsEvaluate::getGrade).reduce(BigDecimal.ZERO, BigDecimal::add).divide(new BigDecimal(list.size()), 1, BigDecimal.ROUND_HALF_UP); // technician.setGrade(avg); // technician.setServeCount(orderIdsByTechId.getData().size()); // // } // return R.ok(page); // } //算出平均分并保留一位小数 BigDecimal avg = list.stream().map(GoodsEvaluate::getGrade).reduce(BigDecimal.ZERO, BigDecimal::add).divide(new BigDecimal(list.size()), 1, BigDecimal.ROUND_HALF_UP); technician.setGrade(avg); technician.setServeCount(orderIdsByTechId.getData().size()); } return R.ok(page); } @PostMapping("/shop/detail") @ApiOperation(value = "获取门店的技师详情", tags = {"小程序-门店详情-技师预约"}) public R<Technician> shopdetail(@RequestParam Integer techId){ //查出技师列表 Technician technician = technicianService.getById(techId); //查出技师订单 R<List<Long>> orderIdsByTechId = orderClient.getOrderIdsByTechId(technician.getId()); if (orderIdsByTechId.getData().isEmpty()){ technician.setGrade(new BigDecimal(0)); technician.setServeCount(0); return R.ok(technician); } //查出技师评价 List<GoodsEvaluate> list = goodsEvaluateService.lambdaQuery().in(GoodsEvaluate::getOrderId, orderIdsByTechId.getData()).list(); //算出平均分并保留一位小数 BigDecimal avg = list.stream().map(GoodsEvaluate::getGrade).reduce(BigDecimal.ZERO, BigDecimal::add).divide(new BigDecimal(list.size()), 1, BigDecimal.ROUND_HALF_UP); technician.setGrade(avg); technician.setServeCount(orderIdsByTechId.getData().size()); return R.ok(technician); } @PostMapping("/shop/tech") @ApiOperation(value = "预约操作", tags = {"小程序-门店详情-技师预约"}) public R<Technician> shoptech(@RequestBody TechnicianSubscribe subscribe){ Long userId = tokenService.getLoginUserApplet().getUserId(); subscribe.setAppUserId(userId); technicianSubscribeService.save(subscribe); return R.ok(); } // @PostMapping("/shop/detail") // @ApiOperation(value = "获取门店的技师详情", tags = {"小程序-门店详情-技师预约"}) // public R<Technician> shopdetail(@RequestParam Integer techId){ // //查出技师列表 // Technician technician = technicianService.getById(techId); // // //查出技师订单 // R<List<Long>> orderIdsByTechId = orderClient.getOrderIdsByTechId(technician.getId()); // if (orderIdsByTechId.getData().isEmpty()){ // technician.setGrade(new BigDecimal(0)); // technician.setServeCount(0); // return R.ok(technician); // } // //查出技师评价 // List<GoodsEvaluate> list = goodsEvaluateService.lambdaQuery().in(GoodsEvaluate::getOrderId, orderIdsByTechId.getData()).list(); // // //算出平均分并保留一位小数 // BigDecimal avg = list.stream().map(GoodsEvaluate::getGrade).reduce(BigDecimal.ZERO, BigDecimal::add).divide(new BigDecimal(list.size()), 1, BigDecimal.ROUND_HALF_UP); // technician.setGrade(avg); // technician.setServeCount(orderIdsByTechId.getData().size()); // return R.ok(technician); // } // @PostMapping("/shop/tech") // @ApiOperation(value = "预约操作", tags = {"小程序-门店详情-技师预约"}) // public R<Technician> shoptech(@RequestBody TechnicianSubscribe subscribe){ // Long userId = tokenService.getLoginUserApplet().getUserid(); // subscribe.setAppUserId(userId); // technicianSubscribeService.save(subscribe); // return R.ok(); // } /** ruoyi-service/ruoyi-other/src/main/java/com/ruoyi/other/controller/VipSettingController.java
@@ -1,9 +1,13 @@ 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.security.service.TokenService; import com.ruoyi.other.api.domain.VipGood; import com.ruoyi.other.api.domain.VipSetting; import com.ruoyi.other.service.VipGoodService; import com.ruoyi.other.service.VipSettingService; import io.swagger.annotations.ApiOperation; import org.springframework.web.bind.annotation.PostMapping; @@ -36,12 +40,72 @@ public class VipSettingController { @Resource private VipSettingService vipSettingService; @Resource private AppUserClient appUserClient; @Resource private TokenService tokenService; @Resource private VipGoodService vipGoodService; @PostMapping("/info") @ApiOperation(value = "获取各级会员信息", tags = {"小程序-个人中心首页"}) @ApiOperation(value = "获取各级会员信息", tags = {"小程序-个人中心首页","小程序-会员中心"}) public R<List<VipSetting>> info(){ List<VipSetting> list = vipSettingService.list(); return R.ok(list); } @PostMapping("/button/agent/check") @ApiOperation(value = "准代理,代理按钮是否展示", tags = {"小程序-个人中心首页","小程序-会员中心"}) public R<Boolean> buttoncheck(@ApiParam("4准代理,5代理")Integer id){ Long userid = tokenService.getLoginUserApplet().getUserid(); AppUser appUserById = appUserClient.getAppUserById(userid); Boolean back = true; VipSetting byId = vipSettingService.getById(id); //第一种判断 if (byId == null) { back = false; }else { if (byId.getVipAgentLevelUpRole() == null || byId.getVipAgentLevelUpRole() == 0) { back = false; } if (byId.getVipLevelUpShop() == null || byId.getVipLevelUpShare() == null) { back = false; } else { if (back && appUserById.getShopPoint().compareTo(byId.getVipLevelUpShop()) > 0 && appUserById.getSharePoint().compareTo(byId.getVipLevelUpShare()) > 0) { back = true; } } if (back) { return R.ok(true); } //第二种判断 if (byId.getVipDirectVipRole()== null || byId.getVipDirectVipRole() == 0||byId.getVipDirectVipNum() == null) { back = false; }else { //拿到当前用户直推钻石会员人数 Long data = appUserClient.getVipCount(userid, 3).getData(); if (data>=byId.getVipDirectVipNum()){ return R.ok(true); } } //第三种判断 List<VipGood> list = vipGoodService.lambdaQuery().eq(VipGood::getVipId, id).list(); for (VipGood vipGood : list) { //挨个判断是否购买商品 } } return R.ok(list); } @GetMapping("getVipSettingById") @@ -49,5 +113,8 @@ public R<VipSetting> getVipSettingById(@ApiParam(value = "会员id") Integer id){ return R.ok(vipSettingService.getById(id)); } }