diff --git a/pom.xml b/pom.xml
index 57b71c2d..74b55bf6 100644
--- a/pom.xml
+++ b/pom.xml
@@ -72,6 +72,12 @@
cn.afterturn
easypoi-spring-boot-starter
4.0.0
+
+
+ javassist
+ org.javassist
+
+
com.github.qcloudsms
diff --git a/src/main/java/com/sqx/common/utils/RedisKeys.java b/src/main/java/com/sqx/common/utils/RedisKeys.java
index 6d568f41..e336f71e 100644
--- a/src/main/java/com/sqx/common/utils/RedisKeys.java
+++ b/src/main/java/com/sqx/common/utils/RedisKeys.java
@@ -1,11 +1,15 @@
package com.sqx.common.utils;
+import cn.hutool.core.date.DateUtil;
+
/**
* Redis所有Keys
*
*/
public class RedisKeys {
+ public static final String PAY_FREE_WATCH_KEY = "pay:free:watch:";
+
public static String getSysConfigKey(String key){
return "sys:config:" + key;
}
@@ -13,4 +17,12 @@ public class RedisKeys {
public static String getDateKey(String key){
return "date:" + key;
}
+
+ public static String getPayFreeWatchKey(Long userId) {
+ return PAY_FREE_WATCH_KEY + DateUtil.today() + ":" + userId;
+ }
+
+ public static void main(String[] args) {
+ System.out.println(DateUtil.today());
+ }
}
diff --git a/src/main/java/com/sqx/common/utils/RedisUtils.java b/src/main/java/com/sqx/common/utils/RedisUtils.java
index 3b90d246..6761c2e6 100644
--- a/src/main/java/com/sqx/common/utils/RedisUtils.java
+++ b/src/main/java/com/sqx/common/utils/RedisUtils.java
@@ -1,5 +1,6 @@
package com.sqx.common.utils;
+import com.fasterxml.jackson.databind.JsonNode;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.google.gson.Gson;
import com.sqx.modules.redisService.RedisService;
@@ -10,12 +11,14 @@ import org.springframework.stereotype.Component;
import java.lang.invoke.MethodHandle;
import java.lang.invoke.MethodHandles;
import java.lang.invoke.MethodType;
+import java.util.HashMap;
+import java.util.Iterator;
import java.util.List;
+import java.util.Map;
import java.util.concurrent.TimeUnit;
/**
* Redis工具类
- *
*/
@Component
public class RedisUtils {
@@ -33,19 +36,31 @@ public class RedisUtils {
private SetOperations setOperations;
@Autowired
private ZSetOperations zSetOperations;
- /** 默认过期时长,单位:秒 */
+ /**
+ * 默认过期时长,单位:秒
+ */
public final static long DEFAULT_EXPIRE = 60 * 60 * 24;
- /** 不设置过期时长 */
+ /**
+ * 不设置过期时长
+ */
public final static long NOT_EXPIRE = -1;
private final static Gson Gson = new Gson();
- /**
- * 获取缓存里的数据 如果不存在 则插入 并返回
- * @param key redis Key
- * @param clazz 返回类型
- * @param method RedisService调用的方法名 如果数据不存在会执行该调用方法
- */
- public List getListData(String key, Class clazz,String method) {
+
+ public Map> getMapData(String key, String method, Class clazz) {
+ String jsonStr = getDate(key, method);
+ ObjectMapper objectMapper = new ObjectMapper();
+ try {
+ JsonNode jsonNode = objectMapper.readTree(jsonStr);
+
+ return jsonNodeToMap(jsonNode, clazz);
+ } catch (Exception e) {
+ e.printStackTrace();
+ return null;
+ }
+ }
+
+ public List getListData(String key, Class clazz, String method) {
String jsonStr = getDate(key, method);
ObjectMapper objectMapper = new ObjectMapper();
try {
@@ -59,26 +74,27 @@ public class RedisUtils {
/**
* 获取缓存里的数据 如果不存在 则插入 并返回
- * @param key redis Key
- * @param clazz 返回类型
+ *
+ * @param key redis Key
+ * @param clazz 返回类型
* @param method RedisService调用的方法名 如果数据不存在会执行该调用方法
*/
- public T getObjectDate(String key, Class clazz,String method) {
+ public T getObjectDate(String key, Class clazz, String method) {
String jsonStr = getDate(key, method);
return this.fromJson(jsonStr, clazz);
}
- public String getDate(String key, String method) {
+ public String getDate(String key, String method) {
if (!this.hasKey(key)) {
try {
// 获取Lookup对象
MethodHandles.Lookup lookup = MethodHandles.lookup();
// 构建方法类型(这里假设方法无参数,返回类型为void)
- MethodType methodType = MethodType.methodType(void.class , String.class);
+ MethodType methodType = MethodType.methodType(void.class, String.class);
// 获取方法句柄
MethodHandle methodHandle = lookup.findVirtual(redisService.getClass(), method, methodType);
// 调用方法句柄
- methodHandle.invoke(redisService,key);
+ methodHandle.invoke(redisService, key);
} catch (Exception e) {
e.printStackTrace();
return null;
@@ -93,20 +109,34 @@ public class RedisUtils {
return redisTemplate.hasKey(key);
}
- public void set(String key, Object value, long expire){
+ public void set(String key, Object value, long expire) {
valueOperations.set(key, toJson(value));
+ if (expire != NOT_EXPIRE) {
+ redisTemplate.expire(key, expire, TimeUnit.SECONDS);
+ }
+
+ }
+
+ public boolean setIfAbsent(String key, Object value, long expire){
+ Boolean absent = valueOperations.setIfAbsent(key, toJson(value));
+ if (Boolean.FALSE.equals(absent)) {
+ return false;
+ }
if(expire != NOT_EXPIRE){
redisTemplate.expire(key, expire, TimeUnit.SECONDS);
}
+
+ return true;
+
}
- public void set(String key, Object value){
+ public void set(String key, Object value) {
set(key, value, DEFAULT_EXPIRE);
}
public T get(String key, Class clazz, long expire) {
String value = valueOperations.get(key);
- if(expire != NOT_EXPIRE){
+ if (expire != NOT_EXPIRE) {
redisTemplate.expire(key, expire, TimeUnit.SECONDS);
}
return value == null ? null : fromJson(value, clazz);
@@ -118,7 +148,7 @@ public class RedisUtils {
public String get(String key, long expire) {
String value = valueOperations.get(key);
- if(expire != NOT_EXPIRE){
+ if (expire != NOT_EXPIRE) {
redisTemplate.expire(key, expire, TimeUnit.SECONDS);
}
return value;
@@ -150,9 +180,9 @@ public class RedisUtils {
/**
* Object转成JSON数据
*/
- private String toJson(Object object){
- if(object instanceof Integer || object instanceof Long || object instanceof Float ||
- object instanceof Double || object instanceof Boolean || object instanceof String){
+ private String toJson(Object object) {
+ if (object instanceof Integer || object instanceof Long || object instanceof Float ||
+ object instanceof Double || object instanceof Boolean || object instanceof String) {
return String.valueOf(object);
}
return Gson.toJson(object);
@@ -161,7 +191,25 @@ public class RedisUtils {
/**
* JSON数据,转成Object
*/
- private T fromJson(String json, Class clazz){
+ private T fromJson(String json, Class clazz) {
return Gson.fromJson(json, clazz);
}
+
+
+ public Map> jsonNodeToMap(JsonNode jsonNode, Class clazz) {
+ Map> resultMap = new HashMap<>();
+ ObjectMapper objectMapper = new ObjectMapper();
+
+ if (jsonNode.isObject()) {
+ // 获取字段名(也就是键)的迭代器
+ Iterator fieldNames = jsonNode.fieldNames();
+ while (fieldNames.hasNext()) {
+ String key = fieldNames.next();
+ JsonNode elementNode = jsonNode.get(key);
+ resultMap.put(key, objectMapper.convertValue(elementNode,
+ objectMapper.getTypeFactory().constructCollectionType(List.class, clazz)));
+ }
+ }
+ return resultMap;
+ }
}
diff --git a/src/main/java/com/sqx/config/ShiroConfig.java b/src/main/java/com/sqx/config/ShiroConfig.java
index ef4b9c6e..98adf705 100644
--- a/src/main/java/com/sqx/config/ShiroConfig.java
+++ b/src/main/java/com/sqx/config/ShiroConfig.java
@@ -49,6 +49,7 @@ public class ShiroConfig {
filterMap.put("/banner/**", "anon");
filterMap.put("/courseClassification/selectCourseClassification", "anon");
filterMap.put("/sys/login", "anon");
+ filterMap.put("/sys/registered", "anon");
filterMap.put("/swagger/**", "anon");
filterMap.put("/alioss/**", "anon");
filterMap.put("/v2/api-docs", "anon");
diff --git a/src/main/java/com/sqx/modules/app/controller/AppUserPrizeExchangeController.java b/src/main/java/com/sqx/modules/app/controller/AppUserPrizeExchangeController.java
new file mode 100644
index 00000000..4e5a57ae
--- /dev/null
+++ b/src/main/java/com/sqx/modules/app/controller/AppUserPrizeExchangeController.java
@@ -0,0 +1,46 @@
+package com.sqx.modules.app.controller;
+
+import com.sqx.common.utils.Constant;
+import com.sqx.common.utils.PageUtils;
+import com.sqx.common.utils.Result;
+import com.sqx.modules.app.annotation.Login;
+import com.sqx.modules.app.entity.UserPrizeExchange;
+import com.sqx.modules.app.service.UserPrizeExchangeService;
+import io.swagger.annotations.Api;
+import io.swagger.annotations.ApiImplicitParam;
+import io.swagger.annotations.ApiImplicitParams;
+import io.swagger.annotations.ApiOperation;
+import lombok.AllArgsConstructor;
+import org.springframework.web.bind.annotation.*;
+import springfox.documentation.annotations.ApiIgnore;
+
+import java.util.Map;
+
+@RestController
+@RequestMapping("/app/userPrizeExchange")
+@AllArgsConstructor
+@Api(value = "用户奖品兑换", tags = {"用户奖品兑换"})
+public class AppUserPrizeExchangeController {
+ private final UserPrizeExchangeService userPrizeExchangeService;
+
+ @Login
+ @GetMapping("/page")
+ @ApiOperation("分页")
+ @ApiImplicitParams({
+ @ApiImplicitParam(name = Constant.PAGE, value = "当前页码,从1开始", paramType = "query", required = true, dataType = "int"),
+ @ApiImplicitParam(name = Constant.LIMIT, value = "每页显示记录数", paramType = "query", required = true, dataType = "int"),
+ })
+ public Result page(@RequestAttribute("userId") Long userId, @ApiIgnore @RequestParam Map params) {
+ params.put("userId", userId);
+ PageUtils page = userPrizeExchangeService.page(params);
+ return Result.success().put("page", page);
+ }
+
+ @Login
+ @PostMapping("/exchange")
+ @ApiOperation("兑换")
+ public Result exchange(@RequestAttribute("userId") Long userId, @RequestBody UserPrizeExchange entity) {
+ userPrizeExchangeService.exchange(userId, entity);
+ return Result.success();
+ }
+}
diff --git a/src/main/java/com/sqx/modules/app/controller/app/AppController.java b/src/main/java/com/sqx/modules/app/controller/app/AppController.java
index 1dd37c5f..345c1bd7 100644
--- a/src/main/java/com/sqx/modules/app/controller/app/AppController.java
+++ b/src/main/java/com/sqx/modules/app/controller/app/AppController.java
@@ -1,9 +1,9 @@
package com.sqx.modules.app.controller.app;
+import cn.hutool.core.util.StrUtil;
import com.alibaba.fastjson.JSONObject;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
-import com.sqx.common.annotation.Debounce;
import com.sqx.common.utils.ApiAccessLimitUtil;
import com.sqx.common.utils.Result;
import com.sqx.modules.app.annotation.Login;
@@ -11,7 +11,6 @@ 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 com.sqx.modules.message.entity.MessageInfo;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.apache.commons.codec.digest.DigestUtils;
@@ -75,22 +74,37 @@ public class AppController {
@ApiOperation("用户修改个人信息")
@ResponseBody
public Result updateUserImageUrl(@RequestAttribute("userId") Long userId, String zhiFuBao, String zhiFuBaoName) {
+ if(StrUtil.isEmpty(zhiFuBao) || StrUtil.isEmpty(zhiFuBaoName)){
+ return Result.error("支付宝账户及姓名不能为空!");
+ }
int count = userService.count(new QueryWrapper()
- .ne( "user_id", userId)
+ .ne("user_id", userId)
.eq("zhi_fu_bao_name", zhiFuBaoName)
.eq("zhi_fu_bao", zhiFuBao));
if (count > 0) {
- return Result.error("一个支付宝账号仅可绑定一个支付宝用户");
+ return Result.error("一个支付宝账号仅可绑定一个用户");
}
if (!ApiAccessLimitUtil.isAccessAllowed(userId.toString(), "updateZFB", 3, "month")) {
return Result.error("每月仅支持修改三次,请联系管理员");
}
+ UserEntity old = userService.getById(userId);
+ String accountNo = old.getZhiFuBao();
+ String accountName = old.getZhiFuBaoName();
+ boolean isFirstBind = false;
+ if (StrUtil.isEmpty(accountNo) && StrUtil.isEmpty(accountName)) {
+ isFirstBind = true;
+ }
UserEntity userEntity = new UserEntity();
userEntity.setZhiFuBao(zhiFuBao);
userEntity.setZhiFuBaoName(zhiFuBaoName);
userEntity.setUserId(userId);
- userService.updateById(userEntity);
+ old.setZhiFuBao(userEntity.getZhiFuBao());
+ old.setZhiFuBaoName(userEntity.getZhiFuBaoName());
+ boolean bool = userService.updateById(userEntity);
+ if (bool && isFirstBind) {
+ userService.firstBindAwardsMoney(old);
+ }
return Result.success();
}
diff --git a/src/main/java/com/sqx/modules/app/controller/app/AppUserSignController.java b/src/main/java/com/sqx/modules/app/controller/app/AppUserSignController.java
new file mode 100644
index 00000000..2aaf5faa
--- /dev/null
+++ b/src/main/java/com/sqx/modules/app/controller/app/AppUserSignController.java
@@ -0,0 +1,51 @@
+package com.sqx.modules.app.controller.app;
+
+import com.sqx.common.utils.Result;
+import com.sqx.modules.app.annotation.Login;
+import com.sqx.modules.userSign.dto.UserSignDTO;
+import com.sqx.modules.userSign.service.UserSignRecordService;
+import io.swagger.annotations.Api;
+import io.swagger.annotations.ApiOperation;
+import lombok.extern.slf4j.Slf4j;
+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;
+
+/**
+ * @author tankaikai
+ * @since 2024-12-19 15:23
+ */
+
+@Slf4j
+@RestController
+@Api(value = "用户签到", tags = {"用户签到"})
+@RequestMapping(value = "/app/userSignRecord")
+public class AppUserSignController {
+
+ @Autowired
+ private UserSignRecordService userSignRecordService;
+
+ /**
+ * 获取用户连续签到数据
+ */
+ @Login
+ @GetMapping("/getUserSignData")
+ @ApiOperation("获取用户连续签到数据")
+ public Result getUserSignData(@RequestAttribute("userId") Long userId) {
+ UserSignDTO data = userSignRecordService.getUserSignData(userId);
+ return Result.success().put("data", data);
+ }
+
+ /**
+ * 获取连续签到奖励配置
+ */
+ @Login
+ @GetMapping("/getUserSignAwardConfig")
+ @ApiOperation(value = "获取连续签到奖励配置", notes = "如:[7,7] = 连续签到7天奖励7元")
+ public Result getUserSignAwardConfig() {
+ String[] data = userSignRecordService.getUserSignAwardConfig();
+ return Result.success().put("data", data);
+ }
+}
diff --git a/src/main/java/com/sqx/modules/app/dao/UserPrizeExchangeDao.java b/src/main/java/com/sqx/modules/app/dao/UserPrizeExchangeDao.java
new file mode 100644
index 00000000..006c7609
--- /dev/null
+++ b/src/main/java/com/sqx/modules/app/dao/UserPrizeExchangeDao.java
@@ -0,0 +1,15 @@
+package com.sqx.modules.app.dao;
+
+import com.baomidou.mybatisplus.core.mapper.BaseMapper;
+import com.sqx.modules.app.entity.UserPrizeExchange;
+import org.apache.ibatis.annotations.Mapper;
+
+/**
+ * 用户奖品兑换
+ *
+ * @author tankaikai
+ * @since 2024-12-20 18:11
+ */
+@Mapper
+public interface UserPrizeExchangeDao extends BaseMapper {
+}
diff --git a/src/main/java/com/sqx/modules/app/entity/UserPrizeExchange.java b/src/main/java/com/sqx/modules/app/entity/UserPrizeExchange.java
new file mode 100644
index 00000000..5b6d7efa
--- /dev/null
+++ b/src/main/java/com/sqx/modules/app/entity/UserPrizeExchange.java
@@ -0,0 +1,68 @@
+package com.sqx.modules.app.entity;
+
+import com.baomidou.mybatisplus.annotation.IdType;
+import com.baomidou.mybatisplus.annotation.TableId;
+import com.baomidou.mybatisplus.annotation.TableName;
+import lombok.Data;
+
+import java.io.Serializable;
+import java.util.Date;
+
+/**
+ * 用户奖品兑换
+ * @author tankaikai
+ * @since 2024-12-20 17:52
+ */
+@Data
+@TableName("user_prize_exchange")
+public class UserPrizeExchange implements Serializable {
+
+ private static final long serialVersionUID = 1L;
+
+ /**
+ * 奖品记录
+ */
+ @TableId(type = IdType.ID_WORKER)
+ private Long id;
+
+ /**
+ * 奖品记录id
+ */
+ private Long discSpinningRecordId;
+ /**
+ * 奖品名称
+ */
+ private String prizeName;
+ /**
+ * 用户id
+ */
+ private Long userId;
+ /**
+ * 用户名
+ */
+ private String userName;
+ /**
+ * 手机号
+ */
+ private String phone;
+ /**
+ * 收货地址
+ */
+ private String address;
+ /**
+ * 备注
+ */
+ private String remark;
+ /**
+ * 状态 0-待发放 1-已发放
+ */
+ private Integer status;
+ /**
+ * 创建时间
+ */
+ private Date createTime;
+ /**
+ * 更新时间
+ */
+ private Date updateTime;
+}
diff --git a/src/main/java/com/sqx/modules/app/service/UserPrizeExchangeService.java b/src/main/java/com/sqx/modules/app/service/UserPrizeExchangeService.java
new file mode 100644
index 00000000..6adc1191
--- /dev/null
+++ b/src/main/java/com/sqx/modules/app/service/UserPrizeExchangeService.java
@@ -0,0 +1,38 @@
+package com.sqx.modules.app.service;
+
+import com.baomidou.mybatisplus.extension.service.IService;
+import com.sqx.common.utils.PageUtils;
+import com.sqx.modules.app.entity.UserPrizeExchange;
+
+import java.util.Map;
+
+/**
+ * 用户奖品兑换Service
+ *
+ * @author tankaikai
+ * @since 2024-12-20 18:04
+ */
+public interface UserPrizeExchangeService extends IService {
+ /**
+ * 分页查询
+ *
+ * @param params
+ * @return
+ */
+ PageUtils page(Map params);
+
+ /**
+ * 兑换奖品
+ *
+ * @param entity
+ */
+ void exchange(Long currentUserId, UserPrizeExchange entity);
+
+ /**
+ * 发放奖品
+ *
+ * @param dto
+ */
+
+ void deliver(UserPrizeExchange dto);
+}
diff --git a/src/main/java/com/sqx/modules/app/service/UserService.java b/src/main/java/com/sqx/modules/app/service/UserService.java
index 6b92be42..eb3bc9ac 100644
--- a/src/main/java/com/sqx/modules/app/service/UserService.java
+++ b/src/main/java/com/sqx/modules/app/service/UserService.java
@@ -227,4 +227,6 @@ public interface UserService extends IService {
int updateUserClientIdIsNull(String clientid);
+ void firstBindAwardsMoney(UserEntity entity);
+
}
diff --git a/src/main/java/com/sqx/modules/app/service/impl/UserPrizeExchangeServiceImpl.java b/src/main/java/com/sqx/modules/app/service/impl/UserPrizeExchangeServiceImpl.java
new file mode 100644
index 00000000..d133090d
--- /dev/null
+++ b/src/main/java/com/sqx/modules/app/service/impl/UserPrizeExchangeServiceImpl.java
@@ -0,0 +1,145 @@
+package com.sqx.modules.app.service.impl;
+
+import cn.hutool.core.lang.Validator;
+import cn.hutool.core.map.MapProxy;
+import cn.hutool.core.util.ArrayUtil;
+import cn.hutool.core.util.StrUtil;
+import com.aliyun.tea.ValidateException;
+import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
+import com.baomidou.mybatisplus.core.metadata.IPage;
+import com.baomidou.mybatisplus.core.toolkit.Wrappers;
+import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
+import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+import com.sqx.common.exception.SqxException;
+import com.sqx.common.utils.Constant;
+import com.sqx.common.utils.PageUtils;
+import com.sqx.modules.app.dao.UserDao;
+import com.sqx.modules.app.dao.UserPrizeExchangeDao;
+import com.sqx.modules.app.entity.UserEntity;
+import com.sqx.modules.app.entity.UserPrizeExchange;
+import com.sqx.modules.app.service.UserPrizeExchangeService;
+import com.sqx.modules.discSpinning.dao.DiscSpinningRecordDao;
+import com.sqx.modules.discSpinning.entity.DiscSpinningRecord;
+import lombok.extern.slf4j.Slf4j;
+import org.springframework.stereotype.Service;
+
+import javax.annotation.Resource;
+import java.util.Date;
+import java.util.Map;
+
+/**
+ * @author tankaikai
+ * @since 2024-12-20 18:10
+ */
+@Slf4j
+@Service
+public class UserPrizeExchangeServiceImpl extends ServiceImpl implements UserPrizeExchangeService {
+
+ @Resource
+ private DiscSpinningRecordDao discSpinningRecordDao;
+
+ @Resource
+ private UserDao userDao;
+
+ @Override
+ public PageUtils page(Map params) {
+ MapProxy proxy = MapProxy.create(params);
+ Long discSpinningRecordId = proxy.getLong("discSpinningRecordId");
+ Long userId = proxy.getLong("userId");
+ String userName = proxy.getStr("userName");
+ String prizeName = proxy.getStr("prizeName");
+ Integer status = proxy.getInt("status");
+ String phone = proxy.getStr("phone");
+ String remark = proxy.getStr("remark");
+ String beginDate = proxy.getStr("beginDate");
+ String endDate = proxy.getStr("endDate");
+ LambdaQueryWrapper wrapper = Wrappers.lambdaQuery();
+ wrapper.eq(discSpinningRecordId != null, UserPrizeExchange::getDiscSpinningRecordId, discSpinningRecordId);
+ wrapper.eq(userId != null, UserPrizeExchange::getUserId, userId);
+ wrapper.like(StrUtil.isNotEmpty(userName), UserPrizeExchange::getUserName, userName);
+ wrapper.like(StrUtil.isNotEmpty(prizeName), UserPrizeExchange::getPrizeName, prizeName);
+ wrapper.eq(status != null, UserPrizeExchange::getStatus, status);
+ wrapper.like(StrUtil.isNotEmpty(phone), UserPrizeExchange::getPhone, phone);
+ wrapper.like(StrUtil.isNotEmpty(remark), UserPrizeExchange::getRemark, remark);
+ if (StrUtil.isNotEmpty(beginDate)) {
+ wrapper.apply("create_time >= str_to_date({0}, '%Y-%m-%d %H:%i:%s')", beginDate + " 00:00:00");
+ }
+ if (StrUtil.isNotEmpty(endDate)) {
+ wrapper.apply("create_time <= str_to_date({0}, '%Y-%m-%d %H:%i:%s')", endDate + " 23:59:59");
+ }
+ wrapper.orderByDesc(UserPrizeExchange::getId);
+ long pageNum = proxy.getLong(Constant.PAGE, 1L);
+ long pageSize = proxy.getLong(Constant.LIMIT, 10L);
+ IPage page = this.page(new Page<>(pageNum, pageSize), wrapper);
+ return new PageUtils(page);
+ }
+
+ @Override
+ public void exchange(Long currentUserId, UserPrizeExchange dto) {
+ if (dto.getDiscSpinningRecordId() == null) {
+ throw new SqxException("中奖记录ID不能为空");
+ }
+ if (StrUtil.isBlank(dto.getPhone())) {
+ throw new SqxException("用户手机号码不能为空");
+ }
+ try {
+ Validator.isMobile(dto.getPhone());
+ } catch (ValidateException e) {
+ throw new SqxException("用户手机号码不合法");
+ }
+ DiscSpinningRecord record = discSpinningRecordDao.selectById(dto.getDiscSpinningRecordId());
+ if (record == null) {
+ throw new SqxException("中奖记录不存在");
+ }
+ if (record.getUserId() == null) {
+ throw new SqxException("中奖用户数据不完整");
+ }
+ if (currentUserId == null) {
+ throw new SqxException("未获取当前登录用户id");
+ }
+ Long userId = record.getUserId();
+ if (!currentUserId.equals(userId)) {
+ throw new SqxException("兑奖用户和获奖用户不一致");
+ }
+ UserEntity user = userDao.selectById(record.getUserId());
+ if (user == null) {
+ throw new SqxException("兑奖用户不存在");
+ }
+ if (ArrayUtil.contains(new int[]{1, 2}, record.getType())) {
+ throw new SqxException("仅限兑换实物、会员卡等奖项");
+ }
+ Integer count = baseMapper.selectCount(Wrappers.lambdaQuery()
+ .eq(UserPrizeExchange::getDiscSpinningRecordId, record.getId())
+ );
+ if (count != null && count > 0) {
+ throw new SqxException("奖品已兑换,请勿重复操作");
+ }
+ dto.setPrizeName(record.getName());
+ dto.setUserId(record.getUserId());
+ dto.setUserName(user.getUserName());
+ dto.setStatus(0);
+ dto.setCreateTime(new Date());
+ baseMapper.insert(dto);
+ }
+
+ @Override
+ public void deliver(UserPrizeExchange dto) {
+ Long id = dto.getId();
+ if (id == null) {
+ throw new SqxException("兑奖id不能为空");
+ }
+ UserPrizeExchange entity = baseMapper.selectById(id);
+ if (entity == null) {
+ throw new SqxException("兑奖订单不存在");
+ }
+ entity.setStatus(1);
+ if (StrUtil.isNotEmpty(dto.getAddress())) {
+ entity.setAddress(dto.getAddress());
+ }
+ if (StrUtil.isNotEmpty(dto.getRemark())) {
+ entity.setRemark(dto.getRemark());
+ }
+ entity.setUpdateTime(new Date());
+ baseMapper.updateById(entity);
+ }
+}
diff --git a/src/main/java/com/sqx/modules/app/service/impl/UserServiceImpl.java b/src/main/java/com/sqx/modules/app/service/impl/UserServiceImpl.java
index 9ec45453..b32ae549 100644
--- a/src/main/java/com/sqx/modules/app/service/impl/UserServiceImpl.java
+++ b/src/main/java/com/sqx/modules/app/service/impl/UserServiceImpl.java
@@ -1,6 +1,9 @@
package com.sqx.modules.app.service.impl;
+import cn.hutool.core.date.DateUtil;
+import cn.hutool.core.thread.ThreadUtil;
+import cn.hutool.json.JSONUtil;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
@@ -42,6 +45,7 @@ import com.sqx.modules.app.utils.JwtUtils;
import com.sqx.modules.app.utils.UserConstantInterface;
import com.sqx.modules.common.entity.CommonInfo;
import com.sqx.modules.common.service.CommonInfoService;
+import com.sqx.modules.discSpinning.service.DiscSpinningService;
import com.sqx.modules.file.utils.Md5Utils;
import com.sqx.modules.invite.service.InviteService;
import com.sqx.modules.message.entity.MessageInfo;
@@ -61,13 +65,17 @@ import org.apache.commons.codec.digest.DigestUtils;
import org.apache.commons.lang.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
+import org.springframework.transaction.annotation.Transactional;
import weixin.popular.api.SnsAPI;
import weixin.popular.util.JsonUtil;
import javax.servlet.http.HttpServletRequest;
import java.math.BigDecimal;
import java.text.SimpleDateFormat;
-import java.util.*;
+import java.util.Date;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
import java.util.concurrent.locks.ReentrantReadWriteLock;
/**
@@ -88,68 +96,72 @@ public class UserServiceImpl extends ServiceImpl implements
@Autowired
private JwtUtils jwtUtils;
private int number = 1;
- @Autowired
- private InviteService inviteService;
- @Autowired
+ @Autowired
+ private InviteService inviteService;
+ @Autowired
private UserMoneyService userMoneyService;
- @Autowired
+ @Autowired
private UserMoneyDetailsService userMoneyDetailsService;
- @Autowired
+ @Autowired
private UserVipService userVipService;
@Autowired
private MessageService messageService;
- private ReentrantReadWriteLock reentrantReadWriteLock=new ReentrantReadWriteLock(true);
+ @Autowired
+ private CommonInfoService commonRepository;
+ @Autowired
+ private DiscSpinningService discSpinningService;
+ private ReentrantReadWriteLock reentrantReadWriteLock = new ReentrantReadWriteLock(true);
@Override
- public Result authenticationRegister(JSONObject jsonObject, HttpServletRequest request){
+ public Result authenticationRegister(JSONObject jsonObject, HttpServletRequest request) {
reentrantReadWriteLock.writeLock().lock();
try {
String apiKey = request.getHeader("apiKey");
- if(StringUtils.isEmpty(apiKey)){
+ if (StringUtils.isEmpty(apiKey)) {
return Result.error("请求错误,请检查参数后重试!");
- }else if(StringUtils.isNotEmpty(apiKey)){
+ } else if (StringUtils.isNotEmpty(apiKey)) {
String value = commonInfoService.findOne(861).getValue();
- if(!apiKey.equals(value)){
+ if (!apiKey.equals(value)) {
return Result.error("请求错误,请检查参数后重试!");
}
}
String phone = jsonObject.getString("phone");
- if(StringUtils.isEmpty(phone)){
+ if (StringUtils.isEmpty(phone)) {
return Result.error("phone参数不能为空");
}
String money = jsonObject.getString("money");
- if(StringUtils.isEmpty(money)){
+ if (StringUtils.isEmpty(money)) {
return Result.error("money参数不能为空");
}
String idempotentId = jsonObject.getString("idempotentId");
- if(StringUtils.isEmpty(idempotentId)){
+ if (StringUtils.isEmpty(idempotentId)) {
return Result.error("idempotentId参数不能为空");
}
String sign = jsonObject.getString("sign");
- if(StringUtils.isEmpty(sign)){
+ if (StringUtils.isEmpty(sign)) {
return Result.error("sign参数不能为空");
}
String apiSecret = commonInfoService.findOne(862).getValue();
- String signs = MD5Util.md5Encrypt32Upper(phone+money+apiSecret);
- if(!signs.equals(sign)){
+ String signs = MD5Util.md5Encrypt32Upper(phone + money + apiSecret);
+ if (!signs.equals(sign)) {
return Result.error("sign参数错误!");
}
MessageInfo messageInfo = messageService.getOne(new QueryWrapper().eq("state", 10).eq("platform", idempotentId));
- if(messageInfo!=null){
+ if (messageInfo != null) {
//请求已经处理过了
- Map result=new HashMap<>();
- result.put("phone",messageInfo.getTitle());
- result.put("userType",messageInfo.getContent());
- return Result.success().put("data",result);
+ Map result = new HashMap<>();
+ result.put("phone", messageInfo.getTitle());
+ result.put("userType", messageInfo.getContent());
+ return Result.success().put("data", result);
}
- messageInfo=new MessageInfo();
+ messageInfo = new MessageInfo();
messageInfo.setState("10");
messageInfo.setPlatform(idempotentId);
messageInfo.setTitle(phone);
UserEntity userEntity = queryByPhone(phone);
- if(userEntity!=null){
+ if (userEntity != null) {
//老用户
- userMoneyService.updateMoney(1, userEntity.getUserId(),Double.parseDouble(money));
+ userMoneyService.updateMoney(1, userEntity.getUserId(), Double.parseDouble(money));
//inviteMoneyDao.updateInviteMoneySum(money,userId);
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
UserMoneyDetails userMoneyDetails = new UserMoneyDetails();
@@ -165,9 +177,9 @@ public class UserServiceImpl extends ServiceImpl implements
userMoneyDetailsService.save(userMoneyDetails);
messageInfo.setContent("2");
- }else{
+ } else {
//新用户
- userEntity=new UserEntity();
+ userEntity = new UserEntity();
userEntity.setPhone(phone);
userEntity.setUserName(userEntity.getPhone().replaceAll("(\\d{3})\\d*([0-9a-zA-Z]{4})", "$1****$2"));
userEntity.setPassword(DigestUtils.sha256Hex(userEntity.getPhone()));
@@ -179,7 +191,7 @@ public class UserServiceImpl extends ServiceImpl implements
baseMapper.updateById(userEntity);
//赠送金币
- userMoneyService.updateMoney(1, userEntity.getUserId(),Double.parseDouble(money));
+ userMoneyService.updateMoney(1, userEntity.getUserId(), Double.parseDouble(money));
//inviteMoneyDao.updateInviteMoneySum(money,userId);
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
UserMoneyDetails userMoneyDetails = new UserMoneyDetails();
@@ -195,40 +207,39 @@ public class UserServiceImpl extends ServiceImpl implements
userMoneyDetailsService.save(userMoneyDetails);
//发送短信
- sendMsg(phone,"newUser",phone);
+ sendMsg(phone, "newUser", phone);
messageInfo.setContent("1");
}
messageService.save(messageInfo);
- Map result=new HashMap<>();
- result.put("phone",messageInfo.getTitle());
- result.put("userType",messageInfo.getContent());
- return Result.success().put("data",result);
- }catch (Exception e){
+ Map result = new HashMap<>();
+ result.put("phone", messageInfo.getTitle());
+ result.put("userType", messageInfo.getContent());
+ return Result.success().put("data", result);
+ } catch (Exception e) {
e.printStackTrace();
- log.error("认证注册用户出错:"+e.getMessage(),e);
- }finally {
+ log.error("认证注册用户出错:" + e.getMessage(), e);
+ } finally {
reentrantReadWriteLock.writeLock().unlock();
}
return Result.error("系统繁忙,请稍后再试!");
}
-
@Override
- public Result getNewUserRed(Long userId){
- reentrantReadWriteLock.writeLock().lock();
- try {
+ public Result getNewUserRed(Long userId) {
+ reentrantReadWriteLock.writeLock().lock();
+ try {
UserEntity userEntity = baseMapper.selectById(userId);
- if(userEntity.getIsNewUser()!=null && userEntity.getIsNewUser()==1){
+ if (userEntity.getIsNewUser() != null && userEntity.getIsNewUser() == 1) {
return Result.error("您已经领取过了!");
}
userEntity.setIsNewUser(1);
baseMapper.updateById(userEntity);
String value = commonInfoService.findOne(837).getValue();
- if(StringUtils.isNotEmpty(value)){
+ if (StringUtils.isNotEmpty(value)) {
BigDecimal money = new BigDecimal(value);
- userMoneyService.updateMoney(1,userId,money.doubleValue());
- UserMoneyDetails userMoneyDetails=new UserMoneyDetails();
+ userMoneyService.updateMoney(1, userId, money.doubleValue());
+ UserMoneyDetails userMoneyDetails = new UserMoneyDetails();
userMoneyDetails.setUserId(userId);
userMoneyDetails.setTitle("[新用户红包]");
userMoneyDetails.setContent("增加金币:" + money);
@@ -241,13 +252,13 @@ public class UserServiceImpl extends ServiceImpl implements
userMoneyDetailsService.save(userMoneyDetails);
}
return Result.success();
- }catch (Exception e){
- e.printStackTrace();
- log.error("新用户领取红包出错:"+e.getMessage(),e);
- }finally {
- reentrantReadWriteLock.writeLock().unlock();
+ } catch (Exception e) {
+ e.printStackTrace();
+ log.error("新用户领取红包出错:" + e.getMessage(), e);
+ } finally {
+ reentrantReadWriteLock.writeLock().unlock();
}
- return Result.error("系统繁忙,请稍后再试!");
+ return Result.error("系统繁忙,请稍后再试!");
}
@@ -293,7 +304,7 @@ public class UserServiceImpl extends ServiceImpl implements
}
@Override
- public UserEntity queryByInvitationCode(String invitationCode){
+ public UserEntity queryByInvitationCode(String invitationCode) {
return baseMapper.selectOne(new QueryWrapper().eq("invitation_code", invitationCode));
}
@@ -370,13 +381,13 @@ public class UserServiceImpl extends ServiceImpl implements
map.put("unionid", "-1");
}
String value = commonInfoService.findOne(237).getValue();
- if("是".equals(value)){
+ if ("是".equals(value)) {
if (userEntity == null || StringUtils.isEmpty(userEntity.getPhone())) {
map.put("flag", "1");
} else {
map.put("flag", "2");
}
- }else{
+ } else {
map.put("flag", "2");
}
return Result.success("登陆成功").put("data", map);
@@ -417,7 +428,7 @@ public class UserServiceImpl extends ServiceImpl implements
} else {
//判断是否在app登陆过 手机号是否有账号
UserEntity userByMobile = null;
- if(StringUtils.isNotEmpty(userInfo1.getPhone())){
+ if (StringUtils.isNotEmpty(userInfo1.getPhone())) {
userByMobile = queryByPhone(userInfo1.getPhone());
}
if (userByMobile != null) {
@@ -428,11 +439,11 @@ public class UserServiceImpl extends ServiceImpl implements
return Result.error("账号已被封禁,请联系客服处理!");
}
} else {
- if(StringUtils.isEmpty(userInfo1.getInviterCode())){
+ if (StringUtils.isEmpty(userInfo1.getInviterCode())) {
userInfo1.setInviterCode(commonInfoService.findOne(88).getValue());
}
UserEntity userEntity = queryByInvitationCode(userInfo1.getInviterCode());
- if(userEntity!=null && StringUtils.isEmpty(userInfo1.getQdCode())){
+ if (userEntity != null && StringUtils.isEmpty(userInfo1.getQdCode())) {
userInfo1.setQdCode(userEntity.getQdCode());
}
//没有则生成新账号
@@ -445,8 +456,8 @@ public class UserServiceImpl extends ServiceImpl implements
baseMapper.insert(userInfo1);
userInfo1.setInvitationCode(InvitationCodeUtil.toSerialCode(userInfo1.getUserId()));
baseMapper.updateById(userInfo1);
- if(userEntity!=null){
- inviteService.saveBody(userInfo1.getUserId(),userEntity);
+ if (userEntity != null) {
+ inviteService.saveBody(userInfo1.getUserId(), userEntity);
}
// userMoneyService.selectUserMoneyByUserId(userInfo1.getUserId());
}
@@ -458,7 +469,7 @@ public class UserServiceImpl extends ServiceImpl implements
@Override
- public Result wxBindMobile(String phone, String code, String wxOpenId, String token, String platform, Integer sysPhone,String inviterCode,String qdCode) {
+ public Result wxBindMobile(String phone, String code, String wxOpenId, String token, String platform, Integer sysPhone, String inviterCode, String qdCode) {
Msg byPhoneAndCode = msgDao.findByPhoneAndCode(phone, code);
if (byPhoneAndCode == null) {
return Result.error("验证码错误");
@@ -489,11 +500,11 @@ public class UserServiceImpl extends ServiceImpl implements
//小程序没有登陆过
userInfo = new UserEntity();
userInfo.setQdCode(qdCode);
- if(StringUtils.isEmpty(inviterCode)){
- inviterCode=commonInfoService.findOne(88).getValue();
+ if (StringUtils.isEmpty(inviterCode)) {
+ inviterCode = commonInfoService.findOne(88).getValue();
}
UserEntity userEntity = queryByInvitationCode(inviterCode);
- if(userEntity!=null && StringUtils.isEmpty(userInfo.getQdCode())){
+ if (userEntity != null && StringUtils.isEmpty(userInfo.getQdCode())) {
userInfo.setQdCode(userEntity.getQdCode());
}
userInfo.setInviterCode(inviterCode);
@@ -518,8 +529,8 @@ public class UserServiceImpl extends ServiceImpl implements
userInfo.setRate(new BigDecimal(commonInfoService.findOne(420).getValue()));
userInfo.setTwoRate(new BigDecimal(commonInfoService.findOne(421).getValue()));
baseMapper.insert(userInfo);
- if(userEntity!=null){
- inviteService.saveBody(userInfo.getUserId(),userEntity);
+ if (userEntity != null) {
+ inviteService.saveBody(userInfo.getUserId(), userEntity);
}
}
UserEntity userEntity = queryByWxOpenId(userInfo.getWxOpenId());
@@ -527,7 +538,7 @@ public class UserServiceImpl extends ServiceImpl implements
}
@Override
- public Result iosBindMobile(String phone, String code, String appleId, String platform, Integer sysPhone,String inviterCode,String qdCode) {
+ public Result iosBindMobile(String phone, String code, String appleId, String platform, Integer sysPhone, String inviterCode, String qdCode) {
Msg byPhoneAndCode = msgDao.findByPhoneAndCode(phone, code);
if (byPhoneAndCode == null) {
return Result.error("验证码错误");
@@ -546,11 +557,11 @@ public class UserServiceImpl extends ServiceImpl implements
} else {
userInfo = new UserEntity();
userInfo.setQdCode(qdCode);
- if(StringUtils.isEmpty(inviterCode)){
- inviterCode=commonInfoService.findOne(88).getValue();
+ if (StringUtils.isEmpty(inviterCode)) {
+ inviterCode = commonInfoService.findOne(88).getValue();
}
UserEntity userEntity = queryByInvitationCode(inviterCode);
- if(userEntity!=null && StringUtils.isEmpty(userInfo.getQdCode())){
+ if (userEntity != null && StringUtils.isEmpty(userInfo.getQdCode())) {
userInfo.setQdCode(userEntity.getQdCode());
}
userInfo.setAppleId(appleId);
@@ -566,8 +577,8 @@ public class UserServiceImpl extends ServiceImpl implements
userInfo.setRate(new BigDecimal(commonInfoService.findOne(420).getValue()));
userInfo.setTwoRate(new BigDecimal(commonInfoService.findOne(421).getValue()));
baseMapper.insert(userInfo);
- if(userEntity!=null){
- inviteService.saveBody(userInfo.getUserId(),userEntity);
+ if (userEntity != null) {
+ inviteService.saveBody(userInfo.getUserId(), userEntity);
}
}
UserEntity userEntity = queryByAppleId(userInfo.getAppleId());
@@ -576,31 +587,31 @@ public class UserServiceImpl extends ServiceImpl implements
@Override
- public Result phoneLogin(String phone){
+ public Result phoneLogin(String phone) {
UserEntity userInfo = queryByPhone(phone);
- if(userInfo!=null){
- if(userInfo.getStatus().equals(2)){
- return Result.error(500,"账号已被禁用,请联系客服处理!");
+ if (userInfo != null) {
+ if (userInfo.getStatus().equals(2)) {
+ return Result.error(500, "账号已被禁用,请联系客服处理!");
}
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
userInfo.setUpdateTime(sdf.format(new Date()));
baseMapper.updateById(userInfo);
return getResult(userInfo);
- }else{
- return Result.error(201,"请绑定密码!");
+ } else {
+ return Result.error(201, "请绑定密码!");
}
}
@Override
- public Result bindMobile(String phone,String platform, Integer sysPhone,String inviterCode,String qdCode) {
+ public Result bindMobile(String phone, String platform, Integer sysPhone, String inviterCode, String qdCode) {
UserEntity userInfo = new UserEntity();
userInfo.setQdCode(qdCode);
- if(StringUtils.isEmpty(inviterCode)){
- inviterCode=commonInfoService.findOne(88).getValue();
+ if (StringUtils.isEmpty(inviterCode)) {
+ inviterCode = commonInfoService.findOne(88).getValue();
}
UserEntity userEntity = queryByInvitationCode(inviterCode);
- if(userEntity!=null && StringUtils.isEmpty(userInfo.getQdCode())){
+ if (userEntity != null && StringUtils.isEmpty(userInfo.getQdCode())) {
userInfo.setQdCode(userEntity.getQdCode());
}
userInfo.setInviterCode(inviterCode);
@@ -615,15 +626,13 @@ public class UserServiceImpl extends ServiceImpl implements
userInfo.setRate(new BigDecimal(commonInfoService.findOne(420).getValue()));
userInfo.setTwoRate(new BigDecimal(commonInfoService.findOne(421).getValue()));
baseMapper.insert(userInfo);
- if(userEntity!=null){
- inviteService.saveBody(userInfo.getUserId(),userEntity);
+ if (userEntity != null) {
+ inviteService.saveBody(userInfo.getUserId(), userEntity);
}
return getResult(userInfo);
}
-
-
@Override
public Result wxAppLogin(String wxOpenId, String token) {
UserEntity userEntity = queryByWxOpenId(wxOpenId);
@@ -652,7 +661,7 @@ public class UserServiceImpl extends ServiceImpl implements
}
@Override
- public Result dyLogin(String code,String anonymous_code) {
+ public Result dyLogin(String code, String anonymous_code) {
String appid = commonInfoService.findOne(805).getValue();
String secret = commonInfoService.findOne(806).getValue();
// 配置请求参数
@@ -666,26 +675,26 @@ public class UserServiceImpl extends ServiceImpl implements
log.info(wxResult);
JSONObject jsonObject = JSONObject.parseObject(wxResult);
String err_no = jsonObject.getString("err_no");
- if(!"0".equals(err_no)){
+ if (!"0".equals(err_no)) {
return Result.error(jsonObject.getString("err_tips"));
}
JSONObject data = jsonObject.getJSONObject("data");
String openid = data.getString("openid");
- if(StringUtils.isEmpty(openid)) {
+ if (StringUtils.isEmpty(openid)) {
openid = data.getString("anonymous_openid");
}
UserEntity userEntity = queryByDyOpenId(openid);
- Map resultMap=new HashMap<>();
- resultMap.put("dyOpenId",openid);
+ Map resultMap = new HashMap<>();
+ resultMap.put("dyOpenId", openid);
String value = commonInfoService.findOne(814).getValue();
- if("是".equals(value)){
+ if ("是".equals(value)) {
if (userEntity == null || StringUtils.isEmpty(userEntity.getPhone())) {
resultMap.put("flag", "1");
} else {
resultMap.put("flag", "2");
}
- }else{
+ } else {
resultMap.put("flag", "2");
}
return Result.success("登陆成功").put("data", resultMap);
@@ -709,7 +718,7 @@ public class UserServiceImpl extends ServiceImpl implements
} else {
//判断是否在app登陆过 手机号是否有账号
UserEntity userByMobile = null;
- if(StringUtils.isNotEmpty(userInfo1.getPhone())){
+ if (StringUtils.isNotEmpty(userInfo1.getPhone())) {
userByMobile = queryByPhone(userInfo1.getPhone());
}
if (userByMobile != null) {
@@ -720,7 +729,7 @@ public class UserServiceImpl extends ServiceImpl implements
return Result.error("账号已被封禁,请联系客服处理!");
}
} else {
- if(StringUtils.isEmpty(userInfo1.getInviterCode())){
+ if (StringUtils.isEmpty(userInfo1.getInviterCode())) {
userInfo1.setInviterCode(commonInfoService.findOne(88).getValue());
}
UserEntity userEntity = queryByInvitationCode(userInfo1.getInviterCode());
@@ -728,7 +737,7 @@ public class UserServiceImpl extends ServiceImpl implements
userInfo1.setCreateTime(date);
userInfo1.setPlatform("抖音");
userInfo1.setStatus(1);
- if(StringUtils.isNotEmpty(userInfo1.getPhone())){
+ if (StringUtils.isNotEmpty(userInfo1.getPhone())) {
userInfo1.setPassword(DigestUtils.sha256Hex(userInfo1.getPhone()));
}
userInfo1.setRate(new BigDecimal(commonInfoService.findOne(420).getValue()));
@@ -736,8 +745,8 @@ public class UserServiceImpl extends ServiceImpl implements
baseMapper.insert(userInfo1);
userInfo1.setInvitationCode(InvitationCodeUtil.toSerialCode(userInfo1.getUserId()));
baseMapper.updateById(userInfo1);
- if(userEntity!=null){
- inviteService.saveBody(userInfo1.getUserId(),userEntity);
+ if (userEntity != null) {
+ inviteService.saveBody(userInfo1.getUserId(), userEntity);
}
// userMoneyService.selectUserMoneyByUserId(userInfo1.getUserId());
}
@@ -753,7 +762,7 @@ public class UserServiceImpl extends ServiceImpl implements
String appid = commonInfoService.findOne(828).getValue();
String secret = commonInfoService.findOne(829).getValue();
// 配置请求参数
- HashMap param = new HashMap<>();
+ HashMap param = new HashMap<>();
param.put("app_id", appid);
param.put("app_secret", secret);
param.put("js_code", code);
@@ -762,7 +771,7 @@ public class UserServiceImpl extends ServiceImpl implements
log.info(ksResult);
JSONObject jsonObject = JSONObject.parseObject(ksResult);
String result = jsonObject.getString("result");
- if(!"1".equals(result)){
+ if (!"1".equals(result)) {
return Result.error("登录失败!");
}
@@ -770,17 +779,17 @@ public class UserServiceImpl extends ServiceImpl implements
String openid = jsonObject.getString("open_id");
UserEntity userEntity = queryByDyOpenId(openid);
- Map resultMap=new HashMap<>();
- resultMap.put("ksOpenId",openid);
- resultMap.put("session_key",session_key);
+ Map resultMap = new HashMap<>();
+ resultMap.put("ksOpenId", openid);
+ resultMap.put("session_key", session_key);
String value = commonInfoService.findOne(830).getValue();
- if("是".equals(value)){
+ if ("是".equals(value)) {
if (userEntity == null || StringUtils.isEmpty(userEntity.getPhone())) {
resultMap.put("flag", "1");
} else {
resultMap.put("flag", "2");
}
- }else{
+ } else {
resultMap.put("flag", "2");
}
return Result.success("登陆成功").put("data", resultMap);
@@ -804,7 +813,7 @@ public class UserServiceImpl extends ServiceImpl implements
} else {
//判断是否在app登陆过 手机号是否有账号
UserEntity userByMobile = null;
- if(StringUtils.isNotEmpty(userInfo1.getPhone())){
+ if (StringUtils.isNotEmpty(userInfo1.getPhone())) {
userByMobile = queryByPhone(userInfo1.getPhone());
}
if (userByMobile != null) {
@@ -815,7 +824,7 @@ public class UserServiceImpl extends ServiceImpl implements
return Result.error("账号已被封禁,请联系客服处理!");
}
} else {
- if(StringUtils.isEmpty(userInfo1.getInviterCode())){
+ if (StringUtils.isEmpty(userInfo1.getInviterCode())) {
userInfo1.setInviterCode(commonInfoService.findOne(88).getValue());
}
UserEntity userEntity = queryByInvitationCode(userInfo1.getInviterCode());
@@ -823,7 +832,7 @@ public class UserServiceImpl extends ServiceImpl implements
userInfo1.setCreateTime(date);
userInfo1.setPlatform("快手");
userInfo1.setStatus(1);
- if(StringUtils.isNotEmpty(userInfo1.getPhone())){
+ if (StringUtils.isNotEmpty(userInfo1.getPhone())) {
userInfo1.setPassword(DigestUtils.sha256Hex(userInfo1.getPhone()));
}
userInfo1.setRate(new BigDecimal(commonInfoService.findOne(420).getValue()));
@@ -831,8 +840,8 @@ public class UserServiceImpl extends ServiceImpl implements
baseMapper.insert(userInfo1);
userInfo1.setInvitationCode(InvitationCodeUtil.toSerialCode(userInfo1.getUserId()));
baseMapper.updateById(userInfo1);
- if(userEntity!=null){
- inviteService.saveBody(userInfo1.getUserId(),userEntity);
+ if (userEntity != null) {
+ inviteService.saveBody(userInfo1.getUserId(), userEntity);
}
// userMoneyService.selectUserMoneyByUserId(userInfo1.getUserId());
}
@@ -843,37 +852,37 @@ public class UserServiceImpl extends ServiceImpl implements
}
@Override
- public Result registerCode(String phone, String msg, String platform, Integer sysPhone,String password,
- String inviterCode,String wxId,String qdCode) {
+ public Result registerCode(String phone, String msg, String platform, Integer sysPhone, String password,
+ String inviterCode, String wxId, String qdCode) {
//校验手机号是否存在
UserEntity userInfo = queryByPhone(phone);
if (userInfo != null) {
- if(StringUtils.isNotEmpty(password)){
+ if (StringUtils.isNotEmpty(password)) {
//密码登录
- if(StringUtils.isEmpty(userInfo.getPassword())){
+ if (StringUtils.isEmpty(userInfo.getPassword())) {
return Result.error("当前账号未绑定密码,请前往忘记密码中进行重置!");
}
- if(!userInfo.getPassword().equals(DigestUtils.sha256Hex(password))){
+ if (!userInfo.getPassword().equals(DigestUtils.sha256Hex(password))) {
return Result.error("账号或密码不正确!");
}
- }else if(StringUtils.isNotEmpty(msg)){
+ } else if (StringUtils.isNotEmpty(msg)) {
//验证码登录
Msg msg1 = msgDao.findByPhoneAndCode(phone, msg);
- if(msg1==null){
+ if (msg1 == null) {
return Result.error("验证码不正确!");
}
msgDao.deleteById(msg1.getId());
- }else{
+ } else {
return Result.error("登录失败,请刷新页面重试!");
}
if (userInfo.getStatus().equals(2)) {
return Result.error("账号已被禁用,请联系客服处理!");
}
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
- if(StringUtils.isNotEmpty(wxId) && StringUtils.isNotEmpty(userInfo.getWxId()) && !wxId.equals(userInfo.getWxId())){
+ if (StringUtils.isNotEmpty(wxId) && StringUtils.isNotEmpty(userInfo.getWxId()) && !wxId.equals(userInfo.getWxId())) {
return Result.error("当前手机号已经绑定过了,请更换其他手机号!");
}
- if(StringUtils.isNotEmpty(wxId)){
+ if (StringUtils.isNotEmpty(wxId)) {
userInfo.setWxId(wxId);
}
userInfo.setUpdateTime(sdf.format(new Date()));
@@ -884,7 +893,7 @@ public class UserServiceImpl extends ServiceImpl implements
if (StringUtils.isEmpty(platform)) {
return Result.error("手机号未注册!");
}
- if(StringUtils.isEmpty(msg)){
+ if (StringUtils.isEmpty(msg)) {
return Result.error("验证码不能为空!");
}
Msg msg1 = null;
@@ -895,22 +904,22 @@ public class UserServiceImpl extends ServiceImpl implements
}
}
userInfo = new UserEntity();
- UserEntity userEntity=null;
- if(StringUtils.isNotEmpty(inviterCode)){
+ UserEntity userEntity = null;
+ if (StringUtils.isNotEmpty(inviterCode)) {
userEntity = queryByInvitationCode(inviterCode);
- if(userEntity==null){
+ if (userEntity == null) {
return Result.error("邀请码不正确!");
}
- }else{
+ } else {
userInfo.setInviterCode(commonInfoService.findOne(88).getValue());
userEntity = queryByInvitationCode(userInfo.getInviterCode());
}
SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
String time = simpleDateFormat.format(new Date());
- if(StringUtils.isNotEmpty(wxId)){
+ if (StringUtils.isNotEmpty(wxId)) {
userInfo.setWxId(wxId);
}
- if(StringUtils.isEmpty(qdCode)){
+ if (StringUtils.isEmpty(qdCode)) {
qdCode = userEntity.getQdCode();
}
userInfo.setQdCode(qdCode);
@@ -919,9 +928,9 @@ public class UserServiceImpl extends ServiceImpl implements
userInfo.setPlatform(platform);
userInfo.setCreateTime(time);
userInfo.setSysPhone(sysPhone);
- if(StringUtils.isNotBlank(password)){
+ if (StringUtils.isNotBlank(password)) {
userInfo.setPassword(DigestUtils.sha256Hex(password));
- }else{
+ } else {
userInfo.setPassword(DigestUtils.sha256Hex(phone));
}
userInfo.setStatus(1);
@@ -935,8 +944,8 @@ public class UserServiceImpl extends ServiceImpl implements
if (msg1 != null) {
msgDao.deleteById(msg1.getId());
}
- if(userEntity!=null){
- inviteService.saveBody(userInfo.getUserId(),userEntity);
+ if (userEntity != null) {
+ inviteService.saveBody(userInfo.getUserId(), userEntity);
}
return getResult(userInfo);
}
@@ -980,8 +989,6 @@ public class UserServiceImpl extends ServiceImpl implements
}
-
-
@Override
public Result login(String phone, String pwd) {
UserEntity userEntity = queryByPhone(phone);
@@ -1014,7 +1021,7 @@ public class UserServiceImpl extends ServiceImpl implements
@Override
- public Result sendMsg(String phone, String state,String pwd) {
+ public Result sendMsg(String phone, String state, String pwd) {
int code = (int) ((Math.random() * 9 + 1) * 100000);
System.out.println("sendMsg code is " + code);
SmsSingleSenderResult result = null;
@@ -1028,14 +1035,14 @@ public class UserServiceImpl extends ServiceImpl implements
if (userByPhone != null && StringUtils.isNotEmpty(userByPhone.getAppleId())) {
return Result.error("当前手机号已被其他苹果账号绑定");
}
- }else if("login".equals(state)){
+ } else if ("login".equals(state)) {
UserEntity userByPhone = queryByPhone(phone);
- if(userByPhone!=null){
+ if (userByPhone != null) {
return Result.error("当前手机号已注册!");
}
- }else if("forget".equals(state)){
+ } else if ("forget".equals(state)) {
UserEntity userByPhone = queryByPhone(phone);
- if(userByPhone==null){
+ if (userByPhone == null) {
return Result.error("手机号未注册!");
}
}
@@ -1044,16 +1051,16 @@ public class UserServiceImpl extends ServiceImpl implements
if (three == null || "1".equals(three.getValue())) {
//腾讯云短信发送
return sendMsgTencent(phone, state, code);
- } else if("2".equals(three.getValue())){
+ } else if ("2".equals(three.getValue())) {
//阿里云短信发送
- return sendMsgAlibaba(phone, state,code);
- }else{
- return sendMsgDXB(phone,state,code,pwd);
+ return sendMsgAlibaba(phone, state, code);
+ } else {
+ return sendMsgDXB(phone, state, code, pwd);
}
}
- private Result sendMsgAlibaba(String phone,String state, int code) {
+ private Result sendMsgAlibaba(String phone, String state, int code) {
CommonInfo three = commonInfoService.findOne(85);
String accessKeyId = three.getValue();
@@ -1073,19 +1080,19 @@ public class UserServiceImpl extends ServiceImpl implements
String value;
switch (state) {
case "login":
- value=commonInfoService.findOne(82).getValue();
+ value = commonInfoService.findOne(82).getValue();
break;
case "forget":
- value=commonInfoService.findOne(83).getValue();
+ value = commonInfoService.findOne(83).getValue();
break;
case "bindWx":
- value=commonInfoService.findOne(84).getValue();
+ value = commonInfoService.findOne(84).getValue();
break;
case "bindIos":
- value=commonInfoService.findOne(84).getValue();
+ value = commonInfoService.findOne(84).getValue();
break;
default:
- value=commonInfoService.findOne(82).getValue();
+ value = commonInfoService.findOne(82).getValue();
break;
}
request.putQueryParameter("TemplateCode", value);
@@ -1210,13 +1217,13 @@ public class UserServiceImpl extends ServiceImpl implements
}
- private Result sendMsgDXB(String phone, String state, int code,String pwd) {
+ private Result sendMsgDXB(String phone, String state, int code, String pwd) {
CommonInfo three = commonInfoService.findOne(238);
CommonInfo four = commonInfoService.findOne(239);
CommonInfo name = commonInfoService.findOne(81);
String testUsername = three.getValue(); //在短信宝注册的用户名
String testPassword = four.getValue(); //在短信宝注册的密码
- String value="";
+ String value = "";
switch (state) {
case "register":
value = "【" + name.getValue() + "】验证码: " + code + ",此验证码可用于登录或注册,10分钟内有效,如非您本人操作,可忽略本条消息";
@@ -1228,7 +1235,7 @@ public class UserServiceImpl extends ServiceImpl implements
value = "【" + name.getValue() + "】验证码: " + code + ",您正在执行绑定手机号操作,10分钟内有效,如非您本人操作,可忽略本条消息";
break;
case "newUser":
- value = "【" + name.getValue() + "】新用户账号注册成功,账号:"+phone+",密码:"+pwd+",请及时登录并修改密码!";
+ value = "【" + name.getValue() + "】新用户账号注册成功,账号:" + phone + ",密码:" + pwd + ",请及时登录并修改密码!";
break;
default:
value = "【" + name.getValue() + "】验证码: " + code + ",此验证码可用于登录或注册,10分钟内有效,如非您本人操作,可忽略本条消息";
@@ -1240,7 +1247,7 @@ public class UserServiceImpl extends ServiceImpl implements
httpArg.append("m=").append(phone).append("&");
httpArg.append("c=").append(Md5Utils.encodeUrlString(value, "UTF-8"));
String result = Md5Utils.request("https://api.smsbao.com/sms", httpArg.toString());
- log.error("短信包返回值:"+result);
+ log.error("短信包返回值:" + result);
if ("0".equals(result)) {
Msg byPhone = msgDao.findByPhone(phone);
if (byPhone != null) {
@@ -1261,18 +1268,18 @@ public class UserServiceImpl extends ServiceImpl implements
}
} else {
// return ResultUtil.error(6, result.errMsg);
- if("30".equals(result)){
- return Result.error( "错误密码");
- }else if("40".equals(result)){
- return Result.error( "账号不存在");
- }else if("41".equals(result)){
- return Result.error( "余额不足");
- }else if("43".equals(result)){
- return Result.error( "IP地址限制");
- }else if("50".equals(result)){
- return Result.error( "内容含有敏感词");
- }else if("51".equals(result)){
- return Result.error( "手机号码不正确");
+ if ("30".equals(result)) {
+ return Result.error("错误密码");
+ } else if ("40".equals(result)) {
+ return Result.error("账号不存在");
+ } else if ("41".equals(result)) {
+ return Result.error("余额不足");
+ } else if ("43".equals(result)) {
+ return Result.error("IP地址限制");
+ } else if ("50".equals(result)) {
+ return Result.error("内容含有敏感词");
+ } else if ("51".equals(result)) {
+ return Result.error("手机号码不正确");
}
}
@@ -1305,9 +1312,9 @@ public class UserServiceImpl extends ServiceImpl implements
@Override
public UserEntity selectUserById(Long userId) {
UserEntity userEntity = baseMapper.selectById(userId);
- if(userEntity!=null){
+ if (userEntity != null) {
UserVip userVip = userVipService.selectUserVipByUserId(userId);
- if(userVip!=null){
+ if (userVip != null) {
userEntity.setMember(userVip.getIsVip());
userEntity.setEndTime(userVip.getEndTime());
}
@@ -1319,10 +1326,10 @@ public class UserServiceImpl extends ServiceImpl implements
@Override
public PageUtils selectUserPage(Integer page, Integer limit, String search, 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) {
+ String invitationCode, String startTime, String endTime, String qdCode, String sysUserName, Integer vipType) {
Page pages = new Page<>(page, limit);
return new PageUtils(baseMapper.selectUserPage(pages, search, sex, platform, sysPhone, status, member,
- inviterCode, userName, invitationCode, startTime, endTime,qdCode,sysUserName,vipType));
+ inviterCode, userName, invitationCode, startTime, endTime, qdCode, sysUserName, vipType));
}
@Override
@@ -1337,29 +1344,29 @@ public class UserServiceImpl extends ServiceImpl implements
}
@Override
- public int queryUserCount(int type,String date,String platform,String qdCode) {
+ public int queryUserCount(int type, String date, String platform, String qdCode) {
SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd HH:ss:mm");
- if(date==null||date==""){
+ if (date == null || date == "") {
date = simpleDateFormat.format(new Date());
}
- return baseMapper.queryUserCount(type, date,platform,qdCode);
+ return baseMapper.queryUserCount(type, date, platform, qdCode);
}
@Override
- public Double queryPayMoney(int type,String qdCode) {
+ public Double queryPayMoney(int type, String qdCode) {
SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd HH:ss:mm");
String date = simpleDateFormat.format(new Date());
- return baseMapper.queryPayMoney(type, date,qdCode);
+ return baseMapper.queryPayMoney(type, date, qdCode);
}
@Override
- public IPage