杨杰 4 anni fa
parent
commit
5743b95511

+ 9 - 18
pom.xml

@@ -24,28 +24,10 @@
 
 	<dependencies>
 		<dependency>
-			<groupId>com.llisoft</groupId>
-			<artifactId>mta-common</artifactId>
-			<version>3.9.2-SNAPSHOT</version>
-		</dependency>
-		<dependency>
-			<groupId>org.springframework.cloud</groupId>
-			<artifactId>spring-cloud-starter-netflix-eureka-client</artifactId>
-		</dependency>
-		<dependency>
-            <groupId>org.springframework.cloud</groupId>
-            <artifactId>spring-cloud-starter-openfeign</artifactId>
-        </dependency>
-		<dependency>
 			<groupId>org.springframework.boot</groupId>
 			<artifactId>spring-boot-starter-web</artifactId>
 		</dependency>
 		<dependency>
-			<groupId>de.codecentric</groupId>
-			<artifactId>spring-boot-admin-starter-client</artifactId>
-			<version>2.0.1</version>
-		</dependency>
-		<dependency>
 			<groupId>org.mybatis.spring.boot</groupId>
 			<artifactId>mybatis-spring-boot-starter</artifactId>
 			<version>2.0.0</version>
@@ -59,6 +41,15 @@
 			<artifactId>alipay-sdk-java</artifactId>
 			<version>3.1.0</version>
 		</dependency>
+		<dependency><!-- jackson解析xml -->
+			<groupId>com.fasterxml.jackson.dataformat</groupId>
+			<artifactId>jackson-dataformat-xml</artifactId>
+		</dependency>
+		<dependency><!-- http工具 -->
+			<groupId>com.squareup.okhttp3</groupId>
+			<artifactId>okhttp</artifactId>
+		</dependency>
+		
 		<dependency>
 			<groupId>io.springfox</groupId>
 			<artifactId>springfox-swagger2</artifactId>

+ 0 - 4
src/main/java/com/llisoft/pay/Application.java

@@ -4,11 +4,7 @@ import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 import org.springframework.boot.SpringApplication;
 import org.springframework.boot.autoconfigure.SpringBootApplication;
-import org.springframework.cloud.netflix.eureka.EnableEurekaClient;
-import org.springframework.cloud.openfeign.EnableFeignClients;
 
-@EnableFeignClients // 启用feign
-@EnableEurekaClient // 注册中心客户端 同类注解 @EnableDiscoveryClient
 @SpringBootApplication
 public class Application {
 	

+ 2 - 3
src/main/java/com/llisoft/pay/controller/AliPayController.java

@@ -14,7 +14,6 @@ import org.springframework.web.bind.annotation.PostMapping;
 import org.springframework.web.bind.annotation.RequestMapping;
 import org.springframework.web.bind.annotation.ResponseBody;
 
-import com.llisoft.common.exception.MtaException;
 import com.llisoft.pay.service.AliPayService;
 
 import io.swagger.annotations.Api;
@@ -41,7 +40,7 @@ public class AliPayController {
 				logger.info("支付宝同步回调处理成功!");
 				return "redirect:/pay/"+resultMap.get("out_trade_no")+"/ok";
 			}
-		} catch (MtaException e) {
+		} catch (Exception e) {
 			e.printStackTrace();
 		}
 		logger.error("支付宝同步回调处理失败!");
@@ -58,7 +57,7 @@ public class AliPayController {
 				logger.info("支付宝异步通知处理成功!");
 				return "success";
 			}
-		} catch (MtaException e) {
+		} catch (Exception e) {
 			e.printStackTrace();
 		}
 		logger.error("支付宝异步通知处理失败!");

+ 2 - 2
src/main/java/com/llisoft/pay/controller/OrderController.java

@@ -10,15 +10,15 @@ import org.springframework.web.bind.annotation.RequestBody;
 import org.springframework.web.bind.annotation.RequestMapping;
 import org.springframework.web.bind.annotation.RestController;
 
-import com.llisoft.common.util.JsonUtil;
-import com.llisoft.common.vo.ResponseVo;
 import com.llisoft.pay.service.OrderService;
+import com.llisoft.pay.util.JsonUtil;
 import com.llisoft.pay.vo.OrderAddRequestVo;
 import com.llisoft.pay.vo.OrderAddResponseVo;
 import com.llisoft.pay.vo.OrderInfoRequestVo;
 import com.llisoft.pay.vo.OrderInfoResponseVo;
 import com.llisoft.pay.vo.OrderPayRequestVo;
 import com.llisoft.pay.vo.OrderPayResponseVo;
+import com.llisoft.pay.vo.ResponseVo;
 
 import io.swagger.annotations.Api;
 import io.swagger.annotations.ApiOperation;

+ 1 - 1
src/main/java/com/llisoft/pay/controller/WxPayController.java

@@ -16,8 +16,8 @@ import org.springframework.web.bind.annotation.PostMapping;
 import org.springframework.web.bind.annotation.RequestMapping;
 import org.springframework.web.bind.annotation.ResponseBody;
 
-import com.llisoft.common.util.XmlUtil;
 import com.llisoft.pay.service.WxPayService;
+import com.llisoft.pay.util.XmlUtil;
 
 import io.swagger.annotations.Api;
 import io.swagger.annotations.ApiOperation;

+ 2 - 2
src/main/java/com/llisoft/pay/service/AliPayService.java

@@ -22,8 +22,8 @@ import com.alipay.api.internal.util.AlipaySignature;
 import com.alipay.api.request.AlipayTradePagePayRequest;
 import com.alipay.api.request.AlipayTradeQueryRequest;
 import com.alipay.api.request.AlipayTradeWapPayRequest;
-import com.llisoft.common.util.DecimalUtil;
-import com.llisoft.common.util.JsonUtil;
+import com.llisoft.pay.util.DecimalUtil;
+import com.llisoft.pay.util.JsonUtil;
 
 /**
  * 支付宝支付

+ 3 - 4
src/main/java/com/llisoft/pay/service/AppService.java

@@ -5,7 +5,6 @@ import java.util.Objects;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 
-import com.llisoft.common.exception.MtaException;
 import com.llisoft.pay.dao.AppDao;
 import com.llisoft.pay.entity.App;
 
@@ -20,12 +19,12 @@ public class AppService {
 	 * 获取
 	 * @param appKey
 	 * @return
-	 * @throws MtaException 
+	 * @throws Exception 
 	 */
-	public App get(String appKey) throws MtaException{
+	public App get(String appKey) throws Exception{
 		App app = appDao.selectByAppKey(appKey);
 		if (Objects.isNull(app)) {
-			throw new MtaException("APP不存在: " + appKey);
+			throw new Exception("APP不存在: " + appKey);
 		}
 		return app;
 	}

+ 8 - 9
src/main/java/com/llisoft/pay/service/OrderService.java

@@ -7,12 +7,11 @@ import org.slf4j.LoggerFactory;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 
-import com.llisoft.common.exception.MtaException;
-import com.llisoft.common.util.BeanUtil;
-import com.llisoft.common.util.CodeUtil;
 import com.llisoft.pay.dao.OrderDao;
 import com.llisoft.pay.entity.App;
 import com.llisoft.pay.entity.Order;
+import com.llisoft.pay.util.BeanUtil;
+import com.llisoft.pay.util.CodeUtil;
 import com.llisoft.pay.vo.OrderAddResponseVo;
 import com.llisoft.pay.vo.OrderInfoResponseVo;
 import com.llisoft.pay.vo.OrderPayResponseVo;
@@ -42,13 +41,13 @@ public class OrderService {
 	 * @param orderMoney 订单金额(分)
 	 * @param orderTitle 标题(如果客户端没有传会使用app的name)
 	 * @return
-	 * @throws MtaException 
+	 * @throws Exception 
 	 */
-	public OrderAddResponseVo add(String appKey, int orderMoney, String orderTitle) throws MtaException{
+	public OrderAddResponseVo add(String appKey, int orderMoney, String orderTitle) throws Exception{
 		// 验证appKey合法性
 		App app = appService.get(appKey);
 		if (Objects.isNull(app)) {
-			throw new MtaException("appKey不存在: " + appKey);
+			throw new Exception("appKey不存在: " + appKey);
 		}
 		// 生成订单号, 当前时间+5位随机数
 		String orderNum = CodeUtil.time();
@@ -75,12 +74,12 @@ public class OrderService {
 	 * @param orderNum
 	 * @param payType
 	 * @return
-	 * @throws MtaException
+	 * @throws Exception
 	 */
-	public OrderPayResponseVo pay(String orderNum, byte payType, boolean isMobile) throws MtaException{
+	public OrderPayResponseVo pay(String orderNum, byte payType, boolean isMobile) throws Exception{
 		Order order = orderDao.selectByOrderNum(orderNum);
 		if(order.getOrderStatus() == STATUS_PAYED){
-			throw new MtaException("订单已经支付过: " + orderNum);
+			throw new Exception("订单已经支付过: " + orderNum);
 		}
 		// 添加支付记录
 		String payNum = payService.add(order.getOrderId(), payType);

+ 12 - 13
src/main/java/com/llisoft/pay/service/PayService.java

@@ -8,14 +8,13 @@ import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 import org.springframework.transaction.annotation.Transactional;
 
-import com.llisoft.common.exception.MtaException;
-import com.llisoft.common.util.CodeUtil;
-import com.llisoft.common.util.HttpUtil;
-import com.llisoft.common.util.JsonUtil;
 import com.llisoft.pay.dao.ItemDao;
 import com.llisoft.pay.dao.OrderDao;
 import com.llisoft.pay.entity.Item;
 import com.llisoft.pay.entity.Order;
+import com.llisoft.pay.util.CodeUtil;
+import com.llisoft.pay.util.HttpUtil;
+import com.llisoft.pay.util.JsonUtil;
 
 @Service
 public class PayService {
@@ -58,12 +57,12 @@ public class PayService {
 	 * 获取
 	 * @param payNum
 	 * @return
-	 * @throws MtaException 
+	 * @throws Exception 
 	 */
-	public Item get(String payNum) throws MtaException{
+	public Item get(String payNum) throws Exception{
 		Item pay = payDao.selectByPayNum(payNum);
 		if (Objects.isNull(pay)) {
-			throw new MtaException("支付记录不存在: " + payNum);
+			throw new Exception("支付记录不存在: " + payNum);
 		}
 		return pay;
 	}
@@ -91,12 +90,12 @@ public class PayService {
 	 * @param payNum 支付号
 	 * @param isMobile 是否移动端页面
 	 * @return
-	 * @throws MtaException 
+	 * @throws Exception 
 	 */
-	public String pay(String payNum, boolean isMobile) throws MtaException{
+	public String pay(String payNum, boolean isMobile) throws Exception{
 		Item item = this.get(payNum);
 		if (Objects.isNull(item)) {
-			throw new MtaException("支付记录不存在: " + payNum);
+			throw new Exception("支付记录不存在: " + payNum);
 		}
 		Order order = orderDao.select(item.getOrderId());
 		if (item.getPayType() == TYPE_ALI) { // 支付宝
@@ -123,7 +122,7 @@ public class PayService {
 		Item item = this.get(payNum);
 		Order order = orderDao.select(item.getOrderId());
 		if (order.getOrderMoney() != money) { // 核对金额
-			throw new MtaException("支付金额异常: " + money);
+			throw new Exception("支付金额异常: " + money);
 		}
 		// 更新支付状态
 		payDao.updatePay(item.getPayId(), tradeNum, STATUS_PAYED, flag);
@@ -145,9 +144,9 @@ public class PayService {
 	 * 验证
 	 * @param payNum
 	 * @return
-	 * @throws MtaException 
+	 * @throws Exception 
 	 */
-	public boolean check(String payNum) throws MtaException {
+	public boolean check(String payNum) throws Exception {
 		Item pay = this.get(payNum);
 		if (pay.getPayStatus() == STATUS_PAYED) { // 已经处理过
 			logger.warn("支付结果处理: 已经处理过, 收到重复通知: {}", payNum);

+ 6 - 6
src/main/java/com/llisoft/pay/service/WxPayService.java

@@ -7,17 +7,17 @@ import java.util.List;
 import java.util.Map;
 import java.util.UUID;
 
-import org.apache.commons.codec.digest.DigestUtils;
 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.stereotype.Service;
+import org.springframework.util.DigestUtils;
 
-import com.llisoft.common.util.DecimalUtil;
-import com.llisoft.common.util.HttpUtil;
-import com.llisoft.common.util.JsonUtil;
-import com.llisoft.common.util.XmlUtil;
+import com.llisoft.pay.util.DecimalUtil;
+import com.llisoft.pay.util.HttpUtil;
+import com.llisoft.pay.util.JsonUtil;
+import com.llisoft.pay.util.XmlUtil;
 
 /**
  * 微信支付
@@ -220,7 +220,7 @@ public class WxPayService {
         	}
         } // 添加私钥
         paramBuffer.append("key=").append(mchkey);   
-        return DigestUtils.md5Hex(paramBuffer.toString()).toUpperCase();
+        return DigestUtils.md5DigestAsHex(paramBuffer.toString().getBytes()).toUpperCase();
     }
 	
 	/**

+ 0 - 15
src/main/java/com/llisoft/pay/service/feign/FeignMailService.java

@@ -1,15 +0,0 @@
-package com.llisoft.pay.service.feign;
-
-import org.springframework.cloud.openfeign.FeignClient;
-import org.springframework.web.bind.annotation.PostMapping;
-
-import com.llisoft.common.vo.feign.FeignMailSendRequestVo;
-
-// 通过@FeignClient注解来指定服务名进而绑定服务
-@FeignClient("mta-service-sms")
-public interface FeignMailService {
-
-	@PostMapping("/feign/mail/send")
-	public void send(FeignMailSendRequestVo requestVo);
-	
-}

+ 59 - 0
src/main/java/com/llisoft/pay/util/BeanUtil.java

@@ -0,0 +1,59 @@
+package com.llisoft.pay.util;
+
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Objects;
+
+import org.springframework.beans.BeanUtils;
+
+/**
+ * 实体工具类
+ * @author YangJie [2018年12月25日]
+ */
+public class BeanUtil {
+	
+	/**
+	 * 转换实体
+	 * 将obj中属性复制到返回bean中
+	 * @param obj
+	 * @param clazz
+	 * @return
+	 * @throws Exception 
+	 */
+	public static <T> T transformBean(Object obj, Class<T> clazz) throws Exception{
+		if(Objects.nonNull(obj)) {
+			T t = clazz.newInstance();
+			BeanUtils.copyProperties(obj, t);
+			return t;
+		}
+		return null;
+	}
+	
+	/**
+	 * 转换List中实体
+	 * 将obj中属性复制到返回bean中
+	 * @param objList
+	 * @param clazz
+	 * @return
+	 * @throws Exception 
+	 */
+	public static <T> List<T> transformList(Object objList, Class<T> clazz) throws Exception{
+		List<T> tList = new ArrayList<T>();
+		if (objList != null && objList instanceof List<?>) {
+			for(Object obj : (List<?>)objList){
+				tList.add(transformBean(obj, clazz));
+			}
+		}
+		return tList;
+	}
+	
+	/**
+	 * 复制属性
+	 * @param source
+	 * @param target
+	 */
+	public static void copyProperties(Object source, Object target) {
+		BeanUtils.copyProperties(source, target);
+	}
+	
+}

+ 58 - 0
src/main/java/com/llisoft/pay/util/CodeUtil.java

@@ -0,0 +1,58 @@
+package com.llisoft.pay.util;
+
+import java.text.SimpleDateFormat;
+import java.util.Date;
+import java.util.Random;
+import java.util.UUID;
+
+/**
+ * 生成各种随机码/随机数等
+ * @author YangJie [2019年6月27日]
+ */
+public class CodeUtil {
+
+	/**
+	 * UUID
+	 * @return
+	 */
+	public static String uuid() {
+		return UUID.randomUUID().toString().replace("-", "").toLowerCase();
+	}
+	
+	/**
+	 * 当前时间精确到毫秒 + 5位随机数
+	 * @return
+	 */
+	public static String time() {
+		return new SimpleDateFormat("yyyyMMddHHmmssSSS").format(new Date()) + ints(5);
+	}
+	
+	/**
+	 * 随机数字 (支持[1-10]位)
+	 * @param n
+	 * @return
+	 */
+	public static String ints(int n) {
+		int min = (int)Math.pow(10, n-1);
+		int max = (int)Math.pow(10, n) - min - 1;
+		return String.valueOf(new Random().nextInt(max) + min);
+	}
+	
+	/**
+	 * 随机字符串 (支持[1-64]位)
+	 * @param n
+	 * @return
+	 */
+	public static String strs(int n) {
+		String str = UUID.randomUUID().toString().replace("-", "");
+		if (n>0 && n<=32) {
+			return str.substring(0, n);
+		}
+		str += UUID.randomUUID().toString().replace("-", "");
+		if (n>32 && n<=64) {
+			return str.substring(0, n);
+		}
+		return null;
+	}
+
+}

+ 53 - 0
src/main/java/com/llisoft/pay/util/DecimalUtil.java

@@ -0,0 +1,53 @@
+package com.llisoft.pay.util;
+
+import java.math.BigDecimal;
+import java.util.Objects;
+
+/**
+ * 小数工具类
+ * @author YangJie [2020年4月15日]
+ */
+public class DecimalUtil {
+
+	/**
+	 * 转字符串 默认两位小数
+	 * @param num
+	 * @return
+	 */
+	public static String toString(int num) {
+		return toString(num, 2);
+	}
+
+	/**
+	 * 转字符串
+	 * @param num
+	 * @param size 指定几位小数
+	 * @return
+	 */
+	public static String toString(int num, int size) {
+		return new BigDecimal(num).divide(new BigDecimal(Math.pow(10, size))).toString();
+	}
+	
+	/**
+	 * 转数字 默认两位小数
+	 * @param num
+	 * @return
+	 */
+	public static int toInt(String num) {
+		return toInt(num, 2);
+	}
+	
+	/**
+	 * 转数字 默认两位小数
+	 * @param num
+	 * @param size 指定几位小数
+	 * @return
+	 */
+	public static int toInt(String num, int size) {
+		if (Objects.isNull(num) || num.trim().isEmpty()) {
+			return 0;
+		}
+		return new BigDecimal(num).multiply(new BigDecimal(Math.pow(10, size))).intValue();
+	}
+	
+}

+ 239 - 0
src/main/java/com/llisoft/pay/util/HttpUtil.java

@@ -0,0 +1,239 @@
+package com.llisoft.pay.util;
+import java.io.IOException;
+import java.io.InputStream;
+import java.util.Map;
+import java.util.concurrent.TimeUnit;
+
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import okhttp3.FormBody;
+import okhttp3.Headers;
+import okhttp3.MediaType;
+import okhttp3.MultipartBody;
+import okhttp3.MultipartBody.Builder;
+import okhttp3.OkHttpClient;
+import okhttp3.Request;
+import okhttp3.RequestBody;
+
+/**
+ * HTTP工具类
+ * @author YangJie [2019年6月27日]
+ */
+public class HttpUtil {
+
+	private static Logger logger = LoggerFactory.getLogger(HttpUtil.class);
+
+	private static final OkHttpClient client = new OkHttpClient().newBuilder()
+			.connectTimeout(30, TimeUnit.MINUTES)
+			.readTimeout(30, TimeUnit.MINUTES)
+			.writeTimeout(30, TimeUnit.MINUTES)
+			.retryOnConnectionFailure(true).build();
+
+	private static final MediaType jsonMediaType = MediaType.parse("application/json; charset=utf-8");
+	private static final MediaType xmlMediaType = MediaType.parse("application/xml; charset=utf-8");
+
+	private static final MediaType jpgMediaType = MediaType.parse(" image/jpeg");
+
+	/**
+	 * get
+	 * 
+	 * @param url
+	 * @return
+	 * @throws Exception
+	 */
+	public static String get(String url) {
+		return execute(new Request.Builder().url(url).get().build());
+	}
+	
+	/**
+	 * get
+	 * 
+	 * @param url
+	 * @return
+	 * @throws Exception
+	 */
+	public static String get(String url, String referer) {
+		return execute(new Request.Builder().url(url).get().addHeader("referer", referer).build());
+	}
+	
+	/**
+	 * get
+	 * 
+	 * @param url
+	 * @return
+	 * @throws Exception
+	 */
+	public static String get(String url, Map<String, String> headerMap) {
+		return execute(new Request.Builder().url(url).get().headers(Headers.of(headerMap)).build());
+	}
+
+	/**
+	 * get
+	 * 
+	 * @param url
+	 * @return
+	 * @throws IOException 
+	 * @throws Exception
+	 */
+	public static InputStream getStream(String url) throws IOException {
+		return executeByteStream(new Request.Builder().url(url).get().build());
+	}
+	
+	/**
+	 * get
+	 * 
+	 * @param url
+	 * @return
+	 * @throws Exception
+	 */
+	public static byte[] getBytes(String url) {
+		return executeBytes(new Request.Builder().url(url).get().build());
+	}
+
+	/**
+	 * post (json)
+	 * 
+	 * @param url
+	 * @return
+	 */
+	public static String postJson(String url, String body) {
+		return post(url, body, jsonMediaType);
+	}
+
+	/**
+	 * post (xml)
+	 * 
+	 * @param url
+	 * @param body
+	 * @return
+	 */
+	public static String postXml(String url, String body) {
+		return post(url, body, xmlMediaType);
+	}
+
+	/**
+	 * post (map)
+	 * 
+	 * @param url
+	 * @param formMap
+	 * @return
+	 */
+	public static String postMap(String url, Map<String, Object> formMap) {
+		FormBody.Builder form = new FormBody.Builder();
+		if (formMap != null && !formMap.isEmpty()) {
+			for (String key : formMap.keySet()) {
+				form.add(key, String.valueOf(formMap.get(key)));
+			}
+			return post(url, form.build());
+		}
+		return null;
+	}
+
+	/**
+	 * post (byte[])
+	 * 
+	 * @param url
+	 * @param body
+	 * @return
+	 */
+	public static String postJpg(String url, byte[] body) {
+		Headers headers = Headers.of("Content-Disposition",
+			"form-data;name=\"media\";filename=\"file.jpg\";filelength=" + body.length);
+		return post(url, new MultipartBody.Builder().setType(MultipartBody.FORM)
+			.addPart(headers, RequestBody.create(jpgMediaType, body)).build());
+	}
+
+	/**
+	 * post (byte[] form)
+	 * 
+	 * @param url
+	 * @param name 文件字段名称
+	 * @param body 文件字节流
+	 * @param formMap 其他属性
+	 * @return
+	 */
+	public static String postJpgForm(String url, String name, byte[] body, Map<String, String> formMap) {
+		Builder builder = new MultipartBody.Builder().setType(MultipartBody.FORM)
+				.addFormDataPart(name, name, RequestBody.create(jpgMediaType, body));
+		if (formMap != null && !formMap.isEmpty()) {
+			for (String key : formMap.keySet()) {
+				builder.addFormDataPart(key, formMap.get(key));
+			}
+		}
+		return post(url, builder.build());
+	}
+
+	/**
+	 * post (string)
+	 * 
+	 * @param url
+	 * @param body
+	 * @param mediaType
+	 * @return
+	 */
+	private static String post(String url, String body, MediaType mediaType) {
+		return post(url, RequestBody.create(mediaType, body));
+	}
+
+	/**
+	 * post
+	 * 
+	 * @param url
+	 * @param body
+	 * @return
+	 */
+	private static String post(String url, RequestBody body) {
+		return execute(new Request.Builder().url(url).post(body).build());
+	}
+
+	/**
+	 * execute
+	 * 
+	 * @param request
+	 * @return
+	 */
+	private static String execute(Request request) {
+		logger.debug("http: {}", request.toString());
+		try {
+			return client.newCall(request).execute().body().string();
+		} catch (IOException e) {
+			logger.error("okhttp请求出错", e);
+		}
+		return null;
+	}
+
+	/**
+	 * execute
+	 * 
+	 * @param request
+	 * @return
+	 */
+	private static byte[] executeBytes(Request request) {
+		logger.debug("http: {}", request.toString());
+		try {
+			return client.newCall(request).execute().body().bytes();
+		} catch (IOException e) {
+			logger.error("okhttp请求出错", e);
+		}
+		return null;
+	}
+	
+	/**
+	 * execute
+	 * 
+	 * @param request
+	 * @return
+	 * @throws IOException 
+	 */
+	private static InputStream executeByteStream(Request request) throws IOException {
+		logger.debug("http: {}", request.toString());
+		try {
+			return client.newCall(request).execute().body().byteStream();
+		} catch (IOException e) {
+			logger.error("okhttp请求出错", e);
+			throw e;
+		}
+	}
+
+}

+ 100 - 0
src/main/java/com/llisoft/pay/util/JsonUtil.java

@@ -0,0 +1,100 @@
+package com.llisoft.pay.util;
+
+import java.util.Objects;
+
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import com.fasterxml.jackson.core.type.TypeReference;
+import com.fasterxml.jackson.databind.DeserializationFeature;
+import com.fasterxml.jackson.databind.ObjectMapper;
+
+/**
+ * Json处理工具类
+ * @author YangJie [2018年12月26日]
+ */
+public class JsonUtil {
+	
+	private static Logger logger = LoggerFactory.getLogger(JsonUtil.class);
+
+	public static ObjectMapper objectMapper = new ObjectMapper()
+			.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false); // 忽略未知属性
+	
+	
+	/**
+	 * 对象转json
+	 * @param object
+	 * @return
+	 * @throws Exception 
+	 */
+	public static String toJson(Object object) throws Exception{
+		try {
+			if (Objects.nonNull(object)) {
+				return objectMapper.writeValueAsString(object);
+			}
+			return "";
+		} catch (Exception e) {
+			logger.error("object转json异常:" + object, e);
+			throw e;
+		}
+	}
+	
+	/**
+	 * json转对象
+	 * @param json
+	 * @param valueType
+	 * @return
+	 * @throws Exception 
+	 */
+	public static <T> T toObject(String json, Class<T> valueType) throws Exception {
+		try {
+			if(Objects.nonNull(json) && !json.trim().isEmpty()) {
+				return objectMapper.readValue(json, valueType);
+			}
+			return null;
+		} catch (Exception e) {
+			logger.error("json转object异常:" + json, e);
+			throw e;
+		}
+	}
+	
+	/**
+	 * json转对象(处理容器类型对象) 
+	 * List<bean> : json, List.class, Bean.class
+	 * Map<bean1, bean2> : json, Map.class, Bean1.class, Bean2.class
+	 * @param json
+	 * @param valueTypeRef
+	 * @return
+	 * @throws Exception 
+	 */
+	public static <T> T toObject(String json, Class<?> collectionClass, Class<?>... elementClasses) throws Exception {
+		try {
+			if(Objects.nonNull(json) && !json.trim().isEmpty()) {
+				return objectMapper.readValue(json, objectMapper.getTypeFactory().constructParametricType(collectionClass, elementClasses));
+			}
+			return null;
+		} catch (Exception e) {
+			logger.error("json转object异常:" + json, e);
+			throw e;
+		}
+	}
+	
+	/**
+	 * json转对象(处理复杂类型对象) 
+	 * List<List<Object>> : (json, new TypeReference<List<List<Object>>>(){})
+	 * Map<String, List<List<Object>>> : (json, new TypeReference<Map<String, List<List<Object>>>(){})
+	 * @param json
+	 * @param valueType
+	 * @return
+	 * @throws Exception 
+	 */
+	public static <T> T toObject(String json, TypeReference<T> typeReference) throws Exception {
+		try {
+			return objectMapper.readValue(json, typeReference);
+		} catch (Exception e) {
+			logger.error("json转object异常:" + json, e);
+			throw e;
+		}
+	}
+
+}

+ 48 - 0
src/main/java/com/llisoft/pay/util/XmlUtil.java

@@ -0,0 +1,48 @@
+package com.llisoft.pay.util;
+
+import com.fasterxml.jackson.dataformat.xml.XmlMapper;
+
+/**
+ * xml处理工具类
+ * @author YangJie [2014年11月13日 下午8:35:48]
+ */
+public class XmlUtil {
+
+	public static XmlMapper xmlMapper = new XmlMapper();
+	
+	
+	/**
+	 * xml转对象
+	 * @author YangJie [2015年11月4日 下午1:52:59]
+	 * @param xml
+	 * @param valueType
+	 * @return
+	 */
+	public static <T> T toObject(String xml, Class<T> valueType) {
+		try {
+			return xmlMapper.readValue(xml, valueType);
+		} catch (Exception e) {
+			e.printStackTrace();
+		}
+		return null;
+	}
+	
+	/**
+	 * xml文件转对象(处理复杂类型对象) 
+	 * List<bean> : json, List.class, Bean.class
+	 * Map<bean1, bean2> : json, Map.class, Bean1.class, Bean2.class
+	 * @author YangJie [2015年11月9日 下午4:19:04]
+	 * @param json
+	 * @param valueTypeRef
+	 * @return
+	 */
+	public static <T> T toObject(String xml, Class<?> collectionClass, Class<?>... elementClasses) {
+		try {
+			return xmlMapper.readValue(xml, xmlMapper.getTypeFactory().constructParametricType(collectionClass, elementClasses));
+		} catch (Exception e) {
+			e.printStackTrace();
+		}
+		return null;
+	}
+
+}

+ 45 - 0
src/main/java/com/llisoft/pay/vo/CodeEnum.java

@@ -0,0 +1,45 @@
+package com.llisoft.pay.vo;
+
+/**
+ * 返回状态枚举
+ * @author YangJie [2018年12月27日]
+ */
+public enum CodeEnum {
+	
+	SUCCESS(0, "请求成功"),
+	FAIL(1001, "请求失败"),
+	
+	// 全局异常
+	C400(400, "参数错误"),
+	C401(401, "登录超时"),
+	C402(402, "签名错误"),
+	C403(403, "无权访问"),
+	C404(404, "请求无效"),
+	C500(500, "系统错误");
+
+	
+	private int code;
+	private String msg; 
+	
+	CodeEnum(int code, String msg) {
+		this.code = code;
+		this.msg = msg;
+	}
+
+	public int getCode() {
+		return code;
+	}
+
+	public void setCode(int code) {
+		this.code = code;
+	}
+
+	public String getMsg() {
+		return msg;
+	}
+
+	public void setMsg(String msg) {
+		this.msg = msg;
+	}
+
+}

+ 122 - 0
src/main/java/com/llisoft/pay/vo/ResponseVo.java

@@ -0,0 +1,122 @@
+package com.llisoft.pay.vo;
+
+import io.swagger.annotations.ApiModel;
+import io.swagger.annotations.ApiModelProperty;
+
+@ApiModel("公共返回实体")
+public class ResponseVo<T> {
+
+	@ApiModelProperty(value="代码", required=true)
+	private int code;
+	@ApiModelProperty(value="信息", required=true)
+	private String msg; 
+	@ApiModelProperty("数据")
+    private T data;
+
+    
+    /**
+     * 默认成功方法
+     * @param data
+     * @return
+     */
+    public static <T> ResponseVo<T> success(T data){
+    	return ResponseVo.build(data, CodeEnum.SUCCESS); 
+    }
+
+    /**
+     * 默认成功方法
+     * @param data
+     * @return 
+     * @return
+     */
+    public static <T> ResponseVo<T> success(T data, String msg){
+    	return ResponseVo.build(data, CodeEnum.SUCCESS.getCode(), msg); 
+    }
+    
+    /**
+     * 默认失败方法
+     * @param data
+     * @return
+     */
+    public static <T> ResponseVo<T> fail(T data){
+    	return ResponseVo.build(data, CodeEnum.FAIL); 
+    }
+    
+    /**
+     * 默认失败方法
+     * @param data
+     * @return
+     */
+    public static <T> ResponseVo<T> fail(String msg){
+    	return ResponseVo.build(null, CodeEnum.FAIL.getCode(), msg); 
+    }
+    
+    /**
+     * 默认失败方法
+     * @param data
+     * @return
+     */
+    public static <T> ResponseVo<T> fail(T data, String msg){
+    	return ResponseVo.build(data, CodeEnum.FAIL.getCode(), msg); 
+    }
+	
+    /**
+     * 默认构建方法
+     * @param data
+     * @return
+     */
+    public static <T> ResponseVo<T> build(CodeEnum codeEnum){
+    	return ResponseVo.build(null, codeEnum); 
+    }
+    
+    /**
+     * 默认构建方法
+     * @param data
+     * @return
+     */
+    public static <T> ResponseVo<T> build(T data, CodeEnum codeEnum){
+    	return ResponseVo.build(data, codeEnum.getCode(), codeEnum.getMsg()); 
+    }
+    
+    /**
+     * 默认构建方法
+     * @param data
+     * @return
+     */
+    public static <T> ResponseVo<T> build(int code, String msg){
+    	return build(null, code, msg); 
+    }
+    
+    /**
+     * 默认构建方法
+     * @param data
+     * @return
+     */
+    public static <T> ResponseVo<T> build(T data, int code, String msg){
+    	ResponseVo<T> responseBean = new ResponseVo<>();
+    	responseBean.setCode(code);
+    	responseBean.setMsg(msg);
+    	responseBean.setData(data);
+    	return responseBean; 
+    }
+    
+	public int getCode() {
+		return code;
+	}
+	public void setCode(int code) {
+		this.code = code;
+	}
+	public String getMsg() {
+		return msg;
+	}
+	public void setMsg(String msg) {
+		this.msg = msg;
+	}
+	public T getData() {
+		return data;
+	}
+	public void setData(T data) {
+		this.data = data;
+	}
+
+}

+ 0 - 32
src/main/resources/application.yml

@@ -35,38 +35,6 @@ spring.datasource:
 
 ##MYBATIS配置
 mybatis.configuration.mapUnderscoreToCamelCase: true #开启自动驼峰命名规则映射    
-
-
-##服务名称
-spring.application.name: mta-service-pay #服务名称
- 
-##注册中心配置
-eureka:
-  instance: 
-    preferIpAddress: true #使用ip注册服务
-    ipAddress: localhost #配置ip地址
-    instanceId: ${eureka.instance.ipAddress}:${server.port} #实例显示名称
-    leaseRenewalIntervalInSeconds: 30 #表示eureka client发送心跳给server端的频率 默认30秒
-    leaseExpirationDurationInSeconds: 90 #表示eureka server等待心跳的超时时间,在这个时间内若没收到下一次心跳,则将移除该instance, 默认为90秒
-  client:
-    healthcheck.enabled: true #开启健康检测
-    serviceUrl.defaultZone: http://192.168.0.179:8761/eureka #配置中心地址
-
-
-##监控端点配置
-management:
-  server.port: 1${server.port} #监控端口
-  endpoints.web.exposure.include: "*" #开启所有端点
-  endpoint.health.show-details: always #显示健康详情
-
-##监控服务配置
-spring.boot.admin.client: 
-  url: http://localhost:1111 #监控服务地址
-  instance: #监控实例地址配置
-    serviceUrl: http://${eureka.instance.ipAddress}:${server.port}
-    healthUrl: http://${eureka.instance.ipAddress}:${management.server.port}/actuator/health
-    managementUrl: http://${eureka.instance.ipAddress}:${management.server.port}/actuator
-
   
 ##系统异常配置
 spring.resources.addMappings: false #不为工程中的资源文件建立映射

+ 1 - 1
src/test/java/com/llisoft/pay/ServiceTest.java

@@ -6,8 +6,8 @@ import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.boot.test.context.SpringBootTest;
 import org.springframework.test.context.junit4.SpringRunner;
 
-import com.llisoft.common.util.CodeUtil;
 import com.llisoft.pay.service.WxPayService;
+import com.llisoft.pay.util.CodeUtil;
 
 @SpringBootTest
 @RunWith(SpringRunner.class)