Selaa lähdekoodia

feature: 订单下载

wuyongyi 2 vuotta sitten
vanhempi
commit
ebf9602864
49 muutettua tiedostoa jossa 6724 lisäystä ja 6 poistoa
  1. 5 1
      config_fillters/filters-dev.properties
  2. 1 0
      config_fillters/filters-preproduct.properties
  3. 1 0
      config_fillters/filters-product.properties
  4. 1 0
      config_fillters/filters-test.properties
  5. 12 1
      src/main/java/com/ywt/mg/configs/Beans.java
  6. 21 0
      src/main/java/com/ywt/mg/configs/Constants.java
  7. 20 0
      src/main/java/com/ywt/mg/configs/Datasources.java
  8. 60 0
      src/main/java/com/ywt/mg/configs/jpa/YwtMealConfig.java
  9. 13 0
      src/main/java/com/ywt/mg/core/utils/BizUtil.java
  10. 25 0
      src/main/java/com/ywt/mg/core/utils/FormatUtil.java
  11. 15 0
      src/main/java/com/ywt/mg/core/utils/PaymentChannelUtil.java
  12. 622 0
      src/main/java/com/ywt/mg/domain/entities/MedicalCard.java
  13. 13 0
      src/main/java/com/ywt/mg/domain/entities/MedicalCardRepository.java
  14. 15 0
      src/main/java/com/ywt/mg/domain/entities/OutpatientOrder.java
  15. 149 0
      src/main/java/com/ywt/mg/domain/mealEntities/OrderDish.java
  16. 19 0
      src/main/java/com/ywt/mg/domain/mealEntities/OrderDishRepository.java
  17. 275 0
      src/main/java/com/ywt/mg/domain/mealEntities/Shop.java
  18. 36 0
      src/main/java/com/ywt/mg/domain/mealEntities/ShopRepository.java
  19. 382 0
      src/main/java/com/ywt/mg/domain/mealEntities/UserMealOrderView.java
  20. 14 0
      src/main/java/com/ywt/mg/domain/mealEntities/UserMealOrderViewRepository.java
  21. 36 0
      src/main/java/com/ywt/mg/domain/models/enums/MealPaymentStatusEnum.java
  22. 106 0
      src/main/java/com/ywt/mg/domain/models/enums/NutrimealOrderStatusEnum.java
  23. 56 0
      src/main/java/com/ywt/mg/domain/models/enums/NutrimealOrderTypeEnum.java
  24. 35 0
      src/main/java/com/ywt/mg/domain/models/enums/NutrimealPaymentStatusEnum.java
  25. 37 0
      src/main/java/com/ywt/mg/domain/models/enums/OrderPayTypeEnum.java
  26. 52 0
      src/main/java/com/ywt/mg/domain/models/pojo/CustomExcelItem.java
  27. 130 0
      src/main/java/com/ywt/mg/params/checkupBooking/QueryCheckUpOrderListRequest.java
  28. 274 0
      src/main/java/com/ywt/mg/params/deposit/DepositOrderInfo.java
  29. 120 0
      src/main/java/com/ywt/mg/params/deposit/QueryDepositListRequest.java
  30. 262 0
      src/main/java/com/ywt/mg/params/mealOrder/MealOrderListRequest.java
  31. 215 0
      src/main/java/com/ywt/mg/params/outpatientOrder/QueryOutPatientOrderListRequest.java
  32. 199 0
      src/main/java/com/ywt/mg/params/registeredOrder/RegisteredOrderListRequest.java
  33. 317 0
      src/main/java/com/ywt/mg/services/CheckUpOrderService.java
  34. 422 0
      src/main/java/com/ywt/mg/services/DepositService.java
  35. 38 0
      src/main/java/com/ywt/mg/services/DownloadRecordService.java
  36. 814 0
      src/main/java/com/ywt/mg/services/MealOrderService.java
  37. 69 0
      src/main/java/com/ywt/mg/services/OrderDishService.java
  38. 42 3
      src/main/java/com/ywt/mg/services/OrderPaymentService.java
  39. 530 0
      src/main/java/com/ywt/mg/services/OutpatientOrderService.java
  40. 619 0
      src/main/java/com/ywt/mg/services/RegisteredOrderService.java
  41. 27 0
      src/main/java/com/ywt/mg/services/ShopService.java
  42. 41 0
      src/main/java/com/ywt/mg/services/UserService.java
  43. 96 0
      src/main/java/com/ywt/mg/web/common/ExcelDownloadSrv.java
  44. 84 0
      src/main/java/com/ywt/mg/web/controllers/CheckUpOrderController.java
  45. 87 0
      src/main/java/com/ywt/mg/web/controllers/DepositController.java
  46. 142 0
      src/main/java/com/ywt/mg/web/controllers/MealOrderController.java
  47. 83 0
      src/main/java/com/ywt/mg/web/controllers/OutpatientOrderController.java
  48. 78 0
      src/main/java/com/ywt/mg/web/controllers/RegisteredOrderController.java
  49. 14 1
      src/main/resources/application.properties

+ 5 - 1
config_fillters/filters-dev.properties

@@ -3,6 +3,8 @@ db.ywtcenter.username=ywt_qa
 db.ywtcenter.password=Ywtqa123456x*#
 
 db.ywtdrug.url=jdbc:mysql://rm-wz9a76b4u608w6f0efo.mysql.rds.aliyuncs.com:3306/ywt_drug?characterEncoding=utf8&useSSL=false&useOldAliasMetadataBehavior=true&autoReconnect=true
+db.nutrimeal.url=jdbc:mysql://rm-wz9a76b4u608w6f0efo.mysql.rds.aliyuncs.com:3306/nutrimeal?characterEncoding=utf8&useSSL=false&useOldAliasMetadataBehavior=true&autoReconnect=true
+
 
 logging.level.root=INFO
 
@@ -15,4 +17,6 @@ ywt.env.test=true
 # 测试数据
 test.doctor.ids=10178,112,10179,10470,7,10533
 test.admin.ids=1,7,10
-test.doctor.codes=169
+test.doctor.codes=169
+
+

+ 1 - 0
config_fillters/filters-preproduct.properties

@@ -3,6 +3,7 @@ db.ywtcenter.username=ywt_qa
 db.ywtcenter.password=Ywtqa123456x*#
 
 db.ywtdrug.url=jdbc:mysql://rm-wz9a76b4u608w6f0efo.mysql.rds.aliyuncs.com:3306/ywt_drug?characterEncoding=utf8&useSSL=false&useOldAliasMetadataBehavior=true&autoReconnect=true
+db.nutrimeal.url=jdbc:mysql://rm-wz9a76b4u608w6f0efo.mysql.rds.aliyuncs.com:3306/nutrimeal?characterEncoding=utf8&useSSL=false&useOldAliasMetadataBehavior=true&autoReconnect=true
 
 logging.level.root=DEBUG
 

+ 1 - 0
config_fillters/filters-product.properties

@@ -3,6 +3,7 @@ db.ywtcenter.username=ywt_qa
 db.ywtcenter.password=Ywtqa123456x*#
 
 db.ywtdrug.url=jdbc:mysql://rm-wz9a76b4u608w6f0efo.mysql.rds.aliyuncs.com:3306/ywt_drug?characterEncoding=utf8&useSSL=false&useOldAliasMetadataBehavior=true&autoReconnect=true
+db.nutrimeal.url=jdbc:mysql://rm-wz9a76b4u608w6f0efo.mysql.rds.aliyuncs.com:3306/nutrimeal?characterEncoding=utf8&useSSL=false&useOldAliasMetadataBehavior=true&autoReconnect=true
 
 logging.level.root=DEBUG
 

+ 1 - 0
config_fillters/filters-test.properties

@@ -3,6 +3,7 @@ db.ywtcenter.username=ywt_qa
 db.ywtcenter.password=Ywtqa123456x*#
 
 db.ywtdrug.url=jdbc:mysql://rm-wz9a76b4u608w6f0efo.mysql.rds.aliyuncs.com:3306/ywt_drug?characterEncoding=utf8&useSSL=false&useOldAliasMetadataBehavior=true&autoReconnect=true
+db.nutrimeal.url=jdbc:mysql://rm-wz9a76b4u608w6f0efo.mysql.rds.aliyuncs.com:3306/nutrimeal?characterEncoding=utf8&useSSL=false&useOldAliasMetadataBehavior=true&autoReconnect=true
 
 logging.level.root=DEBUG
 

+ 12 - 1
src/main/java/com/ywt/mg/configs/Beans.java

@@ -38,6 +38,12 @@ public class Beans {
     @Qualifier("ywtDrugJdbcTemplate")
     private JdbcTemplate ywtDrugJdbcTemplate;
 
+
+    @Autowired
+    @Qualifier("nutrimealJdbcTemplate")
+    private JdbcTemplate nutrimealJdbcTemplate;
+
+
     @Bean(name = "jedisCommandsClient")
     public JedisCommands getjedisCommands() {
         ShardedJedisProxy shardedJedisProxy = new ShardedJedisProxy(redisCacheManager);
@@ -55,9 +61,14 @@ public class Beans {
     public SqlHelper getSqlHelperywtDrug() {
         return new SqlHelper(ywtDrugJdbcTemplate);
     }
+    @Bean(name = "sqlHelperNutrimeal")
+    public SqlHelper getSqlHelperNutrimeal() {
+        return new SqlHelper(nutrimealJdbcTemplate);
+    }
+
 
     @Bean(name = "restCaller")
-    public RestCaller restCaller(){
+    public RestCaller restCaller() {
         return new RestCaller(restServiceAgent);
     }
 

+ 21 - 0
src/main/java/com/ywt/mg/configs/Constants.java

@@ -13,5 +13,26 @@ public class Constants {
 
 
     public static final String CHARSET_NAME = "iso-8859-1";
+
+    public static final String PARAM_LIST = "PARAM_LIST";
+
+    /**
+     * 常量,标记sql语句
+     */
+    public static final String WHERE_SQL = "WHERE_SQL";
+
+
+    /**
+     * 太和医院名称
+     */
+    public static final String HOSPITAL_NAME_TAIHE = "南方医院太和分院";
+
+    /**
+     * 南方医科大学南方医院白云分院 名称
+     */
+    public static final String HOSPITAL_NAME_NFYYBYFY = "南方医科大学南方医院白云分院";
+
+    public static final int HOSPITAL_ID_TAIHE = 12;
+    public static final int HOSPITAL_ID_NFYYBYFY = 41;
 }
 

+ 20 - 0
src/main/java/com/ywt/mg/configs/Datasources.java

@@ -34,6 +34,15 @@ public class Datasources {
         return DataSourceBuilder.create().build();
     }
 
+    /**
+     * 营养餐数据库的配置
+     */
+    @Bean(name = "ywtMealDataSource")
+    @Qualifier("ywtMealDataSource")
+    @ConfigurationProperties(prefix="spring.datasource.ywtMeal")
+    public DataSource ywtMealDataSource(){
+        return DataSourceBuilder.create().build();
+    }
 
     /**
      * 注入 ywt_center 数据库
@@ -59,4 +68,15 @@ public class Datasources {
         return new JdbcTemplate(dataSource);
     }
 
+    /**
+     * 注入 nutrimeal 数据库
+     *
+     * @param dataSource
+     * @return
+     */
+    @Bean(name = "nutrimealJdbcTemplate")
+    public JdbcTemplate nutrimealJdbcTemplate(@Qualifier("ywtMealDataSource") DataSource dataSource) {
+        return new JdbcTemplate(dataSource);
+    }
+
 }

+ 60 - 0
src/main/java/com/ywt/mg/configs/jpa/YwtMealConfig.java

@@ -0,0 +1,60 @@
+package com.ywt.mg.configs.jpa;
+
+
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.beans.factory.annotation.Qualifier;
+import org.springframework.boot.autoconfigure.orm.jpa.JpaProperties;
+import org.springframework.boot.orm.jpa.EntityManagerFactoryBuilder;
+import org.springframework.context.annotation.Bean;
+import org.springframework.context.annotation.Configuration;
+import org.springframework.data.jpa.repository.config.EnableJpaRepositories;
+import org.springframework.orm.jpa.JpaTransactionManager;
+import org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean;
+import org.springframework.transaction.PlatformTransactionManager;
+import org.springframework.transaction.annotation.EnableTransactionManagement;
+
+import javax.persistence.EntityManager;
+import javax.sql.DataSource;
+import java.util.Map;
+
+
+@Configuration
+@EnableTransactionManagement
+@EnableJpaRepositories(
+        entityManagerFactoryRef = "entityManagerFactoryMeal",
+        transactionManagerRef = "transactionManagerMeal",
+        basePackages = {"com.ywt.mg.domain.mealEntities"}
+)
+public class YwtMealConfig {
+    @Autowired
+    @Qualifier("ywtMealDataSource")
+    private DataSource ywtMealDataSource;
+
+    @Bean(name = "entityManagerMeal")
+    public EntityManager entityManager(EntityManagerFactoryBuilder builder) {
+        return entityManagerFactory(builder).getObject().createEntityManager();
+    }
+
+    @Bean(name = "entityManagerFactoryMeal")
+    public LocalContainerEntityManagerFactoryBean entityManagerFactory(EntityManagerFactoryBuilder builder) {
+        return builder
+                .dataSource(ywtMealDataSource)
+                .properties(getVendorProperties(ywtMealDataSource))
+                .packages("com.ywt.mg.domain.mealEntities") //设置实体类所在位置
+                .persistenceUnit("ywtMealPersistenceUnit")
+                .build();
+    }
+
+    @Autowired
+    private JpaProperties jpaProperties;
+
+    private Map<String, String> getVendorProperties(DataSource dataSource) {
+        return jpaProperties.getHibernateProperties(dataSource);
+    }
+
+
+    @Bean(name = "transactionManagerMeal")
+    public PlatformTransactionManager transactionManager(EntityManagerFactoryBuilder builder) {
+        return new JpaTransactionManager(entityManagerFactory(builder).getObject());
+    }
+}

+ 13 - 0
src/main/java/com/ywt/mg/core/utils/BizUtil.java

@@ -2,6 +2,7 @@ package com.ywt.mg.core.utils;
 
 
 import com.google.gson.JsonObject;
+import com.ywt.mg.configs.Constants;
 import com.ywt.mg.domain.models.enums.TerminalEnum;
 
 import java.util.Map;
@@ -166,4 +167,16 @@ public final class BizUtil {
         int suffixLength = suffix.length();
         return str.regionMatches(true, str.length() - suffixLength, suffix, 0, suffixLength);
     }
+
+
+    public static String getHospitalNameByHospitalId(int hospitalId) {
+        switch (hospitalId) {
+            default:
+                return "";
+            case Constants.HOSPITAL_ID_TAIHE:
+                return Constants.HOSPITAL_NAME_TAIHE;
+            case Constants.HOSPITAL_ID_NFYYBYFY:
+                return Constants.HOSPITAL_NAME_NFYYBYFY;
+        }
+    }
 }

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

@@ -1,8 +1,11 @@
 package com.ywt.mg.core.utils;
 
+import com.fasterxml.jackson.core.type.TypeReference;
+import com.fasterxml.jackson.databind.ObjectMapper;
 import com.google.gson.Gson;
 import com.ywt.mg.core.utils.serializers.JsonSerializer;
 
+import java.io.IOException;
 import java.math.BigDecimal;
 import java.text.DecimalFormat;
 import java.text.ParseException;
@@ -319,5 +322,27 @@ public class FormatUtil {
         // 再对日期格式化,得到每天的截止时间
         return FormatUtil.stringToDate(value, FormatUtil.FORMAT_DATE_SECOND);
     }
+
+    /**
+     * string 转 map,仅适用于json格式的string,eg:{"refuseOrderRemark":"this is add remark","company":{"companyName":"中华","address":"北京"},"username":"tom"}
+     *
+     * @param data
+     * @return
+     * @throws Exception
+     */
+    public static Map<String, Object> stringToMapT(String data) {
+        if (StringHelper.isNullOrWhiteSpace(data)) {
+            data = "{}";
+        }
+        ObjectMapper mapper = new ObjectMapper();
+        TypeReference<HashMap<String,Object>> typeRef
+                = new TypeReference<HashMap<String,Object>>() {};
+        try {
+            return mapper.readValue(data, typeRef);
+        } catch (IOException e) {
+            e.printStackTrace();
+        }
+        return new HashMap<>();
+    }
 }
 

+ 15 - 0
src/main/java/com/ywt/mg/core/utils/PaymentChannelUtil.java

@@ -0,0 +1,15 @@
+package com.ywt.mg.core.utils;
+
+public class PaymentChannelUtil {
+
+    public static final int NF_HOSPITAL_BY_PATIENT_MINI_PROGRAM_ZFB = 24;
+
+    public static final int NF_HOSPITAL_TH_PATIENT_MINI_PROGRAM_ZFB = 25;
+
+    public static String paymentChannel(int terminal) {
+        if (terminal == NF_HOSPITAL_BY_PATIENT_MINI_PROGRAM_ZFB || terminal == NF_HOSPITAL_TH_PATIENT_MINI_PROGRAM_ZFB) {
+            return "支付宝";
+        }
+        return "微信";
+    }
+}

+ 622 - 0
src/main/java/com/ywt/mg/domain/entities/MedicalCard.java

@@ -0,0 +1,622 @@
+package com.ywt.mg.domain.entities;
+
+import javax.persistence.Column;
+import javax.persistence.Entity;
+import javax.persistence.Id;
+import javax.persistence.Table;
+import java.io.Serializable;
+import java.util.Date;
+
+@Entity
+@Table(name = "medical_card")
+public class MedicalCard implements Serializable {
+
+    private static final long serialVersionUID = 1L;
+
+    /**
+     * 主键
+     */
+    @Id
+    @Column(name = "id", nullable = false)
+    private Integer id;
+
+    /**
+     * 用户Id
+     */
+    @Column(name = "user_id", nullable = false)
+    private Integer userId;
+
+    /**
+     * 医院Id
+     */
+    @Column(name = "hospital_id", nullable = false)
+    private Integer hospitalId;
+
+    /**
+     * 卡号
+     */
+    @Column(name = "card_no", nullable = false)
+    private String cardNo;
+
+    /**
+     * 卡类型
+     */
+    @Column(name = "card_type")
+    private String cardType;
+
+    /**
+     * 姓名
+     */
+    @Column(name = "patient_name", nullable = false)
+    private String patientName;
+
+    /**
+     * 手机号
+     */
+    @Column(name = "mobile", nullable = false)
+    private String mobile;
+
+    /**
+     * 性别(0-未知 1-男 2-女)
+     */
+    @Column(name = "sex", nullable = false)
+    private Integer sex;
+
+    /**
+     * 出生日期
+     */
+    @Column(name = "birthday")
+    private String birthday;
+
+    /**
+     * 家庭住址
+     */
+    @Column(name = "address")
+    private String address;
+
+    /**
+     * 联系电话
+     */
+    @Column(name = "telephone_no")
+    private String telephoneNo;
+
+    /**
+     * 病案号
+     */
+    @Column(name = "document_id")
+    private String documentId;
+
+    /**
+     * 账户余额(以分为单位)
+     */
+    @Column(name = "balance", nullable = false)
+    private Integer balance;
+
+    /**
+     * 证件类型(代码)
+     */
+    @Column(name = "id_type_code")
+    private String idTypeCode;
+
+    /**
+     * 证件类型(描述)
+     */
+    @Column(name = "id_type_desc")
+    private String idTypeDesc;
+
+    /**
+     * 证件号
+     */
+    @Column(name = "id_no")
+    private String idNo;
+
+    /**
+     * 医保卡号
+     */
+    @Column(name = "insure_card_no")
+    private String insureCardNo;
+
+    /**
+     * 账户信息
+     */
+    @Column(name = "acc_info")
+    private String accInfo;
+
+    /**
+     * 病人类型
+     */
+    @Column(name = "patient_type")
+    private String patientType;
+
+    /**
+     * 状态(1-正常,2-删除)
+     */
+    @Column(name = "status", nullable = false)
+    private Integer status;
+
+    /**
+     * 修改时间(上次使用时间)
+     */
+    @Column(name = "update_time")
+    private Date updateTime;
+
+    /**
+     * 创建时间
+     */
+    @Column(name = "create_time", nullable = false)
+    private Date createTime;
+
+    @Column(name = "his_patient_id")
+    private String hisPatientId;
+
+    /**
+     * 监护人(家长姓名)
+     */
+    @Column(name = "guardian")
+    private String guardian;
+
+    /**
+     * 最后(上一次)的选择,0-否,1-是
+     */
+    @Column(name = "last_choice")
+    private Boolean lastChoice;
+
+    /**
+     * 上一次 HIS 同步的时间戳
+     */
+    @Column(name = "his_sync_time")
+    private Date hisSyncTime;
+
+    /**
+     * 上次选择时间
+     */
+    @Column(name = "last_chosen_time")
+    private Date lastChosenTime;
+
+    /**
+     * 与本人关系:1-本人,2-家庭成员,3-亲戚,4-朋友,5-其他
+     */
+    @Column(name = "relationship")
+    private Integer relationship;
+
+    /**
+     * 是否是默认卡,0-不是,1-是
+     */
+    @Column(name = "default_card")
+    private Boolean defaultCard;
+
+    /**
+     * 主键
+     */
+    public void setId(Integer id) {
+        this.id = id;
+    }
+
+    /**
+     * 主键
+     */
+    public Integer getId() {
+        return id;
+    }
+
+    /**
+     * 用户Id
+     */
+    public void setUserId(Integer userId) {
+        this.userId = userId;
+    }
+
+    /**
+     * 用户Id
+     */
+    public Integer getUserId() {
+        return userId;
+    }
+
+    /**
+     * 医院Id
+     */
+    public void setHospitalId(Integer hospitalId) {
+        this.hospitalId = hospitalId;
+    }
+
+    /**
+     * 医院Id
+     */
+    public Integer getHospitalId() {
+        return hospitalId;
+    }
+
+    /**
+     * 卡号
+     */
+    public void setCardNo(String cardNo) {
+        this.cardNo = cardNo;
+    }
+
+    /**
+     * 卡号
+     */
+    public String getCardNo() {
+        return cardNo;
+    }
+
+    /**
+     * 卡类型
+     */
+    public void setCardType(String cardType) {
+        this.cardType = cardType;
+    }
+
+    /**
+     * 卡类型
+     */
+    public String getCardType() {
+        return cardType;
+    }
+
+    /**
+     * 姓名
+     */
+    public void setPatientName(String patientName) {
+        this.patientName = patientName;
+    }
+
+    /**
+     * 姓名
+     */
+    public String getPatientName() {
+        return patientName;
+    }
+
+    /**
+     * 手机号
+     */
+    public void setMobile(String mobile) {
+        this.mobile = mobile;
+    }
+
+    /**
+     * 手机号
+     */
+    public String getMobile() {
+        return mobile;
+    }
+
+    /**
+     * 性别(0-未知 1-男 2-女)
+     */
+    public void setSex(Integer sex) {
+        this.sex = sex;
+    }
+
+    /**
+     * 性别(0-未知 1-男 2-女)
+     */
+    public Integer getSex() {
+        return sex;
+    }
+
+    /**
+     * 出生日期
+     */
+    public void setBirthday(String birthday) {
+        this.birthday = birthday;
+    }
+
+    /**
+     * 出生日期
+     */
+    public String getBirthday() {
+        return birthday;
+    }
+
+    /**
+     * 家庭住址
+     */
+    public void setAddress(String address) {
+        this.address = address;
+    }
+
+    /**
+     * 家庭住址
+     */
+    public String getAddress() {
+        return address;
+    }
+
+    /**
+     * 联系电话
+     */
+    public void setTelephoneNo(String telephoneNo) {
+        this.telephoneNo = telephoneNo;
+    }
+
+    /**
+     * 联系电话
+     */
+    public String getTelephoneNo() {
+        return telephoneNo;
+    }
+
+    /**
+     * 病案号
+     */
+    public void setDocumentId(String documentId) {
+        this.documentId = documentId;
+    }
+
+    /**
+     * 病案号
+     */
+    public String getDocumentId() {
+        return documentId;
+    }
+
+    /**
+     * 账户余额(以分为单位)
+     */
+    public void setBalance(Integer balance) {
+        this.balance = balance;
+    }
+
+    /**
+     * 账户余额(以分为单位)
+     */
+    public Integer getBalance() {
+        return balance;
+    }
+
+    /**
+     * 证件类型(代码)
+     */
+    public void setIdTypeCode(String idTypeCode) {
+        this.idTypeCode = idTypeCode;
+    }
+
+    /**
+     * 证件类型(代码)
+     */
+    public String getIdTypeCode() {
+        return idTypeCode;
+    }
+
+    /**
+     * 证件类型(描述)
+     */
+    public void setIdTypeDesc(String idTypeDesc) {
+        this.idTypeDesc = idTypeDesc;
+    }
+
+    /**
+     * 证件类型(描述)
+     */
+    public String getIdTypeDesc() {
+        return idTypeDesc;
+    }
+
+    /**
+     * 证件号
+     */
+    public void setIdNo(String idNo) {
+        this.idNo = idNo;
+    }
+
+    /**
+     * 证件号
+     */
+    public String getIdNo() {
+        return idNo;
+    }
+
+    /**
+     * 医保卡号
+     */
+    public void setInsureCardNo(String insureCardNo) {
+        this.insureCardNo = insureCardNo;
+    }
+
+    /**
+     * 医保卡号
+     */
+    public String getInsureCardNo() {
+        return insureCardNo;
+    }
+
+    /**
+     * 账户信息
+     */
+    public void setAccInfo(String accInfo) {
+        this.accInfo = accInfo;
+    }
+
+    /**
+     * 账户信息
+     */
+    public String getAccInfo() {
+        return accInfo;
+    }
+
+    /**
+     * 病人类型
+     */
+    public void setPatientType(String patientType) {
+        this.patientType = patientType;
+    }
+
+    /**
+     * 病人类型
+     */
+    public String getPatientType() {
+        return patientType;
+    }
+
+    /**
+     * 状态(1-正常,2-删除)
+     */
+    public void setStatus(Integer status) {
+        this.status = status;
+    }
+
+    /**
+     * 状态(1-正常,2-删除)
+     */
+    public Integer getStatus() {
+        return status;
+    }
+
+    /**
+     * 修改时间(上次使用时间)
+     */
+    public void setUpdateTime(Date updateTime) {
+        this.updateTime = updateTime;
+    }
+
+    /**
+     * 修改时间(上次使用时间)
+     */
+    public Date getUpdateTime() {
+        return updateTime;
+    }
+
+    /**
+     * 创建时间
+     */
+    public void setCreateTime(Date createTime) {
+        this.createTime = createTime;
+    }
+
+    /**
+     * 创建时间
+     */
+    public Date getCreateTime() {
+        return createTime;
+    }
+
+    public void setHisPatientId(String hisPatientId) {
+        this.hisPatientId = hisPatientId;
+    }
+
+    public String getHisPatientId() {
+        return hisPatientId;
+    }
+
+    /**
+     * 监护人(家长姓名)
+     */
+    public void setGuardian(String guardian) {
+        this.guardian = guardian;
+    }
+
+    /**
+     * 监护人(家长姓名)
+     */
+    public String getGuardian() {
+        return guardian;
+    }
+
+    /**
+     * 最后(上一次)的选择,0-否,1-是
+     */
+    public void setLastChoice(Boolean lastChoice) {
+        this.lastChoice = lastChoice;
+    }
+
+    /**
+     * 最后(上一次)的选择,0-否,1-是
+     */
+    public Boolean isLastChoice() {
+        return lastChoice;
+    }
+
+    /**
+     * 上一次 HIS 同步的时间戳
+     */
+    public void setHisSyncTime(Date hisSyncTime) {
+        this.hisSyncTime = hisSyncTime;
+    }
+
+    /**
+     * 上一次 HIS 同步的时间戳
+     */
+    public Date getHisSyncTime() {
+        return hisSyncTime;
+    }
+
+    /**
+     * 上次选择时间
+     */
+    public void setLastChosenTime(Date lastChosenTime) {
+        this.lastChosenTime = lastChosenTime;
+    }
+
+    /**
+     * 上次选择时间
+     */
+    public Date getLastChosenTime() {
+        return lastChosenTime;
+    }
+
+    /**
+     * 与本人关系:1-本人,2-家庭成员,3-亲戚,4-朋友,5-其他
+     */
+    public void setRelationship(Integer relationship) {
+        this.relationship = relationship;
+    }
+
+    /**
+     * 与本人关系:1-本人,2-家庭成员,3-亲戚,4-朋友,5-其他
+     */
+    public Integer getRelationship() {
+        return relationship;
+    }
+
+    /**
+     * 是否是默认卡,0-不是,1-是
+     */
+    public void setDefaultCard(Boolean defaultCard) {
+        this.defaultCard = defaultCard;
+    }
+
+    /**
+     * 是否是默认卡,0-不是,1-是
+     */
+    public Boolean isDefaultCard() {
+        return defaultCard;
+    }
+
+    @Override
+    public String toString() {
+        return "MedicalCard{" +
+                "id=" + id + '\'' +
+                "userId=" + userId + '\'' +
+                "hospitalId=" + hospitalId + '\'' +
+                "cardNo=" + cardNo + '\'' +
+                "cardType=" + cardType + '\'' +
+                "patientName=" + patientName + '\'' +
+                "mobile=" + mobile + '\'' +
+                "sex=" + sex + '\'' +
+                "birthday=" + birthday + '\'' +
+                "address=" + address + '\'' +
+                "telephoneNo=" + telephoneNo + '\'' +
+                "documentId=" + documentId + '\'' +
+                "balance=" + balance + '\'' +
+                "idTypeCode=" + idTypeCode + '\'' +
+                "idTypeDesc=" + idTypeDesc + '\'' +
+                "idNo=" + idNo + '\'' +
+                "insureCardNo=" + insureCardNo + '\'' +
+                "accInfo=" + accInfo + '\'' +
+                "patientType=" + patientType + '\'' +
+                "status=" + status + '\'' +
+                "updateTime=" + updateTime + '\'' +
+                "createTime=" + createTime + '\'' +
+                "hisPatientId=" + hisPatientId + '\'' +
+                "guardian=" + guardian + '\'' +
+                "lastChoice=" + lastChoice + '\'' +
+                "hisSyncTime=" + hisSyncTime + '\'' +
+                "lastChosenTime=" + lastChosenTime + '\'' +
+                "relationship=" + relationship + '\'' +
+                "defaultCard=" + defaultCard + '\'' +
+                '}';
+    }
+}

+ 13 - 0
src/main/java/com/ywt/mg/domain/entities/MedicalCardRepository.java

@@ -0,0 +1,13 @@
+package com.ywt.mg.domain.entities;
+
+import org.springframework.data.jpa.repository.JpaRepository;
+import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
+import org.springframework.data.jpa.repository.Query;
+
+import java.util.List;
+
+public interface MedicalCardRepository extends JpaRepository<MedicalCard, Integer>, JpaSpecificationExecutor<MedicalCard> {
+
+    @Query(value = "select * from medical_card where mobile = ? ;", nativeQuery = true)
+    List<MedicalCard> getCardByMobile(String patientmobile);
+}

+ 15 - 0
src/main/java/com/ywt/mg/domain/entities/OutpatientOrder.java

@@ -352,6 +352,13 @@ public class OutpatientOrder implements Serializable {
   @Column(name = "med_pay_url")
   private String medPayUrl;
 
+  /**
+   * 来源
+   */
+  @Column(name = "terminal")
+  private Integer terminal;
+
+
   public Integer getId() {
     return id;
   }
@@ -1146,6 +1153,14 @@ public class OutpatientOrder implements Serializable {
     this.medPayUrl = medPayUrl;
   }
 
+  public Integer getTerminal() {
+    return terminal;
+  }
+
+  public void setTerminal(Integer terminal) {
+    this.terminal = terminal;
+  }
+
   public String toString() {
     return "OutpatientOrder{id=" + id + 
       ", hospitalId=" + hospitalId + 

+ 149 - 0
src/main/java/com/ywt/mg/domain/mealEntities/OrderDish.java

@@ -0,0 +1,149 @@
+package com.ywt.mg.domain.mealEntities;
+
+import javax.persistence.Column;
+import javax.persistence.Entity;
+import javax.persistence.Id;
+import javax.persistence.Table;
+import java.util.Date;
+
+/**
+ *
+ * @author Walker
+ * Created on 2019/3/6
+ * Updated on 2919/06/03: Update comments.
+ * Updated on 2019.06.11: 增加 dish_name, dish_price, dish_package_fee 字段作为订单历史数据
+ */
+@Entity
+@Table(name = "order_dish")
+public class OrderDish {
+    @Id
+    private Integer id;
+    @Column(name = "dish_id", nullable = false)
+    private Integer dishId;
+    @Column(name = "create_time", nullable = false)
+    private Date createTime;
+    @Column(name = "update_time", nullable = false)
+    private Date updateTime;
+    @Column(name = "deleted", nullable = false)
+    private Integer deleted;
+    @Column(name = "order_id", nullable = false)
+    private Integer orderId;
+    @Column(name = "count", nullable = false)
+    private Integer count;
+    @Column(name = "dish_name")
+    private String dishName;
+    @Column(name = "dish_price")
+    private Integer dishPrice;
+    @Column(name = "dish_package_fee")
+    private Integer dishPackageFee;
+    @Column(name = "dish_coin")
+    private Integer dishCoin;
+    @Column(name = "dish_cost_price")
+    private Integer dishCostPrice;
+    @Column(name = "user_spec")
+    private String userSpec;
+
+    public Integer getId() {
+        return id;
+    }
+
+    public void setId(Integer id) {
+        this.id = id;
+    }
+
+    public Integer getDishId() {
+        return dishId;
+    }
+
+    public void setDishId(Integer dishId) {
+        this.dishId = dishId;
+    }
+
+    public Date getCreateTime() {
+        return createTime;
+    }
+
+    public void setCreateTime(Date createTime) {
+        this.createTime = createTime;
+    }
+
+    public Date getUpdateTime() {
+        return updateTime;
+    }
+
+    public void setUpdateTime(Date updateTime) {
+        this.updateTime = updateTime;
+    }
+
+    public Integer getDeleted() {
+        return deleted;
+    }
+
+    public void setDeleted(Integer deleted) {
+        this.deleted = deleted;
+    }
+
+    public Integer getOrderId() {
+        return orderId;
+    }
+
+    public void setOrderId(Integer orderId) {
+        this.orderId = orderId;
+    }
+
+    public Integer getCount() {
+        return count;
+    }
+
+    public void setCount(Integer count) {
+        this.count = count;
+    }
+
+    public String getDishName() {
+        return dishName;
+    }
+
+    public void setDishName(String dishName) {
+        this.dishName = dishName;
+    }
+
+    public Integer getDishPrice() {
+        return dishPrice;
+    }
+
+    public void setDishPrice(Integer dishPrice) {
+        this.dishPrice = dishPrice;
+    }
+
+    public Integer getDishPackageFee() {
+        return dishPackageFee;
+    }
+
+    public void setDishPackageFee(Integer dishPackageFee) {
+        this.dishPackageFee = dishPackageFee;
+    }
+
+    public Integer getDishCoin() {
+        return dishCoin;
+    }
+
+    public void setDishCoin(Integer dishCoin) {
+        this.dishCoin = dishCoin;
+    }
+
+    public Integer getDishCostPrice() {
+        return dishCostPrice;
+    }
+
+    public void setDishCostPrice(Integer dishCostPrice) {
+        this.dishCostPrice = dishCostPrice;
+    }
+
+    public String getUserSpec() {
+        return userSpec;
+    }
+
+    public void setUserSpec(String userSpec) {
+        this.userSpec = userSpec;
+    }
+}

+ 19 - 0
src/main/java/com/ywt/mg/domain/mealEntities/OrderDishRepository.java

@@ -0,0 +1,19 @@
+package com.ywt.mg.domain.mealEntities;
+
+import org.springframework.data.jpa.repository.JpaRepository;
+import org.springframework.data.jpa.repository.Query;
+
+import java.util.List;
+
+/**
+ * @author Walker
+ * Created on 2019/3/6
+ */
+public interface OrderDishRepository extends JpaRepository<OrderDish, Integer> {
+    // 获取 order_dish by orderId, 包括 deleted = 1 的历史菜品,通常用于获取订单菜品列表历史信息
+    @Query(value = "select * from order_dish where order_id = ? ;", nativeQuery = true)
+    List<OrderDish> getAllByOrderId(int orderId);
+
+    @Query(value = "select * from order_dish;", nativeQuery = true)
+    List<OrderDish> getAllOrderDishes();
+}

+ 275 - 0
src/main/java/com/ywt/mg/domain/mealEntities/Shop.java

@@ -0,0 +1,275 @@
+package com.ywt.mg.domain.mealEntities;
+
+import javax.persistence.Column;
+import javax.persistence.Entity;
+import javax.persistence.Id;
+import javax.persistence.Table;
+import java.sql.Time;
+import java.util.Date;
+
+/**
+ * @author Walker
+ * Created on 2019/3/6
+ */
+@Entity
+@Table(name = "shop")
+public class Shop {
+
+    @Id
+    private Integer id;
+    @Column(name = "name", nullable = false)
+    private String name;
+    @Column(name = "mobile")
+    private String mobile;
+    @Column(name = "create_time", nullable = false)
+    private Date create_time;
+    @Column(name = "update_time", nullable = false)
+    private Date update_time;
+    @Column(name = "deleted", nullable = false)
+    private Integer deleted;
+    @Column(name = "available", nullable = false)
+    private Integer available;
+    @Column(name = "address", nullable = false)
+    private String address;
+    @Column(name = "psw", nullable = false)
+    private String psw;
+    @Column(name = "logo")
+    private String logo;
+    @Column(name = "remark")
+    private String remark;
+    @Column(name = "delivery_fee")
+    private Integer deliveryFee;
+    @Column(name = "open_time")
+    private Time openTime;
+    @Column(name = "close_time")
+    private Time closeTime;
+    @Column(name = "hospital_id", nullable = false)
+    private Integer hospitalId;
+    @Column(name = "accept_order_timeout", nullable = false)
+    private Integer acceptOrderTimeout;
+    @Column(name = "auto_accept_order")
+    private Boolean autoAcceptOrder;
+    @Column(name = "biz_type")
+    private Integer bizType;
+    @Column(name = "delivery_type")
+    private Integer deliveryType;
+    @Column(name = "pc_create_order")
+    private Boolean pcCreateOrder;
+    @Column(name = "print_setting")
+    private Integer printSetting;
+    @Column(name = "weight")
+    private Integer weight;
+    @Column(name = "auto_print_tag")
+    private Boolean autoPrintTag;
+
+    /**
+     * 该店铺是否只允许职工下单:0-否,1-是
+     */
+    @Column(name = "staff_order_only")
+    private Boolean staffOrderOnly;
+    /**
+     * 是否允许商家编辑菜品:0-否,1-是
+     */
+    @Column(name = "merchant_edit_dish")
+    private Boolean merchantEditDish;
+
+    public Integer getId() {
+        return id;
+    }
+
+    public void setId(Integer id) {
+        this.id = id;
+    }
+
+    public String getName() {
+        return name;
+    }
+
+    public void setName(String name) {
+        this.name = name;
+    }
+
+    public String getMobile() {
+        return mobile;
+    }
+
+    public void setMobile(String mobile) {
+        this.mobile = mobile;
+    }
+
+    public Date getCreate_time() {
+        return create_time;
+    }
+
+    public void setCreate_time(Date create_time) {
+        this.create_time = create_time;
+    }
+
+    public Date getUpdate_time() {
+        return update_time;
+    }
+
+    public void setUpdate_time(Date update_time) {
+        this.update_time = update_time;
+    }
+
+    public Integer getDeleted() {
+        return deleted;
+    }
+
+    public void setDeleted(Integer deleted) {
+        this.deleted = deleted;
+    }
+
+    public Integer getAvailable() {
+        return available;
+    }
+
+    public void setAvailable(Integer available) {
+        this.available = available;
+    }
+
+    public String getAddress() {
+        return address;
+    }
+
+    public void setAddress(String address) {
+        this.address = address;
+    }
+
+    public String getPsw() {
+        return psw;
+    }
+
+    public void setPsw(String psw) {
+        this.psw = psw;
+    }
+
+    public String getLogo() {
+        return logo;
+    }
+
+    public void setLogo(String logo) {
+        this.logo = logo;
+    }
+
+    public String getRemark() {
+        return remark;
+    }
+
+    public void setRemark(String remark) {
+        this.remark = remark;
+    }
+
+    public Integer getDeliveryFee() {
+        return deliveryFee;
+    }
+
+    public void setDeliveryFee(Integer deliveryFee) {
+        this.deliveryFee = deliveryFee;
+    }
+
+    public Time getOpenTime() {
+        return openTime;
+    }
+
+    public void setOpenTime(Time openTime) {
+        this.openTime = openTime;
+    }
+
+    public Time getCloseTime() {
+        return closeTime;
+    }
+
+    public void setCloseTime(Time closeTime) {
+        this.closeTime = closeTime;
+    }
+
+    public Integer getHospitalId() {
+        return hospitalId;
+    }
+
+    public void setHospitalId(Integer hospitalId) {
+        this.hospitalId = hospitalId;
+    }
+
+    public Integer getAcceptOrderTimeout() {
+        return acceptOrderTimeout;
+    }
+
+    public void setAcceptOrderTimeout(Integer acceptOrderTimeout) {
+        this.acceptOrderTimeout = acceptOrderTimeout;
+    }
+
+    public Boolean getAutoAcceptOrder() {
+        return autoAcceptOrder;
+    }
+
+    public void setAutoAcceptOrder(Boolean autoAcceptOrder) {
+        this.autoAcceptOrder = autoAcceptOrder;
+    }
+
+    public Integer getBizType() {
+        return bizType;
+    }
+
+    public void setBizType(Integer bizType) {
+        this.bizType = bizType;
+    }
+
+    public Integer getDeliveryType() {
+        return deliveryType;
+    }
+
+    public void setDeliveryType(Integer deliveryType) {
+        this.deliveryType = deliveryType;
+    }
+
+    public Boolean getPcCreateOrder() {
+        return pcCreateOrder;
+    }
+
+    public void setPcCreateOrder(Boolean pcCreateOrder) {
+        this.pcCreateOrder = pcCreateOrder;
+    }
+
+    public Integer getPrintSetting() {
+        return printSetting;
+    }
+
+    public void setPrintSetting(Integer printSetting) {
+        this.printSetting = printSetting;
+    }
+
+    public Integer getWeight() {
+        return weight;
+    }
+
+    public void setWeight(Integer weight) {
+        this.weight = weight;
+    }
+
+    public Boolean getAutoPrintTag() {
+        return autoPrintTag;
+    }
+
+    public void setAutoPrintTag(Boolean autoPrintTag) {
+        this.autoPrintTag = autoPrintTag;
+    }
+
+    public Boolean getStaffOrderOnly() {
+        return staffOrderOnly;
+    }
+
+    public void setStaffOrderOnly(Boolean staffOrderOnly) {
+        this.staffOrderOnly = staffOrderOnly;
+    }
+
+    public Boolean getMerchantEditDish() {
+        return merchantEditDish;
+    }
+
+    public void setMerchantEditDish(Boolean merchantEditDish) {
+        this.merchantEditDish = merchantEditDish;
+    }
+}

+ 36 - 0
src/main/java/com/ywt/mg/domain/mealEntities/ShopRepository.java

@@ -0,0 +1,36 @@
+package com.ywt.mg.domain.mealEntities;
+
+import org.springframework.data.jpa.repository.JpaRepository;
+import org.springframework.data.jpa.repository.Query;
+
+import java.util.List;
+
+/**
+ * @author Walker
+ * Created on 2019/3/6
+ */
+public interface ShopRepository extends JpaRepository<Shop, Integer> {
+    @Query(value = "select * from shop where deleted = 0", nativeQuery = true)
+    List<Shop> getUndeletedShops();
+
+    @Query(value = "select * from shop order by weight desc; ", nativeQuery = true)
+    List<Shop> getAllShops();
+
+    @Query(value = "select * from shop where id = ? and deleted = 0 limit 1", nativeQuery = true)
+    Shop getById(int id);
+
+    @Query(value = "select * from shop where id = ? and deleted = 0 and available = 1 limit 1", nativeQuery = true)
+    Shop getAvailableShopById(int id);
+
+    @Query(value = "select * from shop where id = ? limit 1", nativeQuery = true)
+    Shop getByIdIncludingDeleted(int id);
+
+    @Query(value = "select * from shop where mobile = ? and psw = ? and deleted = 0 limit 1;", nativeQuery = true)
+    Shop getByMobileAndPsw(String mobile, String paw);
+
+    @Query(value = "select * from shop where mobile = ? and deleted = 0 limit 1;",nativeQuery = true)
+    Shop findOneByMobile(String mobile);
+
+    @Query(value = "select * from shop where name = ? and deleted = 0 limit 1;",nativeQuery = true)
+    Shop findOneByName(String mobile);
+}

+ 382 - 0
src/main/java/com/ywt/mg/domain/mealEntities/UserMealOrderView.java

@@ -0,0 +1,382 @@
+package com.ywt.mg.domain.mealEntities;
+
+import javax.persistence.Column;
+import javax.persistence.Entity;
+import javax.persistence.Id;
+import javax.persistence.Table;
+import java.io.Serializable;
+import java.util.Date;
+
+/**
+ * @author: daiyihua
+ * @date: 2019/3/9
+ */
+@Entity
+@Table(name = "user_meal_order_view")
+public class UserMealOrderView implements Serializable {
+    private static final long serialVersionUID = 1L;
+    @Column(name = "id", nullable = false)
+    @Id
+    private Integer id;
+
+    @Column(name = "order_id")
+    private String orderId;
+
+    @Column(name = "order_no")
+    private String orderNo;
+
+    @Column(name = "type")
+    private Integer type;
+
+    @Column(name = "status")
+    private Integer status;
+
+    @Column(name = "payment_status")
+    private Integer paymentStatus;
+
+    @Column(name = "delivery_fee")
+    private Integer deliveryFee;
+
+    @Column(name = "create_time", nullable = false)
+    private Date createTime;
+
+    @Column(name = "payment_time")
+    private Date paymentTime;
+
+    @Column(name = "delivery_time")
+    private Date deliveryTime;
+    /**
+     * 删除标识:0-未删除;1-已删除
+     */
+    @Column(name = "deleted", nullable = false)
+    private Boolean deleted;
+
+    @Column(name = "user_address_id")
+    private Integer userAddressId;
+
+    @Column(name = "contact_name")
+    private String contactName;
+
+    @Column(name = "mobile")
+    private String mobile;
+
+    @Column(name = "shop_id")
+    private int shopId;
+
+    @Column(name = "pay_type")
+    private int payType;
+
+    @Column(name = "payment_no")
+    private String paymentNo;
+
+    @Column(name = "refund_time")
+    private Date refundTime;
+
+    @Column(name = "ext_data")
+    private String extData;
+
+    @Column(name = "order_amount")
+    private Integer orderAmount;
+    @Column(name = "wechat_pay_amount")
+    private Integer wechatPayAmount;
+    @Column(name = "coin_pay_amount")
+    private Integer coinPayAmount;
+    @Column(name = "f2f_pay_amount")
+    private Integer f2fPayAmount;
+
+    @Column(name = "hospital_id", nullable = false)
+    private Integer hospitalId;
+    @Column(name = "pickup_code")
+    private String pickupCode;
+    @Column(name = "refund_status")
+    private Integer refundStatus;
+    /**
+     * 下单时记录职工科室信息
+     */
+    @Column(name = "dept_name")
+    private String deptName;
+    @Column(name = "staff_id")
+    private Integer staffId;
+    @Column(name = "ext_status")
+    private Integer extStatus;
+
+    public Integer getHospitalId() {
+        return hospitalId;
+    }
+
+    public void setHospitalId(Integer hospitalId) {
+        this.hospitalId = hospitalId;
+    }
+
+    public Integer getId() {
+        return id;
+    }
+
+    public void setId(Integer id) {
+        this.id = id;
+    }
+
+    public String getOrderId() {
+        return orderId;
+    }
+
+    public void setOrderId(String orderId) {
+        this.orderId = orderId;
+    }
+
+    public String getOrderNo() {
+        return orderNo;
+    }
+
+    public void setOrderNo(String orderNo) {
+        this.orderNo = orderNo;
+    }
+
+    public Integer getType() {
+        return type;
+    }
+
+    public void setType(Integer type) {
+        this.type = type;
+    }
+
+    public Integer getStatus() {
+        return status;
+    }
+
+    public void setStatus(Integer status) {
+        this.status = status;
+    }
+
+    public Integer getPaymentStatus() {
+        return paymentStatus;
+    }
+
+    public void setPaymentStatus(Integer paymentStatus) {
+        this.paymentStatus = paymentStatus;
+    }
+
+    public Integer getDeliveryFee() {
+        return deliveryFee;
+    }
+
+    public void setDeliveryFee(Integer deliveryFee) {
+        this.deliveryFee = deliveryFee;
+    }
+
+    public Date getCreateTime() {
+        return createTime;
+    }
+
+    public void setCreateTime(Date createTime) {
+        this.createTime = createTime;
+    }
+
+    public Date getPaymentTime() {
+        return paymentTime;
+    }
+
+    public void setPaymentTime(Date paymentTime) {
+        this.paymentTime = paymentTime;
+    }
+
+    public Date getDeliveryTime() {
+        return deliveryTime;
+    }
+
+    public void setDeliveryTime(Date deliveryTime) {
+        this.deliveryTime = deliveryTime;
+    }
+
+    public Integer getUserAddressId() {
+        return userAddressId;
+    }
+
+    public void setUserAddressId(Integer userAddressId) {
+        this.userAddressId = userAddressId;
+    }
+
+    public String getContactName() {
+        return contactName;
+    }
+
+    public void setContactName(String contactName) {
+        this.contactName = contactName;
+    }
+
+    public String getMobile() {
+        return mobile;
+    }
+
+    public void setMobile(String mobile) {
+        this.mobile = mobile;
+    }
+
+    public int getShopId() {
+        return shopId;
+    }
+
+    public void setShopId(int shopId) {
+        this.shopId = shopId;
+    }
+
+    public int getPayType() {
+        return payType;
+    }
+
+    public void setPayType(int payType) {
+        this.payType = payType;
+    }
+
+    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 String getExtData() {
+        return extData;
+    }
+
+    public void setExtData(String extData) {
+        this.extData = extData;
+    }
+
+    public Integer getOrderAmount() {
+        return orderAmount;
+    }
+
+    public void setOrderAmount(Integer orderAmount) {
+        this.orderAmount = orderAmount;
+    }
+
+    public Integer getWechatPayAmount() {
+        return wechatPayAmount;
+    }
+
+    public void setWechatPayAmount(Integer wechatPayAmount) {
+        this.wechatPayAmount = wechatPayAmount;
+    }
+
+    public Integer getCoinPayAmount() {
+        return coinPayAmount;
+    }
+
+    public void setCoinPayAmount(Integer coinPayAmount) {
+        this.coinPayAmount = coinPayAmount;
+    }
+
+    public Integer getF2fPayAmount() {
+        return f2fPayAmount;
+    }
+
+    public void setF2fPayAmount(Integer f2fPayAmount) {
+        this.f2fPayAmount = f2fPayAmount;
+    }
+
+    public String getPickupCode() {
+        return pickupCode;
+    }
+
+    public void setPickupCode(String pickupCode) {
+        this.pickupCode = pickupCode;
+    }
+
+    public Integer getRefundStatus() {
+        return refundStatus;
+    }
+
+    public void setRefundStatus(Integer refundStatus) {
+        this.refundStatus = refundStatus;
+    }
+
+    public Integer getStaffId() {
+        return staffId;
+    }
+
+    public void setStaffId(Integer staffId) {
+        this.staffId = staffId;
+    }
+
+    public Integer getExtStatus() {
+        return extStatus;
+    }
+
+    public void setExtStatus(Integer extStatus) {
+        this.extStatus = extStatus;
+    }
+
+
+    /**
+     * 删除标识:0-未删除;1-已删除
+     */
+    public void setDeleted(Boolean deleted) {
+        this.deleted = deleted;
+    }
+
+    /**
+     * 删除标识:0-未删除;1-已删除
+     */
+    public Boolean isDeleted() {
+        return deleted;
+    }
+
+    /**
+     * 下单时记录职工科室信息
+     */
+    public void setDeptName(String deptName) {
+        this.deptName = deptName;
+    }
+
+    /**
+     * 下单时记录职工科室信息
+     */
+    public String getDeptName() {
+        return deptName;
+    }
+
+    @Override
+    public String toString() {
+        return "UserMealOrderView{" +
+                "id=" + id + '\'' +
+                "orderId=" + orderId + '\'' +
+                "orderNo=" + orderNo + '\'' +
+                "type=" + type + '\'' +
+                "status=" + status + '\'' +
+                "paymentStatus=" + paymentStatus + '\'' +
+                "deliveryFee=" + deliveryFee + '\'' +
+                "createTime=" + createTime + '\'' +
+                "paymentTime=" + paymentTime + '\'' +
+                "deliveryTime=" + deliveryTime + '\'' +
+                "deleted=" + deleted + '\'' +
+                "userAddressId=" + userAddressId + '\'' +
+                "contactName=" + contactName + '\'' +
+                "mobile=" + mobile + '\'' +
+                "shopId=" + shopId + '\'' +
+                "payType=" + payType + '\'' +
+                "paymentNo=" + paymentNo + '\'' +
+                "refundTime=" + refundTime + '\'' +
+                "extData=" + extData + '\'' +
+                "orderAmount=" + orderAmount + '\'' +
+                "wechatPayAmount=" + wechatPayAmount + '\'' +
+                "coinPayAmount=" + coinPayAmount + '\'' +
+                "f2fPayAmount=" + f2fPayAmount + '\'' +
+                "hospitalId=" + hospitalId + '\'' +
+                "pickupCode=" + pickupCode + '\'' +
+                "refundStatus=" + refundStatus + '\'' +
+                "deptName=" + deptName + '\'' +
+                "staffId=" + staffId + '\'' +
+                "extStatus=" + extStatus + '\'' +
+                '}';
+    }
+}

+ 14 - 0
src/main/java/com/ywt/mg/domain/mealEntities/UserMealOrderViewRepository.java

@@ -0,0 +1,14 @@
+package com.ywt.mg.domain.mealEntities;
+
+import org.springframework.data.jpa.repository.JpaRepository;
+import org.springframework.data.jpa.repository.Query;
+
+/**
+ * @author: daiyihua
+ * @date: 2019/3/9
+ */
+public interface UserMealOrderViewRepository extends JpaRepository<UserMealOrderView, Integer> {
+
+    @Query(value = "select * from user_meal_order_view where order_no = ? limit 1;", nativeQuery = true)
+    public UserMealOrderView getUserMealOrderViewByOrderNo(String orderNo);
+}

+ 36 - 0
src/main/java/com/ywt/mg/domain/models/enums/MealPaymentStatusEnum.java

@@ -0,0 +1,36 @@
+package com.ywt.mg.domain.models.enums;
+
+public enum MealPaymentStatusEnum {
+
+    UNKNOWN("待支付", -1),
+    Pending("待支付", 0),
+    Processing("支付处理中", 1),
+    Success("支付成功", 2),
+    Failed("支付失败", 3);
+
+    private final String displayName;
+
+    private final int value;
+
+    MealPaymentStatusEnum(String displayName, int value) {
+        this.displayName = displayName;
+        this.value = value;
+    }
+
+    public String getDisplayName() {
+        return displayName;
+    }
+
+    public int getValue() {
+        return value;
+    }
+
+    public static MealPaymentStatusEnum valueOf(int value) {
+        for (MealPaymentStatusEnum typeEnum : MealPaymentStatusEnum.values()) {
+            if (typeEnum.value == value) {
+                return typeEnum;
+            }
+        }
+        return UNKNOWN;
+    }
+}

+ 106 - 0
src/main/java/com/ywt/mg/domain/models/enums/NutrimealOrderStatusEnum.java

@@ -0,0 +1,106 @@
+package com.ywt.mg.domain.models.enums;
+
+public enum NutrimealOrderStatusEnum {
+
+    UNPAID("待支付", 0),
+    PAID("已支付", 1),
+    ORDER_REC("已接单", 2),
+    DELIVERING("配送中", 4),
+    WAIT_FOR_PICKINGUP("待自取", 8),
+    FINISHED("已完成", 16),
+    CANCELED("已取消", 32),
+    REFUND("已退款", 64)
+    ;
+
+    private String name;
+    private int value;
+
+    NutrimealOrderStatusEnum(String name, int value) {
+        this.name = name;
+        this.value = value;
+    }
+
+    public String getName() {
+        return name;
+    }
+
+    public int getValue() {
+        return value;
+    }
+
+//    public static String getDisplayName(int value) {
+//        for (OrderStatusEnum orderStatusEnum : values()) {
+//            if (orderStatusEnum.value == value) return orderStatusEnum.name;
+//        }
+//        return "";
+//    }
+
+
+    public static String getDisplayName(int value) {
+        /** 方式一:
+         for (MealOrderStatusEnum statusEnum : MealOrderStatusEnum.values()) {
+         if ((statusEnum.value & value) == statusEnum.value && value < 2 * statusEnum.value) {
+         return statusEnum.name;
+         }
+         }
+         return "";
+         */
+
+        /**
+         * 方式二:
+         */
+        if ((REFUND.value & value) == REFUND.value && (CANCELED.value & value) == CANCELED.value) {
+            return REFUND.name;
+        }
+        if ((CANCELED.value & value) == CANCELED.value) {
+            return CANCELED.name;
+        }
+        if ((FINISHED.value & value) == FINISHED.value) {
+            return FINISHED.name;
+        }
+        if ((WAIT_FOR_PICKINGUP.value & value) == WAIT_FOR_PICKINGUP.value) {
+            return WAIT_FOR_PICKINGUP.name;
+        }
+        if ((DELIVERING.value & value) == DELIVERING.value) {
+            return DELIVERING.name;
+        }
+        if ((ORDER_REC.value & value) == ORDER_REC.value) {
+            return ORDER_REC.name;
+        }
+        if ((PAID.value & value) == PAID.value) {
+            return PAID.name;
+        }
+        if ((UNPAID.value & value) == UNPAID.value) {
+            return UNPAID.name;
+        }
+        return "";
+    }
+
+    public static int getEnumValue(int value) {
+        if ((REFUND.value & value) == REFUND.value && (CANCELED.value & value) == CANCELED.value) {
+            return REFUND.value;
+        }
+        if ((CANCELED.value & value) == CANCELED.value) {
+            return CANCELED.value;
+        }
+        if ((FINISHED.value & value) == FINISHED.value) {
+            return FINISHED.value;
+        }
+        if ((WAIT_FOR_PICKINGUP.value & value) == WAIT_FOR_PICKINGUP.value) {
+            return WAIT_FOR_PICKINGUP.value;
+        }
+        if ((DELIVERING.value & value) == DELIVERING.value) {
+            return DELIVERING.value;
+        }
+        if ((ORDER_REC.value & value) == ORDER_REC.value) {
+            return ORDER_REC.value;
+        }
+        if ((PAID.value & value) == PAID.value) {
+            return PAID.value;
+        }
+        if ((UNPAID.value & value) == UNPAID.value) {
+            return UNPAID.value;
+        }
+        return UNPAID.value;
+    }
+}

+ 56 - 0
src/main/java/com/ywt/mg/domain/models/enums/NutrimealOrderTypeEnum.java

@@ -0,0 +1,56 @@
+package com.ywt.mg.domain.models.enums;
+
+public enum NutrimealOrderTypeEnum {
+
+    UNKNOWN("未知订单类型", 0),
+    DELIVERY("配送", 1),
+    DOGGY_BAG("堂食", 2),// 原到店自取
+    DINE_IN_SHOP("堂食", 3);
+    private String name;
+    private int value;
+
+    NutrimealOrderTypeEnum(String name, int value) {
+        this.name = name;
+        this.value = value;
+    }
+
+    public String getName() {
+        return name;
+    }
+
+    public int getValue() {
+        return value;
+    }
+
+    public static String getDisplayName(int value) {
+        for (NutrimealOrderTypeEnum typeEnum : NutrimealOrderTypeEnum.values()) {
+            if (typeEnum.value == value) {
+                return typeEnum.name;
+            }
+        }
+        return "";
+    }
+
+    public static NutrimealOrderTypeEnum valueOf(int value) {
+        for (NutrimealOrderTypeEnum typeEnum : NutrimealOrderTypeEnum.values()) {
+            if (typeEnum.value == value) {
+                return typeEnum;
+            }
+        }
+        return UNKNOWN;
+    }
+
+    /**
+     * 是否堂食
+     */
+    public static boolean isDiningInShop(int value) {
+        return valueOf(value) == DINE_IN_SHOP || valueOf(value) == DOGGY_BAG;
+    }
+
+    /**
+     * 是否配送
+     */
+    public static boolean isDelivery(int value) {
+        return valueOf(value) == DELIVERY;
+    }
+}

+ 35 - 0
src/main/java/com/ywt/mg/domain/models/enums/NutrimealPaymentStatusEnum.java

@@ -0,0 +1,35 @@
+package com.ywt.mg.domain.models.enums;
+
+public enum NutrimealPaymentStatusEnum {
+    UNKNOWN("待支付", -1),
+    Pending("待支付", 0),
+    Processing("支付处理中", 1),
+    Success("支付成功", 2),
+    Failed("支付失败", 3);
+
+    private final String displayName;
+
+    private final int value;
+
+    NutrimealPaymentStatusEnum(String displayName, int value) {
+        this.displayName = displayName;
+        this.value = value;
+    }
+
+    public String getDisplayName() {
+        return displayName;
+    }
+
+    public int getValue() {
+        return value;
+    }
+
+    public static NutrimealPaymentStatusEnum valueOf(int value) {
+        for (NutrimealPaymentStatusEnum typeEnum : NutrimealPaymentStatusEnum.values()) {
+            if (typeEnum.value == value) {
+                return typeEnum;
+            }
+        }
+        return UNKNOWN;
+    }
+}

+ 37 - 0
src/main/java/com/ywt/mg/domain/models/enums/OrderPayTypeEnum.java

@@ -0,0 +1,37 @@
+package com.ywt.mg.domain.models.enums;
+
+public enum OrderPayTypeEnum {
+
+    UNKNOWN(0, "未知支付渠道"),
+    WECHAT(1, "微信支付"),
+    @Deprecated
+    WALLET(2, "钱包支付"),
+    F2F(3, "现场支付"),
+    COIN(4, "微信+金币");
+    String displayName;
+    int value;
+
+    OrderPayTypeEnum(int value, String displayName) {
+        this.displayName = displayName;
+        this.value = value;
+    }
+
+    public String getDisplayName() {
+        return displayName;
+    }
+
+    public int getValue() {
+        return value;
+    }
+
+    public static OrderPayTypeEnum valueOf(int value) {
+        for (OrderPayTypeEnum typeEnum : OrderPayTypeEnum.values()) {
+            // v3.0.5 移除钱包支付,新增金币支付
+            if (value == WALLET.value) return UNKNOWN;
+            if (typeEnum.value == value) {
+                return typeEnum;
+            }
+        }
+        return UNKNOWN;
+    }
+}

+ 52 - 0
src/main/java/com/ywt/mg/domain/models/pojo/CustomExcelItem.java

@@ -0,0 +1,52 @@
+package com.ywt.mg.domain.models.pojo;
+
+import jxl.format.CellFormat;
+
+import java.io.Serializable;
+
+public class CustomExcelItem implements Serializable {
+
+    private int column;
+    private int row;
+    private String content;
+    private CellFormat cellFormat;
+
+    public CustomExcelItem(int column, int row, String content, CellFormat cellFormat) {
+        this.column = column;
+        this.row = row;
+        this.content = content;
+        this.cellFormat = cellFormat;
+    }
+
+    public int getColumn() {
+        return column;
+    }
+
+    public void setColumn(int column) {
+        this.column = column;
+    }
+
+    public int getRow() {
+        return row;
+    }
+
+    public void setRow(int row) {
+        this.row = row;
+    }
+
+    public String getContent() {
+        return content;
+    }
+
+    public void setContent(String content) {
+        this.content = content;
+    }
+
+    public CellFormat getCellFormat() {
+        return cellFormat;
+    }
+
+    public void setCellFormat(CellFormat cellFormat) {
+        this.cellFormat = cellFormat;
+    }
+}

+ 130 - 0
src/main/java/com/ywt/mg/params/checkupBooking/QueryCheckUpOrderListRequest.java

@@ -0,0 +1,130 @@
+package com.ywt.mg.params.checkupBooking;
+
+import com.ywt.mg.params.PageRequest;
+import io.swagger.annotations.ApiModelProperty;
+
+import java.io.Serializable;
+
+public class QueryCheckUpOrderListRequest extends PageRequest implements Serializable {
+
+    @ApiModelProperty(value = "订单号")
+    private String orderNo;
+
+    @ApiModelProperty(value = "患者姓名")
+    private String patientName;
+
+    @ApiModelProperty(value = "就诊ID")
+    private String admId;
+
+    @ApiModelProperty(value = "登记号")
+    private String regNo;
+
+    @ApiModelProperty(value = "支付状态")
+    private String paymentStatus;
+
+    @ApiModelProperty(value = "支付时间查询开始时间")
+    private String paymentTimeStart;
+
+    @ApiModelProperty(value = "支付时间查询截止时间")
+    private String paymentTimeEnd;
+
+    @ApiModelProperty(value = "医院")
+    private String hospitalId;
+
+    @ApiModelProperty(value = "交易流水号")
+    private String transactionId;
+
+    @ApiModelProperty(value = "对账时间查询开始时间")
+    private String billStartTime;
+
+    @ApiModelProperty(value = "对账时间查询截止时间")
+    private String billEndTime;
+
+    public String getOrderNo() {
+        return orderNo;
+    }
+
+    public void setOrderNo(String orderNo) {
+        this.orderNo = orderNo;
+    }
+
+    public String getPatientName() {
+        return patientName;
+    }
+
+    public void setPatientName(String patientName) {
+        this.patientName = patientName;
+    }
+
+    public String getAdmId() {
+        return admId;
+    }
+
+    public void setAdmId(String admId) {
+        this.admId = admId;
+    }
+
+    public String getRegNo() {
+        return regNo;
+    }
+
+    public void setRegNo(String regNo) {
+        this.regNo = regNo;
+    }
+
+    public String getPaymentStatus() {
+        return paymentStatus;
+    }
+
+    public void setPaymentStatus(String paymentStatus) {
+        this.paymentStatus = paymentStatus;
+    }
+
+    public String getPaymentTimeStart() {
+        return paymentTimeStart;
+    }
+
+    public void setPaymentTimeStart(String paymentTimeStart) {
+        this.paymentTimeStart = paymentTimeStart;
+    }
+
+    public String getPaymentTimeEnd() {
+        return paymentTimeEnd;
+    }
+
+    public void setPaymentTimeEnd(String paymentTimeEnd) {
+        this.paymentTimeEnd = paymentTimeEnd;
+    }
+
+    public String getHospitalId() {
+        return hospitalId;
+    }
+
+    public void setHospitalId(String 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;
+    }
+}

+ 274 - 0
src/main/java/com/ywt/mg/params/deposit/DepositOrderInfo.java

@@ -0,0 +1,274 @@
+package com.ywt.mg.params.deposit;
+
+import java.io.Serializable;
+import java.util.Date;
+
+public class DepositOrderInfo implements Serializable {
+
+    private static final long serialVersionUID = 1L;
+
+    /**
+     * 对应deposit的id字段
+     */
+    private Integer depositId;
+
+    /**
+     * 用户Id
+     */
+    private Integer userId;
+
+    /**
+     * 对应medical_card的id字段
+     */
+    private Integer medicalCardId;
+
+    /**
+     * 住院就诊号
+     */
+    private String admNo;
+
+    /**
+     * 订单ID
+     */
+    private Integer orderId;
+
+    /**
+     * 订单编码
+     */
+    private String orderNo;
+
+    /**
+     * 押金充值金额,单位:分
+     */
+    private Integer amount;
+
+    /**
+     * 支付状态
+     */
+    private Integer paymentStatus;
+
+    /**
+     * 支付流水号
+     */
+    private String paymentNo;
+
+    /**
+     * 支付回调时间
+     */
+    private Date paymentTime;
+
+    /**
+     * 支付到his的状态,0-待同步,1-同步处理中,2-同步成功,3-同步失败
+     */
+    private Integer syncHisStatus;
+
+    /**
+     * 创建时间
+     */
+    private Date createTime;
+
+    /**
+     * 交易流水号
+     */
+    private String transactionId;
+
+    /**
+     * 医院ID
+     */
+    private int hospitalId;
+
+    /**
+     * 医院名称
+     */
+    private String hospitalName;
+
+
+    /**
+     * 患者姓名
+     */
+    private String patientName;
+
+
+    /**
+     * 患者手机号
+     */
+    private String patientMobile;
+
+
+    /**
+     * 支付途径
+     */
+    private String paymentChannel;
+
+
+    /**
+     * 诊疗卡号
+     */
+    private String cardNo;
+
+    /**
+     * 来源
+     */
+    private Integer terminal;
+
+
+    public Integer getDepositId() {
+        return depositId;
+    }
+
+    public void setDepositId(Integer depositId) {
+        this.depositId = depositId;
+    }
+
+    public Integer getUserId() {
+        return userId;
+    }
+
+    public void setUserId(Integer userId) {
+        this.userId = userId;
+    }
+
+    public Integer getMedicalCardId() {
+        return medicalCardId;
+    }
+
+    public void setMedicalCardId(Integer medicalCardId) {
+        this.medicalCardId = medicalCardId;
+    }
+
+    public String getAdmNo() {
+        return admNo;
+    }
+
+    public void setAdmNo(String admNo) {
+        this.admNo = admNo;
+    }
+
+    public Integer getOrderId() {
+        return orderId;
+    }
+
+    public void setOrderId(Integer orderId) {
+        this.orderId = orderId;
+    }
+
+    public String getOrderNo() {
+        return orderNo;
+    }
+
+    public void setOrderNo(String orderNo) {
+        this.orderNo = orderNo;
+    }
+
+    public Integer getAmount() {
+        return amount;
+    }
+
+    public void setAmount(Integer amount) {
+        this.amount = amount;
+    }
+
+    public Integer getPaymentStatus() {
+        return paymentStatus;
+    }
+
+    public void setPaymentStatus(Integer paymentStatus) {
+        this.paymentStatus = paymentStatus;
+    }
+
+    public String getPaymentNo() {
+        return paymentNo;
+    }
+
+    public void setPaymentNo(String paymentNo) {
+        this.paymentNo = paymentNo;
+    }
+
+    public Date getPaymentTime() {
+        return paymentTime;
+    }
+
+    public void setPaymentTime(Date paymentTime) {
+        this.paymentTime = paymentTime;
+    }
+
+    public Integer getSyncHisStatus() {
+        return syncHisStatus;
+    }
+
+    public void setSyncHisStatus(Integer syncHisStatus) {
+        this.syncHisStatus = syncHisStatus;
+    }
+
+    public Date getCreateTime() {
+        return createTime;
+    }
+
+    public void setCreateTime(Date createTime) {
+        this.createTime = createTime;
+    }
+
+    public String getTransactionId() {
+        return transactionId;
+    }
+
+    public void setTransactionId(String transactionId) {
+        this.transactionId = transactionId;
+    }
+
+    public int getHospitalId() {
+        return hospitalId;
+    }
+
+    public void setHospitalId(int hospitalId) {
+        this.hospitalId = hospitalId;
+    }
+
+    public String getHospitalName() {
+        return hospitalName;
+    }
+
+    public void setHospitalName(String hospitalName) {
+        this.hospitalName = hospitalName;
+    }
+
+    public String getPatientName() {
+        return patientName;
+    }
+
+    public void setPatientName(String patientName) {
+        this.patientName = patientName;
+    }
+
+    public String getPatientMobile() {
+        return patientMobile;
+    }
+
+    public void setPatientMobile(String patientMobile) {
+        this.patientMobile = patientMobile;
+    }
+
+    public String getPaymentChannel() {
+        return paymentChannel;
+    }
+
+    public void setPaymentChannel(String paymentChannel) {
+        this.paymentChannel = paymentChannel;
+    }
+
+    public String getCardNo() {
+        return cardNo;
+    }
+
+    public void setCardNo(String cardNo) {
+        this.cardNo = cardNo;
+    }
+
+    public Integer getTerminal() {
+        return terminal;
+    }
+
+    public void setTerminal(Integer terminal) {
+        this.terminal = terminal;
+    }
+}

+ 120 - 0
src/main/java/com/ywt/mg/params/deposit/QueryDepositListRequest.java

@@ -0,0 +1,120 @@
+package com.ywt.mg.params.deposit;
+
+import com.ywt.mg.params.PageRequest;
+import io.swagger.annotations.ApiModelProperty;
+
+import java.io.Serializable;
+
+public class QueryDepositListRequest extends PageRequest implements Serializable {
+
+    @ApiModelProperty(value = "订单号")
+    private String orderNo;
+
+    @ApiModelProperty(value = "患者姓名")
+    private String patientName;
+
+    @ApiModelProperty(value = "手机号")
+    private String patientMobile;
+
+    @ApiModelProperty(value = "支付时间查询开始时间")
+    private String paymentTimeStart;
+
+
+    @ApiModelProperty(value = "支付时间查询截止时间")
+    private String paymentTimeEnd;
+
+    @ApiModelProperty(value = "医院")
+    private int hospitalId = 0;
+
+    @ApiModelProperty(value = "交易流水号")
+    private String transactionId;
+
+    @ApiModelProperty(value = "对账时间查询开始时间")
+    private String billStartTime;
+
+    @ApiModelProperty(value = "对账时间查询结束时间")
+    private String billEndTime;
+
+    @ApiModelProperty(value = "来源")
+    private String terminal;
+
+    public String getOrderNo() {
+        return orderNo;
+    }
+
+    public void setOrderNo(String orderNo) {
+        this.orderNo = orderNo;
+    }
+
+    public String getPatientName() {
+        return patientName;
+    }
+
+    public void setPatientName(String patientName) {
+        this.patientName = patientName;
+    }
+
+    public String getPatientMobile() {
+        return patientMobile;
+    }
+
+    public void setPatientMobile(String patientMobile) {
+        this.patientMobile = patientMobile;
+    }
+
+    public String getPaymentTimeStart() {
+        return paymentTimeStart;
+    }
+
+    public void setPaymentTimeStart(String paymentTimeStart) {
+        this.paymentTimeStart = paymentTimeStart;
+    }
+
+    public String getPaymentTimeEnd() {
+        return paymentTimeEnd;
+    }
+
+    public void setPaymentTimeEnd(String paymentTimeEnd) {
+        this.paymentTimeEnd = paymentTimeEnd;
+    }
+
+    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;
+    }
+
+    public String getTerminal() {
+        return terminal;
+    }
+
+    public void setTerminal(String terminal) {
+        this.terminal = terminal;
+    }
+}

+ 262 - 0
src/main/java/com/ywt/mg/params/mealOrder/MealOrderListRequest.java

@@ -0,0 +1,262 @@
+package com.ywt.mg.params.mealOrder;
+
+import io.swagger.annotations.ApiModelProperty;
+
+import java.io.Serializable;
+
+public class MealOrderListRequest implements Serializable {
+
+    @ApiModelProperty(value = "订单编号")
+    private String orderNo;
+
+    @ApiModelProperty(value = "姓名")
+    private String name;
+
+    @ApiModelProperty(value = "患者手机号")
+    private String mobile;
+
+    @ApiModelProperty(value = "取餐方式")
+    private String type;
+
+    @ApiModelProperty(value = "状态")
+    private String status;
+
+    @ApiModelProperty(value = "支付状态")
+    private String payStatus;
+
+    @ApiModelProperty(value = "支付时间")
+    private String payTimeStart;
+
+    @ApiModelProperty(value = "支付时间")
+    private String payTimeEnd;
+
+    @ApiModelProperty(value = "商品Id")
+    private String shopId;
+
+    @ApiModelProperty(value = "客户类型")
+    private String clientType;
+
+    @ApiModelProperty(value = "支付类型")
+    private String payType;
+
+    @ApiModelProperty(value = "支付号码")
+    private String paymentNo;
+
+    @ApiModelProperty(value = "退款时间")
+    private String refundTimeStart;
+
+    @ApiModelProperty(value = "退款时间")
+    private String refundTimeEnd;
+
+    @ApiModelProperty(value = "")
+    private boolean dineInStatusCompat;
+
+    @ApiModelProperty(value = "医院")
+    private int hospitalId;
+
+    @ApiModelProperty(value = "取餐码")
+    private String pickupCode;
+
+    @ApiModelProperty(value = "是否是员工")
+    private String isStaff;
+
+    @ApiModelProperty(value = "是否是员工")
+    private Boolean bIsStaff;
+
+    @ApiModelProperty(value = "对账时间")
+    private String billStartTime;
+
+    @ApiModelProperty(value = "对账时间")
+    private String billEndTime;
+
+    @ApiModelProperty(value = "交易流水号")
+    private String transactionId;
+
+    @ApiModelProperty(value = "拥有的商铺")
+    private String shopIds;
+
+
+    public String getOrderNo() {
+        return orderNo;
+    }
+
+    public void setOrderNo(String orderNo) {
+        this.orderNo = orderNo;
+    }
+
+    public String getName() {
+        return name;
+    }
+
+    public void setName(String name) {
+        this.name = name;
+    }
+
+    public String getMobile() {
+        return mobile;
+    }
+
+    public void setMobile(String mobile) {
+        this.mobile = mobile;
+    }
+
+    public String getType() {
+        return type;
+    }
+
+    public void setType(String type) {
+        this.type = type;
+    }
+
+    public String getStatus() {
+        return status;
+    }
+
+    public void setStatus(String status) {
+        this.status = status;
+    }
+
+    public String getPayStatus() {
+        return payStatus;
+    }
+
+    public void setPayStatus(String payStatus) {
+        this.payStatus = payStatus;
+    }
+
+    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 getShopId() {
+        return shopId;
+    }
+
+    public void setShopId(String shopId) {
+        this.shopId = shopId;
+    }
+
+    public String getClientType() {
+        return clientType;
+    }
+
+    public void setClientType(String clientType) {
+        this.clientType = clientType;
+    }
+
+    public String getPayType() {
+        return payType;
+    }
+
+    public void setPayType(String payType) {
+        this.payType = payType;
+    }
+
+    public String getPaymentNo() {
+        return paymentNo;
+    }
+
+    public void setPaymentNo(String paymentNo) {
+        this.paymentNo = paymentNo;
+    }
+
+    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 boolean isDineInStatusCompat() {
+        return dineInStatusCompat;
+    }
+
+    public void setDineInStatusCompat(boolean dineInStatusCompat) {
+        this.dineInStatusCompat = dineInStatusCompat;
+    }
+
+    public int getHospitalId() {
+        return hospitalId;
+    }
+
+    public void setHospitalId(int hospitalId) {
+        this.hospitalId = hospitalId;
+    }
+
+    public String getPickupCode() {
+        return pickupCode;
+    }
+
+    public void setPickupCode(String pickupCode) {
+        this.pickupCode = pickupCode;
+    }
+
+    public String getIsStaff() {
+        return isStaff;
+    }
+
+    public void setIsStaff(String isStaff) {
+        this.isStaff = isStaff;
+    }
+
+    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;
+    }
+
+    public String getShopIds() {
+        return shopIds;
+    }
+
+    public void setShopIds(String shopIds) {
+        this.shopIds = shopIds;
+    }
+
+    public Boolean getbIsStaff() {
+        return bIsStaff;
+    }
+
+    public void setbIsStaff(Boolean bIsStaff) {
+        this.bIsStaff = bIsStaff;
+    }
+}

+ 215 - 0
src/main/java/com/ywt/mg/params/outpatientOrder/QueryOutPatientOrderListRequest.java

@@ -0,0 +1,215 @@
+package com.ywt.mg.params.outpatientOrder;
+
+import io.swagger.annotations.ApiModelProperty;
+
+import java.io.Serializable;
+
+public class QueryOutPatientOrderListRequest implements Serializable {
+
+    @ApiModelProperty(value = "订单编号")
+    private String orderno;
+
+    @ApiModelProperty(value = "患者姓名")
+    private String patientname;
+
+    @ApiModelProperty(value = "患者手机号,输入11位")
+    private String userMobile;
+
+    @ApiModelProperty(value = "医生姓名")
+    private String doctorname;
+
+    @ApiModelProperty(value = "科室名称")
+    private String deptname;
+
+    @ApiModelProperty(value = "医院名称")
+    private String hospitalname;
+
+    @ApiModelProperty(value = "订单状态")
+    private String outpatientstatus;
+
+    @ApiModelProperty(value = "支付状态")
+    private String paymentstatus;
+
+    @ApiModelProperty(value = "是否可以快递:1-可以快递,0-不可以")
+    private String express;
+
+    @ApiModelProperty(value = "创建时间查询开始时间")
+    private String createStartTime;
+
+    @ApiModelProperty(value = "创建时间查询截止时间")
+    private String createEndTime;
+
+    @ApiModelProperty(value = "支付时间查询开始时间")
+    private String payStartTime;
+
+    @ApiModelProperty(value = "支付时间查询截止时间")
+    private String payEndTime;
+
+    @ApiModelProperty(value = "医院ID")
+    private int hospitalId;
+
+    @ApiModelProperty(value = "交易流水号")
+    private String transactionId;
+
+    @ApiModelProperty(value = "对账时间查询开始时间")
+    private String billStartTime;
+
+    @ApiModelProperty(value = "对账时间查询截止时间")
+    private String billEndTime;
+
+    private boolean isAdmin = false;
+
+    private String terminal;
+
+    public String getOrderno() {
+        return orderno;
+    }
+
+    public void setOrderno(String orderno) {
+        this.orderno = orderno;
+    }
+
+    public String getPatientname() {
+        return patientname;
+    }
+
+    public void setPatientname(String patientname) {
+        this.patientname = patientname;
+    }
+
+    public String getUserMobile() {
+        return userMobile;
+    }
+
+    public void setUserMobile(String userMobile) {
+        this.userMobile = userMobile;
+    }
+
+    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 getHospitalname() {
+        return hospitalname;
+    }
+
+    public void setHospitalname(String hospitalname) {
+        this.hospitalname = hospitalname;
+    }
+
+    public String getOutpatientstatus() {
+        return outpatientstatus;
+    }
+
+    public void setOutpatientstatus(String outpatientstatus) {
+        this.outpatientstatus = outpatientstatus;
+    }
+
+    public String getPaymentstatus() {
+        return paymentstatus;
+    }
+
+    public void setPaymentstatus(String paymentstatus) {
+        this.paymentstatus = paymentstatus;
+    }
+
+    public String getExpress() {
+        return express;
+    }
+
+    public void setExpress(String express) {
+        this.express = express;
+    }
+
+    public String getCreateStartTime() {
+        return createStartTime;
+    }
+
+    public void setCreateStartTime(String createStartTime) {
+        this.createStartTime = createStartTime;
+    }
+
+    public String getCreateEndTime() {
+        return createEndTime;
+    }
+
+    public void setCreateEndTime(String createEndTime) {
+        this.createEndTime = createEndTime;
+    }
+
+    public String getPayStartTime() {
+        return payStartTime;
+    }
+
+    public void setPayStartTime(String payStartTime) {
+        this.payStartTime = payStartTime;
+    }
+
+    public String getPayEndTime() {
+        return payEndTime;
+    }
+
+    public void setPayEndTime(String payEndTime) {
+        this.payEndTime = payEndTime;
+    }
+
+    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;
+    }
+
+    public boolean isAdmin() {
+        return isAdmin;
+    }
+
+    public void setAdmin(boolean admin) {
+        isAdmin = admin;
+    }
+
+    public String getTerminal() {
+        return terminal;
+    }
+
+    public void setTerminal(String terminal) {
+        this.terminal = terminal;
+    }
+}

+ 199 - 0
src/main/java/com/ywt/mg/params/registeredOrder/RegisteredOrderListRequest.java

@@ -0,0 +1,199 @@
+package com.ywt.mg.params.registeredOrder;
+
+
+import com.ywt.mg.params.PageRequest;
+import io.swagger.annotations.ApiModel;
+import io.swagger.annotations.ApiModelProperty;
+
+import java.io.Serializable;
+
+@ApiModel(value = "按条件查找挂号订单Request")
+public class RegisteredOrderListRequest extends PageRequest implements Serializable {
+
+    @ApiModelProperty(value = "订单编号")
+    private String orderno;
+
+    @ApiModelProperty(value = "患者姓名")
+    private String patientname;
+
+    @ApiModelProperty(value = "患者手机号")
+    private String patientmobile;
+
+    @ApiModelProperty(value = "医生姓名")
+    private String doctorname;
+
+    @ApiModelProperty(value = "科室名称")
+    private String deptname;
+
+    @ApiModelProperty(value = "挂号状态")
+    private String registeredstatus;
+
+    @ApiModelProperty(value = "支付状态")
+    private String paymentstatus;
+
+    @ApiModelProperty(value = "来源")
+    private String source;
+
+    @ApiModelProperty(value = "类型")
+    private String type;
+
+    @ApiModelProperty(value = "创建时间查询开始时间")
+    private String createStartTime;
+
+    @ApiModelProperty(value = "创建时间查询结束时间")
+    private String createEndTime;
+
+    @ApiModelProperty(value = "挂号时间查询开始时间")
+    private String registeredStartTime;
+
+    @ApiModelProperty(value = "挂号时间查询结束时间")
+    private String registeredEndTime;
+
+    @ApiModelProperty(value = "医院ID")
+    private int hospitalId = -1;
+
+    @ApiModelProperty(value = "对账时间查询开始时间")
+    private String billStartTime;
+
+    @ApiModelProperty(value = "对账时间查询结束时间")
+    private String billEndTime;
+
+    @ApiModelProperty(value = "交易流水号")
+    private String transactionId;
+
+    public String getOrderno() {
+        return orderno;
+    }
+
+    public void setOrderno(String orderno) {
+        this.orderno = orderno;
+    }
+
+    public String getPatientname() {
+        return patientname;
+    }
+
+    public void setPatientname(String patientname) {
+        this.patientname = patientname;
+    }
+
+    public String getPatientmobile() {
+        return patientmobile;
+    }
+
+    public void setPatientmobile(String patientmobile) {
+        this.patientmobile = patientmobile;
+    }
+
+    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 getRegisteredstatus() {
+        return registeredstatus;
+    }
+
+    public void setRegisteredstatus(String registeredstatus) {
+        this.registeredstatus = registeredstatus;
+    }
+
+    public String getPaymentstatus() {
+        return paymentstatus;
+    }
+
+    public void setPaymentstatus(String paymentstatus) {
+        this.paymentstatus = paymentstatus;
+    }
+
+    public String getSource() {
+        return source;
+    }
+
+    public void setSource(String source) {
+        this.source = source;
+    }
+
+    public String getType() {
+        return type;
+    }
+
+    public void setType(String type) {
+        this.type = type;
+    }
+
+    public String getCreateStartTime() {
+        return createStartTime;
+    }
+
+    public void setCreateStartTime(String createStartTime) {
+        this.createStartTime = createStartTime;
+    }
+
+    public String getCreateEndTime() {
+        return createEndTime;
+    }
+
+    public void setCreateEndTime(String createEndTime) {
+        this.createEndTime = createEndTime;
+    }
+
+    public String getRegisteredStartTime() {
+        return registeredStartTime;
+    }
+
+    public void setRegisteredStartTime(String registeredStartTime) {
+        this.registeredStartTime = registeredStartTime;
+    }
+
+    public String getRegisteredEndTime() {
+        return registeredEndTime;
+    }
+
+    public void setRegisteredEndTime(String registeredEndTime) {
+        this.registeredEndTime = registeredEndTime;
+    }
+
+    public int getHospitalId() {
+        return hospitalId;
+    }
+
+    public void setHospitalId(int hospitalId) {
+        this.hospitalId = hospitalId;
+    }
+
+    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;
+    }
+}

+ 317 - 0
src/main/java/com/ywt/mg/services/CheckUpOrderService.java

@@ -0,0 +1,317 @@
+package com.ywt.mg.services;
+
+import com.ywt.mg.core.SqlHelper;
+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.CheckUpOrder;
+import com.ywt.mg.domain.entities.OrderPayment;
+import com.ywt.mg.domain.entities.RefundLog;
+import com.ywt.mg.domain.models.ConstantDef;
+import com.ywt.mg.domain.models.ExcelDataMap;
+import com.ywt.mg.domain.models.enums.PaymentChannelEnum;
+import com.ywt.mg.domain.models.enums.PaymentStatusEnum;
+import com.ywt.mg.domain.models.enums.RefundStatusEnum;
+import com.ywt.mg.domain.models.enums.SexEnum;
+import com.ywt.mg.domain.models.pojo.ExcelCollectPojo;
+import com.ywt.mg.params.checkupBooking.QueryCheckUpOrderListRequest;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Service;
+
+import java.util.ArrayList;
+import java.util.Date;
+import java.util.List;
+import java.util.Map;
+import java.util.stream.Collectors;
+
+@Service
+public class CheckUpOrderService {
+
+    private Logger logger = LoggerFactory.getLogger(CheckUpOrderService.class);
+
+    @Autowired
+    private SqlHelper sqlHelper;
+
+    @Autowired
+    private OrderPaymentService orderPaymentService;
+
+    @Autowired
+    private RefundLogService refundLogService;
+
+    @Autowired
+    private DownloadRecordService downloadRecordService;
+
+
+    private List<CheckUpOrder> queryCheckUpOrderListCommon(QueryCheckUpOrderListRequest request) throws Exception {
+        // 时间查询处理
+        Map<String, Object> map = queryCheckUpOrderListCommonMapNew(request);
+        String whereSql = (String) map.get("whereSql");
+        List<Object> paramList = (List<Object>) map.get("paramList");
+        return sqlHelper.getListWithNoPage("*", whereSql, " id desc ", CheckUpOrder.class, paramList.toArray());
+    }
+
+    private Map<String, Object> queryCheckUpOrderListCommonMapNew(QueryCheckUpOrderListRequest request) throws Exception {
+        List<Object> paramList = new ArrayList<>();
+        String whereSql = " ( 1=1 )";
+
+        String orderNo = request.getOrderNo();
+        if (!Checker.isNull(orderNo)) {
+            whereSql += " and ( order_no like ?)";
+            paramList.add("%" + orderNo.trim() + "%");
+        }
+        String patientName = request.getPatientName();
+        if (!Checker.isNull(patientName)) {
+            whereSql += " and ( name like ?)";
+            paramList.add("%" + patientName.trim() + "%");
+        }
+        String admId = request.getAdmId();
+        if (!Checker.isNull(admId)) {
+            whereSql += " and ( adm_id = ?)";
+            paramList.add(admId.trim());
+        }
+        String regNo = request.getRegNo();
+        if (!Checker.isNull(regNo)) {
+            whereSql += " and ( reg_no = ?)";
+            paramList.add(regNo.trim());
+        }
+        String paymentStatus = request.getPaymentStatus();
+        if (!Checker.isNull(paymentStatus)) {
+            whereSql += " and ( payment_status = ?)";
+            paramList.add(Integer.parseInt(paymentStatus));
+        }
+        String hospitalId = request.getHospitalId();
+        if (!Checker.isNone(hospitalId)) {
+            int hospitalIdInt = Integer.parseInt(hospitalId);
+            if (hospitalIdInt != -1) {
+                whereSql += " and ( hospital_id = ?)";
+                paramList.add(hospitalIdInt);
+            }
+        }
+        whereSql += "and deleted = 0 ";
+
+        // 对账时间搜索
+        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("CheckUpOrderService#queryCheckUpOrderListCommonMapNew(transactionId={} ):\n {} ", transactionId, e.getMessage(), e);
+        }
+        String paymentTimeStart = request.getPaymentTimeStart();
+        String paymentTimeEnd = request.getPaymentTimeEnd();
+        // 时间查询处理
+        Map<String, Object> map = sqlHelper.timeQuerySql(whereSql, paramList, "pay_time", paymentTimeStart, paymentTimeEnd);
+        return map;
+    }
+
+    public void downloadCheckUpOrderListNew(int downloadRecordId, String fileName, QueryCheckUpOrderListRequest request) {
+        try {
+//            String[] title = new String[]{"订单号", "支付流水号", "交易流水号", "患者姓名", "性别", "就诊ID", "登记号", "金额", "支付状态", "支付时间", "医院"};
+            // 单元格
+            String col0 = "订单号";
+            String col1 = "支付流水号";
+            String col2 = "交易流水号";
+            String col3 = "患者姓名";
+            String col4 = "性别";
+            String col5 = "就诊ID";
+            String col6 = "登记号";
+            String col7 = "金额";
+            String col8 = "支付状态";
+            String col9 = "支付时间";
+            String col10 = "医院";
+
+            String[] columns = new String[]{col0, col1, col2, col3, col4, col5, col6, col7, col8, col9, col10};
+            List<CheckUpOrder> list = queryCheckUpOrderListCommon(request);
+            List<OrderPayment> orderPaymentList = orderPaymentService.getOrderPaymentListByCheckUpOrderList(list);
+            ExcelDataMap map = new ExcelDataMap(columns);
+            int payTotal = 0, refundTotal = 0;
+            if (!Checker.isNone(list)) {
+                for (CheckUpOrder p : list) {
+                    if (!Checker.isNone(p)) {
+                        String orderNoValue = p.getOrderNo();
+                        String paymentNoValue = p.getPaymentNo();
+                        String patientNameValue = p.getName();
+                        String sexValue = SexEnum.valueOf(Checker.getIntegerValue(p.getSex())).getDisplayName();
+                        String admIdValue = p.getAdmId();
+                        String regNoValue = p.getRegNo();
+                        String amountValue = FormatUtil.intShrink100ToStr(p.getAmount());
+                        String paymentStatusValue = PaymentStatusEnum.getPaymentStatus(p.getPaymentStatus()).getDisplayName();
+                        String paymentTimeValue = FormatUtil.createTimeFormatList(p.getPayTime());
+                        String hospitalName = p.getHospitalName();
+                        // 交易流水号
+                        String transactionId = orderPaymentService.getTransactionIdByOrderId(orderPaymentList, Checker.getIntegerValue(p.getOrderId()));
+
+                        if (Checker.getIntegerValue(p.getPaymentStatus()) == PaymentStatusEnum.Success.getValue()) {
+                            payTotal += Checker.getIntegerValue(p.getAmount());
+                        }
+                        if (Checker.getIntegerValue(p.getRefundStatus()) == RefundStatusEnum.SUCCESS.getValue()) {
+                            refundTotal += Checker.getIntegerValue(p.getAmount());
+                        }
+
+                        // "订单号", "支付流水号", "交易流水号", "患者姓名", "性别", "就诊ID", "登记号", "金额", "支付状态", "支付时间"
+//                        String[] bodyStr = new String[]{orderNoValue, paymentNoValue, transactionId, patientNameValue, sexValue, admIdValue, regNoValue, amountValue, paymentStatusValue, paymentTimeValue, hospitalName};
+                        // 写入excel的body
+                        map.getStringListSafely(col0).add(orderNoValue);
+                        map.getStringListSafely(col1).add(paymentNoValue);
+                        map.getStringListSafely(col2).add(transactionId);
+                        map.getStringListSafely(col3).add(patientNameValue);
+                        map.getStringListSafely(col4).add(sexValue);
+                        map.getStringListSafely(col5).add(admIdValue);
+                        map.getStringListSafely(col6).add(regNoValue);
+                        map.getStringListSafely(col7).add(amountValue);
+                        map.getStringListSafely(col8).add(paymentStatusValue);
+                        map.getStringListSafely(col9).add(paymentTimeValue);
+                        map.getStringListSafely(col10).add(hospitalName);
+
+                    }
+                }
+            }
+            int size = list.size();
+            List<ExcelCollectPojo> itemList = getStatisticsData(size, payTotal, refundTotal);
+            downloadRecordService.createFileAndUploadOssAndSaveToDataBase(fileName, downloadRecordId, map, itemList);
+
+        } catch (Exception e) {
+            logger.error("/checkUp/downloadCheckUpOrderList(): {}", e.getMessage(), e);
+            e.printStackTrace();
+        }
+    }
+
+    /**
+     * 获取统计数据
+     *
+     * @param size        隔行
+     * @param payTotal    总金额
+     * @param refundTotal 退款金额
+     * @return {@link List<ExcelCollectPojo> }
+     */
+    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;
+    }
+
+    public void downloadOutPatientOrderBillListNew(int downloadRecordId, String fileName, QueryCheckUpOrderListRequest request) {
+        try {
+            String col0 = "交易类型*";
+            String col1 = "系统参考号*";
+            String col2 = "交易金额*";
+            String col3 = "交易日期*";
+            String col4 = "订单号";
+            String col5 = "类型";
+            String[] columns = new String[]{col0, col1, col2, col3, col4, col5};
+
+            request.setPaymentStatus(PaymentStatusEnum.Success.getValue() + "");
+            List<CheckUpOrder> checkUpOrderList = queryCheckUpOrderListCommon(request);
+            ExcelDataMap map = new ExcelDataMap(columns);
+            if (!Checker.isNone(checkUpOrderList)) {
+                // 得到支付的记录日志(需要从 order_payment 获取 transaction_id 字段)
+                List<OrderPayment> orderPaymentList = orderPaymentService.getOrderPaymentListByCheckUpOrderList(checkUpOrderList);
+                // 得到退款的记录日志(需要从 refund_log 获取 refund_id 字段)
+                List<RefundLog> refundLogList = refundLogService.getRefundLogListByCheckUpOrderList(checkUpOrderList);
+                Date billStartTime = DateUtil.stringToDate(request.getBillStartTime() + ConstantDef.BILL_TIME_START_FORMAT);
+                Date billEndTime = DateUtil.stringToDate(request.getBillEndTime() + ConstantDef.BILL_TIME_END_FORMAT);
+                for (CheckUpOrder p : checkUpOrderList) {
+                    if (!Checker.isNone(p) && Checker.getIntegerValue(p.getPaymentStatus()) == PaymentStatusEnum.Success.getValue()
+                            && Checker.getIntegerValue(p.getPaymentChannel()) == PaymentChannelEnum.WeChat.getValue()
+                            && !Checker.isNone(p.getPayTime())) {
+                        // "交易类型*", "系统参考号*", "交易金额*", "交易日期*", "订单号", "类型"
+                        Date paymentTime = Checker.getDateValue(p.getPayTime());
+                        if (!Checker.isNone(paymentTime) && paymentTime.after(billStartTime) && paymentTime.before(billEndTime)) {
+                            String type = ConstantDef.BILL_PAYMENT_STR;
+                            // 交易流水号
+                            String transactionId = orderPaymentService.getTransactionIdByOrderId(orderPaymentList, Checker.getIntegerValue(p.getOrderId()));
+                            // 交易金额
+                            int total = Checker.getIntegerValue(p.getAmount());
+                            String totalStr = FormatUtil.intShrink100ToStr(total);
+                            // 交易时间
+                            String paymentTimeStr = FormatUtil.createTimeFormatDetail(p.getPayTime());
+                            // 订单号
+                            String orderNo = Checker.getStringValue(p.getOrderNo());
+                            // 类型
+                            String typeStr = "体检缴费";
+//                            String[] bodyStr = {type, transactionId, totalStr, paymentTimeStr, orderNo, typeStr};
+                            map.getStringListSafely(col0).add(type);
+                            map.getStringListSafely(col1).add(transactionId);
+                            map.getStringListSafely(col2).add(totalStr);
+                            map.getStringListSafely(col3).add(paymentTimeStr);
+                            map.getStringListSafely(col4).add(orderNo);
+                            map.getStringListSafely(col5).add(typeStr);
+                        }
+                    }
+                }
+                // 得到退款的处方订单
+                List<CheckUpOrder> refundCheckUpOrderList = getRefundCheckUpOrderList(checkUpOrderList);
+                for (CheckUpOrder p : refundCheckUpOrderList) {
+                    if (!Checker.isNone(p) && Checker.getIntegerValue(p.getRefundStatus()) == RefundStatusEnum.SUCCESS.getValue()) {
+                        // "交易类型*", "系统参考号*", "交易金额*", "交易日期*", "订单号", "类型"
+                        Date refundTime = Checker.getDateValue(p.getRefundTime());
+                        if (!Checker.isNone(refundTime) && refundTime.after(billStartTime) && refundTime.before(billEndTime)) {
+                            String type = ConstantDef.BILL_REFUND_STR;
+                            String transactionId = refundLogService.getRefundIdByRefundNo(refundLogList, p.getRefundNo());
+                            // 交易金额
+                            int total = Checker.getIntegerValue(p.getAmount());
+                            String totalStr = FormatUtil.intShrink100ToStr(total);
+                            // 交易时间
+                            String refundTimeStr = FormatUtil.createTimeFormatDetail(p.getRefundTime());
+                            // 订单号
+                            String orderNo = Checker.getStringValue(p.getOrderNo());
+                            // 类型
+                            String typeName = "体检缴费";
+                            map.getStringListSafely(col0).add(type);
+                            map.getStringListSafely(col1).add(transactionId);
+                            map.getStringListSafely(col2).add(totalStr);
+                            map.getStringListSafely(col3).add(refundTimeStr);
+                            map.getStringListSafely(col4).add(orderNo);
+                            map.getStringListSafely(col5).add(typeName);
+
+//                            String[] bodyStr = {type, transactionId, totalStr, refundTimeStr, orderNo, typeName};
+                        }
+                    }
+                }
+            }
+            int size = checkUpOrderList.size();
+            List<ExcelCollectPojo> itemList = new ArrayList<>();
+            downloadRecordService.createFileAndUploadOssAndSaveToDataBase(fileName, downloadRecordId, map, itemList);
+        } catch (Exception e) {
+            logger.error("/checkUp/downloadCheckUpOrderBillList(): {}", e.getMessage(), e);
+            e.printStackTrace();
+        }
+    }
+
+    private List<CheckUpOrder> getRefundCheckUpOrderList(List<CheckUpOrder> list) {
+        if (!Checker.isNone(list)) {
+            return list.stream().filter(p -> Checker.getIntegerValue(p.getRefundStatus()) == RefundStatusEnum.SUCCESS.getValue()).collect(Collectors.toList());
+        }
+        return new ArrayList<>();
+    }
+
+}

+ 422 - 0
src/main/java/com/ywt/mg/services/DepositService.java

@@ -0,0 +1,422 @@
+package com.ywt.mg.services;
+
+import com.ywt.mg.core.PagedList;
+import com.ywt.mg.core.SqlHelper;
+import com.ywt.mg.core.utils.*;
+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.PaymentStatusEnum;
+import com.ywt.mg.domain.models.enums.TerminalEnum;
+import com.ywt.mg.domain.models.pojo.ExcelCollectPojo;
+import com.ywt.mg.params.deposit.DepositOrderInfo;
+import com.ywt.mg.params.deposit.QueryDepositListRequest;
+import com.ywt.mg.params.offline.DownloadOfflineListNewRequest;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Service;
+
+import java.text.ParseException;
+import java.util.ArrayList;
+import java.util.Date;
+import java.util.List;
+
+@Service
+public class DepositService {
+
+    private static Logger logger = LoggerFactory.getLogger(DepositService.class);
+
+    @Autowired
+    private SqlHelper sqlHelper;
+
+
+    @Autowired
+    private HospitalCacheService hospitalCacheService;
+
+    @Autowired
+    private OrderPaymentService orderPaymentService;
+
+    @Autowired
+    private DownloadRecordService downloadRecordService;
+
+
+    private PagedList<DepositOrderInfo> queryDepositPageList(QueryDepositListRequest request) {
+        List<Object> paramList = new ArrayList<>();
+        StringBuilder sqlBuilder = new StringBuilder(" d.medical_card_id = m.id and d.deleted = 0 and d.payment_status = 2 ");
+
+        String orderNo = request.getOrderNo();
+        if (!Checker.isNull(orderNo)) {
+            sqlBuilder.append(" and ( d.order_no = ? ) ");
+            paramList.add(orderNo.trim());
+        }
+        String patientName = request.getPatientName();
+        if (!Checker.isNull(patientName)) {
+            sqlBuilder.append(" and ( m.patient_name = ? ) ");
+            paramList.add(patientName.trim());
+        }
+        String patientMobile = request.getPatientMobile();
+        if (!Checker.isNull(patientMobile)) {
+            sqlBuilder.append(" and ( m.mobile = ? ) ");
+            paramList.add(patientMobile.trim());
+        }
+
+        String terminal = request.getTerminal();
+        if (!Checker.isNull(terminal)) {
+            int terminalId = Integer.parseInt(terminal);
+            sqlBuilder.append(" and ( d.terminal = ? )");
+            paramList.add(terminalId);
+        }
+        String paymentTimeStart = request.getPaymentTimeStart();
+        String paymentTimeEnd = request.getPaymentTimeEnd();
+        try {
+            if (!Checker.isNull(paymentTimeStart)) {
+                sqlBuilder.append(" and d.payment_time >= ? ");
+                Date date = FormatUtil.stringToDateDayTimeStart(paymentTimeStart);
+                paramList.add(date);
+            }
+            if (!Checker.isNull(paymentTimeEnd)) {
+                sqlBuilder.append(" and d.payment_time <= ? ");
+                Date date = FormatUtil.stringToDateDayTimeEnd(paymentTimeEnd);
+                paramList.add(date);
+            }
+        } catch (ParseException e) {
+            logger.error("DepositService#queryDepositPageList(): paymentTimeStart:{} \t paymentTimeEnd:{} \t message:{}", paymentTimeStart, paymentTimeEnd, e.getMessage(), e);
+        }
+        int hospitalId = request.getHospitalId();
+        if (hospitalId != -1) {
+            sqlBuilder.append(" and m.hospital_id = ").append(hospitalId);
+        }
+        String transactionId = request.getTransactionId();
+        try {
+            // 处理交易流水号,考虑到性能,直接采用全匹配到方式
+            if (!Checker.isNull(transactionId)) {
+                OrderPayment orderPayment = orderPaymentService.getOrderPaymentByTransactionId(transactionId);
+                if (!Checker.isNone(orderPayment)) {
+                    sqlBuilder.append(" and d.order_id = ").append(orderPayment.getOrderId());
+                } else {
+                    sqlBuilder.append(" and d.order_id = -1 ");
+                }
+            }
+        } catch (Exception e) {
+            logger.error("DepositService#queryDepositPageList(transactionId={} ):\n {} ", transactionId, e.getMessage(), e);
+        }
+
+        // 对账时间
+        String billStartTime = request.getBillStartTime();
+        String billEndTime = request.getBillEndTime();
+        try {
+            if (!Checker.isNull(billEndTime)) {
+                sqlBuilder.append(" and ( d.payment_time < ? )");
+                Date date = FormatUtil.stringToDateDayTimeEnd(billEndTime);
+                paramList.add(date);
+            }
+            if (!Checker.isNull(billStartTime)) {
+                sqlBuilder.append(" and ( d.payment_time >= ? )");
+                Date date = FormatUtil.stringToDateDayTimeStart(billStartTime);
+                paramList.add(date);
+            }
+        } catch (Exception e) {
+            logger.error("DepositService#queryDepositPageList(): billStartTime:{} \t billEndTime:{} \t message:{}", billStartTime, billEndTime, e.getMessage(), e);
+        }
+
+        String fields = "  d.id as depositId, d.user_id as userId, d.medical_card_id as medicalCardId, d.adm_no as admNo, d.order_id as orderId, " +
+                "d.order_no as orderNo, d.amount as amount, d.payment_status as paymentStatus, d.payment_no as paymentNo, d.payment_time as paymentTime, " +
+                "d.sync_his_status as syncHisStatus, d.create_time as createTime, m.hospital_id as hospitalId, m.patient_name as patientName, m.mobile as patientMobile," +
+                " m.card_no as cardNo, d.terminal as terminal ";
+        return sqlHelper.getMultipleTablePagedList(request.getPageIndex(), request.getPageSize(), fields, " deposit d, medical_card m ", sqlBuilder.toString(), " d.id desc", paramList.toArray(), DepositOrderInfo.class);
+    }
+
+    public void downloadDepositList(int downloadRecordId, String fileName, QueryDepositListRequest request) {
+        try {
+//            String[] title = new String[]{"订单号", "支付流水号", "交易流水号", "医院", "来源", "患者姓名", "手机号", "诊疗卡号", "支付金额", "支付方式", "同步状态", "支付时间"};
+            int hospitalId = Checker.getIntegerValue(request.getHospitalId());
+            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[] columns = new String[]{col0, col1, col2, col3, col4, col5, col6, col7, col8, col9, col10,
+                    col11};
+            if (hospitalId > 0) {
+                columns = new String[]{col0, col1, col2, col4, col5, col6, col7, col8, col9, col10,
+                        col11};
+            }
+            PagedList<DepositOrderInfo> list = queryDepositPageList(request);
+            ExcelDataMap map = new ExcelDataMap(columns);
+            if (!Checker.isNone(list.getItems())) {
+                // 得到支付的记录日志(需要从 order_payment 获取 transaction_id 字段)
+                List<OrderPayment> orderPaymentList = orderPaymentService.getOrderPaymentListByDepositList(list.getItems());
+//                for (DepositOrderInfo p : list.getItems()) {
+//                    hospitalId = Checker.getIntegerValue(p.getHospitalId());
+//                    String hospitalName = hospitalCacheService.getCacheHospitalNameByHospitalId(hospitalId);
+//                    String transactionId = orderPaymentService.getTransactionIdByOrderId(orderPaymentList, Checker.getIntegerValue(p.getOrderId()));
+//                    String amount = FormatUtil.intShrink100ToStr(p.getAmount());
+//                    int terminalId = Checker.getIntegerValue(p.getTerminal());
+//                    String paymentChannel = PaymentChannelUtil.paymentChannel(terminalId);
+//                    String paymentStatus = getSyncHisStatusStr(Checker.getIntegerValue(p.getSyncHisStatus()));
+//                    String paymentTime = FormatUtil.createTimeFormatList(p.getPaymentTime());
+//                    String terminal = "";
+//                    if (!Checker.isNone(p.getTerminal())) {
+//                        terminal = TerminalEnum.valueOf(p.getTerminal()).getDisplayName();
+//                    }
+//                    ;
+//
+//                    if (request.getHospitalId() > 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());
+//                        map.getStringListSafely(col1).add(p.getPaymentNo());
+//                        map.getStringListSafely(col2).add(transactionId);
+//                        map.getStringListSafely(col4).add(terminal);
+//                        map.getStringListSafely(col5).add(p.getPatientName());
+//                        map.getStringListSafely(col6).add(p.getPatientMobile());
+//                        map.getStringListSafely(col7).add(p.getCardNo());
+//                        map.getStringListSafely(col8).add(amount);
+//                        map.getStringListSafely(col9).add(terminal);
+//                        map.getStringListSafely(col10).add(paymentChannel);
+//                        map.getStringListSafely(col11).add(paymentStatus);
+//                    } else {
+//                        // "订单号", "支付流水号", "交易流水号", "医院", "患者姓名", "手机号", "诊疗卡号", "支付金额", "支付方式", "同步状态", "支付时间"
+//                        map.getStringListSafely(col0).add(p.getOrderNo());
+//                        map.getStringListSafely(col1).add(p.getPaymentNo());
+//                        map.getStringListSafely(col2).add(transactionId);
+//                        map.getStringListSafely(col3).add(hospitalName);
+//                        map.getStringListSafely(col4).add(terminal);
+//                        map.getStringListSafely(col5).add(p.getPatientName());
+//                        map.getStringListSafely(col6).add(p.getPatientMobile());
+//                        map.getStringListSafely(col7).add(p.getCardNo());
+//                        map.getStringListSafely(col8).add(amount);
+//                        map.getStringListSafely(col9).add(terminal);
+//                        map.getStringListSafely(col10).add(paymentChannel);
+//                        map.getStringListSafely(col11).add(paymentStatus);
+////                    String[] bodyStr = new String[]{p.getOrderNo(), p.getPaymentNo(), transactionId, hospitalName, terminal, p.getPatientName(),
+////                            p.getPatientMobile(), p.getCardNo(), amount, paymentChannel, paymentStatus, paymentTime};
+//                    }
+//                }
+                map = setExcelDataMap(orderPaymentList, list, map, hospitalId, request,
+                        col0,
+                        col1,
+                        col2,
+                        col3,
+                        col4,
+                        col5,
+                        col6,
+                        col7,
+                        col8,
+                        col9,
+                        col10,
+                        col11);
+                int size = list.getTotalPage();
+                if (size > 1) {
+                    for (int i = 2; i <= size; i++) {
+                        request.setPageIndex(i);
+                        list = queryDepositPageList(request);
+                        map = setExcelDataMap(orderPaymentList, list, map, hospitalId, request,
+                                col0,
+                                col1,
+                                col2,
+                                col3,
+                                col4,
+                                col5,
+                                col6,
+                                col7,
+                                col8,
+                                col9,
+                                col10,
+                                col11);
+
+                    }
+                }
+
+            }
+            List<ExcelCollectPojo> itemList = new ArrayList<>();
+            downloadRecordService.createFileAndUploadOssAndSaveToDataBase(fileName, downloadRecordId, map, itemList);
+        } catch (Exception e) {
+            logger.error("/deposit/downloadDepositList(): {}", e.getMessage(), e);
+            e.printStackTrace();
+        }
+    }
+
+    /**
+     * @param syncHisStatus 支付到his的状态,0-待同步,1-同步处理中,2-同步成功,3-同步失败
+     * @return 返回同步状态
+     */
+    private String getSyncHisStatusStr(int syncHisStatus) {
+        switch (syncHisStatus) {
+            case 1:
+                return "同步处理中";
+            case 2:
+                return "同步成功";
+            case 3:
+                return "同步失败";
+            default:
+                return "待同步";
+        }
+    }
+
+    private ExcelDataMap setExcelDataMap(List<OrderPayment> orderPaymentList, PagedList<DepositOrderInfo> list, ExcelDataMap map, int hospitalId, QueryDepositListRequest request,
+                                         String col0,
+                                         String col1,
+                                         String col2,
+                                         String col3,
+                                         String col4,
+                                         String col5,
+                                         String col6,
+                                         String col7,
+                                         String col8,
+                                         String col9,
+                                         String col10,
+                                         String col11) {
+        for (DepositOrderInfo p : list.getItems()) {
+            hospitalId = Checker.getIntegerValue(p.getHospitalId());
+            String hospitalName = hospitalCacheService.getCacheHospitalNameByHospitalId(hospitalId);
+            String transactionId = orderPaymentService.getTransactionIdByOrderId(orderPaymentList, Checker.getIntegerValue(p.getOrderId()));
+            String amount = FormatUtil.intShrink100ToStr(p.getAmount());
+            int terminalId = Checker.getIntegerValue(p.getTerminal());
+            String paymentChannel = PaymentChannelUtil.paymentChannel(terminalId);
+            String paymentStatus = getSyncHisStatusStr(Checker.getIntegerValue(p.getSyncHisStatus()));
+            String paymentTime = FormatUtil.createTimeFormatList(p.getPaymentTime());
+            String terminal = "";
+            if (!Checker.isNone(p.getTerminal())) {
+                terminal = TerminalEnum.valueOf(p.getTerminal()).getDisplayName();
+            }
+            ;
+
+            if (request.getHospitalId() > 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());
+                map.getStringListSafely(col1).add(p.getPaymentNo());
+                map.getStringListSafely(col2).add(transactionId);
+                map.getStringListSafely(col4).add(terminal);
+                map.getStringListSafely(col5).add(p.getPatientName());
+                map.getStringListSafely(col6).add(p.getPatientMobile());
+                map.getStringListSafely(col7).add(p.getCardNo());
+                map.getStringListSafely(col8).add(amount);
+                map.getStringListSafely(col9).add(terminal);
+                map.getStringListSafely(col10).add(paymentChannel);
+                map.getStringListSafely(col11).add(paymentStatus);
+            } else {
+                // "订单号", "支付流水号", "交易流水号", "医院", "患者姓名", "手机号", "诊疗卡号", "支付金额", "支付方式", "同步状态", "支付时间"
+                map.getStringListSafely(col0).add(p.getOrderNo());
+                map.getStringListSafely(col1).add(p.getPaymentNo());
+                map.getStringListSafely(col2).add(transactionId);
+                map.getStringListSafely(col3).add(hospitalName);
+                map.getStringListSafely(col4).add(terminal);
+                map.getStringListSafely(col5).add(p.getPatientName());
+                map.getStringListSafely(col6).add(p.getPatientMobile());
+                map.getStringListSafely(col7).add(p.getCardNo());
+                map.getStringListSafely(col8).add(amount);
+                map.getStringListSafely(col9).add(terminal);
+                map.getStringListSafely(col10).add(paymentChannel);
+                map.getStringListSafely(col11).add(paymentStatus);
+//                    String[] bodyStr = new String[]{p.getOrderNo(), p.getPaymentNo(), transactionId, hospitalName, terminal, p.getPatientName(),
+//                            p.getPatientMobile(), p.getCardNo(), amount, paymentChannel, paymentStatus, paymentTime};
+            }
+        }
+        return map;
+    }
+
+    public void downloadDepositBillList(int downloadRecordId, String fileName, QueryDepositListRequest request) {
+        try {
+//            String[] titleStr = {"交易类型*", "系统参考号*", "交易金额*", "交易日期*", "订单号", "类型"};
+            String col0 = "交易类型*";
+            String col1 = "系统参考号*";
+            String col2 = "交易金额*";
+            String col3 = "交易日期*";
+            String col4 = "订单号";
+            String col5 = "类型";
+            String[] columns = new String[]{col0, col1, col2, col3, col4, col5};
+
+            PagedList<DepositOrderInfo> depositPageList = queryDepositPageList(request);
+            ExcelDataMap map = new ExcelDataMap(columns);
+            if (!Checker.isNone(depositPageList)) {
+                // 得到支付的记录日志(需要从 order_payment 获取 transaction_id 字段)
+                List<OrderPayment> orderPaymentList = orderPaymentService.getOrderPaymentListByDepositOrderInfoList(depositPageList.getItems());
+                int size = depositPageList.getTotalPage();
+                map = setBillDeposit(request, depositPageList, orderPaymentList, map,
+                        col0,
+                        col1,
+                        col2,
+                        col3,
+                        col4,
+                        col5);
+                if (size > 1) {
+                    for (int i = 2; i <= size; i++) {
+                        map = setBillDeposit(request, depositPageList, orderPaymentList, map,
+                                col0,
+                                col1,
+                                col2,
+                                col3,
+                                col4,
+                                col5);
+                    }
+                }
+
+            }
+            List<ExcelCollectPojo> itemList = new ArrayList<>();
+            downloadRecordService.createFileAndUploadOssAndSaveToDataBase(fileName, downloadRecordId, map, itemList);
+        } catch (Exception e) {
+            logger.error("/deposit/downloadDepositBillList(): {}", e.getMessage(), e);
+            e.printStackTrace();
+        }
+    }
+
+
+        private ExcelDataMap setBillDeposit (QueryDepositListRequest
+        request, PagedList < DepositOrderInfo > depositPageList, List < OrderPayment > orderPaymentList, ExcelDataMap
+        map,
+                String col0,
+                String col1,
+                String col2,
+                String col3,
+                String col4,
+                String col5
+    ){
+            Date billStartTime = DateUtil.stringToDate(request.getBillStartTime() + ConstantDef.BILL_TIME_START_FORMAT);
+            Date billEndTime = DateUtil.stringToDate(request.getBillEndTime() + ConstantDef.BILL_TIME_END_FORMAT);
+            for (DepositOrderInfo p : depositPageList.getItems()) {
+                if (!Checker.isNone(p) && Checker.getIntegerValue(p.getPaymentStatus()) == PaymentStatusEnum.Success.getValue()
+                        && !Checker.isNone(p.getPaymentTime())) {
+                    // "交易类型*", "系统参考号*", "交易金额*", "交易日期*", "订单号", "类型"
+                    Date paymentTime = Checker.getDateValue(p.getPaymentTime());
+                    if (!Checker.isNone(paymentTime) && paymentTime.after(billStartTime) && paymentTime.before(billEndTime)) {
+                        String type = ConstantDef.BILL_PAYMENT_STR;
+                        // 交易流水号
+                        String transactionId = "";
+                        OrderPayment orderPayment = orderPaymentList.stream().filter(o -> o.getOrderId().intValue() == p.getOrderId().intValue()).findFirst().orElse(null);
+                        if (orderPayment != null && !Checker.isNone(orderPayment.getTransactionId())) {
+                            transactionId = orderPayment.getTransactionId();
+                        }
+                        // 交易金额
+                        String totalStr = FormatUtil.intShrink100ToStr(p.getAmount());
+                        // 交易时间
+                        String paymentTimeStr = FormatUtil.createTimeFormatDetail(p.getPaymentTime());
+                        // 订单号
+                        String orderNo = Checker.getStringValue(p.getOrderNo());
+                        // 类型
+                        String typeStr = "住院押金订单";
+//                    String[] bodyStr = {type, transactionId, totalStr, paymentTimeStr, orderNo, typeStr};
+                        map.getStringListSafely(col0).add(type);
+                        map.getStringListSafely(col1).add(transactionId);
+                        map.getStringListSafely(col2).add(totalStr);
+                        map.getStringListSafely(col3).add(paymentTimeStr);
+                        map.getStringListSafely(col4).add(orderNo);
+                        map.getStringListSafely(col5).add(typeStr);
+
+                    }
+                }
+            }
+            return map;
+
+        }
+
+    }

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

@@ -17,6 +17,7 @@ import com.ywt.mg.domain.models.ExcelDataMap;
 import com.ywt.mg.domain.models.ExcelStyleMap;
 import com.ywt.mg.domain.models.enums.DownloadRecordStatusEnum;
 import com.ywt.mg.domain.models.enums.TosEnum;
+import com.ywt.mg.domain.models.pojo.CustomExcelItem;
 import com.ywt.mg.domain.models.pojo.ExcelCollectPojo;
 import com.ywt.mg.domain.ywtDrugEntities.Pharmacy;
 import com.ywt.mg.domain.ywtDrugEntities.PharmacyRepository;
@@ -260,4 +261,41 @@ public class DownloadRecordService {
         // 删除文件
         fileSrv.deleteFile(localPath);
     }
+
+
+    /**
+     * 创建文件 并且上传到 OSS,最后保存到本地数据库
+     *
+     * @param fileName         文件名称
+     * @param downloadRecordId 对应 downloadRecord 表ID
+     * @param map              数据map
+     * @param itemList         统计map
+     * @throws Exception
+     */
+    public void createMealFileAndUploadOssAndSaveToDataBase(String fileName, int downloadRecordId, ExcelDataMap map, List<CustomExcelItem> itemList) throws Exception {
+        // 前缀(路径)
+        String preLocalPath = ConstantDef.LOCAL_DOWNLOAD_FILE_PATH;
+        // 后缀(下载时间和格式)
+        String suffixFormat = FormatUtil.formatDate(new Date(), FormatUtil.FORMAT_DATE_SECOND_NUMBER) + ConstantDef.EXCEL_SUFFIX_FORMAT;
+        // 写到本地,拼凑本地路径
+        String localPath = preLocalPath + fileName + suffixFormat;
+
+        // 生成本地文件
+        ExcelStyleMap excelStyleMap = new ExcelStyleMap(new String[]{});
+        excelDownloadSrv.generateAndReturnMealExcelFileWithNoStyleAndCollectLocal(fileName, localPath, map, excelStyleMap, itemList);
+
+        // 本地文件上传到oss,文件名带后缀
+        String ossPath = String.format(ConstantDef.BIG_DATA_EXCEL_FILE_PATH, FormatUtil.formatDate(new Date(), "yyyy-MM"));
+        String ossFileName = fileName + suffixFormat;
+        DataResponse dataResponse = fileSrv.localFileUploadToOss(localPath, ossFileName, ossPath);
+        if (dataResponse.getCode() == BaseResponse.SUCCEED) {
+            // 上传成功,将上传状态和地址保存到数据库
+            saveUrlAndStatus(downloadRecordId, dataResponse.getData().toString(), DownloadRecordStatusEnum.SUCCESS.getValue());
+        } else {
+            // 上传失败,将上传状态保存到数据库
+            saveUrlAndStatus(downloadRecordId, "", DownloadRecordStatusEnum.FAILURE.getValue());
+        }
+        // 删除文件
+        fileSrv.deleteFile(localPath);
+    }
 }

+ 814 - 0
src/main/java/com/ywt/mg/services/MealOrderService.java

@@ -0,0 +1,814 @@
+package com.ywt.mg.services;
+
+import com.ywt.mg.configs.Constants;
+import com.ywt.mg.core.SqlHelper;
+import com.ywt.mg.core.utils.*;
+import com.ywt.mg.domain.entities.OrderPayment;
+import com.ywt.mg.domain.entities.RefundLog;
+import com.ywt.mg.domain.mealEntities.Shop;
+
+import com.ywt.mg.domain.mealEntities.UserMealOrderView;
+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.models.nutrimeal.MealOrderInfo;
+import com.ywt.mg.domain.models.pojo.CustomExcelItem;
+import com.ywt.mg.domain.models.pojo.ExcelCollectPojo;
+import com.ywt.mg.params.mealOrder.MealOrderListRequest;
+import com.ywt.mg.web.common.ExcelDownloadSrv;
+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.*;
+import java.util.stream.Collectors;
+
+@Service
+public class MealOrderService {
+
+    private Logger logger = LoggerFactory.getLogger(MealOrderService.class);
+
+    @Autowired
+    private SqlHelper sqlHelper;
+
+    @Autowired
+    private DownloadRecordService downloadRecordService;
+
+    @Autowired
+    private JdbcTemplate jdbcTemplate;
+
+    @Autowired
+    private ShopService shopService;
+
+    @Autowired
+    private OrderDishService orderDishService;
+
+    @Autowired
+    private RefundLogService refundLogService;
+
+
+    //客户端类型:商家 PC 端
+    public static final int CLIENT_PC_MERCHANT = 1;
+    //客户端类型:管理后台
+    public static final int CLIENT_WEB_MG = 2;
+
+    public static final String DATE_FORMAT1 = "yyyy-MM-dd";
+
+    @Autowired
+    private OrderPaymentService orderPaymentService;
+
+
+    public List<UserMealOrderView> queryDownLoadMealOrderList(MealOrderListRequest request) {
+
+        Map<String, Object> map = queryMealOrderListCommon(request);
+        List<Object> paramList = (List<Object>) map.get(Constants.PARAM_LIST);
+        String whereSql = (String) map.get(Constants.WHERE_SQL);
+        // 分页查找
+        StringBuilder sqlBuilder = new StringBuilder();
+        // 拼凑sql语句
+        sqlBuilder.append("select * from user_meal_order_view where ")
+                .append(whereSql)
+                .append("order by create_time desc");
+        return jdbcTemplate.query(sqlBuilder.toString(), paramList.toArray(), new BeanPropertyRowMapper<>(UserMealOrderView.class));
+
+    }
+
+
+    private Map queryMealOrderListCommon(MealOrderListRequest request) {
+        List<Object> paramList = new ArrayList<>();
+        String whereSql = " ( 1=1 )";
+
+        if (!Checker.isNone(request.getOrderNo())) {
+            String orderNo = request.getOrderNo();
+            whereSql += " and ( order_no like ?)";
+            paramList.add("%" + orderNo + "%");
+        }
+
+        if (!Checker.isNone(request.getName())) {
+            String name = request.getName();
+            whereSql += " and ( contact_name like ?)";
+            paramList.add("%" + name + "%");
+        }
+
+        if (!Checker.isNone(request.getMobile())) {
+            String mobile = request.getMobile();
+            whereSql += " and ( mobile like ?)";
+            paramList.add("%" + mobile + "%");
+        }
+
+        if (!Checker.isNone(request.getPickupCode())) {
+            String pickupCode = request.getPickupCode();
+            whereSql += " and ( pickup_code like ?)";
+            paramList.add("%" + pickupCode + "%");
+        }
+
+        if (!Checker.isNone(request.getType())) {
+            String type = request.getType();
+            boolean dineInStatusCompat = Checker.getBooleanValue(request.isDineInStatusCompat());
+            if (dineInStatusCompat && (type.equals(String.valueOf(NutrimealOrderTypeEnum.DOGGY_BAG.getValue())) || type.equals(String.valueOf(NutrimealOrderTypeEnum.DINE_IN_SHOP.getValue())))) {
+                whereSql += " and ( type = 2 or type = 3)";
+            } else {
+                whereSql += " and ( type = ?)";
+                paramList.add(Integer.parseInt(type));
+            }
+        }
+
+        if (!Checker.isNone(request.getPayType())) {
+            String payType = request.getPayType();
+            whereSql += " and ( pay_type = ?)";
+            paramList.add(Integer.parseInt(payType));
+        }
+
+        if (!Checker.isNone(request.getPaymentNo())) {
+            String paymentNo = request.getPaymentNo();
+            whereSql += " and ( payment_no = ?)";
+            paramList.add(paymentNo);
+        }
+
+        int hospitalId = Checker.getIntegerValue(request.getHospitalId());
+        if (hospitalId > 0) {
+            whereSql += " and ( hospital_id = ?)";
+            paramList.add(hospitalId);
+        }
+        /**
+         * 根据职工管理版本将shopId, 转为shopIds, 即是shopIds 拥有多个shopId
+         *
+         */
+        String shopId = Checker.getStringValue(request.getShopId());
+        String shopIds = Checker.getStringValue(request.getShopIds());
+        if (!Checker.isNone(shopId)) {
+            int shopIdInt = Integer.parseInt(shopId);
+            if (shopIdInt > 0) {
+                whereSql += " and ( shop_id = ?)";
+                paramList.add(shopIdInt);
+            } else if (!Checker.isNone(shopIds) && !shopIds.equals("0") && !shopIds.startsWith(",") && !shopIds.endsWith(",")) {
+                whereSql += " and ( shop_id in (" + shopIds + "))";
+            }
+        }
+        try {
+            int clientTypeInt = 2;
+            if (!Checker.isNone(request.getClientType())) {
+                clientTypeInt = Integer.parseInt(request.getClientType());
+            }
+
+            if (clientTypeInt == CLIENT_PC_MERCHANT) {
+                // PC 商家端过滤未支付订单,只显示支付成功或失败的订单
+                whereSql += " and ( status <> 0 and payment_status > 1 )";
+            }
+        } catch (NumberFormatException e) {
+            logger.warn("MealOrderService#queryMealOrderListCommon(): Cannot format clientType {} as number!", shopIds);
+        }
+
+        if (request.getbIsStaff() != null) {
+            boolean isStaff = request.getbIsStaff();
+            whereSql += isStaff ? " and staff_id is not null " : " and staff_id is null ";
+        }
+
+        /**
+         * status参考下面枚举
+         * @see  com.ywt.mg.domain.models.enums.MealOrderStatusEnum
+         */
+        if (!Checker.isNone(request.getStatus())) {
+            int statusInt = Integer.parseInt(request.getStatus());
+            whereSql += " and ( (status & ?) = ? and status < ?) ";
+            paramList.add(statusInt);
+            paramList.add(statusInt);
+            paramList.add(2 * statusInt);
+        }
+
+        if (!Checker.isNone(request.getStatus())) {
+            try {
+                int payStatusInt = Integer.parseInt(request.getStatus());
+                if (payStatusInt == 0) {
+                    // payStatus 传 0,可以查到未支付的订单
+                    whereSql += " and ( payment_status is null or payment_status = 0 ) ";
+                } else {
+                    whereSql += " and ( payment_status = ? ) ";
+                    paramList.add(payStatusInt);
+                }
+            } catch (NumberFormatException e) {
+                logger.error("MealOrderService#queryMealOrderListCommon(orderNo={} , name={} , mobile={} , type={} , " +
+                                "status={} , payStatus={} , payTimeStart={} , payTimeEnd={} , shopId={} , clientType={} , payType={} , " +
+                                "paymentNo={} , refundTimeStart={} , refundTimeEnd={} , dineInStatusCompat={} , hospitalId={} , pickupCode={} ):\npayStatus 参数解析失败{}",
+                        request.getOrderNo(), request.getName(), request.getMobile(), request.getType(), request.getStatus(), request.getPayStatus(), request.getPayTimeStart(), request.getPayTimeEnd(), shopIds, request.getClientType(),
+                        request.getPayType(), request.getPaymentNo(), request.getRefundTimeStart(), request.getRefundTimeEnd(), request.isDineInStatusCompat(), hospitalId, request.getPickupCode(),
+                        e.getMessage(), e);
+            }
+        }
+
+        String Format_Date = DATE_FORMAT1;
+        SimpleDateFormat format = new SimpleDateFormat(Format_Date);
+
+        try {
+            // 支付时间
+            if (!Checker.isNone(request.getPayTimeEnd())) {
+                String payTimeEnd = request.getPayTimeEnd();
+                whereSql += " and ( payment_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.isNone(request.getPayTimeStart())) {
+                String payTimeStart = request.getPayTimeStart();
+                whereSql += " and ( payment_time >= ?)";
+                Date date = format.parse(payTimeStart);
+                paramList.add(date);
+            }
+
+            //退款时间
+            if (!Checker.isNone(request.getRefundTimeEnd())) {
+                String refundTimeEnd = request.getRefundTimeEnd();
+                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.isNone(request.getRefundTimeStart())) {
+                String refundTimeStart = request.getRefundTimeStart();
+                whereSql += " and ( refund_time >= ?)";
+                Date date = format.parse(refundTimeStart);
+                paramList.add(date);
+            }
+            // 对账时间
+            // billStartTime, billEndTime
+            if (!Checker.isNone(request.getBillEndTime())) {
+                String billEndTime = request.getBillEndTime();
+                whereSql += " and ( payment_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.isNone(request.getBillStartTime())) {
+                String billStartTime = request.getBillStartTime();
+                whereSql += " and ( payment_time >= ? or refund_time >= ? )";
+                Date date = format.parse(billStartTime);
+                paramList.add(date);
+                paramList.add(date);
+            }
+        } catch (Exception e) {
+            logger.error("MealOrderService#queryMealOrderListCommon(orderNo={} , name={} , mobile={} , type={} , status={} , " +
+                            "payStatus={} , payTimeStart={} , payTimeEnd={} ,billStartTime={} , billEndTime={} , shopId={} ):\n {}",
+                    request.getOrderNo(), request.getName(), request.getMobile(), request.getType(), request.getStatus(), request.getPayStatus(), request.getPayTimeStart(), request.getPayTimeEnd(), request.getBillStartTime(), request.getBillEndTime(), shopIds, e.getMessage(), e);
+        }
+        try {
+            // 处理交易流水号,考虑到性能,直接采用全匹配到方式
+            if (!Checker.isNull(request.getTransactionId())) {
+                String transactionId = request.getTransactionId();
+                OrderPayment orderPayment = orderPaymentService.getOrderPaymentByTransactionId(transactionId);
+                if (!Checker.isNone(orderPayment)) {
+                    whereSql += " and ( order_no = ? )";
+                    paramList.add(orderPayment.getOrderNo());
+                } else {
+                    whereSql += " and ( order_no = '-1' )";
+                }
+            }
+        } catch (Exception e) {
+            logger.error("MealOrderService#queryMealOrderListCommon(transactionId={} ):\n {} ", request.getTransactionId(), e.getMessage(), e);
+        }
+        whereSql += " and (deleted = 0)";
+        Map<String, Object> map = new HashMap<>();
+        map.put(Constants.WHERE_SQL, whereSql);
+        map.put(Constants.PARAM_LIST, paramList);
+        return map;
+    }
+
+
+    public void downloadMealOrderListNew(int downloadRecordId, String fileName, MealOrderListRequest request) {
+        try {
+
+            String col2 = "订单号";
+            String col3 = "支付流水号";
+            String col3_1 = "交易流水号";
+            String col3_2 = "店铺名";
+            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 filename = "订餐订单列表";
+            String col19 = "取餐码";
+            String col20 = "职工";
+            String col21 = "科室";
+            String[] columns;
+
+            String clientType = "2";
+            if (!Checker.isNone(request.getClientType())) {
+                clientType = request.getClientType();
+            }
+            int clientTypeInt = Integer.parseInt(clientType);
+            if (clientTypeInt == CLIENT_WEB_MG) {
+                // 管理后台显示支付流水号
+                columns = new String[]{
+                        col2, col3, col3_1, col3_2, col18, col4, col5, col20, col21, col6, col19, col7, col8, col9,
+                        col10, col15, col16, col17, col11, col12, col13, col14
+                };
+            } else {
+                columns = new String[]{
+                        col2, col4, col5, col20, col6, col19, col7, col8, col9,
+                        col10, col15, col16, col17, col11, col12, col13, col14
+                };
+            }
+            List<Shop> shopList = shopService.getAllShops();
+            ExcelDataMap map = new ExcelDataMap(columns);
+            List<UserMealOrderView> userMealOrderViews = queryDownLoadMealOrderList(request);
+            List<OrderPayment> orderPaymentList = orderPaymentService.getOrderPaymentListByMealOrderList(userMealOrderViews);
+            userMealOrderViews.forEach(userMealOrderView -> {
+//                map.getStringListSafely(col1).add(userMealOrderView.getId() + "");
+                map.getStringListSafely(col2).add(Checker.getStringValue(userMealOrderView.getOrderNo()));
+                map.getStringListSafely(col4).add(Checker.getStringValue(userMealOrderView.getContactName()));
+                map.getStringListSafely(col5).add(Checker.getStringValue(userMealOrderView.getMobile()));
+                String typeStr = NutrimealOrderTypeEnum.getDisplayName(Checker.getIntegerValue(userMealOrderView.getType()));
+                map.getStringListSafely(col6).add(typeStr);
+                String statusStr = NutrimealOrderStatusEnum.getDisplayName(Checker.getIntegerValue(userMealOrderView.getStatus()));
+                map.getStringListSafely(col7).add(statusStr);
+                String totalPriceStr = FormatUtil.intShrink100ToStr(userMealOrderView.getOrderAmount());
+                map.getStringListSafely(col10).add(totalPriceStr);
+                String payTime = FormatUtil.createTimeFormatList(userMealOrderView.getPaymentTime());
+                map.getStringListSafely(col11).add(payTime);
+                String deliveryTime = FormatUtil.createTimeFormatList(userMealOrderView.getDeliveryTime());
+                map.getStringListSafely(col13).add(deliveryTime);
+                map.getStringListSafely(col9).add(OrderPayTypeEnum.valueOf(Checker.getIntegerValue(userMealOrderView.getPayType())).getDisplayName());
+                //支付状态
+                Integer paymentStatus = userMealOrderView.getPaymentStatus();
+                map.getStringListSafely(col8).add(paymentStatus == null ? NutrimealPaymentStatusEnum.Pending.getDisplayName() :
+                        NutrimealPaymentStatusEnum.valueOf(paymentStatus).getDisplayName());
+                //退款时间
+                map.getStringListSafely(col12).add(FormatUtil.createTimeFormatList(userMealOrderView.getRefundTime()));
+                //备注
+                String extData = Checker.getStringValue(userMealOrderView.getExtData());
+                Map<String, Object> m = FormatUtil.stringToMapT(extData);
+                map.getStringListSafely(col14).add(m == null ? "" : (String) m.getOrDefault("refuseOrderRemark", ""));
+                if (clientTypeInt == CLIENT_WEB_MG) {
+                    // 管理后台显示支付流水号
+                    map.getStringListSafely(col3).add(Checker.getStringValue(userMealOrderView.getPaymentNo()));
+
+                    String transactionIdStr = orderPaymentService.getTransactionIdByOrderNo(orderPaymentList, Checker.getStringValue(userMealOrderView.getOrderNo()));
+                    map.getStringListSafely(col3_1).add(transactionIdStr);
+
+                    String shopName = getShopName(shopList, Checker.getIntegerValue(userMealOrderView.getShopId()));
+                    map.getStringListSafely(col3_2).add(shopName);
+                    map.getStringListSafely(col18).add(BizUtil.getHospitalNameByHospitalId(Checker.getIntegerValue(userMealOrderView.getHospitalId())));
+                    map.getStringListSafely(col21).add(Checker.getStringValue(userMealOrderView.getDeptName()));
+
+                }
+                String wechatPayAmount = FormatUtil.intShrink100ToStr(userMealOrderView.getWechatPayAmount());
+                map.getStringListSafely(col15).add(wechatPayAmount);
+                String coinPayAmount = FormatUtil.intShrink100ToStr(userMealOrderView.getCoinPayAmount());
+                map.getStringListSafely(col16).add(coinPayAmount);
+                String f2fPayAmount = FormatUtil.intShrink100ToStr(userMealOrderView.getF2fPayAmount());
+                map.getStringListSafely(col17).add(f2fPayAmount);
+                map.getStringListSafely(col19).add(Checker.getStringValue(userMealOrderView.getPickupCode()));
+                map.getStringListSafely(col20).add(userMealOrderView.getStaffId() == null ? "否" : "是");
+            });
+            boolean needStat = clientTypeInt == CLIENT_WEB_MG && !Checker.isNone(userMealOrderViews);
+            int size = userMealOrderViews.size();
+//         List<ExcelCollectPojo> itemList = getStatisticsData(size, payTotal);
+//         downloadRecordService.createFileAndUploadOssAndSaveToDataBase(fileName, downloadRecordId, map, itemList);
+            List<CustomExcelItem> itemList = getStatisticsData(userMealOrderViews, shopList);
+            downloadRecordService.createMealFileAndUploadOssAndSaveToDataBase(fileName, downloadRecordId, map,
+                    needStat ? itemList : null);
+
+        } catch (Exception e) {
+            logger.error("/mealOrder/downloadMealOrderList(): {}", e.getMessage(), e);
+            e.printStackTrace();
+        }
+
+    }
+
+    /**
+     * 获取店铺名称
+     *
+     * @param shopList 店铺list
+     * @param shopId   店铺ID
+     * @return 店铺名称
+     */
+    public String getShopName(List<Shop> shopList, int shopId) {
+        String backValue = "";
+        Shop shop = shopList.stream().filter(p -> p.getId() == shopId).findFirst().orElse(null);
+        if (shop != null) {
+            backValue = shop.getName();
+        }
+        return backValue;
+    }
+
+    private List<CustomExcelItem> getStatisticsData(List<UserMealOrderView> userMealOrderViews, List<Shop> shopList) {
+        int startRows = userMealOrderViews.size() + 3;
+        Map<Integer, List<UserMealOrderView>> shopDataMap = userMealOrderViews.stream()
+                // 过滤未支付的订单
+                .filter(v -> Checker.getIntegerValue(v.getPaymentStatus()) > 1)
+                .collect(Collectors.groupingBy(UserMealOrderView::getShopId));
+        int startColumn = 3;
+        List<CustomExcelItem> customExcelItemList = new ArrayList<>();
+        // 按店铺统计
+        for (Integer sId : shopDataMap.keySet()) {
+            List<UserMealOrderView> orders = shopDataMap.get(sId);
+            String shopName = getShopName(shopList, sId);
+            customExcelItemList.add(new CustomExcelItem(startColumn, startRows, shopName, null));
+            /**
+             4、总成本=微信点单成本+金币点单成本+现场点单成本(也等于各个菜品成本价乘以份数的相加的总额) ;
+             5、微信点单成本:支付方式是”微信支付“的订单,其各个菜品成本价乘以份数的相加的总额(不包含退款订单) ;
+             金币点单成本:支付方式是”微信+金币“的订单,其各个菜品成本价乘以份数的相加的总额(不包含退款订单) ;
+             现场点单成本:支付方式是”现场支付“的订单,其各个菜品成本价乘以份数的相加的总额(不包含退款订单) ;*/
+
+            List<UserMealOrderView> wechatSinglePointCostList = orders.stream()
+                    .filter(p -> p.getPayType() == OrderPayTypeEnum.WECHAT.getValue()
+                            && RefundStatusEnum.SUCCESS.getValue() != Checker.getIntegerValue(p.getRefundStatus()))
+                    .collect(Collectors.toList());
+            int wechatSinglePointCostInt = orderDishService.getAllDishCostPriceSumByUserMealOrderViewList(wechatSinglePointCostList);
+            List<UserMealOrderView> coinSinglePointCostList = orders.stream()
+                    .filter(p -> p.getPayType() == OrderPayTypeEnum.COIN.getValue()
+                            && RefundStatusEnum.SUCCESS.getValue() != Checker.getIntegerValue(p.getRefundStatus()))
+                    .collect(Collectors.toList());
+            int coinSinglePointCostInt = orderDishService.getAllDishCostPriceSumByUserMealOrderViewList(coinSinglePointCostList);
+            List<UserMealOrderView> p2fSinglePointCostList = orders.stream()
+                    .filter(p -> p.getPayType() == OrderPayTypeEnum.F2F.getValue()
+                            && RefundStatusEnum.SUCCESS.getValue() != Checker.getIntegerValue(p.getRefundStatus()))
+                    .collect(Collectors.toList());
+            int p2fSinglePointCostInt = orderDishService.getAllDishCostPriceSumByUserMealOrderViewList(p2fSinglePointCostList);
+            String wechatSinglePointCost = FormatUtil.intShrink100ToStr(wechatSinglePointCostInt);
+            String coinSinglePointCost = FormatUtil.intShrink100ToStr(coinSinglePointCostInt);
+            String p2fSinglePointCost = FormatUtil.intShrink100ToStr(p2fSinglePointCostInt);
+            String allCost = FormatUtil.intShrink100ToStr(wechatSinglePointCostInt + coinSinglePointCostInt + p2fSinglePointCostInt);
+
+            // 总计
+            customExcelItemList.add(new CustomExcelItem(startColumn + 1, startRows, "支付总额", null));
+            customExcelItemList.add(new CustomExcelItem(startColumn + 2, startRows,
+                    FormatUtil.intShrink100ToStr(orders.stream()
+                            .mapToInt(v -> Checker.getIntegerValue(v.getOrderAmount()))
+                            .sum()), null));
+            customExcelItemList.add(new CustomExcelItem(startColumn + 3, startRows, "退款总额", null));
+            customExcelItemList.add(new CustomExcelItem(startColumn + 4, startRows,
+                    FormatUtil.intShrink100ToStr(orders.stream()
+                            .filter(v -> RefundStatusEnum.SUCCESS.getValue() == Checker.getIntegerValue(v.getRefundStatus()))
+                            .mapToInt(v -> Checker.getIntegerValue(v.getOrderAmount()))
+                            .sum()), null));
+            customExcelItemList.add(new CustomExcelItem(startColumn + 5, startRows, "实际支付总额", null));
+            customExcelItemList.add(new CustomExcelItem(startColumn + 6, startRows,
+                    FormatUtil.intShrink100ToStr(orders.stream()
+                            .filter(v -> RefundStatusEnum.SUCCESS.getValue() != Checker.getIntegerValue(v.getRefundStatus()))
+                            .mapToInt(v -> Checker.getIntegerValue(v.getOrderAmount()))
+                            .sum()), null));
+            customExcelItemList.add(new CustomExcelItem(startColumn + 7, startRows, "总成本", null));
+            customExcelItemList.add(new CustomExcelItem(startColumn + 8, startRows, allCost, null));
+            startRows += 1;
+            // 微信支付
+            customExcelItemList.add(new CustomExcelItem(startColumn + 1, startRows, "微信支付总额", null));
+            customExcelItemList.add(new CustomExcelItem(startColumn + 2, startRows,
+                    FormatUtil.intShrink100ToStr(orders.stream()
+                            .mapToInt(v -> Checker.getIntegerValue(v.getWechatPayAmount()))
+                            .sum()), null));
+            customExcelItemList.add(new CustomExcelItem(startColumn + 3, startRows, "微信退款总额", null));
+            customExcelItemList.add(new CustomExcelItem(startColumn + 4, startRows,
+                    FormatUtil.intShrink100ToStr(orders.stream()
+                            .filter(v -> RefundStatusEnum.SUCCESS.getValue() == Checker.getIntegerValue(v.getRefundStatus()))
+                            .mapToInt(v -> Checker.getIntegerValue(v.getWechatPayAmount()))
+                            .sum()), null));
+            customExcelItemList.add(new CustomExcelItem(startColumn + 5, startRows, "微信实际支付总额", null));
+            customExcelItemList.add(new CustomExcelItem(startColumn + 6, startRows,
+                    FormatUtil.intShrink100ToStr(orders.stream()
+                            .filter(v -> RefundStatusEnum.SUCCESS.getValue() != Checker.getIntegerValue(v.getRefundStatus()))
+                            .mapToInt(v -> Checker.getIntegerValue(v.getWechatPayAmount()))
+                            .sum()), null));
+            customExcelItemList.add(new CustomExcelItem(startColumn + 7, startRows, "微信点单成本", null));
+            customExcelItemList.add(new CustomExcelItem(startColumn + 8, startRows, wechatSinglePointCost, null));
+            startRows += 1;
+            // 金币支付
+            customExcelItemList.add(new CustomExcelItem(startColumn + 1, startRows, "金币支付总额", null));
+            customExcelItemList.add(new CustomExcelItem(startColumn + 2, startRows,
+                    FormatUtil.intShrink100ToStr(orders.stream()
+                            .mapToInt(v -> Checker.getIntegerValue(v.getCoinPayAmount()))
+                            .sum()), null));
+            customExcelItemList.add(new CustomExcelItem(startColumn + 3, startRows, "金币退款总额", null));
+            customExcelItemList.add(new CustomExcelItem(startColumn + 4, startRows,
+                    FormatUtil.intShrink100ToStr(orders.stream()
+                            .filter(v -> RefundStatusEnum.SUCCESS.getValue() == Checker.getIntegerValue(v.getRefundStatus()))
+                            .mapToInt(v -> Checker.getIntegerValue(v.getCoinPayAmount()))
+                            .sum()), null));
+            customExcelItemList.add(new CustomExcelItem(startColumn + 5, startRows, "金币实际支付总额", null));
+            customExcelItemList.add(new CustomExcelItem(startColumn + 6, startRows,
+                    FormatUtil.intShrink100ToStr(orders.stream()
+                            .filter(v -> RefundStatusEnum.SUCCESS.getValue() != Checker.getIntegerValue(v.getRefundStatus()))
+                            .mapToInt(v -> Checker.getIntegerValue(v.getCoinPayAmount()))
+                            .sum()), null));
+            customExcelItemList.add(new CustomExcelItem(startColumn + 7, startRows, "金币点单成本", null));
+            customExcelItemList.add(new CustomExcelItem(startColumn + 8, startRows, coinSinglePointCost, null));
+            startRows += 1;
+            // 现场支付
+            customExcelItemList.add(new CustomExcelItem(startColumn + 1, startRows, "现场支付总额", null));
+            customExcelItemList.add(new CustomExcelItem(startColumn + 2, startRows,
+                    FormatUtil.intShrink100ToStr(orders.stream()
+                            .mapToInt(v -> Checker.getIntegerValue(v.getF2fPayAmount()))
+                            .sum()), null));
+            customExcelItemList.add(new CustomExcelItem(startColumn + 3, startRows, "现场退款总额", null));
+            customExcelItemList.add(new CustomExcelItem(startColumn + 4, startRows,
+                    FormatUtil.intShrink100ToStr(orders.stream()
+                            .filter(v -> RefundStatusEnum.SUCCESS.getValue() == Checker.getIntegerValue(v.getRefundStatus()))
+                            .mapToInt(v -> Checker.getIntegerValue(v.getF2fPayAmount()))
+                            .sum()), null));
+            customExcelItemList.add(new CustomExcelItem(startColumn + 5, startRows, "现场实际支付总额", null));
+            customExcelItemList.add(new CustomExcelItem(startColumn + 6, startRows,
+                    FormatUtil.intShrink100ToStr(orders.stream()
+                            .filter(v -> RefundStatusEnum.SUCCESS.getValue() != Checker.getIntegerValue(v.getRefundStatus()))
+                            .mapToInt(v -> Checker.getIntegerValue(v.getF2fPayAmount()))
+                            .sum()), null));
+            customExcelItemList.add(new CustomExcelItem(startColumn + 7, startRows, "现场点单成本", null));
+            customExcelItemList.add(new CustomExcelItem(startColumn + 8, startRows, p2fSinglePointCost, null));
+            startRows += 1;
+            // 洗碗费
+            // 目前只计算有金币支付的订单,不包括纯微信支付及现场支付订单。计算的规则是符合条件的订单的微信支付金额总和。
+            // 等同这个 SQL 语句:
+            // select sum(wechat_pay_amount) from nutrimeal.meal_order where deleted = 0 and pay_type = 4 and (refund_status is null or refund_status != 1) and wechat_pay_amount is not null ;
+            customExcelItemList.add(new CustomExcelItem(startColumn + 1, startRows, "2元洗碗费总额", null));
+            customExcelItemList.add(new CustomExcelItem(startColumn + 2, startRows,
+                    FormatUtil.intShrink100ToStr(orders.stream()
+                            .filter(v -> OrderPayTypeEnum.COIN.getValue() == Checker.getIntegerValue(v.getPayType()) &&
+                                    RefundStatusEnum.SUCCESS.getValue() != Checker.getIntegerValue(v.getRefundStatus()))
+                            .mapToInt(v -> Checker.getIntegerValue(v.getWechatPayAmount()))
+                            .sum()), null));
+            startRows += 2;
+            // v1.3.1_nfyybyfy 新增职工统计
+            // 职工支付
+            customExcelItemList.add(new CustomExcelItem(startColumn + 1, startRows, "职工支付总额", null));
+            customExcelItemList.add(new CustomExcelItem(startColumn + 2, startRows,
+                    FormatUtil.intShrink100ToStr(orders.stream()
+                            .filter(v -> Checker.getIntegerValue(v.getStaffId()) > 0)
+                            .mapToInt(v -> Checker.getIntegerValue(v.getOrderAmount()))
+                            .sum()), null));
+            customExcelItemList.add(new CustomExcelItem(startColumn + 3, startRows, "退款总额", null));
+            customExcelItemList.add(new CustomExcelItem(startColumn + 4, startRows,
+                    FormatUtil.intShrink100ToStr(orders.stream()
+                            .filter(v -> Checker.getIntegerValue(v.getStaffId()) > 0)
+                            .filter(v -> RefundStatusEnum.SUCCESS.getValue() == Checker.getIntegerValue(v.getRefundStatus()))
+                            .mapToInt(v -> Checker.getIntegerValue(v.getOrderAmount()))
+                            .sum()), null));
+            customExcelItemList.add(new CustomExcelItem(startColumn + 5, startRows, "实际支付总额", null));
+            customExcelItemList.add(new CustomExcelItem(startColumn + 6, startRows,
+                    FormatUtil.intShrink100ToStr(orders.stream()
+                            .filter(v -> Checker.getIntegerValue(v.getStaffId()) > 0)
+                            .filter(v -> RefundStatusEnum.SUCCESS.getValue() != Checker.getIntegerValue(v.getRefundStatus()))
+                            .mapToInt(v -> Checker.getIntegerValue(v.getOrderAmount()))
+                            .sum()), null));
+            startRows += 1;
+            // 非职工支付
+            customExcelItemList.add(new CustomExcelItem(startColumn + 1, startRows, "非职工支付总额", null));
+            customExcelItemList.add(new CustomExcelItem(startColumn + 2, startRows,
+                    FormatUtil.intShrink100ToStr(orders.stream()
+                            .filter(v -> Checker.getIntegerValue(v.getStaffId()) <= 0)
+                            .mapToInt(v -> Checker.getIntegerValue(v.getOrderAmount()))
+                            .sum()), null));
+            customExcelItemList.add(new CustomExcelItem(startColumn + 3, startRows, "退款总额", null));
+            customExcelItemList.add(new CustomExcelItem(startColumn + 4, startRows,
+                    FormatUtil.intShrink100ToStr(orders.stream()
+                            .filter(v -> Checker.getIntegerValue(v.getStaffId()) <= 0)
+                            .filter(v -> RefundStatusEnum.SUCCESS.getValue() == Checker.getIntegerValue(v.getRefundStatus()))
+                            .mapToInt(v -> Checker.getIntegerValue(v.getOrderAmount()))
+                            .sum()), null));
+            customExcelItemList.add(new CustomExcelItem(startColumn + 5, startRows, "实际支付总额", null));
+            customExcelItemList.add(new CustomExcelItem(startColumn + 6, startRows,
+                    FormatUtil.intShrink100ToStr(orders.stream()
+                            .filter(v -> Checker.getIntegerValue(v.getStaffId()) <= 0)
+                            .filter(v -> RefundStatusEnum.SUCCESS.getValue() != Checker.getIntegerValue(v.getRefundStatus()))
+                            .mapToInt(v -> Checker.getIntegerValue(v.getOrderAmount()))
+                            .sum()), null));
+            startRows += 2;
+        }
+        if (customExcelItemList.size() > 0) {
+            customExcelItemList.add(new CustomExcelItem(startColumn + 1, startRows,
+                    "备注(单位:元):", ExcelDownloadSrv.getCellFormat4StatRemarkWithNoSetBorder()));
+            customExcelItemList.add(new CustomExcelItem(startColumn + 1, startRows + 1,
+                    "1、支付总额=微信支付总额+金币支付总额+现场支付总额;", ExcelDownloadSrv.getCellFormat4StatRemarkWithNoSetBorder()));
+            customExcelItemList.add(new CustomExcelItem(startColumn + 1, startRows + 2,
+                    "2、退款总额=微信退款总额+金币退款总额+现场退款总额;", ExcelDownloadSrv.getCellFormat4StatRemarkWithNoSetBorder()));
+            customExcelItemList.add(new CustomExcelItem(startColumn + 1, startRows + 3,
+                    "3、实际支付总额=微信实际支付总额+金币实际支付总额+现场实际支付总额=支付总额-退款总额;", ExcelDownloadSrv.getCellFormat4StatRemarkWithNoSetBorder()));
+            customExcelItemList.add(new CustomExcelItem(startColumn + 1, startRows + 4,
+                    "4、总成本=微信点单成本+金币点单成本+现场点单成本(也等于各个菜品成本价乘以份数的相加的总额);", ExcelDownloadSrv.getCellFormat4StatRemarkWithNoSetBorder()));
+            customExcelItemList.add(new CustomExcelItem(startColumn + 1, startRows + 5,
+                    "5、微信点单成本:支付方式是“微信支付”的订单,其各个菜品成本价乘以份数的相加的总额(不包含退款订单);", ExcelDownloadSrv.getCellFormat4StatRemarkWithNoSetBorder()));
+            customExcelItemList.add(new CustomExcelItem(startColumn + 1, startRows + 6,
+                    "   金币点单成本:支付方式是“微信+金币”的订单,其各个菜品成本价乘以份数的相加的总额(不包含退款订单);", ExcelDownloadSrv.getCellFormat4StatRemarkWithNoSetBorder()));
+            customExcelItemList.add(new CustomExcelItem(startColumn + 1, startRows + 7,
+                    "   现场点单成本:支付方式是“现场支付”的订单,其各个菜品成本价乘以份数的相加的总额(不包含退款订单);", ExcelDownloadSrv.getCellFormat4StatRemarkWithNoSetBorder()));
+            customExcelItemList.add(new CustomExcelItem(startColumn + 1, startRows + 8,
+                    "6、2元洗碗费总额:支付方式是“微信+金币”的订单,其微信支付部分的总额(不包含退款订单)。", ExcelDownloadSrv.getCellFormat4StatRemarkWithNoSetBorder()));
+        }
+        return customExcelItemList;
+    }
+
+
+    public void downloadMealOrderBillList(int downloadRecordId, String fileName, MealOrderListRequest request) {
+        try {
+
+
+            String col0 = "交易类型*";
+            String col1 = "系统参考号*";
+            String col2 = "交易金额*";
+            String col3 = "交易日期*";
+            String col4 = "订单号";
+            String col5 = "类型";
+            String[] columns = new String[]{col0, col1, col2, col3, col4, col5};
+            List<Shop> shopList = shopService.getAllShops();
+            ExcelDataMap map = new ExcelDataMap(columns);
+            List<UserMealOrderView> userMealOrderViews = queryDownLoadMealOrderList(request);
+//        List<OrderPayment> orderPaymentList = orderPaymentService.getOrderPaymentListByMealOrderList(userMealOrderViews);
+            List<MealOrderInfo> list = new ArrayList<>();
+            if (!Checker.isNone(userMealOrderViews)) {
+                for (UserMealOrderView p : userMealOrderViews) {
+                    MealOrderInfo info = new MealOrderInfo();
+                    info.setId(p.getId());
+
+                    // 订单号
+                    info.setOrderNo(p.getOrderNo());
+
+//                // 店铺名称
+//                String shopName = mealOrderService.getShopName(shopList, Checker.getIntegerValue(p.getShopId()));
+//                item.put("shopName", shopName);
+                    // 客户姓名
+                    info.setContactName(p.getContactName());
+                    info.setMobile(p.getMobile());
+
+                    int typeInt = Checker.getIntegerValue(p.getType());
+                    String typeStr = MealOrderTypeEnum.getDisplayName(typeInt);
+                    info.setType(typeStr);
+//                item.put("type", typeStr);
+//                item.put("typeInt", typeInt);
+                    // 状态
+                    int statusInt = Checker.getIntegerValue(p.getStatus());
+                    String statusStr = MealOrderStatusEnum.getDisplayName(statusInt);
+                    info.setStatus(statusStr);
+                    info.setStatusInt(statusInt);
+//                item.put("statusInt", statusInt);
+//                item.put("status", statusStr);
+                    // 总价
+                    info.setTotalStr(FormatUtil.intShrink100ToStr(p.getOrderAmount()));
+                    info.setWechatInt(Checker.getIntegerValue(p.getWechatPayAmount()));
+
+//                item.put("totalStr", FormatUtil.intShrink100ToStr(p.getOrderAmount()));
+//                item.put("wechatStr", FormatUtil.intShrink100ToStr(p.getWechatPayAmount()));
+//                item.put("wechatInt", Checker.getIntegerValue(p.getWechatPayAmount()));
+//                item.put("coinStr", FormatUtil.intShrink100ToStr(p.getCoinPayAmount()));
+//                item.put("cashStr", FormatUtil.intShrink100ToStr(p.getF2fPayAmount()));
+                    // 支付时间
+                    info.setPaymentTime(FormatUtil.createTimeFormatList(p.getPaymentTime()));
+//                item.put("paymentTime", FormatUtil.createTimeFormatList(p.getPaymentTime()));
+                    // 取餐时间
+                    info.setCreateTime(FormatUtil.createTimeFormatList(p.getDeliveryTime()));
+//                item.put("createTime", FormatUtil.createTimeFormatList(p.getDeliveryTime()));
+                    //支付方式
+//                item.put("payType", OrderPayTypeEnum.valueOf(Checker.getIntegerValue(p.getPayType())).getDisplayName());
+                    //支付流水号
+                    info.setPaymentNo(Checker.getStringValue(p.getPaymentNo()));
+                    info.setRefundTime(FormatUtil.createTimeFormatList(p.getRefundTime()));
+//                item.put("paymentNo", Checker.getStringValue(p.getPaymentNo()));
+//                item.put("refundTime", FormatUtil.createTimeFormatList(p.getRefundTime()));
+                    Integer paymentStatus = p.getPaymentStatus();
+                    info.setPayStatus(paymentStatus == null ? PaymentStatusEnum.Pending.getDisplayName() :
+                            MealPaymentStatusEnum.valueOf(paymentStatus).getDisplayName());
+//                item.put("payStatus", paymentStatus == null ? PaymentStatusEnum.Pending.getDisplayName() :
+//                        PaymentStatusEnum.valueOf(paymentStatus).getDisplayName());
+                    String extData = Checker.getStringValue(p.getExtData());
+                    Map<String, Object> m = FormatUtil.stringToMapT(extData);
+                    info.setRemark(m == null ? "" : (String) m.getOrDefault("refuseOrderRemark", ""));
+//                item.put("remark", m == null ? "" : (String) m.getOrDefault("refuseOrderRemark", ""));
+                    int hid = Checker.getIntegerValue(p.getHospitalId());
+                    list.add(info);
+//                item.put("hospitalId", hid);
+//                item.put("hospitalName", BizUtil.getHospitalNameByHospitalId(hid));
+//                item.put("pickupCode", Checker.getStringValue(p.getPickupCode()));
+//                item.put("staffId", p.getStaffId());
+//                item.put("deptName", Checker.getStringValue(p.getDeptName()));
+//                item.put("extStatus", Checker.getIntegerValue(p.getExtStatus()));
+
+//                String transactionIdStr = orderPaymentService.getTransactionIdByOrderNo(orderPaymentList, Checker.getStringValue(p.getOrderNo()));
+//                item.put("transactionId", transactionIdStr);
+                }
+                if (!Checker.isNone(list)) {
+                    List<OrderPayment> orderPaymentList = orderPaymentService.getOrderPaymentListByMealOrderListB(list);
+                    // 得到退款的记录日志(需要从 refund_log 获取 refund_id 字段)
+                    List<RefundLog> refundLogList = refundLogService.getRefundLogListByMealOrderList(list);
+                    List<MealOrderInfo> refundList = new ArrayList<>();
+                    Date billStartTime = DateUtil.stringToDate(request.getBillStartTime() + ConstantDef.BILL_TIME_START_FORMAT);
+                    Date billEndTime = DateUtil.stringToDate(request.getBillEndTime() + ConstantDef.BILL_TIME_END_FORMAT);
+                    for (MealOrderInfo p : list) {
+                        if (PaymentStatusEnum.Success.getDisplayName().equals(p.getPayStatus())
+                                && Checker.getIntegerValue(p.getWechatInt()) > 0
+                                && !Checker.isNone(p.getPaymentTime())) {
+                            // "交易类型*", "系统参考号*", "交易金额*", "交易日期*", "订单号", "类型"
+                            Date paymentTime = DateUtil.stringToDate(p.getPaymentTime() + ConstantDef.BILL_TIME_LIST_FORMAT);
+                            if (!Checker.isNone(paymentTime) && paymentTime.after(billStartTime) && paymentTime.before(billEndTime)) {
+                                // 交易类型: 已支付,已退款,先处理已支付的,再处理已退款的
+                                String type = ConstantDef.BILL_PAYMENT_STR;
+                                // 交易流水号
+                                String transactionId = "";
+                                if (!Checker.isNone(orderPaymentList)) {
+                                    OrderPayment orderPayment = orderPaymentList.stream().filter(o -> p.getOrderNo().equals(Checker.getStringValue(o.getOrderNo()))).findFirst().orElse(null);
+                                    if (orderPayment != null && !Checker.isNone(orderPayment.getTransactionId())) {
+                                        transactionId = Checker.getStringValue(orderPayment.getTransactionId());
+                                    }
+                                }
+                                // 交易金额
+                                String totalStr = FormatUtil.intShrink100ToStr(p.getWechatInt());
+                                // 交易时间
+                                String paymentTimeStr = FormatUtil.createTimeFormatDetail(p.getPaymentTime());
+                                // 订单号
+                                String orderNo = Checker.getStringValue(p.getOrderNo());
+                                // 类型
+                                String typeName = "营养餐";
+
+                                String[] bodyStr = {type, transactionId, totalStr, paymentTimeStr, orderNo, typeName};
+                                map.getStringListSafely(col0).add(type);
+                                map.getStringListSafely(col1).add(transactionId);
+                                map.getStringListSafely(col2).add(totalStr);
+                                map.getStringListSafely(col3).add(paymentTimeStr);
+                                map.getStringListSafely(col4).add(orderNo);
+                                map.getStringListSafely(col5).add(typeName);
+//                            ExcelHelper.settingMainBodyLabelCell(sheet, cellFormat2, n, bodyStr);
+//                            n++;
+                                refundList.addAll(getRefundMealOrderList(list));
+                            }
+                        }
+                    }
+                    for (MealOrderInfo p : refundList) {
+                        if (!Checker.isNone(p) && !Checker.isNone(p.getRefundTime()) && Checker.getIntegerValue(p.getWechatInt()) > 0) {
+                            // "交易类型*", "系统参考号*", "交易金额*", "交易日期*", "订单号", "类型"
+                            Date refundTime = DateUtil.stringToDate(p.getRefundTime() + ConstantDef.BILL_TIME_LIST_FORMAT);
+                            if (!Checker.isNone(refundTime) && refundTime.after(billStartTime) && refundTime.before(billEndTime)) {
+                                String type = ConstantDef.BILL_REFUND_STR;
+                                // 交易流水号
+                                String transactionId = "";
+                                RefundLog refundLog = refundLogList.stream().filter(o -> p.getPaymentNo().equals(o.getOutOrderNo())).findFirst().orElse(null);
+                                if (refundLog != null && !Checker.isNone(refundLog.getRefundId())) {
+                                    transactionId = refundLog.getRefundId();
+                                }
+                                // 交易金额
+                                String totalStr = FormatUtil.intShrink100ToStr(p.getWechatInt());
+                                // 交易时间
+                                String refundTimeStr = FormatUtil.createTimeFormatDetail(p.getRefundTime());
+                                // 订单号
+                                String orderNo = Checker.getStringValue(p.getOrderNo());
+                                // 类型
+                                String typeName = "营养餐";
+
+                                String[] bodyStr = {type, transactionId, totalStr, refundTimeStr, orderNo, typeName};
+//                            ExcelHelper.settingMainBodyLabelCell(sheet, cellFormat2, n, bodyStr);
+//                            n++;
+                                map.getStringListSafely(col0).add(type);
+                                map.getStringListSafely(col1).add(transactionId);
+                                map.getStringListSafely(col2).add(totalStr);
+                                map.getStringListSafely(col3).add(refundTimeStr);
+                                map.getStringListSafely(col4).add(orderNo);
+                                map.getStringListSafely(col5).add(typeName);
+                            }
+                        }
+                    }
+
+                }
+            }
+            int size = list.size();
+            List<ExcelCollectPojo> itemList = new ArrayList<>();
+            downloadRecordService.createFileAndUploadOssAndSaveToDataBase(fileName, downloadRecordId, map, itemList);
+
+        } catch (Exception e) {
+            logger.error("/mealOrder/downloadMealOrderBillsList(): {}", e.getMessage(), e);
+            e.printStackTrace();
+        }
+
+    }
+
+    private List<MealOrderInfo> getRefundMealOrderList(List<MealOrderInfo> list) {
+        if (!Checker.isNone(list)) {
+            return list.stream().filter(p -> !Checker.isNone(p.getRefundTime())).collect(Collectors.toList());
+        }
+        return new ArrayList<>();
+    }
+}

+ 69 - 0
src/main/java/com/ywt/mg/services/OrderDishService.java

@@ -0,0 +1,69 @@
+package com.ywt.mg.services;
+
+import com.ywt.mg.core.SqlHelper;
+import com.ywt.mg.core.utils.Checker;
+
+import com.ywt.mg.domain.mealEntities.UserMealOrderView;
+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.List;
+
+@Service
+public class OrderDishService {
+
+    @Autowired
+    private JdbcTemplate jdbcTemplate;
+
+    @Autowired
+    private SqlHelper sqlHelper;
+
+    private final Logger logger = LoggerFactory.getLogger(OrderDishService.class);
+
+
+
+    /**
+     * 根据订单IDs得到所有的成本之和
+     *
+     * @param orderIds eg:1,3,5
+     * @return 和
+     */
+    public int getAllDishCostPriceSumByOrderIds(String orderIds) {
+        StringBuilder sqlBuilder = new StringBuilder();
+        sqlBuilder.append("select sum(dish_cost_price * count) from order_dish where order_id in (")
+                .append(orderIds)
+                .append(") and deleted = 0 and dish_cost_price is not null;");
+        Integer dishCostPriceSum = jdbcTemplate.queryForObject(sqlBuilder.toString(), Integer.class);
+        return Checker.getIntegerValue(dishCostPriceSum);
+    }
+
+
+    /**
+     * 根据 list 列表得到所有的成本之和
+     *
+     * @param list {@link List <UserMealOrderView>}
+     * @return 和
+     */
+    public int getAllDishCostPriceSumByUserMealOrderViewList(List<UserMealOrderView> list) {
+        String orderIds = getOrderIdsByUserMealOrderViewList(list);
+        return getAllDishCostPriceSumByOrderIds(orderIds);
+    }
+
+
+    /**
+     * 根据 list 列表得到oderIds
+     * @param list {@link List<UserMealOrderView>}
+     * @return orderIds eg:1,3,5,-1
+     */
+    public String getOrderIdsByUserMealOrderViewList(List<UserMealOrderView> list) {
+        StringBuilder sqlBuilder = new StringBuilder();
+        for (UserMealOrderView view : list) {
+            sqlBuilder.append(view.getOrderId()).append(",");
+        }
+        sqlBuilder.append("-1");
+        return sqlBuilder.toString();
+    }
+}

+ 42 - 3
src/main/java/com/ywt/mg/services/OrderPaymentService.java

@@ -2,8 +2,10 @@ package com.ywt.mg.services;
 
 import com.ywt.mg.core.utils.Checker;
 import com.ywt.mg.domain.entities.*;
+import com.ywt.mg.domain.mealEntities.UserMealOrderView;
 import com.ywt.mg.domain.models.enums.PaymentStatusEnum;
 import com.ywt.mg.domain.models.nutrimeal.MealOrderInfo;
+import com.ywt.mg.params.deposit.DepositOrderInfo;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 import org.springframework.beans.factory.annotation.Autowired;
@@ -73,15 +75,16 @@ public class OrderPaymentService extends ServiceBase {
         return getOrderPaymentListByOrderIds(orderIds);
     }
 
-    public List<OrderPayment> getOrderPaymentListByMealOrderList(List<MealOrderInfo> list) {
+    public List<OrderPayment> getOrderPaymentListByMealOrderList(List<UserMealOrderView> list) {
         if (Checker.isNone(list)) {
             return new ArrayList<>();
         }
-        list = list.stream().filter(p -> PaymentStatusEnum.Success.getDisplayName().equals(p.getPayStatus()) && Checker.getIntegerValue(p.getWechatInt()) > 0 && !Checker.isNone(p.getPaymentNo())).collect(Collectors.toList());
-        List<String> paymentNos = list.stream().map(MealOrderInfo::getPaymentNo).collect(Collectors.toList());
+        list = list.stream().filter(p -> Checker.getIntegerValue(p.getPaymentStatus()) == PaymentStatusEnum.Success.getValue() && Checker.getIntegerValue(p.getWechatPayAmount()) > 0 && !Checker.isNone(p.getPaymentNo())).collect(Collectors.toList());
+        List<String> paymentNos = list.stream().map(UserMealOrderView::getPaymentNo).collect(Collectors.toList());
         return getOrderPaymentListByPaymentNos(paymentNos);
     }
 
+
     private List<OrderPayment> getOrderPaymentListByPaymentNos(List<String> paymentNos) {
         paymentNos = paymentNos.stream().filter(p -> !Checker.isNone(p)).collect(Collectors.toList());
         int size = paymentNos.size();
@@ -170,4 +173,40 @@ public class OrderPaymentService extends ServiceBase {
         return "";
     }
 
+    public List<OrderPayment> getOrderPaymentListByDepositList(List<DepositOrderInfo> list) {
+        if (Checker.isNone(list)) {
+            return new ArrayList<>();
+        }
+        list = list.stream().filter(p -> !Checker.isNone(p.getPaymentNo())).collect(Collectors.toList());
+        List<String> paymentNos = list.stream().map(DepositOrderInfo::getPaymentNo).collect(Collectors.toList());
+        return getOrderPaymentListByPaymentNos(paymentNos);
+    }
+
+    public List<OrderPayment> getOrderPaymentListByDepositOrderInfoList(List<DepositOrderInfo> list) {
+        if (Checker.isNone(list)) {
+            return new ArrayList<>();
+        }
+        list = list.stream().filter(p -> !Checker.isNone(p.getPaymentNo())).collect(Collectors.toList());
+        List<String> paymentNos = list.stream().map(DepositOrderInfo::getPaymentNo).collect(Collectors.toList());
+        return getOrderPaymentListByPaymentNos(paymentNos);
+    }
+
+    public String getTransactionIdByOrderNo(List<OrderPayment> orderPaymentList, String orderNo) {
+        if (!Checker.isNone(orderPaymentList) && !Checker.isNull(orderNo)) {
+            OrderPayment orderPayment = orderPaymentList.stream().filter(o -> Checker.getStringValue(o.getOrderNo()).equals(orderNo)).findFirst().orElse(null);
+            if (orderPayment != null && !Checker.isNone(orderPayment.getTransactionId())) {
+                return orderPayment.getTransactionId();
+            }
+        }
+        return "";
+    }
+
+    public List<OrderPayment> getOrderPaymentListByMealOrderListB(List<MealOrderInfo> list) {
+        if (Checker.isNone(list)) {
+            return new ArrayList<>();
+        }
+        list = list.stream().filter(p -> PaymentStatusEnum.Success.getDisplayName().equals(p.getPayStatus()) && Checker.getIntegerValue(p.getWechatInt()) > 0 && !Checker.isNone(p.getPaymentNo())).collect(Collectors.toList());
+        List<String> paymentNos = list.stream().map(MealOrderInfo::getPaymentNo).collect(Collectors.toList());
+        return getOrderPaymentListByPaymentNos(paymentNos);
+    }
 }

+ 530 - 0
src/main/java/com/ywt/mg/services/OutpatientOrderService.java

@@ -0,0 +1,530 @@
+package com.ywt.mg.services;
+
+import com.ywt.mg.configs.ParameterConfigurer;
+import com.ywt.mg.core.SqlHelper;
+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.entities.OutpatientOrder;
+import com.ywt.mg.domain.entities.RefundLog;
+import com.ywt.mg.domain.entities.User;
+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.models.pojo.ExcelCollectPojo;
+import com.ywt.mg.params.outpatientOrder.QueryOutPatientOrderListRequest;
+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.*;
+import java.util.stream.Collectors;
+
+@Service
+public class OutpatientOrderService {
+
+    private static Logger logger = LoggerFactory.getLogger(OutpatientOrderService.class);
+
+    @Autowired
+    private SqlHelper sqlHelper;
+
+    @Autowired
+    private ParameterConfigurer parameterConfigurer;
+
+    @Autowired
+    private AuthService authService;
+
+    @Autowired
+    private UserService userService;
+
+    @Autowired
+    private OrderPaymentService orderPaymentService;
+
+    @Autowired
+    private JdbcTemplate jdbcTemplate;
+
+    @Autowired
+    private DownloadRecordService downloadRecordService;
+
+    @Autowired
+    private RefundLogService refundLogService;
+
+
+    private List<OutpatientOrder> queryOutPatientOrderList(QueryOutPatientOrderListRequest request) throws Exception {
+        Map map = queryOutPatientOrderListCommonNew(request);
+
+        String whereSql = (String) map.get(ConstantDef.KEY_WHERE_SQL);
+        List paramList = (List) map.get(ConstantDef.KEY_PARAM_LIST);
+        return sqlHelper.getListWithNoPage("*", whereSql, " id desc ", OutpatientOrder.class, paramList.toArray());
+    }
+
+    public Map<String, Object> queryOutPatientOrderListCommonNew(QueryOutPatientOrderListRequest request) throws Exception {
+        List<Object> paramList = new ArrayList<>();
+        String whereSql = " ( 1=1 )";
+
+        // 添加测试账号过滤
+        String testAdminIds = parameterConfigurer.getTestAdminIds();
+        String testDoctorCodes = parameterConfigurer.getTestDoctorCodes();
+        String adminStr = "," + authService.getCurrentAdminId() + ",";
+        String testAdminIdsStr = "," + testAdminIds + ",";
+
+        // 不是测试账号
+        if (!(testAdminIdsStr.contains(adminStr))) {
+            String[] testDoctorIdsArr = testDoctorCodes.split(",");
+            if (!Checker.isNone(testDoctorIdsArr)) {
+                String sqlSubFrom = "";
+                for (String doctorCode : testDoctorIdsArr) {
+                    sqlSubFrom += "doctor_code != " + doctorCode + " and ";
+                }
+                sqlSubFrom = sqlSubFrom.substring(0, sqlSubFrom.lastIndexOf("and"));
+                whereSql += String.format(" and ((%s) or doctor_code is null)", sqlSubFrom);
+            }
+        }
+        String orderno = request.getOrderno();
+        if (!Checker.isNone(orderno)) {
+            whereSql += " and ( order_no like ?)";
+            paramList.add("%" + orderno.trim() + "%");
+        }
+        String patientname = request.getPatientname();
+        if (!Checker.isNull(patientname)) {
+            whereSql += " and ( patient_name like ?)";
+            paramList.add("%" + patientname.trim() + "%");
+        }
+        String userMobile = request.getUserMobile();
+        if (!Checker.isNull(userMobile)) {
+            int userId = userService.getUserIdByMobile(userMobile);
+            if (userId > 0) {
+                whereSql += " and ( user_id = ?)";
+                paramList.add(userId);
+            } else {
+                whereSql += " and ( user_id = -1)";
+            }
+        }
+        String doctorname = request.getDoctorname();
+        if (!Checker.isNull(doctorname)) {
+            whereSql += " and ( doctor_name like ?)";
+            paramList.add("%" + doctorname.trim() + "%");
+        }
+        String deptname = request.getDeptname();
+        if (!Checker.isNull(deptname)) {
+            whereSql += " and ( dept_name like ?)";
+            paramList.add("%" + deptname.trim() + "%");
+        }
+        String hospitalname = request.getHospitalname();
+        if (!Checker.isNull(hospitalname)) {
+            whereSql += " and ( hospital_name like ?)";
+            paramList.add("%" + hospitalname.trim() + "%");
+        }
+
+        //门诊缴费状态
+        String outpatientstatus = request.getOutpatientstatus();
+        if (!Checker.isNull(outpatientstatus)) {
+            int status = Integer.parseInt(outpatientstatus);
+            whereSql += " and ( outpatient_status = ?  )";
+            paramList.add(status);
+        } else {
+            whereSql += " and ( outpatient_status > ?  )";
+            paramList.add(OutpatientStatusEnum.PENDING.getValue());
+        }
+
+        //支付状态(0-待支付,1-支付处理中,2-支付成功,3-支付失败)
+        String paymentstatus = request.getPaymentstatus();
+        if (!Checker.isNull(paymentstatus)) {
+            whereSql += " and ( payment_status =  ?  )";
+            paramList.add(Integer.parseInt(paymentstatus));
+        }
+
+        String terminal = request.getTerminal();
+        if (!Checker.isNull(terminal)) {
+            int terminalId = Integer.parseInt(terminal);
+            whereSql += " and ( terminal = ? )";
+            paramList.add(terminalId);
+        }
+
+        //express   1-可以快递   0-不可以
+        String express = request.getExpress();
+        if (!Checker.isNull(express)) {
+            int expressInt = Integer.parseInt(express);
+            if (expressInt == 1) {
+                whereSql += " and ( express =  ? )";
+                paramList.add(expressInt);
+            } else {
+                whereSql += " and ( express =  ? or express is null)";
+                paramList.add(expressInt);
+            }
+        }
+
+        String formatDate = "yyyy-MM-dd";
+        SimpleDateFormat format = new SimpleDateFormat(formatDate);
+
+        //下单时间
+        String createEndTime = request.getCreateEndTime();
+        String createStartTime = request.getCreateStartTime();
+        if (!Checker.isNull(createEndTime)) {
+            whereSql += " and ( create_time < ? )";
+            Date date = format.parse(createEndTime);
+
+            // 把日期往后增加一天.整数往后推,负数往前移动
+            Calendar calendar = new GregorianCalendar();
+            calendar.setTime(date);
+            calendar.add(Calendar.DATE, 1);
+            // 这个时间就是日期往后推一天的结果
+            date = calendar.getTime();
+
+            paramList.add(date);
+        }
+
+        if (!Checker.isNull(createStartTime)) {
+            whereSql += " and ( create_time >= ?)";
+            Date date = format.parse(createStartTime);
+            paramList.add(date);
+        }
+
+        //支付时间
+        String payEndTime = request.getPayEndTime();
+        String payStartTime = request.getPayStartTime();
+        if (!Checker.isNull(payEndTime)) {
+            whereSql += " and ( pay_time < ? )";
+            Date date = format.parse(payEndTime);
+
+            // 把日期往后增加一天.整数往后推,负数往前移动
+            Calendar calendar = new GregorianCalendar();
+            calendar.setTime(date);
+            calendar.add(Calendar.DATE, 1);
+            // 这个时间就是日期往后推一天的结果
+            date = calendar.getTime();
+
+            paramList.add(date);
+        }
+
+        if (!Checker.isNull(payStartTime)) {
+            whereSql += " and ( pay_time >= ?)";
+            Date date = format.parse(payStartTime);
+            paramList.add(date);
+        }
+        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 = 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);
+        }
+
+        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);
+        }
+
+        whereSql += " and ( deleted = 0 )";
+        Map map = new HashMap();
+        map.put(ConstantDef.KEY_WHERE_SQL, whereSql);
+        map.put(ConstantDef.KEY_PARAM_LIST, paramList);
+        return map;
+    }
+
+    public void downloadOutPatientOrderListCommon(int downloadRecordId, String fileName, QueryOutPatientOrderListRequest request) {
+        try {
+            boolean isAdmin = request.isAdmin();
+            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[] columns = new String[]{col0, col1, col2, col3, col4, col5, col6, col7, col8, col9, col10,
+                    col11, col12, col13, col14, col15};
+            if (isAdmin == false) {
+                columns = new String[]{col0, col1, col2, col3, col4, col5, col6, col7, col9, col10,
+                        col12, col13, col14, col15};
+            }
+
+            List<OutpatientOrder> list = queryOutPatientOrderList(request);
+            List<User> userList = getUserListByOutpatientOrderViewList(list, list.size());
+            List<OrderPayment> orderPaymentList = orderPaymentService.getOrderPaymentListByOutPatientOrderList(list);
+            int payTotal = 0;
+            ExcelDataMap map = new ExcelDataMap(columns);
+            if (!Checker.isNone(list)) {
+                for (OutpatientOrder p : list) {
+                    String orderNoValue = Checker.getStringValue(p.getOrderNo());
+                    String paymentNoValue = Checker.getStringValue(p.getPaymentNo());
+                    String patientNameValue = p.getPatientName();
+                    String mobileValue = getUserMobile(userList, Checker.getIntegerValue(p.getUserId()));
+                    String hisPatientId = p.getHisPatientId();
+                    String doctorNameValue = p.getDoctorName();
+                    String deptNameValue = p.getDeptName();
+                    String hospitalNameValue = p.getHospitalName();
+                    String total = FormatUtil.decimalFormat(p.getTotal() / 100.0);
+                    String expressStr = getOutpatientExpressStr(Checker.getIntegerValue(p.getExpress()));
+
+                    int outpatientStatusInt = Checker.getIntegerValue(p.getOutpatientStatus());
+                    String outpatientStatusStr = OutpatientStatusEnum.valueOf(outpatientStatusInt).getDisplayName();
+
+                    int paymentStatusInt = Checker.getIntegerValue(p.getPaymentStatus());
+                    String paymentStatusStr = PaymentStatusEnum.getPaymentStatus(paymentStatusInt).getDisplayName();
+                    String createTimeValue = FormatUtil.createTimeFormatList(p.getCreateTime());
+                    String payTimeValue = FormatUtil.createTimeFormatList(p.getPayTime());
+                    String terminal = "";
+                    if (!Checker.isNone(p.getTerminal())) {
+                        terminal = TerminalEnum.valueOf(p.getTerminal()).getDisplayName();
+                    }
+                    // 交易流水号
+                    String transactionId = orderPaymentService.getTransactionIdByOrderId(orderPaymentList, Checker.getIntegerValue(p.getOrderId()));
+//
+//                    String[] bodyStr = new String[]{orderNoValue, paymentNoValue, transactionId, patientNameValue, mobileValue, hisPatientId, doctorNameValue, deptNameValue,
+//                            hospitalNameValue, terminal, total, expressStr, outpatientStatusStr, paymentStatusStr, createTimeValue, payTimeValue};
+//                    if (isAdmin == false) {
+//                        bodyStr = new String[]{orderNoValue, paymentNoValue, transactionId, patientNameValue, mobileValue, hisPatientId, doctorNameValue, deptNameValue, terminal,
+//                                total, outpatientStatusStr, paymentStatusStr, createTimeValue, payTimeValue};
+//                    }
+                    if (Checker.getIntegerValue(p.getPaymentStatus()) == PaymentStatusEnum.Success.getValue()) {
+                        payTotal += Checker.getIntegerValue(p.getTotal());
+                    }
+
+                    if (isAdmin == false) {
+                        map.getStringListSafely(col0).add(orderNoValue);
+                        map.getStringListSafely(col1).add(paymentNoValue);
+                        map.getStringListSafely(col2).add(transactionId);
+                        map.getStringListSafely(col3).add(patientNameValue);
+                        map.getStringListSafely(col4).add(mobileValue);
+                        map.getStringListSafely(col5).add(hisPatientId);
+                        map.getStringListSafely(col6).add(doctorNameValue);
+                        map.getStringListSafely(col7).add(deptNameValue);
+//                        map.getStringListSafely(col8).add(hospitalNameValue);
+                        map.getStringListSafely(col9).add(terminal);
+                        map.getStringListSafely(col10).add(total);
+//                        map.getStringListSafely(col11).add(expressStr);
+                        map.getStringListSafely(col12).add(outpatientStatusStr);
+                        map.getStringListSafely(col13).add(paymentStatusStr);
+                        map.getStringListSafely(col14).add(createTimeValue);
+                        map.getStringListSafely(col15).add(payTimeValue);
+                    } else {
+                        map.getStringListSafely(col0).add(orderNoValue);
+                        map.getStringListSafely(col1).add(paymentNoValue);
+                        map.getStringListSafely(col2).add(transactionId);
+                        map.getStringListSafely(col3).add(patientNameValue);
+                        map.getStringListSafely(col4).add(mobileValue);
+                        map.getStringListSafely(col5).add(hisPatientId);
+                        map.getStringListSafely(col6).add(doctorNameValue);
+                        map.getStringListSafely(col7).add(deptNameValue);
+                        map.getStringListSafely(col8).add(hospitalNameValue);
+                        map.getStringListSafely(col9).add(terminal);
+                        map.getStringListSafely(col10).add(total);
+                        map.getStringListSafely(col11).add(expressStr);
+                        map.getStringListSafely(col12).add(outpatientStatusStr);
+                        map.getStringListSafely(col13).add(paymentStatusStr);
+                        map.getStringListSafely(col14).add(createTimeValue);
+                        map.getStringListSafely(col15).add(payTimeValue);
+                    }
+                }
+            }
+            int size = list.size();
+            List<ExcelCollectPojo> itemList = getStatisticsData(size, payTotal);
+            downloadRecordService.createFileAndUploadOssAndSaveToDataBase(fileName, downloadRecordId, map, itemList);
+        } catch (Exception e) {
+            logger.error("/outPatient/downloadOutPatientOrderList(): {}", e.getMessage(), e);
+            e.printStackTrace();
+        }
+
+    }
+
+    public String getUserMobile(List<User> userList, int userId) {
+        if (userId == 0) {
+            return "";
+        }
+        if (!Checker.isNone(userList)) {
+            User user = userList.stream().filter(p -> p.getId().intValue() == userId).findFirst().orElse(null);
+            if (!Checker.isNone(user)) {
+                return Checker.getStringValue(user.getMobile());
+            }
+        }
+        return "";
+    }
+
+
+    public List<User> getUserListByOutpatientOrderViewList(List<OutpatientOrder> offList, int size) {
+        String userIds = getUserIdsByList(offList);
+        if (!Checker.isNone(userIds)) {
+            String sql = "select * from user where is_deleted = 0 and (" + userIds + ") limit " + size + ";";
+            return jdbcTemplate.query(sql, new BeanPropertyRowMapper<>(User.class));
+        }
+        return null;
+    }
+
+    public String getUserIdsByList(List<OutpatientOrder> viewList) {
+        String userIds = "";
+        if (!Checker.isNone(viewList)) {
+            for (OutpatientOrder view : viewList) {
+                if (Checker.getIntegerValue(view.getUserId()) != 0) {
+                    userIds += " id = " + view.getUserId() + " or";
+                }
+            }
+            if (userIds.length() > 0) {
+                userIds = userIds.substring(0, userIds.length() - 2);
+            }
+        }
+        return userIds;
+    }
+
+    public String getOutpatientExpressStr(int express) {
+        if (express == OutpatientExpressEnum.YES.getValue()) {
+            return OutpatientExpressEnum.YES.getDisplayName();
+        }
+        if (express == OutpatientExpressEnum.NO.getValue()) {
+            return OutpatientExpressEnum.NO.getDisplayName();
+        }
+        return "";
+    }
+
+    /**
+     * 获取统计数据
+     *
+     * @param size     隔行
+     * @param payTotal 总金额
+     * @return {@link List<ExcelCollectPojo> }
+     */
+    private List<ExcelCollectPojo> getStatisticsData(int size, int payTotal) {
+        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)}));
+        return customExcelItemList;
+    }
+
+    public void downloadOutPatientOrderBillListNew(int downloadRecordId, String fileName,  QueryOutPatientOrderListRequest request){
+        try {
+                    String col0 = "交易类型*";
+                    String col1 = "系统参考号*";
+                    String col2 = "交易金额*";
+                    String col3 =  "交易日期*";
+                    String col4 = "订单号";
+                    String col5 = "类型";
+            String[] columns = new String[]{col0, col1, col2, col3, col4, col5};
+            //给第二行设置背景、字体颜色、对齐方式等等;
+            // 只搜索已支付的订单
+            request.setPaymentstatus(PaymentStatusEnum.Success.getValue() + "");
+            List<OutpatientOrder> outpatientOrderList = queryOutPatientOrderList(request);
+            ExcelDataMap map = new ExcelDataMap(columns);
+            if (!Checker.isNone(outpatientOrderList)) {
+                // 得到支付的记录日志(需要从 order_payment 获取 transaction_id 字段)
+                List<OrderPayment> orderPaymentList = orderPaymentService.getOrderPaymentListByOutPatientOrderList(outpatientOrderList);
+                Date billStartTime = DateUtil.stringToDate(request.getBillStartTime() + ConstantDef.BILL_TIME_START_FORMAT);
+                Date billEndTime = DateUtil.stringToDate(request.getBillEndTime() + ConstantDef.BILL_TIME_END_FORMAT);
+                for (OutpatientOrder p : outpatientOrderList){
+                    if (!Checker.isNone(p) && Checker.getIntegerValue(p.getPaymentStatus()) == PaymentStatusEnum.Success.getValue()
+                            && !Checker.isNone(p.getPayTime())) {
+                        Date paymentTime = Checker.getDateValue(p.getPayTime());
+                        if (!Checker.isNone(paymentTime) && paymentTime.after(billStartTime) && paymentTime.before(billEndTime)) {
+                            String type = ConstantDef.BILL_PAYMENT_STR;
+                            // 交易流水号
+                            String transactionId = orderPaymentService.getTransactionIdByOrderId(orderPaymentList, Checker.getIntegerValue(p.getOrderId()));
+                            // 交易金额
+                            int total = Checker.getIntegerValue(p.getTotal());
+                            String totalStr = FormatUtil.intShrink100ToStr(total);
+                            // 交易时间
+                            String paymentTimeStr = FormatUtil.createTimeFormatDetail(p.getPayTime());
+                            // 订单号
+                            String orderNo = Checker.getStringValue(p.getOrderNo());
+                            // 类型
+                            String typeStr = "门诊缴费";
+//                            String[] bodyStr = {type, transactionId, totalStr, paymentTimeStr, orderNo, typeStr};
+                            map.getStringListSafely(col0).add(type);
+                            map.getStringListSafely(col1).add(transactionId);
+                            map.getStringListSafely(col2).add(totalStr);
+                            map.getStringListSafely(col3).add(paymentTimeStr);
+                            map.getStringListSafely(col4).add(orderNo);
+                            map.getStringListSafely(col5).add(typeStr);
+                        }
+                    }
+                }
+                // 得到退款的记录日志(需要从 refund_log 获取 refund_id 字段)
+                List<RefundLog> refundLogList = refundLogService.getRefundLogListByOutPatientOrderList(outpatientOrderList);
+                List<OutpatientOrder> refundPrescriptionInfoList = getRefundOutpatientOrderList(outpatientOrderList);
+                for (OutpatientOrder p : refundPrescriptionInfoList) {
+                    if (!Checker.isNone(p) && Checker.getIntegerValue(p.getRefundStatus()) == RefundStatusEnum.SUCCESS.getValue()) {
+                        // "交易类型*", "系统参考号*", "交易金额*", "交易日期*", "订单号", "类型"
+                        Date refundTime = Checker.getDateValue(p.getRefundTime());
+                        if (!Checker.isNone(refundTime) && refundTime.after(billStartTime) && refundTime.before(billEndTime)) {
+                            String type = ConstantDef.BILL_REFUND_STR;
+                            String transactionId = refundLogService.getRefundIdByRefundNo(refundLogList, p.getRefundNo());
+
+                            // 交易金额
+                            int total = Checker.getIntegerValue(p.getTotal());
+                            String totalStr = FormatUtil.intShrink100ToStr(total);
+                            // 交易时间
+                            String refundTimeStr = FormatUtil.createTimeFormatDetail(p.getRefundTime());
+                            // 订单号
+                            String orderNo = Checker.getStringValue(p.getOrderNo());
+                            // 类型
+                            String typeName = "门诊缴费";
+                            map.getStringListSafely(col0).add(type);
+                            map.getStringListSafely(col1).add(transactionId);
+                            map.getStringListSafely(col2).add(totalStr);
+                            map.getStringListSafely(col3).add(refundTimeStr);
+                            map.getStringListSafely(col4).add(orderNo);
+                            map.getStringListSafely(col5).add(typeName);
+//                            String[] bodyStr = {type, transactionId, totalStr, refundTimeStr, orderNo, typeName};
+                        }
+                    }
+                }
+            }
+            int size = outpatientOrderList.size();
+            List<ExcelCollectPojo> itemList = new ArrayList<>();
+            downloadRecordService.createFileAndUploadOssAndSaveToDataBase(fileName, downloadRecordId, map, itemList);
+        } catch (Exception e) {
+            e.printStackTrace();
+        }
+    }
+
+    private List<OutpatientOrder> getRefundOutpatientOrderList(List<OutpatientOrder> list) {
+        if (!Checker.isNone(list)) {
+            return list.stream().filter(p -> Checker.getIntegerValue(p.getRefundStatus()) == RefundStatusEnum.SUCCESS.getValue()).collect(Collectors.toList());
+        }
+        return new ArrayList<>();
+    }
+}

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

@@ -0,0 +1,619 @@
+package com.ywt.mg.services;
+
+import com.ywt.mg.core.SqlHelper;
+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.*;
+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.models.pojo.ExcelCollectPojo;
+import com.ywt.mg.params.registeredOrder.RegisteredOrderListRequest;
+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 RegisteredOrderService {
+    private static Logger logger = LoggerFactory.getLogger(RegisteredOrderService.class);
+
+
+    @Autowired
+    private SqlHelper sqlHelper;
+
+    @Autowired
+    private OrderPaymentService orderPaymentService;
+
+    @Autowired
+    private MedicalCardRepository medicalCardRepository;
+
+    @Autowired
+    private JdbcTemplate jdbcTemplate;
+
+    @Autowired
+    private DownloadRecordService downloadRecordService;
+
+    @Autowired
+    private RefundLogService refundLogService;
+
+
+    public List<RegisteredOrder> queryRegisteredOrderList(RegisteredOrderListRequest request) {
+        List<Object> paramList = new ArrayList<>();
+        String whereSql = " ( 1=1 )";
+        try {
+            String orderno = request.getOrderno();
+            if (!Checker.isNull(orderno)) {
+                whereSql += " and ( order_no like ?)";
+                paramList.add("%" + orderno.trim() + "%");
+            }
+
+            String patientname = request.getPatientname();
+            if (!Checker.isNull(patientname)) {
+                whereSql += " and ( patient_name like ?)";
+                paramList.add("%" + patientname.trim() + "%");
+            }
+
+            String patientmobile = request.getPatientmobile();
+            if (!Checker.isNull(patientmobile)) {
+                List<MedicalCard> medicalCardList = medicalCardRepository.getCardByMobile(patientmobile);
+                if (!Checker.isNone(medicalCardList)) {
+                    whereSql += " and ( medical_card_id = -1 ";
+                    for (MedicalCard medicalCard : medicalCardList) {
+                        whereSql += " or medical_card_id = ? ";
+                        paramList.add(medicalCard.getId());
+                    }
+                    whereSql += " ) ";
+                } else {
+                    whereSql += " and (medical_card_id = -1) ";
+                }
+
+            }
+
+            String doctorname = request.getDoctorname();
+            if (!Checker.isNull(doctorname)) {
+                whereSql += " and ( doctor_name like ?)";
+                paramList.add("%" + doctorname.trim() + "%");
+            }
+
+            String deptname = request.getDeptname();
+            if (!Checker.isNull(deptname)) {
+                whereSql += " and ( dept_name like ?)";
+                paramList.add("%" + deptname.trim() + "%");
+            }
+
+            //支付状态(0-待支付,1-支付处理中,2-支付成功,3-支付失败)
+            String paymentstatus = request.getPaymentstatus();
+            if (!Checker.isNull(paymentstatus)) {
+                whereSql += " and ( payment_status =  ?  )";
+                paramList.add(Integer.parseInt(paymentstatus));
+            }
+
+            //订单来源( 1-患者端-安卓,2-患者端-苹果,3-微信小程序,4-微信公众号)
+            String source = request.getSource();
+            if (!Checker.isNull(source)) {
+                int sourceInt = Integer.parseInt(source);
+                if (sourceInt == TerminalEnum.TaiheWxOfficial.getValue() || sourceInt == TerminalEnum.NF_HOSPITAL_BY_PATIENT_MINI_PROGRAM.getValue()) {
+                    whereSql += " and ( registered_status > 0 )";
+                }
+                whereSql += " and ( source = ? )";
+                paramList.add(sourceInt);
+
+            }
+            //订单类型( 1-普通预约,2-加号预约)
+            String type = request.getType();
+            if (!Checker.isNull(type)) {
+                int typeInt = Integer.parseInt(type);
+                if (typeInt == 2) {
+                    whereSql += " and ( registered_type =  ?)";
+                    paramList.add(RegisteredTypeEnum.ADDITIONAL.getValue());
+                } else {
+                    // 当类型为普通预约时,还有部分数据的值为空
+                    whereSql += " and ( registered_type =  ?  or registered_type is null )";
+                    paramList.add(RegisteredTypeEnum.GENERAL.getValue());
+                }
+            }
+
+            String Format_Date = "yyyy-MM-dd";
+            SimpleDateFormat format = new SimpleDateFormat(Format_Date);
+
+            //就诊时间
+            String registeredEndTime = request.getRegisteredEndTime();
+            if (!Checker.isNull(registeredEndTime)) {
+                whereSql += " and ( registered_date < ? )";
+                Date date = format.parse(registeredEndTime);
+
+                // 把日期往后增加一天.整数往后推,负数往前移动
+                Calendar calendar = new GregorianCalendar();
+                calendar.setTime(date);
+                calendar.add(calendar.DATE, 1);
+                // 这个时间就是日期往后推一天的结果
+                date = calendar.getTime();
+
+                paramList.add(date);
+            }
+
+            String registeredStartTime = request.getRegisteredStartTime();
+            if (!Checker.isNull(registeredStartTime)) {
+                whereSql += " and ( registered_date >= ?)";
+                Date date = format.parse(registeredStartTime);
+                paramList.add(date);
+            }
+
+            //下单时间
+            String createEndTime = request.getCreateEndTime();
+            if (!Checker.isNull(createEndTime)) {
+                whereSql += " and ( create_time < ? )";
+                Date date = format.parse(createEndTime);
+
+                // 把日期往后增加一天.整数往后推,负数往前移动
+                Calendar calendar = new GregorianCalendar();
+                calendar.setTime(date);
+                calendar.add(calendar.DATE, 1);
+                // 这个时间就是日期往后推一天的结果
+                date = calendar.getTime();
+
+                paramList.add(date);
+            }
+
+            String createStartTime = request.getCreateStartTime();
+            if (!Checker.isNull(createStartTime)) {
+                whereSql += " and ( create_time >= ?)";
+                Date date = format.parse(createStartTime);
+                paramList.add(date);
+            }
+
+            // 医院ID不为空,registered_status 根据hospitalID代表不同的值
+            // 南方医院挂号:0-待支付、1-待就诊、2-已完成、3-已取消
+            // 太和医院挂号:1-待就诊、2-已完成、3-已取消、4-已退款
+            // 南方医科大学南方医院白云分院挂号:1-待就诊、2-已完成、3-已取消、4-已退款
+            String registeredstatus = request.getRegisteredstatus();
+            int hospitalId = Checker.getIntegerValue(request.getHospitalId());
+            if (request.getHospitalId() > 0) {
+                if (hospitalId == ConstantDef.NF_HOSPITAL_ID) {
+                    // 医院过滤
+                    whereSql += " and ( hospital_id = ?) ";
+                    paramList.add(hospitalId);
+                    if (!Checker.isNull(registeredstatus)) {
+                        int status = Integer.parseInt(registeredstatus);
+                        //  0-待支付 registered_status = 0

+                        if (status == 0) {
+                            whereSql += " and (registered_status = 0 and ( registered_type =  ?  or registered_type is null ) )";
+                            paramList.add(RegisteredTypeEnum.GENERAL.getValue());
+                        }
+                        // 1-待就诊:registered_status=1,以及时间判断
+                        if (status == 1) {
+                            whereSql += "  and ( str_to_date(CONCAT(registered_date,\" \",end_time), '%Y-%m-%d %H:%i') >= now() )";
+                            whereSql += " and ( registered_status & ? = 0 and registered_status & ? = 0 and registered_status > 0 ) ";
+                            paramList.add(RegisteredStatusEnum.Cancel.getValue());
+                            paramList.add(RegisteredStatusEnum.Back.getValue());
+                        }
+                        // 2- 已完成:registered_status=1,4 以及时间判断

+                        if (status == 2) {
+                            whereSql += " and ( str_to_date(CONCAT(registered_date,\" \",end_time), '%Y-%m-%d %H:%i') < now() )";
+                            whereSql += " and ( registered_status & ? = 0 and registered_status & ? = 0 and registered_status > 0 ) ";
+                            paramList.add(RegisteredStatusEnum.Cancel.getValue());
+                            paramList.add(RegisteredStatusEnum.Back.getValue());
+                        }
+                        // 3-已取消:registered_status=2
+                        if (status == 3) {
+                            status = RegisteredStatusEnum.Cancel.getValue();
+                            whereSql += " and ( registered_status & ? > 0 or registered_status & ? > 0)";
+                            paramList.add(status);
+                            paramList.add(RegisteredStatusEnum.Back.getValue());
+                        }
+                        if (status == 4) {
+                            whereSql += " and ( registered_status = -1 )";
+                        }
+                    }
+                }
+
+                // 太和医院的不显示出来位支付的订单
+                if (hospitalId == ConstantDef.TAIHE_HOSPITAL_ID || hospitalId == ConstantDef.NFBY_HOSPITAL_ID) {
+                    // 太和医院挂号订单过滤掉未支付的
+                    whereSql += " and ( (registered_status > 0 and payment_status = ? ) or (refund_status = ?) ) and ( hospital_id = ?)  ";
+                    paramList.add(PaymentStatusEnum.Success.getValue());
+                    paramList.add(RefundStatusEnum.SUCCESS.getValue());
+                    paramList.add(hospitalId);
+
+                    // 太和医院挂号:1-待就诊、2-已完成、3-已取消、4-已退款
+                    if (!Checker.isNull(registeredstatus)) {
+                        int status = Integer.parseInt(registeredstatus);
+                        if (status == 0) {
+                            // 因为不显示带支付的,所以如果搜索待支付的,直接给显示空
+                            whereSql += " and ( registered_status = -1 )";
+                        }
+                        //  1-待就诊、2-已完成、3-已取消、4-已退款
+                        // 1-待就诊:payment_status = 1, registered_status=1,以及时间判断
+                        if (status == 1) {
+                            status = RegisteredStatusEnum.Booked.getValue();
+                            int tookStatus = RegisteredStatusEnum.Took.getValue();
+                            whereSql += " and (( registered_status & ?  > 0 and registered_status < ? ) or  (registered_status & ?  > 0 and registered_status < ?) )";
+                            whereSql += " and (payment_status = ?) ";
+                            whereSql += " and ( str_to_date(CONCAT(registered_date,\" \",end_time), '%Y-%m-%d %H:%i') >= now() )";
+                            paramList.add(status);
+                            paramList.add(2 * status);
+                            paramList.add(tookStatus);
+                            paramList.add(2 * tookStatus);
+                            paramList.add(PaymentStatusEnum.Success.getValue());
+                        }
+                        if (status == 2) {
+                            //2-已完成:payment_status = 1, registered_status=1,4 以及时间判断
+                            status = RegisteredStatusEnum.Booked.getValue();
+                            int tookStatus = RegisteredStatusEnum.Took.getValue();
+                            whereSql += " and ( (registered_status & ?  > 0 and registered_status < ?) or  (registered_status & ?  > 0 and registered_status < ?) )";
+                            whereSql += " and (payment_status = ?) ";
+                            whereSql += " and ( str_to_date(CONCAT(registered_date,\" \",end_time), '%Y-%m-%d %H:%i') < now() )";
+                            paramList.add(status);
+                            paramList.add(2 * status);
+                            paramList.add(tookStatus);
+                            paramList.add(2 * tookStatus);
+                            paramList.add(PaymentStatusEnum.Success.getValue());
+                        }
+                        if (status == 3) {
+                            // 3-已取消:registered_status=2
+                            status = RegisteredStatusEnum.Cancel.getValue();
+                            whereSql += " and ( registered_status & ?  > 0 )";
+                            paramList.add(status);
+                        }
+                        if (status == 4) {
+                            // 4-已退款:refund_status=1
+                            whereSql += " and ( refund_status = ? or (registered_status & ?  > 0 and registered_status < ?) )";
+                            paramList.add(RefundStatusEnum.SUCCESS.getValue());
+                            int backStatus = RegisteredStatusEnum.Back.getValue();
+                            paramList.add(backStatus);
+                            paramList.add(2 * backStatus);
+                        }
+                    }
+                }
+            }
+
+            //对账时间
+            String billEndTime = request.getBillEndTime();
+            if (!Checker.isNull(billEndTime)) {
+                whereSql += " and ( payment_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);
+            }
+
+            String billStartTime = request.getBillStartTime();
+            if (!Checker.isNull(billStartTime)) {
+                whereSql += " and ( payment_time >= ? or refund_time >= ?)";
+                Date date = format.parse(billStartTime);
+                paramList.add(date);
+                paramList.add(date);
+            }
+            // 处理交易流水号,考虑到性能,直接采用全匹配到方式
+            String transactionId = request.getTransactionId();
+            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) {
+            e.printStackTrace();
+            logger.error("queryRegisteredOrderList:{},{}", e.getMessage(), e);
+        }
+        return sqlHelper.getDownLoadList("*", whereSql, "create_time desc", RegisteredOrder.class, paramList.toArray());
+    }
+
+    public void downloadRegisteredOrderList(int downloadRecordId, String fileName, RegisteredOrderListRequest request) {
+        try {
+            int hospitalId = Checker.getIntegerValue(request.getHospitalId());
+//            String[] titleStr = {"订单号", "支付流水号", "交易流水号", "患者姓名", "患者手机号", "诊疗卡",
+//                    "医生姓名", "科室", "金额", "就诊时间", "来源", "类型",
+//                    "订单状态", "支付状态", "下单时间", "备注"};
+            // 单元格
+            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[] columns = new String[]{col0, col1, col2, col3, col4, col5, col6, col7, col8, col9, col10,
+                    col11, col12, col13, col14, col15};
+            if (hospitalId > 0) {
+                columns = new String[]{col0, col1, col4, col5, col6, col7, col8, col9, col10,
+                        col11};
+            }
+            List<RegisteredOrder> registeredOrderList = queryRegisteredOrderList(request);
+            List<RegisteredOrder> valueList = new ArrayList();
+            int payTotal = 0, refundTotal = 0;
+            ExcelDataMap map = new ExcelDataMap(columns);
+            if (!Checker.isNone(registeredOrderList)) {
+//                valueList.addAll(registeredOrderList.getItems());
+//                int size = registeredOrderList.getTotalPage();
+//                List<RegisteredOrder> lst = registeredOrderList.getItems();
+                List<MedicalCard> medicalCardList = getMedicalCardListByRegisteredOrderList(registeredOrderList);
+                List<OrderPayment> orderPaymentList = orderPaymentService.getOrderPaymentListByRegisteredOrderList(registeredOrderList);
+                SimpleDateFormat sdf2 = new SimpleDateFormat("yyyy-MM-dd");
+                for (RegisteredOrder p : registeredOrderList) {
+                    // 金额
+                    String totalStr = FormatUtil.intShrink100ToStr(p.getTotal());
+                    // 就诊时间
+                    String registeredTime = sdf2.format(p.getRegisteredDate()) + "\t" + p.getStartTime() + "~" + p.getEndTime();
+                    // 来源
+                    String source = TerminalEnum.valueOf(p.getSource()).getDisplayName();
+                    // 类型
+                    int typeInt = Checker.getIntegerValue(p.getRegisteredType());
+                    String typeName = RegisteredTypeEnum.valueOf(typeInt).getDisplayName();
+                    // 订单状态
+                    int value = RegisteredStatusEnum.getValue(p.getRegisteredStatus());
+                    String registeredStatus = getRegisteredStatusName(value, p);
+                    // 支付状态
+                    String paymentStatus = PaymentStatusEnum.getPaymentStatus(p.getPaymentStatus()).getDisplayName();
+                    // 下单时间
+                    String createTime = FormatUtil.createTimeFormatList(p.getCreateTime());
+                    // 备注
+                    String cancelRemark = Checker.getStringValue(p.getCancelRemark());
+
+                    String patientMobile = "", cardNo = "";
+                    MedicalCard medicalCard = medicalCardList.stream().filter(m -> m.getId().intValue() == p.getMedicalCardId()).findFirst().orElse(null);
+                    if (!Checker.isNone(medicalCard)) {
+                        patientMobile = Checker.getStringValue(medicalCard.getMobile());
+                        cardNo = Checker.getStringValue(medicalCard.getCardNo());
+                    }
+                    String transactionId = orderPaymentService.getTransactionIdByOrderId(orderPaymentList, Checker.getIntegerValue(p.getOrderId()));
+//                    String[] bodyStr = {p.getOrderNo(), p.getPaymentNo(), transactionId, p.getPatientName(), patientMobile, cardNo,
+//                            p.getDoctorName(), p.getDeptName(), totalStr, registeredTime, source,
+//                            typeName, registeredStatus, paymentStatus, createTime, cancelRemark};
+                    if (Checker.getIntegerValue(p.getPaymentStatus()) == PaymentStatusEnum.Success.getValue()) {
+                        payTotal += Checker.getIntegerValue(p.getTotal());
+                    }
+                    if (Checker.getIntegerValue(p.getRefundStatus()) == RefundStatusEnum.SUCCESS.getValue()) {
+                        refundTotal += Checker.getIntegerValue(p.getTotal());
+                    }
+                    if (hospitalId > 0) {
+                        map.getStringListSafely(col0).add(p.getOrderNo());
+                        map.getStringListSafely(col1).add(p.getPaymentNo());
+//                        map.getStringListSafely(col2).add(transactionId);
+                        map.getStringListSafely(col3).add(p.getPatientName());
+                        map.getStringListSafely(col4).add(patientMobile);
+                        map.getStringListSafely(col5).add(cardNo);
+                        map.getStringListSafely(col6).add(p.getDoctorName());
+                        map.getStringListSafely(col7).add(p.getDeptName());
+                        map.getStringListSafely(col8).add(totalStr);
+                        map.getStringListSafely(col9).add(registeredTime);
+                        map.getStringListSafely(col10).add(source);
+                        map.getStringListSafely(col11).add(typeName);
+                        map.getStringListSafely(col12).add(registeredStatus);
+                        map.getStringListSafely(col13).add(paymentStatus);
+                        map.getStringListSafely(col14).add(createTime);
+                        map.getStringListSafely(col15).add(cancelRemark);
+                    } else {
+                        map.getStringListSafely(col0).add(p.getOrderNo());
+                        map.getStringListSafely(col1).add(p.getPaymentNo());
+                        map.getStringListSafely(col2).add(transactionId);
+                        map.getStringListSafely(col3).add(p.getPatientName());
+                        map.getStringListSafely(col4).add(patientMobile);
+                        map.getStringListSafely(col5).add(cardNo);
+                        map.getStringListSafely(col6).add(p.getDoctorName());
+                        map.getStringListSafely(col7).add(p.getDeptName());
+                        map.getStringListSafely(col8).add(totalStr);
+                        map.getStringListSafely(col9).add(registeredTime);
+                        map.getStringListSafely(col10).add(source);
+                        map.getStringListSafely(col11).add(typeName);
+                        map.getStringListSafely(col12).add(registeredStatus);
+                        map.getStringListSafely(col13).add(paymentStatus);
+                        map.getStringListSafely(col14).add(createTime);
+                        map.getStringListSafely(col15).add(cancelRemark);
+                    }
+                }
+            }
+            int size = registeredOrderList.size();
+            List<ExcelCollectPojo> itemList = getStatisticsData(size, payTotal, refundTotal);
+            downloadRecordService.createFileAndUploadOssAndSaveToDataBase(fileName, downloadRecordId, map, itemList);
+
+        } catch (Exception e) {
+            logger.error("/registeredOrder/downloadRegisteredOrderList: {}", e.getMessage(), e);
+            e.printStackTrace();
+        }
+    }
+
+    public List<MedicalCard> getMedicalCardListByRegisteredOrderList(List<RegisteredOrder> registeredOrderList) {
+        List<Integer> medIds = getMedicalCardIdListByRegisteredOrderList(registeredOrderList);
+        String medIdsStr = FormatUtil.listToIds(medIds);
+        String sql = "select * from medical_card where id in (-1" + medIdsStr + "-1) ;";
+        List<MedicalCard> medicalCardList = jdbcTemplate.query(sql, new BeanPropertyRowMapper<>(MedicalCard.class));
+        return medicalCardList;
+    }
+
+
+    private List<Integer> getMedicalCardIdListByRegisteredOrderList(List<RegisteredOrder> items) {
+        ArrayList<Integer> medIds = new ArrayList<>();
+        for (RegisteredOrder item : items) {
+            medIds.add(item.getMedicalCardId());
+        }
+        return medIds;
+    }
+
+    /**
+     * 普通挂号 -- 太和医院挂号后台显示状态:待就诊、已完成、已取消、已退款
+     * 普通挂号 -- 南方医院挂号后台显示状态:待支付、待就诊、已完成、已取消
+     * 加号预约状态:待就诊、已完成、已取消
+     *
+     * @param dealtRegisteredValue 处理过后的预约挂号订单状态值
+     * @return
+     */
+    public String getRegisteredStatusName(int dealtRegisteredValue, RegisteredOrder registeredOrder) {
+        if (!Checker.isNone(registeredOrder)) {
+            // type: 2-加号预约 1或其他-普通预约
+            int type = Checker.getIntegerValue(registeredOrder.getRegisteredType());
+            int payStatus = Checker.getIntegerValue(registeredOrder.getPaymentStatus());
+            int registeredStatus = Checker.getIntegerValue(registeredOrder.getRegisteredStatus());
+
+            // 加号预约 :待就诊、已完成、已取消
+            if (type == RegisteredTypeEnum.ADDITIONAL.getValue()) {
+                // 已取消:registered_status=2
+                if ((registeredStatus & RegisteredStatusEnum.Cancel.getValue()) > 0) {
+                    return RegisteredStatusEnum.Cancel.getDisplayName();
+                }
+                // 待就诊:registered_status=1,以及时间判断

+                // 已完成:registered_status=1,4,以及时间判断

+                // 得到就诊时间的最大时间段
+                Date date = getStringToDate(registeredOrder.getRegisteredDate(), registeredOrder.getEndTime());
+                Date currentDate = new Date();
+                if (currentDate.after(date)) {
+                    return "已完成";
+                } else {
+                    return "待就诊";
+                }
+            }
+            // 普通挂号,根据医院来
+            int hospitalId = Checker.getIntegerValue(registeredOrder.getHospitalId());
+            // 1 - 南方医院, 12 -太和医院, 41-南方医科大学白云分院
+            if (hospitalId == ConstantDef.NF_HOSPITAL_ID) {
+                // 已取消
+                if (dealtRegisteredValue == RegisteredStatusEnum.Back.getValue()
+                        || dealtRegisteredValue == RegisteredStatusEnum.Cancel.getValue()) {
+                    return RegisteredStatusEnum.Cancel.getDisplayName();
+                }
+                if (dealtRegisteredValue == RegisteredStatusEnum.Booked.getValue() || dealtRegisteredValue == RegisteredStatusEnum.Took.getValue()) {
+                    // 得到就诊时间的最大时间段
+                    Date date = getStringToDate(registeredOrder.getRegisteredDate(), registeredOrder.getEndTime());
+                    Date currentDate = new Date();
+                    if (currentDate.after(date)) {
+                        return "已完成";
+                    } else {
+                        return "待就诊";
+                    }
+                }
+                return "待支付";
+            }
+            if (hospitalId == ConstantDef.TAIHE_HOSPITAL_ID || hospitalId == ConstantDef.NFBY_HOSPITAL_ID) {
+                int refundStatus = Checker.getIntegerValue(registeredOrder.getRefundStatus());
+                // 已退款
+                if (refundStatus == RefundStatusEnum.SUCCESS.getValue() || dealtRegisteredValue == RegisteredStatusEnum.Back.getValue()) {
+                    return "已退款";
+                }
+                // 已取消
+                if (dealtRegisteredValue == RegisteredStatusEnum.Cancel.getValue()) {
+                    return RegisteredStatusEnum.Cancel.getDisplayName();
+                }
+                if (payStatus == PaymentStatusEnum.Success.getValue() &&
+                        (dealtRegisteredValue == RegisteredStatusEnum.Booked.getValue() || dealtRegisteredValue == RegisteredStatusEnum.Took.getValue())) {
+                    // 得到就诊时间的最大时间段
+                    Date date = getStringToDate(registeredOrder.getRegisteredDate(), registeredOrder.getEndTime());
+                    Date currentDate = new Date();
+                    if (currentDate.after(date)) {
+                        return "已完成";
+                    } else {
+                        return "待就诊";
+                    }
+                }
+            }
+            return "";
+        }
+        return "";
+    }
+
+    private Date getStringToDate(Date date, String endTime) {
+        String dateStr = DateUtil.convertToString(date, "yyyy-MM-dd");
+        dateStr = dateStr + " " + endTime + ":00";
+        Date backDate = DateUtil.stringToDate(dateStr);
+        return backDate;
+    }
+
+    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;
+    }
+
+
+    public void downloadRegisteredOrderBillsList(int downloadRecordId, String fileName, RegisteredOrderListRequest request) {
+//        String[] titleStr = {"交易类型*", "系统参考号*", "交易金额*", "交易日期*", "订单号", "类型"};
+        try {
+            String col0 = "交易类型*";
+            String col1 = "系统参考号*";
+            String col2 = "交易金额*";
+            String col3 = "交易日期*";
+            String col4 = "订单号";
+            String col5 = "类型";
+            String[] columns = new String[]{col0, col1, col2, col3, col4, col5};
+
+            List<RegisteredOrder> registeredOrderList = queryRegisteredOrderList(request);
+            ExcelDataMap map = new ExcelDataMap(columns);
+            if(!Checker.isNone(registeredOrderList)){
+                List<OrderPayment> orderPaymentList = orderPaymentService.getOrderPaymentListByRegisteredOrderList(registeredOrderList);
+                // 得到退款的记录日志(需要从 refund_log 获取 refund_id 字段)
+                List<RefundLog> refundLogList = refundLogService.getRefundLogListByRegisteredOrderList(registeredOrderList);
+
+                Date billStartTime = DateUtil.stringToDate(request.getBillStartTime() + ConstantDef.BILL_TIME_START_FORMAT);
+                Date billEndTime = DateUtil.stringToDate(request.getBillEndTime() + ConstantDef.BILL_TIME_END_FORMAT);
+                for (RegisteredOrder p : registeredOrderList) {
+                    if (!Checker.isNone(p) && Checker.getIntegerValue(p.getPaymentStatus()) == PaymentStatusEnum.Success.getValue()
+                            && Checker.getIntegerValue(p.getTotal()) > 0
+                            && !Checker.isNone(p.getPaymentTime())) {
+                        // "交易类型*", "系统参考号*", "交易金额*", "交易日期*", "订单号", "类型"
+                        Date paymentTime = Checker.getDateValue(p.getPaymentTime());
+                        if (!Checker.isNone(paymentTime) && paymentTime.after(billStartTime) && paymentTime.before(billEndTime)) {
+                            String type = ConstantDef.BILL_PAYMENT_STR;
+                            // 交易流水号
+                            String transactionId = orderPaymentService.getTransactionIdByOrderId(orderPaymentList, Checker.getIntegerValue(p.getOrderId()));
+                            // 交易金额
+                            String totalStr = FormatUtil.intShrink100ToStr(p.getTotal());
+                            // 交易时间
+                            String paymentTimeStr = FormatUtil.createTimeFormatDetail(p.getPaymentTime());
+                            // 订单号
+                            String orderNo = Checker.getStringValue(p.getOrderNo());
+                            // 类型
+                            int typeInt = Checker.getIntegerValue(p.getRegisteredType());
+                            String typeName = RegisteredTypeEnum.valueOf(typeInt).getDisplayName();
+
+//                            String[] bodyStr = {type, transactionId, totalStr, paymentTimeStr, orderNo, typeName};
+
+                            map.getStringListSafely(col0).add(type);
+                            map.getStringListSafely(col1).add(transactionId);
+                            map.getStringListSafely(col2).add(totalStr);
+                            map.getStringListSafely(col3).add(paymentTimeStr);
+                            map.getStringListSafely(col4).add(orderNo);
+                            map.getStringListSafely(col5).add(typeName);
+
+                        }
+                    }
+                }
+            }
+            List<ExcelCollectPojo> itemList = new ArrayList<>();
+            downloadRecordService.createFileAndUploadOssAndSaveToDataBase(fileName, downloadRecordId, map, itemList);
+
+        } catch (Exception e) {
+            logger.error("/registeredOrder/downloadRegisteredOrderBillsList: {}", e.getMessage(), e);
+            e.printStackTrace();
+        }
+    }
+}

+ 27 - 0
src/main/java/com/ywt/mg/services/ShopService.java

@@ -0,0 +1,27 @@
+package com.ywt.mg.services;
+
+import com.ywt.mg.core.SqlHelper;
+import com.ywt.mg.domain.mealEntities.Shop;
+import com.ywt.mg.domain.mealEntities.ShopRepository;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Service;
+
+import java.util.List;
+
+@Service
+public class ShopService {
+
+    private final Logger logger = LoggerFactory.getLogger(ShopService.class);
+
+    @Autowired
+    SqlHelper sqlHelper;
+
+    @Autowired
+    ShopRepository shopRepository;
+
+    public List<Shop> getAllShops() {
+        return shopRepository.getAllShops();
+    }
+}

+ 41 - 0
src/main/java/com/ywt/mg/services/UserService.java

@@ -0,0 +1,41 @@
+package com.ywt.mg.services;
+
+import com.ywt.mg.core.SqlHelper;
+import com.ywt.mg.core.utils.Checker;
+import com.ywt.mg.domain.entities.User;
+import com.ywt.mg.domain.entities.UserRepository;
+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;
+
+@Service
+public class UserService {
+
+    private static Logger logger = LoggerFactory.getLogger(UserService.class);
+
+    @Autowired
+    private SqlHelper sqlHelper;
+
+    @Autowired
+    private UserRepository userRepository;
+
+    @Autowired
+    private IdGenerator idGenerator;
+
+    @Autowired
+    private JdbcTemplate jdbcTemplate;
+
+//    @Autowired
+//    private DoctorService doctorService;
+
+
+    public int getUserIdByMobile(String mobile) {
+        User user = userRepository.findUserByMobile(mobile);
+        if (!Checker.isNone(user)) {
+            return user.getId();
+        }
+        return 0;
+    }
+}

+ 96 - 0
src/main/java/com/ywt/mg/web/common/ExcelDownloadSrv.java

@@ -5,6 +5,7 @@ import com.ywt.mg.core.utils.Checker;
 import com.ywt.mg.core.utils.ExcelHelper;
 import com.ywt.mg.domain.models.ExcelDataMap;
 import com.ywt.mg.domain.models.ExcelStyleMap;
+import com.ywt.mg.domain.models.pojo.CustomExcelItem;
 import com.ywt.mg.domain.models.pojo.ExcelCollectPojo;
 import jxl.Workbook;
 import jxl.format.*;
@@ -345,4 +346,99 @@ public class ExcelDownloadSrv {
         }
 //        return path;
     }
+
+    /**
+     * 订单统计中备注的样式(没有边框样式)
+     */
+    public static WritableCellFormat getCellFormat4StatRemarkWithNoSetBorder() {
+        //设置字体;
+        WritableFont font = new WritableFont(WritableFont.ARIAL, 14, WritableFont.NO_BOLD, false, UnderlineStyle.NO_UNDERLINE, Colour.DEFAULT_BACKGROUND);
+
+        WritableCellFormat cellFormat = new WritableCellFormat(font);
+        try {
+            //设置背景颜色;
+            cellFormat.setBackground(Colour.WHITE);
+            //设置边框;
+            // cellFormat.setBorder(Border.ALL, BorderLineStyle.THIN);
+            //设置自动换行;
+//            cellFormat.setWrap(true);
+            //设置文字居中对齐方式;
+            cellFormat.setAlignment(Alignment.LEFT);
+            //设置垂直居中;
+            cellFormat.setVerticalAlignment(VerticalAlignment.CENTRE);
+            return cellFormat;
+        } catch (WriteException e) {
+            return null;
+        }
+    }
+
+
+    /**
+     * 通用的生成 Excel 文件(包含汇总)并以流返回(一点样式也没有)
+     *
+     * @param fileName            excel 文件名
+     * @param data                需要填充的数据,key 是列名,value 是每一列的数据组成的 list, 类型必须是 {@link String}
+     * @throws AppMessageException 业务层异常抛出,如传入数据为空
+     * @author Walker, added on 06/27/2019.
+     */
+    public void generateAndReturnMealExcelFileWithNoStyleAndCollectLocal(String fileName, String path, ExcelDataMap data, ExcelStyleMap excelStyleMap,
+                                                                     List<CustomExcelItem> collectList) throws AppMessageException {
+        if (data == null || data.isEmpty()) {
+            throw new AppMessageException("数据为空");
+        }
+        try {
+            File file = new File(path);
+            // 创建写工作簿对象
+            WritableWorkbook workbook = Workbook.createWorkbook(file);
+            // 工作表
+            WritableSheet sheet = workbook.createSheet(fileName, 0);
+            WritableFont font2 = new WritableFont(WritableFont.ARIAL, 14, WritableFont.NO_BOLD, false, UnderlineStyle.NO_UNDERLINE, Colour.BLACK);
+            WritableCellFormat cellFormat2 = new WritableCellFormat(font2);
+            //单独应用样式
+            if (excelStyleMap != null) {
+                for (String column : excelStyleMap.keySet()) {
+                    // 指定列宽
+                    int styleColumnWidth = excelStyleMap.getIntValueSafely(column, ExcelStyleMap.STYLE_COLUMN_WIDTH, 0);
+                    List<String> columns = new ArrayList<>(data.keySet());
+                    for (int i = 0; i < columns.size(); i++) {
+                        if (columns.get(i).equals(column)) {
+                            sheet.setColumnView(i, styleColumnWidth);
+                        }
+                    }
+                }
+            }
+            // 设置格式(实线)
+            WritableCellFormat cellFormat = new WritableCellFormat();
+            //行号
+            int firstRow = 0;
+            //填充表头
+            int headerColumn = 0;
+            for (String key : data.keySet()) {
+                Label label = new Label(headerColumn, firstRow, key, cellFormat);
+                sheet.addCell(label);
+                List<String> colData = data.get(key);
+                for (int i = 0; i < colData.size(); i++) {
+                    Label lb = new Label(headerColumn, i + 1, Checker.getStringValue(colData.get(i)), cellFormat2);
+                    sheet.addCell(lb);
+                }
+                headerColumn++;
+            }
+            // 添加汇总
+            if (!Checker.isNone(collectList)) {
+                for (CustomExcelItem item : collectList) {
+                        sheet.addCell(new Label(item.getColumn(), item.getRow(), item.getContent(),
+                                item.getCellFormat() == null ? cellFormat2 : item.getCellFormat()));
+
+                }
+            }
+            //开始执行写入操作
+            workbook.write();
+            //关闭流
+            workbook.close();
+        } catch (Exception e) {
+            logger.error("ExcelDownloadSrv#generateAndReturnExcelFileWithNoStyleAndCollectLocal(fileName={}, path={} ):\n {}",
+                    fileName, path, e.getMessage(), e);
+        }
+//        return path;
+    }
 }

+ 84 - 0
src/main/java/com/ywt/mg/web/controllers/CheckUpOrderController.java

@@ -0,0 +1,84 @@
+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.checkupBooking.QueryCheckUpOrderListRequest;
+import com.ywt.mg.params.deposit.QueryDepositListRequest;
+import com.ywt.mg.services.AuthService;
+import com.ywt.mg.services.CheckUpOrderService;
+import com.ywt.mg.services.DownloadRecordService;
+import com.ywt.mg.services.IdGenerator;
+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.RequestMapping;
+import org.springframework.web.bind.annotation.RestController;
+
+@RestController("/checkUp")
+@RequestMapping({"/checkUp"})
+@MGRight
+public class CheckUpOrderController {
+
+    private static Logger logger = LoggerFactory.getLogger(DepositController.class);
+
+    @Autowired
+    private IdGenerator idGenerator;
+
+    @Autowired
+    private DownloadRecordService downloadRecordService;
+
+    @Autowired
+    private AuthService authService;
+
+    @Autowired
+    private CheckUpOrderService checkUpOrderService;
+
+
+    @RequestMapping({"/downloadCheckUpOrderList"})
+    public BaseResponse downloadDepositList(QueryCheckUpOrderListRequest request) {
+        int currentAdminId = Checker.getIntegerValue(authService.getCurrentAdminId());
+//        request.setCurrentAdminId(currentAdminId);
+        // 插入记录
+        int downloadRecordId = idGenerator.genDownloadRecordId();
+        String name = "公司后台-订单管理-体检缴费";
+        String fileName = "体检缴费列表";
+        String excelSuffixFormat = ConstantDef.EXCEL_SUFFIX_FORMAT;
+        String paramUrl = "/checkUp/downloadCheckUpOrderList";
+        String paramJson = JsonSerializer.toJson(request);
+        downloadRecordService.getOrInsertDownloadRecord(downloadRecordId, name, fileName + excelSuffixFormat, paramUrl, paramJson);
+        Thread t = new Thread() {
+            @Override
+            public void run() {
+                checkUpOrderService.downloadCheckUpOrderListNew(downloadRecordId, fileName, request);
+            }
+        };
+        t.start();
+        return new BaseResponse().succeed("后台下载中...");
+    }
+
+    @RequestMapping({"/downloadCheckUpOrderBillList"})
+    public BaseResponse downloadCheckUpOrderBillList(QueryCheckUpOrderListRequest request) {
+        int currentAdminId = Checker.getIntegerValue(authService.getCurrentAdminId());
+//        request.setCurrentAdminId(currentAdminId);
+        // 插入记录
+        int downloadRecordId = idGenerator.genDownloadRecordId();
+        String name = "公司后台-订单管理-住院押金";
+        String fileName = "体检缴费对账数据";
+        String excelSuffixFormat = ConstantDef.EXCEL_SUFFIX_FORMAT;
+        String paramUrl = "/checkUp/downloadCheckUpOrderBillList";
+        String paramJson = JsonSerializer.toJson(request);
+        downloadRecordService.getOrInsertDownloadRecord(downloadRecordId, name, fileName + excelSuffixFormat, paramUrl, paramJson);
+        Thread t = new Thread() {
+            @Override
+            public void run() {
+                checkUpOrderService.downloadOutPatientOrderBillListNew(downloadRecordId, fileName, request);
+            }
+        };
+        t.start();
+        return new BaseResponse().succeed("后台下载中...");
+    }
+}

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

@@ -0,0 +1,87 @@
+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.deposit.QueryDepositListRequest;
+import com.ywt.mg.params.outpatientOrder.QueryOutPatientOrderListRequest;
+import com.ywt.mg.services.AuthService;
+import com.ywt.mg.services.DepositService;
+import com.ywt.mg.services.DownloadRecordService;
+import com.ywt.mg.services.IdGenerator;
+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.RequestMapping;
+import org.springframework.web.bind.annotation.RestController;
+
+@RestController("/deposit")
+@RequestMapping({"/deposit"})
+@MGRight
+public class DepositController {
+
+    private static Logger logger = LoggerFactory.getLogger(DepositController.class);
+
+
+    @Autowired
+    private IdGenerator idGenerator;
+
+    @Autowired
+    private DownloadRecordService downloadRecordService;
+
+    @Autowired
+    private AuthService authService;
+
+    @Autowired
+    private DepositService depositService;
+
+
+    @RequestMapping({"/downloadDepositList"})
+    public BaseResponse downloadDepositList(QueryDepositListRequest request) {
+        int currentAdminId = Checker.getIntegerValue(authService.getCurrentAdminId());
+//        request.setCurrentAdminId(currentAdminId);
+        // 插入记录
+        int downloadRecordId = idGenerator.genDownloadRecordId();
+        String name = "公司后台-订单管理-住院押金";
+        String fileName = "押金缴费记录";
+        String excelSuffixFormat = ConstantDef.EXCEL_SUFFIX_FORMAT;
+        String paramUrl = "/deposit/downloadDepositList";
+        String paramJson = JsonSerializer.toJson(request);
+        downloadRecordService.getOrInsertDownloadRecord(downloadRecordId, name, fileName + excelSuffixFormat, paramUrl, paramJson);
+        Thread t = new Thread() {
+            @Override
+            public void run() {
+                depositService.downloadDepositList(downloadRecordId, fileName, request);
+            }
+        };
+        t.start();
+        return new BaseResponse().succeed("后台下载中...");
+    }
+
+    @RequestMapping({"/downloadDepositBillList"})
+    public BaseResponse downloadDepositBillList(QueryDepositListRequest request) {
+        int currentAdminId = Checker.getIntegerValue(authService.getCurrentAdminId());
+//        request.setCurrentAdminId(currentAdminId);
+        // 插入记录
+        int downloadRecordId = idGenerator.genDownloadRecordId();
+        String name = "公司后台-订单管理-住院押金对账数据";
+        String fileName = "住院押金对账列表";
+        String excelSuffixFormat = ConstantDef.EXCEL_SUFFIX_FORMAT;
+        String paramUrl = "/deposit/downloadDepositBillList";
+        String paramJson = JsonSerializer.toJson(request);
+        downloadRecordService.getOrInsertDownloadRecord(downloadRecordId, name, fileName + excelSuffixFormat, paramUrl, paramJson);
+        Thread t = new Thread() {
+            @Override
+            public void run() {
+                depositService.downloadDepositBillList(downloadRecordId, fileName, request);
+            }
+        };
+        t.start();
+        return new BaseResponse().succeed("后台下载中...");
+    }
+
+
+}

+ 142 - 0
src/main/java/com/ywt/mg/web/controllers/MealOrderController.java

@@ -0,0 +1,142 @@
+package com.ywt.mg.web.controllers;
+
+
+import com.ywt.mg.core.exceptions.AppMessageException;
+import com.ywt.mg.core.utils.Checker;
+import com.ywt.mg.core.utils.StringHelper;
+import com.ywt.mg.core.utils.serializers.JsonSerializer;
+import com.ywt.mg.domain.models.ConstantDef;
+import com.ywt.mg.params.mealOrder.MealOrderListRequest;
+import com.ywt.mg.services.AuthService;
+import com.ywt.mg.services.DownloadRecordService;
+import com.ywt.mg.services.IdGenerator;
+import com.ywt.mg.services.MealOrderService;
+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.RequestMapping;
+import org.springframework.web.bind.annotation.RestController;
+
+import java.io.UnsupportedEncodingException;
+import java.net.URLDecoder;
+
+@RequestMapping({"/mealOrder"})
+@RestController("/mealOrder")
+public class MealOrderController {
+
+    private final Logger logger = LoggerFactory.getLogger(MealOrderController.class);
+
+
+    @Autowired
+    private IdGenerator idGenerator;
+
+    @Autowired
+    private DownloadRecordService downloadRecordService;
+
+    @Autowired
+    private MealOrderService mealOrderService;
+
+    @Autowired
+    private AuthService authService;
+
+
+    @RequestMapping({"/downloadMealOrderList"})
+    public BaseResponse downloadMealOrderList(MealOrderListRequest request) {
+//        int currentAdminId = Checker.getIntegerValue(authService.getCurrentAdminId());
+//        request.setCurrentAdminId(currentAdminId);
+        // 插入记录
+
+        int downloadRecordId = idGenerator.genDownloadRecordId();
+        String name = "公司后台-订单管理-订餐订单列表列表";
+        String fileName = "订餐订单列表";
+        String excelSuffixFormat = ConstantDef.EXCEL_SUFFIX_FORMAT;
+        String paramUrl = "/mealOrder/downloadMealOrderListNew";
+        String paramJson = JsonSerializer.toJson(request);
+        downloadRecordService.getOrInsertDownloadRecord(downloadRecordId, name, fileName + excelSuffixFormat, paramUrl, paramJson);
+        Thread t = new Thread() {
+            @Override
+            public void run() {
+                try {
+                    String shopIds = "0";
+                    if (!Checker.isNone(request.getShopIds())) {
+                        shopIds = URLDecoder.decode(request.getShopIds(), "UTF-8");
+                    }
+                    request.setShopIds(shopIds);
+                    Boolean bIsStaff = getIsStaffParamCompat(request.getIsStaff());
+                    request.setbIsStaff(bIsStaff);
+                    mealOrderService.downloadMealOrderListNew(downloadRecordId, fileName, request);
+                } catch (AppMessageException e) {
+                    logger.error("MealOrderController#downloadMealOrderList(orderNo={} , name={} , mobile={} , type={} , " +
+                                    "status={} , payStatus={} , payTimeStart={} , payTimeEnd={} , httpServletResponse={} ):\n {}",
+                            e.getMessage(), e);
+                } catch (Exception e) {
+                    logger.error("MealOrderController#downloadMealOrderList(orderNo={} , name={} , mobile={} , type={} , " +
+                                    "status={} , payStatus={} , payTimeStart={} , payTimeEnd={} , httpServletResponse={} ):\n {}",
+                            request.getOrderNo(), name, request.getMobile(), request.getType(), request.getStatus(), request.getPayStatus(), request.getPayTimeStart(),
+                            request.getPayTimeEnd(), e.getMessage(), e);
+                }
+            }
+        };
+        t.start();
+        return new BaseResponse().succeed("后台下载中...");
+    }
+
+
+    private Boolean getIsStaffParamCompat(String isStaff) throws AppMessageException {
+        if (StringHelper.isNullOrEmpty(isStaff)) return null;
+        try {
+            int integer = Integer.parseInt(isStaff);
+            return integer == 1;
+        } catch (NumberFormatException e) {
+            throw new AppMessageException(String.format("参数有误:%s", isStaff));
+        }
+    }
+
+    @RequestMapping({"/downloadMealOrderBillList"})
+    public BaseResponse downloadMealOrderBillList(MealOrderListRequest request) {
+//        int currentAdminId = Checker.getIntegerValue(authService.getCurrentAdminId());
+//        request.setCurrentAdminId(currentAdminId);
+        // 插入记录
+
+        int downloadRecordId = idGenerator.genDownloadRecordId();
+        String name = "公司后台-订单管理-订餐订单列表列表";
+        String fileName = "订餐订单列表";
+        String excelSuffixFormat = ConstantDef.EXCEL_SUFFIX_FORMAT;
+        String paramUrl = "/mealOrder/downloadMealOrderBillList";
+        String paramJson = JsonSerializer.toJson(request);
+        downloadRecordService.getOrInsertDownloadRecord(downloadRecordId, name, fileName + excelSuffixFormat, paramUrl, paramJson);
+        Thread t = new Thread() {
+            @Override
+            public void run() {
+                int adminId = 0;
+//                String shopIds = "";
+//                if (request.getHospitalId() > 0) {
+//                    adminId = authService.getCurrentAdminId();
+//                    shopIds = mgAdminService.getNutrimealShopIdsByAdminId(adminId);
+//                }
+                try {
+
+
+                    String shopIds = "0";
+                    if (!Checker.isNone(request.getShopIds())) {
+                        shopIds = URLDecoder.decode(request.getShopIds(), "UTF-8");
+                    }
+                    request.setShopIds(shopIds);
+                    mealOrderService.downloadMealOrderListNew(downloadRecordId, fileName, request);
+                } catch (Exception e) {
+                    logger.error("MealOrderController#downloadMealOrderList(orderNo={} , name={} , mobile={} , type={} , " +
+                                    "status={} , payStatus={} , payTimeStart={} , payTimeEnd={} , httpServletResponse={} ):\n {}",
+                            request.getOrderNo(), name, request.getMobile(), request.getType(), request.getStatus(), request.getPayStatus(), request.getPayTimeStart(),
+                            request.getPayTimeEnd(), e.getMessage(), e);
+                    e.printStackTrace();
+                }
+
+            }
+        };
+        t.start();
+        return new BaseResponse().succeed("后台下载中...");
+    }
+
+
+}

+ 83 - 0
src/main/java/com/ywt/mg/web/controllers/OutpatientOrderController.java

@@ -0,0 +1,83 @@
+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.outpatientOrder.QueryOutPatientOrderListRequest;
+import com.ywt.mg.services.AuthService;
+import com.ywt.mg.services.DownloadRecordService;
+import com.ywt.mg.services.IdGenerator;
+import com.ywt.mg.services.OutpatientOrderService;
+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.RequestMapping;
+import org.springframework.web.bind.annotation.RestController;
+
+
+@RestController("/outPatient")
+@RequestMapping({"/outPatient"})
+@MGRight
+public class OutpatientOrderController {
+
+    private static Logger logger = LoggerFactory.getLogger(OutpatientOrderController.class);
+
+    @Autowired
+    private IdGenerator idGenerator;
+
+    @Autowired
+    private DownloadRecordService downloadRecordService;
+
+    @Autowired
+    private AuthService authService;
+
+    @Autowired
+    private OutpatientOrderService outpatientOrderService;
+
+
+    @RequestMapping({"/downloadOutPatientOrderList"})
+    public BaseResponse downloadOutPatientOrderList(QueryOutPatientOrderListRequest request) {
+        int currentAdminId = Checker.getIntegerValue(authService.getCurrentAdminId());
+//        request.setCurrentAdminId(currentAdminId);
+        // 插入记录
+        int downloadRecordId = idGenerator.genDownloadRecordId();
+        String name = "公司后台-订单管理-门诊缴费订单列表";
+        String fileName = "门诊缴费记录";
+        String excelSuffixFormat = ConstantDef.EXCEL_SUFFIX_FORMAT;
+        String paramUrl = "/outpatient/downloadOutPatientOrderList";
+        String paramJson = JsonSerializer.toJson(request);
+        downloadRecordService.getOrInsertDownloadRecord(downloadRecordId, name, fileName + excelSuffixFormat, paramUrl, paramJson);
+        Thread t = new Thread() {
+            @Override
+            public void run() {
+              outpatientOrderService.downloadOutPatientOrderListCommon(downloadRecordId, fileName, request);
+            }
+        };
+        t.start();
+        return new BaseResponse().succeed("后台下载中...");
+    }
+
+    @RequestMapping({"/downloadOutPatientOrderBillList"})
+    public BaseResponse downloadOutPatientOrderBillList(QueryOutPatientOrderListRequest request) {
+        int currentAdminId = Checker.getIntegerValue(authService.getCurrentAdminId());
+//        request.setCurrentAdminId(currentAdminId);
+        // 插入记录
+        int downloadRecordId = idGenerator.genDownloadRecordId();
+        String name = "公司后台-订单管理-门诊缴费对账记录";
+        String fileName = "门诊缴费对账记录";
+        String excelSuffixFormat = ConstantDef.EXCEL_SUFFIX_FORMAT;
+        String paramUrl = "/outpatient/downloadOutPatientOrderBillList";
+        String paramJson = JsonSerializer.toJson(request);
+        downloadRecordService.getOrInsertDownloadRecord(downloadRecordId, name, fileName + excelSuffixFormat, paramUrl, paramJson);
+        Thread t = new Thread() {
+            @Override
+            public void run() {
+                outpatientOrderService.downloadOutPatientOrderBillListNew(downloadRecordId, fileName, request);
+            }
+        };
+        t.start();
+        return new BaseResponse().succeed("后台下载中...");
+    }
+}

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

@@ -0,0 +1,78 @@
+package com.ywt.mg.web.controllers;
+
+import com.ywt.mg.core.MGRight;
+import com.ywt.mg.core.utils.serializers.JsonSerializer;
+import com.ywt.mg.domain.models.ConstantDef;
+import com.ywt.mg.params.registeredOrder.RegisteredOrderListRequest;
+import com.ywt.mg.services.DownloadRecordService;
+import com.ywt.mg.services.IdGenerator;
+import com.ywt.mg.services.RegisteredOrderService;
+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.RequestMapping;
+import org.springframework.web.bind.annotation.RestController;
+
+@RestController("/registeredOrder")
+@RequestMapping({"/registeredOrder"})
+@MGRight
+public class RegisteredOrderController {
+
+    private static Logger logger = LoggerFactory.getLogger(RegisteredOrderController.class);
+
+    @Autowired
+    private IdGenerator idGenerator;
+
+    @Autowired
+    private DownloadRecordService downloadRecordService;
+
+
+    @Autowired
+    private RegisteredOrderService registeredOrderService;
+
+
+    @RequestMapping({"/downloadRegisteredOrderList"})
+    public BaseResponse downloadDepositList(RegisteredOrderListRequest request) {
+//        int currentAdminId = Checker.getIntegerValue(authService.getCurrentAdminId());
+//        request.setCurrentAdminId(currentAdminId);
+        // 插入记录
+        int downloadRecordId = idGenerator.genDownloadRecordId();
+        String name = "公司后台-订单管理-挂号订单";
+        String fileName = "挂号订单记录";
+        String excelSuffixFormat = ConstantDef.EXCEL_SUFFIX_FORMAT;
+        String paramUrl = "/registeredOrder/downloadRegisteredOrderList";
+        String paramJson = JsonSerializer.toJson(request);
+        downloadRecordService.getOrInsertDownloadRecord(downloadRecordId, name, fileName + excelSuffixFormat, paramUrl, paramJson);
+        Thread t = new Thread() {
+            @Override
+            public void run() {
+                registeredOrderService.downloadRegisteredOrderList(downloadRecordId, fileName, request);
+            }
+        };
+        t.start();
+        return new BaseResponse().succeed("后台下载中...");
+    }
+
+    @RequestMapping({"/downloadRegisteredOrderBillsList"})
+    public BaseResponse downloadRegisteredOrderBillsList(RegisteredOrderListRequest request) {
+//        int currentAdminId = Checker.getIntegerValue(authService.getCurrentAdminId());
+//        request.setCurrentAdminId(currentAdminId);
+        // 插入记录
+        int downloadRecordId = idGenerator.genDownloadRecordId();
+        String name = "公司后台-订单管理-挂号订单对账数据";
+        String fileName = "挂号订单对账数据";
+        String excelSuffixFormat = ConstantDef.EXCEL_SUFFIX_FORMAT;
+        String paramUrl = "/registeredOrder/downloadRegisteredOrderBillsList";
+        String paramJson = JsonSerializer.toJson(request);
+        downloadRecordService.getOrInsertDownloadRecord(downloadRecordId, name, fileName + excelSuffixFormat, paramUrl, paramJson);
+        Thread t = new Thread() {
+            @Override
+            public void run() {
+                registeredOrderService.downloadRegisteredOrderBillsList(downloadRecordId, fileName, request);
+            }
+        };
+        t.start();
+        return new BaseResponse().succeed("后台下载中...");
+    }
+}

+ 14 - 1
src/main/resources/application.properties

@@ -46,4 +46,17 @@ ywt.env.test=@ywt.env.test@
 # 测试账号配置
 test.doctor.ids=@test.doctor.ids@
 test.admin.ids=@test.admin.ids@
-test.doctor.codes=@test.doctor.codes@
+test.doctor.codes=@test.doctor.codes@
+
+spring.datasource.ywtMeal.url=@db.nutrimeal.url@
+spring.datasource.ywtMeal.username=@db.ywtcenter.username@
+spring.datasource.ywtMeal.password=@db.ywtcenter.password@
+spring.datasource.ywtMeal.driver-class-name=com.mysql.jdbc.Driver
+spring.datasource.ywtMeal.max-idle=10
+spring.datasource.ywtMeal.max-wait=10000
+spring.datasource.ywtMeal.min-idle=1
+spring.datasource.ywtMeal.initial-size=1
+spring.datasource.ywtMeal.validation-query=SELECT 1
+spring.datasource.ywtMeal.test-on-borrow=false
+spring.datasource.ywtMeal.test-while-idle=true
+spring.datasource.ywtMeal.time-between-eviction-runs-millis=18800