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
|
-//} |
1
|
+package com.yoho.unions.server.service.impl;
|
|
|
2
|
+
|
|
|
3
|
+import com.yoho.unions.common.utils.MathUtils;
|
|
|
4
|
+import com.yoho.unions.server.service.IOrderPushService;
|
|
|
5
|
+import com.yoho.unions.vo.OrderInfo;
|
|
|
6
|
+import com.yoho.unions.vo.OrdersGood;
|
|
|
7
|
+import net.spy.memcached.compat.log.Logger;
|
|
|
8
|
+import net.spy.memcached.compat.log.LoggerFactory;
|
|
|
9
|
+
|
|
|
10
|
+import java.math.BigDecimal;
|
|
|
11
|
+import java.net.URLEncoder;
|
|
|
12
|
+import java.util.ArrayList;
|
|
|
13
|
+import java.util.LinkedHashMap;
|
|
|
14
|
+import java.util.List;
|
|
|
15
|
+import java.util.Set;
|
|
|
16
|
+
|
|
|
17
|
+/**
|
|
|
18
|
+ * 多麦推送订单数据
|
|
|
19
|
+ * Created by yoho on 2016/12/15.
|
|
|
20
|
+ */
|
|
|
21
|
+public class DuomaiServiceImpl implements IOrderPushService {
|
|
|
22
|
+
|
|
|
23
|
+ static Logger logger = LoggerFactory.getLogger(DuomaiServiceImpl.class);
|
|
|
24
|
+
|
|
|
25
|
+ @Override
|
|
|
26
|
+ public void pushOrder(List<OrderInfo> orderInfoList){
|
|
|
27
|
+ String duomaiContext = getDuomaiContext(orderInfoList);
|
|
|
28
|
+
|
|
|
29
|
+
|
|
|
30
|
+ }
|
|
|
31
|
+
|
|
|
32
|
+ private String getDuomaiContext(List<OrderInfo> orderInfoList){
|
|
|
33
|
+ for(OrderInfo orderInfo:orderInfoList){
|
|
|
34
|
+ //联盟id
|
|
|
35
|
+ int client_id = orderInfo.getClientId();
|
|
|
36
|
+ String hash = "";
|
|
|
37
|
+ int channel = 0;
|
|
|
38
|
+ if (client_id == 3017) {
|
|
|
39
|
+ hash = "96613bf38393aa3d16451218f22344a8";
|
|
|
40
|
+ channel = 0;
|
|
|
41
|
+ } else if (client_id == 3019) {
|
|
|
42
|
+ hash = "d54be2dbc75753eb863ba6139950656b";
|
|
|
43
|
+ channel = 1;
|
|
|
44
|
+ } else if (client_id == 3057) {
|
|
|
45
|
+ hash = "bbf70bcaf5c52947ad26853f7cc1176d";
|
|
|
46
|
+ channel = 0;
|
|
|
47
|
+ }
|
|
|
48
|
+ //多麦在YOHO上的网站主标识
|
|
|
49
|
+ String euid = orderInfo.getMbrName();
|
|
|
50
|
+ String orderCode = orderInfo.getOrderCode();
|
|
|
51
|
+ int orderTime = orderInfo.getOrderTime();
|
|
|
52
|
+ BigDecimal orderAmount = orderInfo.getOrderAmount();
|
|
|
53
|
+ String orderStatus = orderInfo.getOrderStatus();
|
|
|
54
|
+ List<OrdersGood> goods = orderInfo.getOrdersGoods();
|
|
|
55
|
+ List<Integer> goodsIdList = new ArrayList<>();
|
|
|
56
|
+ StringBuffer goodId = new StringBuffer();
|
|
|
57
|
+ StringBuffer goodsName = new StringBuffer();
|
|
|
58
|
+ StringBuffer goodPrice = new StringBuffer();
|
|
|
59
|
+ StringBuffer goodNum = new StringBuffer();
|
|
|
60
|
+ //商品分类编号
|
|
|
61
|
+ StringBuffer goodCate = new StringBuffer();
|
|
|
62
|
+ //商品结算金额 price*num-优惠&折扣
|
|
|
63
|
+ StringBuffer totalPrice = new StringBuffer();
|
|
|
64
|
+ for(int i=0;i<goods.size();i++){
|
|
|
65
|
+ goodId.append(goods.get(i).getProductSkn()+ "|");
|
|
|
66
|
+ goodsName.append(goods.get(i).getProductName()+"|");
|
|
|
67
|
+ goodPrice.append(goods.get(i).getLastPrice()+"|");
|
|
|
68
|
+ goodNum.append(goods.get(i).getBuyNumber()+"|");
|
|
|
69
|
+ goodCate.append(goods.get(i).getSortId()+"|");
|
|
|
70
|
+ totalPrice.append(goods.get(i).getRealPayFee()+"|");
|
|
|
71
|
+ }
|
|
|
72
|
+
|
|
|
73
|
+ LinkedHashMap<String,Object> linkedHashMap = new LinkedHashMap<>();
|
|
|
74
|
+ linkedHashMap.put("hash",hash);
|
|
|
75
|
+ linkedHashMap.put("euid",euid);
|
|
|
76
|
+ linkedHashMap.put("order_sn",orderCode);
|
|
|
77
|
+ linkedHashMap.put("order_time",orderTime);
|
|
|
78
|
+ linkedHashMap.put("orders_price",orderAmount);
|
|
|
79
|
+ linkedHashMap.put("promotion_code",0);
|
|
|
80
|
+ //@TODO需要订单传过来,是否新用户
|
|
|
81
|
+ linkedHashMap.put("is_new_custom",0);
|
|
|
82
|
+ linkedHashMap.put("channel", channel);
|
|
|
83
|
+ linkedHashMap.put("status", orderStatus);
|
|
|
84
|
+ linkedHashMap.put("goods_id",goodId.toString());
|
|
|
85
|
+ linkedHashMap.put("goods_name",goodsName.toString());
|
|
|
86
|
+ linkedHashMap.put("goods_price",goodPrice.toString());
|
|
|
87
|
+ linkedHashMap.put("goods_ta",goodNum.toString());
|
|
|
88
|
+ linkedHashMap.put("goods_cate",goodCate.toString());
|
|
|
89
|
+ linkedHashMap.put("goods_cate_name",0);
|
|
|
90
|
+ linkedHashMap.put("totalPrice",totalPrice.toString());
|
|
|
91
|
+ //佣金计算,月底计算一次,7%计算,数据库比例已经老的
|
|
|
92
|
+ linkedHashMap.put("rate", 0);
|
|
|
93
|
+ linkedHashMap.put("commission","");
|
|
|
94
|
+ linkedHashMap.put("commission_type", 0);
|
|
|
95
|
+ double coupon = 12d;
|
|
|
96
|
+ linkedHashMap.put("coupon", MathUtils.roundPrice(coupon));
|
|
|
97
|
+ Set<String> keys = linkedHashMap.keySet();
|
|
|
98
|
+ StringBuilder builder = new StringBuilder();
|
|
|
99
|
+ for (String key : keys) {
|
|
|
100
|
+ builder.append(key).append("=").append(linkedHashMap.get(key)).append("&");
|
|
|
101
|
+ }
|
|
|
102
|
+ String url = null;
|
|
|
103
|
+ try{
|
|
|
104
|
+ url = URLEncoder.encode(builder.substring(0, builder.length() - 1), "UTF-8");
|
|
|
105
|
+ }catch (Exception e){
|
|
|
106
|
+ logger.warn("send duomai error",e.getMessage());
|
|
|
107
|
+ }
|
|
|
108
|
+
|
|
|
109
|
+ return url;
|
|
|
110
|
+
|
|
|
111
|
+ }
|
|
|
112
|
+ }
|
|
|
113
|
+
|
|
|
114
|
+} |