陈少旭 1 ヶ月 前
コミット
0db6c3c1d8
共有1 個のファイルを変更した25 個の追加3 個の削除を含む
  1. 25 3
      service/fapiao_service.go

+ 25 - 3
service/fapiao_service.go ファイルの表示

@@ -1,6 +1,10 @@
1 1
 package service
2 2
 
3
-import "XT_New/models"
3
+import (
4
+	"XT_New/models"
5
+	"fmt"
6
+	"strings"
7
+)
4 8
 
5 9
 func FindFaPiaoConfigInfo(org_id int64) (config models.FapiaoConfig, err error) {
6 10
 	err = readDb.Model(&models.FapiaoConfig{}).Where("status = 1 AND user_org_id = ?", org_id).First(&config).Error
@@ -46,6 +50,8 @@ func GetFaPiaoSettleList(user_org_id int64, page int64, limit int64, start_time_
46 50
 
47 51
 	}
48 52
 
53
+	db = db.Where("his_order.status =  1 and his_order.order_status = 2")
54
+
49 55
 	// Preload related data
50 56
 	db = db.Preload("Patients", "status = 1 AND user_org_id = ?", user_org_id).
51 57
 		Preload("HisPatient", "status = 1 AND user_org_id = ?", user_org_id).
@@ -73,13 +79,21 @@ func GetFaPiaoList(user_org_id int64, page int64, limit int64, start_time_timest
73 79
 	offset := (page - 1) * limit
74 80
 	db := readDb.Model(&models.HisFaPiaoOrder{})
75 81
 	db = db.Preload("Patients", "status = 1 AND user_org_id = ?", user_org_id)
76
-	db = db.Where("ctime >= ? and ctime <= ? and user_org_id = ? and status = 1", start_time_timestamp, end_time_timestamp, user_org_id)
82
+	db = db.Where("ctime >= ? and ctime <= ? and user_org_id = ? and status = 1 and pdf_url <> ''", start_time_timestamp, end_time_timestamp, user_org_id)
77 83
 	// Count the total number of records
78 84
 	db = db.Count(&total)
79 85
 	// Apply pagination
80 86
 	db = db.Limit(limit).Offset(offset)
81 87
 	// Execute query and return results
82 88
 	err = db.Find(&order).Error
89
+	for _, item := range order {
90
+		var os []*models.SettleAccountsDateOrder
91
+		order_ids := strings.Split(item.OrderIds, ",")
92
+		err := readDb.Model(&models.SettleAccountsDateOrder{}).Where("id in (?)", order_ids).Find(&os).Error
93
+		if err == nil {
94
+			item.SettleAccountsDateOrder = append(item.SettleAccountsDateOrder, os...)
95
+		}
96
+	}
83 97
 	return
84 98
 }
85 99
 
@@ -98,7 +112,7 @@ func GetFaPiaoOrderInfoByNumbers(numbers []string) (infos []models.HisOrderInfo,
98 112
 	return
99 113
 }
100 114
 
101
-func SaveFaPiaoOrder(fapiao models.HisFaPiaoOrder) (err error) {
115
+func SaveFaPiaoOrder(fapiao *models.HisFaPiaoOrder) (err error) {
102 116
 	err = writeDb.Save(&fapiao).Error
103 117
 	return
104 118
 }
@@ -108,6 +122,14 @@ func UpdateFaPiaoNumber(number string, ids []string) (err error) {
108 122
 	return
109 123
 }
110 124
 
125
+func UpdateFaPiaoSN(number string, ids []string) (err error) {
126
+	fmt.Println(ids)
127
+	fmt.Println(number)
128
+
129
+	err = XTWriteDB().Model(&models.HisOrder{}).Where("id in (?)", ids).Updates(map[string]interface{}{"fa_piao_sn": number}).Error
130
+	return
131
+}
132
+
111 133
 func UpdateFaPiaoNumberByNumber(number string) (err error) {
112 134
 	err = XTWriteDB().Model(&models.HisOrder{}).Where("fa_piao_number = ?", number).Updates(map[string]interface{}{"fa_piao_number": ""}).Error
113 135
 	return