Browse Source

增加易乾支付

周箭河 5 years ago
parent
commit
56688279f6

+ 36 - 0
mec-biz/src/main/java/com/ym/mec/biz/dal/dto/RegisterPayDto.java

@@ -0,0 +1,36 @@
+package com.ym.mec.biz.dal.dto;
+
+import java.util.Arrays;
+
+/**
+ * 学团注册支付
+ */
+public class RegisterPayDto {
+    private Integer registerId;
+    private String goodsGroupIds;
+    private String goodsIds;
+
+    public Integer getRegisterId() {
+        return registerId;
+    }
+
+    public void setRegisterId(Integer registerId) {
+        this.registerId = registerId;
+    }
+
+    public String getGoodsGroupId() {
+        return goodsGroupIds;
+    }
+
+    public void setGoodsGroupId(String goodsGroupIds) {
+        this.goodsGroupIds = goodsGroupIds;
+    }
+
+    public String getGoodsIds() {
+        return goodsIds;
+    }
+
+    public void setGoodsIds(String goodsIds) {
+        this.goodsIds = goodsIds;
+    }
+}

+ 3 - 2
mec-student/src/main/java/com/ym/mec/student/controller/RegisterController.java

@@ -3,6 +3,7 @@ package com.ym.mec.student.controller;
 import com.ym.mec.auth.api.client.SysUserFeignService;
 import com.ym.mec.auth.api.entity.SysUser;
 import com.ym.mec.biz.dal.dto.MusicGroupSubjectGoodsAndInfoDto;
+import com.ym.mec.biz.dal.dto.RegisterPayDto;
 import com.ym.mec.biz.dal.entity.*;
 import com.ym.mec.biz.service.MusicGroupService;
 import com.ym.mec.biz.service.MusicGroupSubjectPlanService;
@@ -66,8 +67,8 @@ public class RegisterController extends BaseController {
 
     @ApiOperation(value = "乐团报名支付")
     @GetMapping("/pay")
-    @ApiImplicitParams({@ApiImplicitParam(name = "musicGroupId", value = "乐团编号", required = true, dataType = "Integer")})
-    public HttpResponseResult Pay(StudentPaymentOrder studentPaymentOrder) {
+    @ApiImplicitParams({@ApiImplicitParam(name = "registerPayDto", value = "支付信息", required = true, dataType = "Integer")})
+    public HttpResponseResult pay(RegisterPayDto registerPayDto) {
         Map<String, Object> rqMap = new LinkedHashMap<String, Object>();
         rqMap.put("merNo", "07654478");
         rqMap.put("version", "v1");

BIN
mec-thirdparty/libs/SADK-3.2.5.2.jar


+ 7 - 0
mec-thirdparty/pom.xml

@@ -58,6 +58,13 @@
 			<scope>system</scope>
 			<systemPath>${project.basedir}/libs/utils-3.0.6.jar</systemPath>
 		</dependency>
+		<dependency>
+			<groupId>cfca.sadk</groupId>
+			<artifactId>cfca.sadk</artifactId>
+			<version>1.0.0</version>
+			<scope>system</scope>
+			<systemPath>${project.basedir}/libs/SADK-3.2.5.2.jar</systemPath>
+		</dependency>
 
 	</dependencies>
 

+ 288 - 0
mec-thirdparty/src/main/java/com/ym/mec/thirdparty/yqpay/CFCARAUtil.java

@@ -0,0 +1,288 @@
+package com.ym.mec.thirdparty.yqpay;
+
+import cfca.sadk.algorithm.common.Mechanism;
+import cfca.sadk.algorithm.common.PKIException;
+import cfca.sadk.lib.crypto.JCrypto;
+import cfca.sadk.system.FileHelper;
+import cfca.sadk.util.*;
+import cfca.sadk.x509.certificate.X509Cert;
+import org.springframework.core.io.ClassPathResource;
+
+import javax.crypto.spec.SecretKeySpec;
+import java.io.File;
+import java.io.FileInputStream;
+import java.security.Key;
+import java.security.KeyFactory;
+import java.security.PrivateKey;
+import java.security.PublicKey;
+import java.security.cert.CertificateFactory;
+import java.security.cert.X509Certificate;
+import java.security.spec.X509EncodedKeySpec;
+import java.util.Map;
+
+
+public class CFCARAUtil {
+    private static final String deviceName = JCrypto.JSOFT_LIB;
+    private static cfca.sadk.lib.crypto.Session session = null;
+
+
+    static {
+        try {
+            JCrypto jCrypto = JCrypto.getInstance();
+            jCrypto.initialize(deviceName, null);
+            session = jCrypto.openSession(deviceName);
+        } catch (PKIException e) {
+            e.printStackTrace();
+        }
+    }
+
+
+    /******* p1 *********/
+    /**
+     *
+     * p1消息签名
+     * @param :message
+     * @return
+     * @throws Exception
+     *
+     */
+    public static String signMessageByP1(String message, String pfxPath, String passWord) throws Exception{
+       // File file = new ClassPathResource(pfxPath).getFile();
+
+        PrivateKey userPriKey = KeyUtil.getPrivateKeyFromPFX(new ClassPathResource(pfxPath).getInputStream(), passWord);
+        Signature signature = new Signature();
+        byte[] base64P7SignedData = signature.p1SignMessage(Mechanism.SHA256_RSA, message.getBytes("UTF-8"), userPriKey, session);
+        return new String(base64P7SignedData);
+    }
+
+    /**
+     * p1消息校验(公钥证书验签)
+     * @param :beforeSignedData
+     * @param :afterSignedData
+     * @param :certPath
+     * @return
+     * @throws Exception
+     */
+    public static boolean verifyMessageByP1(String beforeSignedData, String afterSignedData, String certPath) throws Exception{
+        //File file = new ClassPathResource(certPath).getFile();
+        X509Cert cert = new X509Cert(new ClassPathResource(certPath).getInputStream());
+        PublicKey publicKey = cert.getPublicKey();
+        Signature signature = new Signature();
+        return signature.p1VerifyMessage(Mechanism.SHA256_RSA, beforeSignedData.getBytes("UTF-8"), afterSignedData.getBytes("UTF-8"), publicKey, session);
+    }
+    /**
+     * p1消息校验(公钥证书验签)
+     * @return
+     * @throws Exception
+     */
+    public static boolean verifyMessageByP1Location(String beforeSignedData, String afterSignedData, String certPath) throws Exception{
+        X509Cert cert = new X509Cert(new FileInputStream(certPath));
+        PublicKey publicKey = cert.getPublicKey();
+        Signature signature = new Signature();
+        return signature.p1VerifyMessage(Mechanism.SHA256_RSA, beforeSignedData.getBytes("UTF-8"), afterSignedData.getBytes("UTF-8"), publicKey, session);
+    }
+
+    /**
+     *
+     * p1消息校验(公钥字符串验签)
+     * @param :beforeSignedData
+     * @param :afterSignedData
+     * @param :publicKeyStr
+     * @return
+     * @throws Exception
+     *
+     */
+    public static boolean verifyMessageByP1AndPubKey(String beforeSignedData, String afterSignedData, String publicKeyStr) throws Exception{
+        KeyFactory keyFactory = KeyFactory.getInstance("RSA");
+        X509EncodedKeySpec keySpec = new X509EncodedKeySpec(Base64.decode(publicKeyStr));
+        PublicKey publicKey = keyFactory.generatePublic(keySpec);
+        Signature signature = new Signature();
+        return signature.p1VerifyMessage(Mechanism.SHA256_RSA, beforeSignedData.getBytes("UTF-8"), afterSignedData.getBytes("UTF-8"), publicKey, session);
+    }
+
+    /********* RSA_PKCS ***********/
+    /**
+     *  RSA证书加密消息
+     *  RSA_PKCS公钥加密
+     * @param :message
+     * @throws Exception
+     */
+    public static String encryptMessageByRSA_PKCS(String message, String certPath) throws Exception{
+        File file = new ClassPathResource(certPath).getFile();
+        X509Cert cert = new X509Cert(new FileInputStream(file));
+        PublicKey userPubKey = cert.getPublicKey();
+        Mechanism mechanism = new Mechanism(Mechanism.RSA_PKCS);
+        byte[] encryptedData = EncryptUtil.encrypt(mechanism, userPubKey, message.getBytes("UTF-8"), session);
+        return new String(encryptedData);
+    }
+
+    /**
+     *  RSA证书加密消息
+     *  RSA_PKCS公钥字符串加密
+     * @param :message
+     * @throws Exception
+     */
+    public static String encryptMessageByRSA_PKCS_String(String message, String publicKeyStr) throws Exception{
+        KeyFactory keyFactory = KeyFactory.getInstance("RSA");
+        X509EncodedKeySpec keySpec = new X509EncodedKeySpec(Base64.decode(publicKeyStr));
+        PublicKey userPubKey = keyFactory.generatePublic(keySpec);
+
+//        File file = new ClassPathResource(certPath).getFile();
+//        X509Cert cert = new X509Cert(new FileInputStream(file));
+//        PublicKey userPubKey = cert.getPublicKey();
+        Mechanism mechanism = new Mechanism(Mechanism.RSA_PKCS);
+        byte[] encryptedData = EncryptUtil.encrypt(mechanism, userPubKey, message.getBytes("UTF-8"), session);
+        return new String(encryptedData);
+    }
+
+    /**
+     * RSA证书解密消息
+     * RSA_PKCS私钥解密
+     * @param :key
+     * @param :message
+     * @throws Exception
+     */
+    public static String decryptMessageByRSA_PKCS(String message, String pfxPath, String passWord) throws Exception{
+        File file = new ClassPathResource(pfxPath).getFile();
+        PrivateKey userPriKey = KeyUtil.getPrivateKeyFromPFX(new FileInputStream(file), passWord);
+        Mechanism mechanism = new Mechanism(Mechanism.RSA_PKCS);
+        byte[] dataBytes = message.getBytes("UTF-8");
+        byte[] encryptedData = EncryptUtil.decrypt(mechanism, userPriKey, dataBytes, session);
+        return new String(encryptedData);
+    }
+
+    /********* RC4 **********/
+    /**
+     * RSA证书加密消息
+     * RC4对称加密
+     * @param :message
+     * @return
+     * @throws Exception
+     */
+    public static String encryptMessageByRC4(String message, String pfxPath, String passWord) throws Exception{
+        byte[] data = FileHelper.read(pfxPath);
+        Key key = new SecretKeySpec(Base64.decode(Base64.encode(data)), "RC4");
+        Mechanism mechanism = new Mechanism(Mechanism.RC4);
+        byte[] dataBytes = message.getBytes("UTF-8");
+        byte[] encryptedData = EncryptUtil.encrypt(mechanism, key, dataBytes, session);
+        return new String(encryptedData);
+
+    }
+
+    /**
+     * RSA证书解密消息
+     * RC4对称解密
+     * @param :message
+     * @return
+     * @throws Exception
+     */
+    public static String decryptMessageByRC4(String message, String pfxPath, String passWord) throws Exception{
+        byte[] data = FileHelper.read(pfxPath);
+        Key key = new SecretKeySpec(Base64.decode(Base64.encode(data)), "RC4");
+        Mechanism mechanism = new Mechanism(Mechanism.RC4);
+        byte[] encryptedData = EncryptUtil.decrypt(mechanism, key, message.getBytes("UTF-8"), session);
+        return new String(encryptedData);
+    }
+
+    /****** p7 ******/
+    /**
+     * P7 分离式文件签名(签名)
+     */
+    public static String signData(String toBeSigned, String certPath, String certPass) throws Exception {
+        X509Cert cert = CertUtil.getCertFromPFX(certPath, certPass);
+        PrivateKey priKey = KeyUtil.getPrivateKeyFromPFX(certPath, certPass);
+        Signature signature = new Signature();
+        return new String(signature.p7SignMessageDetach(Mechanism.SHA256_RSA, toBeSigned.getBytes("UTF8"), priKey, cert, session), "UTF8");
+    }
+
+    /**
+     * P7 分离式消息校验(验签)
+     */
+    public static boolean verifySignature(String data, String signdata) throws Exception {
+        Signature signature = new Signature();
+        return signature.p7VerifyMessageDetach(data.getBytes("UTF8"), signdata.getBytes("UTF8"), session);
+    }
+
+    /**
+     * 消息数字信封(公钥加密)
+     */
+    public static String encryptData(String data, String certPath) throws Exception {
+        // X509Cert cert = CertUtil.getCertFromPFX(certPath, certPass);
+        X509Cert cert = new X509Cert(new FileInputStream(certPath));
+        X509Cert[] recvcerts = new X509Cert[]{ cert };
+        return new String(EnvelopeUtil.envelopeMessage(data.getBytes("UTF8"), Mechanism.RC4, recvcerts, session), "UTF8");
+    }
+
+    /**
+     * 数据解密
+     */
+    public static String decryptData(String encryptedData, String certPath, String certPass) throws Exception {
+        PrivateKey priKey = KeyUtil.getPrivateKeyFromPFX(certPath, certPass);
+        X509Cert cert = CertUtil.getCertFromPFX(certPath, certPass);
+        return new String(EnvelopeUtil.openEvelopedMessage(encryptedData.getBytes("UTF8"), priKey, cert, session), "UTF8");
+    }
+
+
+
+    /**
+     * 拼接字符串方法
+     * @param map
+     * @param connector
+     * @return
+     */
+    public static String joinMapValue(Map<String, Object> map, char connector)	{
+        StringBuffer b = new StringBuffer();
+        for (Map.Entry<String, Object> entry : map.entrySet()){
+            b.append(entry.getKey());
+            b.append('=');
+            if (entry.getValue() != null){
+                b.append(entry.getValue());
+            }
+            b.append(connector);
+        }
+        return b.toString().substring(0, b.length()-1);
+    }
+
+
+    public static void main(String[] args) throws Exception {
+        // 实际地址,请改为项目路径
+        String pfxPath = "D:\\certificate\\168885_test.pfx";
+        // 实际地址,请改为项目路径
+        String certPath = "D:\\certificate\\168885_test.cer";
+        String password = "123123";
+        String plaintext = "幸福是你有食物吃,睡觉的地方,有所爱的人。";
+        String plaintext1 = "幸福是你有食物吃,睡觉的地方,有所爱的人";
+
+        /******* p1 ******/
+        //签名
+        String base64P7SignedData = signMessageByP1(plaintext, pfxPath, password);
+        //验签
+        boolean verifyByp1 = verifyMessageByP1(plaintext, base64P7SignedData, certPath);
+        System.out.println("p1-cert:"+verifyByp1);
+
+        //验签
+        String publicKeyStr = "MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEApSC4H4PvPuS9GJq9chCHq"
+                + "PHb+MK2dYRwVlU+9LJHhEA0mbmkhbSyvcakHuvrXtrBCBt5GMSU2BQeZy2IqQoZDJ"
+                + "Cn5CHufgMUpyMD7qvRo+GOg3GRC3k506ebb/Od/LL0eMAcCiOcCC7HHiPGP44VtBs"
+                + "OgqX22/BSAxyK93bnQbb4+8sc4id0io403rLjBle7vIzrNJtqftuTSQJMm/OmRDvf"
+                + "hg0asdUZYCsb3TdhRqO5hblDl/s/5b6gFTYcgPAw9qKdknqAWGqHP/J6i3GDAqedq"
+                + "7lFuDvkqSnYnWgVzpv9luWzrvXYOl2K4fvDSl9JIXHUMMz9cELEJjmq7yM+fQIDAQ"
+                + "AB";
+        boolean verifyByp1PublicKeyStr = verifyMessageByP1AndPubKey(plaintext, base64P7SignedData, publicKeyStr);
+        System.out.println("p1-PublicKeyStr:"+verifyByp1PublicKeyStr);
+
+        File file = new File("D:\\certificate\\168885_test.cer");
+        CertificateFactory cf = CertificateFactory.getInstance("X.509");
+        X509Certificate cert = (X509Certificate)cf.generateCertificate(new FileInputStream(file));
+        PublicKey publicKey = cert.getPublicKey();
+        String publicKeyString = Base64.toBase64String(publicKey.getEncoded());
+        System.out.println("-----------------公钥--------------------");
+        System.out.println(publicKeyString);
+        System.out.println("-----------------公钥--------------------");
+    }
+
+
+
+
+
+}

+ 384 - 0
mec-thirdparty/src/main/java/com/ym/mec/thirdparty/yqpay/DateUtils.java

@@ -0,0 +1,384 @@
+package com.ym.mec.thirdparty.yqpay;
+
+import org.apache.commons.lang3.time.DateFormatUtils;
+
+import java.text.DateFormat;
+import java.text.ParseException;
+import java.text.SimpleDateFormat;
+import java.util.ArrayList;
+import java.util.Calendar;
+import java.util.Date;
+import java.util.List;
+
+public class DateUtils extends org.apache.commons.lang3.time.DateUtils {
+	
+	private static String[] parsePatterns = {
+		"yyyy-MM-dd", "yyyy-MM-dd HH:mm:ss", "yyyy-MM-dd HH:mm", "yyyy-MM", 
+		"yyyy/MM/dd", "yyyy/MM/dd HH:mm:ss", "yyyy/MM/dd HH:mm", "yyyy/MM",
+		"yyyy.MM.dd", "yyyy.MM.dd HH:mm:ss", "yyyy.MM.dd HH:mm", "yyyy.MM"};
+
+	public static final String YYYY_MM_DD = "yyyyMMdd";
+	public static final String HH_SS_MM = "HHssmm";
+	public static final String YYYY_MM_DD_DEF = "yyyy-MM-dd";
+	public static final String YYYY_MM_DD_HH_MM_SS = "yyyyMMddHHmmss";
+	public static final String DATE_WEB_FORMAT = "yyyy-MM-dd HH:mm:ss";
+	public static final String DATE_WEB_FORMAT_NO_SS = "yyyy-MM-dd HH:mm";
+	public static final String E_MMM_DD_HH_MM_SS_Z_YYYY = "E MMM dd hh:mm:ss z yyyy";//日期格式 "Tue Sep 26 13:56:19 CST 2017"
+	public static final String YYYY_MM_DD_HH_MM_SS_SSS = "yyyyMMddHHmmssSSS";
+
+	public static void main(String[] args) {
+		getTimeOfY0(new Date());
+		int i=0;
+	}
+
+	public static String getDate() {
+		return getDate("yyyy-MM-dd");
+	}
+
+	public static String getDate(String pattern) {
+		return DateFormatUtils.format(new Date(), pattern);
+	}
+
+
+
+	public static String formatDate(Date date, Object... pattern) {
+		if (date == null)
+			return null;
+
+		String formatDate;
+		if (pattern != null && pattern.length > 0) {
+			formatDate = DateFormatUtils.format(date, pattern[0].toString());
+		} else {
+			formatDate = DateFormatUtils.format(date, "yyyy-MM-dd");
+		}
+		return formatDate;
+	}
+
+	public static String formatDateTime(Date date) {
+		return formatDate(date, "yyyy-MM-dd HH:mm:ss");
+	}
+
+	public static Date getTimeOfY0(Date date) {
+		Calendar cal = Calendar.getInstance();
+		cal.setTime(date);
+		cal.set(Calendar.MONTH, 0);
+		cal.set(Calendar.DATE, 1);
+		cal.set(Calendar.HOUR_OF_DAY, 0);
+		cal.set(Calendar.MINUTE, 0);
+		cal.set(Calendar.SECOND, 0);
+		cal.set(Calendar.MILLISECOND, 0);
+		return  cal.getTime();
+	}
+
+	public static Date getTimeOfM0(Date date) {
+		Calendar cal = Calendar.getInstance();
+		cal.setTime(date);
+		cal.set(Calendar.DATE, 1);
+		cal.set(Calendar.HOUR_OF_DAY, 0);
+		cal.set(Calendar.MINUTE, 0);
+		cal.set(Calendar.SECOND, 0);
+		cal.set(Calendar.MILLISECOND, 0);
+		return  cal.getTime();
+	}
+
+	public static Date getTimeOfD0(Date date){
+		Calendar cal = Calendar.getInstance();
+		cal.setTime(date);
+		cal.set(Calendar.HOUR_OF_DAY, 0);
+		cal.set(Calendar.MINUTE, 0);
+		cal.set(Calendar.SECOND, 0);
+		cal.set(Calendar.MILLISECOND, 0);
+		return  cal.getTime();
+	}
+
+	public static Date getTimeOfH0(Date date){
+		Calendar cal = Calendar.getInstance();
+		cal.setTime(date);
+		cal.set(Calendar.MINUTE, 0);
+		cal.set(Calendar.SECOND, 0);
+		cal.set(Calendar.MILLISECOND, 0);
+		return  cal.getTime();
+	}
+
+	public static Date getFirstTimeOfMonth(Date date){
+		Calendar cal = Calendar.getInstance();
+		cal.setTime(date);
+		cal.set(Calendar.DAY_OF_MONTH,
+				cal.getActualMinimum(Calendar.DAY_OF_MONTH));
+		cal.set(Calendar.HOUR_OF_DAY, 0);
+		cal.set(Calendar.MINUTE, 0);
+		cal.set(Calendar.SECOND, 0);
+		cal.set(Calendar.MILLISECOND, 0);
+		return  cal.getTime();
+	}
+
+	public static Date getLastTimeOfMonth(Date date){
+		Calendar cal = Calendar.getInstance();
+		cal.setTime(date);
+		cal.add(Calendar.MONTH, 1);
+		cal.set(Calendar.DAY_OF_MONTH,
+				cal.getActualMinimum(Calendar.DAY_OF_MONTH));
+		cal.set(Calendar.HOUR_OF_DAY, 0);
+		cal.set(Calendar.MINUTE, 0);
+		cal.set(Calendar.SECOND, 0);
+		cal.set(Calendar.MILLISECOND, 0);
+		return  cal.getTime();
+	}
+
+	/*是否为指定月份的最后一天*/
+	public static boolean isLastDayOfMonth(Date date) {
+		Calendar calendar = Calendar.getInstance();
+		calendar.setTime(date);
+		calendar.set(Calendar.DATE, (calendar.get(Calendar.DATE) + 1));
+		if (calendar.get(Calendar.DAY_OF_MONTH) == 1) {
+			return true;
+		}
+		return false;
+	}
+
+	/*是否为本月第一天*/
+	public static boolean isFirstDayOfThisMonth(Date date) {
+		if(date==null){
+			return false;
+		}
+		String now = formatDate(date,"yyyy-MM-dd");
+		Calendar calendar = Calendar.getInstance();
+		calendar.setTime(new Date());
+		calendar.set(Calendar.DAY_OF_MONTH,1);
+		Date firstDate = calendar.getTime();
+		String first = formatDate(firstDate,"yyyy-MM-dd");
+
+		if(now.equals(first)){
+			return true;
+		}else {
+			return false;
+		}
+	}
+
+	public static String getYearAndMonth(Date date){
+		String ym = formatDate(date,"yyyy-MM");
+		return ym;
+	}
+
+	public static String getTime() {
+		return formatDate(new Date(), "HH:mm:ss");
+	}
+
+	public static String getDateTime() {
+		return formatDate(new Date(), "yyyy-MM-dd HH:mm:ss");
+	}
+
+	public static String getYear() {
+		return formatDate(new Date(), "yyyy");
+	}
+
+	public static String getMonth() {
+		return formatDate(new Date(), "MM");
+	}
+
+	public static String getDay() {
+		return formatDate(new Date(), "dd");
+	}
+
+	public static String getHour(Date date) {
+		return formatDate(date, "HH");
+	}
+
+	public static String getWeek() {
+		return formatDate(new Date(), "E");
+	}
+	public static String getWeekByParam(Date date) {
+		return formatDate(date, "E");
+	}
+
+	public static Date parseDate(Object str) {
+		if (str == null){
+			return null;
+		}
+		try {
+			return parseDate(str.toString(), parsePatterns);
+		} catch (ParseException e) {
+			return null;
+		}
+	}
+
+	public static long pastDays(Date date) {
+		long t = new Date().getTime()-date.getTime();
+		return t/(24*60*60*1000);
+	}
+
+	public static long pastHour(Date date) {
+		long t = new Date().getTime()-date.getTime();
+		return t/(60*60*1000);
+	}
+
+	public static long pastMinutes(Date date) {
+		long t = new Date().getTime()-date.getTime();
+		return t/(60*1000);
+	}
+
+    public static String formatDateTime(long timeMillis){
+		long day = timeMillis/(24*60*60*1000);
+		long hour = (timeMillis/(60*60*1000)-day*24);
+		long min = ((timeMillis/(60*1000))-day*24*60-hour*60);
+		long s = (timeMillis/1000-day*24*60*60-hour*60*60-min*60);
+		long sss = (timeMillis-day*24*60*60*1000-hour*60*60*1000-min*60*1000-s*1000);
+		return (day>0?day+",":"")+hour+":"+min+":"+s+"."+sss;
+    }
+
+	public static double getDistanceOfTwoDate(Date before, Date after) {
+		long beforeTime = before.getTime();
+		long afterTime = after.getTime();
+		return (afterTime - beforeTime) / (1000 * 60 * 60 * 24);
+	}
+
+	/**
+	 *  日期大小比较
+	 * @param date1
+	 * @param date2
+	 * @return date2 == date1-->0
+	 * @return date2 > date1-->1
+	 * @return date2 < date1-->-1
+	 * @return -2 异常
+	 */
+	public static int dateStringCompare(Date date1,String date2) {
+		DateFormat df = new SimpleDateFormat("yyyy-MM");
+		try {
+			Date dt1 = df.parse(date2);
+			Date dt2 = df.parse(df.format(date1));;
+			if (dt1.getTime()>dt2.getTime()){
+				return  1;
+			}else if (dt1.getTime()== dt2.getTime()){
+				return  0;
+			}else {
+				return  -1;
+			}
+		} catch (ParseException e) {
+			e.printStackTrace();
+		}
+		return  2;
+	}
+
+	/**
+	 * 取得当月天数
+	 * */
+	public static int getCurrentMonthLastDay()
+	{
+		Calendar a = Calendar.getInstance();
+		a.set(Calendar.DATE, 1);
+		a.roll(Calendar.DATE, -1);
+		int maxDate = a.get(Calendar.DATE);
+		return maxDate;
+	}
+
+
+	/**
+	 * 字符串转换成日期
+	 * @param str
+	 * @param formatType
+	 * @return
+	 */
+	public static Date StrToDate(String str,String formatType) {
+
+		SimpleDateFormat format = new SimpleDateFormat(formatType);
+		Date date = null;
+		try {
+			//date = format.parse(new SimpleDateFormat(formatType).format(str));
+			date = format.parse(str);
+		} catch (ParseException e) {
+			e.printStackTrace();
+		}
+		return date;
+	}
+
+	public static List<String> getWeekend(Integer year){
+		List<String> list = new ArrayList<String>();
+		try{
+			SimpleDateFormat df=new SimpleDateFormat("yyyy-mm-dd");
+			Date date=null;
+			Calendar calendar=Calendar.getInstance();
+			int totalDay;
+			if(year % 4 == 0 && year % 100 != 0 || year % 400 == 0){//闰年的判断规则
+				totalDay=366;
+			}else{
+				totalDay=365;
+			}
+			date=df.parse(year+"-01-01");
+			Calendar cal = Calendar.getInstance();
+			cal.setTime(date);
+			for(int i=0;i<totalDay;i++){
+				if(cal.get(Calendar.DAY_OF_WEEK)==Calendar.SATURDAY||cal.get(Calendar.DAY_OF_WEEK)==Calendar.SUNDAY) {
+					list.add(DateUtils.formatDate(cal.getTime(),"yyyy-MM-dd"));
+				}
+				cal.add(Calendar.DAY_OF_MONTH,1);
+			}
+		}catch(ParseException e){
+			e.printStackTrace();
+		}
+
+		return list;
+	}
+
+	/**
+	 * 使用SimpleDateFormat类对时间字符串的合法性进行校验
+	 *
+	 * @param dateStr
+	 *            将要被校验合法性的时间字符串,格式:yyyyMMddHHmmss
+	 */
+	public static Boolean checkLegalityInClassSimpleDateFormat(String dateStr,String format) {
+		SimpleDateFormat sdf = new SimpleDateFormat(format);
+		try {
+			Date realDate = sdf.parse(dateStr);
+			if (dateStr.equals(sdf.format(realDate))) {
+				return true;
+			} else {
+				return false;
+			}
+			// System.out.println(realDate.toString());
+		} catch (ParseException e) {
+			e.printStackTrace();
+			return false;
+		}
+	}// end method - checkLegalityInClassSimpleDateFormat
+
+    /**
+     * 判断日期是否为周末
+     *
+     * @param date 入参日期
+     * @return true:为周末
+     */
+    public static boolean isWeekend(Date date) {
+        if (date == null)
+            return false;
+
+        Calendar cal = Calendar.getInstance();
+        cal.setTime(date);
+        return cal.get(Calendar.DAY_OF_WEEK) == Calendar.SUNDAY || cal.get(Calendar.DAY_OF_WEEK) == Calendar.SATURDAY;
+    }
+
+    /*
+ * 计算时间差
+ */
+    public static int getTwoDayTimes(String fromDate ,String toDate) {
+        SimpleDateFormat simpleFormat = new SimpleDateFormat("yyyy-MM-dd hh:mm:ss");
+        try {
+            long from = simpleFormat.parse(fromDate).getTime();
+            long to = simpleFormat.parse(toDate).getTime();
+            int seconds = (int) ((to - from)/(1000));
+            return seconds;
+        } catch (ParseException e) {
+            e.printStackTrace();
+            return -1;
+        }
+    }
+    
+    public static String getDayForAfter(Date d, int day){
+    	Calendar now =Calendar.getInstance();
+	    now.setTime(d);
+	    now.set(Calendar.DATE,now.get(Calendar.DATE)+day);
+	    SimpleDateFormat simpleFormat = new SimpleDateFormat("yyyy-MM-dd");
+	    return simpleFormat.format(now.getTime());
+
+    }
+
+}

+ 72 - 0
mec-thirdparty/src/main/java/com/ym/mec/thirdparty/yqpay/Intfc.java

@@ -0,0 +1,72 @@
+package com.ym.mec.thirdparty.yqpay;
+
+/**
+ * 提现信息
+ */
+
+public class Intfc {
+
+    private String wdMerNo; //提现商户号
+    private String amount; //提现金额
+    private String cardNo; //提现银行卡号
+    private String phone; //预留手机号(选填)
+    private String cardType; //卡类型 0-个人银行卡,1-企业银行卡。(选填)
+    private String seqNo; //流水号(选填)
+    private String smsCode; //验证码(选填)
+
+    public String getWdMerNo() {
+        return wdMerNo;
+    }
+
+    public void setWdMerNo(String wdMerNo) {
+        this.wdMerNo = wdMerNo;
+    }
+
+    public String getAmount() {
+        return amount;
+    }
+
+    public void setAmount(String amount) {
+        this.amount = amount;
+    }
+
+    public String getCardNo() {
+        return cardNo;
+    }
+
+    public void setCardNo(String cardNo) {
+        this.cardNo = cardNo;
+    }
+
+    public String getPhone() {
+        return phone;
+    }
+
+    public void setPhone(String phone) {
+        this.phone = phone;
+    }
+
+    public String getCardType() {
+        return cardType;
+    }
+
+    public void setCardType(String cardType) {
+        this.cardType = cardType;
+    }
+
+    public String getSeqNo() {
+        return seqNo;
+    }
+
+    public void setSeqNo(String seqNo) {
+        this.seqNo = seqNo;
+    }
+
+    public String getSmsCode() {
+        return smsCode;
+    }
+
+    public void setSmsCode(String smsCode) {
+        this.smsCode = smsCode;
+    }
+}

+ 50 - 0
mec-thirdparty/src/main/java/com/ym/mec/thirdparty/yqpay/Msg.java

@@ -0,0 +1,50 @@
+package com.ym.mec.thirdparty.yqpay;
+
+public class Msg {
+
+    private String code;
+    private String msg;
+    private String responseType;
+    private String responseParameters;
+    private String sign;
+
+    public String getCode() {
+        return code;
+    }
+
+    public void setCode(String code) {
+        this.code = code;
+    }
+
+    public String getMsg() {
+        return msg;
+    }
+
+    public void setMsg(String msg) {
+        this.msg = msg;
+    }
+
+    public String getResponseType() {
+        return responseType;
+    }
+
+    public void setResponseType(String responseType) {
+        this.responseType = responseType;
+    }
+
+    public String getResponseParameters() {
+        return responseParameters;
+    }
+
+    public void setResponseParameters(String responseParameters) {
+        this.responseParameters = responseParameters;
+    }
+
+    public String getSign() {
+        return sign;
+    }
+
+    public void setSign(String sign) {
+        this.sign = sign;
+    }
+}

+ 81 - 0
mec-thirdparty/src/main/java/com/ym/mec/thirdparty/yqpay/NotifyMsg.java

@@ -0,0 +1,81 @@
+package com.ym.mec.thirdparty.yqpay;
+
+import java.math.BigDecimal;
+
+/**
+ * 异步通知具体信息
+ */
+public class NotifyMsg {
+    private String merMerOrderNo;
+    private BigDecimal payAmount;
+    private String orderNo;
+    private String sellerNo;
+    private String buyerNo;
+    private String qyfcustUniqueNo;
+    private String tradeFee;
+    private String channelType;
+
+    public String getMerMerOrderNo() {
+        return merMerOrderNo;
+    }
+
+    public void setMerMerOrderNo(String merMerOrderNo) {
+        this.merMerOrderNo = merMerOrderNo;
+    }
+
+    public BigDecimal getPayAmount() {
+        return payAmount;
+    }
+
+    public void setPayAmount(BigDecimal payAmount) {
+        this.payAmount = payAmount;
+    }
+
+    public String getOrderNo() {
+        return orderNo;
+    }
+
+    public void setOrderNo(String orderNo) {
+        this.orderNo = orderNo;
+    }
+
+    public String getSellerNo() {
+        return sellerNo;
+    }
+
+    public void setSellerNo(String sellerNo) {
+        this.sellerNo = sellerNo;
+    }
+
+    public String getBuyerNo() {
+        return buyerNo;
+    }
+
+    public void setBuyerNo(String buyerNo) {
+        this.buyerNo = buyerNo;
+    }
+
+    public String getQyfcustUniqueNo() {
+        return qyfcustUniqueNo;
+    }
+
+    public void setQyfcustUniqueNo(String qyfcustUniqueNo) {
+        this.qyfcustUniqueNo = qyfcustUniqueNo;
+    }
+
+    public String getTradeFee() {
+        return tradeFee;
+    }
+
+    public void setTradeFee(String tradeFee) {
+        this.tradeFee = tradeFee;
+    }
+
+    public String getChannelType() {
+        return channelType;
+    }
+
+    public void setChannelType(String channelType) {
+        this.channelType = channelType;
+    }
+}

+ 68 - 0
mec-thirdparty/src/main/java/com/ym/mec/thirdparty/yqpay/RspMsg.java

@@ -0,0 +1,68 @@
+package com.ym.mec.thirdparty.yqpay;
+
+public class RspMsg {
+
+    private String merOrderNo;
+    private String merMerOrderNo;
+    private String payUrlSAO;
+    private String qrCode;
+    private String apiStr;
+    private String tradeNo;
+    private String payHtml;
+
+    public String getMerOrderNo() {
+        return merOrderNo;
+    }
+
+    public void setMerOrderNo(String merOrderNo) {
+        this.merOrderNo = merOrderNo;
+    }
+
+    public String getMerMerOrderNo() {
+        return merMerOrderNo;
+    }
+
+    public void setMerMerOrderNo(String merMerOrderNo) {
+        this.merMerOrderNo = merMerOrderNo;
+    }
+
+    public String getPayUrlSAO() {
+        return payUrlSAO;
+    }
+
+    public void setPayUrlSAO(String payUrlSAO) {
+        this.payUrlSAO = payUrlSAO;
+    }
+
+    public String getQrCode() {
+        return qrCode;
+    }
+
+    public void setQrCode(String qrCode) {
+        this.qrCode = qrCode;
+    }
+
+    public String getApiStr() {
+        return apiStr;
+    }
+
+    public void setApiStr(String apiStr) {
+        this.apiStr = apiStr;
+    }
+
+    public String getTradeNo() {
+        return tradeNo;
+    }
+
+    public void setTradeNo(String tradeNo) {
+        this.tradeNo = tradeNo;
+    }
+
+    public String getPayHtml() {
+        return payHtml;
+    }
+
+    public void setPayHtml(String payHtml) {
+        this.payHtml = payHtml;
+    }
+}

+ 50 - 0
mec-thirdparty/src/main/java/com/ym/mec/thirdparty/yqpay/YqPayUtil.java

@@ -0,0 +1,50 @@
+package com.ym.mec.thirdparty.yqpay;
+
+import com.alibaba.fastjson.JSON;
+
+import java.util.LinkedHashMap;
+import java.util.Map;
+
+public class YqPayUtil {
+
+    private String merNo = "0021677";
+    private static final String version = "1.1";
+    private String notifyUrl;
+    private String timestamp;
+    private String apiContent;
+    private static final String signType = "CFCA";
+    private String sign;
+    private Map<String, Object> resultMap;
+    private Map<String, Object> requestMap;
+
+    public YqPayUtil(String notifyUrl, Map<String, Object> resultMap) throws Exception {
+        Map<String, Object> rqMap = new LinkedHashMap<String, Object>();
+        rqMap.put("merNo", this.merNo);
+        rqMap.put("version", this.version);
+        rqMap.put("notifyUrl", notifyUrl);
+        rqMap.put("timestamp", DateUtils.getDateTime());
+        rqMap.put("apiContent", JSON.toJSONString(resultMap));
+        rqMap.put("signType", signType);
+        String beforeSignedData = CFCARAUtil.joinMapValue(rqMap, '&');
+        this.sign = CFCARAUtil.signMessageByP1(beforeSignedData, "certificate/yqpay.pfx", "aaa123123");
+        rqMap.put("sign", this.sign);
+        this.requestMap = rqMap;
+    }
+
+    public Map<String, Object> getRequestMap() {
+        return this.requestMap;
+    }
+
+    //验签
+    public static boolean verify(Map<String, Object> rsMap) {
+        String sign = (String) rsMap.get("sign");
+        rsMap.remove("sign");
+        String beforeSignedData = CFCARAUtil.joinMapValue(rsMap, '&');
+        try {
+            return CFCARAUtil.verifyMessageByP1(beforeSignedData, sign, "certificate/sq_formal_sign.cer");
+        } catch (Exception e) {
+            return false;
+        }
+    }
+
+}