Compare commits

..

No commits in common. 'fe920d33c532ffe915599cfe3f4dc8c6d9e994ac' and '15270e323c72085b63432f2a8b3c73c5ed0d8a2e' have entirely different histories.

  1. 48
      bweb/src/main/java/com/hfkj/controller/partner/PartnerController.java
  2. BIN
      cweb/lib/taobao-sdk-java-elm.jar
  3. 7
      cweb/pom.xml
  4. 1
      cweb/src/main/java/com/hfkj/config/AuthConfig.java
  5. 44
      cweb/src/main/java/com/hfkj/controller/ElmController.java
  6. 25
      cweb/src/main/java/com/hfkj/controller/TakeOutController.java
  7. 1
      cweb/src/main/java/com/hfkj/controller/TestController.java
  8. 35
      cweb/src/main/java/com/hfkj/controller/order/BsOrderController.java
  9. 37
      cweb/src/main/java/com/hfkj/controller/partner/PartnerController.java
  10. 59
      cweb/src/main/java/com/hfkj/controller/promotion/PromotionController.java
  11. BIN
      service/lib/taobao-sdk-java-elm.jar
  12. 8
      service/pom.xml
  13. 37
      service/src/main/java/com/hfkj/common/utils/HttpsUtils.java
  14. 111
      service/src/main/java/com/hfkj/common/utils/TaoBaoUtil.java
  15. 24
      service/src/main/java/com/hfkj/model/BsOrderModel.java
  16. 8
      service/src/main/java/com/hfkj/service/cornucopia/Impl/BsCornucopiaLotteryRecordServiceImpl.java
  17. 99
      service/src/main/java/com/hfkj/service/elm/ElmService.java
  18. 19
      service/src/main/java/com/hfkj/service/meituan/MeiTuanService.java
  19. 30
      service/src/main/java/com/hfkj/service/order/BsOrderService.java
  20. 117
      service/src/main/java/com/hfkj/service/order/Impl/BsOrderServiceImpl.java
  21. 50
      service/src/main/java/com/hfkj/service/order/OrderBusinessService.java
  22. 1
      service/src/main/java/com/hfkj/service/partner/BsPartnerPoolService.java
  23. 5
      service/src/main/java/com/hfkj/service/partner/Impl/BsPartnerLevelServiceImpl.java
  24. 18
      service/src/main/java/com/hfkj/service/partner/Impl/BsPartnerPoolPreServiceImpl.java
  25. 20
      service/src/main/java/com/hfkj/service/partner/Impl/BsPartnerPoolServiceImpl.java
  26. 8
      service/src/main/java/com/hfkj/service/partner/Impl/BsPartnerUserRecordServiceImpl.java
  27. 186
      service/src/main/java/com/hfkj/service/partner/Impl/PartnerServiceImpl.java
  28. 12
      service/src/main/java/com/hfkj/service/partner/PartnerService.java
  29. 46
      service/src/main/java/com/hfkj/service/pdd/PddService.java
  30. 29
      service/src/main/java/com/hfkj/service/promotion/Impl/PromotionServiceImpl.java
  31. 63
      service/src/main/java/com/hfkj/service/promotion/PromotionBusinessService.java
  32. 20
      service/src/main/java/com/hfkj/service/promotion/PromotionService.java
  33. 25
      service/src/main/java/com/hfkj/service/taobao/TaoBaoService.java

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

Binary file not shown.

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

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

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

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

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

@ -13,8 +13,6 @@ import com.hfkj.model.ResponseData;
import com.hfkj.model.SecUserSessionObject; import com.hfkj.model.SecUserSessionObject;
import com.hfkj.model.UserSessionObject; import com.hfkj.model.UserSessionObject;
import com.hfkj.service.order.BsOrderService; import com.hfkj.service.order.BsOrderService;
import com.hfkj.service.promotion.PromotionBusinessService;
import com.hfkj.service.promotion.PromotionService;
import io.swagger.annotations.Api; import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation; import io.swagger.annotations.ApiOperation;
import org.slf4j.Logger; import org.slf4j.Logger;
@ -40,13 +38,14 @@ public class BsOrderController {
@Resource @Resource
private UserCenter userCenter; private UserCenter userCenter;
@Resource
private BsOrderService bsOrderService;
@RequestMapping(value="/getOrderList",method = RequestMethod.GET) @RequestMapping(value="/getOrderList",method = RequestMethod.GET)
@ResponseBody @ResponseBody
@ApiOperation(value = "查询列表") @ApiOperation(value = "查询列表")
public ResponseData getOrderList(@RequestParam(value = "orderNo" , required = false) String orderNo, public ResponseData getOrderList(@RequestParam(value = "orderNo" , required = false) String orderNo,
@RequestParam(value = "type" , required = false) Integer type, @RequestParam(value = "type" , required = false) Integer type,
@RequestParam(value = "orderType" , required = true) Integer orderType,
@RequestParam(value = "status" , required = false) Integer status, @RequestParam(value = "status" , required = false) Integer status,
@RequestParam(value = "userPhone" , required = false) String userPhone, @RequestParam(value = "userPhone" , required = false) String userPhone,
@RequestParam(value = "goodsName" , required = false) String goodsName, @RequestParam(value = "goodsName" , required = false) String goodsName,
@ -56,23 +55,24 @@ public class BsOrderController {
@RequestParam(value = "pageSize" , required = true) Integer pageSize, HttpServletRequest request) { @RequestParam(value = "pageSize" , required = true) Integer pageSize, HttpServletRequest request) {
try { try {
// 用户session SessionObject sessionObject = userCenter.getSessionObject(request);
UserSessionObject session = userCenter.getSessionModel(UserSessionObject.class); SecUserSessionObject userModel = (SecUserSessionObject) sessionObject.getObject();
Map<String , Object> map = new HashMap<>(); Map<String , Object> map = new HashMap<>();
map.put("orderNo", orderNo); map.put("orderNo", orderNo);
map.put("userPhone", userPhone); map.put("userPhone", userPhone);
map.put("type", type); map.put("type", type);
map.put("orderType", orderType); map.put("userId", userModel.getAccount().getId());
map.put("userId", session.getUser().getId());
map.put("status", status); map.put("status", status);
map.put("goodsName", goodsName); map.put("goodsName", goodsName);
map.put("createTimeS", createTimeS); map.put("createTimeS", createTimeS);
map.put("createTimeE", createTimeE); map.put("createTimeE", createTimeE);
PageHelper.startPage(pageNum, pageSize); PageHelper.startPage(pageNum, pageSize);
return ResponseMsgUtil.success(new PageInfo<>(orderService.getOrderListParent(map))); return ResponseMsgUtil.success(new PageInfo<>(orderService.getOrderList(map)));
} catch (Exception e) { } catch (Exception e) {
log.error("error!",e); log.error("error!",e);
@ -80,13 +80,22 @@ public class BsOrderController {
} }
} }
@RequestMapping(value="/getPddOrderList",method = RequestMethod.GET) @RequestMapping(value="/create",method = RequestMethod.POST)
@ResponseBody @ResponseBody
@ApiOperation(value = "用时间段查询推广订单接口") @ApiOperation(value = "创建订单")
public ResponseData getPddOrderList() { public ResponseData create(@RequestBody JSONObject jsonObject) {
try { try {
return ResponseMsgUtil.success(orderService.getOrderList()); // 用户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));
} catch (Exception e) { } catch (Exception e) {
log.error("error!",e); log.error("error!",e);
@ -94,6 +103,4 @@ public class BsOrderController {
} }
} }
} }

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

@ -1,59 +0,0 @@
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);
}
}
}

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

@ -2,19 +2,22 @@ package com.hfkj.service.pdd;
import com.alibaba.fastjson.JSON; import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject; import com.alibaba.fastjson.JSONObject;
import com.hfkj.common.utils.DateUtil;
import com.pdd.pop.sdk.common.util.JsonUtil; import com.pdd.pop.sdk.common.util.JsonUtil;
import com.pdd.pop.sdk.http.PopClient; import com.pdd.pop.sdk.http.PopClient;
import com.pdd.pop.sdk.http.PopHttpClient; import com.pdd.pop.sdk.http.PopHttpClient;
import com.pdd.pop.sdk.http.api.pop.request.*; import com.pdd.pop.sdk.http.api.pop.request.PddDdkGoodsPromotionUrlGenerateRequest;
import com.pdd.pop.sdk.http.api.pop.response.*; 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 org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
import javax.xml.crypto.Data;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Date;
import java.util.List; import java.util.List;
public class PddService { public class PddService {
@ -160,36 +163,5 @@ 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));
}
} }

@ -1,29 +0,0 @@
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;
}
}

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

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

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

Loading…
Cancel
Save