Commit 69f2e867 authored by hezhen's avatar hezhen

123

parent 98792612
......@@ -57,6 +57,7 @@ public class AppUserRelationBiz extends BaseBiz<AppUserRelationMapper,AppUserRel
/**
* 关系绑定
* 规则A->B (B无有效上线+无有效下线)
* @param userId
* @param parentId
*/
......@@ -70,8 +71,6 @@ public class AppUserRelationBiz extends BaseBiz<AppUserRelationMapper,AppUserRel
if(relation==null){
relation=new AppUserRelation();
relation.setUserId(parentId);
relation.setIsForever(1);
relation.setBindTime(time);
relation.setBindType(type);
insertSelective(relation);
}
......@@ -84,8 +83,10 @@ public class AppUserRelationBiz extends BaseBiz<AppUserRelationMapper,AppUserRel
relation.setBindTime(time);
insertSelective(relation);
}else {
//用户存在父id为0的不能成为任何人下线
if((relation.getIsForever()!=1&&(time-relation.getBindTime())>validTime)){
//(B无有效上线+无有效下线)
Long bindTime=time-validTime;
log.info("----userId==="+userId+"----bindTime===="+bindTime+"----relation.getBindTime()==="+relation.getBindTime());
if((relation.getParentId()==null||relation.getParentId()==0||(relation.getIsForever()!=1&&relation.getBindTime()<bindTime))&&getCountByParentId(userId,bindTime)==0L){
relation.setParentId(parentId);
relation.setBindType(type);
relation.setBindTime(time);
......@@ -197,6 +198,28 @@ public class AppUserRelationBiz extends BaseBiz<AppUserRelationMapper,AppUserRel
return selectOne(relation);
}
//获取有效的上线
public AppUserRelation getRelationByIdUserIdAndTime(Integer userId){
AppUserRelation userRelation= getMyBiz().getRelationByUserId(userId);
if (userRelation==null){
return null;
}
log.info("---userId==="+userId+"-----isForever==="+userRelation.getIsForever());
Long time=System.currentTimeMillis()-validTime;
if (userRelation.getIsForever()==1||userRelation.getBindTime()>time){
return userRelation;
}
log.info("---userId==="+userId+"-----time==="+time+"----userRelation.getBindTime()==="+userRelation.getBindTime());
return null;
}
//获取用户的下线总数
public int getCountByParentId(Integer parentId,Long time){
Example example=new Example(AppUserRelation.class);
example.createCriteria().andEqualTo("parentId",parentId).andNotEqualTo("isForever",1).andGreaterThan("bindTime",time);
return mapper.selectCountByExample(example);
}
@CacheClear(key="user:relation{1.userId}")
public int updRelation(AppUserRelation appUserRelation){
return super.updateSelectiveByIdRe(appUserRelation);
......
......@@ -95,9 +95,9 @@ public class AppUserSellingWaterBiz extends BaseBiz<AppUserSellingWaterMapper, A
log.info("购买计算用户拥金----payOrderWater----参数不能为空----orderId===" + orderId);
return;
}
AppUserRelation relation = relationBiz.getRelationByUserId(userId);
AppUserRelation relation = relationBiz.getRelationByIdUserIdAndTime(userId);
if (relation == null || relation.getParentId() == null || relation.getParentId() == 0) {
log.info("购买计算用户拥金----payOrderWater--------userId===" + userId + "---无上线");
log.info("购买计算用户拥金----payOrderWater--------userId===" + userId + "---无有效上线");
return;
}
......
......@@ -43,9 +43,10 @@ public class AppUserRelationController extends BaseController<AppUserRelationBiz
@ApiModelProperty("app分享绑定")
public ObjectRestResponse bind(
@RequestParam(value = "code",defaultValue = "")String code,
@RequestParam(value = "userid",defaultValue = "0")Integer userid,
HttpServletRequest request){
try {
Integer userid = Integer.parseInt(userAuthUtil.getInfoFromToken(userAuthConfig.getToken(request)).getId());
//Integer userid = Integer.parseInt(userAuthUtil.getInfoFromToken(userAuthConfig.getToken(request)).getId());
return baseBiz.appBindRelation(userid,code);
} catch (Exception e) {
e.printStackTrace();
......
......@@ -86,9 +86,9 @@
SELECT g.id as `id`,g.name as `name`,g.cover as `imgUrl`,g.price,
REPLACE(GROUP_CONCAT( DISTINCT t.`name`),',','|')as name1
from tour_good g
LEFT JOIN tour_good_tag tag ON g.id=tag.good_id
LEFT JOIN tour_tag t ON tag.tag_id=t.id
where g.recommend=1 and g.status=1 and g.is_del=0 and t.is_del=0
LEFT JOIN (SELECT * FROM tour_good_tag WHERE is_del=0) tag ON g.id=tag.good_id
LEFT JOIN (SELECT * FROM tour_tag WHERE is_del=0) t ON tag.tag_id=t.id
where g.recommend=1 and g.status=1 and g.is_del=0
GROUP BY g.id
ORDER BY g.rank DESC ,g.id DESC
limit #{start,jdbcType=INTEGER},#{size,jdbcType=INTEGER}
......@@ -101,16 +101,16 @@
<!--后台查询旅游路线列表-->
<select id="findGoodList" resultMap="tourGoodVoMap">
SELECT g.*,REPLACE(GROUP_CONCAT( DISTINCT t.`name`),',','|')as tagNames from tour_good g
LEFT JOIN tour_good_tag tag ON g.id=tag.good_id
LEFT JOIN tour_tag t ON tag.tag_id=t.id
LEFT JOIN (SELECT * FROM tour_good_tag WHERE is_del=0) tag ON g.id=tag.good_id
LEFT JOIN (SELECT * FROM tour_tag WHERE is_del=0) t ON tag.tag_id=t.id
<where>
g.is_del=0 and t.is_del=0
g.is_del=0
<if test="params.name != null and params.name != ''">
and (g.`name` like CONCAT('%',#{params.name},'%') or g.introduce like CONCAT('%',#{params.name},'%'))
</if>
<if test="params.tagId != null and params.tagId != '' ">
and g.id in (SELECT good_id from tour_good_tag
where tag_id = #{params.tagId})
where tag_id = #{params.tagId} and is_del=0 )
</if>
</where>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment