소스 검색

feature: 线下就诊下载与核算缴费下载

wuyongyi 2 년 전
부모
커밋
988243ff0b
29개의 변경된 파일2995개의 추가작업 그리고 14개의 파일을 삭제
  1. 25 0
      src/main/java/com/ywt/mg/core/utils/DateUtil.java
  2. 25 0
      src/main/java/com/ywt/mg/domain/models/ConstantDef.java
  3. 38 0
      src/main/java/com/ywt/mg/domain/models/enums/DeliveryMethodEnum.java
  4. 1 1
      src/main/java/com/ywt/mg/domain/models/enums/DownloadRecordStatusEnum.java
  5. 40 0
      src/main/java/com/ywt/mg/domain/models/enums/PresPaymentChannelEnum.java
  6. 47 0
      src/main/java/com/ywt/mg/domain/models/enums/PrescriptionInfoExtStatusEnum.java
  7. 41 0
      src/main/java/com/ywt/mg/domain/models/enums/PrescriptionInfoSourceEnum.java
  8. 45 0
      src/main/java/com/ywt/mg/domain/models/enums/PrescriptionInfoStatusEnum.java
  9. 2 2
      src/main/java/com/ywt/mg/domain/models/enums/TerminalEnum.java
  10. 65 0
      src/main/java/com/ywt/mg/domain/ywtDrugEntities/PharmacyRepository.java
  11. 841 0
      src/main/java/com/ywt/mg/domain/ywtDrugEntities/PrescriptionInfo.java
  12. 48 0
      src/main/java/com/ywt/mg/domain/ywtDrugEntities/PrescriptionInfoRepository.java
  13. 207 0
      src/main/java/com/ywt/mg/params/natOrder/NatOrderListRequest.java
  14. 275 0
      src/main/java/com/ywt/mg/params/prescription/QueryPrescriptionListRequest.java
  15. 275 0
      src/main/java/com/ywt/mg/services/CommonServices.java
  16. 7 5
      src/main/java/com/ywt/mg/services/DepositService.java
  17. 1 1
      src/main/java/com/ywt/mg/services/DownloadRecordService.java
  18. 236 0
      src/main/java/com/ywt/mg/services/NatOrderService.java
  19. 2 1
      src/main/java/com/ywt/mg/services/OutpatientOrderService.java
  20. 110 0
      src/main/java/com/ywt/mg/services/PharmacyCacheService.java
  21. 452 0
      src/main/java/com/ywt/mg/services/PrescriptionServices.java
  22. 4 4
      src/main/java/com/ywt/mg/services/RegisteredOrderService.java
  23. 1 0
      src/main/java/com/ywt/mg/web/controllers/DepositController.java
  24. 71 0
      src/main/java/com/ywt/mg/web/controllers/NatOrderController.java
  25. 1 0
      src/main/java/com/ywt/mg/web/controllers/RegisteredOrderController.java
  26. 1 0
      src/main/java/com/ywt/mg/web/controllers/hospital/HospDepositController.java
  27. 69 0
      src/main/java/com/ywt/mg/web/controllers/hospital/HospNatOrderController.java
  28. 64 0
      src/main/java/com/ywt/mg/web/controllers/hospital/HospOfflineController.java
  29. 1 0
      src/main/java/com/ywt/mg/web/controllers/hospital/HospRegisteredOrderController.java

+ 25 - 0
src/main/java/com/ywt/mg/core/utils/DateUtil.java

@@ -190,4 +190,29 @@ public class DateUtil {
         return sdf.format(date);
     }
 
+    /**
+     * 得到相对时间
+     *
+     * @param date 传入的时间
+     * @param num  前几天,或者后几天
+     * @return 改变之后的时间
+     */
+    public static Date getRelativeDate(Date date, int num) {
+        Calendar calendar = Calendar.getInstance();
+        calendar.setTime(date);
+        calendar.add(Calendar.DATE, num);
+        return calendar.getTime();
+    }
+
+    /**
+     * 得到相对时间
+     *
+     * @param num 天数,大于0表示几天之后的时间,小于0表示几天之前的时间
+     * @return 时间
+     */
+    public static Date getRelativeDate(int num) {
+        return getRelativeDate(new Date(), num);
+    }
+
+
 }

+ 25 - 0
src/main/java/com/ywt/mg/domain/models/ConstantDef.java

@@ -95,4 +95,29 @@ public class ConstantDef {
      * excel的后缀格式
      */
     public static final String EXCEL_SUFFIX_FORMAT = ".xls";
+
+    /**
+     * 过期天数,负号表示时间往前移
+     */
+    public static final int OVERDUE_DAY_NUM = -3;
+
+    /**
+     * 对应ywt_drug库pharmacy表id=1的广州医科大学附属第三医院生殖药房ID
+     */
+    public static final int GUANGSAN_PHARMACY_ID = 1;
+
+    /**
+     * 对应ywt_drug库pharmacy表id=2的南方医院太和分院的药房ID
+     */
+    public static final int TAIHE_PHARMACY_ID = 2;
+
+    /**
+     * 对应ywt_drug库pharmacy表id=10的国控大药房的药房ID
+     */
+    public static final int GK_PHARMACY_ID = 10;
+
+    /**
+     * 南方医科大学南方医院白云分院药房
+     */
+    public static final int NFBY_PHARMACY_ID = 11;
 }

+ 38 - 0
src/main/java/com/ywt/mg/domain/models/enums/DeliveryMethodEnum.java

@@ -0,0 +1,38 @@
+package com.ywt.mg.domain.models.enums;
+
+/**
+ * 取药方式
+ */
+public enum DeliveryMethodEnum {
+    UNKNOWN("", 0),
+    HomeDelivery("快递到家", 1),
+    SelfPickUp("自行取药", 2);
+
+    private final String displayName;
+
+    private final int value;
+
+    DeliveryMethodEnum(String displayName, int value) {
+        this.displayName = displayName;
+        this.value = value;
+    }
+
+    public String getDisplayName() {
+        return displayName;
+    }
+
+    public int getValue() {
+        return value;
+    }
+
+    public static DeliveryMethodEnum valueOf(int value) {
+        switch (value) {
+            case 1:
+                return HomeDelivery;
+            case 2:
+                return SelfPickUp;
+            default:
+                return UNKNOWN;
+        }
+    }
+}

+ 1 - 1
src/main/java/com/ywt/mg/domain/models/enums/DownloadRecordStatusEnum.java

@@ -7,7 +7,7 @@ public enum DownloadRecordStatusEnum {
     /**
      * 上传状态:0-下载中,1-下载成功,2-下载失败
      */
-    Default("下载中", 0),
+    Default("获取中", 0),
     SUCCESS("下载成功", 1),
     FAILURE("下载失败", 2);
 

+ 40 - 0
src/main/java/com/ywt/mg/domain/models/enums/PresPaymentChannelEnum.java

@@ -0,0 +1,40 @@
+package com.ywt.mg.domain.models.enums;
+
+public enum PresPaymentChannelEnum {
+
+    WeChat("微信", 1),
+    AliPay("支付宝", 2),
+    Cash("现金", 3),          //现场支付
+    MedicalCard("诊疗卡", 4),
+    POS("pos机", 5),
+    FREE("无须支付", 6),
+    MedicalInsurance("医保", 7),
+    ICBC("工行", 8),
+    UNKNOWN("", 0);
+
+    private final String displayName;
+
+    private final int value;
+
+    PresPaymentChannelEnum(String displayName, int value) {
+        this.displayName = displayName;
+        this.value = value;
+    }
+
+    public String getDisplayName() {
+        return displayName;
+    }
+
+    public int getValue() {
+        return value;
+    }
+
+    public static PresPaymentChannelEnum valueOf(int value) {
+        for (PresPaymentChannelEnum item : PresPaymentChannelEnum.values()) {
+            if (item.getValue() == value) {
+                return item;
+            }
+        }
+        return UNKNOWN;
+    }
+}

+ 47 - 0
src/main/java/com/ywt/mg/domain/models/enums/PrescriptionInfoExtStatusEnum.java

@@ -0,0 +1,47 @@
+package com.ywt.mg.domain.models.enums;
+
+/**
+ * 处方单扩展状态(位运算)
+ */
+public enum PrescriptionInfoExtStatusEnum {
+
+    IsCheckIn("已报到", 1),                 // 1
+    IsSendOut("已发药", 1 << 1),            // 2
+    IsPrint("已打印发票", 1 << 2),          // 4
+    OtherFee("是否有其它付费", 1 << 3),      // 8
+    PrintInjection("打印注射单", 1 << 4),   // 16
+    PresNoPass("不通过", 1 << 5),           // 32
+    Evaluate("已评价", 1 << 6),             // 64
+    ExistInjection("是否有注射药品", 1 << 7);// 128
+
+    private final String displayName;
+
+    private final int value;
+
+    PrescriptionInfoExtStatusEnum(String displayName, int value) {
+        this.displayName = displayName;
+        this.value = value;
+    }
+
+    public String getDisplayName() {
+        return displayName;
+    }
+
+    public int getValue() {
+        return value;
+    }
+
+    public static String getDisplayName(int value) {
+        if ((value & PresNoPass.value) == PresNoPass.value) {
+            return PresNoPass.displayName;
+        } else if ((value & IsPrint.value) == IsPrint.value) {
+            return IsPrint.displayName;
+        } else if ((value & IsSendOut.value) == IsSendOut.value) {
+            return IsSendOut.displayName;
+        } else if ((value & IsCheckIn.value) == IsCheckIn.value) {
+            return IsCheckIn.displayName;
+        } else {
+            return "";
+        }
+    }
+}

+ 41 - 0
src/main/java/com/ywt/mg/domain/models/enums/PrescriptionInfoSourceEnum.java

@@ -0,0 +1,41 @@
+package com.ywt.mg.domain.models.enums;
+
+public enum PrescriptionInfoSourceEnum {
+
+    //    GY3Y("广州医科大学附属第三医院", 1),
+//    APP("APP", 2),
+//    TH_DOCTOR_WX("太和医生端公众号", 12),
+    GY3Y("广州医科大学附属第三医院", 1),
+    PLATFORM("平台系统", 2),
+    PC("PC", 3),
+    NFYYTHFY("南方医院太和分院", 4),
+    NFYYBYFY("南方医院白云分院", 5),
+    UNKONWN("",0);
+
+
+    private final String displayName;
+
+    private final int value;
+
+    PrescriptionInfoSourceEnum(String displayName, int value) {
+        this.displayName = displayName;
+        this.value = value;
+    }
+
+    public String getDisplayName() {
+        return displayName;
+    }
+
+    public int getValue() {
+        return value;
+    }
+
+    public static PrescriptionInfoSourceEnum getSource(int value) {
+        for (PrescriptionInfoSourceEnum e : PrescriptionInfoSourceEnum.values()) {
+            if (e.value == value) {
+                return e;
+            }
+        }
+        return UNKONWN;
+    }
+}

+ 45 - 0
src/main/java/com/ywt/mg/domain/models/enums/PrescriptionInfoStatusEnum.java

@@ -0,0 +1,45 @@
+package com.ywt.mg.domain.models.enums;
+
+public enum PrescriptionInfoStatusEnum {
+
+    WaitForPayment("待支付", 1),
+    Dispatching("配送中", 2),
+    Finished("已完成", 3),
+    HaveARefund("已退费", 4),
+    EXPIRED("已过期", 5),
+    UNKNOW("",0);
+
+    private final String displayName;
+
+    private final int value;
+
+    PrescriptionInfoStatusEnum(String displayName, int value) {
+        this.displayName = displayName;
+        this.value = value;
+    }
+
+    public String getDisplayName() {
+        return displayName;
+    }
+
+    public int getValue() {
+        return value;
+    }
+
+    public static PrescriptionInfoStatusEnum valueOf (int value){
+        switch (value) {
+            case 1 :
+                return WaitForPayment;
+            case 2:
+                return Dispatching;
+            case 3:
+                return Finished;
+            case 4:
+                return HaveARefund;
+            case 5:
+                return EXPIRED;
+            default:
+                return UNKNOW;
+        }
+    }
+}

+ 2 - 2
src/main/java/com/ywt/mg/domain/models/enums/TerminalEnum.java

@@ -15,7 +15,7 @@ public enum TerminalEnum {
     PatientAndroid("安卓患者版", 5),
     PatientIOS("苹果患者版", 6),
     DoctorWxOfficial("微信公众号医生版", 7),
-    TaiheWxOfficial("太和医院公众号", 8),
+    TaiheWxOfficial("南方医院太和分院公众号", 8),
     NfHealth("南方大健康", 9),
     TAI_HE_OFFICIAL("太和医院官网", 10),
     TAI_HE_INTERNET_HOSPITAL_PATIENT_MINI_PROGRAM("太和互联网医院患者端小程序版", 11),
@@ -32,7 +32,7 @@ public enum TerminalEnum {
     DOCTOR_H5("医生端H5", 17),
     YWT_CLOUD_PLATFORM_PATIENT_MINI_PROGRAM("医务通云平台患者端小程序版", 18),
     ORDER_SERVICE_MINI_PROGRAM("下单服务助手小程序", 19),
-    NF_HOSPITAL_BY_PATIENT_MINI_PROGRAM("南方医院白云分院小程序", 20),
+    NF_HOSPITAL_BY_PATIENT_MINI_PROGRAM("南方医科大学南方医院白云分院微信小程序", 20),
     NF_HOSPITAL_BY_PATIENT_WX_OFFICIAL("南方医院白云分院公众号", 21),
     NF_HOSPITAL_BY_DOCTOR_WX_OFFICIAL("南方医院白云分院医生版公众号", 22),
     NF_HOSPITAL_BY_PATIENT_MINI_PROGRAM_ZFB("南方医科大学南方医院白云分院支付宝小程序", 24),

+ 65 - 0
src/main/java/com/ywt/mg/domain/ywtDrugEntities/PharmacyRepository.java

@@ -2,7 +2,72 @@ package com.ywt.mg.domain.ywtDrugEntities;
 
 import org.springframework.data.jpa.repository.JpaRepository;
 import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
+import org.springframework.data.jpa.repository.Query;
+import org.springframework.data.repository.query.Param;
+
+import java.util.List;
 
 public interface PharmacyRepository extends JpaRepository<Pharmacy, Integer>, JpaSpecificationExecutor<Pharmacy> {
 
+    /**
+     * 得到药房list(不包括删除和不显示的)
+     * @return {@link List <Pharmacy>}
+     */
+    @Query(value = "select * from pharmacy where deleted = 0 and display = 0;", nativeQuery = true)
+    public List<Pharmacy> getPharmacyList();
+
+    /**
+     * 获取该药房及子药房的列表
+     *
+     * @param pharmacyId 药房 id
+     * @return {@link Pharmacy}
+     */
+    @Query(value = "select * from pharmacy where deleted = 0 and (id = :pId or tree_code like concat(:pId, '|%') or tree_code like concat('%|', :pId, '|%'));", nativeQuery = true)
+    List<Pharmacy> getDecendantPharmacyList(@Param("pId") int pharmacyId);
+
+    /**
+     * 判断是否存在药房名称相同的药房
+     *
+     * @param id   药房ID
+     * @param name 药房名称
+     * @return 数量
+     */
+    @Query(value = "select count(1) from pharmacy where deleted = 0 and id != ? and name = ? ;", nativeQuery = true)
+    public int checkExistName(int id, String name);
+
+    /**
+     * 根据药房ID的药房对象
+     *
+     * @param id 药房ID
+     * @return {@link Pharmacy}
+     */
+    @Query(value = "select * from pharmacy where id = ? and deleted = 0 limit 1;", nativeQuery = true)
+    Pharmacy getPharmacyById(int id);
+
+    /**
+     * 根据父类ID得到对象
+     *
+     * @param id 父类ID
+     * @return {@link Pharmacy}
+     */
+    @Query(value = "select * from pharmacy where parent_id = ? and deleted = 0 limit 1;", nativeQuery = true)
+    Pharmacy getPharmacyByParentId(int id);
+
+    /**
+     * 根据药房ID得到药房以及自药房(不包括删除和不显示的)
+     *
+     * @param id 药房ID
+     * @param id 父类ID
+     * @return {@link  List<Pharmacy>}
+     */
+    @Query(value = "select * from pharmacy where id = ? or parent_id = ? and deleted = 0;", nativeQuery = true)
+    List<Pharmacy> getPharmacyAndSonList(int id, int parentId);
+
+    /**
+     * 得到所有药房list(不包括删除的)
+     * @return {@link List<Pharmacy>}
+     */
+    @Query(value = "select * from pharmacy where deleted = 0;", nativeQuery = true)
+    public List<Pharmacy> getAllPharmacyList();
+
 }

+ 841 - 0
src/main/java/com/ywt/mg/domain/ywtDrugEntities/PrescriptionInfo.java

@@ -0,0 +1,841 @@
+package com.ywt.mg.domain.ywtDrugEntities;
+
+import javax.persistence.Column;
+import javax.persistence.Entity;
+import javax.persistence.Id;
+import javax.persistence.Table;
+import java.util.Date;
+
+@Entity
+@Table(name = "prescription_info")
+public class PrescriptionInfo {
+
+    @Id
+    private int id;
+
+    /**
+     * 业务编码
+     */
+    @Column(name = "pre_biz_no")
+    private String preBizNo;
+
+    /**
+     * 第三方编码
+     */
+    @Column(name = "biz_no_3th")
+    private String bizNo3th;
+
+    /**
+     * 医生姓名
+     */
+    @Column(name = "doctor_name")
+    private String doctorName;
+
+    /**
+     * 医生编号
+     */
+    @Column(name = "doctor_code")
+    private String doctorCode;
+
+    /**
+     * 患者姓名
+     */
+    @Column(name = "patient_name")
+    private String patientName;
+
+    /**
+     * 患者年龄
+     */
+    @Column(name = "patient_age")
+    private String patientAge;
+
+    /**
+     * 患者性别(男、女)
+     */
+    @Column(name = "patient_sex")
+    private String patientSex;
+
+    /**
+     * 患者编号
+     */
+    @Column(name = "patient_no")
+    private String patientNo;
+
+    /**
+     * 临床诊断
+     */
+    @Column(name = "diagnose")
+    private String diagnose;
+
+    /**
+     * 科室
+     */
+    @Column(name = "dept")
+    private String dept;
+
+    /**
+     * 创建时间
+     */
+    @Column(name = "create_on")
+    private Date createOn;
+
+    /**
+     * 来源
+     */
+    @Column(name = "source")
+    private Integer source;
+
+    /**
+     * 状态
+     */
+    @Column(name = "status")
+    private Integer status;
+
+    /**
+     * 总价格
+     */
+    @Column(name = "total_price")
+    private Integer totalPrice;
+
+    /**
+     * 支付状态 (0: 待支付, 1: 支付处理中, 2: 支付成功, 3: 支付失败)
+     */
+    @Column(name = "payment_status")
+    private Integer paymentStatus;
+
+    @Column(name = "user_id")
+    private Integer userId;
+
+    @Column(name = "user_type")
+    private Integer userType;
+
+    @Column(name = "user_key_id")
+    private String userKeyId;
+
+    /**
+     * 患者手机号
+     */
+    @Column(name = "patient_mobile")
+    private String patientMobile;
+
+    /**
+     * 过敏史
+     */
+    @Column(name = "allergic_history")
+    private String allergicHistory;
+
+    /**
+     * 病情描述
+     */
+    @Column(name = "description")
+    private String description;
+
+    /**
+     * 医生签名Id
+     */
+    @Column(name = "doctor_sign_id")
+    private Integer doctorSignId;
+
+    /**
+     * 医生Id
+     */
+    @Column(name = "doctor_id")
+    private Integer doctorId;
+
+    @Column(name = "hospital_id")
+    private Integer hospitalId;
+
+    /**
+     * 取药方式
+     */
+    @Column(name = "delivery_method")
+    private Integer deliveryMethod;
+
+    /**
+     * 送货地址/药店地址
+     */
+    @Column(name = "address_id")
+    private Integer addressId;
+
+    /**
+     * HIS单号
+     * HIS订单号(当source字段的值为12的时候,对应ywt_center数据库的outpatient_order表的his_order_no字段)
+     */
+    @Column(name = "his_order_no")
+    private String hisOrderNo;
+
+    /**
+     * 快递运费
+     */
+    @Column(name = "freight")
+    private Integer freight;
+
+    /**
+     * 药房地址ID,对应pharmacy表
+     */
+    @Column(name = "pharmacy_id")
+    private Integer pharmacyId;
+
+    /**
+     * 个人支付总金额(药品总金额 - 医保 + 运费)
+     */
+    @Column(name = "individual", nullable = false)
+    private Integer individual;
+
+    /**
+     * 开始时间(发药)
+     */
+    @Column(name = "start_send_time")
+    private Date startSendTime;
+
+    /**
+     * 完成时间(快递)
+     */
+    @Column(name = "finish_send_time")
+    private Date finishSendTime;
+
+    /**
+     * 配送号
+     */
+    @Column(name = "send_no")
+    private String sendNo;
+
+    /**
+     * 取药二维码
+     */
+    @Column(name = "qr_code_url")
+    private String qrCodeUrl;
+
+    @Column(name = "id_card_no")
+    private String idCardNo;
+
+    /**
+     * 拓展状态,位运算,1-是否报到,2-是否发药,4-是否打印发票
+     */
+    @Column(name = "ext_status")
+    private Integer extStatus;
+
+    /**
+     * 是否需要打印发票,0-不需要,1-需要
+     */
+    @Column(name = "need_print_status")
+    private Integer needPrintStatus;
+
+    /**
+     * 患者报到时间
+     */
+    @Column(name = "check_in_time")
+    private Date checkInTime;
+
+    /**
+     * 平台
+     */
+    @Column(name = "terminal")
+    private Integer terminal;
+
+    /**
+     * 患者支付时间
+     */
+    @Column(name = "pay_time")
+    private Date payTime;
+
+    /**
+     * 订单号,对应orders表order_no字段
+     */
+    @Column(name = "order_no")
+    private String orderNo;
+
+    /**
+     * 订单Id,对应orders表id字段
+     */
+    @Column(name = "order_id")
+    private Integer orderId;
+
+    /**
+     * 支付渠道
+     */
+    @Column(name = "payment_channel")
+    private Integer paymentChannel;
+
+    /**
+     * 订单支付流水号
+     */
+    @Column(name = "payment_no")
+    private String paymentNo;
+
+    /**
+     * 退费时间
+     */
+    @Column(name = "refund_time")
+    private Date refundTime;
+
+    /**
+     * 是否已经发送微信取药消息,0-否,1-是 (1-发送"未取药"提醒,2-发送"提醒取药",位运算)
+     */
+    @Column(name = "get_medicine_notice")
+    private Integer getMedicineNotice;
+
+    /**
+     * 推送给国控的进度(位存储)
+     * 0-未推送 1-药品匹配成功 2-处方订单确认
+     */
+    @Column(name = "sinopharm")
+    private Integer sinopharm;
+
+    /**
+     * 匹配成功流水
+     */
+    @Column(name = "match_id")
+    private String matchId;
+
+    @Column(name = "ext_data")
+    private String extData;
+
+    @Column(name = "remarks")
+    private String remarks;
+
+    @Column(name = "sender_account")
+    private String senderAccount;
+
+    @Column(name = "sender_nickname")
+    private String senderNickname;
+
+    /**
+     * 退费状态
+     */
+    @Column(name = "refund_status")
+    private Integer refundStatus;
+
+    /**
+     * 退款流水号
+     */
+    @Column(name = "refund_no")
+    private String refundNo;
+
+    /**
+     * 药房树编码
+     */
+    @Column(name = "pharmacy_tree_code")
+    private String pharmacyTreeCode;
+
+
+    /**
+     * 3.1.5 新增
+     * 处方作废状态:0-初始状态,1-作废申请中,2-已作废,3-作废失败
+     */
+    @Column(name = "cancel_status")
+    private Integer cancelStatus;
+
+
+    /**
+     * 3.1.5 新增
+     * 处方作废备注
+     */
+    @Column(name = "cancel_remark")
+    private String cancelRemark;
+
+    @Column(name = "his_patient_id")
+    private String hisPatientId;
+
+    /**
+     * HIS 插入医嘱返回的 orderId, 多个用英文逗号隔开
+     */
+    @Column(name = "his_oeori_order_id")
+    private String hisOeoriOrderId;
+
+    /**
+     * 3.3.3 新增
+     * 申请作废原因
+     */
+    @Column(name = "cancel_reason")
+    private String cancelReason;
+
+
+    public int getId() {
+        return id;
+    }
+
+    public void setId(int id) {
+        this.id = id;
+    }
+
+    public String getPreBizNo() {
+        return preBizNo;
+    }
+
+    public void setPreBizNo(String preBizNo) {
+        this.preBizNo = preBizNo;
+    }
+
+    public String getBizNo3th() {
+        return bizNo3th;
+    }
+
+    public void setBizNo3th(String bizNo3th) {
+        this.bizNo3th = bizNo3th;
+    }
+
+    public String getDoctorName() {
+        return doctorName;
+    }
+
+    public void setDoctorName(String doctorName) {
+        this.doctorName = doctorName;
+    }
+
+    public String getDoctorCode() {
+        return doctorCode;
+    }
+
+    public void setDoctorCode(String doctorCode) {
+        this.doctorCode = doctorCode;
+    }
+
+    public String getPatientName() {
+        return patientName;
+    }
+
+    public void setPatientName(String patientName) {
+        this.patientName = patientName;
+    }
+
+    public String getPatientSex() {
+        return patientSex;
+    }
+
+    public void setPatientSex(String patientSex) {
+        this.patientSex = patientSex;
+    }
+
+    public String getPatientNo() {
+        return patientNo;
+    }
+
+    public void setPatientNo(String patientNo) {
+        this.patientNo = patientNo;
+    }
+
+    public String getDiagnose() {
+        return diagnose;
+    }
+
+    public void setDiagnose(String diagnose) {
+        this.diagnose = diagnose;
+    }
+
+    public String getDept() {
+        return dept;
+    }
+
+    public void setDept(String dept) {
+        this.dept = dept;
+    }
+
+    public Date getCreateOn() {
+        return createOn;
+    }
+
+    public void setCreateOn(Date createOn) {
+        this.createOn = createOn;
+    }
+
+    public Integer getSource() {
+        return source;
+    }
+
+    public void setSource(Integer source) {
+        this.source = source;
+    }
+
+    public Integer getStatus() {
+        return status;
+    }
+
+    public void setStatus(Integer status) {
+        this.status = status;
+    }
+
+    public Integer getTotalPrice() {
+        return totalPrice;
+    }
+
+    public void setTotalPrice(Integer totalPrice) {
+        this.totalPrice = totalPrice;
+    }
+
+    public Integer getPaymentStatus() {
+        return paymentStatus;
+    }
+
+    public void setPaymentStatus(Integer paymentStatus) {
+        this.paymentStatus = paymentStatus;
+    }
+
+    public Integer getUserId() {
+        return userId;
+    }
+
+    public void setUserId(Integer userId) {
+        this.userId = userId;
+    }
+
+    public Integer getUserType() {
+        return userType;
+    }
+
+    public void setUserType(Integer userType) {
+        this.userType = userType;
+    }
+
+    public String getUserKeyId() {
+        return userKeyId;
+    }
+
+    public void setUserKeyId(String userKeyId) {
+        this.userKeyId = userKeyId;
+    }
+
+    public String getPatientAge() {
+        return patientAge;
+    }
+
+    public void setPatientAge(String patientAge) {
+        this.patientAge = patientAge;
+    }
+
+    public String getPatientMobile() {
+        return patientMobile;
+    }
+
+    public void setPatientMobile(String patientMobile) {
+        this.patientMobile = patientMobile;
+    }
+
+    public String getAllergicHistory() {
+        return allergicHistory;
+    }
+
+    public void setAllergicHistory(String allergicHistory) {
+        this.allergicHistory = allergicHistory;
+    }
+
+    public String getDescription() {
+        return description;
+    }
+
+    public void setDescription(String description) {
+        this.description = description;
+    }
+
+    public Integer getDoctorSignId() {
+        return doctorSignId;
+    }
+
+    public void setDoctorSignId(Integer doctorSignId) {
+        this.doctorSignId = doctorSignId;
+    }
+
+    public Integer getDoctorId() {
+        return doctorId;
+    }
+
+    public void setDoctorId(Integer doctorId) {
+        this.doctorId = doctorId;
+    }
+
+    public Integer getHospitalId() {
+        return hospitalId;
+    }
+
+    public void setHospitalId(Integer hospitalId) {
+        this.hospitalId = hospitalId;
+    }
+
+    public Integer getDeliveryMethod() {
+        return deliveryMethod;
+    }
+
+    public void setDeliveryMethod(Integer deliveryMethod) {
+        this.deliveryMethod = deliveryMethod;
+    }
+
+    public Integer getAddressId() {
+        return addressId;
+    }
+
+    public void setAddressId(Integer addressId) {
+        this.addressId = addressId;
+    }
+
+    public String getHisOrderNo() {
+        return hisOrderNo;
+    }
+
+    public void setHisOrderNo(String hisOrderNo) {
+        this.hisOrderNo = hisOrderNo;
+    }
+
+    public Integer getFreight() {
+        return freight;
+    }
+
+    public void setFreight(Integer freight) {
+        this.freight = freight;
+    }
+
+    public Integer getPharmacyId() {
+        return pharmacyId;
+    }
+
+    public void setPharmacyId(Integer pharmacyId) {
+        this.pharmacyId = pharmacyId;
+    }
+
+    public Integer getIndividual() {
+        return individual;
+    }
+
+    public void setIndividual(Integer individual) {
+        this.individual = individual;
+    }
+
+    public Date getStartSendTime() {
+        return startSendTime;
+    }
+
+    public void setStartSendTime(Date startSendTime) {
+        this.startSendTime = startSendTime;
+    }
+
+    public Date getFinishSendTime() {
+        return finishSendTime;
+    }
+
+    public void setFinishSendTime(Date finishSendTime) {
+        this.finishSendTime = finishSendTime;
+    }
+
+    public String getSendNo() {
+        return sendNo;
+    }
+
+    public void setSendNo(String sendNo) {
+        this.sendNo = sendNo;
+    }
+
+    public String getQrCodeUrl() {
+        return qrCodeUrl;
+    }
+
+    public void setQrCodeUrl(String qrCodeUrl) {
+        this.qrCodeUrl = qrCodeUrl;
+    }
+
+    public String getIdCardNo() {
+        return idCardNo;
+    }
+
+    public void setIdCardNo(String idCardNo) {
+        this.idCardNo = idCardNo;
+    }
+
+    public Integer getExtStatus() {
+        return extStatus;
+    }
+
+    public void setExtStatus(Integer extStatus) {
+        this.extStatus = extStatus;
+    }
+
+    public Integer getNeedPrintStatus() {
+        return needPrintStatus;
+    }
+
+    public void setNeedPrintStatus(Integer needPrintStatus) {
+        this.needPrintStatus = needPrintStatus;
+    }
+
+    public Date getCheckInTime() {
+        return checkInTime;
+    }
+
+    public void setCheckInTime(Date checkInTime) {
+        this.checkInTime = checkInTime;
+    }
+
+    public Integer getTerminal() {
+        return terminal;
+    }
+
+    public void setTerminal(Integer terminal) {
+        this.terminal = terminal;
+    }
+
+    public Date getPayTime() {
+        return payTime;
+    }
+
+    public void setPayTime(Date payTime) {
+        this.payTime = payTime;
+    }
+
+    public Integer getPaymentChannel() {
+        return paymentChannel;
+    }
+
+    public void setPaymentChannel(Integer paymentChannel) {
+        this.paymentChannel = paymentChannel;
+    }
+
+    public String getPaymentNo() {
+        return paymentNo;
+    }
+
+    public void setPaymentNo(String paymentNo) {
+        this.paymentNo = paymentNo;
+    }
+
+    public Date getRefundTime() {
+        return refundTime;
+    }
+
+    public void setRefundTime(Date refundTime) {
+        this.refundTime = refundTime;
+    }
+
+    public Integer getGetMedicineNotice() {
+        return getMedicineNotice;
+    }
+
+    public void setGetMedicineNotice(Integer getMedicineNotice) {
+        this.getMedicineNotice = getMedicineNotice;
+    }
+
+    public Integer getSinopharm() {
+        return sinopharm;
+    }
+
+    public void setSinopharm(Integer sinopharm) {
+        this.sinopharm = sinopharm;
+    }
+
+    public String getMatchId() {
+        return matchId;
+    }
+
+    public void setMatchId(String matchId) {
+        this.matchId = matchId;
+    }
+
+    public String getExtData() {
+        return extData;
+    }
+
+    public void setExtData(String extData) {
+        this.extData = extData;
+    }
+
+    public String getRemarks() {
+        return remarks;
+    }
+
+    public void setRemarks(String remarks) {
+        this.remarks = remarks;
+    }
+
+    public String getSenderAccount() {
+        return senderAccount;
+    }
+
+    public void setSenderAccount(String senderAccount) {
+        this.senderAccount = senderAccount;
+    }
+
+    public String getSenderNickname() {
+        return senderNickname;
+    }
+
+    public void setSenderNickname(String senderNickname) {
+        this.senderNickname = senderNickname;
+    }
+
+    public String getOrderNo() {
+        return orderNo;
+    }
+
+    public void setOrderNo(String orderNo) {
+        this.orderNo = orderNo;
+    }
+
+    public Integer getOrderId() {
+        return orderId;
+    }
+
+    public void setOrderId(Integer orderId) {
+        this.orderId = orderId;
+    }
+
+    public Integer getRefundStatus() {
+        return refundStatus;
+    }
+
+    public void setRefundStatus(Integer refundStatus) {
+        this.refundStatus = refundStatus;
+    }
+
+    public String getRefundNo() {
+        return refundNo;
+    }
+
+    public void setRefundNo(String refundNo) {
+        this.refundNo = refundNo;
+    }
+
+    public String getPharmacyTreeCode() {
+        return pharmacyTreeCode;
+    }
+
+    public void setPharmacyTreeCode(String pharmacyTreeCode) {
+        this.pharmacyTreeCode = pharmacyTreeCode;
+    }
+
+    public Integer getCancelStatus() {
+        return cancelStatus;
+    }
+
+    public void setCancelStatus(Integer cancelStatus) {
+        this.cancelStatus = cancelStatus;
+    }
+
+    public String getCancelRemark() {
+        return cancelRemark;
+    }
+
+    public void setCancelRemark(String cancelRemark) {
+        this.cancelRemark = cancelRemark;
+    }
+
+    public String getHisPatientId() {
+        return hisPatientId;
+    }
+
+    public void setHisPatientId(String hisPatientId) {
+        this.hisPatientId = hisPatientId;
+    }
+
+    public String getHisOeoriOrderId() {
+        return hisOeoriOrderId;
+    }
+
+    public void setHisOeoriOrderId(String hisOeoriOrderId) {
+        this.hisOeoriOrderId = hisOeoriOrderId;
+    }
+
+    public String getCancelReason() {
+        return cancelReason;
+    }
+
+    public void setCancelReason(String cancelReason) {
+        this.cancelReason = cancelReason;
+    }
+}

+ 48 - 0
src/main/java/com/ywt/mg/domain/ywtDrugEntities/PrescriptionInfoRepository.java

@@ -0,0 +1,48 @@
+package com.ywt.mg.domain.ywtDrugEntities;
+
+import org.springframework.data.jpa.repository.JpaRepository;
+import org.springframework.data.jpa.repository.Query;
+
+import java.util.List;
+
+public interface PrescriptionInfoRepository extends JpaRepository<PrescriptionInfo, Integer>{
+
+    /**
+     * 根据处方编码得到处方对象
+     * @param preBizNo
+     * @return
+     */
+    @Query(value = "select * from prescription_info where pre_biz_no = ? limit 1 ", nativeQuery = true)
+    PrescriptionInfo findOneByPreBizNo(String preBizNo);
+
+
+    /**
+     * 判断患者是否有处方单记录
+     *
+     * @param patientName
+     * @param patientNo
+     * @return
+     */
+    @Query(value = "select count(1) from prescription_info where patient_name = ? or patient_no = ? limit 1", nativeQuery = true)
+    int checkCount(String patientName,String patientNo);
+
+    /**
+     *  药房药师点击“发药”,过了当天00:00后,患者端(自取)处方订单状态才变成已完成。(排除广三的)
+     *  source 参考字段{@link com.ywt.mg.domain.models.enums.PrescriptionInfoSourceEnum}
+     *  找到符合条件的记录,关键点:支付成功,自取,已发药,订单状态(配送中),小于当前时间
+     * @return
+     */
+    @Query(value = "select * from prescription_info where source != 1 and payment_status = 2 and delivery_method = 2 and status = 2 and ((ext_status & 2) = 2) and start_send_time < now(); ", nativeQuery = true)
+    List<PrescriptionInfo> getScheduledList();
+
+    /**
+     * 根据处方编码得到处方对象
+     * @param orderNo
+     * @return
+     */
+    @Query(value = "select * from prescription_info where order_no = ? limit 1 ", nativeQuery = true)
+    PrescriptionInfo findOneByOrderNo(String orderNo);
+
+    @Query(value = "select * from prescription_info where order_id = ? limit 1 ", nativeQuery = true)
+    PrescriptionInfo findOneByOrderId(int orderId);
+}

+ 207 - 0
src/main/java/com/ywt/mg/params/natOrder/NatOrderListRequest.java

@@ -0,0 +1,207 @@
+package com.ywt.mg.params.natOrder;
+
+import io.swagger.annotations.ApiModelProperty;
+
+import java.io.Serializable;
+
+public class NatOrderListRequest implements Serializable {
+
+    @ApiModelProperty(value = "缴费码")
+    private String paymentCode;
+
+    @ApiModelProperty(value = "患者姓名")
+    private String patientName;
+
+    @ApiModelProperty(value = "身份证号")
+    private String idCard;
+
+    @ApiModelProperty(value = "手机号")
+    private String mobile;
+
+    @ApiModelProperty(value = "订单号")
+    private String orderNo;
+
+    @ApiModelProperty(value = "疫苗码")
+    private String vaccineCode;
+
+    @ApiModelProperty(value = "支付状态:0-待支付,1-支付处理中,2-支付成功,3-支付失败")
+    private String paymentStatus;
+
+    @ApiModelProperty(value = "订单状态,位运算:1-未支付;2-已支付/待检测;4-已完成;8-已取消;16-已退款")
+    private String orderStatus;
+
+    @ApiModelProperty(value = "支付时间查询开始时间")
+    private String paymentStartTime;
+
+    @ApiModelProperty(value = "支付时间查询截止时间")
+    private String paymentEndTime;
+
+    @ApiModelProperty(value = "退款时间查询开始时间")
+    private String refundStartTime;
+
+    @ApiModelProperty(value = "退款时间查询截止时间")
+    private String refundEndTime;
+
+    @ApiModelProperty(value = "执行时间查询开始时间")
+    private String confirmStartTime;
+
+    @ApiModelProperty(value = "执行时间查询截止时间")
+    private String confirmEndTime;
+
+    @ApiModelProperty(value = "医院ID")
+    private int hospitalId;
+
+    @ApiModelProperty(value = "交易流水号")
+    private String transactionId;
+
+    @ApiModelProperty(value = "对账时间查询开始时间")
+    private String billStartTime;
+
+    @ApiModelProperty(value = "对账时间查询截止时间")
+    private String billEndTime;
+
+
+    public String getPaymentCode() {
+        return paymentCode;
+    }
+
+    public void setPaymentCode(String paymentCode) {
+        this.paymentCode = paymentCode;
+    }
+
+    public String getPatientName() {
+        return patientName;
+    }
+
+    public void setPatientName(String patientName) {
+        this.patientName = patientName;
+    }
+
+    public String getIdCard() {
+        return idCard;
+    }
+
+    public void setIdCard(String idCard) {
+        this.idCard = idCard;
+    }
+
+    public String getMobile() {
+        return mobile;
+    }
+
+    public void setMobile(String mobile) {
+        this.mobile = mobile;
+    }
+
+    public String getOrderNo() {
+        return orderNo;
+    }
+
+    public void setOrderNo(String orderNo) {
+        this.orderNo = orderNo;
+    }
+
+    public String getVaccineCode() {
+        return vaccineCode;
+    }
+
+    public void setVaccineCode(String vaccineCode) {
+        this.vaccineCode = vaccineCode;
+    }
+
+    public String getPaymentStatus() {
+        return paymentStatus;
+    }
+
+    public void setPaymentStatus(String paymentStatus) {
+        this.paymentStatus = paymentStatus;
+    }
+
+    public String getOrderStatus() {
+        return orderStatus;
+    }
+
+    public void setOrderStatus(String orderStatus) {
+        this.orderStatus = orderStatus;
+    }
+
+    public String getPaymentStartTime() {
+        return paymentStartTime;
+    }
+
+    public void setPaymentStartTime(String paymentStartTime) {
+        this.paymentStartTime = paymentStartTime;
+    }
+
+    public String getPaymentEndTime() {
+        return paymentEndTime;
+    }
+
+    public void setPaymentEndTime(String paymentEndTime) {
+        this.paymentEndTime = paymentEndTime;
+    }
+
+    public String getRefundStartTime() {
+        return refundStartTime;
+    }
+
+    public void setRefundStartTime(String refundStartTime) {
+        this.refundStartTime = refundStartTime;
+    }
+
+    public String getRefundEndTime() {
+        return refundEndTime;
+    }
+
+    public void setRefundEndTime(String refundEndTime) {
+        this.refundEndTime = refundEndTime;
+    }
+
+    public String getConfirmStartTime() {
+        return confirmStartTime;
+    }
+
+    public void setConfirmStartTime(String confirmStartTime) {
+        this.confirmStartTime = confirmStartTime;
+    }
+
+    public String getConfirmEndTime() {
+        return confirmEndTime;
+    }
+
+    public void setConfirmEndTime(String confirmEndTime) {
+        this.confirmEndTime = confirmEndTime;
+    }
+
+    public int getHospitalId() {
+        return hospitalId;
+    }
+
+    public void setHospitalId(int hospitalId) {
+        this.hospitalId = hospitalId;
+    }
+
+    public String getTransactionId() {
+        return transactionId;
+    }
+
+    public void setTransactionId(String transactionId) {
+        this.transactionId = transactionId;
+    }
+
+    public String getBillStartTime() {
+        return billStartTime;
+    }
+
+    public void setBillStartTime(String billStartTime) {
+        this.billStartTime = billStartTime;
+    }
+
+    public String getBillEndTime() {
+        return billEndTime;
+    }
+
+    public void setBillEndTime(String billEndTime) {
+        this.billEndTime = billEndTime;
+    }
+}

+ 275 - 0
src/main/java/com/ywt/mg/params/prescription/QueryPrescriptionListRequest.java

@@ -0,0 +1,275 @@
+package com.ywt.mg.params.prescription;
+
+import io.swagger.annotations.ApiModelProperty;
+
+import java.io.Serializable;
+
+public class QueryPrescriptionListRequest implements Serializable {
+
+    @ApiModelProperty(value = "医生姓名", example = "")
+    private String doctorname;
+
+    @ApiModelProperty(value = "科室名称", example = "")
+    private String deptname;
+
+    @ApiModelProperty(value = "患者姓名", example = "")
+    private String patientname;
+
+    @ApiModelProperty(value = "订单来源", example = "")
+    private String source;
+
+    @ApiModelProperty(value = "药房ID", example = "")
+    private String pharmacyId;
+
+    @ApiModelProperty(value = "配送方式:''-全部,1-快递,2-自取", example = "")
+    private String deliveryMethod;
+
+    @ApiModelProperty(value = "创建时间查询开始时间", example = "")
+    private String createTimeStart;
+
+    @ApiModelProperty(value = "创建时间查询截止时间", example = "")
+    private String createTimeEnd;
+
+    @ApiModelProperty(value = "支付时间查询开始时间", example = "")
+    private String payTimeStart;
+
+    @ApiModelProperty(value = "支付时间查询截止时间", example = "")
+    private String payTimeEnd;
+
+    @ApiModelProperty(value = "退款时间查询开始时间", example = "")
+    private String refundTimeStart;
+
+    @ApiModelProperty(value = "退款时间查询截止时间", example = "")
+    private String refundTimeEnd;
+
+    @ApiModelProperty(value = "支付状态,参考PaymentStatusEnum类", example = "")
+    private String paymentStatus;
+
+    @ApiModelProperty(value = "订单状态", example = "")
+    private String status;
+
+    @ApiModelProperty(value = "业务编码", example = "")
+    private String preBizNo;
+
+    @ApiModelProperty(value = "处方编码", example = "")
+    private String bizNo3th;
+
+    @ApiModelProperty(value = "配送号", example = "")
+    private String sendNo;
+
+    @ApiModelProperty(value = "支付渠道", example = "")
+    private String paymentChannel;
+
+    @ApiModelProperty(value = "支付流水号", example = "")
+    private String paymentNo;
+
+    /**
+     * 处方作废状态: ""-全部,"1"-作废申请中,"2"-已作废,"3"-作废失败
+     */
+    @ApiModelProperty(value = "作废状态,''-全部,'1'-作废申请中,'2'-已作废,'3'-作废失败", example = "")
+    private String cancelStatus;
+
+    @ApiModelProperty(value = "订单号", example = "")
+    private String orderNo;
+
+    @ApiModelProperty(value = "对账时间查询开始时间", example = "")
+    private String billStartTime;
+
+    @ApiModelProperty(value = "对账时间查询截止时间", example = "")
+    private String billEndTime;
+
+    @ApiModelProperty(value = "交易流水号", example = "")
+    private String transactionId;
+
+    public String getDoctorname() {
+        return doctorname;
+    }
+
+    public void setDoctorname(String doctorname) {
+        this.doctorname = doctorname;
+    }
+
+    public String getDeptname() {
+        return deptname;
+    }
+
+    public void setDeptname(String deptname) {
+        this.deptname = deptname;
+    }
+
+    public String getPatientname() {
+        return patientname;
+    }
+
+    public void setPatientname(String patientname) {
+        this.patientname = patientname;
+    }
+
+    public String getSource() {
+        return source;
+    }
+
+    public void setSource(String source) {
+        this.source = source;
+    }
+
+    public String getPharmacyId() {
+        return pharmacyId;
+    }
+
+    public void setPharmacyId(String pharmacyId) {
+        this.pharmacyId = pharmacyId;
+    }
+
+    public String getDeliveryMethod() {
+        return deliveryMethod;
+    }
+
+    public void setDeliveryMethod(String deliveryMethod) {
+        this.deliveryMethod = deliveryMethod;
+    }
+
+    public String getCreateTimeStart() {
+        return createTimeStart;
+    }
+
+    public void setCreateTimeStart(String createTimeStart) {
+        this.createTimeStart = createTimeStart;
+    }
+
+    public String getCreateTimeEnd() {
+        return createTimeEnd;
+    }
+
+    public void setCreateTimeEnd(String createTimeEnd) {
+        this.createTimeEnd = createTimeEnd;
+    }
+
+    public String getPayTimeStart() {
+        return payTimeStart;
+    }
+
+    public void setPayTimeStart(String payTimeStart) {
+        this.payTimeStart = payTimeStart;
+    }
+
+    public String getPayTimeEnd() {
+        return payTimeEnd;
+    }
+
+    public void setPayTimeEnd(String payTimeEnd) {
+        this.payTimeEnd = payTimeEnd;
+    }
+
+    public String getRefundTimeStart() {
+        return refundTimeStart;
+    }
+
+    public void setRefundTimeStart(String refundTimeStart) {
+        this.refundTimeStart = refundTimeStart;
+    }
+
+    public String getRefundTimeEnd() {
+        return refundTimeEnd;
+    }
+
+    public void setRefundTimeEnd(String refundTimeEnd) {
+        this.refundTimeEnd = refundTimeEnd;
+    }
+
+    public String getPaymentStatus() {
+        return paymentStatus;
+    }
+
+    public void setPaymentStatus(String paymentStatus) {
+        this.paymentStatus = paymentStatus;
+    }
+
+    public String getStatus() {
+        return status;
+    }
+
+    public void setStatus(String status) {
+        this.status = status;
+    }
+
+    public String getPreBizNo() {
+        return preBizNo;
+    }
+
+    public void setPreBizNo(String preBizNo) {
+        this.preBizNo = preBizNo;
+    }
+
+    public String getBizNo3th() {
+        return bizNo3th;
+    }
+
+    public void setBizNo3th(String bizNo3th) {
+        this.bizNo3th = bizNo3th;
+    }
+
+    public String getSendNo() {
+        return sendNo;
+    }
+
+    public void setSendNo(String sendNo) {
+        this.sendNo = sendNo;
+    }
+
+    public String getPaymentChannel() {
+        return paymentChannel;
+    }
+
+    public void setPaymentChannel(String paymentChannel) {
+        this.paymentChannel = paymentChannel;
+    }
+
+    public String getPaymentNo() {
+        return paymentNo;
+    }
+
+    public void setPaymentNo(String paymentNo) {
+        this.paymentNo = paymentNo;
+    }
+
+    public String getCancelStatus() {
+        return cancelStatus;
+    }
+
+    public void setCancelStatus(String cancelStatus) {
+        this.cancelStatus = cancelStatus;
+    }
+
+    public String getOrderNo() {
+        return orderNo;
+    }
+
+    public void setOrderNo(String orderNo) {
+        this.orderNo = orderNo;
+    }
+
+    public String getBillStartTime() {
+        return billStartTime;
+    }
+
+    public void setBillStartTime(String billStartTime) {
+        this.billStartTime = billStartTime;
+    }
+
+    public String getBillEndTime() {
+        return billEndTime;
+    }
+
+    public void setBillEndTime(String billEndTime) {
+        this.billEndTime = billEndTime;
+    }
+
+    public String getTransactionId() {
+        return transactionId;
+    }
+
+    public void setTransactionId(String transactionId) {
+        this.transactionId = transactionId;
+    }
+}

+ 275 - 0
src/main/java/com/ywt/mg/services/CommonServices.java

@@ -0,0 +1,275 @@
+package com.ywt.mg.services;
+
+import com.ywt.mg.core.utils.Checker;
+import com.ywt.mg.core.utils.DateUtil;
+import com.ywt.mg.domain.models.ConstantDef;
+import com.ywt.mg.domain.models.enums.*;
+import com.ywt.mg.domain.ywtDrugEntities.PrescriptionInfo;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Service;
+
+import java.util.Date;
+
+@Service
+public class CommonServices {
+
+    @Autowired
+    private UserService userService;
+
+
+    /**
+     * 得到公司后台的处方状态
+     * 平台处方+太和药房:状态:待支付、待取药、配送中、不通过、已退费、待评价、已评价、已过期、退费中
+     * 平台处方+广三生殖药房:状态:待支付、待取药、已退费、已完成、已过期、退费中
+     * his处方+广三生殖药房+如意坊大药房:待支付、待取药、已退费、已完成、已过期、退费中
+     *
+     * @param p 处方单
+     * @return 处方状态
+     */
+
+    public String getCompanyPrescriptionStatusStr(PrescriptionInfo p) {
+        int paymentStatusInt = Checker.getIntegerValue(p.getPaymentStatus());
+
+        if (!Checker.isNone(p.getRefundStatus()) && p.getRefundStatus().equals(RefundStatusEnum.PENDING.getValue())) {
+            return "退费中";
+        }
+
+        // 只要不是支付成功,那则返回:"待支付"
+        if (paymentStatusInt != PaymentStatusEnum.Success.getValue()) {
+            // 计算支付时间
+            Date sixDayBefore = DateUtil.getRelativeDate(ConstantDef.OVERDUE_DAY_NUM);
+            // todo 平台处方(广三his处方)+ 广三生殖药房,超过3天未支付,算已过期 ,换句话说:只要是广三生殖药房的处方,超过3天未支付,算过期,有些未支付的未选择药房的,也按照这个标准算
+            // todo 2020-06-08:太和药房,也增加已过期状态(3天未支付,则过期)
+            if (sixDayBefore.after(p.getCreateOn())) {
+                return "已过期";
+            }
+            return PaymentStatusEnum.Pending.getDisplayName();
+        }
+
+        int extStatus = Checker.getIntegerValue(p.getExtStatus());
+        String statusStr = PrescriptionInfoStatusEnum.valueOf(p.getStatus()).getDisplayName();
+        // 太和药房ID
+        if (p.getPharmacyId() == ConstantDef.TAIHE_PHARMACY_ID || p.getPharmacyId() == ConstantDef.NFBY_PHARMACY_ID) {
+            // 已退费
+            if (p.getStatus() == PrescriptionInfoStatusEnum.HaveARefund.getValue()) {
+                statusStr = PrescriptionInfoStatusEnum.HaveARefund.getDisplayName();
+                return statusStr;
+            }
+            if ((extStatus & PrescriptionInfoExtStatusEnum.Evaluate.getValue()) == PrescriptionInfoExtStatusEnum.Evaluate.getValue()) {
+                statusStr = "已评价";
+                return statusStr;
+            }
+
+            // 不通过
+            if ((extStatus & PrescriptionInfoExtStatusEnum.PresNoPass.getValue()) == PrescriptionInfoExtStatusEnum.PresNoPass.getValue()) {
+                statusStr = "不通过";
+                return statusStr;
+            }
+            int deliveryMethodInt = Checker.getIntegerValue(p.getDeliveryMethod());
+            // 顺丰返回完成状态或者自取且已发药
+            if (p.getStatus() == PrescriptionInfoStatusEnum.Finished.getValue() ||
+                    (deliveryMethodInt == DeliveryMethodEnum.SelfPickUp.getValue() && (extStatus & PrescriptionInfoExtStatusEnum.IsSendOut.getValue()) == PrescriptionInfoExtStatusEnum.IsSendOut.getValue())) {
+                statusStr = "待评价";
+                return statusStr;
+            } else {
+                // 快递到家
+                if (deliveryMethodInt == DeliveryMethodEnum.HomeDelivery.getValue()) {
+                    return "配送中";
+                } else {
+                    return "待取药";
+                }
+            }
+        }
+
+        if ((Checker.getIntegerValue(p.getDeliveryMethod()) == DeliveryMethodEnum.SelfPickUp.getValue() && Checker.getIntegerValue(p.getStatus()) == PrescriptionInfoStatusEnum.Dispatching.getValue())
+                || (Checker.getIntegerValue(p.getSource()) == PrescriptionInfoSourceEnum.GY3Y.getValue() && Checker.getIntegerValue(p.getStatus()) == PrescriptionInfoStatusEnum.Dispatching.getValue())) {
+            statusStr = "待取药";
+        }
+        // 已退费
+        if (p.getStatus() == PrescriptionInfoStatusEnum.HaveARefund.getValue()) {
+            statusStr = PrescriptionInfoStatusEnum.HaveARefund.getDisplayName();
+            return statusStr;
+        }
+        // 单独处理国控药房的 "待取药" 状态
+        if (p.getPharmacyId() == ConstantDef.GK_PHARMACY_ID && p.getPaymentStatus() == PaymentStatusEnum.Success.getValue()) {
+            return "待取药";
+        }
+        return statusStr;
+    }
+
+
+    /**
+     * 得到药房客户端、医院后台的处方状态
+     *
+     * @param p {@link PrescriptionInfo}
+     * @return 处方状态
+     */
+//    public String getPrescriptionInfoStatusStr(PrescriptionInfo p) {
+//        int currentPharmacyId = userService.getPharmacyId();
+//        int pharmacyId = Checker.getIntegerValue(p.getPharmacyId());
+//        // todo:目前来说,药房ID为1、4、5的是广三的,其它暂定太和的,当需要新开药房时,需要再做处理
+//        // 目前来说,广三生殖药房可以看到其他几个药房的,所以需要针对广三生殖药房单独做处理,后续做广三药房版本(互联网医院v4.3.6(广三处方优化-开放其它药房))时,需要再做调整
+//        if (currentPharmacyId == 1 || pharmacyId == 1 || pharmacyId == 4 || pharmacyId == 5 || pharmacyId == 12 || pharmacyId == 13 || pharmacyId == 14) {
+////        if ((pharmacyId == p.getPharmacyId()) && (pharmacyId == 1 || pharmacyId == 4 || pharmacyId == 5|| pharmacyId == 18 || pharmacyId == 19)) {
+//            return getPrescriptionInfoStatusStrForGS(p);
+//        } else if (pharmacyId == p.getPharmacyId() && (pharmacyId == ConstantDef.GK_PHARMACY_ID)) {
+//            // 10表示国控来的处方单
+//            return getPrescriptionInfoStatusStrForGK(p);
+//        } else if (pharmacyId == p.getPharmacyId() && (pharmacyId == ConstantDef.NFBY_PHARMACY_ID)) {
+//            // 11表示白云药房处方单
+//            return getPrescriptionInfoStatusStrForBY(p);
+//        }
+//        return getPrescriptionInfoStatusStrForTH(p);
+//    }
+
+//
+//    /**
+//     * 太和药房客户端、太和后台管理系统
+//     * <p>
+//     * 平台处方+太和药房:状态:待报到、待捡药、已发药、不通过、已退费、退费中
+//     *
+//     * @param p 处方记录
+//     * @return 处方状态
+//     */
+//    public String getPrescriptionInfoStatusStrForTH(PrescriptionInfo p) {
+//        if (Checker.isNone(p)) {
+//            return "";
+//        }
+//        // 处理退费中的状态
+//        if (!Checker.isNone(p.getRefundStatus()) && p.getRefundStatus().equals(RefundStatusEnum.PENDING.getValue())) {
+//            return "退费中";
+//        }
+//        // 处理退款的状态
+//        if (p.getStatus() == PrescriptionInfoStatusEnum.HaveARefund.getValue()) {
+//            return PrescriptionInfoStatusEnum.HaveARefund.getDisplayName();
+//        }
+//        // 处理不通过的状态
+//        int extStatusInt = Checker.getIntegerValue(p.getExtStatus());
+//        if ((extStatusInt & PrescriptionInfoExtStatusEnum.PresNoPass.getValue()) == PrescriptionInfoExtStatusEnum.PresNoPass.getValue()) {
+//            return PrescriptionInfoExtStatusEnum.PresNoPass.getDisplayName();
+//        }
+//        // 如果是快递患者,药师筛选的状态有“待捡药、已发药“,如果是自取患者,药师筛选的状态有“待报到、待捡药、已发药“
+//        int deliveryMethodInt = Checker.getIntegerValue(p.getDeliveryMethod());
+//        // 快递到家
+//        if (deliveryMethodInt == DeliveryMethodEnum.HomeDelivery.getValue()) {
+//            if ((extStatusInt & PrescriptionInfoExtStatusEnum.IsSendOut.getValue()) == PrescriptionInfoExtStatusEnum.IsSendOut.getValue()) {
+//                return "已发药";
+//            } else {
+//                return "待捡药";
+//            }
+//        }
+//        // 自取
+//        else if (deliveryMethodInt == DeliveryMethodEnum.SelfPickUp.getValue()) {
+//            if ((extStatusInt & PrescriptionInfoExtStatusEnum.IsSendOut.getValue()) == PrescriptionInfoExtStatusEnum.IsSendOut.getValue()) {
+//                return "已发药";
+//            } else if ((extStatusInt & PrescriptionInfoExtStatusEnum.IsCheckIn.getValue()) == PrescriptionInfoExtStatusEnum.IsCheckIn.getValue()) {
+//                return "待捡药";
+//            } else {
+//                return "待报到";
+//            }
+//        }
+//        return "";
+//    }
+//
+//
+//    /**
+//     * 广三药房客户端:获取广三的处方状态
+//     * <p>
+//     * 广三his处方_广三生殖药房:状态:待支付、待取药、已退费、已完成、已过期
+//     * his处方+广三生殖药房+如意坊大药房:状态:待支付、待取药、已退费、已完成、已过期、退费中
+//     *
+//     * @param p 处方记录
+//     * @return 处方状态
+//     */
+//    public String getPrescriptionInfoStatusStrForGS(PrescriptionInfo p) {
+//        if (Checker.isNone(p)) {
+//            return "";
+//        }
+//        // 处理退费中的状态
+//        if (!Checker.isNone(p.getRefundStatus()) && p.getRefundStatus().equals(RefundStatusEnum.PENDING.getValue())) {
+//            return "退费中";
+//        }
+//        String statusStr = PrescriptionInfoStatusEnum.valueOf(p.getStatus()).getDisplayName();
+//        if (Checker.getIntegerValue(p.getStatus()) == PrescriptionInfoStatusEnum.Dispatching.getValue()) {
+//            statusStr = "待取药";
+//        }
+//        return statusStr;
+//    }
+//
+//
+//    /**
+//     * 国控药房客户端:获取his的处方状态
+//     * <p>
+//     * 药房客户端:
+//     * <p>
+//     * 状态:待支付、待取药、已退费、已过期
+//     *
+//     * @param p 处方记录
+//     * @return 处方状态
+//     */
+//    private String getPrescriptionInfoStatusStrForGK(PrescriptionInfo p) {
+//        if (Checker.isNone(p)) {
+//            return "";
+//        }
+//        // 处理退款的状态
+//        if (p.getStatus() == PrescriptionInfoStatusEnum.HaveARefund.getValue()) {
+//            return PrescriptionInfoStatusEnum.HaveARefund.getDisplayName();
+//        }
+//        // 处理支付成功的状态
+//        int paymentStatusInt = Checker.getIntegerValue(p.getPaymentStatus());
+//        if (paymentStatusInt == PaymentStatusEnum.Success.getValue()) {
+//            return "待取药";
+//        }
+//        // 处理过期状态,3天未支付就过期
+//        if (paymentStatusInt != PaymentStatusEnum.Success.getValue()) {
+//            // 计算支付时间
+//            Date sixDayBefore = DateUtil.getRelativeDate(ConstantDef.OVERDUE_DAY_NUM);
+//            if (sixDayBefore.after(p.getCreateOn())) {
+//                return "已过期";
+//            }
+//        }
+//        // 其他则返回:"待支付"
+//        return "待支付";
+//    }
+//
+//    /***
+//     * 白云药房
+//     * @param p
+//     * @return
+//     */
+//    private String getPrescriptionInfoStatusStrForBY(PrescriptionInfo p) {
+//        if (Checker.isNone(p)) {
+//            return "";
+//        }
+//        // 处理退款的状态
+//        if (p.getStatus() == PrescriptionInfoStatusEnum.HaveARefund.getValue()) {
+//            return PrescriptionInfoStatusEnum.HaveARefund.getDisplayName();
+//        }
+//        // 处理支付成功的状态
+//        int paymentStatusInt = Checker.getIntegerValue(p.getPaymentStatus());
+//        int extStatusInt = Checker.getIntegerValue(p.getExtStatus());
+//        if (paymentStatusInt == PaymentStatusEnum.Success.getValue()) {
+//            if ((extStatusInt & PrescriptionInfoExtStatusEnum.IsSendOut.getValue()) == PrescriptionInfoExtStatusEnum.IsSendOut.getValue()) {
+//                return "已发药";
+//            } else if (extStatusInt < 1) {
+//                return "待取药";
+//            }
+//        }
+//        // 处理过期状态,3天未支付就过期
+//        else {
+//            // 计算支付时间
+//            Date sixDayBefore = DateUtil.getRelativeDate(ConstantDef.OVERDUE_DAY_NUM);
+//            if (sixDayBefore.after(p.getCreateOn())) {
+//                return "已过期";
+//            }
+//        }
+//
+//        if((extStatusInt & PrescriptionInfoExtStatusEnum.PresNoPass.getValue()) == PrescriptionInfoExtStatusEnum.PresNoPass.getValue()) {
+//            return  "不通过";
+//
+//        }
+//        // 其他则返回:"待支付"
+//        return "待支付";
+//    }
+
+}

+ 7 - 5
src/main/java/com/ywt/mg/services/DepositService.java

@@ -129,7 +129,9 @@ public class DepositService {
 
     public void downloadDepositList(int downloadRecordId, String fileName, QueryDepositListRequest request) {
         try {
+
 //            String[] title = new String[]{"订单号", "支付流水号", "交易流水号", "医院", "来源", "患者姓名", "手机号", "诊疗卡号", "支付金额", "支付方式", "同步状态", "支付时间"};
+            int hosp = Checker.getIntegerValue(request.getHosp());
             int hospitalId = Checker.getIntegerValue(request.getHospitalId());
             String col0 = "订单号";
             String col1 = "支付流水号";
@@ -145,7 +147,7 @@ public class DepositService {
             String col11 = "支付时间";
             String[] columns = new String[]{col0, col1, col2, col3, col4, col5, col6, col7, col8, col9, col10,
                     col11};
-            if (hospitalId > 0) {
+            if (hosp > 0) {
                 columns = new String[]{col0, col1, col2, col4, col5, col6, col7, col8, col9, col10,
                         col11};
             }
@@ -201,7 +203,7 @@ public class DepositService {
 ////                            p.getPatientMobile(), p.getCardNo(), amount, paymentChannel, paymentStatus, paymentTime};
 //                    }
 //                }
-                map = setExcelDataMap(orderPaymentList, list, map, hospitalId, request,
+                map = setExcelDataMap(orderPaymentList, list, map, hospitalId, hosp, request,
                         col0,
                         col1,
                         col2,
@@ -219,7 +221,7 @@ public class DepositService {
                     for (int i = 2; i <= size; i++) {
                         request.setPageIndex(i);
                         list = queryDepositPageList(request);
-                        map = setExcelDataMap(orderPaymentList, list, map, hospitalId, request,
+                        map = setExcelDataMap(orderPaymentList, list, map, hospitalId, hosp, request,
                                 col0,
                                 col1,
                                 col2,
@@ -262,7 +264,7 @@ public class DepositService {
         }
     }
 
-    private ExcelDataMap setExcelDataMap(List<OrderPayment> orderPaymentList, PagedList<DepositOrderInfo> list, ExcelDataMap map, int hospitalId, QueryDepositListRequest request,
+    private ExcelDataMap setExcelDataMap(List<OrderPayment> orderPaymentList, PagedList<DepositOrderInfo> list, ExcelDataMap map, int hospitalId, int hosp, QueryDepositListRequest request,
                                          String col0,
                                          String col1,
                                          String col2,
@@ -290,7 +292,7 @@ public class DepositService {
             }
             ;
 
-            if (request.getHospitalId() > 1) {
+            if (hosp > 1) {
 //                        bodyStr = new String[]{p.getOrderNo(), p.getPaymentNo(), transactionId, terminal, p.getPatientName(),
 //                                p.getPatientMobile(), p.getCardNo(), amount, paymentChannel, paymentStatus, paymentTime};
                 map.getStringListSafely(col0).add(p.getOrderNo());

+ 1 - 1
src/main/java/com/ywt/mg/services/DownloadRecordService.java

@@ -159,7 +159,7 @@ public class DownloadRecordService {
                 item.put("status", p.getStatus());
                 item.put("statusStr", DownloadRecordStatusEnum.getDisplayName(p.getStatus()));
                 if(p.getStatus() == DownloadRecordStatusEnum.Default.getValue()){
-                    item.put("updateTime", "下载中");
+                    item.put("updateTime", "获取中");
                 } else {
                     item.put("updateTime", FormatUtil.createTimeFormatDetail(p.getUpdateTime()));
                 }

+ 236 - 0
src/main/java/com/ywt/mg/services/NatOrderService.java

@@ -0,0 +1,236 @@
+package com.ywt.mg.services;
+
+import com.ywt.mg.core.SqlHelper;
+import com.ywt.mg.core.utils.Checker;
+import com.ywt.mg.core.utils.FormatUtil;
+import com.ywt.mg.core.utils.IdCardUtil;
+import com.ywt.mg.domain.entities.NatOrder;
+import com.ywt.mg.domain.entities.OrderPayment;
+import com.ywt.mg.domain.models.ConstantDef;
+import com.ywt.mg.domain.models.ExcelDataMap;
+import com.ywt.mg.domain.models.enums.DatePeriodEnum;
+import com.ywt.mg.domain.models.enums.NatOrderStatusEnum;
+import com.ywt.mg.domain.models.enums.PaymentStatusEnum;
+import com.ywt.mg.domain.models.enums.RefundStatusEnum;
+import com.ywt.mg.domain.models.pojo.ExcelCollectPojo;
+import com.ywt.mg.params.deposit.QueryDepositListRequest;
+import com.ywt.mg.params.natOrder.NatOrderListRequest;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.jdbc.core.JdbcTemplate;
+import org.springframework.stereotype.Service;
+
+import java.util.ArrayList;
+import java.util.Date;
+import java.util.List;
+import java.util.Map;
+
+@Service
+public class NatOrderService {
+
+    private static Logger logger = LoggerFactory.getLogger(NatOrderService.class);
+
+    @Autowired
+    private SqlHelper sqlHelper;
+
+    @Autowired
+    private AuthService authService;
+
+    @Autowired
+    private JdbcTemplate jdbcTemplate;
+
+    @Autowired
+    private OrderPaymentService orderPaymentService;
+
+    @Autowired
+    private HospitalCacheService hospitalCacheService;
+
+    @Autowired
+    private DownloadRecordService downloadRecordService;
+
+
+    public List<NatOrder> queryNatOrderList(NatOrderListRequest request) throws Exception {
+        Map<String, Object> map = queryNatOrderListCommon(request);
+        String whereSql = (String) map.get(ConstantDef.KEY_WHERE_SQL);
+        List<Object> paramList = (List<Object>) map.get(ConstantDef.KEY_PARAM_LIST);
+        return sqlHelper.getListWithNoPage("*", whereSql, " id desc ", NatOrder.class, paramList.toArray());
+    }
+
+    private Map<String, Object> queryNatOrderListCommon(NatOrderListRequest request) throws Exception {
+        List<Object> paramList = new ArrayList<>();
+        // 只显示未删除和支付成功的记录
+        String whereSql = " ( 1=1 and deleted = 0 and payment_status = 2 )";
+
+        String paymentCode = request.getPaymentCode().trim();
+        if (!Checker.isNull(paymentCode)) {
+            whereSql += " and ( payment_code = ?)";
+            paramList.add(paymentCode);
+        }
+
+        String patientName = request.getPatientName().trim();
+        if (!Checker.isNull(patientName)) {
+            whereSql += " and ( patient_name like ?)";
+            paramList.add(patientName + "%");
+        }
+
+        String idCard = request.getIdCard().trim();
+        if (!Checker.isNull(idCard)) {
+            whereSql += " and ( id_card = ?)";
+            paramList.add(idCard);
+        }
+
+        String mobile = request.getMobile().trim();
+        if (!Checker.isNull(mobile)) {
+            whereSql += " and ( mobile like ?)";
+            paramList.add(mobile + "%");
+        }
+
+        String orderNo = request.getOrderNo().trim();
+        if (!Checker.isNull(orderNo)) {
+            whereSql += " and ( order_no like ?)";
+            paramList.add(orderNo + "%");
+        }
+
+        String vaccineCode = request.getVaccineCode().trim();
+        if (!Checker.isNull(vaccineCode)) {
+            whereSql += " and ( vaccine_code like ?)";
+            paramList.add(vaccineCode + "%");
+        }
+
+        String paymentStatus = request.getPaymentStatus().trim();
+        if (!Checker.isNull(paymentStatus)) {
+            whereSql += " and ( payment_status = ?)";
+            paramList.add(Integer.parseInt(paymentStatus));
+        }
+
+        String orderStatus = request.getOrderStatus().trim();
+        if (!Checker.isNull(orderStatus)) {
+            int orderStatusInt = Integer.parseInt(orderStatus);
+            whereSql += " and ( (status & ?) = ? and status < ? ) ";
+            paramList.add(orderStatusInt);
+            paramList.add(orderStatusInt);
+            paramList.add(2 * orderStatusInt);
+        }
+
+        int hospitalId = request.getHospitalId();
+        if (hospitalId != -1) {
+            whereSql += " and ( hospital_id = ?)";
+            paramList.add(hospitalId);
+        }
+
+        // 对账时间搜索
+        String billEndTime = request.getBillEndTime();
+        String billStartTime = request.getBillStartTime();
+        if (!Checker.isNull(billEndTime)) {
+            whereSql += " and ( pay_time < ? or refund_time < ?)";
+            Date date = FormatUtil.stringToDateDayTimeEnd(billEndTime);
+            paramList.add(date);
+            paramList.add(date);
+        }
+        if (!Checker.isNull(billStartTime)) {
+            whereSql += " and ( pay_time >= ? or refund_time >= ?)";
+            Date date = FormatUtil.stringToDateDayTimeStart(billStartTime);
+            paramList.add(date);
+            paramList.add(date);
+        }
+        String transactionId = request.getTransactionId();
+        try {
+            // 处理交易流水号,考虑到性能,直接采用全匹配到方式
+            if (!Checker.isNull(transactionId)) {
+                OrderPayment orderPayment = orderPaymentService.getOrderPaymentByTransactionId(transactionId);
+                if (!Checker.isNone(orderPayment)) {
+                    whereSql += " and ( order_id = ? )";
+                    paramList.add(orderPayment.getOrderId());
+                } else {
+                    whereSql += " and ( order_id = -1 )";
+                }
+            }
+        } catch (Exception e) {
+            logger.error("NatOrderService#queryNatOrderListCommon(transactionId={} ):\n {} ", transactionId, e.getMessage(), e);
+        }
+
+        String paymentStartTime = request.getPaymentStartTime().trim();
+        String paymentEndTime = request.getPaymentEndTime().trim();
+        Map<String, Object> map = sqlHelper.timeQuerySql(whereSql, paramList, "pay_time", paymentStartTime, paymentEndTime);
+
+        String refundStartTime = request.getRefundStartTime().trim();
+        String refundEndTime = request.getRefundEndTime().trim();
+        map = sqlHelper.timeQuerySql(map, "refund_time", refundStartTime, refundEndTime);
+
+        String confirmStartTime = request.getConfirmStartTime().trim();
+        String confirmEndTime = request.getConfirmEndTime().trim();
+        map = sqlHelper.timeQuerySql(map, "confirm_time", confirmStartTime, confirmEndTime, FormatUtil.FORMAT_DATE_SECOND);
+        return map;
+    }
+
+
+    public void downloadNatOrderList(int downloadRecordId, String fileName, NatOrderListRequest request) {
+        try {
+            String col1 = "订单号", col1_1 = "支付流水号", col1_1_1 = "交易流水号", col2 = "医院", col3 = "患者姓名", col4 = "身份证号", col5 = "年龄", col6 = "性别", col7 = "手机号";
+            String col8 = "缴费码", col9 = "疫苗码", col10 = "金额", col11 = "支付状态", col12 = "订单状态";
+            String col13 = "支付时间", col14 = "退费时间", col15 = "预约时间", col16 = "执行时间", col17 = "备注";
+            String[] columns = new String[]{col1, col1_1, col1_1_1, col2, col3, col4, col5, col6, col7, col8, col9, col10, col11, col12, col13, col14, col15, col16, col17};
+            ExcelDataMap map = new ExcelDataMap(columns);
+            List<NatOrder> list = queryNatOrderList(request);
+            int payTotal = 0, refundTotal = 0, realityTotal = 0;
+            List<OrderPayment> orderPaymentList = orderPaymentService.getOrderPaymentListByNatOrderList(list);
+            for (NatOrder item : list) {
+                // 交易流水号
+                String transactionId = orderPaymentService.getTransactionIdByOrderId(orderPaymentList, Checker.getIntegerValue(item.getOrderId()));
+                map.getStringListSafely(col1).add(Checker.getStringValue(item.getOrderNo()));
+                map.getStringListSafely(col1_1).add(Checker.getStringValue(item.getPaymentNo()));
+                map.getStringListSafely(col1_1_1).add(transactionId);
+                map.getStringListSafely(col2).add(hospitalCacheService.getCacheHospitalNameByHospitalId(item.getHospitalId()));
+                map.getStringListSafely(col3).add(Checker.getStringValue(item.getPatientName()));
+                map.getStringListSafely(col4).add(Checker.getStringValue(item.getIdCard()));
+                String idCard = Checker.getStringValue(item.getIdCard());
+                if (!Checker.isNone(idCard)) {
+                    int currentAge = IdCardUtil.getCurrentAge(idCard);
+                    String sex = IdCardUtil.getSex(idCard);
+                    map.getStringListSafely(col5).add(currentAge + "");
+                    map.getStringListSafely(col6).add(sex);
+                }
+
+                map.getStringListSafely(col7).add(Checker.getStringValue(item.getMobile()));
+
+                map.getStringListSafely(col8).add(Checker.getStringValue(item.getPaymentCode()));
+                map.getStringListSafely(col9).add(Checker.getStringValue(item.getVaccineCode()));
+                map.getStringListSafely(col10).add(FormatUtil.intShrink100ToStr(item.getAmount()));
+                map.getStringListSafely(col11).add(PaymentStatusEnum.getPaymentStatus(item.getPaymentStatus()).getDisplayName());
+                map.getStringListSafely(col12).add(NatOrderStatusEnum.valueOf(item.getStatus()).getDisplayName());
+
+                map.getStringListSafely(col13).add(FormatUtil.createTimeFormatDetail(item.getPayTime()));
+                map.getStringListSafely(col14).add(FormatUtil.createTimeFormatDetail(item.getRefundTime()));
+                map.getStringListSafely(col15).add(FormatUtil.formatDate(item.getRegDate()) + " " + DatePeriodEnum.valueOf(item.getRegTimePeriod()).getDisplayName());
+                map.getStringListSafely(col16).add(FormatUtil.createTimeFormatDetail(item.getConfirmTime()));
+                map.getStringListSafely(col17).add(Checker.getStringValue(item.getRemark()));
+
+                if (Checker.getIntegerValue(item.getPaymentStatus()) == PaymentStatusEnum.Success.getValue()) {
+                    payTotal += Checker.getIntegerValue(item.getAmount());
+                }
+                if (Checker.getIntegerValue(item.getRefundStatus()) == RefundStatusEnum.SUCCESS.getValue()) {
+                    refundTotal += Checker.getIntegerValue(item.getAmount());
+                }
+            }
+            int size = list.size();
+            List<ExcelCollectPojo> itemList = getStatisticsData(size, payTotal, refundTotal);
+            downloadRecordService.createFileAndUploadOssAndSaveToDataBase(fileName, downloadRecordId, map, itemList);
+
+        } catch (Exception e) {
+            logger.error("/natOrder/downloadNatOrderList: {}", e.getMessage(), e);
+            e.printStackTrace();
+        }
+    }
+
+    private List<ExcelCollectPojo> getStatisticsData(int size, int payTotal, int refundTotal) {
+        int startRows = size + 3;
+        int startColumn = 3;
+
+        List<ExcelCollectPojo> customExcelItemList = new ArrayList<>();
+        customExcelItemList.add(new ExcelCollectPojo(startColumn + 1, startRows + 1, new String[]{"支付总额", FormatUtil.intShrink100ToStr(payTotal)}));
+        customExcelItemList.add(new ExcelCollectPojo(startColumn + 1, startRows + 2, new String[]{"退款总额", FormatUtil.intShrink100ToStr(refundTotal)}));
+        customExcelItemList.add(new ExcelCollectPojo(startColumn + 1, startRows + 3, new String[]{"实际支付金额", FormatUtil.intShrink100ToStr(payTotal - refundTotal)}));
+        return customExcelItemList;
+    }
+}

+ 2 - 1
src/main/java/com/ywt/mg/services/OutpatientOrderService.java

@@ -247,7 +247,7 @@ public class OutpatientOrderService {
                 }
             }
         } catch (Exception e) {
-            logger.error("PrescriptionServices#getQueryMapCommonNew(transactionId={} ):\n {} ", transactionId, e.getMessage(), e);
+            logger.error("OutpatientOrderService#queryOutPatientOrderListCommonNew(transactionId={} ):\n {} ", transactionId, e.getMessage(), e);
         }
 
         whereSql += " and ( deleted = 0 )";
@@ -517,6 +517,7 @@ public class OutpatientOrderService {
             List<ExcelCollectPojo> itemList = new ArrayList<>();
             downloadRecordService.createFileAndUploadOssAndSaveToDataBase(fileName, downloadRecordId, map, itemList);
         } catch (Exception e) {
+            logger.error("/registeredOrder/downloadRegisteredOrderList: {}", e.getMessage(), e);
             e.printStackTrace();
         }
     }

+ 110 - 0
src/main/java/com/ywt/mg/services/PharmacyCacheService.java

@@ -0,0 +1,110 @@
+package com.ywt.mg.services;
+
+import com.ywt.mg.core.SqlHelper;
+import com.ywt.mg.core.utils.CacheUtil;
+import com.ywt.mg.core.utils.Checker;
+import com.ywt.mg.core.utils.CollectionUtil;
+import com.ywt.mg.domain.ywtDrugEntities.Pharmacy;
+import com.ywt.mg.domain.ywtDrugEntities.PharmacyRepository;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Service;
+
+import java.util.HashMap;
+import java.util.LinkedList;
+import java.util.List;
+import java.util.Map;
+import java.util.stream.Collectors;
+
+@Service
+public class PharmacyCacheService {
+
+    private static Logger logger = LoggerFactory.getLogger(PharmacyCacheService.class);
+
+    private final String PHARMACY_LIST = "PharmacyList";
+    private final String Pharmacy_MAP = "PharmacyMap";
+
+    @Autowired
+    private PharmacyRepository pharmacyRepository;
+
+    @Autowired
+    private SqlHelper sqlHelperYwtcenter;
+
+    /**
+     * 从数据库返回所有药房数据
+     *
+     * @return
+     */
+    public List<Pharmacy> getPharmacyList() {
+        try {
+            List<Pharmacy> pharmacyList = getAllPharmacyList();
+            if (!Checker.isNone(pharmacyList)) {
+                // display:0-显示,1-不显示, status: 0-正常,1-禁用
+                // todo: status,不管禁用不禁用,都展示
+                return pharmacyList.stream().filter(p -> Checker.getIntegerValue(p.getDisplay()) == 0).collect(Collectors.toList());
+            }
+        } catch (Exception e) {
+        }
+        return new LinkedList<>();
+    }
+
+    /**
+     * 从数据库返回所有药房数据
+     *
+     * @return
+     */
+    public List<Pharmacy> getAllPharmacyList() {
+        try {
+            return pharmacyRepository.getAllPharmacyList();
+        } catch (Exception e) {
+        }
+        return new LinkedList<>();
+    }
+
+    /**
+     * 从缓存中返回药房医院
+     *
+     * @return
+     */
+    public List<Pharmacy> getPharmacyListHigh() {
+        try {
+            return (List<Pharmacy>) CacheUtil.getInstance().get(PHARMACY_LIST, () -> getAllPharmacyList());
+        } catch (Exception e) {
+            logger.error("PharmacyCacheService#getPharmacyListHigh():\n {}", e.getMessage(), e);
+        }
+        return new LinkedList<>();
+    }
+
+    /**
+     * 从缓存中返回所有药房 Map by ID
+     *
+     * @return {@link Map<Integer, Pharmacy>}
+     */
+    public Map<Integer, Pharmacy> getPharmacyMap() {
+        try {
+            return (Map<Integer, Pharmacy>) CacheUtil.getInstance().get(Pharmacy_MAP, () -> CollectionUtil.toMap(getPharmacyListHigh(), Pharmacy::getId));
+        } catch (Exception e) {
+            logger.error("PharmacyCacheService#getPharmacyMap():\n {}", e.getMessage(), e);
+        }
+        return new HashMap<>();
+    }
+
+    public Pharmacy getPharmacyById(int id) {
+        Map<Integer, Pharmacy> map = getPharmacyMap();
+        Pharmacy pharmacy = map.getOrDefault(id, null);
+        return pharmacy;
+    }
+
+
+    public String getPharmacyNameById(int id) {
+        Map<Integer, Pharmacy> map = getPharmacyMap();
+        Pharmacy pharmacy = map.getOrDefault(id, null);
+        if (pharmacy == null) {
+            return "";
+        }
+        return pharmacy.getName();
+    }
+
+
+}

+ 452 - 0
src/main/java/com/ywt/mg/services/PrescriptionServices.java

@@ -0,0 +1,452 @@
+package com.ywt.mg.services;
+
+import com.ywt.mg.core.utils.Checker;
+import com.ywt.mg.core.utils.DateUtil;
+import com.ywt.mg.core.utils.FormatUtil;
+import com.ywt.mg.domain.entities.OrderPayment;
+import com.ywt.mg.domain.models.ConstantDef;
+import com.ywt.mg.domain.models.ExcelDataMap;
+import com.ywt.mg.domain.models.enums.*;
+import com.ywt.mg.domain.ywtDrugEntities.Pharmacy;
+import com.ywt.mg.domain.ywtDrugEntities.PrescriptionInfo;
+import com.ywt.mg.params.prescription.QueryPrescriptionListRequest;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.jdbc.core.BeanPropertyRowMapper;
+import org.springframework.jdbc.core.JdbcTemplate;
+import org.springframework.stereotype.Service;
+
+import java.text.SimpleDateFormat;
+import java.util.*;
+
+@Service
+public class PrescriptionServices {
+
+    private static final Logger logger = LoggerFactory.getLogger(PrescriptionServices.class);
+
+
+    @Autowired
+    private JdbcTemplate ywtDrugJdbcTemplate;
+
+    @Autowired
+    private OrderPaymentService orderPaymentService;
+
+    @Autowired
+    private PharmacyCacheService pharmacyCacheService;
+
+    @Autowired
+    private CommonServices commonServices;
+
+
+    /**
+     * 根据条件查询用药记录
+     *
+     * @param request
+     * @return
+     */
+    public List<PrescriptionInfo> downloadPrescriptionlistNew(QueryPrescriptionListRequest request) {
+        Map<String, Object> map = getQueryMapCommonNew(request);
+        List<Object> paramList = (List<Object>) map.get("paramList");
+        String whereSql = (String) map.get("whereSql");
+
+        // 分页查找
+        StringBuilder sqlBuilder = new StringBuilder();
+        // 拼凑sql语句
+        sqlBuilder.append("select * from prescription_info where ")
+                .append(whereSql)
+                .append("order by create_on desc");
+        List<PrescriptionInfo> list = ywtDrugJdbcTemplate.query(sqlBuilder.toString(), paramList.toArray(), new BeanPropertyRowMapper<>(PrescriptionInfo.class));
+        return list;
+    }
+
+
+    /**
+     * 抽取公共的sql查找语句
+     */
+    public Map<String, Object> getQueryMapCommonNew(QueryPrescriptionListRequest request) {
+        List<Object> paramList = new ArrayList<>();
+        String whereSql = " ( 1=1 )";
+
+        String doctorname = request.getDoctorname();
+        if (!Checker.isNull(doctorname)) {
+            whereSql += " and ( doctor_name like ?)";
+            paramList.add("%" + doctorname + "%");
+        }
+
+        String patientname = request.getPatientname();
+        if (!Checker.isNull(patientname)) {
+            whereSql += " and ( patient_name like ?)";
+            paramList.add("%" + patientname + "%");
+        }
+        String deptname = request.getDeptname();
+        if (!Checker.isNull(deptname)) {
+            whereSql += " and ( dept like ?)";
+            paramList.add("%" + deptname + "%");
+        }
+        String source = request.getSource();
+        if (!Checker.isNull(source)) {
+            whereSql += " and ( source = ?)";
+            paramList.add(Integer.parseInt(source));
+        }
+        String pharmacyId = request.getPharmacyId();
+        if (!Checker.isNull(pharmacyId)) {
+            whereSql += " and ( pharmacy_id = ?)";
+            paramList.add(Integer.parseInt(pharmacyId));
+        }
+        String deliveryMethod = request.getDeliveryMethod();
+        if (!Checker.isNull(deliveryMethod)) {
+            whereSql += " and ( delivery_method = ?)";
+            paramList.add(Integer.parseInt(deliveryMethod));
+        }
+
+        // 1待支付,2-配送中/待取药,3、已完成(不包括已评价的),4、已退费,5、不通过 (存在ext_status字段),6、已评价, 7-已过期,8-待评价, 10-退费中
+        String status = request.getStatus();
+        if (!Checker.isNone(status)) {
+            int statusInt = Integer.parseInt(status);
+            if (statusInt == 1) {
+                // 只查找待支付的,不查找已过期的,需要计算时间
+                //把日期往后前推3天.整数往后推,负数往前移动
+                Date date = DateUtil.getRelativeDate(new Date(), ConstantDef.OVERDUE_DAY_NUM);
+                whereSql += " and ( status = ? and create_on > ? ) ";
+                paramList.add(statusInt);
+                paramList.add(date);
+            } else if (statusInt == 2) {
+                // 查找只是配送中/待取药 (不包含不通过的)
+                whereSql += " and ( ((ext_status & ?) != ? or ext_status is null) && status = ?  ) ";
+                paramList.add(PrescriptionInfoExtStatusEnum.PresNoPass.getValue());
+                paramList.add(PrescriptionInfoExtStatusEnum.PresNoPass.getValue());
+                paramList.add(PrescriptionInfoStatusEnum.Dispatching.getValue());
+            } else if (statusInt == 3) {
+                // 查找只是已完成的,只有广三的有已完成的状态
+                whereSql += " and ( status = ? and pharmacy_id = ? ) ";
+                paramList.add(PrescriptionInfoStatusEnum.Finished.getValue());
+                paramList.add(ConstantDef.GUANGSAN_PHARMACY_ID);
+            } else if (statusInt == 5) {
+                // 查找只是不通过的,退费的不找出来,已评价的也不找出来
+                whereSql += " and ( (ext_status & ?) = ? and ext_status < ? and status != ? ) ";
+                paramList.add(PrescriptionInfoExtStatusEnum.PresNoPass.getValue());
+                paramList.add(PrescriptionInfoExtStatusEnum.PresNoPass.getValue());
+                paramList.add(2 * PrescriptionInfoExtStatusEnum.PresNoPass.getValue());
+                paramList.add(PrescriptionInfoStatusEnum.HaveARefund.getValue());
+            } else if (statusInt == 6) {
+                // 查找已评价的
+                whereSql += " and ( (ext_status & ?) = ? and status != ? and pharmacy_id = ? ) ";
+                paramList.add(PrescriptionInfoExtStatusEnum.Evaluate.getValue());
+                paramList.add(PrescriptionInfoExtStatusEnum.Evaluate.getValue());
+                paramList.add(PrescriptionInfoStatusEnum.HaveARefund.getValue());
+                paramList.add(ConstantDef.TAIHE_PHARMACY_ID);
+            } else if (statusInt == 7) {
+                // 根据原型图,订单3天未支付,状态变为已过期
+                //把日期往后前推3天.整数往后推,负数往前移动
+                Date date = DateUtil.getRelativeDate(new Date(), ConstantDef.OVERDUE_DAY_NUM);
+                whereSql += " and ( status = ? or (status = ? and create_on < ?)) ";
+                paramList.add(PrescriptionInfoStatusEnum.EXPIRED.getValue());
+                paramList.add(PrescriptionInfoStatusEnum.WaitForPayment.getValue());
+                paramList.add(date);
+            } else if (statusInt == 8) {
+                // 查找只是待评价的, 顺丰返回完成状态,需要排除不通过的
+                whereSql += " and ( (ext_status & ?) != ? and status = ?  and (ext_status & ?) != ? and pharmacy_id = ?  ) ";
+                paramList.add(PrescriptionInfoExtStatusEnum.Evaluate.getValue());
+                paramList.add(PrescriptionInfoExtStatusEnum.Evaluate.getValue());
+                paramList.add(PrescriptionInfoStatusEnum.Finished.getValue());
+                paramList.add(PrescriptionInfoExtStatusEnum.PresNoPass.getValue());
+                paramList.add(PrescriptionInfoExtStatusEnum.PresNoPass.getValue());
+                paramList.add(ConstantDef.TAIHE_PHARMACY_ID);
+            } else if (statusInt == 10) {
+                whereSql += " and ( refund_status = ? ) ";
+                paramList.add(RefundStatusEnum.PENDING.getValue());
+            } else {
+                whereSql += " and ( status = ? ) and ( refund_status != ?  or refund_status is null )   ";
+                paramList.add(statusInt);
+                paramList.add(RefundStatusEnum.PENDING.getValue());
+            }
+        }
+
+        String paymentStatus = request.getPaymentStatus();
+        if (!Checker.isNone(paymentStatus)) {
+            whereSql += " and ( payment_status = ? ) ";
+            paramList.add(Integer.parseInt(paymentStatus));
+        }
+
+        String preBizNo = request.getPreBizNo();
+        if (!Checker.isNone(preBizNo)) {
+            whereSql += " and ( pre_biz_no like ? ) ";
+            paramList.add("%" + preBizNo + "%");
+        }
+        String bizNo3th = request.getBizNo3th();
+        if (!Checker.isNone(bizNo3th)) {
+            whereSql += " and ( biz_no_3th like ? ) ";
+            paramList.add("%" + bizNo3th + "%");
+        }
+        String sendNo = request.getSendNo();
+        if (!Checker.isNone(sendNo)) {
+            whereSql += " and ( send_no like ? ) ";
+            paramList.add("%" + sendNo + "%");
+        }
+        String paymentChannel = request.getPaymentChannel();
+        if (!Checker.isNone(paymentChannel)) {
+            whereSql += " and ( payment_channel = ? ) ";
+            paramList.add(Integer.parseInt(paymentChannel));
+        }
+
+        String paymentNo = request.getPaymentNo();
+        if (!Checker.isNone(paymentNo)) {
+            whereSql += " and ( payment_no like ? ) ";
+            paramList.add("%" + paymentNo.trim() + "%");
+        }
+
+        String cancelStatus = request.getCancelStatus();
+        if (!Checker.isNone(cancelStatus)) {
+            whereSql += " and ( cancel_status = ? ) ";
+            paramList.add(Integer.parseInt(cancelStatus));
+        }
+
+        String orderNo = request.getOrderNo();
+        if (!Checker.isNone(orderNo)) {
+            whereSql += " and ( order_no like ? ) ";
+            paramList.add("%" + orderNo.trim() + "%");
+        }
+
+        String Format_Date = "yyyy-MM-dd";
+        SimpleDateFormat format = new SimpleDateFormat(Format_Date);
+
+        String createTimeEnd = request.getCreateTimeEnd();
+        String createTimeStart = request.getCreateTimeStart();
+        String payTimeEnd = request.getPayTimeEnd();
+        String payTimeStart = request.getPayTimeStart();
+        String refundTimeEnd = request.getRefundTimeEnd();
+        String refundTimeStart = request.getRefundTimeStart();
+        String billEndTime = request.getBillEndTime();
+        String billStartTime = request.getBillStartTime();
+        try {
+            // 创建时间
+            if (!Checker.isNull(createTimeEnd)) {
+                whereSql += " and ( create_on < ?)";
+                Date date = format.parse(createTimeEnd);
+                //把日期往后增加一天.整数往后推,负数往前移动
+                Calendar calendar = new GregorianCalendar();
+                calendar.setTime(date);
+                calendar.add(calendar.DATE, 1);
+                date = calendar.getTime();   //这个时间就是日期往后推一天的结果
+
+                paramList.add(date);
+            }
+            if (!Checker.isNull(createTimeStart)) {
+                whereSql += " and ( create_on >= ?)";
+                Date date = format.parse(createTimeStart);
+                paramList.add(date);
+            }
+
+            // 支付时间
+            if (!Checker.isNull(payTimeEnd)) {
+                whereSql += " and ( pay_time < ?)";
+                Date date = format.parse(payTimeEnd);
+                //把日期往后增加一天.整数往后推,负数往前移动
+                Calendar calendar = new GregorianCalendar();
+                calendar.setTime(date);
+                calendar.add(calendar.DATE, 1);
+                date = calendar.getTime();   //这个时间就是日期往后推一天的结果
+
+                paramList.add(date);
+            }
+            if (!Checker.isNull(payTimeStart)) {
+                whereSql += " and ( pay_time >= ?)";
+                Date date = format.parse(payTimeStart);
+                paramList.add(date);
+            }
+
+            // 退费时间搜索
+            if (!Checker.isNull(refundTimeEnd)) {
+                whereSql += " and (refund_time < ?)";
+                Date date = format.parse(refundTimeEnd);
+                //把日期往后增加一天.整数往后推,负数往前移动
+                Calendar calendar = new GregorianCalendar();
+                calendar.setTime(date);
+                calendar.add(calendar.DATE, 1);
+                date = calendar.getTime();   //这个时间就是日期往后推一天的结果
+
+                paramList.add(date);
+            }
+            if (!Checker.isNull(refundTimeStart)) {
+                whereSql += " and ( refund_time >= ?)";
+                Date date = format.parse(refundTimeStart);
+                paramList.add(date);
+            }
+            // 对账时间搜索
+            if (!Checker.isNull(billEndTime)) {
+                whereSql += " and ( pay_time < ? or refund_time < ?)";
+                Date date = format.parse(billEndTime);
+                //把日期往后增加一天.整数往后推,负数往前移动
+                Calendar calendar = new GregorianCalendar();
+                calendar.setTime(date);
+                calendar.add(calendar.DATE, 1);
+                date = calendar.getTime();   //这个时间就是日期往后推一天的结果
+
+                paramList.add(date);
+                paramList.add(date);
+            }
+            if (!Checker.isNull(billStartTime)) {
+                whereSql += " and ( pay_time >= ? or refund_time >= ?)";
+                Date date = format.parse(billStartTime);
+                paramList.add(date);
+                paramList.add(date);
+            }
+
+        } catch (Exception e) {
+            e.printStackTrace();
+            logger.error("getQueryMapCommonNew():createTimeEnd:{}\t,createTimeStart:{}\t,payTimeEnd:{}\t,payTimeStart:{}\t," +
+                            "refundTimeEnd:{}\t,refundTimeStart:{}\t,billEndTime:{}\t,billStartTime:{}\t", createTimeEnd, createTimeStart, payTimeEnd,
+                    payTimeStart, refundTimeEnd, refundTimeStart, billEndTime, billStartTime);
+        }
+
+        String transactionId = request.getTransactionId();
+        try {
+            // 处理交易流水号,考虑到性能,直接采用全匹配到方式
+            if (!Checker.isNull(transactionId)) {
+                OrderPayment orderPayment = orderPaymentService.getOrderPaymentByTransactionId(transactionId);
+                if (!Checker.isNone(orderPayment)) {
+                    whereSql += " and ( order_id = ? )";
+                    paramList.add(orderPayment.getOrderId());
+                } else {
+                    whereSql += " and ( order_id = -1 )";
+                }
+            }
+        } catch (Exception e) {
+            logger.error("PrescriptionServices#getQueryMapCommonNew(transactionId={} ):\n {} ", transactionId, e.getMessage(), e);
+        }
+        Map map = new HashMap();
+        map.put("whereSql", whereSql);
+        map.put("paramList", paramList);
+        return map;
+    }
+
+
+    public void downloadPrescriptionlist(int downloadRecordId, String fileName, QueryPrescriptionListRequest request) {
+        try {
+            String col0 = "订单号";
+            String col1 = "支付流水号";
+            String col2 = "取药方式";
+            String col3 = "医生姓名";
+            String col4 = "患者姓名";
+            String col5 = "来源";
+            String col6 = "药房";
+            String col7 = "状态";
+            String col8 = "支付状态";
+            String col9 = "支付渠道";
+            String col10 = "总金额";
+            String col11 = "创建时间";
+            String col12 = "支付时间";
+            String col13 = "退款时间";
+            String col14 = "退款状态";
+            String col15 = "退费流水号";
+            String col16 = "备注";
+            String col17 = "作废状态";
+            String col18 = "作废备注";
+
+            String[] columns = new String[]{col0, col1, col2, col3, col4, col5, col6, col7, col8, col9, col10,
+                    col11, col12, col13, col14, col15, col16, col17, col18};
+            int payTotal = 0, refundTotal = 0, realTotal = 0,
+                    weChatPay = 0, weChatRefundTotal = 0, weChatRealTotal = 0,
+                    aliPay = 0, aliRefundTotal = 0, aliRealTotal = 0,
+                    cashPay = 0, cashRefundTotal = 0, cashRealTotal = 0,
+                    medicalCardPay = 0, medicalCardRefundTotal = 0, medicalCardRealTotal = 0,
+                    posPay = 0, posRefundTotal = 0, posRealTotal = 0,
+                    medicalInsurancePay = 0, medicalInsuranceRefundTotal = 0, medicalInsuranceRealTotal = 0,
+                    icbcPay = 0, icbcRefundTotal = 0, icbcRealTotal = 0;
+            List<PrescriptionInfo> prescriptionInfoList = downloadPrescriptionlistNew(request);
+            ExcelDataMap map = new ExcelDataMap(columns);
+            if (!Checker.isNone(prescriptionInfoList)) {
+                SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm");
+
+                Map<Integer, Pharmacy> pharmacyMap = pharmacyCacheService.getPharmacyMap();
+                for (PrescriptionInfo p : prescriptionInfoList) {
+
+                    map.getStringListSafely(col0).add(p.getOrderNo());
+                    map.getStringListSafely(col1).add(p.getPaymentNo());
+                    int deliveryMethodInt = Checker.getIntegerValue(p.getDeliveryMethod());
+                    String deliveryMethodStr = getDeliveryMethodStr(deliveryMethodInt);
+//                        map.getStringListSafely(col2).add(transactionId);
+                    map.getStringListSafely(col3).add(p.getDoctorName());
+                    map.getStringListSafely(col4).add(p.getPatientName());
+                    String sourceStr = PrescriptionInfoSourceEnum.getSource(p.getSource()).getDisplayName();
+                    map.getStringListSafely(col5).add(sourceStr);
+                    Pharmacy pharmacy = pharmacyMap.get(Checker.getIntegerValue(p.getPharmacyId()));
+                    String pharmacyName = !Checker.isNone(pharmacy) ? pharmacy.getName() : "";
+                    String statusStr = getPrescriptionInfoStatusStr(p);
+                    map.getStringListSafely(col6).add(pharmacyName);
+                    map.getStringListSafely(col7).add(statusStr);
+                    map.getStringListSafely(col8).add(PaymentStatusEnum.getPaymentStatus(p.getPaymentStatus()).getDisplayName());
+                    map.getStringListSafely(col9).add(PresPaymentChannelEnum.valueOf(Checker.getIntegerValue(p.getPaymentChannel())).getDisplayName());
+                    String total = FormatUtil.decimalFormat(p.getTotalPrice() / 100.0);
+                    map.getStringListSafely(col10).add(total);
+                    map.getStringListSafely(col11).add(sdf.format(p.getCreateOn()));
+                    String payTime = !Checker.isNone(p.getPayTime()) ? sdf.format(p.getPayTime()) : "";
+                    map.getStringListSafely(col12).add(payTime);
+                    String refundTime = !Checker.isNone(p.getRefundTime()) ? sdf.format(p.getRefundTime()) : "";
+                    String refundStatus = Checker.isNone(p.getRefundStatus()) ? "" : RefundStatusEnum.getDisplayName(p.getRefundStatus());
+                    map.getStringListSafely(col13).add(refundTime);
+                    map.getStringListSafely(col14).add(refundStatus);
+                    map.getStringListSafely(col15).add(Checker.getStringValue(p.getRefundNo()));
+                    map.getStringListSafely(col16).add( Checker.getStringValue(p.getRemarks()));
+                    int cancelStatusInt = Checker.getIntegerValue(p.getCancelStatus());
+                    String cancelStatusStr = getPrescriptionInfoCancelStatusStr(cancelStatusInt);
+                    map.getStringListSafely(col17).add(cancelStatusStr);
+                    map.getStringListSafely(col18).add(Checker.getStringValue(p.getCancelRemark()));
+
+                }
+
+            }
+        } catch (Exception e) {
+            e.printStackTrace();
+        }
+    }
+
+    /**
+     * 得到处方的配送方法
+     *
+     * @param value 1-快递,2-自取
+     * @return 中文状态
+     */
+    private String getDeliveryMethodStr(int value) {
+        if (value == 1) {
+            return "快递";
+        }
+        if (value == 2) {
+            return "自取";
+        }
+        return "";
+    }
+
+    /**
+     * 公司后台:得到处方状态
+     * <p>
+     * pharmacyId :1 - 医院生殖中心1楼药房(广三),2-南方医院太和分院药房(太和)
+     *
+     * @param p {@link PrescriptionInfo}
+     * @return 处方状态
+     */
+    public String getPrescriptionInfoStatusStr(PrescriptionInfo p) {
+        return commonServices.getCompanyPrescriptionStatusStr(p);
+    }
+
+    /**
+     * 0-初始状态,1-作废申请中,2-已作废,3-作废失败
+     *
+     * @param cancelStatusInt 作废状态(数字)
+     * @return 作废状态
+     */
+    public String getPrescriptionInfoCancelStatusStr(int cancelStatusInt) {
+        switch (cancelStatusInt) {
+            case 1:
+                return "作废申请中";
+            case 2:
+                return "已作废";
+            case 3:
+                return "作废失败";
+            default:
+                return "";
+        }
+    }
+
+}

+ 4 - 4
src/main/java/com/ywt/mg/services/RegisteredOrderService.java

@@ -317,7 +317,7 @@ public class RegisteredOrderService {
 
     public void downloadRegisteredOrderList(int downloadRecordId, String fileName, RegisteredOrderListRequest request) {
         try {
-            int hospitalId = Checker.getIntegerValue(request.getHospitalId());
+            int hosp = Checker.getIntegerValue(request.getHosp());
 //            String[] titleStr = {"订单号", "支付流水号", "交易流水号", "患者姓名", "患者手机号", "诊疗卡",
 //                    "医生姓名", "科室", "金额", "就诊时间", "来源", "类型",
 //                    "订单状态", "支付状态", "下单时间", "备注"};
@@ -341,7 +341,7 @@ public class RegisteredOrderService {
 
             String[] columns = new String[]{col0, col1, col2, col3, col4, col5, col6, col7, col8, col9, col10,
                     col11, col12, col13, col14, col15};
-            if (hospitalId > 0) {
+            if (hosp > 0) {
                 columns = new String[]{col0, col1, col4, col5, col6, col7, col8, col9, col10,
                         col11};
             }
@@ -360,7 +360,7 @@ public class RegisteredOrderService {
                     // 金额
                     String totalStr = FormatUtil.intShrink100ToStr(p.getTotal());
                     // 就诊时间
-                    String registeredTime = sdf2.format(p.getRegisteredDate()) + "\t" + p.getStartTime() + "~" + p.getEndTime();
+                    String registeredTime = sdf2.format(p.getRegisteredDate()) + "  " + p.getStartTime() + "~" + p.getEndTime();
                     // 来源
                     String source = TerminalEnum.valueOf(p.getSource()).getDisplayName();
                     // 类型
@@ -392,7 +392,7 @@ public class RegisteredOrderService {
                     if (Checker.getIntegerValue(p.getRefundStatus()) == RefundStatusEnum.SUCCESS.getValue()) {
                         refundTotal += Checker.getIntegerValue(p.getTotal());
                     }
-                    if (hospitalId > 0) {
+                    if (hosp > 0) {
                         map.getStringListSafely(col0).add(p.getOrderNo());
                         map.getStringListSafely(col1).add(p.getPaymentNo());
 //                        map.getStringListSafely(col2).add(transactionId);

+ 1 - 0
src/main/java/com/ywt/mg/web/controllers/DepositController.java

@@ -52,6 +52,7 @@ public class DepositController {
 //            hospital = authService.getCurrentHospitalId();
 //            request.setHospitalId(hospital);
 //        }
+        request.setHosp(0);
         int downloadRecordId = idGenerator.genDownloadRecordId();
         String name = "公司后台-订单管理-住院押金";
         String fileName = "押金缴费记录";

+ 71 - 0
src/main/java/com/ywt/mg/web/controllers/NatOrderController.java

@@ -0,0 +1,71 @@
+package com.ywt.mg.web.controllers;
+
+import com.ywt.mg.core.MGRight;
+import com.ywt.mg.core.utils.Checker;
+import com.ywt.mg.core.utils.serializers.JsonSerializer;
+import com.ywt.mg.domain.models.ConstantDef;
+import com.ywt.mg.params.natOrder.NatOrderListRequest;
+import com.ywt.mg.services.AuthService;
+import com.ywt.mg.services.DownloadRecordService;
+import com.ywt.mg.services.IdGenerator;
+import com.ywt.mg.services.NatOrderService;
+import com.ywt.mg.web.BaseResponse;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.web.bind.annotation.RequestBody;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RestController;
+
+
+@RestController("/natOrder")
+@RequestMapping({"/natOrder"})
+@MGRight
+public class NatOrderController {
+
+    private static Logger logger = LoggerFactory.getLogger(NatOrderController.class);
+
+
+    @Autowired
+    private IdGenerator idGenerator;
+
+    @Autowired
+    private DownloadRecordService downloadRecordService;
+
+    @Autowired
+    private AuthService authService;
+
+    @Autowired
+    private NatOrderService natOrderService;
+
+
+    @RequestMapping({"/downloadNatOrderList"})
+    public BaseResponse downloadNatOrderList(@RequestBody NatOrderListRequest request) {
+        int currentAdminId = Checker.getIntegerValue(authService.getCurrentAdminId());
+//        request.setCurrentAdminId(currentAdminId);
+        // 插入记录
+        int  hospital = authService.getCurrentHospitalId();
+        request.setHospitalId(hospital);
+//        if(request.getHosp() > 0){
+//            hospital = authService.getCurrentHospitalId();
+//            request.setHospitalId(hospital);
+//        }
+        int downloadRecordId = idGenerator.genDownloadRecordId();
+        String name = "公司后台-订单管理-核酸检测";
+        String fileName = "核酸检测记录";
+        String excelSuffixFormat = ConstantDef.EXCEL_SUFFIX_FORMAT;
+        String paramUrl = "/natOrder/downloadNatOrderList";
+        String paramJson = JsonSerializer.toJson(request);
+        downloadRecordService.getOrInsertDownloadRecord(downloadRecordId, name, fileName + excelSuffixFormat, paramUrl, paramJson);
+        Thread t = new Thread() {
+            @Override
+            public void run() {
+                natOrderService.downloadNatOrderList(downloadRecordId, fileName, request);
+//
+            }
+        };
+        t.start();
+        return new BaseResponse().succeed("后台下载中...");
+    }
+
+}

+ 1 - 0
src/main/java/com/ywt/mg/web/controllers/RegisteredOrderController.java

@@ -47,6 +47,7 @@ public class RegisteredOrderController {
 //            hospital = authService.getCurrentHospitalId();
 //        }
 //        request.setHospitalId(hospital);
+        request.setHosp(0);
         int downloadRecordId = idGenerator.genDownloadRecordId();
         String name = "公司后台-订单管理-挂号订单";
         String fileName = "挂号订单记录";

+ 1 - 0
src/main/java/com/ywt/mg/web/controllers/hospital/HospDepositController.java

@@ -53,6 +53,7 @@ public class HospDepositController {
 //            hospital = authService.getCurrentHospitalId();
 //            request.setHospitalId(hospital);
 //        }
+        request.setHosp(1);
         int downloadRecordId = idGenerator.genDownloadRecordId();
         String name = "医院后台-订单管理-住院押金";
         String fileName = "押金缴费记录";

+ 69 - 0
src/main/java/com/ywt/mg/web/controllers/hospital/HospNatOrderController.java

@@ -0,0 +1,69 @@
+package com.ywt.mg.web.controllers.hospital;
+
+import com.ywt.mg.core.MGRight;
+import com.ywt.mg.core.utils.Checker;
+import com.ywt.mg.core.utils.serializers.JsonSerializer;
+import com.ywt.mg.domain.models.ConstantDef;
+import com.ywt.mg.params.deposit.QueryDepositListRequest;
+import com.ywt.mg.params.natOrder.NatOrderListRequest;
+import com.ywt.mg.services.AuthService;
+import com.ywt.mg.services.DownloadRecordService;
+import com.ywt.mg.services.IdGenerator;
+import com.ywt.mg.services.NatOrderService;
+import com.ywt.mg.web.BaseResponse;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.web.bind.annotation.RequestBody;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RestController;
+
+@RestController("/hosp/natOrder")
+@RequestMapping({"/hosp/natOrder"})
+@MGRight
+public class HospNatOrderController {
+
+    private static Logger logger = LoggerFactory.getLogger(HospNatOrderController.class);
+
+    @Autowired
+    private IdGenerator idGenerator;
+
+    @Autowired
+    private DownloadRecordService downloadRecordService;
+
+    @Autowired
+    private AuthService authService;
+
+    @Autowired
+    private NatOrderService natOrderService;
+
+
+    @RequestMapping({"/downloadNatOrderList"})
+    public BaseResponse downloadNatOrderList(@RequestBody NatOrderListRequest request) {
+        int currentAdminId = Checker.getIntegerValue(authService.getCurrentAdminId());
+//        request.setCurrentAdminId(currentAdminId);
+        // 插入记录
+        int  hospital = authService.getCurrentHospitalId();
+        request.setHospitalId(hospital);
+//        if(request.getHosp() > 0){
+//            hospital = authService.getCurrentHospitalId();
+//            request.setHospitalId(hospital);
+//        }
+        int downloadRecordId = idGenerator.genDownloadRecordId();
+        String name = "医院后台-订单管理-核酸检测";
+        String fileName = "核酸检测记录";
+        String excelSuffixFormat = ConstantDef.EXCEL_SUFFIX_FORMAT;
+        String paramUrl = "/hosp/natOrder/downloadNatOrderList";
+        String paramJson = JsonSerializer.toJson(request);
+        downloadRecordService.getOrInsertDownloadRecord(downloadRecordId, name, fileName + excelSuffixFormat, paramUrl, paramJson);
+        Thread t = new Thread() {
+            @Override
+            public void run() {
+                natOrderService.downloadNatOrderList(downloadRecordId, fileName, request);
+//
+            }
+        };
+        t.start();
+        return new BaseResponse().succeed("后台下载中...");
+    }
+}

+ 64 - 0
src/main/java/com/ywt/mg/web/controllers/hospital/HospOfflineController.java

@@ -0,0 +1,64 @@
+package com.ywt.mg.web.controllers.hospital;
+
+import com.ywt.mg.core.MGRight;
+import com.ywt.mg.core.utils.Checker;
+import com.ywt.mg.core.utils.serializers.JsonSerializer;
+import com.ywt.mg.domain.models.ConstantDef;
+import com.ywt.mg.params.offline.DownloadOfflineListNewRequest;
+import com.ywt.mg.services.AuthService;
+import com.ywt.mg.services.DownloadRecordService;
+import com.ywt.mg.services.IdGenerator;
+import com.ywt.mg.services.OfflineNewService;
+import com.ywt.mg.web.BaseResponse;
+import com.ywt.mg.web.controllers.OfflineController;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RestController;
+
+@RestController("/hosp/offline")
+@RequestMapping({"/hosp/offline"})
+@MGRight
+public class HospOfflineController {
+
+    private static Logger logger = LoggerFactory.getLogger(HospOfflineController.class);
+
+    @Autowired
+    private AuthService authService;
+
+    @Autowired
+    private OfflineNewService offlineNewService;
+
+    @Autowired
+    private IdGenerator idGenerator;
+
+    @Autowired
+    private DownloadRecordService downloadRecordService;
+
+
+    @RequestMapping({"/downloadOfflineList"})
+    public BaseResponse downloadOfflineList(DownloadOfflineListNewRequest request) {
+        int currentAdminId = Checker.getIntegerValue(authService.getCurrentAdminId());
+        request.setCurrentAdminId(currentAdminId);
+        // 插入记录
+        int  hospital = authService.getCurrentHospitalId();
+        request.setHospitalId(hospital);
+        int downloadRecordId = idGenerator.genDownloadRecordId();
+        String name = "医院后台-订单管理-线下就诊";
+        String fileName = "线下就诊记录";
+        String excelSuffixFormat = ConstantDef.EXCEL_SUFFIX_FORMAT;
+        String paramUrl = "/hosp/offline/downloadOfflineList";
+        String paramJson = JsonSerializer.toJson(request);
+        downloadRecordService.getOrInsertDownloadRecord(downloadRecordId, name, fileName + excelSuffixFormat, paramUrl, paramJson);
+        Thread t = new Thread() {
+            @Override
+            public void run() {
+                offlineNewService.downloadOfflineListCommon(downloadRecordId, fileName, request);
+            }
+        };
+        t.start();
+        return new BaseResponse().succeed("后台下载中...");
+    }
+
+}

+ 1 - 0
src/main/java/com/ywt/mg/web/controllers/hospital/HospRegisteredOrderController.java

@@ -49,6 +49,7 @@ public class HospRegisteredOrderController {
           int  hospital = authService.getCurrentHospitalId();
 //        }
         request.setHospitalId(hospital);
+        request.setHosp(1);
         int downloadRecordId = idGenerator.genDownloadRecordId();
         String name = "医院后台-订单管理-挂号订单";
         String fileName = "挂号订单记录";