yonge há 5 anos atrás
pai
commit
a91dc4cf1d

+ 6 - 1
mec-biz/src/main/java/com/ym/mec/biz/dal/dao/SysUserTsignDao.java

@@ -5,5 +5,10 @@ import com.ym.mec.common.dal.BaseDAO;
 
 public interface SysUserTsignDao extends BaseDAO<Integer, SysUserTsign> {
 
-	
+	/**
+	 * 根据证件号码查询
+	 * @param cardNo
+	 * @return
+	 */
+	SysUserTsign queryByCardNo(String cardNo);
 }

+ 24 - 2
mec-biz/src/main/java/com/ym/mec/biz/dal/entity/SysUserTsign.java

@@ -18,17 +18,23 @@ public class SysUserTsign {
 	/** 电子印章数据 */
 	private String sealData;
 
+	private String name;
+
+	private String cardNo;
+
 	/**  */
 	private java.util.Date createTime = new Date();
-	
+
 	public SysUserTsign() {
 		// TODO Auto-generated constructor stub
 	}
 
-	public SysUserTsign(Integer userId, String accountId, String sealData) {
+	public SysUserTsign(Integer userId, String accountId, String sealData, String name, String cardNo) {
 		this.userId = userId;
 		this.accountId = accountId;
 		this.sealData = sealData;
+		this.name = name;
+		this.cardNo = cardNo;
 	}
 
 	public void setUserId(Integer userId) {
@@ -55,6 +61,22 @@ public class SysUserTsign {
 		return this.sealData;
 	}
 
+	public String getName() {
+		return name;
+	}
+
+	public void setName(String name) {
+		this.name = name;
+	}
+
+	public String getCardNo() {
+		return cardNo;
+	}
+
+	public void setCardNo(String cardNo) {
+		this.cardNo = cardNo;
+	}
+
 	public void setCreateTime(java.util.Date createTime) {
 		this.createTime = createTime;
 	}

+ 6 - 0
mec-biz/src/main/java/com/ym/mec/biz/service/SysUserTsignService.java

@@ -5,4 +5,10 @@ import com.ym.mec.common.service.BaseService;
 
 public interface SysUserTsignService extends BaseService<Integer, SysUserTsign> {
 
+	/**
+	 * 根据证件号码查询
+	 * @param cardNo
+	 * @return
+	 */
+	SysUserTsign queryByCardNo(String cardNo);
 }

+ 54 - 24
mec-biz/src/main/java/com/ym/mec/biz/service/impl/ContractServiceImpl.java

@@ -12,6 +12,7 @@ import java.util.stream.Collectors;
 
 import org.apache.commons.io.FileUtils;
 import org.apache.commons.lang3.StringUtils;
+import org.springframework.beans.factory.InitializingBean;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.beans.factory.annotation.Value;
 import org.springframework.stereotype.Service;
@@ -51,7 +52,7 @@ import com.ym.mec.util.money.MoneyUtil;
 import com.ym.mec.util.pdf.PDFUtil;
 
 @Service
-public class ContractServiceImpl implements ContractService {
+public class ContractServiceImpl implements ContractService, InitializingBean {
 
 	@Autowired
 	private SysUserTsignService sysUserTsignService;
@@ -73,7 +74,7 @@ public class ContractServiceImpl implements ContractService {
 
 	@Autowired
 	private MusicGroupPaymentCalenderDao musicGroupPaymentCalenderDao;
-	
+
 	@Autowired
 	private MusicGroupStudentFeeDao musicGroupStudentFeeDao;
 
@@ -94,7 +95,7 @@ public class ContractServiceImpl implements ContractService {
 
 	@Autowired
 	private GoodsService goodsService;
-	
+
 	@Autowired
 	private MusicGroupService musicGroupService;
 
@@ -104,6 +105,35 @@ public class ContractServiceImpl implements ContractService {
 	private DateFormat dateFormatOss = new SimpleDateFormat("yyyy/MM/dd");
 
 	@Override
+	public void afterPropertiesSet() throws Exception {
+		// 注册企业账户
+		String orgName = "武汉长乐长风乐器销售有限公司";
+		String organCode = "91420106333619290A";
+
+		SysUserTsign sysUserTsign = sysUserTsignService.queryByCardNo(organCode);
+
+		if (sysUserTsign == null) {
+
+			String accountId = eSealPlugin.createOrganAccount(orgName, organCode);
+
+			if (StringUtils.isBlank(accountId)) {
+				throw new BizException("创建企业电子存证账户失败");
+			}
+
+			String sealData = eSealPlugin.createSeal(accountId);
+
+			if (StringUtils.isBlank(sealData)) {
+				throw new BizException("创建电子存证印章失败");
+			}
+
+			sysUserTsign = new SysUserTsign(null, accountId, sealData, orgName, organCode);
+
+			sysUserTsignService.insert(sysUserTsign);
+
+		}
+	}
+
+	@Override
 	public SysUserTsign register(Integer userId, String realName, String idCardNo, String mobileNo) {
 
 		SysUserTsign sysUserTsign = sysUserTsignService.get(userId);
@@ -122,7 +152,7 @@ public class ContractServiceImpl implements ContractService {
 				throw new BizException("创建电子存证印章失败");
 			}
 
-			sysUserTsign = new SysUserTsign(userId, accountId, sealData);
+			sysUserTsign = new SysUserTsign(userId, accountId, sealData, realName, idCardNo);
 
 			sysUserTsignService.insert(sysUserTsign);
 
@@ -281,14 +311,14 @@ public class ContractServiceImpl implements ContractService {
 		} else {
 			params.put("paymentcalender", calenders.stream().map(cal -> cal.getPaymentMonth().toString()).collect(Collectors.joining("月,")));
 		}
-		
+
 		params.put("isShowVisualSeal", false);
-		
+
 		MusicGroup musicGroup = musicGroupService.get(musicGroupId);
-		if(musicGroup == null){
+		if (musicGroup == null) {
 			throw new BizException("乐团信息没找到");
 		}
-		
+
 		params.put("ownershipType", musicGroup.getOwnershipType().name());
 
 		templateEngine.render(params, "courses.ftl", srcFile);
@@ -371,14 +401,14 @@ public class ContractServiceImpl implements ContractService {
 		} else {
 			params.put("paymentcalender", calenders.stream().map(cal -> cal.getPaymentMonth().toString()).collect(Collectors.joining("月,")));
 		}
-		
+
 		params.put("isShowVisualSeal", true);
-		
+
 		MusicGroup musicGroup = musicGroupService.get(musicGroupId);
-		if(musicGroup == null){
+		if (musicGroup == null) {
 			throw new BizException("乐团信息没找到");
 		}
-		
+
 		params.put("ownershipType", musicGroup.getOwnershipType().name());
 
 		templateEngine.render(params, "courses.ftl", srcFile);
@@ -437,9 +467,9 @@ public class ContractServiceImpl implements ContractService {
 
 		// 收费形式
 		params.put("paymentcalender", "一次性");
-		
+
 		params.put("isShowVisualSeal", false);
-		
+
 		params.put("ownershipType", "OWN");
 
 		templateEngine.render(params, "courses.ftl", srcFile);
@@ -505,9 +535,9 @@ public class ContractServiceImpl implements ContractService {
 
 		// 收费形式
 		params.put("paymentcalender", "一次性");
-		
+
 		params.put("isShowVisualSeal", true);
-		
+
 		params.put("ownershipType", "OWN");
 
 		templateEngine.render(params, "courses.ftl", srcFile);
@@ -569,14 +599,14 @@ public class ContractServiceImpl implements ContractService {
 		}
 		params.put("depositFee", musicGroupSubjectPlan.getDepositFee().doubleValue());
 		params.put("depositFeeFmt", MoneyUtil.toChinese(musicGroupSubjectPlan.getDepositFee().toString()));
-		
+
 		params.put("isShowVisualSeal", false);
-		
+
 		MusicGroup musicGroup = musicGroupService.get(musicGroupId);
-		if(musicGroup == null){
+		if (musicGroup == null) {
 			throw new BizException("乐团信息没找到");
 		}
-		
+
 		params.put("ownershipType", musicGroup.getOwnershipType().name());
 
 		templateEngine.render(params, "goods.ftl", srcFile);
@@ -646,14 +676,14 @@ public class ContractServiceImpl implements ContractService {
 		}
 		params.put("depositFee", musicGroupSubjectPlan.getDepositFee().doubleValue());
 		params.put("depositFeeFmt", MoneyUtil.toChinese(musicGroupSubjectPlan.getDepositFee().toString()));
-		
+
 		params.put("isShowVisualSeal", true);
-		
+
 		MusicGroup musicGroup = musicGroupService.get(musicGroupId);
-		if(musicGroup == null){
+		if (musicGroup == null) {
 			throw new BizException("乐团信息没找到");
 		}
-		
+
 		params.put("ownershipType", musicGroup.getOwnershipType().name());
 
 		templateEngine.render(params, "goods.ftl", srcFile);

+ 5 - 0
mec-biz/src/main/java/com/ym/mec/biz/service/impl/SysUserTsignServiceImpl.java

@@ -19,5 +19,10 @@ public class SysUserTsignServiceImpl extends BaseServiceImpl<Integer, SysUserTsi
 	public BaseDAO<Integer, SysUserTsign> getDAO() {
 		return sysUserTsignDao;
 	}
+
+	@Override
+	public SysUserTsign queryByCardNo(String cardNo) {
+		return sysUserTsignDao.queryByCardNo(cardNo);
+	}
 	
 }

+ 26 - 14
mec-biz/src/main/resources/config/mybatis/SysUserTsignMapper.xml

@@ -10,6 +10,8 @@
 		<result column="user_id_" property="userId" />
 		<result column="account_id_" property="accountId" />
 		<result column="seal_data_" property="sealData" />
+		<result column="name_" property="name" />
+		<result column="card_no_" property="cardNo" />
 		<result column="create_time_" property="createTime" />
 	</resultMap>
 	
@@ -30,25 +32,31 @@
 		SELECT SEQ_WSDEFINITION_ID.nextval AS ID FROM DUAL 
 		</selectKey>
 		-->
-		INSERT INTO sys_user_tsign (user_id_,account_id_,seal_data_,create_time_) VALUES(#{userId},#{accountId},#{sealData},#{createTime})
+		INSERT INTO sys_user_tsign (user_id_,account_id_,seal_data_,name,card_no_,create_time_) VALUES(#{userId},#{accountId},#{sealData},#{name},#{cardNo},now())
 	</insert>
 	
 	<!-- 根据主键查询一条记录 -->
 	<update id="update" parameterType="com.ym.mec.biz.dal.entity.SysUserTsign">
 		UPDATE sys_user_tsign <set>
-<if test="userId != null">
-user_id_ = #{userId},
-</if>
-<if test="accountId != null">
-account_id_ = #{accountId},
-</if>
-<if test="sealData != null">
-seal_data_ = #{sealData},
-</if>
-<if test="createTime != null">
-create_time_ = #{createTime},
-</if>
-</set> WHERE user_id_ = #{userId} 
+		<if test="userId != null">
+		user_id_ = #{userId},
+		</if>
+		<if test="accountId != null">
+		account_id_ = #{accountId},
+		</if>
+		<if test="sealData != null">
+		seal_data_ = #{sealData},
+		</if>
+		<if test="name != null">
+		name_ = #{name},
+		</if>
+		<if test="cardNo != null">
+		card_no_ = #{cardNo},
+		</if>
+		<if test="createTime != null">
+		create_time_ = #{createTime},
+		</if>
+		</set> WHERE user_id_ = #{userId} 
 	</update>
 	
 	<!-- 根据主键删除一条记录 -->
@@ -65,4 +73,8 @@ create_time_ = #{createTime},
 	<select id="queryCount" resultType="int">
 		SELECT COUNT(*) FROM sys_user_tsign
 	</select>
+	
+	<select id="queryByCardNo" resultMap="SysUserTsign">
+		SELECT * FROM sys_user_tsign where card_no_ = #{cardNo}
+	</select>
 </mapper>

+ 2 - 0
mec-common/common-core/src/main/java/com/ym/mec/common/service/impl/RedisIdGeneratorService.java

@@ -3,10 +3,12 @@ package com.ym.mec.common.service.impl;
 import com.google.common.base.Strings;
 import com.ym.mec.common.redis.service.RedisCache;
 import com.ym.mec.common.service.IdGeneratorService;
+
 import org.apache.commons.lang3.StringUtils;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.beans.factory.annotation.Value;
 import org.springframework.data.redis.core.RedisTemplate;
 import org.springframework.data.redis.core.ValueOperations;
 import org.springframework.stereotype.Service;