Browse Source

提交代码

陈少旭 1 month ago
parent
commit
0db6c3c1d8
1 changed files with 25 additions and 3 deletions
  1. 25 3
      service/fapiao_service.go

+ 25 - 3
service/fapiao_service.go View File

1
 package service
1
 package service
2
 
2
 
3
-import "XT_New/models"
3
+import (
4
+	"XT_New/models"
5
+	"fmt"
6
+	"strings"
7
+)
4
 
8
 
5
 func FindFaPiaoConfigInfo(org_id int64) (config models.FapiaoConfig, err error) {
9
 func FindFaPiaoConfigInfo(org_id int64) (config models.FapiaoConfig, err error) {
6
 	err = readDb.Model(&models.FapiaoConfig{}).Where("status = 1 AND user_org_id = ?", org_id).First(&config).Error
10
 	err = readDb.Model(&models.FapiaoConfig{}).Where("status = 1 AND user_org_id = ?", org_id).First(&config).Error
46
 
50
 
47
 	}
51
 	}
48
 
52
 
53
+	db = db.Where("his_order.status =  1 and his_order.order_status = 2")
54
+
49
 	// Preload related data
55
 	// Preload related data
50
 	db = db.Preload("Patients", "status = 1 AND user_org_id = ?", user_org_id).
56
 	db = db.Preload("Patients", "status = 1 AND user_org_id = ?", user_org_id).
51
 		Preload("HisPatient", "status = 1 AND user_org_id = ?", user_org_id).
57
 		Preload("HisPatient", "status = 1 AND user_org_id = ?", user_org_id).
73
 	offset := (page - 1) * limit
79
 	offset := (page - 1) * limit
74
 	db := readDb.Model(&models.HisFaPiaoOrder{})
80
 	db := readDb.Model(&models.HisFaPiaoOrder{})
75
 	db = db.Preload("Patients", "status = 1 AND user_org_id = ?", user_org_id)
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
 	// Count the total number of records
83
 	// Count the total number of records
78
 	db = db.Count(&total)
84
 	db = db.Count(&total)
79
 	// Apply pagination
85
 	// Apply pagination
80
 	db = db.Limit(limit).Offset(offset)
86
 	db = db.Limit(limit).Offset(offset)
81
 	// Execute query and return results
87
 	// Execute query and return results
82
 	err = db.Find(&order).Error
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
 	return
97
 	return
84
 }
98
 }
85
 
99
 
98
 	return
112
 	return
99
 }
113
 }
100
 
114
 
101
-func SaveFaPiaoOrder(fapiao models.HisFaPiaoOrder) (err error) {
115
+func SaveFaPiaoOrder(fapiao *models.HisFaPiaoOrder) (err error) {
102
 	err = writeDb.Save(&fapiao).Error
116
 	err = writeDb.Save(&fapiao).Error
103
 	return
117
 	return
104
 }
118
 }
108
 	return
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
 func UpdateFaPiaoNumberByNumber(number string) (err error) {
133
 func UpdateFaPiaoNumberByNumber(number string) (err error) {
112
 	err = XTWriteDB().Model(&models.HisOrder{}).Where("fa_piao_number = ?", number).Updates(map[string]interface{}{"fa_piao_number": ""}).Error
134
 	err = XTWriteDB().Model(&models.HisOrder{}).Where("fa_piao_number = ?", number).Updates(map[string]interface{}{"fa_piao_number": ""}).Error
113
 	return
135
 	return