From 53e7558400dcacecdce70e39ebfe1727740f9296 Mon Sep 17 00:00:00 2001 From: puzhibing <393733352@qq.com> Date: 星期六, 25 十一月 2023 17:20:06 +0800 Subject: [PATCH] 重写课包支付和排课逻辑 --- cloud-server-account/src/main/java/com/dsh/account/controller/AppUserController.java | 214 ++++++++++++++++++++++++++-------------------------- 1 files changed, 107 insertions(+), 107 deletions(-) diff --git a/cloud-server-account/src/main/java/com/dsh/account/controller/AppUserController.java b/cloud-server-account/src/main/java/com/dsh/account/controller/AppUserController.java index 7c21dbc..2286c62 100644 --- a/cloud-server-account/src/main/java/com/dsh/account/controller/AppUserController.java +++ b/cloud-server-account/src/main/java/com/dsh/account/controller/AppUserController.java @@ -55,30 +55,33 @@ @Autowired private TAppGiftService appGiftService; + /** * 根据介绍有礼id查询当前活动参与次数 */ @ResponseBody @PostMapping("/base/appUser/getActivityPeoples") - public Integer getActivityPeoples(@RequestBody Integer activityId){ + public Integer getActivityPeoples(@RequestBody Integer activityId) { int activityId1 = appGiftService.list(new QueryWrapper<TAppGift>().eq("activityId", activityId)) .size(); return activityId1; } + /** * 介绍有礼 -- 参与用户列表 */ @ResponseBody @PostMapping("/base/appUser/queryIntroduceAll") - public List<IntroduceUser> queryIntroduceAll(@RequestBody IntroduceUserQuery query){ + public List<IntroduceUser> queryIntroduceAll(@RequestBody IntroduceUserQuery query) { return appGiftService.queryIntroduceAll(query); } + /** * 获取所有用户 */ @ResponseBody @PostMapping("/base/appUser/queryAppUserList") - public List<TAppUser> queryAppUserList(@RequestBody AppUserByNameAndPhoneDTO dto){ + public List<TAppUser> queryAppUserList(@RequestBody AppUserByNameAndPhoneDTO dto) { return appUserService.queryAPPUserByNameAndPhone(dto); } @@ -87,41 +90,45 @@ */ @ResponseBody @PostMapping("/base/appUser/queryAPPUserByNameAndPhone") - public List<TAppUser> queryAPPUserByNameAndPhone(@RequestBody AppUserByNameAndPhoneDTO dto){ + public List<TAppUser> queryAPPUserByNameAndPhone(@RequestBody AppUserByNameAndPhoneDTO dto) { return appUserService.queryAPPUserByNameAndPhone(dto); } + /** * 根据用户id获取用户信息 + * * @param appUserId * @return */ @ResponseBody @PostMapping("/base/appUser/queryAppUser1") - public TAppUser queryAppUser1(@RequestBody Integer appUserId){ - TAppUser appUser = appUserService.getById(appUserId); - return appUser; + public TAppUser queryAppUser1(@RequestBody Integer appUserId) { + TAppUser appUser = appUserService.getById(appUserId); + return appUser; } + /** * 冻结/解冻 1=解冻 2=冻结 */ @RequestMapping("/base/appUser/changeState") - public Object changeState(@RequestBody AdvertisementChangeStateDTO dto){ + public Object changeState(@RequestBody AdvertisementChangeStateDTO dto) { return appUserService.changeState(dto); } + /** - * 后台添加 + * 后台添加 */ @RequestMapping("/base/appUser/addAppUser1") - public Object addAppUser1(@RequestBody TAppUser query){ + public Object addAppUser1(@RequestBody TAppUser query) { // 修改 - if (query.getId()!=null){ - TAppUser phone = appUserService.getOne(new QueryWrapper<TAppUser>().eq("phone", query.getPhone()).ne("id",query.getId())); - if (null != phone){ + if (query.getId() != null) { + TAppUser phone = appUserService.getOne(new QueryWrapper<TAppUser>().eq("phone", query.getPhone()).ne("id", query.getId())); + if (null != phone) { return 5001; } - }else { + } else { TAppUser phone = appUserService.getOne(new QueryWrapper<TAppUser>().eq("phone", query.getPhone())); - if (null != phone){ + if (null != phone) { return 5001; } } @@ -135,27 +142,27 @@ */ @ResponseBody @RequestMapping("/base/appUser/listAll") - public List<QueryAppUserVO> listAll(@RequestBody QueryAppUser query){ + public List<QueryAppUserVO> listAll(@RequestBody QueryAppUser query) { List<QueryAppUserVO> queryAppUserVOS = appUserService.listAll(query); ArrayList<QueryAppUserVO> res = new ArrayList<>(); - if (query.getUserIds()!=null && query.getUserIds().size()!=0){ + if (query.getUserIds() != null && query.getUserIds().size() != 0) { List<QueryAppUserVO> queryAppUserVOS1 = appUserService.listAll1(query); queryAppUserVOS.addAll(queryAppUserVOS1); } List<QueryAppUserVO> collect = queryAppUserVOS.stream().distinct().collect(Collectors.toList()); for (QueryAppUserVO vo : collect) { // 会员到期时间小于当前时间或者会员到期时间为null 则会员过期 - if (vo.getVipEndTime()!=null && vo.getVipEndTime().after(new Date())){ + if (vo.getVipEndTime() != null && vo.getVipEndTime().after(new Date())) { vo.setIsVip(1); - }else{ + } else { vo.setIsVip(0); } - if (query.getIsVip() != null && (!query.getIsVip().equals("")) ){ - if (vo.getIsVip() == query.getIsVip()){ + if (query.getIsVip() != null && (!query.getIsVip().equals(""))) { + if (vo.getIsVip() == query.getIsVip()) { res.add(vo); } - }else{ + } else { res.add(vo); } } @@ -167,7 +174,7 @@ */ @ResponseBody @GetMapping("/base/appUser/getAppUserByPhone/{phone}") - public TAppUser getAppUserByPhone(@PathVariable("phone") String phone){ + public TAppUser getAppUserByPhone(@PathVariable("phone") String phone) { TAppUser appUser = appUserService.getOne(new QueryWrapper<TAppUser>().eq("phone", phone)); return appUser; } @@ -180,17 +187,17 @@ @ApiImplicitParam(value = "类型(1:登录,2:注册,3:修改密码,4:忘记密码)", name = "type", dataType = "int", required = true), @ApiImplicitParam(value = "电话号码", name = "phone", dataType = "string", required = true) }) - public ResultUtil getSMSCode(Integer type, String phone){ - if(ToolUtil.isEmpty(phone)){ + public ResultUtil getSMSCode(Integer type, String phone) { + if (ToolUtil.isEmpty(phone)) { return ResultUtil.paranErr("phone"); } - if(ToolUtil.isEmpty(type)){ + if (ToolUtil.isEmpty(type)) { return ResultUtil.paranErr("type"); } try { ResultUtil smsCode = appUserService.getSMSCode(type, phone); return smsCode; - }catch (Exception e){ + } catch (Exception e) { e.printStackTrace(); return ResultUtil.runErr(); } @@ -199,20 +206,21 @@ @Autowired private TStudentService studentService; + @ResponseBody @PostMapping("/base/appUser/logOff") @ApiOperation(value = "注销", tags = {"注销"}) @ApiImplicitParams({ @ApiImplicitParam(value = "账号id", name = "appId", dataType = "int", required = true) }) - public ResultUtil<String> logOff(Integer appId){ + public ResultUtil<String> logOff(Integer appId) { try { appUserService.removeById(appId); - studentService.remove(new QueryWrapper<TStudent>().eq("appUserId",appId)); + studentService.remove(new QueryWrapper<TStudent>().eq("appUserId", appId)); return ResultUtil.success("注销成功"); - }catch (Exception e){ + } catch (Exception e) { e.printStackTrace(); return ResultUtil.runErr(); } @@ -224,10 +232,10 @@ @ApiOperation(value = "注册用户", tags = {"APP-登录注册"}) @ApiImplicitParams({ }) - public ResultUtil addAppUser(AddAppUserVo addAppUserVo){ + public ResultUtil addAppUser(AddAppUserVo addAppUserVo) { try { return appUserService.addAppUser(addAppUserVo); - }catch (Exception e){ + } catch (Exception e) { e.printStackTrace(); return ResultUtil.runErr(); } @@ -241,21 +249,20 @@ @ApiImplicitParam(value = "电话号码", name = "phone", dataType = "string", required = true), @ApiImplicitParam(value = "登录密码", name = "password", dataType = "string", required = true) }) - public ResultUtil<String> loginPassword(String phone, String password){ - if(ToolUtil.isEmpty(phone)){ + public ResultUtil<String> loginPassword(String phone, String password) { + if (ToolUtil.isEmpty(phone)) { return ResultUtil.paranErr("phone"); } - if(ToolUtil.isEmpty(password)){ + if (ToolUtil.isEmpty(password)) { return ResultUtil.paranErr("password"); } try { return appUserService.loginPassword(phone, password); - }catch (Exception e){ + } catch (Exception e) { e.printStackTrace(); return ResultUtil.runErr(); } } - @ResponseBody @@ -263,23 +270,24 @@ @ApiOperation(value = "短信验证码登录", tags = {"APP-登录注册"}) @ApiImplicitParams({ }) - public ResultUtil<String> loginSMSCode(LoginSMSCodeVo loginSMSCodeVo){ + public ResultUtil<String> loginSMSCode(LoginSMSCodeVo loginSMSCodeVo) { try { return appUserService.loginSMSCode(loginSMSCodeVo); - }catch (Exception e){ + } catch (Exception e) { e.printStackTrace(); return ResultUtil.runErr(); } } + @ResponseBody @PostMapping("/base/appUser/bind") @ApiOperation(value = "微信登录绑定手机号", tags = {"APP-登录注册"}) @ApiImplicitParams({ }) - public ResultUtil bind(BindDto dto){ + public ResultUtil bind(BindDto dto) { try { return appUserService.bind(dto); - }catch (Exception e){ + } catch (Exception e) { e.printStackTrace(); return ResultUtil.runErr(); } @@ -291,15 +299,14 @@ @ApiOperation(value = "微信登录", tags = {"APP-登录注册"}) @ApiImplicitParams({ }) - public ResultUtil<String> loginWeChat(LoginWeChatVo loginWeChatVo){ + public ResultUtil<String> loginWeChat(LoginWeChatVo loginWeChatVo) { try { return appUserService.loginWechat(loginWeChatVo); - }catch (Exception e){ + } catch (Exception e) { e.printStackTrace(); return ResultUtil.runErr(); } } - @ResponseBody @@ -307,22 +314,18 @@ @ApiOperation(value = "修改个人信息", tags = {"APP-登录注册"}) @ApiImplicitParams({ }) - public ResultUtil<String> updateInfo(UpdateInfoDto dto){ + public ResultUtil<String> updateInfo(UpdateInfoDto dto) { try { Integer uid = tokenUtil.getUserIdFormRedis(); - if(null == uid){ + if (null == uid) { return ResultUtil.tokenErr(); } - return appUserService.updateInfo(dto,uid); - }catch (Exception e){ + return appUserService.updateInfo(dto, uid); + } catch (Exception e) { e.printStackTrace(); return ResultUtil.runErr(); } } - - - - @ResponseBody @@ -333,19 +336,19 @@ @ApiImplicitParam(value = "短信验证码", name = "code", dataType = "string", required = true), @ApiImplicitParam(value = "新密码", name = "password", dataType = "string", required = true) }) - public ResultUtil updatePassword(String phone, String code, String password){ - if(ToolUtil.isEmpty(phone)){ + public ResultUtil updatePassword(String phone, String code, String password) { + if (ToolUtil.isEmpty(phone)) { return ResultUtil.paranErr("phone"); } - if(ToolUtil.isEmpty(code)){ + if (ToolUtil.isEmpty(code)) { return ResultUtil.paranErr("code"); } - if(ToolUtil.isEmpty(password)){ + if (ToolUtil.isEmpty(password)) { return ResultUtil.paranErr("password"); } try { return appUserService.updatePassword(phone, code, password); - }catch (Exception e){ + } catch (Exception e) { e.printStackTrace(); return ResultUtil.runErr(); } @@ -360,24 +363,23 @@ @ApiImplicitParam(value = "短信验证码", name = "code", dataType = "string", required = true), @ApiImplicitParam(value = "新密码", name = "password", dataType = "string", required = true) }) - public ResultUtil forgetPassword(String phone, String code, String password){ - if(ToolUtil.isEmpty(phone)){ + public ResultUtil forgetPassword(String phone, String code, String password) { + if (ToolUtil.isEmpty(phone)) { return ResultUtil.paranErr("phone"); } - if(ToolUtil.isEmpty(code)){ + if (ToolUtil.isEmpty(code)) { return ResultUtil.paranErr("code"); } - if(ToolUtil.isEmpty(password)){ + if (ToolUtil.isEmpty(password)) { return ResultUtil.paranErr("password"); } try { return appUserService.updatePassword(phone, code, password); - }catch (Exception e){ + } catch (Exception e) { e.printStackTrace(); return ResultUtil.runErr(); } } - @ResponseBody @@ -388,23 +390,20 @@ @ApiImplicitParam(value = "纬度", name = "lat", dataType = "string", required = false), @ApiImplicitParam(name = "Authorization", value = "用户token(Bearer +token)", required = true, dataType = "String", paramType = "header", defaultValue = "Bearer eyJhbGciOiJIUzUxMiJ9.....") }) - public ResultUtil<JoinPlayPaiVo> queryJoinPlayPai(String lon, String lat){ - + public ResultUtil<JoinPlayPaiVo> queryJoinPlayPai(String lon, String lat) { + try { Integer uid = tokenUtil.getUserIdFormRedis(); - if(null == uid){ + if (null == uid) { return ResultUtil.tokenErr(); } JoinPlayPaiVo joinPlayPaiVo = appUserService.queryJoinPlayPai(uid, lon, lat); return ResultUtil.success(joinPlayPaiVo); - }catch (Exception e){ + } catch (Exception e) { e.printStackTrace(); return ResultUtil.runErr(); } } - - - @ResponseBody @@ -414,50 +413,47 @@ @ApiImplicitParam(value = "支付方式(1=微信,2=支付宝)", name = "payType", dataType = "int", required = true), @ApiImplicitParam(name = "Authorization", value = "用户token(Bearer +token)", required = true, dataType = "String", paramType = "header", defaultValue = "Bearer eyJhbGciOiJIUzUxMiJ9.....") }) - public ResultUtil addVipPayment(Integer payType){ - if(ToolUtil.isEmpty(payType)){ + public ResultUtil addVipPayment(Integer payType) { + if (ToolUtil.isEmpty(payType)) { return ResultUtil.paranErr("payType"); } try { Integer uid = tokenUtil.getUserIdFormRedis(); - if(null == uid){ + if (null == uid) { return ResultUtil.tokenErr(); } return vipPaymentService.addVipPayment(uid, payType); - }catch (Exception e){ + } catch (Exception e) { e.printStackTrace(); return ResultUtil.runErr(); } } - - - - /** * 购买年度会员支付微信回调 + * * @param request * @param response */ @ResponseBody @PostMapping("/base/appUser/addVipPaymentWeChatCallback") - public void addVipPaymentWeChatCallback(HttpServletRequest request, HttpServletResponse response){ + public void addVipPaymentWeChatCallback(HttpServletRequest request, HttpServletResponse response) { try { Map<String, String> map = payMoneyUtil.weixinpayCallback(request); - if(null != map){ + if (null != map) { String out_trade_no = map.get("out_trade_no"); String transaction_id = map.get("transaction_id"); String result = map.get("result"); ResultUtil resultUtil = vipPaymentService.addVipPaymentCallback(out_trade_no, transaction_id); - if(resultUtil.getCode() == 200){ + if (resultUtil.getCode() == 200) { PrintWriter out = response.getWriter(); out.write(result); out.flush(); out.close(); } } - }catch (Exception e){ + } catch (Exception e) { e.printStackTrace(); } } @@ -465,28 +461,29 @@ /** * 购买年度会员支付支付宝回调 + * * @param request * @param response */ @ResponseBody @PostMapping("/base/appUser/addVipPaymentAliCallback") - public void addVipPaymentAliCallback(HttpServletRequest request, HttpServletResponse response){ + public void addVipPaymentAliCallback(HttpServletRequest request, HttpServletResponse response) { try { System.err.println("==============购买优惠卷回调========="); Map<String, String> map = payMoneyUtil.alipayCallback(request); - if(null != map){ + if (null != map) { String out_trade_no = map.get("out_trade_no"); String trade_no = map.get("trade_no"); String appUserId = map.get("passback_params"); ResultUtil resultUtil = vipPaymentService.addVipPaymentCallback(out_trade_no, trade_no); - if(resultUtil.getCode() == 200){ + if (resultUtil.getCode() == 200) { PrintWriter out = response.getWriter(); out.write("success"); out.flush(); out.close(); } } - }catch (Exception e){ + } catch (Exception e) { e.printStackTrace(); } } @@ -494,16 +491,17 @@ /** * 根据用户id获取用户信息 + * * @param appUserId * @return */ @ResponseBody @PostMapping("/base/appUser/queryAppUser") - public TAppUser queryAppUser(@RequestBody Integer appUserId){ + public TAppUser queryAppUser(@RequestBody Integer appUserId) { try { TAppUser appUser = appUserService.getById(appUserId); return appUser; - }catch (Exception e){ + } catch (Exception e) { e.printStackTrace(); return null; } @@ -512,25 +510,27 @@ @Autowired private UserIntegralChangesService userIntegralChangesService; + /** * 修改用户信息 + * * @param appUser */ @ResponseBody @PostMapping("/base/appUser/updateAppUser") - public void updateAppUser(@RequestBody TAppUser appUser){ + public void updateAppUser(@RequestBody TAppUser appUser) { try { appUserService.updateById(appUser); UserIntegralChanges userIntegralChanges = new UserIntegralChanges(); userIntegralChanges.setAppUserId(appUser.getId()); - userIntegralChanges.setOldIntegral(appUser.getIntegral()+appUser.getPoints()); + userIntegralChanges.setOldIntegral(appUser.getIntegral() + appUser.getPoints()); userIntegralChanges.setType(5); userIntegralChanges.setNewIntegral(appUser.getIntegral()); userIntegralChanges.setInsertTime(new Date()); userIntegralChanges.setCategory(2); userIntegralChangesService.save(userIntegralChanges); - }catch (Exception e){ + } catch (Exception e) { e.printStackTrace(); } } @@ -538,38 +538,38 @@ @PostMapping("/base/appUser/getAllUser") @ResponseBody - public List<TAppUser> getAllUser(){ + public List<TAppUser> getAllUser() { try { return appUserService.list(); - }catch (Exception e){ + } catch (Exception e) { e.printStackTrace(); return new ArrayList<>(); } } @PostMapping("/base/appUser/queryByNamePhone") - public List<TAppUser> queryByNamePhone(@RequestBody QueryByNamePhone queryByNamePhone){ + public List<TAppUser> queryByNamePhone(@RequestBody QueryByNamePhone queryByNamePhone) { try { LambdaQueryWrapper<TAppUser> tAppUserLambdaQueryWrapper = new LambdaQueryWrapper<>(); - if(ToolUtil.isNotEmpty(queryByNamePhone.getName())){ - tAppUserLambdaQueryWrapper.like(TAppUser::getName,queryByNamePhone.getName()); + if (ToolUtil.isNotEmpty(queryByNamePhone.getName())) { + tAppUserLambdaQueryWrapper.like(TAppUser::getName, queryByNamePhone.getName()); } - if(ToolUtil.isNotEmpty(queryByNamePhone.getPhone())){ - tAppUserLambdaQueryWrapper.like(TAppUser::getPhone,queryByNamePhone.getPhone()); + if (ToolUtil.isNotEmpty(queryByNamePhone.getPhone())) { + tAppUserLambdaQueryWrapper.like(TAppUser::getPhone, queryByNamePhone.getPhone()); } List<TAppUser> list = appUserService.list(tAppUserLambdaQueryWrapper); return list; - }catch (Exception e){ + } catch (Exception e) { e.printStackTrace(); return new ArrayList<>(); } } @PostMapping("/base/appUser/queryById") - public TAppUser queryById(@RequestBody Integer appUserId){ + public TAppUser queryById(@RequestBody Integer appUserId) { try { return appUserService.getById(appUserId); - }catch (Exception e){ + } catch (Exception e) { e.printStackTrace(); return new TAppUser(); } @@ -578,27 +578,27 @@ /** * 根据名称模糊搜索用户 + * * @param name * @return */ @ResponseBody @PostMapping("/appUser/queryAppUserListByName") - public List<TAppUser> queryAppUserListByName(@RequestBody String name){ + public List<TAppUser> queryAppUserListByName(@RequestBody String name) { return appUserService.list(new QueryWrapper<TAppUser>().eq("state", 1).like("name", name)); } - @PostMapping("/appUser/addCourseInfoRecord") - public Boolean addCourseInfoRecord(@RequestBody TCourseInfoRecord tCourseInfoRecord){ + public Boolean addCourseInfoRecord(@RequestBody TCourseInfoRecord tCourseInfoRecord) { boolean save = courseInfoRecordService.save(tCourseInfoRecord); return save; } @PostMapping("/appUser/getSelects") - public List<SelectDto> getSelects(@RequestBody List<Integer> studentIds){ - List<SelectDto> selectDtos = appUserService.getSelects(studentIds); - System.out.println("=======selectDtos======>"+selectDtos); + public List<SelectDto> getSelects(@RequestBody List<Integer> studentIds) { + List<SelectDto> selectDtos = appUserService.getSelects(studentIds); + System.out.println("=======selectDtos======>" + selectDtos); return selectDtos; } } -- Gitblit v1.7.1