|
@@ -1,10 +1,16 @@
|
|
|
package com.usky.dxtop;
|
|
|
|
|
|
+import com.alibaba.fastjson.JSON;
|
|
|
+import com.alibaba.fastjson.JSONObject;
|
|
|
+import com.usky.dxtop.common.exception.CustomException;
|
|
|
+import com.usky.dxtop.common.utils.Arith;
|
|
|
+import com.usky.dxtop.common.utils.http.HttpUtils;
|
|
|
import com.usky.dxtop.model.Charge;
|
|
|
import com.usky.dxtop.model.Dish;
|
|
|
import com.usky.dxtop.service.ChargeService;
|
|
|
import com.usky.dxtop.service.DishService;
|
|
|
import com.usky.dxtop.service.MsgLogService;
|
|
|
+import com.usky.dxtop.service.api.TopApiConfiger;
|
|
|
import com.usky.dxtop.service.api.WxApi;
|
|
|
import com.usky.dxtop.service.job.SmJob;
|
|
|
import com.usky.dxtop.service.listener.ChargeTransMqListener;
|
|
@@ -15,6 +21,8 @@ import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.boot.test.context.SpringBootTest;
|
|
|
import org.springframework.test.context.junit4.SpringRunner;
|
|
|
|
|
|
+import java.util.TreeMap;
|
|
|
+
|
|
|
/**
|
|
|
* @author yq
|
|
|
* @date 2021/9/28 15:11
|
|
@@ -43,6 +51,9 @@ public class SmApiTest {
|
|
|
|
|
|
@Autowired
|
|
|
private SmJob smJob;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private TopApiConfiger topApiConfiger;
|
|
|
@Test
|
|
|
public void test1(){
|
|
|
smJob.personApi(null);
|
|
@@ -57,4 +68,55 @@ public class SmApiTest {
|
|
|
wxApi.sendMessageApi("o5P6I5tLj-TjrK7leWUT8EFmTCa4",chargeTransMqListener.getMessageData(charge),wxApi.getToken(WxApi.APP_ID,WxApi.SECRET), WxApi.CHARGE_TEMPLATE_ID,"https://smartpark.caih.com/vuepay/#/record?id=2");
|
|
|
}
|
|
|
|
|
|
+ @Test
|
|
|
+ public void order(){
|
|
|
+
|
|
|
+ TreeMap<String, String> stringStringTreeMap = topApiConfiger.generateUnifyParam("fsfsfsfjwo1214578", new Double(Arith.mul(0.01, 100)).intValue(),
|
|
|
+ topApiConfiger.notifyUrl, null,
|
|
|
+ null, null, "ojJtF5WLIcOsQVXcLu9n6JkvE0Zw", "W06", null, "wx40274c2aaec24330",
|
|
|
+ null, null, null, null);
|
|
|
+ String unify = topApiConfiger.generateParam(stringStringTreeMap);
|
|
|
+ String result;
|
|
|
+ try {
|
|
|
+ result = HttpUtils.sendGet(topApiConfiger.unifyUrl, unify,null);
|
|
|
+ }catch (Exception e){
|
|
|
+ throw new CustomException("调用统一支付接口异常:"+e.getMessage());
|
|
|
+ }
|
|
|
+ JSONObject obj= JSON.parseObject(result);
|
|
|
+ String payInfo;
|
|
|
+ if ("0000".equals(obj.get("status"))){
|
|
|
+ payInfo = obj.get("payinfo").toString();
|
|
|
+ System.out.println(payInfo);
|
|
|
+ }else {
|
|
|
+ throw new CustomException(obj.get("errorMessage").toString());
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ public TreeMap<String, String> generateUnifyParam(String merchantOrderNo, Integer amount, String notifyUrl,
|
|
|
+ String backUrl, String note, String orderName, String acct,
|
|
|
+ String payType, String validTime, String subAppid,
|
|
|
+ String remark, String asinfo, String groupNo,
|
|
|
+ String consumerIp){
|
|
|
+ TreeMap<String, String> tMap = new TreeMap<>();
|
|
|
+ tMap.put("version","v1.0");
|
|
|
+ tMap.put("merchantNo","228304018003");
|
|
|
+ tMap.put("merchantOrderNo",merchantOrderNo);
|
|
|
+ tMap.put("amount",amount.toString());
|
|
|
+ tMap.put("notifyUrl",notifyUrl);
|
|
|
+ tMap.put("backUrl",backUrl);
|
|
|
+ tMap.put("note",note);
|
|
|
+ tMap.put("orderName",orderName);
|
|
|
+ tMap.put("acct",acct);
|
|
|
+ tMap.put("payType",payType);
|
|
|
+ tMap.put("validTime",validTime);
|
|
|
+ tMap.put("subAppid",subAppid);
|
|
|
+ tMap.put("remark",remark);
|
|
|
+ tMap.put("asinfo",asinfo);
|
|
|
+ tMap.put("groupNo",groupNo);
|
|
|
+ tMap.put("consumerIp",consumerIp);
|
|
|
+ return tMap;
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
}
|