Explorar el Código

Accept Merge Request #238 merge to test : (master -> test)

Merge Request: merge to test
Created By: @albertshaw
Accepted By: @albertshaw
URL: https://coding.net/t/aft/p/AFT/git/merge/238
albertshaw hace 8 años
padre
commit
af05e3b750

+ 2 - 0
schema/20170920-member-rank-unique.sql

@@ -0,0 +1,2 @@
+ALTER TABLE `member_grade` 
+ADD UNIQUE INDEX `member_rank_UNIQUE` (`member_rank` ASC);

+ 34 - 32
src/main/java/com/goafanti/common/constant/AFTConstants.java

@@ -1,61 +1,63 @@
 package com.goafanti.common.constant;
 
 public class AFTConstants {
-	public static final String	YYYYMMDDHHMMSS					= "yyyy-MM-dd HH:mm:ss";
+	public static final String	YYYYMMDDHHMMSS						= "yyyy-MM-dd HH:mm:ss";
 
-	public static final String	YYYYMMDD						= "yyyy-MM-dd";
+	public static final String	YYYYMMDD							= "yyyy-MM-dd";
 
-	public static final String	YYYY							= "yyyy";
+	public static final String	YYYY								= "yyyy";
 
-	public static final String	MMDD							= "MM-dd";
+	public static final String	MMDD								= "MM-dd";
 
-	public static final String	INITIALPASSWORD					= "123456";				// 初始密码
+	public static final String	INITIALPASSWORD						= "123456";				// 初始密码
 
-	public static final String	SUPERADMIN						= "999999";				// 超级管理员
+	public static final String	SUPERADMIN							= "999999";				// 超级管理员
 
-	public static final String	AREAADMIN						= "99999";				// 地区管理员
+	public static final String	AREAADMIN							= "99999";				// 地区管理员
 
-	public static final String	AUDITORADMIN					= "9999";				// 审核员
+	public static final String	AUDITORADMIN						= "9999";				// 审核员
 
-	public static final String	MANAGERADMIN					= "4";					// 客户经理
+	public static final String	MANAGERADMIN						= "4";					// 客户经理
 
-	public static final String	SALESMANAGERADMIN				= "5";					// 营销经理
+	public static final String	SALESMANAGERADMIN					= "5";					// 营销经理
 
-	public static final String	SALESMANADMIN					= "6";					// 营销员
+	public static final String	SALESMANADMIN						= "6";					// 营销员
 
-	public static final String	TECHBROKER						= "7";					// 技术经纪人
+	public static final String	TECHBROKER							= "7";					// 技术经纪人
 
-	public static final String	PATENTINFO						= "专利申请管理";
+	public static final String	PATENTINFO							= "专利申请管理";
 
-	public static final String	COGNIZANCE						= "高企认定管理";
+	public static final String	COGNIZANCE							= "高企认定管理";
 
-	public static final String	COPYRIGHT						= "软著申请管理";
+	public static final String	COPYRIGHT							= "软著申请管理";
 
-	public static final String	TECHPROJECT						= "科技项目申报管理";
+	public static final String	TECHPROJECT							= "科技项目申报管理";
 
-	public static final int		KEYWORDLENTH					= 16;
+	public static final int		KEYWORDLENTH						= 16;
 
-	public static final int		IMPORTMAXLENTH					= 1000;					// 科技需求&科技成果批量导入最大数据量
+	public static final int		IMPORTMAXLENTH						= 1000;					// 科技需求&科技成果批量导入最大数据量
 
-	public static final int		PROVINCEMAXNUM					= 99;
+	public static final int		PROVINCEMAXNUM						= 99;
 
-	public static final int		CITYMAXNUM						= 999;
+	public static final int		CITYMAXNUM							= 999;
 
-	public static final Integer	ACHIEVEMENT_DEMAND_INIT_COUNT	= 0;
+	public static final Integer	ACHIEVEMENT_DEMAND_INIT_COUNT		= 0;
 
-	public static final Integer	ACHIEVEMENT_DEMAND_FIRST_COUNT	= 1;
+	public static final Integer	ACHIEVEMENT_DEMAND_FIRST_COUNT		= 1;
 
-	public static final Integer	BIG_SHOT_STAR_CACHE_KEY			= 666;
+	public static final Integer	BIG_SHOT_STAR_CACHE_KEY				= 666;
 
-	public static final Integer	BIG_SHOT_LECTURE_CACHE_KEY		= 667;
+	public static final Integer	BIG_SHOT_LECTURE_CACHE_KEY			= 667;
 
-	public static final Integer	LECTURE_DYNAMIC_LIST_CACHE_KEY	= 668;
+	public static final Integer	LECTURE_DYNAMIC_LIST_CACHE_KEY		= 668;
 
-	public static final Integer	LECTURE_LIST_CACHE_KEY			= 669;
-	
-	public static final Integer INTERNATIONAL_ACHIEVEMENT_CACHE_KEY = 670;
-	
-	public static final Integer INTERNATIONAL_USER_CACHE_KEY    = 671;
-	
-	public static final Integer INTERNATIONAL_ORG_CACHE_KEY    = 672;
+	public static final Integer	LECTURE_LIST_CACHE_KEY				= 669;
+
+	public static final Integer	INTERNATIONAL_ACHIEVEMENT_CACHE_KEY	= 670;
+
+	public static final Integer	INTERNATIONAL_USER_CACHE_KEY		= 671;
+
+	public static final Integer	INTERNATIONAL_ORG_CACHE_KEY			= 672;
+
+	public static final String	YES									= "1";
 }

+ 1 - 1
src/main/java/com/goafanti/common/controller/BaseController.java

@@ -118,10 +118,10 @@ public class BaseController {
 		model.addAttribute("shiro", SecurityUtils.getSubject());
 		model.addAttribute("isLogin", TokenManager.isLogin());
 		model.addAttribute("csrf", TokenManager.getCSRF());
+		model.addAttribute("isAdmin", false);
 		if (TokenManager.isLogin() && TokenManager.getToken() instanceof User) {
 			model.addAttribute("userData", TokenManager.getUserToken());
 			model.addAttribute("userName", TokenManager.getUserToken().getNickname());
-			model.addAttribute("isAdmin", false);
 		}
 
 		if (TokenManager.isLogin() && TokenManager.getToken() instanceof Admin) {

+ 2 - 3
src/main/java/com/goafanti/common/dao/MemberGradeMapper.java

@@ -30,7 +30,6 @@ public interface MemberGradeMapper {
 	int updateMemberOrder(Map<String, Object> map);
 
 	int delMemberOrder(Map<String, Object> map);
-
-	int updateUserLvl(Map<String, Object> map);
-
+	
+	String selectMemberBusiness(int memberRank);
 }

+ 5 - 0
src/main/java/com/goafanti/common/dao/MemberOrderMapper.java

@@ -1,5 +1,6 @@
 package com.goafanti.common.dao;
 
+import java.util.List;
 import java.util.Map;
 
 import com.goafanti.common.model.MemberOrder;
@@ -18,4 +19,8 @@ public interface MemberOrderMapper {
 	int updateByPrimaryKey(MemberOrder record);
 
 	int updateUserLvl(Map<String, Object> params);
+
+	int updateBatchUserLvl(Map<String, Object> params);
+
+	List<String> selectExpired();
 }

+ 6 - 5
src/main/java/com/goafanti/common/mapper/MemberGradeMapper.xml

@@ -128,6 +128,12 @@
 		member_order
 		WHERE  user_id=#{userId} and order_state &lt; 9
 	</select>
+	
+	<select id="selectMemberBusiness" parameterType="int"  resultType="java.lang.String">
+		SELECT business FROM
+		member_grade
+		WHERE  member_rank=#{memberRank}
+	</select>
 
 	<!-- 后台订单更改 -->
 	<update id="updateMemberOrder" parameterType="java.util.Map" >
@@ -149,9 +155,4 @@
 		<if test="uid!=null">AND user_id = #{uid}</if>
 	</update>
 
-	<!-- 更改用户会员等级 -->
-	<update id="updateUserLvl" parameterType="java.util.Map">
-		UPDATE user SET lvl=#{lvl}  WHERE id=#{userId}
-	</update>
-	
 </mapper>

+ 14 - 0
src/main/java/com/goafanti/common/mapper/MemberOrderMapperExt.xml

@@ -6,4 +6,18 @@
 		UPDATE user SET
 		lvl=#{lvl} WHERE id=#{userId}
 	</update>
+	
+	<update id="updateBatchUserLvl" parameterType="java.util.Map">
+	 	update user set lvl = #{lvl}
+	 	where id in 
+		<foreach item="item" collection="list" open="(" separator="," close=")">
+			#{item}
+		</foreach>
+	 </update>
+	
+	<select id="selectExpired" resultType="java.lang.String">
+		SELECT user_id FROM member_order 
+		where (order_state=1 or order_state=3) 
+		and valid_time &gt; CURDATE() and valid_time &lt; date_sub(CURDATE(),interval -1 day)  
+    </select>
 </mapper>

+ 26 - 0
src/main/java/com/goafanti/common/task/ExpiredUserMemberTask.java

@@ -0,0 +1,26 @@
+package com.goafanti.common.task;
+
+import javax.annotation.Resource;
+
+import org.springframework.scheduling.annotation.Scheduled;
+import org.springframework.stereotype.Component;
+
+import com.goafanti.common.utils.LoggerUtils;
+import com.goafanti.memberGrade.service.MemberOrderService;
+
+@Component
+public class ExpiredUserMemberTask {
+
+	@Resource
+	MemberOrderService memberOrderService;
+
+	/**
+	 * "0 0 1 * * ?" 每天1点触发一次
+	 */
+	@Scheduled(cron = "0 0 1 * * ?")
+	public void exprireRun() {
+		LoggerUtils.debug(getClass(), "开始检查会员到期");
+		memberOrderService.updateExpiredUser();
+	}
+
+}

+ 35 - 2
src/main/java/com/goafanti/memberGrade/controller/MemberGradeFrontController.java

@@ -5,19 +5,28 @@ import java.util.HashMap;
 import java.util.List;
 import java.util.Map;
 
+import org.apache.commons.lang3.StringUtils;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.util.Assert;
 import org.springframework.web.bind.annotation.RequestMapping;
 import org.springframework.web.bind.annotation.RequestMethod;
 import org.springframework.web.bind.annotation.RestController;
 
+import com.alibaba.fastjson.JSONObject;
 import com.goafanti.common.bo.Result;
+import com.goafanti.common.constant.AFTConstants;
 import com.goafanti.common.controller.BaseApiController;
 import com.goafanti.common.enums.OrderState;
+import com.goafanti.common.enums.UserLevel;
 import com.goafanti.common.model.MemberOrder;
+import com.goafanti.common.model.User;
+import com.goafanti.common.model.UserIdentity;
 import com.goafanti.core.mybatis.JDBCIdGenerator;
 import com.goafanti.core.shiro.token.TokenManager;
+import com.goafanti.memberGrade.bo.BusinessType;
 import com.goafanti.memberGrade.service.MemberGradeService;
+import com.goafanti.user.service.UserIdentityService;
+import com.goafanti.user.service.UserService;
 
 /**
  * 会员 前台
@@ -31,6 +40,10 @@ public class MemberGradeFrontController extends BaseApiController {
 	@Autowired
 	private MemberGradeService	memberGradeService;
 	@Autowired
+	private UserService			userService;
+	@Autowired
+	private UserIdentityService	userIdentityService;
+	@Autowired
 	private JDBCIdGenerator		jDBCIdGenerator;
 
 	/**
@@ -66,6 +79,9 @@ public class MemberGradeFrontController extends BaseApiController {
 	 */
 	@RequestMapping(value = "/addBasicsMemberOrder", method = RequestMethod.POST)
 	public Result addBasicsMemberOrder(Integer menberType, String price, Integer validMonth) {
+		Assert.notNull(TokenManager.getUserToken(), "必须用户登录");
+		User u = userService.selectByPrimaryKey(TokenManager.getUserId());
+		Assert.isTrue(u.getLvl() == 1, "必须为实名认证用户,已经是会员的无需重复申请");
 		MemberOrder mo = new MemberOrder();
 		mo.setId(jDBCIdGenerator.generateId());
 		mo.setMenberType(menberType);
@@ -73,8 +89,7 @@ public class MemberGradeFrontController extends BaseApiController {
 		mo.setValidMonth(validMonth);
 		mo.setOrderState(OrderState.UNPAYED.getCode());
 		mo.setOrderTime(new Date());
-		Assert.notNull(TokenManager.getUserToken(), "必须用户登录");
-		mo.setUserId(TokenManager.getUserId());
+		mo.setUserId(u.getId());
 		return res().data(memberGradeService.addBasicsMemberOrder(mo));
 	}
 
@@ -88,4 +103,22 @@ public class MemberGradeFrontController extends BaseApiController {
 		return res().data(memberGradeService.delMemberOrder(id));
 	}
 
+	/**
+	 * 获取专家联系手机
+	 */
+	@RequestMapping(value = "/contact", method = RequestMethod.GET)
+	public Result contact(String uid) {
+		User u = userService.selectByPrimaryKey(TokenManager.getUserId());
+		Assert.isTrue(u != null && u.getLvl() > UserLevel.CERTIFIED.getCode(), "必须是登录实名用户");
+		Assert.hasText(uid, "找不到专家");
+		JSONObject business = memberGradeService.selectMemberBusiness(u.getLvl());
+		Assert.isTrue(AFTConstants.YES.equals(business.get(BusinessType.CHA_KAN_LIAN_XI.getKey())), "该会员不能查看专家联系方式");
+		UserIdentity ui = userIdentityService.selectUserIdentityByUserId(uid);
+		if (ui != null && StringUtils.isNotBlank(ui.getContactMobile())) {
+			return res().data(ui.getContactMobile());
+		}
+		User expert = userService.selectByPrimaryKey(uid);
+		Assert.notNull(expert, "找不到专家");
+		return res().data(expert.getMobile());
+	}
 }

+ 7 - 8
src/main/java/com/goafanti/memberGrade/service/MemberGradeService.java

@@ -7,8 +7,9 @@ import java.util.Map;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 
+import com.alibaba.fastjson.JSON;
+import com.alibaba.fastjson.JSONObject;
 import com.goafanti.common.dao.MemberGradeMapper;
-import com.goafanti.common.enums.OrderState;
 import com.goafanti.common.model.MemberOrder;
 import com.goafanti.core.shiro.token.TokenManager;
 import com.goafanti.memberGrade.bo.MemberGrade;
@@ -58,13 +59,6 @@ public class MemberGradeService {
 		return memberGradeMapper.countMemberOrderWhere(map);
 	}
 
-	public void updateMemberOrder(Map<String, Object> map, Map<String, Object> umap) {
-		if (OrderState.getStatus((Integer) map.get("orderState")) == OrderState.PAYED) {
-			memberGradeMapper.updateUserLvl(umap);
-		}
-		memberGradeMapper.updateMemberOrder(map);
-	}
-
 	public int delMemberOrder(Long id) {
 		Map<String, Object> map = new HashMap<>();
 		map.put("id", id);
@@ -74,4 +68,9 @@ public class MemberGradeService {
 		return memberGradeMapper.delMemberOrder(map);
 	}
 
+	public JSONObject selectMemberBusiness(int memberRank) {
+		String b = memberGradeMapper.selectMemberBusiness(memberRank);
+		return b == null ? null : JSON.parseObject(b);
+	}
+
 }

+ 11 - 0
src/main/java/com/goafanti/memberGrade/service/MemberOrderService.java

@@ -1,6 +1,7 @@
 package com.goafanti.memberGrade.service;
 
 import java.util.HashMap;
+import java.util.List;
 import java.util.Map;
 
 import org.springframework.beans.factory.annotation.Autowired;
@@ -28,4 +29,14 @@ public class MemberOrderService {
 		}
 		return memberOrderMapper.updateByPrimaryKeySelective(mo);
 	}
+
+	public void updateExpiredUser() {
+		List<String> uids = memberOrderMapper.selectExpired();
+		if (!uids.isEmpty()) {
+			Map<String, Object> umap = new HashMap<>();
+			umap.put("lvl", 1);
+			umap.put("list", uids);
+			memberOrderMapper.updateBatchUserLvl(umap);
+		}
+	}
 }

+ 11 - 4
src/main/webapp/WEB-INF/views/common.html

@@ -162,13 +162,19 @@
 				</div>
 			</div>
 		</div>
-		<div class="pub_fix">
+		<div th:if="${!isAdmin}" class="pub_fix">
 			<span class="index_blur"></span>
 			<ul class="ret_top">
-				<li><a th:href="${basePath + '/portal/member'}"> <img
-						th:src="${portalHost+'/img/index_fix0.png'}" alt="" />
+				<li th:classappend="${!isLogin}? 'head_login'">
+					<a th:if="${!isLogin || userData.lvl == 1}" th:href="${isLogin?(basePath + '/portal/member') : 'javascript:;'}" >
+						<img th:src="${portalHost+'/img/index_fix0.png'}" alt="" />
 						<p>申请会员</p>
-				</a></li>
+					</a>
+					<a th:if="${isLogin && userData.lvl == 0}" th:href="${basePath + '/user/certify'}" >
+						<img th:src="${portalHost+'/img/index_fix0.png'}" alt="" />
+						<p>实名认证</p>
+					</a>
+				</li>
 				<li th:if="${!isLogin}"><a href=""> <img
 						th:src="${portalHost+'/img/index_fix1.png'}" alt="" />
 						<p>发布需求</p>
@@ -197,6 +203,7 @@
 			</ul>
 			<span class="index_orange"></span>
 		</div>
+		<div class="message"><span></span></div>
 	</th:block>
 	<th:block th:fragment="login">
 		<div class="login">

+ 1 - 1
src/main/webapp/WEB-INF/views/portal/member.html

@@ -64,7 +64,7 @@
 	<div class="msg"><span></span></div>
 	<div th:replace="common::footer(~{::script})">
 		<script type="text/javascript" th:src="${portalHost + '/vendors.js'}"></script>
-		<script type="text/javascript" th:src="${portalHost + '/service.js'}"></script>
+		<script type="text/javascript" th:src="${portalHost + '/member.js'}"></script>
 	</div>
 </body>
 

+ 17 - 2
src/main/webapp/WEB-INF/views/user/subscriberDetail.html

@@ -73,7 +73,7 @@
 					</div>
 					<div class="right_btn">
 						<div class="btn_right">在线咨询</div>
-						<div>线下约见</div>
+						<div id="consultBtn">线下约见</div>
 					</div>
 				</div>
 					<h3>相关智者</h3>
@@ -90,7 +90,22 @@
 			</div>
 		</div>
 	</div>
-
+	<div class="modal fade" id="myModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel">
+		<div class="modal-dialog" role="document">
+			<div class="modal-content">
+				<div class="modal-header">
+					<button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
+					<h4 class="modal-title" id="myModalLabel">咨询订单提交</h4>
+				</div>
+				<div class="modal-body" id="modal-content">
+				</div>
+				<div class="modal-footer">
+					<button type="button" class="btn btn-default" data-dismiss="modal">取消</button>
+					<button type="button" class="btn btn-primary" id="submitOrder">提交订单</button>
+				</div>
+			</div>
+		</div>
+	</div>
 	<footer>
 		<div th:replace="common::copyright"></div>
 		<div th:replace="common::login"></div>