Merge branch 'jihan_0920_护理服务、商城、积分兑换、在线问诊功能分支' of http://182.92.166.109:3000/jihan/xinelu-api into jihan_0920_护理服务、商城、积分兑换、在线问诊功能分支

This commit is contained in:
haown 2023-10-19 13:40:41 +08:00
commit 2a85d219fd
22 changed files with 300 additions and 581 deletions

View File

@ -299,14 +299,6 @@ xyl-we-chat-config:
xyl-payment-key: Xyl699003981qazVFR4xsw23edcASDFG
xyl-wechat-notify-url: https://1608.xinelu.cn
# 医路优品微信商户号配置参数
ylyp-we-chat-config:
ylyp-mch-id: 1633506981
ylyp-mch-serial-no: 7840E8CE4B9B1F0F19D5DD2AB7BC159E007F9D90
ylyp-private-key-path: yiluyoupin_apiclient_key.pem
ylyp-payment-key: Xyk699003981qazxsw23edcvfr4bgt56
ylyp-we-chat-notify-url: https://1608.xinelu.cn
# 微信支付接口地址包含小程序和App支付接口地址
we-chat-payment-url-config:
jsapi-palce-order-url: https://api.mch.weixin.qq.com/v3/pay/transactions/jsapi

View File

@ -1,28 +0,0 @@
-----BEGIN PRIVATE KEY-----
MIIEvwIBADANBgkqhkiG9w0BAQEFAASCBKkwggSlAgEAAoIBAQC3rkr2Mp+Xb31y
xfTOJPSmjQkG5/Eko6cyJcb8e6fGrrtsPVM9kExpVIor61oWTS1gyKYLwCQ92xmh
qjKtazzd6KvqjKdxFknxxH9R1L+n7LnSEfK2KNaxIL17h2vdXOJatuinX0+7A9Ct
5ZnKb5O5HVctQH0xCca6C6yyuF0q11BFquKyGPVwhqVwQnt+qIeQ/VCKFD5AYf1r
ebkaHwKCg0rbzPFWeZfVI0z3j6M71DLxdIHV40xDn31ygQYlBeuTOUxFvKnri8m+
BalcSUhocS9VAIyuPyDXCAdujm3hKz/WgqVtvgB3OOiIeGVppbgDlW+JWgR7lizM
TzMYfhjPAgMBAAECggEBAJbB6SjVOAO1MEOpklo4Hs0saMJQUK3/3FTeiMnmPDho
ZdBbLR0UeILjLl0J2HEBe0M6rH5sf9J9KDZ2WQ3ZPKXuOFxUgYHiB2L2IoHpmjyb
oZB3xrwYHM5Yzuy6o5+Wgvptsdrd8bTPVtHD50wt9BM1r72mdppvKbq9pksx4tYr
apw4WXfjO2zbdOngY4T5pCk5NZgXrlBfY0/vXsP/3SR+52KXGre/lSt35A4SjNe6
voI1vZLDNlqzRaEZqBC0tLyvMH3NaYpRhwyEHtoABE9AQvVaQNt+fN1qhbhjtVdQ
lR64Dqdc6jjIhuUhs1umYswf2umA3duZox8RTLZo1UECgYEA4oM2gLsX7dVNiDI4
bZsMBdm8cb+N3/npiZBlDL9UL4tWCzLQP8sR/HJH3OZHQ1iLk+7QXi2g0YR5VtNx
tLvECK1+Cd3sGt2zyFcrSpeYAnvbsMqB9F/K3grCCnvzKKmHJS27c9EVGr+sRTbx
6hSqQyEAYTP1yRLnLVmWzkCBXh8CgYEAz5eqFmfou3U7B04tK739HTJGAaHTxVAR
C4u4x0HGUP+NhPKZzySc70vWHoNgyP/QBUgzf5gTEnGCJ7Rk6Y2YZxCLyPksEDFc
meW9ENSOQMwTWM1PAF+XLr4wXbyojMqlI7vWimTMOPK7WMVt4jYCoaN9lBS+McYj
e1ZpB5yEj1ECgYEAiSXLXVxq2604GYvW0L59JBm22OSTwZZuycUs+e/qyDLEcVld
8BJDnKeRTXX8lhFJydNiRHO6GMHuOh0ijrzVsC9jzhOZvpaYIWhuJObuuipGVZ/3
2YAatCCtZm2wR+GFm4Q6KKDi92QwqWPgS8whXy3fLfupCQsyACprfgxeiB8CgYBF
pfjm843d9wMK/GujVWbquMdMHONUO/y8BvDDyYmj+1mb1VlNaldM4gDA1AtQ5KMC
YqsEkB01/udQMvH4eg075w0/LHpgJG+RIsdAMlBX5SBIlvl+gpPSlvTbPkS+l+64
AnmEjTUHlkjNC9BGKSDQ4m1rlVoKkROuedtbNmQzQQKBgQCQdmmWy2Nr9NRmy5+r
3FKymUVGujww+R7IiFGnFiBBhec8hUPaBp1xG5d8XVIcLt6nleOX5ZunXBwTOmp6
XH6tQuup+hjFiNpRLmbVkTv8uQVy5sWEqiGp0i7Jhb+0QEOSEshOr8sQDDAFwWXl
FyCbC1amAeC1i1knzGrNOdppUw==
-----END PRIVATE KEY-----

View File

@ -1,27 +0,0 @@
package com.xinelu.common.config;
import lombok.Data;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.stereotype.Component;
/**
* @Description 医路优品商户号微信支付参数配置类
* @Author 纪寒
* @Date 2022-10-17 16:55:04
* @Version 1.0
*/
@Data
@Component
@ConfigurationProperties(prefix = "ylyp-we-chat-config")
public class YlypWeChatPaymentConfig {
private String ylypMchId;
private String ylypMchSerialNo;
private String ylypPrivateKeyPath;
private String ylypPaymentKey;
private String ylypWeChatNotifyUrl;
}

View File

@ -1,97 +0,0 @@
package com.xinelu.framework.config;
import com.wechat.pay.contrib.apache.httpclient.WechatPayHttpClientBuilder;
import com.wechat.pay.contrib.apache.httpclient.auth.PrivateKeySigner;
import com.wechat.pay.contrib.apache.httpclient.auth.Verifier;
import com.wechat.pay.contrib.apache.httpclient.auth.WechatPay2Credentials;
import com.wechat.pay.contrib.apache.httpclient.auth.WechatPay2Validator;
import com.wechat.pay.contrib.apache.httpclient.cert.CertificatesManager;
import com.wechat.pay.contrib.apache.httpclient.util.PemUtil;
import com.xinelu.common.config.YlypWeChatPaymentConfig;
import com.xinelu.common.exception.ServiceException;
import lombok.extern.slf4j.Slf4j;
import org.apache.http.impl.client.CloseableHttpClient;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.core.io.ClassPathResource;
import javax.annotation.Resource;
import java.nio.charset.StandardCharsets;
import java.security.PrivateKey;
/**
* @Description 医路优品微信支付核心配置类
* @Author 纪寒
* @Date 2022-10-17 18:56:22
* @Version 1.0
*/
@Configuration
@Slf4j
public class YlypWeChatPaymentUtilConfig {
@Resource
private YlypWeChatPaymentConfig ylypWeChatPaymentConfig;
/**
* 获取新医路签名信息
*
* @return 签名信息
* @throws Exception 异常信息
*/
@Bean(name = "ylypVerifier")
public Verifier getYlypVerifier() throws Exception {
PrivateKey privateKey = getPrivateKey(ylypWeChatPaymentConfig.getYlypPrivateKeyPath());
PrivateKeySigner privateKeySigner = new PrivateKeySigner(ylypWeChatPaymentConfig.getYlypMchSerialNo(), privateKey);
WechatPay2Credentials wechatPay2Credentials = new WechatPay2Credentials(ylypWeChatPaymentConfig.getYlypMchId(), privateKeySigner);
CertificatesManager certificatesManager = CertificatesManager.getInstance();
certificatesManager.putMerchant(ylypWeChatPaymentConfig.getYlypMchId(), wechatPay2Credentials, ylypWeChatPaymentConfig.getYlypPaymentKey().getBytes(StandardCharsets.UTF_8));
return certificatesManager.getVerifier(ylypWeChatPaymentConfig.getYlypMchId());
}
/**
* 获取医路优品商户带有签名信息的http请求对象
*
* @return CloseableHttpClient对象
*/
@Bean(name = "yiLuYouPinWeChatPayClient")
public CloseableHttpClient getYiLuYouPinWeChatPayClient(Verifier ylypVerifier) {
PrivateKey privateKey = getPrivateKey(ylypWeChatPaymentConfig.getYlypPrivateKeyPath());
CloseableHttpClient closeableHttpClient = null;
try {
closeableHttpClient = WechatPayHttpClientBuilder.create()
.withMerchant(ylypWeChatPaymentConfig.getYlypMchId(), ylypWeChatPaymentConfig.getYlypMchSerialNo(), privateKey)
.withValidator(new WechatPay2Validator(ylypVerifier)).build();
} catch (Exception e) {
log.error("医路优品验证签名信息失败,失败信息:{}", e.getMessage());
}
return closeableHttpClient;
}
/**
* 获取HttpClient无需进行应答签名验证跳过验签的流程
*
* @return CloseableHttpClient对象
*/
@Bean(name = "yiLuYouPinWeChatPayNoSignClient")
public CloseableHttpClient getYiLuYouPinWeChatPayNoSignClient() {
PrivateKey privateKey = getPrivateKey(ylypWeChatPaymentConfig.getYlypPrivateKeyPath());
return WechatPayHttpClientBuilder.create()
.withMerchant(ylypWeChatPaymentConfig.getYlypMchId(), ylypWeChatPaymentConfig.getYlypMchSerialNo(), privateKey)
.withValidator((response) -> true).build();
}
/**
* 获取商户的私钥文件
*
* @param filename 获取商户的私钥文件
* @return 商户私钥
*/
private PrivateKey getPrivateKey(String filename) {
try {
return PemUtil.loadPrivateKey(new ClassPathResource(filename).getInputStream());
} catch (Exception e) {
log.error("医路优品商户私钥文件不存在,错误原因:{}", e.getMessage());
throw new ServiceException("医路优品商户私钥文件不存在,请联系管理员!");
}
}
}

View File

@ -31,7 +31,7 @@ public class NursingOrderController extends BaseController {
private INursingOrderService nursingOrderService;
/**
* 根据登录id查询订单列表
* 根据登录id查询订单列表(暂时不用)
*/
@GetMapping("/userPage")
public TableDataInfo page(Long parentId) {
@ -93,4 +93,16 @@ public class NursingOrderController extends BaseController {
}
return nursingOrderService.getAppointmentDetailsInfo(orderNo);
}
/**
* 根据openid编号查询对应得订单
*/
@MobileRequestAuthorization
@GetMapping("/getAppletOrderList")
public AjaxResult getAppletOrderList(Long parentId, String orderStatus) {
if (Objects.isNull(parentId)) {
return AjaxResult.error("请选择要查询的用户信息!");
}
return nursingOrderService.getAppletOrderList(parentId, orderStatus);
}
}

View File

@ -123,10 +123,9 @@ public class WeChatPaymentController extends BaseController {
*
* @param refundDTO 退款参数
* @return 退款申请结果
* @throws Exception 异常信息
*/
@PostMapping("/weChatRefundOrderApply")
public AjaxResult weChatRefundOrderApply(@Validated(Insert.class) @RequestBody RefundDTO refundDTO) throws Exception {
public AjaxResult weChatRefundOrderApply(@Validated(Insert.class) @RequestBody RefundDTO refundDTO) {
return weChatRefundService.weChatRefundOrderApply(refundDTO);
}

View File

@ -3,9 +3,11 @@ package com.xinelu.applet.mapper.nursingorder;
import com.xinelu.applet.vo.nursingorder.AppletGoodsOrderVO;
import com.xinelu.applet.vo.nursingorder.NursingOrderInfoVO;
import com.xinelu.applet.vo.nursingorder.PatientOrder;
import com.xinelu.applet.vo.specialdisease.AppointmentOrderDetailsInfoVO;
import com.xinelu.common.core.domain.entity.SysDictData;
import com.xinelu.manage.domain.goodsOrder.GoodsOrder;
import org.apache.ibatis.annotations.Param;
import java.util.List;
@ -63,4 +65,22 @@ public interface NursingOrderMapper {
* @return 护理站信息
*/
AppointmentOrderDetailsInfoVO getNurseStationByItemId(Long nurseStationItemId);
/**
* 根据openid编号查询对应得订单
*
* @param patientId openid编号
* @param orderStatus 订单状态
* @return AjaxResult
*/
List<PatientOrder> getAppointmentOrderListByParentId(@Param("patientId") Long patientId, @Param("orderStatus") String orderStatus);
/**
* 根据openid编号查询对应得订单
*
* @param patientId openid编号
* @param orderStatus 订单状态
* @return AjaxResult
*/
List<PatientOrder> getGoodsOrderAndConsultationOrder(@Param("patientId") Long patientId, @Param("orderStatus") String orderStatus);
}

View File

@ -55,4 +55,13 @@ public interface INursingOrderService {
* @return 详情信息
*/
AjaxResult getAppointmentDetailsInfo(String orderNo);
/**
* 根据openid编号查询对应得订单
*
* @param parentId openid编号
* @param orderStatus 订单状态
* @return AjaxResult
*/
AjaxResult getAppletOrderList(Long parentId, String orderStatus);
}

View File

@ -5,17 +5,21 @@ import com.xinelu.applet.mapper.nursingorder.NursingOrderMapper;
import com.xinelu.applet.service.nursingorder.INursingOrderService;
import com.xinelu.applet.vo.nursingorder.AppletGoodsOrderVO;
import com.xinelu.applet.vo.nursingorder.NursingOrderInfoVO;
import com.xinelu.applet.vo.nursingorder.PatientOrder;
import com.xinelu.applet.vo.specialdisease.AppointmentOrderDetailsInfoVO;
import com.xinelu.common.core.domain.AjaxResult;
import com.xinelu.common.core.domain.entity.SysDictData;
import com.xinelu.common.enums.ConfirmRefundStatusEnum;
import com.xinelu.common.enums.GooodsOrderStatusEnum;
import com.xinelu.common.enums.OrderStatusEnum;
import com.xinelu.manage.domain.goodsOrder.GoodsOrder;
import org.apache.commons.collections4.CollectionUtils;
import org.apache.commons.lang3.StringUtils;
import org.springframework.stereotype.Service;
import javax.annotation.Resource;
import java.time.LocalDateTime;
import java.util.ArrayList;
import java.util.List;
import java.util.Objects;
@ -31,6 +35,16 @@ public class NursingOrderServiceImpl implements INursingOrderService {
@Resource
private NursingOrderMapper nursingOrderMapper;
/**
* 未评价标识
*/
private final String NOT_EVALUATED = "NOT_EVALUATED";
/**
* 未评价标识
*/
private final String EVALUATED = "EVALUATED";
/**
* 查询个人订单列表并分页
*
@ -107,4 +121,33 @@ public class NursingOrderServiceImpl implements INursingOrderService {
}
return AjaxResult.success(detailsInfoVO);
}
/**
* 根据openid编号查询对应得订单
*
* @param parentId openid编号
* @param orderStatus 订单状态
* @return AjaxResult
*/
@Override
public AjaxResult getAppletOrderList(Long parentId, String orderStatus) {
List<PatientOrder> patientOrders = new ArrayList<>();
List<PatientOrder> appletOrderList = new ArrayList<>();
List<PatientOrder> goodsOrderAndConsultationOrder = new ArrayList<>();
if (NOT_EVALUATED.equals(orderStatus)) {
appletOrderList = nursingOrderMapper.getAppointmentOrderListByParentId(parentId, OrderStatusEnum.COMPLETE.getInfo());
goodsOrderAndConsultationOrder = nursingOrderMapper.getGoodsOrderAndConsultationOrder(parentId, GooodsOrderStatusEnum.RECEIVED_GOODS.getInfo());
}
if (EVALUATED.equals(orderStatus)) {
appletOrderList = nursingOrderMapper.getAppointmentOrderListByParentId(parentId, OrderStatusEnum.EVALUATED.getInfo());
goodsOrderAndConsultationOrder = nursingOrderMapper.getGoodsOrderAndConsultationOrder(parentId, GooodsOrderStatusEnum.EVALUATED.getInfo());
}
if (CollectionUtils.isNotEmpty(appletOrderList)) {
patientOrders.addAll(appletOrderList);
}
if (CollectionUtils.isNotEmpty(goodsOrderAndConsultationOrder)) {
patientOrders.addAll(goodsOrderAndConsultationOrder);
}
return AjaxResult.success(patientOrders);
}
}

View File

@ -30,26 +30,6 @@ public interface WeChatPaymentService {
*/
AjaxResult appletAppointmentOrderPay(PaymentDTO paymentDTO) throws Exception;
/**
* 取消订单接口
*
* @param orderNo 点单编号
* @param buySource 购买来源
* @return 取消结果信息
* @throws Exception 异常信息
*/
AjaxResult cancelOrderInfo(String orderNo, String buySource) throws Exception;
/**
* 查询订单状态信息
*
* @param orderNo 点单编号
* @param buySource 购买来源
* @return 结果信息
* @throws Exception 异常信息
*/
AjaxResult getOrderStatusInfo(String orderNo, String buySource) throws Exception;
/**
* 微信关闭订单方法
*

View File

@ -17,9 +17,8 @@ public interface WeChatRefundService {
*
* @param refundDTO 退款参数
* @return 返回信息
* @throws Exception 异常信息
*/
AjaxResult weChatRefundOrderApply(RefundDTO refundDTO) throws Exception;
AjaxResult weChatRefundOrderApply(RefundDTO refundDTO);
/**
* 调用微信查询单笔退款接口查询预约订单状态信息
@ -35,7 +34,6 @@ public interface WeChatRefundService {
* @param refundNo 退单编号
* @param buySource 购买来源
* @return 退款信息
* @throws Exception 异常信息
*/
WeChatRefundInfoVO queryGoodsOrderRefundStatus(String refundNo, String buySource) throws Exception;
WeChatRefundInfoVO queryGoodsOrderRefundStatus(String refundNo, String buySource);
}

View File

@ -11,7 +11,6 @@ import com.xinelu.applet.service.wechatpaymentinfo.WeChatPayNotifyService;
import com.xinelu.applet.vo.wechatpaymentinfo.vo.WeChatPayNotifyPlaintextVO;
import com.xinelu.applet.vo.wechatpaymentinfo.vo.WeChatRefundNotifyVO;
import com.xinelu.common.config.XylWeChatPaymentConfig;
import com.xinelu.common.config.YlypWeChatPaymentConfig;
import com.xinelu.common.constant.Constants;
import com.xinelu.common.enums.*;
import com.xinelu.common.exception.ServiceException;
@ -67,8 +66,6 @@ public class WeChatPayNotifyServiceImpl implements WeChatPayNotifyService {
@Resource
private AppointmentOrderMapper appointmentOrderMapper;
@Resource
private YlypWeChatPaymentConfig ylypWeChatPaymentConfig;
@Resource
private PaymentInfoMapper paymentInfoMapper;
@Resource
private RedisDistributedLockUtils redisDistributedLockUtils;
@ -80,23 +77,11 @@ public class WeChatPayNotifyServiceImpl implements WeChatPayNotifyService {
private RefundInfoMapper refundInfoMapper;
@Resource(name = "xylVerifier")
private Verifier xylVerifier;
@Resource(name = "ylypVerifier")
private Verifier ylypVerifier;
@Resource
private RedisTemplate<String, Object> redisTemplate;
@Resource
private PatientCouponReceiveMapper patientCouponReceiveMapper;
/**
* 新医路账户标识
*/
private static final String XINYILU_ACCOUNT = "XINYILU";
/**
* 新医路账户标识
*/
private static final String YILUYOUPIN_ACCOUNT = "YILUYOUPIN";
/**
* 支付回调标识
*/
@ -187,19 +172,10 @@ public class WeChatPayNotifyServiceImpl implements WeChatPayNotifyService {
String timestamp = request.getHeader("Wechatpay-Timestamp");
String signature = request.getHeader("Wechatpay-Signature");
String serialNo = request.getHeader("Wechatpay-Serial");
Notification notification = null;
if (XINYILU_ACCOUNT.equals(accountFlag)) {
NotificationRequest notificationRequest = new NotificationRequest.Builder().withSerialNumber(serialNo)
.withNonce(nonce).withTimestamp(timestamp).withSignature(signature).withBody(body).build();
NotificationHandler handler = new NotificationHandler(xylVerifier, xylWeChatPaymentConfig.getXylPaymentKey().getBytes(StandardCharsets.UTF_8));
notification = handler.parse(notificationRequest);
}
if (YILUYOUPIN_ACCOUNT.equals(accountFlag)) {
NotificationRequest notificationRequest = new NotificationRequest.Builder().withSerialNumber(serialNo)
.withNonce(nonce).withTimestamp(timestamp).withSignature(signature).withBody(body).build();
NotificationHandler handler = new NotificationHandler(ylypVerifier, ylypWeChatPaymentConfig.getYlypPaymentKey().getBytes(StandardCharsets.UTF_8));
notification = handler.parse(notificationRequest);
}
NotificationRequest notificationRequest = new NotificationRequest.Builder().withSerialNumber(serialNo)
.withNonce(nonce).withTimestamp(timestamp).withSignature(signature).withBody(body).build();
NotificationHandler handler = new NotificationHandler(xylVerifier, xylWeChatPaymentConfig.getXylPaymentKey().getBytes(StandardCharsets.UTF_8));
Notification notification = handler.parse(notificationRequest);
if (Objects.isNull(notification)) {
log.error(accountFlag + "微信通知验签失败,请求体 ====> {}", body);
response.setStatus(500);
@ -210,15 +186,8 @@ public class WeChatPayNotifyServiceImpl implements WeChatPayNotifyService {
String ciphertext = StringUtils.isBlank(notification.getResource().getCiphertext()) ? "" : notification.getResource().getCiphertext();
String nonceTwo = StringUtils.isBlank(notification.getResource().getNonce()) ? "" : notification.getResource().getNonce();
String associatedData = StringUtils.isBlank(notification.getResource().getAssociatedData()) ? "" : notification.getResource().getAssociatedData();
String plainText = "";
if (XINYILU_ACCOUNT.equals(accountFlag)) {
AesUtil aesUtil = new AesUtil(xylWeChatPaymentConfig.getXylPaymentKey().getBytes(StandardCharsets.UTF_8));
plainText = aesUtil.decryptToString(associatedData.getBytes(StandardCharsets.UTF_8), nonceTwo.getBytes(StandardCharsets.UTF_8), ciphertext);
}
if (YILUYOUPIN_ACCOUNT.equals(accountFlag)) {
AesUtil aesUtil = new AesUtil(ylypWeChatPaymentConfig.getYlypPaymentKey().getBytes(StandardCharsets.UTF_8));
plainText = aesUtil.decryptToString(associatedData.getBytes(StandardCharsets.UTF_8), nonceTwo.getBytes(StandardCharsets.UTF_8), ciphertext);
}
AesUtil aesUtil = new AesUtil(xylWeChatPaymentConfig.getXylPaymentKey().getBytes(StandardCharsets.UTF_8));
String plainText = aesUtil.decryptToString(associatedData.getBytes(StandardCharsets.UTF_8), nonceTwo.getBytes(StandardCharsets.UTF_8), ciphertext);
if (StringUtils.isBlank(plainText)) {
response.setStatus(500);
resultMap.put("code", "ERROR");
@ -337,12 +306,7 @@ public class WeChatPayNotifyServiceImpl implements WeChatPayNotifyService {
paymentInfo.setWechatTradeState(StringUtils.isBlank(notifyPlaintext.getTradeState()) ? "" : notifyPlaintext.getTradeState());
paymentInfo.setPayNotifyContent(plainText);
paymentInfo.setPayTime(LocalDateTime.parse(StringUtils.isBlank(notifyPlaintext.getSuccessTime()) ? "" : notifyPlaintext.getSuccessTime(), DateTimeFormatter.ISO_DATE_TIME));
if (notifyPlaintext.getMchid().equals(xylWeChatPaymentConfig.getXylMchId())) {
paymentInfo.setPaymentMerchantType(PaymentMerchantTypeEnum.XINYILU.getInfo());
}
if (notifyPlaintext.getMchid().equals(ylypWeChatPaymentConfig.getYlypMchId())) {
paymentInfo.setPaymentMerchantType(PaymentMerchantTypeEnum.YILUYOUPIN.getInfo());
}
paymentInfo.setPaymentMerchantType(PaymentMerchantTypeEnum.XINYILU.getInfo());
paymentInfo.setDelFlag(0);
paymentInfo.setCreateTime(LocalDateTime.now());
return paymentInfo;

View File

@ -11,10 +11,8 @@ import com.xinelu.applet.vo.wechatpaymentinfo.vo.WeChatQueryOrderVO;
import com.xinelu.common.config.AppletChatConfig;
import com.xinelu.common.config.WeChatPaymentUrlConfig;
import com.xinelu.common.config.XylWeChatPaymentConfig;
import com.xinelu.common.config.YlypWeChatPaymentConfig;
import com.xinelu.common.constant.Constants;
import com.xinelu.common.core.domain.AjaxResult;
import com.xinelu.common.enums.BuySourceEnum;
import com.xinelu.common.enums.GooodsOrderStatusEnum;
import com.xinelu.common.enums.OrderStatusEnum;
import com.xinelu.common.enums.WeChatTradeStateEnum;
@ -24,7 +22,6 @@ import com.xinelu.manage.domain.goodsOrder.GoodsOrder;
import com.xinelu.manage.mapper.appointmentorder.AppointmentOrderMapper;
import com.xinelu.manage.mapper.goodsOrder.GoodsOrderMapper;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.BooleanUtils;
import org.apache.commons.lang3.StringUtils;
import org.apache.http.client.methods.CloseableHttpResponse;
import org.apache.http.client.methods.HttpGet;
@ -34,7 +31,6 @@ import org.apache.http.impl.client.CloseableHttpClient;
import org.apache.http.util.EntityUtils;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.util.Base64Utils;
import javax.annotation.Resource;
@ -42,7 +38,6 @@ import java.math.BigDecimal;
import java.nio.charset.StandardCharsets;
import java.security.PrivateKey;
import java.security.Signature;
import java.time.LocalDateTime;
import java.util.*;
import java.util.concurrent.TimeUnit;
import java.util.stream.Collectors;
@ -66,12 +61,8 @@ public class WeChatPaymentServiceImpl implements WeChatPaymentService {
private AppletChatConfig appletChatConfig;
@Resource
private XylWeChatPaymentConfig xylWeChatPaymentConfig;
@Resource
private YlypWeChatPaymentConfig ylypWeChatPaymentConfig;
@Resource(name = "xinYiLuWeChatPayClient")
private CloseableHttpClient xinYiLuWeChatPayClient;
@Resource(name = "yiLuYouPinWeChatPayClient")
private CloseableHttpClient yiLuYouPinWeChatPayClient;
@Resource
private WeChatPaymentUrlConfig weChatPaymentUrlConfig;
@Resource
@ -84,11 +75,6 @@ public class WeChatPaymentServiceImpl implements WeChatPaymentService {
*/
private static final String XIN_YI_LU_DESCRIPTION = "山东新医路信息科技有限公司";
/**
* 医路优品支付商品描述
*/
private static final String YI_LU_YOU_PIN_DESCRIPTION = "医路优品信息科技有限公司";
/**
* JsApi下单成功状态码
*/
@ -114,11 +100,6 @@ public class WeChatPaymentServiceImpl implements WeChatPaymentService {
*/
private static final String XINYILU_WE_CHAT_NOTIFY_URL = "/nurseApp/weChatPayment/xylWeChatPayNotify";
/**
* 医路优品支付回调接口地址
*/
private static final String YINLUYOUPIN_WE_CHAT_NOTIFY_URL = "/nurseApp/weChatPayment/ylypWeChatPayNotify";
/**
* 微信小程序购买商品和健康咨询支付接口
*
@ -147,7 +128,7 @@ public class WeChatPaymentServiceImpl implements WeChatPaymentService {
} else {
prepayId = redisTemplate.opsForValue().get(Constants.PREPAY_ID_KEY + paymentDTO.getOrderNo());
}
return AjaxResult.success(getSignInfo(prepayId, paymentDTO.getBuySource()));
return AjaxResult.success(getSignInfo(prepayId));
}
/**
@ -173,97 +154,7 @@ public class WeChatPaymentServiceImpl implements WeChatPaymentService {
} else {
prepayId = redisTemplate.opsForValue().get(Constants.PREPAY_ID_KEY + paymentDTO.getOrderNo());
}
return AjaxResult.success(getSignInfo(prepayId, paymentDTO.getBuySource()));
}
/**
* 取消订单接口
*
* @param orderNo 点单编号
* @param buySource 购买来源
* @return 取消结果信息
*/
@Transactional(rollbackFor = Exception.class)
@Override
public AjaxResult cancelOrderInfo(String orderNo, String buySource) throws Exception {
GoodsOrder goodsOrderInfo = goodsOrderMapper.getGoodsOrderByOrderNo(orderNo);
AppointmentOrder appointmentOrderInfo = appointmentOrderMapper.getAppointmentOrderByOrderNo(orderNo);
if (Objects.isNull(goodsOrderInfo) && Objects.isNull(appointmentOrderInfo)) {
return AjaxResult.error("当前订单信息不存在,请重新选择!");
}
//商品订单
if (Objects.nonNull(goodsOrderInfo)) {
if (StringUtils.isBlank(goodsOrderInfo.getOrderStatus())
|| !GooodsOrderStatusEnum.WAIT_PAY.getInfo().equals(goodsOrderInfo.getOrderStatus())) {
log.info("订单状态为:====> {}", StringUtils.isBlank(goodsOrderInfo.getOrderStatus()) ? "不存在" : goodsOrderInfo.getOrderStatus());
return AjaxResult.error("当前订单状态异常,请联系管理员!");
}
LocalDateTime tenAfterTime = goodsOrderInfo.getOrderTime().plusMinutes(10);
if (LocalDateTime.now().isBefore(tenAfterTime)) {
return AjaxResult.error("10分钟以后才能取消当前订单请耐心等待");
}
OrderStatusInfoVO orderStatusInfoVO = new OrderStatusInfoVO();
OrderStatusInfoVO vo = this.queryGoodsOrderStatus(goodsOrderInfo.getOrderNo(), orderStatusInfoVO, buySource);
if (BooleanUtils.isTrue(vo.getPayFlag())) {
int statusCode = this.closeWeChatOrderInfo(goodsOrderInfo.getOrderNo(), goodsOrderInfo.getBuySource());
if (!(statusCode == HAVE_BODY_SUCCESS_CODE || statusCode == NO_HAVE_BODY_SUCCESS_CODE)) {
return AjaxResult.error("取消订单失败,请联系管理员!");
}
goodsOrderMapper.updateGoodsOrderStatus(GooodsOrderStatusEnum.CANCEL.getInfo(), orderNo);
}
}
//预约服务订单信息
if (Objects.nonNull(appointmentOrderInfo)) {
if (StringUtils.isBlank(appointmentOrderInfo.getOrderStatus())
|| !OrderStatusEnum.WAIT_PAY.getInfo().equals(appointmentOrderInfo.getOrderStatus())) {
log.info("订单状态为:====> {}", StringUtils.isBlank(appointmentOrderInfo.getOrderStatus()) ? "不存在" : appointmentOrderInfo.getOrderStatus());
return AjaxResult.error("当前订单状态异常,请联系管理员!");
}
LocalDateTime tenAfterTime = appointmentOrderInfo.getCreateTime().plusMinutes(10);
if (LocalDateTime.now().isBefore(tenAfterTime)) {
return AjaxResult.error("10分钟以后才能取消当前订单请耐心等待");
}
OrderStatusInfoVO orderStatusInfoVO = new OrderStatusInfoVO();
OrderStatusInfoVO vo = this.queryAppointmentOrderStatus(appointmentOrderInfo.getOrderNo(), orderStatusInfoVO);
if (BooleanUtils.isTrue(vo.getPayFlag())) {
int statusCode = this.closeWeChatOrderInfo(appointmentOrderInfo.getOrderNo(), BuySourceEnum.NURSE_STATION.getInfo());
if (!(statusCode == HAVE_BODY_SUCCESS_CODE || statusCode == NO_HAVE_BODY_SUCCESS_CODE)) {
return AjaxResult.error("取消订单失败,请联系管理员!");
}
appointmentOrderMapper.updateAppointmentOrderStatus(OrderStatusEnum.CANCEL.getInfo(), orderNo);
}
}
return AjaxResult.success("取消订单成功!");
}
/**
* 查询订单状态信息
*
* @param orderNo 点单编号
* @param buySource 购买来源
* @return 结果信息
* @throws Exception 异常信息
*/
@Override
public AjaxResult getOrderStatusInfo(String orderNo, String buySource) throws Exception {
OrderStatusInfoVO vo = new OrderStatusInfoVO();
GoodsOrder goodsOrder = goodsOrderMapper.getGoodsOrderByOrderNo(orderNo);
AppointmentOrder appointmentOrder = appointmentOrderMapper.getAppointmentOrderByOrderNo(orderNo);
if (Objects.isNull(goodsOrder) && Objects.isNull(appointmentOrder)) {
vo.setPayFlag(true);
return AjaxResult.success(vo);
}
//预约服务订单不为空调用微信查单接口确认订单状态
if (Objects.nonNull(appointmentOrder)) {
OrderStatusInfoVO order = new OrderStatusInfoVO();
vo = this.queryAppointmentOrderStatus(appointmentOrder.getOrderNo(), order);
}
//商品订单不为空调用微信查单接口确认订单状态
if (Objects.nonNull(goodsOrder)) {
OrderStatusInfoVO order = new OrderStatusInfoVO();
vo = this.queryGoodsOrderStatus(goodsOrder.getOrderNo(), order, buySource);
}
return AjaxResult.success(vo);
return AjaxResult.success(getSignInfo(prepayId));
}
/**
@ -279,28 +170,13 @@ public class WeChatPaymentServiceImpl implements WeChatPaymentService {
String closeUrl = String.format(weChatPaymentUrlConfig.getCloseOrderUrl(), orderNo);
HttpPost httpPost = new HttpPost(closeUrl);
Map<String, Object> paramMap = new HashMap<>();
String jsonParams;
CloseableHttpResponse response = null;
if (BuySourceEnum.NURSE_STATION.getInfo().equals(buySource)) {
paramMap.put("mchid", xylWeChatPaymentConfig.getXylMchId());
jsonParams = JSON.toJSONString(paramMap);
StringEntity entity = new StringEntity(jsonParams, "utf-8");
entity.setContentType("application/json");
httpPost.setEntity(entity);
httpPost.setHeader("Accept", "application/json");
response = xinYiLuWeChatPayClient.execute(httpPost);
}
if (BuySourceEnum.SHOPPING_MALL.getInfo().equals(buySource)
|| BuySourceEnum.HEALTH_CONSULTATION.getInfo().equals(buySource) || BuySourceEnum.TRAINING.getInfo().equals(buySource)) {
paramMap.put("mchid", ylypWeChatPaymentConfig.getYlypMchId());
jsonParams = JSON.toJSONString(paramMap);
StringEntity entity = new StringEntity(jsonParams, "utf-8");
entity.setContentType("application/json");
httpPost.setEntity(entity);
httpPost.setHeader("Accept", "application/json");
response = yiLuYouPinWeChatPayClient.execute(httpPost);
}
try {
paramMap.put("mchid", xylWeChatPaymentConfig.getXylMchId());
String jsonParams = JSON.toJSONString(paramMap);
StringEntity entity = new StringEntity(jsonParams, "utf-8");
entity.setContentType("application/json");
httpPost.setEntity(entity);
httpPost.setHeader("Accept", "application/json");
try (CloseableHttpResponse response = xinYiLuWeChatPayClient.execute(httpPost)) {
if (response == null) {
throw new ServiceException("获取微信HttpClient对象失败请联系管理员");
}
@ -316,10 +192,6 @@ public class WeChatPaymentServiceImpl implements WeChatPaymentService {
throw new ServiceException("微信关闭订单失败!");
}
return statusCode;
} finally {
if (response != null) {
response.close();
}
}
}
@ -363,27 +235,11 @@ public class WeChatPaymentServiceImpl implements WeChatPaymentService {
* @param vo 返回值信息
*/
@Override
public OrderStatusInfoVO queryGoodsOrderStatus(String orderNo, OrderStatusInfoVO vo,
String buySource) throws Exception {
String requestUrl = "";
if (BuySourceEnum.NURSE_STATION.getInfo().equals(buySource)) {
requestUrl = String.format(weChatPaymentUrlConfig.getQueryMchIdUrl(), orderNo).concat("?mchid=").concat(xylWeChatPaymentConfig.getXylMchId());
}
if (BuySourceEnum.SHOPPING_MALL.getInfo().equals(buySource)
|| BuySourceEnum.HEALTH_CONSULTATION.getInfo().equals(buySource) || BuySourceEnum.TRAINING.getInfo().equals(buySource)) {
requestUrl = String.format(weChatPaymentUrlConfig.getQueryMchIdUrl(), orderNo).concat("?mchid=").concat(ylypWeChatPaymentConfig.getYlypMchId());
}
public OrderStatusInfoVO queryGoodsOrderStatus(String orderNo, OrderStatusInfoVO vo, String buySource) {
String requestUrl = String.format(weChatPaymentUrlConfig.getQueryMchIdUrl(), orderNo).concat("?mchid=").concat(xylWeChatPaymentConfig.getXylMchId());
HttpGet httpGet = new HttpGet(requestUrl);
httpGet.setHeader("Accept", "application/json");
CloseableHttpResponse response = null;
try {
if (BuySourceEnum.NURSE_STATION.getInfo().equals(buySource)) {
response = xinYiLuWeChatPayClient.execute(httpGet);
}
if (BuySourceEnum.SHOPPING_MALL.getInfo().equals(buySource)
|| BuySourceEnum.HEALTH_CONSULTATION.getInfo().equals(buySource) || BuySourceEnum.TRAINING.getInfo().equals(buySource)) {
response = yiLuYouPinWeChatPayClient.execute(httpGet);
}
try (CloseableHttpResponse response = xinYiLuWeChatPayClient.execute(httpGet)) {
if (response == null) {
throw new ServiceException("获取微信HttpClient对象失败请联系管理员");
}
@ -403,10 +259,6 @@ public class WeChatPaymentServiceImpl implements WeChatPaymentService {
} catch (Exception e) {
log.error("请求微信查单接口异常,异常信息为 ====> {}", e.getMessage());
throw new ServiceException("查询商品订单状态失败,请联系管理员!");
} finally {
if (response != null) {
response.close();
}
}
}
@ -419,20 +271,11 @@ public class WeChatPaymentServiceImpl implements WeChatPaymentService {
*/
private String buildGoodsOrderJsApiParams(PaymentDTO paymentDTO, GoodsOrder goodsOrderInfo) {
Map<String, Object> paramMap = new LinkedHashMap<>();
if (BuySourceEnum.NURSE_STATION.getInfo().equals(paymentDTO.getBuySource())) {
paramMap.put("mchid", xylWeChatPaymentConfig.getXylMchId());
paramMap.put("out_trade_no", goodsOrderInfo.getOrderNo());
paramMap.put("appid", appletChatConfig.getAppletId());
paramMap.put("description", XIN_YI_LU_DESCRIPTION);
paramMap.put("notify_url", xylWeChatPaymentConfig.getXylWeChatNotifyUrl() + XINYILU_WE_CHAT_NOTIFY_URL);
}
if (BuySourceEnum.SHOPPING_MALL.getInfo().equals(paymentDTO.getBuySource()) || BuySourceEnum.HEALTH_CONSULTATION.getInfo().equals(paymentDTO.getBuySource())) {
paramMap.put("mchid", ylypWeChatPaymentConfig.getYlypMchId());
paramMap.put("out_trade_no", goodsOrderInfo.getOrderNo());
paramMap.put("appid", appletChatConfig.getAppletId());
paramMap.put("description", YI_LU_YOU_PIN_DESCRIPTION);
paramMap.put("notify_url", ylypWeChatPaymentConfig.getYlypWeChatNotifyUrl() + YINLUYOUPIN_WE_CHAT_NOTIFY_URL);
}
paramMap.put("mchid", xylWeChatPaymentConfig.getXylMchId());
paramMap.put("out_trade_no", goodsOrderInfo.getOrderNo());
paramMap.put("appid", appletChatConfig.getAppletId());
paramMap.put("description", XIN_YI_LU_DESCRIPTION);
paramMap.put("notify_url", xylWeChatPaymentConfig.getXylWeChatNotifyUrl() + XINYILU_WE_CHAT_NOTIFY_URL);
Map<String, Object> amountParamMap = new LinkedHashMap<>();
int totalPrice = paymentDTO.getPaymentPrice().multiply(BigDecimal.valueOf(100)).intValue();
amountParamMap.put("total", totalPrice);
@ -451,30 +294,16 @@ public class WeChatPaymentServiceImpl implements WeChatPaymentService {
* @param paymentDTO 输入参数
* @param prepayId JsAp下单接口返回值
* @return 结果
* @throws Exception 异常信息
*/
private String requestJsApiInterface(String jsApiParams, PaymentDTO paymentDTO, String prepayId) throws Exception {
private String requestJsApiInterface(String jsApiParams, PaymentDTO paymentDTO, String prepayId) {
StringEntity stringEntity = new StringEntity(jsApiParams, StandardCharsets.UTF_8);
stringEntity.setContentType("application/json");
HttpPost httpPost = new HttpPost(weChatPaymentUrlConfig.getJsapiPalceOrderUrl());
httpPost.setEntity(stringEntity);
httpPost.setHeader("Accept", "application/json");
CloseableHttpResponse response = null;
String payAccount = "";
try {
if (BuySourceEnum.NURSE_STATION.getInfo().equals(paymentDTO.getBuySource())) {
response = xinYiLuWeChatPayClient.execute(httpPost);
payAccount = "山东新医路信息科技有限公司";
}
//泉医会员小程序中的商城订单健康咨询订单泉医助手学习培训订单都使用医路优品账户进行支付
if (BuySourceEnum.SHOPPING_MALL.getInfo().equals(paymentDTO.getBuySource())
|| BuySourceEnum.HEALTH_CONSULTATION.getInfo().equals(paymentDTO.getBuySource())
|| BuySourceEnum.TRAINING.getInfo().equals(paymentDTO.getBuySource())) {
response = yiLuYouPinWeChatPayClient.execute(httpPost);
payAccount = "医路优品信息科技有限公司";
}
try (CloseableHttpResponse response = xinYiLuWeChatPayClient.execute(httpPost)) {
if (Objects.isNull(response)) {
log.error("JsApi下单接口执行错误 执行账户为 ====> {}", payAccount);
log.error("JsApi下单接口执行错误 执行账户为 ====> 山东新医路信息科技有限公司");
throw new ServiceException("JsApi下单接口执行异常请联系管理员");
}
int statusCode = response.getStatusLine().getStatusCode();
@ -492,10 +321,6 @@ public class WeChatPaymentServiceImpl implements WeChatPaymentService {
} catch (Exception e) {
log.error("JsApi下单失败失败原因 =====> {}", e.getMessage());
throw new ServiceException("JsApi下单失败请联系管理员");
} finally {
if (response != null) {
response.close();
}
}
return prepayId;
}
@ -503,27 +328,16 @@ public class WeChatPaymentServiceImpl implements WeChatPaymentService {
/**
* 构建微信小程序调起支付参数设置
*
* @param prepayId jsapi下单返回参数信息
* @param buySource 购买来源
* @param prepayId jsapi下单返回参数信息
* @return 参数信息
* @throws Exception 异常信息
*/
private WeChatAppletSignVO getSignInfo(String prepayId, String buySource) throws Exception {
private WeChatAppletSignVO getSignInfo(String prepayId) throws Exception {
String appId = appletChatConfig.getAppletId();
String nonceStr = UUID.randomUUID().toString().replace("-", "");
String timestamp = String.valueOf(System.currentTimeMillis() / 1000);
PrivateKey privateKey = null;
//泉医到家小程序中的护理站模块的支付账户均使用新医路账户进行支付
if (BuySourceEnum.NURSE_STATION.getInfo().equals(buySource)) {
privateKey = weChatUtil.getPrivateKey(xylWeChatPaymentConfig.getXylPrivateKeyPath());
}
//泉医到家小程序中的商城模块和健康咨询模块以及泉医助手中的学习培训模块使用医路优品账户进行支付
if (BuySourceEnum.SHOPPING_MALL.getInfo().equals(buySource)
|| BuySourceEnum.HEALTH_CONSULTATION.getInfo().equals(buySource)
|| BuySourceEnum.TRAINING.getInfo().equals(buySource)) {
privateKey = weChatUtil.getPrivateKey(ylypWeChatPaymentConfig.getYlypPrivateKeyPath());
}
if (privateKey == null) {
PrivateKey privateKey = weChatUtil.getPrivateKey(xylWeChatPaymentConfig.getXylPrivateKeyPath());
if (Objects.isNull(privateKey)) {
throw new ServiceException("获取商户私钥失败,请联系管理员!");
}
prepayId = "prepay_id=" + prepayId;

View File

@ -8,7 +8,6 @@ import com.xinelu.applet.vo.wechatpaymentinfo.dto.RefundDTO;
import com.xinelu.applet.vo.wechatpaymentinfo.vo.WeChatRefundInfoVO;
import com.xinelu.common.config.WeChatPaymentUrlConfig;
import com.xinelu.common.config.XylWeChatPaymentConfig;
import com.xinelu.common.config.YlypWeChatPaymentConfig;
import com.xinelu.common.core.domain.AjaxResult;
import com.xinelu.common.enums.*;
import com.xinelu.common.exception.ServiceException;
@ -58,12 +57,8 @@ public class WeChatRefundServiceImpl implements WeChatRefundService {
private AppointmentOrderMapper appointmentOrderMapper;
@Resource
private XylWeChatPaymentConfig xylWeChatPaymentConfig;
@Resource
private YlypWeChatPaymentConfig ylypWeChatPaymentConfig;
@Resource(name = "xinYiLuWeChatPayClient")
private CloseableHttpClient xinYiLuWeChatPayClient;
@Resource(name = "yiLuYouPinWeChatPayClient")
private CloseableHttpClient yiLuYouPinWeChatPayClient;
@Resource
private WeChatPaymentUrlConfig weChatPaymentUrlConfig;
@Resource
@ -90,21 +85,15 @@ public class WeChatRefundServiceImpl implements WeChatRefundService {
*/
private static final String XINYILU_WE_CHAT_REFUND_URL = "/nurseApp/weChatPayment/xylWeChatRefundNotify";
/**
* 医路优品退款回调接口地址
*/
private static final String YINLUYOUPIN_WE_CHAT_REFUND_URL = "/nurseApp/weChatPayment/ylypWeChatRefundNotify";
/**
* 微信确认退款接口
*
* @param refundDTO 退款参数
* @return 退款申请结果
* @throws Exception 异常信息
*/
@Transactional(rollbackFor = Exception.class)
@Override
public AjaxResult weChatRefundOrderApply(RefundDTO refundDTO) throws Exception {
public AjaxResult weChatRefundOrderApply(RefundDTO refundDTO) {
if (StringUtils.isNotBlank(refundDTO.getOrderType()) && StringUtils.equals(OrderTypeEnum.INTEGRAL_EXCHANGE.getInfo(), refundDTO.getOrderType())) {
return refundPointsRedemption(refundDTO);
}
@ -188,23 +177,14 @@ public class WeChatRefundServiceImpl implements WeChatRefundService {
* @param refundNo 退单编号
* @param buySource 购买来源
* @return 退款信息
* @throws Exception 异常信息
*/
@Override
public WeChatRefundInfoVO queryGoodsOrderRefundStatus(String refundNo, String buySource) throws Exception {
public WeChatRefundInfoVO queryGoodsOrderRefundStatus(String refundNo, String buySource) {
WeChatRefundInfoVO weChatRefundInfoVO = new WeChatRefundInfoVO();
String requestUrl = String.format(weChatPaymentUrlConfig.getRefundQueryOrderUrl(), refundNo);
HttpGet httpGet = new HttpGet(requestUrl);
httpGet.setHeader("Accept", "application/json");
CloseableHttpResponse response = null;
try {
if (BuySourceEnum.NURSE_STATION.getInfo().equals(buySource)) {
response = xinYiLuWeChatPayClient.execute(httpGet);
}
if (BuySourceEnum.SHOPPING_MALL.getInfo().equals(buySource)
|| BuySourceEnum.HEALTH_CONSULTATION.getInfo().equals(buySource) || BuySourceEnum.TRAINING.getInfo().equals(buySource)) {
response = yiLuYouPinWeChatPayClient.execute(httpGet);
}
try (CloseableHttpResponse response = xinYiLuWeChatPayClient.execute(httpGet)) {
if (response == null) {
throw new ServiceException("获取微信HttpClient对象失败请联系管理员");
}
@ -221,10 +201,6 @@ public class WeChatRefundServiceImpl implements WeChatRefundService {
} catch (Exception e) {
log.error("请求微信查询单笔退款接口,异常信息为 ====> {}", e.getMessage());
throw new ServiceException("查询商品订单状态失败,请联系管理员!");
} finally {
if (response != null) {
response.close();
}
}
}
@ -261,21 +237,12 @@ public class WeChatRefundServiceImpl implements WeChatRefundService {
paramMap.put("out_trade_no", refundDTO.getOrderNo());
paramMap.put("out_refund_no", outRefundNo);
Map<String, Object> amountMap = new LinkedHashMap<>();
//回调通知地址和退款金额预约订单使用新医路账户
paramMap.put("notify_url", xylWeChatPaymentConfig.getXylWeChatNotifyUrl() + XINYILU_WE_CHAT_REFUND_URL);
amountMap.put("refund", refundDTO.getRefundPrice().multiply(BigDecimal.valueOf(100)).intValue());
if (Objects.nonNull(appointmentOrderInfo) && Objects.isNull(goodsOrderInfo)) {
paramMap.put("notify_url", xylWeChatPaymentConfig.getXylWeChatNotifyUrl() + XINYILU_WE_CHAT_REFUND_URL);
amountMap.put("refund", refundDTO.getRefundPrice().multiply(BigDecimal.valueOf(100)).intValue());
amountMap.put("total", appointmentOrderInfo.getTotalPrice().multiply(BigDecimal.valueOf(100)).intValue());
}
//护理站商品购买订单使用新医路账户商城商品订单和健康咨询订单使用医路优品账户
if (Objects.nonNull(goodsOrderInfo) && Objects.isNull(appointmentOrderInfo)) {
if (BuySourceEnum.NURSE_STATION.getInfo().equals(goodsOrderInfo.getBuySource())) {
paramMap.put("notify_url", xylWeChatPaymentConfig.getXylWeChatNotifyUrl() + XINYILU_WE_CHAT_REFUND_URL);
}
if (BuySourceEnum.SHOPPING_MALL.getInfo().equals(goodsOrderInfo.getBuySource()) || BuySourceEnum.HEALTH_CONSULTATION.getInfo().equals(goodsOrderInfo.getBuySource())) {
paramMap.put("notify_url", ylypWeChatPaymentConfig.getYlypWeChatNotifyUrl() + YINLUYOUPIN_WE_CHAT_REFUND_URL);
}
amountMap.put("refund", refundDTO.getRefundPrice().multiply(BigDecimal.valueOf(100)).intValue());
amountMap.put("total", goodsOrderInfo.getTotalPrice().multiply(BigDecimal.valueOf(100)).intValue());
}
amountMap.put("currency", "CNY");
@ -291,35 +258,17 @@ public class WeChatRefundServiceImpl implements WeChatRefundService {
* @param goodsOrderInfo 商品订单信息
* @param patientId 会员id
* @param refundDTO 申请信息
* @throws Exception 异常信息
*/
public void applyWeRefund(String refundParam, AppointmentOrder appointmentOrderInfo, GoodsOrder goodsOrderInfo,
Long patientId, RefundDTO refundDTO) throws Exception {
public void applyWeRefund(String refundParam, AppointmentOrder appointmentOrderInfo,
GoodsOrder goodsOrderInfo, Long patientId, RefundDTO refundDTO) {
String requestUrl = weChatPaymentUrlConfig.getRefundApplyUrl();
HttpPost httpPost = new HttpPost(requestUrl);
StringEntity entity = new StringEntity(refundParam, "utf-8");
entity.setContentType("application/json");
httpPost.setEntity(entity);
httpPost.setHeader("Accept", "application/json");
CloseableHttpResponse response = null;
String refundMerchantType = "";
try {
//预约订单使用新医路账户
if (Objects.nonNull(appointmentOrderInfo) && Objects.isNull(goodsOrderInfo)) {
response = xinYiLuWeChatPayClient.execute(httpPost);
refundMerchantType = PaymentMerchantTypeEnum.XINYILU.getInfo();
}
//护理站商品购买订单使用新医路账户商城商品订单和健康咨询订单使用医路优品账户
if (Objects.nonNull(goodsOrderInfo) && Objects.isNull(appointmentOrderInfo)) {
if (BuySourceEnum.NURSE_STATION.getInfo().equals(goodsOrderInfo.getBuySource())) {
response = xinYiLuWeChatPayClient.execute(httpPost);
refundMerchantType = PaymentMerchantTypeEnum.XINYILU.getInfo();
}
if (BuySourceEnum.SHOPPING_MALL.getInfo().equals(goodsOrderInfo.getBuySource()) || BuySourceEnum.HEALTH_CONSULTATION.getInfo().equals(goodsOrderInfo.getBuySource())) {
response = yiLuYouPinWeChatPayClient.execute(httpPost);
refundMerchantType = PaymentMerchantTypeEnum.YILUYOUPIN.getInfo();
}
}
String refundMerchantType = PaymentMerchantTypeEnum.XINYILU.getInfo();
try (CloseableHttpResponse response = xinYiLuWeChatPayClient.execute(httpPost)) {
if (Objects.isNull(response)) {
throw new ServiceException("获取httpclient对象失败");
}
@ -345,10 +294,6 @@ public class WeChatRefundServiceImpl implements WeChatRefundService {
}
} catch (Exception e) {
log.error("微信申请退款接口出错,原因:{}", e.getMessage());
} finally {
if (response != null) {
response.close();
}
}
}

View File

@ -7,6 +7,7 @@ import java.io.Serializable;
import java.math.BigDecimal;
import java.time.LocalDateTime;
import java.util.Date;
import java.util.List;
/**
@ -174,6 +175,10 @@ public class AppletGoodsOrderVO implements Serializable {
*/
private String orderType;
/**
* 订单类型积分兑换INTEGRAL_EXCHANGE直接购买DIRECT_BUY健康咨询HEALTH_CONSULTATION
*/
private List<String> orderTypeList;
/**
* 积分抵扣数量

View File

@ -75,7 +75,6 @@ public class NursingOrderInfoVO extends BaseDomain implements Serializable {
*/
private BigDecimal nurseItemPrice;
/**
* 是否删除标识01
*/

View File

@ -0,0 +1,63 @@
package com.xinelu.applet.vo.nursingorder;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import java.io.Serializable;
import java.time.LocalDateTime;
/**
* @Description 服务评价
* @Author zhangheng
* @Date 2022-10-18
*/
@Data
public class PatientOrder implements Serializable {
/**
* 被护理人信息表id
*/
@ApiModelProperty(value = "被护理人信息表id")
private Long patientId;
/**
* 预约订单编号
*/
@ApiModelProperty(value = "订单编号")
private String orderNo;
/**
* 预约订单状态
*/
@ApiModelProperty(value = "订单状态")
private String orderStatus;
/**
* 下单时间
*/
private LocalDateTime createTime;
/**
* 订单名称
*/
@ApiModelProperty(value = "订单名称")
private String orderName;
/**
* 护理站护理项目表id
*/
@ApiModelProperty(value = "护理站护理项目表id")
private Long nurseStationItemId;
/**
* 护理项目图片地址
*/
@ApiModelProperty(value = "护理项目图片地址")
private String pictureUrl;
/**
* 订单类型
*/
private String orderType;
}

View File

@ -155,6 +155,9 @@
<if test="orderType != null and orderType != ''">
and gr.order_type = #{orderType}
</if>
<if test="orderType = null and orderType = ''">
and gr.order_type IN #{orderTypeList}
</if>
and gr.del_flag = 0
and god.del_flag = 0
</where>
@ -272,63 +275,108 @@
<select id="getAppointmentOrderDetailsInfo" resultMap="getAppointmentDetailsResultMap">
SELECT pi.patient_name,
pi.phone patientPhone,
aor.id appointmentOrderId,
aor.patient_id,
aor.order_no,
aor.total_price,
aor.order_status,
aor.remark,
aor.create_time,
aor.order_type,
aor.companion_start_date,
aor.companion_end_date,
aor.companion_days,
aor.order_write_name,
aod.nurse_station_item_id,
aod.service_address,
aod.service_date,
aod.service_start_time,
aod.service_end_time,
aod.nurse_item_name,
aod.nurse_item_price,
aod.item_serve_duration_unit,
aod.consumable_total_price,
aoc.id,
aoc.appoint_order_details_id,
aoc.order_consumable_name,
aoc.order_consumable_price,
aoc.order_consumable_count,
aoc.consumable_unit,
aod.disabling_condition,
aod.disabling_reason,
aod.caregiver_name,
aod.caregiver_phone,
aod.hospital_name,
aod.department_name,
aod.hospital_bed_number
FROM appointment_order aor
LEFT JOIN appointment_order_details aod ON aor.order_no = aod.order_no
LEFT JOIN appointment_order_consumable aoc ON aod.id = aoc.appoint_order_details_id
LEFT JOIN patient_info pi ON pi.id = aor.patient_id
where aor.order_no = #{ordeNo}
AND aor.del_flag = 0
and aod.del_flag = 0
SELECT pi.patient_name,
pi.phone patientPhone,
aor.id appointmentOrderId,
aor.patient_id,
aor.order_no,
aor.total_price,
aor.order_status,
aor.remark,
aor.create_time,
aor.order_type,
aor.companion_start_date,
aor.companion_end_date,
aor.companion_days,
aor.order_write_name,
aod.nurse_station_item_id,
aod.service_address,
aod.service_date,
aod.service_start_time,
aod.service_end_time,
aod.nurse_item_name,
aod.nurse_item_price,
aod.item_serve_duration_unit,
aod.consumable_total_price,
aoc.id,
aoc.appoint_order_details_id,
aoc.order_consumable_name,
aoc.order_consumable_price,
aoc.order_consumable_count,
aoc.consumable_unit,
aod.disabling_condition,
aod.disabling_reason,
aod.caregiver_name,
aod.caregiver_phone,
aod.hospital_name,
aod.department_name,
aod.hospital_bed_number
FROM appointment_order aor
LEFT JOIN appointment_order_details aod ON aor.order_no = aod.order_no
LEFT JOIN appointment_order_consumable aoc ON aod.id = aoc.appoint_order_details_id
LEFT JOIN patient_info pi ON pi.id = aor.patient_id
where aor.order_no = #{ordeNo}
AND aor.del_flag = 0
and aod.del_flag = 0
</select>
<select id="getNurseStationByItemId"
resultType="com.xinelu.applet.vo.specialdisease.AppointmentOrderDetailsInfoVO">
SELECT ns.nurse_station_name nurseStationName,
ns.phone stationPhone,
ns.address,
ns.station_picture_url,
nsi.item_picture_url
FROM nurse_station_item nsi
LEFT JOIN nurse_station ns ON nsi.nurse_station_id = ns.id
WHERE nsi.id = #{nurseStationItemId}
SELECT ns.nurse_station_name nurseStationName,
ns.phone stationPhone,
ns.address,
ns.station_picture_url,
nsi.item_picture_url
FROM nurse_station_item nsi
LEFT JOIN nurse_station ns ON nsi.nurse_station_id = ns.id
WHERE nsi.id = #{nurseStationItemId}
</select>
<select id="getAppointmentOrderListByParentId" resultType="com.xinelu.applet.vo.nursingorder.PatientOrder">
SELECT
ao.patient_id,
ao.order_no,
ao.order_status,
ao.create_time,
aod.nurse_item_name orderName,
nsi.item_picture_url pictureUrl,
'APPOINTMENT_ORDER' AS orderType
FROM
appointment_order ao
LEFT JOIN appointment_order_details aod ON ao.order_no = aod.order_no
LEFT JOIN nurse_station_item nsi ON nsi.id = aod.nurse_station_item_id
where
ao.order_status = #{orderStatus}
and ao.patient_id = #{patientId}
and ao.del_flag = 0
</select>
<select id="getGoodsOrderAndConsultationOrder"
resultType="com.xinelu.applet.vo.nursingorder.PatientOrder">
SELECT
gor.patient_id,
gor.order_no,
gor.order_status,
gor.order_time,
gor.order_type,
god.goods_name orderName,
gad.attribute_piture_url pictureUrl,
hpi.person_picture_url
FROM
goods_order gor
LEFT JOIN goods_order_details god ON god.order_no = gor.order_no
LEFT JOIN goods_attribute_details gad ON gad.id = god.goods_attribute_details_id
LEFT JOIN hospital_person_info hpi ON hpi.id = gor.hospital_person_id
where
gor.order_status = #{orderStatus}
and gor.patient_id = #{patientId}
and gor.del_flag = 0
</select>
</mapper>

View File

@ -11,8 +11,6 @@ public interface RefundInfoTaskService {
/**
* 自动处理退款状态定时任务
* 防止由于网络等其它原因未接受到退款回调通知进而导致的退款单状态修改不及时
*
* @throws Exception 异常信息
*/
void automaticProcessRefundInfo() throws Exception;
void automaticProcessRefundInfo();
}

View File

@ -5,8 +5,6 @@ import com.xinelu.applet.service.goodstock.GoodsStockService;
import com.xinelu.applet.service.wechatpaymentinfo.WeChatPaymentService;
import com.xinelu.applet.vo.wechatpaymentinfo.vo.OrderStatusInfoVO;
import com.xinelu.applet.vo.wechatpaymentinfo.vo.WeChatQueryOrderVO;
import com.xinelu.common.config.XylWeChatPaymentConfig;
import com.xinelu.common.config.YlypWeChatPaymentConfig;
import com.xinelu.common.constant.Constants;
import com.xinelu.common.enums.*;
import com.xinelu.manage.domain.appointmentorder.AppointmentOrder;
@ -50,7 +48,6 @@ import java.util.stream.Collectors;
@Slf4j
@Service
public class PaymentInfoTaskServiceImpl implements PaymentInfoTaskService {
@Resource
private AppointmentOrderMapper appointmentOrderMapper;
@Resource
@ -59,10 +56,6 @@ public class PaymentInfoTaskServiceImpl implements PaymentInfoTaskService {
private WeChatPaymentService weChatPaymentService;
@Resource
private PaymentInfoMapper paymentInfoMapper;
@Resource
private XylWeChatPaymentConfig xylWeChatPaymentConfig;
@Resource
private YlypWeChatPaymentConfig ylypWeChatPaymentConfig;
@Resource(name = "transactionManager")
private DataSourceTransactionManager transactionManager;
@Resource
@ -350,12 +343,7 @@ public class PaymentInfoTaskServiceImpl implements PaymentInfoTaskService {
paymentInfo.setWechatTradeState(StringUtils.isBlank(weChatQueryOrderVO.getTradeState()) ? "" : weChatQueryOrderVO.getTradeState());
paymentInfo.setPayNotifyContent(JSON.toJSON(weChatQueryOrderVO).toString());
paymentInfo.setPayTime(LocalDateTime.parse(StringUtils.isBlank(weChatQueryOrderVO.getSuccessTime()) ? "" : weChatQueryOrderVO.getSuccessTime(), DateTimeFormatter.ISO_DATE_TIME));
if (weChatQueryOrderVO.getMchid().equals(xylWeChatPaymentConfig.getXylMchId())) {
paymentInfo.setPaymentMerchantType(PaymentMerchantTypeEnum.XINYILU.getInfo());
}
if (weChatQueryOrderVO.getMchid().equals(ylypWeChatPaymentConfig.getYlypMchId())) {
paymentInfo.setPaymentMerchantType(PaymentMerchantTypeEnum.YILUYOUPIN.getInfo());
}
paymentInfo.setPaymentMerchantType(PaymentMerchantTypeEnum.XINYILU.getInfo());
paymentInfo.setDelFlag(0);
paymentInfo.setCreateTime(LocalDateTime.now());
return paymentInfo;
@ -382,5 +370,4 @@ public class PaymentInfoTaskServiceImpl implements PaymentInfoTaskService {
}
}
}
}

View File

@ -59,11 +59,9 @@ public class RefundInfoTaskServiceImpl implements RefundInfoTaskService {
/**
* 自动处理退款状态定时任务每15分钟执行一次
* 防止由于网络等其它原因未接受到退款回调通知进而导致的退款单状态修改不及时
*
* @throws Exception 异常信息
*/
@Override
public void automaticProcessRefundInfo() throws Exception {
public void automaticProcessRefundInfo() {
List<RefundOrderInfoVO> appointmentOrderList = appointmentOrderMapper.getRefundAppointmentOrderInfo(OrderStatusEnum.WAIT_REFUND.getInfo(), RefundStatusEnum.PROCESSING.getInfo(), ConfirmRefundStatusEnum.CONFIRMED.getInfo());
List<RefundOrderInfoVO> refundGoodsOrderLit = goodsOrderMapper.getRefundGoodsOrderInfo(GooodsOrderStatusEnum.WAIT_REFUND.getInfo(), RefundStatusEnum.PROCESSING.getInfo(), ConfirmRefundStatusEnum.CONFIRMED.getInfo());
if (CollectionUtils.isEmpty(appointmentOrderList) && CollectionUtils.isEmpty(refundGoodsOrderLit)) {
@ -131,9 +129,8 @@ public class RefundInfoTaskServiceImpl implements RefundInfoTaskService {
* 处理退款成功的商品订单信息
*
* @param refundGoodsOrderLit 商品退款订单信息
* @throws Exception 异常信息
*/
private void processGoodsRefundInfo(List<RefundOrderInfoVO> refundGoodsOrderLit) throws Exception {
private void processGoodsRefundInfo(List<RefundOrderInfoVO> refundGoodsOrderLit) {
List<String> orderNoList = Lists.newArrayList();
for (RefundOrderInfoVO refundOrderInfoVO : refundGoodsOrderLit) {
if (StringUtils.isBlank(refundOrderInfoVO.getOrderNo())

View File

@ -22,10 +22,8 @@ public class RefundInfoTask {
/**
* 自动处理退款状态定时任务
* 防止由于网络等其它原因未接受到退款回调通知进而导致的退款单状态修改不及时
*
* @throws Exception 异常信息
*/
public void automaticProcessRefundInfo() throws Exception {
public void automaticProcessRefundInfo() {
log.info("开始执行关闭退款状态定时任务........");
refundInfoTaskService.automaticProcessRefundInfo();
log.info("完成关闭退款状态定时任务........");