|
|
@ -1,14 +1,18 @@ |
|
|
|
package com.hfkj.service.order.Impl; |
|
|
|
package com.hfkj.service.order.Impl; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
import com.alibaba.fastjson.JSON; |
|
|
|
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.DateUtil; |
|
|
|
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.BsCornucopiaConfig; |
|
|
|
import com.hfkj.entity.BsOrder; |
|
|
|
import com.hfkj.entity.BsOrder; |
|
|
|
import com.hfkj.entity.BsOrderExample; |
|
|
|
import com.hfkj.entity.BsOrderExample; |
|
|
|
|
|
|
|
import com.hfkj.entity.BsUser; |
|
|
|
import com.hfkj.model.BsOrderModel; |
|
|
|
import com.hfkj.model.BsOrderModel; |
|
|
|
import com.hfkj.model.UserTeamModel; |
|
|
|
import com.hfkj.model.UserTeamModel; |
|
|
|
import com.hfkj.service.order.BsOrderService; |
|
|
|
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.sec.SecDictionaryService; |
|
|
|
import com.hfkj.service.user.BsUserContributeService; |
|
|
|
import com.hfkj.service.user.BsUserContributeService; |
|
|
|
import com.hfkj.service.user.BsUserParentRelService; |
|
|
|
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.collections4.MapUtils; |
|
|
|
import org.apache.commons.lang3.StringUtils; |
|
|
|
import org.apache.commons.lang3.StringUtils; |
|
|
|
import org.springframework.beans.BeanUtils; |
|
|
|
import org.springframework.beans.BeanUtils; |
|
|
@ -52,6 +60,14 @@ public class BsOrderServiceImpl implements BsOrderService { |
|
|
|
@Resource |
|
|
|
@Resource |
|
|
|
private SecDictionaryService secDictionaryService; |
|
|
|
private SecDictionaryService secDictionaryService; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Resource |
|
|
|
|
|
|
|
private BsUserService userService; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
|
|
|
|
public void create(BsOrder order) { |
|
|
|
|
|
|
|
bsOrderMapper.insert(order); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
@Override |
|
|
|
public BsOrder editData(BsOrder order) { |
|
|
|
public BsOrder editData(BsOrder order) { |
|
|
|
bsOrderMapper.updateByPrimaryKey(order); |
|
|
|
bsOrderMapper.updateByPrimaryKey(order); |
|
|
@ -129,10 +145,13 @@ public class BsOrderServiceImpl implements BsOrderService { |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
@Override |
|
|
|
public JSONObject getOrderList() throws Exception{ |
|
|
|
public JSONObject getOrderList(String startTime) throws Exception{ |
|
|
|
return PddService.getOrderList(); |
|
|
|
|
|
|
|
|
|
|
|
pddOrder(startTime); |
|
|
|
|
|
|
|
return null; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
@Override |
|
|
|
public List<BsOrderModel> getOrderListParent(Map<String, Object> map) { |
|
|
|
public List<BsOrderModel> getOrderListParent(Map<String, Object> map) { |
|
|
|
|
|
|
|
|
|
|
@ -190,9 +209,7 @@ public class BsOrderServiceImpl implements BsOrderService { |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
@Override |
|
|
|
public void orderRebate(String orderNo, BigDecimal gold) throws Exception { |
|
|
|
public void orderRebate(BsOrder bsOrder) throws Exception { |
|
|
|
BsOrder bsOrder = findByOrderNo(orderNo); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// 判断订单状态是否为4或5
|
|
|
|
// 判断订单状态是否为4或5
|
|
|
|
if (bsOrder.getStatus().equals(4) || bsOrder.getStatus().equals(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("sourceId", bsOrder.getId()); |
|
|
|
otherParam.put("sourceOrderNo", bsOrder.getOrderNo()); |
|
|
|
otherParam.put("sourceOrderNo", bsOrder.getOrderNo()); |
|
|
|
userContributeService.purchase(bsOrder.getPromotionAmount(), bsOrder.getUserId(), otherParam); |
|
|
|
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); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|