Merge branch 'test' into dev
This commit is contained in:
commit
32fe771c31
6
pom.xml
6
pom.xml
|
|
@ -72,6 +72,12 @@
|
|||
<groupId>cn.afterturn</groupId>
|
||||
<artifactId>easypoi-spring-boot-starter</artifactId>
|
||||
<version>4.0.0</version>
|
||||
<exclusions>
|
||||
<exclusion>
|
||||
<artifactId>javassist</artifactId>
|
||||
<groupId>org.javassist</groupId>
|
||||
</exclusion>
|
||||
</exclusions>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.github.qcloudsms</groupId>
|
||||
|
|
|
|||
|
|
@ -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());
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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<String, Object> setOperations;
|
||||
@Autowired
|
||||
private ZSetOperations<String, Object> 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 <T> List<T> getListData(String key, Class<T> clazz,String method) {
|
||||
|
||||
public <T> Map<String, List<T>> getMapData(String key, String method, Class<T> 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 <T> List<T> getListData(String key, Class<T> 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> T getObjectDate(String key, Class<T> clazz,String method) {
|
||||
public <T> T getObjectDate(String key, Class<T> 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> T get(String key, Class<T> 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> T fromJson(String json, Class<T> clazz){
|
||||
private <T> T fromJson(String json, Class<T> clazz) {
|
||||
return Gson.fromJson(json, clazz);
|
||||
}
|
||||
|
||||
|
||||
public <T> Map<String, List<T>> jsonNodeToMap(JsonNode jsonNode, Class<T> clazz) {
|
||||
Map<String, List<T>> resultMap = new HashMap<>();
|
||||
ObjectMapper objectMapper = new ObjectMapper();
|
||||
|
||||
if (jsonNode.isObject()) {
|
||||
// 获取字段名(也就是键)的迭代器
|
||||
Iterator<String> 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;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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");
|
||||
|
|
|
|||
|
|
@ -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<String, Object> 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();
|
||||
}
|
||||
}
|
||||
|
|
@ -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<UserEntity>()
|
||||
.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();
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
|
@ -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<UserPrizeExchange> {
|
||||
}
|
||||
|
|
@ -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;
|
||||
}
|
||||
|
|
@ -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<UserPrizeExchange> {
|
||||
/**
|
||||
* 分页查询
|
||||
*
|
||||
* @param params
|
||||
* @return
|
||||
*/
|
||||
PageUtils page(Map<String, Object> params);
|
||||
|
||||
/**
|
||||
* 兑换奖品
|
||||
*
|
||||
* @param entity
|
||||
*/
|
||||
void exchange(Long currentUserId, UserPrizeExchange entity);
|
||||
|
||||
/**
|
||||
* 发放奖品
|
||||
*
|
||||
* @param dto
|
||||
*/
|
||||
|
||||
void deliver(UserPrizeExchange dto);
|
||||
}
|
||||
|
|
@ -227,4 +227,6 @@ public interface UserService extends IService<UserEntity> {
|
|||
|
||||
int updateUserClientIdIsNull(String clientid);
|
||||
|
||||
void firstBindAwardsMoney(UserEntity entity);
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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<UserPrizeExchangeDao, UserPrizeExchange> implements UserPrizeExchangeService {
|
||||
|
||||
@Resource
|
||||
private DiscSpinningRecordDao discSpinningRecordDao;
|
||||
|
||||
@Resource
|
||||
private UserDao userDao;
|
||||
|
||||
@Override
|
||||
public PageUtils page(Map<String, Object> 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<UserPrizeExchange> 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<UserPrizeExchange> 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.<UserPrizeExchange>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);
|
||||
}
|
||||
}
|
||||
|
|
@ -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<UserDao, UserEntity> 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<MessageInfo>().eq("state", 10).eq("platform", idempotentId));
|
||||
if(messageInfo!=null){
|
||||
if (messageInfo != null) {
|
||||
//请求已经处理过了
|
||||
Map<String,String> result=new HashMap<>();
|
||||
result.put("phone",messageInfo.getTitle());
|
||||
result.put("userType",messageInfo.getContent());
|
||||
return Result.success().put("data",result);
|
||||
Map<String, String> 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<UserDao, UserEntity> 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<UserDao, UserEntity> 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<UserDao, UserEntity> implements
|
|||
userMoneyDetailsService.save(userMoneyDetails);
|
||||
|
||||
//发送短信
|
||||
sendMsg(phone,"newUser",phone);
|
||||
sendMsg(phone, "newUser", phone);
|
||||
messageInfo.setContent("1");
|
||||
}
|
||||
messageService.save(messageInfo);
|
||||
Map<String,String> result=new HashMap<>();
|
||||
result.put("phone",messageInfo.getTitle());
|
||||
result.put("userType",messageInfo.getContent());
|
||||
return Result.success().put("data",result);
|
||||
}catch (Exception e){
|
||||
Map<String, String> 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<UserDao, UserEntity> 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<UserDao, UserEntity> implements
|
|||
}
|
||||
|
||||
@Override
|
||||
public UserEntity queryByInvitationCode(String invitationCode){
|
||||
public UserEntity queryByInvitationCode(String invitationCode) {
|
||||
return baseMapper.selectOne(new QueryWrapper<UserEntity>().eq("invitation_code", invitationCode));
|
||||
}
|
||||
|
||||
|
|
@ -370,13 +381,13 @@ public class UserServiceImpl extends ServiceImpl<UserDao, UserEntity> 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<UserDao, UserEntity> 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<UserDao, UserEntity> 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<UserDao, UserEntity> 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<UserDao, UserEntity> 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<UserDao, UserEntity> 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<UserDao, UserEntity> 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<UserDao, UserEntity> 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<UserDao, UserEntity> 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<UserDao, UserEntity> 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<UserDao, UserEntity> 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<UserDao, UserEntity> 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<UserDao, UserEntity> 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<UserDao, UserEntity> 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<String,String> resultMap=new HashMap<>();
|
||||
resultMap.put("dyOpenId",openid);
|
||||
Map<String, String> 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<UserDao, UserEntity> 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<UserDao, UserEntity> 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<UserDao, UserEntity> 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<UserDao, UserEntity> 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<UserDao, UserEntity> implements
|
|||
String appid = commonInfoService.findOne(828).getValue();
|
||||
String secret = commonInfoService.findOne(829).getValue();
|
||||
// 配置请求参数
|
||||
HashMap<String,String> param = new HashMap<>();
|
||||
HashMap<String, String> 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<UserDao, UserEntity> 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<UserDao, UserEntity> implements
|
|||
String openid = jsonObject.getString("open_id");
|
||||
|
||||
UserEntity userEntity = queryByDyOpenId(openid);
|
||||
Map<String,String> resultMap=new HashMap<>();
|
||||
resultMap.put("ksOpenId",openid);
|
||||
resultMap.put("session_key",session_key);
|
||||
Map<String, String> 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<UserDao, UserEntity> 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<UserDao, UserEntity> 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<UserDao, UserEntity> 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<UserDao, UserEntity> 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<UserDao, UserEntity> 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<UserDao, UserEntity> 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<UserDao, UserEntity> 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<UserDao, UserEntity> 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<UserDao, UserEntity> 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<UserDao, UserEntity> implements
|
|||
}
|
||||
|
||||
|
||||
|
||||
|
||||
@Override
|
||||
public Result login(String phone, String pwd) {
|
||||
UserEntity userEntity = queryByPhone(phone);
|
||||
|
|
@ -1014,7 +1021,7 @@ public class UserServiceImpl extends ServiceImpl<UserDao, UserEntity> 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<UserDao, UserEntity> 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<UserDao, UserEntity> 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<UserDao, UserEntity> 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<UserDao, UserEntity> 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<UserDao, UserEntity> 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<UserDao, UserEntity> 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<UserDao, UserEntity> 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<UserDao, UserEntity> 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<UserDao, UserEntity> 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<UserEntity> 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<UserDao, UserEntity> 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<Map<String, Object>> queryCourseOrder(Page<Map<String, Object>> iPage,int type, String date,Long sysUserId) {
|
||||
return baseMapper.queryCourseOrder(iPage,type, date,sysUserId);
|
||||
public IPage<Map<String, Object>> queryCourseOrder(Page<Map<String, Object>> iPage, int type, String date, Long sysUserId) {
|
||||
return baseMapper.queryCourseOrder(iPage, type, date, sysUserId);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int userMessage( String date, int type,String qdCode,Integer vipType) {
|
||||
return baseMapper.userMessage(date, type,qdCode,vipType);
|
||||
public int userMessage(String date, int type, String qdCode, Integer vipType) {
|
||||
return baseMapper.userMessage(date, type, qdCode, vipType);
|
||||
}
|
||||
|
||||
|
||||
|
|
@ -1434,8 +1441,8 @@ public class UserServiceImpl extends ServiceImpl<UserDao, UserEntity> implements
|
|||
}
|
||||
|
||||
@Override
|
||||
public Result selectInviteUserList(Integer page,Integer limit,String userName,String phone){
|
||||
return Result.success().put("data",baseMapper.selectInviteUserList(new Page<>(page,limit),userName,phone));
|
||||
public Result selectInviteUserList(Integer page, Integer limit, String userName, String phone) {
|
||||
return Result.success().put("data", baseMapper.selectInviteUserList(new Page<>(page, limit), userName, phone));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
@ -1453,13 +1460,47 @@ public class UserServiceImpl extends ServiceImpl<UserDao, UserEntity> implements
|
|||
}
|
||||
|
||||
@Override
|
||||
public Result selectUserOnLineCount(String qdCode){
|
||||
return Result.success().put("data",baseMapper.selectUserOnLineCount(qdCode));
|
||||
public Result selectUserOnLineCount(String qdCode) {
|
||||
return Result.success().put("data", baseMapper.selectUserOnLineCount(qdCode));
|
||||
}
|
||||
|
||||
@Override
|
||||
public int updateUserClientIdIsNull(String clientid){
|
||||
public int updateUserClientIdIsNull(String clientid) {
|
||||
return baseMapper.updateUserClientIdIsNull(clientid);
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public void firstBindAwardsMoney(UserEntity entity) {
|
||||
reentrantReadWriteLock.writeLock().lock();
|
||||
try {
|
||||
CommonInfo one = commonRepository.findOne(920);
|
||||
BigDecimal money = new BigDecimal(one.getValue());
|
||||
userMoneyService.updateAmount(1, entity.getUserId(), money.doubleValue());
|
||||
UserMoneyDetails userMoneyDetails = new UserMoneyDetails();
|
||||
userMoneyDetails.setUserId(entity.getUserId());
|
||||
userMoneyDetails.setTitle("[首绑支付宝]");
|
||||
userMoneyDetails.setContent("现金红包奖励:" + money + "元");
|
||||
// 充值
|
||||
userMoneyDetails.setType(1);
|
||||
// 任务领取
|
||||
userMoneyDetails.setClassify(7);
|
||||
userMoneyDetails.setMoney(money);
|
||||
userMoneyDetails.setCreateTime(DateUtil.format(new Date(System.currentTimeMillis() - 1000), "yyyy-MM-dd HH:mm:ss"));
|
||||
userMoneyDetails.setMoneyType(1);
|
||||
boolean ret = userMoneyDetailsService.save(userMoneyDetails);
|
||||
if (ret) {
|
||||
ThreadUtil.execAsync(()->{
|
||||
discSpinningService.withdrawAsync(entity, money.doubleValue(), "[首绑支付宝]");
|
||||
},true);
|
||||
}
|
||||
} catch (Exception e) {
|
||||
log.error("首绑支付宝发放奖励异常,用户信息:{}", JSONUtil.toJsonStr(entity));
|
||||
log.error("首绑支付宝发放奖励异常:", e);
|
||||
throw new RuntimeException("首绑奖励失败");
|
||||
} finally {
|
||||
reentrantReadWriteLock.writeLock().unlock();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,6 +1,8 @@
|
|||
package com.sqx.modules.course.service.impl;
|
||||
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.baomidou.mybatisplus.core.toolkit.CollectionUtils;
|
||||
|
|
@ -12,6 +14,8 @@ import com.sqx.common.utils.Result;
|
|||
import com.sqx.modules.app.entity.UserEntity;
|
||||
import com.sqx.modules.app.service.UserService;
|
||||
import com.sqx.modules.app.utils.JwtUtils;
|
||||
import com.sqx.modules.common.dao.CommonInfoDao;
|
||||
import com.sqx.modules.common.entity.CommonInfo;
|
||||
import com.sqx.modules.course.dao.CourseCollectDao;
|
||||
import com.sqx.modules.course.dao.CourseDao;
|
||||
import com.sqx.modules.course.dao.CourseDetailsDao;
|
||||
|
|
@ -22,11 +26,15 @@ import com.sqx.modules.course.entity.CourseDetails;
|
|||
import com.sqx.modules.course.entity.CourseUser;
|
||||
import com.sqx.modules.course.service.CourseDetailsService;
|
||||
import com.sqx.modules.course.vo.CourseDetailsIn;
|
||||
import com.sqx.modules.orders.dao.OrdersDao;
|
||||
import com.sqx.modules.orders.entity.Orders;
|
||||
import com.sqx.modules.orders.service.OrdersService;
|
||||
import com.sqx.modules.redisService.impl.RedisServiceImpl;
|
||||
import com.sqx.modules.utils.EasyPoi.ExcelUtils;
|
||||
import com.sqx.modules.utils.HttpClientUtil;
|
||||
import com.sqx.modules.utils.SenInfoCheckUtil;
|
||||
import io.jsonwebtoken.Claims;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
import org.springframework.beans.BeanUtils;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
|
|
@ -39,6 +47,7 @@ import java.util.Date;
|
|||
import java.util.List;
|
||||
|
||||
@Service
|
||||
@Slf4j
|
||||
public class CourseDetailsServiceImpl extends ServiceImpl<CourseDetailsDao, CourseDetails> implements CourseDetailsService {
|
||||
|
||||
@Autowired
|
||||
|
|
@ -53,6 +62,12 @@ public class CourseDetailsServiceImpl extends ServiceImpl<CourseDetailsDao, Cour
|
|||
private OrdersService ordersService;
|
||||
@Autowired
|
||||
private UserService userService;
|
||||
@Autowired
|
||||
private OrdersDao ordersDao;
|
||||
@Autowired
|
||||
private CommonInfoDao commonInfoDao;
|
||||
@Autowired
|
||||
private RedisServiceImpl redisServiceImpl;
|
||||
|
||||
|
||||
@Override
|
||||
|
|
@ -77,6 +92,37 @@ public class CourseDetailsServiceImpl extends ServiceImpl<CourseDetailsDao, Cour
|
|||
return Result.success();
|
||||
}
|
||||
|
||||
/**
|
||||
* 校验用户是否达到免费播放购买次数
|
||||
* @param userId 用户id
|
||||
* @return true 可观看
|
||||
*/
|
||||
private boolean checkFreeWatchPayCount(Long userId) {
|
||||
Boolean isExpire = redisServiceImpl.getPayFreeWatchTimeIsExpire(userId);
|
||||
if (isExpire == null) {
|
||||
Integer count = ordersDao.countPayOrderByDay(userId);
|
||||
CommonInfo needCountCommonInfo = commonInfoDao.selectOne(new LambdaQueryWrapper<CommonInfo>()
|
||||
.eq(CommonInfo::getType, 916));
|
||||
CommonInfo freeTimeCommonInfo = commonInfoDao.selectOne(new LambdaQueryWrapper<CommonInfo>()
|
||||
.eq(CommonInfo::getType, 917));
|
||||
if (needCountCommonInfo == null || freeTimeCommonInfo == null
|
||||
|| StrUtil.isBlank(needCountCommonInfo.getValue()) || StrUtil.isBlank(freeTimeCommonInfo.getValue())) {
|
||||
log.warn("系统未配置全免次数或时间");
|
||||
return false;
|
||||
}
|
||||
|
||||
// 购买次数超过,设置redis标识
|
||||
if (count >= Integer.parseInt(needCountCommonInfo.getValue())) {
|
||||
redisServiceImpl.setPayFreeWatchTime(userId, Integer.parseInt(freeTimeCommonInfo.getValue()));
|
||||
isExpire = false;
|
||||
}else {
|
||||
isExpire = true;
|
||||
}
|
||||
}
|
||||
return !isExpire;
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public Result selectCourseDetailsById(Long id, String token, String courseDetailsId) {
|
||||
Course bean = courseDao.selectById(id);
|
||||
|
|
@ -99,7 +145,9 @@ public class CourseDetailsServiceImpl extends ServiceImpl<CourseDetailsDao, Cour
|
|||
UserEntity userEntity = userService.selectUserById(userId);
|
||||
//查询用户是否购买了整集
|
||||
CourseUser courseUser = courseUserDao.selectCourseUser(id, userId);
|
||||
if (courseUser != null || (userEntity != null && userEntity.getMember() != null && userEntity.getMember() == 2)) {
|
||||
// 每天购买超过上限,获得免费时间段资格
|
||||
boolean freeWatch = checkFreeWatchPayCount(userId);
|
||||
if (freeWatch || courseUser != null || (userEntity != null && userEntity.getMember() != null && userEntity.getMember() == 2)) {
|
||||
bean.setListsDetail(baseMapper.findByCourseId(id, userId));
|
||||
} else {
|
||||
bean.setListsDetail(baseMapper.findByCourseIdNotUrl(id, userId));
|
||||
|
|
|
|||
|
|
@ -59,7 +59,7 @@ public class DiscSpinningAmountController {
|
|||
@GetMapping("/selectDiscSpinningAmount")
|
||||
@ApiOperation("查询现金红包 抽奖配置")
|
||||
public Result selectDiscSpinningAmount(Integer page, Integer limit) {
|
||||
return Result.success().put("data", discSpinningAmountService.page(new Page<>(page, limit), new QueryWrapper<DiscSpinningAmount>().orderByDesc("status").orderByAsc("random","max_amount")));
|
||||
return Result.success().put("data", discSpinningAmountService.page(new Page<>(page, limit), new QueryWrapper<DiscSpinningAmount>().orderByDesc("status").orderByAsc("num","random","max_amount")));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1,5 +1,6 @@
|
|||
package com.sqx.modules.discSpinning.controller;
|
||||
|
||||
import cn.hutool.core.collection.CollectionUtil;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.sqx.common.annotation.Debounce;
|
||||
|
|
@ -20,6 +21,7 @@ import io.swagger.annotations.*;
|
|||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
import reactor.util.annotation.Nullable;
|
||||
import springfox.documentation.annotations.ApiIgnore;
|
||||
|
|
@ -55,9 +57,26 @@ public class DiscSpinningController {
|
|||
|
||||
@PostMapping("/discSpinning/insertDiscSpinning")
|
||||
@ApiOperation("添加大转盘")
|
||||
@Transactional
|
||||
public Result insertDiscSpinning(@RequestBody DiscSpinning discSpinning) {
|
||||
discSpinning.setCreateTime(DateUtils.format(new Date()));
|
||||
discSpinning.setNumber(discSpinning.getOdds());
|
||||
discSpinningService.save(discSpinning);
|
||||
|
||||
List<DiscSpinning> prizes = discSpinningService.list(new QueryWrapper<DiscSpinning>().eq("disc_type", discSpinning.getDiscType()).orderByAsc("type", "id"));
|
||||
BigDecimal number = BigDecimal.ZERO;
|
||||
for (DiscSpinning prize : prizes) {
|
||||
number = number.add(prize.getOdds());
|
||||
prize.setNumber(number);
|
||||
}
|
||||
BigDecimal totalOdds = prizes.stream()
|
||||
.map(DiscSpinning::getOdds)
|
||||
.filter(Objects::nonNull)
|
||||
.reduce(BigDecimal.ZERO, BigDecimal::add);
|
||||
if (totalOdds.compareTo(new BigDecimal(100)) > 0) {
|
||||
return Result.error("中奖概率总和 不可超过100");
|
||||
}
|
||||
discSpinningService.updateBatchById(prizes);
|
||||
return Result.success();
|
||||
}
|
||||
|
||||
|
|
@ -70,20 +89,13 @@ public class DiscSpinningController {
|
|||
@PostMapping("/discSpinning/updateDiscSpinning")
|
||||
@ApiOperation("修改大转盘")
|
||||
public Result updateDiscSpinning(@RequestBody DiscSpinning discSpinning) {
|
||||
List<DiscSpinning> prizes = discSpinningService.list(new QueryWrapper<DiscSpinning>().orderByAsc("type", "id"));
|
||||
discSpinningService.updateById(discSpinning);
|
||||
|
||||
List<DiscSpinning> prizes = discSpinningService.list(new QueryWrapper<DiscSpinning>().eq("disc_type", discSpinning.getDiscType()).orderByAsc("type", "id"));
|
||||
BigDecimal number = BigDecimal.ZERO;
|
||||
List<DiscSpinning> prizesResult = new ArrayList<>();
|
||||
for (DiscSpinning prize : prizes) {
|
||||
if (discSpinning.getId().equals(prize.getId())) {
|
||||
number = prize.getNumber().add(discSpinning.getOdds().subtract(prize.getOdds()));
|
||||
discSpinning.setNumber(number);
|
||||
prize.setOdds(discSpinning.getOdds());
|
||||
prizesResult.add(discSpinning);
|
||||
} else if (number.compareTo(BigDecimal.ZERO) > 0) {
|
||||
number = number.add(prize.getOdds());
|
||||
prize.setNumber(number);
|
||||
prizesResult.add(prize);
|
||||
}
|
||||
number = number.add(prize.getOdds());
|
||||
prize.setNumber(number);
|
||||
}
|
||||
BigDecimal totalOdds = prizes.stream()
|
||||
.map(DiscSpinning::getOdds)
|
||||
|
|
@ -92,7 +104,7 @@ public class DiscSpinningController {
|
|||
if (totalOdds.compareTo(new BigDecimal(100)) > 0) {
|
||||
return Result.error("中奖概率总和 不可超过100");
|
||||
}
|
||||
discSpinningService.updateBatchById(prizesResult);
|
||||
discSpinningService.updateBatchById(prizes);
|
||||
return Result.success();
|
||||
}
|
||||
|
||||
|
|
@ -105,32 +117,31 @@ public class DiscSpinningController {
|
|||
|
||||
@GetMapping("/app/discSpinning/selectDiscSpinning")
|
||||
@ApiImplicitParams({
|
||||
@ApiImplicitParam(name = "type", value = "`1`普通转盘 `2`任务转盘", dataTypeClass = String.class, paramType = "body"),
|
||||
@ApiImplicitParam(name = "source", value = "1 普通转盘 2 周任务转盘 3 月任务转盘", dataTypeClass = Integer.class),
|
||||
})
|
||||
@ApiOperation("查询大转盘")
|
||||
public Result selectDiscSpinning(@RequestParam(required = false, defaultValue = "1") Integer type) {
|
||||
public Result selectDiscSpinning(@RequestParam(required = false, defaultValue = "1") Integer source) {
|
||||
return Result.success().put("data", discSpinningService.page(new Page<>(1, 20),
|
||||
new QueryWrapper<DiscSpinning>().eq("disc_type", type).orderByAsc("disc_type", "odds")));
|
||||
new QueryWrapper<DiscSpinning>().eq("disc_type", source).orderByAsc("disc_type", "odds")));
|
||||
}
|
||||
|
||||
|
||||
//14232
|
||||
@Login
|
||||
@GetMapping("/app/discSpinning/drawCount")
|
||||
@ApiOperation("获取大转盘抽奖次数")
|
||||
@ApiImplicitParams({
|
||||
@ApiImplicitParam(name = "source", value = "`task`任务拉起抽奖 或者 `order` 订单拉起抽奖", dataTypeClass = String.class, paramType = "body"),
|
||||
@ApiImplicitParam(name = "source", value = "`1` 订单拉起抽奖 `2` 周任务拉起抽奖 `3` 月任务拉起抽奖", dataTypeClass = Integer.class),
|
||||
})
|
||||
@ApiResponses({
|
||||
@ApiResponse(code = 200, message = "{\"sum\":\"总抽奖次数\",\"count\":\"剩余抽奖次数\"}"),
|
||||
})
|
||||
public Result drawCount(@ApiIgnore @RequestAttribute("userId") Long userId, @Nullable @ApiIgnore @RequestBody Map maps) {
|
||||
public Result drawCount(@ApiIgnore @RequestAttribute("userId") Long userId, @RequestParam(required = false, defaultValue = "1") Integer source) {
|
||||
Map<String, Object> map = new HashMap<>();
|
||||
int drawCount = Integer.parseInt(commonRepository.findOne(901).getValue());
|
||||
map.put("sum", drawCount);
|
||||
if (maps != null && maps.containsKey("source") && "task".equals(maps.get("source"))) {
|
||||
if (source != null && !source.equals(1)) {
|
||||
//任务可抽奖次数
|
||||
map.put("count", taskCenterService.countTaskDisc(userId));
|
||||
map.put("count", taskCenterService.countTaskDisc(userId, source.toString()));
|
||||
} else {
|
||||
int i = recordService.countDraw(userId);
|
||||
if (drawCount - i > 0) {
|
||||
|
|
@ -145,28 +156,30 @@ public class DiscSpinningController {
|
|||
@Login
|
||||
@GetMapping("/app/discSpinning/draw")
|
||||
@ApiImplicitParams({
|
||||
@ApiImplicitParam(name = "source", value = "`task`任务拉起抽奖 或者 `order` 订单拉起抽奖", dataTypeClass = String.class, paramType = "body"),
|
||||
@ApiImplicitParam(name = "source", value = "1 普通转盘 2 周任务转盘 3 月任务转盘", dataTypeClass = Integer.class),
|
||||
})
|
||||
@ApiOperation("抽取大转盘")
|
||||
public Result draw(@ApiIgnore @RequestAttribute("userId") Long userId, @Nullable @ApiIgnore @RequestBody Map maps) {
|
||||
public Result draw(@ApiIgnore @RequestAttribute("userId") Long userId, @RequestParam(required = false, defaultValue = "1") Integer source) {
|
||||
double amount = 0;
|
||||
Long orderId = null;
|
||||
if (maps == null || !maps.containsKey("source") || !"task".equals(maps.get("source"))) {
|
||||
Integer i = recordService.countDraw(userId);
|
||||
if (source != null && source.equals(1)) {
|
||||
//任务抽奖
|
||||
int drawCount = Integer.parseInt(commonRepository.findOne(901).getValue());
|
||||
Integer i = recordService.countDraw(userId);
|
||||
if (i != null && i >= drawCount) {
|
||||
return Result.error("当日可抽奖次数已超限");
|
||||
}
|
||||
Orders orders = ordersService.selectOrdersByDay(userId);
|
||||
amount = orders.getPayMoney().doubleValue();
|
||||
orderId = orders.getOrdersId();
|
||||
if (orders == null) {
|
||||
return Result.error("无可抽奖机会");
|
||||
}
|
||||
amount = orders.getPayMoney().doubleValue();
|
||||
orderId = orders.getOrdersId();
|
||||
} else if (source == null) {
|
||||
source = 1;
|
||||
}
|
||||
return new Result().put("data",
|
||||
discSpinningService.draws(amount, orderId, userId, maps == null || maps.get("source") == null ? "order" : maps.get("source").toString()));
|
||||
discSpinningService.draws(i == null ? 1 : i + 1, amount, orderId, userId, source));
|
||||
}
|
||||
|
||||
@ApiOperation("大转盘奖项领取")
|
||||
|
|
|
|||
|
|
@ -0,0 +1,42 @@
|
|||
package com.sqx.modules.discSpinning.controller;
|
||||
|
||||
import com.sqx.common.utils.Constant;
|
||||
import com.sqx.common.utils.PageUtils;
|
||||
import com.sqx.common.utils.Result;
|
||||
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("/userPrizeExchange")
|
||||
@AllArgsConstructor
|
||||
@Api(value = "用户奖品兑换", tags = {"用户奖品兑换"})
|
||||
public class UserPrizeExchangeController {
|
||||
private final UserPrizeExchangeService userPrizeExchangeService;
|
||||
|
||||
@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(@ApiIgnore @RequestParam Map<String, Object> params) {
|
||||
PageUtils page = userPrizeExchangeService.page(params);
|
||||
return Result.success().put("page", page);
|
||||
}
|
||||
|
||||
@PostMapping("/deliver")
|
||||
@ApiOperation("发放")
|
||||
public Result exchange(@RequestBody UserPrizeExchange entity) {
|
||||
userPrizeExchangeService.deliver(entity);
|
||||
return Result.success();
|
||||
}
|
||||
}
|
||||
|
|
@ -21,12 +21,12 @@ public class DiscSpinning extends Model<DiscSpinning> {
|
|||
private String url;
|
||||
//描述
|
||||
private String name;
|
||||
//1 普通转盘 2 周任务转盘 3 月任务转盘
|
||||
private Integer discType;
|
||||
//类型 1谢谢惠顾 2 红包 9 其它
|
||||
private Integer type;
|
||||
//数值
|
||||
private BigDecimal number;
|
||||
//红包金额比例
|
||||
private BigDecimal ratio;
|
||||
//中奖概率
|
||||
private BigDecimal odds;
|
||||
//创建时间
|
||||
|
|
|
|||
|
|
@ -1,5 +1,7 @@
|
|||
package com.sqx.modules.discSpinning.entity;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.FieldStrategy;
|
||||
import com.baomidou.mybatisplus.annotation.TableField;
|
||||
import com.baomidou.mybatisplus.extension.activerecord.Model;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import io.swagger.annotations.ApiModel;
|
||||
|
|
@ -18,6 +20,9 @@ import lombok.Data;
|
|||
public class DiscSpinningAmount extends Model<DiscSpinningAmount> {
|
||||
@ApiModelProperty("主键id")
|
||||
private Long id;
|
||||
@ApiModelProperty("从第几次开始变化")
|
||||
@TableField(updateStrategy = FieldStrategy.IGNORED)
|
||||
private Integer num;
|
||||
@ApiModelProperty("描述")
|
||||
private String name;
|
||||
@ApiModelProperty("0-1 小于 多少为该奖励")
|
||||
|
|
@ -27,6 +32,12 @@ public class DiscSpinningAmount extends Model<DiscSpinningAmount> {
|
|||
@ApiModelProperty("是否启动 0否1是")
|
||||
private Integer status;
|
||||
|
||||
|
||||
public void setNum(Integer num) {
|
||||
if (num != null && num.equals(0)) {
|
||||
this.num = null;
|
||||
} else {
|
||||
this.num = num;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -47,7 +47,7 @@ public class DiscSpinningRecord extends Model<DiscSpinningRecord> {
|
|||
}
|
||||
|
||||
public DiscSpinningRecord(String name, Long orderId, Long userId, Integer type, BigDecimal number,
|
||||
String drawDay, String createTime, String source) {
|
||||
String drawDay, String createTime, Integer source) {
|
||||
this.name = name;
|
||||
this.userId = userId;
|
||||
this.orderId = orderId;
|
||||
|
|
@ -55,8 +55,20 @@ public class DiscSpinningRecord extends Model<DiscSpinningRecord> {
|
|||
this.number = number;
|
||||
this.drawDay = drawDay;
|
||||
this.createTime = createTime;
|
||||
if (StringUtils.isNotBlank(source)) {
|
||||
this.source = source;
|
||||
if (source != null) {
|
||||
switch (source) {
|
||||
case 1:
|
||||
this.source = "order";
|
||||
break;
|
||||
case 2:
|
||||
this.source = "taskW";
|
||||
break;
|
||||
case 3:
|
||||
this.source = "taskM";
|
||||
break;
|
||||
default:
|
||||
this.source = source.toString();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -8,7 +8,7 @@ import com.sqx.modules.discSpinning.entity.DiscSpinningRecord;
|
|||
public interface DiscSpinningService extends IService<DiscSpinning> {
|
||||
|
||||
//抽奖
|
||||
DiscSpinningRecord draws(double orderAmount, Long orderId, Long userId, String source);
|
||||
DiscSpinningRecord draws(int drawCount, double orderAmount, Long orderId, Long userId, Integer source);
|
||||
|
||||
//领奖
|
||||
void receiveAsync(DiscSpinningRecord receive);
|
||||
|
|
@ -16,6 +16,11 @@ public interface DiscSpinningService extends IService<DiscSpinning> {
|
|||
//提现
|
||||
void withdraw(UserEntity userInfo, Double money);
|
||||
|
||||
//提现
|
||||
void withdraw(UserEntity userInfo, Double money, String title);
|
||||
|
||||
//提现
|
||||
void withdrawAsync(UserEntity userInfo, Double money, String title);
|
||||
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -17,27 +17,27 @@ import com.sqx.modules.discSpinning.dao.DiscSpinningDao;
|
|||
import com.sqx.modules.discSpinning.entity.DiscSpinning;
|
||||
import com.sqx.modules.discSpinning.entity.DiscSpinningAmount;
|
||||
import com.sqx.modules.discSpinning.entity.DiscSpinningRecord;
|
||||
import com.sqx.modules.discSpinning.service.DiscSpinningAmountService;
|
||||
import com.sqx.modules.discSpinning.service.DiscSpinningRecordService;
|
||||
import com.sqx.modules.discSpinning.service.DiscSpinningService;
|
||||
import com.sqx.modules.orders.service.OrdersService;
|
||||
import com.sqx.modules.pay.entity.CashOut;
|
||||
import com.sqx.modules.pay.service.CashOutService;
|
||||
import com.sqx.modules.pay.wuyou.BaseResp;
|
||||
import com.sqx.modules.pay.wuyou.WuyouPay;
|
||||
import com.sqx.modules.utils.AliPayOrderUtil;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.PlatformTransactionManager;
|
||||
import org.springframework.transaction.TransactionStatus;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
import org.springframework.transaction.support.DefaultTransactionDefinition;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.math.RoundingMode;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
import java.util.Random;
|
||||
import java.util.*;
|
||||
|
||||
@Slf4j
|
||||
@Service
|
||||
public class DiscSpinningServiceImpl extends ServiceImpl<DiscSpinningDao, DiscSpinning> implements DiscSpinningService {
|
||||
|
||||
|
|
@ -49,6 +49,9 @@ public class DiscSpinningServiceImpl extends ServiceImpl<DiscSpinningDao, DiscSp
|
|||
private final CashOutService cashOutService;
|
||||
private final RedisUtils redisUtils;
|
||||
|
||||
@Autowired
|
||||
private PlatformTransactionManager transactionManager;
|
||||
|
||||
|
||||
@Autowired
|
||||
public DiscSpinningServiceImpl(CommonInfoService commonRepository,
|
||||
|
|
@ -95,6 +98,12 @@ public class DiscSpinningServiceImpl extends ServiceImpl<DiscSpinningDao, DiscSp
|
|||
@Override
|
||||
@Transactional
|
||||
public void withdraw(UserEntity userInfo, Double money) {
|
||||
withdraw(userInfo, money, "[现金大转盘]");
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional
|
||||
public void withdraw(UserEntity userInfo, Double money, String title) {
|
||||
CashOut cashOut = new CashOut();
|
||||
cashOut.setIsOut(false);
|
||||
cashOut.setMoney(money.toString());
|
||||
|
|
@ -114,7 +123,7 @@ public class DiscSpinningServiceImpl extends ServiceImpl<DiscSpinningDao, DiscSp
|
|||
BaseResp baseResp = WuyouPay.extractOrder(outOrderNo, cashOut.getMoney(), cashOut.getZhifubao(), cashOut.getZhifubaoName());
|
||||
if (baseResp.getStatus() != null && (baseResp.getStatus().equals(2) || baseResp.getStatus().equals(10000))) {
|
||||
UserMoneyDetails userMoneyDetails = new UserMoneyDetails(
|
||||
userInfo.getUserId(), null, null, "[现金大转盘]", 4, 2, 1,
|
||||
userInfo.getUserId(), null, null, title, 4, 2, 1,
|
||||
new BigDecimal(money), "现金红包自动提现" + money + "元", 1);
|
||||
userMoneyDetailsService.save(userMoneyDetails);
|
||||
//减去余额 钱
|
||||
|
|
@ -125,26 +134,43 @@ public class DiscSpinningServiceImpl extends ServiceImpl<DiscSpinningDao, DiscSp
|
|||
cashOut.setState(2);
|
||||
if (baseResp.getErrorMsg().contains("收款人账户号出款属性不匹配")) {
|
||||
cashOut.setRefund("提现失败,请检查支付宝账号与收款人姓名后,重试。");
|
||||
}else {
|
||||
} else {
|
||||
cashOut.setRefund(baseResp.getErrorMsg());
|
||||
}
|
||||
} else if (StringUtils.isNotBlank(baseResp.getMsg())) {
|
||||
cashOut.setState(2);
|
||||
cashOut.setRefund("提现失败,请检查支付宝账号与收款人姓名后,重试。");
|
||||
}
|
||||
}else {
|
||||
} else {
|
||||
UserMoneyDetails userMoneyDetails = new UserMoneyDetails(
|
||||
userInfo.getUserId(), null, null, "[现金大转盘]", 4, 2, 1,
|
||||
userInfo.getUserId(), null, null, title, 4, 2, 1,
|
||||
new BigDecimal(money), "现金红包自动提现" + money + "元", 1);
|
||||
userMoneyDetailsService.save(userMoneyDetails);
|
||||
//减去余额 钱
|
||||
userMoneyService.updateAmount(2, userInfo.getUserId(), money);
|
||||
}
|
||||
cashOutService.saveBody(cashOut);
|
||||
log.info("领取奖励执行完毕");
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional
|
||||
public DiscSpinningRecord draws(double orderAmount, Long orderId, Long userId, String source) {
|
||||
public void withdrawAsync(UserEntity userInfo, Double money, String title) {
|
||||
TransactionStatus transactionStatus = transactionManager.getTransaction(new DefaultTransactionDefinition());
|
||||
try {
|
||||
withdraw(userInfo, money, title);
|
||||
transactionManager.commit(transactionStatus);
|
||||
}catch (Exception e){
|
||||
transactionManager.rollback(transactionStatus);
|
||||
throw e;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional
|
||||
public DiscSpinningRecord draws(int drawCount, double orderAmount, Long orderId, Long userId, Integer source) {
|
||||
DiscSpinning result = new DiscSpinning("谢谢惠顾", 1, null);
|
||||
List<DiscSpinning> prizes = baseMapper.selectList(new QueryWrapper<DiscSpinning>().eq("disc_type", "order".equals(source) ? 1 : 2).orderByAsc("odds"));
|
||||
List<DiscSpinning> prizes = baseMapper.selectList(new QueryWrapper<DiscSpinning>().eq("disc_type", source).orderByAsc("odds"));
|
||||
|
||||
Random random = new Random();
|
||||
double randomDouble;
|
||||
|
|
@ -153,7 +179,14 @@ public class DiscSpinningServiceImpl extends ServiceImpl<DiscSpinningDao, DiscSp
|
|||
} while (randomDouble == 0);
|
||||
BigDecimal randomNum = new BigDecimal(randomDouble).multiply(new BigDecimal(10000)).divide(new BigDecimal(100));
|
||||
|
||||
List<DiscSpinningAmount> amounts = redisUtils.getListData(RedisKeys.getDateKey("spinning:amount"), DiscSpinningAmount.class, "setDiscSpinningAmounts");
|
||||
List<DiscSpinningAmount> amounts = new ArrayList<>();
|
||||
Map<String, List<DiscSpinningAmount>> amountMaps = redisUtils.getMapData(RedisKeys.getDateKey("spinning:amount"), "setDiscSpinningAmounts", DiscSpinningAmount.class);
|
||||
for (int i = drawCount; i >= 0; i--) {
|
||||
if (amountMaps.containsKey(i + "")) {
|
||||
amounts = amountMaps.get(i + "");
|
||||
break;
|
||||
}
|
||||
}
|
||||
for (DiscSpinning prize : prizes) {
|
||||
if (randomNum.compareTo(prize.getNumber()) < 0) {
|
||||
if (prize.getType() == 2) {
|
||||
|
|
@ -180,12 +213,14 @@ public class DiscSpinningServiceImpl extends ServiceImpl<DiscSpinningDao, DiscSp
|
|||
}
|
||||
result = new DiscSpinning(prize.getName(), 2, new BigDecimal(resultAmount).setScale(2, RoundingMode.HALF_UP));
|
||||
break;
|
||||
} else {
|
||||
if (source != 1) {
|
||||
result = prize;
|
||||
}
|
||||
}
|
||||
// else {
|
||||
// result = prize;
|
||||
// }
|
||||
}
|
||||
}
|
||||
|
||||
DiscSpinningRecord record = new DiscSpinningRecord(result.getName(), orderId, userId, result.getType(),
|
||||
result.getNumber(), DateUtils.formatYMD(new Date()), DateUtils.format(new Date()), source);
|
||||
recordService.save(record);
|
||||
|
|
|
|||
|
|
@ -1,8 +1,15 @@
|
|||
package com.sqx.modules.orders.controller;
|
||||
|
||||
import cn.hutool.core.date.DateTime;
|
||||
import cn.hutool.core.date.DateUtil;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.sqx.common.utils.DateUtils;
|
||||
import com.sqx.common.utils.Result;
|
||||
import com.sqx.modules.course.entity.CourseCollect;
|
||||
import com.sqx.modules.orders.service.OrdersService;
|
||||
import com.sqx.modules.pay.dao.CashOutDao;
|
||||
import com.sqx.modules.pay.entity.CashOut;
|
||||
import com.sqx.modules.pay.service.CashOutService;
|
||||
import com.sqx.modules.sys.controller.AbstractController;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
|
|
@ -14,6 +21,8 @@ import org.springframework.web.bind.annotation.RestController;
|
|||
|
||||
import java.text.ParseException;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.time.LocalDateTime;
|
||||
import java.time.format.DateTimeFormatter;
|
||||
import java.util.*;
|
||||
|
||||
@RestController
|
||||
|
|
@ -22,19 +31,21 @@ import java.util.*;
|
|||
public class OrdersController extends AbstractController {
|
||||
@Autowired
|
||||
private OrdersService ordersService;
|
||||
@Autowired
|
||||
private CashOutDao cashOutDao;
|
||||
|
||||
@GetMapping("/selectOrders")
|
||||
@ApiOperation("订单信息列表")
|
||||
public Result selectOrders(Integer page,Integer limit,String ordersNo,Integer status,Long userId,
|
||||
Long courseId,Integer flag,String time,String userName,Integer ordersType,
|
||||
String startTime,String endTime,Long sysUserId,String qdCode,String sysUserName){
|
||||
return ordersService.selectOrders(page,limit,ordersNo,status,userId,courseId,flag,time,userName,ordersType,
|
||||
startTime,endTime,sysUserId,qdCode,sysUserName);
|
||||
public Result selectOrders(Integer page, Integer limit, String ordersNo, Integer status, Long userId,
|
||||
Long courseId, Integer flag, String time, String userName, Integer ordersType,
|
||||
String startTime, String endTime, Long sysUserId, String qdCode, String sysUserName) {
|
||||
return ordersService.selectOrders(page, limit, ordersNo, status, userId, courseId, flag, time, userName, ordersType,
|
||||
startTime, endTime, sysUserId, qdCode, sysUserName);
|
||||
}
|
||||
|
||||
@GetMapping("/deleteOrders")
|
||||
@ApiOperation("删除订单")
|
||||
public Result deleteOrders(String ids){
|
||||
public Result deleteOrders(String ids) {
|
||||
return ordersService.deleteOrders(ids);
|
||||
}
|
||||
|
||||
|
|
@ -46,75 +57,93 @@ public class OrdersController extends AbstractController {
|
|||
|
||||
@GetMapping("/selectOrdersMoneyList")
|
||||
@ApiOperation("订单收入分析")
|
||||
public Result selectOrdersMoneyList(Integer page,Integer limit,Integer flag,String time){
|
||||
public Result selectOrdersMoneyList(Integer page, Integer limit, Integer flag, String time) {
|
||||
return ordersService.selectOrdersMoneyList(page, limit, flag, time);
|
||||
}
|
||||
|
||||
@PostMapping("/refundOrders")
|
||||
@ApiOperation("退款订单")
|
||||
public Result refundOrders(Long ordersId){
|
||||
return ordersService.refundOrder(ordersId,"系统退款");
|
||||
public Result refundOrders(Long ordersId) {
|
||||
return ordersService.refundOrder(ordersId, "系统退款");
|
||||
}
|
||||
|
||||
|
||||
@GetMapping("/selectOrdersCount")
|
||||
@ApiOperation("订单统计")
|
||||
public Result selectOrdersCount(Integer flag,String time,Long sysUserId){
|
||||
public Result selectOrdersCount(Integer flag, String time, Long sysUserId) {
|
||||
//短剧订单 总 待 完 退
|
||||
Integer sumCourseOrdersCount = ordersService.selectOrdersCount(null, 1, flag, time,sysUserId);
|
||||
Integer daiCourseKeOrdersCount = ordersService.selectOrdersCount(0, 1, flag, time,sysUserId);
|
||||
Integer wanCourseKeOrdersCount = ordersService.selectOrdersCount(1, 1, flag, time,sysUserId);
|
||||
Integer tuiCourseOrdersCount = ordersService.selectOrdersCount(2, 1, flag, time,sysUserId);
|
||||
Integer sumCourseOrdersCount = ordersService.selectOrdersCount(null, 1, flag, time, sysUserId);
|
||||
Integer daiCourseKeOrdersCount = ordersService.selectOrdersCount(0, 1, flag, time, sysUserId);
|
||||
Integer wanCourseKeOrdersCount = ordersService.selectOrdersCount(1, 1, flag, time, sysUserId);
|
||||
Integer tuiCourseOrdersCount = ordersService.selectOrdersCount(2, 1, flag, time, sysUserId);
|
||||
//短剧钱
|
||||
Double sumCourseOrdersMoney = ordersService.selectOrdersMoney(null, 1, flag, time,null,sysUserId);
|
||||
Double daiCourseOrdersMoney = ordersService.selectOrdersMoney(0, 1, flag, time,null,sysUserId);
|
||||
Double wanCourseOrdersMoney = ordersService.selectOrdersMoney(1, 1, flag, time,null,sysUserId);
|
||||
Double tuiCourseOrdersMoney = ordersService.selectOrdersMoney(2, 1, flag, time,null,sysUserId);
|
||||
Double sumCourseOrdersMoney = ordersService.selectOrdersMoney(null, 1, flag, time, null, sysUserId);
|
||||
Double daiCourseOrdersMoney = ordersService.selectOrdersMoney(0, 1, flag, time, null, sysUserId);
|
||||
Double wanCourseOrdersMoney = ordersService.selectOrdersMoney(1, 1, flag, time, null, sysUserId);
|
||||
Double tuiCourseOrdersMoney = ordersService.selectOrdersMoney(2, 1, flag, time, null, sysUserId);
|
||||
//会员订单 总 待 完 退
|
||||
Integer sumMemberOrdersCount = ordersService.selectOrdersCount(null, 2, flag, time,sysUserId);
|
||||
Integer daiMemberKeOrdersCount = ordersService.selectOrdersCount(0, 2, flag, time,sysUserId);
|
||||
Integer wanMemberKeOrdersCount = ordersService.selectOrdersCount(1, 2, flag, time,sysUserId);
|
||||
Integer tuiMemberOrdersCount = ordersService.selectOrdersCount(2, 2, flag, time,sysUserId);
|
||||
Integer sumMemberOrdersCount = ordersService.selectOrdersCount(null, 2, flag, time, sysUserId);
|
||||
Integer daiMemberKeOrdersCount = ordersService.selectOrdersCount(0, 2, flag, time, sysUserId);
|
||||
Integer wanMemberKeOrdersCount = ordersService.selectOrdersCount(1, 2, flag, time, sysUserId);
|
||||
Integer tuiMemberOrdersCount = ordersService.selectOrdersCount(2, 2, flag, time, sysUserId);
|
||||
//会员钱
|
||||
Double sumMemberOrdersMoney = ordersService.selectOrdersMoney(null, 2, flag, time,null,sysUserId);
|
||||
Double daiMemberOrdersMoney = ordersService.selectOrdersMoney(0, 2, flag, time,null,sysUserId);
|
||||
Double wanMemberOrdersMoney = ordersService.selectOrdersMoney(1, 2, flag, time,null,sysUserId);
|
||||
Double tuiMemberOrdersMoney = ordersService.selectOrdersMoney(2, 2, flag, time,null,sysUserId);
|
||||
Map<String,Object> result=new HashMap<>();
|
||||
result.put("sumCourseOrdersCount",sumCourseOrdersCount);result.put("daiCourseKeOrdersCount",daiCourseKeOrdersCount);
|
||||
result.put("wanCourseKeOrdersCount",wanCourseKeOrdersCount);result.put("tuiCourseOrdersCount",tuiCourseOrdersCount);
|
||||
result.put("sumCourseOrdersMoney",sumCourseOrdersMoney);result.put("daiCourseOrdersMoney",daiCourseOrdersMoney);
|
||||
result.put("wanCourseOrdersMoney",wanCourseOrdersMoney);result.put("tuiCourseOrdersMoney",tuiCourseOrdersMoney);
|
||||
result.put("sumMemberOrdersCount",sumMemberOrdersCount);result.put("daiMemberKeOrdersCount",daiMemberKeOrdersCount);
|
||||
result.put("wanMemberKeOrdersCount",wanMemberKeOrdersCount);result.put("tuiMemberOrdersCount",tuiMemberOrdersCount);
|
||||
result.put("sumMemberOrdersMoney",sumMemberOrdersMoney);result.put("daiMemberOrdersMoney",daiMemberOrdersMoney);
|
||||
result.put("wanMemberOrdersMoney",wanMemberOrdersMoney);result.put("tuiMemberOrdersMoney",tuiMemberOrdersMoney);
|
||||
return Result.success().put("data",result);
|
||||
Double sumMemberOrdersMoney = ordersService.selectOrdersMoney(null, 2, flag, time, null, sysUserId);
|
||||
Double daiMemberOrdersMoney = ordersService.selectOrdersMoney(0, 2, flag, time, null, sysUserId);
|
||||
Double wanMemberOrdersMoney = ordersService.selectOrdersMoney(1, 2, flag, time, null, sysUserId);
|
||||
Double tuiMemberOrdersMoney = ordersService.selectOrdersMoney(2, 2, flag, time, null, sysUserId);
|
||||
//提现
|
||||
Integer cashCount = cashOutDao.selectCount(new QueryWrapper<CashOut>()
|
||||
.eq("sys_user_id", sysUserId)
|
||||
.eq("state", 1)
|
||||
.gt("create_at", DateUtil.format(DateUtil.parse(time, "yyyy-MM-dd"), "yyyy-MM-dd HH:mm:ss")));
|
||||
Double cashSum = cashOutDao.selectSysUserCashOutSum(sysUserId, DateUtil.format(DateUtil.parse(time, "yyyy-MM-dd"), "yyyy-MM-dd HH:mm:ss"));
|
||||
|
||||
Map<String, Object> result = new HashMap<>();
|
||||
|
||||
result.put("sumCourseOrdersCount", sumCourseOrdersCount);
|
||||
result.put("daiCourseKeOrdersCount", daiCourseKeOrdersCount);
|
||||
result.put("wanCourseKeOrdersCount", wanCourseKeOrdersCount);
|
||||
result.put("tuiCourseOrdersCount", tuiCourseOrdersCount);
|
||||
result.put("sumCourseOrdersMoney", sumCourseOrdersMoney);
|
||||
result.put("daiCourseOrdersMoney", daiCourseOrdersMoney);
|
||||
result.put("wanCourseOrdersMoney", wanCourseOrdersMoney);
|
||||
result.put("tuiCourseOrdersMoney", tuiCourseOrdersMoney);
|
||||
result.put("sumMemberOrdersCount", sumMemberOrdersCount);
|
||||
result.put("daiMemberKeOrdersCount", daiMemberKeOrdersCount);
|
||||
result.put("wanMemberKeOrdersCount", wanMemberKeOrdersCount);
|
||||
result.put("tuiMemberOrdersCount", tuiMemberOrdersCount);
|
||||
result.put("sumMemberOrdersMoney", sumMemberOrdersMoney);
|
||||
result.put("daiMemberOrdersMoney", daiMemberOrdersMoney);
|
||||
result.put("wanMemberOrdersMoney", wanMemberOrdersMoney);
|
||||
result.put("tuiMemberOrdersMoney", tuiMemberOrdersMoney);
|
||||
result.put("cashCount", cashCount == null ? 0 : cashCount);
|
||||
result.put("cashSum", cashSum);
|
||||
return Result.success().put("data", result);
|
||||
}
|
||||
|
||||
@GetMapping("/selectCourseOrdersMoneyCount")
|
||||
@ApiOperation("统计具体剧的收益")
|
||||
public Result selectCourseOrdersMoneyCount(Long courseId,Long sysUserId){
|
||||
public Result selectCourseOrdersMoneyCount(Long courseId, Long sysUserId) {
|
||||
//总收益
|
||||
Double sumMoney = ordersService.selectOrdersMoney(1, 1, null, null,courseId,sysUserId);
|
||||
Double sumMoney = ordersService.selectOrdersMoney(1, 1, null, null, courseId, sysUserId);
|
||||
String dateTime = DateUtils.format(new Date());
|
||||
//年
|
||||
Double yearMoney = ordersService.selectOrdersMoney(1, 1, 3, dateTime,courseId,sysUserId);
|
||||
Double yearMoney = ordersService.selectOrdersMoney(1, 1, 3, dateTime, courseId, sysUserId);
|
||||
//月
|
||||
Double monthMoney = ordersService.selectOrdersMoney(1, 1, 2, dateTime,courseId,sysUserId);
|
||||
Double monthMoney = ordersService.selectOrdersMoney(1, 1, 2, dateTime, courseId, sysUserId);
|
||||
//日
|
||||
Double dayMoney = ordersService.selectOrdersMoney(1, 1, 1, dateTime,courseId,sysUserId);
|
||||
Map<String,Double> result=new HashMap<>();
|
||||
result.put("sumMoney",sumMoney);
|
||||
result.put("yearMoney",yearMoney);
|
||||
result.put("monthMoney",monthMoney);
|
||||
result.put("dayMoney",dayMoney);
|
||||
return Result.success().put("data",result);
|
||||
Double dayMoney = ordersService.selectOrdersMoney(1, 1, 1, dateTime, courseId, sysUserId);
|
||||
Map<String, Double> result = new HashMap<>();
|
||||
result.put("sumMoney", sumMoney);
|
||||
result.put("yearMoney", yearMoney);
|
||||
result.put("monthMoney", monthMoney);
|
||||
result.put("dayMoney", dayMoney);
|
||||
return Result.success().put("data", result);
|
||||
}
|
||||
|
||||
@GetMapping("/selectFenXiaoMoney")
|
||||
@ApiOperation("统计分销金币")
|
||||
public Result selectFenXiaoMoney(Long sysUserId,Integer flag,String time){
|
||||
public Result selectFenXiaoMoney(Long sysUserId, Integer flag, String time) {
|
||||
//一级
|
||||
Double oneMoney = ordersService.selectFenXiaoMoney(1, sysUserId, flag, time);
|
||||
//二级
|
||||
|
|
@ -123,25 +152,25 @@ public class OrdersController extends AbstractController {
|
|||
Double qdMoney = ordersService.selectFenXiaoMoney(3, sysUserId, flag, time);
|
||||
//总分销
|
||||
Double sumMoney = ordersService.selectFenXiaoMoney(4, sysUserId, flag, time);
|
||||
Map<String,Object> result=new HashMap<>();
|
||||
result.put("oneMoney",oneMoney);
|
||||
result.put("twoMoney",twoMoney);
|
||||
result.put("qdMoney",qdMoney);
|
||||
result.put("sumMoney",sumMoney);
|
||||
return Result.success().put("data",result);
|
||||
Map<String, Object> result = new HashMap<>();
|
||||
result.put("oneMoney", oneMoney);
|
||||
result.put("twoMoney", twoMoney);
|
||||
result.put("qdMoney", qdMoney);
|
||||
result.put("sumMoney", sumMoney);
|
||||
return Result.success().put("data", result);
|
||||
}
|
||||
|
||||
@GetMapping("/selectOrdersCountStatisticsByYear")
|
||||
@ApiOperation("订单数量统计")
|
||||
public Result selectOrdersCountStatisticsByYear(String startTime,String endTime){
|
||||
public Result selectOrdersCountStatisticsByYear(String startTime, String endTime) {
|
||||
//总数量 0待支付 1已支付 2已退款
|
||||
List<Integer> ordersCountList=new ArrayList<>();
|
||||
List<Integer> ordersDaiFuKuanCountList=new ArrayList<>();
|
||||
List<Integer> ordersYiZhiFuCountList=new ArrayList<>();
|
||||
List<Integer> ordersYiTuiKuanLunCountList=new ArrayList<>();
|
||||
List<String> year=new ArrayList<>();
|
||||
List<Integer> ordersCountList = new ArrayList<>();
|
||||
List<Integer> ordersDaiFuKuanCountList = new ArrayList<>();
|
||||
List<Integer> ordersYiZhiFuCountList = new ArrayList<>();
|
||||
List<Integer> ordersYiTuiKuanLunCountList = new ArrayList<>();
|
||||
List<String> year = new ArrayList<>();
|
||||
SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd");
|
||||
Calendar calendar=Calendar.getInstance();
|
||||
Calendar calendar = Calendar.getInstance();
|
||||
Date parse = null;
|
||||
try {
|
||||
parse = simpleDateFormat.parse(startTime);
|
||||
|
|
@ -149,7 +178,7 @@ public class OrdersController extends AbstractController {
|
|||
e.printStackTrace();
|
||||
}
|
||||
calendar.setTime(parse);
|
||||
while (true){
|
||||
while (true) {
|
||||
String dateTime = simpleDateFormat.format(calendar.getTime());
|
||||
//状态 0待支付 1已支付 2已退款
|
||||
//总订单数
|
||||
|
|
@ -165,22 +194,17 @@ public class OrdersController extends AbstractController {
|
|||
Integer ordersQuXiaoCount = ordersService.selectOrdersCountStatisticsByYear(1, dateTime, 2);
|
||||
ordersYiTuiKuanLunCountList.add(ordersQuXiaoCount);
|
||||
year.add(dateTime);
|
||||
if(dateTime.equals(endTime)){
|
||||
if (dateTime.equals(endTime)) {
|
||||
break;
|
||||
}
|
||||
calendar.add(Calendar.DATE,1);
|
||||
calendar.add(Calendar.DATE, 1);
|
||||
}
|
||||
Map<String,Object> result=new HashMap<>();
|
||||
result.put("ordersCountList",ordersCountList);
|
||||
result.put("ordersDaiFuKuanCountList",ordersDaiFuKuanCountList);
|
||||
result.put("ordersYiZhiFuCountList",ordersYiZhiFuCountList);
|
||||
result.put("ordersYiTuiKuanLunCountList",ordersYiTuiKuanLunCountList);
|
||||
result.put("year",year);
|
||||
return Result.success().put("data",result);
|
||||
Map<String, Object> result = new HashMap<>();
|
||||
result.put("ordersCountList", ordersCountList);
|
||||
result.put("ordersDaiFuKuanCountList", ordersDaiFuKuanCountList);
|
||||
result.put("ordersYiZhiFuCountList", ordersYiZhiFuCountList);
|
||||
result.put("ordersYiTuiKuanLunCountList", ordersYiTuiKuanLunCountList);
|
||||
result.put("year", year);
|
||||
return Result.success().put("data", result);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -39,6 +39,8 @@ public interface OrdersDao extends BaseMapper<Orders> {
|
|||
Integer selectOrdersCountStatisticsByDay(Long userId);
|
||||
|
||||
Orders selectOrdersByDay(Long userId);
|
||||
Integer countPayOrderByDay(Long userId);
|
||||
|
||||
|
||||
Integer countOrderNum(Long userId, String time);
|
||||
|
||||
|
|
|
|||
|
|
@ -32,6 +32,8 @@ import com.sqx.modules.utils.AmountCalUtils;
|
|||
import com.sqx.modules.utils.excel.ExcelData;
|
||||
import com.sqx.modules.utils.excel.ExportExcelUtils;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiImplicitParam;
|
||||
import io.swagger.annotations.ApiImplicitParams;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import lombok.val;
|
||||
|
|
@ -484,8 +486,16 @@ public class CashController {
|
|||
@Login
|
||||
@GetMapping(value = "/withdraw")
|
||||
@ApiOperation("发起提现 余额 金钱")
|
||||
public Result withdraw(Long userId, Double money) {
|
||||
return cashOutService.withdraw(userId, money, true);
|
||||
@ApiImplicitParams({
|
||||
@ApiImplicitParam(name = "userId", value = "提现人员Id", dataTypeClass = String.class, paramType = "param"),
|
||||
@ApiImplicitParam(name = "money", value = "提现金额", dataTypeClass = Double.class, paramType = "param"),
|
||||
@ApiImplicitParam(name = "msg", value = "验证码", dataTypeClass = String.class, paramType = "param"),
|
||||
})
|
||||
public Result withdraw(Long userId, Double money, String msg) {
|
||||
if (StringUtils.isBlank(msg)) {
|
||||
return Result.error("请输入验证码");
|
||||
}
|
||||
return cashOutService.withdraw(userId, money, msg, true);
|
||||
}
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -48,7 +48,7 @@ public class AppCashController {
|
|||
@Debounce(interval = 3000, value = "#userId")
|
||||
@ApiOperation("发起提现 余额 金钱")
|
||||
public Result withdraw(@RequestAttribute("userId") Long userId, Double amount) {
|
||||
return cashOutService.withdraw(userId, amount, false);
|
||||
return cashOutService.withdraw(userId, amount, null, false);
|
||||
}
|
||||
|
||||
@Login
|
||||
|
|
|
|||
|
|
@ -2,9 +2,7 @@ package com.sqx.modules.pay.controller.app;
|
|||
|
||||
import cn.hutool.core.date.DateUtil;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.amazonaws.services.dynamodbv2.xspec.S;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.sqx.common.annotation.Debounce;
|
||||
import com.sqx.common.utils.DateUtils;
|
||||
import com.sqx.common.utils.Result;
|
||||
|
|
@ -36,7 +34,6 @@ import io.swagger.annotations.Api;
|
|||
import io.swagger.annotations.ApiOperation;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
|
|
@ -46,6 +43,9 @@ import java.util.Date;
|
|||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.concurrent.CompletableFuture;
|
||||
import java.util.concurrent.Executors;
|
||||
import java.util.concurrent.ScheduledExecutorService;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
/**
|
||||
* @author GYJ
|
||||
|
|
@ -67,7 +67,7 @@ public class WuyouController {
|
|||
private final CashOutDao cashOutDao;
|
||||
private final CompletAwardService completAwardService;
|
||||
private final SysUserService sysUserService;
|
||||
|
||||
ScheduledExecutorService scheduledExecutorService = Executors.newScheduledThreadPool(5);
|
||||
private final SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
|
||||
|
||||
WuyouController(OrdersService ordersService, PayDetailsDao payDetailsDao, UserService userService, InviteService inviteService, CashOutDao cashOutDao,
|
||||
|
|
@ -169,45 +169,18 @@ public class WuyouController {
|
|||
|
||||
@PostMapping("/extractNotify")
|
||||
public String extractNotify(HttpServletRequest request, NotifyDto notifyDto) {
|
||||
log.info("无忧支付提现回调, {}", notifyDto);
|
||||
Map<String, Object> params = new HashMap<>();
|
||||
params.put("callbacks", notifyDto.getCallbacks());
|
||||
params.put("total", notifyDto.getTotal());
|
||||
params.put("out_trade_no", notifyDto.getOut_trade_no());
|
||||
params.put("status", notifyDto.getStatus());
|
||||
params.put("msg", notifyDto.getMsg());
|
||||
|
||||
String sign = Encrypt.getParamsSign(params);
|
||||
if (!sign.equals(notifyDto.getSign())) {
|
||||
log.error("无忧支付提现回调签名错误, 参数: {},签名结果:{}", JSONObject.toJSONString(notifyDto), sign);
|
||||
// return "签名错误";
|
||||
}
|
||||
CashOut cashOut = cashOutDao.selectOne(new QueryWrapper<CashOut>().eq("order_number", notifyDto.getOut_trade_no()));
|
||||
if (cashOut != null) {
|
||||
if ("2".equals(notifyDto.getStatus())) {
|
||||
cashOut.setState(1);
|
||||
cashOut.setOutAt(DateUtil.now());
|
||||
} else if(!cashOut.getState().equals(2)){
|
||||
cashOut.setState(2);
|
||||
cashOut.setRefund(notifyDto.getMsg());
|
||||
if(StringUtils.isNotBlank(notifyDto.getMsg()) && notifyDto.getMsg().contains("已驳回")){
|
||||
cashOut.setRefund("提现失败,请检查支付宝账号与收款人姓名后,重试。");
|
||||
}
|
||||
|
||||
UserMoneyDetails userMoneyDetails = new UserMoneyDetails(
|
||||
cashOut.getUserId(), null, null, "提现失败", 4, 1, 1,
|
||||
new BigDecimal(cashOut.getMoney()), "提现失败存入余额" + cashOut.getMoney() + "元", 1);
|
||||
//存入余额 钱
|
||||
userMoneyService.updateAmount(1, cashOut.getUserId(), Double.parseDouble(cashOut.getMoney()));
|
||||
userMoneyDetailsService.save(userMoneyDetails);
|
||||
}else{
|
||||
return "success";
|
||||
}
|
||||
cashOutDao.updateById(cashOut);
|
||||
}
|
||||
CompletableFuture.runAsync(() -> {
|
||||
updateCashAsync(notifyDto);
|
||||
// try {
|
||||
// scheduledExecutorService.schedule(() -> updateCashAsync(notifyDto), 3, TimeUnit.SECONDS);
|
||||
// } catch (Exception e) {
|
||||
// e.printStackTrace();
|
||||
// }
|
||||
});
|
||||
return "success";
|
||||
}
|
||||
|
||||
|
||||
@PostMapping("/notify")
|
||||
public String notify(HttpServletRequest request, NotifyDto notifyDto) {
|
||||
log.info("无忧支付回调, {}", notifyDto);
|
||||
|
|
@ -363,4 +336,42 @@ public class WuyouController {
|
|||
activities(user, byUser);
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
private void updateCashAsync(NotifyDto notifyDto){
|
||||
log.info("无忧支付提现回调, {}", notifyDto);
|
||||
Map<String, Object> params = new HashMap<>();
|
||||
params.put("callbacks", notifyDto.getCallbacks());
|
||||
params.put("total", notifyDto.getTotal());
|
||||
params.put("out_trade_no", notifyDto.getOut_trade_no());
|
||||
params.put("status", notifyDto.getStatus());
|
||||
params.put("msg", notifyDto.getMsg());
|
||||
|
||||
String sign = Encrypt.getParamsSign(params);
|
||||
if (!sign.equals(notifyDto.getSign())) {
|
||||
log.error("无忧支付提现回调签名错误, 参数: {},签名结果:{}", JSONObject.toJSONString(notifyDto), sign);
|
||||
// return "签名错误";
|
||||
}
|
||||
CashOut cashOut = cashOutDao.selectOne(new QueryWrapper<CashOut>().eq("order_number", notifyDto.getOut_trade_no()));
|
||||
if (cashOut != null) {
|
||||
if ("2".equals(notifyDto.getStatus())) {
|
||||
cashOut.setState(1);
|
||||
cashOut.setOutAt(DateUtil.now());
|
||||
} else if(!cashOut.getState().equals(2)){
|
||||
cashOut.setState(2);
|
||||
cashOut.setRefund(notifyDto.getMsg());
|
||||
if(StringUtils.isNotBlank(notifyDto.getMsg()) && notifyDto.getMsg().contains("已驳回")){
|
||||
cashOut.setRefund("提现失败,请检查支付宝账号与收款人姓名后重试。");
|
||||
}
|
||||
|
||||
UserMoneyDetails userMoneyDetails = new UserMoneyDetails(
|
||||
cashOut.getUserId(), null, null, "提现失败", 4, 1, 1,
|
||||
new BigDecimal(cashOut.getMoney()), "提现失败存入余额" + cashOut.getMoney() + "元", 1);
|
||||
//存入余额 钱
|
||||
userMoneyService.updateAmount(1, cashOut.getUserId(), Double.parseDouble(cashOut.getMoney()));
|
||||
userMoneyDetailsService.save(userMoneyDetails);
|
||||
}
|
||||
cashOutDao.updateById(cashOut);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -22,6 +22,7 @@ public interface CashOutDao extends BaseMapper<CashOut> {
|
|||
List<CashOut> selectYesterday();
|
||||
|
||||
Double selectCashOutSum(@Param("userId") Long userId, @Param("startTime") Date startTime, @Param("endTime") Date endTime);
|
||||
Double selectSysUserCashOutSum(@Param("sysUserId") Long sysUserId, @Param("time") String time);
|
||||
|
||||
Double sumMoney(@Param("time") String time, @Param("flag") Integer flag);
|
||||
|
||||
|
|
|
|||
|
|
@ -12,7 +12,7 @@ import java.util.List;
|
|||
|
||||
public interface CashOutService {
|
||||
|
||||
PageUtils selectCashOutList(Integer page,Integer limit,CashOut cashOut);
|
||||
PageUtils selectCashOutList(Integer page, Integer limit, CashOut cashOut);
|
||||
|
||||
ExcelData excelPayDetails(CashOut cashOut);
|
||||
|
||||
|
|
@ -43,11 +43,10 @@ public interface CashOutService {
|
|||
Result sysCashMoney(Long userId, Double money);
|
||||
|
||||
/**
|
||||
*
|
||||
* @param userId 用户Id tb_user的id
|
||||
* @param money 提现金额
|
||||
* @param isSys 是否是系统用户提现
|
||||
* @param isSys 是否是系统用户提现
|
||||
*/
|
||||
Result withdraw(Long userId, Double money, boolean isSys);
|
||||
Result withdraw(Long userId, Double money, String msg, boolean isSys);
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -5,6 +5,8 @@ import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
|||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.sqx.common.utils.PageUtils;
|
||||
import com.sqx.common.utils.Result;
|
||||
import com.sqx.modules.app.dao.MsgDao;
|
||||
import com.sqx.modules.app.entity.Msg;
|
||||
import com.sqx.modules.app.entity.UserEntity;
|
||||
import com.sqx.modules.app.entity.UserMoney;
|
||||
import com.sqx.modules.app.entity.UserMoneyDetails;
|
||||
|
|
@ -76,6 +78,8 @@ public class CashOutServiceImpl extends ServiceImpl<CashOutDao, CashOut> impleme
|
|||
private InviteMoneyService inviteMoneyService;
|
||||
@Autowired
|
||||
private SysUserService sysUserService;
|
||||
@Autowired
|
||||
private MsgDao msgDao;
|
||||
|
||||
@Override
|
||||
public PageUtils selectCashOutList(Integer page, Integer limit, CashOut cashOut) {
|
||||
|
|
@ -402,7 +406,7 @@ public class CashOutServiceImpl extends ServiceImpl<CashOutDao, CashOut> impleme
|
|||
|
||||
@Override
|
||||
@Transactional
|
||||
public Result withdraw(Long userId, Double money, boolean isSys) {
|
||||
public Result withdraw(Long userId, Double money, String msg, boolean isSys) {
|
||||
if (money == null || money <= 0.00) {
|
||||
return Result.error("请不要输入小于0的数字,请输入正确的提现金额!");
|
||||
}
|
||||
|
|
@ -412,6 +416,10 @@ public class CashOutServiceImpl extends ServiceImpl<CashOutDao, CashOut> impleme
|
|||
|
||||
if (isSys) {
|
||||
SysUserEntity sysUserEntity = sysUserService.getById(userId);
|
||||
Msg msg1 = msgDao.findByPhoneAndCode(sysUserEntity.getMobile(), msg);
|
||||
if (msg1 == null) {
|
||||
return Result.error("验证码不正确!");
|
||||
}
|
||||
if (StringUtils.isBlank(sysUserEntity.getZhiFuBao()) || StringUtils.isBlank(sysUserEntity.getZhiFuBaoName())) {
|
||||
return Result.error(9999, "请先绑定支付宝账号!");
|
||||
}
|
||||
|
|
|
|||
|
|
@ -8,4 +8,8 @@ public interface RedisService {
|
|||
|
||||
|
||||
void setDiscSpinningAmounts(String key);
|
||||
|
||||
void setPayFreeWatchTime(Long userId, Integer time);
|
||||
|
||||
Boolean getPayFreeWatchTimeIsExpire(Long userId);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,6 +1,9 @@
|
|||
package com.sqx.modules.redisService.impl;
|
||||
|
||||
import cn.hutool.core.date.DateUnit;
|
||||
import cn.hutool.core.date.DateUtil;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.sqx.common.utils.RedisKeys;
|
||||
import com.sqx.common.utils.RedisUtils;
|
||||
import com.sqx.modules.discSpinning.entity.DiscSpinningAmount;
|
||||
import com.sqx.modules.discSpinning.service.DiscSpinningAmountService;
|
||||
|
|
@ -9,7 +12,11 @@ import org.springframework.beans.factory.annotation.Autowired;
|
|||
import org.springframework.context.annotation.Lazy;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
@Service
|
||||
public class RedisServiceImpl implements RedisService {
|
||||
@Lazy
|
||||
|
|
@ -21,6 +28,29 @@ public class RedisServiceImpl implements RedisService {
|
|||
@Override
|
||||
public void setDiscSpinningAmounts(String key) {
|
||||
List<DiscSpinningAmount> amounts = amountService.list(new QueryWrapper<DiscSpinningAmount>().eq("status", 1).orderByAsc("max_amount"));
|
||||
redisUtils.set(key, amounts);
|
||||
Map<Integer, List<DiscSpinningAmount>> map =
|
||||
amounts.stream().collect(Collectors.groupingBy(
|
||||
disc -> disc.getNum() == null ? 0 : disc.getNum()
|
||||
));
|
||||
redisUtils.set(key, map);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setPayFreeWatchTime(Long userId, Integer minute) {
|
||||
Date now = DateUtil.date();
|
||||
Date tomorrow = DateUtil.beginOfDay(DateUtil.offsetDay(now, 1));
|
||||
long seconds = DateUtil.between(now, tomorrow, DateUnit.SECOND);
|
||||
redisUtils.setIfAbsent(RedisKeys.getPayFreeWatchKey(userId), DateUtil.offsetMinute(now, minute).getTime(), seconds);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Boolean getPayFreeWatchTimeIsExpire(Long userId) {
|
||||
String data = redisUtils.get(RedisKeys.getPayFreeWatchKey(userId));
|
||||
if (data == null) {
|
||||
return null;
|
||||
}
|
||||
|
||||
long expireTime = Long.parseLong(data);
|
||||
return DateUtil.current() > expireTime;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,12 +1,21 @@
|
|||
package com.sqx.modules.sys.controller;
|
||||
|
||||
import com.sqx.common.utils.Result;
|
||||
import com.sqx.common.validator.ValidatorUtils;
|
||||
import com.sqx.common.validator.group.AddGroup;
|
||||
import com.sqx.modules.app.dao.MsgDao;
|
||||
import com.sqx.modules.app.entity.Msg;
|
||||
import com.sqx.modules.sys.entity.SysUserEntity;
|
||||
import com.sqx.modules.sys.form.SysLoginForm;
|
||||
import com.sqx.modules.sys.service.SysCaptchaService;
|
||||
import com.sqx.modules.sys.service.SysUserService;
|
||||
import com.sqx.modules.sys.service.SysUserTokenService;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiImplicitParam;
|
||||
import io.swagger.annotations.ApiImplicitParams;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import org.apache.commons.io.IOUtils;
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
import org.apache.shiro.crypto.hash.Sha256Hash;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
|
|
@ -19,80 +28,113 @@ import javax.servlet.ServletOutputStream;
|
|||
import javax.servlet.http.HttpServletResponse;
|
||||
import java.awt.image.BufferedImage;
|
||||
import java.io.IOException;
|
||||
import java.math.BigDecimal;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collections;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* 登录相关
|
||||
*
|
||||
*/
|
||||
@RestController
|
||||
@Api(value = "登录相关", tags = {"登录相关"})
|
||||
public class SysLoginController extends AbstractController {
|
||||
@Autowired
|
||||
private SysUserService sysUserService;
|
||||
@Autowired
|
||||
private SysUserTokenService sysUserTokenService;
|
||||
@Autowired
|
||||
private SysCaptchaService sysCaptchaService;
|
||||
@Autowired
|
||||
private SysUserService sysUserService;
|
||||
@Autowired
|
||||
private SysUserTokenService sysUserTokenService;
|
||||
@Autowired
|
||||
private SysCaptchaService sysCaptchaService;
|
||||
@Autowired
|
||||
private MsgDao msgDao;
|
||||
|
||||
/**
|
||||
* 验证码
|
||||
*/
|
||||
@GetMapping("captcha.jpg")
|
||||
public void captcha(HttpServletResponse response, String uuid)throws IOException {
|
||||
response.setHeader("Cache-Control", "no-store, no-cache");
|
||||
response.setContentType("image/jpeg");
|
||||
/**
|
||||
* 验证码
|
||||
*/
|
||||
@GetMapping("captcha.jpg")
|
||||
public void captcha(HttpServletResponse response, String uuid) throws IOException {
|
||||
response.setHeader("Cache-Control", "no-store, no-cache");
|
||||
response.setContentType("image/jpeg");
|
||||
|
||||
//获取图片验证码
|
||||
BufferedImage image = sysCaptchaService.getCaptcha(uuid);
|
||||
//获取图片验证码
|
||||
BufferedImage image = sysCaptchaService.getCaptcha(uuid);
|
||||
|
||||
ServletOutputStream out = response.getOutputStream();
|
||||
ImageIO.write(image, "jpg", out);
|
||||
IOUtils.closeQuietly(out);
|
||||
}
|
||||
|
||||
/**
|
||||
* 登录
|
||||
*/
|
||||
@PostMapping("/sys/login")
|
||||
public Map<String, Object> login(@RequestBody SysLoginForm form)throws IOException {
|
||||
boolean captcha = sysCaptchaService.validate(form.getUuid(), form.getCaptcha());
|
||||
if(!captcha){
|
||||
return Result.error("验证码不正确");
|
||||
}
|
||||
|
||||
//用户信息
|
||||
SysUserEntity user = sysUserService.queryByUserName(form.getUsername());
|
||||
|
||||
//账号不存在、密码错误
|
||||
if(user == null || !user.getPassword().equals(new Sha256Hash(form.getPassword(), user.getSalt()).toHex())) {
|
||||
return Result.error("账号或密码不正确");
|
||||
}
|
||||
|
||||
//账号锁定
|
||||
if(user.getStatus() == 0){
|
||||
return Result.error("账号已被锁定,请联系管理员");
|
||||
}
|
||||
|
||||
//判断角色类型
|
||||
if(form.getAdminType()==1 && user.getIsChannel()!=null && user.getIsChannel()==1){
|
||||
return Result.error("代理账号请登录代理端!");
|
||||
}else if(form.getAdminType()==2 && user.getIsChannel()==null){
|
||||
return Result.error("管理员请登录管理端!");
|
||||
}
|
||||
|
||||
//生成token,并保存到数据库
|
||||
Result r = sysUserTokenService.createToken(user.getUserId());
|
||||
return r;
|
||||
}
|
||||
ServletOutputStream out = response.getOutputStream();
|
||||
ImageIO.write(image, "jpg", out);
|
||||
IOUtils.closeQuietly(out);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 退出
|
||||
*/
|
||||
@PostMapping("/sys/logout")
|
||||
public Result logout() {
|
||||
sysUserTokenService.logout(getUserId());
|
||||
return Result.success();
|
||||
}
|
||||
|
||||
@PostMapping("/sys/registered")
|
||||
@ApiOperation("代理注册")
|
||||
@ApiImplicitParams({
|
||||
@ApiImplicitParam(name = "msg", value = "验证码", dataTypeClass = String.class, paramType = "param"),
|
||||
})
|
||||
public Result registered(@RequestBody SysUserEntity user, String msg) {
|
||||
if(StringUtils.isBlank(user.getMobile())){
|
||||
return Result.error("注册失败,请输入手机号");
|
||||
}
|
||||
if(StringUtils.isBlank(msg)){
|
||||
return Result.error("注册失败,请输入验证码");
|
||||
}
|
||||
Msg msg1 = msgDao.findByPhoneAndCode(user.getMobile(), msg);
|
||||
if (msg1 == null) {
|
||||
return Result.error("验证码不正确!");
|
||||
}
|
||||
user.setIsChannel(1);
|
||||
user.setQdRate(new BigDecimal("0.01"));
|
||||
user.setStatus(1);
|
||||
user.setRoleIdList(Collections.singletonList(4L));
|
||||
ValidatorUtils.validateEntity(user, AddGroup.class);
|
||||
sysUserService.saveUser(user);
|
||||
return Result.success();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 登录
|
||||
*/
|
||||
@PostMapping("/sys/login")
|
||||
public Map<String, Object> login(@RequestBody SysLoginForm form) throws IOException {
|
||||
boolean captcha = sysCaptchaService.validate(form.getUuid(), form.getCaptcha());
|
||||
if (!captcha) {
|
||||
return Result.error("验证码不正确");
|
||||
}
|
||||
|
||||
//用户信息
|
||||
SysUserEntity user = sysUserService.queryByUserName(form.getUsername());
|
||||
|
||||
//账号不存在、密码错误
|
||||
if (user == null || !user.getPassword().equals(new Sha256Hash(form.getPassword(), user.getSalt()).toHex())) {
|
||||
return Result.error("账号或密码不正确");
|
||||
}
|
||||
|
||||
//账号锁定
|
||||
if (user.getStatus() == 0) {
|
||||
return Result.error("账号已被锁定,请联系管理员");
|
||||
}
|
||||
|
||||
//判断角色类型
|
||||
if (form.getAdminType() == 1 && user.getIsChannel() != null && user.getIsChannel() == 1) {
|
||||
return Result.error("代理账号请登录代理端!");
|
||||
} else if (form.getAdminType() == 2 && user.getIsChannel() == null) {
|
||||
return Result.error("管理员请登录管理端!");
|
||||
}
|
||||
|
||||
//生成token,并保存到数据库
|
||||
Result r = sysUserTokenService.createToken(user.getUserId());
|
||||
return r;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 退出
|
||||
*/
|
||||
@PostMapping("/sys/logout")
|
||||
public Result logout() {
|
||||
sysUserTokenService.logout(getUserId());
|
||||
return Result.success();
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -10,6 +10,7 @@ import com.sqx.modules.sys.entity.SysUserEntity;
|
|||
import com.sqx.modules.sys.service.SysRoleService;
|
||||
import com.sqx.modules.sys.service.SysUserRoleService;
|
||||
import com.sqx.modules.sys.service.SysUserService;
|
||||
import com.sqx.modules.utils.InvitationCodeUtil;
|
||||
import org.apache.commons.lang.RandomStringUtils;
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
import org.apache.shiro.crypto.hash.Sha256Hash;
|
||||
|
|
@ -25,103 +26,105 @@ import java.util.Map;
|
|||
|
||||
/**
|
||||
* 系统用户
|
||||
*
|
||||
*/
|
||||
@SuppressWarnings("ALL")
|
||||
@Service("sysUserService")
|
||||
public class SysUserServiceImpl extends ServiceImpl<SysUserDao, SysUserEntity> implements SysUserService {
|
||||
@Autowired
|
||||
private SysUserRoleService sysUserRoleService;
|
||||
@Autowired
|
||||
private SysRoleService sysRoleService;
|
||||
@Autowired
|
||||
private SysUserRoleService sysUserRoleService;
|
||||
@Autowired
|
||||
private SysRoleService sysRoleService;
|
||||
|
||||
@Override
|
||||
public PageUtils queryPage(Map<String, Object> params) {
|
||||
String username = (String)params.get("username");
|
||||
Long createUserId = (Long)params.get("createUserId");
|
||||
Object isChannel = params.get("isChannel");
|
||||
Object sysUserId = params.get("sysUserId");
|
||||
IPage<SysUserEntity> page = this.page(
|
||||
new Query<SysUserEntity>().getPage(params),
|
||||
new QueryWrapper<SysUserEntity>()
|
||||
.like(StringUtils.isNotBlank(username),"username", username)
|
||||
.eq(createUserId != null,"create_user_id", createUserId)
|
||||
.eq(isChannel!=null,"is_channel",isChannel)
|
||||
.eq(sysUserId!=null,"sys_user_id",sysUserId)
|
||||
.isNull(sysUserId==null,"sys_user_id")
|
||||
.isNull(isChannel==null,"is_channel")
|
||||
);
|
||||
@Override
|
||||
public PageUtils queryPage(Map<String, Object> params) {
|
||||
String username = (String) params.get("username");
|
||||
Long createUserId = (Long) params.get("createUserId");
|
||||
Object isChannel = params.get("isChannel");
|
||||
Object sysUserId = params.get("sysUserId");
|
||||
IPage<SysUserEntity> page = this.page(
|
||||
new Query<SysUserEntity>().getPage(params),
|
||||
new QueryWrapper<SysUserEntity>()
|
||||
.like(StringUtils.isNotBlank(username), "username", username)
|
||||
.eq(createUserId != null, "create_user_id", createUserId)
|
||||
.eq(isChannel != null, "is_channel", isChannel)
|
||||
.eq(sysUserId != null, "sys_user_id", sysUserId)
|
||||
.isNull(sysUserId == null, "sys_user_id")
|
||||
.isNull(isChannel == null, "is_channel")
|
||||
);
|
||||
|
||||
return new PageUtils(page);
|
||||
}
|
||||
return new PageUtils(page);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> queryAllPerms(Long userId) {
|
||||
return baseMapper.queryAllPerms(userId);
|
||||
}
|
||||
@Override
|
||||
public List<String> queryAllPerms(Long userId) {
|
||||
return baseMapper.queryAllPerms(userId);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<Long> queryAllMenuId(Long userId) {
|
||||
return baseMapper.queryAllMenuId(userId);
|
||||
}
|
||||
@Override
|
||||
public List<Long> queryAllMenuId(Long userId) {
|
||||
return baseMapper.queryAllMenuId(userId);
|
||||
}
|
||||
|
||||
@Override
|
||||
public SysUserEntity queryByUserName(String username) {
|
||||
return baseMapper.queryByUserName(username);
|
||||
}
|
||||
@Override
|
||||
public SysUserEntity queryByUserName(String username) {
|
||||
return baseMapper.queryByUserName(username);
|
||||
}
|
||||
|
||||
@SuppressWarnings("AlibabaTransactionMustHaveRollback")
|
||||
@Override
|
||||
@Transactional
|
||||
public void saveUser(SysUserEntity user) {
|
||||
user.setCreateTime(new Date());
|
||||
//sha256加密
|
||||
String salt = RandomStringUtils.randomAlphanumeric(20);
|
||||
user.setPassword(new Sha256Hash(user.getPassword(), salt).toHex());
|
||||
user.setSalt(salt);
|
||||
this.save(user);
|
||||
|
||||
//检查角色是否越权
|
||||
checkRole(user);
|
||||
|
||||
//保存用户与角色关系
|
||||
sysUserRoleService.saveOrUpdate(user.getUserId(), user.getRoleIdList());
|
||||
}
|
||||
@SuppressWarnings("AlibabaTransactionMustHaveRollback")
|
||||
@Override
|
||||
@Transactional
|
||||
public void saveUser(SysUserEntity user) {
|
||||
user.setCreateTime(new Date());
|
||||
//sha256加密
|
||||
String salt = RandomStringUtils.randomAlphanumeric(20);
|
||||
user.setPassword(new Sha256Hash(user.getPassword(), salt).toHex());
|
||||
user.setSalt(salt);
|
||||
this.save(user);
|
||||
if (user.getIsChannel() != null && user.getIsChannel().equals(1) && StringUtils.isBlank(user.getQdCode())) {
|
||||
user.setQdCode(InvitationCodeUtil.toRegisteredCode(user.getUserId()));
|
||||
this.updateById(user);
|
||||
}
|
||||
//检查角色是否越权
|
||||
checkRole(user);
|
||||
|
||||
@Override
|
||||
@Transactional
|
||||
public void update(SysUserEntity user) {
|
||||
if(StringUtils.isBlank(user.getPassword())){
|
||||
user.setPassword(null);
|
||||
}else{
|
||||
user.setPassword(new Sha256Hash(user.getPassword(), user.getSalt()).toHex());
|
||||
}
|
||||
this.updateById(user);
|
||||
|
||||
//检查角色是否越权
|
||||
checkRole(user);
|
||||
|
||||
//保存用户与角色关系
|
||||
sysUserRoleService.saveOrUpdate(user.getUserId(), user.getRoleIdList());
|
||||
}
|
||||
//保存用户与角色关系
|
||||
sysUserRoleService.saveOrUpdate(user.getUserId(), user.getRoleIdList());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void deleteBatch(Long[] userId) {
|
||||
this.removeByIds(Arrays.asList(userId));
|
||||
}
|
||||
@Override
|
||||
@Transactional
|
||||
public void update(SysUserEntity user) {
|
||||
if (StringUtils.isBlank(user.getPassword())) {
|
||||
user.setPassword(null);
|
||||
} else {
|
||||
user.setPassword(new Sha256Hash(user.getPassword(), user.getSalt()).toHex());
|
||||
}
|
||||
this.updateById(user);
|
||||
|
||||
@Override
|
||||
public boolean updatePassword(Long userId, String password, String newPassword) {
|
||||
SysUserEntity userEntity = new SysUserEntity();
|
||||
userEntity.setPassword(newPassword);
|
||||
return this.update(userEntity,
|
||||
new QueryWrapper<SysUserEntity>().eq("user_id", userId).eq("password", password));
|
||||
}
|
||||
|
||||
/**
|
||||
* 检查角色是否越权
|
||||
*/
|
||||
private void checkRole(SysUserEntity user){
|
||||
//检查角色是否越权
|
||||
checkRole(user);
|
||||
|
||||
//保存用户与角色关系
|
||||
sysUserRoleService.saveOrUpdate(user.getUserId(), user.getRoleIdList());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void deleteBatch(Long[] userId) {
|
||||
this.removeByIds(Arrays.asList(userId));
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean updatePassword(Long userId, String password, String newPassword) {
|
||||
SysUserEntity userEntity = new SysUserEntity();
|
||||
userEntity.setPassword(newPassword);
|
||||
return this.update(userEntity,
|
||||
new QueryWrapper<SysUserEntity>().eq("user_id", userId).eq("password", password));
|
||||
}
|
||||
|
||||
/**
|
||||
* 检查角色是否越权
|
||||
*/
|
||||
private void checkRole(SysUserEntity user) {
|
||||
/*if(user.getRoleIdList() == null || user.getRoleIdList().size() == 0){
|
||||
return;
|
||||
}
|
||||
|
|
@ -137,11 +140,11 @@ public class SysUserServiceImpl extends ServiceImpl<SysUserDao, SysUserEntity> i
|
|||
if(!roleIdList.containsAll(user.getRoleIdList())){
|
||||
throw new SqxException("新增用户所选角色,不是本人创建");
|
||||
}*/
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public SysUserEntity selectSysUserByQdCode(String qdCode){
|
||||
return baseMapper.selectOne(new QueryWrapper<SysUserEntity>().isNull("sys_user_id").eq("qd_code", qdCode));
|
||||
}
|
||||
@Override
|
||||
public SysUserEntity selectSysUserByQdCode(String qdCode) {
|
||||
return baseMapper.selectOne(new QueryWrapper<SysUserEntity>().isNull("sys_user_id").eq("qd_code", qdCode));
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -10,6 +10,6 @@ import java.util.List;
|
|||
public interface TaskCenterDao extends BaseMapper<TaskCenter> {
|
||||
|
||||
//大转盘任务
|
||||
List<TaskCenter> queryTaskDiscCenter(Long userId);
|
||||
List<TaskCenter> queryTaskDiscCenter();
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1,15 +1,10 @@
|
|||
package com.sqx.modules.taskCenter.entity;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.TableField;
|
||||
import com.baomidou.mybatisplus.extension.activerecord.Model;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import com.baomidou.mybatisplus.extension.activerecord.Model;
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
/**
|
||||
|
|
@ -46,6 +41,10 @@ public class TaskCenter extends Model<TaskCenter> {
|
|||
private Integer jumpType;
|
||||
@ApiModelProperty("按钮跳转地址")
|
||||
private String buttonUrl;
|
||||
@ApiModelProperty("按钮下方内容")
|
||||
private String buttonUnderContent;
|
||||
@ApiModelProperty("按钮下方内容 跳转路径")
|
||||
private String buttonUnderUrl;
|
||||
private String createTime;
|
||||
private String updateTime;
|
||||
@ApiModelProperty("排序")
|
||||
|
|
|
|||
|
|
@ -12,6 +12,6 @@ public interface TaskCenterService extends IService<TaskCenter> {
|
|||
|
||||
Result taskReceive(Long userId, Long id);
|
||||
|
||||
int countTaskDisc(Long userId);
|
||||
int countTaskDisc(Long userId,String type);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -19,6 +19,7 @@ import com.sqx.modules.taskCenter.service.TaskCenterRewardService;
|
|||
import com.sqx.modules.taskCenter.service.TaskCenterService;
|
||||
import com.sqx.modules.userSign.entity.UserSignRecord;
|
||||
import com.sqx.modules.userSign.service.UserSignRecordService;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
|
@ -70,7 +71,7 @@ public class TaskCenterServiceImpl extends ServiceImpl<TaskCenterDao, TaskCenter
|
|||
} else if (recordService.countTaskNum(userId, s.getId(), DateUtil.today() + " 00:00:00") > 0) {
|
||||
s.setButtonTitle("已领取");
|
||||
s.setNumber(null);
|
||||
s.setDisabled(false);
|
||||
// s.setDisabled(false);
|
||||
} else {
|
||||
s.setDiscNumber(0);
|
||||
s.setNumber(null);
|
||||
|
|
@ -79,7 +80,7 @@ public class TaskCenterServiceImpl extends ServiceImpl<TaskCenterDao, TaskCenter
|
|||
} else {
|
||||
if (todaySign) {
|
||||
if ((signCount < (s.getNumber().intValue() - 1))) {
|
||||
s.setDiscNumber(s.getNumber() - signCount);
|
||||
s.setDiscNumber(signCount);
|
||||
s.setNumber(null);
|
||||
s.setDisabled(false);
|
||||
} else if (recordService.countTaskNum(userId, s.getId(), DateUtil.beginOfMonth(new Date()).toString()) > 0) {
|
||||
|
|
@ -89,7 +90,7 @@ public class TaskCenterServiceImpl extends ServiceImpl<TaskCenterDao, TaskCenter
|
|||
}
|
||||
} else {
|
||||
if ((signCount < s.getNumber().intValue())) {
|
||||
s.setDiscNumber(s.getNumber() - signCount);
|
||||
s.setDiscNumber(signCount);
|
||||
s.setDisabled(false);
|
||||
s.setNumber(null);
|
||||
} else if (recordService.countTaskNum(userId, s.getId(), DateUtil.beginOfMonth(new Date()).toString()) > 0) {
|
||||
|
|
@ -226,7 +227,10 @@ public class TaskCenterServiceImpl extends ServiceImpl<TaskCenterDao, TaskCenter
|
|||
}
|
||||
|
||||
@Override
|
||||
public int countTaskDisc(Long userId) {
|
||||
public int countTaskDisc(Long userId, String type) {
|
||||
if (StringUtils.isBlank(type) || "1".equals(type)) {
|
||||
return 0;
|
||||
}
|
||||
//月 签到记录
|
||||
QueryWrapper<UserSignRecord> signWrapper = new QueryWrapper<>();
|
||||
signWrapper.eq("user_id", userId);
|
||||
|
|
@ -235,7 +239,7 @@ public class TaskCenterServiceImpl extends ServiceImpl<TaskCenterDao, TaskCenter
|
|||
int signCount = signRecordService.count(signWrapper);
|
||||
|
||||
//TaskCenter的number为大转盘次数
|
||||
List<TaskCenter> taskCenters = baseMapper.queryTaskDiscCenter(userId);
|
||||
List<TaskCenter> taskCenters = baseMapper.queryTaskDiscCenter();
|
||||
int countTaskDisc = 0;
|
||||
Integer dayOrderNum = ordersService.countOrderNum(userId, DateUtil.today() + " 00:00:00");
|
||||
for (TaskCenter taskCenter : taskCenters) {
|
||||
|
|
@ -245,16 +249,27 @@ public class TaskCenterServiceImpl extends ServiceImpl<TaskCenterDao, TaskCenter
|
|||
countTaskDisc = countTaskDisc + taskCenter.getDiscNumber();
|
||||
}
|
||||
} else {
|
||||
if (dayOrderNum > 2) {
|
||||
if (signCount - taskCenter.getNumber().intValue() >= -1 && recordService.countTaskNum(userId, taskCenter.getId(), DateUtil.beginOfMonth(new Date()).toString()) < 1) {
|
||||
countTaskDisc = countTaskDisc + taskCenter.getDiscNumber();
|
||||
if ("2".equals(type) && taskCenter.getNumber().intValue() > 1 && taskCenter.getNumber().intValue() < 8) {
|
||||
if (dayOrderNum > 2) {
|
||||
if (signCount - taskCenter.getNumber().intValue() >= -1 && recordService.countTaskNum(userId, taskCenter.getId(), DateUtil.beginOfMonth(new Date()).toString()) < 1) {
|
||||
countTaskDisc = countTaskDisc + taskCenter.getDiscNumber();
|
||||
}
|
||||
} else {
|
||||
if (signCount - taskCenter.getNumber().intValue() >= 0 && recordService.countTaskNum(userId, taskCenter.getId(), DateUtil.beginOfMonth(new Date()).toString()) < 1) {
|
||||
countTaskDisc = countTaskDisc + taskCenter.getDiscNumber();
|
||||
}
|
||||
}
|
||||
} else {
|
||||
if (signCount - taskCenter.getNumber().intValue() >= 0 && recordService.countTaskNum(userId, taskCenter.getId(), DateUtil.beginOfMonth(new Date()).toString()) < 1) {
|
||||
countTaskDisc = countTaskDisc + taskCenter.getDiscNumber();
|
||||
} else if ("3".equals(type) && taskCenter.getNumber().intValue() > 7 && taskCenter.getNumber().intValue() < 32) {
|
||||
if (dayOrderNum > 2) {
|
||||
if (signCount - taskCenter.getNumber().intValue() >= -1 && recordService.countTaskNum(userId, taskCenter.getId(), DateUtil.beginOfMonth(new Date()).toString()) < 1) {
|
||||
countTaskDisc = countTaskDisc + taskCenter.getDiscNumber();
|
||||
}
|
||||
} else {
|
||||
if (signCount - taskCenter.getNumber().intValue() >= 0 && recordService.countTaskNum(userId, taskCenter.getId(), DateUtil.beginOfMonth(new Date()).toString()) < 1) {
|
||||
countTaskDisc = countTaskDisc + taskCenter.getDiscNumber();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,35 +1,46 @@
|
|||
package com.sqx.modules.userSign.controller;
|
||||
|
||||
|
||||
import com.sqx.modules.userSign.entity.UserSignRecord;
|
||||
import com.sqx.modules.userSign.service.UserSignRecordService;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.sqx.common.utils.DateUtils;
|
||||
import com.sqx.common.utils.Result;
|
||||
import com.sqx.modules.sys.controller.AbstractController;
|
||||
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.*;
|
||||
|
||||
import java.util.Date;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
@Slf4j
|
||||
@RestController
|
||||
@Api(value = "用户签到", tags = {"用户签到"})
|
||||
@RequestMapping(value = "/userSignRecord")
|
||||
public class UserSignRecordController {
|
||||
public class UserSignRecordController extends AbstractController {
|
||||
/**
|
||||
* 服务对象
|
||||
*/
|
||||
@Autowired
|
||||
private UserSignRecordService userSignRecordService;
|
||||
|
||||
// @GetMapping("/selectUserSignRecord")
|
||||
// @ApiOperation("查询用户签到表")
|
||||
// public Result selectUserSignRecord(Integer page, Integer limit,@RequestAttribute("userId") Long userId) {
|
||||
// return Result.success().put("data", userSignRecordService.page(new Page<>(page, limit), new QueryWrapper<UserSignRecord>().orderByAsc("create_time")));
|
||||
// }
|
||||
/**
|
||||
* 获取用户连续签到数据
|
||||
*/
|
||||
@GetMapping("/getUserSignData")
|
||||
@ApiOperation("获取用户连续签到数据")
|
||||
public Result getUserSignData() {
|
||||
//UserSignDTO data = userSignRecordService.getUserSignData();
|
||||
return Result.success().put("data", null);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取连续签到奖励配置
|
||||
*/
|
||||
@GetMapping("/getUserSignAwardConfig")
|
||||
@ApiOperation(value = "获取连续签到奖励配置", notes = "如:[7,7] = 连续签到7天奖励7元")
|
||||
public Result getUserSignAwardConfig() {
|
||||
String[] data = userSignRecordService.getUserSignAwardConfig();
|
||||
return Result.success().put("data", data);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -0,0 +1,38 @@
|
|||
package com.sqx.modules.userSign.dto;
|
||||
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 用户签到数据
|
||||
*
|
||||
* @author tankaikai
|
||||
* @since 2024-12-18 17:34
|
||||
*/
|
||||
@Data
|
||||
@ApiModel(value = "用户签到数据")
|
||||
public class UserSignDTO implements Serializable {
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
@ApiModelProperty(value = "用户id")
|
||||
private Long userId;
|
||||
|
||||
@ApiModelProperty(value = "用户名")
|
||||
private String username;
|
||||
|
||||
@ApiModelProperty(value = "手机号")
|
||||
private String mobile;
|
||||
|
||||
@ApiModelProperty(value = "连续签到天数")
|
||||
private Integer signDays;
|
||||
|
||||
@ApiModelProperty(value = "该用户能否参加签到活动", example = "1-允许,0-不允许")
|
||||
private Integer enable;
|
||||
|
||||
@ApiModelProperty(value = "连续签到记录")
|
||||
private List<UserSignRecordDTO> recordList;
|
||||
}
|
||||
|
|
@ -0,0 +1,32 @@
|
|||
package com.sqx.modules.userSign.dto;
|
||||
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
/**
|
||||
* 用户连续签到记录
|
||||
*
|
||||
* @author tankaikai
|
||||
* @since 2024-12-18 17:34
|
||||
*/
|
||||
@Data
|
||||
@ApiModel(value = "用户连续签到记录")
|
||||
public class UserSignRecordDTO implements Serializable {
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
@ApiModelProperty(value = "签到日期", required = true, example = "2024-12-18")
|
||||
private String signDay;
|
||||
|
||||
@ApiModelProperty(value = "签到状态", required = true, example = "0-未签到, 1-已签到")
|
||||
private String status;
|
||||
|
||||
@ApiModelProperty(value = "展示文本", required = true, example = "未签到, 待签到, 已签到, 第x天")
|
||||
private String showText;
|
||||
|
||||
@ApiModelProperty(value = "签到时间", example = "2024-12-18 17:34:00")
|
||||
private String signDate;
|
||||
|
||||
}
|
||||
|
|
@ -1,11 +1,14 @@
|
|||
package com.sqx.modules.userSign.service;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
import com.sqx.modules.userSign.dto.UserSignDTO;
|
||||
import com.sqx.modules.userSign.entity.UserSignRecord;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
public interface UserSignRecordService extends IService<UserSignRecord> {
|
||||
|
||||
UserSignDTO getUserSignData(long userId);
|
||||
|
||||
String[] getUserSignAwardConfig();
|
||||
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1,14 +1,145 @@
|
|||
package com.sqx.modules.userSign.service.impl;
|
||||
|
||||
import cn.hutool.core.collection.CollUtil;
|
||||
import cn.hutool.core.convert.Convert;
|
||||
import cn.hutool.core.date.DateUtil;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.sqx.common.exception.SqxException;
|
||||
import com.sqx.modules.app.dao.UserDao;
|
||||
import com.sqx.modules.app.entity.UserEntity;
|
||||
import com.sqx.modules.common.dao.CommonInfoDao;
|
||||
import com.sqx.modules.common.entity.CommonInfo;
|
||||
import com.sqx.modules.userSign.dao.UserSignRecordDao;
|
||||
import com.sqx.modules.userSign.dto.UserSignDTO;
|
||||
import com.sqx.modules.userSign.dto.UserSignRecordDTO;
|
||||
import com.sqx.modules.userSign.entity.UserSignRecord;
|
||||
import com.sqx.modules.userSign.service.UserSignRecordService;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.time.LocalDate;
|
||||
import java.time.format.DateTimeFormatter;
|
||||
import java.time.temporal.ChronoUnit;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
@Service
|
||||
public class UserSignRecordServiceImpl extends ServiceImpl<UserSignRecordDao, UserSignRecord> implements UserSignRecordService {
|
||||
|
||||
|
||||
@Autowired
|
||||
private CommonInfoDao commonInfoDao;
|
||||
|
||||
@Autowired
|
||||
private UserDao userDao;
|
||||
|
||||
@Override
|
||||
public UserSignDTO getUserSignData(long userId) {
|
||||
UserEntity currentUser = userDao.selectById(userId);
|
||||
UserSignDTO dto = new UserSignDTO();
|
||||
dto.setUserId(currentUser.getUserId());
|
||||
dto.setUsername(currentUser.getUserName());
|
||||
dto.setMobile(currentUser.getPhone());
|
||||
dto.setSignDays(0);
|
||||
dto.setEnable(1);
|
||||
CommonInfo config = commonInfoDao.findOne(918);
|
||||
if (config == null) {
|
||||
throw new SqxException("签到活动配置不存在");
|
||||
}
|
||||
// 活动天数
|
||||
int activeDays = Convert.toInt(config.getValue().split(",")[0]);
|
||||
// 当前日期
|
||||
LocalDate beginDay = LocalDate.now();
|
||||
// 签到记录
|
||||
List<UserSignRecordDTO> recordList = new ArrayList<>();
|
||||
// 连续签到日期
|
||||
List<String> flowDays = buildFlowDays(beginDay, activeDays);
|
||||
// 实际签到记录
|
||||
List<UserSignRecord> list = baseMapper.selectList(Wrappers.<UserSignRecord>lambdaQuery().eq(UserSignRecord::getUserId, currentUser.getUserId()).orderByAsc(UserSignRecord::getCreateTime));
|
||||
// 第x天
|
||||
int index = 1;
|
||||
// 连续签到天数
|
||||
int signDays = 0;
|
||||
if (CollUtil.isEmpty(list)) {
|
||||
for (String day : flowDays) {
|
||||
UserSignRecordDTO record = new UserSignRecordDTO();
|
||||
record.setSignDay(day);
|
||||
record.setStatus("0");
|
||||
record.setShowText(StrUtil.format("第{}天", index));
|
||||
record.setSignDate("");
|
||||
recordList.add(record);
|
||||
index++;
|
||||
}
|
||||
dto.setRecordList(recordList);
|
||||
dto.setSignDays(signDays);
|
||||
return dto;
|
||||
}
|
||||
String beginSignDay = list.stream().findFirst().get().getSignDay();
|
||||
flowDays = buildFlowDays(LocalDate.parse(beginSignDay, DateTimeFormatter.ofPattern("yyyy-MM-dd")), activeDays);
|
||||
index = 1;
|
||||
Map<String, Date> signMap = list.stream().collect(Collectors.toMap(UserSignRecord::getSignDay, UserSignRecord::getCreateTime));
|
||||
for (String day : flowDays) {
|
||||
Date date = signMap.get(day);
|
||||
UserSignRecordDTO record = new UserSignRecordDTO();
|
||||
if (date != null) {
|
||||
String signDay = DateUtil.formatDateTime(signMap.get(day));
|
||||
record.setSignDay(day);
|
||||
record.setStatus("1");
|
||||
record.setSignDate(signDay);
|
||||
record.setShowText("已签到");
|
||||
signDays++;
|
||||
} else {
|
||||
record.setSignDay(day);
|
||||
record.setStatus("0");
|
||||
record.setSignDate("");
|
||||
LocalDate thisDay = LocalDate.parse(day);
|
||||
LocalDate currentDay = LocalDate.now();
|
||||
long daysBetween = ChronoUnit.DAYS.between(thisDay, currentDay);
|
||||
if (daysBetween > 0) {
|
||||
signDays = 0;
|
||||
record.setShowText("未签到");
|
||||
} else if (daysBetween == 0) {
|
||||
record.setShowText("待签到");
|
||||
} else {
|
||||
record.setShowText(StrUtil.format("第{}天", index));
|
||||
}
|
||||
}
|
||||
recordList.add(record);
|
||||
index++;
|
||||
}
|
||||
dto.setRecordList(recordList);
|
||||
dto.setSignDays(signDays);
|
||||
// 该用户是否可以继续签到
|
||||
UserSignRecordDTO last = recordList.get(recordList.size() - 1);
|
||||
LocalDate lastDay = LocalDate.parse(last.getSignDay());
|
||||
LocalDate currentDay = LocalDate.now();
|
||||
long daysBetween = ChronoUnit.DAYS.between(currentDay, lastDay);
|
||||
if (daysBetween < 0 || "1".equals(last.getStatus())) {
|
||||
dto.setEnable(0);
|
||||
}
|
||||
return dto;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String[] getUserSignAwardConfig() {
|
||||
CommonInfo config = commonInfoDao.findOne(918);
|
||||
if (config == null) {
|
||||
throw new SqxException("签到活动配置不存在");
|
||||
}
|
||||
return config.getValue().split(",");
|
||||
}
|
||||
|
||||
private List<String> buildFlowDays(LocalDate beginDay, int activeDays) {
|
||||
List<String> flowDays = new ArrayList<>();
|
||||
for (int i = 0; i < activeDays; i++) {
|
||||
flowDays.add(beginDay.plusDays(i).format(DateTimeFormatter.ofPattern("yyyy-MM-dd")));
|
||||
}
|
||||
return flowDays;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -2,85 +2,125 @@ package com.sqx.modules.utils;
|
|||
|
||||
/**
|
||||
* 邀请码生成解密工具类
|
||||
*
|
||||
* @author fang
|
||||
* @date 2020/7/8
|
||||
*/
|
||||
public class InvitationCodeUtil {
|
||||
|
||||
|
||||
/** 自定义进制(选择你想要的进制数,不能重复且最好不要0、1这些容易混淆的字符) */
|
||||
private static final char[] r=new char[]{ 'M', 'J', 'U', 'D', 'Z', 'X', '9', 'C', '7', 'P','E', '8', '6', 'B', 'G', 'H', 'S', '2', '5', 'F', 'R', '4','Q', 'W', 'K', '3', 'V', 'Y', 'T', 'N'};
|
||||
/**
|
||||
* 自定义进制(选择你想要的进制数,不能重复且最好不要0、1这些容易混淆的字符)
|
||||
*/
|
||||
private static final char[] r = new char[]{'M', 'J', 'U', 'D', 'Z', 'X', '9', 'C', '7', 'P', 'E', '8', '6', 'B', 'G', 'H', 'S', '2', '5', 'F', 'R', '4', 'Q', 'W', 'K', '3', 'V', 'Y', 'T', 'N'};
|
||||
|
||||
/** 定义一个字符用来补全邀请码长度(该字符前面是计算出来的邀请码,后面是用来补全用的) */
|
||||
private static final char b='A';
|
||||
/**
|
||||
* 定义一个字符用来补全邀请码长度(该字符前面是计算出来的邀请码,后面是用来补全用的)
|
||||
*/
|
||||
private static final char b = 'A';
|
||||
|
||||
/** 进制长度 */
|
||||
private static final int binLen=r.length;
|
||||
/**
|
||||
* 进制长度
|
||||
*/
|
||||
private static final int binLen = r.length;
|
||||
|
||||
/** 邀请码长度 */
|
||||
private static final int s=6;
|
||||
/**
|
||||
* 邀请码长度
|
||||
*/
|
||||
private static final int s = 6;
|
||||
|
||||
|
||||
/** 补位字符串 */
|
||||
private static final String e="KSLFXFR";
|
||||
/**
|
||||
* 补位字符串
|
||||
*/
|
||||
private static final String e = "KSLFXFR";
|
||||
|
||||
/**
|
||||
* 代理注册 补位字符串
|
||||
*/
|
||||
private static final String re = "REGISTER";
|
||||
|
||||
/**
|
||||
* 根据ID生成六位随机码
|
||||
*
|
||||
* @param id ID
|
||||
* @return 随机码
|
||||
*/
|
||||
public static String toRegisteredCode(long id) {
|
||||
char[] buf = new char[32];
|
||||
int charPos = 32;
|
||||
|
||||
while ((id / binLen) > 0) {
|
||||
int ind = (int) (id % binLen);
|
||||
buf[--charPos] = r[ind];
|
||||
id /= binLen;
|
||||
}
|
||||
buf[--charPos] = r[(int) (id % binLen)];
|
||||
String str = new String(buf, charPos, (32 - charPos));
|
||||
// 不够长度的自动补全
|
||||
if (str.length() < s) {
|
||||
StringBuilder sb = new StringBuilder();
|
||||
sb.append(re.subSequence(0, s - str.length()));
|
||||
str += sb.toString();
|
||||
}
|
||||
return str;
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据ID生成六位随机码
|
||||
*
|
||||
* @param id ID
|
||||
* @return 随机码
|
||||
*/
|
||||
public static String toSerialCode(long id) {
|
||||
char[] buf=new char[32];
|
||||
int charPos=32;
|
||||
char[] buf = new char[32];
|
||||
int charPos = 32;
|
||||
|
||||
while((id / binLen) > 0) {
|
||||
int ind=(int)(id % binLen);
|
||||
buf[--charPos]=r[ind];
|
||||
while ((id / binLen) > 0) {
|
||||
int ind = (int) (id % binLen);
|
||||
buf[--charPos] = r[ind];
|
||||
id /= binLen;
|
||||
}
|
||||
buf[--charPos]=r[(int)(id % binLen)];
|
||||
String str=new String(buf, charPos, (32 - charPos));
|
||||
buf[--charPos] = r[(int) (id % binLen)];
|
||||
String str = new String(buf, charPos, (32 - charPos));
|
||||
// 不够长度的自动补全
|
||||
if(str.length() < s) {
|
||||
StringBuilder sb=new StringBuilder();
|
||||
sb.append(e.subSequence(0, s-str.length()));
|
||||
str+=sb.toString();
|
||||
if (str.length() < s) {
|
||||
StringBuilder sb = new StringBuilder();
|
||||
sb.append(e.subSequence(0, s - str.length()));
|
||||
str += sb.toString();
|
||||
}
|
||||
return str;
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据随机码生成ID
|
||||
*
|
||||
* @param code 随机码
|
||||
* @return ID
|
||||
*/
|
||||
public static long codeToId(String code) {
|
||||
char[] chs;
|
||||
chs = code.toCharArray();
|
||||
long res=0L;
|
||||
for(int i=0; i < chs.length; i++) {
|
||||
int ind=0;
|
||||
for(int j=0; j < binLen; j++) {
|
||||
if(chs[i] == r[j]) {
|
||||
ind=j;
|
||||
long res = 0L;
|
||||
for (int i = 0; i < chs.length; i++) {
|
||||
int ind = 0;
|
||||
for (int j = 0; j < binLen; j++) {
|
||||
if (chs[i] == r[j]) {
|
||||
ind = j;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if(chs[i] == b) {
|
||||
if (chs[i] == b) {
|
||||
break;
|
||||
}
|
||||
if(i > 0) {
|
||||
res=res * binLen + ind;
|
||||
if (i > 0) {
|
||||
res = res * binLen + ind;
|
||||
} else {
|
||||
res=ind;
|
||||
res = ind;
|
||||
}
|
||||
}
|
||||
return res;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
|
@ -319,4 +319,12 @@
|
|||
and create_time > #{time}
|
||||
</if>
|
||||
</select>
|
||||
<select id="countPayOrderByDay" resultType="java.lang.Integer">
|
||||
SELECT count(*)
|
||||
FROM orders
|
||||
WHERE orders.user_id = #{userId}
|
||||
AND orders.`status` = 1
|
||||
AND orders.`pay_way` = 9
|
||||
AND orders.create_time > DATE_FORMAT(CURDATE(), '%Y-%m-%d 00:00:00')
|
||||
</select>
|
||||
</mapper>
|
||||
|
|
|
|||
|
|
@ -19,6 +19,10 @@
|
|||
select sum(money) from cash_out where state in (0,1) and user_id=#{userId} and date_format(create_at,'%Y-%m-%d') between #{startTime} and #{endTime}
|
||||
</select>
|
||||
|
||||
<select id="selectSysUserCashOutSum" resultType="Double">
|
||||
select sum(money) from cash_out where state = 1 and sys_user_id=#{sysUserId} and create_at > #{time}
|
||||
</select>
|
||||
|
||||
<select id="sumMoney" resultType="Double">
|
||||
select sum(money) from cash_out where state =1
|
||||
<if test="flag!=null and flag==1">
|
||||
|
|
|
|||
|
|
@ -9,7 +9,6 @@
|
|||
FROM task_center_reward reward
|
||||
INNER JOIN task_center task ON reward.task_id = task.id and task.shows = 1
|
||||
where reward.type = 9
|
||||
and user_id = #{userId}
|
||||
</select>
|
||||
|
||||
</mapper>
|
||||
Loading…
Reference in New Issue