预约挂号医院管理项目

阅读: 评论:0

预约挂号医院管理项目

预约挂号医院管理项目

service_order模块

  • 一. 导入相关的包
  • 二. application.properties配置信息和其他配置
  • 三. 微信支付相关的配置和文件
  • 四. Rabbitmq监听定时任务
  • 五. Controller层
    • ①. 订单相关接口 OrderApiController
    • ②. 微信接口 WeixinController
  • 六. Service层
    • ①. OrderService
    • ②. PaymentService
    • ③. WeixinService
    • ④. RefundInfoService
  • 七. 自定义工具类
    • ①. ConstantPropertiesUtils 常量属性工具类
    • ②. http请求客户端
  • 八. Mapper层
    • ①. OrderMapper PaymentMapper RefundInfoMapper
    • ②. l
  • 九. 根据订单号返回微信支付的二维码
  • 十. 根据订单ID进行取消预约,微信退款

一. 导入相关的包

    <dependencies><!--导入cmn服务开放接口--><dependency><groupId>com.xizi</groupId><artifactId>service_cmn_client</artifactId><version>0.0.1-SNAPSHOT</version></dependency><!--导入hosp服务开放接口--><dependency><groupId>com.xizi</groupId><artifactId>service_hosp_client</artifactId><version>0.0.1-SNAPSHOT</version></dependency><!--导入user服务开放接口--><dependency><groupId>com.xizi</groupId><artifactId>service_user_client</artifactId><version>0.0.1-SNAPSHOT</version></dependency><!--导入order服务开放接口--><dependency><groupId>com.xizi</groupId><artifactId>service_order_client</artifactId><version>0.0.1-SNAPSHOT</version></dependency><!--rabbit工具类--><dependency><groupId>com.xizi</groupId><artifactId>rabbit_util</artifactId><version>0.0.1-SNAPSHOT</version></dependency><!--微信支付sdk--><dependency><groupId>com.github.wxpay</groupId><artifactId>wxpay-sdk</artifactId><version>0.0.3</version></dependency></dependencies>

二. application.properties配置信息和其他配置

# 服务端口
server.port=8206
# 服务名
spring.application.name=service-order
# 环境设置:dev、test、prod
spring.profiles.active=dev# mysql数据库连接
spring.datasource.driver-class-name&#sql.jdbc.Driver
spring.datasource.url=jdbc:mysql://112.74.164.23:3306/yygh_order?characterEncoding=utf-8&useSSL=false
spring.datasource.username=yygh_order
spring.datasource.password=1234#返回json的全局时间格式
spring.jackson.date-format=yyyy-MM-dd HH:mm:ss
spring.jackson.time-zone=GMT+8#mongodb
db.uri=mongodb://112.74.164.23:27017/yygh_hosp# nacos服务地址
spring.cloud.nacos.discovery.server-addr=112.74.164.23:8848
#mp
mybatis-plus.mapper-locations=classpath:com/xizi/order/mapper/xml/*.xml#rabbitmq地址
spring.rabbitmq.host=112.74.164.23
spring.rabbitmq.port=5672
spring.rabbitmq.username=guest
spring.rabbitmq.password=guest#redis
dis.host=112.74.164.23
dis.port=6379
dis.database= 0
dis.password=123456
dis.timeout=1800000
dis.lettuce.pool.max-active=20
dis.lettuce.pool.max-wait=-1
dis.lettuce.pool.max-idle=5
dis.lettuce.pool.min-idle=0

三. 微信支付相关的配置和文件

#关联的公众号appid
weixin.appid=wx74862e0dfcf69954
#商户号
weixin.partner=1558950191
#商户key
weixin.partnerkey=T6m9iK73b0kn9g5v426MKfHQH7X8rKwb
#退款证书
=D:\IDEA\JavaWorkSpace\hospital\service\service_order\src\main\resources\cert\apiclient_cert.p12

四. Rabbitmq监听定时任务


// 监听定时任务![在这里插入图片描述](.png?x-oss-process=image/watermark,type_ZmFuZ3poZW5naGVpdGk,shadow_10,text_aHR0cHM6Ly9ibG9nLmNzZG4ubmV0L3dlaXhpbl80NTQ4MDc4NQ==,size_16,color_FFFFFF,t_70)@Component
public class OrderReceiver {@Autowiredprivate OrderService orderService;//发送就诊监听就诊通知@RabbitListener(bindings = @QueueBinding(value = @Queue(value = MqConst.QUEUE_TASK_8, durable = "true"),exchange = @Exchange(value = MqConst.EXCHANGE_DIRECT_TASK),key = {MqConst.ROUTING_TASK_8}))public void patientTips(Message message, Channel channel) throws IOException {orderService.patientTips();}
}

五. Controller层

①. 订单相关接口 OrderApiController

// 订单相关接口
@RestController
@RequestMapping("/api/order/orderInfo")
public class OrderApiController {@Autowiredprivate OrderService orderService;//根据排班id和病人id 生成挂号订单@PostMapping("auth/submitOrder/{scheduleId}/{patientId}")public Result savaOrders(@PathVariable String scheduleId,@PathVariable Long patientId) {Long orderId = orderService.saveOrder(scheduleId,patientId);//返回订单idreturn Result.ok(orderId);}//根据订单id 查询订单详情@GetMapping("auth/getOrders/{orderId}")public Result getOrders(@PathVariable String orderId) {OrderInfo orderInfo = Order(orderId);//返回订单信息return Result.ok(orderInfo);}//订单列表(条件查询带分页)  XML自定义分页 page 分页对象@GetMapping("auth/{page}/{limit}")public Result list(@PathVariable Long page,@PathVariable Long limit,OrderQueryVo orderQueryVo, HttpServletRequest request) {//设置当前用户idorderQueryVo.UserId(request));//创建一个分页对象Page<OrderInfo> pageParam = new Page<>(page,limit);//查询订单列表 存入到分页对象中IPage<OrderInfo> pageModel = orderService.selectPage(pageParam,orderQueryVo);//封装结果集返回 分页对象数据return Result.ok(pageModel);}//从枚举类中获取订单的状态@ApiOperation(value = "获取订单状态")@GetMapping("auth/getStatusList")public Result getStatusList() {return Result.StatusList());}//根据订单对的id 取消预约@GetMapping("auth/cancelOrder/{orderId}")public Result cancelOrder(@PathVariable Long orderId) {//取消预约Boolean isOrder = orderService.cancelOrder(orderId);return Result.ok(isOrder);}//获取订单统计数据@ApiOperation(value = "获取订单统计数据")@PostMapping("inner/getCountMap")public Map<String, Object> getCountMap(@RequestBody OrderCountQueryVo orderCountQueryVo) {CountMap(orderCountQueryVo);}

②. 微信接口 WeixinController

// 微信接口
@RestController
@RequestMapping("/api/order/weixin")
public class WeixinController {@Autowiredprivate WeixinService weixinService;@Autowiredprivate PaymentService paymentService;//根据订单id 生成微信支付二维码@GetMapping("createNative/{orderId}")public Result createNative(@PathVariable Long orderId) {Map map = ateNative(orderId);return Result.ok(map);}//根据订单id 查询支付状态@GetMapping("queryPayStatus/{orderId}")public Result queryPayStatus(@PathVariable Long orderId) {//调用微信接口实现支付状态查询Map<String,String> resultMap = weixinService.queryPayStatus(orderId);//若查询的结果状态为null 直接返回支付出错信息if(resultMap == null) {return Result.fail().message("支付出错");}//支付成功if("SUCCESS".("trade_state"))) {//更新订单状态//订单编码String out_trade_no = ("out_trade_no");//调用支付服务中更新订单方法paymentService.paySuccess(out_trade_no,resultMap);//返回支付成功状态信息return Result.ok().message("支付成功");}//其他的都判断在支付中return Result.ok().message("支付中");}
}

六. Service层

①. OrderService

public interface OrderService extends IService<OrderInfo> {//生成挂号订单Long saveOrder(String scheduleId, Long patientId);//根据订单id查询订单详情OrderInfo getOrder(String orderId);//订单列表(条件查询带分页)IPage<OrderInfo> selectPage(Page<OrderInfo> pageParam, OrderQueryVo orderQueryVo);//根据订单id 取消预约Boolean cancelOrder(Long orderId);//就诊通知void patientTips();//预约统计Map<String,Object> getCountMap(OrderCountQueryVo orderCountQueryVo );}

②. PaymentService

public interface PaymentService extends IService<PaymentInfo> {//向支付记录表添加信息void savePaymentInfo(OrderInfo order, Integer status);//更新订单状态void paySuccess(String out_trade_no, Map<String, String> resultMap);// 获取支付记录PaymentInfo getPaymentInfo(Long orderId, Integer paymentType);}

③. WeixinService


public interface WeixinService {// 根据订单id 生成微信支付二维码Map createNative(Long orderId);// 根据订单id 调用微信接口实现支付状态查询Map<String, String> queryPayStatus(Long orderId);// 根据订单id 微信退款Boolean refund(Long orderId);}

④. RefundInfoService

public interface RefundInfoService extends IService<RefundInfo> {//根据支付信息 保存退款记录RefundInfo saveRefundInfo(PaymentInfo paymentInfo);}

七. 自定义工具类

①. ConstantPropertiesUtils 常量属性工具类

@Component
public class ConstantPropertiesUtils implements InitializingBean {@Value("${weixin.appid}")private String appid;@Value("${weixin.partner}")private String partner;@Value("${weixin.partnerkey}")private String partnerkey;@Value("${}")private String cert;public static String APPID;public static String PARTNER;public static String PARTNERKEY;public static String CERT;@Overridepublic void afterPropertiesSet() throws Exception {APPID = appid;PARTNER = partner;PARTNERKEY = partnerkey;CERT = cert;}
}

②. http请求客户端

// http请求客户端
public class HttpClient {private String url;private Map<String, String> param;private int statusCode;private String content;private String xmlParam;private boolean isHttps;private boolean isCert = false;//证书密码 微信商户号(mch_id)private String certPassword;public boolean isHttps() {return isHttps;}public void setHttps(boolean isHttps) {this.isHttps = isHttps;}public boolean isCert() {return isCert;}public void setCert(boolean cert) {isCert = cert;}public String getXmlParam() {return xmlParam;}public void setXmlParam(String xmlParam) {lParam = xmlParam;}public HttpClient(String url, Map<String, String> param) {this.url = url;this.param = param;}public HttpClient(String url) {this.url = url;}public String getCertPassword() {return certPassword;}public void setCertPassword(String certPassword) {Password = certPassword;}public void setParameter(Map<String, String> map) {param = map;}public void addParameter(String key, String value) {if (param == null)param = new HashMap<String, String>();param.put(key, value);}public void post() throws ClientProtocolException, IOException {HttpPost http = new HttpPost(url);setEntity(http);execute(http);}public void put() throws ClientProtocolException, IOException {HttpPut http = new HttpPut(url);setEntity(http);execute(http);}public void get() throws ClientProtocolException, IOException {if (param != null) {StringBuilder url = new StringBuilder(this.url);boolean isFirst = true;for (String key : param.keySet()) {if (isFirst)url.append("?");elseurl.append("&");url.append(key).append("=").(key));}this.url = String();}HttpGet http = new HttpGet(url);execute(http);}/*** set http post,put param*/private void setEntity(HttpEntityEnclosingRequestBase http) {if (param != null) {List<NameValuePair> nvps = new LinkedList<NameValuePair>();for (String key : param.keySet())nvps.add(new BasicNameValuePair(key, (key))); // 参数http.setEntity(new UrlEncodedFormEntity(nvps, Consts.UTF_8)); // 设置参数}if (xmlParam != null) {http.setEntity(new StringEntity(xmlParam, Consts.UTF_8));}}private void execute(HttpUriRequest http) throws ClientProtocolException,IOException {CloseableHttpClient httpClient = null;try {if (isHttps) {if(isCert) {//TODO 需要完善FileInputStream inputStream = new FileInputStream(new File(ConstantPropertiesUtils.CERT));KeyStore keystore = Instance("PKCS12");char[] partnerId2charArray = CharArray();keystore.load(inputStream, partnerId2charArray);SSLContext sslContext = SSLContexts.custom().loadKeyMaterial(keystore, partnerId2charArray).build();SSLConnectionSocketFactory sslsf =new SSLConnectionSocketFactory(sslContext,new String[] { "TLSv1" },null,SSLConnectionSocketFactory.BROWSER_COMPATIBLE_HOSTNAME_VERIFIER);httpClient = HttpClients.custom().setSSLSocketFactory(sslsf).build();} else {SSLContext sslContext = new SSLContextBuilder().loadTrustMaterial(null, new TrustStrategy() {// 信任所有public boolean isTrusted(X509Certificate[] chain,String authType)throws CertificateException {return true;}}).build();SSLConnectionSocketFactory sslsf = new SSLConnectionSocketFactory(sslContext);httpClient = HttpClients.custom().setSSLSocketFactory(sslsf).build();}} else {httpClient = ateDefault();}CloseableHttpResponse response = ute(http);try {if (response != null) {if (StatusLine() != null)statusCode = StatusLine().getStatusCode();HttpEntity entity = Entity();// 响应内容content = String(entity, Consts.UTF_8);}} finally {response.close();}} catch (Exception e) {e.printStackTrace();} finally {httpClient.close();}}public int getStatusCode() {return statusCode;}public String getContent() throws ParseException, IOException {return content;}
}

八. Mapper层

①. OrderMapper PaymentMapper RefundInfoMapper

public interface OrderMapper extends BaseMapper<OrderInfo> {//查询预约统计数据的方法List<OrderCountVo> selectOrderCount(@Param("vo") OrderCountQueryVo orderCountQueryVo);
}

②. l

<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE mapperPUBLIC "-//mybatis//DTD Config 3.0//EN"".dtd">
<mapper namespace="der.mapper.OrderMapper"><select id="selectOrderCount" resultType="der.OrderCountVo">SELECT COUNT(*) AS count ,reserve_date AS reserveDate FROM order_info<where><if test="vo.hosname!=null and vo.hosname!=''">and hosname like CONCAT('%',#{vo.hosname},'%')</if><if test=&#serveDateBegin != null serveDateBegin != ''">and reserve_date >= #{vo.reserveDateBegin}</if><if test=&#serveDateEnd != null serveDateEnd != ''">and reserve_date &lt;= #{vo.reserveDateEnd}</if>and is_deleted = 0</where>GROUP BY reserve_dateORDER BY reserve_date</select>
</mapper>

public interface PaymentMapper extends BaseMapper<PaymentInfo> {
}

九. 根据订单号返回微信支付的二维码

十. 根据订单ID进行取消预约,微信退款

本文发布于:2024-02-04 07:56:58,感谢您对本站的认可!

本文链接:https://www.4u4v.net/it/170702485853716.html

版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。

标签:医院管理   项目
留言与评论(共有 0 条评论)
   
验证码:

Copyright ©2019-2022 Comsenz Inc.Powered by ©

网站地图1 网站地图2 网站地图3 网站地图4 网站地图5 网站地图6 网站地图7 网站地图8 网站地图9 网站地图10 网站地图11 网站地图12 网站地图13 网站地图14 网站地图15 网站地图16 网站地图17 网站地图18 网站地图19 网站地图20 网站地图21 网站地图22/a> 网站地图23