Authored by zhengwen.ge

unionType整改

package com.yoho.unions.vo;
/**
* Created by yoho on 2016/12/27.
*/
public class CommonJumpReqVO {
private String client_id;
private String channel_code;
private String go_url;
private String utm_source;
private String utm_medium;
private String utm_campaign;
public String getClient_id() {
return client_id;
}
public void setClient_id(String client_id) {
this.client_id = client_id;
}
public String getChannel_code() {
return channel_code;
}
public void setChannel_code(String channel_code) {
this.channel_code = channel_code;
}
public String getGo_url() {
return go_url;
}
public void setGo_url(String go_url) {
this.go_url = go_url;
}
public String getUtm_source() {
return utm_source;
}
public void setUtm_source(String utm_source) {
this.utm_source = utm_source;
}
public String getUtm_medium() {
return utm_medium;
}
public void setUtm_medium(String utm_medium) {
this.utm_medium = utm_medium;
}
public String getUtm_campaign() {
return utm_campaign;
}
public void setUtm_campaign(String utm_campaign) {
this.utm_campaign = utm_campaign;
}
}
... ...
... ... @@ -16,5 +16,5 @@ public interface IUnionOrderPushDAO {
int updateByPrimaryKey(UnionOrderPush record);
UnionOrderPush selectByChannelId(int channelId);
UnionOrderPush selectByChannelId(String channelId);
}
\ No newline at end of file
... ...
... ... @@ -3,7 +3,7 @@ package com.yoho.unions.dal.model;
public class UnionOrderPush {
private Integer id;
private Integer channelId;
private String channelId;
private String url;
... ... @@ -17,11 +17,11 @@ public class UnionOrderPush {
this.id = id;
}
public Integer getChannelId() {
public String getChannelId() {
return channelId;
}
public void setChannelId(Integer channelId) {
public void setChannelId(String channelId) {
this.channelId = channelId;
}
... ...
... ... @@ -17,7 +17,7 @@ public class UnionTypeManage {
private Integer createTime;
private Integer unionType;
private String unionType;
@Override
public String toString() {
... ... @@ -80,11 +80,11 @@ public class UnionTypeManage {
this.createTime = createTime;
}
public Integer getUnionType() {
public String getUnionType() {
return unionType;
}
public void setUnionType(Integer unionType) {
public void setUnionType(String unionType) {
this.unionType = unionType;
}
}
... ...
... ... @@ -5,10 +5,7 @@ import com.yoho.unions.common.utils.SpringContextUtil;
import com.yoho.unions.server.service.IOrderPushService;
import com.yoho.unions.server.service.IRedirectService;
import com.yoho.unions.server.task.BigDataOrderInfoTask;
import com.yoho.unions.vo.OrderInfo;
import com.yoho.unions.vo.OrdersGood;
import com.yoho.unions.vo.UnionOrderReqVO;
import com.yoho.unions.vo.UnionReqVO;
import com.yoho.unions.vo.*;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
... ... @@ -49,6 +46,16 @@ public class OrderUnionRest {
}
/**
* 迁移北京的订单联盟跳转接口
*/
@RequestMapping("/go")
@ResponseBody
public void go(CommonJumpReqVO commonJumpReqVO, HttpServletRequest request, HttpServletResponse response){
logger.info("Enter OrderUnionRest.go unionReqVO {} ", commonJumpReqVO);
}
/**
* 执行订单推送
* @param req
* @return
... ... @@ -75,7 +82,7 @@ public class OrderUnionRest {
orderInfo.setShippingCost(new BigDecimal(1));
orderInfo.setOrderStatus("1");
orderInfo.setOrderType("web");
orderInfo.setClientId(3001);
orderInfo.setClientId("3001");
List<OrdersGood> ordersGoods = new ArrayList<>();
for(int i = 0;i<3;i++){
OrdersGood ordersGood = new OrdersGood();
... ...
package com.yoho.unions.server.service;
import com.yoho.unions.vo.CommonJumpReqVO;
import com.yoho.unions.vo.UnionReqVO;
import javax.servlet.http.HttpServletRequest;
... ... @@ -8,4 +9,6 @@ import javax.servlet.http.HttpServletResponse;
public interface IRedirectService {
public void jump(UnionReqVO unionReqVO, HttpServletRequest request, HttpServletResponse response);
public void go(CommonJumpReqVO commonJumpReqVO, HttpServletRequest request, HttpServletResponse response);
}
... ...
... ... @@ -99,7 +99,7 @@ public class OrderPushServiceImpl implements IOrderPushService{
param.put("channelId",orderInfo.getClientId());
//佣金比例---根据不同的厂商去计算,在表中维护
//根据不同的厂商,发送不同的URL
int clientId = orderInfo.getClientId();
String clientId = orderInfo.getClientId();
UnionOrderPush unionOrderPush = unionOrderPushDAO.selectByChannelId(clientId);
String commRate = null;
if(null!=unionOrderPush&& StringUtils.isNotEmpty(unionOrderPush.getCommRate())){
... ...
... ... @@ -2,8 +2,11 @@ package com.yoho.unions.server.service.impl;
import com.alibaba.fastjson.JSONObject;
import com.yoho.unions.common.enums.SourceEnum;
import com.yoho.unions.dal.IUnionDepartmentUrlDAO;
import com.yoho.unions.dal.model.UnionDepartmentUrl;
import com.yoho.unions.dal.model.UnionType;
import com.yoho.unions.server.service.IRedirectService;
import com.yoho.unions.vo.CommonJumpReqVO;
import com.yoho.unions.vo.UnionReqVO;
import org.apache.commons.lang3.StringUtils;
import org.slf4j.Logger;
... ... @@ -36,7 +39,7 @@ public class RedirectServiceImpl implements IRedirectService {
private static final String WEB_REDIRECT_URL = "http://www.yohobuy.com/3party/ads";
@Autowired
private I
private IUnionDepartmentUrlDAO unionDepartmentUrlDAO;
@Override
public void jump(UnionReqVO uionReqVO, HttpServletRequest request, HttpServletResponse response) {
... ... @@ -70,6 +73,31 @@ public class RedirectServiceImpl implements IRedirectService {
}
}
@Override
public void go(CommonJumpReqVO commonJumpReqVO, HttpServletRequest request, HttpServletResponse response){
logger.info("Enter go: request param is {} ", commonJumpReqVO);
try{
if (null == commonJumpReqVO) {
logger.warn("jump: request params is null");
return;
}
String client_id = commonJumpReqVO.getClient_id();
if (StringUtils.isEmpty(client_id)) {
logger.warn("jump: channelId is null, requst param is {}", commonJumpReqVO);
return;
}
if (StringUtils.isEmpty(commonJumpReqVO.getChannel_code())) {
logger.warn("jump: trackCode is null, requst param is {}", uionReqVO);
return;
}
String redirectUrl = builderCommonUrl(commonJumpReqVO);
}catch (IOException e){
}
}
private String builderUrlForPanshi(UnionReqVO uionReqVO) {
uionReqVO.setUnion_type(uionReqVO.getChannel_id());
String param = this.generateReqParam(uionReqVO);
... ... @@ -131,22 +159,22 @@ public class RedirectServiceImpl implements IRedirectService {
if(Integer.parseInt(channelId.trim())==2891&&!uionReqVO.getTracking_code().equals("mbdcpc2")){
url = "http://m.yohobuy.com/";
}else{
UnionType unionType = unionTypeDAO.selectByUnionType(Integer.parseInt(channelId.trim()));
url = unionType.getGoUrl();
UnionDepartmentUrl unionDepartmentUrl = unionDepartmentUrlDAO.selectByUnionType(channelId.trim());
url = unionDepartmentUrl.getSrcUrl();
}
logger.info("builderCommonUrl find the channelId={}", channelId);
if( StringUtils.isBlank(url))
return "";
StringBuilder targetUrl = new StringBuilder("http://union.yohobuy.com/go?client_id=");
StringBuilder targetUrl = new StringBuilder("http://union.yoho.cn/union/jump?client_id=");
targetUrl.append(channelId.trim());
targetUrl.append("&channel_code=");
targetUrl.append(uionReqVO.getTracking_code());
targetUrl.append("&append=&go_url=");
targetUrl.append(url);
targetUrl.append("?utm_source=").append(uionReqVO.getUtm_source()).append("&utm_medium=").append(uionReqVO.getUtm_medium()).append("&utm_campaign=").append(uionReqVO.getUtm_campaign());
logger.info("builderCommonUrl url is {}",targetUrl.toString());
logger.info("builderCommonUrl url is {}", targetUrl.toString());
return targetUrl.toString();
}
... ...
... ... @@ -72,7 +72,7 @@ public class UnionOrderServiceImpl implements IUnionOrderService {
return null;
}
OrderInfo orderInfo = new OrderInfo();
orderInfo.setClientId(StringUtils.isEmpty(unionOrder.getUnionid()) ? "0" : Integer.valueOf(unionOrder.getUnionid()));
orderInfo.setClientId(StringUtils.isEmpty(unionOrder.getUnionid()) ? "0" : unionOrder.getUnionid());
orderInfo.setOrderAmount(StringUtils.isEmpty(unionOrder.getOrder_amount()) ? new BigDecimal(0) : new BigDecimal(unionOrder.getOrder_amount()));
orderInfo.setOrderCode(unionOrder.getOrder_code());
orderInfo.setOrderStatus(unionOrder.getOrder_status());
... ...
... ... @@ -75,7 +75,7 @@ public class BigDataOrderInfoTask {
List<UserOrders> userOrderList = userOrdersDAO.getExistOrderCodes(orderMap.keySet());
logger.info("execute: userOrdersDAO.getExistOrderCodes: param is {}, result is {}", orderMap.keySet(), userOrderList == null ? 0 : userOrderList.size());
//按source分类
Map<Integer, List<OrderInfo>> orderInfoMap = Maps.newHashMap();
Map<String, List<OrderInfo>> orderInfoMap = Maps.newHashMap();
for (UserOrders userOrders : userOrderList) {
OrderInfo orderInfo = orderMap.get(userOrders.getOrderCode());
logger.info("execute: get orderInfo is {}", orderInfo);
... ... @@ -99,7 +99,7 @@ public class BigDataOrderInfoTask {
//应该推送的clientId
List<UnionTypeManage> unionTypeManageList = unionTypeManageDAO.selectAll();
//按source分类推送
for (Integer clientId : orderInfoMap.keySet()) {
for (String clientId : orderInfoMap.keySet()) {
if(!checkIsPush(clientId,unionTypeManageList))
continue;
IOrderPushService orderPushService = orderPushServiceMap.get(clientId);
... ... @@ -118,9 +118,9 @@ public class BigDataOrderInfoTask {
}
//是否需要推送
private boolean checkIsPush(Integer clientId,List<UnionTypeManage> unionTypeManageList){
private boolean checkIsPush(String clientId,List<UnionTypeManage> unionTypeManageList){
for(UnionTypeManage unionTypeManage : unionTypeManageList){
if(clientId.intValue() == unionTypeManage.getUnionType()){
if(clientId == unionTypeManage.getUnionType()){
if(UnionTypeStatusEnum.OPEN.getStatus().equals(unionTypeManage.getStatus())){}
return true;
}
... ...