| | |
| | | package com.ruoyi.account.controller; |
| | | |
| | | |
| | | 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.api.model.UserSignRecord; |
| | | import com.ruoyi.account.service.AppUserService; |
| | | import com.ruoyi.account.service.UserCancellationLogService; |
| | | import com.ruoyi.account.service.UserCouponService; |
| | | import com.ruoyi.account.service.UserSignRecordService; |
| | | import com.ruoyi.common.core.domain.R; |
| | | import com.ruoyi.common.core.web.domain.AjaxResult; |
| | | 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 javax.annotation.Resource; |
| | | import java.time.LocalDate; |
| | | import java.util.ArrayList; |
| | | import java.util.List; |
| | | |
| | | import com.ruoyi.account.vo.*; |
| | | import com.ruoyi.common.core.web.controller.BaseController; |
| | | import com.ruoyi.common.core.web.page.TableDataInfo; |
| | | import org.springframework.web.bind.annotation.*; |
| | | |
| | | /** |
| | | * <p> |
| | |
| | | * @author luodangjia |
| | | * @since 2024-11-21 |
| | | */ |
| | | @Api(tags = {"登录注册-小程序"}) |
| | | @RestController |
| | | @RequestMapping("/app-user") |
| | | public class AppUserController { |
| | | public class AppUserController extends BaseController { |
| | | |
| | | |
| | | |
| | | @Resource |
| | | private TokenService tokenService; |
| | | @Resource |
| | | private AppUserService appUserService; |
| | | @Resource |
| | | private StoreClient storeClient; |
| | | @Resource |
| | | private UserCouponService userCouponService; |
| | | |
| | | @Resource |
| | | private UserSignRecordService userSignRecordService; |
| | | |
| | | |
| | | @ResponseBody |
| | | @PostMapping("/mobileLogin") |
| | | @ApiOperation(value = "手机号登录") |
| | | public R<LoginVo> mobileLogin(@RequestBody MobileLogin mobileLogin){ |
| | | return appUserService.mobileLogin(mobileLogin); |
| | | } |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | @ResponseBody |
| | | @PostMapping("/appletLogin") |
| | | @ApiOperation(value = "小程序一键登录") |
| | | public R<LoginVo> appletLogin(@RequestBody AppletLogin appletLogin){ |
| | | return appUserService.appletLogin(appletLogin); |
| | | } |
| | | |
| | | |
| | | @ResponseBody |
| | | @PostMapping("/getAppUserById") |
| | | public AppUser getAppUserById(@RequestParam("id") Long id){ |
| | | return appUserService.getById(id); |
| | | } |
| | | |
| | | @ResponseBody |
| | | @PostMapping("/editAppUserById") |
| | | public R<Void> editAppUserById(@RequestBody AppUser appUser) { |
| | | appUserService.updateById(appUser); |
| | | return R.ok(); |
| | | |
| | | } |
| | | |
| | | @ResponseBody |
| | | @PostMapping("/getTopUsers") |
| | | public R<List<AppUser>> getTopUsers(@RequestBody AppUser appUser) { |
| | | List<Integer> vipIds = new ArrayList<>(); |
| | | vipIds.add(5); |
| | | vipIds.add(6); |
| | | vipIds.add(7); |
| | | List<AppUser> list = appUserService.lambdaQuery().in(AppUser::getVipId, vipIds).list(); |
| | | return R.ok(list); |
| | | |
| | | } |
| | | |
| | | @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 ){ |
| | | Long count = appUserService.lambdaQuery().eq(AppUser::getInviteUserId, userId).eq(AppUser::getVipId, vipId).count(); |
| | | return R.ok(count); |
| | | } |
| | | |
| | | |
| | | |
| | | |
| | | @ResponseBody |
| | | @PostMapping("/getSMSCode") |
| | | @ApiOperation(value = "获取短信验证码") |
| | | public R getSMSCode(@RequestBody SMSCode smsCode){ |
| | | return appUserService.getSMSCode(smsCode); |
| | | } |
| | | |
| | | |
| | | |
| | | @ResponseBody |
| | | @PostMapping("/registerAccount") |
| | | @ApiOperation(value = "注册新账号") |
| | | public R<LoginVo> registerAccount(@RequestBody RegisterAccount registerAccount){ |
| | | return appUserService.registerAccount(registerAccount); |
| | | } |
| | | |
| | | |
| | | @ResponseBody |
| | | @GetMapping("/getReferrer/{id}") |
| | | @ApiOperation(value = "获取推荐人信息") |
| | | @ApiImplicitParams({ |
| | | @ApiImplicitParam(name = "id", value = "推荐人id", required = true, dataType = "long") |
| | | }) |
| | | public R<String> getReferrer(@PathVariable("id") Long id){ |
| | | AppUser appUser = appUserService.getById(id); |
| | | String phone = appUser.getPhone(); |
| | | phone = phone.substring(0, 3) + "****" + phone.substring(7); |
| | | return R.ok(appUser.getName() + "-" + phone); |
| | | } |
| | | |
| | | |
| | | |
| | | @ResponseBody |
| | | @GetMapping("/getNearbyReferrer") |
| | | @ApiOperation(value = "获取附近推荐人列表") |
| | | public TableDataInfo<NearbyReferrerVo> getNearbyReferrer(NearbyReferrer nearbyReferrer){ |
| | | startPage(); |
| | | List<NearbyReferrerVo> list = appUserService.getNearbyReferrer(nearbyReferrer); |
| | | return getDataTable(list); |
| | | } |
| | | |
| | | |
| | | @ResponseBody |
| | | @PostMapping("/info") |
| | | @ApiOperation(value = "我的资料", tags = {"小程序-个人中心首页-我的资料"}) |
| | | public R<AppUser> info(){ |
| | | Long userId = tokenService.getLoginUserApplet().getUserid(); |
| | | AppUser user = appUserService.getById(userId); |
| | | |
| | | List<UserSignRecord> list = userSignRecordService.lambdaQuery().eq(UserSignRecord::getSignDay, LocalDate.now()).list(); |
| | | if (!list.isEmpty()){ |
| | | user.setIsSign(1); |
| | | }else { |
| | | user.setIsSign(0); |
| | | } |
| | | |
| | | return R.ok(user); |
| | | } |
| | | @Resource |
| | | private UserCancellationLogService userCancellationLogService; |
| | | |
| | | @ResponseBody |
| | | @GetMapping("/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(); |
| | | } |
| | | |
| | | |
| | | |
| | | @ResponseBody |
| | | @GetMapping("/recommend") |
| | | @ApiOperation(value = "推广中心", tags = {"小程序-推广中心"}) |
| | | public R<AppUser> recommend(){ |
| | | Long userId = tokenService.getLoginUserApplet().getUserid(); |
| | | //获取绑定门店 |
| | | AppUser user = appUserService.getById(userId); |
| | | if (user.getShopId()!=null){ |
| | | R<Shop> storeById = storeClient.getStoreById(user.getShopId()); |
| | | if (storeById.getData()!=null){ |
| | | user.setShopName(storeById.getData().getName()); |
| | | user.setShopCover(storeById.getData().getHomePicture()); |
| | | user.setShopAddress(storeById.getData().getAddress()); |
| | | } |
| | | } |
| | | |
| | | //获取绑定上级 |
| | | if (user.getInviteUserId()!=null) { |
| | | AppUser byId = appUserService.getById(user.getInviteUserId()); |
| | | user.setTopUser(byId); |
| | | } |
| | | //获取绑定下级列表 |
| | | List<AppUser> list = appUserService.lambdaQuery().eq(AppUser::getInviteUserId, user.getInviteUserId()).list(); |
| | | for (AppUser appUser : list) { |
| | | Long count1 = appUserService.lambdaQuery().eq(AppUser::getVipId, 1).eq(AppUser::getTopInviteId, 1).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(); |
| | | appUser.setCount1(count1); |
| | | appUser.setCount2(count2); |
| | | appUser.setCount3(count3); |
| | | appUser.setCount4(count4); |
| | | appUser.setCount5(count5); |
| | | appUser.setCount6(count6); |
| | | appUser.setCount7(count7); |
| | | } |
| | | user.setBottomUsers(list); |
| | | |
| | | return R.ok(user); |
| | | } |
| | | |
| | | @ResponseBody |
| | | @GetMapping("/change") |
| | | @ApiOperation(value = "推广中心", tags = {"小程序-推广中心"}) |
| | | public R<AppUser> change(@ApiParam("换绑用户手机号") String phone){ |
| | | Long userId1 = tokenService.getLoginUserApplet().getUserid(); |
| | | AppUser byId = appUserService.getById(userId1); |
| | | //获取绑定门店 |
| | | AppUser user = appUserService.lambdaQuery().eq(AppUser::getPhone,phone).one(); |
| | | if (user==null){ |
| | | return R.fail("当前手机号未注册"); |
| | | } |
| | | byId.setInviteUserId(user.getId()); |
| | | appUserService.updateById(byId); |
| | | return R.ok(); |
| | | } |
| | | |
| | | |
| | | |
| | | @GetMapping("/index") |
| | | @ApiOperation(value = "个人中心首页", tags = {"小程序-个人中心首页"}) |
| | | public R<AppUser> index(){ |
| | | System.err.println("=-===="); |
| | | 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, 1).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); |
| | | |
| | | |
| | | } |
| | | |
| | | @GetMapping("/index/change") |
| | | @ApiOperation(value = "修改个人资料", tags = {"小程序-个人中心首页"}) |
| | | public R<AppUser> indexchange(String avatar,String name){ |
| | | Long userId = tokenService.getLoginUserApplet().getUserid(); |
| | | //当前用户信息 |
| | | AppUser user = appUserService.getById(userId); |
| | | user.setName(name); |
| | | user.setAvatar(avatar); |
| | | appUserService.updateById(user); |
| | | return R.ok(); |
| | | } |
| | | /** |
| | | * 获取用户的祖籍列表 |
| | | */ |
| | | @GetMapping("/getUserAncestorList") |
| | | public R<List<AppUser>> getUserAncestorList(Long id){ |
| | | List<AppUser> list = appUserService.getUserAncestorList(id,null); |
| | | return R.ok(list); |
| | | } |
| | | |
| | | /** |
| | | * 获取用户的直帮上级用户 |
| | | */ |
| | | @ResponseBody |
| | | @PostMapping("/getSuperiorLeader") |
| | | @ApiOperation(value = "获取用户的直帮上级用户") |
| | | public R<AppUser> getSuperiorLeader(@RequestParam("id") Long id) { |
| | | AppUser superiorLeader = appUserService.getSuperiorLeader(id); |
| | | return R.ok(superiorLeader); |
| | | } |
| | | |
| | | |
| | | |