Authored by Ge

update

  1 +package com.yoho.unions.server.service.impl;
  2 +
  3 +import com.yoho.service.model.union.request.ActivateUnionRequestBO;
  4 +import com.yoho.service.model.union.request.ClickUnionRequestBO;
  5 +import com.yoho.unions.server.service.IUnionService;
  6 +import org.apache.commons.lang.StringUtils;
  7 +import org.slf4j.Logger;
  8 +import org.slf4j.LoggerFactory;
  9 +import org.springframework.stereotype.Service;
  10 +
  11 +import javax.servlet.http.HttpServletRequest;
  12 +import java.net.URLDecoder;
  13 +
  14 +/**
  15 + * 汇川对接
  16 + * Created by zhengwen.ge on 2017/9/21.
  17 + */
  18 +@Service("UnionServiceImpl_6")
  19 +public class HuiChuanServiceImpl extends UnionServiceImpl implements IUnionService {
  20 +
  21 + static Logger log = LoggerFactory.getLogger(HuiChuanServiceImpl.class);
  22 +
  23 + public ClickUnionRequestBO clickHttpRequestTOBO(HttpServletRequest request, ClickUnionRequestBO bo){
  24 + bo = new ClickUnionRequestBO();
  25 + String idfa = request.getParameter("IDFA_SUM");
  26 + String imei = request.getParameter("IMEI_SUM");
  27 +
  28 + bo.setIdfa(idfa);
  29 + bo.setImei(imei);
  30 +
  31 + bo.setUnion_type(request.getParameter("UNION_TYPE"));
  32 + String callBackUrl = request.getParameter("CALLBACK_URL");
  33 + bo.setCallbackurl(callBackUrl);
  34 + log.info("HuiChuan request is {}",bo);
  35 + return bo;
  36 + }
  37 +
  38 + @Override
  39 + public String getCallbackUrl(ClickUnionRequestBO clickBO, ActivateUnionRequestBO activateUnionRequestBO) {
  40 + try{
  41 + if(null!=clickBO.getCallbackurl()){
  42 + String url = URLDecoder.decode(clickBO.getCallbackurl(),"UTF-8");
  43 + return url;
  44 + }
  45 + }catch (Exception e){
  46 + log.warn("getCallbackUrl exception is {}",e.getMessage());
  47 + }
  48 + return null;
  49 + }
  50 +}
@@ -302,6 +302,14 @@ public class UnionServiceImpl implements IUnionService,ApplicationEventPublisher @@ -302,6 +302,14 @@ public class UnionServiceImpl implements IUnionService,ApplicationEventPublisher
302 } 302 }
303 value = yhValueOperations.get(key); 303 value = yhValueOperations.get(key);
304 } 304 }
  305 + if(StringUtils.isEmpty(value)){
  306 + if (ClientTypeEnum.IOS.getName().equals(request.getClient_type())) {
  307 + key = UNION_KEY + "_" + MD5.md5(request.getIdfa().toUpperCase()).toUpperCase() + "_" + request.getAppkey();
  308 + } else if (ClientTypeEnum.ANDROID.getName().equals(request.getClient_type())) {
  309 + key = UNION_KEY + "_" + MD5.md5(request.getImei().toUpperCase()).toUpperCase() + "_" + request.getAppkey();
  310 + }
  311 + value = yhValueOperations.get(key);
  312 + }
305 } 313 }
306 314
307 activeUnion.info("activateUnion with get redis first with key={}, value={}", key, value); 315 activeUnion.info("activateUnion with get redis first with key={}, value={}", key, value);