| | |
| | | package com.dsh.account.controller; |
| | | |
| | | import com.alibaba.nacos.common.utils.Md5Utils; |
| | | import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
| | | import com.alibaba.fastjson.JSONObject; |
| | | import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
| | | import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
| | | import com.baomidou.mybatisplus.extension.api.R; |
| | | import com.dsh.account.dto.BindDto; |
| | | import com.dsh.account.dto.IntroduceUserQuery; |
| | | import com.dsh.account.dto.SelectDto; |
| | | import com.dsh.account.dto.UpdateInfoDto; |
| | | import com.dsh.account.entity.*; |
| | | import com.dsh.account.model.*; |
| | | import com.dsh.account.feignclient.other.VipClient; |
| | | import com.dsh.account.model.AddAppUserVo; |
| | | import com.dsh.account.model.AdvertisementChangeStateDTO; |
| | | import com.dsh.account.model.AppUserByNameAndPhoneDTO; |
| | | import com.dsh.account.model.AppUserIdsByCityName; |
| | | import com.dsh.account.model.JoinPlayPaiVo; |
| | | import com.dsh.account.model.LoginSMSCodeVo; |
| | | import com.dsh.account.model.LoginWeChatVo; |
| | | import com.dsh.account.model.QueryByNamePhone; |
| | | import com.dsh.account.model.query.UserDetailsOfSearch; |
| | | import com.dsh.account.model.query.appUserQuery.QueryAppUser; |
| | | import com.dsh.account.model.vo.QueryAppUserVO; |
| | | import com.dsh.account.service.*; |
| | | import com.dsh.account.service.IVipPaymentService; |
| | | import com.dsh.account.service.TAppGiftService; |
| | | import com.dsh.account.service.TAppUserService; |
| | | import com.dsh.account.service.TCourseInfoRecordService; |
| | | import com.dsh.account.service.TStudentService; |
| | | import com.dsh.account.service.UserIntegralChangesService; |
| | | import com.dsh.account.util.PayMoneyUtil; |
| | | import com.dsh.account.util.ResultUtil; |
| | | import com.dsh.account.util.TokenUtil; |
| | | import com.dsh.account.util.ToolUtil; |
| | | import com.dsh.account.util.wx.WxV3PayConfig; |
| | | import com.dsh.account.vo.VipPaymentVO; |
| | | import com.wechat.pay.contrib.apache.httpclient.util.AesUtil; |
| | | import io.swagger.annotations.ApiImplicitParam; |
| | | import io.swagger.annotations.ApiImplicitParams; |
| | | import io.swagger.annotations.ApiOperation; |
| | | import io.swagger.models.auth.In; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.web.bind.annotation.*; |
| | | import org.springframework.web.bind.annotation.GetMapping; |
| | | import org.springframework.web.bind.annotation.PathVariable; |
| | | 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.ResponseBody; |
| | | import org.springframework.web.bind.annotation.RestController; |
| | | |
| | | import javax.servlet.http.HttpServletRequest; |
| | | import javax.servlet.http.HttpServletResponse; |
| | | import java.io.BufferedReader; |
| | | import java.io.PrintWriter; |
| | | import java.util.*; |
| | | import java.nio.charset.StandardCharsets; |
| | | import java.util.ArrayList; |
| | | import java.util.Date; |
| | | import java.util.List; |
| | | import java.util.Map; |
| | | import java.util.stream.Collectors; |
| | | |
| | | /** |
| | |
| | | |
| | | @Autowired |
| | | private TAppUserService appUserService; |
| | | @Autowired |
| | | private VipClient vipClient; |
| | | |
| | | @Autowired |
| | | private PayMoneyUtil payMoneyUtil; |
| | |
| | | @ResponseBody |
| | | @GetMapping("/base/appUser/getAppUserByPhone/{phone}") |
| | | public TAppUser getAppUserByPhone(@PathVariable("phone") String phone) { |
| | | TAppUser appUser = appUserService.getOne(new QueryWrapper<TAppUser>().eq("phone", phone)); |
| | | TAppUser appUser = appUserService.getOne(new QueryWrapper<TAppUser>().eq("phone", phone) |
| | | .eq("state",1)); |
| | | return appUser; |
| | | } |
| | | |
| | | // todo 短信验证码 |
| | | @ResponseBody |
| | | @PostMapping("/base/appUser/getSMSCode") |
| | | @ApiOperation(value = "获取短信验证码", tags = {"APP-登录注册"}) |
| | |
| | | @ResponseBody |
| | | @PostMapping("/base/appUser/loginSMSCode") |
| | | @ApiOperation(value = "短信验证码登录", tags = {"APP-登录注册"}) |
| | | @ApiImplicitParams({ |
| | | }) |
| | | |
| | | public ResultUtil<String> loginSMSCode(LoginSMSCodeVo loginSMSCodeVo) { |
| | | try { |
| | | return appUserService.loginSMSCode(loginSMSCodeVo); |
| | |
| | | @ApiOperation(value = "购买年度会员", tags = {"APP-成为会员"}) |
| | | @ApiImplicitParams({ |
| | | @ApiImplicitParam(value = "支付方式(1=微信,2=支付宝)", name = "payType", dataType = "int", required = true), |
| | | @ApiImplicitParam(value = "会员卡id", name = "id", 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) { |
| | | public ResultUtil addVipPayment(Integer payType,Integer id) { |
| | | if (ToolUtil.isEmpty(payType)) { |
| | | return ResultUtil.paranErr("payType"); |
| | | } |
| | |
| | | if (null == uid) { |
| | | return ResultUtil.tokenErr(); |
| | | } |
| | | return vipPaymentService.addVipPayment(uid, payType); |
| | | return vipPaymentService.addVipPayment(uid, payType, id); |
| | | } catch (Exception e) { |
| | | e.printStackTrace(); |
| | | return ResultUtil.runErr(); |
| | | } |
| | | } |
| | | @ResponseBody |
| | | @PostMapping("/api/appUser/vipPayment") |
| | | @ApiOperation(value = "页面数据展示", tags = {"APP-成为会员"}) |
| | | @ApiImplicitParams({ |
| | | @ApiImplicitParam(name = "Authorization", value = "用户token(Bearer +token)", required = true, dataType = "String", paramType = "header", defaultValue = "Bearer eyJhbGciOiJIUzUxMiJ9.....") |
| | | }) |
| | | public ResultUtil<VipPaymentVO> vipPayment() { |
| | | |
| | | |
| | | try { |
| | | Integer uid = tokenUtil.getUserIdFormRedis(); |
| | | if (null == uid) { |
| | | return ResultUtil.tokenErr(); |
| | | } |
| | | TAppUser appUser = appUserService.getById(uid); |
| | | VipPaymentVO res = new VipPaymentVO(); |
| | | res.setHeadImg(appUser.getHeadImg()); |
| | | res.setName(appUser.getName()); |
| | | res.setIsVip(appUser.getIsVip()); |
| | | List<Vip> vips = vipClient.listAll(); |
| | | res.setVipList(vips); |
| | | } catch (Exception e) { |
| | | e.printStackTrace(); |
| | | return ResultUtil.runErr(); |
| | | } |
| | | return ResultUtil.success(); |
| | | } |
| | | // |
| | | // /** |
| | | // * 购买年度会员支付微信回调V3版本回调 |
| | | // * |
| | | // * @param request |
| | | // * @param response |
| | | // */ |
| | | // @ResponseBody |
| | | // @PostMapping("/base/appUser/addVipPaymentWeChatCallback1") |
| | | // public void addVipPaymentWeChatCallback1(HttpServletRequest request, HttpServletResponse response) { |
| | | // try { |
| | | // System.err.println("微信回调"); |
| | | // System.err.println("请求" + request); |
| | | // BufferedReader reader = request.getReader(); |
| | | // String string1 = reader.toString(); |
| | | // System.err.println("请求reader" + string1); |
| | | // StringBuilder requestBody = new StringBuilder(); |
| | | // String line; |
| | | // while ((line = reader.readLine()) != null) { |
| | | // requestBody.append(line); |
| | | // } |
| | | // System.err.println("全部请求体" + requestBody); |
| | | // JSONObject jsonObject = JSONObject.parseObject(requestBody.toString()); |
| | | // JSONObject resource = jsonObject.getJSONObject("resource"); |
| | | // |
| | | // AesUtil aesUtil = new AesUtil(WxV3PayConfig.apiV3Key.getBytes(StandardCharsets.UTF_8)); |
| | | // String decryptedData = aesUtil.decryptToString(resource.getString("associated_data").getBytes(StandardCharsets.UTF_8), resource.getString("nonce").getBytes(StandardCharsets.UTF_8), |
| | | // resource.getString("ciphertext")); |
| | | // System.err.println("微信解密的字符串信息" + decryptedData); |
| | | // JSONObject jsonInfo = (JSONObject) JSONObject.parse(decryptedData); |
| | | // String out_trade_no = jsonInfo.getString("out_trade_no"); |
| | | // String transaction_id = jsonInfo.getString("transaction_id"); |
| | | // String trade_state = jsonInfo.getString("trade_state"); |
| | | // if (trade_state.equals("SUCCESS")) { |
| | | // ResultUtil resultUtil = vipPaymentService.addVipPaymentCallback(out_trade_no, transaction_id); |
| | | // if (resultUtil.getCode() == 200) { |
| | | // PrintWriter out = response.getWriter(); |
| | | // out.write("SUCCESS"); |
| | | // out.flush(); |
| | | // out.close(); |
| | | // } |
| | | // } |
| | | // } catch (Exception e) { |
| | | // e.printStackTrace(); |
| | | // } |
| | | // } |
| | | /** |
| | | * 购买年度会员支付微信回调 |
| | | * |
| | |
| | | } |
| | | } |
| | | |
| | | |
| | | /** |
| | | * 购买年度会员支付支付宝回调 |
| | | * |
| | |
| | | @PostMapping("/base/appUser/addVipPaymentAliCallback") |
| | | public void addVipPaymentAliCallback(HttpServletRequest request, HttpServletResponse response) { |
| | | try { |
| | | System.err.println("==============购买优惠卷回调========="); |
| | | Map<String, String> map = payMoneyUtil.alipayCallback(request); |
| | | if (null != map) { |
| | | String out_trade_no = map.get("out_trade_no"); |
| | |
| | | return null; |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * 根据用户id获取用户信息 |
| | | * |
| | | * @param appUserIdList |
| | | * @return |
| | | */ |
| | | @ResponseBody |
| | | @PostMapping("/base/appUser/queryAppUserBatch") |
| | | List<TAppUser> queryAppUserBatch(@RequestBody List<Integer> appUserIdList){ |
| | | return appUserService.listByIds(appUserIdList); |
| | | } |
| | | |
| | | @Autowired |
| | | private UserIntegralChangesService userIntegralChangesService; |
| | |
| | | @PostMapping("/base/appUser/updateAppUser") |
| | | public void updateAppUser(@RequestBody TAppUser appUser) { |
| | | try { |
| | | TAppUser appUser1 = appUserService.getById(appUser.getId()); |
| | | appUserService.updateById(appUser); |
| | | UserIntegralChanges userIntegralChanges = new UserIntegralChanges(); |
| | | userIntegralChanges.setAppUserId(appUser.getId()); |
| | | userIntegralChanges.setOldIntegral(appUser.getIntegral() + appUser.getPoints()); |
| | | userIntegralChanges.setType(5); |
| | | userIntegralChanges.setNewIntegral(appUser.getIntegral()); |
| | | userIntegralChanges.setInsertTime(new Date()); |
| | | userIntegralChanges.setCategory(2); |
| | | userIntegralChangesService.save(userIntegralChanges); |
| | | if(appUser.getIntegral().compareTo(appUser1.getIntegral()) != 0){ |
| | | UserIntegralChanges userIntegralChanges = new UserIntegralChanges(); |
| | | userIntegralChanges.setAppUserId(appUser.getId()); |
| | | userIntegralChanges.setOldIntegral(appUser1.getIntegral()); |
| | | userIntegralChanges.setType(5); |
| | | userIntegralChanges.setNewIntegral(appUser.getIntegral()); |
| | | userIntegralChanges.setInsertTime(new Date()); |
| | | userIntegralChanges.setCategory(2); |
| | | userIntegralChangesService.save(userIntegralChanges); |
| | | } |
| | | |
| | | } catch (Exception e) { |
| | | e.printStackTrace(); |
| | |
| | | System.out.println("=======selectDtos======>" + selectDtos); |
| | | return selectDtos; |
| | | } |
| | | |
| | | |
| | | @PostMapping("/appUser/queryAppUserByCityCode") |
| | | public List<TAppUser> queryAppUserByCityCode(@RequestBody String cityCode){ |
| | | return appUserService.list(new QueryWrapper<TAppUser>() |
| | | .eq("state", 1) |
| | | .eq("cityCode", cityCode) |
| | | ); |
| | | } |
| | | |
| | | |
| | | |
| | | /** |
| | | * 根据城市code获取用户的id集合 |
| | | * @param cityCode 城市code |
| | | * @return |
| | | */ |
| | | @PostMapping("/appUser/getAppUserIds") |
| | | public List<Integer> getAppUserIds(@RequestBody String cityCode){ |
| | | List<TAppUser> list = appUserService.list(new QueryWrapper<TAppUser>().eq("cityCode", cityCode).eq("state", 1)); |
| | | return list.stream().map(TAppUser::getId).collect(Collectors.toList()); |
| | | } |
| | | |
| | | |
| | | /** |
| | | * 根据省市名称所有用户 |
| | | * @param appUserIdsByCityName |
| | | * @return |
| | | */ |
| | | @PostMapping("/appUser/getAppUserIdsByCityName") |
| | | public List<Integer> getAppUserIdsByCityName(@RequestBody AppUserIdsByCityName appUserIdsByCityName){ |
| | | QueryWrapper<TAppUser> queryWrapper = new QueryWrapper<TAppUser>().eq("state", 1); |
| | | if(ToolUtil.isNotEmpty(appUserIdsByCityName.getProvince())){ |
| | | queryWrapper.like("province", appUserIdsByCityName.getProvince()); |
| | | } |
| | | if(ToolUtil.isNotEmpty(appUserIdsByCityName.getCity())){ |
| | | queryWrapper.like("city", appUserIdsByCityName.getCity()); |
| | | } |
| | | List<TAppUser> list = appUserService.list(queryWrapper); |
| | | return list.stream().map(TAppUser::getId).collect(Collectors.toList()); |
| | | } |
| | | |
| | | |
| | | @PostMapping("/appUser/queryAppUserByIds") |
| | | @ResponseBody |
| | | public List<TAppUser> queryAppUserByIds(@RequestBody UserDetailsOfSearch search){ |
| | | LambdaQueryWrapper<TAppUser> tAppUserLambdaQueryWrapper = new LambdaQueryWrapper<>(); |
| | | if(ToolUtil.isNotEmpty(search.getIdCard())){ |
| | | tAppUserLambdaQueryWrapper.eq(TAppUser::getIdCard, search.getIdCard()); |
| | | } |
| | | if(ToolUtil.isNotEmpty(search.getPhone())){ |
| | | tAppUserLambdaQueryWrapper.eq(TAppUser::getPhone, search.getPhone()); |
| | | } |
| | | if(ToolUtil.isNotEmpty(search.getName())){ |
| | | tAppUserLambdaQueryWrapper.eq(TAppUser::getName, search.getName()); |
| | | } |
| | | tAppUserLambdaQueryWrapper.in(TAppUser::getId,search.getUseIds()); |
| | | return appUserService.list(tAppUserLambdaQueryWrapper); |
| | | } |
| | | } |