|
|
@@ -2,6 +2,8 @@ package cn.hnthyy.thmz.service.pay;
|
|
|
|
|
|
import cn.hnthyy.thmz.common.RestApiUtil;
|
|
|
import cn.hnthyy.thmz.common.model.ResultCode;
|
|
|
+import cn.hnthyy.thmz.entity.his.mz.MzDepositFile;
|
|
|
+import cn.hnthyy.thmz.vo.MzDepositFileVo;
|
|
|
import com.alibaba.fastjson.JSONObject;
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
import org.springframework.beans.factory.annotation.Value;
|
|
|
@@ -10,9 +12,7 @@ import org.springframework.stereotype.Service;
|
|
|
import java.io.IOException;
|
|
|
import java.math.BigDecimal;
|
|
|
import java.math.RoundingMode;
|
|
|
-import java.util.HashMap;
|
|
|
-import java.util.Map;
|
|
|
-import java.util.Objects;
|
|
|
+import java.util.*;
|
|
|
|
|
|
@Slf4j
|
|
|
@Service
|
|
|
@@ -54,6 +54,49 @@ public class NongPayService {
|
|
|
return result;
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * 通过收费凭条上的二维码进行扫码支付
|
|
|
+ * @param body
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ public JSONObject unifiedOrderByCodeImgUrl(Map<String, String> body) {
|
|
|
+ JSONObject result = new JSONObject();
|
|
|
+ result.put("code", ResultCode.pay_error.getCode());
|
|
|
+ body.put("payType", "1");
|
|
|
+ String amount = body.get("amount");
|
|
|
+ BigDecimal amountBigDecimal = new BigDecimal(amount);
|
|
|
+ String payAmount = String.valueOf(amountBigDecimal.multiply(new BigDecimal(100)).setScale(0, RoundingMode.HALF_UP));
|
|
|
+ // todo 测试写死1分钱
|
|
|
+ body.put("amount", "1");
|
|
|
+// body.put("amount", payAmount);
|
|
|
+ body.put("subject", body.get("subject"));
|
|
|
+ body.put("body", body.get("body"));
|
|
|
+ JSONObject channelExtra = new JSONObject();
|
|
|
+ channelExtra.put("payDataType", body.get("codeImgUrl"));
|
|
|
+ body.put("channelExtra", JSONObject.toJSONString(channelExtra));
|
|
|
+ JSONObject extParam = new JSONObject();
|
|
|
+ extParam.put("patientId", body.get("patientId"));
|
|
|
+ extParam.put("times", body.get("times"));
|
|
|
+ extParam.put("amount", body.get("amount"));
|
|
|
+ body.put("extParam", JSONObject.toJSONString(extParam));
|
|
|
+
|
|
|
+ try {
|
|
|
+ log.info("--------------------门诊收费开始-------------------------");
|
|
|
+ log.info("param={}", JSONObject.toJSONString(body));
|
|
|
+ String postResponse = RestApiUtil.doPost(payUrl + "/unifiedOrder", JSONObject.toJSONString(body));
|
|
|
+ JSONObject response = JSONObject.parseObject(postResponse);
|
|
|
+ log.info("response={}", response);
|
|
|
+ if(Objects.equals(response.getInteger("code"), ResultCode.pay_success.getCode())) {
|
|
|
+ result.put("code", ResultCode.pay_success.getCode());
|
|
|
+ result.put("data", response.getJSONObject("data"));
|
|
|
+ }
|
|
|
+ } catch (IOException e) {
|
|
|
+ e.printStackTrace();
|
|
|
+ log.error("支付失败:" + e.getMessage());
|
|
|
+ }
|
|
|
+ return result;
|
|
|
+ }
|
|
|
+
|
|
|
public JSONObject query(String mchOrderNo, String type) {
|
|
|
JSONObject result = new JSONObject();
|
|
|
result.put("code", ResultCode.pay_error.getCode());
|
|
|
@@ -74,6 +117,43 @@ public class NongPayService {
|
|
|
return result;
|
|
|
}
|
|
|
|
|
|
+ public String notifyCodeImg(Map<String, Object> body) {
|
|
|
+ String payOrderId = (String) body.get("payOrderId");
|
|
|
+ String mchOrderNo = (String) body.get("mchOrderNo");
|
|
|
+ String extParam = (String) body.get("extParam");
|
|
|
+ int amount = (Integer) body.get("amount");
|
|
|
+ int state = (Integer) body.get("state");
|
|
|
+ if(state == 2) {
|
|
|
+ JSONObject extraParam = JSONObject.parseObject(extParam);
|
|
|
+ List<MzDepositFile> mzDepositFiles = new ArrayList<>();
|
|
|
+ MzDepositFile mzDepositFile = new MzDepositFile();
|
|
|
+ mzDepositFile.setChequeType("O");
|
|
|
+ mzDepositFile.setAmount(extraParam.getBigDecimal("amount"));
|
|
|
+ mzDepositFile.setTraceNo(mchOrderNo);
|
|
|
+ mzDepositFiles.add(mzDepositFile);
|
|
|
+ MzDepositFileVo mzDepositFileVo = new MzDepositFileVo();
|
|
|
+ mzDepositFileVo.setPatientId(extraParam.getString("patientId"));
|
|
|
+ mzDepositFileVo.setTimes(Integer.valueOf(extraParam.getString("times")));
|
|
|
+ mzDepositFileVo.setReceiptNo(1);
|
|
|
+ mzDepositFileVo.setMzDepositFiles(mzDepositFiles);
|
|
|
+ Map<String, Object> fee = chargeFee(mzDepositFileVo);
|
|
|
+ Integer code = (Integer) fee.get("code");
|
|
|
+ if(code == 0) {
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ return "success";
|
|
|
+ } else {
|
|
|
+ return "fail";
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ private Map<String, Object> chargeFee(MzDepositFileVo mzDepositFileVo) {
|
|
|
+ Map<String, Object> result = new HashMap<>();
|
|
|
+ return result;
|
|
|
+ }
|
|
|
+
|
|
|
public static void main(String[] args) {
|
|
|
String amount = "10";
|
|
|
BigDecimal amountBigDecimal = new BigDecimal(amount);
|