🎨 优化代码
This commit is contained in:
@@ -44,9 +44,8 @@ public interface PayScoreService {
|
|||||||
* @param queryId the query id
|
* @param queryId the query id
|
||||||
* @return the wx pay score result
|
* @return the wx pay score result
|
||||||
* @throws WxPayException the wx pay exception
|
* @throws WxPayException the wx pay exception
|
||||||
* @throws URISyntaxException the uri syntax exception
|
|
||||||
*/
|
*/
|
||||||
WxPayScoreResult queryServiceOrder(String outOrderNo, String queryId) throws WxPayException, URISyntaxException;
|
WxPayScoreResult queryServiceOrder(String outOrderNo, String queryId) throws WxPayException;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* <pre>
|
* <pre>
|
||||||
|
|||||||
@@ -60,10 +60,17 @@ public class PayScoreServiceImpl implements PayScoreService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public WxPayScoreResult queryServiceOrder(String outOrderNo, String queryId) throws WxPayException, URISyntaxException {
|
public WxPayScoreResult queryServiceOrder(String outOrderNo, String queryId) throws WxPayException {
|
||||||
WxPayConfig config = this.payService.getConfig();
|
WxPayConfig config = this.payService.getConfig();
|
||||||
String url = this.payService.getPayBaseUrl() + "/v3/payscore/serviceorder";
|
String url = this.payService.getPayBaseUrl() + "/v3/payscore/serviceorder";
|
||||||
URIBuilder uriBuilder = new URIBuilder(url);
|
|
||||||
|
URIBuilder uriBuilder;
|
||||||
|
try {
|
||||||
|
uriBuilder = new URIBuilder(url);
|
||||||
|
} catch (URISyntaxException e) {
|
||||||
|
throw new WxPayException("未知异常!", e);
|
||||||
|
}
|
||||||
|
|
||||||
if (StringUtils.isAllEmpty(outOrderNo, queryId) || !StringUtils.isAnyEmpty(outOrderNo, queryId)) {
|
if (StringUtils.isAllEmpty(outOrderNo, queryId) || !StringUtils.isAnyEmpty(outOrderNo, queryId)) {
|
||||||
throw new WxPayException("out_order_no,query_id不允许都填写或都不填写");
|
throw new WxPayException("out_order_no,query_id不允许都填写或都不填写");
|
||||||
}
|
}
|
||||||
@@ -75,8 +82,13 @@ public class PayScoreServiceImpl implements PayScoreService {
|
|||||||
}
|
}
|
||||||
uriBuilder.setParameter("service_id", config.getServiceId());
|
uriBuilder.setParameter("service_id", config.getServiceId());
|
||||||
uriBuilder.setParameter("appid", config.getAppId());
|
uriBuilder.setParameter("appid", config.getAppId());
|
||||||
String result = payService.getV3(uriBuilder.build());
|
try {
|
||||||
return GSON.fromJson(result, WxPayScoreResult.class);
|
String result = payService.getV3(uriBuilder.build());
|
||||||
|
return GSON.fromJson(result, WxPayScoreResult.class);
|
||||||
|
} catch (URISyntaxException e) {
|
||||||
|
throw new WxPayException("未知异常!", e);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -139,7 +151,7 @@ public class PayScoreServiceImpl implements PayScoreService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public PayScoreNotifyData parseNotifyData(String data){
|
public PayScoreNotifyData parseNotifyData(String data) {
|
||||||
return GSON.fromJson(data, PayScoreNotifyData.class);
|
return GSON.fromJson(data, PayScoreNotifyData.class);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -8,6 +8,8 @@ import com.google.inject.Inject;
|
|||||||
import org.testng.annotations.Guice;
|
import org.testng.annotations.Guice;
|
||||||
import org.testng.annotations.Test;
|
import org.testng.annotations.Test;
|
||||||
|
|
||||||
|
import java.net.URISyntaxException;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 测试代码,待补充完善.
|
* 测试代码,待补充完善.
|
||||||
*
|
*
|
||||||
@@ -62,14 +64,14 @@ public class PayScoreServiceImplTest {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testQueryServiceOrder() {
|
public void testQueryServiceOrder() throws URISyntaxException, WxPayException {
|
||||||
//两个参数选填一个
|
//两个参数选填一个
|
||||||
this.payService.getPayScoreService().queryServiceOrder("11","");
|
this.payService.getPayScoreService().queryServiceOrder("11", "");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testCancelServiceOrder() {
|
public void testCancelServiceOrder() throws WxPayException {
|
||||||
this.payService.getPayScoreService().cancelServiceOrder("11","测试取消");
|
this.payService.getPayScoreService().cancelServiceOrder("11", "测试取消");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@@ -77,7 +79,7 @@ public class PayScoreServiceImplTest {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testCompleteServiceOrder() throws WxPayException{
|
public void testCompleteServiceOrder() throws WxPayException {
|
||||||
/* {
|
/* {
|
||||||
"appid":"",
|
"appid":"",
|
||||||
"service_id":"",
|
"service_id":"",
|
||||||
@@ -96,9 +98,10 @@ public class PayScoreServiceImplTest {
|
|||||||
],
|
],
|
||||||
"total_amount":100
|
"total_amount":100
|
||||||
}
|
}
|
||||||
}*/
|
*/
|
||||||
this.payService.getPayScoreService().completeServiceOrder(WxPayScoreRequest.builder().build());
|
this.payService.getPayScoreService().completeServiceOrder(WxPayScoreRequest.builder().build());
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testPayServiceOrder() {
|
public void testPayServiceOrder() {
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user