胡锐 5 days ago
commit e4ea430426
  1. 24
      cweb/src/main/java/com/hfkj/controller/GoodsController.java
  2. 120
      cweb/src/main/java/com/hfkj/controller/TestController.java
  3. 6
      cweb/src/main/java/com/hfkj/controller/notify/TaoBaoNotify.java
  4. 2
      cweb/src/main/java/com/hfkj/controller/order/BsOrderController.java
  5. 2
      service/src/main/java/com/hfkj/entity/BsOrder.java
  6. 10
      service/src/main/java/com/hfkj/service/order/BsOrderService.java
  7. 126
      service/src/main/java/com/hfkj/service/order/Impl/BsOrderServiceImpl.java
  8. 31
      service/src/main/java/com/hfkj/service/pdd/PddService.java
  9. 2
      service/src/main/java/com/hfkj/service/promotion/PromotionBusinessService.java

@ -68,7 +68,7 @@ public class GoodsController {
} else if (type == 2) {
// 用户session
UserSessionObject userSession = userCenter.getSessionModel(UserSessionObject.class);
Map<String , Object> mapUser = new HashMap<>();
Map<String , Object> mapUser = new JSONObject();
mapUser.put("uid", userSession.getUser().getId());
JSONObject object = PddService.authority(mapUser.toString());
boolean generateAuthorityUrl = object.getJSONObject("authorityQueryResponse").getInteger("bind") == 0;
@ -124,29 +124,7 @@ public class GoodsController {
}
}
@RequestMapping(value="/promotion",method = RequestMethod.GET)
@ResponseBody
@ApiOperation(value = "多多进宝推广链接生成")
public ResponseData promotion(@RequestParam(value = "searchId" , required = false) String searchId,
@RequestParam(value = "goodsSign" , required = false) String goodsSign
) {
try {
Map<String , Object> map = new HashMap<>();
map.put("searchId" , searchId);
map.put("goodsSign" , goodsSign);
JSONObject object = PddService.authority("139");
boolean generateAuthorityUrl = object.getJSONObject("authorityQueryResponse").getInteger("bind") == 0;
JSONObject jsonObject = PddService.promotion(searchId , goodsSign , generateAuthorityUrl , map.toString());
return ResponseMsgUtil.success(jsonObject.getJSONObject("goodsPromotionUrlGenerateResponse").getJSONArray("goodsPromotionUrlList").getJSONObject(0));
} catch (Exception e) {
log.error("error!",e);
return ResponseMsgUtil.exception(e);
}
}
@RequestMapping(value="/publisher",method = RequestMethod.GET)
@ResponseBody

@ -41,12 +41,6 @@ import java.util.Map;
public class TestController {
private static Logger log = LoggerFactory.getLogger(TestController.class);
@Resource
private BsUserParentRelService userParentRelService;
@Resource
private BsUserContributeService userContributeService;
@RequestMapping(value="/material",method = RequestMethod.GET)
@ResponseBody
@ApiOperation(value = "淘宝客-推广者-物料id列表查询 ")
@ -70,120 +64,6 @@ public class TestController {
}
}
@RequestMapping(value="/createCommand",method = RequestMethod.GET)
@ResponseBody
@ApiOperation(value = "淘口令生成 ")
public ResponseData createCommand(@RequestParam(value = "url" , required = false) String url
) {
try {
JSONObject jsonObject = TaoBaoService.createCommand("https:" + url);
if (jsonObject.getBoolean("success")) {
return ResponseMsgUtil.success(jsonObject.getJSONObject("data"));
} else {
throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "请求失败!");
}
} catch (Exception e) {
log.error("error!",e);
return ResponseMsgUtil.exception(e);
}
}
@RequestMapping(value="/generateLink",method = RequestMethod.GET)
@ResponseBody
@ApiOperation(value = "自助取链接口 ")
public ResponseData generateLink(@RequestParam(value = "actId" , required = false) Long actId,
@RequestParam(value = "linkType" , required = false) Integer linkType
) {
try {
JSONObject jsonObject = new JSONObject();
jsonObject.put("actId" , actId);
jsonObject.put("sid" , "001");
jsonObject.put("linkType" , linkType);
JSONObject object = MeiTuanService.generateLink(jsonObject);
return ResponseMsgUtil.success(object);
} catch (Exception e) {
log.error("error!",e);
return ResponseMsgUtil.exception(e);
}
}
@RequestMapping(value="/getParent",method = RequestMethod.GET)
@ResponseBody
@ApiOperation(value = "getParent ")
public ResponseData getParent() {
try {
return ResponseMsgUtil.success(userParentRelService.getParent(Arrays.asList(UserGradeEnum.grade3,UserGradeEnum.grade4), 4L));
} catch (Exception e) {
log.error("error!",e);
return ResponseMsgUtil.exception(e);
}
}
@Resource
private BsUserGradeService userGradeService;
@RequestMapping(value="/promote",method = RequestMethod.GET)
@ResponseBody
@ApiOperation(value = "promote")
public ResponseData promote() {
try {
userGradeService.promote(1L);
return ResponseMsgUtil.success("操作成功");
} catch (Exception e) {
log.error("error!",e);
return ResponseMsgUtil.exception(e);
}
}
@RequestMapping(value="/purchase",method = RequestMethod.GET)
@ResponseBody
@ApiOperation(value = "会员贡献测试")
public ResponseData purchase(@RequestParam(value = "rebate" , required = true) BigDecimal rebate,
@RequestParam(value = "userId" , required = true) Long userId) {
try {
Map<String,Object> otherParam = new HashMap<>();
otherParam.put("sourceId", System.currentTimeMillis());
otherParam.put("sourceOrderNo", System.currentTimeMillis());
userContributeService.purchase(rebate, userId, otherParam);
return ResponseMsgUtil.success("操作成功");
} catch (Exception e) {
log.error("error!",e);
return ResponseMsgUtil.exception(e);
}
}
@RequestMapping(value="/authorize",method = RequestMethod.GET)
@ResponseBody
@ApiOperation(value = "获取淘宝code")
public ResponseData authorize() {
try {
JSONObject object = HttpsUtils.doGet("https://oauth.taobao.com/authorize?response_type=code&client_id=34807616&redirect_uri=https://yuanqiyoutao.com/crest/taoBaoNotify/notify&state=1212&view=wap");
return ResponseMsgUtil.success(object);
} catch (Exception e) {
log.error("error!",e);
return ResponseMsgUtil.exception(e);
}
}

@ -1,9 +1,6 @@
package com.hfkj.controller.notify;
import com.alibaba.fastjson.JSONObject;
import com.hfkj.common.utils.HttpsUtils;
import com.hfkj.config.CommonSysConst;
import com.hfkj.service.taobao.TaoBaoService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.slf4j.Logger;
@ -11,9 +8,6 @@ import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;
import javax.servlet.http.HttpServletResponse;
import java.io.PrintWriter;
@Controller
@RequestMapping(value = "/taoBaoNotify")
@Api(value = "淘宝业务通知")

@ -99,7 +99,7 @@ public class BsOrderController {
public ResponseData getPddOrderList() {
try {
return ResponseMsgUtil.success(orderService.getOrderList());
return ResponseMsgUtil.success(orderService.getOrderList("2024-10-01 00:00:00"));
} catch (Exception e) {
log.error("error!",e);

@ -75,7 +75,7 @@ public class BsOrder implements Serializable {
private BigDecimal gold;
/**
* 1-已支付 2-确认收货3-审核成功4-审核失败不可提现5-已经结算 ;10-已处罚
* 状态 0-已支付1-已成团2-确认收货3-审核成功4-审核失败不可提现5-已经结算 6-已失效 ;10-已处罚
*/
private Integer status;

@ -1,6 +1,7 @@
package com.hfkj.service.order;
import com.alibaba.fastjson.JSONObject;
import com.hfkj.entity.BsCornucopiaConfig;
import com.hfkj.entity.BsOrder;
import com.hfkj.model.BsOrderModel;
@ -16,6 +17,8 @@ import java.util.Map;
**/
public interface BsOrderService {
void create(BsOrder order);
/**
* 编辑数据
* @param order
@ -64,7 +67,7 @@ public interface BsOrderService {
* @Author: Sum1Dream
* @Date: 2024/10/23 上午10:27
*/
JSONObject getOrderList() throws Exception;
JSONObject getOrderList(String startTime) throws Exception;
/**
* @MethodName getOrderListParent
@ -79,13 +82,12 @@ public interface BsOrderService {
/**
* @MethodName orderRebate
* @Description: 订单返利
* @param orderNo 订单号
* @param gold 返利金额
* @param bsOrder 订单
* @return: void
* @Author: Sum1Dream
* @Date: 2024/10/24 下午3:03
*/
void orderRebate(String orderNo , BigDecimal gold) throws Exception;
void orderRebate(BsOrder bsOrder) throws Exception;
}

@ -1,14 +1,18 @@
package com.hfkj.service.order.Impl;
import com.alibaba.fastjson.JSON;
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.DateUtil;
import com.hfkj.common.utils.OrderUtil;
import com.hfkj.common.utils.RedisUtil;
import com.hfkj.dao.BsOrderMapper;
import com.hfkj.entity.BsCornucopiaConfig;
import com.hfkj.entity.BsOrder;
import com.hfkj.entity.BsOrderExample;
import com.hfkj.entity.BsUser;
import com.hfkj.model.BsOrderModel;
import com.hfkj.model.UserTeamModel;
import com.hfkj.service.order.BsOrderService;
@ -18,6 +22,10 @@ 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 com.hfkj.service.user.BsUserService;
import com.hfkj.sysenum.partner.PartnerEnum;
import com.hfkj.sysenum.user.UserAccountRecordSourceTypeEnum;
import com.pdd.pop.sdk.http.api.pop.response.PddDdkOrderListRangeGetResponse;
import org.apache.commons.collections4.MapUtils;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.BeanUtils;
@ -52,6 +60,14 @@ public class BsOrderServiceImpl implements BsOrderService {
@Resource
private SecDictionaryService secDictionaryService;
@Resource
private BsUserService userService;
@Override
public void create(BsOrder order) {
bsOrderMapper.insert(order);
}
@Override
public BsOrder editData(BsOrder order) {
bsOrderMapper.updateByPrimaryKey(order);
@ -129,10 +145,13 @@ public class BsOrderServiceImpl implements BsOrderService {
}
@Override
public JSONObject getOrderList() throws Exception{
return PddService.getOrderList();
public JSONObject getOrderList(String startTime) throws Exception{
pddOrder(startTime);
return null;
}
@Override
public List<BsOrderModel> getOrderListParent(Map<String, Object> map) {
@ -190,9 +209,7 @@ public class BsOrderServiceImpl implements BsOrderService {
}
@Override
public void orderRebate(String orderNo, BigDecimal gold) throws Exception {
BsOrder bsOrder = findByOrderNo(orderNo);
public void orderRebate(BsOrder bsOrder) throws Exception {
// 判断订单状态是否为4或5
if (bsOrder.getStatus().equals(4) || bsOrder.getStatus().equals(5)) {
// 如果是,则抛出异常,提示订单状态不可返利
@ -202,5 +219,104 @@ public class BsOrderServiceImpl implements BsOrderService {
otherParam.put("sourceId", bsOrder.getId());
otherParam.put("sourceOrderNo", bsOrder.getOrderNo());
userContributeService.purchase(bsOrder.getPromotionAmount(), bsOrder.getUserId(), otherParam);
bsOrder.setStatus(8);
bsOrder.setUpdateTime(new Date());
bsOrder.setFinishTime(new Date());
editData(bsOrder);
}
// 根据开始时间获取拼多多订单列表
private void pddOrder(String startTime) throws Exception{
// 调用PddService的getOrderList方法获取订单列表
PddDdkOrderListRangeGetResponse rangeGetResponse = PddService.getOrderList(startTime);
// 调用getOrderList方法获取本地订单列表
List<BsOrder> list = getOrderList(new HashMap<>());
// 判断rangeGetResponse是否为空
if (rangeGetResponse != null) {
// 获取订单列表
List<PddDdkOrderListRangeGetResponse.OrderListGetResponseOrderListItem> orderListItems = rangeGetResponse.getOrderListGetResponse().getOrderList();
// 判断订单列表是否为空
if (!orderListItems.isEmpty()) {
for (PddDdkOrderListRangeGetResponse.OrderListGetResponseOrderListItem orderListItem : orderListItems) {
// 用户uid
boolean containsEqual = orderListItem.getCustomParameters().contains("=");
String uid;
if (containsEqual) {
// 去掉字符串中的'{'
char charToRemove = '{';
String strippedString = StringUtils.strip(orderListItem.getCustomParameters(), String.valueOf(charToRemove));
// 以'='为分隔符,将字符串分割成数组
String[] split = strippedString.substring(0, strippedString.length()-1).split("=");
// 获取数组中的第二个元素,即uid
uid = split[1];
} else {
// 将字符串转换为JSONObject对象
JSONObject custom = JSON.parseObject(orderListItem.getCustomParameters());
// 获取JSONObject对象中的uid
uid = custom.getString("uid");
}
// 根据订单号获取BsOrder对象
BsOrder bsOrder = list.stream().filter(s->s.getOrderNo().equals(orderListItem.getOrderSn())).findFirst().orElse(null);
// 根据uid获取BsUser对象
BsUser user = userService.getUser(uid);
if (bsOrder == null) {
// 如果BsOrder对象为空,则创建新的BsOrder对象
bsOrder = new BsOrder();
bsOrder.setOrderNo(orderListItem.getOrderSn());
bsOrder.setUserId(Long.valueOf(uid));
bsOrder.setUserPhone(user.getPhone());
bsOrder.setCreateTime(new Date());
bsOrder.setUpdateTime(new Date());
bsOrder.setStatus(orderListItem.getOrderStatus());
bsOrder.setImg(orderListItem.getGoodsThumbnailUrl());
bsOrder.setType(2);
bsOrder.setGoodsName(orderListItem.getGoodsName());
bsOrder.setGoodsCount(Math.toIntExact(orderListItem.getGoodsQuantity()));
bsOrder.setCustomparameters(orderListItem.getCustomParameters());
bsOrder.setTotalPrice(BigDecimal.valueOf(orderListItem.getOrderAmount()));
bsOrder.setPromotionAmount(BigDecimal.valueOf(orderListItem.getPromotionAmount()));
bsOrder.setPayTime(DateUtil.long2Date(orderListItem.getOrderPayTime()));
bsOrder.setCreateTime(DateUtil.long2Date(orderListItem.getOrderCreateTime()));
bsOrder.setFinishTime(DateUtil.long2Date(orderListItem.getOrderSettleTime()));
bsOrder.setRefundTime(DateUtil.long2Date(orderListItem.getOrderModifyAt()));
bsOrder.setCancelTime(DateUtil.long2Date(orderListItem.getOrderModifyAt()));
create(bsOrder);
}else {
// 如果BsOrder对象不为空,则更新BsOrder对象
bsOrder.setUpdateTime(new Date());
bsOrder.setStatus(orderListItem.getOrderStatus());
bsOrder.setImg(orderListItem.getGoodsThumbnailUrl());
bsOrder.setType(2);
bsOrder.setGoodsName(orderListItem.getGoodsName());
bsOrder.setGoodsCount(Math.toIntExact(orderListItem.getGoodsQuantity()));
bsOrder.setCustomparameters(orderListItem.getCustomParameters());
bsOrder.setTotalPrice(BigDecimal.valueOf(orderListItem.getOrderAmount()));
bsOrder.setPromotionAmount(BigDecimal.valueOf(orderListItem.getPromotionAmount()));
bsOrder.setPayTime(DateUtil.long2Date(orderListItem.getOrderPayTime()));
bsOrder.setCreateTime(DateUtil.long2Date(orderListItem.getOrderCreateTime()));
bsOrder.setFinishTime(DateUtil.long2Date(orderListItem.getOrderSettleTime()));
bsOrder.setRefundTime(DateUtil.long2Date(orderListItem.getOrderModifyAt()));
bsOrder.setCancelTime(DateUtil.long2Date(orderListItem.getOrderModifyAt()));
// 如果订单状态为5,则调用orderRebate方法
if (bsOrder.getStatus() == 5){
orderRebate(bsOrder);
} else {
editData(bsOrder);
}
}
}
}
}
}
}

@ -168,7 +168,7 @@ public class PddService {
* @Author: Sum1Dream
* @Date: 2024/10/23 上午10:27
*/
public static JSONObject getOrderList() throws Exception {
public static PddDdkOrderListRangeGetResponse getOrderList(String startTime) throws Exception {
log.info("============ 拼多多请求-START =============");
String clientId = "71a050c5d93d4169a237539af44c7c33";
@ -176,12 +176,37 @@ public class PddService {
PopClient client = new PopHttpClient(clientId, clientSecret);
PddDdkOrderListRangeGetRequest request = new PddDdkOrderListRangeGetRequest();
request.setCashGiftOrder(true);
request.setStartTime("2024-05-07 00:00:00");
request.setStartTime(startTime);
request.setPageSize(300);
request.setQueryOrderType(1);
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 response;
}
public static JSONObject increment() throws Exception {
log.info("============ 拼多多请求-START =============");
String clientId = "71a050c5d93d4169a237539af44c7c33";
String clientSecret = "b96def667dd28660d09f19ba2e9e9f23d810d563";
PopClient client = new PopHttpClient(clientId, clientSecret);
PddDdkOrderListIncrementGetRequest request = new PddDdkOrderListIncrementGetRequest();
request.setCashGiftOrder(true);
request.setEndUpdateTime(24L);
request.setPage(1);
request.setPageSize(50);
request.setQueryOrderType(1);
request.setReturnCount(true);
request.setStartUpdateTime(new Date().getTime());
PddDdkOrderListIncrementGetResponse response = client.syncInvoke(request);
log.info("请求接口:" + "authority");
log.info("请求参数:" + JSONObject.toJSONString(request));
log.info("响应参数:" + JsonUtil.transferToJson(response));

@ -48,7 +48,7 @@ public class PromotionBusinessService {
throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "缺少goodsSign!");
}
Map<String , Object> mapUser = new HashMap<>();
Map<String , Object> mapUser = new JSONObject();
mapUser.put("uid", jsonObject.getLong("userId"));
// 判断是否需要授权

Loading…
Cancel
Save