Authored by zhengwen.ge

Merge branch 'master' into 日志优化

# Conflicts:
#	server/src/main/java/com/yoho/unions/server/service/impl/UnionServiceImpl.java
... ... @@ -2,7 +2,6 @@ package com.yoho.unions.dal.model;
import lombok.Data;
@Data
public class UnionOrders {
private String create_time;
... ... @@ -29,4 +28,99 @@ public class UnionOrders {
private String update_time;
public String getCreate_time() {
return create_time;
}
public void setCreate_time(String create_time) {
this.create_time = create_time;
}
public String getParent_order_code() {
return parent_order_code;
}
public void setParent_order_code(String parent_order_code) {
this.parent_order_code = parent_order_code;
}
public String getOrder_code() {
return order_code;
}
public void setOrder_code(String order_code) {
this.order_code = order_code;
}
public String getUid() {
return uid;
}
public void setUid(String uid) {
this.uid = uid;
}
public String getUnionid() {
return unionid;
}
public void setUnionid(String unionid) {
this.unionid = unionid;
}
public String getUnion_cookie() {
return union_cookie;
}
public void setUnion_cookie(String union_cookie) {
this.union_cookie = union_cookie;
}
public String getOrder_amount() {
return order_amount;
}
public void setOrder_amount(String order_amount) {
this.order_amount = order_amount;
}
public String getPayment() {
return payment;
}
public void setPayment(String payment) {
this.payment = payment;
}
public String getShipping_cost() {
return shipping_cost;
}
public void setShipping_cost(String shipping_cost) {
this.shipping_cost = shipping_cost;
}
public String getOrder_status() {
return order_status;
}
public void setOrder_status(String order_status) {
this.order_status = order_status;
}
public String getOrder_type() {
return order_type;
}
public void setOrder_type(String order_type) {
this.order_type = order_type;
}
public String getUpdate_time() {
return update_time;
}
public void setUpdate_time(String update_time) {
this.update_time = update_time;
}
}
\ No newline at end of file
... ...
... ... @@ -2,7 +2,6 @@ package com.yoho.unions.dal.model;
import lombok.Data;
@Data
public class UnionOrdersGoods {
private String uid;
... ... @@ -39,4 +38,139 @@ public class UnionOrdersGoods {
private String url;
public String getUid() {
return uid;
}
public void setUid(String uid) {
this.uid = uid;
}
public String getOrder_ode() {
return order_ode;
}
public void setOrder_ode(String order_ode) {
this.order_ode = order_ode;
}
public String getParent_order_code() {
return parent_order_code;
}
public void setParent_order_code(String parent_order_code) {
this.parent_order_code = parent_order_code;
}
public String getProduct_skc() {
return product_skc;
}
public void setProduct_skc(String product_skc) {
this.product_skc = product_skc;
}
public String getProduct_skn() {
return product_skn;
}
public void setProduct_skn(String product_skn) {
this.product_skn = product_skn;
}
public String getProduct_sku() {
return product_sku;
}
public void setProduct_sku(String product_sku) {
this.product_sku = product_sku;
}
public String getProduct_name() {
return product_name;
}
public void setProduct_name(String product_name) {
this.product_name = product_name;
}
public String getSort_id() {
return sort_id;
}
public void setSort_id(String sort_id) {
this.sort_id = sort_id;
}
public String getSort_name() {
return sort_name;
}
public void setSort_name(String sort_name) {
this.sort_name = sort_name;
}
public String getLast_price() {
return last_price;
}
public void setLast_price(String last_price) {
this.last_price = last_price;
}
public String getBuy_number() {
return buy_number;
}
public void setBuy_number(String buy_number) {
this.buy_number = buy_number;
}
public String getReal_pay_fee() {
return real_pay_fee;
}
public void setReal_pay_fee(String real_pay_fee) {
this.real_pay_fee = real_pay_fee;
}
public String getDiscount_fee() {
return discount_fee;
}
public void setDiscount_fee(String discount_fee) {
this.discount_fee = discount_fee;
}
public String getCommission() {
return commission;
}
public void setCommission(String commission) {
this.commission = commission;
}
public String getComm_type() {
return comm_type;
}
public void setComm_type(String comm_type) {
this.comm_type = comm_type;
}
public String getUpdate_time() {
return update_time;
}
public void setUpdate_time(String update_time) {
this.update_time = update_time;
}
public String getUrl() {
return url;
}
public void setUrl(String url) {
this.url = url;
}
}
\ No newline at end of file
... ...
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");
//
// }
// }
//
//}
... ...
... ... @@ -73,7 +73,7 @@ public class GDT2ServiceImpl extends UnionServiceImpl implements IUnionService {
* @param requestBO
* @return
*/
private String urlEode(ActivateUnionRequestBO requestBO) {
public String urlEode(ActivateUnionRequestBO requestBO) {
log.info("enter GDTServiceImpl.urlEode param{} is ", requestBO);
// 根据不同的应用类型,获取不同的加密密钥和签名密钥
String encryptKey = null;
... ... @@ -106,7 +106,7 @@ public class GDT2ServiceImpl extends UnionServiceImpl implements IUnionService {
String url = DynamicPropertyFactory.getInstance().getStringProperty("guangdiantong.url", "").get();
int conv_time = DateUtil.getCurrentTimeSecond();
String client_ip = requestBO.getClientIp();
String clickId = requestBO.getCommonUse();
String clickId = requestBO.getUdid();
String appId = requestBO.getAppid();
StringBuffer bf = new StringBuffer();
StringBuffer sf = new StringBuffer();
... ...
... ... @@ -9,9 +9,6 @@ import java.util.concurrent.TimeUnit;
import javax.annotation.Resource;
import com.yoho.unions.common.redis.RedisValueCache;
import com.yoho.unions.dal.IUnionTypeDAO;
import com.yoho.unions.dal.model.UnionType;
import org.apache.commons.collections.CollectionUtils;
import org.apache.commons.lang3.StringUtils;
import org.apache.commons.lang3.tuple.Pair;
... ... @@ -32,15 +29,17 @@ import com.yoho.service.model.union.UnionTypeModel;
import com.yoho.service.model.union.request.ActivateUnionRequestBO;
import com.yoho.service.model.union.request.ClickUnionRequestBO;
import com.yoho.service.model.union.response.UnionResponse;
import com.yoho.unions.common.constant.UnionConstant;
import com.yoho.unions.common.enums.ClientTypeEnum;
import com.yoho.unions.common.redis.RedisValueCache;
import com.yoho.unions.common.utils.DateUtil;
import com.yoho.unions.common.utils.HttpUtils;
import com.yoho.unions.common.utils.SpringContextUtil;
import com.yoho.unions.dal.IAppActivateIdfaListDAO;
import com.yoho.unions.dal.IUnionLogsDAO;
import com.yoho.unions.dal.IUnionTypeDAO;
import com.yoho.unions.dal.model.AppActivateIdfaList;
import com.yoho.unions.dal.model.UnionLogs;
import com.yoho.unions.dal.model.UnionType;
import com.yoho.unions.server.service.IUnionService;
/**
... ... @@ -161,9 +160,18 @@ public class UnionServiceImpl implements IUnionService {
String invalidTime = "activeTime"+"_"+request.getUnion_type();
DynamicIntProperty activeTime = DynamicPropertyFactory.getInstance().getIntProperty(invalidTime, 3);
yHRedisTemplate.longExpire(key, activeTime.get(), TimeUnit.HOURS);
log.info("clickUnion set redis success with request={}", request);
//把IP作为key,也保存到redis
key = UNION_KEY + "_" + request.getClientIp() + "_" + request.getAppkey();
yhValueOperations.set(key, JSON.toJSONString(request));
yHRedisTemplate.longExpire(key, activeTime.get(), TimeUnit.HOURS);
log.info("clickUnion set redis second success. with key={}, value={}", key, JSON.toJSONString(request));
log.info("clickUnion set redis success with request={}", request);
// if (union != null) {
// //如果90天以内,已经存在点击记录,则不需要插入或更新数据库
// log.info("clickUnion have click in 90 days with request={}", request);
... ... @@ -308,6 +316,13 @@ public class UnionServiceImpl implements IUnionService {
// request);
// return new UnionResponse(205, "not click record");
// }
//删除redis中的点击记录
yHRedisTemplate.delete(key);
//强制删除带ip的key
yHRedisTemplate.delete(UNION_KEY + "_" + request.getClientIp() + "_" + request.getAppkey());
if (union != null && union.getIsActivate() != null && union.getIsActivate().byteValue() == 1) {
// 如果90天之内有过激活日志,则不允许重复激活
... ... @@ -386,8 +401,7 @@ public class UnionServiceImpl implements IUnionService {
unionLogsDAO.insert(logs);
log.info("activateUnion add db success with request is {}, and dbData={}", request, logs);
//删除redis中的点击记录
yHRedisTemplate.delete(key);
// 记录日志
JSONObject j = new JSONObject();
... ... @@ -431,7 +445,10 @@ public class UnionServiceImpl implements IUnionService {
log.info("activateUnion in success request is {}", request);
return new UnionResponse();
}
url = URLDecoder.decode(url, "UTF-8");
if(!"3".equals(union_type)){
url = URLDecoder.decode(url, "UTF-8");
}
if (url.indexOf("?") > 0) {
url += "&identify_id=" + click.getIdentify_id();
} else {
... ...
... ... @@ -39,8 +39,8 @@ public class Test {
requestBO.setAppid("490655927");
requestBO.setClient_type("ios");
// requestBO.setClientIp("171.213.29.236");
String url = gdt2Service.urlEode(requestBO);
String url1 = url+"&identify_id=null";
// String url = gdt2Service.urlEode(requestBO);
// String url1 = url+"&identify_id=null";
// Pair<Integer, String> pair = HttpUtils.httpGet(url1);
// try{
// url = URLDecoder.decode(url1, "UTF-8");
... ...