| | |
| | | import java.math.BigDecimal;
|
| | | import java.net.URLEncoder;
|
| | | import java.util.ArrayList;
|
| | | import java.util.Comparator;
|
| | | import java.util.Date;
|
| | | import java.util.HashMap;
|
| | | import java.util.Iterator;
|
| | | import java.util.List;
|
| | | import java.util.Map;
|
| | | import java.util.concurrent.ConcurrentHashMap;
|
| | |
|
| | | import javax.annotation.PostConstruct;
|
| | | import javax.annotation.Resource;
|
| | |
|
| | | import org.apache.commons.httpclient.HttpClient;
|
| | | import org.apache.commons.httpclient.HttpException;
|
| | |
| | | import org.springframework.stereotype.Component;
|
| | | import org.yeshi.utils.HttpUtil;
|
| | |
|
| | | import com.yeshi.fanli.dto.order.OrderItem;
|
| | | import com.yeshi.fanli.entity.bus.user.Order;
|
| | | import com.yeshi.fanli.entity.bus.user.OrderItem;
|
| | | import com.yeshi.fanli.entity.bus.user.UserInfo;
|
| | | import com.yeshi.fanli.entity.order.CommonOrder;
|
| | | import com.yeshi.fanli.entity.taobao.TaoBaoOrder;
|
| | |
| | | import com.yeshi.fanli.entity.taobao.TaoBaoWeiQuanOrder;
|
| | | import com.yeshi.fanli.exception.TaoBaoOrderException;
|
| | | import com.yeshi.fanli.log.LogHelper;
|
| | | import com.yeshi.fanli.service.inter.config.ConfigService;
|
| | | import com.yeshi.fanli.service.inter.hongbao.HongBaoManageService;
|
| | | import com.yeshi.fanli.service.inter.hongbao.HongBaoService;
|
| | | import com.yeshi.fanli.service.inter.hongbao.ThreeSaleSerivce;
|
| | | import com.yeshi.fanli.service.inter.order.OrderItemServcie;
|
| | | import com.yeshi.fanli.service.inter.order.OrderService;
|
| | | import com.yeshi.fanli.util.Constant;
|
| | | import com.yeshi.fanli.util.MoneyBigDecimalUtil;
|
| | | import com.yeshi.fanli.util.StringUtil;
|
| | |
| | | @Component
|
| | | public class TaoBaoOrderUtil {
|
| | |
|
| | | private final static String CACHENAME = "tbCookie";
|
| | |
|
| | | private static final String ORDERFAILURE = "订单失效";
|
| | | private static final String ORDERPAYMENT = "订单付款";
|
| | | private static final String ORDERSETTLEMENT = "订单结算";
|
| | | private static final String ORDERSUCCESS = "订单成功";
|
| | |
|
| | | @Resource
|
| | | private OrderService orderService;
|
| | | @Resource
|
| | | private HongBaoService hongBaoService;
|
| | | @Resource
|
| | | private ConfigService configService;
|
| | |
|
| | | @Resource
|
| | | private OrderItemServcie orderItemServcie;
|
| | |
|
| | | @Resource
|
| | | private HongBaoManageService hongBaoManageService;
|
| | |
|
| | | @Resource
|
| | | private ThreeSaleSerivce threeSaleSerivce;
|
| | |
|
| | | private static TaoBaoOrderUtil taoBaoOrderUtil;
|
| | |
|
| | | @PostConstruct
|
| | | public void init() {
|
| | | taoBaoOrderUtil = this;
|
| | | taoBaoOrderUtil.orderService = this.orderService;
|
| | | taoBaoOrderUtil.hongBaoService = this.hongBaoService;
|
| | | taoBaoOrderUtil.configService = this.configService;
|
| | | taoBaoOrderUtil.hongBaoManageService = this.hongBaoManageService;
|
| | | taoBaoOrderUtil.orderItemServcie = this.orderItemServcie;
|
| | | }
|
| | |
|
| | | /**
|
| | | * 获取淘宝联盟的Cookie
|
| | |
| | |
|
| | | }
|
| | |
|
| | |
|
| | | /**
|
| | | * 解析维权订单
|
| | | *
|
| | |
| | | order.setOrderBy(map.get(order.getOrderId()).size() + 1);
|
| | | map.get(order.getOrderId()).add(order);
|
| | | }
|
| | |
|
| | | // 订单排序值灰度测试
|
| | | try {
|
| | | for (Iterator<String> its = map.keySet().iterator(); its.hasNext();) {
|
| | | String orderId = its.next();
|
| | | try {
|
| | | setOrderBy(map.get(orderId));
|
| | | } catch (Exception e) {
|
| | | LogHelper.errorDetailInfo(e, "订单号:" + orderId, "订单排序值灰度测试");
|
| | | }
|
| | | }
|
| | | } catch (Exception e) {
|
| | | }
|
| | |
|
| | | return map;
|
| | | }
|
| | |
|
| | | public static void setOrderBy(List<TaoBaoOrder> orderList) {// 提取一样的
|
| | | if (orderList == null || orderList.size() == 1)
|
| | | return;
|
| | | int len = orderList.get(0).getTradeId().length();
|
| | | int startIndex = 0;
|
| | | for (int i = 0; i < len; i++) {
|
| | | boolean isSame = true;
|
| | | for (int j = 0; j < orderList.size() - 1; j++) {
|
| | | if (orderList.get(j).getTradeId().charAt(i) != orderList.get(j + 1).getTradeId().charAt(i)) {
|
| | | isSame = false;
|
| | | break;
|
| | | }
|
| | | }
|
| | | if (!isSame) {
|
| | | startIndex = i;
|
| | | break;
|
| | | }
|
| | | }
|
| | | int endIndex = 0;
|
| | |
|
| | | for (int i = len - 1; i >= 0; i--) {
|
| | | boolean isSame = true;
|
| | | for (int j = 0; j < orderList.size() - 1; j++) {
|
| | | if (orderList.get(j).getTradeId().charAt(i) != orderList.get(j + 1).getTradeId().charAt(i)) {
|
| | | isSame = false;
|
| | | break;
|
| | | }
|
| | | }
|
| | | if (!isSame) {
|
| | | endIndex = i;
|
| | | break;
|
| | | }
|
| | | }
|
| | | for (TaoBaoOrder taoBaoOrder : orderList) {
|
| | | String tradeId = taoBaoOrder.getTradeId();
|
| | | String orderByStr = tradeId.substring(startIndex, endIndex + 1);
|
| | | if (orderByStr.length() > 8) {
|
| | | LogHelper.error("订单的orderBy超过8位:" + taoBaoOrder.getOrderBy());
|
| | | }
|
| | | int orderBy = Integer.parseInt(orderByStr);
|
| | | // taoBaoOrder.setOrderBy(orderBy);
|
| | | }
|
| | | }
|
| | |
|
| | | /**
|
| | |
| | | CommonOrder commonOrder = new CommonOrder();
|
| | | commonOrder.setCount(taoBaoOrder.getCount());
|
| | | commonOrder.setCreateTime(new Date());
|
| | | commonOrder.seteIncome(taoBaoOrder.geteIncome());
|
| | | if (taoBaoOrder.geteIncome() != null && taoBaoOrder.getSubsidy() != null)
|
| | | commonOrder.seteIncome(taoBaoOrder.geteIncome().add(taoBaoOrder.getSubsidy()));
|
| | | else
|
| | | commonOrder.seteIncome(taoBaoOrder.geteIncome());
|
| | | commonOrder.setEstimate(taoBaoOrder.getEstimate());
|
| | | commonOrder.setOrderNo(taoBaoOrder.getOrderId());
|
| | | commonOrder.setPayment(taoBaoOrder.getPayment());
|
| | |
| | | if (!StringUtil.isNullOrEmpty(taoBaoOrder.getSettlementTime()))
|
| | | commonOrder.setSettleTime(
|
| | | new Date(TimeUtil.convertToTimeTemp(taoBaoOrder.getSettlementTime(), "yyyy-MM-dd HH:mm:ss")));
|
| | | commonOrder.setSourcePosition(
|
| | | String.format("mm_%s_%s_%s", "124933865", taoBaoOrder.getSourceMediaId(), taoBaoOrder.getAdPositionId()));
|
| | | commonOrder.setSourcePosition(String.format("mm_%s_%s_%s", "124933865", taoBaoOrder.getSourceMediaId(),
|
| | | taoBaoOrder.getAdPositionId()));
|
| | | commonOrder.setSourceType(Constant.SOURCE_TYPE_TAOBAO);
|
| | | int state = 0;
|
| | | if ("订单付款".equalsIgnoreCase(taoBaoOrder.getOrderState())) {
|
| | |
| | | commonOrder.setThirdCreateTime(
|
| | | new Date(TimeUtil.convertToTimeTemp(taoBaoOrder.getCreateTime(), "yyyy-MM-dd HH:mm:ss")));
|
| | | commonOrder.setUpdateTime(new Date());
|
| | | commonOrder.setTradeId(taoBaoOrder.getTradeId());
|
| | |
|
| | | return commonOrder;
|
| | |
|