| | |
| | | } |
| | | vipInfoVO.setTime(datum.getTime()); |
| | | vipInfoVO.setAmount(datum.getAmount()); |
| | | vipInfoVOS.add(vipInfoVO); |
| | | } |
| | | return AjaxResult.ok(vipInfoVOS); |
| | | } |
| | |
| | | List<TPage> data = managementClient.getPage1().getData(); |
| | | for (TPage datum : data) { |
| | | if (datum.getType() == 4) { |
| | | return AjaxResult.success(datum); |
| | | return AjaxResult.success(datum.getImg()); |
| | | } |
| | | } |
| | | return AjaxResult.success(); |
| | | } |
| | | @PostMapping("/parentPage") |
| | | @ApiOperation(value = "平板", tags = {"家长端-启动页"}) |
| | | public AjaxResult<String> parentPage() { |
| | | List<TPage> data = managementClient.getPage1().getData(); |
| | | for (TPage datum : data) { |
| | | if (datum.getType() == 3) { |
| | | return AjaxResult.success(datum.getImg()); |
| | | } |
| | | } |
| | | return AjaxResult.success(); |
| | | } |
| | | @PostMapping("/parentPage1") |
| | | @ApiOperation(value = "手机", tags = {"家长端-启动页"}) |
| | | public AjaxResult<String> parentPage1() { |
| | | List<TPage> data = managementClient.getPage1().getData(); |
| | | for (TPage datum : data) { |
| | | if (datum.getType() == 2) { |
| | | return AjaxResult.success(datum.getImg()); |
| | | } |
| | | } |
| | | return AjaxResult.success(); |
| | | } |
| | | @PostMapping("/getProtocol") |
| | | @ApiOperation(value = "获取协议", tags = {"家长端-协议"}) |
| | | @ApiImplicitParams({ |
| | | @ApiImplicitParam(value = "类型 1用户 2隐私 3注销", name = "type", dataType = "string", required = true), |
| | | }) |
| | | public AjaxResult<String> getProtocol(Integer type) { |
| | | String data = managementClient.agreement1(type).getData(); |
| | | return AjaxResult.success(data); |
| | | } |
| | | |
| | | @PostMapping("/useGuide") |
| | |
| | | */ |
| | | @GetMapping("/sendPhoneCode") |
| | | @ApiOperation(value = "发送手机验证码", tags = {"家长端/学习端-发送手机验证码"}) |
| | | @ApiImplicitParams({ |
| | | @ApiImplicitParam(value = "手机号", name = "phone", dataType = "string", required = true), |
| | | }) |
| | | public AjaxResult sendPhoneCode(@RequestParam String phone) { |
| | | return userService.phoneCode(phone) ? AjaxResult.success() : AjaxResult.error(); |
| | | } |
| | | |
| | | /** |
| | | * 家长端 学习端都可用 |
| | | * |
| | | * @param url app网页链接 |
| | | */ |
| | | @GetMapping("/weiXinShare") |
| | | @ApiOperation(value = "微信分享", tags = {"微信分享"}) |
| | | @ApiImplicitParams({ |
| | | @ApiImplicitParam(value = "应用分享url地址", name = "url", dataType = "string", required = true), |
| | | }) |
| | | public AjaxResult weiXinShare(@RequestParam String url) { |
| | | return AjaxResult.success(userService.weiXinShare(url)); |
| | | } |
| | | |
| | | @PostMapping("/deleteUser") |
| | |
| | | if (StringUtils.hasLength(headImg)) { |
| | | byId.setHeadImg(headImg); |
| | | } |
| | | userService.updateById(byId); |
| | | userService.saveOrUpdate(byId); |
| | | return AjaxResult.success("修改成功"); |
| | | } |
| | | @ResponseBody |
| | | @PostMapping("/base/wxRefund") |
| | | public void cancelMySiteCallback(HttpServletRequest request, HttpServletResponse response) { |
| | | try { |
| | | Map<String, String> map = payMoneyUtil.wxRefundCallback(request); |
| | | if (null != map) { |
| | | String code = map.get("out_refund_no"); |
| | | String refund_id = map.get("refund_id"); |
| | | String result = map.get("result"); |
| | | TVipOrder one = vipOrderService.getOne(new QueryWrapper<TVipOrder>() |
| | | .eq("outTradeNo", code) |
| | | .eq("payState", 3)); |
| | | one.setBackTime(new Date()); |
| | | vipOrderService.updateById(one); |
| | | Integer userId = one.getUserId(); |
| | | TUser byId1 = userService.getById(userId); |
| | | // 判断用户是不是第一次充值 |
| | | List<TVipOrder> list = vipOrderService.list(new QueryWrapper<TVipOrder>() |
| | | .eq("userId", userId) |
| | | .eq("payState", 2) |
| | | .orderByDesc("createTime")); |
| | | int size = list.size(); |
| | | if (size == 0){ |
| | | // 证明这是用户第一次充值会员 将首次充值会员时间和会员到期时间清空 |
| | | byId1.setVipEndTime(null); |
| | | byId1.setVipPayTime(null); |
| | | userService.updateById(byId1); |
| | | }else{ |
| | | // 最近的一次充值会员时间 |
| | | TVipOrder tVipOrder = list.get(0); |
| | | // 将会员到期时间回退到上一次 |
| | | byId1.setVipEndTime(tVipOrder.getTime()); |
| | | userService.updateById(byId1); |
| | | } |
| | | |
| | | PrintWriter out = response.getWriter(); |
| | | out.write(result); |
| | | out.flush(); |
| | | out.close(); |
| | | } |
| | | } catch (Exception e) { |
| | | e.printStackTrace(); |
| | | } |
| | | } |
| | | @PostMapping("/vipBack/{id}") |
| | | @ApiOperation(value = "会员退款", tags = {"管理后台-会员退款"}) |
| | | public R vipBack(@PathVariable("id") Integer id) throws AlipayApiException { |
| | |
| | | String transactionId = byId.getTransactionId(); |
| | | // 内部订单号 |
| | | String outTradeNo = byId.getOutTradeNo(); |
| | | switch (byId.getPayType()) { |
| | | switch (byId.getPayType()){ |
| | | case 1: |
| | | // 微信退款 |
| | | Map<String, String> stringStringMap = payMoneyUtil.wxRefund(transactionId, outTradeNo, byId.getMoney().toString(), byId.getMoney().toString(), "/base/wxRefund"); |
| | | if (stringStringMap.get("code").equals("SUCCESS")) { |
| | | byId.setPayState(3); |
| | | byId.setBackTime(new Date()); |
| | | vipOrderService.updateById(byId); |
| | | // 用户的vip剩余时间减少 |
| | | Calendar calendar = Calendar.getInstance(); |
| | | calendar.setTime(new Date()); |
| | | calendar.add(Calendar.MONTH, -byId.getCount()); |
| | | Date dateAfterOneMonth = calendar.getTime(); |
| | | Integer userId = byId.getUserId(); |
| | | TUser byId1 = userService.getById(userId); |
| | | // 判断用户是不是第一次充值 |
| | | List<TVipOrder> list = vipOrderService.list(new QueryWrapper<TVipOrder>() |
| | | .eq("userId", userId) |
| | | .eq("payState", 2) |
| | | .orderByDesc("createTime")); |
| | | int size = list.size(); |
| | | if (size == 0) { |
| | | // 证明这是用户第一次充值会员 将首次充值会员时间和会员到期时间清空 |
| | | byId1.setVipEndTime(null); |
| | | byId1.setVipPayTime(null); |
| | | userService.updateById(byId1); |
| | | } else { |
| | | // 最近的一次充值会员时间 |
| | | TVipOrder tVipOrder = list.get(0); |
| | | // 将会员到期时间回退到上一次 |
| | | byId1.setVipEndTime(tVipOrder.getTime()); |
| | | userService.updateById(byId1); |
| | | } |
| | | |
| | | return R.ok(); |
| | | } else { |
| | | return R.fail(stringStringMap.get("msg")); |
| | | if (null == stringStringMap) { |
| | | return R.fail("取消退款异常"); |
| | | } |
| | | String result_code = stringStringMap.get("result_code"); |
| | | if (!"SUCCESS".equals(result_code)) { |
| | | return R.fail(stringStringMap.get("return_msg")); |
| | | } |
| | | byId.setPayState(3); |
| | | vipOrderService.updateById(byId); |
| | | case 2: |
| | | // 支付宝退款 |
| | | Map<String, String> stringStringMap1 = payMoneyUtil.aliRefund(transactionId, byId.getMoney().toString()); |
| | | if (stringStringMap1.get("code").equals("10000")) { |
| | | byId.setPayState(3); |
| | | byId.setBackTime(new Date()); |
| | | vipOrderService.updateById(byId); |
| | | // 用户的vip剩余时间减少 |
| | | Calendar calendar = Calendar.getInstance(); |
| | | calendar.setTime(new Date()); |
| | | calendar.add(Calendar.MONTH, -byId.getCount()); |
| | | Date dateAfterOneMonth = calendar.getTime(); |
| | | Integer userId = byId.getUserId(); |
| | | TUser byId1 = userService.getById(userId); |
| | | // 判断用户是不是第一次充值 |
| | | List<TVipOrder> list = vipOrderService.list(new QueryWrapper<TVipOrder>() |
| | | .eq("userId", userId) |
| | | .eq("payState", 2) |
| | | .orderByDesc("createTime")); |
| | | int size = list.size(); |
| | | if (size == 0) { |
| | | // 证明这是用户第一次充值会员 将首次充值会员时间和会员到期时间清空 |
| | | byId1.setVipEndTime(null); |
| | | byId1.setVipPayTime(null); |
| | | userService.updateById(byId1); |
| | | } else { |
| | | // 最近的一次充值会员时间 |
| | | TVipOrder tVipOrder = list.get(0); |
| | | // 将会员到期时间回退到上一次 |
| | | byId1.setVipEndTime(tVipOrder.getTime()); |
| | | userService.updateById(byId1); |
| | | } |
| | | return R.ok(); |
| | | } else { |
| | | return R.fail(stringStringMap1.get("msg")); |
| | | Map<String, String> stringStringMap1 = payMoneyUtil.aliRefund(transactionId,byId.getMoney().toString()); |
| | | if (null == stringStringMap1) { |
| | | return R.fail("取消退款异常"); |
| | | } |
| | | String code = stringStringMap1.get("code"); |
| | | if (!"10000".equals(code)) { |
| | | return R.fail(stringStringMap1.get("return_msg")); |
| | | } |
| | | byId.setPayState(3); |
| | | byId.setBackTime(new Date()); |
| | | vipOrderService.updateById(byId); |
| | | // 用户的vip剩余时间减少 |
| | | Calendar calendar = Calendar.getInstance(); |
| | | calendar.setTime(new Date()); |
| | | calendar.add(Calendar.MONTH, -byId.getCount()); |
| | | Date dateAfterOneMonth = calendar.getTime(); |
| | | Integer userId = byId.getUserId(); |
| | | TUser byId1 = userService.getById(userId); |
| | | // 判断用户是不是第一次充值 |
| | | List<TVipOrder> list = vipOrderService.list(new QueryWrapper<TVipOrder>() |
| | | .eq("userId", userId) |
| | | .eq("payState", 2) |
| | | .orderByDesc("createTime")); |
| | | int size = list.size(); |
| | | if (size == 0){ |
| | | // 证明这是用户第一次充值会员 将首次充值会员时间和会员到期时间清空 |
| | | byId1.setVipEndTime(null); |
| | | byId1.setVipPayTime(null); |
| | | userService.updateById(byId1); |
| | | }else{ |
| | | // 最近的一次充值会员时间 |
| | | TVipOrder tVipOrder = list.get(0); |
| | | // 将会员到期时间回退到上一次 |
| | | byId1.setVipEndTime(tVipOrder.getTime()); |
| | | userService.updateById(byId1); |
| | | } |
| | | return R.ok(); |
| | | } |
| | | return R.ok(); |
| | | } |