first commit
This commit is contained in:
12
src/main/java/com/sqx/modules/app/annotation/Login.java
Normal file
12
src/main/java/com/sqx/modules/app/annotation/Login.java
Normal file
@@ -0,0 +1,12 @@
|
||||
package com.sqx.modules.app.annotation;
|
||||
|
||||
import java.lang.annotation.*;
|
||||
|
||||
/**
|
||||
* app登录效验
|
||||
*/
|
||||
@Target(ElementType.METHOD)
|
||||
@Retention(RetentionPolicy.RUNTIME)
|
||||
@Documented
|
||||
public @interface Login {
|
||||
}
|
||||
16
src/main/java/com/sqx/modules/app/annotation/LoginUser.java
Normal file
16
src/main/java/com/sqx/modules/app/annotation/LoginUser.java
Normal file
@@ -0,0 +1,16 @@
|
||||
package com.sqx.modules.app.annotation;
|
||||
|
||||
import java.lang.annotation.ElementType;
|
||||
import java.lang.annotation.Retention;
|
||||
import java.lang.annotation.RetentionPolicy;
|
||||
import java.lang.annotation.Target;
|
||||
|
||||
/**
|
||||
* 登录用户信息
|
||||
*
|
||||
*/
|
||||
@Target(ElementType.PARAMETER)
|
||||
@Retention(RetentionPolicy.RUNTIME)
|
||||
public @interface LoginUser {
|
||||
|
||||
}
|
||||
38
src/main/java/com/sqx/modules/app/config/WebMvcConfig.java
Normal file
38
src/main/java/com/sqx/modules/app/config/WebMvcConfig.java
Normal file
@@ -0,0 +1,38 @@
|
||||
package com.sqx.modules.app.config;
|
||||
|
||||
import com.sqx.modules.app.interceptor.AuthorizationInterceptor;
|
||||
import com.sqx.modules.app.resolver.LoginUserHandlerMethodArgumentResolver;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.web.method.support.HandlerMethodArgumentResolver;
|
||||
import org.springframework.web.servlet.config.annotation.CorsRegistry;
|
||||
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
|
||||
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* MVC配置
|
||||
*
|
||||
*/
|
||||
@Configuration
|
||||
public class WebMvcConfig implements WebMvcConfigurer {
|
||||
@Autowired
|
||||
private AuthorizationInterceptor authorizationInterceptor;
|
||||
@Autowired
|
||||
private LoginUserHandlerMethodArgumentResolver loginUserHandlerMethodArgumentResolver;
|
||||
|
||||
@Override
|
||||
public void addInterceptors(InterceptorRegistry registry) {
|
||||
registry.addInterceptor(authorizationInterceptor).addPathPatterns("/app/**");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addArgumentResolvers(List<HandlerMethodArgumentResolver> argumentResolvers) {
|
||||
argumentResolvers.add(loginUserHandlerMethodArgumentResolver);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,70 @@
|
||||
package com.sqx.modules.app.controller;
|
||||
|
||||
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.sqx.common.utils.Result;
|
||||
import com.sqx.modules.app.entity.App;
|
||||
import com.sqx.modules.app.service.AppService;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.Date;
|
||||
|
||||
/**
|
||||
* APP登录授权
|
||||
*
|
||||
*/
|
||||
@RestController
|
||||
@RequestMapping("/appinfo")
|
||||
@Api(value = "APP升级管理", tags = {"APP升级管理"})
|
||||
public class AppUpgradeController {
|
||||
|
||||
@Autowired
|
||||
private AppService iAppService;
|
||||
|
||||
@RequestMapping(value = "/list", method = RequestMethod.GET)
|
||||
@ApiOperation("管理平台升级详情")
|
||||
@ResponseBody
|
||||
public Result list(Integer page,Integer limit) {
|
||||
IPage<App> pages =new Page<>(page,limit);
|
||||
return Result.success().put("data",iAppService.page(pages));
|
||||
}
|
||||
|
||||
|
||||
@RequestMapping(value = "/{id}", method = RequestMethod.GET)
|
||||
@ApiOperation("管理平台升级详情")
|
||||
@ResponseBody
|
||||
public Result getBanner(@PathVariable Long id) {
|
||||
return Result.success().put("data",iAppService.selectAppById(id));
|
||||
}
|
||||
|
||||
@RequestMapping(value = "/save", method = RequestMethod.POST)
|
||||
@ApiOperation("管理平台添加升级信息")
|
||||
@ResponseBody
|
||||
public Result addBanner(@RequestBody App app) {
|
||||
if(app.getId()!=null){
|
||||
iAppService.updateAppById(app);
|
||||
}else{
|
||||
SimpleDateFormat sdf=new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
|
||||
app.setCreateAt(sdf.format(new Date()));
|
||||
iAppService.insertApp(app);
|
||||
}
|
||||
return Result.success();
|
||||
}
|
||||
|
||||
@RequestMapping(value = "/delete/{id}", method = RequestMethod.GET)
|
||||
@ApiOperation("管理平台删除升级信息")
|
||||
public Result deleteBanner(@PathVariable Long id) {
|
||||
iAppService.deleteAppById(id);
|
||||
return Result.success();
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
414
src/main/java/com/sqx/modules/app/controller/UserController.java
Normal file
414
src/main/java/com/sqx/modules/app/controller/UserController.java
Normal file
@@ -0,0 +1,414 @@
|
||||
package com.sqx.modules.app.controller;
|
||||
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.sqx.common.utils.PageUtils;
|
||||
import com.sqx.common.utils.Result;
|
||||
import com.sqx.modules.app.entity.UserEntity;
|
||||
import com.sqx.modules.app.entity.UserMoneyDetails;
|
||||
import com.sqx.modules.app.entity.UserVip;
|
||||
import com.sqx.modules.app.response.HomeMessageResponse;
|
||||
import com.sqx.modules.app.service.UserMoneyDetailsService;
|
||||
import com.sqx.modules.app.service.UserMoneyService;
|
||||
import com.sqx.modules.app.service.UserService;
|
||||
import com.sqx.modules.app.service.UserVipService;
|
||||
import com.sqx.modules.invite.dao.InviteMoneyDao;
|
||||
import com.sqx.modules.invite.entity.InviteMoney;
|
||||
import com.sqx.modules.invite.service.InviteMoneyService;
|
||||
import com.sqx.modules.pay.dao.CashOutDao;
|
||||
import com.sqx.modules.pay.dao.PayDetailsDao;
|
||||
import com.sqx.modules.pay.entity.PayDetails;
|
||||
import com.sqx.modules.pay.service.PayDetailsService;
|
||||
import com.sqx.modules.sys.entity.SysUserEntity;
|
||||
import com.sqx.modules.sys.service.SysUserService;
|
||||
import com.sqx.modules.utils.EasyPoi.ExcelUtils;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import io.swagger.annotations.ApiParam;
|
||||
import org.apache.commons.codec.digest.DigestUtils;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import java.io.IOException;
|
||||
import java.math.BigDecimal;
|
||||
import java.text.ParseException;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.*;
|
||||
|
||||
/**
|
||||
* @author fang
|
||||
* @date 2020/7/30
|
||||
*/
|
||||
@RestController
|
||||
@Api(value = "用户管理", tags = {"用户管理"})
|
||||
@RequestMapping(value = "/user")
|
||||
public class UserController {
|
||||
|
||||
@Autowired
|
||||
private UserService userService;
|
||||
@Autowired
|
||||
private CashOutDao cashOutDao;
|
||||
@Autowired
|
||||
private PayDetailsService payDetailsService;
|
||||
@Autowired
|
||||
private UserMoneyDetailsService userMoneyDetailsService;
|
||||
@Autowired
|
||||
private UserMoneyService userMoneyService;
|
||||
@Autowired
|
||||
private InviteMoneyService inviteMoneyService;
|
||||
@Autowired
|
||||
private InviteMoneyDao inviteMoneyDao;
|
||||
@Autowired
|
||||
private UserVipService userVipService;
|
||||
@Autowired
|
||||
private SysUserService sysUserService;
|
||||
@Autowired
|
||||
private PayDetailsDao payDetailsDao;
|
||||
|
||||
@RequestMapping(value = "/selectUserByInvitationCode", method = RequestMethod.GET)
|
||||
@ApiOperation("获取用户详细信息")
|
||||
@ResponseBody
|
||||
public Result selectUserByInvitationCode(String invitationCode) {
|
||||
Map<String, Object> map = new HashMap<>();
|
||||
UserEntity userEntity = userService.queryByInvitationCode(invitationCode);
|
||||
Long userId=userEntity.getUserId();
|
||||
//查询用户钱包
|
||||
// Double money = cashOutDao.selectMayMoney(userId);
|
||||
InviteMoney inviteMoney = inviteMoneyService.selectInviteMoneyByUserId(userId);
|
||||
Double money = inviteMoney.getMoney();
|
||||
SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
|
||||
String date = simpleDateFormat.format(new Date());
|
||||
//查询本月充值
|
||||
Double consume = payDetailsService.instantselectSumPay(date, userId);
|
||||
//查询本月提现
|
||||
Double income = userMoneyDetailsService.monthIncome(date, userId);
|
||||
//查询邀请人数
|
||||
int count = userService.queryInviterCount(userEntity.getInvitationCode());
|
||||
UserVip userVip = userVipService.selectUserVipByUserId(userId);
|
||||
if(userVip!=null){
|
||||
userEntity.setMember(userVip.getIsVip());
|
||||
userEntity.setEndTime(userVip.getEndTime());
|
||||
userEntity.setVipType(userVip.getVipType());
|
||||
}
|
||||
map.put("userEntity", userEntity);
|
||||
map.put("money", money);
|
||||
map.put("consume", consume);
|
||||
map.put("income", income);
|
||||
map.put("count", count);
|
||||
return Result.success().put("data", map);
|
||||
}
|
||||
|
||||
@RequestMapping(value = "/{userId}", method = RequestMethod.GET)
|
||||
@ApiOperation("获取用户详细信息")
|
||||
@ResponseBody
|
||||
public Result selectUserById(@ApiParam("用户id") @PathVariable Long userId) {
|
||||
Map<String, Object> map = new HashMap<>();
|
||||
UserEntity userEntity = userService.queryByUserId(userId);
|
||||
//查询用户钱包
|
||||
// Double money = cashOutDao.selectMayMoney(userId);
|
||||
InviteMoney inviteMoney = inviteMoneyService.selectInviteMoneyByUserId(userId);
|
||||
Double money = inviteMoney.getMoney();
|
||||
SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
|
||||
String date = simpleDateFormat.format(new Date());
|
||||
//查询本月充值
|
||||
Double consume = payDetailsService.instantselectSumPay(date, userId);
|
||||
//查询本月提现
|
||||
Double income = userMoneyDetailsService.monthIncome(date, userId);
|
||||
//查询邀请人数
|
||||
int count = userService.queryInviterCount(userEntity.getInvitationCode());
|
||||
UserVip userVip = userVipService.selectUserVipByUserId(userId);
|
||||
if(userVip!=null){
|
||||
userEntity.setMember(userVip.getIsVip());
|
||||
userEntity.setEndTime(userVip.getEndTime());
|
||||
userEntity.setVipType(userVip.getVipType());
|
||||
}
|
||||
map.put("userEntity", userEntity);
|
||||
map.put("money", money);
|
||||
map.put("consume", consume);
|
||||
map.put("income", income);
|
||||
map.put("count", count);
|
||||
return Result.success().put("data", map);
|
||||
}
|
||||
|
||||
@RequestMapping(value = "/selectUserList", method = RequestMethod.GET)
|
||||
@ApiOperation("查询所有用户列表")
|
||||
@ResponseBody
|
||||
public Result selectUserList(Integer page, Integer limit,String phone,Integer sex,String platform,
|
||||
String sysPhone,Integer status, Integer member, String inviterCode,
|
||||
String userName, String invitationCode, String startTime, String endTime,
|
||||
String qdCode,String sysUserName,Integer vipType) {
|
||||
return Result.success().put("data", userService.selectUserPage(page, limit, phone, sex, platform, sysPhone, status, member,
|
||||
inviterCode, userName, invitationCode, startTime, endTime,qdCode,sysUserName,vipType));
|
||||
}
|
||||
|
||||
@GetMapping("/userListExcel")
|
||||
public void userListExcel(UserEntity userEntity, String startTime, String endTime, HttpServletResponse response) throws IOException {
|
||||
List<UserEntity> list = userService.userListExcel(startTime, endTime, userEntity);
|
||||
ExcelUtils.exportExcel(list, "用户表", "用户Sheet", UserEntity.class, "用户表", response);
|
||||
}
|
||||
|
||||
|
||||
@RequestMapping(value = "/deleteUserByUserId/{userId}", method = RequestMethod.POST)
|
||||
@ApiOperation("删除用户")
|
||||
@ResponseBody
|
||||
public Result deleteUserByUserId(@PathVariable("userId") Long userId) {
|
||||
userService.removeById(userId);
|
||||
return Result.success();
|
||||
}
|
||||
|
||||
@RequestMapping(value = "/updateUserByUserId", method = RequestMethod.POST)
|
||||
@ApiOperation("修改用户")
|
||||
@ResponseBody
|
||||
public Result updateUserByUserId(@RequestBody UserEntity userEntity) {
|
||||
if(StringUtils.isNotEmpty(userEntity.getPhone())){
|
||||
UserEntity phoneUser = userService.queryByPhone(userEntity.getPhone());
|
||||
if(phoneUser!=null && !phoneUser.getUserId().equals(userEntity.getUserId())){
|
||||
return Result.error("手机号已被其他用户绑定!");
|
||||
}
|
||||
}
|
||||
if(StringUtils.isNotEmpty(userEntity.getQdCode())){
|
||||
SysUserEntity sysUserEntity = sysUserService.getOne(new QueryWrapper<SysUserEntity>().eq("qd_code", userEntity.getQdCode()));
|
||||
if(sysUserEntity==null){
|
||||
return Result.error("渠道码不正确!");
|
||||
}
|
||||
}
|
||||
userService.updateById(userEntity);
|
||||
return Result.success();
|
||||
}
|
||||
|
||||
@RequestMapping(value = "/updateUserStatusByUserId", method = RequestMethod.GET)
|
||||
@ApiOperation("禁用或启用用户")
|
||||
@ResponseBody
|
||||
public Result updateUserByUserId(Long userId) {
|
||||
UserEntity byId = userService.getById(userId);
|
||||
if (byId.getStatus().equals(1)) {
|
||||
byId.setStatus(2);
|
||||
} else {
|
||||
byId.setStatus(1);
|
||||
}
|
||||
userService.updateById(byId);
|
||||
return Result.success();
|
||||
}
|
||||
|
||||
@ApiOperation("修改用户密码")
|
||||
@RequestMapping(value = "/updatePwd", method = RequestMethod.POST)
|
||||
@ResponseBody
|
||||
public Result forgetPwd(String pwd, Long userId) {
|
||||
UserEntity userEntity = userService.selectUserById(userId);
|
||||
userEntity.setPassword(DigestUtils.sha256Hex(pwd));
|
||||
userService.updateById(userEntity);
|
||||
return Result.success();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 获取openid
|
||||
*
|
||||
* @param code 微信code
|
||||
* @return openid
|
||||
*/
|
||||
@GetMapping("/openId/{code:.+}/{userId}")
|
||||
@ApiOperation("根据code获取openid")
|
||||
public Result getOpenid(@PathVariable("code") String code, @PathVariable("userId") Long userId) {
|
||||
return userService.getOpenId(code, userId);
|
||||
}
|
||||
|
||||
/**
|
||||
* 信息分析
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
@GetMapping("/homeMessage")
|
||||
@ApiOperation("信息分析")
|
||||
public Result homeMessage(Long sysUserId) {
|
||||
String qdCode=null;
|
||||
if(sysUserId!=null){
|
||||
qdCode=sysUserService.getById(sysUserId).getQdCode();
|
||||
}
|
||||
HomeMessageResponse homeMessageResponse = new HomeMessageResponse();
|
||||
// 0查总 1查天 2查月 3查年
|
||||
//设置总用户人数
|
||||
homeMessageResponse.setTotalUsers(userService.queryUserCount(0, null,null,qdCode));
|
||||
//设置今日新增
|
||||
homeMessageResponse.setNewToday(userService.queryUserCount(1, null,null,qdCode));
|
||||
//设置本月新增
|
||||
homeMessageResponse.setNewMonth(userService.queryUserCount(2, null,null,qdCode));
|
||||
//设置本年新增
|
||||
homeMessageResponse.setNewYear(userService.queryUserCount(3, null,null,qdCode));
|
||||
//设置总收入
|
||||
homeMessageResponse.setTotalRevenue(userService.queryPayMoney(0,qdCode));
|
||||
//设置今日收入
|
||||
homeMessageResponse.setTodayRevenue(userService.queryPayMoney(1,qdCode));
|
||||
//设置本月收入
|
||||
homeMessageResponse.setMonthRevenue(userService.queryPayMoney(2,qdCode));
|
||||
//设置本年收入
|
||||
homeMessageResponse.setYearRevenue(userService.queryPayMoney(3,qdCode));
|
||||
//查询指定日期下的短剧购买的 量
|
||||
return Result.success().put("data", homeMessageResponse);
|
||||
}
|
||||
|
||||
/**
|
||||
* 短剧分析
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
@GetMapping("/courseMessage")
|
||||
@ApiOperation("短剧分析")
|
||||
public Result courseMessage(Long page, Long limit, String date, int type,Long sysUserId) {
|
||||
Page<Map<String, Object>> iPage = new Page<>(page, limit);
|
||||
IPage<Map<String, Object>> mapIPage = userService.queryCourseOrder(iPage, type, date,sysUserId);
|
||||
return Result.success().put("data", new PageUtils(mapIPage));
|
||||
}
|
||||
|
||||
/**
|
||||
* 用户分析
|
||||
*/
|
||||
@GetMapping("/userMessage")
|
||||
@ApiOperation("用户分析")
|
||||
public Result userMessage(String date, int type,Long sysUserId) {
|
||||
String qdCode=null;
|
||||
if(sysUserId!=null){
|
||||
qdCode=sysUserService.getById(sysUserId).getQdCode();
|
||||
}
|
||||
int sumUserCount = userService.queryUserCount(type, date,null,qdCode);
|
||||
int h5Count = userService.queryUserCount(type, date,"h5",qdCode);
|
||||
int appCount = userService.queryUserCount(type, date,"app",qdCode);
|
||||
int wxCount = userService.queryUserCount(type, date,"小程序",qdCode);
|
||||
int dyCount = userService.queryUserCount(type, date,"抖音",qdCode);
|
||||
int giveMemberCount = userService.userMessage(date, type,qdCode,1);
|
||||
int moneyMemberCount = userService.userMessage(date, type,qdCode,2);
|
||||
int memberCount = userService.userMessage(date, type,qdCode,null);
|
||||
int userCount = sumUserCount-memberCount;
|
||||
Map<String,Integer> result=new HashMap<>();
|
||||
result.put("sumUserCount",sumUserCount);
|
||||
result.put("h5Count",h5Count);
|
||||
result.put("appCount",appCount);
|
||||
result.put("wxCount",wxCount);
|
||||
result.put("dyCount",dyCount);
|
||||
result.put("memberCount",memberCount);
|
||||
result.put("giveMemberCount",giveMemberCount);
|
||||
result.put("moneyMemberCount",moneyMemberCount);
|
||||
result.put("userCount",userCount);
|
||||
return Result.success().put("data", result);
|
||||
}
|
||||
|
||||
|
||||
@PostMapping("addCannotMoney/{userId}/{money}")
|
||||
@ApiOperation("添加金豆")
|
||||
public Result addCannotMoney(@PathVariable("userId") Long userId, @PathVariable("money") Double money) {
|
||||
userMoneyService.updateMoney(1, userId, money);
|
||||
//inviteMoneyDao.updateInviteMoneySum(money,userId);
|
||||
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
|
||||
UserMoneyDetails userMoneyDetails = new UserMoneyDetails();
|
||||
userMoneyDetails.setUserId(userId);
|
||||
userMoneyDetails.setTitle("[增加金豆]平台增加金豆:" + money);
|
||||
userMoneyDetails.setContent("[增加金豆]平台增加金豆:" + money);
|
||||
userMoneyDetails.setType(1);
|
||||
userMoneyDetails.setClassify(1);
|
||||
userMoneyDetails.setMoney(new BigDecimal(money));
|
||||
userMoneyDetails.setCreateTime(sdf.format(new Date()));
|
||||
userMoneyDetailsService.save(userMoneyDetails);
|
||||
PayDetails payDetails=new PayDetails();
|
||||
payDetails.setState(1);
|
||||
payDetails.setCreateTime(sdf.format(new Date()));
|
||||
payDetails.setUserId(userId);
|
||||
payDetails.setMoney(money);
|
||||
payDetails.setClassify(9);
|
||||
payDetails.setType(1);
|
||||
payDetails.setPayTime(sdf.format(new Date()));
|
||||
payDetailsDao.insert(payDetails);
|
||||
return Result.success();
|
||||
}
|
||||
|
||||
@PostMapping("subCannotMoney/{userId}/{money}")
|
||||
@ApiOperation("减少金豆")
|
||||
public Result subCannotMoney(@PathVariable("userId") Long userId, @PathVariable("money") Double money) {
|
||||
userMoneyService.updateMoney(2, userId, money);
|
||||
//inviteMoneyDao.updateInviteMoneySumSub(money,userId);
|
||||
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
|
||||
UserMoneyDetails userMoneyDetails = new UserMoneyDetails();
|
||||
userMoneyDetails.setUserId(userId);
|
||||
userMoneyDetails.setTitle("[减少金豆]平台减少金豆:" + money);
|
||||
userMoneyDetails.setContent("平台减少金豆:" + money);
|
||||
userMoneyDetails.setType(1);
|
||||
userMoneyDetails.setClassify(1);
|
||||
userMoneyDetails.setMoney(new BigDecimal(money));
|
||||
userMoneyDetails.setCreateTime(sdf.format(new Date()));
|
||||
userMoneyDetailsService.save(userMoneyDetails);
|
||||
return Result.success();
|
||||
}
|
||||
|
||||
@PostMapping("/updateSysUserMoney")
|
||||
@ApiOperation("修改金豆")
|
||||
public Result updateSysUserMoney(Long userId, Double money,Integer type) {
|
||||
userMoneyService.updateSysMoney(type, userId, money);
|
||||
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
|
||||
UserMoneyDetails userMoneyDetails = new UserMoneyDetails();
|
||||
userMoneyDetails.setSysUserId(userId);
|
||||
if(type==1){
|
||||
userMoneyDetails.setTitle("[增加金豆]平台增加金豆:" + money);
|
||||
userMoneyDetails.setContent("[增加金豆]平台增加金豆:" + money);
|
||||
}else{
|
||||
userMoneyDetails.setTitle("[减少金豆]平台减少金豆:" + money);
|
||||
userMoneyDetails.setContent("[减少金豆]平台减少金豆:" + money);
|
||||
}
|
||||
userMoneyDetails.setType(type);
|
||||
userMoneyDetails.setClassify(1);
|
||||
userMoneyDetails.setMoney(new BigDecimal(money));
|
||||
userMoneyDetails.setCreateTime(sdf.format(new Date()));
|
||||
userMoneyDetailsService.save(userMoneyDetails);
|
||||
return Result.success();
|
||||
}
|
||||
|
||||
@GetMapping("/selectInviteUserList")
|
||||
@ApiOperation("邀请用户排行榜")
|
||||
public Result selectInviteUserList(Integer page,Integer limit,String phone,String userName){
|
||||
return userService.selectInviteUserList(page, limit, userName, phone);
|
||||
}
|
||||
|
||||
@GetMapping("/selectUserOnLineCount")
|
||||
@ApiOperation("统计当前在线人数")
|
||||
public Result selectUserCount(Long sysUserId){
|
||||
String qdCode=null;
|
||||
if(sysUserId!=null){
|
||||
qdCode=sysUserService.getById(sysUserId).getQdCode();
|
||||
}
|
||||
return userService.selectUserOnLineCount(qdCode);
|
||||
}
|
||||
|
||||
@GetMapping("/selectUserCountStatisticsByTime")
|
||||
@ApiOperation("用户统计")
|
||||
public Result selectUserCountStatisticsByTime(String startTime,String endTime){
|
||||
List<Integer> userCountList=new ArrayList<>();
|
||||
List<String> year=new ArrayList<>();
|
||||
SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd");
|
||||
Calendar calendar=Calendar.getInstance();
|
||||
Date parse = null;
|
||||
try {
|
||||
parse = simpleDateFormat.parse(startTime);
|
||||
} catch (ParseException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
calendar.setTime(parse);
|
||||
while (true){
|
||||
String dateTime = simpleDateFormat.format(calendar.getTime());
|
||||
int i = userService.queryUserCount(1, dateTime,null,null);
|
||||
userCountList.add(i);
|
||||
year.add(dateTime);
|
||||
if(dateTime.equals(endTime)){
|
||||
break;
|
||||
}
|
||||
calendar.add(Calendar.DATE,1);
|
||||
}
|
||||
Map<String,Object> result=new HashMap<>();
|
||||
result.put("userCountList",userCountList);
|
||||
result.put("year",year);
|
||||
return Result.success().put("data",result);
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,41 @@
|
||||
package com.sqx.modules.app.controller;
|
||||
|
||||
import com.sqx.common.utils.Result;
|
||||
import com.sqx.modules.app.service.UserMoneyDetailsService;
|
||||
import com.sqx.modules.app.service.UserMoneyService;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import lombok.AllArgsConstructor;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
@RestController
|
||||
@RequestMapping("/moneyDetails")
|
||||
@AllArgsConstructor
|
||||
@Api("钱包明细")
|
||||
public class UserMoneyDetailsController {
|
||||
private UserMoneyDetailsService userMoneyDetailsService;
|
||||
private UserMoneyService userMoneyService;
|
||||
|
||||
|
||||
@ApiOperation("钱包明细")
|
||||
@GetMapping("/queryUserMoneyDetails")
|
||||
public Result queryUserMoneyDetails(Integer page, Integer limit,Long sysUserId, Long userId,Integer classify,Integer type) {
|
||||
return userMoneyDetailsService.queryUserMoneyDetails(page, limit, sysUserId, userId,classify,type);
|
||||
}
|
||||
|
||||
@GetMapping("/selectUserMoney")
|
||||
@ApiOperation("我的钱包")
|
||||
public Result selectUserMoney(Long userId){
|
||||
return Result.success().put("data",userMoneyService.selectUserMoneyByUserId(userId));
|
||||
}
|
||||
|
||||
@GetMapping("/selectSysUserMoney")
|
||||
@ApiOperation("代理钱包")
|
||||
public Result selectSysUserMoney(Long userId){
|
||||
return Result.success().put("data",userMoneyService.selectSysUserMoneyByUserId(userId));
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,95 @@
|
||||
package com.sqx.modules.app.controller;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.sqx.common.utils.DateUtils;
|
||||
import com.sqx.common.utils.PageUtils;
|
||||
import com.sqx.common.utils.Result;
|
||||
import com.sqx.modules.app.entity.UserVip;
|
||||
import com.sqx.modules.app.entity.VipDetails;
|
||||
import com.sqx.modules.app.service.UserVipService;
|
||||
import com.sqx.modules.app.service.VipDetailsService;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import io.swagger.annotations.ApiParam;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import java.util.Calendar;
|
||||
import java.util.Date;
|
||||
|
||||
@RestController
|
||||
@Api(value = "会员管理", tags = {"会员管理"})
|
||||
@RequestMapping(value = "/vipDetails")
|
||||
public class VipDetailsController {
|
||||
|
||||
@Autowired
|
||||
private VipDetailsService vipDetailsService;
|
||||
@Autowired
|
||||
private UserVipService userVipService;
|
||||
|
||||
@PostMapping("/sendVip")
|
||||
@ApiOperation("赠送会员")
|
||||
public Result sendVip(Long userId,Integer num){
|
||||
UserVip userVip = userVipService.selectUserVipByUserId(userId);
|
||||
Calendar calendar=Calendar.getInstance();
|
||||
if(userVip!=null){
|
||||
if(userVip.getIsVip()==2){
|
||||
Date date = DateUtils.stringToDate(userVip.getEndTime(), "yyyy-MM-dd HH:mm:ss");
|
||||
calendar.setTime(date);
|
||||
}
|
||||
}else{
|
||||
userVip=new UserVip();
|
||||
userVip.setUserId(userId);
|
||||
userVip.setCreateTime(DateUtils.format(new Date()));
|
||||
}
|
||||
userVip.setVipType(1);
|
||||
userVip.setIsVip(2);
|
||||
calendar.add(Calendar.DAY_OF_MONTH,num);
|
||||
userVip.setEndTime(DateUtils.format(calendar.getTime()));
|
||||
if(userVip.getVipId()!=null){
|
||||
userVipService.updateById(userVip);
|
||||
}else{
|
||||
userVipService.save(userVip);
|
||||
}
|
||||
return Result.success();
|
||||
}
|
||||
|
||||
@PostMapping("/deleteVip")
|
||||
@ApiOperation("取消会员")
|
||||
public Result deleteVip(Long userId){
|
||||
UserVip userVip = userVipService.selectUserVipByUserId(userId);
|
||||
if(userVip!=null){
|
||||
userVipService.removeById(userVip.getVipId());
|
||||
}
|
||||
return Result.success();
|
||||
}
|
||||
|
||||
|
||||
@ApiParam("添加会员的详情信息")
|
||||
@PostMapping("/insertVipDetails")
|
||||
public Result insertVipDetails(@RequestBody VipDetails vipDetails) {
|
||||
return vipDetailsService.insertVipDetails(vipDetails);
|
||||
}
|
||||
|
||||
|
||||
@ApiParam("修改会员的详情信息")
|
||||
@PostMapping("/updateVipDetails")
|
||||
public Result updateVipDetails(@RequestBody VipDetails vipDetails) {
|
||||
vipDetailsService.updateById(vipDetails);
|
||||
return Result.success();
|
||||
}
|
||||
|
||||
@ApiParam("删除的详情信息")
|
||||
@PostMapping("/deleteVipDetails")
|
||||
public Result deleteVipDetails(Long id) {
|
||||
vipDetailsService.removeById(id);
|
||||
return Result.success();
|
||||
}
|
||||
|
||||
@ApiParam("查询会员列表")
|
||||
@GetMapping("/selectVipDetailsList")
|
||||
public Result selectVipDetailsList(Integer page,Integer limit) {
|
||||
return Result.success().put("data",new PageUtils(vipDetailsService.page(new Page<>(page,limit))));
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,166 @@
|
||||
package com.sqx.modules.app.controller.app;
|
||||
|
||||
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.sqx.common.utils.Result;
|
||||
import com.sqx.modules.app.annotation.Login;
|
||||
import com.sqx.modules.app.annotation.LoginUser;
|
||||
import com.sqx.modules.app.entity.UserEntity;
|
||||
import com.sqx.modules.app.service.AppService;
|
||||
import com.sqx.modules.app.service.UserService;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import org.apache.commons.codec.digest.DigestUtils;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
|
||||
/**
|
||||
* APP登录授权
|
||||
*
|
||||
*/
|
||||
@RestController
|
||||
@RequestMapping("/app/user")
|
||||
@Api(value = "APP管理", tags = {"APP管理"})
|
||||
public class AppController {
|
||||
|
||||
@Autowired
|
||||
private UserService userService;
|
||||
@Autowired
|
||||
private AppService appService;
|
||||
|
||||
@PostMapping("/authenticationRegister")
|
||||
@ApiOperation("认证创建账号")
|
||||
public Result authenticationRegister(@RequestBody JSONObject jsonObject, HttpServletRequest request){
|
||||
return userService.authenticationRegister(jsonObject,request);
|
||||
}
|
||||
|
||||
@Login
|
||||
@PostMapping("/getNewUserRed")
|
||||
@ApiOperation("领取新用户红包")
|
||||
public Result getNewUserRed(@RequestAttribute Long userId){
|
||||
return userService.getNewUserRed(userId);
|
||||
}
|
||||
|
||||
@Login
|
||||
@RequestMapping(value = "/updatePwd", method = RequestMethod.POST)
|
||||
@ResponseBody
|
||||
@ApiOperation("用户端修改密码")
|
||||
public Result updatePwd(@LoginUser UserEntity user,String pwd,String oldPwd) {
|
||||
if(!user.getPassword().equals(DigestUtils.sha256Hex(oldPwd))){
|
||||
return Result.error("原始密码不正确!");
|
||||
}
|
||||
if(pwd.equals(oldPwd)){
|
||||
return Result.error("新密码不能与旧密码相同!");
|
||||
}
|
||||
user.setPassword(DigestUtils.sha256Hex(pwd));
|
||||
userService.updateById(user);
|
||||
return Result.success();
|
||||
}
|
||||
|
||||
@Login
|
||||
@RequestMapping(value = "/updatePhone", method = RequestMethod.POST)
|
||||
@ApiOperation("用户端换绑手机号")
|
||||
@ResponseBody
|
||||
public Result updatePhone(@RequestAttribute("userId") Long userId,@RequestParam String phone, @RequestParam String msg) {
|
||||
return userService.updatePhone(phone, msg,userId);
|
||||
}
|
||||
|
||||
@Login
|
||||
@RequestMapping(value = "/updateUser", method = RequestMethod.POST)
|
||||
@ApiOperation("用户修改个人信息")
|
||||
@ResponseBody
|
||||
public Result updateUserImageUrl(@RequestAttribute("userId") Long userId,String zhiFuBao,String zhiFuBaoName) {
|
||||
UserEntity userEntity=new UserEntity();
|
||||
userEntity.setZhiFuBao(zhiFuBao);
|
||||
userEntity.setZhiFuBaoName(zhiFuBaoName);
|
||||
userEntity.setUserId(userId);
|
||||
userService.updateById(userEntity);
|
||||
return Result.success();
|
||||
}
|
||||
|
||||
|
||||
|
||||
@Login
|
||||
@RequestMapping(value = "/updateUsers", method = RequestMethod.POST)
|
||||
@ApiOperation("用户修改个人信息")
|
||||
@ResponseBody
|
||||
public Result updateUsers(@RequestAttribute("userId") Long userId,@RequestBody UserEntity userEntity) {
|
||||
userEntity.setUserId(userId);
|
||||
userService.updateById(userEntity);
|
||||
return Result.success();
|
||||
}
|
||||
|
||||
|
||||
/*@Login
|
||||
@RequestMapping(value = "/updateUsers", method = RequestMethod.POST)
|
||||
@ApiOperation("用户修改个人信息")
|
||||
@ResponseBody
|
||||
public Result updateUsers(@RequestAttribute("userId") Long userId,String userName,String avatar,String phone) {
|
||||
UserEntity userEntity=new UserEntity();
|
||||
userEntity.setUserId(userId);
|
||||
userEntity.setUserName(userName);
|
||||
userEntity.setAvatar(avatar);
|
||||
userEntity.setPhone(phone);
|
||||
userService.updateById(userEntity);
|
||||
return Result.success();
|
||||
}*/
|
||||
|
||||
|
||||
@Login
|
||||
@RequestMapping(value = "/updateUserImageUrl", method = RequestMethod.POST)
|
||||
@ApiOperation("用户修改头像")
|
||||
@ResponseBody
|
||||
public Result updateUserImageUrl(@LoginUser UserEntity user,String avatar) {
|
||||
user.setAvatar(avatar);
|
||||
userService.updateById(user);
|
||||
return Result.success();
|
||||
}
|
||||
|
||||
@Login
|
||||
@RequestMapping(value = "/updateUserName", method = RequestMethod.POST)
|
||||
@ApiOperation("用户修改昵称")
|
||||
@ResponseBody
|
||||
public Result updateUserName(@LoginUser UserEntity user,String userName) {
|
||||
user.setUserName(userName);
|
||||
userService.updateById(user);
|
||||
return Result.success();
|
||||
}
|
||||
|
||||
@Login
|
||||
@RequestMapping(value = "/selectUserById", method = RequestMethod.GET)
|
||||
@ApiOperation("获取用户详细信息")
|
||||
@ResponseBody
|
||||
public Result selectUserById(@LoginUser UserEntity user) {
|
||||
return Result.success().put("data",user);
|
||||
}
|
||||
|
||||
|
||||
@RequestMapping(value = "/selectNewApp", method = RequestMethod.GET)
|
||||
@ApiOperation("升级检测")
|
||||
@ResponseBody
|
||||
public Result selectNewApp() {
|
||||
return Result.success().put("data",appService.selectNewApp());
|
||||
}
|
||||
|
||||
@GetMapping("/openId/{code:.+}/{userId}")
|
||||
@ApiOperation("根据code获取openid")
|
||||
public Result getOpenid(@PathVariable("code") String code,@PathVariable("userId")Long userId) {
|
||||
return userService.getOpenId(code,userId);
|
||||
}
|
||||
|
||||
@RequestMapping(value = "/updateClientId", method = RequestMethod.GET)
|
||||
@ApiOperation("绑定ClientId")
|
||||
@ResponseBody
|
||||
public Result updateClientId(String clientId,Long userId,Integer sysPhone ) {
|
||||
userService.updateUserClientIdIsNull(clientId);
|
||||
UserEntity userEntity=new UserEntity();
|
||||
userEntity.setSysPhone(sysPhone);
|
||||
userEntity.setUserId(userId);
|
||||
userEntity.setClientid(clientId);
|
||||
userService.updateById(userEntity);
|
||||
return Result.success();
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,218 @@
|
||||
package com.sqx.modules.app.controller.app;
|
||||
|
||||
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.sqx.common.utils.Result;
|
||||
import com.sqx.modules.app.entity.UserEntity;
|
||||
import com.sqx.modules.app.service.IAppleService;
|
||||
import com.sqx.modules.app.service.UserService;
|
||||
import com.sqx.modules.app.utils.UserConstantInterface;
|
||||
import com.sqx.modules.app.utils.WxPhone;
|
||||
import com.sqx.modules.common.entity.CommonInfo;
|
||||
import com.sqx.modules.common.service.CommonInfoService;
|
||||
import com.sqx.modules.utils.HttpClientUtil;
|
||||
import com.sqx.modules.utils.SenInfoCheckUtil;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import io.swagger.annotations.ApiParam;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
import weixin.popular.api.SnsAPI;
|
||||
import weixin.popular.bean.sns.SnsToken;
|
||||
|
||||
/**
|
||||
* APP登录授权
|
||||
*
|
||||
*/
|
||||
@RestController
|
||||
@RequestMapping("/app/Login")
|
||||
@Api("APP登录接口")
|
||||
@Slf4j
|
||||
public class AppLoginController {
|
||||
@Autowired
|
||||
private UserService userService;
|
||||
@Autowired
|
||||
private IAppleService appleService;
|
||||
@Autowired
|
||||
private CommonInfoService commonInfoService;
|
||||
|
||||
@ApiOperation("微信小程序登陆")
|
||||
@RequestMapping(value = "/wxLogin", method = RequestMethod.GET)
|
||||
public Result wxLogin(@ApiParam("小程序code码") String code){
|
||||
return userService.wxLogin(code);
|
||||
}
|
||||
|
||||
|
||||
@ApiOperation("小程序登录新增或修改个人信息")
|
||||
@RequestMapping(value = "/insertWxUser", method = RequestMethod.POST)
|
||||
public Result insertWxUser(@RequestBody UserEntity userInfo){
|
||||
return userService.wxRegister(userInfo);
|
||||
}
|
||||
|
||||
@RequestMapping(value = "/dyLogin", method = RequestMethod.POST)
|
||||
@ApiOperation("抖音登录")
|
||||
@ResponseBody
|
||||
public Result dyLogin(String code,String anonymous_code) {
|
||||
return userService.dyLogin(code,anonymous_code);
|
||||
}
|
||||
|
||||
@ApiOperation("抖音登录新增或修改个人信息")
|
||||
@RequestMapping(value = "/dyRegister", method = RequestMethod.POST)
|
||||
public Result dyRegister(@RequestBody UserEntity userInfo){
|
||||
return userService.dyRegister(userInfo);
|
||||
}
|
||||
|
||||
@RequestMapping(value = "/ksLogin", method = RequestMethod.POST)
|
||||
@ApiOperation("快手登录")
|
||||
@ResponseBody
|
||||
public Result ksLogin(String code) {
|
||||
return userService.ksLogin(code);
|
||||
}
|
||||
|
||||
@ApiOperation("快手登录新增或修改个人信息")
|
||||
@RequestMapping(value = "/ksRegister", method = RequestMethod.POST)
|
||||
public Result ksRegister(@RequestBody UserEntity userInfo){
|
||||
return userService.ksRegister(userInfo);
|
||||
}
|
||||
|
||||
|
||||
@RequestMapping(value = "/appleLogin", method = RequestMethod.GET)
|
||||
@ApiOperation("苹果登陆获取appleUserId")
|
||||
public Result loginVerify(@RequestParam("identityToken") String identityToken) {
|
||||
try {
|
||||
log.info("苹果token:{}", identityToken);
|
||||
JSONObject jsonObject = JSON.parseObject(identityToken);
|
||||
JSONObject userInfo = jsonObject.getJSONObject("userInfo");
|
||||
String identityTokens = userInfo.getString("identityToken");
|
||||
return appleService.getAppleUserInfo(identityTokens);
|
||||
} catch (Exception e) {
|
||||
log.error("苹果token校验失败:{}", identityToken, e);
|
||||
return Result.error("苹果账号验证失败,请退出重试!");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ApiOperation("苹果登录")
|
||||
@RequestMapping(value = "/insertAppleUser", method = RequestMethod.GET)
|
||||
public Result insertAppleUser(@RequestParam String appleId){
|
||||
return userService.iosRegister(appleId);
|
||||
}
|
||||
|
||||
@RequestMapping(value = "/iosBindMobile", method = RequestMethod.POST)
|
||||
@ApiOperation("苹果登录绑定手机号")
|
||||
@ResponseBody
|
||||
public Result iosBindMobile(@RequestParam String phone,@RequestParam String code,@RequestParam String appleId,
|
||||
@RequestParam String platform,@RequestParam Integer sysPhone,String inviterCode,String qdCode) {
|
||||
return userService.iosBindMobile(phone, code, appleId, platform, sysPhone,inviterCode,qdCode);
|
||||
}
|
||||
|
||||
|
||||
@RequestMapping(value = "/wxAppLogin", method = RequestMethod.POST)
|
||||
@ApiOperation("微信APP登录")
|
||||
@ResponseBody
|
||||
public Result wxAppLogin(@RequestParam String wxOpenId,@RequestParam String token) {
|
||||
return userService.wxAppLogin(wxOpenId,token);
|
||||
}
|
||||
|
||||
|
||||
@RequestMapping(value = "/wxBindMobile", method = RequestMethod.POST)
|
||||
@ApiOperation("微信登录绑定手机号")
|
||||
@ResponseBody
|
||||
public Result wxBindMobile(@RequestParam String phone,@RequestParam String code,@RequestParam String wxOpenId,@RequestParam String token,
|
||||
@RequestParam String platform,@RequestParam Integer sysPhone,String inviterCode,String qdCode) {
|
||||
return userService.wxBindMobile(phone, code, wxOpenId, token, platform, sysPhone,inviterCode,qdCode);
|
||||
}
|
||||
|
||||
@PostMapping("/phoneLogin")
|
||||
@ApiOperation("手机号一键登录")
|
||||
@ResponseBody
|
||||
public Result phoneLogin(String phone){
|
||||
return userService.phoneLogin(phone);
|
||||
}
|
||||
|
||||
@PostMapping("/bindMobile")
|
||||
@ApiOperation("手机号一键登录")
|
||||
@ResponseBody
|
||||
public Result bindMobile(String phone,String platform, Integer sysPhone,String inviterCode,String qdCode){
|
||||
return userService.bindMobile(phone, platform, sysPhone, inviterCode, qdCode);
|
||||
}
|
||||
|
||||
|
||||
@RequestMapping(value = "/registerCode", method = RequestMethod.POST)
|
||||
@ApiOperation("app或h5注册或登录")
|
||||
@ResponseBody
|
||||
public Result registerCode(@RequestParam String phone,String msg,String platform,Integer sysPhone,
|
||||
String password,String inviterCode,String wxId,String qdCode) {
|
||||
return userService.registerCode(phone,msg,platform,sysPhone,password,inviterCode,wxId,qdCode);
|
||||
}
|
||||
|
||||
@PostMapping("/bindWxOpenPhone")
|
||||
@ApiOperation("微信公众号绑定手机号")
|
||||
public Result bindWxOpenPhone(Long userId,String phone,String msg){
|
||||
return userService.bindWxOpenPhone(userId, phone, msg);
|
||||
}
|
||||
|
||||
@ApiOperation("用户端发送验证码")
|
||||
@RequestMapping(value = "/sendMsg/{phone}/{state}", method = RequestMethod.GET)
|
||||
@ResponseBody
|
||||
public Result sendMsg(@PathVariable String phone, @PathVariable String state) {
|
||||
return userService.sendMsg(phone, state,null);
|
||||
}
|
||||
|
||||
@ApiOperation("解密手机号")
|
||||
@RequestMapping(value = "/selectPhone",method = RequestMethod.POST)
|
||||
public Result getPhoneNumberBeanS5(@RequestBody WxPhone wxPhone) {
|
||||
return UserConstantInterface.decryptS5(wxPhone.getDecryptData(), wxPhone.getKey(), wxPhone.getIv());
|
||||
}
|
||||
|
||||
@ApiOperation("微信小程序解密手机号")
|
||||
@RequestMapping(value = "/wxPhone",method = RequestMethod.POST)
|
||||
public Result wxPhone(String code) {
|
||||
String url="https://api.weixin.qq.com/wxa/business/getuserphonenumber?access_token="+SenInfoCheckUtil.getMpToken();
|
||||
JSONObject param=new JSONObject();
|
||||
param.put("code",code);
|
||||
String result = HttpClientUtil.doPostJson(url, param.toJSONString());
|
||||
return Result.success().put("data",JSONObject.parseObject(result));
|
||||
}
|
||||
|
||||
@ApiOperation("用户端忘记密码")
|
||||
@RequestMapping(value = "/forgetPwd", method = RequestMethod.POST)
|
||||
@ResponseBody
|
||||
public Result forgetPwd(String pwd, String phone, String msg) {
|
||||
return userService.forgetPwd(pwd, phone, msg);
|
||||
}
|
||||
|
||||
|
||||
@GetMapping("/getOpenId")
|
||||
@ApiOperation("公众号根据code换取openId")
|
||||
public Result getOpenId(String code,Long userId) {
|
||||
try {
|
||||
//微信appid
|
||||
CommonInfo one = commonInfoService.findOne(5);
|
||||
//微信秘钥
|
||||
CommonInfo two = commonInfoService.findOne(21);
|
||||
SnsToken snsToken = SnsAPI.oauth2AccessToken(one.getValue(), two.getValue(), code);
|
||||
String openid = snsToken.getOpenid();
|
||||
return Result.success().put("data",openid);
|
||||
} catch (Exception e) {
|
||||
throw new RuntimeException("GET_OPENID_FAIL");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ApiOperation("用户端openid登录呢")
|
||||
@RequestMapping(value = "/openid/login", method = RequestMethod.GET)
|
||||
@ResponseBody
|
||||
public Result loginByOpenId(@RequestParam String openId) {
|
||||
return userService.loginByOpenId(openId);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,40 @@
|
||||
package com.sqx.modules.app.controller.app;
|
||||
|
||||
import com.sqx.common.utils.Result;
|
||||
import com.sqx.modules.app.annotation.Login;
|
||||
import com.sqx.modules.app.service.UserMoneyDetailsService;
|
||||
import com.sqx.modules.app.service.UserMoneyService;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import lombok.AllArgsConstructor;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.RequestAttribute;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
@RestController
|
||||
@RequestMapping("/app/moneyDetails")
|
||||
@AllArgsConstructor
|
||||
@Api("钱包明细")
|
||||
public class AppUserMoneyDetailsController {
|
||||
|
||||
private UserMoneyDetailsService userMoneyDetailsService;
|
||||
private UserMoneyService userMoneyService;
|
||||
|
||||
|
||||
@Login
|
||||
@ApiOperation("钱包明细")
|
||||
@GetMapping("/queryUserMoneyDetails")
|
||||
public Result queryUserMoneyDetails(Integer page, Integer limit, @RequestAttribute Long userId,Integer classify,Integer type) {
|
||||
return userMoneyDetailsService.queryUserMoneyDetails(page, limit,null, userId,1,type);
|
||||
}
|
||||
|
||||
@Login
|
||||
@GetMapping("/selectUserMoney")
|
||||
@ApiOperation("我的钱包")
|
||||
public Result selectUserMoney(@RequestAttribute Long userId){
|
||||
return Result.success().put("data",userMoneyService.selectUserMoneyByUserId(userId));
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,30 @@
|
||||
package com.sqx.modules.app.controller.app;
|
||||
|
||||
import com.sqx.common.utils.Result;
|
||||
import com.sqx.modules.app.annotation.Login;
|
||||
import com.sqx.modules.app.service.UserVipService;
|
||||
import com.sqx.modules.sys.controller.AbstractController;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.RequestAttribute;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
@RestController
|
||||
@Api(value = "用户会员信息", tags = {"用户会员信息"})
|
||||
@RequestMapping(value = "/app/UserVip")
|
||||
public class AppUserVipController extends AbstractController {
|
||||
@Autowired
|
||||
private UserVipService userVipService;
|
||||
@Login
|
||||
@GetMapping("/selectUserVip")
|
||||
@ApiOperation("查询用户会员信息")
|
||||
public Result selectUserVip(@RequestAttribute Long userId){
|
||||
return Result.success().put("data",userVipService.selectUserVipByUserId(userId));
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,49 @@
|
||||
package com.sqx.modules.app.controller.app;
|
||||
|
||||
import com.sqx.common.utils.Result;
|
||||
import com.sqx.modules.app.annotation.Login;
|
||||
import com.sqx.modules.app.entity.VipDetails;
|
||||
import com.sqx.modules.app.service.VipDetailsService;
|
||||
import com.sqx.modules.orders.service.OrdersService;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiParam;
|
||||
import lombok.AllArgsConstructor;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
@RestController
|
||||
@RequestMapping("/app/VipDetails")
|
||||
@AllArgsConstructor
|
||||
@Api("会员详情信息")
|
||||
public class AppVipDetailsController {
|
||||
private VipDetailsService appVipDetailsService;
|
||||
private OrdersService ordersService;
|
||||
|
||||
/**
|
||||
* 查询会员的详情信息
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
@Login
|
||||
@ApiParam("查询会员的详情信息")
|
||||
@GetMapping("/selectVipDetails")
|
||||
public Result selectVipDetails() {
|
||||
return appVipDetailsService.selectVipDetails();
|
||||
}
|
||||
|
||||
/**
|
||||
* 添加会员的详情信息
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
@Login
|
||||
@ApiParam("添加会员的详情信息")
|
||||
@GetMapping("/insertVipDetails")
|
||||
public Result insertVipDetails(VipDetails vipDetails) {
|
||||
return appVipDetailsService.insertVipDetails(vipDetails);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
20
src/main/java/com/sqx/modules/app/dao/AppDao.java
Normal file
20
src/main/java/com/sqx/modules/app/dao/AppDao.java
Normal file
@@ -0,0 +1,20 @@
|
||||
package com.sqx.modules.app.dao;
|
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.sqx.modules.app.entity.App;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 用户升级
|
||||
*
|
||||
*/
|
||||
@Mapper
|
||||
public interface AppDao extends BaseMapper<App> {
|
||||
|
||||
List<App> selectNewApp();
|
||||
|
||||
|
||||
|
||||
}
|
||||
20
src/main/java/com/sqx/modules/app/dao/MsgDao.java
Normal file
20
src/main/java/com/sqx/modules/app/dao/MsgDao.java
Normal file
@@ -0,0 +1,20 @@
|
||||
package com.sqx.modules.app.dao;
|
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.sqx.modules.app.entity.Msg;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
|
||||
/**
|
||||
* 用户
|
||||
*
|
||||
*/
|
||||
@Mapper
|
||||
public interface MsgDao extends BaseMapper<Msg> {
|
||||
|
||||
Msg findByPhone(String phone);
|
||||
|
||||
Msg findByPhoneAndCode(String phone, String msg);
|
||||
|
||||
|
||||
|
||||
}
|
||||
47
src/main/java/com/sqx/modules/app/dao/UserDao.java
Normal file
47
src/main/java/com/sqx/modules/app/dao/UserDao.java
Normal file
@@ -0,0 +1,47 @@
|
||||
package com.sqx.modules.app.dao;
|
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.sqx.modules.app.entity.UserEntity;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* 用户
|
||||
*/
|
||||
@Mapper
|
||||
public interface UserDao extends BaseMapper<UserEntity> {
|
||||
|
||||
|
||||
IPage<UserEntity> selectUserPage(@Param("page") Page<UserEntity> page, @Param("search") String search, @Param("sex") Integer sex, @Param("platform") String platform,
|
||||
@Param("sysPhone") String sysPhone, @Param("status") Integer status, @Param("member") Integer member,
|
||||
@Param("inviterCode") String inviterCode, @Param("userName") String userName,
|
||||
@Param("invitationCode") String invitationCode, @Param("startTime") String startTime,
|
||||
@Param("endTime") String endTime,@Param("qdCode") String qdCode,@Param("sysUserName") String sysUserName,Integer vipType);
|
||||
|
||||
List<UserEntity> userListExcel(@Param("startTime") String startTime, @Param("endTime") String endTime, @Param("userEntity") UserEntity userEntity);
|
||||
|
||||
int queryInviterCount(@Param("inviterCode") String inviterCode);
|
||||
|
||||
int queryUserCount(@Param("type") int type, @Param("date") String date,String platform,String qdCode);
|
||||
|
||||
Double queryPayMoney(@Param("type") int type, @Param("date") String date,String qdCode);
|
||||
|
||||
IPage<Map<String, Object>> queryCourseOrder(Page iPage,@Param("type") int type, @Param("date") String date,Long sysUserId);
|
||||
|
||||
int userMessage( String date, int type,String qdCode,Integer vipType);
|
||||
|
||||
int insertUser(UserEntity userEntity);
|
||||
|
||||
IPage<UserEntity> selectInviteUserList(Page<UserEntity> page,String userName,String phone);
|
||||
|
||||
int selectUserOnLineCount(String qdCode);
|
||||
|
||||
int updateUserClientIdIsNull(String clientid);
|
||||
|
||||
|
||||
}
|
||||
14
src/main/java/com/sqx/modules/app/dao/UserMoneyDao.java
Normal file
14
src/main/java/com/sqx/modules/app/dao/UserMoneyDao.java
Normal file
@@ -0,0 +1,14 @@
|
||||
package com.sqx.modules.app.dao;
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.sqx.modules.app.entity.UserMoney;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
|
||||
@Mapper
|
||||
public interface UserMoneyDao extends BaseMapper<UserMoney> {
|
||||
|
||||
void updateMayMoney(@Param("type") Integer type, @Param("userId")Long userId, @Param("money") Double money);
|
||||
|
||||
void updateSysMoney(@Param("type") Integer type, @Param("sysUserId")Long sysUserId, @Param("money") Double money);
|
||||
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
package com.sqx.modules.app.dao;
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.sqx.modules.app.entity.UserMoneyDetails;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
|
||||
@Mapper
|
||||
public interface UserMoneyDetailsDao extends BaseMapper<UserMoneyDetails> {
|
||||
|
||||
|
||||
Double monthIncome(@Param("date") String date,@Param("userId") Long userId);
|
||||
|
||||
}
|
||||
12
src/main/java/com/sqx/modules/app/dao/UserVipDao.java
Normal file
12
src/main/java/com/sqx/modules/app/dao/UserVipDao.java
Normal file
@@ -0,0 +1,12 @@
|
||||
package com.sqx.modules.app.dao;
|
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.sqx.modules.app.entity.UserVip;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
|
||||
@Mapper
|
||||
public interface UserVipDao extends BaseMapper<UserVip> {
|
||||
|
||||
int updateUserVipByEndTime();
|
||||
|
||||
}
|
||||
9
src/main/java/com/sqx/modules/app/dao/VipDetailsDao.java
Normal file
9
src/main/java/com/sqx/modules/app/dao/VipDetailsDao.java
Normal file
@@ -0,0 +1,9 @@
|
||||
package com.sqx.modules.app.dao;
|
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.sqx.modules.app.entity.VipDetails;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
|
||||
@Mapper
|
||||
public interface VipDetailsDao extends BaseMapper<VipDetails> {
|
||||
}
|
||||
35
src/main/java/com/sqx/modules/app/entity/App.java
Normal file
35
src/main/java/com/sqx/modules/app/entity/App.java
Normal file
@@ -0,0 +1,35 @@
|
||||
package com.sqx.modules.app.entity;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import lombok.Data;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
/**
|
||||
* 广告位
|
||||
*/
|
||||
@Data
|
||||
@TableName("app")
|
||||
public class App implements Serializable {
|
||||
@TableId
|
||||
private Long id;
|
||||
|
||||
private String createAt;
|
||||
|
||||
private String androidWgtUrl;
|
||||
|
||||
private String iosWgtUrl;
|
||||
|
||||
private String wgtUrl;
|
||||
|
||||
private String version;
|
||||
|
||||
private String iosVersion;
|
||||
|
||||
private String method;
|
||||
|
||||
private String des;
|
||||
|
||||
}
|
||||
|
||||
23
src/main/java/com/sqx/modules/app/entity/AppUserInfo.java
Normal file
23
src/main/java/com/sqx/modules/app/entity/AppUserInfo.java
Normal file
@@ -0,0 +1,23 @@
|
||||
package com.sqx.modules.app.entity;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@Data
|
||||
public class AppUserInfo {
|
||||
|
||||
|
||||
|
||||
private String openid;
|
||||
private String nickname;
|
||||
private int sex;
|
||||
private String province;
|
||||
private String city;
|
||||
private String country;
|
||||
private String headimgurl;
|
||||
private String unionid;
|
||||
private List<String> privilege;
|
||||
|
||||
|
||||
}
|
||||
27
src/main/java/com/sqx/modules/app/entity/Msg.java
Normal file
27
src/main/java/com/sqx/modules/app/entity/Msg.java
Normal file
@@ -0,0 +1,27 @@
|
||||
package com.sqx.modules.app.entity;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import lombok.Data;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
/**
|
||||
* @author fang
|
||||
* @date 2020/7/10
|
||||
*/
|
||||
@Data
|
||||
@TableName("msg")
|
||||
public class Msg implements Serializable {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
@TableId
|
||||
private Long id;
|
||||
|
||||
private String code;
|
||||
|
||||
private String phone;
|
||||
|
||||
|
||||
}
|
||||
27
src/main/java/com/sqx/modules/app/entity/UserDetails.java
Normal file
27
src/main/java/com/sqx/modules/app/entity/UserDetails.java
Normal file
@@ -0,0 +1,27 @@
|
||||
package com.sqx.modules.app.entity;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
|
||||
@Data
|
||||
public class UserDetails {
|
||||
/**
|
||||
* 本月订单数量
|
||||
*/
|
||||
private int monthlyOrderNum;
|
||||
/**
|
||||
* 本月充值金豆
|
||||
*/
|
||||
private BigDecimal monthlyRechargeMoney;
|
||||
/**
|
||||
*本月提现数量
|
||||
*/
|
||||
private int monthWithdrawalNum;
|
||||
/**
|
||||
* 本月提现金豆
|
||||
*/
|
||||
private BigDecimal monthlyWithdrawalMoney;
|
||||
|
||||
|
||||
}
|
||||
202
src/main/java/com/sqx/modules/app/entity/UserEntity.java
Normal file
202
src/main/java/com/sqx/modules/app/entity/UserEntity.java
Normal file
@@ -0,0 +1,202 @@
|
||||
package com.sqx.modules.app.entity;
|
||||
|
||||
import cn.afterturn.easypoi.excel.annotation.Excel;
|
||||
import com.baomidou.mybatisplus.annotation.IdType;
|
||||
import com.baomidou.mybatisplus.annotation.TableField;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.math.BigDecimal;
|
||||
|
||||
|
||||
/**
|
||||
* 用户
|
||||
*
|
||||
*/
|
||||
@Data
|
||||
@ApiModel("用户")
|
||||
@TableName("tb_user")
|
||||
public class UserEntity implements Serializable {
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
/**
|
||||
* 用户ID
|
||||
*/
|
||||
@Excel(name = "用户id", orderNum = "1")
|
||||
@ApiModelProperty("用户id")
|
||||
@TableId(type = IdType.AUTO, value = "user_id")
|
||||
private Long userId;
|
||||
/**
|
||||
* 用户名
|
||||
*/
|
||||
@Excel(name = "用户昵称", orderNum = "2")
|
||||
@ApiModelProperty("用户名")
|
||||
@TableField("user_name")
|
||||
private String userName;
|
||||
|
||||
/**
|
||||
* 手机号
|
||||
*/
|
||||
@Excel(name = "手机号", orderNum = "4")
|
||||
@ApiModelProperty("手机号")
|
||||
private String phone;
|
||||
|
||||
/**
|
||||
* 头像
|
||||
*/
|
||||
@Excel(name = "头像", orderNum = "3")
|
||||
@ApiModelProperty("头像")
|
||||
private String avatar;
|
||||
|
||||
/**
|
||||
* 性别 1男 2女
|
||||
*/
|
||||
@ApiModelProperty("性别 1男 2女")
|
||||
private Integer sex;
|
||||
|
||||
/**
|
||||
* 微信小程序openid
|
||||
*/
|
||||
@ApiModelProperty("微信小程序openid")
|
||||
@TableField("open_id")
|
||||
private String openId;
|
||||
|
||||
/**
|
||||
* 微信小程序openid
|
||||
*/
|
||||
@ApiModelProperty("微信公众号openid")
|
||||
@TableField("wx_id")
|
||||
private String wxId;
|
||||
|
||||
/**
|
||||
* 微信app openid
|
||||
*/
|
||||
@ApiModelProperty("微信app openid")
|
||||
@TableField("wx_open_id")
|
||||
private String wxOpenId;
|
||||
|
||||
/**
|
||||
* 抖音小程序openId
|
||||
*/
|
||||
private String dyOpenId;
|
||||
|
||||
/**
|
||||
* 快手小程序openId
|
||||
*/
|
||||
private String ksOpenId;
|
||||
|
||||
/**
|
||||
* 密码
|
||||
*/
|
||||
private String password;
|
||||
|
||||
/**
|
||||
* 创建时间
|
||||
*/
|
||||
@Excel(name = "创建时间", orderNum = "13", width = 18)
|
||||
@TableField("create_time")
|
||||
private String createTime;
|
||||
|
||||
/**
|
||||
* 更新时间
|
||||
*/
|
||||
@TableField("update_time")
|
||||
private String updateTime;
|
||||
|
||||
/**
|
||||
* 苹果id
|
||||
*/
|
||||
@TableField("apple_id")
|
||||
private String appleId;
|
||||
|
||||
/**
|
||||
* 手机类型 1安卓 2ios
|
||||
*/
|
||||
@TableField("sys_phone")
|
||||
private Integer sysPhone;
|
||||
|
||||
/**
|
||||
* 状态 1正常 2禁用
|
||||
*/
|
||||
@Excel(name = "状态", orderNum = "13", replace = {"正常_1", "禁用_1"})
|
||||
private Integer status;
|
||||
|
||||
/**
|
||||
* 来源 app 小程序 公众号
|
||||
*/
|
||||
@Excel(name = "渠道来源", orderNum = "9")
|
||||
private String platform;
|
||||
|
||||
/**
|
||||
* 积分
|
||||
*/
|
||||
private Integer jifen;
|
||||
|
||||
/**
|
||||
* 邀请码
|
||||
*/
|
||||
@Excel(name = "邀请码", orderNum = "5")
|
||||
@TableField("invitation_code")
|
||||
private String invitationCode;
|
||||
|
||||
/**
|
||||
* 邀请人邀请码
|
||||
*/
|
||||
@Excel(name = "邀请人邀请码", orderNum = "6",width = 15)
|
||||
@TableField("inviter_code")
|
||||
private String inviterCode;
|
||||
|
||||
private String clientid;
|
||||
|
||||
@Excel(name = "支付宝账号", orderNum = "8", width = 18)
|
||||
private String zhiFuBao;
|
||||
|
||||
@Excel(name = "支付宝名称", orderNum = "8", width = 18)
|
||||
private String zhiFuBaoName;
|
||||
|
||||
@Excel(name = "一级推广收益比例", orderNum = "8", width = 18)
|
||||
private BigDecimal rate;
|
||||
|
||||
@Excel(name = "二级推广收益比例", orderNum = "8", width = 18)
|
||||
private BigDecimal twoRate;
|
||||
|
||||
/**
|
||||
* 最后一次在线时间
|
||||
*/
|
||||
private String onLineTime;
|
||||
|
||||
/**
|
||||
* 渠道码
|
||||
*/
|
||||
private String qdCode;
|
||||
|
||||
/**
|
||||
* 是否是新用户 1否
|
||||
*/
|
||||
private Integer isNewUser;
|
||||
|
||||
@TableField(exist = false)
|
||||
private String sysUserName;
|
||||
|
||||
|
||||
@TableField(exist = false)
|
||||
private Integer member;
|
||||
|
||||
@TableField(exist = false)
|
||||
private Integer counts;
|
||||
|
||||
@TableField(exist = false)
|
||||
private BigDecimal money;
|
||||
|
||||
@TableField(exist = false)
|
||||
private String endTime;
|
||||
|
||||
@TableField(exist = false)
|
||||
private Integer vipType;
|
||||
|
||||
|
||||
}
|
||||
49
src/main/java/com/sqx/modules/app/entity/UserMoney.java
Normal file
49
src/main/java/com/sqx/modules/app/entity/UserMoney.java
Normal file
@@ -0,0 +1,49 @@
|
||||
package com.sqx.modules.app.entity;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.IdType;
|
||||
import com.baomidou.mybatisplus.annotation.TableField;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.math.BigDecimal;
|
||||
|
||||
@Data
|
||||
@AllArgsConstructor
|
||||
@NoArgsConstructor
|
||||
@TableName("user_money")
|
||||
@ApiModel("用户钱包")
|
||||
public class UserMoney implements Serializable {
|
||||
/**
|
||||
* 主键id
|
||||
*/
|
||||
@ApiModelProperty("主键id")
|
||||
@TableId(type = IdType.AUTO)
|
||||
private Long id;
|
||||
|
||||
/**
|
||||
* 钱包金豆
|
||||
*/
|
||||
@ApiModelProperty("钱包金豆")
|
||||
private BigDecimal money;
|
||||
|
||||
/**
|
||||
* 用户id
|
||||
*/
|
||||
@ApiModelProperty("用户id")
|
||||
@TableField("user_id")
|
||||
private Long userId;
|
||||
|
||||
/**
|
||||
* 渠道用户id
|
||||
*/
|
||||
@ApiModelProperty("渠道用户id")
|
||||
@TableField("sys_user_id")
|
||||
private Long sysUserId;
|
||||
|
||||
}
|
||||
@@ -0,0 +1,86 @@
|
||||
package com.sqx.modules.app.entity;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.IdType;
|
||||
import com.baomidou.mybatisplus.annotation.TableField;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.math.BigDecimal;
|
||||
|
||||
@Data
|
||||
@AllArgsConstructor
|
||||
@NoArgsConstructor
|
||||
@TableName("user_money_details")
|
||||
@ApiModel("钱包详情")
|
||||
public class UserMoneyDetails implements Serializable {
|
||||
/**
|
||||
* 钱包详情id
|
||||
*/
|
||||
@ApiModelProperty("钱包详情id")
|
||||
@TableId(type = IdType.AUTO)
|
||||
private Long id;
|
||||
/**
|
||||
* 用户id
|
||||
*/
|
||||
@TableField("user_id")
|
||||
@ApiModelProperty("用户id")
|
||||
private Long userId;
|
||||
|
||||
/**
|
||||
* 渠道用户id
|
||||
*/
|
||||
@ApiModelProperty("渠道用户id")
|
||||
@TableField("sys_user_id")
|
||||
private Long sysUserId;
|
||||
|
||||
/**
|
||||
* 对应用户id
|
||||
*/
|
||||
@TableField("by_user_id")
|
||||
@ApiModelProperty("对应用户id")
|
||||
private Long byUserId;
|
||||
/**
|
||||
* 标题
|
||||
*/
|
||||
@ApiModelProperty("标题")
|
||||
private String title;
|
||||
/**
|
||||
* 1注册 2首次购买 3购买 4提现
|
||||
*/
|
||||
@ApiModelProperty("1充值钱包明细 2提现钱包明细")
|
||||
private Integer classify;
|
||||
/**
|
||||
* 类别(1充值2支出)
|
||||
*/
|
||||
@ApiModelProperty("类别(1充值2支出)")
|
||||
private Integer type;
|
||||
/**
|
||||
* 状态 1待支付 2已到账 3取消
|
||||
*/
|
||||
@ApiModelProperty("状态 1待支付 2已到账 3取消")
|
||||
private Integer state;
|
||||
/**
|
||||
* 金豆
|
||||
*/
|
||||
@ApiModelProperty("金豆")
|
||||
private BigDecimal money;
|
||||
/**
|
||||
* 内容
|
||||
*/
|
||||
@ApiModelProperty("内容")
|
||||
private String content;
|
||||
/**
|
||||
* 创建时间
|
||||
*/
|
||||
@TableField("create_time")
|
||||
@ApiModelProperty("创建时间")
|
||||
private String createTime;
|
||||
|
||||
|
||||
}
|
||||
47
src/main/java/com/sqx/modules/app/entity/UserVip.java
Normal file
47
src/main/java/com/sqx/modules/app/entity/UserVip.java
Normal file
@@ -0,0 +1,47 @@
|
||||
package com.sqx.modules.app.entity;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import lombok.Data;
|
||||
|
||||
import java.io.Serializable;
|
||||
@Data
|
||||
@TableName("user_vip")
|
||||
public class UserVip implements Serializable {
|
||||
private static final long serialVersionUID = 1L;
|
||||
/**
|
||||
* 用户会员ID
|
||||
*/
|
||||
@TableId
|
||||
private Long vipId;
|
||||
/**
|
||||
* 会员类型
|
||||
*/
|
||||
private Integer vipNameType;
|
||||
/**
|
||||
* 用户ID
|
||||
*/
|
||||
private Long userId;
|
||||
|
||||
/**
|
||||
* 会员是否到期
|
||||
*/
|
||||
private Integer isVip;
|
||||
|
||||
|
||||
/**
|
||||
* 购买时间
|
||||
*/
|
||||
private String createTime;
|
||||
/**
|
||||
* 到期时间
|
||||
*/
|
||||
private String endTime;
|
||||
|
||||
/**
|
||||
* 会员类型 1活动赠送 2充值开通
|
||||
*/
|
||||
private Integer vipType;
|
||||
|
||||
public UserVip() {}
|
||||
}
|
||||
38
src/main/java/com/sqx/modules/app/entity/VipDetails.java
Normal file
38
src/main/java/com/sqx/modules/app/entity/VipDetails.java
Normal file
@@ -0,0 +1,38 @@
|
||||
package com.sqx.modules.app.entity;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.IdType;
|
||||
import com.baomidou.mybatisplus.annotation.TableField;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.math.BigDecimal;
|
||||
|
||||
@Data
|
||||
@AllArgsConstructor
|
||||
@NoArgsConstructor
|
||||
@TableName("vip_details")
|
||||
@ApiModel("会员详情")
|
||||
public class VipDetails implements Serializable {
|
||||
|
||||
@TableId(type = IdType.AUTO)
|
||||
private Long id;
|
||||
|
||||
@ApiModelProperty("会员类型")
|
||||
@TableField("vip_name_type")
|
||||
private Integer vipNameType;
|
||||
|
||||
@ApiModelProperty("会员价格")
|
||||
private BigDecimal money;
|
||||
|
||||
/**
|
||||
* 支付钻石
|
||||
*/
|
||||
private BigDecimal payDiamond;
|
||||
|
||||
}
|
||||
24
src/main/java/com/sqx/modules/app/form/LoginForm.java
Normal file
24
src/main/java/com/sqx/modules/app/form/LoginForm.java
Normal file
@@ -0,0 +1,24 @@
|
||||
package com.sqx.modules.app.form;
|
||||
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
|
||||
import javax.validation.constraints.NotBlank;
|
||||
|
||||
/**
|
||||
* 登录表单
|
||||
*
|
||||
*/
|
||||
@Data
|
||||
@ApiModel(value = "登录表单")
|
||||
public class LoginForm {
|
||||
@ApiModelProperty(value = "手机号")
|
||||
@NotBlank(message="手机号不能为空")
|
||||
private String mobile;
|
||||
|
||||
@ApiModelProperty(value = "密码")
|
||||
@NotBlank(message="密码不能为空")
|
||||
private String password;
|
||||
|
||||
}
|
||||
24
src/main/java/com/sqx/modules/app/form/RegisterForm.java
Normal file
24
src/main/java/com/sqx/modules/app/form/RegisterForm.java
Normal file
@@ -0,0 +1,24 @@
|
||||
package com.sqx.modules.app.form;
|
||||
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
|
||||
import javax.validation.constraints.NotBlank;
|
||||
|
||||
/**
|
||||
* 注册表单
|
||||
*
|
||||
*/
|
||||
@Data
|
||||
@ApiModel(value = "注册表单")
|
||||
public class RegisterForm {
|
||||
@ApiModelProperty(value = "手机号")
|
||||
@NotBlank(message="手机号不能为空")
|
||||
private String mobile;
|
||||
|
||||
@ApiModelProperty(value = "密码")
|
||||
@NotBlank(message="密码不能为空")
|
||||
private String password;
|
||||
|
||||
}
|
||||
@@ -0,0 +1,74 @@
|
||||
package com.sqx.modules.app.interceptor;
|
||||
|
||||
|
||||
import com.sqx.common.exception.SqxException;
|
||||
import com.sqx.common.utils.DateUtils;
|
||||
import com.sqx.modules.app.entity.UserEntity;
|
||||
import com.sqx.modules.app.service.UserService;
|
||||
import com.sqx.modules.app.utils.JwtUtils;
|
||||
import io.jsonwebtoken.Claims;
|
||||
import com.sqx.modules.app.annotation.Login;
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.http.HttpStatus;
|
||||
import org.springframework.stereotype.Component;
|
||||
import org.springframework.web.method.HandlerMethod;
|
||||
import org.springframework.web.servlet.handler.HandlerInterceptorAdapter;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import java.util.Date;
|
||||
|
||||
/**
|
||||
* 权限(Token)验证
|
||||
*
|
||||
*/
|
||||
@Component
|
||||
public class AuthorizationInterceptor extends HandlerInterceptorAdapter {
|
||||
@Autowired
|
||||
private JwtUtils jwtUtils;
|
||||
@Autowired
|
||||
private UserService userService;
|
||||
|
||||
public static final String USER_KEY = "userId";
|
||||
|
||||
@Override
|
||||
public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler) throws Exception {
|
||||
Login annotation;
|
||||
if(handler instanceof HandlerMethod) {
|
||||
annotation = ((HandlerMethod) handler).getMethodAnnotation(Login.class);
|
||||
}else{
|
||||
return true;
|
||||
}
|
||||
|
||||
if(annotation == null){
|
||||
return true;
|
||||
}
|
||||
|
||||
//获取用户凭证
|
||||
String token = request.getHeader(jwtUtils.getHeader());
|
||||
if(StringUtils.isBlank(token)){
|
||||
token = request.getParameter(jwtUtils.getHeader());
|
||||
}
|
||||
|
||||
//凭证为空
|
||||
if(StringUtils.isBlank(token)){
|
||||
throw new SqxException(jwtUtils.getHeader() + "不能为空", HttpStatus.UNAUTHORIZED.value());
|
||||
}
|
||||
|
||||
Claims claims = jwtUtils.getClaimByToken(token);
|
||||
if(claims == null || jwtUtils.isTokenExpired(claims.getExpiration())){
|
||||
throw new SqxException(jwtUtils.getHeader() + "失效,请重新登录", HttpStatus.UNAUTHORIZED.value());
|
||||
}
|
||||
|
||||
//设置userId到request里,后续根据userId,获取用户信息
|
||||
long userId = Long.parseLong(claims.getSubject());
|
||||
request.setAttribute(USER_KEY, userId);
|
||||
//记录用户最后一次调用接口的时间
|
||||
UserEntity userEntity=new UserEntity();
|
||||
userEntity.setUserId(userId);
|
||||
userEntity.setOnLineTime(DateUtils.format(new Date()));
|
||||
userService.updateById(userEntity);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,44 @@
|
||||
package com.sqx.modules.app.resolver;
|
||||
|
||||
import com.sqx.modules.app.entity.UserEntity;
|
||||
import com.sqx.modules.app.interceptor.AuthorizationInterceptor;
|
||||
import com.sqx.modules.app.service.UserService;
|
||||
import com.sqx.modules.app.annotation.LoginUser;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.core.MethodParameter;
|
||||
import org.springframework.stereotype.Component;
|
||||
import org.springframework.web.bind.support.WebDataBinderFactory;
|
||||
import org.springframework.web.context.request.NativeWebRequest;
|
||||
import org.springframework.web.context.request.RequestAttributes;
|
||||
import org.springframework.web.method.support.HandlerMethodArgumentResolver;
|
||||
import org.springframework.web.method.support.ModelAndViewContainer;
|
||||
|
||||
/**
|
||||
* 有@LoginUser注解的方法参数,注入当前登录用户
|
||||
*
|
||||
*/
|
||||
@Component
|
||||
public class LoginUserHandlerMethodArgumentResolver implements HandlerMethodArgumentResolver {
|
||||
@Autowired
|
||||
private UserService userService;
|
||||
|
||||
@Override
|
||||
public boolean supportsParameter(MethodParameter parameter) {
|
||||
return parameter.getParameterType().isAssignableFrom(UserEntity.class) && parameter.hasParameterAnnotation(LoginUser.class);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object resolveArgument(MethodParameter parameter, ModelAndViewContainer container,
|
||||
NativeWebRequest request, WebDataBinderFactory factory) throws Exception {
|
||||
//获取用户ID
|
||||
Object object = request.getAttribute(AuthorizationInterceptor.USER_KEY, RequestAttributes.SCOPE_REQUEST);
|
||||
if(object == null){
|
||||
return null;
|
||||
}
|
||||
|
||||
//获取用户信息
|
||||
UserEntity user = userService.getById((Long)object);
|
||||
|
||||
return user;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,25 @@
|
||||
package com.sqx.modules.app.response;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
@Data
|
||||
@AllArgsConstructor
|
||||
@NoArgsConstructor
|
||||
public class CourseOrderResponse implements Serializable {
|
||||
/**
|
||||
* 短剧名称
|
||||
*/
|
||||
private String coursename;
|
||||
/**
|
||||
* 售卖笔数
|
||||
*/
|
||||
private int coursenum;
|
||||
/**
|
||||
* 售卖金豆
|
||||
*/
|
||||
private Double coursemoney;
|
||||
}
|
||||
@@ -0,0 +1,52 @@
|
||||
package com.sqx.modules.app.response;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
import lombok.ToString;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.math.BigDecimal;
|
||||
|
||||
/**
|
||||
* 首页信息返回实体
|
||||
*/
|
||||
@Data
|
||||
@AllArgsConstructor
|
||||
@NoArgsConstructor
|
||||
@ToString
|
||||
public class HomeMessageResponse implements Serializable {
|
||||
/**
|
||||
* 总用户数
|
||||
*/
|
||||
private int totalUsers;
|
||||
/**
|
||||
*今日新增
|
||||
*/
|
||||
private int newToday;
|
||||
/**
|
||||
*本月新增
|
||||
*/
|
||||
private int newMonth;
|
||||
/**
|
||||
* 本年新增
|
||||
*/
|
||||
private int newYear;
|
||||
/**
|
||||
* 总收入
|
||||
*/
|
||||
private Double totalRevenue;
|
||||
/**
|
||||
* 今日收入
|
||||
*/
|
||||
private Double todayRevenue;
|
||||
/**
|
||||
* 本月收入
|
||||
*/
|
||||
private Double monthRevenue;
|
||||
/**
|
||||
* 本年收入
|
||||
*/
|
||||
private Double yearRevenue;
|
||||
|
||||
}
|
||||
@@ -0,0 +1,25 @@
|
||||
package com.sqx.modules.app.response;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
@Data
|
||||
@AllArgsConstructor
|
||||
@NoArgsConstructor
|
||||
public class UserMessageResponse implements Serializable {
|
||||
/**
|
||||
* 总人数
|
||||
*/
|
||||
private int totalNumber;
|
||||
/**
|
||||
* 普通用户人数
|
||||
*/
|
||||
private int userNumber;
|
||||
/**
|
||||
* 会员人数
|
||||
*/
|
||||
private int vipUserNumber;
|
||||
}
|
||||
25
src/main/java/com/sqx/modules/app/service/AppService.java
Normal file
25
src/main/java/com/sqx/modules/app/service/AppService.java
Normal file
@@ -0,0 +1,25 @@
|
||||
package com.sqx.modules.app.service;
|
||||
|
||||
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
import com.sqx.modules.app.entity.App;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 升级
|
||||
*
|
||||
*/
|
||||
public interface AppService extends IService<App> {
|
||||
|
||||
App selectAppById(Long id);
|
||||
|
||||
int insertApp(App app);
|
||||
|
||||
int updateAppById(App app);
|
||||
|
||||
int deleteAppById(Long id);
|
||||
|
||||
List<App> selectNewApp();
|
||||
|
||||
}
|
||||
10
src/main/java/com/sqx/modules/app/service/IAppleService.java
Normal file
10
src/main/java/com/sqx/modules/app/service/IAppleService.java
Normal file
@@ -0,0 +1,10 @@
|
||||
package com.sqx.modules.app.service;
|
||||
|
||||
|
||||
import com.sqx.common.utils.Result;
|
||||
|
||||
public interface IAppleService {
|
||||
|
||||
Result getAppleUserInfo(String identityToken) throws Exception;
|
||||
|
||||
}
|
||||
17
src/main/java/com/sqx/modules/app/service/MsgService.java
Normal file
17
src/main/java/com/sqx/modules/app/service/MsgService.java
Normal file
@@ -0,0 +1,17 @@
|
||||
package com.sqx.modules.app.service;
|
||||
|
||||
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
import com.sqx.modules.app.entity.Msg;
|
||||
|
||||
/**
|
||||
* 验证码
|
||||
*
|
||||
*/
|
||||
public interface MsgService extends IService<Msg> {
|
||||
|
||||
Msg findByPhone(String phone);
|
||||
|
||||
Msg findByPhoneAndCode(String phone, String msg);
|
||||
|
||||
}
|
||||
@@ -0,0 +1,10 @@
|
||||
package com.sqx.modules.app.service;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
import com.sqx.common.utils.Result;
|
||||
import com.sqx.modules.app.entity.UserMoneyDetails;
|
||||
|
||||
public interface UserMoneyDetailsService extends IService<UserMoneyDetails> {
|
||||
Result queryUserMoneyDetails(Integer page, Integer limit,Long sysUserId,Long userId,Integer classify,Integer type);
|
||||
Double monthIncome(String date,Long userId);
|
||||
}
|
||||
@@ -0,0 +1,16 @@
|
||||
package com.sqx.modules.app.service;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
import com.sqx.modules.app.entity.UserMoney;
|
||||
|
||||
public interface UserMoneyService extends IService<UserMoney> {
|
||||
|
||||
UserMoney selectUserMoneyByUserId(Long userId);
|
||||
|
||||
UserMoney selectSysUserMoneyByUserId(Long userId);
|
||||
|
||||
void updateMoney(int i, Long userId, double money);
|
||||
|
||||
void updateSysMoney(int i, Long userId, double money);
|
||||
|
||||
}
|
||||
230
src/main/java/com/sqx/modules/app/service/UserService.java
Normal file
230
src/main/java/com/sqx/modules/app/service/UserService.java
Normal file
@@ -0,0 +1,230 @@
|
||||
package com.sqx.modules.app.service;
|
||||
|
||||
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
import com.sqx.common.utils.PageUtils;
|
||||
import com.sqx.common.utils.Result;
|
||||
import com.sqx.modules.app.entity.UserEntity;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* 用户
|
||||
*
|
||||
* @author fang
|
||||
* @date 2021/2/27
|
||||
*/
|
||||
public interface UserService extends IService<UserEntity> {
|
||||
|
||||
|
||||
Result authenticationRegister(JSONObject jsonObject, HttpServletRequest request);
|
||||
|
||||
|
||||
Result getNewUserRed(Long userId);
|
||||
|
||||
/**
|
||||
* 根据手机号查询用户
|
||||
*
|
||||
* @param phone 手机号
|
||||
* @return
|
||||
*/
|
||||
UserEntity queryByPhone(String phone);
|
||||
|
||||
/**
|
||||
* 根据小程序微信openId查询用户
|
||||
*
|
||||
* @param openId 微信小程序openId
|
||||
* @return
|
||||
*/
|
||||
UserEntity queryByOpenId(String openId);
|
||||
|
||||
UserEntity queryByWxId(String wxId);
|
||||
|
||||
UserEntity queryByDyOpenId(String dyOpenId);
|
||||
|
||||
UserEntity queryByKsOpenId(String ksOpenId);
|
||||
|
||||
/**
|
||||
* 根据微信APP openId查询用户
|
||||
*
|
||||
* @param openId 微信APP openId
|
||||
* @return
|
||||
*/
|
||||
UserEntity queryByWxOpenId(String openId);
|
||||
|
||||
/**
|
||||
* 根据userId查询用户
|
||||
*
|
||||
* @param userId userId
|
||||
* @return
|
||||
*/
|
||||
UserEntity queryByUserId(Long userId);
|
||||
|
||||
UserEntity queryByInvitationCode(String invitationCode);
|
||||
|
||||
/**
|
||||
* 根据用户appleId查询用户
|
||||
* @param appleId
|
||||
* @return
|
||||
*/
|
||||
UserEntity queryByAppleId(String appleId);
|
||||
|
||||
|
||||
Result wxLogin(String code);
|
||||
|
||||
/**
|
||||
* 注册或更新用户信息
|
||||
*
|
||||
* @param userInfo1 用户信息
|
||||
* @return 用户信息
|
||||
*/
|
||||
Result wxRegister(UserEntity userInfo1);
|
||||
|
||||
Result dyLogin(String code,String anonymous_code);
|
||||
|
||||
Result dyRegister(UserEntity userInfo1);
|
||||
|
||||
Result ksLogin(String code);
|
||||
|
||||
Result ksRegister(UserEntity userInfo1);
|
||||
|
||||
/**
|
||||
* 注册或更新用户信息
|
||||
*
|
||||
* @param appleId 苹果账号id
|
||||
* @return 用户信息
|
||||
*/
|
||||
Result iosRegister(String appleId);
|
||||
|
||||
/**
|
||||
* 发送验证码
|
||||
*
|
||||
* @param phone 手机号
|
||||
* @param state 验证码类型
|
||||
* @return
|
||||
*/
|
||||
Result sendMsg(String phone, String state,String pwd);
|
||||
|
||||
Result forgetPwd(String pwd, String phone, String msg);
|
||||
|
||||
/**
|
||||
* 绑定手机号
|
||||
*
|
||||
* @param phone 手机号
|
||||
* @param code 验证码
|
||||
* @return
|
||||
*/
|
||||
Result wxBindMobile(String phone, String code, String wxOpenId, String token, String platform, Integer sysPhone,String inviterCode,String qdCode);
|
||||
|
||||
/**
|
||||
* @param phone
|
||||
* @param code
|
||||
* @param appleId
|
||||
* @param platform
|
||||
* @param sysPhone
|
||||
* @return
|
||||
*/
|
||||
Result iosBindMobile(String phone, String code, String appleId, String platform, Integer sysPhone,String inviterCode,String qdCode);
|
||||
|
||||
Result phoneLogin(String phone);
|
||||
|
||||
Result bindMobile(String phone,String platform, Integer sysPhone,String inviterCode,String qdCode);
|
||||
|
||||
|
||||
/**
|
||||
* 换绑手机号
|
||||
*
|
||||
* @param phone 手机号
|
||||
* @param msg 验证码
|
||||
* @param userId 用户id
|
||||
* @return
|
||||
*/
|
||||
Result updatePhone(String phone, String msg, Long userId);
|
||||
|
||||
/**
|
||||
* 登录token
|
||||
*
|
||||
* @param user 用户信息
|
||||
* @return
|
||||
*/
|
||||
Result getResult(UserEntity user);
|
||||
|
||||
/**
|
||||
* app注册或h5注册
|
||||
*
|
||||
* @param phone 手机号
|
||||
* @param msg 验证按
|
||||
* @param pwd 密码
|
||||
* @param platform 来源 app h5
|
||||
* @return
|
||||
*/
|
||||
Result registerCode(String phone, String msg, String platform, Integer sysPhone,String password,
|
||||
String inviterCode,String wxId,String qdCode);
|
||||
|
||||
Result bindWxOpenPhone(Long userId, String phone, String msg);
|
||||
|
||||
|
||||
Result wxAppLogin(String wxOpenId, String token);
|
||||
|
||||
|
||||
/**
|
||||
* app或h5登录
|
||||
*
|
||||
* @param phone 手机号
|
||||
* @param pwd 密码
|
||||
* @return
|
||||
*/
|
||||
Result login(String phone, String pwd);
|
||||
|
||||
|
||||
/**
|
||||
* 根据 code 获取openId
|
||||
*
|
||||
* @param code
|
||||
* @param userId
|
||||
* @return
|
||||
*/
|
||||
Result getOpenId(String code, Long userId);
|
||||
|
||||
|
||||
/**
|
||||
* 根据用户id查询用户
|
||||
*
|
||||
* @param userId 用户id
|
||||
* @return
|
||||
*/
|
||||
UserEntity selectUserById(Long userId);
|
||||
|
||||
void pushToSingle(String title, String content, String clientId);
|
||||
|
||||
PageUtils selectUserPage(Integer page, Integer limit,String phone,Integer sex,String platform,String sysPhone,Integer status,
|
||||
Integer member, String inviterCode, String userName, String invitationCode, String startTime,
|
||||
String endTime,String qdCode,String sysUserName,Integer vipType);
|
||||
|
||||
List<UserEntity> userListExcel(String startTime, String endTime, UserEntity userEntity);
|
||||
|
||||
int queryInviterCount(String inviterCode);
|
||||
|
||||
int queryUserCount(int type,String date,String platform,String qdCode);
|
||||
|
||||
Double queryPayMoney(int type,String qdCode);
|
||||
|
||||
IPage<Map<String, Object>> queryCourseOrder(Page<Map<String, Object>> iPage, int type, String date,Long sysUserId);
|
||||
|
||||
int userMessage( String date, int type,String qdCode,Integer vipType);
|
||||
|
||||
|
||||
Result selectInviteUserList(Integer page,Integer limit,String userName,String phone);
|
||||
|
||||
Result loginByOpenId(String openId);
|
||||
|
||||
Result selectUserOnLineCount(String qdCode);
|
||||
|
||||
int updateUserClientIdIsNull(String clientid);
|
||||
|
||||
}
|
||||
@@ -0,0 +1,10 @@
|
||||
package com.sqx.modules.app.service;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
import com.sqx.modules.app.entity.UserVip;
|
||||
|
||||
public interface UserVipService extends IService<UserVip> {
|
||||
|
||||
UserVip selectUserVipByUserId(Long userId);
|
||||
|
||||
}
|
||||
@@ -0,0 +1,23 @@
|
||||
package com.sqx.modules.app.service;
|
||||
|
||||
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
import com.sqx.common.utils.Result;
|
||||
import com.sqx.modules.app.entity.VipDetails;
|
||||
|
||||
public interface VipDetailsService extends IService<VipDetails> {
|
||||
/**
|
||||
* 查询会员的详情信息
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
Result selectVipDetails();
|
||||
|
||||
/**
|
||||
* 添加会员的详情信息
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
Result insertVipDetails(VipDetails vipDetails);
|
||||
|
||||
}
|
||||
@@ -0,0 +1,45 @@
|
||||
package com.sqx.modules.app.service.impl;
|
||||
|
||||
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.sqx.modules.app.dao.AppDao;
|
||||
import com.sqx.modules.app.entity.App;
|
||||
import com.sqx.modules.app.service.AppService;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
|
||||
@Service("AppService")
|
||||
public class AppServiceImpl extends ServiceImpl<AppDao, App> implements AppService {
|
||||
|
||||
@Autowired
|
||||
private AppDao appDao;
|
||||
|
||||
|
||||
@Override
|
||||
public App selectAppById(Long id) {
|
||||
return appDao.selectById(id);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int insertApp(App app) {
|
||||
return appDao.insert(app);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int updateAppById(App app) {
|
||||
return appDao.updateById(app);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int deleteAppById(Long id) {
|
||||
return appDao.deleteById(id);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<App> selectNewApp() {
|
||||
return appDao.selectNewApp();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,156 @@
|
||||
package com.sqx.modules.app.service.impl;
|
||||
|
||||
|
||||
import com.auth0.jwk.Jwk;
|
||||
import com.sqx.common.utils.Result;
|
||||
import com.sqx.modules.app.service.IAppleService;
|
||||
import io.jsonwebtoken.*;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import net.sf.json.JSONArray;
|
||||
import net.sf.json.JSONObject;
|
||||
import org.apache.tomcat.util.codec.binary.Base64;
|
||||
import org.springframework.stereotype.Component;
|
||||
import org.springframework.web.client.RestTemplate;
|
||||
|
||||
import java.security.PublicKey;
|
||||
|
||||
/**
|
||||
* @Description 苹果登录service
|
||||
* @author fang
|
||||
* @date 2020/11/4
|
||||
*/
|
||||
|
||||
@Slf4j
|
||||
@Component
|
||||
public class AppleServiceImpl implements IAppleService {
|
||||
|
||||
@Override
|
||||
public Result getAppleUserInfo(String identityToken) throws Exception {
|
||||
//验证identityToken
|
||||
if (!verify(identityToken)) {
|
||||
log.error("苹果解析失败!");
|
||||
return Result.error("苹果账号验证失败,请退出重试!");
|
||||
}
|
||||
//对identityToken解码
|
||||
JSONObject json = parserIdentityToken(identityToken);
|
||||
if (json == null) {
|
||||
return Result.error("苹果账号验证失败,请退出重试!");
|
||||
}
|
||||
String appleUserId = String.valueOf(json.get("sub"));
|
||||
log.error("苹果账号解析成功:"+appleUserId);
|
||||
System.err.println(appleUserId);
|
||||
return Result.success().put("data",appleUserId);
|
||||
}
|
||||
|
||||
/**
|
||||
* 对前端传来的JWT字符串identityToken的第二部分进行解码
|
||||
* 主要获取其中的aud和sub,aud大概对应ios前端的包名,sub大概对应当前用户的授权的openID
|
||||
*
|
||||
* @param identityToken 身份token
|
||||
* @return {"aud":"com.xkj.****","sub":"000***.8da764d3f9e34d2183e8da08a1057***.0***","c_hash":"UsKAuEoI-****","email_verified":"true","auth_time":1574673481,"iss":"https://appleid.apple.com","exp":1574674081,"iat":1574673481,"email":"****@qq.com"}
|
||||
*/
|
||||
private JSONObject parserIdentityToken(String identityToken) {
|
||||
String[] arr = identityToken.split("\\.");
|
||||
String decode = new String(Base64.decodeBase64(arr[1]));
|
||||
String substring = decode.substring(0, decode.indexOf("}") + 1);
|
||||
return JSONObject.fromObject(substring);
|
||||
}
|
||||
|
||||
|
||||
public Boolean verify(String jwt) throws Exception {
|
||||
JSONArray arr = getAuthKeys();
|
||||
if (arr == null) {
|
||||
log.error("获取不到苹果的验证秘钥!!");
|
||||
return false;
|
||||
}
|
||||
|
||||
JSONObject authKey = null;
|
||||
//先取苹果第一个key进行校验
|
||||
if(arr.size()==2){
|
||||
authKey = JSONObject.fromObject(arr.getString(0));
|
||||
if (verifyExc(jwt, authKey)) {
|
||||
log.error("苹果解析成功!1");
|
||||
return true;
|
||||
} else {
|
||||
//再取第二个key校验
|
||||
authKey = JSONObject.fromObject(arr.getString(1));
|
||||
return verifyExc(jwt, authKey);
|
||||
}
|
||||
}else{
|
||||
authKey = JSONObject.fromObject(arr.getString(0));
|
||||
if (verifyExc(jwt, authKey)) {
|
||||
log.error("苹果解析成功!1");
|
||||
return true;
|
||||
}
|
||||
//再取第二个key校验
|
||||
authKey = JSONObject.fromObject(arr.getString(1));
|
||||
if(verifyExc(jwt, authKey)){
|
||||
log.error("苹果解析成功!2");
|
||||
return true;
|
||||
}else{
|
||||
authKey = JSONObject.fromObject(arr.getString(2));
|
||||
return verifyExc(jwt, authKey);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 对前端传来的identityToken进行验证
|
||||
*
|
||||
* @param jwt 对应前端传来的 identityToken
|
||||
* @param authKey 苹果的公钥 authKey
|
||||
* @return
|
||||
* @throws Exception
|
||||
*/
|
||||
private static Boolean verifyExc(String jwt, JSONObject authKey) throws Exception {
|
||||
|
||||
Jwk jwa = Jwk.fromValues(authKey);
|
||||
PublicKey publicKey = jwa.getPublicKey();
|
||||
|
||||
String aud = "";
|
||||
String sub = "";
|
||||
if (jwt.split("\\.").length > 1) {
|
||||
String claim = new String(Base64.decodeBase64(jwt.split("\\.")[1]));
|
||||
aud = JSONObject.fromObject(claim).get("aud").toString();
|
||||
sub = JSONObject.fromObject(claim).get("sub").toString();
|
||||
}
|
||||
JwtParser jwtParser = Jwts.parser().setSigningKey(publicKey);
|
||||
jwtParser.requireIssuer("https://appleid.apple.com");
|
||||
jwtParser.requireAudience(aud);
|
||||
jwtParser.requireSubject(sub);
|
||||
|
||||
try {
|
||||
Jws<Claims> claim = jwtParser.parseClaimsJws(jwt);
|
||||
if (claim != null && claim.getBody().containsKey("auth_time")) {
|
||||
System.out.println(claim);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
} catch (ExpiredJwtException e) {
|
||||
log.error("[AppleServiceImpl.verifyExc] [error] [apple identityToken expired]", e);
|
||||
return false;
|
||||
} catch (Exception e) {
|
||||
log.error("[AppleServiceImpl.verifyExc] [error] [apple identityToken illegal]", e);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 获取苹果的公钥
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
private static JSONArray getAuthKeys() {
|
||||
String url = "https://appleid.apple.com/auth/keys";
|
||||
RestTemplate restTemplate = new RestTemplate();
|
||||
JSONObject json = restTemplate.getForObject(url, JSONObject.class);
|
||||
if (json != null) {
|
||||
return json.getJSONArray("keys");
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,30 @@
|
||||
package com.sqx.modules.app.service.impl;
|
||||
|
||||
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.sqx.modules.app.dao.MsgDao;
|
||||
import com.sqx.modules.app.entity.Msg;
|
||||
import com.sqx.modules.app.service.MsgService;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
|
||||
@Service("MsgService")
|
||||
public class MsgServiceImpl extends ServiceImpl<MsgDao, Msg> implements MsgService {
|
||||
|
||||
@Autowired
|
||||
private MsgDao msgDao;
|
||||
|
||||
@Override
|
||||
public Msg findByPhone(String phone){
|
||||
return msgDao.findByPhone(phone);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Msg findByPhoneAndCode(String phone, String msg){
|
||||
return msgDao.findByPhoneAndCode(phone,msg);
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,40 @@
|
||||
package com.sqx.modules.app.service.impl;
|
||||
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.sqx.common.utils.Result;
|
||||
import com.sqx.modules.app.dao.UserMoneyDetailsDao;
|
||||
import com.sqx.modules.app.entity.UserMoneyDetails;
|
||||
import com.sqx.modules.app.service.UserMoneyDetailsService;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
@Service
|
||||
public class UserMoneyDetailsServiceImpl extends ServiceImpl<UserMoneyDetailsDao, UserMoneyDetails> implements UserMoneyDetailsService {
|
||||
|
||||
@Override
|
||||
public Result queryUserMoneyDetails(Integer page, Integer limit,Long sysUserId,Long userId,Integer classify,Integer type) {
|
||||
IPage<UserMoneyDetails> page1 = new Page(page, limit);
|
||||
QueryWrapper<UserMoneyDetails> queryWrapper = new QueryWrapper();
|
||||
if(sysUserId!=null){
|
||||
queryWrapper.eq("sys_user_id", sysUserId);
|
||||
}
|
||||
if(userId!=null){
|
||||
queryWrapper.eq("user_id", userId);
|
||||
}
|
||||
if(classify!=null){
|
||||
queryWrapper.eq("classify", classify);
|
||||
}
|
||||
if(type!=null){
|
||||
queryWrapper.eq("type", type);
|
||||
}
|
||||
queryWrapper.orderByDesc("create_time");
|
||||
return Result.success().put("data", baseMapper.selectPage(page1, queryWrapper));
|
||||
}
|
||||
|
||||
@Override
|
||||
public Double monthIncome(String date, Long userId) {
|
||||
return baseMapper.monthIncome(date,userId);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,52 @@
|
||||
package com.sqx.modules.app.service.impl;
|
||||
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.sqx.modules.app.dao.UserMoneyDao;
|
||||
import com.sqx.modules.app.entity.UserMoney;
|
||||
import com.sqx.modules.app.service.UserMoneyService;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
|
||||
@Service
|
||||
public class UserMoneyServiceImpl extends ServiceImpl<UserMoneyDao, UserMoney> implements UserMoneyService {
|
||||
|
||||
@Override
|
||||
public void updateMoney(int i, Long userId, double money){
|
||||
selectUserMoneyByUserId(userId);
|
||||
baseMapper.updateMayMoney(i,userId,money);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateSysMoney(int i, Long userId, double money){
|
||||
selectSysUserMoneyByUserId(userId);
|
||||
baseMapper.updateSysMoney(i,userId,money);
|
||||
}
|
||||
|
||||
@Override
|
||||
public UserMoney selectUserMoneyByUserId(Long userId){
|
||||
UserMoney userMoney = baseMapper.selectOne(new QueryWrapper<UserMoney>().eq("user_id", userId));
|
||||
if(userMoney==null){
|
||||
userMoney=new UserMoney();
|
||||
userMoney.setUserId(userId);
|
||||
userMoney.setMoney(new BigDecimal("0.00"));
|
||||
baseMapper.insert(userMoney);
|
||||
}
|
||||
return userMoney;
|
||||
}
|
||||
|
||||
@Override
|
||||
public UserMoney selectSysUserMoneyByUserId(Long userId){
|
||||
UserMoney userMoney = baseMapper.selectOne(new QueryWrapper<UserMoney>().eq("sys_user_id", userId));
|
||||
if(userMoney==null){
|
||||
userMoney=new UserMoney();
|
||||
userMoney.setSysUserId(userId);
|
||||
userMoney.setMoney(new BigDecimal("0.00"));
|
||||
baseMapper.insert(userMoney);
|
||||
}
|
||||
return userMoney;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
1450
src/main/java/com/sqx/modules/app/service/impl/UserServiceImpl.java
Normal file
1450
src/main/java/com/sqx/modules/app/service/impl/UserServiceImpl.java
Normal file
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,25 @@
|
||||
package com.sqx.modules.app.service.impl;
|
||||
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.sqx.modules.app.dao.UserVipDao;
|
||||
import com.sqx.modules.app.entity.UserVip;
|
||||
import com.sqx.modules.app.service.UserVipService;
|
||||
import org.springframework.scheduling.annotation.Scheduled;
|
||||
import org.springframework.stereotype.Service;
|
||||
@Service
|
||||
public class UserVipServiceImpl extends ServiceImpl<UserVipDao, UserVip> implements UserVipService {
|
||||
|
||||
@Override
|
||||
public UserVip selectUserVipByUserId(Long userId) {
|
||||
QueryWrapper<UserVip> queryWrapper = new QueryWrapper<>();
|
||||
queryWrapper.eq("user_id",userId);
|
||||
return baseMapper.selectOne(queryWrapper);
|
||||
}
|
||||
|
||||
@Scheduled(cron="0 */1 * * * ?")
|
||||
public void getEndVip() {
|
||||
baseMapper.updateUserVipByEndTime();
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,33 @@
|
||||
package com.sqx.modules.app.service.impl;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.sqx.common.utils.Result;
|
||||
import com.sqx.modules.app.dao.VipDetailsDao;
|
||||
import com.sqx.modules.app.entity.VipDetails;
|
||||
import com.sqx.modules.app.service.VipDetailsService;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
@Service
|
||||
public class VipDetailsServiceImpl extends ServiceImpl<VipDetailsDao, VipDetails> implements VipDetailsService {
|
||||
|
||||
|
||||
|
||||
@Override
|
||||
public Result selectVipDetails() {
|
||||
return Result.success().put("data", baseMapper.selectList(null));
|
||||
}
|
||||
|
||||
@Override
|
||||
public Result insertVipDetails(VipDetails vipDetails) {
|
||||
int cpunt = baseMapper.insert(vipDetails);
|
||||
if (cpunt > 0) {
|
||||
return Result.success("添加成功!");
|
||||
} else {
|
||||
return Result.error("添加失败");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
86
src/main/java/com/sqx/modules/app/utils/JwtUtils.java
Normal file
86
src/main/java/com/sqx/modules/app/utils/JwtUtils.java
Normal file
@@ -0,0 +1,86 @@
|
||||
package com.sqx.modules.app.utils;
|
||||
|
||||
import io.jsonwebtoken.Claims;
|
||||
import io.jsonwebtoken.Jwts;
|
||||
import io.jsonwebtoken.SignatureAlgorithm;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.boot.context.properties.ConfigurationProperties;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
/**
|
||||
* jwt工具类
|
||||
*
|
||||
*/
|
||||
@ConfigurationProperties(prefix = "sqx.jwt")
|
||||
@Component
|
||||
public class JwtUtils {
|
||||
private Logger logger = LoggerFactory.getLogger(getClass());
|
||||
|
||||
private String secret;
|
||||
private long expire;
|
||||
private String header;
|
||||
|
||||
/**
|
||||
* 生成jwt token
|
||||
*/
|
||||
public String generateToken(long userId) {
|
||||
Date nowDate = new Date();
|
||||
//过期时间
|
||||
Date expireDate = new Date(nowDate.getTime() + expire * 1000);
|
||||
|
||||
return Jwts.builder()
|
||||
.setHeaderParam("typ", "JWT")
|
||||
.setSubject(userId+"")
|
||||
.setIssuedAt(nowDate)
|
||||
.setExpiration(expireDate)
|
||||
.signWith(SignatureAlgorithm.HS512, secret)
|
||||
.compact();
|
||||
}
|
||||
|
||||
public Claims getClaimByToken(String token) {
|
||||
try {
|
||||
return Jwts.parser()
|
||||
.setSigningKey(secret)
|
||||
.parseClaimsJws(token)
|
||||
.getBody();
|
||||
}catch (Exception e){
|
||||
logger.debug("validate is token error ", e);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* token是否过期
|
||||
* @return true:过期
|
||||
*/
|
||||
public boolean isTokenExpired(Date expiration) {
|
||||
return expiration.before(new Date());
|
||||
}
|
||||
|
||||
public String getSecret() {
|
||||
return secret;
|
||||
}
|
||||
|
||||
public void setSecret(String secret) {
|
||||
this.secret = secret;
|
||||
}
|
||||
|
||||
public long getExpire() {
|
||||
return expire;
|
||||
}
|
||||
|
||||
public void setExpire(long expire) {
|
||||
this.expire = expire;
|
||||
}
|
||||
|
||||
public String getHeader() {
|
||||
return header;
|
||||
}
|
||||
|
||||
public void setHeader(String header) {
|
||||
this.header = header;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,53 @@
|
||||
package com.sqx.modules.app.utils;
|
||||
|
||||
|
||||
import cn.hutool.core.codec.Base64;
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import com.sqx.common.utils.Result;
|
||||
|
||||
import javax.crypto.Cipher;
|
||||
import javax.crypto.spec.IvParameterSpec;
|
||||
import javax.crypto.spec.SecretKeySpec;
|
||||
import java.security.spec.AlgorithmParameterSpec;
|
||||
|
||||
/**
|
||||
* 参数配置
|
||||
*/
|
||||
public interface UserConstantInterface {
|
||||
|
||||
|
||||
/**
|
||||
* 请求的网址
|
||||
*/
|
||||
String WX_LOGIN_URL = "https://api.weixin.qq.com/sns/jscode2session";
|
||||
|
||||
/**
|
||||
* 固定参数
|
||||
*/
|
||||
String WX_LOGIN_GRANT_TYPE = "authorization_code";
|
||||
|
||||
/**
|
||||
* 解密手机号
|
||||
* @param decryptData 加密手机号(微信返回)
|
||||
* @param key session_key
|
||||
* @param iv iv(微信返回)
|
||||
* @return
|
||||
*/
|
||||
static Result decryptS5(String decryptData, String key, String iv) {
|
||||
try {
|
||||
byte[] encData = Base64.decode(decryptData);
|
||||
byte[] ivs = Base64.decode(iv);
|
||||
byte[] keys = Base64.decode(key);
|
||||
AlgorithmParameterSpec ivSpec = new IvParameterSpec(ivs);
|
||||
Cipher cipher = Cipher.getInstance("AES/CBC/PKCS5Padding");
|
||||
SecretKeySpec keySpec = new SecretKeySpec(keys, "AES");
|
||||
cipher.init(Cipher.DECRYPT_MODE, keySpec, ivSpec);
|
||||
return Result.success("获取手机号成功").put("data", JSON.parseObject(new String(cipher.doFinal(encData), "UTF-8")));
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
return Result.error(-1,"获取手机号失败");
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
14
src/main/java/com/sqx/modules/app/utils/WxPhone.java
Normal file
14
src/main/java/com/sqx/modules/app/utils/WxPhone.java
Normal file
@@ -0,0 +1,14 @@
|
||||
package com.sqx.modules.app.utils;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
@Data
|
||||
public class WxPhone {
|
||||
|
||||
private String decryptData;
|
||||
|
||||
private String key;
|
||||
|
||||
private String iv;
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user