Authored by mingdan.ge

补单时线上分布式获取不到opt处理

... ... @@ -9,6 +9,7 @@ import com.yoho.service.model.union.request.UserInfoBO;
import com.yoho.unions.common.Response;
import com.yoho.unions.common.constant.Constant;
import com.yoho.unions.common.enums.CodeEnum;
import com.yoho.unions.common.redis.RedisValueCache;
import com.yoho.unions.common.service.ILoginService;
import com.yoho.unions.common.utils.SessionUtil;
import org.apache.commons.lang3.StringUtils;
... ... @@ -22,6 +23,7 @@ import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;
import java.util.concurrent.TimeUnit;
/**
* 描述:
... ... @@ -37,6 +39,9 @@ public class LoginController {
@Resource
private ILoginService loginService;
@Resource
RedisValueCache redisValueCache;
private static String SALT= DynamicPropertyFactory.getInstance().getStringProperty("platform.login.salt", "").get();
@RequestMapping("/loginForPid.do")
... ... @@ -50,6 +55,7 @@ public class LoginController {
if (null != userInfoResponseBO && pid.equals(userInfoResponseBO.getPid())) {
request.setAttribute("pid", pid);
request.getRequestDispatcher(callbackUrl).forward(request, response);
addToRedis(pid, userInfoResponseBO);
} else if (pidMd5.equals(MD5.md5(pid + SALT))) {
log.info("loginForPid with session is empty. and login start. with pid={}", pid);
Response<UserInfoBO> responseBO = loginService.loginByPid(pid);
... ... @@ -60,11 +66,16 @@ public class LoginController {
request.setAttribute("pid", pid);
request.getSession().setAttribute(Constant.USER_SESSION, responseBO.getData());
request.getRequestDispatcher(callbackUrl).forward(request, response);
addToRedis(pid, userInfoResponseBO);
}
}
}
private void addToRedis(String pid,UserInfoBO userInfoResponseBO) {
redisValueCache.set("yh:union:pid:"+pid,userInfoResponseBO,300, TimeUnit.SECONDS);
}
/**
* 注销
* @param session
... ...
... ... @@ -8,8 +8,10 @@ import com.yoho.service.model.union.bo.*;
import com.yoho.service.model.union.request.*;
import com.yoho.service.model.union.response.*;
import com.yoho.unions.common.constant.Constant;
import com.yoho.unions.common.redis.RedisValueCache;
import com.yoho.unions.dal.model.*;
import com.yoho.unions.server.task.CpsNewUserActivityTask;
import org.apache.commons.lang3.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
... ... @@ -30,6 +32,7 @@ import com.yoho.unions.common.ApiResponse;
import com.yoho.unions.server.service.IUnionShareService;
import com.yoho.unions.server.task.CpsOrderExtraActivityTask;
import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpSession;
... ... @@ -52,6 +55,9 @@ public class UnionShareRest {
@Autowired
CpsNewUserActivityTask cpsNewUserActivityTask;
@Resource
RedisValueCache redisValueCache;
@RequestMapping("/getShareInfoByUid")
@ResponseBody
public ShareUserSettlementInfoBo getShareInfoByUid(@RequestBody int uid){
... ... @@ -589,12 +595,16 @@ public class UnionShareRest {
log.info("specialAward req is {}", req);
UserInfoBO userInfoBO= (UserInfoBO) session.getAttribute("userSession");
if (userInfoBO == null) {
return new UnionResponse(403, "请刷新页面重新操作");
userInfoBO=getFromredis(req.getString("pid"));
if (userInfoBO == null){
return new UnionResponse(403, "请刷新页面重新操作");
}
}
log.info("specialAward req is {},account is {}", req,userInfoBO);
boolean result = unionShareService.specialAward(req,userInfoBO);
return new UnionResponse(200, "specialAward end",result);
}
/**
* 特殊佣金状态变更
* @param req
... ... @@ -607,7 +617,10 @@ public class UnionShareRest {
log.info("specialAwardChange req is {}", req);
UserInfoBO userInfoBO= (UserInfoBO) session.getAttribute("userSession");
if (userInfoBO == null) {
return new UnionResponse(403, "请刷新页面重新操作");
userInfoBO=getFromredis(req.getString("pid"));
if (userInfoBO == null){
return new UnionResponse(403, "请刷新页面重新操作");
}
}
log.info("specialAwardChange req is {},account is {}", req,userInfoBO);
int result = unionShareService.specialAwardChange(req);
... ... @@ -802,4 +815,11 @@ public class UnionShareRest {
}
private UserInfoBO getFromredis(String pid) {
if (StringUtils.isBlank(pid)) {
return null;
}
UserInfoBO userInfoResponseBO=redisValueCache.get("yh:union:pid:"+pid,UserInfoBO.class);
return userInfoResponseBO;
}
}
... ...
... ... @@ -78,7 +78,7 @@ public class GDT2019ServiceImpl extends UnionServiceImpl implements IUnionServic
activeUnion.warn("GDT2019ServiceImpl Callback error,clickBO is {},url is {},params is {},resp is {}.",clickBO,url,params,resp);
return Pair.of(303, "GDT2019ServiceImpl Callback error");
} else if (resp.getLeft() == 200 && data.getInteger("code") == 0) {
activeUnion.warn("GDT2019ServiceImpl Callback success,clickBO is {},url is {},params is {},resp is {}.",clickBO,url,params,resp);
activeUnion.info("GDT2019ServiceImpl Callback success,clickBO is {},url is {},params is {},resp is {}.",clickBO,url,params,resp);
}
return resp;
} catch (Exception e) {
... ...
... ... @@ -668,7 +668,7 @@ public class UnionServiceImpl implements IUnionService,ApplicationEventPublisher
// 若只走老版本,把zk里的值设true且表union_type_match对应的两个条数据union_type_match改成3;
// 若只走新版本,则把表union_type_match对应的两个条数据union_type_match改成201901即可
if (finalUnionType.equals("3")&&(unionTypeMatch.getUnionType()==100000000003767L||unionTypeMatch.getUnionType()==100000000012786L)&&!configReader.getBoolean("union.gdtAuth2Close", true)) {
log.info("activateUnion call UnionServiceImpl_201901 with request is {}", request);
log.info("activateUnion call UnionServiceImpl_201901,GDT2019ServiceImpl with request is {}", request);
taskExecutor.execute(() -> {
IUnionService uniteService2 = SpringContextUtil.getBean("UnionServiceImpl_201901", IUnionService.class);
uniteService2.visitCallbackUrl(null, click);
... ...
... ... @@ -43,8 +43,23 @@
</div>
<script type="text/javascript">
var checkedItems = [];
$(function () {
function getQueryString(url,name) {
debugger;
var i=url.lastIndexOf('?');
if(i==-1)return;
var querystr=url.substr(i+1);
var arr1=querystr.split('&');
var arr2=new Object();
for (i in arr1){
var ta=arr1[i].split('=');
arr2[ta[0]]=ta[1];
}
return arr2[name];
}
var param=window.location.search;
var pid = getQueryString(param, "pid");
$(function () {
$("#userTable").myDatagrid({
fit: true,
fitColumns: true,
... ... @@ -203,6 +218,7 @@
var param = {};
param.status = $.trim(rewardStatus);
param.orderIds = $.trim(orderIds);
param.pid = pid;
$.ajax({
type: "POST",
... ... @@ -282,6 +298,7 @@
param.activityId = $.trim(activityId);
// param.status = $.trim(rewardStatus);
param.orderCodes = $.trim(orderCodes);
param.pid = pid;
var remarks = $("#remarks").val();
if (remarks != "") {
... ...