diff --git a/xinelu-admin/src/main/resources/application.yml b/xinelu-admin/src/main/resources/application.yml index 9c42939..05c60c8 100644 --- a/xinelu-admin/src/main/resources/application.yml +++ b/xinelu-admin/src/main/resources/application.yml @@ -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 diff --git a/xinelu-admin/src/main/resources/yiluyoupin_apiclient_key.pem b/xinelu-admin/src/main/resources/yiluyoupin_apiclient_key.pem deleted file mode 100644 index cf65f27..0000000 --- a/xinelu-admin/src/main/resources/yiluyoupin_apiclient_key.pem +++ /dev/null @@ -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----- diff --git a/xinelu-common/src/main/java/com/xinelu/common/config/YlypWeChatPaymentConfig.java b/xinelu-common/src/main/java/com/xinelu/common/config/YlypWeChatPaymentConfig.java deleted file mode 100644 index ea976a4..0000000 --- a/xinelu-common/src/main/java/com/xinelu/common/config/YlypWeChatPaymentConfig.java +++ /dev/null @@ -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; -} diff --git a/xinelu-common/src/main/java/com/xinelu/common/enums/GooodsOrderStatusEnum.java b/xinelu-common/src/main/java/com/xinelu/common/enums/GooodsOrderStatusEnum.java index 7315df9..79dacf1 100644 --- a/xinelu-common/src/main/java/com/xinelu/common/enums/GooodsOrderStatusEnum.java +++ b/xinelu-common/src/main/java/com/xinelu/common/enums/GooodsOrderStatusEnum.java @@ -60,6 +60,11 @@ public enum GooodsOrderStatusEnum { * 已评价 */ EVALUATED("EVALUATED"), + + /** + * 已完成 + */ + COMPLETED("COMPLETED"), ; final private String info; diff --git a/xinelu-framework/src/main/java/com/xinelu/framework/config/YlypWeChatPaymentUtilConfig.java b/xinelu-framework/src/main/java/com/xinelu/framework/config/YlypWeChatPaymentUtilConfig.java deleted file mode 100644 index 0507f18..0000000 --- a/xinelu-framework/src/main/java/com/xinelu/framework/config/YlypWeChatPaymentUtilConfig.java +++ /dev/null @@ -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("医路优品商户私钥文件不存在,请联系管理员!"); - } - } -} diff --git a/xinelu-nurse-applet/src/main/java/com/xinelu/applet/controller/appletscreeningrecord/AppletScreeningRecordController.java b/xinelu-nurse-applet/src/main/java/com/xinelu/applet/controller/appletscreeningrecord/AppletScreeningRecordController.java index 01e2e41..7f9531a 100644 --- a/xinelu-nurse-applet/src/main/java/com/xinelu/applet/controller/appletscreeningrecord/AppletScreeningRecordController.java +++ b/xinelu-nurse-applet/src/main/java/com/xinelu/applet/controller/appletscreeningrecord/AppletScreeningRecordController.java @@ -115,10 +115,13 @@ public class AppletScreeningRecordController extends BaseController { public R detail(@PathVariable String screeningId) { ScreeningRecordVo screeningRecordVo = screeningRecordService.detail(screeningId); if (screeningRecordVo != null) { - File file = new File(screeningRecordVo.getAttachment()); - if (file.exists() && file.isFile()) { - String fileName = file.getName(); - screeningRecordVo.setFileType(fileName.substring(fileName.lastIndexOf(".") + 1)); + if (StringUtils.isNotBlank(screeningRecordVo.getAttachment())){ + String fileDir = XinELuConfig.getProfile() + screeningRecordVo.getAttachment().replaceAll("/profile", ""); + File file = new File(fileDir); + if (file.exists() && file.isFile()) { + String fileName = file.getName(); + screeningRecordVo.setFileType(fileName.substring(fileName.lastIndexOf(".") + 1)); + } } if (!StringUtils.contains(screeningRecordVo.getProjectName(), ScreeningProjectConstants.ALZHEIMER)) { diff --git a/xinelu-nurse-applet/src/main/java/com/xinelu/applet/controller/nursingorder/NursingOrderController.java b/xinelu-nurse-applet/src/main/java/com/xinelu/applet/controller/nursingorder/NursingOrderController.java index 35a1960..fec730d 100644 --- a/xinelu-nurse-applet/src/main/java/com/xinelu/applet/controller/nursingorder/NursingOrderController.java +++ b/xinelu-nurse-applet/src/main/java/com/xinelu/applet/controller/nursingorder/NursingOrderController.java @@ -1,5 +1,6 @@ package com.xinelu.applet.controller.nursingorder; +import com.xinelu.applet.dto.nurseorder.NurseOrderDTO; import com.xinelu.applet.service.nursingorder.INursingOrderService; import com.xinelu.applet.vo.nursingorder.AppletGoodsOrderVO; import com.xinelu.applet.vo.nursingorder.NursingOrderInfoVO; @@ -14,6 +15,7 @@ import org.apache.commons.lang3.StringUtils; import org.springframework.web.bind.annotation.*; import javax.annotation.Resource; +import java.util.ArrayList; import java.util.List; import java.util.Objects; @@ -31,7 +33,7 @@ public class NursingOrderController extends BaseController { private INursingOrderService nursingOrderService; /** - * 根据登录id查询订单列表 + * 根据登录id查询订单列表(暂时不用) */ @GetMapping("/userPage") public TableDataInfo page(Long parentId) { @@ -93,4 +95,16 @@ public class NursingOrderController extends BaseController { } return nursingOrderService.getAppointmentDetailsInfo(orderNo); } + + /** + * 根据openid编号查询对应得订单 + */ + //@MobileRequestAuthorization + @GetMapping("/getAppletOrderList") + public TableDataInfo getAppletOrderList(NurseOrderDTO nurseOrder) { + if (Objects.isNull(nurseOrder) || Objects.isNull(nurseOrder.getParentId()) || StringUtils.isBlank(nurseOrder.getCardNo()) || StringUtils.isBlank(nurseOrder.getOrderStatus())) { + return getDataTable(new ArrayList<>()); + } + return getDataTable(nursingOrderService.getAppletOrderList(nurseOrder)); + } } \ No newline at end of file diff --git a/xinelu-nurse-applet/src/main/java/com/xinelu/applet/controller/wechatpaymentinfo/WeChatPaymentController.java b/xinelu-nurse-applet/src/main/java/com/xinelu/applet/controller/wechatpaymentinfo/WeChatPaymentController.java index e40adef..2d9b8a0 100644 --- a/xinelu-nurse-applet/src/main/java/com/xinelu/applet/controller/wechatpaymentinfo/WeChatPaymentController.java +++ b/xinelu-nurse-applet/src/main/java/com/xinelu/applet/controller/wechatpaymentinfo/WeChatPaymentController.java @@ -3,6 +3,7 @@ package com.xinelu.applet.controller.wechatpaymentinfo; import com.xinelu.applet.service.wechatpaymentinfo.WeChatPayNotifyService; import com.xinelu.applet.service.wechatpaymentinfo.WeChatPaymentService; import com.xinelu.applet.service.wechatpaymentinfo.WeChatRefundService; +import com.xinelu.applet.vo.wechatpaymentinfo.dto.CloseOrderDTO; import com.xinelu.applet.vo.wechatpaymentinfo.dto.PaymentDTO; import com.xinelu.applet.vo.wechatpaymentinfo.dto.RefundDTO; import com.xinelu.common.annotation.MobileRequestAuthorization; @@ -105,28 +106,14 @@ public class WeChatPaymentController extends BaseController { return weChatPayNotifyService.xylWeChatPayNotify(request, response); } - /** - * 医路优品微信支付回调通知接口 - * - * @param request 请求头信息 - * @param response 响应信息 - * @return 应答信息,避免微信平台重复发送回调通知 - * @throws Exception 异常信息 - */ - @PostMapping("/ylypWeChatPayNotify") - public String ylypWeChatPayNotify(HttpServletRequest request, HttpServletResponse response) throws Exception { - return weChatPayNotifyService.ylypWeChatPayNotify(request, response); - } - /** * 微信确认退款接口 * * @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); } @@ -144,16 +131,13 @@ public class WeChatPaymentController extends BaseController { } /** - * 医路优品微信退款回调通知接口 + * 专家咨询订单-医生端App拒单接口 * - * @param request 请求头信息 - * @param response 响应信息 - * @return 应答信息,避免微信平台重复发送回调通知 - * @throws Exception 异常信息 + * @param closeOrderDTO 订单关闭参数 + * @return 退款申请结果 */ - @PostMapping("/ylypWeChatRefundNotify") - public String ylypWeChatRefundNotify(HttpServletRequest request, HttpServletResponse response) throws Exception { - return weChatPayNotifyService.ylypWeChatRefundNotify(request, response); + @PostMapping("/closeHealthConsultationOrder") + public AjaxResult closeHealthConsultationOrder(@Validated(Insert.class) @RequestBody CloseOrderDTO closeOrderDTO) { + return weChatRefundService.closeHealthConsultationOrder(closeOrderDTO); } - } diff --git a/xinelu-nurse-applet/src/main/java/com/xinelu/applet/dto/nurseorder/NurseOrderDTO.java b/xinelu-nurse-applet/src/main/java/com/xinelu/applet/dto/nurseorder/NurseOrderDTO.java new file mode 100644 index 0000000..667debd --- /dev/null +++ b/xinelu-nurse-applet/src/main/java/com/xinelu/applet/dto/nurseorder/NurseOrderDTO.java @@ -0,0 +1,38 @@ +package com.xinelu.applet.dto.nurseorder; + + +import com.xinelu.common.core.domain.BaseDomain; +import lombok.Data; +import lombok.EqualsAndHashCode; + +import java.io.Serializable; + +/** + * @Description 个人中心订单查询 + * @Author zhangheng + * @Date 2022-10-18 + */ +@EqualsAndHashCode(callSuper = true) +@Data +public class NurseOrderDTO extends BaseDomain implements Serializable { + + /** + * 用户信息 + */ + private Long parentId; + + /** + * 订单状态 + */ + private String orderStatus; + + /** + * 居民身份证号 + */ + private String cardNo; + + /** + * 地区标识 + */ + private String region; +} \ No newline at end of file diff --git a/xinelu-nurse-applet/src/main/java/com/xinelu/applet/mapper/nursingorder/NursingOrderMapper.java b/xinelu-nurse-applet/src/main/java/com/xinelu/applet/mapper/nursingorder/NursingOrderMapper.java index bd37450..9a4a956 100644 --- a/xinelu-nurse-applet/src/main/java/com/xinelu/applet/mapper/nursingorder/NursingOrderMapper.java +++ b/xinelu-nurse-applet/src/main/java/com/xinelu/applet/mapper/nursingorder/NursingOrderMapper.java @@ -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,30 @@ public interface NursingOrderMapper { * @return 护理站信息 */ AppointmentOrderDetailsInfoVO getNurseStationByItemId(Long nurseStationItemId); + + /** + * 根据openid编号查询对应得订单 + * + * @param patientId openid编号 + * @param orderStatus 订单状态 + * @return AjaxResult + */ + List getAppointmentOrderListByParentId(@Param("patientId") Long patientId, @Param("orderStatus") String orderStatus); + + /** + * 根据openid编号查询对应得订单 + * + * @param patientId openid编号 + * @param orderStatus 订单状态 + * @return AjaxResult + */ + List getGoodsOrderAndConsultationOrder(@Param("patientId") Long patientId, @Param("orderStatus") String orderStatus); + + /** + * 根据patientId编号查询评价信息 + * + * @param patientId openid编号 + * @return AjaxResult + */ + List getOrderEvaluateByPatientId(Long patientId); } \ No newline at end of file diff --git a/xinelu-nurse-applet/src/main/java/com/xinelu/applet/service/apporderevaluate/impl/AppOrderEvaluateServiceImpl.java b/xinelu-nurse-applet/src/main/java/com/xinelu/applet/service/apporderevaluate/impl/AppOrderEvaluateServiceImpl.java index 7fe61cb..2d21548 100644 --- a/xinelu-nurse-applet/src/main/java/com/xinelu/applet/service/apporderevaluate/impl/AppOrderEvaluateServiceImpl.java +++ b/xinelu-nurse-applet/src/main/java/com/xinelu/applet/service/apporderevaluate/impl/AppOrderEvaluateServiceImpl.java @@ -6,6 +6,7 @@ import com.xinelu.applet.service.apporderevaluate.IAppOrderEvaluateService; import com.xinelu.common.config.XinELuConfig; import com.xinelu.common.core.domain.AjaxResult; import com.xinelu.common.enums.GooodsOrderStatusEnum; +import com.xinelu.common.enums.OrderSourceEnum; import com.xinelu.common.enums.OrderStatusEnum; import com.xinelu.common.exception.ServiceException; import com.xinelu.common.utils.bean.BeanUtils; @@ -85,12 +86,14 @@ public class AppOrderEvaluateServiceImpl implements IAppOrderEvaluateService { @Transactional(rollbackFor = Exception.class) @Override public AjaxResult insertGoodsOrderEvaluate(OrderEvaluateAndPictureDTO orderEvaluateAndPictureDTO) { - GoodsOrder goodsOrder = appOrderEvaluateMapper.selectGoodsOrderByOrderNo(orderEvaluateAndPictureDTO.getOrderNo()); - if (Objects.isNull(goodsOrder) || StringUtils.isBlank(goodsOrder.getOrderStatus()) || !goodsOrder.getOrderStatus().equals(GooodsOrderStatusEnum.RECEIVED_GOODS.getInfo())) { - return AjaxResult.error("当前订单未确认收货,请先确认收货后进行评价!"); - } - if (StringUtils.equals(GooodsOrderStatusEnum.EVALUATED.getInfo(), goodsOrder.getOrderStatus())) { - return AjaxResult.error("当前订单已评价!"); + if (OrderSourceEnum.SPRING_DOCTOR.getInfo().equals(orderEvaluateAndPictureDTO.getOrderSource())) { + GoodsOrder goodsOrder = appOrderEvaluateMapper.selectGoodsOrderByOrderNo(orderEvaluateAndPictureDTO.getOrderNo()); + if (Objects.isNull(goodsOrder) || StringUtils.isBlank(goodsOrder.getOrderStatus()) || !goodsOrder.getOrderStatus().equals(GooodsOrderStatusEnum.RECEIVED_GOODS.getInfo())) { + return AjaxResult.error("当前订单未确认收货,请先确认收货后进行评价!"); + } + if (StringUtils.equals(GooodsOrderStatusEnum.EVALUATED.getInfo(), goodsOrder.getOrderStatus())) { + return AjaxResult.error("当前订单已评价!"); + } } //新增评价信息 OrderEvaluateInfo orderEvaluateInfo = new OrderEvaluateInfo(); @@ -100,9 +103,12 @@ public class AppOrderEvaluateServiceImpl implements IAppOrderEvaluateService { if (insertOrderEvaluateInfo <= 0) { throw new ServiceException("评价失败,请联系管理员!"); } + if (OrderSourceEnum.FAMILY_DOCTOR.getInfo().equals(orderEvaluateAndPictureDTO.getOrderSource())) { + return AjaxResult.success(); + } //新增评价图片 List afferentEvaluatePicture = orderEvaluateAndPictureDTO.getOrderEvaluatePictureInfoList(); - if (CollectionUtils.isNotEmpty(orderEvaluateAndPictureDTO.getOrderEvaluatePictureInfoList())) { + if (CollectionUtils.isNotEmpty(afferentEvaluatePicture)) { afferentEvaluatePicture.forEach(item -> { item.setOrderEvaluateId(orderEvaluateInfo.getId()); item.setCreateTime(LocalDateTime.now()); diff --git a/xinelu-nurse-applet/src/main/java/com/xinelu/applet/service/nursingorder/INursingOrderService.java b/xinelu-nurse-applet/src/main/java/com/xinelu/applet/service/nursingorder/INursingOrderService.java index 1ea42de..7347154 100644 --- a/xinelu-nurse-applet/src/main/java/com/xinelu/applet/service/nursingorder/INursingOrderService.java +++ b/xinelu-nurse-applet/src/main/java/com/xinelu/applet/service/nursingorder/INursingOrderService.java @@ -1,8 +1,10 @@ package com.xinelu.applet.service.nursingorder; +import com.xinelu.applet.dto.nurseorder.NurseOrderDTO; import com.xinelu.applet.vo.nursingorder.AppletGoodsOrderVO; import com.xinelu.applet.vo.nursingorder.NursingOrderInfoVO; +import com.xinelu.applet.vo.nursingorder.PatientOrder; import com.xinelu.common.core.domain.AjaxResult; import com.xinelu.common.core.domain.entity.SysDictData; import com.xinelu.manage.domain.goodsOrder.GoodsOrder; @@ -55,4 +57,12 @@ public interface INursingOrderService { * @return 详情信息 */ AjaxResult getAppointmentDetailsInfo(String orderNo); + + /** + * 根据openid编号查询对应得订单 + * + * @param nurseOrder nurseOrder + * @return AjaxResult + */ + List getAppletOrderList(NurseOrderDTO nurseOrder); } \ No newline at end of file diff --git a/xinelu-nurse-applet/src/main/java/com/xinelu/applet/service/nursingorder/impl/NursingOrderServiceImpl.java b/xinelu-nurse-applet/src/main/java/com/xinelu/applet/service/nursingorder/impl/NursingOrderServiceImpl.java index 6756490..afc3bf0 100644 --- a/xinelu-nurse-applet/src/main/java/com/xinelu/applet/service/nursingorder/impl/NursingOrderServiceImpl.java +++ b/xinelu-nurse-applet/src/main/java/com/xinelu/applet/service/nursingorder/impl/NursingOrderServiceImpl.java @@ -1,23 +1,37 @@ package com.xinelu.applet.service.nursingorder.impl; +import com.alibaba.fastjson2.JSON; +import com.xinelu.applet.dto.nurseorder.NurseOrderDTO; 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.nursingorder.PatientOrderVO; 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.OrderSourceEnum; +import com.xinelu.common.enums.OrderStatusEnum; +import com.xinelu.common.exception.ServiceException; +import com.xinelu.common.utils.http.HttpUtils; +import com.xinelu.common.utils.spring.SpringUtils; 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; +import java.util.stream.Collectors; + +import static com.xinelu.common.utils.PageUtils.startPage; /** * @Description 订单分页 @@ -31,6 +45,16 @@ public class NursingOrderServiceImpl implements INursingOrderService { @Resource private NursingOrderMapper nursingOrderMapper; + /** + * 未评价标识 + */ + private final String NOT_EVALUATED = "NOT_EVALUATED"; + + /** + * 已评价标识 + */ + private final String EVALUATED = "EVALUATED"; + /** * 查询个人订单列表并分页 * @@ -107,4 +131,56 @@ public class NursingOrderServiceImpl implements INursingOrderService { } return AjaxResult.success(detailsInfoVO); } + + /** + * 根据openid编号查询对应得订单 + * + * @param nurseOrder nurseOrder + * @return AjaxResult + */ + @Override + public List getAppletOrderList(NurseOrderDTO nurseOrder) { + List patientOrders = new ArrayList<>(); + List appletOrderList = new ArrayList<>(); + List goodsOrderAndConsultationOrder = new ArrayList<>(); + if (NOT_EVALUATED.equals(nurseOrder.getOrderStatus())) { + appletOrderList = nursingOrderMapper.getAppointmentOrderListByParentId(nurseOrder.getParentId(), OrderStatusEnum.COMPLETE.getInfo()); + goodsOrderAndConsultationOrder = nursingOrderMapper.getGoodsOrderAndConsultationOrder(nurseOrder.getParentId(), GooodsOrderStatusEnum.RECEIVED_GOODS.getInfo()); + } + if (EVALUATED.equals(nurseOrder.getOrderStatus())) { + appletOrderList = nursingOrderMapper.getAppointmentOrderListByParentId(nurseOrder.getParentId(), OrderStatusEnum.EVALUATED.getInfo()); + goodsOrderAndConsultationOrder = nursingOrderMapper.getGoodsOrderAndConsultationOrder(nurseOrder.getParentId(), GooodsOrderStatusEnum.EVALUATED.getInfo()); + } + if (CollectionUtils.isNotEmpty(appletOrderList)) { + patientOrders.addAll(appletOrderList); + } + if (CollectionUtils.isNotEmpty(goodsOrderAndConsultationOrder)) { + patientOrders.addAll(goodsOrderAndConsultationOrder); + } + String result = HttpUtils.sendGet(SpringUtils.getFdUrl(nurseOrder.getRegion()) + "/performance/recordV2/" + nurseOrder.getCardNo()); + if (StringUtils.isBlank(result)) { + throw new ServiceException("获取微信小程序用户信息失败", 201); + } + PatientOrderVO resultHttp = JSON.parseObject(result, PatientOrderVO.class); + if (Objects.nonNull(resultHttp) && CollectionUtils.isNotEmpty(resultHttp.getData())) { + List data = resultHttp.getData(); + List orderEvaluate = nursingOrderMapper.getOrderEvaluateByPatientId(nurseOrder.getParentId()); + if (CollectionUtils.isNotEmpty(orderEvaluate) && EVALUATED.equals(nurseOrder.getOrderStatus())) { + for (PatientOrder patientOrder : orderEvaluate) { + PatientOrder dataFirst = data.stream().filter(Objects::nonNull).filter(item -> Objects.nonNull(item.getOrderNo()) && patientOrder.getOrderNo().equals(item.getOrderNo())).findFirst().orElse(new PatientOrder()); + dataFirst.setCompositeScore(patientOrder.getCompositeScore()); + dataFirst.setOrderSource(OrderSourceEnum.FAMILY_DOCTOR.getInfo()); + patientOrders.add(dataFirst); + } + } + if (CollectionUtils.isNotEmpty(orderEvaluate) && NOT_EVALUATED.equals(nurseOrder.getOrderStatus())) { + data.removeAll(orderEvaluate); + data.forEach(item ->item.setOrderSource(OrderSourceEnum.FAMILY_DOCTOR.getInfo())); + } + patientOrders.addAll(data); + } + startPage(); + patientOrders.sort((t1, t2) -> t2.getCreateTime().compareTo(t1.getCreateTime())); + return patientOrders; + } } \ No newline at end of file diff --git a/xinelu-nurse-applet/src/main/java/com/xinelu/applet/service/wechatpaymentinfo/WeChatPayNotifyService.java b/xinelu-nurse-applet/src/main/java/com/xinelu/applet/service/wechatpaymentinfo/WeChatPayNotifyService.java index 1ede360..114a37c 100644 --- a/xinelu-nurse-applet/src/main/java/com/xinelu/applet/service/wechatpaymentinfo/WeChatPayNotifyService.java +++ b/xinelu-nurse-applet/src/main/java/com/xinelu/applet/service/wechatpaymentinfo/WeChatPayNotifyService.java @@ -21,16 +21,6 @@ public interface WeChatPayNotifyService { */ String xylWeChatPayNotify(HttpServletRequest request, HttpServletResponse response) throws Exception; - /** - * 医路优品支付回调接口 - * - * @param request 请求信息 - * @param response 响应信息 - * @return 应答信息,避免微信平台重复发送回调通知 - * @throws Exception 异常信息 - */ - String ylypWeChatPayNotify(HttpServletRequest request, HttpServletResponse response) throws Exception; - /** * 新医路退款回调接口 * @@ -40,14 +30,4 @@ public interface WeChatPayNotifyService { * @throws Exception 异常信息 */ String xylWeChatRefundNotify(HttpServletRequest request, HttpServletResponse response) throws Exception; - - /** - * 医路优品退款回调接口 - * - * @param request 请求信息 - * @param response 响应信息 - * @return 应答信息,避免微信平台重复发送回调通知 - * @throws Exception 异常信息 - */ - String ylypWeChatRefundNotify(HttpServletRequest request, HttpServletResponse response) throws Exception; } diff --git a/xinelu-nurse-applet/src/main/java/com/xinelu/applet/service/wechatpaymentinfo/WeChatPaymentService.java b/xinelu-nurse-applet/src/main/java/com/xinelu/applet/service/wechatpaymentinfo/WeChatPaymentService.java index 75bdf05..94691b0 100644 --- a/xinelu-nurse-applet/src/main/java/com/xinelu/applet/service/wechatpaymentinfo/WeChatPaymentService.java +++ b/xinelu-nurse-applet/src/main/java/com/xinelu/applet/service/wechatpaymentinfo/WeChatPaymentService.java @@ -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; - /** * 微信关闭订单方法 * diff --git a/xinelu-nurse-applet/src/main/java/com/xinelu/applet/service/wechatpaymentinfo/WeChatRefundService.java b/xinelu-nurse-applet/src/main/java/com/xinelu/applet/service/wechatpaymentinfo/WeChatRefundService.java index 966dd61..6057ef6 100644 --- a/xinelu-nurse-applet/src/main/java/com/xinelu/applet/service/wechatpaymentinfo/WeChatRefundService.java +++ b/xinelu-nurse-applet/src/main/java/com/xinelu/applet/service/wechatpaymentinfo/WeChatRefundService.java @@ -1,5 +1,6 @@ package com.xinelu.applet.service.wechatpaymentinfo; +import com.xinelu.applet.vo.wechatpaymentinfo.dto.CloseOrderDTO; import com.xinelu.applet.vo.wechatpaymentinfo.dto.RefundDTO; import com.xinelu.applet.vo.wechatpaymentinfo.vo.WeChatRefundInfoVO; import com.xinelu.common.core.domain.AjaxResult; @@ -17,9 +18,8 @@ public interface WeChatRefundService { * * @param refundDTO 退款参数 * @return 返回信息 - * @throws Exception 异常信息 */ - AjaxResult weChatRefundOrderApply(RefundDTO refundDTO) throws Exception; + AjaxResult weChatRefundOrderApply(RefundDTO refundDTO); /** * 调用微信查询单笔退款接口查询预约订单状态信息 @@ -35,7 +35,14 @@ public interface WeChatRefundService { * @param refundNo 退单编号 * @param buySource 购买来源 * @return 退款信息 - * @throws Exception 异常信息 */ - WeChatRefundInfoVO queryGoodsOrderRefundStatus(String refundNo, String buySource) throws Exception; + WeChatRefundInfoVO queryGoodsOrderRefundStatus(String refundNo, String buySource); + + /** + * 专家咨询订单-医生端App拒单接口 + * + * @param closeOrderDTO 订单关闭参数 + * @return 返回信息 + */ + AjaxResult closeHealthConsultationOrder(CloseOrderDTO closeOrderDTO); } diff --git a/xinelu-nurse-applet/src/main/java/com/xinelu/applet/service/wechatpaymentinfo/impl/WeChatPayNotifyServiceImpl.java b/xinelu-nurse-applet/src/main/java/com/xinelu/applet/service/wechatpaymentinfo/impl/WeChatPayNotifyServiceImpl.java index c530ea7..c50932a 100644 --- a/xinelu-nurse-applet/src/main/java/com/xinelu/applet/service/wechatpaymentinfo/impl/WeChatPayNotifyServiceImpl.java +++ b/xinelu-nurse-applet/src/main/java/com/xinelu/applet/service/wechatpaymentinfo/impl/WeChatPayNotifyServiceImpl.java @@ -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 redisTemplate; @Resource private PatientCouponReceiveMapper patientCouponReceiveMapper; - /** - * 新医路账户标识 - */ - private static final String XINYILU_ACCOUNT = "XINYILU"; - - /** - * 新医路账户标识 - */ - private static final String YILUYOUPIN_ACCOUNT = "YILUYOUPIN"; - /** * 支付回调标识 */ @@ -120,20 +105,6 @@ public class WeChatPayNotifyServiceImpl implements WeChatPayNotifyService { return weChatPayNotifyInfo(request, response, PaymentMerchantTypeEnum.XINYILU.getInfo(), PAY); } - /** - * 医路优品支付回调接口 - * - * @param request 请求信息 - * @param response 响应信息 - * @return 应答信息,避免微信平台重复发送回调通知 - * @throws Exception 异常信息 - */ - @Override - public String ylypWeChatPayNotify(HttpServletRequest request, HttpServletResponse response) throws Exception { - log.info("医路优品微信支付回调开始执行"); - return weChatPayNotifyInfo(request, response, PaymentMerchantTypeEnum.YILUYOUPIN.getInfo(), PAY); - } - /** * 新医路退款回调接口 * @@ -148,20 +119,6 @@ public class WeChatPayNotifyServiceImpl implements WeChatPayNotifyService { return weChatPayNotifyInfo(request, response, PaymentMerchantTypeEnum.XINYILU.getInfo(), REFUND); } - /** - * 医路优品退款回调接口 - * - * @param request 请求信息 - * @param response 响应信息 - * @return 应答信息,避免微信平台重复发送回调通知 - * @throws Exception 异常信息 - */ - @Override - public String ylypWeChatRefundNotify(HttpServletRequest request, HttpServletResponse response) throws Exception { - log.info("医路优品微信退款回调开始执行"); - return weChatPayNotifyInfo(request, response, PaymentMerchantTypeEnum.YILUYOUPIN.getInfo(), REFUND); - } - /** * 微信支付回调通知公共方法 * @@ -187,19 +144,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,26 +158,17 @@ 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"); resultMap.put("message", "解密失败!"); return JSON.toJSONString(resultMap); } - //记录支付日志和修改订单状态 if (Constants.PAY_NOTIFY.equals(refundAndPaymentFlag)) { this.processPaymentInfo(plainText); } - //修改订单状态以及增加库存以及退还用户所使用的优惠券信息 if (Constants.REFUND_NOTIFY.equals(refundAndPaymentFlag)) { this.processRefundInfo(plainText); } @@ -337,12 +276,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; diff --git a/xinelu-nurse-applet/src/main/java/com/xinelu/applet/service/wechatpaymentinfo/impl/WeChatPaymentServiceImpl.java b/xinelu-nurse-applet/src/main/java/com/xinelu/applet/service/wechatpaymentinfo/impl/WeChatPaymentServiceImpl.java index fcb03dd..8476b24 100644 --- a/xinelu-nurse-applet/src/main/java/com/xinelu/applet/service/wechatpaymentinfo/impl/WeChatPaymentServiceImpl.java +++ b/xinelu-nurse-applet/src/main/java/com/xinelu/applet/service/wechatpaymentinfo/impl/WeChatPaymentServiceImpl.java @@ -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 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 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 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; diff --git a/xinelu-nurse-applet/src/main/java/com/xinelu/applet/service/wechatpaymentinfo/impl/WeChatRefundServiceImpl.java b/xinelu-nurse-applet/src/main/java/com/xinelu/applet/service/wechatpaymentinfo/impl/WeChatRefundServiceImpl.java index c275f33..51029e5 100644 --- a/xinelu-nurse-applet/src/main/java/com/xinelu/applet/service/wechatpaymentinfo/impl/WeChatRefundServiceImpl.java +++ b/xinelu-nurse-applet/src/main/java/com/xinelu/applet/service/wechatpaymentinfo/impl/WeChatRefundServiceImpl.java @@ -4,11 +4,11 @@ import com.alibaba.fastjson2.JSON; import com.alibaba.fastjson2.JSONObject; import com.xinelu.applet.service.goodstock.GoodsStockService; import com.xinelu.applet.service.wechatpaymentinfo.WeChatRefundService; +import com.xinelu.applet.vo.wechatpaymentinfo.dto.CloseOrderDTO; 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 +58,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 +86,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); } @@ -126,7 +116,8 @@ public class WeChatRefundServiceImpl implements WeChatRefundService { Long patientId = Objects.isNull(appointmentOrderInfo.getPatientId()) ? 0 : appointmentOrderInfo.getPatientId(); String outRefundNo = com.xinelu.common.utils.StringUtils.fillZeroByPatientId(patientId, 5) + System.nanoTime(); String refundParam = buildRefundParam(null, appointmentOrderInfo, refundDTO, outRefundNo); - this.applyWeRefund(refundParam, appointmentOrderInfo, null, patientId, refundDTO); + String refundReason = StringUtils.isBlank(refundDTO.getRefundReason()) ? "" : refundDTO.getRefundReason(); + this.applyWeRefund(refundParam, appointmentOrderInfo, null, patientId, refundReason); return AjaxResult.success(); } GoodsOrder goodsOrderInfo = goodsOrderMapper.getGoodsOrderByOrderNo(refundDTO.getOrderNo()); @@ -147,7 +138,8 @@ public class WeChatRefundServiceImpl implements WeChatRefundService { Long patientId = Objects.isNull(goodsOrderInfo.getPatientId()) ? 0 : goodsOrderInfo.getPatientId(); String outRefundNo = com.xinelu.common.utils.StringUtils.fillZeroByPatientId(patientId, 5) + System.nanoTime(); String refundParam = buildRefundParam(goodsOrderInfo, null, refundDTO, outRefundNo); - this.applyWeRefund(refundParam, null, goodsOrderInfo, patientId, refundDTO); + String refundReason = StringUtils.isBlank(refundDTO.getRefundReason()) ? "" : refundDTO.getRefundReason(); + this.applyWeRefund(refundParam, null, goodsOrderInfo, patientId, refundReason); return AjaxResult.success(); } return AjaxResult.success(); @@ -188,23 +180,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,13 +204,41 @@ public class WeChatRefundServiceImpl implements WeChatRefundService { } catch (Exception e) { log.error("请求微信查询单笔退款接口,异常信息为 ====> {}", e.getMessage()); throw new ServiceException("查询商品订单状态失败,请联系管理员!"); - } finally { - if (response != null) { - response.close(); - } } } + /** + * 专家咨询订单-医生端App拒单接口 + * + * @param closeOrderDTO 订单关闭参数 + * @return 返回信息 + */ + @Transactional(rollbackFor = Exception.class) + @Override + public AjaxResult closeHealthConsultationOrder(CloseOrderDTO closeOrderDTO) { + GoodsOrder goodsOrderInfo = goodsOrderMapper.getGoodsOrderByOrderNo(closeOrderDTO.getOrderNo()); + if (Objects.isNull(goodsOrderInfo) || StringUtils.isBlank(goodsOrderInfo.getOrderNo())) { + return AjaxResult.error("当前订单信息不存在,无法拒单!"); + } + if (StringUtils.isBlank(goodsOrderInfo.getOrderType()) + || !StringUtils.equals(OrderTypeEnum.HEALTH_CONSULTATION.getInfo(), goodsOrderInfo.getOrderType())) { + return AjaxResult.error("当前订单非专家咨询订单,无法拒单!"); + } + if (StringUtils.isBlank(goodsOrderInfo.getOrderStatus()) + || !StringUtils.equals(GooodsOrderStatusEnum.WAIT_RECEIVED_GOODS.getInfo(), goodsOrderInfo.getOrderStatus())) { + return AjaxResult.error("当前订单状态异常,无法拒单!"); + } + if (Objects.isNull(goodsOrderInfo.getTotalPrice()) || goodsOrderInfo.getTotalPrice().compareTo(BigDecimal.ZERO) <= 0) { + return AjaxResult.error("当前订单金额异常,无法拒单!"); + } + Long patientId = Objects.isNull(goodsOrderInfo.getPatientId()) ? 0 : goodsOrderInfo.getPatientId(); + String outRefundNo = com.xinelu.common.utils.StringUtils.fillZeroByPatientId(patientId, 5) + System.nanoTime(); + String refundParam = this.buildHealthConsultationRefundParam(goodsOrderInfo, outRefundNo); + String refundReason = StringUtils.isBlank(closeOrderDTO.getRemark()) ? "" : closeOrderDTO.getRemark(); + this.applyWeRefund(refundParam, null, goodsOrderInfo, patientId, refundReason); + return AjaxResult.success(); + } + /** * 退款参数检验 * @@ -261,21 +272,12 @@ public class WeChatRefundServiceImpl implements WeChatRefundService { paramMap.put("out_trade_no", refundDTO.getOrderNo()); paramMap.put("out_refund_no", outRefundNo); Map 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"); @@ -290,36 +292,18 @@ public class WeChatRefundServiceImpl implements WeChatRefundService { * @param appointmentOrderInfo 预约服务订单信息 * @param goodsOrderInfo 商品订单信息 * @param patientId 会员id - * @param refundDTO 申请信息 - * @throws Exception 异常信息 + * @param refundReason 退款原因 */ - 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, String refundReason) { 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对象失败!"); } @@ -337,7 +321,7 @@ public class WeChatRefundServiceImpl implements WeChatRefundService { WeChatRefundInfoVO weChatRefundInfoVO = JSONObject.parseObject(body, WeChatRefundInfoVO.class); int refundInfoCount = refundInfoMapper.getRefundInfoByOrderNo(weChatRefundInfoVO.getOutTradeNo()); if (refundInfoCount <= 0) { - RefundInfo refundInfo = buildRefundInfo(patientId, weChatRefundInfoVO, refundDTO, body, refundMerchantType); + RefundInfo refundInfo = buildRefundInfo(patientId, weChatRefundInfoVO, refundReason, body, refundMerchantType); int insertCunt = refundInfoMapper.insertRefundInfo(refundInfo); if (insertCunt <= 0) { throw new ServiceException("记录退款信息失败,请联系管理员!"); @@ -345,10 +329,6 @@ public class WeChatRefundServiceImpl implements WeChatRefundService { } } catch (Exception e) { log.error("微信申请退款接口出错,原因:{}", e.getMessage()); - } finally { - if (response != null) { - response.close(); - } } } @@ -357,19 +337,19 @@ public class WeChatRefundServiceImpl implements WeChatRefundService { * * @param patientId 会员id * @param refundInfoVO 退款信息参数 - * @param refundDTO 退款申请参数 + * @param refundReason 退款原因 * @param refundBody 返回体 * @param refundMerchantType 退款账户类型,新医路或者医路优品 */ private RefundInfo buildRefundInfo(Long patientId, WeChatRefundInfoVO refundInfoVO, - RefundDTO refundDTO, String refundBody, String refundMerchantType) { + String refundReason, String refundBody, String refundMerchantType) { RefundInfo refundInfo = new RefundInfo(); refundInfo.setPatientId(patientId); refundInfo.setOrderNo(refundInfoVO.getOutTradeNo()); refundInfo.setRefundNo(refundInfoVO.getRefundId()); refundInfo.setOutRefundNo(refundInfoVO.getOutRefundNo()); refundInfo.setTransactionNo(StringUtils.isBlank(refundInfoVO.getTransactionId()) ? "" : refundInfoVO.getTransactionId()); - refundInfo.setRefundReason(StringUtils.isBlank(refundDTO.getRefundReason()) ? "" : refundDTO.getRefundReason()); + refundInfo.setRefundReason(refundReason); refundInfo.setRefundType(RefundTypeEnum.WE_CHAT.getInfo()); refundInfo.setWechatRefundStatus(RefundStatusEnum.PROCESSING.getInfo()); refundInfo.setOrderTotalPrice(BigDecimal.valueOf(refundInfoVO.getAmount().getTotal()).divide(BigDecimal.valueOf(100), 2, BigDecimal.ROUND_DOWN)); @@ -448,4 +428,24 @@ public class WeChatRefundServiceImpl implements WeChatRefundService { } return null; } + + /** + * 构建专家咨询微信退款参数信息 + * + * @param goodsOrderInfo 专家咨询订单信息 + * @param outRefundNo 退款单号 + * @return 退款申请Json串 + */ + private String buildHealthConsultationRefundParam(GoodsOrder goodsOrderInfo, String outRefundNo) { + Map paramMap = new LinkedHashMap<>(); + paramMap.put("out_trade_no", goodsOrderInfo.getOrderNo()); + paramMap.put("out_refund_no", outRefundNo); + Map amountMap = new LinkedHashMap<>(); + paramMap.put("notify_url", xylWeChatPaymentConfig.getXylWeChatNotifyUrl() + XINYILU_WE_CHAT_REFUND_URL); + amountMap.put("refund", goodsOrderInfo.getTotalPrice().multiply(BigDecimal.valueOf(100)).intValue()); + amountMap.put("total", goodsOrderInfo.getTotalPrice().multiply(BigDecimal.valueOf(100)).intValue()); + amountMap.put("currency", "CNY"); + paramMap.put("amount", amountMap); + return JSON.toJSONString(paramMap); + } } diff --git a/xinelu-nurse-applet/src/main/java/com/xinelu/applet/vo/nursingorder/AppletGoodsOrderVO.java b/xinelu-nurse-applet/src/main/java/com/xinelu/applet/vo/nursingorder/AppletGoodsOrderVO.java index 12b5735..33a6233 100644 --- a/xinelu-nurse-applet/src/main/java/com/xinelu/applet/vo/nursingorder/AppletGoodsOrderVO.java +++ b/xinelu-nurse-applet/src/main/java/com/xinelu/applet/vo/nursingorder/AppletGoodsOrderVO.java @@ -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 orderTypeList; /** * 积分抵扣数量 diff --git a/xinelu-nurse-applet/src/main/java/com/xinelu/applet/vo/nursingorder/NursingOrderInfoVO.java b/xinelu-nurse-applet/src/main/java/com/xinelu/applet/vo/nursingorder/NursingOrderInfoVO.java index 065ed8a..edf8519 100644 --- a/xinelu-nurse-applet/src/main/java/com/xinelu/applet/vo/nursingorder/NursingOrderInfoVO.java +++ b/xinelu-nurse-applet/src/main/java/com/xinelu/applet/vo/nursingorder/NursingOrderInfoVO.java @@ -75,7 +75,6 @@ public class NursingOrderInfoVO extends BaseDomain implements Serializable { */ private BigDecimal nurseItemPrice; - /** * 是否删除标识,0:否,1:是 */ diff --git a/xinelu-nurse-applet/src/main/java/com/xinelu/applet/vo/nursingorder/PatientOrder.java b/xinelu-nurse-applet/src/main/java/com/xinelu/applet/vo/nursingorder/PatientOrder.java new file mode 100644 index 0000000..0ef603a --- /dev/null +++ b/xinelu-nurse-applet/src/main/java/com/xinelu/applet/vo/nursingorder/PatientOrder.java @@ -0,0 +1,80 @@ +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; + + /** + * 预约服务满意度,一般:COMMONLY,满意:SATISFIED,不满意:DISSATISFIED + */ + @ApiModelProperty(value = "预约服务满意度,一般:COMMONLY,满意:SATISFIED,不满意:DISSATISFIED") + private String evaluateSatisfaction; + + /** + * 商品订单综合评分,取值,1:代表1颗星,2:代表两颗星,3:代表三颗星,4:代表四颗星,5:代表五颗星 + */ + @ApiModelProperty(value = "商品订单综合评分,取值,1:代表1颗星,2:代表两颗星,3:代表三颗星,4:代表四颗星,5:代表五颗星") + private Integer compositeScore; + + /** + * 订单来源,泉医模块:SPRING_DOCTOR,家医模块:FAMILY_DOCTOR + */ + private String orderSource; +} diff --git a/xinelu-nurse-applet/src/main/java/com/xinelu/applet/vo/nursingorder/PatientOrderVO.java b/xinelu-nurse-applet/src/main/java/com/xinelu/applet/vo/nursingorder/PatientOrderVO.java new file mode 100644 index 0000000..37ddd4a --- /dev/null +++ b/xinelu-nurse-applet/src/main/java/com/xinelu/applet/vo/nursingorder/PatientOrderVO.java @@ -0,0 +1,31 @@ +package com.xinelu.applet.vo.nursingorder; + +import lombok.Data; + +import java.io.Serializable; +import java.util.List; + +/** + * @Description 服务评价 + * @Author zhangheng + * @Date 2022-10-18 + */ + +@Data +public class PatientOrderVO implements Serializable { + + /** + * 成功标识 + */ + private String code; + + /** + * 文字描述 + */ + private String msg; + + /** + * 信息集合 + */ + private List data; +} \ No newline at end of file diff --git a/xinelu-nurse-applet/src/main/java/com/xinelu/applet/vo/wechatpaymentinfo/dto/CloseOrderDTO.java b/xinelu-nurse-applet/src/main/java/com/xinelu/applet/vo/wechatpaymentinfo/dto/CloseOrderDTO.java new file mode 100644 index 0000000..c2385bd --- /dev/null +++ b/xinelu-nurse-applet/src/main/java/com/xinelu/applet/vo/wechatpaymentinfo/dto/CloseOrderDTO.java @@ -0,0 +1,27 @@ +package com.xinelu.applet.vo.wechatpaymentinfo.dto; + +import com.xinelu.common.custominterface.Insert; +import lombok.Data; + +import javax.validation.constraints.NotBlank; +import java.io.Serializable; + +/** + * @Description 订单关闭DTO + * @Author 纪寒 + * @Date 2023-10-19 14:28:07 + * @Version 1.0 + */ +@Data +public class CloseOrderDTO implements Serializable { + private static final long serialVersionUID = -1681680608523099847L; + /** + * 订单编号,必传字段 + */ + @NotBlank(message = "订单编号不能为空!", groups = {Insert.class}) + private String orderNo; + /** + * 拒单原因 + */ + private String remark; +} diff --git a/xinelu-nurse-applet/src/main/resources/mapper/applet/nursingorder/NusringOrderMapper.xml b/xinelu-nurse-applet/src/main/resources/mapper/applet/nursingorder/NusringOrderMapper.xml index b5b9772..72bae6c 100644 --- a/xinelu-nurse-applet/src/main/resources/mapper/applet/nursingorder/NusringOrderMapper.xml +++ b/xinelu-nurse-applet/src/main/resources/mapper/applet/nursingorder/NusringOrderMapper.xml @@ -155,6 +155,9 @@ and gr.order_type = #{orderType} + + and gr.order_type IN #{orderTypeList} + and gr.del_flag = 0 and god.del_flag = 0 @@ -272,63 +275,120 @@ + + + + + + \ No newline at end of file diff --git a/xinelu-nurse-manage/src/main/java/com/xinelu/manage/controller/orderevaluateinfo/OrderEvaluateInfoController.java b/xinelu-nurse-manage/src/main/java/com/xinelu/manage/controller/orderevaluateinfo/OrderEvaluateInfoController.java index b4d5ca0..c0aa63c 100644 --- a/xinelu-nurse-manage/src/main/java/com/xinelu/manage/controller/orderevaluateinfo/OrderEvaluateInfoController.java +++ b/xinelu-nurse-manage/src/main/java/com/xinelu/manage/controller/orderevaluateinfo/OrderEvaluateInfoController.java @@ -62,9 +62,9 @@ public class OrderEvaluateInfoController extends BaseController { /** * 新增预约服务订单和商品订单评价信息 */ -// @PreAuthorize("@ss.hasPermi('system:orderEvaluateInfo:add')") + //@PreAuthorize("@ss.hasPermi('system:orderEvaluateInfo:add')") @Log(title = "预约服务订单和商品订单评价信息", businessType = BusinessType.INSERT) - @PostMapping("add") + @PostMapping("/add") public AjaxResult add(@RequestBody OrderEvaluateInfo orderEvaluateInfo) { return toAjax(orderEvaluateInfoService.insertOrderEvaluateInfo(orderEvaluateInfo)); } @@ -74,7 +74,7 @@ public class OrderEvaluateInfoController extends BaseController { */ @PreAuthorize("@ss.hasPermi('system:orderEvaluateInfo:edit')") @Log(title = "预约服务订单和商品订单评价信息", businessType = BusinessType.UPDATE) - @PostMapping("edit") + @PostMapping("/edit") public AjaxResult edit(@RequestBody OrderEvaluateInfo orderEvaluateInfo) { return toAjax(orderEvaluateInfoService.updateOrderEvaluateInfo(orderEvaluateInfo)); } diff --git a/xinelu-nurse-manage/src/main/java/com/xinelu/manage/service/screeningrecord/impl/ScreeningRecordServiceImpl.java b/xinelu-nurse-manage/src/main/java/com/xinelu/manage/service/screeningrecord/impl/ScreeningRecordServiceImpl.java index 701aeaa..0fcb254 100644 --- a/xinelu-nurse-manage/src/main/java/com/xinelu/manage/service/screeningrecord/impl/ScreeningRecordServiceImpl.java +++ b/xinelu-nurse-manage/src/main/java/com/xinelu/manage/service/screeningrecord/impl/ScreeningRecordServiceImpl.java @@ -284,10 +284,13 @@ public class ScreeningRecordServiceImpl implements IScreeningRecordService { if(recordVo == null) { return null; } - File file = new File(recordVo.getAttachment()); - if (file.exists() && file.isFile()) { - String fileName = file.getName(); - recordVo.setFileType(fileName.substring(fileName.lastIndexOf(".") + 1)); + if(StringUtils.isNotBlank(recordVo.getAttachment())) { + String fileDir = XinELuConfig.getProfile() + recordVo.getAttachment().replaceAll("/profile", ""); + File file = new File(fileDir); + if (file.exists() && file.isFile()) { + String fileName = file.getName(); + recordVo.setFileType(fileName.substring(fileName.lastIndexOf(".") + 1)); + } } if (!StringUtils.contains(recordVo.getProjectName(), ScreeningProjectConstants.ALZHEIMER)) { getRecordDetail(recordVo); @@ -430,16 +433,18 @@ public class ScreeningRecordServiceImpl implements IScreeningRecordService { /** 获取图片附件转base64 */ private void setAttachment(ScreeningRecordVo record) { - if(!StringUtils.isBlank(record.getAttachment())) { - File file = new File(record.getAttachment()); - if(file.exists()) { - record.setAttachment(FileUtils.PicToBase64(record.getAttachment())); + if(StringUtils.isNotBlank(record.getAttachment())) { + String fileDir = XinELuConfig.getProfile() + record.getAttachment().replaceAll("/profile", ""); + File file = new File(fileDir); + if(file.exists() && file.isFile()) { + record.setAttachment(FileUtils.PicToBase64(fileDir)); } } - if(!StringUtils.isBlank(record.getAttachmentTwo())) { - File file = new File(record.getAttachmentTwo()); - if (file.exists()) { - record.setAttachmentTwo(FileUtils.PicToBase64(record.getAttachmentTwo())); + if(StringUtils.isNotBlank(record.getAttachmentTwo())) { + String fileDir = XinELuConfig.getProfile() + record.getAttachmentTwo().replaceAll("/profile", ""); + File file = new File(fileDir); + if (file.exists() && file.isFile()) { + record.setAttachmentTwo(FileUtils.PicToBase64(fileDir)); } } } diff --git a/xinelu-quartz/src/main/java/com/xinelu/quartz/controller/RefundInfoTaskController.java b/xinelu-quartz/src/main/java/com/xinelu/quartz/controller/RefundInfoTaskController.java index 2ef9ba8..f4f31c7 100644 --- a/xinelu-quartz/src/main/java/com/xinelu/quartz/controller/RefundInfoTaskController.java +++ b/xinelu-quartz/src/main/java/com/xinelu/quartz/controller/RefundInfoTaskController.java @@ -1,5 +1,6 @@ package com.xinelu.quartz.controller; +import com.xinelu.quartz.task.RefundHealthConsultationOrderTask; import com.xinelu.quartz.task.RefundInfoTask; import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.RequestMapping; @@ -19,14 +20,22 @@ public class RefundInfoTaskController { @Resource private RefundInfoTask refundInfoTask; + @Resource + private RefundHealthConsultationOrderTask refundHealthConsultationOrderTask; /** * 手动执行修改退款单状态定时任务 - * - * @throws Exception 异常信息 */ @GetMapping("/handleRefundStatus") - public void handleRefundStatus() throws Exception { + public void handleRefundStatus() { refundInfoTask.automaticProcessRefundInfo(); } + + /** + * 手动执行处理专家咨询订单医生手动拒单定时任务 + */ + @GetMapping("/handleHealthConsultationStatus") + public void handleHealthConsultationRefund() { + refundHealthConsultationOrderTask.automaticProcessHealthConsultationRefund(); + } } diff --git a/xinelu-quartz/src/main/java/com/xinelu/quartz/service/RefundInfoTaskService.java b/xinelu-quartz/src/main/java/com/xinelu/quartz/service/RefundInfoTaskService.java index 339a24f..18ca7f7 100644 --- a/xinelu-quartz/src/main/java/com/xinelu/quartz/service/RefundInfoTaskService.java +++ b/xinelu-quartz/src/main/java/com/xinelu/quartz/service/RefundInfoTaskService.java @@ -11,8 +11,11 @@ public interface RefundInfoTaskService { /** * 自动处理退款状态定时任务, * 防止由于网络等其它原因未接受到退款回调通知进而导致的退款单状态修改不及时 - * - * @throws Exception 异常信息 */ - void automaticProcessRefundInfo() throws Exception; + void automaticProcessRefundInfo(); + + /** + * 自动处理专家咨询订单医生手动拒单定时任务 + */ + void automaticProcessHealthConsultationRefund(); } diff --git a/xinelu-quartz/src/main/java/com/xinelu/quartz/service/impl/PaymentInfoTaskServiceImpl.java b/xinelu-quartz/src/main/java/com/xinelu/quartz/service/impl/PaymentInfoTaskServiceImpl.java index 57e9c87..1f0edbd 100644 --- a/xinelu-quartz/src/main/java/com/xinelu/quartz/service/impl/PaymentInfoTaskServiceImpl.java +++ b/xinelu-quartz/src/main/java/com/xinelu/quartz/service/impl/PaymentInfoTaskServiceImpl.java @@ -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 { } } } - } diff --git a/xinelu-quartz/src/main/java/com/xinelu/quartz/service/impl/RefundInfoTaskServiceImpl.java b/xinelu-quartz/src/main/java/com/xinelu/quartz/service/impl/RefundInfoTaskServiceImpl.java index 30436c3..b822ce4 100644 --- a/xinelu-quartz/src/main/java/com/xinelu/quartz/service/impl/RefundInfoTaskServiceImpl.java +++ b/xinelu-quartz/src/main/java/com/xinelu/quartz/service/impl/RefundInfoTaskServiceImpl.java @@ -59,11 +59,9 @@ public class RefundInfoTaskServiceImpl implements RefundInfoTaskService { /** * 自动处理退款状态定时任务,每15分钟执行一次 * 防止由于网络等其它原因未接受到退款回调通知进而导致的退款单状态修改不及时 - * - * @throws Exception 异常信息 */ @Override - public void automaticProcessRefundInfo() throws Exception { + public void automaticProcessRefundInfo() { List appointmentOrderList = appointmentOrderMapper.getRefundAppointmentOrderInfo(OrderStatusEnum.WAIT_REFUND.getInfo(), RefundStatusEnum.PROCESSING.getInfo(), ConfirmRefundStatusEnum.CONFIRMED.getInfo()); List refundGoodsOrderLit = goodsOrderMapper.getRefundGoodsOrderInfo(GooodsOrderStatusEnum.WAIT_REFUND.getInfo(), RefundStatusEnum.PROCESSING.getInfo(), ConfirmRefundStatusEnum.CONFIRMED.getInfo()); if (CollectionUtils.isEmpty(appointmentOrderList) && CollectionUtils.isEmpty(refundGoodsOrderLit)) { @@ -95,6 +93,26 @@ public class RefundInfoTaskServiceImpl implements RefundInfoTaskService { } } + /** + * 自动处理专家咨询订单医生手动拒单定时任务 + */ + @Override + public void automaticProcessHealthConsultationRefund() { + List refundGoodsOrderLit = goodsOrderMapper.getRefundGoodsOrderInfo(GooodsOrderStatusEnum.WAIT_RECEIVED_GOODS.getInfo(), RefundStatusEnum.PROCESSING.getInfo(), ConfirmRefundStatusEnum.CONFIRMED.getInfo()); + if (CollectionUtils.isEmpty(refundGoodsOrderLit)) { + return; + } + TransactionStatus transactionStatus = transactionManager.getTransaction(new DefaultTransactionDefinition()); + try { + processHealthConsultationRefund(refundGoodsOrderLit); + transactionManager.commit(transactionStatus); + } catch (Exception e) { + transactionManager.rollback(transactionStatus); + log.error("处理专家咨询订单医生手动拒单定时任务异常,异常信息 =====> {}", e.getMessage()); + throw e; + } + } + /** * 处理退款的预约订单信息 * @@ -131,9 +149,8 @@ public class RefundInfoTaskServiceImpl implements RefundInfoTaskService { * 处理退款成功的商品订单信息 * * @param refundGoodsOrderLit 商品退款订单信息 - * @throws Exception 异常信息 */ - private void processGoodsRefundInfo(List refundGoodsOrderLit) throws Exception { + private void processGoodsRefundInfo(List refundGoodsOrderLit) { List orderNoList = Lists.newArrayList(); for (RefundOrderInfoVO refundOrderInfoVO : refundGoodsOrderLit) { if (StringUtils.isBlank(refundOrderInfoVO.getOrderNo()) @@ -161,4 +178,28 @@ public class RefundInfoTaskServiceImpl implements RefundInfoTaskService { } } + /** + * 处理退款成功的专家咨询订单信息 + * + * @param refundGoodsOrderLit 专家咨询订单信息 + */ + private void processHealthConsultationRefund(List refundGoodsOrderLit) { + List orderNoList = Lists.newArrayList(); + for (RefundOrderInfoVO refundOrderInfoVO : refundGoodsOrderLit) { + if (StringUtils.isBlank(refundOrderInfoVO.getOrderNo()) + || StringUtils.isBlank(refundOrderInfoVO.getOutRefundNo()) || StringUtils.isBlank(refundOrderInfoVO.getBuySource())) { + continue; + } + WeChatRefundInfoVO weChatRefundInfoVO = weChatRefundService.queryGoodsOrderRefundStatus(refundOrderInfoVO.getOutRefundNo(), refundOrderInfoVO.getBuySource()); + if (StringUtils.isNotBlank(weChatRefundInfoVO.getStatus()) + && RefundStatusEnum.SUCCESS.getInfo().equals(weChatRefundInfoVO.getStatus())) { + orderNoList.add(refundOrderInfoVO.getOrderNo()); + } + LocalDateTime successTime = StringUtils.isBlank(weChatRefundInfoVO.getSuccessTime()) ? LocalDateTime.now() : LocalDateTime.parse(weChatRefundInfoVO.getSuccessTime(), DateTimeFormatter.ISO_DATE_TIME); + refundInfoMapper.updateBatchRefundStatus(refundOrderInfoVO.getOrderNo(), successTime, weChatRefundInfoVO.getStatus()); + } + if (CollectionUtils.isNotEmpty(orderNoList)) { + goodsOrderMapper.updateBatchGoodsOrderStatus(orderNoList, OrderStatusEnum.REFUNDED.getInfo()); + } + } } diff --git a/xinelu-quartz/src/main/java/com/xinelu/quartz/task/RefundHealthConsultationOrderTask.java b/xinelu-quartz/src/main/java/com/xinelu/quartz/task/RefundHealthConsultationOrderTask.java new file mode 100644 index 0000000..a0cb063 --- /dev/null +++ b/xinelu-quartz/src/main/java/com/xinelu/quartz/task/RefundHealthConsultationOrderTask.java @@ -0,0 +1,30 @@ +package com.xinelu.quartz.task; + +import com.xinelu.quartz.service.RefundInfoTaskService; +import lombok.extern.slf4j.Slf4j; +import org.springframework.stereotype.Component; + +import javax.annotation.Resource; + +/** + * @Description 专家咨询订单医生手动拒单定时任务 + * @Author 纪寒 + * @Date 2022-10-25 14:35:59 + * @Version 1.0 + */ +@Slf4j +@Component("refundHealthConsultationOrderTask") +public class RefundHealthConsultationOrderTask { + + @Resource + private RefundInfoTaskService refundInfoTaskService; + + /** + * 自动处理专家咨询订单医生手动拒单定时任务 + */ + public void automaticProcessHealthConsultationRefund() { + log.info("开始执行专家咨询订单医生手动拒单定时任务........"); + refundInfoTaskService.automaticProcessHealthConsultationRefund(); + log.info("完成专家咨询订单医生手动拒单定时任务........"); + } +} diff --git a/xinelu-quartz/src/main/java/com/xinelu/quartz/task/RefundInfoTask.java b/xinelu-quartz/src/main/java/com/xinelu/quartz/task/RefundInfoTask.java index de957c4..5afa317 100644 --- a/xinelu-quartz/src/main/java/com/xinelu/quartz/task/RefundInfoTask.java +++ b/xinelu-quartz/src/main/java/com/xinelu/quartz/task/RefundInfoTask.java @@ -22,10 +22,8 @@ public class RefundInfoTask { /** * 自动处理退款状态定时任务, * 防止由于网络等其它原因未接受到退款回调通知进而导致的退款单状态修改不及时 - * - * @throws Exception 异常信息 */ - public void automaticProcessRefundInfo() throws Exception { + public void automaticProcessRefundInfo() { log.info("开始执行关闭退款状态定时任务........"); refundInfoTaskService.automaticProcessRefundInfo(); log.info("完成关闭退款状态定时任务........");