|
|
@ -1,6 +1,7 @@ |
|
|
|
package com.hfkj.service.order.Impl; |
|
|
|
package com.hfkj.service.order.Impl; |
|
|
|
|
|
|
|
|
|
|
|
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; |
|
|
@ -15,17 +16,21 @@ import com.hfkj.entity.BsOrderExample; |
|
|
|
import com.hfkj.entity.BsUser; |
|
|
|
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.meituan.MeiTuanService; |
|
|
|
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.pdd.PddService; |
|
|
|
import com.hfkj.service.promotion.PromotionBusinessService; |
|
|
|
import com.hfkj.service.promotion.PromotionBusinessService; |
|
|
|
import com.hfkj.service.sec.SecDictionaryService; |
|
|
|
import com.hfkj.service.sec.SecDictionaryService; |
|
|
|
|
|
|
|
import com.hfkj.service.taobao.TaoBaoService; |
|
|
|
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.service.user.BsUserService; |
|
|
|
import com.hfkj.sysenum.partner.PartnerEnum; |
|
|
|
import com.hfkj.sysenum.partner.PartnerEnum; |
|
|
|
import com.hfkj.sysenum.user.UserAccountRecordSourceTypeEnum; |
|
|
|
import com.hfkj.sysenum.user.UserAccountRecordSourceTypeEnum; |
|
|
|
import com.pdd.pop.sdk.http.api.pop.response.PddDdkOrderListRangeGetResponse; |
|
|
|
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.collections4.MapUtils; |
|
|
|
import org.apache.commons.lang3.StringUtils; |
|
|
|
import org.apache.commons.lang3.StringUtils; |
|
|
|
import org.springframework.beans.BeanUtils; |
|
|
|
import org.springframework.beans.BeanUtils; |
|
|
@ -35,6 +40,8 @@ import org.springframework.stereotype.Service; |
|
|
|
|
|
|
|
|
|
|
|
import javax.annotation.Resource; |
|
|
|
import javax.annotation.Resource; |
|
|
|
import java.math.BigDecimal; |
|
|
|
import java.math.BigDecimal; |
|
|
|
|
|
|
|
import java.math.RoundingMode; |
|
|
|
|
|
|
|
import java.time.format.DateTimeFormatter; |
|
|
|
import java.util.*; |
|
|
|
import java.util.*; |
|
|
|
import java.util.stream.Collectors; |
|
|
|
import java.util.stream.Collectors; |
|
|
|
|
|
|
|
|
|
|
@ -145,12 +152,43 @@ public class BsOrderServiceImpl implements BsOrderService { |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
@Override |
|
|
|
public JSONObject getOrderList(String startTime) throws Exception{ |
|
|
|
public void getOrderPddList(String startTime , String endTime) { |
|
|
|
|
|
|
|
try { |
|
|
|
|
|
|
|
pddOrder(startTime , endTime); |
|
|
|
|
|
|
|
} catch (Exception e) { |
|
|
|
|
|
|
|
System.out.println(e.getMessage()); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
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 void getOrderMeiTuanList(String startTime, String endTime) { |
|
|
|
|
|
|
|
try { |
|
|
|
|
|
|
|
meiTuanOrder(startTime , endTime); |
|
|
|
|
|
|
|
} catch (Exception e) { |
|
|
|
|
|
|
|
System.out.println(e.getMessage()); |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
|
|
|
|
public void getOrderElmList(String startTime, String endTime) { |
|
|
|
|
|
|
|
try { |
|
|
|
|
|
|
|
meiTuanOrder(startTime , endTime); |
|
|
|
|
|
|
|
} catch (Exception e) { |
|
|
|
|
|
|
|
System.out.println(e.getMessage()); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
@Override |
|
|
|
public List<BsOrderModel> getOrderListParent(Map<String, Object> map) { |
|
|
|
public List<BsOrderModel> getOrderListParent(Map<String, Object> map) { |
|
|
@ -176,6 +214,18 @@ public class BsOrderServiceImpl implements BsOrderService { |
|
|
|
orderModel.setGold(order.getPromotionAmount().multiply(goldCoinExchangeRate)); |
|
|
|
orderModel.setGold(order.getPromotionAmount().multiply(goldCoinExchangeRate)); |
|
|
|
// 将订单模型添加到订单模型列表中
|
|
|
|
// 将订单模型添加到订单模型列表中
|
|
|
|
orderModels.add(orderModel); |
|
|
|
orderModels.add(orderModel); |
|
|
|
|
|
|
|
if (order.getType() == 1) { |
|
|
|
|
|
|
|
// 根据订单查询淘宝订单
|
|
|
|
|
|
|
|
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)); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (order.getType() == 2) { |
|
|
|
|
|
|
|
// 根据订单查询拼多多订单
|
|
|
|
|
|
|
|
getOrderPddList(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)); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
if (order.getType() == 3) { |
|
|
|
|
|
|
|
getOrderMeiTuanList( String.valueOf(new Date().getTime()/1000 - 300) , String.valueOf(new Date().getTime()/1000 + 300)); |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
return orderModels; |
|
|
|
return orderModels; |
|
|
|
} |
|
|
|
} |
|
|
@ -203,38 +253,35 @@ public class BsOrderServiceImpl implements BsOrderService { |
|
|
|
} |
|
|
|
} |
|
|
|
return orderModels; |
|
|
|
return orderModels; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return null; |
|
|
|
return null; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
@Override |
|
|
|
public void orderRebate(BsOrder bsOrder) throws Exception { |
|
|
|
public void orderRebate(BsOrder bsOrder){ |
|
|
|
// 判断订单状态是否为4或5
|
|
|
|
|
|
|
|
if (bsOrder.getStatus().equals(4) || bsOrder.getStatus().equals(5)) { |
|
|
|
try { |
|
|
|
// 如果是,则抛出异常,提示订单状态不可返利
|
|
|
|
|
|
|
|
throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "订单状态不可返利"); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
Map<String,Object> otherParam = new HashMap<>(); |
|
|
|
Map<String,Object> otherParam = new HashMap<>(); |
|
|
|
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.setStatus(3); |
|
|
|
bsOrder.setUpdateTime(new Date()); |
|
|
|
bsOrder.setUpdateTime(new Date()); |
|
|
|
bsOrder.setFinishTime(new Date()); |
|
|
|
bsOrder.setFinishTime(new Date()); |
|
|
|
editData(bsOrder); |
|
|
|
editData(bsOrder); |
|
|
|
|
|
|
|
} catch (Exception e) { |
|
|
|
|
|
|
|
System.out.println(e); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
// 根据开始时间获取拼多多订单列表
|
|
|
|
// 根据开始时间获取拼多多订单列表
|
|
|
|
private void pddOrder(String startTime) throws Exception{ |
|
|
|
private void pddOrder(String startTime , String endTime) throws Exception{ |
|
|
|
// 调用PddService的getOrderList方法获取订单列表
|
|
|
|
// 调用PddService的getOrderList方法获取订单列表
|
|
|
|
PddDdkOrderListRangeGetResponse rangeGetResponse = PddService.getOrderList(startTime); |
|
|
|
PddDdkOrderListRangeGetResponse rangeGetResponse = PddService.getOrderList(startTime , endTime); |
|
|
|
// 调用getOrderList方法获取本地订单列表
|
|
|
|
// 调用getOrderList方法获取本地订单列表
|
|
|
|
List<BsOrder> list = getOrderList(new HashMap<>()); |
|
|
|
List<BsOrder> list = getOrderList(new HashMap<>()); |
|
|
|
|
|
|
|
List<BsUser> userList = userService.getList(new HashMap<>()); |
|
|
|
// 判断rangeGetResponse是否为空
|
|
|
|
// 判断rangeGetResponse是否为空
|
|
|
|
if (rangeGetResponse != null) { |
|
|
|
if (rangeGetResponse != null) { |
|
|
|
// 获取订单列表
|
|
|
|
// 获取订单列表
|
|
|
@ -264,30 +311,45 @@ public class BsOrderServiceImpl implements BsOrderService { |
|
|
|
// 根据订单号获取BsOrder对象
|
|
|
|
// 根据订单号获取BsOrder对象
|
|
|
|
BsOrder bsOrder = list.stream().filter(s->s.getOrderNo().equals(orderListItem.getOrderSn())).findFirst().orElse(null); |
|
|
|
BsOrder bsOrder = list.stream().filter(s->s.getOrderNo().equals(orderListItem.getOrderSn())).findFirst().orElse(null); |
|
|
|
// 根据uid获取BsUser对象
|
|
|
|
// 根据uid获取BsUser对象
|
|
|
|
BsUser user = userService.getUser(uid); |
|
|
|
BsUser user = userList.stream().filter(s->s.getId().equals(Long.valueOf(uid))).findFirst().orElse(null); |
|
|
|
if (bsOrder == null) { |
|
|
|
if (bsOrder == null) { |
|
|
|
// 如果BsOrder对象为空,则创建新的BsOrder对象
|
|
|
|
// 如果BsOrder对象为空,则创建新的BsOrder对象
|
|
|
|
bsOrder = new BsOrder(); |
|
|
|
bsOrder = new BsOrder(); |
|
|
|
bsOrder.setOrderNo(orderListItem.getOrderSn()); |
|
|
|
bsOrder.setOrderNo(orderListItem.getOrderSn()); |
|
|
|
bsOrder.setUserId(Long.valueOf(uid)); |
|
|
|
bsOrder.setUserId(Long.valueOf(uid)); |
|
|
|
bsOrder.setUserPhone(user.getPhone()); |
|
|
|
if (user != null) { |
|
|
|
|
|
|
|
bsOrder.setUserPhone(user.getPhone() == null ? "" : user.getPhone()); |
|
|
|
|
|
|
|
} |
|
|
|
bsOrder.setCreateTime(new Date()); |
|
|
|
bsOrder.setCreateTime(new Date()); |
|
|
|
bsOrder.setUpdateTime(new Date()); |
|
|
|
bsOrder.setUpdateTime(new Date()); |
|
|
|
bsOrder.setStatus(orderListItem.getOrderStatus()); |
|
|
|
bsOrder.setStatus(pddStatus(Long.valueOf(orderListItem.getOrderStatus()))); |
|
|
|
bsOrder.setImg(orderListItem.getGoodsThumbnailUrl()); |
|
|
|
bsOrder.setImg(orderListItem.getGoodsThumbnailUrl()); |
|
|
|
bsOrder.setType(2); |
|
|
|
bsOrder.setType(2); |
|
|
|
bsOrder.setGoodsName(orderListItem.getGoodsName()); |
|
|
|
bsOrder.setGoodsName(orderListItem.getGoodsName()); |
|
|
|
bsOrder.setGoodsCount(Math.toIntExact(orderListItem.getGoodsQuantity())); |
|
|
|
bsOrder.setGoodsCount(Math.toIntExact(orderListItem.getGoodsQuantity())); |
|
|
|
bsOrder.setCustomparameters(orderListItem.getCustomParameters()); |
|
|
|
bsOrder.setCustomparameters(orderListItem.getCustomParameters()); |
|
|
|
bsOrder.setTotalPrice(BigDecimal.valueOf(orderListItem.getOrderAmount())); |
|
|
|
bsOrder.setTotalPrice(BigDecimal.valueOf(orderListItem.getOrderAmount()).divide(new BigDecimal(100), 2, RoundingMode.HALF_UP)); |
|
|
|
bsOrder.setPromotionAmount(BigDecimal.valueOf(orderListItem.getPromotionAmount())); |
|
|
|
bsOrder.setPromotionAmount(BigDecimal.valueOf(orderListItem.getPromotionAmount()).divide(new BigDecimal(100), 2, RoundingMode.HALF_UP)); |
|
|
|
bsOrder.setPayTime(DateUtil.long2Date(orderListItem.getOrderPayTime())); |
|
|
|
if (orderListItem.getOrderPayTime() != null) { |
|
|
|
bsOrder.setCreateTime(DateUtil.long2Date(orderListItem.getOrderCreateTime())); |
|
|
|
bsOrder.setPayTime(DateUtil.long2Date(orderListItem.getOrderPayTime()*1000)); |
|
|
|
bsOrder.setFinishTime(DateUtil.long2Date(orderListItem.getOrderSettleTime())); |
|
|
|
} |
|
|
|
bsOrder.setRefundTime(DateUtil.long2Date(orderListItem.getOrderModifyAt())); |
|
|
|
|
|
|
|
bsOrder.setCancelTime(DateUtil.long2Date(orderListItem.getOrderModifyAt())); |
|
|
|
if (orderListItem.getOrderCreateTime() != null) { |
|
|
|
|
|
|
|
bsOrder.setCreateTime(DateUtil.long2Date(orderListItem.getOrderCreateTime()*1000)); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
if (orderListItem.getOrderSettleTime() != null) { |
|
|
|
|
|
|
|
bsOrder.setFinishTime(DateUtil.long2Date(orderListItem.getOrderSettleTime()*1000)); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (bsOrder.getStatus().equals(4)) { |
|
|
|
|
|
|
|
if (orderListItem.getOrderModifyAt() != null) { |
|
|
|
|
|
|
|
bsOrder.setCancelTime(DateUtil.long2Date(orderListItem.getOrderModifyAt()*1000)); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
create(bsOrder); |
|
|
|
create(bsOrder); |
|
|
|
}else { |
|
|
|
}else { |
|
|
|
|
|
|
|
if (bsOrder.getStatus() == 2) { |
|
|
|
// 如果BsOrder对象不为空,则更新BsOrder对象
|
|
|
|
// 如果BsOrder对象不为空,则更新BsOrder对象
|
|
|
|
bsOrder.setUpdateTime(new Date()); |
|
|
|
bsOrder.setUpdateTime(new Date()); |
|
|
|
bsOrder.setStatus(orderListItem.getOrderStatus()); |
|
|
|
bsOrder.setStatus(orderListItem.getOrderStatus()); |
|
|
@ -296,17 +358,242 @@ public class BsOrderServiceImpl implements BsOrderService { |
|
|
|
bsOrder.setGoodsName(orderListItem.getGoodsName()); |
|
|
|
bsOrder.setGoodsName(orderListItem.getGoodsName()); |
|
|
|
bsOrder.setGoodsCount(Math.toIntExact(orderListItem.getGoodsQuantity())); |
|
|
|
bsOrder.setGoodsCount(Math.toIntExact(orderListItem.getGoodsQuantity())); |
|
|
|
bsOrder.setCustomparameters(orderListItem.getCustomParameters()); |
|
|
|
bsOrder.setCustomparameters(orderListItem.getCustomParameters()); |
|
|
|
bsOrder.setTotalPrice(BigDecimal.valueOf(orderListItem.getOrderAmount())); |
|
|
|
bsOrder.setTotalPrice(BigDecimal.valueOf(orderListItem.getOrderAmount()).divide(new BigDecimal(100), 6, RoundingMode.HALF_UP)); |
|
|
|
bsOrder.setPromotionAmount(BigDecimal.valueOf(orderListItem.getPromotionAmount())); |
|
|
|
bsOrder.setPromotionAmount(BigDecimal.valueOf(orderListItem.getPromotionAmount()).divide(new BigDecimal(100), 6, RoundingMode.HALF_UP)); |
|
|
|
bsOrder.setPayTime(DateUtil.long2Date(orderListItem.getOrderPayTime())); |
|
|
|
if (orderListItem.getOrderPayTime() != null) { |
|
|
|
bsOrder.setCreateTime(DateUtil.long2Date(orderListItem.getOrderCreateTime())); |
|
|
|
bsOrder.setPayTime(DateUtil.long2Date(orderListItem.getOrderPayTime()*1000)); |
|
|
|
bsOrder.setFinishTime(DateUtil.long2Date(orderListItem.getOrderSettleTime())); |
|
|
|
} |
|
|
|
bsOrder.setRefundTime(DateUtil.long2Date(orderListItem.getOrderModifyAt())); |
|
|
|
|
|
|
|
bsOrder.setCancelTime(DateUtil.long2Date(orderListItem.getOrderModifyAt())); |
|
|
|
if (orderListItem.getOrderCreateTime() != null) { |
|
|
|
|
|
|
|
bsOrder.setCreateTime(DateUtil.long2Date(orderListItem.getOrderCreateTime()*1000)); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
if (orderListItem.getOrderSettleTime() != null) { |
|
|
|
|
|
|
|
bsOrder.setFinishTime(DateUtil.long2Date(orderListItem.getOrderSettleTime()*1000)); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (orderListItem.getOrderModifyAt() != null) { |
|
|
|
|
|
|
|
bsOrder.setRefundTime(DateUtil.long2Date(orderListItem.getOrderModifyAt()*1000)); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (orderListItem.getOrderModifyAt() != null) { |
|
|
|
|
|
|
|
bsOrder.setCancelTime(DateUtil.long2Date(orderListItem.getOrderModifyAt()*1000)); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// 如果订单状态为5,则调用orderRebate方法
|
|
|
|
|
|
|
|
if (bsOrder.getStatus() == 2 && orderListItem.getOrderStatus().equals(5)){ |
|
|
|
|
|
|
|
orderRebate(bsOrder); |
|
|
|
|
|
|
|
} else { |
|
|
|
|
|
|
|
editData(bsOrder); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// 淘宝
|
|
|
|
|
|
|
|
private void taoBaoOrder(String startTime , String endTime) throws Exception { |
|
|
|
|
|
|
|
// 调用TaoBaoService的getOrderList方法,获取淘宝订单列表
|
|
|
|
|
|
|
|
TaobaoTbkOrderDetailsGetResponse response = TaoBaoService.getOrderList(startTime , endTime); |
|
|
|
|
|
|
|
// 调用getOrderList方法,获取本地订单列表
|
|
|
|
|
|
|
|
List<BsOrder> list = getOrderList(new HashMap<>()); |
|
|
|
|
|
|
|
// 创建一个Map,用于存储relationId
|
|
|
|
|
|
|
|
Map<String , Object> reMap = new HashMap<>(); |
|
|
|
|
|
|
|
reMap.put("relationId" , 1); |
|
|
|
|
|
|
|
// 调用userService的getList方法,获取用户列表
|
|
|
|
|
|
|
|
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); |
|
|
|
|
|
|
|
// 根据relationId,从用户列表中查找用户
|
|
|
|
|
|
|
|
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方法,将新订单保存到本地订单列表中
|
|
|
|
|
|
|
|
create(bsOrder); |
|
|
|
|
|
|
|
} else { |
|
|
|
|
|
|
|
// 如果本地订单列表中已有该订单,则更新订单信息
|
|
|
|
|
|
|
|
if (bsOrder.getStatus() == 2) { |
|
|
|
|
|
|
|
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() == 2 && orderListItem.getTkStatus() == 3){ |
|
|
|
|
|
|
|
orderRebate(bsOrder); |
|
|
|
|
|
|
|
} else { |
|
|
|
|
|
|
|
// 否则,调用editData方法,更新订单信息
|
|
|
|
|
|
|
|
editData(bsOrder); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private void meiTuanOrder(String startTime , String endTime) throws Exception { |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
JSONObject jsonObject = new JSONObject(); |
|
|
|
|
|
|
|
jsonObject.put("startTime" , startTime); |
|
|
|
|
|
|
|
jsonObject.put("endTime" , endTime); |
|
|
|
|
|
|
|
JSONObject object = MeiTuanService.orderList(jsonObject); |
|
|
|
|
|
|
|
JSONArray meiTuanOrder = object.getJSONArray("dataList"); |
|
|
|
|
|
|
|
List<BsOrder> list = getOrderList(new HashMap<>()); |
|
|
|
|
|
|
|
List<BsUser> userList = userService.getList(new HashMap<>()); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (meiTuanOrder != null && !meiTuanOrder.isEmpty()) { |
|
|
|
|
|
|
|
for (int i = 0; i < meiTuanOrder.size(); i++) { |
|
|
|
|
|
|
|
JSONObject meiTuan = meiTuanOrder.getJSONObject(i); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// 根据订单号,从本地订单列表中查找订单
|
|
|
|
|
|
|
|
BsOrder bsOrder = list.stream().filter(s->s.getOrderNo().equals(meiTuan.getString("orderid"))).findFirst().orElse(null); |
|
|
|
|
|
|
|
// 根据relationId,从用户列表中查找用户
|
|
|
|
|
|
|
|
BsUser bsUser = userList.stream().filter(s->s.getId().equals(meiTuan.getLong("sid"))).findFirst().orElse(null); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// 如果本地订单列表中没有该订单,则创建一个新的订单
|
|
|
|
|
|
|
|
if (bsOrder == null) { |
|
|
|
|
|
|
|
bsOrder = new BsOrder(); |
|
|
|
|
|
|
|
bsOrder.setOrderNo(meiTuan.getString("orderid")); |
|
|
|
|
|
|
|
if (bsUser != null) { |
|
|
|
|
|
|
|
bsOrder.setUserId(bsUser.getId()); |
|
|
|
|
|
|
|
bsOrder.setUserPhone(bsUser.getPhone() == null ? "" : bsUser.getPhone()); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
bsOrder.setCreateTime(new Date()); |
|
|
|
|
|
|
|
bsOrder.setUpdateTime(new Date()); |
|
|
|
|
|
|
|
bsOrder.setStatus(meiTuanStatus(meiTuan.getLong("status"))); |
|
|
|
|
|
|
|
bsOrder.setType(3); |
|
|
|
|
|
|
|
bsOrder.setGoodsName(meiTuan.getString("smstitle")); |
|
|
|
|
|
|
|
bsOrder.setGoodsCount(1); |
|
|
|
|
|
|
|
bsOrder.setTotalPrice(meiTuan.getBigDecimal("payprice")); |
|
|
|
|
|
|
|
bsOrder.setPromotionAmount(meiTuan.getBigDecimal("profit")); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (meiTuan.getLong("paytime") != null) { |
|
|
|
|
|
|
|
bsOrder.setPayTime(DateUtil.long2Date(meiTuan.getLong("paytime")*1000)); |
|
|
|
|
|
|
|
bsOrder.setCreateTime(DateUtil.long2Date(meiTuan.getLong("paytime")*1000)); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (meiTuan.getLong("modTime") != null) { |
|
|
|
|
|
|
|
bsOrder.setFinishTime(DateUtil.long2Date(meiTuan.getLong("modTime")*1000)); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
if (meiTuan.getLong("refundtime") != null) { |
|
|
|
|
|
|
|
bsOrder.setRefundTime(DateUtil.long2Date(meiTuan.getLong("refundtime")*1000)); |
|
|
|
|
|
|
|
bsOrder.setCancelTime(DateUtil.long2Date(meiTuan.getLong("refundtime")*1000)); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// 调用create方法,将新订单保存到本地订单列表中
|
|
|
|
|
|
|
|
create(bsOrder); |
|
|
|
|
|
|
|
} else { |
|
|
|
|
|
|
|
// 如果本地订单列表中已有该订单,则更新订单信息
|
|
|
|
|
|
|
|
if (bsOrder.getStatus() == 2) { |
|
|
|
|
|
|
|
bsOrder.setOrderNo(meiTuan.getString("orderid")); |
|
|
|
|
|
|
|
if (bsUser != null) { |
|
|
|
|
|
|
|
bsOrder.setUserId(bsUser.getId()); |
|
|
|
|
|
|
|
bsOrder.setUserPhone(bsUser.getPhone() == null ? "" : bsUser.getPhone()); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
bsOrder.setCreateTime(new Date()); |
|
|
|
|
|
|
|
bsOrder.setUpdateTime(new Date()); |
|
|
|
|
|
|
|
bsOrder.setStatus(meiTuanStatus(meiTuan.getLong("status"))); |
|
|
|
|
|
|
|
bsOrder.setType(3); |
|
|
|
|
|
|
|
bsOrder.setGoodsName(meiTuan.getString("smstitle")); |
|
|
|
|
|
|
|
bsOrder.setGoodsCount(1); |
|
|
|
|
|
|
|
bsOrder.setTotalPrice(meiTuan.getBigDecimal("payprice")); |
|
|
|
|
|
|
|
bsOrder.setPromotionAmount(meiTuan.getBigDecimal("profit")); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (meiTuan.getLong("paytime") != null) { |
|
|
|
|
|
|
|
bsOrder.setPayTime(DateUtil.long2Date(meiTuan.getLong("paytime")*1000)); |
|
|
|
|
|
|
|
bsOrder.setCreateTime(DateUtil.long2Date(meiTuan.getLong("paytime")*1000)); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (meiTuan.getLong("modTime") != null) { |
|
|
|
|
|
|
|
bsOrder.setFinishTime(DateUtil.long2Date(meiTuan.getLong("modTime")*1000)); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
if (meiTuan.getLong("refundtime") != null) { |
|
|
|
|
|
|
|
bsOrder.setRefundTime(DateUtil.long2Date(meiTuan.getLong("refundtime")*1000)); |
|
|
|
|
|
|
|
bsOrder.setCancelTime(DateUtil.long2Date(meiTuan.getLong("refundtime")*1000)); |
|
|
|
|
|
|
|
} |
|
|
|
// 如果订单状态为5,则调用orderRebate方法
|
|
|
|
// 如果订单状态为5,则调用orderRebate方法
|
|
|
|
if (bsOrder.getStatus() == 5){ |
|
|
|
if (bsOrder.getStatus() == 2 && meiTuan.getInteger("status") == 8){ |
|
|
|
orderRebate(bsOrder); |
|
|
|
orderRebate(bsOrder); |
|
|
|
} else { |
|
|
|
} else { |
|
|
|
|
|
|
|
// 否则,调用editData方法,更新订单信息
|
|
|
|
editData(bsOrder); |
|
|
|
editData(bsOrder); |
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
@ -319,4 +606,50 @@ public class BsOrderServiceImpl implements BsOrderService { |
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private Integer pddStatus(Long status) { |
|
|
|
|
|
|
|
int result = 4; |
|
|
|
|
|
|
|
if (status == 0) { |
|
|
|
|
|
|
|
result = 1; |
|
|
|
|
|
|
|
} else if (status == 1) { |
|
|
|
|
|
|
|
result = 1; |
|
|
|
|
|
|
|
} else if (status == 2) { |
|
|
|
|
|
|
|
result = 2; |
|
|
|
|
|
|
|
} else if (status == 3) { |
|
|
|
|
|
|
|
result = 2; |
|
|
|
|
|
|
|
} else if (status == 4) { |
|
|
|
|
|
|
|
result = 4; |
|
|
|
|
|
|
|
} else if (status == 5) { |
|
|
|
|
|
|
|
result = 2; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
return result; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// 1 已下单 2 已收货 3 已结算 4 已失效
|
|
|
|
|
|
|
|
private Integer taoBaoStatus(Long status) { |
|
|
|
|
|
|
|
int result = 4; |
|
|
|
|
|
|
|
if (status == 3) { |
|
|
|
|
|
|
|
result = 2; |
|
|
|
|
|
|
|
} else if (status == 12) { |
|
|
|
|
|
|
|
result = 1; |
|
|
|
|
|
|
|
} else if (status == 13) { |
|
|
|
|
|
|
|
result = 4; |
|
|
|
|
|
|
|
} else if (status == 14) { |
|
|
|
|
|
|
|
result = 2; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
return result; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private Integer meiTuanStatus(Long status) { |
|
|
|
|
|
|
|
int result = 4; |
|
|
|
|
|
|
|
if (status == 1) { |
|
|
|
|
|
|
|
result = 1; |
|
|
|
|
|
|
|
} else if (status == 8) { |
|
|
|
|
|
|
|
result = 2; |
|
|
|
|
|
|
|
} else if (status == 9) { |
|
|
|
|
|
|
|
result = 4; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
return result; |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|