소스 검색

Merge remote-tracking branch 'origin/saas' into saas

zouxuan 3 년 전
부모
커밋
3366a90e88

+ 1 - 1
cms/src/main/java/com/ym/mec/cms/config/ResourceServerConfig.java

@@ -27,7 +27,7 @@ public class ResourceServerConfig extends ResourceServerConfigurerAdapter {
 		http.authorizeRequests()
 		.antMatchers("/task/**")
 		.hasIpAddress("0.0.0.0/0")
-				.antMatchers("/v2/api-docs", "/news/list", "/news/query", "/news/homeList", "/news/typeList")
+				.antMatchers("/v2/api-docs", "/news/list", "/news/query", "/news/homeList", "/news/typeList","/helpCenterContent/list")
 				.permitAll()
 				// 任何人不登录都可以获取的资源
 				// .antMatchers("/ipController/**").hasIpAddress("127.0.0.1") //特定ip可以不登录获取资源

+ 11 - 0
mec-biz/src/main/java/com/ym/mec/biz/dal/dao/TeacherContractsDao.java

@@ -0,0 +1,11 @@
+package com.ym.mec.biz.dal.dao;
+
+import com.ym.mec.common.dal.BaseDAO;
+import com.ym.mec.biz.dal.entity.TeacherContracts;
+
+public interface TeacherContractsDao extends BaseDAO<Long, TeacherContracts> {
+
+	TeacherContracts queryByUserId(Integer userId);
+	
+	TeacherContracts queryBySerialNo(String serialNo);
+}

+ 103 - 0
mec-biz/src/main/java/com/ym/mec/biz/dal/entity/TeacherContracts.java

@@ -0,0 +1,103 @@
+package com.ym.mec.biz.dal.entity;
+
+import org.apache.commons.lang3.builder.ToStringBuilder;
+
+/**
+ * 对应数据库表(teacher_contracts):
+ */
+public class TeacherContracts {
+
+	/**  */
+	private Long id;
+	
+	/**  */
+	private Integer userId;
+	
+	/**  */
+	private String contractNo;
+	
+	/**  */
+	private String type;
+	
+	/**  */
+	private String url;
+	
+	/**  */
+	private String serialNo;
+	
+	/**  */
+	private java.util.Date createTime;
+	
+	/**  */
+	private Integer tenantId;
+	
+	public void setId(Long id){
+		this.id = id;
+	}
+	
+	public Long getId(){
+		return this.id;
+	}
+			
+	public void setUserId(Integer userId){
+		this.userId = userId;
+	}
+	
+	public Integer getUserId(){
+		return this.userId;
+	}
+			
+	public void setContractNo(String contractNo){
+		this.contractNo = contractNo;
+	}
+	
+	public String getContractNo(){
+		return this.contractNo;
+	}
+			
+	public void setType(String type){
+		this.type = type;
+	}
+	
+	public String getType(){
+		return this.type;
+	}
+			
+	public void setUrl(String url){
+		this.url = url;
+	}
+	
+	public String getUrl(){
+		return this.url;
+	}
+			
+	public void setSerialNo(String serialNo){
+		this.serialNo = serialNo;
+	}
+	
+	public String getSerialNo(){
+		return this.serialNo;
+	}
+			
+	public void setCreateTime(java.util.Date createTime){
+		this.createTime = createTime;
+	}
+	
+	public java.util.Date getCreateTime(){
+		return this.createTime;
+	}
+			
+	public void setTenantId(Integer tenantId){
+		this.tenantId = tenantId;
+	}
+	
+	public Integer getTenantId(){
+		return this.tenantId;
+	}
+			
+	@Override
+	public String toString() {
+		return ToStringBuilder.reflectionToString(this);
+	}
+
+}

+ 14 - 0
mec-biz/src/main/java/com/ym/mec/biz/service/TeacherContractsService.java

@@ -0,0 +1,14 @@
+package com.ym.mec.biz.service;
+
+import com.ym.mec.auth.api.entity.SysUser;
+import com.ym.mec.biz.dal.entity.TeacherContracts;
+import com.ym.mec.common.service.BaseService;
+
+public interface TeacherContractsService extends BaseService<Long, TeacherContracts> {
+
+	TeacherContracts queryByUserId(Integer userId);
+	
+	boolean sign(SysUser user);
+	
+	boolean callback(String jsonStr);
+}

+ 93 - 0
mec-biz/src/main/java/com/ym/mec/biz/service/impl/TeacherContractsServiceImpl.java

@@ -0,0 +1,93 @@
+package com.ym.mec.biz.service.impl;
+
+import java.util.Date;
+
+import org.apache.commons.lang3.StringUtils;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Service;
+import org.springframework.transaction.annotation.Transactional;
+
+import com.alibaba.fastjson.JSONObject;
+import com.ym.mec.auth.api.entity.SysUser;
+import com.ym.mec.biz.dal.dao.TeacherContractsDao;
+import com.ym.mec.biz.dal.entity.TeacherContracts;
+import com.ym.mec.biz.service.TeacherContractsService;
+import com.ym.mec.common.dal.BaseDAO;
+import com.ym.mec.common.exception.BizException;
+import com.ym.mec.common.service.impl.BaseServiceImpl;
+import com.ym.mec.common.tenant.TenantContextHolder;
+import com.ym.mec.thirdparty.lingxinpay.ContractSignService;
+
+@Service
+public class TeacherContractsServiceImpl extends BaseServiceImpl<Long, TeacherContracts> implements TeacherContractsService {
+
+	private static final Logger logger = LoggerFactory.getLogger(TeacherContractsServiceImpl.class);
+
+	@Autowired
+	private TeacherContractsDao teacherContractsDao;
+
+	@Autowired
+	private ContractSignService contractSignService;
+
+	@Override
+	public BaseDAO<Long, TeacherContracts> getDAO() {
+		return teacherContractsDao;
+	}
+
+	@Override
+	public TeacherContracts queryByUserId(Integer userId) {
+		return teacherContractsDao.queryByUserId(userId);
+	}
+
+	@Override
+	@Transactional
+	public boolean sign(SysUser user) {
+
+		if (StringUtils.isBlank(user.getRealName()) || StringUtils.isBlank(user.getIdCardNo())) {
+			throw new BizException("请先实名认证");
+		}
+
+		TeacherContracts teacherContracts = new TeacherContracts();
+		teacherContracts.setUserId(user.getId());
+		teacherContracts.setCreateTime(new Date());
+		teacherContracts.setType(null);
+		teacherContracts.setTenantId(TenantContextHolder.getTenantId());
+		teacherContracts.setSerialNo(user.getId() + "_" + System.currentTimeMillis());
+
+		teacherContractsDao.insert(teacherContracts);
+
+		contractSignService.signContract(user.getRealName(), user.getIdCardNo(), user.getPhone(), teacherContracts.getSerialNo());
+
+		return true;
+	}
+
+	@Override
+	public boolean callback(String jsonStr) {
+		JSONObject jsonObject = JSONObject.parseObject(jsonStr);
+
+		String serialNo = jsonObject.getString("serialNo");
+
+		TeacherContracts teacherContracts = teacherContractsDao.queryBySerialNo(serialNo);
+		if (teacherContracts == null) {
+			return true;
+		}
+
+		if (StringUtils.equals("F", jsonObject.getString("return_code"))) {
+			teacherContractsDao.delete(teacherContracts.getId());
+			logger.error("老师签署协议回调异常:{}", jsonObject.getString("return_message"));
+			return true;
+		}
+
+		String contractResultNo = jsonObject.getString("contractResultNo");
+		String contractUrl = jsonObject.getString("contractUrl");
+
+		teacherContracts.setContractNo(contractResultNo);
+		teacherContracts.setUrl(contractUrl);
+		teacherContractsDao.update(teacherContracts);
+
+		return true;
+	}
+
+}

+ 40 - 7
mec-biz/src/main/java/com/ym/mec/biz/service/impl/TeacherServiceImpl.java

@@ -16,13 +16,7 @@ import java.util.Objects;
 import java.util.Set;
 import java.util.stream.Collectors;
 
-import com.ym.mec.biz.dal.dao.*;
-import com.ym.mec.biz.dal.dto.*;
-import com.ym.mec.biz.dal.page.*;
-
-import com.ym.mec.biz.service.TenantInfoService;
 import org.apache.commons.lang3.StringUtils;
-import org.apache.poi.ss.formula.functions.T;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.data.redis.core.RedisTemplate;
 import org.springframework.stereotype.Service;
@@ -30,9 +24,34 @@ import org.springframework.transaction.annotation.Transactional;
 import org.springframework.util.CollectionUtils;
 
 import com.alibaba.fastjson.JSONObject;
-import com.ym.mec.auth.api.client.SysUserFeignService;
 import com.ym.mec.auth.api.entity.SysUser;
 import com.ym.mec.auth.api.enums.YesOrNoEnum;
+import com.ym.mec.biz.dal.dao.ClassGroupDao;
+import com.ym.mec.biz.dal.dao.CloudTeacherDao;
+import com.ym.mec.biz.dal.dao.DemoGroupDao;
+import com.ym.mec.biz.dal.dao.ImGroupDao;
+import com.ym.mec.biz.dal.dao.ImUserFriendDao;
+import com.ym.mec.biz.dal.dao.MusicGroupDao;
+import com.ym.mec.biz.dal.dao.OrganizationDao;
+import com.ym.mec.biz.dal.dao.SchoolDao;
+import com.ym.mec.biz.dal.dao.StudentDao;
+import com.ym.mec.biz.dal.dao.StudentExtracurricularExercisesSituationDao;
+import com.ym.mec.biz.dal.dao.StudentPaymentOrderDao;
+import com.ym.mec.biz.dal.dao.StudentRegistrationDao;
+import com.ym.mec.biz.dal.dao.SubjectDao;
+import com.ym.mec.biz.dal.dao.SysUserCashAccountDao;
+import com.ym.mec.biz.dal.dao.TeacherDao;
+import com.ym.mec.biz.dal.dto.BasicUserDto;
+import com.ym.mec.biz.dal.dto.ImUserFriendDto;
+import com.ym.mec.biz.dal.dto.MusicGroupStudentApplyDto;
+import com.ym.mec.biz.dal.dto.MusicGroupTeacherAttendanceDto;
+import com.ym.mec.biz.dal.dto.MusicGroupTeachersDto;
+import com.ym.mec.biz.dal.dto.TeacherBasicDto;
+import com.ym.mec.biz.dal.dto.TeacherCloseDto;
+import com.ym.mec.biz.dal.dto.TeacherDefaultSalaryDto;
+import com.ym.mec.biz.dal.dto.TeacherExercisesServiceDto;
+import com.ym.mec.biz.dal.dto.TeacherMusicStudentOverViewDto;
+import com.ym.mec.biz.dal.dto.TeacherStudentDataDto;
 import com.ym.mec.biz.dal.entity.CourseHomework;
 import com.ym.mec.biz.dal.entity.ImUserFriend;
 import com.ym.mec.biz.dal.entity.MusicGroup;
@@ -43,8 +62,16 @@ import com.ym.mec.biz.dal.entity.StudentPaymentOrder;
 import com.ym.mec.biz.dal.entity.SysUserCashAccount;
 import com.ym.mec.biz.dal.entity.Teacher;
 import com.ym.mec.biz.dal.enums.GroupType;
+import com.ym.mec.biz.dal.page.MusicGroupTeacherAttendanceQueryInfo;
+import com.ym.mec.biz.dal.page.MusicGroupTeachersQueryInfo;
+import com.ym.mec.biz.dal.page.TeacherCloseQueryInfo;
+import com.ym.mec.biz.dal.page.TeacherNameQueryInfo;
+import com.ym.mec.biz.dal.page.TeacherQueryInfo;
+import com.ym.mec.biz.dal.page.TeacherServeQueryInfo;
+import com.ym.mec.biz.dal.page.queryMusicGroupStudentQueryInfo;
 import com.ym.mec.biz.service.ClassGroupService;
 import com.ym.mec.biz.service.TeacherService;
+import com.ym.mec.biz.service.TenantInfoService;
 import com.ym.mec.common.constant.CommonConstants;
 import com.ym.mec.common.dal.BaseDAO;
 import com.ym.mec.common.entity.ImGroupModel;
@@ -701,6 +728,12 @@ public class TeacherServiceImpl extends BaseServiceImpl<Integer, Teacher>  imple
 		teacher.setIdcardHandImg(idcardHandImg);
 		teacher.setUpdateTime(date);
 		teacherDao.update(teacher);
+		
+		user.setRealName(realName);
+		user.setIdCardNo(idcardNo);
+		user.setUpdateTime(date);
+		teacherDao.updateUser(user);
+		
 		return true;
 	}
 

+ 98 - 0
mec-biz/src/main/resources/config/mybatis/TeacherContractsMapper.xml

@@ -0,0 +1,98 @@
+<?xml version="1.0" encoding="UTF-8" ?>
+<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
+<!-- 这个文件是自动生成的。 不要修改此文件。所有改动将在下次重新自动生成时丢失。 -->
+<mapper namespace="com.ym.mec.biz.dal.dao.TeacherContractsDao">
+
+	<resultMap type="com.ym.mec.biz.dal.entity.TeacherContracts"
+		id="TeacherContracts">
+		<result column="id_" property="id" />
+		<result column="user_id_" property="userId" />
+		<result column="contract_no_" property="contractNo" />
+		<result column="type_" property="type" />
+		<result column="url_" property="url" />
+		<result column="serial_no_" property="serialNo" />
+		<result column="create_time_" property="createTime" />
+		<result column="tenant_id_" property="tenantId" />
+	</resultMap>
+
+	<!-- 根据主键查询一条记录 -->
+	<select id="get" resultMap="TeacherContracts">
+		SELECT * FROM
+		teacher_contracts WHERE id_ = #{id}
+	</select>
+
+	<!-- 全查询 -->
+	<select id="findAll" resultMap="TeacherContracts">
+		SELECT * FROM teacher_contracts
+		ORDER BY id_
+	</select>
+
+	<!-- 向数据库增加一条记录 -->
+	<insert id="insert" parameterType="com.ym.mec.biz.dal.entity.TeacherContracts"
+		useGeneratedKeys="true" keyColumn="id" keyProperty="id">
+		<!-- <selectKey resultClass="int" keyProperty="id" > SELECT SEQ_WSDEFINITION_ID.nextval 
+			AS ID FROM DUAL </selectKey> -->
+		INSERT INTO teacher_contracts
+		(id_,user_id_,contract_no_,type_,url_,serial_no_,create_time_,tenant_id_)
+		VALUES(#{id},#{userId},#{contractNo},#{type},#{url},#{serialNo},#{createTime},#{tenantId})
+	</insert>
+
+	<!-- 根据主键查询一条记录 -->
+	<update id="update" parameterType="com.ym.mec.biz.dal.entity.TeacherContracts">
+		UPDATE teacher_contracts
+		<set>
+			<if test="userId != null">
+				user_id_ = #{userId},
+			</if>
+			<if test="id != null">
+				id_ = #{id},
+			</if>
+			<if test="serialNo != null">
+				serial_no_ = #{serialNo},
+			</if>
+			<if test="url != null">
+				url_ = #{url},
+			</if>
+			<if test="tenantId != null">
+				tenant_id_ = #{tenantId},
+			</if>
+			<if test="contractNo != null">
+				contract_no_ = #{contractNo},
+			</if>
+			<if test="type != null">
+				type_ = #{type},
+			</if>
+			<if test="createTime != null">
+				create_time_ = #{createTime},
+			</if>
+		</set>
+		WHERE id_ = #{id}
+	</update>
+
+	<!-- 根据主键删除一条记录 -->
+	<delete id="delete">
+		DELETE FROM teacher_contracts WHERE id_ =
+		#{id}
+	</delete>
+
+	<!-- 分页查询 -->
+	<select id="queryPage" resultMap="TeacherContracts"
+		parameterType="map">
+		SELECT * FROM teacher_contracts ORDER BY id_
+		<include refid="global.limit" />
+	</select>
+
+	<!-- 查询当前表的总记录数 -->
+	<select id="queryCount" resultType="int">
+		SELECT COUNT(*) FROM
+		teacher_contracts
+	</select>
+
+	<select id="queryByUserId" resultMap="TeacherContracts">
+		SELECT * FROM teacher_contracts where user_id_ = #{userId}
+	</select>
+
+	<select id="queryBySerialNo" resultMap="TeacherContracts">
+		SELECT * FROM teacher_contracts where serial_no_ = #{serialNo}
+	</select>
+</mapper>

+ 1 - 1
mec-teacher/src/main/java/com/ym/mec/teacher/config/ResourceServerConfig.java

@@ -32,7 +32,7 @@ public class ResourceServerConfig extends ResourceServerConfigurerAdapter {
 				.and()
 				.authorizeRequests()
 				.antMatchers("/v2/api-docs", "/code/*", "/teacher/queryStudentApply", "/teacher/querySubByMusicGroupId", "/studentRegistration/updateSubject",
-						"/studyReport/createEvaluate", "/teacherOrder/*","/teacher/getRegisterOrPreList").permitAll().anyRequest().authenticated().and().httpBasic();
+						"/studyReport/createEvaluate", "/teacherOrder/*","/teacher/getRegisterOrPreList","/teacherContract/callback").permitAll().anyRequest().authenticated().and().httpBasic();
 	}
 
 	@Override

+ 65 - 0
mec-teacher/src/main/java/com/ym/mec/teacher/controller/TeacherContractController.java

@@ -0,0 +1,65 @@
+package com.ym.mec.teacher.controller;
+
+import io.swagger.annotations.Api;
+import io.swagger.annotations.ApiOperation;
+
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.http.HttpStatus;
+import org.springframework.web.bind.annotation.GetMapping;
+import org.springframework.web.bind.annotation.PostMapping;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RestController;
+
+import com.ym.mec.auth.api.client.SysUserFeignService;
+import com.ym.mec.auth.api.entity.SysUser;
+import com.ym.mec.biz.dal.entity.TeacherContracts;
+import com.ym.mec.biz.service.TeacherContractsService;
+import com.ym.mec.common.controller.BaseController;
+import com.ym.mec.common.entity.HttpResponseResult;
+
+@RequestMapping("teacherContract")
+@Api(tags = "教师协议服务")
+@RestController
+public class TeacherContractController extends BaseController {
+
+	@Autowired
+	private TeacherContractsService teacherContractsService;
+
+	@Autowired
+	private SysUserFeignService sysUserFeignService;
+
+	@ApiOperation(value = "是否需要签订协议")
+	@GetMapping("/isRequireSign")
+	public HttpResponseResult<Boolean> isRequireSign() {
+		SysUser sysUser = sysUserFeignService.queryUserInfo();
+		if (sysUser == null || sysUser.getId() == null) {
+			return failed(HttpStatus.FORBIDDEN, "请重新登录");
+		}
+
+		if (sysUser.getTenantId() == 1) {
+			TeacherContracts teacherContracts = teacherContractsService.queryByUserId(sysUser.getId());
+			if (teacherContracts == null) {
+				return succeed(true);
+			}
+		}
+		return succeed(false);
+	}
+
+	@ApiOperation(value = "签订协议")
+	@PostMapping("/sign")
+	public HttpResponseResult<Boolean> sign() {
+		SysUser sysUser = sysUserFeignService.queryUserInfo();
+		if (sysUser == null || sysUser.getId() == null) {
+			return failed(HttpStatus.FORBIDDEN, "请重新登录");
+		}
+
+		return succeed(teacherContractsService.sign(sysUser));
+	}
+
+	@ApiOperation(value = "异步通知")
+	@PostMapping("/callback")
+	public HttpResponseResult<String> callback(String jsonStr) {
+		teacherContractsService.callback(jsonStr);
+		return succeed("success");
+	}
+}

+ 1 - 1
mec-teacher/src/main/java/com/ym/mec/teacher/controller/TeacherController.java

@@ -182,7 +182,7 @@ public class TeacherController extends BaseController {
 			@ApiImplicitParam(name = "idcardHandImg", value = "手持身份证照", required = true, dataType = "String") })
 	public Object realNameAuthentication(String realName, String idcardNo, String idcardFrontImg, String idcardBackImg, String idcardHandImg) {
 		SysUser user = sysUserFeignService.queryUserInfo();
-		if (user == null) {
+		if (user == null || user.getId() == null) {
 			return failed(HttpStatus.FORBIDDEN, "请登录");
 		}
 		teacherService.realNameAuthentication(user.getId(), realName, idcardNo, idcardFrontImg, idcardBackImg, idcardHandImg);

+ 124 - 0
mec-thirdparty/src/main/java/com/ym/mec/thirdparty/lingxinpay/ContractSignService.java

@@ -0,0 +1,124 @@
+package com.ym.mec.thirdparty.lingxinpay;
+
+import java.io.IOException;
+import java.text.SimpleDateFormat;
+import java.util.Date;
+
+import org.apache.commons.lang3.StringUtils;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.springframework.beans.factory.annotation.Value;
+import org.springframework.stereotype.Service;
+
+import com.alibaba.fastjson.JSONObject;
+import com.alibaba.fastjson.JSONPath;
+import com.ym.mec.thirdparty.exception.ThirdpartyException;
+import com.ym.mec.util.http.HttpUtil;
+
+@Service
+public class ContractSignService {
+
+	private static final Logger logger = LoggerFactory.getLogger(ContractSignService.class);
+
+	private static String publicKey = "MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQCYT5eCY6r8sGWgbiId/VqSZmS6XkBNGMkzUqTIkpkecOzsFBxFXTQmgDeR991YfgqmyOaHsJ/ons/H+e8l+RmHsOm4eErFU+9qXFq+k195YFV1vAR9O7MIG+FR5vmLDuhgimPsgqscWhUrGinc8RUpi5KwClgx7d+d8ZJ4GmkR0QIDAQAB";
+
+	private SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
+
+	private String contractNo = "1164462240733069312";// 模板协议号
+
+	private String outMemberNo = "1491663782974988288";// 商户号
+	
+	@Value("${teacher.contract.notifyUrl:http://www.baidu.com}")
+	private String notifyUrl;
+	
+	@Value("${teacher.contract.apiUrl:http://39.107.15.64:8095}")
+	private String apiUrl;
+
+	public boolean signContract(String realName, String idcard, String mobileNo, String serialNo) {
+		JSONObject jsonObject = new JSONObject();
+		jsonObject.put("signType", "RSA");
+		jsonObject.put("service", "bpotop.zx.contract");
+		jsonObject.put("charset", "UTF-8");
+		jsonObject.put("version", "1.0");
+		jsonObject.put("createTime", sdf.format(new Date()));
+
+		jsonObject.put("outMemberNo", outMemberNo);// 公司商户号
+		jsonObject.put("serialNo", serialNo);// 流水号(商户唯一标识)
+		jsonObject.put("contractNo", contractNo);// 合同模板号
+		jsonObject.put("notifyUrl", notifyUrl);// 返回结果异步通知地址
+
+		JSONObject jsonObject2 = new JSONObject();
+		jsonObject2.put("name", realName);
+		jsonObject2.put("phone", mobileNo);
+		jsonObject2.put("identityId", idcard);
+		jsonObject2.put("citizenship", "0");
+		jsonObject2.put("signTime", sdf.format(new Date()));
+		jsonObject.put("contractSignInfo", jsonObject2);
+		String jsonStr = JSONObject.toJSONString(jsonObject);
+
+		try {
+			String encryptStr = RSA.encryptPub(jsonStr, publicKey);
+			jsonObject.put("sign", encryptStr);
+		} catch (Exception e) {
+			logger.error("加密失败", e);
+			throw new ThirdpartyException("加密失败:{}", e.getMessage());
+		}
+		logger.info("[合同签署]请求参数:{}", jsonObject.toJSONString());
+		try {
+			String s = HttpUtil.postForHttp(apiUrl + "/api/signContract", jsonObject.toJSONString(), null);
+			logger.info("请求[合同签署]响应参数:{}", s);
+
+			jsonObject = JSONObject.parseObject(s);
+			if (StringUtils.equals(jsonObject.getString("return_code"), "T")) {
+				return true;
+			}
+
+			throw new ThirdpartyException("合同签署失败:{}", jsonObject.getString("content"));
+
+		} catch (IOException e) {
+			logger.error("请求[合同签署]接口报错", e);
+			throw new ThirdpartyException("请求[合同签署]接口报错:{}", e.getMessage());
+		}
+	}
+
+	public String querySignContractResult(String serialNo) {
+		JSONObject jsonObject = new JSONObject();
+		jsonObject.put("outMemberNo", outMemberNo);
+		jsonObject.put("serialNo", serialNo);
+		jsonObject.put("contractNo", contractNo);
+		try {
+			String encryptStr = RSA.encryptPub(JSONObject.toJSONString(jsonObject), publicKey);
+			jsonObject.put("sign", encryptStr);
+		} catch (Exception e) {
+			logger.error("加密失败", e);
+			throw new ThirdpartyException("加密失败:{}", e.getMessage());
+		}
+		jsonObject.put("signType", "RSA");
+		jsonObject.put("service", "bpotop.zx.contract");
+		jsonObject.put("charset", "UTF-8");
+		jsonObject.put("version", "1.0");
+		jsonObject.put("createTime", sdf.format(new Date()));
+		try {
+			String s = HttpUtil.postForHttp(apiUrl + "/api/queryContractInfo", jsonObject.toJSONString(), null);
+
+			logger.info("[合同查询]响应参数:{}", s);
+
+			jsonObject = JSONObject.parseObject(s);
+			if (StringUtils.equals(jsonObject.getString("return_code"), "T")) {
+				return (String) JSONPath.eval(jsonObject, "$.content.contractUrl");
+			}
+
+			throw new ThirdpartyException("查询合同签署结果失败:{}", JSONPath.eval(jsonObject, "$.content.message"));
+		} catch (IOException e) {
+			logger.error("请求[合同查询]接口报错", e);
+			throw new ThirdpartyException("请求[合同查询]接口报错:{}", e.getMessage());
+		}
+	}
+
+	public static void main(String[] args) {
+		ContractSignService service = new ContractSignService();
+		// service.signContract("何亮", "130423199206192818", "17600220933","11");
+
+		service.querySignContractResult("11");
+	}
+}

+ 443 - 0
mec-thirdparty/src/main/java/com/ym/mec/thirdparty/lingxinpay/RSA.java

@@ -0,0 +1,443 @@
+package com.ym.mec.thirdparty.lingxinpay;
+
+import org.apache.commons.codec.binary.Base64;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import javax.crypto.Cipher;
+import java.io.ByteArrayOutputStream;
+import java.io.UnsupportedEncodingException;
+import java.security.*;
+import java.security.interfaces.RSAPrivateKey;
+import java.security.interfaces.RSAPublicKey;
+import java.security.spec.PKCS8EncodedKeySpec;
+import java.security.spec.X509EncodedKeySpec;
+import java.util.HashMap;
+import java.util.Map;
+
+/**
+ *
+ * <p>
+ * RSA签名,加解密处理核心文件,注意:密钥长度1024
+ * </p>
+ * 
+ * @author leelun
+ * @version $Id: RSA.java, v 0.1 2013-11-15 下午2:33:53 lilun Exp $
+ */
+public class RSA {
+
+	/**
+	 * 签名算法
+	 */
+	public static final String SIGNATURE_ALGORITHM = "SHA1withRSA";
+	/**
+	 * 加密算法RSA
+	 */
+	public static final String KEY_ALGORITHM = "RSA";
+	/**
+	 * RSA最大加密明文大小
+	 */
+	private static final int MAX_ENCRYPT_BLOCK = 117;
+
+	/**
+	 * RSA最大解密密文大小
+	 */
+	private static final int MAX_DECRYPT_BLOCK = 128;
+
+	/**
+	 * 获取公钥的key
+	 */
+	public static final String PUBLIC_KEY = "RSAPublicKey";
+
+	/**
+	 * 获取私钥的key
+	 */
+	public static final String PRIVATE_KEY = "RSAPrivateKey";
+
+	private static Logger logger = LoggerFactory.getLogger(RSA.class);
+
+	/**
+	 * <p>
+	 * 生成密钥对(公钥和私钥)
+	 * </p>
+	 *
+	 * @return
+	 * @throws Exception
+	 */
+	public static Map<String, Object> genKeyPair() throws Exception {
+		KeyPairGenerator keyPairGen = KeyPairGenerator.getInstance(KEY_ALGORITHM);
+		keyPairGen.initialize(1024);
+		KeyPair keyPair = keyPairGen.generateKeyPair();
+		RSAPublicKey publicKey = (RSAPublicKey) keyPair.getPublic();
+		RSAPrivateKey privateKey = (RSAPrivateKey) keyPair.getPrivate();
+		Map<String, Object> keyMap = new HashMap<String, Object>(2);
+		keyMap.put(PUBLIC_KEY, publicKey);
+		keyMap.put(PRIVATE_KEY, privateKey);
+		return keyMap;
+
+	}
+
+	/**
+	 * 签名字符串
+	 *
+	 * @param text
+	 *            需要签名的字符串
+	 * @param privateKey
+	 *            私钥(BASE64编码)
+	 *
+	 * @param input_charset
+	 *            编码格式
+	 * @return 签名结果(BASE64编码)
+	 */
+	public static String sign(String text, String privateKey, String charset) throws Exception {
+
+		byte[] keyBytes = Base64.decodeBase64(privateKey);
+		PKCS8EncodedKeySpec pkcs8KeySpec = new PKCS8EncodedKeySpec(keyBytes);
+		KeyFactory keyFactory = KeyFactory.getInstance(KEY_ALGORITHM);
+		PrivateKey privateK = keyFactory.generatePrivate(pkcs8KeySpec);
+		Signature signature = Signature.getInstance(SIGNATURE_ALGORITHM);
+		signature.initSign(privateK);
+		signature.update(getContentBytes(text, charset));
+		byte[] result = signature.sign();
+		return Base64.encodeBase64String(result);
+
+	}
+
+	/**
+	 * 签名字符串
+	 *
+	 * @param text
+	 *            需要签名的字符串
+	 * @param sign
+	 *            客户签名结果
+	 * @param publicKey
+	 *            公钥(BASE64编码)
+	 * @param input_charset
+	 *            编码格式
+	 * @return 验签结果
+	 */
+	public static boolean verify(String text, String sign, String publicKey, String charset) throws Exception {
+		byte[] keyBytes = Base64.decodeBase64(publicKey);
+		X509EncodedKeySpec keySpec = new X509EncodedKeySpec(keyBytes);
+		KeyFactory keyFactory = KeyFactory.getInstance(KEY_ALGORITHM);
+		PublicKey publicK = keyFactory.generatePublic(keySpec);
+
+		Signature signature = Signature.getInstance(SIGNATURE_ALGORITHM);
+		signature.initVerify(publicK);
+		signature.update(getContentBytes(text, charset));
+		return signature.verify(Base64.decodeBase64(sign));
+
+	}
+
+	/**
+	 * <P>
+	 * 私钥解密
+	 * </p>
+	 *
+	 * @param encryptedData
+	 *            已加密数据
+	 * @param privateKey
+	 *            私钥(BASE64编码)
+	 * @return
+	 * @throws Exception
+	 */
+	public static byte[] decryptByPrivateKey(byte[] encryptedData, String privateKey) throws Exception {
+		byte[] keyBytes = Base64.decodeBase64(privateKey);
+		PKCS8EncodedKeySpec pkcs8KeySpec = new PKCS8EncodedKeySpec(keyBytes);
+		KeyFactory keyFactory = KeyFactory.getInstance(KEY_ALGORITHM);
+		Key privateK = keyFactory.generatePrivate(pkcs8KeySpec);
+		Cipher cipher = Cipher.getInstance(keyFactory.getAlgorithm());
+		cipher.init(Cipher.DECRYPT_MODE, privateK);
+		int inputLen = encryptedData.length;
+		ByteArrayOutputStream out = new ByteArrayOutputStream();
+		int offSet = 0;
+		byte[] cache;
+		int i = 0;
+		// 对数据分段解密
+		while (inputLen - offSet > 0) {
+			if (inputLen - offSet > MAX_DECRYPT_BLOCK) {
+				cache = cipher.doFinal(encryptedData, offSet, MAX_DECRYPT_BLOCK);
+			} else {
+				cache = cipher.doFinal(encryptedData, offSet, inputLen - offSet);
+			}
+			out.write(cache, 0, cache.length);
+			i++;
+			offSet = i * MAX_DECRYPT_BLOCK;
+		}
+		byte[] decryptedData = out.toByteArray();
+		out.close();
+		return decryptedData;
+
+	}
+
+	/**
+	 * <p>
+	 * 公钥解密
+	 * </p>
+	 *
+	 * @param encryptedData
+	 *            已加密数据
+	 * @param publicKey
+	 *            公钥(BASE64编码)
+	 * @return
+	 * @throws Exception
+	 */
+	public static byte[] decryptByPublicKey(byte[] encryptedData, String publicKey) throws Exception {
+		byte[] keyBytes = Base64.decodeBase64(publicKey);
+		X509EncodedKeySpec x509KeySpec = new X509EncodedKeySpec(keyBytes);
+		KeyFactory keyFactory = KeyFactory.getInstance(KEY_ALGORITHM);
+		Key publicK = keyFactory.generatePublic(x509KeySpec);
+		Cipher cipher = Cipher.getInstance(keyFactory.getAlgorithm());
+		cipher.init(Cipher.DECRYPT_MODE, publicK);
+		int inputLen = encryptedData.length;
+		ByteArrayOutputStream out = new ByteArrayOutputStream();
+		int offSet = 0;
+		byte[] cache;
+		int i = 0;
+		// 对数据分段解密
+		while (inputLen - offSet > 0) {
+			if (inputLen - offSet > MAX_DECRYPT_BLOCK) {
+				cache = cipher.doFinal(encryptedData, offSet, MAX_DECRYPT_BLOCK);
+			} else {
+				cache = cipher.doFinal(encryptedData, offSet, inputLen - offSet);
+			}
+			out.write(cache, 0, cache.length);
+			i++;
+			offSet = i * MAX_DECRYPT_BLOCK;
+		}
+		byte[] decryptedData = out.toByteArray();
+		out.close();
+		return decryptedData;
+
+	}
+
+	/**
+	 * <p>
+	 * 公钥加密
+	 * </p>
+	 *
+	 * @param data
+	 *            源数据
+	 * @param publicKey
+	 *            公钥(BASE64编码)
+	 * @return
+	 * @throws Exception
+	 */
+	public static byte[] encryptByPublicKey(byte[] data, String publicKey) throws Exception {
+		byte[] keyBytes = Base64.decodeBase64(publicKey);
+		X509EncodedKeySpec x509KeySpec = new X509EncodedKeySpec(keyBytes);
+		KeyFactory keyFactory = KeyFactory.getInstance(KEY_ALGORITHM);
+		Key publicK = keyFactory.generatePublic(x509KeySpec);
+		// 对数据加密
+		Cipher cipher = Cipher.getInstance(keyFactory.getAlgorithm());
+		cipher.init(Cipher.ENCRYPT_MODE, publicK);
+		int inputLen = data.length;
+		ByteArrayOutputStream out = new ByteArrayOutputStream();
+		int offSet = 0;
+		byte[] cache;
+		int i = 0;
+		// 对数据分段加密
+		while (inputLen - offSet > 0) {
+			if (inputLen - offSet > MAX_ENCRYPT_BLOCK) {
+				cache = cipher.doFinal(data, offSet, MAX_ENCRYPT_BLOCK);
+			} else {
+				cache = cipher.doFinal(data, offSet, inputLen - offSet);
+			}
+			out.write(cache, 0, cache.length);
+			i++;
+			offSet = i * MAX_ENCRYPT_BLOCK;
+		}
+		byte[] encryptedData = out.toByteArray();
+		out.close();
+		return encryptedData;
+
+	}
+
+	/**
+	 * <p>
+	 * 私钥加密
+	 * </p>
+	 *
+	 * @param data
+	 *            源数据
+	 * @param privateKey
+	 *            私钥(BASE64编码)
+	 * @return
+	 * @throws Exception
+	 */
+	public static byte[] encryptByPrivateKey(byte[] data, String privateKey) throws Exception {
+		byte[] keyBytes = Base64.decodeBase64(privateKey);
+		PKCS8EncodedKeySpec pkcs8KeySpec = new PKCS8EncodedKeySpec(keyBytes);
+		KeyFactory keyFactory = KeyFactory.getInstance(KEY_ALGORITHM);
+		Key privateK = keyFactory.generatePrivate(pkcs8KeySpec);
+		Cipher cipher = Cipher.getInstance(keyFactory.getAlgorithm());
+		cipher.init(Cipher.ENCRYPT_MODE, privateK);
+		int inputLen = data.length;
+		ByteArrayOutputStream out = new ByteArrayOutputStream();
+		int offSet = 0;
+		byte[] cache;
+		int i = 0;
+		// 对数据分段加密
+		while (inputLen - offSet > 0) {
+			if (inputLen - offSet > MAX_ENCRYPT_BLOCK) {
+				cache = cipher.doFinal(data, offSet, MAX_ENCRYPT_BLOCK);
+			} else {
+				cache = cipher.doFinal(data, offSet, inputLen - offSet);
+			}
+			out.write(cache, 0, cache.length);
+			i++;
+			offSet = i * MAX_ENCRYPT_BLOCK;
+		}
+		byte[] encryptedData = out.toByteArray();
+		out.close();
+		return encryptedData;
+
+	}
+
+	/**
+	 * @param content
+	 * @param charset
+	 * @return
+	 * @throws SignatureException
+	 * @throws UnsupportedEncodingException
+	 */
+	private static byte[] getContentBytes(String content, String charset) {
+		if (charset == null || "".equals(charset)) {
+			return content.getBytes();
+		}
+		try {
+			return content.getBytes(charset);
+		} catch (UnsupportedEncodingException e) {
+			throw new RuntimeException("签名过程中出现错误,指定的编码集不对,您目前指定的编码集是:" + charset);
+		}
+	}
+
+	/**
+	 * <p>
+	 * 获取私钥
+	 * </p>
+	 *
+	 * @param keyMap
+	 *            密钥对
+	 * @return
+	 * @throws Exception
+	 */
+	public static String getPrivateKey(Map<String, Object> keyMap) throws Exception {
+		Key key = (Key) keyMap.get(PRIVATE_KEY);
+		return Base64.encodeBase64String(key.getEncoded());
+	}
+
+	/**
+	 * <p>
+	 * 获取公钥
+	 * </p>
+	 *
+	 * @param keyMap
+	 *            密钥对
+	 * @return
+	 * @throws Exception
+	 */
+	public static String getPublicKey(Map<String, Object> keyMap) throws Exception {
+		Key key = (Key) keyMap.get(PUBLIC_KEY);
+		return Base64.encodeBase64String(key.getEncoded());
+	}
+
+	public static void main(String[] args) throws Exception {
+		Map<String, Object> stringObjectMap = genKeyPair();
+		String publicKey = getPublicKey(stringObjectMap);
+		String privateKey = getPrivateKey(stringObjectMap);
+
+		System.out.println(publicKey);
+		System.out.println(privateKey);
+		// String jiami =
+		String jiami = "{'cardAttribute':'1','cardType':'DC','certificateNo':'340323199401163311','charset':'UTF-8','md5Key':'819ee10adc87e33486c8df1aa299c0b6','mobile':'18621542144','name':'崔','notifyUrl':'test','outMemberNo':'1136225387043356673','outerOrderNo':'111111','payAccount':'12345678','payType':'1','predictAmount':10,'projectName':'测试','salaryType':'1','service':'1dada','signType':'RSA','version':'1.0'}";
+		//String jiami = "{'cardAttribute':'1'}";
+
+		/*
+		 * byte[] bytes1 = encryptByPublicKey(jiami.getBytes(), publicKey); String bytes
+		 * = RSAUtils.decryptByPrivateKey(bytes1, privateKey);
+		 * System.out.println(bytes);
+		 */
+
+		/*
+		 * byte[] encryptPub = encryptByPublicKey(jiami.getBytes(), publicKey); byte[]
+		 * decryptPri =
+		 * decryptByPrivateKey(Base64.decodeBase64(Base64.encodeBase64(encryptPub)),
+		 * privateKey); System.out.println(decryptPri);
+		 */
+		/*String encryptPub = encryptPub(jiami, publicKey);
+		String decryptPri = decryptPri(encryptPub, privateKey);
+*/
+		String encryptPub = encryptPub(jiami, publicKey);
+		String decryptPri = decryptPri(encryptPub, privateKey);
+		System.out.println(decryptPri);
+
+	}
+
+	public static String encryptPub(String str, String publicKey) throws Exception {
+		// base64编码的公钥
+		byte[] decoded = Base64.decodeBase64(publicKey);
+		RSAPublicKey pubKey = (RSAPublicKey) KeyFactory.getInstance("RSA")
+				.generatePublic(new X509EncodedKeySpec(decoded));
+		// RSA加密
+		Cipher cipher = Cipher.getInstance("RSA");
+		cipher.init(Cipher.ENCRYPT_MODE, pubKey);
+		int inputLen = str.getBytes("utf-8").length;
+		ByteArrayOutputStream out = new ByteArrayOutputStream();
+		int offSet = 0;
+		byte[] cache;
+		int i = 0;
+		// 对数据分段加密
+		while (inputLen - offSet > 0) {
+			if (inputLen - offSet > MAX_ENCRYPT_BLOCK) {
+				cache = cipher.doFinal(str.getBytes("UTF-8"), offSet, MAX_ENCRYPT_BLOCK);
+			} else {
+				cache = cipher.doFinal(str.getBytes("UTF-8"), offSet, inputLen - offSet);
+			}
+			out.write(cache, 0, cache.length);
+			i++;
+			offSet = i * MAX_ENCRYPT_BLOCK;
+		}
+		byte[] encryptedData = out.toByteArray();
+		out.close();
+		// String outStr =
+		// Base64.encodeBase64String(cipher.doFinal(str.getBytes("UTF-8")));
+		String outStr = Base64.encodeBase64String(encryptedData);
+		return outStr;
+	}
+
+	public static String decryptPri(String str, String privateKey) throws Exception {
+		// 64位解码加密后的字符串
+		byte[] inputByte = Base64.decodeBase64(str.getBytes("UTF-8"));
+		// base64编码的私钥
+		byte[] decoded = Base64.decodeBase64(privateKey);
+		RSAPrivateKey priKey = (RSAPrivateKey) KeyFactory.getInstance("RSA")
+				.generatePrivate(new PKCS8EncodedKeySpec(decoded));
+		// RSA解密
+		Cipher cipher = Cipher.getInstance("RSA");
+		cipher.init(Cipher.DECRYPT_MODE, priKey);
+
+		int inputLen = inputByte.length;
+		ByteArrayOutputStream out = new ByteArrayOutputStream();
+		int offSet = 0;
+		byte[] cache;
+		int i = 0;
+		// 对数据分段解密
+		while (inputLen - offSet > 0) {
+			if (inputLen - offSet > MAX_DECRYPT_BLOCK) {
+				cache = cipher.doFinal(inputByte, offSet, MAX_DECRYPT_BLOCK);
+			} else {
+				cache = cipher.doFinal(inputByte, offSet, inputLen - offSet);
+			}
+			out.write(cache, 0, cache.length);
+			i++;
+			offSet = i * MAX_DECRYPT_BLOCK;
+		}
+		byte[] decryptedData = out.toByteArray();
+		out.close();
+		// String outStr = new String(cipher.doFinal(inputByte));
+		String outStr = new String(decryptedData);
+		return outStr;
+	}
+
+}

+ 43 - 0
mec-web/src/main/java/com/ym/mec/web/controller/TeacherContractController.java

@@ -0,0 +1,43 @@
+package com.ym.mec.web.controller;
+
+import io.swagger.annotations.Api;
+import io.swagger.annotations.ApiImplicitParam;
+import io.swagger.annotations.ApiImplicitParams;
+import io.swagger.annotations.ApiOperation;
+import io.swagger.annotations.ApiParam;
+
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.security.access.prepost.PreAuthorize;
+import org.springframework.web.bind.annotation.GetMapping;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RestController;
+
+import com.ym.mec.biz.service.TeacherContractsService;
+import com.ym.mec.common.controller.BaseController;
+import com.ym.mec.common.page.QueryInfo;
+
+@RequestMapping("teacherContract")
+@Api(tags = "教师协议服务")
+@RestController
+public class TeacherContractController extends BaseController {
+
+    @Autowired
+    private TeacherContractsService teacherContractsService;
+
+    @ApiOperation(value = "分页查询协议列表")
+    @GetMapping("/queryPage")
+    @PreAuthorize("@pcs.hasPermissions('teacherContract/queryPage')")
+    public Object queryPage(QueryInfo queryInfo) {
+        return succeed(teacherContractsService.queryPage(queryInfo));
+    }
+
+    @ApiOperation(value = "根据教师编号查询教师协议")
+    @GetMapping("/get")
+    @ApiParam(value = "教师编号", required = true)
+    @PreAuthorize("@pcs.hasPermissions('teacherContract/get')")
+    @ApiImplicitParams({@ApiImplicitParam(name = "teacherId", value = "教师编号", required = true, dataType = "Integer")})
+    public Object get(Integer teacherId) {
+        return succeed(teacherContractsService.queryByUserId(teacherId));
+    }
+    
+}