diff --git a/bweb/src/main/java/com/hfkj/controller/order/BsOrderController.java b/bweb/src/main/java/com/hfkj/controller/order/BsOrderController.java index 4f27c74..e1e6f27 100644 --- a/bweb/src/main/java/com/hfkj/controller/order/BsOrderController.java +++ b/bweb/src/main/java/com/hfkj/controller/order/BsOrderController.java @@ -4,7 +4,9 @@ import com.github.pagehelper.PageHelper; import com.github.pagehelper.PageInfo; 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.BsOrder; import com.hfkj.model.ResponseData; import com.hfkj.model.SecUserSessionObject; import com.hfkj.service.order.BsOrderService; @@ -20,8 +22,9 @@ import org.springframework.web.bind.annotation.ResponseBody; import javax.annotation.Resource; import javax.servlet.http.HttpServletRequest; -import java.util.HashMap; -import java.util.Map; +import java.math.BigDecimal; +import java.util.*; +import java.util.stream.Collectors; @Controller @RequestMapping(value="/order") @@ -66,4 +69,75 @@ public class BsOrderController { } } + @RequestMapping(value="/statisticsOrder",method = RequestMethod.GET) + @ResponseBody + @ApiOperation(value = "统计订单") + public ResponseData statisticsOrder() { + // 今日时间 + Map todayTime = DateUtil.getTodayTimeObj(); + // 昨日时间 + Map yesterdayTime = DateUtil.getYesterdayTimeObj(); + // 本月时间 + Map thisMonthTime = DateUtil.getThisMonthTimeObj(); + // 上月时间 + Map 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 orderList = orderService.getOrderList(new HashMap<>()); + + Map map = new HashMap<>(); + + // 平台总订单数 + Map 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 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 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); + + } + } diff --git a/bweb/src/main/java/com/hfkj/controller/partner/PartnerController.java b/bweb/src/main/java/com/hfkj/controller/partner/PartnerController.java index e179473..9dace49 100644 --- a/bweb/src/main/java/com/hfkj/controller/partner/PartnerController.java +++ b/bweb/src/main/java/com/hfkj/controller/partner/PartnerController.java @@ -1,6 +1,8 @@ package com.hfkj.controller.partner; 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.ErrorHelp; import com.hfkj.common.exception.SysCode; @@ -42,18 +44,21 @@ public class PartnerController { @Resource private PartnerService partnerService; + @Resource + private BsPartnerPoolPreService bsPartnerPoolPreService; + @RequestMapping(value="/partnerData",method = RequestMethod.GET) @ResponseBody @ApiOperation(value = "合伙人统计") public ResponseData partnerData( - @RequestParam(value = "startTime" , required = false) Long startTime, - @RequestParam(value = "endTime" , required = false) Long endTime + @RequestParam(value = "createTimeS" , required = false) Long createTimeS, + @RequestParam(value = "createTimeE" , required = false) Long createTimeE ) { try { - return ResponseMsgUtil.success(partnerService.partnerData(startTime , endTime)); + return ResponseMsgUtil.success(partnerService.partnerData(createTimeS , createTimeE)); } catch (Exception e) { log.error("error!",e); @@ -65,12 +70,43 @@ public class PartnerController { @ResponseBody @ApiOperation(value = "分红统计") public ResponseData dividendData( - @RequestParam(value = "startTime" , required = false) Long startTime, - @RequestParam(value = "endTime" , required = false) Long endTime + @RequestParam(value = "createTimeS" , required = false) Long createTimeS, + @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 { - return ResponseMsgUtil.success(partnerService.dividendData(startTime , endTime)); + Map 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) { log.error("error!",e); diff --git a/bweb/src/main/resources/prod/application.yml b/bweb/src/main/resources/prod/application.yml index 18a5cc0..8d5c08d 100644 --- a/bweb/src/main/resources/prod/application.yml +++ b/bweb/src/main/resources/prod/application.yml @@ -1,5 +1,5 @@ server: - port: 9302 + port: 9102 servlet: context-path: /brest @@ -9,9 +9,9 @@ debug: false #datasource数据源设置 spring: datasource: - url: jdbc:mysql://127.0.0.1:3306/hsg?allowMultiQueries=true&useUnicode=true&characterEncoding=UTF-8 - username: root - password: HF123456. + url: jdbc:mysql://127.0.0.1:3306/youtao?allowMultiQueries=true&useUnicode=true&characterEncoding=UTF-8&useSSL=false + username: yqyt + password: yqyt123!@#Mysql type: com.alibaba.druid.pool.DruidDataSource driver-class-name: com.mysql.jdbc.Driver filters: stat @@ -31,7 +31,7 @@ spring: database: 0 host: 127.0.0.1 port: 36379 - password: HF123456.Redis + password: yqyt123!@#Redis timeout: 1000 jedis: pool: diff --git a/cweb/lib/taobao-sdk-java-elm.jar b/cweb/lib/taobao-sdk-java-elm.jar new file mode 100644 index 0000000..15bf43d Binary files /dev/null and b/cweb/lib/taobao-sdk-java-elm.jar differ diff --git a/cweb/pom.xml b/cweb/pom.xml index 882d490..2eef013 100644 --- a/cweb/pom.xml +++ b/cweb/pom.xml @@ -25,6 +25,13 @@ 1.0.1 ${basedir}/lib/taobao-sdk.jar + + taobao-elm.skd + taobao-open-elm-sdk + system + 1.0.1 + ${basedir}/lib/taobao-sdk-java-elm.jar + pop.skd pop-open-sdk diff --git a/cweb/src/main/java/com/hfkj/config/AuthConfig.java b/cweb/src/main/java/com/hfkj/config/AuthConfig.java index 63229f3..c825d4a 100644 --- a/cweb/src/main/java/com/hfkj/config/AuthConfig.java +++ b/cweb/src/main/java/com/hfkj/config/AuthConfig.java @@ -97,6 +97,7 @@ public class AuthConfig implements WebMvcConfigurer { .excludePathPatterns("/goods/*") .excludePathPatterns("/taoBaoNotify/*") .excludePathPatterns("/cms/*") + .excludePathPatterns("/order/*") ; } diff --git a/cweb/src/main/java/com/hfkj/controller/ClientController.java b/cweb/src/main/java/com/hfkj/controller/ClientController.java index 4238cd1..eb41c3a 100644 --- a/cweb/src/main/java/com/hfkj/controller/ClientController.java +++ b/cweb/src/main/java/com/hfkj/controller/ClientController.java @@ -5,9 +5,11 @@ 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.HttpsUtils; import com.hfkj.common.utils.MemberValidateUtil; import com.hfkj.common.utils.RedisUtil; import com.hfkj.common.utils.ResponseMsgUtil; +import com.hfkj.entity.BsUser; import com.hfkj.model.ResponseData; import com.hfkj.model.SecUserSessionObject; import com.hfkj.service.user.BsUserService; @@ -22,6 +24,7 @@ import org.springframework.web.bind.annotation.*; import javax.annotation.Resource; import javax.servlet.http.HttpServletRequest; import java.util.HashMap; +import java.util.Map; /** * @className: ClientController @@ -78,21 +81,40 @@ public class ClientController { } } - - @RequestMapping(value = "/smsLogin", method = RequestMethod.GET) + @RequestMapping(value = "/weChat", method = RequestMethod.POST) @ResponseBody - @ApiOperation(value = "登录并注册") - public ResponseData smsLogin(@RequestParam(value = "phone" , required = true) String phone) { + @ApiOperation(value = "微信授权登录") + public ResponseData weChat(@RequestBody JSONObject body) { try { - - - // 校验手机号格式 - if (!MemberValidateUtil.validatePhone(phone)) { - throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "请输入正确的手机号"); + if (body == null || StringUtils.isBlank(body.getString("code"))) { + throw ErrorHelp.genException(SysCode.System, ErrorCode.REQ_PARAMS_ERROR, ""); } + // 邀请人id + Long inviteUseId = body.getLong("inviteUseId"); - - return ResponseMsgUtil.success(userService.login(phone, UserLoginType.SMS, new HashMap<>(), null)); + Map 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, "获取用户信息失败"); + } + 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) { return ResponseMsgUtil.exception(e); diff --git a/cweb/src/main/java/com/hfkj/controller/ElmController.java b/cweb/src/main/java/com/hfkj/controller/ElmController.java new file mode 100644 index 0000000..5c5ba7c --- /dev/null +++ b/cweb/src/main/java/com/hfkj/controller/ElmController.java @@ -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); + } + } +} diff --git a/cweb/src/main/java/com/hfkj/controller/TakeOutController.java b/cweb/src/main/java/com/hfkj/controller/TakeOutController.java index 85409ce..28b7425 100644 --- a/cweb/src/main/java/com/hfkj/controller/TakeOutController.java +++ b/cweb/src/main/java/com/hfkj/controller/TakeOutController.java @@ -52,4 +52,29 @@ public class TakeOutController { 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); + } + } } diff --git a/cweb/src/main/java/com/hfkj/controller/TestController.java b/cweb/src/main/java/com/hfkj/controller/TestController.java index 8644eca..81dd1f3 100644 --- a/cweb/src/main/java/com/hfkj/controller/TestController.java +++ b/cweb/src/main/java/com/hfkj/controller/TestController.java @@ -8,6 +8,7 @@ import com.hfkj.common.exception.SysCode; import com.hfkj.common.utils.ResponseMsgUtil; import com.hfkj.model.ResponseData; +import com.hfkj.service.elm.ElmService; import com.hfkj.service.meituan.MeiTuanService; import com.hfkj.service.pdd.PddService; import com.hfkj.service.taobao.TaoBaoService; diff --git a/cweb/src/main/java/com/hfkj/controller/UserController.java b/cweb/src/main/java/com/hfkj/controller/UserController.java index 6703bb9..5556a84 100644 --- a/cweb/src/main/java/com/hfkj/controller/UserController.java +++ b/cweb/src/main/java/com/hfkj/controller/UserController.java @@ -6,10 +6,7 @@ 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.DateUtil; -import com.hfkj.common.utils.MemberValidateUtil; -import com.hfkj.common.utils.RedisUtil; -import com.hfkj.common.utils.ResponseMsgUtil; +import com.hfkj.common.utils.*; import com.hfkj.config.CommonSysConst; import com.hfkj.config.SysConfig; import com.hfkj.entity.BsUser; @@ -205,8 +202,12 @@ public class UserController { if (StringUtils.isBlank(body.getString("smsCode"))) { 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); @@ -294,8 +295,12 @@ public class UserController { if (userSession.getUser().getPhone().equals(phone)) { 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)) { @@ -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 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) @ResponseBody @ApiOperation(value = "注销账户") diff --git a/cweb/src/main/java/com/hfkj/controller/UserCountController.java b/cweb/src/main/java/com/hfkj/controller/UserCountController.java new file mode 100644 index 0000000..153a886 --- /dev/null +++ b/cweb/src/main/java/com/hfkj/controller/UserCountController.java @@ -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 todayTime = DateUtil.getTodayTimeObj(); + // 昨日时间 + Map yesterdayTime = DateUtil.getYesterdayTimeObj(); + // 本月时间 + Map thisMonthTime = DateUtil.getThisMonthTimeObj(); + // 上月时间 + Map lastMonthTime = DateUtil.getLastMonthTimeObj(); + + Map 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); + } + } + + +} diff --git a/cweb/src/main/java/com/hfkj/controller/order/BsOrderController.java b/cweb/src/main/java/com/hfkj/controller/order/BsOrderController.java index 51f2427..453f382 100644 --- a/cweb/src/main/java/com/hfkj/controller/order/BsOrderController.java +++ b/cweb/src/main/java/com/hfkj/controller/order/BsOrderController.java @@ -8,22 +8,31 @@ 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.model.ResponseData; -import com.hfkj.model.SecUserSessionObject; -import com.hfkj.model.UserSessionObject; +import com.hfkj.entity.BsOrder; +import com.hfkj.model.*; 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.ApiOperation; +import org.apache.commons.collections4.MapUtils; import org.slf4j.Logger; import org.slf4j.LoggerFactory; +import org.springframework.beans.BeanUtils; import org.springframework.stereotype.Controller; import org.springframework.web.bind.annotation.*; import javax.annotation.Resource; import javax.servlet.http.HttpServletRequest; -import java.util.HashMap; -import java.util.Map; +import java.math.BigDecimal; +import java.util.*; +import java.util.stream.Collectors; @Controller @RequestMapping(value="/order") @@ -37,15 +46,20 @@ public class BsOrderController { @Resource private UserCenter userCenter; - @Resource - private BsOrderService bsOrderService; + private BsUserParentRelService userParentRelService; + @Resource + private BsUserAccountRecordService userAccountRecordService; + @Resource + private SecDictionaryService secDictionaryService; + @RequestMapping(value="/getOrderList",method = RequestMethod.GET) @ResponseBody @ApiOperation(value = "查询列表") public ResponseData getOrderList(@RequestParam(value = "orderNo" , required = false) String orderNo, @RequestParam(value = "type" , required = false) Integer type, + @RequestParam(value = "orderType" , required = true) Integer orderType, @RequestParam(value = "status" , required = false) Integer status, @RequestParam(value = "userPhone" , required = false) String userPhone, @RequestParam(value = "goodsName" , required = false) String goodsName, @@ -55,24 +69,23 @@ public class BsOrderController { @RequestParam(value = "pageSize" , required = true) Integer pageSize, HttpServletRequest request) { try { - SessionObject sessionObject = userCenter.getSessionObject(request); - SecUserSessionObject userModel = (SecUserSessionObject) sessionObject.getObject(); + // 用户session + UserSessionObject session = userCenter.getSessionModel(UserSessionObject.class); Map map = new HashMap<>(); - - map.put("orderNo", orderNo); map.put("userPhone", userPhone); 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("goodsName", goodsName); map.put("createTimeS", createTimeS); map.put("createTimeE", createTimeE); PageHelper.startPage(pageNum, pageSize); - return ResponseMsgUtil.success(new PageInfo<>(orderService.getOrderList(map))); + return ResponseMsgUtil.success(new PageInfo<>(orderService.getOrderListParent(map))); } catch (Exception 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 - @ApiOperation(value = "创建订单") - public ResponseData create(@RequestBody JSONObject jsonObject) { + @ApiOperation(value = "用时间段查询推广订单接口") + public ResponseData getPddOrderList() { 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()); - jsonObject.put("userPhone", userSession.getUser().getPhone()); - - return ResponseMsgUtil.success(bsOrderService.create(jsonObject)); + return ResponseMsgUtil.success(orderService.getOrderList()); } catch (Exception 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 todayTime = DateUtil.getTodayTimeObj(); + // 昨日时间 + Map yesterdayTime = DateUtil.getYesterdayTimeObj(); + // 本月时间 + Map thisMonthTime = DateUtil.getThisMonthTimeObj(); + // 上月时间 + Map 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 list = orderService.getOrderList(new HashMap<>()); + // 查询个人订单 + List orderUserList = list.stream().filter(s->s.getUserId().equals(session.getUser().getId())).collect(Collectors.toList()); + //查询团队 + // 查询团队用户 + Map param = new HashMap<>(); + param.put("parentUserId", session.getUser().getId()); + // 查询下级数据 + List subList = userParentRelService.getTeamSubList(param); + List teamOrderList = new ArrayList<>(); + // 遍历下级数据 + for (UserTeamModel userTeamModel : subList) { + List teamList = list.stream().filter(bsOrder -> bsOrder.getUserId().equals(userTeamModel.getUserId())).collect(Collectors.toList()); + teamOrderList.addAll(teamList); + } + + // 所有订单 + List allOrderList = new ArrayList<>(); + allOrderList.addAll(orderUserList); + allOrderList.addAll(teamOrderList); + Map 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 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 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 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 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); + + } + + + } diff --git a/cweb/src/main/java/com/hfkj/controller/partner/PartnerController.java b/cweb/src/main/java/com/hfkj/controller/partner/PartnerController.java index c6f0055..5b05c80 100644 --- a/cweb/src/main/java/com/hfkj/controller/partner/PartnerController.java +++ b/cweb/src/main/java/com/hfkj/controller/partner/PartnerController.java @@ -1,14 +1,12 @@ package com.hfkj.controller.partner; import com.alibaba.fastjson.JSONObject; -import com.github.pagehelper.PageInfo; 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.DateUtil; import com.hfkj.common.utils.ResponseMsgUtil; -import com.hfkj.controller.cornucopia.CornucopiaController; import com.hfkj.entity.BsPartnerLevel; import com.hfkj.entity.BsPartnerPool; import com.hfkj.entity.BsPartnerPoolPre; @@ -26,7 +24,6 @@ import org.springframework.stereotype.Controller; import org.springframework.web.bind.annotation.*; import javax.annotation.Resource; -import javax.servlet.http.HttpServletRequest; import java.math.BigDecimal; import java.util.Date; import java.util.HashMap; @@ -106,7 +103,7 @@ public class PartnerController { @RequestMapping(value="/getUserPartner",method = RequestMethod.GET) @ResponseBody @ApiOperation(value = "查询合伙人等级与当期投入总元宝,与用户当前等级") - public ResponseData getUserPartner() { + public ResponseData getUserPartner(@RequestParam(value = "level" , required = false) Integer level) { try { // 用户session @@ -115,10 +112,14 @@ public class PartnerController { throw ErrorHelp.genException(SysCode.System, ErrorCode.ACCOUNT_LOGIN_NOT, ""); } + // 查询上一期 + String lotteryNo = DateUtil.date2String(new Date() , DateUtil.YMD); JSONObject obj = new JSONObject(); // 查询当期用户内容 Map map = new HashMap<>(); map.put("status" , 1); + map.put("level" , level); + map.put("lotteryNo" , lotteryNo); List list = bsPartnerPoolPreService.queryAllList(map); BigDecimal toDayPartner = list.stream().map(BsPartnerPoolPre::getGoldCoin).reduce(BigDecimal.ZERO, BigDecimal::add); obj.put("toDayPartner" , toDayPartner); @@ -126,8 +127,8 @@ public class PartnerController { List partnerLevels = bsPartnerLevelService.queryAllList(map); obj.put("partnerLevels" , partnerLevels); // 查询用户合伙人等级 - BsPartnerPool partnerPool = bsPartnerPoolService.queryDetail(userSession.getUser().getId()); - obj.put("partnerPool" , partnerPool); + BsPartnerPool partnerPool = bsPartnerPoolService.queryDetail(userSession.getUser().getId() , level); + obj.put("partnerLevel" , partnerPool); return ResponseMsgUtil.success(obj); @@ -140,7 +141,7 @@ public class PartnerController { @RequestMapping(value="/prePartner",method = RequestMethod.GET) @ResponseBody @ApiOperation(value = "查询上一期竞选与竞选排名") - public ResponseData prePartner() { + public ResponseData prePartner(@RequestParam(value = "level" , required = true) Integer level) { try { // 用户session @@ -151,15 +152,27 @@ public class PartnerController { // 查询上一期 String lotteryNo = DateUtil.date2String(new Date() , DateUtil.YMD); - Integer preLotteryNo = Integer.parseInt(lotteryNo) - 1; + Map map = new HashMap<>(); - map.put("status" , 2); - map.put("lotteryNo" , preLotteryNo.toString()); - List list = bsPartnerPoolPreService.queryAllList(map); + map.put("status" , 1); + map.put("level" , level); + List list = bsPartnerPoolService.queryAllList(map); + + + Map userMap = new HashMap<>(); + userMap.put("userId" , userSession.getUser().getId()); + userMap.put("lotteryNo" , lotteryNo); + + Map mapPre = new HashMap<>(); + int preLotteryNo = Integer.parseInt(lotteryNo) - 1; + mapPre.put("lotteryNo" , Integer.toString(preLotteryNo)); + map.put("level" , level); + List pres = bsPartnerPoolPreService.queryAllList(mapPre); JSONObject obj = new JSONObject(); // 插入上一期内容 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); diff --git a/cweb/src/main/java/com/hfkj/controller/promotion/PromotionController.java b/cweb/src/main/java/com/hfkj/controller/promotion/PromotionController.java new file mode 100644 index 0000000..e979f0d --- /dev/null +++ b/cweb/src/main/java/com/hfkj/controller/promotion/PromotionController.java @@ -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); + } + } +} diff --git a/cweb/src/main/resources/prod/application.yml b/cweb/src/main/resources/prod/application.yml index 18a5cc0..1d0831a 100644 --- a/cweb/src/main/resources/prod/application.yml +++ b/cweb/src/main/resources/prod/application.yml @@ -1,7 +1,7 @@ server: - port: 9302 + port: 9101 servlet: - context-path: /brest + context-path: /crest #配置是否为debug模式,debug模式下,不开启权限校验 debug: false @@ -9,9 +9,9 @@ debug: false #datasource数据源设置 spring: datasource: - url: jdbc:mysql://127.0.0.1:3306/hsg?allowMultiQueries=true&useUnicode=true&characterEncoding=UTF-8 - username: root - password: HF123456. + url: jdbc:mysql://127.0.0.1:3306/youtao?allowMultiQueries=true&useUnicode=true&characterEncoding=UTF-8&useSSL=false + username: yqyt + password: yqyt123!@#Mysql type: com.alibaba.druid.pool.DruidDataSource driver-class-name: com.mysql.jdbc.Driver filters: stat @@ -31,7 +31,7 @@ spring: database: 0 host: 127.0.0.1 port: 36379 - password: HF123456.Redis + password: yqyt123!@#Redis timeout: 1000 jedis: pool: diff --git a/schedule/src/main/resources/prod/application.yml b/schedule/src/main/resources/prod/application.yml index 18a5cc0..6f67edf 100644 --- a/schedule/src/main/resources/prod/application.yml +++ b/schedule/src/main/resources/prod/application.yml @@ -1,7 +1,7 @@ server: - port: 9302 + port: 9103 servlet: - context-path: /brest + context-path: /schedule #配置是否为debug模式,debug模式下,不开启权限校验 debug: false @@ -9,9 +9,9 @@ debug: false #datasource数据源设置 spring: datasource: - url: jdbc:mysql://127.0.0.1:3306/hsg?allowMultiQueries=true&useUnicode=true&characterEncoding=UTF-8 - username: root - password: HF123456. + url: jdbc:mysql://127.0.0.1:3306/youtao?allowMultiQueries=true&useUnicode=true&characterEncoding=UTF-8&useSSL=false + username: yqyt + password: yqyt123!@#Mysql type: com.alibaba.druid.pool.DruidDataSource driver-class-name: com.mysql.jdbc.Driver filters: stat @@ -31,7 +31,7 @@ spring: database: 0 host: 127.0.0.1 port: 36379 - password: HF123456.Redis + password: yqyt123!@#Redis timeout: 1000 jedis: pool: diff --git a/service/lib/taobao-sdk-java-elm.jar b/service/lib/taobao-sdk-java-elm.jar new file mode 100644 index 0000000..15bf43d Binary files /dev/null and b/service/lib/taobao-sdk-java-elm.jar differ diff --git a/service/pom.xml b/service/pom.xml index d1447a7..45f70b3 100644 --- a/service/pom.xml +++ b/service/pom.xml @@ -275,6 +275,14 @@ 1.0.1 ${basedir}/lib/taobao-sdk.jar + + taobao-elm.skd + taobao-open-elm-sdk + system + 1.0.1 + ${basedir}/lib/taobao-sdk-java-elm.jar + + pop.skd pop-open-sdk diff --git a/service/src/main/java/com/hfkj/common/utils/HttpsUtils.java b/service/src/main/java/com/hfkj/common/utils/HttpsUtils.java index 41315bf..de5b081 100644 --- a/service/src/main/java/com/hfkj/common/utils/HttpsUtils.java +++ b/service/src/main/java/com/hfkj/common/utils/HttpsUtils.java @@ -137,6 +137,7 @@ public class HttpsUtils { i++; } apiUrl += param; + apiUrl += "&query_request=" + o; String result = null; HttpClient httpClient = null; try { @@ -502,6 +503,42 @@ public class HttpsUtils { return null; } + public static JSONObject doPostS(String apiUrl, Map 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 header) { CloseableHttpClient httpClient = null; if (apiUrl.startsWith("https")) { diff --git a/service/src/main/java/com/hfkj/common/utils/TaoBaoUtil.java b/service/src/main/java/com/hfkj/common/utils/TaoBaoUtil.java new file mode 100644 index 0000000..b62ce99 --- /dev/null +++ b/service/src/main/java/com/hfkj/common/utils/TaoBaoUtil.java @@ -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 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; + } + +} diff --git a/service/src/main/java/com/hfkj/dao/BsUserAccountRecordMapperExt.java b/service/src/main/java/com/hfkj/dao/BsUserAccountRecordMapperExt.java index 703f40b..61b5604 100644 --- a/service/src/main/java/com/hfkj/dao/BsUserAccountRecordMapperExt.java +++ b/service/src/main/java/com/hfkj/dao/BsUserAccountRecordMapperExt.java @@ -10,6 +10,11 @@ import java.math.BigDecimal; */ public interface BsUserAccountRecordMapperExt { - @Select("") - BigDecimal queryUserTotalProfit(@Param("userId") Long userId); + @Select("") + BigDecimal queryUserTotalProfit(@Param("userId") Long userId,@Param("timeS") String timeS,@Param("timeE") String timeE); } diff --git a/service/src/main/java/com/hfkj/dao/BsUserMapper.java b/service/src/main/java/com/hfkj/dao/BsUserMapper.java index 3dd804f..8b5cb9c 100644 --- a/service/src/main/java/com/hfkj/dao/BsUserMapper.java +++ b/service/src/main/java/com/hfkj/dao/BsUserMapper.java @@ -41,6 +41,7 @@ public interface BsUserMapper extends BsUserMapperExt { @Insert({ "insert into bs_user (head_img, `name`, ", "phone, grade, wechat_num, ", +<<<<<<< HEAD "special_id, wechat_open_id, ", "wechat_unionid, elm_pid, ", "invite_user_id, invite_time, ", @@ -57,6 +58,22 @@ public interface BsUserMapper extends BsUserMapperExt { "#{status,jdbcType=INTEGER}, #{createTime,jdbcType=TIMESTAMP}, ", "#{updateTime,jdbcType=TIMESTAMP}, #{ext1,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") int insert(BsUser record); @@ -73,7 +90,10 @@ public interface BsUserMapper extends BsUserMapperExt { @Result(column="phone", property="phone", jdbcType=JdbcType.VARCHAR), @Result(column="grade", property="grade", jdbcType=JdbcType.INTEGER), @Result(column="wechat_num", property="wechatNum", jdbcType=JdbcType.VARCHAR), +<<<<<<< HEAD @Result(column="special_id", property="specialId", jdbcType=JdbcType.VARCHAR), +======= +>>>>>>> 9fd569d446b9f1a74c4b28147a3572ee8a076825 @Result(column="wechat_open_id", property="wechatOpenId", jdbcType=JdbcType.VARCHAR), @Result(column="wechat_unionid", property="wechatUnionid", jdbcType=JdbcType.VARCHAR), @Result(column="elm_pid", property="elmPid", jdbcType=JdbcType.VARCHAR), @@ -92,9 +112,15 @@ public interface BsUserMapper extends BsUserMapperExt { @Select({ "select", +<<<<<<< HEAD "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, ", "`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", "where id = #{id,jdbcType=BIGINT}" }) @@ -105,7 +131,10 @@ public interface BsUserMapper extends BsUserMapperExt { @Result(column="phone", property="phone", jdbcType=JdbcType.VARCHAR), @Result(column="grade", property="grade", jdbcType=JdbcType.INTEGER), @Result(column="wechat_num", property="wechatNum", jdbcType=JdbcType.VARCHAR), +<<<<<<< HEAD @Result(column="special_id", property="specialId", jdbcType=JdbcType.VARCHAR), +======= +>>>>>>> 9fd569d446b9f1a74c4b28147a3572ee8a076825 @Result(column="wechat_open_id", property="wechatOpenId", jdbcType=JdbcType.VARCHAR), @Result(column="wechat_unionid", property="wechatUnionid", 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},", "grade = #{grade,jdbcType=INTEGER},", "wechat_num = #{wechatNum,jdbcType=VARCHAR},", +<<<<<<< HEAD "special_id = #{specialId,jdbcType=VARCHAR},", +======= +>>>>>>> 9fd569d446b9f1a74c4b28147a3572ee8a076825 "wechat_open_id = #{wechatOpenId,jdbcType=VARCHAR},", "wechat_unionid = #{wechatUnionid,jdbcType=VARCHAR},", "elm_pid = #{elmPid,jdbcType=VARCHAR},", diff --git a/service/src/main/java/com/hfkj/dao/BsUserSqlProvider.java b/service/src/main/java/com/hfkj/dao/BsUserSqlProvider.java index 5150a17..7cf9f7a 100644 --- a/service/src/main/java/com/hfkj/dao/BsUserSqlProvider.java +++ b/service/src/main/java/com/hfkj/dao/BsUserSqlProvider.java @@ -48,10 +48,13 @@ public class BsUserSqlProvider { sql.VALUES("wechat_num", "#{wechatNum,jdbcType=VARCHAR}"); } +<<<<<<< HEAD if (record.getSpecialId() != null) { sql.VALUES("special_id", "#{specialId,jdbcType=VARCHAR}"); } +======= +>>>>>>> 9fd569d446b9f1a74c4b28147a3572ee8a076825 if (record.getWechatOpenId() != null) { sql.VALUES("wechat_open_id", "#{wechatOpenId,jdbcType=VARCHAR}"); } @@ -119,7 +122,10 @@ public class BsUserSqlProvider { sql.SELECT("phone"); sql.SELECT("grade"); sql.SELECT("wechat_num"); +<<<<<<< HEAD sql.SELECT("special_id"); +======= +>>>>>>> 9fd569d446b9f1a74c4b28147a3572ee8a076825 sql.SELECT("wechat_open_id"); sql.SELECT("wechat_unionid"); sql.SELECT("elm_pid"); @@ -174,10 +180,13 @@ public class BsUserSqlProvider { sql.SET("wechat_num = #{record.wechatNum,jdbcType=VARCHAR}"); } +<<<<<<< HEAD if (record.getSpecialId() != null) { sql.SET("special_id = #{record.specialId,jdbcType=VARCHAR}"); } +======= +>>>>>>> 9fd569d446b9f1a74c4b28147a3572ee8a076825 if (record.getWechatOpenId() != null) { 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("grade = #{record.grade,jdbcType=INTEGER}"); sql.SET("wechat_num = #{record.wechatNum,jdbcType=VARCHAR}"); +<<<<<<< HEAD sql.SET("special_id = #{record.specialId,jdbcType=VARCHAR}"); +======= +>>>>>>> 9fd569d446b9f1a74c4b28147a3572ee8a076825 sql.SET("wechat_open_id = #{record.wechatOpenId,jdbcType=VARCHAR}"); sql.SET("wechat_unionid = #{record.wechatUnionid,jdbcType=VARCHAR}"); sql.SET("elm_pid = #{record.elmPid,jdbcType=VARCHAR}"); @@ -288,10 +300,13 @@ public class BsUserSqlProvider { sql.SET("wechat_num = #{wechatNum,jdbcType=VARCHAR}"); } +<<<<<<< HEAD if (record.getSpecialId() != null) { sql.SET("special_id = #{specialId,jdbcType=VARCHAR}"); } +======= +>>>>>>> 9fd569d446b9f1a74c4b28147a3572ee8a076825 if (record.getWechatOpenId() != null) { sql.SET("wechat_open_id = #{wechatOpenId,jdbcType=VARCHAR}"); } diff --git a/service/src/main/java/com/hfkj/entity/BsUser.java b/service/src/main/java/com/hfkj/entity/BsUser.java index fa63185..3721e1e 100644 --- a/service/src/main/java/com/hfkj/entity/BsUser.java +++ b/service/src/main/java/com/hfkj/entity/BsUser.java @@ -45,11 +45,14 @@ public class BsUser implements Serializable { private String wechatNum; /** +<<<<<<< HEAD * 淘宝会员独有 */ private String specialId; /** +======= +>>>>>>> 9fd569d446b9f1a74c4b28147a3572ee8a076825 * 微信openid */ private String wechatOpenId; @@ -155,6 +158,7 @@ public class BsUser implements Serializable { this.wechatNum = wechatNum; } +<<<<<<< HEAD public String getSpecialId() { return specialId; } @@ -163,6 +167,8 @@ public class BsUser implements Serializable { this.specialId = specialId; } +======= +>>>>>>> 9fd569d446b9f1a74c4b28147a3572ee8a076825 public String getWechatOpenId() { return wechatOpenId; } @@ -266,4 +272,96 @@ public class BsUser implements Serializable { public void setExt3(String 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 } \ No newline at end of file diff --git a/service/src/main/java/com/hfkj/entity/BsUserExample.java b/service/src/main/java/com/hfkj/entity/BsUserExample.java index 0526f1c..a63057a 100644 --- a/service/src/main/java/com/hfkj/entity/BsUserExample.java +++ b/service/src/main/java/com/hfkj/entity/BsUserExample.java @@ -526,6 +526,7 @@ public class BsUserExample { return (Criteria) this; } +<<<<<<< HEAD public Criteria andSpecialIdIsNull() { addCriterion("special_id is null"); return (Criteria) this; @@ -596,6 +597,8 @@ public class BsUserExample { return (Criteria) this; } +======= +>>>>>>> 9fd569d446b9f1a74c4b28147a3572ee8a076825 public Criteria andWechatOpenIdIsNull() { addCriterion("wechat_open_id is null"); return (Criteria) this; diff --git a/service/src/main/java/com/hfkj/model/BsOrderModel.java b/service/src/main/java/com/hfkj/model/BsOrderModel.java new file mode 100644 index 0000000..fb799dc --- /dev/null +++ b/service/src/main/java/com/hfkj/model/BsOrderModel.java @@ -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; +} diff --git a/service/src/main/java/com/hfkj/service/cornucopia/Impl/BsCornucopiaLotteryRecordServiceImpl.java b/service/src/main/java/com/hfkj/service/cornucopia/Impl/BsCornucopiaLotteryRecordServiceImpl.java index 67f3d43..7601cac 100644 --- a/service/src/main/java/com/hfkj/service/cornucopia/Impl/BsCornucopiaLotteryRecordServiceImpl.java +++ b/service/src/main/java/com/hfkj/service/cornucopia/Impl/BsCornucopiaLotteryRecordServiceImpl.java @@ -56,11 +56,11 @@ public class BsCornucopiaLotteryRecordServiceImpl implements BsCornucopiaLottery if (MapUtils.getInteger(map, "type") != null) { criteria.andTypeEqualTo(MapUtils.getInteger(map, "type")); } - if (MapUtils.getLong(map, "startTime") != null) { - criteria.andCreateTimeGreaterThanOrEqualTo(new Date(MapUtils.getLong(map, "startTime"))); + if (MapUtils.getLong(map, "createTimeS") != null) { + criteria.andCreateTimeGreaterThanOrEqualTo(new Date(MapUtils.getLong(map, "createTimeS"))); } - if (MapUtils.getLong(map, "endTime") != null) { - criteria.andCreateTimeLessThan(new Date(MapUtils.getLong(map, "endTime"))); + if (MapUtils.getLong(map, "createTimeE") != null) { + criteria.andCreateTimeLessThan(new Date(MapUtils.getLong(map, "createTimeE"))); } if (MapUtils.getString(map, "lotteryNo") != null) { criteria.andLotteryNoLike("%" + MapUtils.getString(map, "lotteryNo") + "%"); diff --git a/service/src/main/java/com/hfkj/service/elm/ElmService.java b/service/src/main/java/com/hfkj/service/elm/ElmService.java new file mode 100644 index 0000000..84ad5df --- /dev/null +++ b/service/src/main/java/com/hfkj/service/elm/ElmService.java @@ -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)); + + } +} diff --git a/service/src/main/java/com/hfkj/service/meituan/MeiTuanService.java b/service/src/main/java/com/hfkj/service/meituan/MeiTuanService.java index 35c2ad6..738b14a 100644 --- a/service/src/main/java/com/hfkj/service/meituan/MeiTuanService.java +++ b/service/src/main/java/com/hfkj/service/meituan/MeiTuanService.java @@ -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 * @Description: 统一请求 diff --git a/service/src/main/java/com/hfkj/service/order/BsOrderService.java b/service/src/main/java/com/hfkj/service/order/BsOrderService.java index 1cd6103..0e9e99a 100644 --- a/service/src/main/java/com/hfkj/service/order/BsOrderService.java +++ b/service/src/main/java/com/hfkj/service/order/BsOrderService.java @@ -2,7 +2,9 @@ package com.hfkj.service.order; import com.alibaba.fastjson.JSONObject; import com.hfkj.entity.BsOrder; +import com.hfkj.model.BsOrderModel; +import java.math.BigDecimal; import java.util.List; import java.util.Map; @@ -34,14 +36,6 @@ public interface BsOrderService { * @return */ void cacheDelete(String orderNo); - - /** - * 创建订单 - * @param jsonObject 订单 - * @return - */ - JSONObject create(JSONObject jsonObject) throws Exception; - /** * @MethodName findByOrderNo * @Description: 查询订单 @@ -62,5 +56,36 @@ public interface BsOrderService { */ List getOrderList(Map 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 + * @Author: Sum1Dream + * @Date: 2024/10/24 下午2:52 + */ + List getOrderListParent(Map 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; + } diff --git a/service/src/main/java/com/hfkj/service/order/Impl/BsOrderServiceImpl.java b/service/src/main/java/com/hfkj/service/order/Impl/BsOrderServiceImpl.java index e269e8e..9cdbcc4 100644 --- a/service/src/main/java/com/hfkj/service/order/Impl/BsOrderServiceImpl.java +++ b/service/src/main/java/com/hfkj/service/order/Impl/BsOrderServiceImpl.java @@ -1,20 +1,34 @@ package com.hfkj.service.order.Impl; 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.RedisUtil; import com.hfkj.dao.BsOrderMapper; import com.hfkj.entity.BsOrder; 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.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.lang3.StringUtils; +import org.springframework.beans.BeanUtils; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.core.annotation.OrderUtils; import org.springframework.stereotype.Service; import javax.annotation.Resource; +import java.math.BigDecimal; import java.util.*; +import java.util.stream.Collectors; @Service("bsOrderService") public class BsOrderServiceImpl implements BsOrderService { @@ -31,7 +45,12 @@ public class BsOrderServiceImpl implements BsOrderService { private BsOrderMapper bsOrderMapper; @Resource - private OrderBusinessService orderBusinessService; + private BsUserParentRelService userParentRelService; + + @Resource + private BsUserContributeService userContributeService; + @Resource + private SecDictionaryService secDictionaryService; @Override public BsOrder editData(BsOrder order) { @@ -54,44 +73,6 @@ public class BsOrderServiceImpl implements BsOrderService { 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 public BsOrder findByOrderNo(String orderNo) { @@ -120,16 +101,16 @@ public class BsOrderServiceImpl implements BsOrderService { BsOrderExample example = new BsOrderExample(); BsOrderExample.Criteria criteria = example.createCriteria(); - if (MapUtils.getString(map , "orderNo") != null) { + if (StringUtils.isNotBlank(MapUtils.getString(map , "orderNo"))) { criteria.andOrderNoEqualTo(MapUtils.getString(map , "orderNo")); } if (MapUtils.getInteger(map , "type") != null) { 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")); } - if (MapUtils.getString(map , "goodsName") != null) { + if (StringUtils.isNotBlank(MapUtils.getString(map , "goodsName"))) { criteria.andGoodsNameLike("%" + MapUtils.getString(map , "goodsName") + "%"); } if (MapUtils.getLong(map, "createTimeS") != null) { @@ -139,11 +120,87 @@ public class BsOrderServiceImpl implements BsOrderService { criteria.andCreateTimeLessThan(new Date(MapUtils.getLong(map, "createTimeE"))); } if (MapUtils.getInteger(map , "status") != null) { - criteria.andTypeEqualTo(MapUtils.getInteger(map , "status")); + criteria.andStatusEqualTo(MapUtils.getInteger(map , "status")); } if (MapUtils.getLong(map , "userId") != null) { criteria.andUserIdEqualTo(MapUtils.getLong(map , "userId")); } return bsOrderMapper.selectByExample(example); } + + @Override + public JSONObject getOrderList() throws Exception{ + return PddService.getOrderList(); + } + + @Override + public List getOrderListParent(Map map) { + + // 判断map中是否包含userId键,如果不存在则抛出异常 + if (MapUtils.getLong(map , "userId") == null) { + throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "当前用户未登陆"); + } + + // 创建一个BsOrderModel类型的列表 + List orderModels = new ArrayList<>(); + BigDecimal goldCoinExchangeRate = new BigDecimal(secDictionaryService.getDictionary("GOLD_COIN_EXCHANGE_RATE").get(0).getCodeValue()); + // 查询用户订单 + if (MapUtils.getInteger(map , "orderType").equals(1)) { + // 获取订单列表 + List 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 param = new HashMap<>(); + param.put("parentUserId", MapUtils.getLong(map , "userId")); + // 查询下级数据 + List subList = userParentRelService.getTeamSubList(param); + // 查询订单 + map.put("userId" , null); + List orderList = getOrderList(map); + // 遍历下级数据 + for (UserTeamModel userTeamModel : subList) { + List 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 otherParam = new HashMap<>(); + otherParam.put("sourceId", bsOrder.getId()); + otherParam.put("sourceOrderNo", bsOrder.getOrderNo()); + userContributeService.purchase(bsOrder.getPromotionAmount(), bsOrder.getUserId(), otherParam); + } } diff --git a/service/src/main/java/com/hfkj/service/order/OrderBusinessService.java b/service/src/main/java/com/hfkj/service/order/OrderBusinessService.java index a152a77..bc0071f 100644 --- a/service/src/main/java/com/hfkj/service/order/OrderBusinessService.java +++ b/service/src/main/java/com/hfkj/service/order/OrderBusinessService.java @@ -1,22 +1,9 @@ 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.LoggerFactory; import org.springframework.stereotype.Component; -import java.util.HashMap; -import java.util.Map; - - /** * 创建订单业务 * @className: OrderBusinessService @@ -28,41 +15,4 @@ public class OrderBusinessService { 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 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); - - } - } diff --git a/service/src/main/java/com/hfkj/service/partner/BsPartnerPoolService.java b/service/src/main/java/com/hfkj/service/partner/BsPartnerPoolService.java index cf63c9b..6b10847 100644 --- a/service/src/main/java/com/hfkj/service/partner/BsPartnerPoolService.java +++ b/service/src/main/java/com/hfkj/service/partner/BsPartnerPoolService.java @@ -44,6 +44,7 @@ public interface BsPartnerPoolService { * @Date: 2024/7/4 下午2:30 */ BsPartnerPool queryDetail(Long userId); + BsPartnerPool queryDetail(Long userId , Integer level); /** * @MethodName queryAllList diff --git a/service/src/main/java/com/hfkj/service/partner/Impl/BsPartnerLevelServiceImpl.java b/service/src/main/java/com/hfkj/service/partner/Impl/BsPartnerLevelServiceImpl.java index bfab83a..92f875b 100644 --- a/service/src/main/java/com/hfkj/service/partner/Impl/BsPartnerLevelServiceImpl.java +++ b/service/src/main/java/com/hfkj/service/partner/Impl/BsPartnerLevelServiceImpl.java @@ -8,6 +8,7 @@ import com.hfkj.entity.BsPartnerLevelExample; import com.hfkj.entity.BsPartnerPool; import com.hfkj.service.partner.BsPartnerLevelService; import com.hfkj.service.partner.BsPartnerPoolService; +import org.apache.commons.collections4.MapUtils; import org.springframework.stereotype.Service; import javax.annotation.Resource; @@ -74,6 +75,10 @@ public class BsPartnerLevelServiceImpl implements BsPartnerLevelService { BsPartnerLevelExample example = new BsPartnerLevelExample(); BsPartnerLevelExample.Criteria criteria = example.createCriteria(); + if (MapUtils.getInteger(map, "level") != null) { + criteria.andLevelEqualTo(MapUtils.getInteger(map, "level")); + } + criteria.andStatusEqualTo(1); return bsPartnerLevelMapper.selectByExample(example); diff --git a/service/src/main/java/com/hfkj/service/partner/Impl/BsPartnerPoolPreServiceImpl.java b/service/src/main/java/com/hfkj/service/partner/Impl/BsPartnerPoolPreServiceImpl.java index e416f00..a906626 100644 --- a/service/src/main/java/com/hfkj/service/partner/Impl/BsPartnerPoolPreServiceImpl.java +++ b/service/src/main/java/com/hfkj/service/partner/Impl/BsPartnerPoolPreServiceImpl.java @@ -6,6 +6,7 @@ import com.hfkj.entity.BsPartnerPoolPre; import com.hfkj.entity.BsPartnerPoolPreExample; import com.hfkj.service.partner.BsPartnerPoolPreService; import org.apache.commons.collections4.MapUtils; +import org.apache.commons.lang3.StringUtils; import org.springframework.stereotype.Service; import javax.annotation.Resource; @@ -75,6 +76,9 @@ public class BsPartnerPoolPreServiceImpl implements BsPartnerPoolPreService { if (MapUtils.getString(map, "num") != null) { criteria.andLotteryNoLike("%" + MapUtils.getString(map, "num") + "%"); } + if (StringUtils.isNotBlank(MapUtils.getString(map, "lotteryNo"))) { + criteria.andLotteryNoEqualTo(MapUtils.getString(map, "lotteryNo")); + } List list = bsPartnerPoolPreMapper.selectByExample(example); @@ -95,19 +99,19 @@ public class BsPartnerPoolPreServiceImpl implements BsPartnerPoolPreService { if (MapUtils.getInteger(map, "userId") != null) { criteria.andUserIdEqualTo(MapUtils.getLong(map, "userId")); } - if (MapUtils.getString(map, "num") != null) { - criteria.andLotteryNoLike("%" + MapUtils.getString(map, "num") + "%"); + if (StringUtils.isNotBlank(MapUtils.getString(map, "num"))) { + criteria.andNumLike("%" + MapUtils.getString(map, "num") + "%"); } if (MapUtils.getInteger(map, "status") != null) { criteria.andStatusEqualTo(MapUtils.getInteger(map, "status")); } - if (MapUtils.getLong(map, "startTime") != null) { - criteria.andCreateTimeGreaterThanOrEqualTo(new Date(MapUtils.getLong(map, "startTime"))); + if (MapUtils.getLong(map, "createTimeS") != null) { + criteria.andCreateTimeGreaterThanOrEqualTo(new Date(MapUtils.getLong(map, "createTimeS"))); } - if (MapUtils.getLong(map, "endTime") != null) { - criteria.andCreateTimeLessThan(new Date(MapUtils.getLong(map, "endTime"))); + if (MapUtils.getLong(map, "createTimeE") != null) { + 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")); } diff --git a/service/src/main/java/com/hfkj/service/partner/Impl/BsPartnerPoolServiceImpl.java b/service/src/main/java/com/hfkj/service/partner/Impl/BsPartnerPoolServiceImpl.java index fd69439..c23eb3c 100644 --- a/service/src/main/java/com/hfkj/service/partner/Impl/BsPartnerPoolServiceImpl.java +++ b/service/src/main/java/com/hfkj/service/partner/Impl/BsPartnerPoolServiceImpl.java @@ -44,6 +44,7 @@ public class BsPartnerPoolServiceImpl implements BsPartnerPoolService { } } + @Override public BsPartnerPool queryDetail(Long userId) { BsPartnerPoolExample example = new BsPartnerPoolExample(); @@ -59,6 +60,24 @@ public class BsPartnerPoolServiceImpl implements BsPartnerPoolService { 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 list = bsPartnerPoolMapper.selectByExample(example); + + if (!list.isEmpty()) { + return list.get(0); + } + + return null; + } + @Override public List queryAllList(Map map) { BsPartnerPoolExample example = new BsPartnerPoolExample(); @@ -73,6 +92,7 @@ public class BsPartnerPoolServiceImpl implements BsPartnerPoolService { if (MapUtils.getString(map, "num") != null) { criteria.andNumLike("%" + MapUtils.getString(map, "num") + "%"); } + criteria.andUserIdIsNotNull(); criteria.andStatusEqualTo(1); return bsPartnerPoolMapper.selectByExample(example); diff --git a/service/src/main/java/com/hfkj/service/partner/Impl/BsPartnerUserRecordServiceImpl.java b/service/src/main/java/com/hfkj/service/partner/Impl/BsPartnerUserRecordServiceImpl.java index 9ec8e19..3d50404 100644 --- a/service/src/main/java/com/hfkj/service/partner/Impl/BsPartnerUserRecordServiceImpl.java +++ b/service/src/main/java/com/hfkj/service/partner/Impl/BsPartnerUserRecordServiceImpl.java @@ -84,11 +84,11 @@ public class BsPartnerUserRecordServiceImpl implements BsPartnerUserRecordServic if (MapUtils.getString(map, "userName") != null) { criteria.andUserNameLike("%" + MapUtils.getString(map, "userName") + "%"); } - if (MapUtils.getLong(map, "startTime") != null) { - criteria.andCreateTimeGreaterThanOrEqualTo(new Date(MapUtils.getLong(map, "startTime"))); + if (MapUtils.getLong(map, "createTimeS") != null) { + criteria.andCreateTimeGreaterThanOrEqualTo(new Date(MapUtils.getLong(map, "createTimeS"))); } - if (MapUtils.getLong(map, "endTime") != null) { - criteria.andCreateTimeLessThan(new Date(MapUtils.getLong(map, "endTime"))); + if (MapUtils.getLong(map, "createTimeE") != null) { + criteria.andCreateTimeLessThan(new Date(MapUtils.getLong(map, "createTimeE"))); } if (MapUtils.getString(map, "lotteryNo") != null) { criteria.andLotteryNoLike("%" + MapUtils.getString(map, "lotteryNo") + "%"); diff --git a/service/src/main/java/com/hfkj/service/partner/Impl/PartnerServiceImpl.java b/service/src/main/java/com/hfkj/service/partner/Impl/PartnerServiceImpl.java index d0fd899..8255d57 100644 --- a/service/src/main/java/com/hfkj/service/partner/Impl/PartnerServiceImpl.java +++ b/service/src/main/java/com/hfkj/service/partner/Impl/PartnerServiceImpl.java @@ -57,6 +57,14 @@ public class PartnerServiceImpl implements PartnerService { if (isPartner(jsonObject.getLong("userId"))) { 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"); BigDecimal goldCoin = jsonObject.getBigDecimal("goldCoin"); // 锁编号 @@ -164,30 +172,40 @@ public class PartnerServiceImpl implements PartnerService { List partnerPoolsPreL5 = partnerPoolPres.stream().filter(s-> s.getLevel().equals(5)).sorted(Comparator.comparing(BsPartnerPoolPre::getCampaignNo)).sorted(Comparator.comparing(BsPartnerPoolPre::getGoldCoin).reversed()).collect(Collectors.toList()); List pres = new ArrayList<>(); + List levelList = bsPartnerLevelService.queryAllList(new HashMap<>()); + // 查询开奖记录 + // 根据彩票号码查询合伙人池记录 BsPartnerPoolRecord partnerPoolRecord = bsPartnerPoolRecordService.queryDetail(lotteryNo); + // 如果合伙人池记录不为空 if (partnerPoolRecord != null) { + // 如果合伙人池记录状态为2,抛出异常 if (partnerPoolRecord.getStatus().equals(2)) { throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "当期已经竞选结算!"); } + // 将合伙人池记录状态设置为2 partnerPoolRecord.setStatus(2); + // 设置彩票时间 partnerPoolRecord.setLotteryTime(new Date()); + // 更新合伙人池记录 bsPartnerPoolRecordService.edit(partnerPoolRecord); } - // todo 计算当期的时候需要先预站一个位置 如果当前用户大那么顺序往下走 // L1参选 for (BsPartnerPoolPre partnerPoolPre : partnerPoolsPreL1) { + // 如果合伙人池预约状态为1 if (partnerPoolPre.getStatus().equals(1)) { // 查询还未被占位的合伙人位置并且当前合伙人金额大于 List poolList = partnerPoolsL1.stream().filter(s-> s.getGoldCoin().compareTo(partnerPoolPre.getGoldCoin()) < 0).filter(s->s.getStatus().equals(1)).collect(Collectors.toList()); + // 如果查询结果不为空 if (!poolList.isEmpty()) { BsPartnerPool pool = poolList.get(0); // 竞选成功 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()); @@ -212,14 +230,20 @@ public class PartnerServiceImpl implements PartnerService { // L2参选 for (BsPartnerPoolPre partnerPoolPre : partnerPoolsPreL2) { + // 如果合伙人池预约状态为1 if (partnerPoolPre.getStatus().equals(1)) { + // 查询还未被占位的合伙人位置并且当前合伙人金额大于 List poolList = partnerPoolsL2.stream().filter(s-> s.getGoldCoin().compareTo(partnerPoolPre.getGoldCoin()) < 0).filter(s->s.getStatus().equals(1)).collect(Collectors.toList()); + // 如果查询结果不为空 if (!poolList.isEmpty()) { BsPartnerPool pool = poolList.get(0); + // 竞选成功 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.setGoldCoin(partnerPoolPre.getGoldCoin()); pools.add(pool); @@ -232,6 +256,7 @@ public class PartnerServiceImpl implements PartnerService { }) .collect(Collectors.toList()); + // 配置预约竞选参数 partnerPoolPre.setStatus(2); partnerPoolPre.setNum(pool.getNum()); pres.add(partnerPoolPre); @@ -242,13 +267,19 @@ public class PartnerServiceImpl implements PartnerService { // L3参选 for (BsPartnerPoolPre partnerPoolPre : partnerPoolsPreL3) { + // 如果合伙人池预约状态为1 if (partnerPoolPre.getStatus().equals(1)) { + // 查询还未被占位的合伙人位置并且当前合伙人金额大于 List poolList = partnerPoolsL3.stream().filter(s-> s.getGoldCoin().compareTo(partnerPoolPre.getGoldCoin()) < 0).filter(s->s.getStatus().equals(1)).collect(Collectors.toList()); + // 如果查询结果不为空 if (!poolList.isEmpty()) { BsPartnerPool pool = poolList.get(0); + // 竞选成功 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.setGoldCoin(partnerPoolPre.getGoldCoin()); pools.add(pool); @@ -261,6 +292,7 @@ public class PartnerServiceImpl implements PartnerService { }) .collect(Collectors.toList()); + // 配置预约竞选参数 partnerPoolPre.setStatus(2); partnerPoolPre.setNum(pool.getNum()); pres.add(partnerPoolPre); @@ -270,13 +302,19 @@ public class PartnerServiceImpl implements PartnerService { // L4参选 for (BsPartnerPoolPre partnerPoolPre : partnerPoolsPreL4) { + // 如果合伙人池预约状态为1 if (partnerPoolPre.getStatus().equals(1)) { + // 查询还未被占位的合伙人位置并且当前合伙人金额大于 List poolList = partnerPoolsL4.stream().filter(s-> s.getGoldCoin().compareTo(partnerPoolPre.getGoldCoin()) < 0).filter(s->s.getStatus().equals(1)).collect(Collectors.toList()); + // 如果查询结果不为空 if (!poolList.isEmpty()) { BsPartnerPool pool = poolList.get(0); + // 竞选成功 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.setGoldCoin(partnerPoolPre.getGoldCoin()); pools.add(pool); @@ -289,6 +327,7 @@ public class PartnerServiceImpl implements PartnerService { }) .collect(Collectors.toList()); + // 配置预约竞选参数 partnerPoolPre.setStatus(2); partnerPoolPre.setNum(pool.getNum()); pres.add(partnerPoolPre); @@ -298,13 +337,19 @@ public class PartnerServiceImpl implements PartnerService { // L5参选 for (BsPartnerPoolPre partnerPoolPre : partnerPoolsPreL5) { + // 如果合伙人池预约状态为1 if (partnerPoolPre.getStatus().equals(1)) { + // 查询还未被占位的合伙人位置并且当前合伙人金额大于 List poolList = partnerPoolsL5.stream().filter(s-> s.getGoldCoin().compareTo(partnerPoolPre.getGoldCoin()) < 0).filter(s->s.getStatus().equals(1)).collect(Collectors.toList()); + // 如果查询结果不为空 if (!poolList.isEmpty()) { BsPartnerPool pool = poolList.get(0); + // 竞选成功 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.setGoldCoin(partnerPoolPre.getGoldCoin()); pools.add(pool); @@ -317,6 +362,7 @@ public class PartnerServiceImpl implements PartnerService { }) .collect(Collectors.toList()); + // 配置预约竞选参数 partnerPoolPre.setStatus(2); partnerPoolPre.setNum(pool.getNum()); pres.add(partnerPoolPre); @@ -324,14 +370,18 @@ public class PartnerServiceImpl implements PartnerService { } } + // 更新合伙人池状态 for (BsPartnerPool pool : pools) { pool.setStatus(1); pool.setUpdateTime(new Date()); bsPartnerPoolService.edit(pool); } + // 更新合伙人池预约状态 for (BsPartnerPoolPre partnerPoolPre: pres) { + // 如果合伙人池预约状态为1 if (partnerPoolPre.getStatus().equals(1)) { + // 将合伙人池预约状态设置为3 partnerPoolPre.setStatus(3); partnerPoolPre.setUpdateTime(new Date()); BsUser user = bsUserService.getUser(partnerPoolPre.getUserId()); @@ -347,7 +397,6 @@ public class PartnerServiceImpl implements PartnerService { } - } @Override @@ -358,12 +407,17 @@ public class PartnerServiceImpl implements PartnerService { List partnerLevels = bsPartnerLevelService.queryAllList(new HashMap<>()); String lotteryNo = DateUtil.date2String(new Date() , DateUtil.YMD); for (BsPartnerPool pool : partnerPools) { + // 判断合伙人是否有金币且用户ID不为空 if (pool.getGoldCoin().compareTo(new BigDecimal(0)) > 0 && pool.getUserId() != null) { + // 根据合伙人等级查询分红等级 BsPartnerLevel level = partnerLevels.stream().filter(s-> s.getLevel().equals(pool.getLevel())).findFirst().get(); + // 根据彩票编号和用户ID查询合伙人用户记录 BsPartnerUserRecord partnerUserRecord = bsPartnerUserRecordService.queryDetail(lotteryNo , pool.getUserId()); + // 根据用户ID查询用户信息 BsUser user = bsUserService.getUser(pool.getUserId()); + // 如果合伙人用户记录为空,则创建新的合伙人用户记录 if (partnerUserRecord == null) { partnerUserRecord = new BsPartnerUserRecord(); partnerUserRecord.setCreateTime(new Date()); @@ -372,6 +426,7 @@ public class PartnerServiceImpl implements PartnerService { partnerUserRecord.setLotteryTime(new Date()); partnerUserRecord.setUserId(pool.getUserId()); partnerUserRecord.setUserName(user.getName()); + // 计算分红金额 partnerUserRecord.setGoldCoin(pool.getGoldCoin().multiply(level.getDividendsPer())); partnerUserRecord.setProportion(level.getDividendsPer()); partnerUserRecord.setType(1); @@ -387,59 +442,124 @@ public class PartnerServiceImpl implements PartnerService { userAccountService.recharge(user.getId(),partnerUserRecord.getGoldCoin(), UserAccountRecordSourceTypeEnum.type4, userRechargeParam); } - - } - } } @Override - public List partnerData(Long startTime, Long endTime) throws Exception { + public List partnerData(Long createTimeS, Long createTimeE) throws Exception { + // 创建一个Map,用于存储查询参数 Map params = new HashMap<>(); - params.put("startTime", startTime); - params.put("endTime", endTime); + // 将createTimeS参数放入Map中 + params.put("createTimeS", createTimeS); + // 将createTimeE参数放入Map中 + params.put("createTimeE", createTimeE); + // 调用bsPartnerPoolPreService的queryAllList方法,查询所有符合条件的BsPartnerPoolPre对象,并将结果存入list中 List list = bsPartnerPoolPreService.queryAllList(params); + // 使用stream流将list中的BsPartnerPoolPre对象按照level进行分组,并将结果存入collect中 Map> collect = list.stream().collect(Collectors.groupingBy(BsPartnerPoolPre::getLevel)); - List 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 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 levelList = bsPartnerLevelService.queryAllList(new HashMap<>()); + // 使用stream流将levelList中的BsPartnerLevel对象按照level进行分组,并将结果存入listMap中 + Map> listMap = levelList.stream().collect(Collectors.groupingBy(BsPartnerLevel::getLevel)); + // 将listMap中的数据转换为JSONObject对象,并存入list中 + return listMap.keySet().stream().map(key -> { + // 创建一个JSONObject对象 JSONObject goodObject = new JSONObject(true); + // 将level放入JSONObject中 goodObject.put("level",key); - List pres = collect.get(key); - goodObject.put("campaignUserNum", pres.size()); - goodObject.put("campaignGoldCoin", pres.stream().map(BsPartnerPoolPre::getGoldCoin).reduce(BigDecimal.ZERO, BigDecimal::add)); + // 将campaignUserNum设置为0 + goodObject.put("campaignUserNum", 0); + // 将campaignGoldCoin设置为BigDecimal.ZERO + goodObject.put("campaignGoldCoin", BigDecimal.ZERO); + // 返回JSONObject对象 return goodObject; }).collect(Collectors.toList()); - return countRecords; } @Override - public List dividendData(Long startTime, Long endTime) throws Exception { + public List dividendData(Long createTimeS, Long createTimeE) throws Exception { + // 创建一个Map,用于存储查询参数 Map params = new HashMap<>(); - params.put("startTime", startTime); - params.put("endTime", endTime); + // 将createTimeS参数存入Map + params.put("createTimeS", createTimeS); + // 将createTimeE参数存入Map + params.put("createTimeE", createTimeE); + // 将type参数存入Map params.put("type", 1); + // 根据参数查询所有用户记录 List userRecords = bsPartnerUserRecordService.queryAllList(params); - Map> collect = userRecords.stream().collect(Collectors.groupingBy(BsPartnerUserRecord::getLevel)); - List countRecords = collect.keySet().stream().map(key -> { + // 如果查询结果不为空 + if (!userRecords.isEmpty()) { + // 将查询结果按照level进行分组 + Map> 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 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 list = bsPartnerLevelService.queryAllList(new HashMap<>()); + // 将查询结果按照level进行分组 + Map> listMap = list.stream().collect(Collectors.groupingBy(BsPartnerLevel::getLevel)); + // 返回分组后的结果 + return listMap.keySet().stream().map(key -> { + // 创建一个JSONObject对象 JSONObject goodObject = new JSONObject(true); + // 将level存入JSONObject goodObject.put("level",key); - List pres = collect.get(key); - goodObject.put("dividendCount", pres.size()); - goodObject.put("dividendGoldCoin", pres.stream().map(BsPartnerUserRecord::getGoldCoin).reduce(BigDecimal.ZERO, BigDecimal::add)); + // 将用户记录数量存入JSONObject + goodObject.put("dividendCount", 0); + // 将用户记录的金币数量存入JSONObject + goodObject.put("dividendGoldCoin", BigDecimal.ZERO); + // 返回JSONObject return goodObject; }).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(); + // 根据pool.getUserId()获取BsUser对象 BsUser bsUser = bsUserService.getUser(pool.getUserId()); // 查询差价 BigDecimal differencePrice = partnerPoolPre.getGoldCoin().subtract(pool.getGoldCoin()); @@ -462,6 +582,16 @@ public class PartnerServiceImpl implements PartnerService { pre.setUpdateTime(new Date()); bsPartnerPoolPreService.edit(pre); + // 如果level不为空 + if (level != null) { + // 设置用户合伙人收入比例 + bsUser.setPartnerIncomePer(level.getIncomePer()); + // 设置用户合伙人等级 + bsUser.setPartnerLevel(level.getLevel()); + // 编辑用户数据 + bsUserService.updateInfo(bsUser); + } + // 收益记录 Map userRechargeParam = new HashMap<>(); userRechargeParam.put("sourceId", userRecord.getId()); diff --git a/service/src/main/java/com/hfkj/service/partner/PartnerService.java b/service/src/main/java/com/hfkj/service/partner/PartnerService.java index 071fcdf..fb9675f 100644 --- a/service/src/main/java/com/hfkj/service/partner/PartnerService.java +++ b/service/src/main/java/com/hfkj/service/partner/PartnerService.java @@ -36,22 +36,22 @@ public interface PartnerService { /** * @MethodName partnerData * @Description: 合伙人数据统计 - * @param startTime - * @param endTime + * @param createTimeS + * @param createTimeE * @return: com.alibaba.fastjson.JSONObject * @Author: Sum1Dream * @Date: 2024/10/18 下午2:06 */ - List partnerData(Long startTime, Long endTime) throws Exception; + List partnerData(Long createTimeS, Long createTimeE) throws Exception; /** * @MethodName dividendData * @Description: 分红统计 - * @param startTime - * @param endTime + * @param createTimeS + * @param createTimeE * @return: com.alibaba.fastjson.JSONObject * @Author: Sum1Dream * @Date: 2024/10/18 下午2:25 */ - List dividendData(Long startTime, Long endTime) throws Exception; + List dividendData(Long createTimeS, Long createTimeE) throws Exception; } diff --git a/service/src/main/java/com/hfkj/service/pdd/PddService.java b/service/src/main/java/com/hfkj/service/pdd/PddService.java index 782de2b..a5c523e 100644 --- a/service/src/main/java/com/hfkj/service/pdd/PddService.java +++ b/service/src/main/java/com/hfkj/service/pdd/PddService.java @@ -2,22 +2,19 @@ package com.hfkj.service.pdd; import com.alibaba.fastjson.JSON; import com.alibaba.fastjson.JSONObject; +import com.hfkj.common.utils.DateUtil; import com.pdd.pop.sdk.common.util.JsonUtil; import com.pdd.pop.sdk.http.PopClient; 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.PddDdkGoodsSearchRequest; -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 com.pdd.pop.sdk.http.api.pop.request.*; +import com.pdd.pop.sdk.http.api.pop.response.*; + import org.slf4j.Logger; import org.slf4j.LoggerFactory; +import javax.xml.crypto.Data; import java.util.ArrayList; +import java.util.Date; import java.util.List; 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)); + + } + + } diff --git a/service/src/main/java/com/hfkj/service/promotion/Impl/PromotionServiceImpl.java b/service/src/main/java/com/hfkj/service/promotion/Impl/PromotionServiceImpl.java new file mode 100644 index 0000000..9f55e82 --- /dev/null +++ b/service/src/main/java/com/hfkj/service/promotion/Impl/PromotionServiceImpl.java @@ -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; + } +} diff --git a/service/src/main/java/com/hfkj/service/promotion/PromotionBusinessService.java b/service/src/main/java/com/hfkj/service/promotion/PromotionBusinessService.java new file mode 100644 index 0000000..c4ff9ac --- /dev/null +++ b/service/src/main/java/com/hfkj/service/promotion/PromotionBusinessService.java @@ -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 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); + + } + +} diff --git a/service/src/main/java/com/hfkj/service/promotion/PromotionService.java b/service/src/main/java/com/hfkj/service/promotion/PromotionService.java new file mode 100644 index 0000000..bede88f --- /dev/null +++ b/service/src/main/java/com/hfkj/service/promotion/PromotionService.java @@ -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; +} diff --git a/service/src/main/java/com/hfkj/service/taobao/TaoBaoService.java b/service/src/main/java/com/hfkj/service/taobao/TaoBaoService.java index 59f9bf5..cb4f99f 100644 --- a/service/src/main/java/com/hfkj/service/taobao/TaoBaoService.java +++ b/service/src/main/java/com/hfkj/service/taobao/TaoBaoService.java @@ -1,15 +1,10 @@ package com.hfkj.service.taobao; import com.alibaba.fastjson.JSON; -import com.alibaba.fastjson.JSONArray; 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.entity.SecDictionary; -import com.hfkj.model.*; -import com.hfkj.service.sec.SecDictionaryService; import com.taobao.top.DefaultTopApiClient; import com.taobao.top.TopApiClient; import com.taobao.top.ability304.Ability304; @@ -181,26 +176,6 @@ public class TaoBaoService { 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)); - - } } diff --git a/service/src/main/java/com/hfkj/service/user/BsUserAccountRecordService.java b/service/src/main/java/com/hfkj/service/user/BsUserAccountRecordService.java index d62a0fd..a00dedc 100644 --- a/service/src/main/java/com/hfkj/service/user/BsUserAccountRecordService.java +++ b/service/src/main/java/com/hfkj/service/user/BsUserAccountRecordService.java @@ -3,6 +3,7 @@ package com.hfkj.service.user; import com.hfkj.entity.BsUserAccountRecord; import java.math.BigDecimal; +import java.util.Date; import java.util.List; import java.util.Map; @@ -38,5 +39,5 @@ public interface BsUserAccountRecordService { * @param userId * @return */ - BigDecimal getUserTotalProfit(Long userId); + BigDecimal getUserTotalProfit(Long userId, Date timeS, Date timeE); } diff --git a/service/src/main/java/com/hfkj/service/user/BsUserGradeService.java b/service/src/main/java/com/hfkj/service/user/BsUserGradeService.java index 04aa6d1..225531f 100644 --- a/service/src/main/java/com/hfkj/service/user/BsUserGradeService.java +++ b/service/src/main/java/com/hfkj/service/user/BsUserGradeService.java @@ -16,13 +16,13 @@ public interface BsUserGradeService { * @param userId * @param userGrade */ - void gradeAdjust(Long userId, UserGradeEnum userGrade); + void gradeAdjust(Long userId, UserGradeEnum userGrade) throws Exception; /** * 等级晋升 * @param userId */ - void promote(Long userId); + void promote(Long userId) throws Exception; /** * 购买优淘会员 diff --git a/service/src/main/java/com/hfkj/service/user/BsUserService.java b/service/src/main/java/com/hfkj/service/user/BsUserService.java index 9e4881d..60a0b6e 100644 --- a/service/src/main/java/com/hfkj/service/user/BsUserService.java +++ b/service/src/main/java/com/hfkj/service/user/BsUserService.java @@ -72,18 +72,36 @@ public interface BsUserService { BsUser getUser(Long userId); /** - * 查询详情SmsController + * 查询详情 * @param userPhone * @return */ BsUser getUser(String userPhone); + /** + * 查询详情 + * @param wechatOpenId + * @return + */ + BsUser getUserByWechatOpenId(String wechatOpenId); + /** * 查询列表 * @param param * @return */ List getList(Map param); + + /** + * 微信授权 + * @param user 用户 + * @param other 其他参数 + * @param inviteUseId 邀请人id + * @return + * @throws Exception + */ + SessionObject weChatAuth(BsUser user, Map other, Long inviteUseId) throws Exception; + /** * 用户注册 * @param phone 手机号 diff --git a/service/src/main/java/com/hfkj/service/user/impl/BsUserAccountRecordServiceImpl.java b/service/src/main/java/com/hfkj/service/user/impl/BsUserAccountRecordServiceImpl.java index 49dc2df..2064df9 100644 --- a/service/src/main/java/com/hfkj/service/user/impl/BsUserAccountRecordServiceImpl.java +++ b/service/src/main/java/com/hfkj/service/user/impl/BsUserAccountRecordServiceImpl.java @@ -1,5 +1,6 @@ package com.hfkj.service.user.impl; +import com.hfkj.common.utils.DateUtil; import com.hfkj.dao.BsUserAccountRecordMapper; import com.hfkj.entity.BsUserAccountRecord; import com.hfkj.entity.BsUserAccountRecordExample; @@ -56,7 +57,19 @@ public class BsUserAccountRecordServiceImpl implements BsUserAccountRecordServic } @Override - public BigDecimal getUserTotalProfit(Long userId) { - return userAccountRecordMapper.queryUserTotalProfit(userId); + public BigDecimal getUserTotalProfit(Long userId, Date timeS, Date timeE) { + 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); } } diff --git a/service/src/main/java/com/hfkj/service/user/impl/BsUserGradeServiceImpl.java b/service/src/main/java/com/hfkj/service/user/impl/BsUserGradeServiceImpl.java index 787a941..0a992fc 100644 --- a/service/src/main/java/com/hfkj/service/user/impl/BsUserGradeServiceImpl.java +++ b/service/src/main/java/com/hfkj/service/user/impl/BsUserGradeServiceImpl.java @@ -37,14 +37,14 @@ public class BsUserGradeServiceImpl implements BsUserGradeService { @Override @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); if (user == null) { - throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, ""); + throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "未找到用户"); } user.setGrade(userGrade.getCode()); - userService.editData(user); + userService.updateInfo(user); // 修改上下级关系等级 userParentRelService.updateParentGrade(user.getId(), userGrade); @@ -52,7 +52,7 @@ public class BsUserGradeServiceImpl implements BsUserGradeService { @Override @Transactional(propagation= Propagation.REQUIRED,rollbackFor= {RuntimeException.class}) - public void promote(Long userId) { + public void promote(Long userId) throws Exception { // 查询详情 BsUser user = userService.getUser(userId); if (user == null) { @@ -62,7 +62,7 @@ public class BsUserGradeServiceImpl implements BsUserGradeService { // 晋升优淘会员 if (promoteGrade2(user)) { user.setGrade(UserGradeEnum.grade2.getCode()); - userService.editData(user); + userService.updateInfo(user); // 修改上下级关系等级 userParentRelService.updateParentGrade(user.getId(), UserGradeEnum.grade2); @@ -71,7 +71,7 @@ public class BsUserGradeServiceImpl implements BsUserGradeService { // 晋升团长 if (promoteGrade3(user)) { user.setGrade(UserGradeEnum.grade3.getCode()); - userService.editData(user); + userService.updateInfo(user); // 修改上下级关系等级 userParentRelService.updateParentGrade(user.getId(), UserGradeEnum.grade3); @@ -80,7 +80,7 @@ public class BsUserGradeServiceImpl implements BsUserGradeService { // 晋升渠道 if (promoteGrade4(user)) { user.setGrade(UserGradeEnum.grade4.getCode()); - userService.editData(user); + userService.updateInfo(user); // 修改上下级关系等级 userParentRelService.updateParentGrade(user.getId(), UserGradeEnum.grade4); @@ -116,7 +116,7 @@ public class BsUserGradeServiceImpl implements BsUserGradeService { } // 条件二(元宝收益达到5元宝) - BigDecimal profit = userAccountRecordService.getUserTotalProfit(userId); + BigDecimal profit = userAccountRecordService.getUserTotalProfit(userId,null,null); map.put("condition2", profit); return map; @@ -137,7 +137,7 @@ public class BsUserGradeServiceImpl implements BsUserGradeService { map.put("condition2", subData.stream().filter(o -> o.getRelType().equals(2)).count()); // 条件三(累计元宝收益达到100元宝) - BigDecimal profit = userAccountRecordService.getUserTotalProfit(userId); + BigDecimal profit = userAccountRecordService.getUserTotalProfit(userId,null,null); map.put("condition3", profit); return map; @@ -159,7 +159,7 @@ public class BsUserGradeServiceImpl implements BsUserGradeService { map.put("condition2", directlyUnderData.stream().filter(o -> o.getRelType().equals(2)).count()); // 条件三(累计元宝收益达到10000元宝) - BigDecimal profit = userAccountRecordService.getUserTotalProfit(userId); + BigDecimal profit = userAccountRecordService.getUserTotalProfit(userId, null, null); map.put("condition3", profit); return map; diff --git a/service/src/main/java/com/hfkj/service/user/impl/BsUserServiceImpl.java b/service/src/main/java/com/hfkj/service/user/impl/BsUserServiceImpl.java index 3085fba..539f5e6 100644 --- a/service/src/main/java/com/hfkj/service/user/impl/BsUserServiceImpl.java +++ b/service/src/main/java/com/hfkj/service/user/impl/BsUserServiceImpl.java @@ -92,13 +92,8 @@ public class BsUserServiceImpl implements BsUserService { } String oldPhone = user.getPhone(); 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); } @@ -123,13 +118,7 @@ public class BsUserServiceImpl implements BsUserService { throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "未找到用户"); } user.setWechatNum(wechatNum); - editData(user); - - // 更新session - UserSessionObject session = new UserSessionObject(); - session.setUser(user); - SessionObject sessionObject = new SessionObject(userToken(user.getId()), session); - userCenter.save(sessionObject); + updateInfo(user); } @Override @@ -145,21 +134,15 @@ public class BsUserServiceImpl implements BsUserService { if (getUser(inviteUseId) == null) { throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "未知的邀请人Id"); } - user.setInviteUserId(inviteUseId); - user.setInviteTime(new Date()); - editData(user); - BsUserParentRel userParentRel = new BsUserParentRel(); userParentRel.setParentUserId(userParentRel.getParentUserId()); userParentRel.setParentUserGrade(userParentRel.getParentUserGrade()); userParentRel.setUserId(userId); userParentRelService.editData(userParentRel); - // 更新session - UserSessionObject session = new UserSessionObject(); - session.setUser(user); - SessionObject sessionObject = new SessionObject(userToken(user.getId()), session); - userCenter.save(sessionObject); + user.setInviteUserId(inviteUseId); + user.setInviteTime(new Date()); + updateInfo(user); } @Override @@ -250,6 +233,17 @@ public class BsUserServiceImpl implements BsUserService { return null; } + @Override + public BsUser getUserByWechatOpenId(String wechatOpenId) { + BsUserExample example = new BsUserExample(); + example.createCriteria().andStatusNotEqualTo(0).andWechatOpenIdEqualTo(wechatOpenId); + List list = userMapper.selectByExample(example); + if (!list.isEmpty()) { + return list.get(0); + } + return null; + } + @Override public List getList(Map param) { BsUserExample example = new BsUserExample(); @@ -279,6 +273,49 @@ public class BsUserServiceImpl implements BsUserService { return userMapper.selectByExample(example); } + @Override + @Transactional(propagation= Propagation.REQUIRED,rollbackFor= {RuntimeException.class}) + public SessionObject weChatAuth(BsUser user, Map 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 @Transactional(propagation= Propagation.REQUIRED,rollbackFor= {RuntimeException.class}) public BsUser register(String phone, Map other, Long inviteUseId) { diff --git a/service/src/main/java/com/hfkj/sysenum/user/UserLoginType.java b/service/src/main/java/com/hfkj/sysenum/user/UserLoginType.java index 2e6e833..ddc6594 100644 --- a/service/src/main/java/com/hfkj/sysenum/user/UserLoginType.java +++ b/service/src/main/java/com/hfkj/sysenum/user/UserLoginType.java @@ -19,7 +19,7 @@ public enum UserLoginType { /** * 微信授权 */ - WECHAT_EMPOWER("WECHAT_EMPOWER", "微信授权"), + WECHAT_AUTH("WECHAT_AUTH", "微信授权"), ; private String code;