系统订单
This commit is contained in:
parent
31ee24918e
commit
3fae03a6e8
|
@ -59,6 +59,12 @@
|
|||
<version>2.0.0</version>
|
||||
<scope>compile</scope>
|
||||
</dependency>
|
||||
<!-- 系统订单模块 -->
|
||||
<dependency>
|
||||
<groupId>com.nursingunit.boot</groupId>
|
||||
<artifactId>nu-payment-local-api</artifactId>
|
||||
<version>${nursingunit.version}</version>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
</project>
|
||||
|
|
|
@ -2,7 +2,11 @@ package com.nu.modules.wechart.controller;
|
|||
|
||||
import cn.hutool.core.util.IdUtil;
|
||||
import cn.hutool.json.JSONObject;
|
||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
import com.nu.modules.bizEmployeesInfo.entity.BizEmployeesInfo;
|
||||
import com.nu.modules.systemorder.api.SystemOrderApi;
|
||||
import com.nu.modules.systemorder.entity.SystemOrderApiEntity;
|
||||
import com.nu.modules.wechart.entity.PayParam;
|
||||
import com.nu.modules.wechart.entity.WechatpayConfig;
|
||||
import com.wechat.pay.java.core.Config;
|
||||
import com.wechat.pay.java.core.RSAAutoCertificateConfig;
|
||||
|
@ -23,17 +27,23 @@ import org.apache.http.client.methods.HttpGet;
|
|||
import org.apache.http.impl.client.CloseableHttpClient;
|
||||
import org.apache.http.impl.client.HttpClients;
|
||||
import org.apache.http.util.EntityUtils;
|
||||
import org.jeecg.common.system.api.ISysBaseAPI;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import javax.servlet.ServletInputStream;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import javax.validation.Valid;
|
||||
import java.io.BufferedReader;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStreamReader;
|
||||
import java.math.BigDecimal;
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.Date;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
import com.wechat.pay.java.core.notification.RequestParam;
|
||||
|
||||
import org.apache.http.HttpEntity;
|
||||
|
@ -53,14 +63,15 @@ import com.google.gson.JsonParser;
|
|||
public class WechatPayController {
|
||||
@Autowired
|
||||
public WechatpayConfig wechatpayConfig;
|
||||
|
||||
@Autowired
|
||||
private SystemOrderApi systemOrderApi;
|
||||
|
||||
/**
|
||||
* Native下单
|
||||
* 调用统一下单API,生成支付二维码
|
||||
* 调用统一下单API,生成支付二维码
|
||||
*/
|
||||
@PostMapping("/native")
|
||||
public Map<String,String> nativePay(@RequestBody Map<String,String> params) throws Exception {
|
||||
public Map<String, String> nativePay(@Valid @RequestBody PayParam params) throws Exception {
|
||||
|
||||
Config config =
|
||||
new RSAAutoCertificateConfig.Builder()
|
||||
|
@ -72,45 +83,78 @@ public class WechatPayController {
|
|||
// 构建service
|
||||
JsapiService service = new JsapiService.Builder().config(config).build();
|
||||
PrepayRequest request = new PrepayRequest();
|
||||
String title = params.get("title");
|
||||
String openId = params.get("openId");
|
||||
String amountPrice = params.get("amountPrice");
|
||||
String title = params.getTitle();//订单名称
|
||||
String openId = params.getOpenId();//客户openId
|
||||
BigDecimal amountPrice = params.getAmountPrice();//总价(支付金额)
|
||||
String orgCode = params.getOrgCode();//机构编码
|
||||
String nursingUnit = params.getNursingUnit();//护理单元
|
||||
String customerId = params.getCustomerId();//客户ID
|
||||
String orderType = params.getOrderType();//订单类型
|
||||
BigDecimal price = params.getPrice();//单价
|
||||
Integer count = params.getCount();//数量
|
||||
String unit = params.getUnit();//单位
|
||||
String seniorId = params.getSeniorId();//长者ID
|
||||
String orderDesc = params.getOrderDesc();//订单描述
|
||||
|
||||
String outTradeNo = IdUtil.simpleUUID();//商户订单号
|
||||
Amount amount = new Amount();
|
||||
amount.setTotal(Integer.parseInt(amountPrice));
|
||||
amount.setTotal(Integer.parseInt(amountPrice.toString()));
|
||||
request.setAmount(amount);
|
||||
request.setAppid(wechatpayConfig.getAppid());
|
||||
request.setMchid(wechatpayConfig.getMchId());
|
||||
request.setDescription(title);
|
||||
request.setNotifyUrl(wechatpayConfig.getNotifyDomain());
|
||||
request.setOutTradeNo(IdUtil.simpleUUID());
|
||||
request.setOutTradeNo(outTradeNo);
|
||||
Payer payer = new Payer();
|
||||
payer.setOpenid(openId);
|
||||
request.setPayer(payer);
|
||||
// 调用下单方法,得到应答
|
||||
PrepayResponse response = service.prepay(request);
|
||||
log.info("prepayId:" + response.getPrepayId());
|
||||
Map map = prepayWithRequestPayment(request,config);
|
||||
//存储订单数据
|
||||
{
|
||||
SystemOrderApiEntity systemOrderApiEntity = new SystemOrderApiEntity();
|
||||
systemOrderApiEntity.setOrgCode(orgCode);//机构编码(必传)
|
||||
systemOrderApiEntity.setNursingUnit(nursingUnit);//护理单元(必传)
|
||||
systemOrderApiEntity.setCustomerId(customerId);//客户ID(必传)
|
||||
systemOrderApiEntity.setOrderType(orderType);//订单类型(必传)
|
||||
systemOrderApiEntity.setPrice(price);//单价(必传)
|
||||
systemOrderApiEntity.setCount(count);//数量(必传)
|
||||
systemOrderApiEntity.setUnit(unit);//单位(必传)
|
||||
systemOrderApiEntity.setAmount(amountPrice);//总价(支付金额)(必传)
|
||||
systemOrderApiEntity.setSeniorId(seniorId);//长者ID(非必传)
|
||||
systemOrderApiEntity.setOpenId(openId);//客户openId(必传)
|
||||
systemOrderApiEntity.setOrderName(title);//订单名称(必传)
|
||||
systemOrderApiEntity.setOrderDescription(orderDesc);//订单描述(非必传)
|
||||
systemOrderApiEntity.setOutTradeNo(outTradeNo);//商户订单号
|
||||
systemOrderApiEntity.setTransactionId(response.getPrepayId());//微信支付订单号
|
||||
systemOrderApiEntity.setOrderTime(new Date());//下单时间
|
||||
systemOrderApiEntity.setOrderStatus("created");//订单状态
|
||||
systemOrderApi.save(systemOrderApiEntity);
|
||||
}
|
||||
Map map = prepayWithRequestPayment(request, config);
|
||||
return map;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 返回调起支付的参数
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
private Map<String,String> prepayWithRequestPayment(PrepayRequest request,Config config){
|
||||
Map<String,String> map = new HashMap<>();
|
||||
private Map<String, String> prepayWithRequestPayment(PrepayRequest request, Config config) {
|
||||
Map<String, String> map = new HashMap<>();
|
||||
JsapiServiceExtension jse = new JsapiServiceExtension.Builder().config(config).build();
|
||||
PrepayWithRequestPaymentResponse response = jse.prepayWithRequestPayment(request);
|
||||
map.put("appId",response.getAppId());
|
||||
map.put("timeStamp",response.getTimeStamp());
|
||||
map.put("nonceStr",response.getNonceStr());
|
||||
map.put("package",response.getPackageVal());
|
||||
map.put("signType",response.getSignType());
|
||||
map.put("paySign",response.getPaySign());
|
||||
map.put("appId", response.getAppId());
|
||||
map.put("timeStamp", response.getTimeStamp());
|
||||
map.put("nonceStr", response.getNonceStr());
|
||||
map.put("package", response.getPackageVal());
|
||||
map.put("signType", response.getSignType());
|
||||
map.put("paySign", response.getPaySign());
|
||||
return map;
|
||||
}
|
||||
|
||||
@PostMapping("/callback")
|
||||
public String courseNative(HttpServletRequest request, HttpServletResponse response) {
|
||||
|
||||
|
@ -122,18 +166,18 @@ public class WechatPayController {
|
|||
.merchantSerialNumber(wechatpayConfig.getMchSerialNo())
|
||||
.privateKeyFromPath(wechatpayConfig.getPrivateKeyPath())
|
||||
.build();
|
||||
System.out.println("222222222222222"+config);
|
||||
System.out.println("222222222222222" + config);
|
||||
// 从请求头中获取信息
|
||||
String timestamp = request.getHeader("Wechatpay-Timestamp");
|
||||
String nonce = request.getHeader("Wechatpay-Nonce");
|
||||
String signature = request.getHeader("Wechatpay-Signature");
|
||||
String singType = request.getHeader("Wechatpay-Signature-Type");
|
||||
String timestamp = request.getHeader("Wechatpay-Timestamp");
|
||||
String nonce = request.getHeader("Wechatpay-Nonce");
|
||||
String signature = request.getHeader("Wechatpay-Signature");
|
||||
String singType = request.getHeader("Wechatpay-Signature-Type");
|
||||
String wechatPayCertificateSerialNumber = request.getHeader("Wechatpay-Serial");
|
||||
|
||||
System.out.println("333333333333333");
|
||||
String requestBody = getRequestBody(request);
|
||||
|
||||
System.out.println("333333333333333"+requestBody);
|
||||
System.out.println("333333333333333" + requestBody);
|
||||
// 初始化解析器 NotificationParser
|
||||
NotificationParser parser = new NotificationParser(config);
|
||||
System.out.println("444444444444444444444" + parser);
|
||||
|
@ -148,9 +192,35 @@ public class WechatPayController {
|
|||
System.out.println("555555555555555555555" + requestParam);
|
||||
try {
|
||||
// 这个Transaction是微信包里面的
|
||||
Transaction decryptObject = parser.parse( requestParam, Transaction.class);
|
||||
Transaction decryptObject = parser.parse(requestParam, Transaction.class);
|
||||
|
||||
System.out.println("666666666666666666:"+decryptObject);
|
||||
System.out.println("666666666666666666:" + decryptObject);
|
||||
|
||||
// 获取各项信息
|
||||
String openId = decryptObject.getPayer().getOpenid(); // 用户openId
|
||||
Integer amount = decryptObject.getAmount().getTotal(); // 订单金额(分)
|
||||
String successTime = decryptObject.getSuccessTime(); // 支付成功时间
|
||||
String tradeState = decryptObject.getTradeState().toString(); // 订单状态
|
||||
String tradeStateDesc = decryptObject.getTradeStateDesc(); // 交易状态描述
|
||||
String rawData = requestBody; // 回执报文(原始请求体)
|
||||
|
||||
// 打印获取的信息
|
||||
System.out.println("OpenID: " + openId);
|
||||
System.out.println("金额(分): " + amount);
|
||||
System.out.println("支付成功时间: " + successTime);
|
||||
System.out.println("订单状态: " + tradeState);
|
||||
System.out.println("状态描述: " + tradeStateDesc);
|
||||
System.out.println("原始报文: " + rawData);
|
||||
//系统订单表状态更新
|
||||
{
|
||||
SystemOrderApiEntity systemOrderApiEntity = new SystemOrderApiEntity();
|
||||
systemOrderApiEntity.setTransactionId(decryptObject.getTransactionId());//微信支付订单号
|
||||
systemOrderApiEntity.setOrderStatus(decryptObject.getTradeState().name());//支付状态
|
||||
systemOrderApiEntity.setReceiptDescription(decryptObject.getTradeStateDesc());//回执描述
|
||||
systemOrderApiEntity.setReceiptMessage(new ObjectMapper().writeValueAsString(decryptObject));//回执报文
|
||||
systemOrderApiEntity.setReceiptTime(new Date());
|
||||
systemOrderApi.updateByTransactionId(systemOrderApiEntity);
|
||||
}
|
||||
return decryptObject.getTradeState().toString();
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
|
@ -158,6 +228,7 @@ public class WechatPayController {
|
|||
}
|
||||
|
||||
}
|
||||
|
||||
// 获取请求头里的数据
|
||||
private String getRequestBody(HttpServletRequest request) {
|
||||
StringBuffer sb = new StringBuffer();
|
||||
|
@ -170,18 +241,19 @@ public class WechatPayController {
|
|||
sb.append(line);
|
||||
}
|
||||
} catch (IOException e) {
|
||||
System.out.println("读取数据流异常:"+e);
|
||||
System.out.println("读取数据流异常:" + e);
|
||||
}
|
||||
return sb.toString();
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询订单
|
||||
*
|
||||
* @param params
|
||||
* @return
|
||||
*/
|
||||
@PostMapping("/queryOrderById")
|
||||
public Map<String,Object> queryOrderById(@RequestBody Map<String,String> params) throws Exception {
|
||||
|
||||
public Map<String, Object> queryOrderById(@RequestBody Map<String, String> params) throws Exception {
|
||||
|
||||
|
||||
Config config =
|
||||
|
@ -192,10 +264,10 @@ public class WechatPayController {
|
|||
.apiV3Key(wechatpayConfig.getApiV3Key())
|
||||
.build();
|
||||
String prepay_id = params.get("prepay_id");
|
||||
Map<String,Object> map = new HashMap<>();
|
||||
if(StringUtils.isEmpty(prepay_id)){
|
||||
map.put("code","400");
|
||||
map.put("msg","参数错误,prepay_id为空!");
|
||||
Map<String, Object> map = new HashMap<>();
|
||||
if (StringUtils.isEmpty(prepay_id)) {
|
||||
map.put("code", "400");
|
||||
map.put("msg", "参数错误,prepay_id为空!");
|
||||
return map;
|
||||
}
|
||||
// 构建service
|
||||
|
@ -207,8 +279,8 @@ public class WechatPayController {
|
|||
try {
|
||||
Transaction result = service.queryOrderById(queryRequest);
|
||||
System.out.println(result.getTradeState());
|
||||
map.put("code","200");
|
||||
map.put("msg",result);
|
||||
map.put("code", "200");
|
||||
map.put("msg", result);
|
||||
} catch (ServiceException e) {
|
||||
// API返回失败, 例如ORDER_NOT_EXISTS
|
||||
System.out.printf("code=[%s], message=[%s]\n", e.getErrorCode(), e.getErrorMessage());
|
||||
|
@ -218,12 +290,10 @@ public class WechatPayController {
|
|||
}
|
||||
|
||||
|
||||
|
||||
public static final String GET_TOKEN_URL = "https://api.weixin.qq.com/cgi-bin/token";// 获取access
|
||||
|
||||
// 获取token
|
||||
public static String getToken(String apiurl, String appid, String secret)
|
||||
{
|
||||
public static String getToken(String apiurl, String appid, String secret) {
|
||||
String turl = String.format(
|
||||
"%s?grant_type=client_credential&appid=%s&secret=%s", apiurl,
|
||||
appid, secret);
|
||||
|
@ -233,8 +303,7 @@ public class WechatPayController {
|
|||
System.out.println("get:" + get);
|
||||
JsonParser jsonparer = new JsonParser();// 初始化解析json格式的对象
|
||||
String result = null;
|
||||
try
|
||||
{
|
||||
try {
|
||||
HttpResponse res = client.execute(get);
|
||||
System.out.println("res:" + res);
|
||||
String responseContent = null; // 响应内容
|
||||
|
@ -245,23 +314,15 @@ public class WechatPayController {
|
|||
.getAsJsonObject();
|
||||
System.out.println("json:" + json);
|
||||
// 将json字符串转换为json对象
|
||||
if (res.getStatusLine().getStatusCode() == HttpStatus.SC_OK)
|
||||
{
|
||||
if (json.get("errcode") != null)
|
||||
{// 错误时微信会返回错误码等信息,{"errcode":40013,"errmsg":"invalid appid"}
|
||||
}
|
||||
else
|
||||
{// 正常情况下{"access_token":"ACCESS_TOKEN","expires_in":7200}
|
||||
if (res.getStatusLine().getStatusCode() == HttpStatus.SC_OK) {
|
||||
if (json.get("errcode") != null) {// 错误时微信会返回错误码等信息,{"errcode":40013,"errmsg":"invalid appid"}
|
||||
} else {// 正常情况下{"access_token":"ACCESS_TOKEN","expires_in":7200}
|
||||
result = json.get("access_token").getAsString();
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
finally
|
||||
{
|
||||
} finally {
|
||||
// 关闭连接 ,释放资源
|
||||
client.getConnectionManager().shutdown();
|
||||
return result;
|
||||
|
@ -270,28 +331,28 @@ public class WechatPayController {
|
|||
|
||||
|
||||
@PostMapping("/getUserInfo")
|
||||
public JSONObject getWxUserInfo(@RequestBody Map<String,String> params) throws Exception {
|
||||
public JSONObject getWxUserInfo(@RequestBody Map<String, String> params) throws Exception {
|
||||
// String accessToken = getToken(GET_TOKEN_URL, "wx8fc3e4305d2fbf0b", "3bf3dd4ec72f591432db6b28c2c044e5");// 获取token
|
||||
String accessToken = params.get("access_token");
|
||||
String openid = params.get("openid");
|
||||
System.out.println("---------token-------"+accessToken);
|
||||
System.out.println("---------token-------" + accessToken);
|
||||
// 构造请求URL
|
||||
String requestUrl = "https://api.weixin.qq.com/sns/userinfo?access_token=" + accessToken + "&openid=" + openid + "&lang=zh_CN";
|
||||
|
||||
// 发送HTTP请求,并获取返回结果
|
||||
HttpGet httpGet = new HttpGet(requestUrl);
|
||||
System.out.println("---------httpGet-------"+httpGet);
|
||||
System.out.println("---------httpGet-------" + httpGet);
|
||||
CloseableHttpClient httpClient = HttpClients.createDefault();
|
||||
System.out.println("---------httpClient-------"+httpClient);
|
||||
System.out.println("---------httpClient-------" + httpClient);
|
||||
CloseableHttpResponse httpResponse = httpClient.execute(httpGet);
|
||||
System.out.println("---------httpResponse-------"+httpResponse);
|
||||
System.out.println("---------httpResponse-------" + httpResponse);
|
||||
HttpEntity httpEntity = httpResponse.getEntity();
|
||||
System.out.println("---------httpEntity-------"+httpEntity);
|
||||
System.out.println("---------httpEntity-------" + httpEntity);
|
||||
String responseJson = EntityUtils.toString(httpEntity, "UTF-8");
|
||||
System.out.println("---------responseJson-------"+responseJson);
|
||||
System.out.println("---------responseJson-------" + responseJson);
|
||||
// 解析返回结果,获取手机号
|
||||
JSONObject jsonObject = new JSONObject(responseJson);
|
||||
System.out.println("---------jsonObject-------"+jsonObject);
|
||||
System.out.println("---------jsonObject-------" + jsonObject);
|
||||
return jsonObject;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -0,0 +1,60 @@
|
|||
package com.nu.modules.wechart.entity;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
import javax.validation.constraints.NotBlank;
|
||||
import javax.validation.constraints.NotNull;
|
||||
import java.math.BigDecimal;
|
||||
|
||||
/**
|
||||
* 支付参数实体类(系统需要用到的)
|
||||
*/
|
||||
@Data
|
||||
public class PayParam {
|
||||
|
||||
// 机构编码
|
||||
@NotBlank(message = "机构编码不能为空")
|
||||
private String orgCode;
|
||||
|
||||
// 护理单元编码
|
||||
@NotBlank(message = "护理单元编码不能为空")
|
||||
private String nursingUnit;
|
||||
|
||||
// 客户ID
|
||||
@NotBlank(message = "客户ID不能为空")
|
||||
private String customerId;
|
||||
|
||||
// 微信的openId
|
||||
@NotBlank(message = "微信openId不能为空")
|
||||
private String openId;
|
||||
|
||||
// 长者ID(非必填)
|
||||
private String seniorId;
|
||||
|
||||
// 订单类型
|
||||
@NotBlank(message = "订单类型不能为空")
|
||||
private String orderType;
|
||||
|
||||
// 单价
|
||||
@NotNull(message = "单价不能为空")
|
||||
private BigDecimal price;
|
||||
|
||||
// 数量
|
||||
@NotNull(message = "数量不能为空")
|
||||
private Integer count;
|
||||
|
||||
// 单位
|
||||
@NotBlank(message = "单位不能为空")
|
||||
private String unit;
|
||||
|
||||
// 总价
|
||||
@NotNull(message = "总价不能为空")
|
||||
private BigDecimal amountPrice;
|
||||
|
||||
// 订单名称
|
||||
@NotBlank(message = "订单名称不能为空")
|
||||
private String title;
|
||||
|
||||
// 订单描述(非必填)
|
||||
private String orderDesc;
|
||||
}
|
|
@ -1,5 +1,6 @@
|
|||
package com.nu.modules.documentrecognition;
|
||||
|
||||
import com.aliyun.sdk.service.ocr_api20210707.models.*;
|
||||
import com.nu.modules.aliyun.documentrecognition.DocumentRecognitionUtils;
|
||||
import org.jeecg.common.api.vo.Result;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
|
@ -26,12 +27,12 @@ public class DocumentRecognitionApi {
|
|||
* @param file 图片文件
|
||||
*/
|
||||
@PostMapping("/idCard")
|
||||
public Result<String> recognizeIdCard(
|
||||
public Result<RecognizeIdcardResponseBody> recognizeIdCard(
|
||||
@RequestParam("file") MultipartFile file) {
|
||||
|
||||
DocumentRecognitionUtils utils = new DocumentRecognitionUtils(accessKeyId, accessKeySecret);
|
||||
try (InputStream inputStream = file.getInputStream()) {
|
||||
String result = utils.recognizeIdCard(inputStream);
|
||||
RecognizeIdcardResponseBody result = utils.recognizeIdCard(inputStream);
|
||||
return Result.ok(result);
|
||||
} catch (Exception e) {
|
||||
return Result.error("身份证识别失败: " + e.getMessage());
|
||||
|
@ -45,12 +46,12 @@ public class DocumentRecognitionApi {
|
|||
* @param file 图片文件
|
||||
*/
|
||||
@PostMapping("/household")
|
||||
public Result<String> recognizeHousehold(
|
||||
public Result<RecognizeHouseholdResponseBody> recognizeHousehold(
|
||||
@RequestParam("file") MultipartFile file) {
|
||||
|
||||
DocumentRecognitionUtils utils = new DocumentRecognitionUtils(accessKeyId, accessKeySecret);
|
||||
try (InputStream inputStream = file.getInputStream()) {
|
||||
String result = utils.recognizeHouseholdRegister(inputStream);
|
||||
RecognizeHouseholdResponseBody result = utils.recognizeHouseholdRegister(inputStream);
|
||||
return Result.ok(result);
|
||||
} catch (Exception e) {
|
||||
return Result.error("户口本识别失败: " + e.getMessage());
|
||||
|
@ -64,12 +65,12 @@ public class DocumentRecognitionApi {
|
|||
* @param file 图片文件
|
||||
*/
|
||||
@PostMapping("/bankCard")
|
||||
public Result<String> recognizeBankCard(
|
||||
public Result<RecognizeBankCardResponseBody> recognizeBankCard(
|
||||
@RequestParam("file") MultipartFile file) {
|
||||
|
||||
DocumentRecognitionUtils utils = new DocumentRecognitionUtils(accessKeyId, accessKeySecret);
|
||||
try (InputStream inputStream = file.getInputStream()) {
|
||||
String result = utils.recognizeBankCard(inputStream);
|
||||
RecognizeBankCardResponseBody result = utils.recognizeBankCard(inputStream);
|
||||
return Result.ok(result);
|
||||
} catch (Exception e) {
|
||||
return Result.error("银行卡识别失败: " + e.getMessage());
|
||||
|
@ -83,12 +84,12 @@ public class DocumentRecognitionApi {
|
|||
* @param file 图片文件
|
||||
*/
|
||||
@PostMapping("/medicalCard")
|
||||
public Result<String> recognizeMedicalCard(
|
||||
public Result<RecognizeSocialSecurityCardVersionIIResponseBody> recognizeMedicalCard(
|
||||
@RequestParam("file") MultipartFile file) {
|
||||
|
||||
DocumentRecognitionUtils utils = new DocumentRecognitionUtils(accessKeyId, accessKeySecret);
|
||||
try (InputStream inputStream = file.getInputStream()) {
|
||||
String result = utils.recognizeMedicalCard(inputStream);
|
||||
RecognizeSocialSecurityCardVersionIIResponseBody result = utils.recognizeMedicalCard(inputStream);
|
||||
return Result.ok(result);
|
||||
} catch (Exception e) {
|
||||
return Result.error("医保卡识别失败: " + e.getMessage());
|
||||
|
@ -97,4 +98,22 @@ public class DocumentRecognitionApi {
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 营业执照识别
|
||||
* @param file 图片文件
|
||||
*/
|
||||
@PostMapping("/businessLicense")
|
||||
public Result<RecognizeBusinessLicenseResponseBody> recognizeBusinessLicense(
|
||||
@RequestParam("file") MultipartFile file) {
|
||||
|
||||
DocumentRecognitionUtils utils = new DocumentRecognitionUtils(accessKeyId, accessKeySecret);
|
||||
try (InputStream inputStream = file.getInputStream()) {
|
||||
RecognizeBusinessLicenseResponseBody result = utils.recognizeBusinessLicense(inputStream);
|
||||
return Result.ok(result);
|
||||
} catch (Exception e) {
|
||||
return Result.error("营业执照识别失败: " + e.getMessage());
|
||||
} finally {
|
||||
utils.close();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -2,9 +2,8 @@ package com.nu.modules.aliyun.documentrecognition;
|
|||
|
||||
import com.aliyun.auth.credentials.Credential;
|
||||
import com.aliyun.auth.credentials.provider.StaticCredentialProvider;
|
||||
import com.aliyun.sdk.service.ocr_api20210707.*;
|
||||
import com.aliyun.sdk.service.ocr_api20210707.AsyncClient;
|
||||
import com.aliyun.sdk.service.ocr_api20210707.models.*;
|
||||
import com.google.gson.Gson;
|
||||
import darabonba.core.client.ClientOverrideConfiguration;
|
||||
|
||||
import java.io.InputStream;
|
||||
|
@ -45,58 +44,77 @@ public class DocumentRecognitionUtils {
|
|||
* @param inputStream 图片输入流
|
||||
* @return 识别结果JSON字符串
|
||||
*/
|
||||
public String recognizeIdCard(InputStream inputStream) throws Exception {
|
||||
public RecognizeIdcardResponseBody recognizeIdCard(InputStream inputStream) throws Exception {
|
||||
RecognizeIdcardRequest request = RecognizeIdcardRequest.builder()
|
||||
.body(inputStream)
|
||||
.build();
|
||||
|
||||
CompletableFuture<RecognizeIdcardResponse> future = client.recognizeIdcard(request);
|
||||
RecognizeIdcardResponse response = future.get();
|
||||
return new Gson().toJson(response.getBody());
|
||||
return response.getBody();
|
||||
}
|
||||
|
||||
/**
|
||||
* 识别户口本首页
|
||||
*
|
||||
* @param inputStream 图片输入流
|
||||
* @return 识别结果JSON字符串
|
||||
*/
|
||||
public String recognizeHouseholdRegister(InputStream inputStream) throws Exception {
|
||||
public RecognizeHouseholdResponseBody recognizeHouseholdRegister(InputStream inputStream) throws Exception {
|
||||
RecognizeHouseholdRequest request = RecognizeHouseholdRequest.builder()
|
||||
.body(inputStream)
|
||||
.build();
|
||||
|
||||
CompletableFuture<RecognizeHouseholdResponse> future = client.recognizeHousehold(request);
|
||||
RecognizeHouseholdResponse response = future.get();
|
||||
return new Gson().toJson(response.getBody());
|
||||
return response.getBody();
|
||||
}
|
||||
|
||||
/**
|
||||
* 识别银行卡
|
||||
*
|
||||
* @param inputStream 图片输入流
|
||||
* @return 识别结果JSON字符串
|
||||
*/
|
||||
public String recognizeBankCard(InputStream inputStream) throws Exception {
|
||||
public RecognizeBankCardResponseBody recognizeBankCard(InputStream inputStream) throws Exception {
|
||||
RecognizeBankCardRequest request = RecognizeBankCardRequest.builder()
|
||||
.body(inputStream)
|
||||
.build();
|
||||
|
||||
CompletableFuture<RecognizeBankCardResponse> future = client.recognizeBankCard(request);
|
||||
RecognizeBankCardResponse response = future.get();
|
||||
return new Gson().toJson(response.getBody());
|
||||
return response.getBody();
|
||||
}
|
||||
|
||||
/**
|
||||
* 识别医保卡
|
||||
*
|
||||
* @param inputStream 图片输入流
|
||||
* @return 识别结果JSON字符串
|
||||
*/
|
||||
public String recognizeMedicalCard(InputStream inputStream) throws Exception {
|
||||
public RecognizeSocialSecurityCardVersionIIResponseBody recognizeMedicalCard(InputStream inputStream) throws Exception {
|
||||
RecognizeSocialSecurityCardVersionIIRequest request = RecognizeSocialSecurityCardVersionIIRequest.builder()
|
||||
.body(inputStream)
|
||||
.build();
|
||||
|
||||
CompletableFuture<RecognizeSocialSecurityCardVersionIIResponse> future = client.recognizeSocialSecurityCardVersionII(request);
|
||||
RecognizeSocialSecurityCardVersionIIResponse response = future.get();
|
||||
return new Gson().toJson(response.getBody());
|
||||
return response.getBody();
|
||||
}
|
||||
|
||||
/**
|
||||
* 识别营业执照
|
||||
*
|
||||
* @param inputStream 图片输入流
|
||||
* @return 识别结果JSON字符串
|
||||
*/
|
||||
public RecognizeBusinessLicenseResponseBody recognizeBusinessLicense(InputStream inputStream) throws Exception {
|
||||
RecognizeBusinessLicenseRequest request = RecognizeBusinessLicenseRequest.builder()
|
||||
.body(inputStream)
|
||||
.build();
|
||||
|
||||
CompletableFuture<RecognizeBusinessLicenseResponse> future = client.recognizeBusinessLicense(request);
|
||||
RecognizeBusinessLicenseResponse response = future.get();
|
||||
return response.getBody();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -0,0 +1,16 @@
|
|||
package com.nu.modules.systemorder.api;
|
||||
|
||||
import com.nu.modules.systemorder.entity.SystemOrderApiEntity;
|
||||
|
||||
public interface SystemOrderApi {
|
||||
|
||||
|
||||
int save(SystemOrderApiEntity systemOrder);
|
||||
|
||||
/**
|
||||
* 通过transaction_id更新数据
|
||||
* @param systemOrder
|
||||
* @return
|
||||
*/
|
||||
int updateByTransactionId(SystemOrderApiEntity systemOrder);
|
||||
}
|
|
@ -0,0 +1,59 @@
|
|||
package com.nu.modules.systemorder.entity;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.math.BigDecimal;
|
||||
import java.util.Date;
|
||||
|
||||
/**
|
||||
* @Description: 系统订单
|
||||
* @Author: 张明远
|
||||
* @Date: 2025-06-03
|
||||
* @Version: V1.0
|
||||
*/
|
||||
@Data
|
||||
public class SystemOrderApiEntity implements Serializable {
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
/**主键ID*/
|
||||
private String id;
|
||||
/**机构编码*/
|
||||
private String orgCode;
|
||||
/**护理单元*/
|
||||
private String nursingUnit;
|
||||
/**支付人的openId*/
|
||||
private String openId;
|
||||
/**客户id(系统中的)*/
|
||||
private String customerId;
|
||||
/**订单类型(字典order_type)*/
|
||||
private String orderType;
|
||||
/**下单时间*/
|
||||
private Date orderTime;
|
||||
/**回执时间*/
|
||||
private Date receiptTime;
|
||||
/**订单状态*/
|
||||
private String orderStatus;
|
||||
/**订单名称*/
|
||||
private String orderName;
|
||||
/**订单描述(咱们自己说明的跟微信支付回执没关系)*/
|
||||
private String orderDescription;
|
||||
/**回执描述*/
|
||||
private String receiptDescription;
|
||||
/**回执报文*/
|
||||
private String receiptMessage;
|
||||
/**单价*/
|
||||
private BigDecimal price;
|
||||
/**数量*/
|
||||
private Integer count;
|
||||
/**单位*/
|
||||
private String unit;
|
||||
/**支付金额(总价)*/
|
||||
private BigDecimal amount;
|
||||
/**商户订单号*/
|
||||
private String outTradeNo;
|
||||
/**微信支付订单号*/
|
||||
private String transactionId;
|
||||
/**长者Id*/
|
||||
private String seniorId;
|
||||
}
|
|
@ -40,12 +40,12 @@ import org.jeecg.common.aspect.annotation.AutoLog;
|
|||
import org.apache.shiro.authz.annotation.RequiresPermissions;
|
||||
|
||||
/**
|
||||
* @Description: 系统订单表
|
||||
* @Description: 系统订单
|
||||
* @Author: 张明远
|
||||
* @Date: 2025-05-30
|
||||
* @Date: 2025-06-03
|
||||
* @Version: V1.0
|
||||
*/
|
||||
@Api(tags="系统订单表")
|
||||
@Api(tags="系统订单")
|
||||
@RestController
|
||||
@RequestMapping("/systemorder/systemOrder")
|
||||
@Slf4j
|
||||
|
@ -62,8 +62,8 @@ public class SystemOrderController extends JeecgController<SystemOrder, ISystemO
|
|||
* @param req
|
||||
* @return
|
||||
*/
|
||||
//@AutoLog(value = "系统订单表-分页列表查询")
|
||||
@ApiOperation(value="系统订单表-分页列表查询", notes="系统订单表-分页列表查询")
|
||||
//@AutoLog(value = "系统订单-分页列表查询")
|
||||
@ApiOperation(value="系统订单-分页列表查询", notes="系统订单-分页列表查询")
|
||||
@GetMapping(value = "/list")
|
||||
public Result<IPage<SystemOrder>> queryPageList(SystemOrder systemOrder,
|
||||
@RequestParam(name="pageNo", defaultValue="1") Integer pageNo,
|
||||
|
@ -73,8 +73,8 @@ public class SystemOrderController extends JeecgController<SystemOrder, ISystemO
|
|||
Map<String, QueryRuleEnum> customeRuleMap = new HashMap<>();
|
||||
// 自定义多选的查询规则为:LIKE_WITH_OR
|
||||
customeRuleMap.put("nursingUnit", QueryRuleEnum.LIKE_WITH_OR);
|
||||
customeRuleMap.put("customerId", QueryRuleEnum.LIKE_WITH_OR);
|
||||
customeRuleMap.put("orderType", QueryRuleEnum.LIKE_WITH_OR);
|
||||
customeRuleMap.put("orderStatus", QueryRuleEnum.LIKE_WITH_OR);
|
||||
QueryWrapper<SystemOrder> queryWrapper = QueryGenerator.initQueryWrapper(systemOrder, req.getParameterMap(),customeRuleMap);
|
||||
Page<SystemOrder> page = new Page<SystemOrder>(pageNo, pageSize);
|
||||
IPage<SystemOrder> pageList = systemOrderService.page(page, queryWrapper);
|
||||
|
@ -87,8 +87,8 @@ public class SystemOrderController extends JeecgController<SystemOrder, ISystemO
|
|||
* @param systemOrder
|
||||
* @return
|
||||
*/
|
||||
@AutoLog(value = "系统订单表-添加")
|
||||
@ApiOperation(value="系统订单表-添加", notes="系统订单表-添加")
|
||||
@AutoLog(value = "系统订单-添加")
|
||||
@ApiOperation(value="系统订单-添加", notes="系统订单-添加")
|
||||
@RequiresPermissions("systemorder:nu_system_order:add")
|
||||
@PostMapping(value = "/add")
|
||||
public Result<String> add(@RequestBody SystemOrder systemOrder) {
|
||||
|
@ -102,8 +102,8 @@ public class SystemOrderController extends JeecgController<SystemOrder, ISystemO
|
|||
* @param systemOrder
|
||||
* @return
|
||||
*/
|
||||
@AutoLog(value = "系统订单表-编辑")
|
||||
@ApiOperation(value="系统订单表-编辑", notes="系统订单表-编辑")
|
||||
@AutoLog(value = "系统订单-编辑")
|
||||
@ApiOperation(value="系统订单-编辑", notes="系统订单-编辑")
|
||||
@RequiresPermissions("systemorder:nu_system_order:edit")
|
||||
@RequestMapping(value = "/edit", method = {RequestMethod.PUT,RequestMethod.POST})
|
||||
public Result<String> edit(@RequestBody SystemOrder systemOrder) {
|
||||
|
@ -117,8 +117,8 @@ public class SystemOrderController extends JeecgController<SystemOrder, ISystemO
|
|||
* @param id
|
||||
* @return
|
||||
*/
|
||||
@AutoLog(value = "系统订单表-通过id删除")
|
||||
@ApiOperation(value="系统订单表-通过id删除", notes="系统订单表-通过id删除")
|
||||
@AutoLog(value = "系统订单-通过id删除")
|
||||
@ApiOperation(value="系统订单-通过id删除", notes="系统订单-通过id删除")
|
||||
@RequiresPermissions("systemorder:nu_system_order:delete")
|
||||
@DeleteMapping(value = "/delete")
|
||||
public Result<String> delete(@RequestParam(name="id",required=true) String id) {
|
||||
|
@ -132,8 +132,8 @@ public class SystemOrderController extends JeecgController<SystemOrder, ISystemO
|
|||
* @param ids
|
||||
* @return
|
||||
*/
|
||||
@AutoLog(value = "系统订单表-批量删除")
|
||||
@ApiOperation(value="系统订单表-批量删除", notes="系统订单表-批量删除")
|
||||
@AutoLog(value = "系统订单-批量删除")
|
||||
@ApiOperation(value="系统订单-批量删除", notes="系统订单-批量删除")
|
||||
@RequiresPermissions("systemorder:nu_system_order:deleteBatch")
|
||||
@DeleteMapping(value = "/deleteBatch")
|
||||
public Result<String> deleteBatch(@RequestParam(name="ids",required=true) String ids) {
|
||||
|
@ -147,8 +147,8 @@ public class SystemOrderController extends JeecgController<SystemOrder, ISystemO
|
|||
* @param id
|
||||
* @return
|
||||
*/
|
||||
//@AutoLog(value = "系统订单表-通过id查询")
|
||||
@ApiOperation(value="系统订单表-通过id查询", notes="系统订单表-通过id查询")
|
||||
//@AutoLog(value = "系统订单-通过id查询")
|
||||
@ApiOperation(value="系统订单-通过id查询", notes="系统订单-通过id查询")
|
||||
@GetMapping(value = "/queryById")
|
||||
public Result<SystemOrder> queryById(@RequestParam(name="id",required=true) String id) {
|
||||
SystemOrder systemOrder = systemOrderService.getById(id);
|
||||
|
@ -167,7 +167,7 @@ public class SystemOrderController extends JeecgController<SystemOrder, ISystemO
|
|||
@RequiresPermissions("systemorder:nu_system_order:exportXls")
|
||||
@RequestMapping(value = "/exportXls")
|
||||
public ModelAndView exportXls(HttpServletRequest request, SystemOrder systemOrder) {
|
||||
return super.exportXls(request, systemOrder, SystemOrder.class, "系统订单表");
|
||||
return super.exportXls(request, systemOrder, SystemOrder.class, "系统订单");
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -21,16 +21,16 @@ import lombok.EqualsAndHashCode;
|
|||
import lombok.experimental.Accessors;
|
||||
|
||||
/**
|
||||
* @Description: 系统订单表
|
||||
* @Description: 系统订单
|
||||
* @Author: 张明远
|
||||
* @Date: 2025-05-30
|
||||
* @Date: 2025-06-03
|
||||
* @Version: V1.0
|
||||
*/
|
||||
@Data
|
||||
@TableName("nu_system_order")
|
||||
@Accessors(chain = true)
|
||||
@EqualsAndHashCode(callSuper = false)
|
||||
@ApiModel(value="nu_system_order对象", description="系统订单表")
|
||||
@ApiModel(value="nu_system_order对象", description="系统订单")
|
||||
public class SystemOrder implements Serializable {
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
|
@ -59,10 +59,6 @@ public class SystemOrder implements Serializable {
|
|||
@Dict(dicCode = "order_type")
|
||||
@ApiModelProperty(value = "订单类型(字典order_type)")
|
||||
private java.lang.String orderType;
|
||||
/**金额*/
|
||||
@Excel(name = "金额", width = 15)
|
||||
@ApiModelProperty(value = "金额")
|
||||
private java.math.BigDecimal amount;
|
||||
/**下单时间*/
|
||||
@Excel(name = "下单时间", width = 20, format = "yyyy-MM-dd HH:mm:ss")
|
||||
@JsonFormat(timezone = "GMT+8",pattern = "yyyy-MM-dd HH:mm:ss")
|
||||
|
@ -95,4 +91,32 @@ public class SystemOrder implements Serializable {
|
|||
@Excel(name = "回执报文", width = 15)
|
||||
@ApiModelProperty(value = "回执报文")
|
||||
private java.lang.String receiptMessage;
|
||||
/**单价*/
|
||||
@Excel(name = "单价", width = 15)
|
||||
@ApiModelProperty(value = "单价")
|
||||
private java.math.BigDecimal price;
|
||||
/**数量*/
|
||||
@Excel(name = "数量", width = 15)
|
||||
@ApiModelProperty(value = "数量")
|
||||
private java.lang.Integer count;
|
||||
/**单位*/
|
||||
@Excel(name = "单位", width = 15)
|
||||
@ApiModelProperty(value = "单位")
|
||||
private java.lang.String unit;
|
||||
/**支付金额(总价)*/
|
||||
@Excel(name = "支付金额(总价)", width = 15)
|
||||
@ApiModelProperty(value = "支付金额(总价)")
|
||||
private java.math.BigDecimal amount;
|
||||
/**商户订单号*/
|
||||
@Excel(name = "商户订单号", width = 15)
|
||||
@ApiModelProperty(value = "商户订单号")
|
||||
private java.lang.String outTradeNo;
|
||||
/**微信支付订单号*/
|
||||
@Excel(name = "微信支付订单号", width = 15)
|
||||
@ApiModelProperty(value = "微信支付订单号")
|
||||
private java.lang.String transactionId;
|
||||
/**长者Id*/
|
||||
@Excel(name = "长者Id", width = 15)
|
||||
@ApiModelProperty(value = "长者Id")
|
||||
private java.lang.String seniorId;
|
||||
}
|
||||
|
|
|
@ -7,9 +7,9 @@ import com.nu.modules.systemorder.entity.SystemOrder;
|
|||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
|
||||
/**
|
||||
* @Description: 系统订单表
|
||||
* @Description: 系统订单
|
||||
* @Author: 张明远
|
||||
* @Date: 2025-05-30
|
||||
* @Date: 2025-06-03
|
||||
* @Version: V1.0
|
||||
*/
|
||||
public interface SystemOrderMapper extends BaseMapper<SystemOrder> {
|
||||
|
|
|
@ -4,9 +4,9 @@ import com.nu.modules.systemorder.entity.SystemOrder;
|
|||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
|
||||
/**
|
||||
* @Description: 系统订单表
|
||||
* @Description: 系统订单
|
||||
* @Author: 张明远
|
||||
* @Date: 2025-05-30
|
||||
* @Date: 2025-06-03
|
||||
* @Version: V1.0
|
||||
*/
|
||||
public interface ISystemOrderService extends IService<SystemOrder> {
|
||||
|
|
|
@ -1,19 +1,36 @@
|
|||
package com.nu.modules.systemorder.service.impl;
|
||||
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.nu.modules.systemorder.api.SystemOrderApi;
|
||||
import com.nu.modules.systemorder.entity.SystemOrder;
|
||||
import com.nu.modules.systemorder.entity.SystemOrderApiEntity;
|
||||
import com.nu.modules.systemorder.mapper.SystemOrderMapper;
|
||||
import com.nu.modules.systemorder.service.ISystemOrderService;
|
||||
import org.springframework.beans.BeanUtils;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
|
||||
/**
|
||||
* @Description: 系统订单表
|
||||
* @Description: 系统订单
|
||||
* @Author: 张明远
|
||||
* @Date: 2025-05-30
|
||||
* @Date: 2025-06-03
|
||||
* @Version: V1.0
|
||||
*/
|
||||
@Service
|
||||
public class SystemOrderServiceImpl extends ServiceImpl<SystemOrderMapper, SystemOrder> implements ISystemOrderService {
|
||||
public class SystemOrderServiceImpl extends ServiceImpl<SystemOrderMapper, SystemOrder> implements ISystemOrderService, SystemOrderApi {
|
||||
|
||||
@Override
|
||||
public int save(SystemOrderApiEntity systemOrderApiEntity) {
|
||||
SystemOrder systemOrder = new SystemOrder();
|
||||
BeanUtils.copyProperties(systemOrderApiEntity,systemOrder);
|
||||
return baseMapper.insert(systemOrder);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int updateByTransactionId(SystemOrderApiEntity systemOrderApiEntity) {
|
||||
SystemOrder systemOrder = new SystemOrder();
|
||||
BeanUtils.copyProperties(systemOrderApiEntity,systemOrder);
|
||||
return baseMapper.update(systemOrder,new QueryWrapper<SystemOrder>().eq("transaction_id",systemOrderApiEntity.getTransactionId()));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -42,6 +42,7 @@ public class DictMQListener {
|
|||
|
||||
/**
|
||||
* fanout类型 发给所有人统一处理的
|
||||
*
|
||||
* @param dto
|
||||
*/
|
||||
@RabbitListener(
|
||||
|
@ -62,6 +63,7 @@ public class DictMQListener {
|
|||
|
||||
/**
|
||||
* direct直连 只发给我的
|
||||
*
|
||||
* @param dto
|
||||
*/
|
||||
@RabbitListener(
|
||||
|
@ -98,6 +100,7 @@ public class DictMQListener {
|
|||
}
|
||||
|
||||
try {
|
||||
//TODO 主键重复问题
|
||||
SysDict dict = dictService.getById(dto.getId());
|
||||
//如果是标识删除 查到的也是null 这里要处理的是只要在回收站就删除 重建
|
||||
if (dict == null || (dict != null && dict.getDelFlag() == 1)) {
|
||||
|
|
|
@ -54,6 +54,12 @@
|
|||
<artifactId>nu-services-biz</artifactId>
|
||||
<version>${nursingunit.version}</version>
|
||||
</dependency>
|
||||
<!-- 系统订单 模块 -->
|
||||
<dependency>
|
||||
<groupId>com.nursingunit.boot</groupId>
|
||||
<artifactId>nu-payment-biz</artifactId>
|
||||
<version>${nursingunit.version}</version>
|
||||
</dependency>
|
||||
<!-- 接口 模块 -->
|
||||
<dependency>
|
||||
<groupId>com.nursingunit.boot</groupId>
|
||||
|
|
Loading…
Reference in New Issue