Authored by zhengwen.ge

多麦

@@ -34,10 +34,20 @@ public class OrderInfo implements Serializable { @@ -34,10 +34,20 @@ public class OrderInfo implements Serializable {
34 //平台(web/wap/app) 34 //平台(web/wap/app)
35 private String orderType; 35 private String orderType;
36 36
  37 + public String getMbrName() {
  38 + return mbrName;
  39 + }
  40 +
  41 + public void setMbrName(String mbrName) {
  42 + this.mbrName = mbrName;
  43 + }
  44 +
37 private String trackingCode; 45 private String trackingCode;
38 46
39 private String thirdUid; 47 private String thirdUid;
40 48
  49 + private String mbrName;
  50 +
41 private List<OrdersGood> ordersGoods; 51 private List<OrdersGood> ordersGoods;
42 52
43 public int getOrderTime() { 53 public int getOrderTime() {
@@ -81,6 +81,9 @@ public class OrderPushConsumer implements CommonMessageConsumer { @@ -81,6 +81,9 @@ public class OrderPushConsumer implements CommonMessageConsumer {
81 userOrders.setUserId(unionCookie.getString("fl_uid")); 81 userOrders.setUserId(unionCookie.getString("fl_uid"));
82 //创建时间 82 //创建时间
83 userOrders.setCreateTime(DateUtil.getCurrentTimeSecond()); 83 userOrders.setCreateTime(DateUtil.getCurrentTimeSecond());
  84 +
  85 + userOrders.setMbrName(jsonObject.getString("mbr_name"));
  86 +
84 //是否推送 87 //是否推送
85 userOrders.setIsPush(0); 88 userOrders.setIsPush(0);
86 return userOrders; 89 return userOrders;
  1 +package com.yoho.unions.server.service.impl;
  2 +
  3 +import com.yoho.unions.server.service.IOrderPushService;
  4 +import com.yoho.unions.vo.OrderInfo;
  5 +import com.yoho.unions.vo.OrdersGood;
  6 +import net.spy.memcached.compat.log.Logger;
  7 +import net.spy.memcached.compat.log.LoggerFactory;
  8 +
  9 +import java.math.BigDecimal;
  10 +import java.net.URLEncoder;
  11 +import java.util.ArrayList;
  12 +import java.util.LinkedHashMap;
  13 +import java.util.List;
  14 +import java.util.Set;
  15 +
  16 +/**
  17 + * 多麦推送订单数据
  18 + * Created by yoho on 2016/12/15.
  19 + */
  20 +public class DuomaiServiceImpl implements IOrderPushService {
  21 +
  22 + static Logger logger = LoggerFactory.getLogger(DuomaiServiceImpl.class);
  23 +
  24 + @Override
  25 + public void pushOrder(List<OrderInfo> orderInfoList){
  26 +
  27 + for(OrderInfo orderInfo:orderInfoList){
  28 + //联盟id
  29 + int client_id = orderInfo.getClientId();
  30 + String hash = "";
  31 + int channel = 0;
  32 + if (client_id == 3017) {
  33 + hash = "96613bf38393aa3d16451218f22344a8";
  34 + channel = 0;
  35 + } else if (client_id == 3019) {
  36 + hash = "d54be2dbc75753eb863ba6139950656b";
  37 + channel = 1;
  38 + } else if (client_id == 3057) {
  39 + hash = "bbf70bcaf5c52947ad26853f7cc1176d";
  40 + channel = 0;
  41 + }
  42 + //多麦在YOHO上的网站主标识
  43 + String euid = orderInfo.getMbrName();
  44 + String orderCode = orderInfo.getOrderCode();
  45 + int orderTime = orderInfo.getOrderTime();
  46 + BigDecimal orderAmount = orderInfo.getOrderAmount();
  47 + String orderStatus = orderInfo.getOrderStatus();
  48 + List<OrdersGood> goods = orderInfo.getOrdersGoods();
  49 + List<Integer> goodsIdList = new ArrayList<>();
  50 + StringBuffer goodId = new StringBuffer();
  51 + StringBuffer goodsName = new StringBuffer();
  52 + StringBuffer goodPrice = new StringBuffer();
  53 + StringBuffer goodNum = new StringBuffer();
  54 + //商品分类编号
  55 + StringBuffer goodCate = new StringBuffer();
  56 + //商品结算金额 price*num-优惠&折扣
  57 + StringBuffer totalPrice = new StringBuffer();
  58 + for(int i=0;i<goods.size();i++){
  59 + goodId.append(goods.get(i).getProductSkn()+ "|");
  60 + goodsName.append(goods.get(i).getProductName()+"|");
  61 + goodPrice.append(goods.get(i).getLastPrice()+"|");
  62 + goodNum.append(goods.get(i).getBuyNumber()+"|");
  63 + goodCate.append(goods.get(i).getSortId()+"|");
  64 + totalPrice.append(goods.get(i).getRealPayFee()+"|");
  65 + }
  66 +
  67 + LinkedHashMap<String,Object> linkedHashMap = new LinkedHashMap<>();
  68 + linkedHashMap.put("hash",hash);
  69 + linkedHashMap.put("euid",euid);
  70 + linkedHashMap.put("order_sn",orderCode);
  71 + linkedHashMap.put("order_time",orderTime);
  72 + linkedHashMap.put("orders_price",orderAmount);
  73 + linkedHashMap.put("promotion_code",0);
  74 + //@TODO需要订单传过来,是否新用户
  75 + linkedHashMap.put("is_new_custom",0);
  76 + linkedHashMap.put("channel", channel);
  77 + linkedHashMap.put("status", orderStatus);
  78 + linkedHashMap.put("goods_id",goodId.toString());
  79 + linkedHashMap.put("goods_name",goodsName.toString());
  80 + linkedHashMap.put("goods_price",goodPrice.toString());
  81 + linkedHashMap.put("goods_ta",goodNum.toString());
  82 + linkedHashMap.put("goods_cate",goodCate.toString());
  83 + linkedHashMap.put("goods_cate_name",0);
  84 + linkedHashMap.put("totalPrice",totalPrice.toString());
  85 + //佣金计算,月底计算一次,7%计算,数据库比例已经老的
  86 + linkedHashMap.put("rate", 0);
  87 + linkedHashMap.put("commission","");
  88 + linkedHashMap.put("commission_type", 0);
  89 + linkedHashMap.put("coupon", MathUtils.roundPrice(tmpReturnedOrder.coupon));
  90 + Set<String> keys = linkedHashMap.keySet();
  91 + StringBuilder builder = new StringBuilder();
  92 + for (String key : keys) {
  93 + builder.append(key).append("=").append(linkedHashMap.get(key)).append("&");
  94 + }
  95 +
  96 + return URLEncoder.encode(builder.substring(0, builder.length() - 1), "UTF-8");
  97 +
  98 + }
  99 + }
  100 +
  101 +}
@@ -81,6 +81,7 @@ public class BigDataOrderInfoTask { @@ -81,6 +81,7 @@ public class BigDataOrderInfoTask {
81 orderInfo.setThirdUid(userOrders.getUserId()); 81 orderInfo.setThirdUid(userOrders.getUserId());
82 //获取trackingCode 82 //获取trackingCode
83 orderInfo.setTrackingCode(userOrders.getTrackingCode()); 83 orderInfo.setTrackingCode(userOrders.getTrackingCode());
  84 + orderInfo.setMbrName(userOrders.getMbrName());
84 //组装分类 85 //组装分类
85 if (!orderInfoMap.containsKey(orderInfo.getClientId())) { 86 if (!orderInfoMap.containsKey(orderInfo.getClientId())) {
86 orderInfoMap.put(orderInfo.getClientId(), Lists.newArrayList(orderInfo)); 87 orderInfoMap.put(orderInfo.getClientId(), Lists.newArrayList(orderInfo));