|
|
|
@ -20,12 +20,15 @@ import com.hfkj.service.order.OrderBusinessService; |
|
|
|
|
import com.hfkj.service.pdd.PddService; |
|
|
|
|
import com.hfkj.service.promotion.PromotionBusinessService; |
|
|
|
|
import com.hfkj.service.sec.SecDictionaryService; |
|
|
|
|
import com.hfkj.service.taobao.TaoBaoService; |
|
|
|
|
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 com.taobao.top.ability414.domain.TaobaoTbkOrderDetailsGetPublisherOrderDto; |
|
|
|
|
import com.taobao.top.ability414.response.TaobaoTbkOrderDetailsGetResponse; |
|
|
|
|
import org.apache.commons.collections4.MapUtils; |
|
|
|
|
import org.apache.commons.lang3.StringUtils; |
|
|
|
|
import org.springframework.beans.BeanUtils; |
|
|
|
@ -36,6 +39,7 @@ import org.springframework.stereotype.Service; |
|
|
|
|
import javax.annotation.Resource; |
|
|
|
|
import java.math.BigDecimal; |
|
|
|
|
import java.math.RoundingMode; |
|
|
|
|
import java.time.format.DateTimeFormatter; |
|
|
|
|
import java.util.*; |
|
|
|
|
import java.util.stream.Collectors; |
|
|
|
|
|
|
|
|
@ -146,12 +150,19 @@ public class BsOrderServiceImpl implements BsOrderService { |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
|
public JSONObject getOrderList(String startTime) throws Exception{ |
|
|
|
|
|
|
|
|
|
public void getOrderPddList(String startTime) throws Exception{ |
|
|
|
|
pddOrder(startTime); |
|
|
|
|
return null; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
|
public void getOrderTaoBaoList(String startTime , String endTime) { |
|
|
|
|
try { |
|
|
|
|
taoBaoOrder(startTime , endTime); |
|
|
|
|
} catch (Exception e) { |
|
|
|
|
System.out.println(e.getMessage()); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
|
public List<BsOrderModel> getOrderListParent(Map<String, Object> map) { |
|
|
|
@ -177,6 +188,9 @@ public class BsOrderServiceImpl implements BsOrderService { |
|
|
|
|
orderModel.setGold(order.getPromotionAmount().multiply(goldCoinExchangeRate)); |
|
|
|
|
// 将订单模型添加到订单模型列表中
|
|
|
|
|
orderModels.add(orderModel); |
|
|
|
|
// 根据订单查询淘宝订单
|
|
|
|
|
getOrderTaoBaoList(DateUtil.format( new Date(new Date().getTime() - 300000) , DateUtil.Y_M_D_HMS) , DateUtil.format( new Date(new Date().getTime() + 300000) , DateUtil.Y_M_D_HMS)); |
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
return orderModels; |
|
|
|
|
} |
|
|
|
@ -209,11 +223,6 @@ public class BsOrderServiceImpl implements BsOrderService { |
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
|
public void orderRebate(BsOrder bsOrder) throws Exception { |
|
|
|
|
// 判断订单状态是否为4或5
|
|
|
|
|
if (bsOrder.getStatus().equals(4) || bsOrder.getStatus().equals(5)) { |
|
|
|
|
// 如果是,则抛出异常,提示订单状态不可返利
|
|
|
|
|
throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "订单状态不可返利"); |
|
|
|
|
} |
|
|
|
|
Map<String,Object> otherParam = new HashMap<>(); |
|
|
|
|
otherParam.put("sourceId", bsOrder.getId()); |
|
|
|
|
otherParam.put("sourceOrderNo", bsOrder.getOrderNo()); |
|
|
|
@ -225,15 +234,13 @@ public class BsOrderServiceImpl implements BsOrderService { |
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// 根据开始时间获取拼多多订单列表
|
|
|
|
|
private void pddOrder(String startTime) throws Exception{ |
|
|
|
|
// 调用PddService的getOrderList方法获取订单列表
|
|
|
|
|
PddDdkOrderListRangeGetResponse rangeGetResponse = PddService.getOrderList(startTime); |
|
|
|
|
// 调用getOrderList方法获取本地订单列表
|
|
|
|
|
List<BsOrder> list = getOrderList(new HashMap<>()); |
|
|
|
|
List<BsUser> userList = userService.getList(new HashMap<>()); |
|
|
|
|
// 判断rangeGetResponse是否为空
|
|
|
|
|
if (rangeGetResponse != null) { |
|
|
|
|
// 获取订单列表
|
|
|
|
@ -263,7 +270,7 @@ public class BsOrderServiceImpl implements BsOrderService { |
|
|
|
|
// 根据订单号获取BsOrder对象
|
|
|
|
|
BsOrder bsOrder = list.stream().filter(s->s.getOrderNo().equals(orderListItem.getOrderSn())).findFirst().orElse(null); |
|
|
|
|
// 根据uid获取BsUser对象
|
|
|
|
|
BsUser user = userService.getUser(Long.valueOf(uid)); |
|
|
|
|
BsUser user = userList.stream().filter(s->s.getId().equals(Long.valueOf(uid))).findFirst().orElse(null); |
|
|
|
|
if (bsOrder == null) { |
|
|
|
|
// 如果BsOrder对象为空,则创建新的BsOrder对象
|
|
|
|
|
bsOrder = new BsOrder(); |
|
|
|
@ -293,15 +300,15 @@ public class BsOrderServiceImpl implements BsOrderService { |
|
|
|
|
bsOrder.setFinishTime(DateUtil.long2Date(orderListItem.getOrderSettleTime()*1000)); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
if (orderListItem.getOrderModifyAt() != null) { |
|
|
|
|
bsOrder.setRefundTime(DateUtil.long2Date(orderListItem.getOrderModifyAt()*1000)); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
if (bsOrder.getStatus().equals(4)) { |
|
|
|
|
if (orderListItem.getOrderModifyAt() != null) { |
|
|
|
|
bsOrder.setCancelTime(DateUtil.long2Date(orderListItem.getOrderModifyAt()*1000)); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
create(bsOrder); |
|
|
|
|
}else { |
|
|
|
|
if (bsOrder.getStatus() != 8) { |
|
|
|
|
// 如果BsOrder对象不为空,则更新BsOrder对象
|
|
|
|
|
bsOrder.setUpdateTime(new Date()); |
|
|
|
|
bsOrder.setStatus(orderListItem.getOrderStatus()); |
|
|
|
@ -341,10 +348,125 @@ public class BsOrderServiceImpl implements BsOrderService { |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private void taoBaoOrder(String startTime , String endTime) throws Exception { |
|
|
|
|
TaobaoTbkOrderDetailsGetResponse response = TaoBaoService.getOrderList(startTime , endTime); |
|
|
|
|
List<BsOrder> list = getOrderList(new HashMap<>()); |
|
|
|
|
Map<String , Object> reMap = new HashMap<>(); |
|
|
|
|
reMap.put("relationId" , 1); |
|
|
|
|
List<BsUser> userList = userService.getList(reMap); |
|
|
|
|
|
|
|
|
|
List<TaobaoTbkOrderDetailsGetPublisherOrderDto> results = response.getData().getResults(); |
|
|
|
|
if (results != null && !results.isEmpty()) { |
|
|
|
|
for (TaobaoTbkOrderDetailsGetPublisherOrderDto orderListItem : results) { |
|
|
|
|
|
|
|
|
|
BsOrder bsOrder = list.stream().filter(s->s.getOrderNo().equals(orderListItem.getTradeParentId())).findFirst().orElse(null); |
|
|
|
|
BsUser bsUser = userList.stream().filter(s->s.getRelationId().equals(orderListItem.getRelationId().toString())).findFirst().orElse(null); |
|
|
|
|
|
|
|
|
|
if (bsOrder == null) { |
|
|
|
|
bsOrder = new BsOrder(); |
|
|
|
|
bsOrder.setOrderNo(orderListItem.getTradeParentId()); |
|
|
|
|
if (bsUser != null) { |
|
|
|
|
bsOrder.setUserId(bsUser.getId()); |
|
|
|
|
bsOrder.setUserPhone(bsUser.getPhone() == null ? "" : bsUser.getPhone()); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
bsOrder.setCreateTime(new Date()); |
|
|
|
|
bsOrder.setUpdateTime(new Date()); |
|
|
|
|
bsOrder.setStatus(taoBaoStatus(orderListItem.getTkStatus())); |
|
|
|
|
bsOrder.setImg("https://" + orderListItem.getItemImg()); |
|
|
|
|
bsOrder.setType(1); |
|
|
|
|
bsOrder.setGoodsName(orderListItem.getItemTitle()); |
|
|
|
|
bsOrder.setGoodsCount(Math.toIntExact(orderListItem.getItemNum())); |
|
|
|
|
bsOrder.setTotalPrice(new BigDecimal(orderListItem.getAlipayTotalPrice())); |
|
|
|
|
if (bsOrder.getStatus().equals(5)) { |
|
|
|
|
bsOrder.setPromotionAmount(new BigDecimal(orderListItem.getPubShareFeeForCommission())); |
|
|
|
|
} else { |
|
|
|
|
bsOrder.setPromotionAmount(new BigDecimal(orderListItem.getPubSharePreFeeForCommission())); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
if (orderListItem.getTkPaidTime() != null) { |
|
|
|
|
bsOrder.setPayTime(DateUtil.format(orderListItem.getTkPaidTime() , "yyyy-MM-dd HH:mm:ss")); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
if (orderListItem.getTkCreateTime() != null) { |
|
|
|
|
bsOrder.setCreateTime(DateUtil.format(orderListItem.getTkCreateTime() , "yyyy-MM-dd HH:mm:ss")); |
|
|
|
|
} |
|
|
|
|
if (orderListItem.getTkEarningTime() != null) { |
|
|
|
|
bsOrder.setFinishTime(DateUtil.format(orderListItem.getTkEarningTime() , "yyyy-MM-dd HH:mm:ss")); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
if (orderListItem.getModifiedTime() != null) { |
|
|
|
|
bsOrder.setCancelTime(DateUtil.format(orderListItem.getModifiedTime() , "yyyy-MM-dd HH:mm:ss")); |
|
|
|
|
} |
|
|
|
|
create(bsOrder); |
|
|
|
|
} else { |
|
|
|
|
if (bsOrder.getStatus() != 8) { |
|
|
|
|
bsOrder.setOrderNo(orderListItem.getTradeParentId()); |
|
|
|
|
bsOrder.setUpdateTime(new Date()); |
|
|
|
|
bsOrder.setStatus(taoBaoStatus(orderListItem.getTkStatus())); |
|
|
|
|
bsOrder.setImg("https://" + orderListItem.getItemImg()); |
|
|
|
|
bsOrder.setType(1); |
|
|
|
|
bsOrder.setGoodsName(orderListItem.getItemTitle()); |
|
|
|
|
bsOrder.setGoodsCount(Math.toIntExact(orderListItem.getItemNum())); |
|
|
|
|
bsOrder.setTotalPrice(new BigDecimal(orderListItem.getAlipayTotalPrice())); |
|
|
|
|
if (bsOrder.getStatus().equals(5)) { |
|
|
|
|
bsOrder.setPromotionAmount(new BigDecimal(orderListItem.getPubShareFeeForCommission())); |
|
|
|
|
} else { |
|
|
|
|
bsOrder.setPromotionAmount(new BigDecimal(orderListItem.getPubSharePreFeeForCommission())); |
|
|
|
|
} |
|
|
|
|
if (orderListItem.getTkPaidTime() != null) { |
|
|
|
|
bsOrder.setPayTime(DateUtil.format(orderListItem.getTkPaidTime() , "yyyy-MM-dd HH:mm:ss")); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
if (orderListItem.getTkCreateTime() != null) { |
|
|
|
|
bsOrder.setCreateTime(DateUtil.format(orderListItem.getTkCreateTime() , "yyyy-MM-dd HH:mm:ss")); |
|
|
|
|
} |
|
|
|
|
if (orderListItem.getTkEarningTime() != null) { |
|
|
|
|
bsOrder.setFinishTime(DateUtil.format(orderListItem.getTkEarningTime() , "yyyy-MM-dd HH:mm:ss")); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
if (orderListItem.getModifiedTime() != null) { |
|
|
|
|
bsOrder.setCancelTime(DateUtil.format(orderListItem.getModifiedTime() , "yyyy-MM-dd HH:mm:ss")); |
|
|
|
|
} |
|
|
|
|
// 如果订单状态为5,则调用orderRebate方法
|
|
|
|
|
if (bsOrder.getStatus() == 5){ |
|
|
|
|
orderRebate(bsOrder); |
|
|
|
|
} else { |
|
|
|
|
editData(bsOrder); |
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private Integer taoBaoStatus(Long status) { |
|
|
|
|
int result = 6; |
|
|
|
|
if (status == 3) { |
|
|
|
|
result = 3; |
|
|
|
|
} else if (status == 12) { |
|
|
|
|
result = 0; |
|
|
|
|
} else if (status == 13) { |
|
|
|
|
result = 4; |
|
|
|
|
} else if (status == 14) { |
|
|
|
|
result = 1; |
|
|
|
|
} |
|
|
|
|
return result; |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|