Parcourir la source

Merge branch 'dev' of http://192.168.1.220:10080/Amoy2/wlyy2.0 into baseCopy1

wangjun il y a 3 ans
Parent
commit
85dad8599c
50 fichiers modifiés avec 2583 ajouts et 342 suppressions
  1. 6 1
      business/base-service/src/main/java/com/yihu/jw/order/BusinessOrderService.java
  2. 3 0
      business/base-service/src/main/java/com/yihu/jw/order/dao/BusinessOrderDao.java
  3. 16 0
      common/common-entity/sql记录
  4. 66 0
      common/common-entity/src/main/java/com/yihu/jw/entity/care/common/WxPayHttpLogDO.java
  5. 39 2
      common/common-entity/src/main/java/com/yihu/jw/entity/care/doorCoach/BaseDoorCoachOrderDO.java
  6. 38 0
      common/common-entity/src/main/java/com/yihu/jw/entity/care/lifeCare/LifeCareOrderDO.java
  7. 2 1
      common/common-entity/src/main/java/com/yihu/jw/entity/order/BusinessOrderDO.java
  8. 1 1
      common/common-entity/src/main/java/com/yihu/jw/entity/order/BusinessOrderRefundDO.java
  9. 24 0
      common/common-util/src/main/java/com/yihu/jw/util/common/IpUtil.java
  10. 12 0
      gateway/ag-basic/src/main/resources/application.yml
  11. 9 1
      gateway/ag-basic/src/main/resources/bootstrap.yml
  12. 27 0
      server/svr-authentication/src/main/resources/application.yml
  13. 8 0
      server/svr-authentication/src/main/resources/bootstrap.yml
  14. 14 0
      server/svr-configuration/src/main/resources/bootstrap.yml
  15. 47 1
      svr/svr-base/src/main/resources/application.yml
  16. 9 1
      svr/svr-base/src/main/resources/bootstrap.yml
  17. 3 3
      svr/svr-cloud-care/pom.xml
  18. 3 0
      svr/svr-cloud-care/src/main/java/com/yihu/jw/care/dao/doorCoach/BaseDoorCoachFeeDetailDao.java
  19. 4 0
      svr/svr-cloud-care/src/main/java/com/yihu/jw/care/dao/lifeCare/LifeCareFeeDetailDao.java
  20. 17 0
      svr/svr-cloud-care/src/main/java/com/yihu/jw/care/dao/pay/WxPayHttpLogDao.java
  21. 1 1
      svr/svr-cloud-care/src/main/java/com/yihu/jw/care/endpoint/BaseController.java
  22. 2 2
      svr/svr-cloud-care/src/main/java/com/yihu/jw/care/endpoint/device/DeviceController.java
  23. 3 3
      svr/svr-cloud-care/src/main/java/com/yihu/jw/care/endpoint/device/DoctorDeviceController.java
  24. 11 11
      svr/svr-cloud-care/src/main/java/com/yihu/jw/care/endpoint/device/DoctorHealthController.java
  25. 5 5
      svr/svr-cloud-care/src/main/java/com/yihu/jw/care/endpoint/device/PadDeviceController.java
  26. 12 12
      svr/svr-cloud-care/src/main/java/com/yihu/jw/care/endpoint/device/PatientDeviceController.java
  27. 10 10
      svr/svr-cloud-care/src/main/java/com/yihu/jw/care/endpoint/device/PatientHealthController.java
  28. 12 12
      svr/svr-cloud-care/src/main/java/com/yihu/jw/care/endpoint/device/YsDeviceController.java
  29. 25 25
      svr/svr-cloud-care/src/main/java/com/yihu/jw/care/endpoint/doorCoach/DoctorDoorCoachOrderController.java
  30. 312 0
      svr/svr-cloud-care/src/main/java/com/yihu/jw/care/endpoint/patient/PayEndpoint.java
  31. 2 2
      svr/svr-cloud-care/src/main/java/com/yihu/jw/care/endpoint/dict/PrivateDictEndpoint.java
  32. 5 5
      svr/svr-cloud-care/src/main/java/com/yihu/jw/care/endpoint/third/device/PDeviceController.java
  33. 1 1
      svr/svr-cloud-care/src/main/java/com/yihu/jw/care/endpoint/third/platForm/PatientInfoPlatFormEndpoint.java
  34. 12 3
      svr/svr-cloud-care/src/main/java/com/yihu/jw/care/service/device/YsDeviceService.java
  35. 2 18
      svr/svr-cloud-care/src/main/java/com/yihu/jw/care/service/doorCoach/DoctorDoorCoachOrderService.java
  36. 212 117
      svr/svr-cloud-care/src/main/java/com/yihu/jw/care/service/doorCoach/PatientDoorCoachOrderService.java
  37. 80 101
      svr/svr-cloud-care/src/main/java/com/yihu/jw/care/service/lifeCare/LifeCareOrderService.java
  38. 718 0
      svr/svr-cloud-care/src/main/java/com/yihu/jw/care/service/pay/PayService.java
  39. 1 1
      svr/svr-cloud-care/src/main/java/com/yihu/jw/care/service/third/PatientInfoPlatFormService.java
  40. 80 0
      svr/svr-cloud-care/src/main/java/com/yihu/jw/care/util/HttpsUtil.java
  41. 51 0
      svr/svr-cloud-care/src/main/java/com/yihu/jw/care/util/MD5Util.java
  42. 27 0
      svr/svr-cloud-care/src/main/java/com/yihu/jw/care/util/RequestTrustManager.java
  43. 100 0
      svr/svr-cloud-care/src/main/java/com/yihu/jw/care/util/WxpayUtil.java
  44. 173 0
      svr/svr-cloud-care/src/main/java/com/yihu/jw/care/util/XMLUtil.java
  45. 10 2
      svr/svr-cloud-care/src/main/resources/application.yml
  46. 298 0
      svr/svr-cloud-care/src/main/resources/wechat/README.md
  47. BIN
      svr/svr-cloud-care/src/main/resources/wechat/apiclient_cert.p12
  48. 24 0
      svr/svr-cloud-care/src/main/resources/wechat/apiclient_cert.pem
  49. 28 0
      svr/svr-cloud-care/src/main/resources/wechat/apiclient_key.pem
  50. 18 0
      svr/svr-cloud-care/src/main/resources/wechat/证书使用说明.txt

+ 6 - 1
business/base-service/src/main/java/com/yihu/jw/order/BusinessOrderService.java

@ -453,9 +453,14 @@ public class BusinessOrderService extends BaseJpaService<BusinessOrderDO,Busines
     */
    @Transactional(rollbackFor = Exception.class)
    public String refund(Map<String,String> par,String appKey) throws Exception {
        WlyyHospitalSysDictDO hospitalSysDictDO = hospitalSysDictDao.findById("REFUND");
        if(StringUtils.isNoneBlank(hospitalSysDictDO.getImgUrl())){
            //公网域名必须为https
            par.put("notify_url",hospitalSysDictDO.getImgUrl());
        }
        String xml= WeiXinPayUtils.getXmlBeforUnifiedorder(par, appKey);
        logger.info("xml:"+xml);
        WlyyHospitalSysDictDO hospitalSysDictDO = hospitalSysDictDao.findById("REFUND");
        return HttpUtil.doRefund("https://api.mch.weixin.qq.com/secapi/pay/refund",xml,hospitalSysDictDO.getDictCode(),hospitalSysDictDO.getDictValue());
    }

+ 3 - 0
business/base-service/src/main/java/com/yihu/jw/order/dao/BusinessOrderDao.java

@ -32,4 +32,7 @@ public interface BusinessOrderDao extends PagingAndSortingRepository<BusinessOrd
    @Query("from BusinessOrderDO w where w.status = ?1 and w.orderCategory <>4")
    List<BusinessOrderDO> selectByStatus(Integer status);
    @Query("from BusinessOrderDO w where w.patient = ?1 and w.status=?2  and w.orderCategory =?3")
    List<BusinessOrderDO> selectByPatientAndStatusAndOrderCategory(String patient,Integer status,String orderCategory);
}

+ 16 - 0
common/common-entity/sql记录

@ -1066,3 +1066,19 @@ CREATE TABLE `base_service_news` (
  PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='服务动态信息';
-- 2021-06-29 ysj
CREATE TABLE `base_wx_pay_http_log` (
  `id` varchar(50) NOT NULL,
  `type` varchar(1) DEFAULT NULL COMMENT '类型1 统一下单 2支付回调 3退款 4 退款回调',
  `order_no` varchar(50) DEFAULT NULL COMMENT '订单号',
  `order_res` text,
  `order_req` text,
  `create_time` datetime DEFAULT NULL,
  PRIMARY KEY (`id`),
  KEY `index1` (`order_no`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='微信支付日志表';
-- 2021-06-30
alter table base.base_door_coach_order add column pay_status TINYINT(2) DEFAULT null COMMENT '0待扣费 1已支付 2已退款';
alter table base.base_life_care_order add column pay_status TINYINT(2) DEFAULT null COMMENT '0待扣费 1已支付 2已退款';

+ 66 - 0
common/common-entity/src/main/java/com/yihu/jw/entity/care/common/WxPayHttpLogDO.java

@ -0,0 +1,66 @@
package com.yihu.jw.entity.care.common;
import com.yihu.jw.entity.UuidIdentityEntityWithCreateTime;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Table;
/**
 * Created with IntelliJ IDEA.
 *
 * @Author: yeshijie
 * @Date: 2021/6/29
 * @Description:
 */
@Entity
@Table(name="base_wx_pay_http_log")
public class WxPayHttpLogDO extends UuidIdentityEntityWithCreateTime {
    /**
     * 类型1 统一下单 2支付回调
     */
    private String type;
    /**
     * 订单号
     */
    private String orderNo;
    private String orderRes;
    private String orderReq;
    @Column(name = "type")
    public String getType() {
        return type;
    }
    public void setType(String type) {
        this.type = type;
    }
    @Column(name = "order_no")
    public String getOrderNo() {
        return orderNo;
    }
    public void setOrderNo(String orderNo) {
        this.orderNo = orderNo;
    }
    @Column(name = "order_res")
    public String getOrderRes() {
        return orderRes;
    }
    public void setOrderRes(String orderRes) {
        this.orderRes = orderRes;
    }
    @Column(name = "order_req")
    public String getOrderReq() {
        return orderReq;
    }
    public void setOrderReq(String orderReq) {
        this.orderReq = orderReq;
    }
}

+ 39 - 2
common/common-entity/src/main/java/com/yihu/jw/entity/care/doorCoach/BaseDoorCoachOrderDO.java

@ -33,8 +33,10 @@ public class BaseDoorCoachOrderDO extends UuidIdentityEntityWithOperator {
     * 工单状态
     */
    public enum Status {
        //待付款 status==(1 or 2) and payWay为空
        cancel(-1, "已取消"),
        waitForPay(0, "待支付"),
        waitForSend(1, "待(调度员)派单"),
        waitForAccept(2, "待(医生)接单"),
        accept(3, "已接单"),
@ -64,7 +66,6 @@ public class BaseDoorCoachOrderDO extends UuidIdentityEntityWithOperator {
     * 支付方式
     */
    public enum PayWay {
        wechat(1, "微信支付"),
        offLine(2,"线下支付");
@ -216,6 +217,32 @@ public class BaseDoorCoachOrderDO extends UuidIdentityEntityWithOperator {
    }
    /**
     * 支付状态
     */
    public enum payStatus {
        waitForPay(0, "待支付"),
        paid(1, "已支付"),
        Refunded(1, "已退款");
        private Integer type;
        private String desc;
        payStatus(Integer type, String desc) {
            this.type = type;
            this.desc = desc;
        }
        public Integer getType() {
            return type;
        }
        public void setType(Integer type) {
            this.type = type;
        }
    }
    /**
     * 服务编号
     */
@ -564,7 +591,10 @@ public class BaseDoorCoachOrderDO extends UuidIdentityEntityWithOperator {
     */
    private String shortcutType;
    /**
     * 0待扣费 1已扣费 2已退费
     */
    private Integer payStatus;//支付状态
    @Column(name = "number")
    public String getNumber() {
@ -1192,4 +1222,11 @@ public class BaseDoorCoachOrderDO extends UuidIdentityEntityWithOperator {
        this.followupDate = followupDate;
    }
    public Integer getPayStatus() {
        return payStatus;
    }
    public void setPayStatus(Integer payStatus) {
        this.payStatus = payStatus;
    }
}

+ 38 - 0
common/common-entity/src/main/java/com/yihu/jw/entity/care/lifeCare/LifeCareOrderDO.java

@ -23,6 +23,7 @@ public class LifeCareOrderDO extends UuidIdentityEntityWithOperator {
    public enum Status {
        cancel(-1, "已取消"),
        waitForPay(0, "待支付"),
        waitForAccept(1, "待(医生)接单"),//待服务
        signIn(3, "已签到"),
        complete(2,"已完成");
@ -71,6 +72,31 @@ public class LifeCareOrderDO extends UuidIdentityEntityWithOperator {
    }
    /**
     * 支付状态
     */
    public enum payStatus {
        waitForPay(0, "待支付"),
        paid(1, "已支付"),
        Refunded(1, "已退款");
        private Integer type;
        private String desc;
        payStatus(Integer type, String desc) {
            this.type = type;
            this.desc = desc;
        }
        public Integer getType() {
            return type;
        }
        public void setType(Integer type) {
            this.type = type;
        }
    }
    /**
     * 服务编号
@ -300,6 +326,10 @@ public class LifeCareOrderDO extends UuidIdentityEntityWithOperator {
     * 签到医生姓名
     */
    private String signDoctorName;
    /**
     * 0待扣费 1已扣费 2已退费
     */
    private Integer payStatus;//支付状态
    @Column(name = "number")
    public String getNumber() {
@ -705,4 +735,12 @@ public class LifeCareOrderDO extends UuidIdentityEntityWithOperator {
    public void setConclusionTime(Date conclusionTime) {
        this.conclusionTime = conclusionTime;
    }
    public Integer getPayStatus() {
        return payStatus;
    }
    public void setPayStatus(Integer payStatus) {
        this.payStatus = payStatus;
    }
}

+ 2 - 1
common/common-entity/src/main/java/com/yihu/jw/entity/order/BusinessOrderDO.java

@ -28,7 +28,7 @@ public class BusinessOrderDO extends IntegerIdentityEntity {
    private Integer orderType;
    /**
     * 互联网医院- 1:专家咨询|2:图文诊室|3:视频诊室|4处方结算|5就诊卡充值)
     * 医养项目 订单分类 orderType=1 时 1招生,2 课程,3 上门预约(托幼)
     * 医养项目 订单分类 orderType=1 时 1招生,2 课程,3 上门辅导托幼) 4 生活照料
     */
    private String orderCategory;
    private String relationCode;//业务关联code
@ -39,6 +39,7 @@ public class BusinessOrderDO extends IntegerIdentityEntity {
    private Double payPrice;//支付金额
    private Date payTime;//支付时间
    private String doctor;//医生code
    //医养支付状态 0待支付、1已支付、2已取消、3申请退款中、4已售后
    private Integer status;//0待支付1支付成功2支付失败3取消
    private String pcCallbackUrl;//Pc端查看当前订单的会话信息
    private String appCallbackUrl;//App端查看当前订单的会话信息

+ 1 - 1
common/common-entity/src/main/java/com/yihu/jw/entity/order/BusinessOrderRefundDO.java

@ -27,7 +27,7 @@ public class BusinessOrderRefundDO extends IntegerIdentityEntity {
    private String appId;//公众号id
    private String mchId;//商户号
    private String refundDesc;//退款原因
    private Integer status;//状态1待退款2已退款
    private Integer status;//状态1待退款2已退款 3同意退款
    private Date refundTime;//退款时间
    private String enclosure;//附件
    private Date createTime;

+ 24 - 0
common/common-util/src/main/java/com/yihu/jw/util/common/IpUtil.java

@ -55,6 +55,30 @@ public class IpUtil {
    }
    /**
     * 获取真实ip地址
     *
     * @param request
     * @return java.lang.String
     */
    public static String getOneIpAddress(HttpServletRequest request) {
        String ip = request.getHeader("x-forwarded-for");
        if (ip == null || ip.length() == 0 || "unknown".equalsIgnoreCase(ip)) {
            ip = request.getHeader("Proxy-Client-IP");
        }
        if (ip == null || ip.length() == 0 || "unknown".equalsIgnoreCase(ip)) {
            ip = request.getHeader("WL-Proxy-Client-IP");
        }
        if (ip == null || ip.length() == 0 || "unknown".equalsIgnoreCase(ip)) {
            ip = request.getRemoteAddr();
        }
        if (ip.contains(",")) {
            return ip.split(",")[0];
        } else {
            return ip;
        }
    }
    /**
     * 获取客户端请求中的真实的ip地址
     *  获取客户端的IP地址的方法是:request.getRemoteAddr(),这种方法在大部分情况下都是有效的。

+ 12 - 0
gateway/ag-basic/src/main/resources/application.yml

@ -240,3 +240,15 @@ spring:
    host: 10.18.43.40 # Redis server host.
    port: 6379  # Redis server port.
    password: Kb6wKDQP1W4
---
spring:
  profiles: wjwProd
  datasource:
     url: jdbc:mysql://127.0.0.1:3306/base?useUnicode:true&amp;characterEncoding=utf-8&amp;autoReconnect=true&useSSL=false
     username: wlyy
     password: 0XxS3W*!cRj
  redis:
     host: 127.0.0.1 # Redis server host.
     port: 6380  # Redis server port.
     password: Kb6wKDQP1W4

+ 9 - 1
gateway/ag-basic/src/main/resources/bootstrap.yml

@ -128,4 +128,12 @@ spring:
  cloud:
    config:
      uri: ${wlyy-spring.config.uri:http://127.0.0.1:1221}
      label: ${wlyy-spring.config.label:master}
      label: ${wlyy-spring.config.label:master}
---
spring:
  profiles: wjwProd
  cloud:
    config:
      uri: ${wlyy.pring.config.uri:http://192.168.120.71:1221}
      label: ${wlyy.spring.config.label:master}

+ 27 - 0
server/svr-authentication/src/main/resources/application.yml

@ -405,3 +405,30 @@ testPattern:
wechat:
  id: hz_yyyzh_wx  # base库中,wx_wechat 的id字段
---
spring:
  profiles: wjwProd
  datasource:
    url: jdbc:mysql://127.0.0.1:3306/base?useUnicode:true&amp;characterEncoding=utf-8&amp;autoReconnect=true&useSSL=false
    username: wlyy
    password: 0XxS3W*!cRj
  redis:
    host: 127.0.0.1 # Redis server host.
    port: 6380 # Redis server port.
    password: Kb6wKDQP1W4
iHealth:
  user-info-uri: http://www.xmtyw.cn/wlyy/iHealth/userInfo
zhongshanHospital:
  user-info-uri: http://laptop-u738dn2p:10023/mqsdk/getUserInfoByOpenid
fastDFS:
  fastdfs_file_url: http://127.0.0.1:22122
wlyy:
  url: http://www.xmtyw.cn/wlyy/
testPattern:
  sign: 0
  remote_inner_url: 172.16.100.240:10023/open/fileUpload/upload_stream
wechat:
  id: wjw

+ 8 - 0
server/svr-authentication/src/main/resources/bootstrap.yml

@ -127,6 +127,14 @@ spring:
---
spring:
  profiles: hzprod
  cloud:
    config:
      uri: ${wlyy-spring.config.uri:http://127.0.0.1:1221}
      label: ${wlyy-spring.config.label:jwdev}
---
spring:
  profiles: wjwProd
  cloud:
    config:
      uri: ${wlyy-spring.config.uri:http://127.0.0.1:1221}

+ 14 - 0
server/svr-configuration/src/main/resources/bootstrap.yml

@ -193,4 +193,18 @@ spring:
          basedir: /usr/local/wlyy2.0-config
          username: jkzl
          password: jkzl
        default-label: ${wlyy.spring.config.git.label:master}
---
spring:
  profiles: wjwProd
##git配置
  cloud:
    config:
      failFast: true #启动快速失败 即链接不到配置服务就启动失败
      server:
        git:
          uri: ${wlyy.spring.config.git.uri:http://127.0.0.1:3000/jkzl/ehr.config.git}
          basedir: /usr/local/wlyy2.0-config
        default-label: ${wlyy.spring.config.git.label:master}

+ 47 - 1
svr/svr-base/src/main/resources/application.yml

@ -641,4 +641,50 @@ testPattern:
  sign: 0
  remote_inner_url: 1
im:
  im_list_get: http://10.18.43.41:3000/
  im_list_get: http://10.18.43.41:3000/
---
spring:
  profiles: wjwProd
  datasource:
    url: jdbc:mysql://127.0.0.1:3306/base?useUnicode:true&characterEncoding=utf-8&autoReconnect=true
    username: wlyy
    password: 0XxS3W*!cRj
  elasticsearch:
    cluster-name: jkzl #集群名 默认elasticsearch
    cluster-nodes: 192.0.33.26:9200 #配置es节点信息,逗号分隔,如果没有指定,则启动ClientNode
    client-transport-sniff: false
    jest:
      uris: http://10.9.1.247:9200
      connection-timeout: 60000 # Connection timeout in milliseconds.
      multi-threaded: true # Enable connection requests from multiple execution threads.
  activemq:
    broker-url: tcp://10.9.1.247:9103
    user: jkzl
    password: jkzlehr
  redis:
    host: 127.0.0.1 # Redis server host.
    port: 6380 # Redis server port.
    password: Kb6wKDQP1W4
fastDFS:
  fastdfs_file_url: http://127.0.0.1:8888/
demo:
  flag: true
hospital:
  url: https://wx.xmzsh.com
  mqUser: JKZL
  mqPwd: 123456
  SourceSysCode: S60
  TargetSysCode: S01
wlyy:
  url: http://ehr.yihu.com/wlyy/
wechat:
  id: hz_yyyzh_wx
  url: https://zhyzh.hzxc.gov.cn/
  flag: false
#文件服务器上传配置 0本地,1.I健康,2.内网调用
testPattern:
  sign: 0
  remote_inner_url: 172.16.100.240:10023/open/fileUpload/upload_stream
im:
  im_list_get: http://10.9.1.247:3000/

+ 9 - 1
svr/svr-base/src/main/resources/bootstrap.yml

@ -109,4 +109,12 @@ spring:
  cloud:
    config:
      uri: ${wlyy-spring.config.uri:http://127.0.0.1:1221}
      label: ${wlyy-spring.config.label:master}
      label: ${wlyy-spring.config.label:master}
---
spring:
  profiles: wjwProd
  cloud:
    config:
      uri: ${wlyy-spring.config.uri:http://127.0.0.1:1221}
      label: ${wlyy-spring.config.label:jwdev}

+ 3 - 3
svr/svr-cloud-care/pom.xml

@ -88,9 +88,9 @@
            <artifactId>common-rest-model</artifactId>
        </dependency>
        <dependency>
            <groupId>com.yihu.jw</groupId>
            <artifactId>wxpay-sdk</artifactId>
            <version>3.0.9</version>
            <groupId>org.jdom</groupId>
            <artifactId>jdom</artifactId>
            <version>2.0.2</version>
        </dependency>
        <dependency>
            <groupId>com.yihu.jw</groupId>

+ 3 - 0
svr/svr-cloud-care/src/main/java/com/yihu/jw/care/dao/doorCoach/BaseDoorCoachFeeDetailDao.java

@ -1,6 +1,7 @@
package com.yihu.jw.care.dao.doorCoach;
import com.yihu.jw.entity.care.doorCoach.BaseDoorCoachFeeDetailDO;
import com.yihu.jw.entity.care.lifeCare.LifeCareFeeDetailDO;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.jpa.repository.Modifying;
import org.springframework.data.jpa.repository.Query;
@ -24,6 +25,8 @@ import java.util.Map;
 */
public interface BaseDoorCoachFeeDetailDao extends PagingAndSortingRepository<BaseDoorCoachFeeDetailDO, String>, JpaSpecificationExecutor<BaseDoorCoachFeeDetailDO>  {
    List<BaseDoorCoachFeeDetailDO> findByOrderId(String orderId);
    @Query("select d from BaseDoorCoachFeeDetailDO d where d.orderId = ?1 and d.type=?2 and d.status <> 3")
    List<BaseDoorCoachFeeDetailDO> findByOrderIdAndType(String orderId, Integer type);

+ 4 - 0
svr/svr-cloud-care/src/main/java/com/yihu/jw/care/dao/lifeCare/LifeCareFeeDetailDao.java

@ -4,8 +4,12 @@ import com.yihu.jw.entity.care.lifeCare.LifeCareFeeDetailDO;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.repository.PagingAndSortingRepository;
import java.util.List;
/**
 * Created by yeshijie on 2021/3/26.
 */
public interface LifeCareFeeDetailDao extends PagingAndSortingRepository<LifeCareFeeDetailDO, String>, JpaSpecificationExecutor<LifeCareFeeDetailDO> {
    List<LifeCareFeeDetailDO> findByOrderId(String orderId);
}

+ 17 - 0
svr/svr-cloud-care/src/main/java/com/yihu/jw/care/dao/pay/WxPayHttpLogDao.java

@ -0,0 +1,17 @@
package com.yihu.jw.care.dao.pay;
import com.yihu.jw.entity.care.common.WxPayHttpLogDO;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.repository.PagingAndSortingRepository;
/**
 * Created with IntelliJ IDEA.
 *
 * @Author: yeshijie
 * @Date: 2021/6/29
 * @Description:
 */
public interface WxPayHttpLogDao extends PagingAndSortingRepository<WxPayHttpLogDO,String>, JpaSpecificationExecutor<WxPayHttpLogDO> {
}

+ 1 - 1
svr/svr-cloud-care/src/main/java/com/yihu/jw/care/endpoint/BaseController.java

@ -298,7 +298,7 @@ public class BaseController {
        }
    }
    public String error(int code, String msg,Exception e) {
    public String errorResult(Exception e) {
        try {
            e.printStackTrace();
            Map<Object, Object> map = new HashMap<Object, Object>();

+ 2 - 2
svr/svr-cloud-care/src/main/java/com/yihu/jw/care/endpoint/device/DeviceController.java

@ -36,7 +36,7 @@ public class DeviceController extends BaseController {
            List<Device> list = deviceService.findDeviceByCategory(categoryCode);
            return write(200, "获取设备列表成功!", "data", list);
        } catch (Exception ex) {
            return error(-1, "获取设备列表失败!",ex);
            return errorResult(ex);
        }
    }
@ -50,7 +50,7 @@ public class DeviceController extends BaseController {
            return write(200, "查询成功", "data", device);
        } catch (Exception ex) {
            return error(-1, "获取设备列表失败!",ex);
            return errorResult(ex);
        }
    }

+ 3 - 3
svr/svr-cloud-care/src/main/java/com/yihu/jw/care/endpoint/device/DoctorDeviceController.java

@ -71,7 +71,7 @@ public class DoctorDeviceController extends BaseController {
			return write(200, "查询成功", "data", list);
		} catch (Exception ex) {
			return error(-1, ex.getMessage(),ex);
			return errorResult(ex);
		}
	}
@ -85,7 +85,7 @@ public class DoctorDeviceController extends BaseController {
			return write(200, "查询成功", "data", device);
		} catch (Exception ex) {
			return error( -1, ex.getMessage(),ex);
			return errorResult(ex);
		}
	}
@ -103,7 +103,7 @@ public class DoctorDeviceController extends BaseController {
			List<Map<String,String>> list = patientDeviceService.getDeviceUser(patient,deviceSn,type);
			return write(200, "获取设备绑定信息成功!", "data",list);
		} catch (Exception ex) {
			return error(-1, ex.getMessage(),ex);
			return errorResult(ex);
		}
	}
	@ApiOperation("通过sn码获取设备绑定情况(管理端)")

+ 11 - 11
svr/svr-cloud-care/src/main/java/com/yihu/jw/care/endpoint/device/DoctorHealthController.java

@ -44,7 +44,7 @@ public class DoctorHealthController extends BaseController {
				return error(-1, "查询失败");
			}
		} catch (Exception e) {
			return error(-1, "查询失败",e);
			return errorResult(e);
		}
	}
@ -73,7 +73,7 @@ public class DoctorHealthController extends BaseController {
			}
			return write(200, "查询成功", "list", jsonArray);
		} catch (Exception ex) {
			return error( -1, "查询失败!",ex);
			return errorResult(ex);
		}
	}
@ -110,7 +110,7 @@ public class DoctorHealthController extends BaseController {
			return write(200, "查询成功", "list", jsonObject);
		} catch (Exception ex) {
			return error(-1, "查询失败!",ex);
			return errorResult(ex);
		}
	}
@ -140,7 +140,7 @@ public class DoctorHealthController extends BaseController {
			return write(200, "查询成功", "list", jsonObject);
		} catch (Exception ex) {
			return error( -1, "查询失败!",ex);
			return errorResult(ex);
		}
	}
@ -171,7 +171,7 @@ public class DoctorHealthController extends BaseController {
			json.put("custom", userArray);
			return write(200, "查询成功", "data", json);
		} catch (Exception e) {
			return error( -1, "查询失败!",e);
			return errorResult(e);
		}
	}
@ -208,7 +208,7 @@ public class DoctorHealthController extends BaseController {
			}
			return write(200, "查询成功", "data", map);
		} catch (Exception ex) {
			return error(-1, ex.getMessage(),ex);
			return errorResult(ex);
		}
	}
@ -227,7 +227,7 @@ public class DoctorHealthController extends BaseController {
			return write(200, "获取患者健康指标历史记录成功", "data", list);
		} catch (Exception ex) {
			return error( -1, ex.getMessage(),ex);
			return errorResult(ex);
		}
	}
@ -260,7 +260,7 @@ public class DoctorHealthController extends BaseController {
			json.put("custom", userArray);
			return write(200, "查询成功", "data", json);
		} catch (Exception e) {
			return error( -1, e.getMessage(),e);
			return errorResult(e);
		}
	}
@ -280,7 +280,7 @@ public class DoctorHealthController extends BaseController {
			}
			return write(200, "获取健康指标记录日期成功", "data", list);
		}catch (Exception e){
			return error( -1, e.getMessage(),e);
			return errorResult(e);
		}
	}
@ -295,7 +295,7 @@ public class DoctorHealthController extends BaseController {
			List<Map<String,String>> list = healthIndexService.getHealthIndexByPatientAndDate(patientCode,deviceSn,choseDay,type);
			return write(200, "获取健康指标历史记录成功", "data", list);
		} catch (Exception ex) {
			return error( -1, ex.getMessage(),ex);
			return errorResult(ex);
		}
	}
@ -308,7 +308,7 @@ public class DoctorHealthController extends BaseController {
			DevicePatientHealthIndex patientHealthIndex = healthIndexService.getHealthIndexById(id);
			return write(200, "查询成功", "data", patientHealthIndex);
		} catch (Exception e) {
			return error( -1, e.getMessage(),e);
			return errorResult(e);
		}
	}
}

+ 5 - 5
svr/svr-cloud-care/src/main/java/com/yihu/jw/care/endpoint/device/PadDeviceController.java

@ -65,7 +65,7 @@ public class PadDeviceController extends BaseController {
            return write(200, "查询成功", "data", list);
        } catch (Exception ex) {
            return error( -1, ex.getMessage(),ex);
            return errorResult(ex);
        }
    }
@ -76,7 +76,7 @@ public class PadDeviceController extends BaseController {
            List<Map<String , Object>> list = patientDeviceService.getDeviceType();
            return write(200, "查询成功", "data", list);
        } catch (Exception ex) {
            return error( -1, ex.getMessage(),ex);
            return errorResult(ex);
        }
    }
@ -88,7 +88,7 @@ public class PadDeviceController extends BaseController {
            List<Map<String , Object>> list = patientDeviceService.getDeviceTypeSmall(category_code);
            return write(200, "查询成功", "data", list);
        } catch (Exception ex) {
            return error( -1, ex.getMessage(),ex);
            return errorResult(ex);
        }
    }
@ -126,7 +126,7 @@ public class PadDeviceController extends BaseController {
            return success("设备保存成功!");
        } catch (Exception ex) {
            return error( -1, ex.getMessage(),ex);
            return errorResult(ex);
        }
    }
@ -143,7 +143,7 @@ public class PadDeviceController extends BaseController {
                    return write(-1,"解绑失败,请确认设备sn码");
                }
        } catch (Exception ex) {
            return error( -1, ex.getMessage(),ex);
            return errorResult(ex);
        }
    }

+ 12 - 12
svr/svr-cloud-care/src/main/java/com/yihu/jw/care/endpoint/device/PatientDeviceController.java

@ -63,7 +63,7 @@ public class PatientDeviceController extends BaseController {
            JSONObject json = patientHealthIndexService.getealthStandard(type,getRepUID());
            return write(200,"获取成功","data",json);
        } catch (Exception ex) {
            return error( -1, ex.getMessage(),ex);
            return errorResult(ex);
        }
    }
@ -105,7 +105,7 @@ public class PatientDeviceController extends BaseController {
            return success("设备保存成功!");
        } catch (Exception ex) {
            return error( -1, ex.getMessage(),ex);
            return errorResult(ex);
        }
    }
@ -125,7 +125,7 @@ public class PatientDeviceController extends BaseController {
            return write(200, "查询成功", "data", list);
        } catch (Exception ex) {
            return error( -1, ex.getMessage(),ex);
            return errorResult(ex);
        }
    }
@ -140,7 +140,7 @@ public class PatientDeviceController extends BaseController {
            mapList.put("device", device);
            return write(200, "查询成功", "data", mapList);
        } catch (Exception ex) {
            return error( -1, ex.getMessage(),ex);
            return errorResult(ex);
        }
    }
@ -160,7 +160,7 @@ public class PatientDeviceController extends BaseController {
            List<Map<String, String>> list = patientDeviceService.getDeviceUser(getRepUID(), deviceSn, type);
            return write(200, "获取设备绑定信息成功!", "data", list);
        } catch (Exception ex) {
            return error( -1, ex.getMessage(),ex);
            return errorResult(ex);
        }
    }
@ -173,7 +173,7 @@ public class PatientDeviceController extends BaseController {
        try {
            return write(200,"查询成功","detailModelList",  patientDeviceService.patientDeviceListByTopic(patient,topic));
        } catch (Exception ex) {
            return error(-1, ex.getMessage(),ex);
            return errorResult(ex);
        }
    }
@ -199,7 +199,7 @@ public class PatientDeviceController extends BaseController {
                return error(-1, "不存在该设备!");
            }
        } catch (Exception ex) {
            return error( -1, ex.getMessage(),ex);
            return errorResult(ex);
        }
    }
@ -209,7 +209,7 @@ public class PatientDeviceController extends BaseController {
        try {
            return write(200,"执行成功","data",patientDeviceService.getPatientDeviceTaskInfo(patientCode));
        }catch (Exception e){
            return error( -1, e.getMessage(),e);
            return errorResult(e);
        }
    }
@ -220,7 +220,7 @@ public class PatientDeviceController extends BaseController {
        try {
            return write(200,"获取成功","data",patientDeviceService.getAqgDeviceInfo(deviceSn));
        }catch (Exception e){
            return error( -1, e.getMessage(),e);
            return errorResult(e);
        }
    }
@ -245,7 +245,7 @@ public class PatientDeviceController extends BaseController {
            }
            return error(-1,json.getString("error_desc"));
        }catch (Exception e){
            return error( -1, e.getMessage(),e);
            return errorResult(e);
        }
    }
@ -258,7 +258,7 @@ public class PatientDeviceController extends BaseController {
        try {
            return write(200,"获取成功","data",patientDeviceService.getDeviceLastLocation(deviceSn,type));
        }catch (Exception e){
            return error( -1, e.getMessage(),e);
            return errorResult(e);
        }
    }
@ -286,7 +286,7 @@ public class PatientDeviceController extends BaseController {
        try {
            return write(200,"获取成功","data",patientDeviceService.updateDeviceFenceArea(deviceSn, fenceNO, enable, name, freq, time_begin, time_end, safe_area, clear));
        }catch (Exception e){
            return error( -1, e.getMessage(),e);
            return errorResult(e);
        }
    }
}

+ 10 - 10
svr/svr-cloud-care/src/main/java/com/yihu/jw/care/endpoint/device/PatientHealthController.java

@ -49,7 +49,7 @@ public class PatientHealthController extends BaseController {
            healthIndexService.modify(id,recordDate, value1, value2, value3, value4);
            return write(200, "更改成功!");
        } catch (Exception e) {
            return error( -1, "请求失败",e);
            return errorResult(e);
        }
    }
@ -231,7 +231,7 @@ public class PatientHealthController extends BaseController {
            }
            return write(200, "查询成功", "data", list);
        } catch (Exception e) {
            return error( -1, "请求失败",e);
            return errorResult(e);
        }
    }
@ -250,7 +250,7 @@ public class PatientHealthController extends BaseController {
                return error(-1, "查询失败");
            }
        } catch (Exception e) {
            return error( -1, "请求失败",e);
            return errorResult(e);
        }
    }
@ -290,7 +290,7 @@ public class PatientHealthController extends BaseController {
            }
            return write(200, "查询成功", "data", map);
        } catch (Exception ex) {
            return error( -1, "请求失败",ex);
            return errorResult(ex);
        }
    }
@ -322,7 +322,7 @@ public class PatientHealthController extends BaseController {
            return success("新增患者指标成功!");
        } catch (Exception ex) {
            return error( -1, "请求失败",ex);
            return errorResult(ex);
        }
    }
@ -339,7 +339,7 @@ public class PatientHealthController extends BaseController {
            return success("校验患者指标成功!");
        } catch (Exception ex) {
            return error( -1, "请求失败",ex);
            return errorResult(ex);
        }
    }
@ -363,7 +363,7 @@ public class PatientHealthController extends BaseController {
            }
            return write(200, "查询成功", "list", jsonArray);
        } catch (Exception ex) {
            return error( -1, "请求失败",ex);
            return errorResult(ex);
        }
    }
@ -389,7 +389,7 @@ public class PatientHealthController extends BaseController {
            }
            return write(200, "查询成功", "list", jsonArray);
        } catch (Exception ex) {
            return error( -1, "请求失败",ex);
            return errorResult(ex);
        }
    }
@ -419,7 +419,7 @@ public class PatientHealthController extends BaseController {
            }
            return write(200, "查询成功", "list", jsonObject);
        } catch (Exception ex) {
            return error( -1, "请求失败",ex);
            return errorResult(ex);
        }
    }
@ -447,7 +447,7 @@ public class PatientHealthController extends BaseController {
            json.put("custom", userArray);
            return write(200, "查询成功", "data", json);
        } catch (Exception e) {
            return error( -1, "请求失败",e);
            return errorResult(e);
        }
    }

+ 12 - 12
svr/svr-cloud-care/src/main/java/com/yihu/jw/care/endpoint/device/YsDeviceController.java

@ -51,7 +51,7 @@ public class YsDeviceController extends BaseController {
            }
            return write(200,"查询成功","data",result.getJSONObject(ResponseContant.resultMsg));
        } catch (Exception e) {
            return error(-1,"error",e);
            return errorResult(e);
        }
    }
@ -66,7 +66,7 @@ public class YsDeviceController extends BaseController {
        try {
            return write(200,"查询成功","data",ysDeviceService.deviceFailConfig(deviceSerial,type,request));
        }catch (Exception e){
            return error(-1,"error",e);
            return errorResult(e);
        }
    }
@ -88,7 +88,7 @@ public class YsDeviceController extends BaseController {
            return write(200,"查询成功","data",ysDeviceService.deviceEncrypt(deviceSerial,isEncrypt,validateCode,request));
        }catch (Exception e){
            return error(-1,"error",e);
            return errorResult(e);
        }
    }
@ -104,7 +104,7 @@ public class YsDeviceController extends BaseController {
            return write(200,"查询成功","data",ysDeviceService.deviceCapture(deviceSerial,channelNo,request));
        }catch (Exception e){
            return error(-1,"error",e);
            return errorResult(e);
        }
    }
@ -127,7 +127,7 @@ public class YsDeviceController extends BaseController {
            }
            return write(200,"查询成功","data",result.getJSONObject(ResponseContant.resultMsg));
        }catch (Exception e){
            return error(-1,"error",e);
            return errorResult(e);
        }
    }
@ -149,7 +149,7 @@ public class YsDeviceController extends BaseController {
            return write(200,"查询成功","data",ysDeviceService.ptzStart(deviceSerial,channelNo,direction,speed,request));
        }catch (Exception e){
            return error(-1,"error",e);
            return errorResult(e);
        }
    }
@ -167,7 +167,7 @@ public class YsDeviceController extends BaseController {
            return write(200,"查询成功","data",ysDeviceService.ptzStop(deviceSerial,channelNo,direction,request));
        }catch (Exception e){
            return error(-1,"error",e);
            return errorResult(e);
        }
    }
@ -182,7 +182,7 @@ public class YsDeviceController extends BaseController {
            return write(200,"查询成功","data",ysDeviceService.coverVideoSwitch(is_vod_cover,request));
        }catch (Exception e){
            return error(-1,"error",e);
            return errorResult(e);
        }
    }
@ -212,7 +212,7 @@ public class YsDeviceController extends BaseController {
            }
            return write(200,"查询成功","data",result.getJSONArray(ResponseContant.resultMsg));
        }catch (Exception e){
            return error(-1,"error",e);
            return errorResult(e);
        }
    }
@ -242,7 +242,7 @@ public class YsDeviceController extends BaseController {
            return write(200,"查询成功","data",result.getJSONObject(ResponseContant.resultMsg));
        }catch (Exception e){
            return error(-1,"error",e);
            return errorResult(e);
        }
    }
@ -367,7 +367,7 @@ public class YsDeviceController extends BaseController {
            }
            return write(200,"查询成功","data",result.getJSONObject(ResponseContant.resultMsg));
        }catch (Exception e){
            return error(-1,"error",e);
            return errorResult(e);
        }
    }
@ -394,7 +394,7 @@ public class YsDeviceController extends BaseController {
            }
            return write(200,"查询成功","data",result.getJSONObject(ResponseContant.resultMsg));
        }catch (Exception e){
            return error(-1,"error",e);
            return errorResult(e);
        }
    }

+ 25 - 25
svr/svr-cloud-care/src/main/java/com/yihu/jw/care/endpoint/doorCoach/DoctorDoorCoachOrderController.java

@ -58,7 +58,7 @@ public class DoctorDoorCoachOrderController extends EnvelopRestEndpoint {
            }
            return baseController.write(200, "提交成功!","orderId",result.getString("orderId"));
        }catch (Exception e){
            return baseController.error(-1, e.getMessage(),e);
            return baseController.errorResult(e);
        }
    }
@ -70,7 +70,7 @@ public class DoctorDoorCoachOrderController extends EnvelopRestEndpoint {
        try {
            return  baseController.write(200, "获取成功", "data",doctorDoorCoachOrderService.getDoorOrderNum(doctor));
        } catch (Exception e) {
            return baseController.error(-1, "获取失败!" + e.getMessage(),e);
            return baseController.errorResult(e);
        }
    }
@ -95,7 +95,7 @@ public class DoctorDoorCoachOrderController extends EnvelopRestEndpoint {
            object.put("pageSize",size);
            return baseController.write(200,"查询成功","data",object);
        }catch (Exception e){
            return baseController.error(-1,"查询失败",e);
            return baseController.errorResult(e);
        }
    }
@ -117,7 +117,7 @@ public class DoctorDoorCoachOrderController extends EnvelopRestEndpoint {
            }
            return baseController.write(200,"派单成功","data",result.get(ResponseContant.resultMsg));
        }catch (Exception e){
            return baseController.error(-1,"查询失败",e);
            return baseController.errorResult(e);
        }
    }
@ -138,7 +138,7 @@ public class DoctorDoorCoachOrderController extends EnvelopRestEndpoint {
            }
            return baseController.write(200,"派单成功","data",result.get(ResponseContant.resultMsg));
        }catch (Exception e){
            return baseController.error(-1, "派单失败!",e);
            return baseController.errorResult(e);
        }
    }
@ -153,7 +153,7 @@ public class DoctorDoorCoachOrderController extends EnvelopRestEndpoint {
            doctorDoorCoachOrderService.acceptOrder(orderId,jobCode,jobCodeName,hospitalLevel);
            return baseController.write(200, "操作成功");
        } catch (Exception e) {
            return baseController.error(-1, "操作失败!" + e.getMessage(),e);
            return baseController.errorResult(e);
        }
    }
@ -168,7 +168,7 @@ public class DoctorDoorCoachOrderController extends EnvelopRestEndpoint {
            doctorDoorCoachOrderService.refuseOrder(getUID(),orderId, reason);
            return baseController.write(200, "操作成功");
        } catch (Exception e) {
            return baseController.error(-1, "操作失败!" + e.getMessage(),e);
            return baseController.errorResult(e);
        }
    }
@ -187,7 +187,7 @@ public class DoctorDoorCoachOrderController extends EnvelopRestEndpoint {
            }
            return baseController.write(200,"取消成功","data",result.get(ResponseContant.resultMsg));
        }catch (Exception e){
            return baseController.error(-1,"取消失败",e);
            return baseController.errorResult(e);
        }
    }
@ -215,7 +215,7 @@ public class DoctorDoorCoachOrderController extends EnvelopRestEndpoint {
                return baseController.error(-1,"扫码签到失败");
            }
        } catch (Exception e) {
            return baseController.error(-1, "操作失败!" + e.getMessage(),e);
            return baseController.errorResult(e);
        }
    }
@ -234,7 +234,7 @@ public class DoctorDoorCoachOrderController extends EnvelopRestEndpoint {
            BaseDoorCoachConclusionDO doorConclusion = doctorDoorCoachOrderService.updateDoorConclusion(orderId,conclusion,conclusionImg,conclusionStatus);
            return baseController.write(200, "保存成功", "data", doorConclusion);
        } catch (Exception e) {
            return baseController.error(-1, "保存失败!" + e.getMessage(),e);
            return baseController.errorResult(e);
        }
    }
@ -258,7 +258,7 @@ public class DoctorDoorCoachOrderController extends EnvelopRestEndpoint {
            BaseDoorCoachConclusionDO doorConclusion = doctorDoorCoachOrderService.getDoorConclusion(orderId);
            return baseController.write(200, "获取成功", "data", doorConclusion);
        } catch (Exception e) {
            return baseController.error(-1, "获取失败!" + e.getMessage(),e);
            return baseController.errorResult(e);
        }
    }
@ -274,7 +274,7 @@ public class DoctorDoorCoachOrderController extends EnvelopRestEndpoint {
        try {
            return baseController.write(200, "获取成功", "data", doctorDoorCoachOrderService.saveOrderFinishByDoctor(orderId, finishWay, finishImg));
        } catch (Exception e) {
            return baseController.error(-1, "获取失败!" + e.getMessage(),e);
            return baseController.errorResult(e);
        }
    }
@ -289,7 +289,7 @@ public class DoctorDoorCoachOrderController extends EnvelopRestEndpoint {
            BaseDoorCoachOrderDO baseDoorCoachOrderDO = doctorDoorCoachOrderService.updateArrivingTime(orderId, arrivingTime);
            return baseController.write(200, "修改成功", "data", baseDoorCoachOrderDO);
        } catch (Exception e) {
            return baseController.error(-1, "修改失败!" + e.getMessage(),e);
            return baseController.errorResult(e);
        }
    }
@ -302,7 +302,7 @@ public class DoctorDoorCoachOrderController extends EnvelopRestEndpoint {
            Map<String, Integer> map = doctorDoorCoachOrderService.getNumGroupByStatus(doctor);
            return baseController.write(200, "获取成功", "data", map);
        } catch (Exception e) {
            return baseController.error(-1, "获取失败!" + e.getMessage(),e);
            return baseController.errorResult(e);
        }
    }
@ -337,7 +337,7 @@ public class DoctorDoorCoachOrderController extends EnvelopRestEndpoint {
            org.json.JSONObject waitingMessages = doctorDoorCoachOrderService.getWaitingMessages(message1, types, Integer.valueOf(page), Integer.valueOf(pageSize));
            return baseController.write(200, "查询成功","data",waitingMessages);
        }catch (Exception e){
            return baseController.error( -1, "查询失败!",e);
            return baseController.errorResult(e);
        }
    }
@ -411,7 +411,7 @@ public class DoctorDoorCoachOrderController extends EnvelopRestEndpoint {
                    ss,createTimeStart,createTimeEnd,serverDoctorName,doctorCode,page,pageSize, type);
            return baseController.write(200, "获取成功","data",result);
        } catch (Exception e) {
            return baseController.error(-1, "获取失败!" + e.getMessage(),e);
            return baseController.errorResult(e);
        }
    }
@ -440,7 +440,7 @@ public class DoctorDoorCoachOrderController extends EnvelopRestEndpoint {
            object.put("pageSize",size);
            return baseController.write(200,"查询成功","data",object);
        }catch (Exception e){
            return baseController.error(-1,"查询失败",e);
            return baseController.errorResult(e);
        }
    }
@ -473,7 +473,7 @@ public class DoctorDoorCoachOrderController extends EnvelopRestEndpoint {
            object.put("pageSize",size);
            return baseController.write(200,"查询成功","data",object);
        }catch (Exception e){
            return baseController.error(-1,"查询失败",e);
            return baseController.errorResult(e);
        }
    }
@ -498,7 +498,7 @@ public class DoctorDoorCoachOrderController extends EnvelopRestEndpoint {
            BaseDoorCoachOrderDO baseDoorCoachOrderDO = doctorDoorCoachOrderService.getDoorServiceOrderById(orderId);
            return baseController.write(200, "获取成功", "data", baseDoorCoachOrderDO);
        } catch (Exception e) {
            return baseController.error(-1, "获取失败, 该医生暂无工单!" + e.getMessage(),e);
            return baseController.errorResult(e);
        }
    }
@ -532,7 +532,7 @@ public class DoctorDoorCoachOrderController extends EnvelopRestEndpoint {
            return baseController.write(200, "获取成功","dara",patientDoorCoachOrderService.selectItemsByHospital(hospital,serverItemName));
        } catch (Exception e) {
            return baseController.error(-1, "获取失败!" + e.getMessage(),e);
            return baseController.errorResult(e);
        }
    }
@ -543,7 +543,7 @@ public class DoctorDoorCoachOrderController extends EnvelopRestEndpoint {
            doctorDoorCoachOrderService.initDoorStatus(null);
            return baseController.success("成功");
        } catch (Exception e) {
            return baseController.error(-1, "获取失败!" + e.getMessage(),e);
            return baseController.errorResult(e);
        }
    }
@ -557,7 +557,7 @@ public class DoctorDoorCoachOrderController extends EnvelopRestEndpoint {
            String status = doctorDoorCoachOrderService.findDispatchStatusByDoctor(doctor);
            return baseController.write(200, "获取成功", "data", status);
        } catch (Exception e) {
            return baseController.error(-1, "获取失败!" + e.getMessage(),e);
            return baseController.errorResult(e);
        }
    }
@ -573,7 +573,7 @@ public class DoctorDoorCoachOrderController extends EnvelopRestEndpoint {
            doctorDoorCoachOrderService.updateDispatchStatusByDoctor(doctor, value);
            return baseController.write(200, "修改成功");
        } catch (Exception e) {
            return baseController.error(-1, "修改失败!" + e.getMessage(),e);
            return baseController.errorResult(e);
        }
    }
@ -606,7 +606,7 @@ public class DoctorDoorCoachOrderController extends EnvelopRestEndpoint {
        }catch (Exception e){
            //日志文件中记录异常信息
            //返回接口异常信息处理结果
            return baseController.error(-1, "操作失败!",e);
            return baseController.errorResult(e);
        }
    }
@ -648,7 +648,7 @@ public class DoctorDoorCoachOrderController extends EnvelopRestEndpoint {
            }
            return baseController.write(200,"保存成功","data",result.get(ResponseContant.resultMsg));
        }catch (Exception e){
            return baseController.error(-1,"保存失败",e);
            return baseController.errorResult(e);
        }
    }

+ 312 - 0
svr/svr-cloud-care/src/main/java/com/yihu/jw/care/endpoint/patient/PayEndpoint.java

@ -0,0 +1,312 @@
package com.yihu.jw.care.endpoint.patient;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.yihu.jw.care.exception.BusinessException;
import com.yihu.jw.care.service.doorCoach.PatientDoorCoachOrderService;
import com.yihu.jw.care.service.pay.PayService;
import com.yihu.jw.care.util.XMLUtil;
import com.yihu.jw.entity.order.BusinessOrderDO;
import com.yihu.jw.entity.order.BusinessOrderRefundDO;
import com.yihu.jw.order.dao.BusinessOrderDao;
import com.yihu.jw.order.dao.BusinessOrderRefundDao;
import com.yihu.jw.restmodel.ResponseContant;
import com.yihu.jw.restmodel.web.Envelop;
import com.yihu.jw.restmodel.web.ObjEnvelop;
import com.yihu.jw.restmodel.web.PageEnvelop;
import com.yihu.jw.restmodel.web.endpoint.EnvelopRestEndpoint;
import com.yihu.jw.utils.StringUtil;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import javax.servlet.http.HttpServletRequest;
import java.math.BigDecimal;
import java.util.List;
import java.util.Map;
/**
 * Created with IntelliJ IDEA.
 *
 * @Author: yeshijie
 * @Date: 2021/6/28
 * @Description:
 */
@RestController
@RequestMapping("pay" )
@Api(tags = "支付信息", description = "支付信息")
public class PayEndpoint extends EnvelopRestEndpoint {
    private Logger log = LoggerFactory.getLogger(PatientDoorCoachOrderService.class);
    @Autowired
    private PayService payService;
    @Autowired
    private BusinessOrderDao businessOrderDao;
    @Autowired
    private BusinessOrderRefundDao orderRefundDao;
    @GetMapping("topStatusBarNum")
    @ApiOperation(value = "顶部状态栏订单分类tab")
    public ObjEnvelop topStatusBarNum(
            @ApiParam(name = "patient", value = "居民code")
            @RequestParam(value = "patient", required = true) String patient) {
        try {
            Map<String, Integer> map = payService.topStatusBarNum(patient);
            return ObjEnvelop.getSuccess("获取成功",map);
        } catch (Exception e) {
            return failedObjEnvelopException2(e);
        }
    }
    @GetMapping(value = "orderList")
    @ApiOperation(value = "我的订单列表")
    public PageEnvelop orderList(
            @ApiParam(name = "patient", value = "patient") @RequestParam(value = "patient", required = true) String patient,
            @ApiParam(name = "status", value = "工单状态") @RequestParam(value = "status", required = false) String status,
            @ApiParam(name = "page", value = "分页大小", required = true, defaultValue = "1") @RequestParam(value = "page") int page,
            @ApiParam(name = "size", value = "页码", required = true, defaultValue = "15") @RequestParam(value = "size") int size) {
        try{
            JSONObject result = payService.orderList(patient, status, page, size);
            if (result.getIntValue(ResponseContant.resultFlag) == ResponseContant.fail) {
                return PageEnvelop.getError(result.getString(ResponseContant.resultMsg));
            }
            Long count = result.getLongValue(ResponseContant.count);
            return PageEnvelop.getSuccessListWithPage("查询成功",(List<Map<String,Object>>)result.get(ResponseContant.resultMsg),page,size,count);
        }catch (Exception e){
            return failedPageEnvelopException2(e);
        }
    }
    @GetMapping("orderInfo")
    @ApiOperation(value = "订单详情")
    public ObjEnvelop orderInfo(@ApiParam(name = "id", value = "订单id") @RequestParam(value = "id", required = true) Integer id) {
        try {
            JSONObject json = payService.orderInfo(id);
            return ObjEnvelop.getSuccess("获取成功",json);
        } catch (Exception e) {
            return failedObjEnvelopException2(e);
        }
    }
    @PostMapping(value = "cancleOrder")
    @ApiOperation(value = "取消订单")
    public Envelop cancleOrder(
            @ApiParam(name = "id", value = "订单id")
            @RequestParam(value = "id", required = true) Integer id) {
        try{
            String res = payService.cancleOrder(id);
            if(StringUtil.isBlank(res)){
                return success("取消成功");
            }
            return Envelop.getError(res,-1);
        }catch (Exception e){
            return failedException2(e);
        }
    }
    @GetMapping(value = "existWaitForPay")
    @ApiOperation(value = "查询患者是否存在未支付订单")
    public ObjEnvelop existWaitForPay(
            @ApiParam(name = "patient", value = "patient", required = true)
            @RequestParam(value = "patient") String patient,
            @ApiParam(name ="orderCategory",value = "订单分类 1招生,2 课程,3 上门辅导托幼) 4 生活照料")
            @RequestParam(value = "orderCategory")String orderCategory) {
        try{
            JSONObject result =  result = payService.existWaitForPay(patient,orderCategory);
            return ObjEnvelop.getSuccess("查询成功",result);
        }catch (Exception e){
            return failedObjEnvelopException2(e);
        }
    }
    @GetMapping(value = "getPayInfo")
    @ApiOperation(value = "通过工单id获取支付信息")
    public ObjEnvelop getPayInfo(
            @ApiParam(name = "orderId", value = "工单id", required = true)
            @RequestParam String orderId,
            @ApiParam(name ="orderCategory",value = "3 上门辅导托幼 4 生活照料")
            @RequestParam(value = "orderCategory")String orderCategory) {
        try {
            JSONObject result = payService.getPayInfo(orderId,orderCategory);
            if (result.getIntValue(ResponseContant.resultFlag) == ResponseContant.fail) {
                return ObjEnvelop.getError(result.getString(ResponseContant.resultMsg));
            }
            return ObjEnvelop.getSuccess("查询成功",result.getJSONObject(ResponseContant.resultMsg));
        }catch (Exception e){
            return failedObjEnvelopException2(e);
        }
    }
    @PostMapping(value = "wxWapPay")
    @ApiOperation(value = "微信wap支付")
    public ObjEnvelop wxWapPay(
            @ApiParam(name = "relationId", value = "业务id,如生活照料id 上面辅导id")
            @RequestParam(value = "relationId", required = false) String relationId,
            @ApiParam(name = "orderId", value = "订单id")
            @RequestParam(value = "orderId", required = false) Integer orderId,HttpServletRequest request) {
        try{
            return payService.wxWapPay(relationId, orderId, request);
        }catch (Exception e){
            return failedObjEnvelopException2(e);
        }
    }
    @PostMapping(value = "applyRefund")
    @ApiOperation(value = "申请退款")
    public Envelop applyRefund(
            @ApiParam(name = "description", value = "退款说明")
            @RequestParam(value = "description", required = true) String description,
            @ApiParam(name = "enclosure", value = "退款附件")
            @RequestParam(value = "enclosure", required = false) String enclosure,
            @ApiParam(name = "id", value = "订单id")
            @RequestParam(value = "id", required = true) Integer id) {
        try{
            String res = payService.applyRefund(id, description, enclosure);
            if(StringUtil.isBlank(res)){
                return success("申请退款成功");
            }
            return Envelop.getError(res,-1);
        }catch (Exception e){
            return failedObjEnvelopException2(e);
        }
    }
    @PostMapping(value = "wxNativePay")
    @ApiOperation(value = "微信native支付")
    public ObjEnvelop wxNativePay(
            @ApiParam(name = "relationId", value = "业务id,如生活照料id 上门辅导id")
            @RequestParam(value = "relationId", required = false) String relationId,
            @ApiParam(name = "orderId", value = "订单id")
            @RequestParam(value = "orderId", required = false) Integer orderId,HttpServletRequest request) {
        try{
            return  payService.wxNativePay(relationId, orderId, request);
        }catch (Exception e){
            return failedObjEnvelopException2(e);
        }
    }
    /**
     * 微信支付回调
     *
     * @param request
     * @return java.lang.String
     */
    @ResponseBody
    @PostMapping("open/wxPayNotify")
    @ApiOperation(value = "微信wap支付回调")
    public String payNotify(HttpServletRequest request) {
        log.info("【微信支付】回调通知");
        try {
            // 解析xml成map
            Map<String, String> params = XMLUtil.doXMLParse(request);
            String paramsJson = JSON.toJSONString(params);
            log.error("【微信支付】异步通知回调,{}", paramsJson);
            // 支付校验
            String returnCode = params.get("return_code");
            if (!"SUCCESS".equalsIgnoreCase(returnCode)) {
                log.info("【微信支付】订单支付失败");
                return XMLUtil.setXML("FAIL", "支付失败");
            }
            // 商户需要验证该通知数据中的out_trade_no是否为商户系统中创建的订单号
            String outTradeNo = params.get("out_trade_no");
            String payWaterId = outTradeNo.split("_")[0];
            payService.addHttpLog("2",payWaterId,paramsJson,null);
            BusinessOrderDO orderDO = businessOrderDao.selectByOrderNo(payWaterId);
            if (orderDO == null) {
                log.error("支付流水不存在");
                return XMLUtil.setXML("SUCCESS", "OK");
            }
            String wxSeqNo = params.get("transaction_id");
            orderDO.setTraceNo(wxSeqNo);
//            orderDO.setResponseParam(paramsJson);
            // 判断total_amount是否确实为该订单的实际金额(即商户订单创建时的金额),
            String totalFee = params.get("total_fee");
            BigDecimal payTotalFee = new BigDecimal(totalFee).setScale(2).divide(new BigDecimal(100), BigDecimal.ROUND_HALF_EVEN);
            log.info("【微信支付】支付金额:{}", payTotalFee);
            if (new BigDecimal(orderDO.getPayPrice()).compareTo(payTotalFee) != 0) {
                //通知资金与实际资金不对称,可能是攻击行为!
                orderDO.setRematk("通知资金与实际资金不对称,可能是攻击行为!");
                businessOrderDao.save(orderDO);
                return XMLUtil.setXML("SUCCESS", "OK");
            }
            // 多线程执行操作
            /*********** 业务处理 start ************/
            payService.payNotify(orderDO);
            /*********** 业务处理 end ************/
            return XMLUtil.setXML("SUCCESS", "OK");
        } catch (BusinessException e) {
            log.info("【微信支付】回调失败:{}", e.getMessage());
            return XMLUtil.setXML("FAIL", "支付失败");
        } catch (Exception e) {
            log.info("【微信支付】回调异常:{}", e);
            return XMLUtil.setXML("FAIL", "支付失败");
        }
    }
    /**
     * 微信支付退款回调
     *
     * @param request
     * @return java.lang.String
     */
    @ResponseBody
    @PostMapping("open/wxRefundNotify")
    @ApiOperation(value = "微信支付退款回调")
    public String wxRefundNotify(HttpServletRequest request) {
        log.info("【微信支付退款】回调通知");
        try {
            // 解析xml成map
            Map<String, String> params = XMLUtil.doXMLParse(request);
            String paramsJson = JSON.toJSONString(params);
            log.error("【微信支付退款】异步通知回调,{}", paramsJson);
            // 支付校验
            String returnCode = params.get("return_code");
            if (!"SUCCESS".equalsIgnoreCase(returnCode)) {
                log.info("【微信支付退款】订单失败");
                return XMLUtil.setXML("FAIL", "退款失败");
            }
            // 商户需要验证该通知数据中的out_trade_no是否为商户系统中创建的订单号
            String outTradeNo = params.get("out_trade_no");
            String payWaterId = outTradeNo.split("_")[0];
            payService.addHttpLog("2",payWaterId,paramsJson,null);
            BusinessOrderRefundDO orderDO = orderRefundDao.selectByOrderNo(payWaterId);
            if (orderDO == null) {
                log.error("退款订单不存在");
                return XMLUtil.setXML("SUCCESS", "OK");
            }
            orderDO.setOutRefundNo(params.get("refund_id"));
//            orderDO.setResponseParam(paramsJson);
            // 判断total_amount是否确实为该订单的实际金额(即商户订单创建时的金额),
            String totalFee = params.get("refund_fee");
            BigDecimal payTotalFee = new BigDecimal(totalFee).setScale(2).divide(new BigDecimal(100), BigDecimal.ROUND_HALF_EVEN);
            log.info("【微信支付退款】支付金额:{}", payTotalFee);
            if (new BigDecimal(orderDO.getRefundPrice()).compareTo(payTotalFee) != 0) {
                //通知资金与实际资金不对称,可能是攻击行为!
                log.info("通知资金与实际资金不对称,可能是攻击行为!");
                return XMLUtil.setXML("SUCCESS", "OK");
            }
            // 多线程执行操作
            /*********** 业务处理 start ************/
            payService.refundNotify(orderDO);
            /*********** 业务处理 end ************/
            return XMLUtil.setXML("SUCCESS", "OK");
        } catch (BusinessException e) {
            log.info("【微信支付退款】回调失败:{}", e.getMessage());
            return XMLUtil.setXML("FAIL", "退款失败");
        } catch (Exception e) {
            log.info("【微信支付退款】回调异常:{}", e);
            return XMLUtil.setXML("FAIL", "退款失败");
        }
    }
}

+ 2 - 2
svr/svr-cloud-care/src/main/java/com/yihu/jw/care/endpoint/dict/PrivateDictEndpoint.java

@ -1,4 +1,4 @@
package com.yihu.jw.care.endpoint.dict;
package com.yihu.jw.care.endpoint.third;
import com.yihu.jw.dict.service.PrivateDictService;
import com.yihu.jw.restmodel.web.Envelop;
@ -17,7 +17,7 @@ import org.springframework.web.bind.annotation.*;
 * @Date: 2021/6/23 14:40
 */
@RestController
@RequestMapping("/endpointEy" )
@RequestMapping("/cloudCare/noLogin/endpointEy" )
@Api(tags = "关于我们-隐私策略管理", description = "关于我们-隐私策略管理")
public class PrivateDictEndpoint extends EnvelopRestEndpoint {
    @Autowired

+ 5 - 5
svr/svr-cloud-care/src/main/java/com/yihu/jw/care/endpoint/third/device/PDeviceController.java

@ -50,7 +50,7 @@ public class PDeviceController extends BaseController {
        try {
            return write(200,"执行成功","data",patientDeviceService.getPatientDeviceTaskInfo(patientCode));
        }catch (Exception e){
            return error(-1,"执行失败!",e);
            return errorResult(e);
        }
    }
@ -61,7 +61,7 @@ public class PDeviceController extends BaseController {
        try {
            return write(200,"获取成功","data",patientDeviceService.getAqgDeviceInfo(deviceSn));
        }catch (Exception e){
            return error(-1,"执行失败!",e);
            return errorResult(e);
        }
    }
@ -86,7 +86,7 @@ public class PDeviceController extends BaseController {
            }
            return error(-1,json.getString("error_desc"));
        }catch (Exception e){
            return error(-1,"执行失败!",e);
            return errorResult(e);
        }
    }
@ -99,7 +99,7 @@ public class PDeviceController extends BaseController {
        try {
            return write(200,"获取成功","data",patientDeviceService.getDeviceLastLocation(deviceSn,type));
        }catch (Exception e){
            return error(-1,"执行失败!",e);
            return errorResult(e);
        }
    }
@ -127,7 +127,7 @@ public class PDeviceController extends BaseController {
        try {
            return write(200,"获取成功","data",patientDeviceService.updateDeviceFenceArea(deviceSn, fenceNO, enable, name, freq, time_begin, time_end, safe_area, clear));
        }catch (Exception e){
            return error(-1,"执行失败!",e);
            return errorResult(e);
        }
    }
}

+ 1 - 1
svr/svr-cloud-care/src/main/java/com/yihu/jw/care/endpoint/third/platForm/PatientInfoPlatFormEndpoint.java

@ -161,7 +161,7 @@ public class PatientInfoPlatFormEndpoint extends EnvelopRestEndpoint {
        try {
            return baseController.write (200,"查询成功","data",patientInfoPlatFormService.getHealthIndexInfo(patient,type,gi_type,begin,end));
        }catch (Exception e){
            return baseController.error(-1,"查询失败",e);
            return baseController.errorResult(e);
        }
    }

+ 12 - 3
svr/svr-cloud-care/src/main/java/com/yihu/jw/care/service/device/YsDeviceService.java

@ -8,6 +8,7 @@ import com.yihu.jw.care.dao.device.PatientDeviceDao;
import com.yihu.jw.care.dao.label.WlyyPatientLabelDao;
import com.yihu.jw.entity.care.device.DevicePatientDevice;
import com.yihu.jw.restmodel.ResponseContant;
import com.yihu.jw.rm.iot.IotRequestMapping;
import com.yihu.jw.util.date.DateUtil;
import com.yihu.jw.util.http.HttpClientUtil;
import com.yihu.jw.utils.encode.Base64;
@ -64,7 +65,11 @@ public class YsDeviceService {
        if (responseBody.getInteger("code")==200){
            assToken = responseBody.getJSONObject("data").getString("accessToken");
            Long expireTime = responseBody.getJSONObject("data").getLong("expiresIn");//token有效期
            redisTemplate.opsForValue().set(YsConfig.redisKey,assToken,expireTime, TimeUnit.MILLISECONDS);
            redisTemplate.opsForValue().set(YsConfig.redisKey,assToken,expireTime, TimeUnit.SECONDS);
//            Long ss= redisTemplate.getExpire(YsConfig.redisKey);
//            System.out.println(expireTime+"---"+ss);
        }else {
            throw new Exception("获取token失败");
        }
@ -88,12 +93,16 @@ public class YsDeviceService {
        String assToken = null;
        if (responseBody.getInteger("code")==200){
            assToken = responseBody.getJSONObject("data").getString("ezOpenAccessToken");
            Long expireTime = responseBody.getJSONObject("data").getLong("expireTime");//token有效期
            Long expireTime = responseBody.getJSONObject("data").getLong("expireTime");//token有效截止日期
            Long nowTime = System.currentTimeMillis();
            expireTime = expireTime-nowTime;
            redisTemplate.opsForValue().set(YsConfig.iotRedisKey,assToken,expireTime, TimeUnit.MILLISECONDS);
            //设备解密密钥
            String secretKey = responseBody.getJSONObject("data").getString("secretKey");
            redisTemplate.opsForValue().set(YsConfig.secretKey,secretKey,expireTime, TimeUnit.MILLISECONDS);
//            Long ss= redisTemplate.getExpire(YsConfig.iotRedisKey);
//            System.out.println(expireTime+"---"+ss);
        }else {
            throw new Exception("获取token失败");
        }

+ 2 - 18
svr/svr-cloud-care/src/main/java/com/yihu/jw/care/service/doorCoach/DoctorDoorCoachOrderService.java

@ -4,7 +4,6 @@ import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.yihu.jw.care.dao.doorCoach.*;
import com.yihu.jw.care.dao.course.DoctorPatientTmpDao;
import com.yihu.jw.care.service.consult.ConsultTeamService;
import com.yihu.jw.care.util.EntranceUtil;
import com.yihu.jw.care.util.MessageUtil;
@ -18,7 +17,6 @@ import com.yihu.jw.entity.base.org.BaseOrgDO;
import com.yihu.jw.entity.base.patient.BasePatientDO;
import com.yihu.jw.entity.base.wx.BasePatientWechatDo;
import com.yihu.jw.entity.care.doorCoach.*;
import com.yihu.jw.entity.care.course.DoctorPatientTmpDO;
import com.yihu.jw.entity.hospital.message.SystemMessageDO;
import com.yihu.jw.hospital.message.dao.SystemMessageDao;
import com.yihu.jw.hospital.prescription.dao.PrescriptionDao;
@ -786,20 +784,6 @@ public class DoctorDoorCoachOrderService {
        String applicationSql = "";
        String patientTypeTemp = "";
//        if("1".equals(isApplication)){
//            applicationSql +=                 " JOIN ( " +
//                    "         select a.patient, group_concat(v.type) as type " +
//                    "         from wlyy_door_service_voucher v " +
//                    "                  JOIN (select t.id, t.patient, max(t.create_time) " +
//                    "                        from wlyy_door_service_application t " +
//                    "                        where t.status in (2, 3) " +
//                    "                        group by t.patient) as a " +
//                    "                       on a.id = v.service_id " +
//                    "         where v.status = 1 " +
//                    "         group by a.patient " +
//                    "        ) as t1 on o.patient = t1.patient" ;
//            patientTypeTemp = " ,t1.`type` as patientType ";
//        }
        String sql = "SELECT " +
                "  p.name AS patientName, " +
@ -827,7 +811,7 @@ public class DoctorDoorCoachOrderService {
                " LEFT JOIN base_patient p ON o.patient = p.id ) LEFT JOIN wlyy_consult c on o.id = c.relation_code"+
                applicationSql+" WHERE " +
                "  o.hospital = '{hospital}' and o.type != 3 " +buffer+
                " AND ( o.`status` = {status} OR -100 = {status} ) " +
                " AND ( o.`status` = {status} OR -100 = {status} ) and o.pay_status>0 "+//未付款不展示
                " ORDER BY o.create_time desc " +
                " LIMIT {start},{end};";
@ -845,7 +829,7 @@ public class DoctorDoorCoachOrderService {
                applicationSql +
                " WHERE  " +
                "  o.hospital = '{hospital}' and o.type != 3 " +buffer+
                " AND (o.`status` = {status} or -100 = {status})";
                " AND (o.`status` = {status} or -100 = {status})  and o.pay_status>0  " ;
        String finqlCountSql = countSql.replace("{hospital}", hospital)
                .replace("{status}", String.valueOf(status));

+ 212 - 117
svr/svr-cloud-care/src/main/java/com/yihu/jw/care/service/doorCoach/PatientDoorCoachOrderService.java

@ -5,6 +5,7 @@ import com.alibaba.fastjson.JSONObject;
import com.yihu.jw.care.dao.doorCoach.*;
import com.yihu.jw.care.service.consult.ConsultTeamService;
import com.yihu.jw.care.service.message.BaseServiceNewsService;
import com.yihu.jw.care.service.pay.PayService;
import com.yihu.jw.care.util.MessageUtil;
import com.yihu.jw.doctor.dao.BaseDoctorDao;
import com.yihu.jw.entity.base.doctor.BaseDoctorDO;
@ -13,10 +14,14 @@ import com.yihu.jw.entity.base.im.ConsultTeamDo;
import com.yihu.jw.entity.base.patient.BasePatientDO;
import com.yihu.jw.entity.base.wx.BasePatientWechatDo;
import com.yihu.jw.entity.care.doorCoach.*;
import com.yihu.jw.entity.care.lifeCare.LifeCareFeeDetailDO;
import com.yihu.jw.entity.care.lifeCare.LifeCareOrderDO;
import com.yihu.jw.entity.hospital.message.SystemMessageDO;
import com.yihu.jw.entity.order.BusinessOrderDO;
import com.yihu.jw.hospital.message.dao.SystemMessageDao;
import com.yihu.jw.im.dao.ConsultDao;
import com.yihu.jw.im.util.ImUtil;
import com.yihu.jw.order.dao.BusinessOrderDao;
import com.yihu.jw.patient.dao.BasePatientDao;
import com.yihu.jw.restmodel.ResponseContant;
import com.yihu.jw.util.common.IdCardUtil;
@ -94,6 +99,10 @@ public class PatientDoorCoachOrderService extends BaseJpaService<BaseDoorCoachOr
    private SystemMessageDao systemMessageDao;
    @Autowired
    private BaseServiceNewsService serviceNewsService;
    @Autowired
    private PayService payService;
    @Autowired
    private BusinessOrderDao businessOrderDao;
    /**
     * 创建上门辅导服务工单
@ -126,12 +135,16 @@ public class PatientDoorCoachOrderService extends BaseJpaService<BaseDoorCoachOr
            logger.error(failMsg);
            return result;
        }
        JSONObject dispatcherJson = queryDispatcherInfoByPatient(jsonObjectParam.getJSONObject("hospital").get("code").toString());
        String hospital = jsonObjectParam.getJSONObject("hospital").get("code").toString();
        orderDO.setHospital(hospital);
        orderDO.setNumber(getRandomIntStr());
        orderDO.setCreateTime(new Date());
        orderDO.setCreateUser(orderDO.getProxyPatient());
        orderDO.setCreateUserName(orderDO.getProxyPatientName());
        orderDO.setOrderInfo("0");
        orderDO.setStatus(1);
        orderDO.setStatus(0);//待付款
        orderDO.setPayStatus(0);//待付款
//        orderDO.setConclusionStatus(1);
        if(StringUtils.isEmpty(orderDO.getPatient())){
@ -152,7 +165,9 @@ public class PatientDoorCoachOrderService extends BaseJpaService<BaseDoorCoachOr
        //已取消的订单也可以申请
        boolean bool = baseDoorCoachOrderDao.existsByPatientAndStatusIn(orderDO.getPatient(),
                new Integer[]{BaseDoorCoachOrderDO.Status.waitForSend.getType(),
                new Integer[]{
                        BaseDoorCoachOrderDO.Status.waitForPay.getType(),
                        BaseDoorCoachOrderDO.Status.waitForSend.getType(),
                        BaseDoorCoachOrderDO.Status.waitForAccept.getType(),
                        BaseDoorCoachOrderDO.Status.waitForServe.getType(),
                        BaseDoorCoachOrderDO.Status.accept.getType(),
@ -177,62 +192,25 @@ public class PatientDoorCoachOrderService extends BaseJpaService<BaseDoorCoachOr
        orderDO.setServiceStatus("1");
        this.save(orderDO);
        result.put("orderId",orderDO.getId());
        //创建咨询
        JSONObject successOrNot = null;
        try {
            successOrNot = consultTeamService.addDoorCoachServiceConsult(orderDO.getId());
        } catch (Exception e) {
            e.printStackTrace();
            String failMsg = "创建咨询时异常: " + e.getMessage();
            result.put(ResponseContant.resultFlag, ResponseContant.fail);
            result.put(ResponseContant.resultMsg, failMsg);
            logger.error(failMsg);
            return result;
        }
        if (Integer.parseInt(successOrNot.get(ResponseContant.resultFlag).toString()) == ResponseContant.fail) {
            return JSONObject.parseObject(successOrNot.toString());
        }
        ConsultTeamDo consultTeam = (ConsultTeamDo)successOrNot.get(ResponseContant.resultMsg);
        result.put(ResponseContant.resultFlag, ResponseContant.success);
        result.put(ResponseContant.resultMsg, orderDO);
        orderDO.setTotalFee(new BigDecimal(0));
        //新增工单与服务项费用关联关系
        if (orderWithPackageItemFeeAdd(result, jsonObjectParam, orderDO,null)) {return result;}
        JSONObject dispatcherJson = queryDispatcherInfoByPatient(jsonObjectParam.getJSONObject("hospital").get("code").toString());
        if (dispatcherJson.getInteger("resultFlag")==1){
            List<Map<String,Object>> dispatcherInfoList = (List<Map<String, Object>>) dispatcherJson.get(ResponseContant.resultMsg);
            for(Map<String,Object> map: dispatcherInfoList){
                String dispatcher = map.get("code").toString();
                BaseDoctorDO doctorVO = doctorDao.findById(dispatcher);
                // 派单消息-首页
                this.createMessage("新增居民预约服务申请","702","system","system", orderDO.getId(), dispatcher,doctorVO.getName() ,doctorVO.getIdcard(), orderDO.getPatientName() + "提交了服务预约申请,请您前往处理");
                // 派单-实时工单消息  430 居民提交工单申请-- 张三提交了服务工单12345678申请
                this.createMessage("居民提交工单申请","730","system","system", orderDO.getId(), dispatcher,doctorVO.getName() ,doctorVO.getIdcard(), orderDO.getPatientName() + "提交了服务工单"+orderDO.getNumber()+"申请");
            }
        }
        result.put(ResponseContant.resultFlag, ResponseContant.success);
        result.put(ResponseContant.resultMsg, consultTeam);
        //发送智能助手消息
        sendWeixinMessage(4,orderDO.getDoctor(),orderDO.getPatient());
        //发送 预约卡片信息(2201类型)
        JSONObject orderInfoContent = this.queryOrderCardInfo(orderDO);
        orderInfoContent.put("re_msg_type",0);//居民预约
        this.qucikSendIM(orderDO.getId(), "system", "智能助手", "2201", orderInfoContent.toJSONString());
        if(StringUtils.isNoneBlank(orderDO.getDoctor())){
            //服务医生修改,直接转派
            BaseDoctorDO transDoctor = doctorDao.findById(orderDO.getDoctor());
            sendOrderToDoctor(orderDO.getId(),null,"system","系统",transDoctor.getId(),transDoctor.getName(),transDoctor.getJobTitleName());
        }
        serviceNewsService.addServiceNews(orderDO.getPatientName(),orderDO.getPatient(),"1",null);
        //发起支付订单
        payService.submitOrder(orderDO.getPatient(),"3",orderDO.getId(),orderDO.getTotalFee().doubleValue());
        return result;
    }
    @Transactional
    public JSONObject proxyCreate(String jsonData,String doctorCode) {
        JSONObject result = new JSONObject();
        //医养暂无该功能--屏蔽
        result.put(ResponseContant.resultFlag, ResponseContant.fail);
        result.put(ResponseContant.resultMsg, "暂无该功能");
        return result;
        /*
        JSONObject jsonObjectParam;
        try {
            jsonObjectParam = JSONObject.parseObject(jsonData);
@ -244,8 +222,6 @@ public class PatientDoorCoachOrderService extends BaseJpaService<BaseDoorCoachOr
            return result;
        }
        BaseDoorCoachOrderDO orderDO = null;
        try {
            orderDO = EntityUtils.jsonToEntity(jsonObjectParam.get("order").toString(), BaseDoorCoachOrderDO.class);
@ -276,7 +252,8 @@ public class PatientDoorCoachOrderService extends BaseJpaService<BaseDoorCoachOr
        if(StringUtils.isBlank(orderDO.getId())) {
            //已取消的订单也可以申请
            boolean bool = baseDoorCoachOrderDao.existsByPatientAndStatusIn(orderDO.getPatient(),
                    new Integer[]{BaseDoorCoachOrderDO.Status.waitForAccept.getType(),
                    new Integer[]{BaseDoorCoachOrderDO.Status.waitForPay.getType(),
                            BaseDoorCoachOrderDO.Status.waitForAccept.getType(),
                            BaseDoorCoachOrderDO.Status.waitForServe.getType(),
                            BaseDoorCoachOrderDO.Status.accept.getType(),
                            BaseDoorCoachOrderDO.Status.waitForSend.getType()
@ -311,36 +288,133 @@ public class PatientDoorCoachOrderService extends BaseJpaService<BaseDoorCoachOr
            orderDO.setUpdateUser(orderDO.getProxyPatient());
            orderDO.setUpdateUserName(orderDO.getProxyPatientName());
        }
        orderDO.setStatus(2);
        orderDO.setStatus(0);//待付款
        orderDO.setPayStatus(0);//待付款
        orderDO.setType(3);
        orderDO.setDispatcherResponseTime(new Date());
        this.save(orderDO);
        result.put("orderId",orderDO.getId());
        orderDO.setTotalFee(new BigDecimal(0));
        //新增工单与服务项费用关联关系
        if (orderWithPackageItemFeeAdd(result, jsonObjectParam, orderDO,doctorCode)) {return result;}
        if("1".equals(orderDO.getShortcutType())){
            //快捷的当前医生直接接单
            try{
                String sql = "SELECT d.job_title_code,d.job_title_name,o.org_level from base_doctor d,base_doctor_hospital h,base_org o " +
                        "WHERE d.id = h.doctor_code and h.org_code = o.id";
                sql += " and d.id = '"+orderDO.getDoctor()+"'";
                List<Map<String,Object>> list = jdbcTemplate.queryForList(sql);
        // 给服务医生发接单消息
        this.createMessage("服务工单待接单","707",orderDO.getProxyPatient(),orderDO.getProxyPatientName(), orderDO.getId(),orderDO.getDoctor(),orderDO.getDoctorName(), null,"您有新的服务工单,请前往处理");
        //发送智能助手消息
        sendWeixinMessage(4,orderDO.getDoctor(),orderDO.getPatient());
                doorOrderService.acceptOrder1(orderDO.getId(), list.get(0).get("job_title_code").toString(),
                        list.get(0).get("job_title_name").toString(), Integer.valueOf(list.get(0).get("org_level").toString()));
            }catch (Exception e){
                e.printStackTrace();
            }
        //发起支付订单
        BusinessOrderDO businessOrderDO =  payService.submitOrder(orderDO.getPatient(),"3",orderDO.getId(),orderDO.getTotalFee().doubleValue());
        result.put(ResponseContant.resultFlag, ResponseContant.success);
        return result;
        */
    }
        }else{
            // 给服务医生发接单消息
            this.createMessage("服务工单待接单","707",orderDO.getProxyPatient(),orderDO.getProxyPatientName(), orderDO.getId(),orderDO.getDoctor(),orderDO.getDoctorName(), null,"您有新的服务工单,请前往处理");
            //发送智能助手消息
            sendWeixinMessage(4,orderDO.getDoctor(),orderDO.getPatient());
    //支付完成后开始上门辅导订单
    public JSONObject payOrderAfter(String orderId) {
        JSONObject result = new JSONObject();
        try {
            BusinessOrderDO businessOrderDO = businessOrderDao.selectByRelationCode(orderId);
            if (businessOrderDO==null){
                String failMsg = "未查询到该订单";
                result.put(ResponseContant.resultFlag, ResponseContant.fail);
                result.put(ResponseContant.resultMsg, failMsg);
                return result;
            }
            BaseDoorCoachOrderDO orderDO= baseDoorCoachOrderDao.findOne(orderId);
            if (orderDO!=null){
                orderDO.setPayStatus(1);
                orderDO.setPayWay(1);
                orderDO.setPayTime(new Date());
                if (orderDO.getType()== 3){//医生代预约
                    orderDO.setStatus(2);//待接单
                    this.save(orderDO);
                    // 给服务医生发接单消息
                    this.createMessage("服务工单待接单","707",orderDO.getProxyPatient(),orderDO.getProxyPatientName(), orderDO.getId(),orderDO.getDoctor(),orderDO.getDoctorName(), null,"您有新的服务工单,请前往处理");
                    //发送智能助手消息
                    sendWeixinMessage(4,orderDO.getDoctor(),orderDO.getPatient());
                }else {
                    //创建咨询
                    JSONObject successOrNot = null;
                    try {
                        successOrNot = consultTeamService.addDoorCoachServiceConsult(orderDO.getId());
                    } catch (Exception e) {
                        e.printStackTrace();
                        String failMsg = "创建咨询时异常: " + e.getMessage();
                        result.put(ResponseContant.resultFlag, ResponseContant.fail);
                        result.put(ResponseContant.resultMsg, failMsg);
                        logger.error(failMsg);
                        return result;
                    }
                    if (Integer.parseInt(successOrNot.get(ResponseContant.resultFlag).toString()) == ResponseContant.fail) {
                        return JSONObject.parseObject(successOrNot.toString());
                    }
                    ConsultTeamDo consultTeam = (ConsultTeamDo)successOrNot.get(ResponseContant.resultMsg);
                    //发送智能助手消息
                    sendWeixinMessage(4,orderDO.getDoctor(),orderDO.getPatient());
                    //发送 预约卡片信息(2201类型)
                    JSONObject orderInfoContent = this.queryOrderCardInfo(orderDO);
                    orderInfoContent.put("re_msg_type",0);//居民预约
                    this.qucikSendIM(orderDO.getId(), "system", "智能助手", "2201", orderInfoContent.toJSONString());
                    if(StringUtils.isNoneBlank(orderDO.getDoctor())){
                        //期望服务医生存在,直接转派
                        BaseDoctorDO transDoctor = doctorDao.findById(orderDO.getDoctor());
                        sendOrderToDoctor(orderDO.getId(),null,"system","系统",transDoctor.getId(),transDoctor.getName(),transDoctor.getJobTitleName());
                    }else {
                        orderDO.setStatus(1);//待派单
                        this.save(orderDO);
                        JSONObject dispatcherJson = queryDispatcherInfoByPatient(orderDO.getHospital());
                        if (dispatcherJson.getInteger("resultFlag")==1){
                            List<Map<String,Object>> dispatcherInfoList = (List<Map<String, Object>>) dispatcherJson.get(ResponseContant.resultMsg);
                            for(Map<String,Object> map: dispatcherInfoList){
                                String dispatcher = map.get("code").toString();
                                BaseDoctorDO doctorVO = doctorDao.findById(dispatcher);
                                // 派单消息-首页
                                this.createMessage("新增居民预约服务申请","702","system","system", orderDO.getId(), dispatcher,doctorVO.getName() ,doctorVO.getIdcard(), orderDO.getPatientName() + "提交了服务预约申请,请您前往处理");
                                // 派单-实时工单消息  430 居民提交工单申请-- 张三提交了服务工单12345678申请
                                this.createMessage("居民提交工单申请","730","system","system", orderDO.getId(), dispatcher,doctorVO.getName() ,doctorVO.getIdcard(), orderDO.getPatientName() + "提交了服务工单"+orderDO.getNumber()+"申请");
                            }
                        }
                    }
                    serviceNewsService.addServiceNews(orderDO.getPatientName(),orderDO.getPatient(),"1",null);
                    String failMsg = "success";
                    result.put(ResponseContant.resultFlag, ResponseContant.success);
                    result.put(ResponseContant.resultMsg, failMsg);
                }
            }
            else {
                String failMsg = "工单不存在";
                result.put(ResponseContant.resultFlag, ResponseContant.fail);
                result.put(ResponseContant.resultMsg, failMsg);
            }
        }catch (Exception e){
            e.printStackTrace();
        }
        return result;
    }
        result.put(ResponseContant.resultFlag, ResponseContant.success);
    //退款后回调
    public JSONObject refundOrderAfter(String orderId) {
        JSONObject result = new JSONObject();
        try {
            BaseDoorCoachOrderDO orderDO= baseDoorCoachOrderDao.findOne(orderId);
            if (orderDO == null){
                String failMsg = "工单不存在";
                result.put(ResponseContant.resultFlag, ResponseContant.fail);
                result.put(ResponseContant.resultMsg, failMsg);
                return result;
            }
            orderDO.setPayStatus(2);
            this.save(orderDO);
            String failMsg = "success";
            result.put(ResponseContant.resultFlag, ResponseContant.fail);
            result.put(ResponseContant.resultMsg, failMsg);
        }catch (Exception e){
            e.printStackTrace();
        }
        return result;
    }
@ -783,48 +857,73 @@ public class PatientDoorCoachOrderService extends BaseJpaService<BaseDoorCoachOr
            logger.error(failMsg);
            return result;
        }
        if(orderDO.getStatus() > BaseDoorCoachOrderDO.Status.waitForServe.getType()){
            result.put(ResponseContant.resultFlag, ResponseContant.fail);
            String failMsg = "只有医生服务前的工单才可取消:," + orderId;
            result.put(ResponseContant.resultMsg, failMsg);
            logger.error(failMsg);
            return result;
        }
        orderDO.setCancelType(type);
        orderDO.setCancelTime(new Date());
        orderDO.setCancelReason(reason);
        if(!StringUtils.isEmpty(dispatcher)){
            orderDO.setDoctor(dispatcher);
            orderDO.setDoctorName(dispatcherName);
            orderDO.setDispatcher(dispatcher);
            orderDO.setDispatcherName(dispatcherName);
        }
        //如果是调度员取消,推送IM取消工单json消息,
        if (StringUtils.isNotBlank(dispatcher)){
            if (!consultTeamService.finishConsult(orderDO.getId(),orderDO.getPatient(),dispatcher,2)){
                String failMsg = "咨询结束失败 无法取消工单";
        if(type==2){//v0.5.1 患者仅未支付的订单能取消此时未正式开始工单,未创建咨询
            if(orderDO.getStatus() != BaseDoorCoachOrderDO.Status.waitForPay.getType()){
                result.put(ResponseContant.resultFlag, ResponseContant.fail);
                result.put(ResponseContant.resultMsg,failMsg);
                String failMsg = "无法取消工单,已支付的工单需要到我的订单中进行申请退款," + orderId;
                result.put(ResponseContant.resultMsg, failMsg);
                logger.error(failMsg);
                return result;
            }
        }
        else {
            if (!consultTeamService.finishConsult(orderDO.getId(),orderDO.getPatient(),orderDO.getPatient(),1)){
                String failMsg = "咨询结束失败 无法取消工单";
                result.put(ResponseContant.resultFlag, ResponseContant.fail);
                result.put(ResponseContant.resultMsg,failMsg);
        }else{//调度员拒单,此时工单已支付抵达调度员
            try {
                if (orderDO.getStatus() > BaseDoorCoachOrderDO.Status.waitForPay.getType()&&1==orderDO.getPayWay()){
                    BusinessOrderDO businessOrderDO = businessOrderDao.selectByRelationCode(orderDO.getId());
                    if (businessOrderDO!=null){
                        if (1 == businessOrderDO.getStatus()){
                            //退款流程
                            payService.orderRefund(businessOrderDO.getOrderNo(),"调度员拒单退款");
                            orderDO.setPayStatus(2);
                        }
                    }
                }
                //如果是调度员取消,推送IM取消工单json消息,
                if (StringUtils.isNotBlank(dispatcher)){
                    if (!consultTeamService.finishConsult(orderDO.getId(),orderDO.getPatient(),dispatcher,2)){
                        String failMsg = "咨询结束失败 无法取消工单";
                        result.put(ResponseContant.resultFlag, ResponseContant.fail);
                        result.put(ResponseContant.resultMsg,failMsg);
                        return result;
                    }
                }
                if(!StringUtils.isEmpty(dispatcher)){
                    orderDO.setDoctor(dispatcher);
                    orderDO.setDoctorName(dispatcherName);
                    orderDO.setDispatcher(dispatcher);
                    orderDO.setDispatcherName(dispatcherName);
                }
                if(type == BaseDoorCoachOrderDO.CancelType.dispatcher.getType()){
                    messageUtil.updateDoorCoachMessage(orderDO,new String[]{"702","703","730"},"732",dispatcher,dispatcher);
                }
                else if(type == BaseDoorCoachOrderDO.CancelType.patient.getType()){                   //居民取消,消息列表也应该不显示
                    messageUtil.updateDoorCoachMessage(orderDO,new String[]{"702","703","730"},"patientCancel",dispatcher,dispatcher);
                }
                ConsultDo consult = consultDao.queryByRelationCode(orderId);
                // 发送微信模板消息,通知居民工单已取消(smyyyqx-上门预约已取消)
                String first = "key1您好,您的上门预约订单已退回,点击查看原因";
                BasePatientDO patient = patientDao.findById(orderDO.getPatient());
                first  = first.replace("key1", null != patient.getName() ? patient.getName() : "");
                JSONObject json = new JSONObject();
                json.put("id", orderDO.getId());
                List<BasePatientWechatDo> basePatientWechatDos = basePatientWechatDao.findByWechatIdAndPatientId(wxId,patient.getId());
                if (basePatientWechatDos.size()>0){
                    String openId = basePatientWechatDos.get(0).getOpenid();
                    messageUtil.putTemplateWxMessage(wxId,"template_process_feedback","smyyyqx",openId,first,null,null,2,json, DateUtil.dateToChineseDate(new Date()),"上门预约已取消","已取消");
                }
            }catch (Exception e){
                e.printStackTrace();
                String failMsg = "退款失败,无法取消工单:," + orderId;
                result.put(ResponseContant.resultMsg, failMsg);
                return result;
            }
        }
        orderDO.setCancelType(type);
        orderDO.setCancelTime(new Date());
        orderDO.setCancelReason(reason);
        orderDO.setStatus(BaseDoorCoachOrderDO.Status.cancel.getType());
        this.save(orderDO);
        if(type == BaseDoorCoachOrderDO.CancelType.dispatcher.getType()){
            messageUtil.updateDoorCoachMessage(orderDO,new String[]{"702","703","730"},"732",dispatcher,dispatcher);
        }
        else if(type == BaseDoorCoachOrderDO.CancelType.patient.getType()){                   //居民取消,消息列表也应该不显示
            messageUtil.updateDoorCoachMessage(orderDO,new String[]{"702","703","730"},"patientCancel",dispatcher,dispatcher);
        }
        //保存取消记录
        BaseDoorCoachCancelLogDO cancelLogDO = new BaseDoorCoachCancelLogDO();
@ -845,19 +944,7 @@ public class PatientDoorCoachOrderService extends BaseJpaService<BaseDoorCoachOr
        JSONObject confirmInfoJson = new JSONObject();
        confirmInfoJson.put("confirmInfo",confirmInfo);
        this.orderWithConfirmLogAdd(result,confirmInfo,orderId);
        ConsultDo consult = consultDao.queryByRelationCode(orderId);
        // 发送微信模板消息,通知居民工单已取消(smyyyqx-上门预约已取消)
        String first = "key1您好,您的上门预约订单已退回,点击查看原因";
        BasePatientDO patient = patientDao.findById(orderDO.getPatient());
        first  = first.replace("key1", null != patient.getName() ? patient.getName() : "");
        JSONObject json = new JSONObject();
        json.put("id", orderDO.getId());
        List<BasePatientWechatDo> basePatientWechatDos = basePatientWechatDao.findByWechatIdAndPatientId(wxId,patient.getId());
        if (basePatientWechatDos.size()>0){
            String openId = basePatientWechatDos.get(0).getOpenid();
            messageUtil.putTemplateWxMessage(wxId,"template_process_feedback","smyyyqx",openId,first,null,null,2,json, DateUtil.dateToChineseDate(new Date()),"上门预约已取消","已取消");
        }
        // 工单状态变更记录
        BaseDoorCoachProcessLogDO processLogDO = new BaseDoorCoachProcessLogDO();
@ -1039,6 +1126,7 @@ public class PatientDoorCoachOrderService extends BaseJpaService<BaseDoorCoachOr
        if(null == totalFee){
            totalFee = new BigDecimal(0);
        }
        //新增服务项
        int addNum = 0;
        //服务项费用
@ -1099,7 +1187,8 @@ public class PatientDoorCoachOrderService extends BaseJpaService<BaseDoorCoachOr
                return true;
            }
        }
        order.setTotalFee(totalFee);
        this.save(order);
        return false;
    }
@ -1154,6 +1243,7 @@ public class PatientDoorCoachOrderService extends BaseJpaService<BaseDoorCoachOr
        List<Map<String, Object>> list = jdbcTemplate.queryForList(sql);
        Map<String, Integer> map = new HashMap<>();
        Integer all = 0;
        Integer waitForPay = 0;//待付款
        Integer waitForAccept = 0;//待接单
        Integer waitForServe = 0;//待服务
        Integer served = 0;//已完成
@ -1164,6 +1254,9 @@ public class PatientDoorCoachOrderService extends BaseJpaService<BaseDoorCoachOr
                case "-1":
                    cancel += Integer.valueOf(tmp.get("num").toString()) ;
                    break;
                case "0":
                    waitForPay += Integer.valueOf(tmp.get("num").toString()) ;
                    break;
                case "1":
                    waitForAccept += Integer.valueOf(tmp.get("num").toString()) ;
                    break;
@ -1189,6 +1282,7 @@ public class PatientDoorCoachOrderService extends BaseJpaService<BaseDoorCoachOr
        }
        all = waitForAccept+waitForServe+served+cancel;
        map.put("all",all);
        map.put("waitForPay",waitForAccept);
        map.put("waitForAccept",waitForAccept);
        map.put("waitForServe",waitForServe);
        map.put("served",served);
@ -1273,6 +1367,7 @@ public class PatientDoorCoachOrderService extends BaseJpaService<BaseDoorCoachOr
            String statusName = "";
            switch (statustemp){
                case -1:statusName="已取消";break;
                case 0:statusName="待付款";break;
                case 1:statusName="待服务";break;
                case 2:statusName="待服务";break;
                case 3:statusName="待服务";break;

+ 80 - 101
svr/svr-cloud-care/src/main/java/com/yihu/jw/care/service/lifeCare/LifeCareOrderService.java

@ -8,6 +8,7 @@ import com.yihu.jw.care.dao.lifeCare.LifeCareItemDictDao;
import com.yihu.jw.care.dao.lifeCare.LifeCareOrderDao;
import com.yihu.jw.care.service.common.OrderNoService;
import com.yihu.jw.care.service.message.BaseServiceNewsService;
import com.yihu.jw.care.service.pay.PayService;
import com.yihu.jw.care.util.MessageUtil;
import com.yihu.jw.doctor.dao.BaseDoctorDao;
import com.yihu.jw.doctor.dao.BaseDoctorHospitalDao;
@ -15,10 +16,13 @@ import com.yihu.jw.entity.base.doctor.BaseDoctorDO;
import com.yihu.jw.entity.base.doctor.BaseDoctorHospitalDO;
import com.yihu.jw.entity.base.org.BaseOrgDO;
import com.yihu.jw.entity.base.patient.BasePatientDO;
import com.yihu.jw.entity.care.doorCoach.BaseDoorCoachOrderDO;
import com.yihu.jw.entity.care.lifeCare.LifeCareCancelLogDO;
import com.yihu.jw.entity.care.lifeCare.LifeCareFeeDetailDO;
import com.yihu.jw.entity.care.lifeCare.LifeCareItemDictDO;
import com.yihu.jw.entity.care.lifeCare.LifeCareOrderDO;
import com.yihu.jw.entity.order.BusinessOrderDO;
import com.yihu.jw.order.dao.BusinessOrderDao;
import com.yihu.jw.org.dao.BaseOrgDao;
import com.yihu.jw.patient.dao.BasePatientDao;
import com.yihu.jw.restmodel.ResponseContant;
@ -79,6 +83,11 @@ public class LifeCareOrderService extends BaseJpaService<LifeCareOrderDO, LifeCa
    private OrderNoService orderNoService;
    @Autowired
    private BaseServiceNewsService serviceNewsService;
    @Autowired
    private PayService payService;
    @Autowired
    private BusinessOrderDao businessOrderDao;
    /**
@ -353,7 +362,8 @@ public class LifeCareOrderService extends BaseJpaService<LifeCareOrderDO, LifeCa
        JSONObject result = new JSONObject();
        int total = 0;
        Map<String,Object> res = new HashedMap();
        //状态 待服务 1、已完成 2 、已取消 -1
        //状态 0 待付款 待服务 1、已完成 2 、已取消 -1
        res.put("0",0);
        res.put("1",0);
        res.put("2",0);
        res.put("3",0);
@ -395,13 +405,20 @@ public class LifeCareOrderService extends BaseJpaService<LifeCareOrderDO, LifeCa
            logger.error(failMsg);
            return result;
        }
        if(orderDO.getStatus().equals(LifeCareOrderDO.Status.complete.getType())){
        if(orderDO.getStatus() != LifeCareOrderDO.Status.waitForPay.getType()){
            result.put(ResponseContant.resultFlag, ResponseContant.fail);
            String failMsg = "只有医生服务前的工单才可取消";
            String failMsg = "无法取消工单,已支付的工单需要到我的订单中进行申请退款," + orderId;
            result.put(ResponseContant.resultMsg, failMsg);
            logger.error(failMsg);
            return result;
        }
//        if(orderDO.getStatus().equals(LifeCareOrderDO.Status.complete.getType())){
//            result.put(ResponseContant.resultFlag, ResponseContant.fail);
//            String failMsg = "只有医生服务前的工单才可取消";
//            result.put(ResponseContant.resultMsg, failMsg);
//            logger.error(failMsg);
//            return result;
//        }
        orderDO.setCancelType(type);
        orderDO.setCancelTime(new Date());
        orderDO.setCancelReason(reason);
@ -449,13 +466,15 @@ public class LifeCareOrderService extends BaseJpaService<LifeCareOrderDO, LifeCa
    @Transactional(rollbackFor = Exception.class)
    public JSONObject create(String jsonData,String proxyPatient) {
        logger.info("申请生活照料jsonData参数:" + jsonData);
        proxyPatient = "808080eb78d3ce030178edeb4346002b";
        JSONObject result = new JSONObject();
        JSONObject jsonObjectParam;
        LifeCareOrderDO orderDO = null;
        try {
            jsonObjectParam = JSONObject.parseObject(jsonData);
            orderDO = EntityUtils.jsonToEntity(jsonObjectParam.get("order").toString(), LifeCareOrderDO.class);
            //存在未支付的订单不能发起
            Integer type = orderDO.getType();
            if (type==1||type==2){
                //本人或家人代发起
@ -470,6 +489,7 @@ public class LifeCareOrderService extends BaseJpaService<LifeCareOrderDO, LifeCa
                orderDO.setProxyPatientName(doctorDO.getName());
                orderDO.setProxyPatientPhone(doctorDO.getMobile());
            }
            //todo 代发起时推送待支付模板给患者
        } catch (Exception e) {
            e.printStackTrace();
@ -504,22 +524,70 @@ public class LifeCareOrderService extends BaseJpaService<LifeCareOrderDO, LifeCa
        }
        orderDO.setNumber(orderNoService.getOrderNo(1));
        orderDO.setCreateTime(new Date());
        orderDO.setStatus(1);
        orderDO.setStatus(0);//待付款状态
        this.save(orderDO);
        result.put("orderId",orderDO.getId());
        orderDO.setTotalFee(new BigDecimal(0));
        //新增工单与服务项费用关联关系
        if (orderWithPackageItemFeeAdd(result, jsonObjectParam, orderDO,null)) {return result;}
        result.put(ResponseContant.resultFlag, ResponseContant.success);
        result.put(ResponseContant.resultMsg, orderDO);
        if(orderDO.getType() == 3){
            serviceNewsService.addServiceNews(orderDO.getProxyPatientName(),orderDO.getProxyPatient(),"4",orderDO.getPatientName());
        }else {
            serviceNewsService.addServiceNews(orderDO.getPatientName(),orderDO.getPatient(),"3",null);
        //发起支付订单
        payService.submitOrder(orderDO.getPatient(),"4",orderDO.getId(),orderDO.getTotalFee().doubleValue());
        return result;
    }
    //支付完成后开始订单
    public JSONObject payOrderAfter(String orderId) {
        JSONObject result = new JSONObject();
        BusinessOrderDO businessOrderDO = businessOrderDao.selectByRelationCode(orderId);
        if (businessOrderDO==null){
            String failMsg = "未查询到该订单";
            result.put(ResponseContant.resultFlag, ResponseContant.fail);
            result.put(ResponseContant.resultMsg, failMsg);
            return result;
        }
        LifeCareOrderDO orderDO = lifeCareOrderDao.findOne(orderId);
        if (orderDO!=null) {
            orderDO.setPayStatus(1);
            orderDO.setPayWay(1);
            orderDO.setPayTime(new Date());
            orderDO.setStatus(1);
            this.save(orderDO);
            if(orderDO.getType() == 3){
                serviceNewsService.addServiceNews(orderDO.getProxyPatientName(),orderDO.getProxyPatient(),"4",orderDO.getPatientName());
            }else {
                serviceNewsService.addServiceNews(orderDO.getPatientName(),orderDO.getPatient(),"3",null);
            }
        }
        else {
            String failMsg = "工单不存在";
            result.put(ResponseContant.resultFlag, ResponseContant.fail);
            result.put(ResponseContant.resultMsg, failMsg);
        }
        result.put(ResponseContant.resultFlag, ResponseContant.success);
        result.put(ResponseContant.resultMsg, "success");
        return result;
    }
    //退款成功后回调
    public JSONObject refundOrderAfter(String orderId) {
        JSONObject result = new JSONObject();
        LifeCareOrderDO orderDO = lifeCareOrderDao.findOne(orderId);
        if (orderDO == null){
            String failMsg = "工单不存在";
            result.put(ResponseContant.resultFlag, ResponseContant.fail);
            result.put(ResponseContant.resultMsg, failMsg);
            return result;
        }
        orderDO.setPayStatus(2);
        this.save(orderDO);
        String failMsg = "success";
        result.put(ResponseContant.resultFlag, ResponseContant.fail);
        result.put(ResponseContant.resultMsg, failMsg);
        return result;
    }
@ -571,7 +639,8 @@ public class LifeCareOrderService extends BaseJpaService<LifeCareOrderDO, LifeCa
            logger.error(failMsg);
            return true;
        }
        order.setTotalFee(totalFee);
        lifeCareOrderDao.save(order);
        return false;
    }
@ -686,94 +755,4 @@ public class LifeCareOrderService extends BaseJpaService<LifeCareOrderDO, LifeCa
        }
    }
    /**
     * 生活照料代预约-- 废弃用原来的接口
     * @param jsonData
     * @param doctorCode
     * @return
     */
    @Transactional
    public JSONObject proxyCreate(String jsonData,String doctorCode) {
        JSONObject result = new JSONObject();
        JSONObject jsonObjectParam;
        try {
            jsonObjectParam = JSONObject.parseObject(jsonData);
        } catch (Exception e) {
            result.put(ResponseContant.resultFlag, ResponseContant.fail);
            String failMsg = "参数转换成JSON对象异常:" + e.getMessage();
            result.put(ResponseContant.resultMsg, failMsg);
            logger.error(failMsg);
            return result;
        }
        LifeCareOrderDO orderDO = null;
        try {
            orderDO = EntityUtils.jsonToEntity(jsonObjectParam.get("order").toString(), LifeCareOrderDO.class);
        } catch (Exception e) {
            result.put(ResponseContant.resultFlag, ResponseContant.fail);
            String failMsg = "生活照料工单服务基本信息:" + e.getMessage();
            result.put(ResponseContant.resultMsg, failMsg);
            logger.error(failMsg);
            return result;
        }
        if(StringUtils.isEmpty(orderDO.getPatient())){
            result.put(ResponseContant.resultFlag, ResponseContant.fail);
            String failMsg = "当前服务对象code为空,请联系管理员检查参数!patient = " + orderDO.getPatient();
            result.put(ResponseContant.resultMsg, failMsg);
            logger.error(failMsg);
            return result;
        }
        //医生代预约
        orderDO.setType(3);
        BaseDoctorDO doctorDO = doctorDao.findById(doctorCode);
        orderDO.setProxyPatient(doctorCode);
        orderDO.setProxyPatientName(doctorDO.getName());
        orderDO.setProxyPatientPhone(doctorDO.getMobile());
        //判断工单是否已存在,新建或者编辑
        if(StringUtils.isBlank(orderDO.getId())) {
            //已取消的订单也可以申请
            boolean bool = lifeCareOrderDao.existsByPatientAndStatusIn(orderDO.getPatient(),
                    new Integer[]{LifeCareOrderDO.Status.waitForAccept.getType()
                    });
            if(bool){
                String failMsg = "当前服务对象存在未完成的生活照料,请先完成该服务!";
                result.put(ResponseContant.resultFlag, ResponseContant.fail);
                result.put(ResponseContant.resultMsg, failMsg);
                logger.error(failMsg);
                return result;
            }
            orderDO.setNumber(orderNoService.getOrderNo(1));
            orderDO.setHospital(jsonObjectParam.getJSONObject("hospital").get("code").toString());
            orderDO.setCreateTime(new Date());
            orderDO.setCreateUser(orderDO.getProxyPatient());
            orderDO.setCreateUserName(orderDO.getProxyPatientName());
        }else {
            LifeCareOrderDO serviceOrderDO = lifeCareOrderDao.findOne(orderDO.getId());
            // 删除出诊医生或服务项
            Boolean b = this.orderWithFeeDelete(jsonObjectParam, serviceOrderDO);
            if(b){
                String failMsg = "删除服务项失败!";
                result.put(ResponseContant.resultFlag, ResponseContant.fail);
                result.put(ResponseContant.resultMsg, failMsg);
                return result;
            }
            orderDO.setNumber(serviceOrderDO.getNumber());
            orderDO.setHospital(serviceOrderDO.getHospital());
            orderDO.setUpdateTime(new Date());
            orderDO.setUpdateUser(orderDO.getProxyPatient());
            orderDO.setUpdateUserName(orderDO.getProxyPatientName());
        }
        orderDO.setStatus(2);
        orderDO.setType(3);
        this.save(orderDO);
        result.put("orderId",orderDO.getId());
        //新增工单与服务项费用关联关系
        if (orderWithPackageItemFeeAdd(result, jsonObjectParam, orderDO,doctorCode)) {return result;}
        result.put(ResponseContant.resultFlag, ResponseContant.success);
        return result;
    }
}

+ 718 - 0
svr/svr-cloud-care/src/main/java/com/yihu/jw/care/service/pay/PayService.java

@ -0,0 +1,718 @@
package com.yihu.jw.care.service.pay;
import com.alibaba.fastjson.JSONObject;
import com.fasterxml.jackson.databind.node.ObjectNode;
import com.yihu.fastdfs.FastDFSUtil;
import com.yihu.jw.care.dao.doorCoach.BaseDoorCoachFeeDetailDao;
import com.yihu.jw.care.dao.doorCoach.BaseDoorCoachOrderDao;
import com.yihu.jw.care.dao.lifeCare.LifeCareFeeDetailDao;
import com.yihu.jw.care.dao.lifeCare.LifeCareOrderDao;
import com.yihu.jw.care.dao.pay.WxPayHttpLogDao;
import com.yihu.jw.care.service.doorCoach.PatientDoorCoachOrderService;
import com.yihu.jw.care.service.lifeCare.LifeCareOrderService;
import com.yihu.jw.care.util.WxpayUtil;
import com.yihu.jw.care.util.XMLUtil;
import com.yihu.jw.entity.base.patient.BasePatientDO;
import com.yihu.jw.entity.base.wx.WxWechatDO;
import com.yihu.jw.entity.care.common.WxPayHttpLogDO;
import com.yihu.jw.entity.care.doorCoach.BaseDoorCoachFeeDetailDO;
import com.yihu.jw.entity.care.doorCoach.BaseDoorCoachOrderDO;
import com.yihu.jw.entity.care.lifeCare.LifeCareFeeDetailDO;
import com.yihu.jw.entity.care.lifeCare.LifeCareOrderDO;
import com.yihu.jw.entity.order.BusinessOrderDO;
import com.yihu.jw.entity.order.BusinessOrderRefundDO;
import com.yihu.jw.order.BusinessOrderService;
import com.yihu.jw.order.dao.BusinessOrderDao;
import com.yihu.jw.order.dao.BusinessOrderRefundDao;
import com.yihu.jw.patient.dao.BasePatientDao;
import com.yihu.jw.restmodel.ResponseContant;
import com.yihu.jw.restmodel.web.ObjEnvelop;
import com.yihu.jw.util.common.IpUtil;
import com.yihu.jw.util.common.QrcodeUtil;
import com.yihu.jw.util.date.DateUtil;
import com.yihu.jw.utils.StringUtil;
import com.yihu.jw.wechat.dao.WechatDao;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.util.Assert;
import javax.servlet.http.HttpServletRequest;
import java.io.InputStream;
import java.util.*;
import static jxl.biff.FormatRecord.logger;
/**
 * Created with IntelliJ IDEA.
 * 支付
 * @Author: yeshijie
 * @Date: 2021/6/28
 * @Description:
 */
@Service
public class PayService {
    private Logger log = LoggerFactory.getLogger(PatientDoorCoachOrderService.class);
    @Autowired
    private BasePatientDao patientDao;
    @Autowired
    private BusinessOrderDao businessOrderDao;
    @Value("${wechat.id}")
    public String wechatId;
    @Value("${wechat.appId}")
    public String appId;
    @Value("${wechat.mchId}")
    public String mchId;
    @Value("${wechat.apiKey}")
    public String apiKey;
    @Value("${wechat.wechat_base_url}")
    private String serverUrl;
    @Autowired
    private WxPayHttpLogDao wxPayHttpLogDao;
    @Autowired
    private FastDFSUtil fastDFSUtil;
    @Autowired
    private BusinessOrderService businessOrderService;
    @Autowired
    private WechatDao wechatDao;
    @Autowired
    private BusinessOrderRefundDao orderRefundDao;
    @Autowired
    private LifeCareOrderService lifeCareOrderService;
    @Autowired
    private LifeCareOrderDao lifeCareOrderDao;
    @Autowired
    private PatientDoorCoachOrderService doorCoachOrderService;
    @Autowired
    private BaseDoorCoachOrderDao baseDoorCoachOrderDao;
    @Value("${fastDFS.fastdfs_file_url}")
    private String fastdfs_file_url;
    @Autowired
    private JdbcTemplate jdbcTemplate;
    @Autowired
    private LifeCareFeeDetailDao lifeCareFeeDetailDao;
    @Autowired
    private BaseDoorCoachFeeDetailDao doorCoachFeeDetailDao;
    /**
     * 顶部状态栏订单各分类总条数
     * 0待支付、1已支付、2已取消、3申请退款中、4已售后
     * @param patient
     * @return
     */
    public Map<String, Integer> topStatusBarNum(String patient) {
        String sql = "SELECT a.`status`,COUNT(*) num from base_business_order_pay a  where patient = '"+patient+"' " +
                "GROUP BY a.`status` " ;
        List<Map<String, Object>> list = jdbcTemplate.queryForList(sql);
        Map<String, Integer> map = new HashMap<>();
        //状态 0待支付、1已支付、2已取消、3申请退款中、4已售后
        map.put("0",0);
        map.put("1",0);
        map.put("2",0);
        map.put("3",0);
        map.put("4",0);
        int total = 0;
        if(list.size()>0){
            for (Map<String, Object> one:list){
                map.put(String.valueOf(one.get("status")), Integer.valueOf(String.valueOf(one.get("num"))));
                total+=Integer.valueOf(String.valueOf(one.get("num")));
            }
        }
        map.put("total", total);
        return map;
    }
    /**
     * 居民我的订单列表
     * @param patient
     * @param status
     * @param page
     * @param size
     * @return
     */
    public JSONObject orderList(String patient, String status, int page, int size) {
        JSONObject result = new JSONObject();
        int start = 0 == page ? page++ : (page - 1) * size;
        int end = 0 == size ? 15 : size;
        String filter = " where patient = '"+patient+"' ";
        if(!StringUtil.isEmpty(status)){
            filter += " and status = "+ status +" ";
        }
        String sql = "select a.id,a.patient,a.patient_name patientName,a.order_no orderNo,a.status, " +
                "DATE_FORMAT(a.create_time,'%Y-%m-%d %H:%i:%s') createTime " +
                ",a.order_category orderCategory,a.relation_code relationCode,a.relation_name relationName " +
                ",a.pay_type payType,a.pay_price payPrice from base_business_order_pay a " + filter ;
         sql += " ORDER BY a.create_time desc " +
                " LIMIT {start},{end};";
        String finalSql = sql.replace("{start}", String.valueOf(start))
                .replace("{end}", String.valueOf(end));
        String countSql = "SELECT  count(a.id)  FROM  base_business_order_pay a" + filter ;
        List<Map<String,Object>> sqlResultlist;
        try {
            sqlResultlist = jdbcTemplate.queryForList(finalSql);
        } catch (Exception e) {
            result.put(ResponseContant.resultFlag, ResponseContant.fail);
            result.put(ResponseContant.resultMsg, "从数据库查询工单列表信息失败");
            return result;
        }
        Long count;
        try {
            count = jdbcTemplate.queryForObject(countSql, Long.class);
        } catch (Exception e) {
            result.put(ResponseContant.resultFlag, ResponseContant.fail);
            result.put(ResponseContant.resultMsg, "从数据库统计工单数量失败" );
            return result;
        }
        result.put(ResponseContant.resultFlag, ResponseContant.success);
        result.put(ResponseContant.resultMsg, sqlResultlist);
        JSONObject countItem = new JSONObject();
        countItem.put("count", count);
        result.putAll(countItem);
        return result;
    }
    /**
     * 订单详情接口
     * @param id
     */
    public JSONObject orderInfo(Integer id){
        JSONObject resJson = new JSONObject();
        resJson.put("id",id);
        BusinessOrderDO businessOrderDO = businessOrderDao.findOne(id);
        String type = businessOrderDO.getOrderCategory();
        Integer status = businessOrderDO.getStatus();
        resJson.put("orderCategory",type);
        resJson.put("orderNo",businessOrderDO.getOrderNo());
        resJson.put("payPrice",businessOrderDO.getPayPrice());
        resJson.put("payTime", DateUtil.dateToStrLong(businessOrderDO.getPayTime()));
        resJson.put("createTime",DateUtil.dateToStrLong(businessOrderDO.getCreateTime()));
        resJson.put("updateTime",DateUtil.dateToStrLong(businessOrderDO.getUpdateTime()));
        long time = (businessOrderDO.getCreateTime().getTime() - System.currentTimeMillis())/1000+60*30;
        if(time<0&&status==0){
            cancleOrder(id);
            status = 2;
        }
        resJson.put("status",status);
        resJson.put("time",time);
        //项目
        if("3".equals(type)){
            List<BaseDoorCoachFeeDetailDO> feeDetailDOList = doorCoachFeeDetailDao.findByOrderId(businessOrderDO.getRelationCode());
            resJson.put("fees",feeDetailDOList);
        }else if("4".equals(type)){
            List<LifeCareFeeDetailDO> feeDetailDOList = lifeCareFeeDetailDao.findByOrderId(businessOrderDO.getRelationCode());
            resJson.put("fees",feeDetailDOList);
        }
        //退款信息
        if(status>2){
            BusinessOrderRefundDO refundDO = orderRefundDao.selectByOrderNo(businessOrderDO.getOrderNo());
            resJson.put("refundDO",refundDO);
        }
        return resJson;
    }
    /**
     * 申请退款
     * @param id
     * @return
     */
    @Transactional(rollbackFor = Exception.class)
    public String applyRefund(Integer id,String description,String enclosure){
        BusinessOrderDO businessOrderDO = businessOrderDao.findOne(id);
        String type = businessOrderDO.getOrderCategory();
        String orderId = businessOrderDO.getRelationCode();
        if(businessOrderDO.getStatus()!=1){
            return "订单为已支付状态时,才可申请退款";
        }
        if("3".equals(type)){
            BaseDoorCoachOrderDO orderDO = baseDoorCoachOrderDao.findOne(orderId);
            if(!"6".equals(orderDO.getStatus())){
                return "工单为已完成状态时,才可申请退款";
            }
        }else if("4".equals(type)){
            LifeCareOrderDO orderDO = lifeCareOrderDao.findOne(orderId);
            if(!"2".equals(orderDO.getStatus())){
                return "工单为已完成状态时,才可申请退款";
            }
        }
        BusinessOrderRefundDO orderRefundDO = orderRefundDao.selectByOrderNo(businessOrderDO.getOrderNo());
        if (orderRefundDO!=null){
            return "请勿重复申请退款";
        }
        orderRefundDO = new BusinessOrderRefundDO();
        orderRefundDO.setCreateTime(new Date());
        orderRefundDO.setUpdateTime(new Date());
        orderRefundDO.setStatus(1);
        orderRefundDO.setOrderNo(businessOrderDO.getOrderNo());
        orderRefundDO.setOrderPrice(businessOrderDO.getPayPrice());
        orderRefundDO.setRefundPrice(businessOrderDO.getPayPrice());
        orderRefundDO.setOutRefundNo("CARE"+businessOrderDO.getOrderType()+System.currentTimeMillis()+(int)(Math.random()*900)+100);
        orderRefundDO.setPatient(businessOrderDO.getPatient());
        orderRefundDO.setPatientName(businessOrderDO.getPatientName());
        orderRefundDO.setRefundDesc(description);
        orderRefundDO.setEnclosure(enclosure);
        orderRefundDao.save(orderRefundDO);
        businessOrderDO.setStatus(3);
        businessOrderDao.save(businessOrderDO);
        return null;
    }
    /**
     * 取消订单
     * @param id
     */
    public String cancleOrder(Integer id){
        BusinessOrderDO businessOrderDO = businessOrderDao.findOne(id);
        if(businessOrderDO.getStatus()==0){
            String type = businessOrderDO.getOrderCategory();
            String orderId = businessOrderDO.getRelationCode();
            if("3".equals(type)){
                BaseDoorCoachOrderDO orderDO = baseDoorCoachOrderDao.findOne(orderId);
                if(orderDO.getStatus()==0){
                    orderDO.setStatus(-1);
                    orderDO.setCancelReason("居民取消上门辅导订单");
                    baseDoorCoachOrderDao.save(orderDO);
                }
            }else if("4".equals(type)){
                LifeCareOrderDO orderDO = lifeCareOrderDao.findOne(orderId);
                if(orderDO.getStatus()==0){
                    orderDO.setStatus(-1);
                    lifeCareOrderDao.save(orderDO);
                }
            }
            businessOrderDO.setStatus(2);
            businessOrderDO.setUpdateTime(new Date());
            businessOrderDao.save(businessOrderDO);
        }else{
            return "只有待支付的订单才能取消";
        }
        return null;
    }
    /**
     * 居民是否存在未支付订单
     * @param patient
     * @param orderCategory
     * @return
     */
    public JSONObject existWaitForPay(String patient,String orderCategory){
        JSONObject result = new JSONObject();
        List<BusinessOrderDO> businessOrderDOs = businessOrderDao.selectByPatientAndStatusAndOrderCategory(patient,0,orderCategory);
        if (businessOrderDOs.size()>0){
            result.put("flag",true);
            result.put("OrderDO",businessOrderDOs.get(0));
        }
        else {
            result.put("flag",false);
            result.put("OrderDO",null);
        }
        return result;
    }
    /**
     * 工单获取支付信息
     * @param orderId
     * @param category
     * @return
     */
    public JSONObject getPayInfo(String orderId,String category){
        JSONObject result = new JSONObject();
        if("3".equals(category)){
            BaseDoorCoachOrderDO orderDO = baseDoorCoachOrderDao.findOne(orderId);
            if (orderDO==null){
                result.put(ResponseContant.resultFlag, ResponseContant.fail);
                result.put(ResponseContant.resultMsg, "支付工单不存在");
                return result;
            }
        }else if("4".equals(category)){
            LifeCareOrderDO orderDO = lifeCareOrderDao.findOne(orderId);
            if (orderDO==null){
                result.put(ResponseContant.resultFlag, ResponseContant.fail);
                result.put(ResponseContant.resultMsg, "支付工单不存在");
                return result;
            }
        }
        BusinessOrderDO businessOrderDO = businessOrderDao.selectByRelationCode(orderId);
        if (businessOrderDO==null){
            result.put(ResponseContant.resultFlag, ResponseContant.fail);
            result.put(ResponseContant.resultMsg, "工单未创建支付订单");
            return result;
        }
        JSONObject payInfo = orderInfo(businessOrderDO.getId());
        result.put(ResponseContant.resultFlag, ResponseContant.success);
        result.put(ResponseContant.resultMsg, payInfo);
        return result;
    }
    /**
     * 微信退款
     * @param orderNo
     * @param description
     * @return
     * @throws Exception
     */
    public void orderRefund(String orderNo,String description) throws Exception {
        WxWechatDO wxWechatDO = wechatDao.findById(wechatId);
        if (wxWechatDO==null){
            throw new Exception("this wechatId is null");
        }
        BusinessOrderDO businessOrderDO = businessOrderDao.selectByOrderNo(orderNo);
        if (businessOrderDO==null){
            throw new Exception("this orderId not exit");
        }
        BasePatientDO patientDO = patientDao.findById(businessOrderDO.getPatient());
        if (patientDO==null){
            throw new Exception("this patient not exit");
        }
        BusinessOrderRefundDO orderRefundDO = orderRefundDao.selectByOrderNo(orderNo);
        if (orderRefundDO==null){
            orderRefundDO = new BusinessOrderRefundDO();
        }
        orderRefundDO.setCreateTime(new Date());
        orderRefundDO.setUpdateTime(new Date());
        orderRefundDO.setStatus(1);
        orderRefundDO.setOrderNo(orderNo);
        orderRefundDO.setOrderPrice(businessOrderDO.getPayPrice());
        orderRefundDO.setRefundPrice(businessOrderDO.getPayPrice());
        orderRefundDO.setAppId(wxWechatDO.getAppId());
        orderRefundDO.setMchId(wxWechatDO.getMchId());
        orderRefundDO.setOutRefundNo("CARE"+businessOrderDO.getOrderType()+System.currentTimeMillis()+(int)(Math.random()*900)+100);
        orderRefundDO.setPatient(businessOrderDO.getPatient());
        orderRefundDO.setPatientName(patientDO.getName());
        orderRefundDO.setRefundDesc(description);
        orderRefundDO = orderRefundDao.save(orderRefundDO);
        Integer orderPrice = orderRefundDO.getOrderPrice().intValue();
        Integer refundPrice1 = orderRefundDO.getRefundPrice().intValue();
        Map<String,Object> map = businessOrderService.refund(wechatId,orderRefundDO.getOrderNo(),orderRefundDO.getOutRefundNo(),orderPrice.toString(),refundPrice1.toString(),orderRefundDO.getRefundDesc());
        logger.info("map"+map);
        addHttpLog("1",businessOrderDO.getOrderNo(),null,map.toString());
        if (map.get("return_code").toString().equalsIgnoreCase("SUCCESS")){
            //退款申请提交成功
            throw new Exception(map.get("return_msg").toString());
        }
    }
    /**
     * 添加支付日志
     * @param type
     * @param orderNo
     * @param res
     * @param req
     */
    public void addHttpLog(String type,String orderNo,String res,String req){
        WxPayHttpLogDO logDO = new WxPayHttpLogDO();
        logDO.setType(type);
        logDO.setOrderNo(orderNo);
        logDO.setOrderReq(req);
        logDO.setOrderRes(res);
        wxPayHttpLogDao.save(logDO);
    }
    /**
     * 支付成功处理
     * @return
     */
    @Transactional(rollbackFor = Exception.class)
    public void payNotify(BusinessOrderDO orderDO) {
        log.error("【支付通知】请求,payWater:{}", orderDO);
        String type = orderDO.getOrderCategory();
        //防止重复支付
        if (orderDO.getStatus()!=0) {
            return;
        }
        switch (type){
            case "1":
                //desc = "招生报名";
                break;
            case "2":
                //desc = "课程报名";
                break;
            case "3":
                //desc = "上门辅导";
                doorCoachOrderService.payOrderAfter(orderDO.getRelationCode());
                break;
            case "4":
                //desc = "生活照料服务";
                lifeCareOrderService.payOrderAfter(orderDO.getRelationCode());
                break;
            default:
                break;
        }
        orderDO.setStatus(1);
        orderDO.setPayType(1);
        orderDO.setPayTime(new Date());
        businessOrderDao.save(orderDO);
    }
    /**
     * 退款成功处理
     * @return
     */
    @Transactional(rollbackFor = Exception.class)
    public void refundNotify(BusinessOrderRefundDO orderDO) {
        log.error("【支付通知】请求,payWater:{}", orderDO);
        String type = "";
        //防止重复支付
        if (orderDO.getStatus()!=0) {
            return;
        }
        switch (type){
            case "1":
                //desc = "招生报名";
                break;
            case "2":
                //desc = "课程报名";
                break;
            case "3":
                //desc = "上门辅导";
               // doorCoachOrderService.payOrderAfter(orderDO.getRelationCode());
                break;
            case "4":
                //desc = "生活照料服务";
               // lifeCareOrderService.payOrderAfter(orderDO.getRelationCode());
                break;
            default:
                break;
        }
    }
    /**
     * 微信navite统一下单接口
     *
     * @return prepayId 微信预支付交易会话标识,该值有效期为2小时
     * @throws Exception
     */
    @Transactional(rollbackFor = Exception.class)
    public ObjEnvelop wxNativePay(String relationId,Integer orderId,HttpServletRequest request) throws Exception {
        BusinessOrderDO businessOrderDO;
        if(StringUtil.isBlank(relationId)){
            businessOrderDO = businessOrderDao.findOne(orderId);
        }else{
            businessOrderDO = businessOrderDao.selectByRelationCode(relationId);
        }
        Assert.notNull(businessOrderDO, "支付流水不存在");
        if (businessOrderDO.getStatus()!=0) {
            return ObjEnvelop.getError("待支付订单才能支付",-1);
        }
        long time = (System.currentTimeMillis() - businessOrderDO.getCreateTime().getTime())/1000;
        if(time>=60*30){
            cancleOrder(businessOrderDO.getId());
            return ObjEnvelop.getError("支付超时,订单已关闭",-1);
        }
        businessOrderDO.setOrderNo(getOrderNo());
        String noceStr = WxpayUtil.getNonceStr();
        // 组装统一下单信息
        SortedMap<String, String> reqMap = new TreeMap<>();
        String title = businessOrderDO.getDescription();
        reqMap.put("appid", appId);
        reqMap.put("attach", title);
        reqMap.put("body", title);
        // 微信支付分配的商户号
        reqMap.put("mch_id", mchId);
        reqMap.put("nonce_str", noceStr);
        // 此路径是微信服务器调用支付结果通知路径
        reqMap.put("notify_url", serverUrl+"pay/open/wxPayNotify");
        reqMap.put("out_trade_no", businessOrderDO.getOrderNo());
        reqMap.put("spbill_create_ip", IpUtil.getOneIpAddress(request));
        reqMap.put("product_id", businessOrderDO.getOrderNo());
        // 订单总金额,单位为分
        Double payAmountIntValue = businessOrderDO.getPayPrice() * 100;
        if(payAmountIntValue.intValue()<=0){
            return ObjEnvelop.getError("支付金额必须大于0",-1);
        }
        reqMap.put("total_fee", String.valueOf(payAmountIntValue.intValue()));
        reqMap.put("trade_type", "NATIVE");
        // 创建第一次签名
        log.error("第一次签名: " + reqMap.toString());
        String sign = WxpayUtil.createSign(reqMap, apiKey);
        log.error("【微信支付】签名:{}", sign);
        reqMap.put("sign", sign);
        // 调用微信统一下单返回的值
        log.error("第二次签名: " + reqMap.toString());
        String result = WxpayUtil.createUnifiedorder(reqMap);
        log.error("【微信支付】统一下单响应:{}", result);
        //调用统一接口返回的值转换为XML格式
        Map<String, String> map = XMLUtil.doXMLParse(result);
        addHttpLog("1",businessOrderDO.getOrderNo(),reqMap.toString(),result);
        if ("SUCCESS".equals(map.get("return_code"))) {
            String code_url = map.get("code_url");
            //生成二维码
            InputStream ipt = QrcodeUtil.createQrcode(code_url, 300, "png");
            String fileUrl="";
            try {
                ObjectNode imgNode = fastDFSUtil.upload(ipt, "png", "wx_pay_qrcode" + System.currentTimeMillis());
                JSONObject json = JSONObject.parseObject(imgNode.toString());
                fileUrl = json.getString("fileId");
            } catch (Exception e) {
                e.printStackTrace();
            }
            businessOrderDao.save(businessOrderDO);
            return ObjEnvelop.getSuccess("下单成功",fastdfs_file_url+fileUrl);
        } else {
            return ObjEnvelop.getError(map.get("return_msg"),-1);
        }
    }
    /**
     * 微信统一下单接口
     *
     * @return prepayId 微信预支付交易会话标识,该值有效期为2小时
     * @throws Exception
     */
    @Transactional(rollbackFor = Exception.class)
    public ObjEnvelop wxWapPay(String relationId,Integer orderId,HttpServletRequest request) throws Exception {
        BusinessOrderDO businessOrderDO;
        if(StringUtil.isBlank(relationId)){
            businessOrderDO = businessOrderDao.findOne(orderId);
        }else{
            businessOrderDO = businessOrderDao.selectByRelationCode(relationId);
        }
        Assert.notNull(businessOrderDO, "支付流水不存在");
        if (businessOrderDO.getStatus()!=0) {
            return ObjEnvelop.getError("待支付订单才能支付",-1);
        }
        long time = (System.currentTimeMillis() - businessOrderDO.getCreateTime().getTime())/1000;
        if(time>=60*30){
            cancleOrder(businessOrderDO.getId());
            return ObjEnvelop.getError("支付超时,订单已关闭",-1);
        }
        BasePatientDO patientDO = patientDao.findById(businessOrderDO.getPatient());
        businessOrderDO.setOrderNo(getOrderNo());
        String noceStr = WxpayUtil.getNonceStr();
        // 组装统一下单信息
        SortedMap<String, String> reqMap = new TreeMap<>();
        String title = businessOrderDO.getDescription();
        reqMap.put("appid", appId);
        reqMap.put("attach", title);
        reqMap.put("body", title);
        // 微信支付分配的商户号
        reqMap.put("mch_id", mchId);
        reqMap.put("nonce_str", noceStr);
        // 此路径是微信服务器调用支付结果通知路径
        reqMap.put("notify_url", serverUrl+"pay/open/wxPayNotify");
        reqMap.put("out_trade_no", businessOrderDO.getOrderNo());
        reqMap.put("spbill_create_ip", IpUtil.getOneIpAddress(request));
        reqMap.put("product_id", businessOrderDO.getOrderNo());
        // 订单总金额,单位为分
        Double payAmountIntValue = businessOrderDO.getPayPrice() * 100;
        if(payAmountIntValue.intValue()<=0){
            return ObjEnvelop.getError("支付金额必须大于0",-1);
        }
        reqMap.put("total_fee", String.valueOf(payAmountIntValue.intValue()));
        reqMap.put("trade_type", "JSAPI");
        reqMap.put("openid", patientDO.getOpenid());
        // 创建第一次签名
        log.error("第一次签名: " + reqMap.toString());
        String sign = WxpayUtil.createSign(reqMap, apiKey);
        log.error("【微信支付】签名:{}", sign);
        reqMap.put("sign", sign);
        // 调用微信统一下单返回的值
        log.error("第二次签名: " + reqMap.toString());
        String result = WxpayUtil.createUnifiedorder(reqMap);
        addHttpLog("1",businessOrderDO.getOrderNo(),reqMap.toString(),result);
        log.error("【微信支付】统一下单响应:{}", result);
        //调用统一接口返回的值转换为XML格式
        Map<String, String> map = XMLUtil.doXMLParse(result);
        if (!"SUCCESS".equals(map.get("return_code"))) {
            return ObjEnvelop.getError(map.get("return_msg"),-1);
        }
        log.error("【微信支付】统一下单成功:" + map);
        // 下单返回预支付交易会话标识
        String prepayId = map.get("prepay_id");
        // 返回app调起支付订单信息
        TreeMap<String, String> payMap = new TreeMap<>();
        payMap.put("appId", appId);
        payMap.put("package", "prepay_id=" + prepayId);
        payMap.put("signType", "MD5");
        payMap.put("nonceStr", noceStr);
        payMap.put("timeStamp", WxpayUtil.getTimeStamp());
        // 二次签名
        String paySign = WxpayUtil.createSign(payMap, apiKey);
        payMap.put("paySign", paySign);
        log.error("【微信支付】WAP支付订单信息:{}", payMap);
        businessOrderDao.save(businessOrderDO);
        return ObjEnvelop.getSuccess("下单成功",payMap);
    }
    /**
     * 提交支付订单
     * 订单类型 1招生,2 课程,3 上门辅导托幼) 4 生活照料
     * @return
     */
    public BusinessOrderDO submitOrder(String patientId,String type,String relationCode,Double price){
        BasePatientDO pateint = patientDao.findById(patientId);
        BusinessOrderDO businessOrderDO = new BusinessOrderDO();
        businessOrderDO.setPatient(pateint.getId());
        //支付账号
        businessOrderDO.setYkOrderId(pateint.getMobile());
        businessOrderDO.setPatientName(pateint.getName());
        businessOrderDO.setOrderType(1);
        businessOrderDO.setOrderCategory(type);
        String desc;
        String relateName;
        switch (type){
            case "1":
                desc = "招生报名费";
                relateName = "招生报名";
                break;
            case "2":
                desc = "课程报名费";
                relateName = "课程报名";
                break;
            case "3":
                desc = "上门辅导服务项目费";
                relateName = "上门辅导";
                break;
            case "4":
                desc = "生活照料服务项目费";
                relateName = "生活照料";
                break;
            default:
                desc = "服务费";
                relateName = "服务";
                break;
        }
        businessOrderDO.setDescription(desc);
        businessOrderDO.setRelationCode(relationCode);
        businessOrderDO.setRelationName(relateName);
        businessOrderDO.setCreateTime(new Date());
        businessOrderDO.setUpdateTime(new Date());
        businessOrderDO.setStatus(0);
        businessOrderDO.setOrderNo(getOrderNo());
        businessOrderDO.setUploadStatus(0);
        businessOrderDO.setPayType(1);
        businessOrderDO.setPayPrice(Double.valueOf(price));
        businessOrderService.save(businessOrderDO);
        return businessOrderDO;
    }
    public String getOrderNo(){
        return ""+System.currentTimeMillis()+(int)(Math.random()*900)+100;
    }
}

+ 1 - 1
svr/svr-cloud-care/src/main/java/com/yihu/jw/care/service/third/PatientInfoPlatFormService.java

@ -209,7 +209,7 @@ public class PatientInfoPlatFormService {
                "order by create_time desc  ";
        String countSql = "select count(id) from ("+sql+")A ";
        long count = jdbcTemplate.queryForObject(countSql,long.class);
        sql +=" limit "+page*page+","+pageSize;
        sql +=" limit "+page*pageSize+","+pageSize;
        List<Map<String,Object>> list = jdbcTemplate.queryForList(sql);
        return PageEnvelop.getSuccessListWithPage("查询成功",list,page,pageSize,count);
    }

+ 80 - 0
svr/svr-cloud-care/src/main/java/com/yihu/jw/care/util/HttpsUtil.java

@ -0,0 +1,80 @@
package com.yihu.jw.care.util;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import javax.net.ssl.HttpsURLConnection;
import javax.net.ssl.SSLContext;
import javax.net.ssl.SSLSocketFactory;
import javax.net.ssl.TrustManager;
import java.io.BufferedReader;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.OutputStream;
import java.net.ConnectException;
import java.net.URL;
import java.security.SecureRandom;
/**
 * http请求工具类
 *
 * @author yeshijie
 * @version 1.0
 * @date 2021/06/28 10:20
 */
public class HttpsUtil {
    private static final Logger LOGGER = LoggerFactory.getLogger(HttpsUtil.class);
    /**
     * 发送https请求
     *
     * @param requestUrl    请求地址
     * @param requestMethod 请求方式(GET、POST)
     * @param outputStr     提交的数据
     * @return 返回微信服务器响应的信息
     */
    public static String httpsRequest(String requestUrl, String requestMethod, String outputStr) {
        StringBuffer buffer = null;
        try {
            SSLContext sslContext = SSLContext.getInstance("SSL", "SunJSSE");
            TrustManager[] tm = {new RequestTrustManager()};
            sslContext.init(null, tm, new SecureRandom());
            SSLSocketFactory ssf = sslContext.getSocketFactory();
            URL url = new URL(requestUrl);
            HttpsURLConnection conn = (HttpsURLConnection) url.openConnection();
            conn.setDoOutput(true);
            conn.setDoInput(true);
            conn.setUseCaches(false);
            // 设置请求方式(GET/POST)
            conn.setRequestMethod(requestMethod);
            conn.setSSLSocketFactory(ssf);
            conn.connect();
            if (null != outputStr) {
                OutputStream os = conn.getOutputStream();
                os.write(outputStr.getBytes("utf-8"));
                os.close();
            }
            //读取服务器端返回的内容
            InputStream inputStream = conn.getInputStream();
            InputStreamReader inputStreamReader = new InputStreamReader(inputStream, "utf-8");
            BufferedReader bufferedReader = new BufferedReader(inputStreamReader);
            buffer = new StringBuffer();
            String line;
            while ((line = bufferedReader.readLine()) != null) {
                buffer.append(line);
            }
            // 释放资源
            bufferedReader.close();
            inputStreamReader.close();
            inputStream.close();
            conn.disconnect();
        } catch (ConnectException ce) {
            LOGGER.error("http请求连接超时" + ce);
        } catch (Exception e) {
            LOGGER.error("http请求异常" + e);
        }
        return buffer.toString();
    }
}

+ 51 - 0
svr/svr-cloud-care/src/main/java/com/yihu/jw/care/util/MD5Util.java

@ -0,0 +1,51 @@
package com.yihu.jw.care.util;
import java.security.MessageDigest;
/**
 * MD5加密工具类
 *
 * @author yeshijie
 * @version 1.0.0
 * @date 2021/6/28
 */
public class MD5Util {
    private static final String[] HEX_DIGITS = {"0", "1", "2", "3", "4", "5",
            "6", "7", "8", "9", "a", "b", "c", "d", "e", "f"};
    private static String byteArrayToHexString(byte[] b) {
        StringBuffer buffer = new StringBuffer();
        for (int i = 0; i < b.length; i++) {
            buffer.append(byteToHexString(b[i]));
        }
        return buffer.toString();
    }
    private static String byteToHexString(byte b) {
        int n = b;
        if (n < 0) {
            n += 256;
        }
        int d1 = n / 16;
        int d2 = n % 16;
        return HEX_DIGITS[d1] + HEX_DIGITS[d2];
    }
    public static String MD5Encode(String origin, String charsetname) {
        String resultString = null;
        try {
            resultString = new String(origin);
            MessageDigest md = MessageDigest.getInstance("MD5");
            if (charsetname == null || "".equals(charsetname)) {
                resultString = byteArrayToHexString(md.digest(resultString.getBytes()));
            } else {
                resultString = byteArrayToHexString(md.digest(resultString.getBytes(charsetname)));
            }
        } catch (Exception exception) {
        }
        return resultString;
    }
}

+ 27 - 0
svr/svr-cloud-care/src/main/java/com/yihu/jw/care/util/RequestTrustManager.java

@ -0,0 +1,27 @@
package com.yihu.jw.care.util;
import javax.net.ssl.X509TrustManager;
import java.security.cert.CertificateException;
import java.security.cert.X509Certificate;
/**
 * @author yeshijie
 * @version 1.0
 * @date 2021/06/28 10:20
 */
public class RequestTrustManager implements X509TrustManager {
    @Override
    public void checkClientTrusted(X509Certificate[] x509Certificates, String s) throws CertificateException {
    }
    @Override
    public void checkServerTrusted(X509Certificate[] x509Certificates, String s) throws CertificateException {
    }
    @Override
    public X509Certificate[] getAcceptedIssuers() {
        return new X509Certificate[0];
    }
}

+ 100 - 0
svr/svr-cloud-care/src/main/java/com/yihu/jw/care/util/WxpayUtil.java

@ -0,0 +1,100 @@
package com.yihu.jw.care.util;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.util.*;
/**
 * 微信支付工具类
 *
 * @author yeshijei
 * @version 1.0
 * @date 2021/06/28 18:21
 */
public class WxpayUtil {
    private static final Logger LOGGER = LoggerFactory.getLogger(WxpayUtil.class);
    private static final String STR_CHARS = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789";
    /**
     * 创建签名
     * 创建md5摘要,规则是:按参数名称a-z排序,遇到空值的参数不参加签名。
     *
     * @param parameters
     * @return
     */
    public static String createSign(SortedMap<String, String> parameters, String key) {
        StringBuffer sb = new StringBuffer();
        Set es = parameters.entrySet();
        Iterator it = es.iterator();
        while (it.hasNext()) {
            Map.Entry entry = (Map.Entry) it.next();
            String k = (String) entry.getKey();
            Object v = entry.getValue();
            if (null != v && !"".equals(v) && !"sign".equals(k) && !"key".equals(k)) {
                sb.append(k + "=" + v + "&");
            }
        }
        sb.append("key=" + key);
        return MD5Util.MD5Encode(sb.toString(), "UTF-8").toUpperCase();
    }
    /**
     * 创建自定义长度随机字符串
     *
     * @param length
     * @return java.lang.String
     */
    public static String createNoncestr(int length) {
        String res = "";
        for (int i = 0; i < length; i++) {
            Random rd = new Random();
            res += STR_CHARS.indexOf(rd.nextInt(STR_CHARS.length() - 1));
        }
        return res;
    }
    /**
     * 创建固定长度随机字符串
     *
     * @return java.lang.String
     */
    public static String createNoncestr() {
        String res = "";
        for (int i = 0; i < 16; i++) {
            Random rd = new Random();
            res += STR_CHARS.charAt(rd.nextInt(STR_CHARS.length() - 1));
        }
        return res;
    }
    public static String getNonceStr() {
        Random random = new Random();
        return MD5Util.MD5Encode(String.valueOf(random.nextInt(10000)), "UTF-8");
    }
    public static String getTimeStamp() {
        return String.valueOf(System.currentTimeMillis() / 1000);
    }
    public static void main(String[] args) {
        System.out.println(UUID.randomUUID());
        System.out.println(getNonceStr());
    }
    /**
     * 创建统一下单
     *
     * @param parameters
     * @return java.lang.String
     */
    public static String createUnifiedorder(SortedMap<String, String> parameters) {
        String outputStr = XMLUtil.mapToXml(parameters);
        LOGGER.info("创建统一下单xml" + outputStr);
        return HttpsUtil.httpsRequest("https://api.mch.weixin.qq.com/pay/unifiedorder", "POST", outputStr);
    }
}

+ 173 - 0
svr/svr-cloud-care/src/main/java/com/yihu/jw/care/util/XMLUtil.java

@ -0,0 +1,173 @@
package com.yihu.jw.care.util;
import com.google.common.collect.Maps;
import org.jdom2.Document;
import org.jdom2.Element;
import org.jdom2.JDOMException;
import org.jdom2.input.SAXBuilder;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import javax.servlet.ServletInputStream;
import javax.servlet.http.HttpServletRequest;
import java.io.ByteArrayInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.util.*;
/**
 * xml工具类
 *
 * @author yeshijie
 * @version 1.0
 * @date 2021/06/26 10:05
 */
public class XMLUtil {
    private static final Logger LOGGER = LoggerFactory.getLogger(XMLUtil.class);
    /**
     * 将请求参数转换为xml格式的string
     *
     * @param parameters
     * @return java.lang.String
     */
    public static String mapToXml(Map<String, String> parameters) {
        StringBuffer sb = new StringBuffer();
        sb.append("<xml>");
        Set<Map.Entry<String, String>> es = parameters.entrySet();
        Iterator<Map.Entry<String, String>> it = es.iterator();
        while (it.hasNext()) {
            Map.Entry<String, String> entry = it.next();
            if ("attach".equalsIgnoreCase(entry.getKey()) || "body".equalsIgnoreCase(entry.getKey())) {
                sb.append("<" + entry.getKey() + ">" + "<![CDATA[" + entry.getValue() + "]]></" + entry.getKey() + ">");
            } else if ("sign".equalsIgnoreCase(entry.getKey())) {
                continue;
            } else {
                sb.append("<" + entry.getKey() + ">" + entry.getValue() + "</" + entry.getKey() + ">");
            }
        }
        if (parameters.containsKey("sign")) {
            sb.append("<" + "sign" + ">" + parameters.get("sign") + "</" + "sign" + ">");
        }
        sb.append("</xml>");
        return sb.toString();
    }
    /**
     * 返回给微信的参数
     *
     * @param returnCode 返回编码
     * @param returnMsg  返回信息
     * @return
     */
    public static String setXML(String returnCode, String returnMsg) {
        return "<xml><return_code><![CDATA[" + returnCode
                + "]]></return_code><return_msg><![CDATA[" + returnMsg
                + "]]></return_msg></xml>";
    }
    /**
     * 解析request流对象InputStream
     * 解析xml,返回第一级元素键值对。如果第一级元素有子节点,则此节点的值是子节点的xml数据。
     *
     * @throws JDOMException
     * @throws IOException
     */
    @SuppressWarnings("unchecked")
    public static Map<String, String> doXMLParse(HttpServletRequest request) throws JDOMException, IOException {
        Map<String, String> m = Maps.newHashMap();
        SAXBuilder builder = new SAXBuilder();
        ServletInputStream in = request.getInputStream();
        Document doc = builder.build(in);
        Element root = doc.getRootElement();
        List<Element> list = root.getChildren();
        Iterator<Element> it = list.iterator();
        while (it.hasNext()) {
            Element e = it.next();
            String k = e.getName();
            String v = "";
            List children = e.getChildren();
            if (children.isEmpty()) {
                v = e.getTextNormalize();
            } else {
                v = XMLUtil.getChildrenText(children);
            }
            m.put(k, v);
        }
        //关闭流
        in.close();
        return m;
    }
    /**
     * 解析String类型的xml流对象InputStream
     * 解析xml,返回第一级元素键值对。如果第一级元素有子节点,则此节点的值是子节点的xml数据。
     *
     * @param strxml
     * @return
     * @throws JDOMException
     * @throws IOException
     */
    public static Map<String, String> doXMLParse(String strxml) throws JDOMException, IOException {
        if (null == strxml || "".equals(strxml)) {
            return null;
        }
        Map<String, String> m = Maps.newHashMap();
        InputStream in = new ByteArrayInputStream(strxml.getBytes("UTF-8"));
        SAXBuilder builder = new SAXBuilder();
        Document doc = builder.build(in);
        Element root = doc.getRootElement();
        List list = root.getChildren();
        Iterator it = list.iterator();
        while (it.hasNext()) {
            Element e = (Element) it.next();
            String k = e.getName();
            String v = "";
            List children = e.getChildren();
            if (children.isEmpty()) {
                v = e.getTextNormalize();
            } else {
                v = XMLUtil.getChildrenText(children);
            }
            m.put(k, v);
        }
        //关闭流
        in.close();
        return m;
    }
    /**
     * 获取子结点的xml
     *
     * @param children
     * @return String
     */
    public static String getChildrenText(List children) {
        StringBuffer sb = new StringBuffer();
        if (!children.isEmpty()) {
            Iterator it = children.iterator();
            while (it.hasNext()) {
                Element e = (Element) it.next();
                String name = e.getName();
                String value = e.getTextNormalize();
                List list = e.getChildren();
                sb.append("<" + name + ">");
                if (!list.isEmpty()) {
                    sb.append(XMLUtil.getChildrenText(list));
                }
                sb.append(value);
                sb.append("</" + name + ">");
            }
        }
        return sb.toString();
    }
}

+ 10 - 2
svr/svr-cloud-care/src/main/resources/application.yml

@ -132,6 +132,8 @@ hospital:
wechat:
  appId: wxd03f859efdf0873d
  appSecret: 2935b54b53a957d9516c920a544f2537
  apiKey: zhongjianxinlianxiamenkejiyouxia
  mchId: 1611059985
  wechat_token: 27eb3bb24f149a7760cf1bb154b08040
  wechat_base_url: http%3a%2f%2fweixin.xmtyw.cn%2fwlyy-dev
  accId: gh_ffd64560fb21
@ -228,6 +230,8 @@ hospital:
wechat:
  appId: wxd03f859efdf0873d
  appSecret: 2935b54b53a957d9516c920a544f2537
  apiKey: zhongjianxinlianxiamenkejiyouxia
  mchId: 1611059985
  wechat_token: 27eb3bb24f149a7760cf1bb154b08040
  wechat_base_url: http%3a%2f%2fweixin.xmtyw.cn%2fwlyy-dev
  accId: gh_ffd64560fb21
@ -332,6 +336,8 @@ hospital:
wechat:
  appId: wxd03f859efdf0873d
  appSecret: 2935b54b53a957d9516c920a544f2537
  apiKey: zhongjianxinlianxiamenkejiyouxia
  mchId: 1611059985
  wechat_token: 27eb3bb24f149a7760cf1bb154b08040
  wechat_base_url: http%3a%2f%2fweixin.xmtyw.cn%2fwlyy-dev
  accId: gh_ffd64560fb21
@ -416,7 +422,7 @@ spring:
    port: 6379  # Redis server port.
    password: Kb6wKDQP1W4
fastDFS:
  fastdfs_file_url: http://10.18.43.40:8888/
  fastdfs_file_url: https://zhyzh.hzxc.gov.cn/fastdfs/
fast-dfs:
  tracker-server: 10.18.43.40:22122 #服务器地址
# 短信验证码发送的客户端标识,居民端
@ -439,8 +445,10 @@ hospital:
wechat:
  appId: wx2c55f5b7b2f3cb56
  appSecret: 0dd9927e58125ad5f0efb9299860d145
  apiKey: zhongjianxinlianxiamenkejiyouxia
  mchId: 1611059985
  wechat_token: 27eb3bb24f149a7760cf1bb154b08041
  wechat_base_url: https%3A%2F%2Fzhyzh.hzxc.gov.cn%2Fcityihealth%2FcloudCare%2F
  wechat_base_url: https%3A%2F%2Fzhyzh.hzxc.gov.cn%2FcloudCare%2F
  accId: gh_da06ed9e5751
  id: hz_yyyzh_wx  # base库中,wx_wechat 的id字段
  flag: true #演示环境  true走Mysql数据库  false走Oracle

+ 298 - 0
svr/svr-cloud-care/src/main/resources/wechat/README.md

@ -0,0 +1,298 @@
微信支付 Java SDK
------
对[微信支付开发者文档](https://pay.weixin.qq.com/wiki/doc/api/index.html)中给出的API进行了封装。
com.github.wxpay.sdk.WXPay类下提供了对应的方法:
|方法名 | 说明 |
|--------|--------|
|microPay| 刷卡支付 |
|unifiedOrder | 统一下单|
|orderQuery | 查询订单 |
|reverse | 撤销订单 |
|closeOrder|关闭订单|
|refund|申请退款|
|refundQuery|查询退款|
|downloadBill|下载对账单|
|report|交易保障|
|shortUrl|转换短链接|
|authCodeToOpenid|授权码查询openid|
* 注意:
* 证书文件不能放在web服务器虚拟目录,应放在有访问权限控制的目录中,防止被他人下载
* 建议将证书文件名改为复杂且不容易猜测的文件名
* 商户服务器要做好病毒和木马防护工作,不被非法侵入者窃取证书文件
* 请妥善保管商户支付密钥、公众帐号SECRET,避免密钥泄露
* 参数为`Map<String, String>`对象,返回类型也是`Map<String, String>`
* 方法内部会将参数会转换成含有`appid`、`mch_id`、`nonce_str`、`sign\_type`和`sign`的XML
* 可选HMAC-SHA256算法和MD5算法签名
* 通过HTTPS请求得到返回数据后会对其做必要的处理(例如验证签名,签名错误则抛出异常)
* 对于downloadBill,无论是否成功都返回Map,且都含有`return_code`和`return_msg`,若成功,其中`return_code`为`SUCCESS`,另外`data`对应对账单数据
## 示例
配置类MyConfig:
```java
import com.github.wxpay.sdk.WXPayConfig;
import java.io.*;
public class MyConfig implements WXPayConfig{
    private byte[] certData;
    public MyConfig() throws Exception {
        String certPath = "/path/to/apiclient_cert.p12";
        File file = new File(certPath);
        InputStream certStream = new FileInputStream(file);
        this.certData = new byte[(int) file.length()];
        certStream.read(this.certData);
        certStream.close();
    }
    public String getAppID() {
        return "wx8888888888888888";
    }
    public String getMchID() {
        return "12888888";
    }
    public String getKey() {
        return "88888888888888888888888888888888";
    }
    public InputStream getCertStream() {
        ByteArrayInputStream certBis = new ByteArrayInputStream(this.certData);
        return certBis;
    }
    public int getHttpConnectTimeoutMs() {
        return 8000;
    }
    public int getHttpReadTimeoutMs() {
        return 10000;
    }
}
```
统一下单:
```java
import com.github.wxpay.sdk.WXPay;
import java.util.HashMap;
import java.util.Map;
public class WXPayExample {
    public static void main(String[] args) throws Exception {
        MyConfig config = new MyConfig();
        WXPay wxpay = new WXPay(config);
        Map<String, String> data = new HashMap<String, String>();
        data.put("body", "腾讯充值中心-QQ会员充值");
        data.put("out_trade_no", "2016090910595900000012");
        data.put("device_info", "");
        data.put("fee_type", "CNY");
        data.put("total_fee", "1");
        data.put("spbill_create_ip", "123.12.12.123");
        data.put("notify_url", "http://www.example.com/wxpay/notify");
        data.put("trade_type", "NATIVE");  // 此处指定为扫码支付
        data.put("product_id", "12");
        try {
            Map<String, String> resp = wxpay.unifiedOrder(data);
            System.out.println(resp);
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
}
```
订单查询:
```java
import com.github.wxpay.sdk.WXPay;
import java.util.HashMap;
import java.util.Map;
public class WXPayExample {
    public static void main(String[] args) throws Exception {
        MyConfig config = new MyConfig();
        WXPay wxpay = new WXPay(config);
        Map<String, String> data = new HashMap<String, String>();
        data.put("out_trade_no", "2016090910595900000012");
        try {
            Map<String, String> resp = wxpay.orderQuery(data);
            System.out.println(resp);
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
}
```
退款查询:
```java
import com.github.wxpay.sdk.WXPay;
import java.util.HashMap;
import java.util.Map;
public class WXPayExample {
    public static void main(String[] args) throws Exception {
        MyConfig config = new MyConfig();
        WXPay wxpay = new WXPay(config);
        Map<String, String> data = new HashMap<String, String>();
        data.put("out_trade_no", "2016090910595900000012");
        try {
            Map<String, String> resp = wxpay.refundQuery(data);
            System.out.println(resp);
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
}
```
下载对账单:
```java
import com.github.wxpay.sdk.WXPay;
import java.util.HashMap;
import java.util.Map;
public class WXPayExample {
    public static void main(String[] args) throws Exception {
        MyConfig config = new MyConfig();
        WXPay wxpay = new WXPay(config);
        Map<String, String> data = new HashMap<String, String>();
        data.put("bill_date", "20140603");
        data.put("bill_type", "ALL");
        try {
            Map<String, String> resp = wxpay.downloadBill(data);
            System.out.println(resp);
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
}
```
其他API的使用和上面类似。
暂时不支持下载压缩格式的对账单,但可以使用该SDK生成请求用的XML数据:
```java
import com.github.wxpay.sdk.WXPay;
import com.github.wxpay.sdk.WXPayUtil;
import java.util.HashMap;
import java.util.Map;
public class WXPayExample {
    public static void main(String[] args) throws Exception {
        MyConfig config = new MyConfig();
        WXPay wxpay = new WXPay(config);
        Map<String, String> data = new HashMap<String, String>();
        data.put("bill_date", "20140603");
        data.put("bill_type", "ALL");
        data.put("tar_type", "GZIP");
        try {
            data = wxpay.fillRequestData(data);
            System.out.println(WXPayUtil.mapToXml(data));
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
}
```
收到支付结果通知时,需要验证签名,可以这样做:
```java
import com.github.wxpay.sdk.WXPay;
import com.github.wxpay.sdk.WXPayUtil;
import java.util.Map;
public class WXPayExample {
    public static void main(String[] args) throws Exception {
        String notifyData = "...."; // 支付结果通知的xml格式数据
        MyConfig config = new MyConfig();
        WXPay wxpay = new WXPay(config);
        Map<String, String> notifyMap = WXPayUtil.xmlToMap(notifyData);  // 转换成map
        if (wxpay.isPayResultNotifySignatureValid(notifyMap)) {
            // 签名正确
            // 进行处理。
            // 注意特殊情况:订单已经退款,但收到了支付结果成功的通知,不应把商户侧订单状态从退款改成支付成功
        }
        else {
            // 签名错误,如果数据里没有sign字段,也认为是签名错误
        }
    }
}
```
HTTPS请求可选HMAC-SHA256算法和MD5算法签名:
```
import com.github.wxpay.sdk.WXPay;
import com.github.wxpay.sdk.WXPayConstants;
public class WXPayExample {
    public static void main(String[] args) throws Exception {
        MyConfig config = new MyConfig();
        WXPay wxpay = new WXPay(config, WXPayConstants.SignType.HMACSHA256);
        // ......
    }
}
```
若需要使用sandbox环境:
```
import com.github.wxpay.sdk.WXPay;
import com.github.wxpay.sdk.WXPayConstants;
public class WXPayExample {
    public static void main(String[] args) throws Exception {
        MyConfig config = new MyConfig();
        WXPay wxpay = new WXPay(config, WXPayConstants.SignType.MD5, true);
        // ......
    }
}
```

BIN
svr/svr-cloud-care/src/main/resources/wechat/apiclient_cert.p12


+ 24 - 0
svr/svr-cloud-care/src/main/resources/wechat/apiclient_cert.pem

@ -0,0 +1,24 @@
-----BEGIN CERTIFICATE-----
MIID9jCCAt6gAwIBAgIUP5vgF5jYeVCwLihSnKh9fiuL3JAwDQYJKoZIhvcNAQEL
BQAwXjELMAkGA1UEBhMCQ04xEzARBgNVBAoTClRlbnBheS5jb20xHTAbBgNVBAsT
FFRlbnBheS5jb20gQ0EgQ2VudGVyMRswGQYDVQQDExJUZW5wYXkuY29tIFJvb3Qg
Q0EwHhcNMjEwNjI4MDg0NzEwWhcNMjYwNjI3MDg0NzEwWjCBhzETMBEGA1UEAwwK
MTYxMTA1OTk4NTEbMBkGA1UECgwS5b6u5L+h5ZWG5oi357O757ufMTMwMQYDVQQL
DCrkvJflgaXkv6HogZTvvIjmna3lt57vvInnp5HmioDmnInpmZDlhazlj7gxCzAJ
BgNVBAYMAkNOMREwDwYDVQQHDAhTaGVuWmhlbjCCASIwDQYJKoZIhvcNAQEBBQAD
ggEPADCCAQoCggEBAMPDQiBC4iyBKmyWmBVRqQMOqYET0CK4P3zdxRvvHe6TbC+B
DbzT3NNbCBeqJ3qS8p4c3SptzxTr0P7q3ixNs7Lvl8oJLeYm+vi9wwF2sqzOBYGn
0i9snmKBWCq0KtNaMz8Y86XKGwdmuUXgHEp88foad12KYJPdp1MuonBv6DSs4KYK
nhTy24fpyFFSlvVqMHAHFUCiUYZIxvv5vkzgyS5c5aQeMCRV+xVoN88uAQNAiCli
+cBoDS5fpH2ahqhupHEUEj1iQunI9BcAOgukFszaL9l/L/LSvA7kZQKtZbO69U3r
wYwJ9inJw7warp6hqJiaL5eFuG5N56Y5uaVxD6cCAwEAAaOBgTB/MAkGA1UdEwQC
MAAwCwYDVR0PBAQDAgTwMGUGA1UdHwReMFwwWqBYoFaGVGh0dHA6Ly9ldmNhLml0
cnVzLmNvbS5jbi9wdWJsaWMvaXRydXNjcmw/Q0E9MUJENDIyMEU1MERCQzA0QjA2
QUQzOTc1NDk4NDZDMDFDM0U4RUJEMjANBgkqhkiG9w0BAQsFAAOCAQEAXhesamB9
4zIxgIEBWZNgSL0tL8Q/HoPfDCssK4BPz7fREx+fGPMZ8K3AVPaRuT1kuXABm/XA
qHVLkUPGtVJvu/DpQSWz9OESD35UEvYhm42V1drj5eMjuwQS7JXMLaH5WaUwR8/p
Dx664gbOgXbUEjVvoHDuqa6fiIGrqtGNNMDbscwK0iL2mUpk34UunuNZUkZdkfs3
ZNlzEfRHQZ6TNZTbNakTRZjG3oVnT2/ZEr+nIVe75ikm22eoTENio7wNoNdv+jDo
LLgoIhqIY5b09jZG1qe3YIBIaBoK3FIuuBFsa03TBvj7QuBJ4JdAYs1f+babAeAJ
c0RBy1fNJgScaA==
-----END CERTIFICATE-----

+ 28 - 0
svr/svr-cloud-care/src/main/resources/wechat/apiclient_key.pem

@ -0,0 +1,28 @@
-----BEGIN PRIVATE KEY-----
MIIEvgIBADANBgkqhkiG9w0BAQEFAASCBKgwggSkAgEAAoIBAQDDw0IgQuIsgSps
lpgVUakDDqmBE9AiuD983cUb7x3uk2wvgQ2809zTWwgXqid6kvKeHN0qbc8U69D+
6t4sTbOy75fKCS3mJvr4vcMBdrKszgWBp9IvbJ5igVgqtCrTWjM/GPOlyhsHZrlF
4BxKfPH6GnddimCT3adTLqJwb+g0rOCmCp4U8tuH6chRUpb1ajBwBxVAolGGSMb7
+b5M4MkuXOWkHjAkVfsVaDfPLgEDQIgpYvnAaA0uX6R9moaobqRxFBI9YkLpyPQX
ADoLpBbM2i/Zfy/y0rwO5GUCrWWzuvVN68GMCfYpycO8Gq6eoaiYmi+XhbhuTeem
ObmlcQ+nAgMBAAECggEAd4MbOarbfaQVjFmb21gRQKaQ4RaBeNDXIZoaneUrdt1V
rOKyylbld7sZg6kDlRdlOxYQB7kmNXWKEDa/EHkXfeQ73MIh3WJq0bS3+orGpizY
u8EC1qUPRMAGXXvEsWdd5eWLyelK+wfBkGEzpF4HNFM4EElMkLk/T88mqFIJhy35
xks6HZ0gAtMG5Y8ze8iAtvQfiCr51K/njTK6/LdO/+NZ2n0J6kD62T63OZcIcIYD
oYuFfUY58rqfMHSJ6LXXqVtF+mtUeL3DSwYQoaSCZJ6sLuZLqdWK3dOP1DUVQEdx
E+uW3hzT4ViB263rJvEPZxgfvQQ79ZHZAGH6RsJ5wQKBgQDu1uJRU6O7d7Ifi1Dg
1Y5l3gBIz+d776lg2UP9foDYHYFtW8F51vmnwR2Nx2wsFZTWTz1p1EVKxyOhSPz3
tTnzKlLy/zA+JgJtkTAlWbwfW8ixr3stVQxbrk1QcTVT55T9vRqLfdGLwrACZGkL
tGiJVcvrOdGtv7FKOrcAO04sNwKBgQDR1AoVfj7z1oKPjBZ2Dq9yexBQ+ZaekHTP
R6PFv89kDNzKIcy4TZKNIYePp3Wm9xLMLY/LbCTc8A3eJuLgV6zTk7IQgMTOFWRZ
I+VTY2qBql2XG5p4rcNgpmtoNaiwIuf7xGJSY7sFE5lYLWBVPuKqK1OeABUCd8DM
9WcXffDgEQKBgGMsbStR7KHyUM9SXRIO+yMHbNzPH5LR8GYbsWS4O64BinWrbQo3
ntDummP908f2aigXHSwtjVxAlmXpVclRwi9bergWCKU1yTpP2EsaGMh4pzxI3n/z
Wb9UAByP9ZHSjoZSGIylgPZksAs+QHQwxFuKebNB/fQErgxhlw2Mkqg/AoGBAL8e
IFU1WUel0ePH2EmN1LY0a0cmHs+sigimmwAqVk8t/AjMQnh4h4yuxpfNEreSgfeh
ZEEH7oeiyy7WQn3Ovec0ttKbRybiizU6Ic4TVlZmg7p39PoIY1XsHxabEVvlX2GN
nXSnzBeyo1CSfBUJI1GWByJ5tqk5xE2rFExsdPLRAoGBAM087YnVLfzKPMiE8nc+
ocTDdnBwBFQseYdfJl+dGoE8IBL+7GGQsT5lCYGbXk5iYOnboyOGfPPqUA/jUZU3
tN1uJA267gQJl8qrghDBeiWl2KkrJz0/BYw+5RR9oUwWSf17N48kiwjod+1lPyaQ
70ldmbdfITOESSvdRZ+hbAQ0
-----END PRIVATE KEY-----

+ 18 - 0
svr/svr-cloud-care/src/main/resources/wechat/证书使用说明.txt

@ -0,0 +1,18 @@
欢迎使用微信支付!
附件中的三份文件(证书pkcs12格式、证书pem格式、证书密钥pem格式),为接口中强制要求时需携带的证书文件。
证书属于敏感信息,请妥善保管不要泄露和被他人复制。
不同开发语言下的证书格式不同,以下为说明指引:
    证书pkcs12格式(apiclient_cert.p12)
        包含了私钥信息的证书文件,为p12(pfx)格式,由微信支付签发给您用来标识和界定您的身份
        部分安全性要求较高的API需要使用该证书来确认您的调用身份
        windows上可以直接双击导入系统,导入过程中会提示输入证书密码,证书密码默认为您的商户号(如:1900006031)
    证书pem格式(apiclient_cert.pem)
        从apiclient_cert.p12中导出证书部分的文件,为pem格式,请妥善保管不要泄漏和被他人复制
        部分开发语言和环境,不能直接使用p12文件,而需要使用pem,所以为了方便您使用,已为您直接提供
        您也可以使用openssl命令来自己导出:openssl pkcs12 -clcerts -nokeys -in apiclient_cert.p12 -out apiclient_cert.pem
    证书密钥pem格式(apiclient_key.pem)
        从apiclient_cert.p12中导出密钥部分的文件,为pem格式
        部分开发语言和环境,不能直接使用p12文件,而需要使用pem,所以为了方便您使用,已为您直接提供
        您也可以使用openssl命令来自己导出:openssl pkcs12 -nocerts -in apiclient_cert.p12 -out apiclient_key.pem
备注说明:  
        由于绝大部分操作系统已内置了微信支付服务器证书的根CA证书,  2018年3月6日后, 不再提供CA证书文件(rootca.pem)下载