袁野 4 weeks ago
commit 73c2e669ce
  1. 78
      bweb/src/main/java/com/hfkj/controller/order/BsOrderController.java
  2. 48
      bweb/src/main/java/com/hfkj/controller/partner/PartnerController.java
  3. 10
      bweb/src/main/resources/prod/application.yml
  4. BIN
      cweb/lib/taobao-sdk-java-elm.jar
  5. 7
      cweb/pom.xml
  6. 1
      cweb/src/main/java/com/hfkj/config/AuthConfig.java
  7. 44
      cweb/src/main/java/com/hfkj/controller/ClientController.java
  8. 44
      cweb/src/main/java/com/hfkj/controller/ElmController.java
  9. 25
      cweb/src/main/java/com/hfkj/controller/TakeOutController.java
  10. 1
      cweb/src/main/java/com/hfkj/controller/TestController.java
  11. 64
      cweb/src/main/java/com/hfkj/controller/UserController.java
  12. 89
      cweb/src/main/java/com/hfkj/controller/UserCountController.java
  13. 215
      cweb/src/main/java/com/hfkj/controller/order/BsOrderController.java
  14. 37
      cweb/src/main/java/com/hfkj/controller/partner/PartnerController.java
  15. 59
      cweb/src/main/java/com/hfkj/controller/promotion/PromotionController.java
  16. 12
      cweb/src/main/resources/prod/application.yml
  17. 12
      schedule/src/main/resources/prod/application.yml
  18. BIN
      service/lib/taobao-sdk-java-elm.jar
  19. 8
      service/pom.xml
  20. 37
      service/src/main/java/com/hfkj/common/utils/HttpsUtils.java
  21. 111
      service/src/main/java/com/hfkj/common/utils/TaoBaoUtil.java
  22. 9
      service/src/main/java/com/hfkj/dao/BsUserAccountRecordMapperExt.java
  23. 32
      service/src/main/java/com/hfkj/dao/BsUserMapper.java
  24. 15
      service/src/main/java/com/hfkj/dao/BsUserSqlProvider.java
  25. 98
      service/src/main/java/com/hfkj/entity/BsUser.java
  26. 3
      service/src/main/java/com/hfkj/entity/BsUserExample.java
  27. 28
      service/src/main/java/com/hfkj/model/BsOrderModel.java
  28. 8
      service/src/main/java/com/hfkj/service/cornucopia/Impl/BsCornucopiaLotteryRecordServiceImpl.java
  29. 99
      service/src/main/java/com/hfkj/service/elm/ElmService.java
  30. 19
      service/src/main/java/com/hfkj/service/meituan/MeiTuanService.java
  31. 41
      service/src/main/java/com/hfkj/service/order/BsOrderService.java
  32. 143
      service/src/main/java/com/hfkj/service/order/Impl/BsOrderServiceImpl.java
  33. 50
      service/src/main/java/com/hfkj/service/order/OrderBusinessService.java
  34. 1
      service/src/main/java/com/hfkj/service/partner/BsPartnerPoolService.java
  35. 5
      service/src/main/java/com/hfkj/service/partner/Impl/BsPartnerLevelServiceImpl.java
  36. 18
      service/src/main/java/com/hfkj/service/partner/Impl/BsPartnerPoolPreServiceImpl.java
  37. 20
      service/src/main/java/com/hfkj/service/partner/Impl/BsPartnerPoolServiceImpl.java
  38. 8
      service/src/main/java/com/hfkj/service/partner/Impl/BsPartnerUserRecordServiceImpl.java
  39. 186
      service/src/main/java/com/hfkj/service/partner/Impl/PartnerServiceImpl.java
  40. 12
      service/src/main/java/com/hfkj/service/partner/PartnerService.java
  41. 46
      service/src/main/java/com/hfkj/service/pdd/PddService.java
  42. 29
      service/src/main/java/com/hfkj/service/promotion/Impl/PromotionServiceImpl.java
  43. 63
      service/src/main/java/com/hfkj/service/promotion/PromotionBusinessService.java
  44. 20
      service/src/main/java/com/hfkj/service/promotion/PromotionService.java
  45. 25
      service/src/main/java/com/hfkj/service/taobao/TaoBaoService.java
  46. 3
      service/src/main/java/com/hfkj/service/user/BsUserAccountRecordService.java
  47. 4
      service/src/main/java/com/hfkj/service/user/BsUserGradeService.java
  48. 20
      service/src/main/java/com/hfkj/service/user/BsUserService.java
  49. 17
      service/src/main/java/com/hfkj/service/user/impl/BsUserAccountRecordServiceImpl.java
  50. 20
      service/src/main/java/com/hfkj/service/user/impl/BsUserGradeServiceImpl.java
  51. 81
      service/src/main/java/com/hfkj/service/user/impl/BsUserServiceImpl.java
  52. 2
      service/src/main/java/com/hfkj/sysenum/user/UserLoginType.java

@ -4,7 +4,9 @@ import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo; import com.github.pagehelper.PageInfo;
import com.hfkj.common.security.SessionObject; import com.hfkj.common.security.SessionObject;
import com.hfkj.common.security.UserCenter; import com.hfkj.common.security.UserCenter;
import com.hfkj.common.utils.DateUtil;
import com.hfkj.common.utils.ResponseMsgUtil; import com.hfkj.common.utils.ResponseMsgUtil;
import com.hfkj.entity.BsOrder;
import com.hfkj.model.ResponseData; import com.hfkj.model.ResponseData;
import com.hfkj.model.SecUserSessionObject; import com.hfkj.model.SecUserSessionObject;
import com.hfkj.service.order.BsOrderService; import com.hfkj.service.order.BsOrderService;
@ -20,8 +22,9 @@ import org.springframework.web.bind.annotation.ResponseBody;
import javax.annotation.Resource; import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletRequest;
import java.util.HashMap; import java.math.BigDecimal;
import java.util.Map; import java.util.*;
import java.util.stream.Collectors;
@Controller @Controller
@RequestMapping(value="/order") @RequestMapping(value="/order")
@ -66,4 +69,75 @@ public class BsOrderController {
} }
} }
@RequestMapping(value="/statisticsOrder",method = RequestMethod.GET)
@ResponseBody
@ApiOperation(value = "统计订单")
public ResponseData statisticsOrder() {
// 今日时间
Map<String, Date> todayTime = DateUtil.getTodayTimeObj();
// 昨日时间
Map<String, Date> yesterdayTime = DateUtil.getYesterdayTimeObj();
// 本月时间
Map<String, Date> thisMonthTime = DateUtil.getThisMonthTimeObj();
// 上月时间
Map<String, Date> lastMonthTime = DateUtil.getLastMonthTimeObj();
// 创建一个Calendar对象,并设置为2024年2月0日,即2024年1月最后一天
Calendar timeS = new GregorianCalendar();
timeS.set(Calendar.YEAR, 2024);
timeS.set(Calendar.MONTH, 1);
timeS.set(Calendar.DAY_OF_MONTH, 0);
// 设置时间为23点59分59秒
timeS.set(Calendar.HOUR_OF_DAY, 23);
timeS.set(Calendar.MINUTE, 59);
timeS.set(Calendar.SECOND, 59);
// 调用bsOrderService的getOrderList方法,传入一个空的HashMap,获取订单列表
List<BsOrder> orderList = orderService.getOrderList(new HashMap<>());
Map<String,Object> map = new HashMap<>();
// 平台总订单数
Map<String , Object> platformOrder = new HashMap<>();
// 获取今天订单数量
platformOrder.put("todayOrder", (int) orderList.stream().filter(s -> s.getCreateTime().toInstant().isAfter(todayTime.get("timeS").toInstant()) && s.getCreateTime().toInstant().isBefore(todayTime.get("timeE").toInstant())).count());
// 获取昨天订单数量
platformOrder.put("yesterdayOrder", (int) orderList.stream().filter(s -> s.getCreateTime().toInstant().isAfter(yesterdayTime.get("timeS").toInstant()) && s.getCreateTime().toInstant().isBefore(yesterdayTime.get("timeE").toInstant())).count());
// 获取本月订单数量
platformOrder.put("thisMonthOrder", (int) orderList.stream().filter(s -> s.getCreateTime().toInstant().isAfter(thisMonthTime.get("timeS").toInstant()) && s.getCreateTime().toInstant().isBefore(thisMonthTime.get("timeE").toInstant())).count());
// 获取上月订单数量
platformOrder.put("lastMonthOrder", (int) orderList.stream().filter(s -> s.getCreateTime().toInstant().isAfter(lastMonthTime.get("timeS").toInstant()) && s.getCreateTime().toInstant().isBefore(lastMonthTime.get("timeE").toInstant())).count());
// 将订单数量放入map中
map.put("platformOrder", platformOrder);
// 新增订单数
Map<String , Object> newAddOrder = new HashMap<>();
// 获取今天新增订单数量
newAddOrder.put("todayNewAddOrder", (int) orderList.stream().filter(s->s.getStatus().equals(1)).filter(s -> s.getCreateTime().toInstant().isAfter(todayTime.get("timeS").toInstant()) && s.getCreateTime().toInstant().isBefore(todayTime.get("timeE").toInstant())).count());
// 获取昨天新增订单数量
newAddOrder.put("yesterdayNewAddOrder", (int) orderList.stream().filter(s->s.getStatus().equals(1)).filter(s -> s.getCreateTime().toInstant().isAfter(yesterdayTime.get("timeS").toInstant()) && s.getCreateTime().toInstant().isBefore(yesterdayTime.get("timeE").toInstant())).count());
// 获取本月新增订单数量
newAddOrder.put("thisMonthNewAddOrder", (int) orderList.stream().filter(s->s.getStatus().equals(1)).filter(s -> s.getCreateTime().toInstant().isAfter(thisMonthTime.get("timeS").toInstant()) && s.getCreateTime().toInstant().isBefore(thisMonthTime.get("timeE").toInstant())).count());
// 获取上月新增订单数量
newAddOrder.put("lastMonthNewAddOrder", (int) orderList.stream().filter(s->s.getStatus().equals(1)).filter(s -> s.getCreateTime().toInstant().isAfter(lastMonthTime.get("timeS").toInstant()) && s.getCreateTime().toInstant().isBefore(lastMonthTime.get("timeE").toInstant())).count());
// 将新增订单数放入map中
map.put("newAddOrder", newAddOrder);
// 预估金额
Map<String , Object> estimatedAmount = new HashMap<>();
// 获取今天预估金额
estimatedAmount.put("todayEstimatedAmount", orderList.stream().filter(s->s.getStatus().equals(1) || s.getStatus().equals(2) || s.getStatus().equals(3)).filter(s -> s.getCreateTime().toInstant().isAfter(todayTime.get("timeS").toInstant()) && s.getCreateTime().toInstant().isBefore(todayTime.get("timeE").toInstant())).map(BsOrder::getPromotionAmount).reduce(BigDecimal.ZERO, BigDecimal::add));
// 获取昨天预估金额
estimatedAmount.put("yesterdayEstimatedAmount", orderList.stream().filter(s->s.getStatus().equals(1) || s.getStatus().equals(2) || s.getStatus().equals(3)).filter(s -> s.getCreateTime().toInstant().isAfter(yesterdayTime.get("timeS").toInstant()) && s.getCreateTime().toInstant().isBefore(yesterdayTime.get("timeE").toInstant())).map(BsOrder::getPromotionAmount).reduce(BigDecimal.ZERO, BigDecimal::add));
// 获取本月预估金额
estimatedAmount.put("thisMonthEstimatedAmount", orderList.stream().filter(s->s.getStatus().equals(1) || s.getStatus().equals(2) || s.getStatus().equals(3)).filter(s -> s.getCreateTime().toInstant().isAfter(thisMonthTime.get("timeS").toInstant()) && s.getCreateTime().toInstant().isBefore(thisMonthTime.get("timeE").toInstant())).map(BsOrder::getPromotionAmount).reduce(BigDecimal.ZERO, BigDecimal::add));
// 获取上月预估金额
estimatedAmount.put("lastMonthEstimatedAmount", orderList.stream().filter(s->s.getStatus().equals(1) || s.getStatus().equals(2) || s.getStatus().equals(3)).filter(s -> s.getCreateTime().toInstant().isAfter(lastMonthTime.get("timeS").toInstant()) && s.getCreateTime().toInstant().isBefore(lastMonthTime.get("timeE").toInstant())).map(BsOrder::getPromotionAmount).reduce(BigDecimal.ZERO, BigDecimal::add));
// 将预估金额放入map中
map.put("estimatedAmount", estimatedAmount);
return ResponseMsgUtil.success(map);
}
} }

@ -1,6 +1,8 @@
package com.hfkj.controller.partner; package com.hfkj.controller.partner;
import com.alibaba.fastjson.JSONObject; import com.alibaba.fastjson.JSONObject;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.hfkj.common.exception.ErrorCode; import com.hfkj.common.exception.ErrorCode;
import com.hfkj.common.exception.ErrorHelp; import com.hfkj.common.exception.ErrorHelp;
import com.hfkj.common.exception.SysCode; import com.hfkj.common.exception.SysCode;
@ -42,18 +44,21 @@ public class PartnerController {
@Resource @Resource
private PartnerService partnerService; private PartnerService partnerService;
@Resource
private BsPartnerPoolPreService bsPartnerPoolPreService;
@RequestMapping(value="/partnerData",method = RequestMethod.GET) @RequestMapping(value="/partnerData",method = RequestMethod.GET)
@ResponseBody @ResponseBody
@ApiOperation(value = "合伙人统计") @ApiOperation(value = "合伙人统计")
public ResponseData partnerData( public ResponseData partnerData(
@RequestParam(value = "startTime" , required = false) Long startTime, @RequestParam(value = "createTimeS" , required = false) Long createTimeS,
@RequestParam(value = "endTime" , required = false) Long endTime @RequestParam(value = "createTimeE" , required = false) Long createTimeE
) { ) {
try { try {
return ResponseMsgUtil.success(partnerService.partnerData(startTime , endTime)); return ResponseMsgUtil.success(partnerService.partnerData(createTimeS , createTimeE));
} catch (Exception e) { } catch (Exception e) {
log.error("error!",e); log.error("error!",e);
@ -65,12 +70,43 @@ public class PartnerController {
@ResponseBody @ResponseBody
@ApiOperation(value = "分红统计") @ApiOperation(value = "分红统计")
public ResponseData dividendData( public ResponseData dividendData(
@RequestParam(value = "startTime" , required = false) Long startTime, @RequestParam(value = "createTimeS" , required = false) Long createTimeS,
@RequestParam(value = "endTime" , required = false) Long endTime @RequestParam(value = "createTimeE" , required = false) Long createTimeE
) {
try {
return ResponseMsgUtil.success(partnerService.dividendData(createTimeS , createTimeE));
} catch (Exception e) {
log.error("error!",e);
return ResponseMsgUtil.exception(e);
}
}
@RequestMapping(value="/getPartnerList",method = RequestMethod.GET)
@ResponseBody
@ApiOperation(value = "合伙人列表")
public ResponseData getPartnerList(
@RequestParam(value = "createTimeS" , required = false) Long createTimeS,
@RequestParam(value = "createTimeE" , required = false) Long createTimeE,
@RequestParam(value = "lotteryNo" , required = false) String lotteryNo,
@RequestParam(value = "userId" , required = false) Long userId,
@RequestParam(value = "level" , required = false) Long level,
@RequestParam(value = "status" , required = false) Long status,
@RequestParam(value = "pageNum" , required = true) Integer pageNum,
@RequestParam(value = "pageSize" , required = true) Integer pageSize
) { ) {
try { try {
return ResponseMsgUtil.success(partnerService.dividendData(startTime , endTime)); Map<String , Object> map = new HashMap<>();
map.put("lotteryNo", lotteryNo);
map.put("createTimeS", createTimeS);
map.put("createTimeE", createTimeE);
map.put("userId", userId);
map.put("level", level);
map.put("status", status);
PageHelper.startPage(pageNum, pageSize);
return ResponseMsgUtil.success(new PageInfo<>(bsPartnerPoolPreService.queryAllList(map)));
} catch (Exception e) { } catch (Exception e) {
log.error("error!",e); log.error("error!",e);

@ -1,5 +1,5 @@
server: server:
port: 9302 port: 9102
servlet: servlet:
context-path: /brest context-path: /brest
@ -9,9 +9,9 @@ debug: false
#datasource数据源设置 #datasource数据源设置
spring: spring:
datasource: datasource:
url: jdbc:mysql://127.0.0.1:3306/hsg?allowMultiQueries=true&useUnicode=true&characterEncoding=UTF-8 url: jdbc:mysql://127.0.0.1:3306/youtao?allowMultiQueries=true&useUnicode=true&characterEncoding=UTF-8&useSSL=false
username: root username: yqyt
password: HF123456. password: yqyt123!@#Mysql
type: com.alibaba.druid.pool.DruidDataSource type: com.alibaba.druid.pool.DruidDataSource
driver-class-name: com.mysql.jdbc.Driver driver-class-name: com.mysql.jdbc.Driver
filters: stat filters: stat
@ -31,7 +31,7 @@ spring:
database: 0 database: 0
host: 127.0.0.1 host: 127.0.0.1
port: 36379 port: 36379
password: HF123456.Redis password: yqyt123!@#Redis
timeout: 1000 timeout: 1000
jedis: jedis:
pool: pool:

Binary file not shown.

@ -25,6 +25,13 @@
<version>1.0.1</version> <version>1.0.1</version>
<systemPath>${basedir}/lib/taobao-sdk.jar</systemPath> <systemPath>${basedir}/lib/taobao-sdk.jar</systemPath>
</dependency> </dependency>
<dependency>
<groupId>taobao-elm.skd</groupId>
<artifactId>taobao-open-elm-sdk</artifactId>
<scope>system</scope>
<version>1.0.1</version>
<systemPath>${basedir}/lib/taobao-sdk-java-elm.jar</systemPath>
</dependency>
<dependency> <dependency>
<groupId>pop.skd</groupId> <groupId>pop.skd</groupId>
<artifactId>pop-open-sdk</artifactId> <artifactId>pop-open-sdk</artifactId>

@ -97,6 +97,7 @@ public class AuthConfig implements WebMvcConfigurer {
.excludePathPatterns("/goods/*") .excludePathPatterns("/goods/*")
.excludePathPatterns("/taoBaoNotify/*") .excludePathPatterns("/taoBaoNotify/*")
.excludePathPatterns("/cms/*") .excludePathPatterns("/cms/*")
.excludePathPatterns("/order/*")
; ;
} }

@ -5,9 +5,11 @@ import com.hfkj.common.exception.ErrorCode;
import com.hfkj.common.exception.ErrorHelp; import com.hfkj.common.exception.ErrorHelp;
import com.hfkj.common.exception.SysCode; import com.hfkj.common.exception.SysCode;
import com.hfkj.common.security.UserCenter; import com.hfkj.common.security.UserCenter;
import com.hfkj.common.utils.HttpsUtils;
import com.hfkj.common.utils.MemberValidateUtil; import com.hfkj.common.utils.MemberValidateUtil;
import com.hfkj.common.utils.RedisUtil; import com.hfkj.common.utils.RedisUtil;
import com.hfkj.common.utils.ResponseMsgUtil; import com.hfkj.common.utils.ResponseMsgUtil;
import com.hfkj.entity.BsUser;
import com.hfkj.model.ResponseData; import com.hfkj.model.ResponseData;
import com.hfkj.model.SecUserSessionObject; import com.hfkj.model.SecUserSessionObject;
import com.hfkj.service.user.BsUserService; import com.hfkj.service.user.BsUserService;
@ -22,6 +24,7 @@ import org.springframework.web.bind.annotation.*;
import javax.annotation.Resource; import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletRequest;
import java.util.HashMap; import java.util.HashMap;
import java.util.Map;
/** /**
* @className: ClientController * @className: ClientController
@ -78,21 +81,40 @@ public class ClientController {
} }
} }
@RequestMapping(value = "/weChat", method = RequestMethod.POST)
@RequestMapping(value = "/smsLogin", method = RequestMethod.GET)
@ResponseBody @ResponseBody
@ApiOperation(value = "登录并注册") @ApiOperation(value = "微信授权登录")
public ResponseData smsLogin(@RequestParam(value = "phone" , required = true) String phone) { public ResponseData weChat(@RequestBody JSONObject body) {
try { try {
if (body == null || StringUtils.isBlank(body.getString("code"))) {
throw ErrorHelp.genException(SysCode.System, ErrorCode.REQ_PARAMS_ERROR, "");
// 校验手机号格式
if (!MemberValidateUtil.validatePhone(phone)) {
throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "请输入正确的手机号");
} }
// 邀请人id
Long inviteUseId = body.getLong("inviteUseId");
Map<String, Object> params = new HashMap<>();
return ResponseMsgUtil.success(userService.login(phone, UserLoginType.SMS, new HashMap<>(), null)); params.put("appid", "wxadc7c8cd025639c6");
params.put("secret", "3b11012a83de870c2a81fb52d6427fce");
params.put("code", body.getString("code"));
params.put("grant_type", "authorization_code");
JSONObject accessToken = HttpsUtils.doGet("https://api.weixin.qq.com/sns/oauth2/access_token", params);
if (accessToken == null || StringUtils.isBlank(accessToken.getString("openid"))) {
throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "授权失败");
}
params.clear();
params.put("access_token", accessToken.getString("access_token"));
params.put("openid", accessToken.getString("openid"));
params.put("lang", "zh_CN");
JSONObject userinfo = HttpsUtils.doGet("https://api.weixin.qq.com/sns/userinfo", params);
if (userinfo == null || StringUtils.isBlank(userinfo.getString("openid"))) {
throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "获取用户信息失败");
}
BsUser user = new BsUser();
user.setHeadImg(userinfo.getString("headimgurl"));
user.setName(userinfo.getString("nickname"));
user.setWechatOpenId(userinfo.getString("openid"));
user.setWechatUnionid(userinfo.getString("unionid"));
return ResponseMsgUtil.success(userService.weChatAuth(user, new HashMap<>(), inviteUseId));
} catch (Exception e) { } catch (Exception e) {
return ResponseMsgUtil.exception(e); return ResponseMsgUtil.exception(e);

@ -0,0 +1,44 @@
package com.hfkj.controller;
import com.hfkj.common.security.UserCenter;
import com.hfkj.common.utils.ResponseMsgUtil;
import com.hfkj.model.ResponseData;
import com.hfkj.model.UserSessionObject;
import com.hfkj.service.elm.ElmService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;
@Controller
@RequestMapping(value="/elm")
@Api(value="饿了么")
public class ElmController {
private static Logger log = LoggerFactory.getLogger(ElmController.class);
@Autowired
private UserCenter userCenter;
@RequestMapping(value="/officialactivity",method = RequestMethod.GET)
@ResponseBody
@ApiOperation(value = "本地联盟饿了么推广官方活动查询")
public ResponseData officialactivity() {
try {
// 用户session
UserSessionObject session = userCenter.getSessionModel(UserSessionObject.class);
return ResponseMsgUtil.success(ElmService.officialactivity(session.getUser().getId() , "10144"));
} catch (Exception e) {
log.error("error!",e);
return ResponseMsgUtil.exception(e);
}
}
}

@ -52,4 +52,29 @@ public class TakeOutController {
return ResponseMsgUtil.exception(e); return ResponseMsgUtil.exception(e);
} }
} }
@RequestMapping(value="/orderList",method = RequestMethod.GET)
@ResponseBody
@ApiOperation(value = "订单列表查询接口")
public ResponseData orderList(
@RequestParam(value = "actId" , required = false) Long actId,
@RequestParam(value = "startTime" , required = false) Long startTime,
@RequestParam(value = "endTime" , required = false) Integer endTime
) {
try {
JSONObject jsonObject = new JSONObject();
jsonObject.put("startTime" , startTime);
jsonObject.put("endTime" , endTime);
jsonObject.put("actId" , actId);
JSONObject object = MeiTuanService.orderList(jsonObject);
return ResponseMsgUtil.success(object);
} catch (Exception e) {
log.error("error!",e);
return ResponseMsgUtil.exception(e);
}
}
} }

@ -8,6 +8,7 @@ import com.hfkj.common.exception.SysCode;
import com.hfkj.common.utils.ResponseMsgUtil; import com.hfkj.common.utils.ResponseMsgUtil;
import com.hfkj.model.ResponseData; import com.hfkj.model.ResponseData;
import com.hfkj.service.elm.ElmService;
import com.hfkj.service.meituan.MeiTuanService; import com.hfkj.service.meituan.MeiTuanService;
import com.hfkj.service.pdd.PddService; import com.hfkj.service.pdd.PddService;
import com.hfkj.service.taobao.TaoBaoService; import com.hfkj.service.taobao.TaoBaoService;

@ -6,10 +6,7 @@ import com.hfkj.common.exception.ErrorCode;
import com.hfkj.common.exception.ErrorHelp; import com.hfkj.common.exception.ErrorHelp;
import com.hfkj.common.exception.SysCode; import com.hfkj.common.exception.SysCode;
import com.hfkj.common.security.UserCenter; import com.hfkj.common.security.UserCenter;
import com.hfkj.common.utils.DateUtil; import com.hfkj.common.utils.*;
import com.hfkj.common.utils.MemberValidateUtil;
import com.hfkj.common.utils.RedisUtil;
import com.hfkj.common.utils.ResponseMsgUtil;
import com.hfkj.config.CommonSysConst; import com.hfkj.config.CommonSysConst;
import com.hfkj.config.SysConfig; import com.hfkj.config.SysConfig;
import com.hfkj.entity.BsUser; import com.hfkj.entity.BsUser;
@ -205,8 +202,12 @@ public class UserController {
if (StringUtils.isBlank(body.getString("smsCode"))) { if (StringUtils.isBlank(body.getString("smsCode"))) {
throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "请输入短信验证码"); throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "请输入短信验证码");
} }
if (userService.getUser(phone) != null) { // 手机号用户
throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "手机号已被绑定"); BsUser user = userService.getUser(phone);
if (user != null) {
if (StringUtils.isNotBlank(user.getWechatOpenId())) {
throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "手机号已被绑定");
}
} }
// 手机号的验证码 // 手机号的验证码
Object phoneCodeObject = redisUtil.get("SMS_BIND_PHONE_CODE:" + phone); Object phoneCodeObject = redisUtil.get("SMS_BIND_PHONE_CODE:" + phone);
@ -294,8 +295,12 @@ public class UserController {
if (userSession.getUser().getPhone().equals(phone)) { if (userSession.getUser().getPhone().equals(phone)) {
throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "新手机号与现绑定手机号相同"); throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "新手机号与现绑定手机号相同");
} }
if (userService.getUser(phone) != null) { // 手机号用户
throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "手机号已被绑定"); BsUser user = userService.getUser(phone);
if (user != null) {
if (StringUtils.isNotBlank(user.getWechatOpenId())) {
throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "手机号已被绑定");
}
} }
// 校验手机号格式 // 校验手机号格式
if (!MemberValidateUtil.validatePhone(phone)) { if (!MemberValidateUtil.validatePhone(phone)) {
@ -324,6 +329,49 @@ public class UserController {
} }
} }
@RequestMapping(value = "/bindWeChat", method = RequestMethod.POST)
@ResponseBody
@ApiOperation(value = "绑定微信")
public ResponseData bindWeChat(@RequestBody JSONObject body) {
try {
if (body == null || StringUtils.isBlank(body.getString("code"))) {
throw ErrorHelp.genException(SysCode.System, ErrorCode.REQ_PARAMS_ERROR, "");
}
UserSessionObject userSession = userCenter.getSessionModel(UserSessionObject.class);
if (StringUtils.isNotBlank(userSession.getUser().getWechatOpenId())) {
throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "已绑定过微信");
}
Map<String, Object> params = new HashMap<>();
params.put("appid", "wxadc7c8cd025639c6");
params.put("secret", "3b11012a83de870c2a81fb52d6427fce");
params.put("code", body.getString("code"));
params.put("grant_type", "authorization_code");
JSONObject accessToken = HttpsUtils.doGet("https://api.weixin.qq.com/sns/oauth2/access_token", params);
if (accessToken == null || StringUtils.isBlank(accessToken.getString("openid"))) {
throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "授权失败");
}
params.clear();
params.put("access_token", accessToken.getString("access_token"));
params.put("openid", accessToken.getString("openid"));
params.put("lang", "zh_CN");
JSONObject userinfo = HttpsUtils.doGet("https://api.weixin.qq.com/sns/userinfo", params);
if (userinfo == null || StringUtils.isBlank(userinfo.getString("openid"))) {
throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "获取用户信息失败");
}
if (userService.getUserByWechatOpenId(userinfo.getString("openid")) != null) {
throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "微信已被绑定,无法重复绑定");
}
BsUser user = userSession.getUser();
user.setWechatOpenId(userinfo.getString("openid"));
user.setWechatUnionid(userinfo.getString("unionid"));
userService.updateInfo(user);
return ResponseMsgUtil.success(userCenter.getSessionModel(UserSessionObject.class));
} catch (Exception e) {
return ResponseMsgUtil.exception(e);
}
}
@RequestMapping(value = "/delete", method = RequestMethod.POST) @RequestMapping(value = "/delete", method = RequestMethod.POST)
@ResponseBody @ResponseBody
@ApiOperation(value = "注销账户") @ApiOperation(value = "注销账户")

@ -0,0 +1,89 @@
package com.hfkj.controller;
import com.hfkj.common.exception.ErrorCode;
import com.hfkj.common.exception.ErrorHelp;
import com.hfkj.common.exception.SysCode;
import com.hfkj.common.security.SessionObject;
import com.hfkj.common.security.UserCenter;
import com.hfkj.common.utils.DateUtil;
import com.hfkj.common.utils.ResponseMsgUtil;
import com.hfkj.entity.BsUser;
import com.hfkj.entity.BsUserAccount;
import com.hfkj.model.ResponseData;
import com.hfkj.model.UserSessionObject;
import com.hfkj.service.user.BsUserAccountRecordService;
import com.hfkj.service.user.BsUserAccountService;
import com.hfkj.service.user.BsUserGradeService;
import com.hfkj.service.user.BsUserService;
import com.hfkj.service.user.impl.BsUserServiceImpl;
import com.hfkj.sysenum.user.UserGradeEnum;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;
import javax.annotation.Resource;
import java.util.Date;
import java.util.HashMap;
import java.util.LinkedHashMap;
import java.util.Map;
/**
* @className: ClientController
* @author: HuRui
* @date: 2024/9/6
**/
@Controller
@RequestMapping(value="/userCount")
@Api(value="用户统计业务")
public class UserCountController {
@Autowired
private UserCenter userCenter;
@Resource
private BsUserAccountRecordService userAccountRecordService;
@Resource
private BsUserAccountService userAccountService;
@RequestMapping(value = "/income", method = RequestMethod.GET)
@ResponseBody
@ApiOperation(value = "收益统计")
public ResponseData income() {
try {
UserSessionObject userSession = userCenter.getSessionModel(UserSessionObject.class);
// 查询用户账户
BsUserAccount account = userAccountService.getAccount(userSession.getUser().getId());
if (account == null) {
throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "未找到用户账户");
}
// 今日时间
Map<String, Date> todayTime = DateUtil.getTodayTimeObj();
// 昨日时间
Map<String, Date> yesterdayTime = DateUtil.getYesterdayTimeObj();
// 本月时间
Map<String, Date> thisMonthTime = DateUtil.getThisMonthTimeObj();
// 上月时间
Map<String, Date> lastMonthTime = DateUtil.getLastMonthTimeObj();
Map<String,Object> param = new LinkedHashMap<>();
// 当前账户元宝
param.put("goldCoin", account.getGoldCoin());
// 今日元宝收益
param.put("today", userAccountRecordService.getUserTotalProfit(userSession.getUser().getId(), todayTime.get("timeS"), todayTime.get("timeE")));
// 昨日元宝收益
param.put("yesterday", userAccountRecordService.getUserTotalProfit(userSession.getUser().getId(), yesterdayTime.get("timeS"), yesterdayTime.get("timeE")));
// 本月元宝收益
param.put("thisMonth", userAccountRecordService.getUserTotalProfit(userSession.getUser().getId(), thisMonthTime.get("timeS"), thisMonthTime.get("timeE")));
// 上月元宝收益
param.put("lastMonth", userAccountRecordService.getUserTotalProfit(userSession.getUser().getId(), lastMonthTime.get("timeS"), lastMonthTime.get("timeE")));
return ResponseMsgUtil.success(param);
} catch (Exception e) {
return ResponseMsgUtil.exception(e);
}
}
}

@ -8,22 +8,31 @@ import com.hfkj.common.exception.ErrorHelp;
import com.hfkj.common.exception.SysCode; import com.hfkj.common.exception.SysCode;
import com.hfkj.common.security.SessionObject; import com.hfkj.common.security.SessionObject;
import com.hfkj.common.security.UserCenter; import com.hfkj.common.security.UserCenter;
import com.hfkj.common.utils.DateUtil;
import com.hfkj.common.utils.ResponseMsgUtil; import com.hfkj.common.utils.ResponseMsgUtil;
import com.hfkj.model.ResponseData; import com.hfkj.entity.BsOrder;
import com.hfkj.model.SecUserSessionObject; import com.hfkj.model.*;
import com.hfkj.model.UserSessionObject;
import com.hfkj.service.order.BsOrderService; import com.hfkj.service.order.BsOrderService;
import com.hfkj.service.order.Impl.BsOrderServiceImpl;
import com.hfkj.service.promotion.PromotionBusinessService;
import com.hfkj.service.promotion.PromotionService;
import com.hfkj.service.sec.SecDictionaryService;
import com.hfkj.service.user.BsUserAccountRecordService;
import com.hfkj.service.user.BsUserParentRelService;
import io.swagger.annotations.Api; import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation; import io.swagger.annotations.ApiOperation;
import org.apache.commons.collections4.MapUtils;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
import org.springframework.beans.BeanUtils;
import org.springframework.stereotype.Controller; import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*; import org.springframework.web.bind.annotation.*;
import javax.annotation.Resource; import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletRequest;
import java.util.HashMap; import java.math.BigDecimal;
import java.util.Map; import java.util.*;
import java.util.stream.Collectors;
@Controller @Controller
@RequestMapping(value="/order") @RequestMapping(value="/order")
@ -37,15 +46,20 @@ public class BsOrderController {
@Resource @Resource
private UserCenter userCenter; private UserCenter userCenter;
@Resource @Resource
private BsOrderService bsOrderService; private BsUserParentRelService userParentRelService;
@Resource
private BsUserAccountRecordService userAccountRecordService;
@Resource
private SecDictionaryService secDictionaryService;
@RequestMapping(value="/getOrderList",method = RequestMethod.GET) @RequestMapping(value="/getOrderList",method = RequestMethod.GET)
@ResponseBody @ResponseBody
@ApiOperation(value = "查询列表") @ApiOperation(value = "查询列表")
public ResponseData getOrderList(@RequestParam(value = "orderNo" , required = false) String orderNo, public ResponseData getOrderList(@RequestParam(value = "orderNo" , required = false) String orderNo,
@RequestParam(value = "type" , required = false) Integer type, @RequestParam(value = "type" , required = false) Integer type,
@RequestParam(value = "orderType" , required = true) Integer orderType,
@RequestParam(value = "status" , required = false) Integer status, @RequestParam(value = "status" , required = false) Integer status,
@RequestParam(value = "userPhone" , required = false) String userPhone, @RequestParam(value = "userPhone" , required = false) String userPhone,
@RequestParam(value = "goodsName" , required = false) String goodsName, @RequestParam(value = "goodsName" , required = false) String goodsName,
@ -55,24 +69,23 @@ public class BsOrderController {
@RequestParam(value = "pageSize" , required = true) Integer pageSize, HttpServletRequest request) { @RequestParam(value = "pageSize" , required = true) Integer pageSize, HttpServletRequest request) {
try { try {
SessionObject sessionObject = userCenter.getSessionObject(request); // 用户session
SecUserSessionObject userModel = (SecUserSessionObject) sessionObject.getObject(); UserSessionObject session = userCenter.getSessionModel(UserSessionObject.class);
Map<String , Object> map = new HashMap<>(); Map<String , Object> map = new HashMap<>();
map.put("orderNo", orderNo); map.put("orderNo", orderNo);
map.put("userPhone", userPhone); map.put("userPhone", userPhone);
map.put("type", type); map.put("type", type);
map.put("userId", userModel.getAccount().getId()); map.put("orderType", orderType);
map.put("userId", session.getUser().getId());
map.put("status", status); map.put("status", status);
map.put("goodsName", goodsName); map.put("goodsName", goodsName);
map.put("createTimeS", createTimeS); map.put("createTimeS", createTimeS);
map.put("createTimeE", createTimeE); map.put("createTimeE", createTimeE);
PageHelper.startPage(pageNum, pageSize); PageHelper.startPage(pageNum, pageSize);
return ResponseMsgUtil.success(new PageInfo<>(orderService.getOrderList(map))); return ResponseMsgUtil.success(new PageInfo<>(orderService.getOrderListParent(map)));
} catch (Exception e) { } catch (Exception e) {
log.error("error!",e); log.error("error!",e);
@ -80,22 +93,13 @@ public class BsOrderController {
} }
} }
@RequestMapping(value="/create",method = RequestMethod.POST) @RequestMapping(value="/getPddOrderList",method = RequestMethod.GET)
@ResponseBody @ResponseBody
@ApiOperation(value = "创建订单") @ApiOperation(value = "用时间段查询推广订单接口")
public ResponseData create(@RequestBody JSONObject jsonObject) { public ResponseData getPddOrderList() {
try { try {
// 用户session return ResponseMsgUtil.success(orderService.getOrderList());
UserSessionObject userSession = userCenter.getSessionModel(UserSessionObject.class);
if (userSession == null) {
throw ErrorHelp.genException(SysCode.System, ErrorCode.ACCOUNT_LOGIN_NOT, "");
}
jsonObject.put("userId", userSession.getUser().getId());
jsonObject.put("userPhone", userSession.getUser().getPhone());
return ResponseMsgUtil.success(bsOrderService.create(jsonObject));
} catch (Exception e) { } catch (Exception e) {
log.error("error!",e); log.error("error!",e);
@ -103,4 +107,163 @@ public class BsOrderController {
} }
} }
@RequestMapping(value="/statisticsOrder",method = RequestMethod.GET)
@ResponseBody
@ApiOperation(value = "统计订单")
public ResponseData statisticsOrder() {
// 用户session
UserSessionObject session = userCenter.getSessionModel(UserSessionObject.class);
// 今日时间
Map<String, Date> todayTime = DateUtil.getTodayTimeObj();
// 昨日时间
Map<String, Date> yesterdayTime = DateUtil.getYesterdayTimeObj();
// 本月时间
Map<String, Date> thisMonthTime = DateUtil.getThisMonthTimeObj();
// 上月时间
Map<String, Date> lastMonthTime = DateUtil.getLastMonthTimeObj();
// 创建一个Calendar对象,并设置为2024年2月0日,即2024年1月最后一天
Calendar timeS = new GregorianCalendar();
timeS.set(Calendar.YEAR, 2024);
timeS.set(Calendar.MONTH, 1);
timeS.set(Calendar.DAY_OF_MONTH, 0);
// 设置时间为23点59分59秒
timeS.set(Calendar.HOUR_OF_DAY, 23);
timeS.set(Calendar.MINUTE, 59);
timeS.set(Calendar.SECOND, 59);
List<BsOrder> list = orderService.getOrderList(new HashMap<>());
// 查询个人订单
List<BsOrder> orderUserList = list.stream().filter(s->s.getUserId().equals(session.getUser().getId())).collect(Collectors.toList());
//查询团队
// 查询团队用户
Map<String,Object> param = new HashMap<>();
param.put("parentUserId", session.getUser().getId());
// 查询下级数据
List<UserTeamModel> subList = userParentRelService.getTeamSubList(param);
List<BsOrder> teamOrderList = new ArrayList<>();
// 遍历下级数据
for (UserTeamModel userTeamModel : subList) {
List<BsOrder> teamList = list.stream().filter(bsOrder -> bsOrder.getUserId().equals(userTeamModel.getUserId())).collect(Collectors.toList());
teamOrderList.addAll(teamList);
}
// 所有订单
List<BsOrder> allOrderList = new ArrayList<>();
allOrderList.addAll(orderUserList);
allOrderList.addAll(teamOrderList);
Map<String,Object> map = new HashMap<>();
BigDecimal goldCoinExchangeRate = new BigDecimal(secDictionaryService.getDictionary("GOLD_COIN_EXCHANGE_RATE").get(0).getCodeValue());
map.put("cumulative" , userAccountRecordService.getUserTotalProfit(session.getUser().getId() , null , null));
map.put("unliquidated" , allOrderList.stream().filter(s -> s.getStatus().equals(1) || s.getStatus().equals(2) || s.getStatus().equals(3)).map(BsOrder::getPromotionAmount).reduce(BigDecimal.ZERO, BigDecimal::add).multiply(goldCoinExchangeRate));
// 今日收益报表
Map<String , Object> todayReport = new HashMap<>();
JSONObject object;
// 获取今天新增订单
object = new JSONObject();
object.put("orderNum", (int) allOrderList.stream().filter(s -> s.getStatus().equals(1) || s.getStatus().equals(2) || s.getStatus().equals(3)).filter(s -> s.getCreateTime().toInstant().isAfter(todayTime.get("timeS").toInstant()) && s.getCreateTime().toInstant().isBefore(todayTime.get("timeE").toInstant())).count());
object.put("orderMoney", allOrderList.stream().filter(s -> s.getStatus().equals(1) || s.getStatus().equals(2) || s.getStatus().equals(3)).filter(s -> s.getCreateTime().toInstant().isAfter(todayTime.get("timeS").toInstant()) && s.getCreateTime().toInstant().isBefore(todayTime.get("timeE").toInstant())).map(BsOrder::getPromotionAmount).reduce(BigDecimal.ZERO, BigDecimal::add).multiply(goldCoinExchangeRate));
todayReport.put("todayAddOrder", object);
// 获取今天我的订单
object = new JSONObject();
object.put("orderNum", (int) orderUserList.stream().filter(s->s.getStatus().equals(1) || s.getStatus().equals(2) || s.getStatus().equals(3)).filter(s -> s.getCreateTime().toInstant().isAfter(todayTime.get("timeS").toInstant()) && s.getCreateTime().toInstant().isBefore(todayTime.get("timeE").toInstant())).count());
object.put("orderMoney", orderUserList.stream().filter(s->s.getStatus().equals(1) || s.getStatus().equals(2) || s.getStatus().equals(3)).filter(s -> s.getCreateTime().toInstant().isAfter(todayTime.get("timeS").toInstant()) && s.getCreateTime().toInstant().isBefore(todayTime.get("timeE").toInstant())).map(BsOrder::getPromotionAmount).reduce(BigDecimal.ZERO, BigDecimal::add).multiply(goldCoinExchangeRate));
todayReport.put("todayUserOrder", object);
// 团队订单
object = new JSONObject();
object.put("orderTeamNum", (int) teamOrderList.stream().filter(s->s.getStatus().equals(5)).filter(s -> s.getCreateTime().toInstant().isAfter(todayTime.get("timeS").toInstant()) && s.getCreateTime().toInstant().isBefore(todayTime.get("timeE").toInstant())).count());
object.put("orderTeamMoney", teamOrderList.stream().filter(s->s.getStatus().equals(5)).filter(s -> s.getCreateTime().toInstant().isAfter(todayTime.get("timeS").toInstant()) && s.getCreateTime().toInstant().isBefore(todayTime.get("timeE").toInstant())).map(BsOrder::getPromotionAmount).reduce(BigDecimal.ZERO, BigDecimal::add).multiply(goldCoinExchangeRate));
todayReport.put("teamOrderList", object);
// 获取今天失效订单
object = new JSONObject();
object.put("orderFailureNum", (int) allOrderList.stream().filter(s -> s.getStatus().equals(6)).filter(s -> s.getCreateTime().toInstant().isAfter(todayTime.get("timeS").toInstant()) && s.getCreateTime().toInstant().isBefore(todayTime.get("timeE").toInstant())).count());
object.put("orderFailureMoney", allOrderList.stream().filter(s -> s.getStatus().equals(6)).filter(s -> s.getCreateTime().toInstant().isAfter(todayTime.get("timeS").toInstant()) && s.getCreateTime().toInstant().isBefore(todayTime.get("timeE").toInstant())).map(BsOrder::getPromotionAmount).reduce(BigDecimal.ZERO, BigDecimal::add).multiply(goldCoinExchangeRate));
todayReport.put("todayFailureOrder", object);
map.put("todayReport" ,todayReport);
// 昨天收益报表
Map<String , Object> yesterdayReport = new HashMap<>();
// 获取昨天新增订单
object = new JSONObject();
object.put("orderNum", (int) allOrderList.stream().filter(s -> s.getStatus().equals(1) || s.getStatus().equals(2) || s.getStatus().equals(3)).filter(s -> s.getCreateTime().toInstant().isAfter(yesterdayTime.get("timeS").toInstant()) && s.getCreateTime().toInstant().isBefore(yesterdayTime.get("timeE").toInstant())).count());
object.put("orderMoney", allOrderList.stream().filter(s -> s.getStatus().equals(1) || s.getStatus().equals(2) || s.getStatus().equals(3)).filter(s -> s.getCreateTime().toInstant().isAfter(yesterdayTime.get("timeS").toInstant()) && s.getCreateTime().toInstant().isBefore(yesterdayTime.get("timeE").toInstant())).map(BsOrder::getPromotionAmount).reduce(BigDecimal.ZERO, BigDecimal::add).multiply(goldCoinExchangeRate));
yesterdayReport.put("yesterdayAddOrder", object);
// 获取昨天我的订单
object = new JSONObject();
object.put("orderNum", (int) orderUserList.stream().filter(s->s.getStatus().equals(1) || s.getStatus().equals(2) || s.getStatus().equals(3)).filter(s -> s.getCreateTime().toInstant().isAfter(yesterdayTime.get("timeS").toInstant()) && s.getCreateTime().toInstant().isBefore(yesterdayTime.get("timeE").toInstant())).count());
object.put("orderMoney", orderUserList.stream().filter(s->s.getStatus().equals(1) || s.getStatus().equals(2) || s.getStatus().equals(3)).filter(s -> s.getCreateTime().toInstant().isAfter(yesterdayTime.get("timeS").toInstant()) && s.getCreateTime().toInstant().isBefore(yesterdayTime.get("timeE").toInstant())).map(BsOrder::getPromotionAmount).reduce(BigDecimal.ZERO, BigDecimal::add).multiply(goldCoinExchangeRate));
yesterdayReport.put("yesterdayUserOrder", object);
// 团队订单
object = new JSONObject();
object.put("orderNum", (int) teamOrderList.stream().filter(s->s.getStatus().equals(5)).filter(s -> s.getCreateTime().toInstant().isAfter(yesterdayTime.get("timeS").toInstant()) && s.getCreateTime().toInstant().isBefore(yesterdayTime.get("timeE").toInstant())).count());
object.put("orderMoney", teamOrderList.stream().filter(s->s.getStatus().equals(5)).filter(s -> s.getCreateTime().toInstant().isAfter(yesterdayTime.get("timeS").toInstant()) && s.getCreateTime().toInstant().isBefore(yesterdayTime.get("timeE").toInstant())).map(BsOrder::getPromotionAmount).reduce(BigDecimal.ZERO, BigDecimal::add).multiply(goldCoinExchangeRate));
yesterdayReport.put("yesterdayOrderList", object);
// 获取昨天失效订单
object = new JSONObject();
object.put("orderNum", (int) allOrderList.stream().filter(s -> s.getStatus().equals(6)).filter(s -> s.getCreateTime().toInstant().isAfter(yesterdayTime.get("timeS").toInstant()) && s.getCreateTime().toInstant().isBefore(yesterdayTime.get("timeE").toInstant())).count());
object.put("orderMoney", allOrderList.stream().filter(s -> s.getStatus().equals(6)).filter(s -> s.getCreateTime().toInstant().isAfter(yesterdayTime.get("timeS").toInstant()) && s.getCreateTime().toInstant().isBefore(yesterdayTime.get("timeE").toInstant())).map(BsOrder::getPromotionAmount).reduce(BigDecimal.ZERO, BigDecimal::add).multiply(goldCoinExchangeRate));
yesterdayReport.put("yesterdayFailureOrder", object);
map.put("yesterdayReport" ,yesterdayReport);
// 本月收益报表
Map<String , Object> thisMonthReport = new HashMap<>();
// 获取本月新增订单
object = new JSONObject();
object.put("orderNum", (int) allOrderList.stream().filter(s -> s.getStatus().equals(1) || s.getStatus().equals(2) || s.getStatus().equals(3)).filter(s -> s.getCreateTime().toInstant().isAfter(thisMonthTime.get("timeS").toInstant()) && s.getCreateTime().toInstant().isBefore(thisMonthTime.get("timeE").toInstant())).count());
object.put("orderMoney", allOrderList.stream().filter(s -> s.getStatus().equals(1) || s.getStatus().equals(2) || s.getStatus().equals(3)).filter(s -> s.getCreateTime().toInstant().isAfter(thisMonthTime.get("timeS").toInstant()) && s.getCreateTime().toInstant().isBefore(thisMonthTime.get("timeE").toInstant())).map(BsOrder::getPromotionAmount).reduce(BigDecimal.ZERO, BigDecimal::add).multiply(goldCoinExchangeRate));
thisMonthReport.put("thisMonthAddOrder", object);
// 获取本月我的订单
object = new JSONObject();
object.put("orderNum", (int) orderUserList.stream().filter(s->s.getStatus().equals(1) || s.getStatus().equals(2) || s.getStatus().equals(3)).filter(s -> s.getCreateTime().toInstant().isAfter(thisMonthTime.get("timeS").toInstant()) && s.getCreateTime().toInstant().isBefore(thisMonthTime.get("timeE").toInstant())).count());
object.put("orderMoney", orderUserList.stream().filter(s->s.getStatus().equals(1) || s.getStatus().equals(2) || s.getStatus().equals(3)).filter(s -> s.getCreateTime().toInstant().isAfter(thisMonthTime.get("timeS").toInstant()) && s.getCreateTime().toInstant().isBefore(thisMonthTime.get("timeE").toInstant())).map(BsOrder::getPromotionAmount).reduce(BigDecimal.ZERO, BigDecimal::add).multiply(goldCoinExchangeRate));
thisMonthReport.put("thisMonthUserOrder", object);
// 团队订单
object = new JSONObject();
object.put("orderNum", (int) teamOrderList.stream().filter(s->s.getStatus().equals(5)).filter(s -> s.getCreateTime().toInstant().isAfter(thisMonthTime.get("timeS").toInstant()) && s.getCreateTime().toInstant().isBefore(thisMonthTime.get("timeE").toInstant())).count());
object.put("orderMoney", teamOrderList.stream().filter(s->s.getStatus().equals(5)).filter(s -> s.getCreateTime().toInstant().isAfter(thisMonthTime.get("timeS").toInstant()) && s.getCreateTime().toInstant().isBefore(thisMonthTime.get("timeE").toInstant())).map(BsOrder::getPromotionAmount).reduce(BigDecimal.ZERO, BigDecimal::add).multiply(goldCoinExchangeRate));
thisMonthReport.put("thisMonthOrderList", object);
// 获取本月失效订单
object = new JSONObject();
object.put("orderNum", (int) allOrderList.stream().filter(s -> s.getStatus().equals(6)).filter(s -> s.getCreateTime().toInstant().isAfter(thisMonthTime.get("timeS").toInstant()) && s.getCreateTime().toInstant().isBefore(thisMonthTime.get("timeE").toInstant())).count());
object.put("orderMoney", allOrderList.stream().filter(s -> s.getStatus().equals(6)).filter(s -> s.getCreateTime().toInstant().isAfter(thisMonthTime.get("timeS").toInstant()) && s.getCreateTime().toInstant().isBefore(thisMonthTime.get("timeE").toInstant())).map(BsOrder::getPromotionAmount).reduce(BigDecimal.ZERO, BigDecimal::add).multiply(goldCoinExchangeRate));
thisMonthReport.put("thisMonthFailureOrder", object);
map.put("thisMonthReport" ,thisMonthReport);
// 上月收益报表
Map<String , Object> lastMonthReport = new HashMap<>();
// 获取本月新增订单
object = new JSONObject();
object.put("orderNum", (int) allOrderList.stream().filter(s -> s.getStatus().equals(1) || s.getStatus().equals(2) || s.getStatus().equals(3)).filter(s -> s.getCreateTime().toInstant().isAfter(lastMonthTime.get("timeS").toInstant()) && s.getCreateTime().toInstant().isBefore(lastMonthTime.get("timeE").toInstant())).count());
object.put("orderMoney", allOrderList.stream().filter(s -> s.getStatus().equals(1) || s.getStatus().equals(2) || s.getStatus().equals(3)).filter(s -> s.getCreateTime().toInstant().isAfter(lastMonthTime.get("timeS").toInstant()) && s.getCreateTime().toInstant().isBefore(lastMonthTime.get("timeE").toInstant())).map(BsOrder::getPromotionAmount).reduce(BigDecimal.ZERO, BigDecimal::add).multiply(goldCoinExchangeRate));
lastMonthReport.put("lastMonthAddOrder", object);
// 获取本月我的订单
object = new JSONObject();
object.put("orderNum", (int) orderUserList.stream().filter(s->s.getStatus().equals(1) || s.getStatus().equals(2) || s.getStatus().equals(3)).filter(s -> s.getCreateTime().toInstant().isAfter(lastMonthTime.get("timeS").toInstant()) && s.getCreateTime().toInstant().isBefore(lastMonthTime.get("timeE").toInstant())).count());
object.put("orderMoney", orderUserList.stream().filter(s->s.getStatus().equals(1) || s.getStatus().equals(2) || s.getStatus().equals(3)).filter(s -> s.getCreateTime().toInstant().isAfter(lastMonthTime.get("timeS").toInstant()) && s.getCreateTime().toInstant().isBefore(lastMonthTime.get("timeE").toInstant())).map(BsOrder::getPromotionAmount).reduce(BigDecimal.ZERO, BigDecimal::add).multiply(goldCoinExchangeRate));
lastMonthReport.put("lastMonthUserOrder", object);
// 团队订单
object = new JSONObject();
object.put("orderNum", (int) teamOrderList.stream().filter(s->s.getStatus().equals(5)).filter(s -> s.getCreateTime().toInstant().isAfter(lastMonthTime.get("timeS").toInstant()) && s.getCreateTime().toInstant().isBefore(lastMonthTime.get("timeE").toInstant())).count());
object.put("orderMoney", teamOrderList.stream().filter(s->s.getStatus().equals(5)).filter(s -> s.getCreateTime().toInstant().isAfter(lastMonthTime.get("timeS").toInstant()) && s.getCreateTime().toInstant().isBefore(lastMonthTime.get("timeE").toInstant())).map(BsOrder::getPromotionAmount).reduce(BigDecimal.ZERO, BigDecimal::add).multiply(goldCoinExchangeRate));
lastMonthReport.put("lastMonthOrderList", object);
// 获取本月失效订单
object = new JSONObject();
object.put("orderNum", (int) allOrderList.stream().filter(s -> s.getStatus().equals(6)).filter(s -> s.getCreateTime().toInstant().isAfter(lastMonthTime.get("timeS").toInstant()) && s.getCreateTime().toInstant().isBefore(lastMonthTime.get("timeE").toInstant())).count());
object.put("orderMoney", allOrderList.stream().filter(s -> s.getStatus().equals(6)).filter(s -> s.getCreateTime().toInstant().isAfter(lastMonthTime.get("timeS").toInstant()) && s.getCreateTime().toInstant().isBefore(lastMonthTime.get("timeE").toInstant())).map(BsOrder::getPromotionAmount).reduce(BigDecimal.ZERO, BigDecimal::add).multiply(goldCoinExchangeRate));
lastMonthReport.put("lastMonthFailureOrder", object);
map.put("lastMonthReport" ,lastMonthReport);
return ResponseMsgUtil.success(map);
}
} }

@ -1,14 +1,12 @@
package com.hfkj.controller.partner; package com.hfkj.controller.partner;
import com.alibaba.fastjson.JSONObject; import com.alibaba.fastjson.JSONObject;
import com.github.pagehelper.PageInfo;
import com.hfkj.common.exception.ErrorCode; import com.hfkj.common.exception.ErrorCode;
import com.hfkj.common.exception.ErrorHelp; import com.hfkj.common.exception.ErrorHelp;
import com.hfkj.common.exception.SysCode; import com.hfkj.common.exception.SysCode;
import com.hfkj.common.security.UserCenter; import com.hfkj.common.security.UserCenter;
import com.hfkj.common.utils.DateUtil; import com.hfkj.common.utils.DateUtil;
import com.hfkj.common.utils.ResponseMsgUtil; import com.hfkj.common.utils.ResponseMsgUtil;
import com.hfkj.controller.cornucopia.CornucopiaController;
import com.hfkj.entity.BsPartnerLevel; import com.hfkj.entity.BsPartnerLevel;
import com.hfkj.entity.BsPartnerPool; import com.hfkj.entity.BsPartnerPool;
import com.hfkj.entity.BsPartnerPoolPre; import com.hfkj.entity.BsPartnerPoolPre;
@ -26,7 +24,6 @@ import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*; import org.springframework.web.bind.annotation.*;
import javax.annotation.Resource; import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import java.math.BigDecimal; import java.math.BigDecimal;
import java.util.Date; import java.util.Date;
import java.util.HashMap; import java.util.HashMap;
@ -106,7 +103,7 @@ public class PartnerController {
@RequestMapping(value="/getUserPartner",method = RequestMethod.GET) @RequestMapping(value="/getUserPartner",method = RequestMethod.GET)
@ResponseBody @ResponseBody
@ApiOperation(value = "查询合伙人等级与当期投入总元宝,与用户当前等级") @ApiOperation(value = "查询合伙人等级与当期投入总元宝,与用户当前等级")
public ResponseData getUserPartner() { public ResponseData getUserPartner(@RequestParam(value = "level" , required = false) Integer level) {
try { try {
// 用户session // 用户session
@ -115,10 +112,14 @@ public class PartnerController {
throw ErrorHelp.genException(SysCode.System, ErrorCode.ACCOUNT_LOGIN_NOT, ""); throw ErrorHelp.genException(SysCode.System, ErrorCode.ACCOUNT_LOGIN_NOT, "");
} }
// 查询上一期
String lotteryNo = DateUtil.date2String(new Date() , DateUtil.YMD);
JSONObject obj = new JSONObject(); JSONObject obj = new JSONObject();
// 查询当期用户内容 // 查询当期用户内容
Map<String , Object> map = new HashMap<>(); Map<String , Object> map = new HashMap<>();
map.put("status" , 1); map.put("status" , 1);
map.put("level" , level);
map.put("lotteryNo" , lotteryNo);
List<BsPartnerPoolPre> list = bsPartnerPoolPreService.queryAllList(map); List<BsPartnerPoolPre> list = bsPartnerPoolPreService.queryAllList(map);
BigDecimal toDayPartner = list.stream().map(BsPartnerPoolPre::getGoldCoin).reduce(BigDecimal.ZERO, BigDecimal::add); BigDecimal toDayPartner = list.stream().map(BsPartnerPoolPre::getGoldCoin).reduce(BigDecimal.ZERO, BigDecimal::add);
obj.put("toDayPartner" , toDayPartner); obj.put("toDayPartner" , toDayPartner);
@ -126,8 +127,8 @@ public class PartnerController {
List<BsPartnerLevel> partnerLevels = bsPartnerLevelService.queryAllList(map); List<BsPartnerLevel> partnerLevels = bsPartnerLevelService.queryAllList(map);
obj.put("partnerLevels" , partnerLevels); obj.put("partnerLevels" , partnerLevels);
// 查询用户合伙人等级 // 查询用户合伙人等级
BsPartnerPool partnerPool = bsPartnerPoolService.queryDetail(userSession.getUser().getId()); BsPartnerPool partnerPool = bsPartnerPoolService.queryDetail(userSession.getUser().getId() , level);
obj.put("partnerPool" , partnerPool); obj.put("partnerLevel" , partnerPool);
return ResponseMsgUtil.success(obj); return ResponseMsgUtil.success(obj);
@ -140,7 +141,7 @@ public class PartnerController {
@RequestMapping(value="/prePartner",method = RequestMethod.GET) @RequestMapping(value="/prePartner",method = RequestMethod.GET)
@ResponseBody @ResponseBody
@ApiOperation(value = "查询上一期竞选与竞选排名") @ApiOperation(value = "查询上一期竞选与竞选排名")
public ResponseData prePartner() { public ResponseData prePartner(@RequestParam(value = "level" , required = true) Integer level) {
try { try {
// 用户session // 用户session
@ -151,15 +152,27 @@ public class PartnerController {
// 查询上一期 // 查询上一期
String lotteryNo = DateUtil.date2String(new Date() , DateUtil.YMD); String lotteryNo = DateUtil.date2String(new Date() , DateUtil.YMD);
Integer preLotteryNo = Integer.parseInt(lotteryNo) - 1;
Map<String , Object> map = new HashMap<>(); Map<String , Object> map = new HashMap<>();
map.put("status" , 2); map.put("status" , 1);
map.put("lotteryNo" , preLotteryNo.toString()); map.put("level" , level);
List<BsPartnerPoolPre> list = bsPartnerPoolPreService.queryAllList(map); List<BsPartnerPool> list = bsPartnerPoolService.queryAllList(map);
Map<String , Object> userMap = new HashMap<>();
userMap.put("userId" , userSession.getUser().getId());
userMap.put("lotteryNo" , lotteryNo);
Map<String , Object> mapPre = new HashMap<>();
int preLotteryNo = Integer.parseInt(lotteryNo) - 1;
mapPre.put("lotteryNo" , Integer.toString(preLotteryNo));
map.put("level" , level);
List<BsPartnerPoolPre> pres = bsPartnerPoolPreService.queryAllList(mapPre);
JSONObject obj = new JSONObject(); JSONObject obj = new JSONObject();
// 插入上一期内容 // 插入上一期内容
obj.put("partnerPoolPre" , list); obj.put("partnerPoolPre" , list);
obj.put("userPoolPre" , list.stream().filter(s->s.getUserId().equals(userSession.getUser().getId()))); obj.put("partnerPoolUser" , bsPartnerPoolPreService.queryDetail(userMap));
obj.put("userPoolPre" , pres.stream().filter(s->s.getUserId().equals(userSession.getUser().getId())).filter(s->s.getLevel().equals(level)).findFirst().orElse(null));
return ResponseMsgUtil.success(obj); return ResponseMsgUtil.success(obj);

@ -0,0 +1,59 @@
package com.hfkj.controller.promotion;
import com.alibaba.fastjson.JSONObject;
import com.hfkj.common.exception.ErrorCode;
import com.hfkj.common.exception.ErrorHelp;
import com.hfkj.common.exception.SysCode;
import com.hfkj.common.security.UserCenter;
import com.hfkj.common.utils.ResponseMsgUtil;
import com.hfkj.controller.order.BsOrderController;
import com.hfkj.model.ResponseData;
import com.hfkj.model.UserSessionObject;
import com.hfkj.service.promotion.PromotionService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;
import javax.annotation.Resource;
@Controller
@RequestMapping(value="/promotion")
@Api(value="推广管理")
public class PromotionController {
private static final Logger log = LoggerFactory.getLogger(BsOrderController.class);
@Resource
private UserCenter userCenter;
@Resource
private PromotionService promotionService;
@RequestMapping(value="/createUrl",method = RequestMethod.POST)
@ResponseBody
@ApiOperation(value = "创建推广链接")
public ResponseData createUrl(@RequestBody JSONObject jsonObject) {
try {
// 用户session
UserSessionObject userSession = userCenter.getSessionModel(UserSessionObject.class);
if (userSession == null) {
throw ErrorHelp.genException(SysCode.System, ErrorCode.ACCOUNT_LOGIN_NOT, "");
}
jsonObject.put("userId", userSession.getUser().getId());
return ResponseMsgUtil.success(promotionService.createUrl(jsonObject));
} catch (Exception e) {
log.error("error!",e);
return ResponseMsgUtil.exception(e);
}
}
}

@ -1,7 +1,7 @@
server: server:
port: 9302 port: 9101
servlet: servlet:
context-path: /brest context-path: /crest
#配置是否为debug模式,debug模式下,不开启权限校验 #配置是否为debug模式,debug模式下,不开启权限校验
debug: false debug: false
@ -9,9 +9,9 @@ debug: false
#datasource数据源设置 #datasource数据源设置
spring: spring:
datasource: datasource:
url: jdbc:mysql://127.0.0.1:3306/hsg?allowMultiQueries=true&useUnicode=true&characterEncoding=UTF-8 url: jdbc:mysql://127.0.0.1:3306/youtao?allowMultiQueries=true&useUnicode=true&characterEncoding=UTF-8&useSSL=false
username: root username: yqyt
password: HF123456. password: yqyt123!@#Mysql
type: com.alibaba.druid.pool.DruidDataSource type: com.alibaba.druid.pool.DruidDataSource
driver-class-name: com.mysql.jdbc.Driver driver-class-name: com.mysql.jdbc.Driver
filters: stat filters: stat
@ -31,7 +31,7 @@ spring:
database: 0 database: 0
host: 127.0.0.1 host: 127.0.0.1
port: 36379 port: 36379
password: HF123456.Redis password: yqyt123!@#Redis
timeout: 1000 timeout: 1000
jedis: jedis:
pool: pool:

@ -1,7 +1,7 @@
server: server:
port: 9302 port: 9103
servlet: servlet:
context-path: /brest context-path: /schedule
#配置是否为debug模式,debug模式下,不开启权限校验 #配置是否为debug模式,debug模式下,不开启权限校验
debug: false debug: false
@ -9,9 +9,9 @@ debug: false
#datasource数据源设置 #datasource数据源设置
spring: spring:
datasource: datasource:
url: jdbc:mysql://127.0.0.1:3306/hsg?allowMultiQueries=true&useUnicode=true&characterEncoding=UTF-8 url: jdbc:mysql://127.0.0.1:3306/youtao?allowMultiQueries=true&useUnicode=true&characterEncoding=UTF-8&useSSL=false
username: root username: yqyt
password: HF123456. password: yqyt123!@#Mysql
type: com.alibaba.druid.pool.DruidDataSource type: com.alibaba.druid.pool.DruidDataSource
driver-class-name: com.mysql.jdbc.Driver driver-class-name: com.mysql.jdbc.Driver
filters: stat filters: stat
@ -31,7 +31,7 @@ spring:
database: 0 database: 0
host: 127.0.0.1 host: 127.0.0.1
port: 36379 port: 36379
password: HF123456.Redis password: yqyt123!@#Redis
timeout: 1000 timeout: 1000
jedis: jedis:
pool: pool:

@ -275,6 +275,14 @@
<version>1.0.1</version> <version>1.0.1</version>
<systemPath>${basedir}/lib/taobao-sdk.jar</systemPath> <systemPath>${basedir}/lib/taobao-sdk.jar</systemPath>
</dependency> </dependency>
<dependency>
<groupId>taobao-elm.skd</groupId>
<artifactId>taobao-open-elm-sdk</artifactId>
<scope>system</scope>
<version>1.0.1</version>
<systemPath>${basedir}/lib/taobao-sdk-java-elm.jar</systemPath>
</dependency>
<dependency> <dependency>
<groupId>pop.skd</groupId> <groupId>pop.skd</groupId>
<artifactId>pop-open-sdk</artifactId> <artifactId>pop-open-sdk</artifactId>

@ -137,6 +137,7 @@ public class HttpsUtils {
i++; i++;
} }
apiUrl += param; apiUrl += param;
apiUrl += "&query_request=" + o;
String result = null; String result = null;
HttpClient httpClient = null; HttpClient httpClient = null;
try { try {
@ -502,6 +503,42 @@ public class HttpsUtils {
return null; return null;
} }
public static JSONObject doPostS(String apiUrl, Map<String,String> body) {
CloseableHttpClient httpClient = null;
if (apiUrl.startsWith("https")) {
httpClient = HttpClients.custom().setSSLSocketFactory(createSSLConnSocketFactory())
.setConnectionManager(connMgr).setDefaultRequestConfig(requestConfig).build();
} else {
httpClient = HttpClients.createDefault();
}
String httpStr = null;
CloseableHttpResponse response = null;
try {
HttpPost httpPost = new HttpPost(apiUrl);
httpPost.setConfig(requestConfig);
StringEntity stringEntity = new StringEntity(JSON.toJSONString(body), "UTF-8");// 解决中文乱码问题
stringEntity.setContentEncoding("UTF-8");
stringEntity.setContentType("application/json");
httpPost.setEntity(stringEntity);
response = httpClient.execute(httpPost);
HttpEntity entity = response.getEntity();
httpStr = EntityUtils.toString(entity, "UTF-8");
return JSON.parseObject(httpStr);
} catch (Exception e) {
log.error(e.getMessage(),e);
} finally {
if (response != null) {
try {
EntityUtils.consume(response.getEntity());
} catch (IOException e) {
log.error(e.getMessage(),e);
}
}
}
return null;
}
public static JSONObject doPostForm(String apiUrl, String body, Map<String,Object> header) { public static JSONObject doPostForm(String apiUrl, String body, Map<String,Object> header) {
CloseableHttpClient httpClient = null; CloseableHttpClient httpClient = null;
if (apiUrl.startsWith("https")) { if (apiUrl.startsWith("https")) {

@ -0,0 +1,111 @@
package com.hfkj.common.utils;
import com.alipay.api.internal.util.StringUtils;
import com.taobao.top.Constants;
import javax.crypto.Mac;
import javax.crypto.SecretKey;
import javax.crypto.spec.SecretKeySpec;
import java.io.IOException;
import java.security.GeneralSecurityException;
import java.security.MessageDigest;
import java.util.Arrays;
import java.util.Map;
public class TaoBaoUtil {
public static String signTopRequest(Map<String, String> params, String secret, String signMethod) throws IOException {
// 第一步:检查参数是否已经排序
String[] keys = params.keySet().toArray(new String[0]);
Arrays.sort(keys);
// 第二步:把所有参数名和参数值串在一起
StringBuilder query = new StringBuilder();
if (Constants.SIGN_METHOD_MD5.equals(signMethod)) { //签名的摘要算法,可选值为:hmac,md5,hmac-sha256
query.append(secret);
}
for (String key : keys) {
String value = params.get(key);
if (StringUtils.areNotEmpty(key, value)) {
query.append(key).append(value);
}
}
// 第三步:使用MD5/HMAC加密
byte[] bytes;
if (Constants.SIGN_METHOD_HMAC.equals(signMethod)) {
bytes = encryptHMAC(query.toString(), secret);
} else {
query.append(secret);
bytes = encryptMD5(query.toString());
}
// 第四步:把二进制转化为大写的十六进制(正确签名应该为32大写字符串,此方法需要时使用)
return byte2hex(bytes);
}
// 将字节数组转换为十六进制字符串
public static String byte2hex(byte[] bytes) {
// 创建一个StringBuilder对象,用于存储转换后的十六进制字符串
StringBuilder sign = new StringBuilder();
// 遍历字节数组
for (byte aByte : bytes) {
// 将字节数组中的每个字节转换为十六进制字符串
String hex = Integer.toHexString(aByte & 0xFF);
// 如果转换后的十六进制字符串长度为1,则在前面补0
if (hex.length() == 1) {
sign.append("0");
}
// 将转换后的十六进制字符串转换为大写,并添加到StringBuilder对象中
sign.append(hex.toUpperCase());
}
// 返回转换后的十六进制字符串
return sign.toString();
}
// 加密HMAC
public static byte[] encryptHMAC(String data, String secret) throws IOException {
// 声明一个字节数组
byte[] bytes = null;
try {
// 创建一个SecretKey对象,使用secret和Constants.CHARSET_UTF8编码
SecretKey secretKey = new SecretKeySpec(secret.getBytes(Constants.CHARSET_UTF8), "HmacMD5");
// 获取Mac实例
Mac mac = Mac.getInstance(secretKey.getAlgorithm());
// 初始化Mac对象
mac.init(secretKey);
// 使用Mac对象对data进行加密,使用Constants.CHARSET_UTF8编码
bytes = mac.doFinal(data.getBytes(Constants.CHARSET_UTF8));
} catch (GeneralSecurityException gse) {
// 抛出IOException异常
throw new IOException(gse.toString());
}
// 返回加密后的字节数组
return bytes;
}
// 加密MD5
public static byte[] encryptMD5(String data) throws IOException {
// 将字符串转换为字节数组
return encryptMD5(data.getBytes(Constants.CHARSET_UTF8));
}
// 加密数据为MD5
public static byte[] encryptMD5(byte[] data) throws IOException {
// 声明一个字节数组,用于存储加密后的数据
byte[] bytes = null;
try {
// 获取MD5加密算法实例
MessageDigest md = MessageDigest.getInstance("MD5");
// 对数据进行加密
bytes = md.digest(data);
} catch (GeneralSecurityException gse) {
// 如果发生异常,则抛出IO异常
throw new IOException(gse.toString());
}
// 返回加密后的数据
return bytes;
}
}

@ -10,6 +10,11 @@ import java.math.BigDecimal;
*/ */
public interface BsUserAccountRecordMapperExt { public interface BsUserAccountRecordMapperExt {
@Select("<script> select sum(transaction_amount) from bs_user_account_record where user_id = #{userId} and type = 1 and `status` = 1 </script>") @Select("<script> select " +
BigDecimal queryUserTotalProfit(@Param("userId") Long userId); " case when sum(transaction_amount) is null then 0 else sum(transaction_amount) end" +
" from bs_user_account_record where user_id = #{userId} and type = 1 and `status` = 1 " +
" <if test='timeS != null'> <![CDATA[ and create_time >= #{timeS} ]]> </if>" +
" <if test='timeE != null'> <![CDATA[ and create_time <= #{timeE} ]]> </if>" +
"</script>")
BigDecimal queryUserTotalProfit(@Param("userId") Long userId,@Param("timeS") String timeS,@Param("timeE") String timeE);
} }

@ -41,6 +41,7 @@ public interface BsUserMapper extends BsUserMapperExt {
@Insert({ @Insert({
"insert into bs_user (head_img, `name`, ", "insert into bs_user (head_img, `name`, ",
"phone, grade, wechat_num, ", "phone, grade, wechat_num, ",
<<<<<<< HEAD
"special_id, wechat_open_id, ", "special_id, wechat_open_id, ",
"wechat_unionid, elm_pid, ", "wechat_unionid, elm_pid, ",
"invite_user_id, invite_time, ", "invite_user_id, invite_time, ",
@ -57,6 +58,22 @@ public interface BsUserMapper extends BsUserMapperExt {
"#{status,jdbcType=INTEGER}, #{createTime,jdbcType=TIMESTAMP}, ", "#{status,jdbcType=INTEGER}, #{createTime,jdbcType=TIMESTAMP}, ",
"#{updateTime,jdbcType=TIMESTAMP}, #{ext1,jdbcType=VARCHAR}, ", "#{updateTime,jdbcType=TIMESTAMP}, #{ext1,jdbcType=VARCHAR}, ",
"#{ext2,jdbcType=VARCHAR}, #{ext3,jdbcType=VARCHAR})" "#{ext2,jdbcType=VARCHAR}, #{ext3,jdbcType=VARCHAR})"
=======
"wechat_open_id, wechat_unionid, ",
"elm_pid, invite_user_id, ",
"invite_time, partner_level, ",
"partner_income_per, `status`, ",
"create_time, update_time, ",
"ext_1, ext_2, ext_3)",
"values (#{headImg,jdbcType=VARCHAR}, #{name,jdbcType=VARCHAR}, ",
"#{phone,jdbcType=VARCHAR}, #{grade,jdbcType=INTEGER}, #{wechatNum,jdbcType=VARCHAR}, ",
"#{wechatOpenId,jdbcType=VARCHAR}, #{wechatUnionid,jdbcType=VARCHAR}, ",
"#{elmPid,jdbcType=VARCHAR}, #{inviteUserId,jdbcType=BIGINT}, ",
"#{inviteTime,jdbcType=TIMESTAMP}, #{partnerLevel,jdbcType=INTEGER}, ",
"#{partnerIncomePer,jdbcType=DECIMAL}, #{status,jdbcType=INTEGER}, ",
"#{createTime,jdbcType=TIMESTAMP}, #{updateTime,jdbcType=TIMESTAMP}, ",
"#{ext1,jdbcType=VARCHAR}, #{ext2,jdbcType=VARCHAR}, #{ext3,jdbcType=VARCHAR})"
>>>>>>> 9fd569d446b9f1a74c4b28147a3572ee8a076825
}) })
@Options(useGeneratedKeys=true,keyProperty="id") @Options(useGeneratedKeys=true,keyProperty="id")
int insert(BsUser record); int insert(BsUser record);
@ -73,7 +90,10 @@ public interface BsUserMapper extends BsUserMapperExt {
@Result(column="phone", property="phone", jdbcType=JdbcType.VARCHAR), @Result(column="phone", property="phone", jdbcType=JdbcType.VARCHAR),
@Result(column="grade", property="grade", jdbcType=JdbcType.INTEGER), @Result(column="grade", property="grade", jdbcType=JdbcType.INTEGER),
@Result(column="wechat_num", property="wechatNum", jdbcType=JdbcType.VARCHAR), @Result(column="wechat_num", property="wechatNum", jdbcType=JdbcType.VARCHAR),
<<<<<<< HEAD
@Result(column="special_id", property="specialId", jdbcType=JdbcType.VARCHAR), @Result(column="special_id", property="specialId", jdbcType=JdbcType.VARCHAR),
=======
>>>>>>> 9fd569d446b9f1a74c4b28147a3572ee8a076825
@Result(column="wechat_open_id", property="wechatOpenId", jdbcType=JdbcType.VARCHAR), @Result(column="wechat_open_id", property="wechatOpenId", jdbcType=JdbcType.VARCHAR),
@Result(column="wechat_unionid", property="wechatUnionid", jdbcType=JdbcType.VARCHAR), @Result(column="wechat_unionid", property="wechatUnionid", jdbcType=JdbcType.VARCHAR),
@Result(column="elm_pid", property="elmPid", jdbcType=JdbcType.VARCHAR), @Result(column="elm_pid", property="elmPid", jdbcType=JdbcType.VARCHAR),
@ -92,9 +112,15 @@ public interface BsUserMapper extends BsUserMapperExt {
@Select({ @Select({
"select", "select",
<<<<<<< HEAD
"id, head_img, `name`, phone, grade, wechat_num, special_id, wechat_open_id, ", "id, head_img, `name`, phone, grade, wechat_num, special_id, wechat_open_id, ",
"wechat_unionid, elm_pid, invite_user_id, invite_time, partner_level, partner_income_per, ", "wechat_unionid, elm_pid, invite_user_id, invite_time, partner_level, partner_income_per, ",
"`status`, create_time, update_time, ext_1, ext_2, ext_3", "`status`, create_time, update_time, ext_1, ext_2, ext_3",
=======
"id, head_img, `name`, phone, grade, wechat_num, wechat_open_id, wechat_unionid, ",
"elm_pid, invite_user_id, invite_time, partner_level, partner_income_per, `status`, ",
"create_time, update_time, ext_1, ext_2, ext_3",
>>>>>>> 9fd569d446b9f1a74c4b28147a3572ee8a076825
"from bs_user", "from bs_user",
"where id = #{id,jdbcType=BIGINT}" "where id = #{id,jdbcType=BIGINT}"
}) })
@ -105,7 +131,10 @@ public interface BsUserMapper extends BsUserMapperExt {
@Result(column="phone", property="phone", jdbcType=JdbcType.VARCHAR), @Result(column="phone", property="phone", jdbcType=JdbcType.VARCHAR),
@Result(column="grade", property="grade", jdbcType=JdbcType.INTEGER), @Result(column="grade", property="grade", jdbcType=JdbcType.INTEGER),
@Result(column="wechat_num", property="wechatNum", jdbcType=JdbcType.VARCHAR), @Result(column="wechat_num", property="wechatNum", jdbcType=JdbcType.VARCHAR),
<<<<<<< HEAD
@Result(column="special_id", property="specialId", jdbcType=JdbcType.VARCHAR), @Result(column="special_id", property="specialId", jdbcType=JdbcType.VARCHAR),
=======
>>>>>>> 9fd569d446b9f1a74c4b28147a3572ee8a076825
@Result(column="wechat_open_id", property="wechatOpenId", jdbcType=JdbcType.VARCHAR), @Result(column="wechat_open_id", property="wechatOpenId", jdbcType=JdbcType.VARCHAR),
@Result(column="wechat_unionid", property="wechatUnionid", jdbcType=JdbcType.VARCHAR), @Result(column="wechat_unionid", property="wechatUnionid", jdbcType=JdbcType.VARCHAR),
@Result(column="elm_pid", property="elmPid", jdbcType=JdbcType.VARCHAR), @Result(column="elm_pid", property="elmPid", jdbcType=JdbcType.VARCHAR),
@ -138,7 +167,10 @@ public interface BsUserMapper extends BsUserMapperExt {
"phone = #{phone,jdbcType=VARCHAR},", "phone = #{phone,jdbcType=VARCHAR},",
"grade = #{grade,jdbcType=INTEGER},", "grade = #{grade,jdbcType=INTEGER},",
"wechat_num = #{wechatNum,jdbcType=VARCHAR},", "wechat_num = #{wechatNum,jdbcType=VARCHAR},",
<<<<<<< HEAD
"special_id = #{specialId,jdbcType=VARCHAR},", "special_id = #{specialId,jdbcType=VARCHAR},",
=======
>>>>>>> 9fd569d446b9f1a74c4b28147a3572ee8a076825
"wechat_open_id = #{wechatOpenId,jdbcType=VARCHAR},", "wechat_open_id = #{wechatOpenId,jdbcType=VARCHAR},",
"wechat_unionid = #{wechatUnionid,jdbcType=VARCHAR},", "wechat_unionid = #{wechatUnionid,jdbcType=VARCHAR},",
"elm_pid = #{elmPid,jdbcType=VARCHAR},", "elm_pid = #{elmPid,jdbcType=VARCHAR},",

@ -48,10 +48,13 @@ public class BsUserSqlProvider {
sql.VALUES("wechat_num", "#{wechatNum,jdbcType=VARCHAR}"); sql.VALUES("wechat_num", "#{wechatNum,jdbcType=VARCHAR}");
} }
<<<<<<< HEAD
if (record.getSpecialId() != null) { if (record.getSpecialId() != null) {
sql.VALUES("special_id", "#{specialId,jdbcType=VARCHAR}"); sql.VALUES("special_id", "#{specialId,jdbcType=VARCHAR}");
} }
=======
>>>>>>> 9fd569d446b9f1a74c4b28147a3572ee8a076825
if (record.getWechatOpenId() != null) { if (record.getWechatOpenId() != null) {
sql.VALUES("wechat_open_id", "#{wechatOpenId,jdbcType=VARCHAR}"); sql.VALUES("wechat_open_id", "#{wechatOpenId,jdbcType=VARCHAR}");
} }
@ -119,7 +122,10 @@ public class BsUserSqlProvider {
sql.SELECT("phone"); sql.SELECT("phone");
sql.SELECT("grade"); sql.SELECT("grade");
sql.SELECT("wechat_num"); sql.SELECT("wechat_num");
<<<<<<< HEAD
sql.SELECT("special_id"); sql.SELECT("special_id");
=======
>>>>>>> 9fd569d446b9f1a74c4b28147a3572ee8a076825
sql.SELECT("wechat_open_id"); sql.SELECT("wechat_open_id");
sql.SELECT("wechat_unionid"); sql.SELECT("wechat_unionid");
sql.SELECT("elm_pid"); sql.SELECT("elm_pid");
@ -174,10 +180,13 @@ public class BsUserSqlProvider {
sql.SET("wechat_num = #{record.wechatNum,jdbcType=VARCHAR}"); sql.SET("wechat_num = #{record.wechatNum,jdbcType=VARCHAR}");
} }
<<<<<<< HEAD
if (record.getSpecialId() != null) { if (record.getSpecialId() != null) {
sql.SET("special_id = #{record.specialId,jdbcType=VARCHAR}"); sql.SET("special_id = #{record.specialId,jdbcType=VARCHAR}");
} }
=======
>>>>>>> 9fd569d446b9f1a74c4b28147a3572ee8a076825
if (record.getWechatOpenId() != null) { if (record.getWechatOpenId() != null) {
sql.SET("wechat_open_id = #{record.wechatOpenId,jdbcType=VARCHAR}"); sql.SET("wechat_open_id = #{record.wechatOpenId,jdbcType=VARCHAR}");
} }
@ -244,7 +253,10 @@ public class BsUserSqlProvider {
sql.SET("phone = #{record.phone,jdbcType=VARCHAR}"); sql.SET("phone = #{record.phone,jdbcType=VARCHAR}");
sql.SET("grade = #{record.grade,jdbcType=INTEGER}"); sql.SET("grade = #{record.grade,jdbcType=INTEGER}");
sql.SET("wechat_num = #{record.wechatNum,jdbcType=VARCHAR}"); sql.SET("wechat_num = #{record.wechatNum,jdbcType=VARCHAR}");
<<<<<<< HEAD
sql.SET("special_id = #{record.specialId,jdbcType=VARCHAR}"); sql.SET("special_id = #{record.specialId,jdbcType=VARCHAR}");
=======
>>>>>>> 9fd569d446b9f1a74c4b28147a3572ee8a076825
sql.SET("wechat_open_id = #{record.wechatOpenId,jdbcType=VARCHAR}"); sql.SET("wechat_open_id = #{record.wechatOpenId,jdbcType=VARCHAR}");
sql.SET("wechat_unionid = #{record.wechatUnionid,jdbcType=VARCHAR}"); sql.SET("wechat_unionid = #{record.wechatUnionid,jdbcType=VARCHAR}");
sql.SET("elm_pid = #{record.elmPid,jdbcType=VARCHAR}"); sql.SET("elm_pid = #{record.elmPid,jdbcType=VARCHAR}");
@ -288,10 +300,13 @@ public class BsUserSqlProvider {
sql.SET("wechat_num = #{wechatNum,jdbcType=VARCHAR}"); sql.SET("wechat_num = #{wechatNum,jdbcType=VARCHAR}");
} }
<<<<<<< HEAD
if (record.getSpecialId() != null) { if (record.getSpecialId() != null) {
sql.SET("special_id = #{specialId,jdbcType=VARCHAR}"); sql.SET("special_id = #{specialId,jdbcType=VARCHAR}");
} }
=======
>>>>>>> 9fd569d446b9f1a74c4b28147a3572ee8a076825
if (record.getWechatOpenId() != null) { if (record.getWechatOpenId() != null) {
sql.SET("wechat_open_id = #{wechatOpenId,jdbcType=VARCHAR}"); sql.SET("wechat_open_id = #{wechatOpenId,jdbcType=VARCHAR}");
} }

@ -45,11 +45,14 @@ public class BsUser implements Serializable {
private String wechatNum; private String wechatNum;
/** /**
<<<<<<< HEAD
* 淘宝会员独有 * 淘宝会员独有
*/ */
private String specialId; private String specialId;
/** /**
=======
>>>>>>> 9fd569d446b9f1a74c4b28147a3572ee8a076825
* 微信openid * 微信openid
*/ */
private String wechatOpenId; private String wechatOpenId;
@ -155,6 +158,7 @@ public class BsUser implements Serializable {
this.wechatNum = wechatNum; this.wechatNum = wechatNum;
} }
<<<<<<< HEAD
public String getSpecialId() { public String getSpecialId() {
return specialId; return specialId;
} }
@ -163,6 +167,8 @@ public class BsUser implements Serializable {
this.specialId = specialId; this.specialId = specialId;
} }
=======
>>>>>>> 9fd569d446b9f1a74c4b28147a3572ee8a076825
public String getWechatOpenId() { public String getWechatOpenId() {
return wechatOpenId; return wechatOpenId;
} }
@ -266,4 +272,96 @@ public class BsUser implements Serializable {
public void setExt3(String ext3) { public void setExt3(String ext3) {
this.ext3 = ext3; this.ext3 = ext3;
} }
<<<<<<< HEAD
=======
@Override
public boolean equals(Object that) {
if (this == that) {
return true;
}
if (that == null) {
return false;
}
if (getClass() != that.getClass()) {
return false;
}
BsUser other = (BsUser) that;
return (this.getId() == null ? other.getId() == null : this.getId().equals(other.getId()))
&& (this.getHeadImg() == null ? other.getHeadImg() == null : this.getHeadImg().equals(other.getHeadImg()))
&& (this.getName() == null ? other.getName() == null : this.getName().equals(other.getName()))
&& (this.getPhone() == null ? other.getPhone() == null : this.getPhone().equals(other.getPhone()))
&& (this.getGrade() == null ? other.getGrade() == null : this.getGrade().equals(other.getGrade()))
&& (this.getWechatNum() == null ? other.getWechatNum() == null : this.getWechatNum().equals(other.getWechatNum()))
&& (this.getWechatOpenId() == null ? other.getWechatOpenId() == null : this.getWechatOpenId().equals(other.getWechatOpenId()))
&& (this.getWechatUnionid() == null ? other.getWechatUnionid() == null : this.getWechatUnionid().equals(other.getWechatUnionid()))
&& (this.getElmPid() == null ? other.getElmPid() == null : this.getElmPid().equals(other.getElmPid()))
&& (this.getInviteUserId() == null ? other.getInviteUserId() == null : this.getInviteUserId().equals(other.getInviteUserId()))
&& (this.getInviteTime() == null ? other.getInviteTime() == null : this.getInviteTime().equals(other.getInviteTime()))
&& (this.getPartnerLevel() == null ? other.getPartnerLevel() == null : this.getPartnerLevel().equals(other.getPartnerLevel()))
&& (this.getPartnerIncomePer() == null ? other.getPartnerIncomePer() == null : this.getPartnerIncomePer().equals(other.getPartnerIncomePer()))
&& (this.getStatus() == null ? other.getStatus() == null : this.getStatus().equals(other.getStatus()))
&& (this.getCreateTime() == null ? other.getCreateTime() == null : this.getCreateTime().equals(other.getCreateTime()))
&& (this.getUpdateTime() == null ? other.getUpdateTime() == null : this.getUpdateTime().equals(other.getUpdateTime()))
&& (this.getExt1() == null ? other.getExt1() == null : this.getExt1().equals(other.getExt1()))
&& (this.getExt2() == null ? other.getExt2() == null : this.getExt2().equals(other.getExt2()))
&& (this.getExt3() == null ? other.getExt3() == null : this.getExt3().equals(other.getExt3()));
}
@Override
public int hashCode() {
final int prime = 31;
int result = 1;
result = prime * result + ((getId() == null) ? 0 : getId().hashCode());
result = prime * result + ((getHeadImg() == null) ? 0 : getHeadImg().hashCode());
result = prime * result + ((getName() == null) ? 0 : getName().hashCode());
result = prime * result + ((getPhone() == null) ? 0 : getPhone().hashCode());
result = prime * result + ((getGrade() == null) ? 0 : getGrade().hashCode());
result = prime * result + ((getWechatNum() == null) ? 0 : getWechatNum().hashCode());
result = prime * result + ((getWechatOpenId() == null) ? 0 : getWechatOpenId().hashCode());
result = prime * result + ((getWechatUnionid() == null) ? 0 : getWechatUnionid().hashCode());
result = prime * result + ((getElmPid() == null) ? 0 : getElmPid().hashCode());
result = prime * result + ((getInviteUserId() == null) ? 0 : getInviteUserId().hashCode());
result = prime * result + ((getInviteTime() == null) ? 0 : getInviteTime().hashCode());
result = prime * result + ((getPartnerLevel() == null) ? 0 : getPartnerLevel().hashCode());
result = prime * result + ((getPartnerIncomePer() == null) ? 0 : getPartnerIncomePer().hashCode());
result = prime * result + ((getStatus() == null) ? 0 : getStatus().hashCode());
result = prime * result + ((getCreateTime() == null) ? 0 : getCreateTime().hashCode());
result = prime * result + ((getUpdateTime() == null) ? 0 : getUpdateTime().hashCode());
result = prime * result + ((getExt1() == null) ? 0 : getExt1().hashCode());
result = prime * result + ((getExt2() == null) ? 0 : getExt2().hashCode());
result = prime * result + ((getExt3() == null) ? 0 : getExt3().hashCode());
return result;
}
@Override
public String toString() {
StringBuilder sb = new StringBuilder();
sb.append(getClass().getSimpleName());
sb.append(" [");
sb.append("Hash = ").append(hashCode());
sb.append(", id=").append(id);
sb.append(", headImg=").append(headImg);
sb.append(", name=").append(name);
sb.append(", phone=").append(phone);
sb.append(", grade=").append(grade);
sb.append(", wechatNum=").append(wechatNum);
sb.append(", wechatOpenId=").append(wechatOpenId);
sb.append(", wechatUnionid=").append(wechatUnionid);
sb.append(", elmPid=").append(elmPid);
sb.append(", inviteUserId=").append(inviteUserId);
sb.append(", inviteTime=").append(inviteTime);
sb.append(", partnerLevel=").append(partnerLevel);
sb.append(", partnerIncomePer=").append(partnerIncomePer);
sb.append(", status=").append(status);
sb.append(", createTime=").append(createTime);
sb.append(", updateTime=").append(updateTime);
sb.append(", ext1=").append(ext1);
sb.append(", ext2=").append(ext2);
sb.append(", ext3=").append(ext3);
sb.append(", serialVersionUID=").append(serialVersionUID);
sb.append("]");
return sb.toString();
}
>>>>>>> 9fd569d446b9f1a74c4b28147a3572ee8a076825
} }

@ -526,6 +526,7 @@ public class BsUserExample {
return (Criteria) this; return (Criteria) this;
} }
<<<<<<< HEAD
public Criteria andSpecialIdIsNull() { public Criteria andSpecialIdIsNull() {
addCriterion("special_id is null"); addCriterion("special_id is null");
return (Criteria) this; return (Criteria) this;
@ -596,6 +597,8 @@ public class BsUserExample {
return (Criteria) this; return (Criteria) this;
} }
=======
>>>>>>> 9fd569d446b9f1a74c4b28147a3572ee8a076825
public Criteria andWechatOpenIdIsNull() { public Criteria andWechatOpenIdIsNull() {
addCriterion("wechat_open_id is null"); addCriterion("wechat_open_id is null");
return (Criteria) this; return (Criteria) this;

@ -0,0 +1,28 @@
package com.hfkj.model;
import com.hfkj.entity.BsOrder;
import lombok.Data;
import java.math.BigDecimal;
@Data
public class BsOrderModel extends BsOrder {
/**
* 关系类型 1直属好友 2团队成员
*/
private Integer relType;
/**
* 用户id
*/
private Long userId;
/**
* 名称
*/
private String name;
private BigDecimal gold;
}

@ -56,11 +56,11 @@ public class BsCornucopiaLotteryRecordServiceImpl implements BsCornucopiaLottery
if (MapUtils.getInteger(map, "type") != null) { if (MapUtils.getInteger(map, "type") != null) {
criteria.andTypeEqualTo(MapUtils.getInteger(map, "type")); criteria.andTypeEqualTo(MapUtils.getInteger(map, "type"));
} }
if (MapUtils.getLong(map, "startTime") != null) { if (MapUtils.getLong(map, "createTimeS") != null) {
criteria.andCreateTimeGreaterThanOrEqualTo(new Date(MapUtils.getLong(map, "startTime"))); criteria.andCreateTimeGreaterThanOrEqualTo(new Date(MapUtils.getLong(map, "createTimeS")));
} }
if (MapUtils.getLong(map, "endTime") != null) { if (MapUtils.getLong(map, "createTimeE") != null) {
criteria.andCreateTimeLessThan(new Date(MapUtils.getLong(map, "endTime"))); criteria.andCreateTimeLessThan(new Date(MapUtils.getLong(map, "createTimeE")));
} }
if (MapUtils.getString(map, "lotteryNo") != null) { if (MapUtils.getString(map, "lotteryNo") != null) {
criteria.andLotteryNoLike("%" + MapUtils.getString(map, "lotteryNo") + "%"); criteria.andLotteryNoLike("%" + MapUtils.getString(map, "lotteryNo") + "%");

@ -0,0 +1,99 @@
package com.hfkj.service.elm;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.hfkj.common.utils.DateUtil;
import com.hfkj.common.utils.HttpsUtils;
import com.hfkj.common.utils.TaoBaoUtil;
import com.hfkj.service.taobao.TaoBaoService;
import com.taobao.api.DefaultTaobaoClient;
import com.taobao.api.TaobaoClient;
import com.taobao.api.request.AlibabaAlscUnionElemePromotionOfficialactivityGetRequest;
import com.taobao.api.request.AlibabaAlscUnionMediaZoneAddRequest;
import com.taobao.api.response.AlibabaAlscUnionElemePromotionOfficialactivityGetResponse;
import com.taobao.api.response.AlibabaAlscUnionMediaZoneAddResponse;
import com.taobao.top.DefaultTopApiClient;
import com.taobao.top.TopApiClient;
import com.taobao.top.ability375.Ability375;
import com.taobao.top.ability375.request.TaobaoTbkTpwdCreateRequest;
import com.taobao.top.ability375.response.TaobaoTbkTpwdCreateResponse;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.net.URLEncoder;
import java.util.Date;
import java.util.HashMap;
import java.util.Map;
public class ElmService {
private static Logger log = LoggerFactory.getLogger(TaoBaoService.class);
private static String appKey = "34818013";
private static String appsecret = "822a2df4166dbab7e0acfc42ba0aab75";
private static String url = "https://gw.api.taobao.com/router/rest";
private static String pid = "alsc_28560886_9016007_22442020";
// 本地联盟饿了么推广官方活动查询
public static JSONObject officialactivity(Long userId , String activityId) throws Exception {
// 打印日志,开始本地联盟饿了么推广官方活动查询
log.info("============ 本地联盟饿了么推广官方活动查询-START =============");
// 创建淘宝客户端
TaobaoClient client = new DefaultTaobaoClient(url, appKey, appsecret);
// 创建请求对象
AlibabaAlscUnionElemePromotionOfficialactivityGetRequest req = new AlibabaAlscUnionElemePromotionOfficialactivityGetRequest();
// 创建活动请求对象
AlibabaAlscUnionElemePromotionOfficialactivityGetRequest.ActivityRequest obj1 = new AlibabaAlscUnionElemePromotionOfficialactivityGetRequest.ActivityRequest();
// 设置pid
obj1.setPid(pid);
// 设置活动id
obj1.setActivityId(activityId);
// 设置sid
obj1.setSid(userId.toString());
// 设置请求参数
req.setQueryRequest(obj1);
// 执行请求
AlibabaAlscUnionElemePromotionOfficialactivityGetResponse rsp = client.execute(req);
// 打印日志,请求接口
log.info("请求接口:" + "officialactivity");
// 打印日志,请求参数
log.info("请求参数:" + JSONObject.toJSONString(obj1));
// 打印日志,响应参数
log.info("响应参数:" + rsp);
// 打印日志,结束本地联盟饿了么推广官方活动查询
log.info("============ 本地联盟饿了么推广官方活动查询--END ==============");
// 返回响应参数
return JSONObject.parseObject(JSON.toJSONString(rsp.getData().getLink()));
}
public static JSONObject mediaZoneAdd(String sessionKey) throws Exception {
// 打印日志, 本地生活媒体推广位创建
log.info("============ 本地生活媒体推广位创建-START =============");
// 创建淘宝客户端
TaobaoClient client = new DefaultTaobaoClient(url, appKey, appsecret);
AlibabaAlscUnionMediaZoneAddRequest req = new AlibabaAlscUnionMediaZoneAddRequest();
req.setZoneName("推广位");
req.setMediaId("1");
AlibabaAlscUnionMediaZoneAddResponse rsp = client.execute(req, sessionKey);
// 打印日志,请求接口
log.info("请求接口:" + "officialactivity");
// 打印日志,请求参数
log.info("请求参数:" + JSONObject.toJSONString(req));
// 打印日志,响应参数
log.info("响应参数:" + rsp);
// 打印日志, 本地生活媒体推广位创建
log.info("============ 本地生活媒体推广位创建--END ==============");
// 返回响应参数
return JSONObject.parseObject(JSON.toJSONString(rsp));
}
}

@ -33,6 +33,25 @@ public class MeiTuanService {
} }
} }
/**
* @MethodName orderList
* @Description: 订单列表查询接口
* @param param
* @return: com.alibaba.fastjson.JSONObject
* @Author: Sum1Dream
* @Date: 2024/10/23 上午10:42
*/
public static JSONObject orderList(JSONObject param)throws Exception {
JSONObject object = request("order" , param);
if (object.getInteger("status").equals(0)) {
return object;
} else {
throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, object.getString("des"));
}
}
/** /**
* @MethodName request * @MethodName request
* @Description: 统一请求 * @Description: 统一请求

@ -2,7 +2,9 @@ package com.hfkj.service.order;
import com.alibaba.fastjson.JSONObject; import com.alibaba.fastjson.JSONObject;
import com.hfkj.entity.BsOrder; import com.hfkj.entity.BsOrder;
import com.hfkj.model.BsOrderModel;
import java.math.BigDecimal;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
@ -34,14 +36,6 @@ public interface BsOrderService {
* @return * @return
*/ */
void cacheDelete(String orderNo); void cacheDelete(String orderNo);
/**
* 创建订单
* @param jsonObject 订单
* @return
*/
JSONObject create(JSONObject jsonObject) throws Exception;
/** /**
* @MethodName findByOrderNo * @MethodName findByOrderNo
* @Description: 查询订单 * @Description: 查询订单
@ -62,5 +56,36 @@ public interface BsOrderService {
*/ */
List<BsOrder> getOrderList(Map<String , Object> map); List<BsOrder> getOrderList(Map<String , Object> map);
/**
* @MethodName getOrderList
* @Description:用时间段查询推广订单接口
* @param
* @return: com.alibaba.fastjson.JSONObject
* @Author: Sum1Dream
* @Date: 2024/10/23 上午10:27
*/
JSONObject getOrderList() throws Exception;
/**
* @MethodName getOrderListParent
* @Description: 获取订单
* @param map
* @return: java.util.List<com.hfkj.entity.BsOrder>
* @Author: Sum1Dream
* @Date: 2024/10/24 下午2:52
*/
List<BsOrderModel> getOrderListParent(Map<String , Object> map);
/**
* @MethodName orderRebate
* @Description: 订单返利
* @param orderNo 订单号
* @param gold 返利金额
* @return: void
* @Author: Sum1Dream
* @Date: 2024/10/24 下午3:03
*/
void orderRebate(String orderNo , BigDecimal gold) throws Exception;
} }

@ -1,20 +1,34 @@
package com.hfkj.service.order.Impl; package com.hfkj.service.order.Impl;
import com.alibaba.fastjson.JSONObject; import com.alibaba.fastjson.JSONObject;
import com.hfkj.common.exception.ErrorCode;
import com.hfkj.common.exception.ErrorHelp;
import com.hfkj.common.exception.SysCode;
import com.hfkj.common.utils.OrderUtil; import com.hfkj.common.utils.OrderUtil;
import com.hfkj.common.utils.RedisUtil; import com.hfkj.common.utils.RedisUtil;
import com.hfkj.dao.BsOrderMapper; import com.hfkj.dao.BsOrderMapper;
import com.hfkj.entity.BsOrder; import com.hfkj.entity.BsOrder;
import com.hfkj.entity.BsOrderExample; import com.hfkj.entity.BsOrderExample;
import com.hfkj.model.BsOrderModel;
import com.hfkj.model.UserTeamModel;
import com.hfkj.service.order.BsOrderService; import com.hfkj.service.order.BsOrderService;
import com.hfkj.service.order.OrderBusinessService; import com.hfkj.service.order.OrderBusinessService;
import com.hfkj.service.pdd.PddService;
import com.hfkj.service.promotion.PromotionBusinessService;
import com.hfkj.service.sec.SecDictionaryService;
import com.hfkj.service.user.BsUserContributeService;
import com.hfkj.service.user.BsUserParentRelService;
import org.apache.commons.collections4.MapUtils; import org.apache.commons.collections4.MapUtils;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.core.annotation.OrderUtils; import org.springframework.core.annotation.OrderUtils;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import javax.annotation.Resource; import javax.annotation.Resource;
import java.math.BigDecimal;
import java.util.*; import java.util.*;
import java.util.stream.Collectors;
@Service("bsOrderService") @Service("bsOrderService")
public class BsOrderServiceImpl implements BsOrderService { public class BsOrderServiceImpl implements BsOrderService {
@ -31,7 +45,12 @@ public class BsOrderServiceImpl implements BsOrderService {
private BsOrderMapper bsOrderMapper; private BsOrderMapper bsOrderMapper;
@Resource @Resource
private OrderBusinessService orderBusinessService; private BsUserParentRelService userParentRelService;
@Resource
private BsUserContributeService userContributeService;
@Resource
private SecDictionaryService secDictionaryService;
@Override @Override
public BsOrder editData(BsOrder order) { public BsOrder editData(BsOrder order) {
@ -54,44 +73,6 @@ public class BsOrderServiceImpl implements BsOrderService {
redisUtil.del(CACHE_KEY + orderNo); redisUtil.del(CACHE_KEY + orderNo);
} }
@Override
public JSONObject create(JSONObject body) throws Exception {
BsOrder order = new BsOrder();
order.setOrderNo(OrderUtil.generateOrderNo());
order.setUpdateTime(new Date());
order.setCreateTime(new Date());
order.setStatus(20);
order.setTotalPrice(body.getBigDecimal("totalPrice"));
order.setUserPhone(body.getString("phone"));
order.setUserId(body.getLong("userId"));
JSONObject map = new JSONObject();
map.put("orderNo", order.getOrderNo());
map.put("uid", order.getUserId());
map.put("searchId", body.getString("searchId"));
map.put("goodsSign", body.getString("goodsSign"));
map.put("url", body.getString("url"));
order.setCustomparameters(map.toJSONString());
order.setGoodsName(body.getString("goodsName"));
order.setType(body.getInteger("type"));
order.setImg(body.getString("img"));
bsOrderMapper.insert(order);
// 淘宝订单业务
if (body.getInteger("type") == 1) {
return orderBusinessService.taobaoUrl(order);
}
// 拼多多订单业务
if (body.getInteger("type") == 2) {
return orderBusinessService.pddUrl(order);
}
return null;
}
@Override @Override
public BsOrder findByOrderNo(String orderNo) { public BsOrder findByOrderNo(String orderNo) {
@ -120,16 +101,16 @@ public class BsOrderServiceImpl implements BsOrderService {
BsOrderExample example = new BsOrderExample(); BsOrderExample example = new BsOrderExample();
BsOrderExample.Criteria criteria = example.createCriteria(); BsOrderExample.Criteria criteria = example.createCriteria();
if (MapUtils.getString(map , "orderNo") != null) { if (StringUtils.isNotBlank(MapUtils.getString(map , "orderNo"))) {
criteria.andOrderNoEqualTo(MapUtils.getString(map , "orderNo")); criteria.andOrderNoEqualTo(MapUtils.getString(map , "orderNo"));
} }
if (MapUtils.getInteger(map , "type") != null) { if (MapUtils.getInteger(map , "type") != null) {
criteria.andTypeEqualTo(MapUtils.getInteger(map , "type")); criteria.andTypeEqualTo(MapUtils.getInteger(map , "type"));
} }
if (MapUtils.getString(map , "userPhone") != null) { if (StringUtils.isNotBlank(MapUtils.getString(map , "userPhone"))) {
criteria.andUserPhoneEqualTo(MapUtils.getString(map , "userPhone")); criteria.andUserPhoneEqualTo(MapUtils.getString(map , "userPhone"));
} }
if (MapUtils.getString(map , "goodsName") != null) { if (StringUtils.isNotBlank(MapUtils.getString(map , "goodsName"))) {
criteria.andGoodsNameLike("%" + MapUtils.getString(map , "goodsName") + "%"); criteria.andGoodsNameLike("%" + MapUtils.getString(map , "goodsName") + "%");
} }
if (MapUtils.getLong(map, "createTimeS") != null) { if (MapUtils.getLong(map, "createTimeS") != null) {
@ -139,11 +120,87 @@ public class BsOrderServiceImpl implements BsOrderService {
criteria.andCreateTimeLessThan(new Date(MapUtils.getLong(map, "createTimeE"))); criteria.andCreateTimeLessThan(new Date(MapUtils.getLong(map, "createTimeE")));
} }
if (MapUtils.getInteger(map , "status") != null) { if (MapUtils.getInteger(map , "status") != null) {
criteria.andTypeEqualTo(MapUtils.getInteger(map , "status")); criteria.andStatusEqualTo(MapUtils.getInteger(map , "status"));
} }
if (MapUtils.getLong(map , "userId") != null) { if (MapUtils.getLong(map , "userId") != null) {
criteria.andUserIdEqualTo(MapUtils.getLong(map , "userId")); criteria.andUserIdEqualTo(MapUtils.getLong(map , "userId"));
} }
return bsOrderMapper.selectByExample(example); return bsOrderMapper.selectByExample(example);
} }
@Override
public JSONObject getOrderList() throws Exception{
return PddService.getOrderList();
}
@Override
public List<BsOrderModel> getOrderListParent(Map<String, Object> map) {
// 判断map中是否包含userId键,如果不存在则抛出异常
if (MapUtils.getLong(map , "userId") == null) {
throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "当前用户未登陆");
}
// 创建一个BsOrderModel类型的列表
List<BsOrderModel> orderModels = new ArrayList<>();
BigDecimal goldCoinExchangeRate = new BigDecimal(secDictionaryService.getDictionary("GOLD_COIN_EXCHANGE_RATE").get(0).getCodeValue());
// 查询用户订单
if (MapUtils.getInteger(map , "orderType").equals(1)) {
// 获取订单列表
List<BsOrder> list = getOrderList(map);
// 遍历订单列表
for (BsOrder order :list) {
// 创建订单模型
BsOrderModel orderModel = new BsOrderModel();
// 将订单属性复制到订单模型中
BeanUtils.copyProperties(order, orderModel);
orderModel.setGold(order.getPromotionAmount().multiply(goldCoinExchangeRate));
// 将订单模型添加到订单模型列表中
orderModels.add(orderModel);
}
return orderModels;
}
// 查询团队订单
if (MapUtils.getInteger(map , "orderType").equals(2)) {
// 查询团队用户
Map<String,Object> param = new HashMap<>();
param.put("parentUserId", MapUtils.getLong(map , "userId"));
// 查询下级数据
List<UserTeamModel> subList = userParentRelService.getTeamSubList(param);
// 查询订单
map.put("userId" , null);
List<BsOrder> orderList = getOrderList(map);
// 遍历下级数据
for (UserTeamModel userTeamModel : subList) {
List<BsOrder> list = orderList.stream().filter(bsOrder -> bsOrder.getUserId().equals(userTeamModel.getUserId())).collect(Collectors.toList());
for (BsOrder order : list) {
BsOrderModel orderModel = new BsOrderModel();
BeanUtils.copyProperties(order, orderModel);
orderModel.setRelType(userTeamModel.getRelType());
orderModel.setUserId(userTeamModel.getUserId());
orderModel.setName(userTeamModel.getName());
orderModels.add(orderModel);
}
}
return orderModels;
}
return null;
}
@Override
public void orderRebate(String orderNo, BigDecimal gold) throws Exception {
BsOrder bsOrder = findByOrderNo(orderNo);
// 判断订单状态是否为4或5
if (bsOrder.getStatus().equals(4) || bsOrder.getStatus().equals(5)) {
// 如果是,则抛出异常,提示订单状态不可返利
throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "订单状态不可返利");
}
Map<String,Object> otherParam = new HashMap<>();
otherParam.put("sourceId", bsOrder.getId());
otherParam.put("sourceOrderNo", bsOrder.getOrderNo());
userContributeService.purchase(bsOrder.getPromotionAmount(), bsOrder.getUserId(), otherParam);
}
} }

@ -1,22 +1,9 @@
package com.hfkj.service.order; package com.hfkj.service.order;
import com.alibaba.fastjson.JSONObject;
import com.hfkj.common.exception.ErrorCode;
import com.hfkj.common.exception.ErrorHelp;
import com.hfkj.common.exception.SysCode;
import com.hfkj.common.utils.ResponseMsgUtil;
import com.hfkj.dao.BsOrderMapper;
import com.hfkj.entity.BsOrder;
import com.hfkj.service.pdd.PddService;
import com.hfkj.service.taobao.TaoBaoService;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Component; import org.springframework.stereotype.Component;
import java.util.HashMap;
import java.util.Map;
/** /**
* 创建订单业务 * 创建订单业务
* @className: OrderBusinessService * @className: OrderBusinessService
@ -28,41 +15,4 @@ public class OrderBusinessService {
Logger log = LoggerFactory.getLogger(OrderBusinessService.class); Logger log = LoggerFactory.getLogger(OrderBusinessService.class);
// 淘口令生成业务
public JSONObject taobaoUrl(BsOrder bsOrder) throws Exception{
JSONObject jsonObject = JSONObject.parseObject(bsOrder.getCustomparameters());
JSONObject object = TaoBaoService.createCommand(jsonObject.getString("url"));
if (!object.getBoolean("success")) {
throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "请求失败!");
}
return object.getJSONObject("data");
}
//多多进宝推广链接生成
public JSONObject pddUrl(BsOrder bsOrder) throws Exception{
JSONObject jsonObject = JSONObject.parseObject(bsOrder.getCustomparameters());
String goodsSign = jsonObject.getString("goodsSign");
String searchId = jsonObject.getString("searchId");
if (searchId == null) {
throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "缺少searchId!");
}
if (goodsSign == null) {
throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "缺少goodsSign!");
}
Map<String , Object> mapUser = new HashMap<>();
mapUser.put("uid", bsOrder.getUserId());
// 判断是否需要授权
JSONObject object = PddService.authority(mapUser.toString());
boolean generateAuthorityUrl = object.getJSONObject("authorityQueryResponse").getInteger("bind") == 0;
JSONObject o = PddService.promotion(searchId , goodsSign , generateAuthorityUrl , mapUser.toString());
return o.getJSONObject("goodsPromotionUrlGenerateResponse").getJSONArray("goodsPromotionUrlList").getJSONObject(0);
}
} }

@ -44,6 +44,7 @@ public interface BsPartnerPoolService {
* @Date: 2024/7/4 下午2:30 * @Date: 2024/7/4 下午2:30
*/ */
BsPartnerPool queryDetail(Long userId); BsPartnerPool queryDetail(Long userId);
BsPartnerPool queryDetail(Long userId , Integer level);
/** /**
* @MethodName queryAllList * @MethodName queryAllList

@ -8,6 +8,7 @@ import com.hfkj.entity.BsPartnerLevelExample;
import com.hfkj.entity.BsPartnerPool; import com.hfkj.entity.BsPartnerPool;
import com.hfkj.service.partner.BsPartnerLevelService; import com.hfkj.service.partner.BsPartnerLevelService;
import com.hfkj.service.partner.BsPartnerPoolService; import com.hfkj.service.partner.BsPartnerPoolService;
import org.apache.commons.collections4.MapUtils;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import javax.annotation.Resource; import javax.annotation.Resource;
@ -74,6 +75,10 @@ public class BsPartnerLevelServiceImpl implements BsPartnerLevelService {
BsPartnerLevelExample example = new BsPartnerLevelExample(); BsPartnerLevelExample example = new BsPartnerLevelExample();
BsPartnerLevelExample.Criteria criteria = example.createCriteria(); BsPartnerLevelExample.Criteria criteria = example.createCriteria();
if (MapUtils.getInteger(map, "level") != null) {
criteria.andLevelEqualTo(MapUtils.getInteger(map, "level"));
}
criteria.andStatusEqualTo(1); criteria.andStatusEqualTo(1);
return bsPartnerLevelMapper.selectByExample(example); return bsPartnerLevelMapper.selectByExample(example);

@ -6,6 +6,7 @@ import com.hfkj.entity.BsPartnerPoolPre;
import com.hfkj.entity.BsPartnerPoolPreExample; import com.hfkj.entity.BsPartnerPoolPreExample;
import com.hfkj.service.partner.BsPartnerPoolPreService; import com.hfkj.service.partner.BsPartnerPoolPreService;
import org.apache.commons.collections4.MapUtils; import org.apache.commons.collections4.MapUtils;
import org.apache.commons.lang3.StringUtils;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import javax.annotation.Resource; import javax.annotation.Resource;
@ -75,6 +76,9 @@ public class BsPartnerPoolPreServiceImpl implements BsPartnerPoolPreService {
if (MapUtils.getString(map, "num") != null) { if (MapUtils.getString(map, "num") != null) {
criteria.andLotteryNoLike("%" + MapUtils.getString(map, "num") + "%"); criteria.andLotteryNoLike("%" + MapUtils.getString(map, "num") + "%");
} }
if (StringUtils.isNotBlank(MapUtils.getString(map, "lotteryNo"))) {
criteria.andLotteryNoEqualTo(MapUtils.getString(map, "lotteryNo"));
}
List<BsPartnerPoolPre> list = bsPartnerPoolPreMapper.selectByExample(example); List<BsPartnerPoolPre> list = bsPartnerPoolPreMapper.selectByExample(example);
@ -95,19 +99,19 @@ public class BsPartnerPoolPreServiceImpl implements BsPartnerPoolPreService {
if (MapUtils.getInteger(map, "userId") != null) { if (MapUtils.getInteger(map, "userId") != null) {
criteria.andUserIdEqualTo(MapUtils.getLong(map, "userId")); criteria.andUserIdEqualTo(MapUtils.getLong(map, "userId"));
} }
if (MapUtils.getString(map, "num") != null) { if (StringUtils.isNotBlank(MapUtils.getString(map, "num"))) {
criteria.andLotteryNoLike("%" + MapUtils.getString(map, "num") + "%"); criteria.andNumLike("%" + MapUtils.getString(map, "num") + "%");
} }
if (MapUtils.getInteger(map, "status") != null) { if (MapUtils.getInteger(map, "status") != null) {
criteria.andStatusEqualTo(MapUtils.getInteger(map, "status")); criteria.andStatusEqualTo(MapUtils.getInteger(map, "status"));
} }
if (MapUtils.getLong(map, "startTime") != null) { if (MapUtils.getLong(map, "createTimeS") != null) {
criteria.andCreateTimeGreaterThanOrEqualTo(new Date(MapUtils.getLong(map, "startTime"))); criteria.andCreateTimeGreaterThanOrEqualTo(new Date(MapUtils.getLong(map, "createTimeS")));
} }
if (MapUtils.getLong(map, "endTime") != null) { if (MapUtils.getLong(map, "createTimeE") != null) {
criteria.andCreateTimeLessThan(new Date(MapUtils.getLong(map, "endTime"))); criteria.andCreateTimeLessThan(new Date(MapUtils.getLong(map, "createTimeE")));
} }
if (MapUtils.getString(map, "lotteryNo") != null) { if (StringUtils.isNotBlank(MapUtils.getString(map, "lotteryNo"))) {
criteria.andLotteryNoEqualTo(MapUtils.getString(map, "lotteryNo")); criteria.andLotteryNoEqualTo(MapUtils.getString(map, "lotteryNo"));
} }

@ -44,6 +44,7 @@ public class BsPartnerPoolServiceImpl implements BsPartnerPoolService {
} }
} }
@Override @Override
public BsPartnerPool queryDetail(Long userId) { public BsPartnerPool queryDetail(Long userId) {
BsPartnerPoolExample example = new BsPartnerPoolExample(); BsPartnerPoolExample example = new BsPartnerPoolExample();
@ -59,6 +60,24 @@ public class BsPartnerPoolServiceImpl implements BsPartnerPoolService {
return null; return null;
} }
@Override
public BsPartnerPool queryDetail(Long userId , Integer level) {
BsPartnerPoolExample example = new BsPartnerPoolExample();
BsPartnerPoolExample.Criteria criteria = example.createCriteria();
if (level != null) {
criteria.andLevelEqualTo(level);
}
criteria.andUserIdEqualTo(userId);
List<BsPartnerPool> list = bsPartnerPoolMapper.selectByExample(example);
if (!list.isEmpty()) {
return list.get(0);
}
return null;
}
@Override @Override
public List<BsPartnerPool> queryAllList(Map<String, Object> map) { public List<BsPartnerPool> queryAllList(Map<String, Object> map) {
BsPartnerPoolExample example = new BsPartnerPoolExample(); BsPartnerPoolExample example = new BsPartnerPoolExample();
@ -73,6 +92,7 @@ public class BsPartnerPoolServiceImpl implements BsPartnerPoolService {
if (MapUtils.getString(map, "num") != null) { if (MapUtils.getString(map, "num") != null) {
criteria.andNumLike("%" + MapUtils.getString(map, "num") + "%"); criteria.andNumLike("%" + MapUtils.getString(map, "num") + "%");
} }
criteria.andUserIdIsNotNull();
criteria.andStatusEqualTo(1); criteria.andStatusEqualTo(1);
return bsPartnerPoolMapper.selectByExample(example); return bsPartnerPoolMapper.selectByExample(example);

@ -84,11 +84,11 @@ public class BsPartnerUserRecordServiceImpl implements BsPartnerUserRecordServic
if (MapUtils.getString(map, "userName") != null) { if (MapUtils.getString(map, "userName") != null) {
criteria.andUserNameLike("%" + MapUtils.getString(map, "userName") + "%"); criteria.andUserNameLike("%" + MapUtils.getString(map, "userName") + "%");
} }
if (MapUtils.getLong(map, "startTime") != null) { if (MapUtils.getLong(map, "createTimeS") != null) {
criteria.andCreateTimeGreaterThanOrEqualTo(new Date(MapUtils.getLong(map, "startTime"))); criteria.andCreateTimeGreaterThanOrEqualTo(new Date(MapUtils.getLong(map, "createTimeS")));
} }
if (MapUtils.getLong(map, "endTime") != null) { if (MapUtils.getLong(map, "createTimeE") != null) {
criteria.andCreateTimeLessThan(new Date(MapUtils.getLong(map, "endTime"))); criteria.andCreateTimeLessThan(new Date(MapUtils.getLong(map, "createTimeE")));
} }
if (MapUtils.getString(map, "lotteryNo") != null) { if (MapUtils.getString(map, "lotteryNo") != null) {
criteria.andLotteryNoLike("%" + MapUtils.getString(map, "lotteryNo") + "%"); criteria.andLotteryNoLike("%" + MapUtils.getString(map, "lotteryNo") + "%");

@ -57,6 +57,14 @@ public class PartnerServiceImpl implements PartnerService {
if (isPartner(jsonObject.getLong("userId"))) { if (isPartner(jsonObject.getLong("userId"))) {
throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "用户当期已投入!"); throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "用户当期已投入!");
} }
Calendar calendar = Calendar.getInstance();
// 获取当前的小时
int hour = calendar.get(Calendar.HOUR_OF_DAY);
// 判断当前时间是否在 23点-24点之间
if (hour >= 23) {
throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "当前时间不允许投入!");
}
Long userId = jsonObject.getLong("userId"); Long userId = jsonObject.getLong("userId");
BigDecimal goldCoin = jsonObject.getBigDecimal("goldCoin"); BigDecimal goldCoin = jsonObject.getBigDecimal("goldCoin");
// 锁编号 // 锁编号
@ -164,30 +172,40 @@ public class PartnerServiceImpl implements PartnerService {
List<BsPartnerPoolPre> partnerPoolsPreL5 = partnerPoolPres.stream().filter(s-> s.getLevel().equals(5)).sorted(Comparator.comparing(BsPartnerPoolPre::getCampaignNo)).sorted(Comparator.comparing(BsPartnerPoolPre::getGoldCoin).reversed()).collect(Collectors.toList()); List<BsPartnerPoolPre> partnerPoolsPreL5 = partnerPoolPres.stream().filter(s-> s.getLevel().equals(5)).sorted(Comparator.comparing(BsPartnerPoolPre::getCampaignNo)).sorted(Comparator.comparing(BsPartnerPoolPre::getGoldCoin).reversed()).collect(Collectors.toList());
List<BsPartnerPoolPre> pres = new ArrayList<>(); List<BsPartnerPoolPre> pres = new ArrayList<>();
List<BsPartnerLevel> levelList = bsPartnerLevelService.queryAllList(new HashMap<>());
// 查询开奖记录 // 查询开奖记录
// 根据彩票号码查询合伙人池记录
BsPartnerPoolRecord partnerPoolRecord = bsPartnerPoolRecordService.queryDetail(lotteryNo); BsPartnerPoolRecord partnerPoolRecord = bsPartnerPoolRecordService.queryDetail(lotteryNo);
// 如果合伙人池记录不为空
if (partnerPoolRecord != null) { if (partnerPoolRecord != null) {
// 如果合伙人池记录状态为2,抛出异常
if (partnerPoolRecord.getStatus().equals(2)) { if (partnerPoolRecord.getStatus().equals(2)) {
throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "当期已经竞选结算!"); throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "当期已经竞选结算!");
} }
// 将合伙人池记录状态设置为2
partnerPoolRecord.setStatus(2); partnerPoolRecord.setStatus(2);
// 设置彩票时间
partnerPoolRecord.setLotteryTime(new Date()); partnerPoolRecord.setLotteryTime(new Date());
// 更新合伙人池记录
bsPartnerPoolRecordService.edit(partnerPoolRecord); bsPartnerPoolRecordService.edit(partnerPoolRecord);
} }
// todo 计算当期的时候需要先预站一个位置 如果当前用户大那么顺序往下走
// L1参选 // L1参选
for (BsPartnerPoolPre partnerPoolPre : partnerPoolsPreL1) { for (BsPartnerPoolPre partnerPoolPre : partnerPoolsPreL1) {
// 如果合伙人池预约状态为1
if (partnerPoolPre.getStatus().equals(1)) { if (partnerPoolPre.getStatus().equals(1)) {
// 查询还未被占位的合伙人位置并且当前合伙人金额大于 // 查询还未被占位的合伙人位置并且当前合伙人金额大于
List<BsPartnerPool> poolList = partnerPoolsL1.stream().filter(s-> s.getGoldCoin().compareTo(partnerPoolPre.getGoldCoin()) < 0).filter(s->s.getStatus().equals(1)).collect(Collectors.toList()); List<BsPartnerPool> poolList = partnerPoolsL1.stream().filter(s-> s.getGoldCoin().compareTo(partnerPoolPre.getGoldCoin()) < 0).filter(s->s.getStatus().equals(1)).collect(Collectors.toList());
// 如果查询结果不为空
if (!poolList.isEmpty()) { if (!poolList.isEmpty()) {
BsPartnerPool pool = poolList.get(0); BsPartnerPool pool = poolList.get(0);
// 竞选成功 // 竞选成功
if (pool.getUserId() != null) { if (pool.getUserId() != null) {
campaignPartner(partnerPoolPre , pool); BsPartnerLevel level = levelList.stream().filter(s-> s.getLevel().equals(pool.getLevel())).findFirst().orElse(null);
campaignPartner(partnerPoolPre , pool , level);
} }
// 配置参数 // 配置参数
pool.setUserId(partnerPoolPre.getUserId()); pool.setUserId(partnerPoolPre.getUserId());
@ -212,14 +230,20 @@ public class PartnerServiceImpl implements PartnerService {
// L2参选 // L2参选
for (BsPartnerPoolPre partnerPoolPre : partnerPoolsPreL2) { for (BsPartnerPoolPre partnerPoolPre : partnerPoolsPreL2) {
// 如果合伙人池预约状态为1
if (partnerPoolPre.getStatus().equals(1)) { if (partnerPoolPre.getStatus().equals(1)) {
// 查询还未被占位的合伙人位置并且当前合伙人金额大于
List<BsPartnerPool> poolList = partnerPoolsL2.stream().filter(s-> s.getGoldCoin().compareTo(partnerPoolPre.getGoldCoin()) < 0).filter(s->s.getStatus().equals(1)).collect(Collectors.toList()); List<BsPartnerPool> poolList = partnerPoolsL2.stream().filter(s-> s.getGoldCoin().compareTo(partnerPoolPre.getGoldCoin()) < 0).filter(s->s.getStatus().equals(1)).collect(Collectors.toList());
// 如果查询结果不为空
if (!poolList.isEmpty()) { if (!poolList.isEmpty()) {
BsPartnerPool pool = poolList.get(0); BsPartnerPool pool = poolList.get(0);
// 竞选成功
if (pool.getUserId() != null) { if (pool.getUserId() != null) {
campaignPartner(partnerPoolPre , pool); BsPartnerLevel level = levelList.stream().filter(s-> s.getLevel().equals(pool.getLevel())).findFirst().orElse(null);
campaignPartner(partnerPoolPre , pool , level);
} }
// 配置参数
pool.setUserId(partnerPoolPre.getUserId()); pool.setUserId(partnerPoolPre.getUserId());
pool.setGoldCoin(partnerPoolPre.getGoldCoin()); pool.setGoldCoin(partnerPoolPre.getGoldCoin());
pools.add(pool); pools.add(pool);
@ -232,6 +256,7 @@ public class PartnerServiceImpl implements PartnerService {
}) })
.collect(Collectors.toList()); .collect(Collectors.toList());
// 配置预约竞选参数
partnerPoolPre.setStatus(2); partnerPoolPre.setStatus(2);
partnerPoolPre.setNum(pool.getNum()); partnerPoolPre.setNum(pool.getNum());
pres.add(partnerPoolPre); pres.add(partnerPoolPre);
@ -242,13 +267,19 @@ public class PartnerServiceImpl implements PartnerService {
// L3参选 // L3参选
for (BsPartnerPoolPre partnerPoolPre : partnerPoolsPreL3) { for (BsPartnerPoolPre partnerPoolPre : partnerPoolsPreL3) {
// 如果合伙人池预约状态为1
if (partnerPoolPre.getStatus().equals(1)) { if (partnerPoolPre.getStatus().equals(1)) {
// 查询还未被占位的合伙人位置并且当前合伙人金额大于
List<BsPartnerPool> poolList = partnerPoolsL3.stream().filter(s-> s.getGoldCoin().compareTo(partnerPoolPre.getGoldCoin()) < 0).filter(s->s.getStatus().equals(1)).collect(Collectors.toList()); List<BsPartnerPool> poolList = partnerPoolsL3.stream().filter(s-> s.getGoldCoin().compareTo(partnerPoolPre.getGoldCoin()) < 0).filter(s->s.getStatus().equals(1)).collect(Collectors.toList());
// 如果查询结果不为空
if (!poolList.isEmpty()) { if (!poolList.isEmpty()) {
BsPartnerPool pool = poolList.get(0); BsPartnerPool pool = poolList.get(0);
// 竞选成功
if (pool.getUserId() != null) { if (pool.getUserId() != null) {
campaignPartner(partnerPoolPre , pool); BsPartnerLevel level = levelList.stream().filter(s-> s.getLevel().equals(pool.getLevel())).findFirst().orElse(null);
campaignPartner(partnerPoolPre , pool , level);
} }
// 配置参数
pool.setUserId(partnerPoolPre.getUserId()); pool.setUserId(partnerPoolPre.getUserId());
pool.setGoldCoin(partnerPoolPre.getGoldCoin()); pool.setGoldCoin(partnerPoolPre.getGoldCoin());
pools.add(pool); pools.add(pool);
@ -261,6 +292,7 @@ public class PartnerServiceImpl implements PartnerService {
}) })
.collect(Collectors.toList()); .collect(Collectors.toList());
// 配置预约竞选参数
partnerPoolPre.setStatus(2); partnerPoolPre.setStatus(2);
partnerPoolPre.setNum(pool.getNum()); partnerPoolPre.setNum(pool.getNum());
pres.add(partnerPoolPre); pres.add(partnerPoolPre);
@ -270,13 +302,19 @@ public class PartnerServiceImpl implements PartnerService {
// L4参选 // L4参选
for (BsPartnerPoolPre partnerPoolPre : partnerPoolsPreL4) { for (BsPartnerPoolPre partnerPoolPre : partnerPoolsPreL4) {
// 如果合伙人池预约状态为1
if (partnerPoolPre.getStatus().equals(1)) { if (partnerPoolPre.getStatus().equals(1)) {
// 查询还未被占位的合伙人位置并且当前合伙人金额大于
List<BsPartnerPool> poolList = partnerPoolsL4.stream().filter(s-> s.getGoldCoin().compareTo(partnerPoolPre.getGoldCoin()) < 0).filter(s->s.getStatus().equals(1)).collect(Collectors.toList()); List<BsPartnerPool> poolList = partnerPoolsL4.stream().filter(s-> s.getGoldCoin().compareTo(partnerPoolPre.getGoldCoin()) < 0).filter(s->s.getStatus().equals(1)).collect(Collectors.toList());
// 如果查询结果不为空
if (!poolList.isEmpty()) { if (!poolList.isEmpty()) {
BsPartnerPool pool = poolList.get(0); BsPartnerPool pool = poolList.get(0);
// 竞选成功
if (pool.getUserId() != null) { if (pool.getUserId() != null) {
campaignPartner(partnerPoolPre , pool); BsPartnerLevel level = levelList.stream().filter(s-> s.getLevel().equals(pool.getLevel())).findFirst().orElse(null);
campaignPartner(partnerPoolPre , pool , level);
} }
// 配置参数
pool.setUserId(partnerPoolPre.getUserId()); pool.setUserId(partnerPoolPre.getUserId());
pool.setGoldCoin(partnerPoolPre.getGoldCoin()); pool.setGoldCoin(partnerPoolPre.getGoldCoin());
pools.add(pool); pools.add(pool);
@ -289,6 +327,7 @@ public class PartnerServiceImpl implements PartnerService {
}) })
.collect(Collectors.toList()); .collect(Collectors.toList());
// 配置预约竞选参数
partnerPoolPre.setStatus(2); partnerPoolPre.setStatus(2);
partnerPoolPre.setNum(pool.getNum()); partnerPoolPre.setNum(pool.getNum());
pres.add(partnerPoolPre); pres.add(partnerPoolPre);
@ -298,13 +337,19 @@ public class PartnerServiceImpl implements PartnerService {
// L5参选 // L5参选
for (BsPartnerPoolPre partnerPoolPre : partnerPoolsPreL5) { for (BsPartnerPoolPre partnerPoolPre : partnerPoolsPreL5) {
// 如果合伙人池预约状态为1
if (partnerPoolPre.getStatus().equals(1)) { if (partnerPoolPre.getStatus().equals(1)) {
// 查询还未被占位的合伙人位置并且当前合伙人金额大于
List<BsPartnerPool> poolList = partnerPoolsL5.stream().filter(s-> s.getGoldCoin().compareTo(partnerPoolPre.getGoldCoin()) < 0).filter(s->s.getStatus().equals(1)).collect(Collectors.toList()); List<BsPartnerPool> poolList = partnerPoolsL5.stream().filter(s-> s.getGoldCoin().compareTo(partnerPoolPre.getGoldCoin()) < 0).filter(s->s.getStatus().equals(1)).collect(Collectors.toList());
// 如果查询结果不为空
if (!poolList.isEmpty()) { if (!poolList.isEmpty()) {
BsPartnerPool pool = poolList.get(0); BsPartnerPool pool = poolList.get(0);
// 竞选成功
if (pool.getUserId() != null) { if (pool.getUserId() != null) {
campaignPartner(partnerPoolPre , pool); BsPartnerLevel level = levelList.stream().filter(s-> s.getLevel().equals(pool.getLevel())).findFirst().orElse(null);
campaignPartner(partnerPoolPre , pool , level);
} }
// 配置参数
pool.setUserId(partnerPoolPre.getUserId()); pool.setUserId(partnerPoolPre.getUserId());
pool.setGoldCoin(partnerPoolPre.getGoldCoin()); pool.setGoldCoin(partnerPoolPre.getGoldCoin());
pools.add(pool); pools.add(pool);
@ -317,6 +362,7 @@ public class PartnerServiceImpl implements PartnerService {
}) })
.collect(Collectors.toList()); .collect(Collectors.toList());
// 配置预约竞选参数
partnerPoolPre.setStatus(2); partnerPoolPre.setStatus(2);
partnerPoolPre.setNum(pool.getNum()); partnerPoolPre.setNum(pool.getNum());
pres.add(partnerPoolPre); pres.add(partnerPoolPre);
@ -324,14 +370,18 @@ public class PartnerServiceImpl implements PartnerService {
} }
} }
// 更新合伙人池状态
for (BsPartnerPool pool : pools) { for (BsPartnerPool pool : pools) {
pool.setStatus(1); pool.setStatus(1);
pool.setUpdateTime(new Date()); pool.setUpdateTime(new Date());
bsPartnerPoolService.edit(pool); bsPartnerPoolService.edit(pool);
} }
// 更新合伙人池预约状态
for (BsPartnerPoolPre partnerPoolPre: pres) { for (BsPartnerPoolPre partnerPoolPre: pres) {
// 如果合伙人池预约状态为1
if (partnerPoolPre.getStatus().equals(1)) { if (partnerPoolPre.getStatus().equals(1)) {
// 将合伙人池预约状态设置为3
partnerPoolPre.setStatus(3); partnerPoolPre.setStatus(3);
partnerPoolPre.setUpdateTime(new Date()); partnerPoolPre.setUpdateTime(new Date());
BsUser user = bsUserService.getUser(partnerPoolPre.getUserId()); BsUser user = bsUserService.getUser(partnerPoolPre.getUserId());
@ -347,7 +397,6 @@ public class PartnerServiceImpl implements PartnerService {
} }
} }
@Override @Override
@ -358,12 +407,17 @@ public class PartnerServiceImpl implements PartnerService {
List<BsPartnerLevel> partnerLevels = bsPartnerLevelService.queryAllList(new HashMap<>()); List<BsPartnerLevel> partnerLevels = bsPartnerLevelService.queryAllList(new HashMap<>());
String lotteryNo = DateUtil.date2String(new Date() , DateUtil.YMD); String lotteryNo = DateUtil.date2String(new Date() , DateUtil.YMD);
for (BsPartnerPool pool : partnerPools) { for (BsPartnerPool pool : partnerPools) {
// 判断合伙人是否有金币且用户ID不为空
if (pool.getGoldCoin().compareTo(new BigDecimal(0)) > 0 && pool.getUserId() != null) { if (pool.getGoldCoin().compareTo(new BigDecimal(0)) > 0 && pool.getUserId() != null) {
// 根据合伙人等级查询分红等级
BsPartnerLevel level = partnerLevels.stream().filter(s-> s.getLevel().equals(pool.getLevel())).findFirst().get(); BsPartnerLevel level = partnerLevels.stream().filter(s-> s.getLevel().equals(pool.getLevel())).findFirst().get();
// 根据彩票编号和用户ID查询合伙人用户记录
BsPartnerUserRecord partnerUserRecord = bsPartnerUserRecordService.queryDetail(lotteryNo , pool.getUserId()); BsPartnerUserRecord partnerUserRecord = bsPartnerUserRecordService.queryDetail(lotteryNo , pool.getUserId());
// 根据用户ID查询用户信息
BsUser user = bsUserService.getUser(pool.getUserId()); BsUser user = bsUserService.getUser(pool.getUserId());
// 如果合伙人用户记录为空,则创建新的合伙人用户记录
if (partnerUserRecord == null) { if (partnerUserRecord == null) {
partnerUserRecord = new BsPartnerUserRecord(); partnerUserRecord = new BsPartnerUserRecord();
partnerUserRecord.setCreateTime(new Date()); partnerUserRecord.setCreateTime(new Date());
@ -372,6 +426,7 @@ public class PartnerServiceImpl implements PartnerService {
partnerUserRecord.setLotteryTime(new Date()); partnerUserRecord.setLotteryTime(new Date());
partnerUserRecord.setUserId(pool.getUserId()); partnerUserRecord.setUserId(pool.getUserId());
partnerUserRecord.setUserName(user.getName()); partnerUserRecord.setUserName(user.getName());
// 计算分红金额
partnerUserRecord.setGoldCoin(pool.getGoldCoin().multiply(level.getDividendsPer())); partnerUserRecord.setGoldCoin(pool.getGoldCoin().multiply(level.getDividendsPer()));
partnerUserRecord.setProportion(level.getDividendsPer()); partnerUserRecord.setProportion(level.getDividendsPer());
partnerUserRecord.setType(1); partnerUserRecord.setType(1);
@ -387,59 +442,124 @@ public class PartnerServiceImpl implements PartnerService {
userAccountService.recharge(user.getId(),partnerUserRecord.getGoldCoin(), UserAccountRecordSourceTypeEnum.type4, userRechargeParam); userAccountService.recharge(user.getId(),partnerUserRecord.getGoldCoin(), UserAccountRecordSourceTypeEnum.type4, userRechargeParam);
} }
} }
} }
} }
@Override @Override
public List<JSONObject> partnerData(Long startTime, Long endTime) throws Exception { public List<JSONObject> partnerData(Long createTimeS, Long createTimeE) throws Exception {
// 创建一个Map,用于存储查询参数
Map<String, Object> params = new HashMap<>(); Map<String, Object> params = new HashMap<>();
params.put("startTime", startTime); // 将createTimeS参数放入Map中
params.put("endTime", endTime); params.put("createTimeS", createTimeS);
// 将createTimeE参数放入Map中
params.put("createTimeE", createTimeE);
// 调用bsPartnerPoolPreService的queryAllList方法,查询所有符合条件的BsPartnerPoolPre对象,并将结果存入list中
List<BsPartnerPoolPre> list = bsPartnerPoolPreService.queryAllList(params); List<BsPartnerPoolPre> list = bsPartnerPoolPreService.queryAllList(params);
// 使用stream流将list中的BsPartnerPoolPre对象按照level进行分组,并将结果存入collect中
Map<Integer, List<BsPartnerPoolPre>> collect = list.stream().collect(Collectors.groupingBy(BsPartnerPoolPre::getLevel)); Map<Integer, List<BsPartnerPoolPre>> collect = list.stream().collect(Collectors.groupingBy(BsPartnerPoolPre::getLevel));
List<JSONObject> countRecords = collect.keySet().stream().map(key -> { // 如果collect不为空,则将collect中的数据转换为JSONObject对象,并存入list中
if (!collect.isEmpty()) {
return collect.keySet().stream().map(key -> {
// 创建一个JSONObject对象
JSONObject goodObject = new JSONObject(true);
// 将level放入JSONObject中
goodObject.put("level",key);
// 获取collect中level为key的BsPartnerPoolPre对象列表
List<BsPartnerPoolPre> pres = collect.get(key);
// 将pres的大小放入JSONObject中
goodObject.put("campaignUserNum", pres.size());
// 将pres中所有BsPartnerPoolPre对象的goldCoin相加,并存入JSONObject中
goodObject.put("campaignGoldCoin", pres.stream().map(BsPartnerPoolPre::getGoldCoin).reduce(BigDecimal.ZERO, BigDecimal::add));
// 返回JSONObject对象
return goodObject;
}).collect(Collectors.toList());
}
// 调用bsPartnerLevelService的queryAllList方法,查询所有BsPartnerLevel对象,并将结果存入levelList中
List<BsPartnerLevel> levelList = bsPartnerLevelService.queryAllList(new HashMap<>());
// 使用stream流将levelList中的BsPartnerLevel对象按照level进行分组,并将结果存入listMap中
Map<Integer, List<BsPartnerLevel>> listMap = levelList.stream().collect(Collectors.groupingBy(BsPartnerLevel::getLevel));
// 将listMap中的数据转换为JSONObject对象,并存入list中
return listMap.keySet().stream().map(key -> {
// 创建一个JSONObject对象
JSONObject goodObject = new JSONObject(true); JSONObject goodObject = new JSONObject(true);
// 将level放入JSONObject中
goodObject.put("level",key); goodObject.put("level",key);
List<BsPartnerPoolPre> pres = collect.get(key); // 将campaignUserNum设置为0
goodObject.put("campaignUserNum", pres.size()); goodObject.put("campaignUserNum", 0);
goodObject.put("campaignGoldCoin", pres.stream().map(BsPartnerPoolPre::getGoldCoin).reduce(BigDecimal.ZERO, BigDecimal::add)); // 将campaignGoldCoin设置为BigDecimal.ZERO
goodObject.put("campaignGoldCoin", BigDecimal.ZERO);
// 返回JSONObject对象
return goodObject; return goodObject;
}).collect(Collectors.toList()); }).collect(Collectors.toList());
return countRecords;
} }
@Override @Override
public List<JSONObject> dividendData(Long startTime, Long endTime) throws Exception { public List<JSONObject> dividendData(Long createTimeS, Long createTimeE) throws Exception {
// 创建一个Map,用于存储查询参数
Map<String, Object> params = new HashMap<>(); Map<String, Object> params = new HashMap<>();
params.put("startTime", startTime); // 将createTimeS参数存入Map
params.put("endTime", endTime); params.put("createTimeS", createTimeS);
// 将createTimeE参数存入Map
params.put("createTimeE", createTimeE);
// 将type参数存入Map
params.put("type", 1); params.put("type", 1);
// 根据参数查询所有用户记录
List<BsPartnerUserRecord> userRecords = bsPartnerUserRecordService.queryAllList(params); List<BsPartnerUserRecord> userRecords = bsPartnerUserRecordService.queryAllList(params);
Map<Integer, List<BsPartnerUserRecord>> collect = userRecords.stream().collect(Collectors.groupingBy(BsPartnerUserRecord::getLevel)); // 如果查询结果不为空
List<JSONObject> countRecords = collect.keySet().stream().map(key -> { if (!userRecords.isEmpty()) {
// 将查询结果按照level进行分组
Map<Integer, List<BsPartnerUserRecord>> collect = userRecords.stream().collect(Collectors.groupingBy(BsPartnerUserRecord::getLevel));
// 返回分组后的结果
return collect.keySet().stream().map(key -> {
// 创建一个JSONObject对象
JSONObject goodObject = new JSONObject(true);
// 将level存入JSONObject
goodObject.put("level",key);
// 获取当前level的用户记录
List<BsPartnerUserRecord> pres = collect.get(key);
// 将用户记录数量存入JSONObject
goodObject.put("dividendCount", pres.size());
// 将用户记录的金币数量累加存入JSONObject
goodObject.put("dividendGoldCoin", pres.stream().map(BsPartnerUserRecord::getGoldCoin).reduce(BigDecimal.ZERO, BigDecimal::add));
// 返回JSONObject
return goodObject;
}).collect(Collectors.toList());
}
// 如果查询结果为空,查询所有等级
List<BsPartnerLevel> list = bsPartnerLevelService.queryAllList(new HashMap<>());
// 将查询结果按照level进行分组
Map<Integer, List<BsPartnerLevel>> listMap = list.stream().collect(Collectors.groupingBy(BsPartnerLevel::getLevel));
// 返回分组后的结果
return listMap.keySet().stream().map(key -> {
// 创建一个JSONObject对象
JSONObject goodObject = new JSONObject(true); JSONObject goodObject = new JSONObject(true);
// 将level存入JSONObject
goodObject.put("level",key); goodObject.put("level",key);
List<BsPartnerUserRecord> pres = collect.get(key); // 将用户记录数量存入JSONObject
goodObject.put("dividendCount", pres.size()); goodObject.put("dividendCount", 0);
goodObject.put("dividendGoldCoin", pres.stream().map(BsPartnerUserRecord::getGoldCoin).reduce(BigDecimal.ZERO, BigDecimal::add)); // 将用户记录的金币数量存入JSONObject
goodObject.put("dividendGoldCoin", BigDecimal.ZERO);
// 返回JSONObject
return goodObject; return goodObject;
}).collect(Collectors.toList()); }).collect(Collectors.toList());
return countRecords;
} }
// 竞选成功返利 // 竞选成功返利
private void campaignPartner(BsPartnerPoolPre partnerPoolPre , BsPartnerPool pool) throws Exception { private void campaignPartner(BsPartnerPoolPre partnerPoolPre , BsPartnerPool pool , BsPartnerLevel level) throws Exception {
// 创建BsPartnerUserRecord对象
BsPartnerUserRecord userRecord = new BsPartnerUserRecord(); BsPartnerUserRecord userRecord = new BsPartnerUserRecord();
// 根据pool.getUserId()获取BsUser对象
BsUser bsUser = bsUserService.getUser(pool.getUserId()); BsUser bsUser = bsUserService.getUser(pool.getUserId());
// 查询差价 // 查询差价
BigDecimal differencePrice = partnerPoolPre.getGoldCoin().subtract(pool.getGoldCoin()); BigDecimal differencePrice = partnerPoolPre.getGoldCoin().subtract(pool.getGoldCoin());
@ -462,6 +582,16 @@ public class PartnerServiceImpl implements PartnerService {
pre.setUpdateTime(new Date()); pre.setUpdateTime(new Date());
bsPartnerPoolPreService.edit(pre); bsPartnerPoolPreService.edit(pre);
// 如果level不为空
if (level != null) {
// 设置用户合伙人收入比例
bsUser.setPartnerIncomePer(level.getIncomePer());
// 设置用户合伙人等级
bsUser.setPartnerLevel(level.getLevel());
// 编辑用户数据
bsUserService.updateInfo(bsUser);
}
// 收益记录 // 收益记录
Map<String, Object> userRechargeParam = new HashMap<>(); Map<String, Object> userRechargeParam = new HashMap<>();
userRechargeParam.put("sourceId", userRecord.getId()); userRechargeParam.put("sourceId", userRecord.getId());

@ -36,22 +36,22 @@ public interface PartnerService {
/** /**
* @MethodName partnerData * @MethodName partnerData
* @Description: 合伙人数据统计 * @Description: 合伙人数据统计
* @param startTime * @param createTimeS
* @param endTime * @param createTimeE
* @return: com.alibaba.fastjson.JSONObject * @return: com.alibaba.fastjson.JSONObject
* @Author: Sum1Dream * @Author: Sum1Dream
* @Date: 2024/10/18 下午2:06 * @Date: 2024/10/18 下午2:06
*/ */
List<JSONObject> partnerData(Long startTime, Long endTime) throws Exception; List<JSONObject> partnerData(Long createTimeS, Long createTimeE) throws Exception;
/** /**
* @MethodName dividendData * @MethodName dividendData
* @Description: 分红统计 * @Description: 分红统计
* @param startTime * @param createTimeS
* @param endTime * @param createTimeE
* @return: com.alibaba.fastjson.JSONObject * @return: com.alibaba.fastjson.JSONObject
* @Author: Sum1Dream * @Author: Sum1Dream
* @Date: 2024/10/18 下午2:25 * @Date: 2024/10/18 下午2:25
*/ */
List<JSONObject> dividendData(Long startTime, Long endTime) throws Exception; List<JSONObject> dividendData(Long createTimeS, Long createTimeE) throws Exception;
} }

@ -2,22 +2,19 @@ package com.hfkj.service.pdd;
import com.alibaba.fastjson.JSON; import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject; import com.alibaba.fastjson.JSONObject;
import com.hfkj.common.utils.DateUtil;
import com.pdd.pop.sdk.common.util.JsonUtil; import com.pdd.pop.sdk.common.util.JsonUtil;
import com.pdd.pop.sdk.http.PopClient; import com.pdd.pop.sdk.http.PopClient;
import com.pdd.pop.sdk.http.PopHttpClient; import com.pdd.pop.sdk.http.PopHttpClient;
import com.pdd.pop.sdk.http.api.pop.request.PddDdkGoodsPromotionUrlGenerateRequest; import com.pdd.pop.sdk.http.api.pop.request.*;
import com.pdd.pop.sdk.http.api.pop.request.PddDdkGoodsSearchRequest; import com.pdd.pop.sdk.http.api.pop.response.*;
import com.pdd.pop.sdk.http.api.pop.request.PddDdkMemberAuthorityQueryRequest;
import com.pdd.pop.sdk.http.api.pop.request.PddDdkRpPromUrlGenerateRequest;
import com.pdd.pop.sdk.http.api.pop.response.PddDdkGoodsPromotionUrlGenerateResponse;
import com.pdd.pop.sdk.http.api.pop.response.PddDdkGoodsSearchResponse;
import com.pdd.pop.sdk.http.api.pop.response.PddDdkMemberAuthorityQueryResponse;
import com.pdd.pop.sdk.http.api.pop.response.PddDdkRpPromUrlGenerateResponse;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
import javax.xml.crypto.Data;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Date;
import java.util.List; import java.util.List;
public class PddService { public class PddService {
@ -163,5 +160,36 @@ public class PddService {
} }
/**
* @MethodName getOrderList
* @Description:用时间段查询推广订单接口
* @param
* @return: com.alibaba.fastjson.JSONObject
* @Author: Sum1Dream
* @Date: 2024/10/23 上午10:27
*/
public static JSONObject getOrderList() throws Exception {
log.info("============ 拼多多请求-START =============");
String clientId = "71a050c5d93d4169a237539af44c7c33";
String clientSecret = "b96def667dd28660d09f19ba2e9e9f23d810d563";
PopClient client = new PopHttpClient(clientId, clientSecret);
PddDdkOrderListRangeGetRequest request = new PddDdkOrderListRangeGetRequest();
request.setCashGiftOrder(true);
request.setStartTime("2024-05-07 00:00:00");
request.setPageSize(300);
request.setEndTime(DateUtil.format(new Date(), "yyyy-MM-dd HH:mm:ss"));
PddDdkOrderListRangeGetResponse response = client.syncInvoke(request);
log.info("请求接口:" + "authority");
log.info("请求参数:" + JSONObject.toJSONString(request));
log.info("响应参数:" + JsonUtil.transferToJson(response));
log.info("============ 拼多多请求-END ==============");
return JSONObject.parseObject(JSON.toJSONString(response));
}
} }

@ -0,0 +1,29 @@
package com.hfkj.service.promotion.Impl;
import com.alibaba.fastjson.JSONObject;
import com.hfkj.service.promotion.PromotionBusinessService;
import com.hfkj.service.promotion.PromotionService;
import org.springframework.stereotype.Service;
import javax.annotation.Resource;
@Service("promotionService")
public class PromotionServiceImpl implements PromotionService {
@Resource
private PromotionBusinessService promotionBusinessService;
@Override
public JSONObject createUrl(JSONObject body) throws Exception {
// 淘宝订单业务
if (body.getInteger("type") == 1) {
return promotionBusinessService.taobaoUrl(body);
}
// 拼多多订单业务
if (body.getInteger("type") == 2) {
return promotionBusinessService.pddUrl(body);
}
return null;
}
}

@ -0,0 +1,63 @@
package com.hfkj.service.promotion;
import com.alibaba.fastjson.JSONObject;
import com.hfkj.common.exception.ErrorCode;
import com.hfkj.common.exception.ErrorHelp;
import com.hfkj.common.exception.SysCode;
import com.hfkj.service.pdd.PddService;
import com.hfkj.service.taobao.TaoBaoService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Component;
import java.util.HashMap;
import java.util.Map;
/**
* 创建推广业务
* @className: PromotionBusinessService
* @author: HuRui
* @date: 2024/5/7
**/
@Component
public class PromotionBusinessService {
Logger log = LoggerFactory.getLogger(PromotionBusinessService.class);
// 淘口令生成业务
public JSONObject taobaoUrl(JSONObject jsonObject) throws Exception{
JSONObject object = TaoBaoService.createCommand(jsonObject.getString("url"));
if (!object.getBoolean("success")) {
throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "请求失败!");
}
return object.getJSONObject("data");
}
//多多进宝推广链接生成
public JSONObject pddUrl(JSONObject jsonObject) throws Exception{
String goodsSign = jsonObject.getString("goodsSign");
String searchId = jsonObject.getString("searchId");
if (searchId == null) {
throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "缺少searchId!");
}
if (goodsSign == null) {
throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "缺少goodsSign!");
}
Map<String , Object> mapUser = new HashMap<>();
mapUser.put("uid", jsonObject.getLong("userId"));
// 判断是否需要授权
JSONObject object = PddService.authority(mapUser.toString());
boolean generateAuthorityUrl = object.getJSONObject("authorityQueryResponse").getInteger("bind") == 0;
JSONObject o = PddService.promotion(searchId , goodsSign , generateAuthorityUrl , mapUser.toString());
return o.getJSONObject("goodsPromotionUrlGenerateResponse").getJSONArray("goodsPromotionUrlList").getJSONObject(0);
}
}

@ -0,0 +1,20 @@
package com.hfkj.service.promotion;
import com.alibaba.fastjson.JSONObject;
/**
* @ClassName PromotionService
* @Author Sum1Dream
* @Description
* @Date 2024/10/23 上午10:26
**/
public interface PromotionService {
/**
* 创建推广链接
* @param jsonObject 订单
* @return
*/
JSONObject createUrl(JSONObject jsonObject) throws Exception;
}

@ -1,15 +1,10 @@
package com.hfkj.service.taobao; package com.hfkj.service.taobao;
import com.alibaba.fastjson.JSON; import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject; import com.alibaba.fastjson.JSONObject;
import com.hfkj.common.exception.ErrorCode; import com.hfkj.common.exception.ErrorCode;
import com.hfkj.common.exception.ErrorHelp; import com.hfkj.common.exception.ErrorHelp;
import com.hfkj.common.exception.SysCode; import com.hfkj.common.exception.SysCode;
import com.hfkj.common.utils.ResponseMsgUtil;
import com.hfkj.entity.SecDictionary;
import com.hfkj.model.*;
import com.hfkj.service.sec.SecDictionaryService;
import com.taobao.top.DefaultTopApiClient; import com.taobao.top.DefaultTopApiClient;
import com.taobao.top.TopApiClient; import com.taobao.top.TopApiClient;
import com.taobao.top.ability304.Ability304; import com.taobao.top.ability304.Ability304;
@ -181,26 +176,6 @@ public class TaoBaoService {
return JSONObject.parseObject(JSON.toJSONString(response)); return JSONObject.parseObject(JSON.toJSONString(response));
} }
public static JSONObject officialActivity(String clickUrl) throws Exception {
log.info("============ 淘口令生成-START =============");
TopApiClient client = new DefaultTopApiClient(appKey,appsecret,url);
Ability375 apiPackage = new Ability375(client);
// create domain
// create request
TaobaoTbkTpwdCreateRequest request = new TaobaoTbkTpwdCreateRequest();
request.setUrl(clickUrl);
TaobaoTbkTpwdCreateResponse response = apiPackage.taobaoTbkTpwdCreate(request);
log.info("请求接口:" + "taobaoTbkTpwdCreate");
log.info("请求参数:" + JSONObject.toJSONString(request));
log.info("响应参数:" + response);
log.info("============ 淘口令生成--END ==============");
return JSONObject.parseObject(JSON.toJSONString(response));
}
} }

@ -3,6 +3,7 @@ package com.hfkj.service.user;
import com.hfkj.entity.BsUserAccountRecord; import com.hfkj.entity.BsUserAccountRecord;
import java.math.BigDecimal; import java.math.BigDecimal;
import java.util.Date;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
@ -38,5 +39,5 @@ public interface BsUserAccountRecordService {
* @param userId * @param userId
* @return * @return
*/ */
BigDecimal getUserTotalProfit(Long userId); BigDecimal getUserTotalProfit(Long userId, Date timeS, Date timeE);
} }

@ -16,13 +16,13 @@ public interface BsUserGradeService {
* @param userId * @param userId
* @param userGrade * @param userGrade
*/ */
void gradeAdjust(Long userId, UserGradeEnum userGrade); void gradeAdjust(Long userId, UserGradeEnum userGrade) throws Exception;
/** /**
* 等级晋升 * 等级晋升
* @param userId * @param userId
*/ */
void promote(Long userId); void promote(Long userId) throws Exception;
/** /**
* 购买优淘会员 * 购买优淘会员

@ -72,18 +72,36 @@ public interface BsUserService {
BsUser getUser(Long userId); BsUser getUser(Long userId);
/** /**
* 查询详情SmsController * 查询详情
* @param userPhone * @param userPhone
* @return * @return
*/ */
BsUser getUser(String userPhone); BsUser getUser(String userPhone);
/**
* 查询详情
* @param wechatOpenId
* @return
*/
BsUser getUserByWechatOpenId(String wechatOpenId);
/** /**
* 查询列表 * 查询列表
* @param param * @param param
* @return * @return
*/ */
List<BsUser> getList(Map<String,Object> param); List<BsUser> getList(Map<String,Object> param);
/**
* 微信授权
* @param user 用户
* @param other 其他参数
* @param inviteUseId 邀请人id
* @return
* @throws Exception
*/
SessionObject weChatAuth(BsUser user, Map<String, Object> other, Long inviteUseId) throws Exception;
/** /**
* 用户注册 * 用户注册
* @param phone 手机号 * @param phone 手机号

@ -1,5 +1,6 @@
package com.hfkj.service.user.impl; package com.hfkj.service.user.impl;
import com.hfkj.common.utils.DateUtil;
import com.hfkj.dao.BsUserAccountRecordMapper; import com.hfkj.dao.BsUserAccountRecordMapper;
import com.hfkj.entity.BsUserAccountRecord; import com.hfkj.entity.BsUserAccountRecord;
import com.hfkj.entity.BsUserAccountRecordExample; import com.hfkj.entity.BsUserAccountRecordExample;
@ -56,7 +57,19 @@ public class BsUserAccountRecordServiceImpl implements BsUserAccountRecordServic
} }
@Override @Override
public BigDecimal getUserTotalProfit(Long userId) { public BigDecimal getUserTotalProfit(Long userId, Date timeS, Date timeE) {
return userAccountRecordMapper.queryUserTotalProfit(userId); String timeSStr = null;
String timeEStr = null;
try {
if (timeS != null) {
timeSStr = DateUtil.date2String(timeS, DateUtil.Y_M_D_HMS);
}
if (timeE != null) {
timeEStr = DateUtil.date2String(timeE, DateUtil.Y_M_D_HMS);
}
} catch (Exception e) { }
return userAccountRecordMapper.queryUserTotalProfit(userId,timeSStr,timeEStr);
} }
} }

@ -37,14 +37,14 @@ public class BsUserGradeServiceImpl implements BsUserGradeService {
@Override @Override
@Transactional(propagation= Propagation.REQUIRED,rollbackFor= {RuntimeException.class}) @Transactional(propagation= Propagation.REQUIRED,rollbackFor= {RuntimeException.class})
public void gradeAdjust(Long userId, UserGradeEnum userGrade) { public void gradeAdjust(Long userId, UserGradeEnum userGrade) throws Exception {
// 查询详情 // 查询详情
BsUser user = userService.getUser(userId); BsUser user = userService.getUser(userId);
if (user == null) { if (user == null) {
throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, ""); throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "未找到用户");
} }
user.setGrade(userGrade.getCode()); user.setGrade(userGrade.getCode());
userService.editData(user); userService.updateInfo(user);
// 修改上下级关系等级 // 修改上下级关系等级
userParentRelService.updateParentGrade(user.getId(), userGrade); userParentRelService.updateParentGrade(user.getId(), userGrade);
@ -52,7 +52,7 @@ public class BsUserGradeServiceImpl implements BsUserGradeService {
@Override @Override
@Transactional(propagation= Propagation.REQUIRED,rollbackFor= {RuntimeException.class}) @Transactional(propagation= Propagation.REQUIRED,rollbackFor= {RuntimeException.class})
public void promote(Long userId) { public void promote(Long userId) throws Exception {
// 查询详情 // 查询详情
BsUser user = userService.getUser(userId); BsUser user = userService.getUser(userId);
if (user == null) { if (user == null) {
@ -62,7 +62,7 @@ public class BsUserGradeServiceImpl implements BsUserGradeService {
// 晋升优淘会员 // 晋升优淘会员
if (promoteGrade2(user)) { if (promoteGrade2(user)) {
user.setGrade(UserGradeEnum.grade2.getCode()); user.setGrade(UserGradeEnum.grade2.getCode());
userService.editData(user); userService.updateInfo(user);
// 修改上下级关系等级 // 修改上下级关系等级
userParentRelService.updateParentGrade(user.getId(), UserGradeEnum.grade2); userParentRelService.updateParentGrade(user.getId(), UserGradeEnum.grade2);
@ -71,7 +71,7 @@ public class BsUserGradeServiceImpl implements BsUserGradeService {
// 晋升团长 // 晋升团长
if (promoteGrade3(user)) { if (promoteGrade3(user)) {
user.setGrade(UserGradeEnum.grade3.getCode()); user.setGrade(UserGradeEnum.grade3.getCode());
userService.editData(user); userService.updateInfo(user);
// 修改上下级关系等级 // 修改上下级关系等级
userParentRelService.updateParentGrade(user.getId(), UserGradeEnum.grade3); userParentRelService.updateParentGrade(user.getId(), UserGradeEnum.grade3);
@ -80,7 +80,7 @@ public class BsUserGradeServiceImpl implements BsUserGradeService {
// 晋升渠道 // 晋升渠道
if (promoteGrade4(user)) { if (promoteGrade4(user)) {
user.setGrade(UserGradeEnum.grade4.getCode()); user.setGrade(UserGradeEnum.grade4.getCode());
userService.editData(user); userService.updateInfo(user);
// 修改上下级关系等级 // 修改上下级关系等级
userParentRelService.updateParentGrade(user.getId(), UserGradeEnum.grade4); userParentRelService.updateParentGrade(user.getId(), UserGradeEnum.grade4);
@ -116,7 +116,7 @@ public class BsUserGradeServiceImpl implements BsUserGradeService {
} }
// 条件二(元宝收益达到5元宝) // 条件二(元宝收益达到5元宝)
BigDecimal profit = userAccountRecordService.getUserTotalProfit(userId); BigDecimal profit = userAccountRecordService.getUserTotalProfit(userId,null,null);
map.put("condition2", profit); map.put("condition2", profit);
return map; return map;
@ -137,7 +137,7 @@ public class BsUserGradeServiceImpl implements BsUserGradeService {
map.put("condition2", subData.stream().filter(o -> o.getRelType().equals(2)).count()); map.put("condition2", subData.stream().filter(o -> o.getRelType().equals(2)).count());
// 条件三(累计元宝收益达到100元宝) // 条件三(累计元宝收益达到100元宝)
BigDecimal profit = userAccountRecordService.getUserTotalProfit(userId); BigDecimal profit = userAccountRecordService.getUserTotalProfit(userId,null,null);
map.put("condition3", profit); map.put("condition3", profit);
return map; return map;
@ -159,7 +159,7 @@ public class BsUserGradeServiceImpl implements BsUserGradeService {
map.put("condition2", directlyUnderData.stream().filter(o -> o.getRelType().equals(2)).count()); map.put("condition2", directlyUnderData.stream().filter(o -> o.getRelType().equals(2)).count());
// 条件三(累计元宝收益达到10000元宝) // 条件三(累计元宝收益达到10000元宝)
BigDecimal profit = userAccountRecordService.getUserTotalProfit(userId); BigDecimal profit = userAccountRecordService.getUserTotalProfit(userId, null, null);
map.put("condition3", profit); map.put("condition3", profit);
return map; return map;

@ -92,13 +92,8 @@ public class BsUserServiceImpl implements BsUserService {
} }
String oldPhone = user.getPhone(); String oldPhone = user.getPhone();
user.setPhone(newPhone); user.setPhone(newPhone);
editData(user); updateInfo(user);
// 更新session
UserSessionObject session = new UserSessionObject();
session.setUser(user);
SessionObject sessionObject = new SessionObject(userToken(user.getId()), session);
userCenter.save(sessionObject);
// 删除缓存 // 删除缓存
redisUtil.hdel(CACHE_KEY, oldPhone); redisUtil.hdel(CACHE_KEY, oldPhone);
} }
@ -123,13 +118,7 @@ public class BsUserServiceImpl implements BsUserService {
throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "未找到用户"); throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "未找到用户");
} }
user.setWechatNum(wechatNum); user.setWechatNum(wechatNum);
editData(user); updateInfo(user);
// 更新session
UserSessionObject session = new UserSessionObject();
session.setUser(user);
SessionObject sessionObject = new SessionObject(userToken(user.getId()), session);
userCenter.save(sessionObject);
} }
@Override @Override
@ -145,21 +134,15 @@ public class BsUserServiceImpl implements BsUserService {
if (getUser(inviteUseId) == null) { if (getUser(inviteUseId) == null) {
throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "未知的邀请人Id"); throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "未知的邀请人Id");
} }
user.setInviteUserId(inviteUseId);
user.setInviteTime(new Date());
editData(user);
BsUserParentRel userParentRel = new BsUserParentRel(); BsUserParentRel userParentRel = new BsUserParentRel();
userParentRel.setParentUserId(userParentRel.getParentUserId()); userParentRel.setParentUserId(userParentRel.getParentUserId());
userParentRel.setParentUserGrade(userParentRel.getParentUserGrade()); userParentRel.setParentUserGrade(userParentRel.getParentUserGrade());
userParentRel.setUserId(userId); userParentRel.setUserId(userId);
userParentRelService.editData(userParentRel); userParentRelService.editData(userParentRel);
// 更新session user.setInviteUserId(inviteUseId);
UserSessionObject session = new UserSessionObject(); user.setInviteTime(new Date());
session.setUser(user); updateInfo(user);
SessionObject sessionObject = new SessionObject(userToken(user.getId()), session);
userCenter.save(sessionObject);
} }
@Override @Override
@ -250,6 +233,17 @@ public class BsUserServiceImpl implements BsUserService {
return null; return null;
} }
@Override
public BsUser getUserByWechatOpenId(String wechatOpenId) {
BsUserExample example = new BsUserExample();
example.createCriteria().andStatusNotEqualTo(0).andWechatOpenIdEqualTo(wechatOpenId);
List<BsUser> list = userMapper.selectByExample(example);
if (!list.isEmpty()) {
return list.get(0);
}
return null;
}
@Override @Override
public List<BsUser> getList(Map<String, Object> param) { public List<BsUser> getList(Map<String, Object> param) {
BsUserExample example = new BsUserExample(); BsUserExample example = new BsUserExample();
@ -279,6 +273,49 @@ public class BsUserServiceImpl implements BsUserService {
return userMapper.selectByExample(example); return userMapper.selectByExample(example);
} }
@Override
@Transactional(propagation= Propagation.REQUIRED,rollbackFor= {RuntimeException.class})
public SessionObject weChatAuth(BsUser user, Map<String, Object> other, Long inviteUseId) throws Exception {
if (inviteUseId != null) {
// 校验邀请码
BsUserInviteCode userInviteCode = userInviteCodeService.getDetail(inviteUseId);
if (userInviteCode == null) {
throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "无效的邀请码");
}
user.setInviteUserId(userInviteCode.getUserId());
}
// 查询用户
BsUser bsUser = getUserByWechatOpenId(user.getWechatOpenId());
if (bsUser == null) {
bsUser = new BsUser();
bsUser.setHeadImg(user.getHeadImg());
bsUser.setName(user.getName());
bsUser.setWechatOpenId(user.getWechatOpenId());
bsUser.setWechatUnionid(user.getWechatUnionid());
bsUser.setGrade(UserGradeEnum.grade1.getCode());
bsUser.setStatus(UserStatusEnum.status1.getCode());
editData(bsUser);
// 创建账户余额
userAccountService.create(bsUser.getId());
} else {
bsUser.setHeadImg(user.getHeadImg());
bsUser.setName(user.getName());
bsUser.setInviteUserId(inviteUseId);
bsUser.setInviteTime(new Date());
updateInfo(bsUser);
}
// 缓存
UserSessionObject session = new UserSessionObject();
session.setUser(bsUser);
SessionObject sessionObject = new SessionObject(userToken(bsUser.getId()), session);
userCenter.save(sessionObject);
// 异步记录登录信息
userLoginLogService.asyncCreateLog(UserLoginType.WECHAT_AUTH, bsUser, (HttpServletRequest) RequestContextHolder.getRequestAttributes().resolveReference(RequestAttributes.REFERENCE_REQUEST));
return sessionObject;
}
@Override @Override
@Transactional(propagation= Propagation.REQUIRED,rollbackFor= {RuntimeException.class}) @Transactional(propagation= Propagation.REQUIRED,rollbackFor= {RuntimeException.class})
public BsUser register(String phone, Map<String, Object> other, Long inviteUseId) { public BsUser register(String phone, Map<String, Object> other, Long inviteUseId) {

@ -19,7 +19,7 @@ public enum UserLoginType {
/** /**
* 微信授权 * 微信授权
*/ */
WECHAT_EMPOWER("WECHAT_EMPOWER", "微信授权"), WECHAT_AUTH("WECHAT_AUTH", "微信授权"),
; ;
private String code; private String code;

Loading…
Cancel
Save