|
|
package com.yoho.unions.server.service.impl;
|
|
|
|
|
|
import com.yoho.unions.server.service.IOrderPushService;
|
|
|
import com.yoho.unions.vo.OrderInfo;
|
|
|
import com.yoho.unions.vo.OrdersGood;
|
|
|
import net.spy.memcached.compat.log.Logger;
|
|
|
import net.spy.memcached.compat.log.LoggerFactory;
|
|
|
|
|
|
import java.math.BigDecimal;
|
|
|
import java.net.URLEncoder;
|
|
|
import java.util.ArrayList;
|
|
|
import java.util.LinkedHashMap;
|
|
|
import java.util.List;
|
|
|
import java.util.Set;
|
|
|
|
|
|
/**
|
|
|
* 多麦推送订单数据
|
|
|
* Created by yoho on 2016/12/15.
|
|
|
*/
|
|
|
public class DuomaiServiceImpl implements IOrderPushService {
|
|
|
|
|
|
static Logger logger = LoggerFactory.getLogger(DuomaiServiceImpl.class);
|
|
|
|
|
|
@Override
|
|
|
public void pushOrder(List<OrderInfo> orderInfoList){
|
|
|
|
|
|
for(OrderInfo orderInfo:orderInfoList){
|
|
|
//联盟id
|
|
|
int client_id = orderInfo.getClientId();
|
|
|
String hash = "";
|
|
|
int channel = 0;
|
|
|
if (client_id == 3017) {
|
|
|
hash = "96613bf38393aa3d16451218f22344a8";
|
|
|
channel = 0;
|
|
|
} else if (client_id == 3019) {
|
|
|
hash = "d54be2dbc75753eb863ba6139950656b";
|
|
|
channel = 1;
|
|
|
} else if (client_id == 3057) {
|
|
|
hash = "bbf70bcaf5c52947ad26853f7cc1176d";
|
|
|
channel = 0;
|
|
|
}
|
|
|
//多麦在YOHO上的网站主标识
|
|
|
String euid = orderInfo.getMbrName();
|
|
|
String orderCode = orderInfo.getOrderCode();
|
|
|
int orderTime = orderInfo.getOrderTime();
|
|
|
BigDecimal orderAmount = orderInfo.getOrderAmount();
|
|
|
String orderStatus = orderInfo.getOrderStatus();
|
|
|
List<OrdersGood> goods = orderInfo.getOrdersGoods();
|
|
|
List<Integer> goodsIdList = new ArrayList<>();
|
|
|
StringBuffer goodId = new StringBuffer();
|
|
|
StringBuffer goodsName = new StringBuffer();
|
|
|
StringBuffer goodPrice = new StringBuffer();
|
|
|
StringBuffer goodNum = new StringBuffer();
|
|
|
//商品分类编号
|
|
|
StringBuffer goodCate = new StringBuffer();
|
|
|
//商品结算金额 price*num-优惠&折扣
|
|
|
StringBuffer totalPrice = new StringBuffer();
|
|
|
for(int i=0;i<goods.size();i++){
|
|
|
goodId.append(goods.get(i).getProductSkn()+ "|");
|
|
|
goodsName.append(goods.get(i).getProductName()+"|");
|
|
|
goodPrice.append(goods.get(i).getLastPrice()+"|");
|
|
|
goodNum.append(goods.get(i).getBuyNumber()+"|");
|
|
|
goodCate.append(goods.get(i).getSortId()+"|");
|
|
|
totalPrice.append(goods.get(i).getRealPayFee()+"|");
|
|
|
}
|
|
|
|
|
|
LinkedHashMap<String,Object> linkedHashMap = new LinkedHashMap<>();
|
|
|
linkedHashMap.put("hash",hash);
|
|
|
linkedHashMap.put("euid",euid);
|
|
|
linkedHashMap.put("order_sn",orderCode);
|
|
|
linkedHashMap.put("order_time",orderTime);
|
|
|
linkedHashMap.put("orders_price",orderAmount);
|
|
|
linkedHashMap.put("promotion_code",0);
|
|
|
//@TODO需要订单传过来,是否新用户
|
|
|
linkedHashMap.put("is_new_custom",0);
|
|
|
linkedHashMap.put("channel", channel);
|
|
|
linkedHashMap.put("status", orderStatus);
|
|
|
linkedHashMap.put("goods_id",goodId.toString());
|
|
|
linkedHashMap.put("goods_name",goodsName.toString());
|
|
|
linkedHashMap.put("goods_price",goodPrice.toString());
|
|
|
linkedHashMap.put("goods_ta",goodNum.toString());
|
|
|
linkedHashMap.put("goods_cate",goodCate.toString());
|
|
|
linkedHashMap.put("goods_cate_name",0);
|
|
|
linkedHashMap.put("totalPrice",totalPrice.toString());
|
|
|
//佣金计算,月底计算一次,7%计算,数据库比例已经老的
|
|
|
linkedHashMap.put("rate", 0);
|
|
|
linkedHashMap.put("commission","");
|
|
|
linkedHashMap.put("commission_type", 0);
|
|
|
linkedHashMap.put("coupon", MathUtils.roundPrice(tmpReturnedOrder.coupon));
|
|
|
Set<String> keys = linkedHashMap.keySet();
|
|
|
StringBuilder builder = new StringBuilder();
|
|
|
for (String key : keys) {
|
|
|
builder.append(key).append("=").append(linkedHashMap.get(key)).append("&");
|
|
|
}
|
|
|
|
|
|
return URLEncoder.encode(builder.substring(0, builder.length() - 1), "UTF-8");
|
|
|
|
|
|
}
|
|
|
}
|
|
|
|
|
|
} |
|
|
//package com.yoho.unions.server.service.impl;
|
|
|
//
|
|
|
//import com.yoho.unions.server.service.IOrderPushService;
|
|
|
//import com.yoho.unions.vo.OrderInfo;
|
|
|
//import com.yoho.unions.vo.OrdersGood;
|
|
|
//import net.spy.memcached.compat.log.Logger;
|
|
|
//import net.spy.memcached.compat.log.LoggerFactory;
|
|
|
//
|
|
|
//import java.math.BigDecimal;
|
|
|
//import java.net.URLEncoder;
|
|
|
//import java.util.ArrayList;
|
|
|
//import java.util.LinkedHashMap;
|
|
|
//import java.util.List;
|
|
|
//import java.util.Set;
|
|
|
//
|
|
|
///**
|
|
|
// * 多麦推送订单数据
|
|
|
// * Created by yoho on 2016/12/15.
|
|
|
// */
|
|
|
//public class DuomaiServiceImpl implements IOrderPushService {
|
|
|
//
|
|
|
// static Logger logger = LoggerFactory.getLogger(DuomaiServiceImpl.class);
|
|
|
//
|
|
|
// @Override
|
|
|
// public void pushOrder(List<OrderInfo> orderInfoList){
|
|
|
//
|
|
|
// for(OrderInfo orderInfo:orderInfoList){
|
|
|
// //联盟id
|
|
|
// int client_id = orderInfo.getClientId();
|
|
|
// String hash = "";
|
|
|
// int channel = 0;
|
|
|
// if (client_id == 3017) {
|
|
|
// hash = "96613bf38393aa3d16451218f22344a8";
|
|
|
// channel = 0;
|
|
|
// } else if (client_id == 3019) {
|
|
|
// hash = "d54be2dbc75753eb863ba6139950656b";
|
|
|
// channel = 1;
|
|
|
// } else if (client_id == 3057) {
|
|
|
// hash = "bbf70bcaf5c52947ad26853f7cc1176d";
|
|
|
// channel = 0;
|
|
|
// }
|
|
|
// //多麦在YOHO上的网站主标识
|
|
|
// String euid = orderInfo.getMbrName();
|
|
|
// String orderCode = orderInfo.getOrderCode();
|
|
|
// int orderTime = orderInfo.getOrderTime();
|
|
|
// BigDecimal orderAmount = orderInfo.getOrderAmount();
|
|
|
// String orderStatus = orderInfo.getOrderStatus();
|
|
|
// List<OrdersGood> goods = orderInfo.getOrdersGoods();
|
|
|
// List<Integer> goodsIdList = new ArrayList<>();
|
|
|
// StringBuffer goodId = new StringBuffer();
|
|
|
// StringBuffer goodsName = new StringBuffer();
|
|
|
// StringBuffer goodPrice = new StringBuffer();
|
|
|
// StringBuffer goodNum = new StringBuffer();
|
|
|
// //商品分类编号
|
|
|
// StringBuffer goodCate = new StringBuffer();
|
|
|
// //商品结算金额 price*num-优惠&折扣
|
|
|
// StringBuffer totalPrice = new StringBuffer();
|
|
|
// for(int i=0;i<goods.size();i++){
|
|
|
// goodId.append(goods.get(i).getProductSkn()+ "|");
|
|
|
// goodsName.append(goods.get(i).getProductName()+"|");
|
|
|
// goodPrice.append(goods.get(i).getLastPrice()+"|");
|
|
|
// goodNum.append(goods.get(i).getBuyNumber()+"|");
|
|
|
// goodCate.append(goods.get(i).getSortId()+"|");
|
|
|
// totalPrice.append(goods.get(i).getRealPayFee()+"|");
|
|
|
// }
|
|
|
//
|
|
|
// LinkedHashMap<String,Object> linkedHashMap = new LinkedHashMap<>();
|
|
|
// linkedHashMap.put("hash",hash);
|
|
|
// linkedHashMap.put("euid",euid);
|
|
|
// linkedHashMap.put("order_sn",orderCode);
|
|
|
// linkedHashMap.put("order_time",orderTime);
|
|
|
// linkedHashMap.put("orders_price",orderAmount);
|
|
|
// linkedHashMap.put("promotion_code",0);
|
|
|
// //@TODO需要订单传过来,是否新用户
|
|
|
// linkedHashMap.put("is_new_custom",0);
|
|
|
// linkedHashMap.put("channel", channel);
|
|
|
// linkedHashMap.put("status", orderStatus);
|
|
|
// linkedHashMap.put("goods_id",goodId.toString());
|
|
|
// linkedHashMap.put("goods_name",goodsName.toString());
|
|
|
// linkedHashMap.put("goods_price",goodPrice.toString());
|
|
|
// linkedHashMap.put("goods_ta",goodNum.toString());
|
|
|
// linkedHashMap.put("goods_cate",goodCate.toString());
|
|
|
// linkedHashMap.put("goods_cate_name",0);
|
|
|
// linkedHashMap.put("totalPrice",totalPrice.toString());
|
|
|
// //佣金计算,月底计算一次,7%计算,数据库比例已经老的
|
|
|
// linkedHashMap.put("rate", 0);
|
|
|
// linkedHashMap.put("commission","");
|
|
|
// linkedHashMap.put("commission_type", 0);
|
|
|
// linkedHashMap.put("coupon", MathUtils.roundPrice(tmpReturnedOrder.coupon));
|
|
|
// Set<String> keys = linkedHashMap.keySet();
|
|
|
// StringBuilder builder = new StringBuilder();
|
|
|
// for (String key : keys) {
|
|
|
// builder.append(key).append("=").append(linkedHashMap.get(key)).append("&");
|
|
|
// }
|
|
|
//
|
|
|
// return URLEncoder.encode(builder.substring(0, builder.length() - 1), "UTF-8");
|
|
|
//
|
|
|
// }
|
|
|
// }
|
|
|
//
|
|
|
//} |
...
|
...
|
|