Browse Source

提交代码

陈少旭 3 months ago
parent
commit
496b00c3d7
2 changed files with 16 additions and 18 deletions
  1. 2 7
      controllers/new_stock_api_controller.go
  2. 14 11
      service/stock_service.go

+ 2 - 7
controllers/new_stock_api_controller.go View File

@@ -162,23 +162,18 @@ func (c *NewStockApiController) GetDrugQuery() {
162 162
 func (this *NewStockApiController) GetHisDrugCodeQuery() {
163 163
 
164 164
 	start_time := this.GetString("start_time")
165
-
166 165
 	end_time := this.GetString("end_time")
167
-
168 166
 	limit, _ := this.GetInt64("limit")
169
-
170 167
 	page, _ := this.GetInt64("page")
171
-
172 168
 	is_sale, _ := this.GetInt64("is_sale")
169
+	is_settle, _ := this.GetInt64("is_settle")
173 170
 
174 171
 	orgId := this.GetAdminUserInfo().CurrentOrgId
175
-
176 172
 	timeLayout := "2006-01-02"
177 173
 	loc, _ := time.LoadLocation("Local")
178 174
 	var startTime int64
179 175
 	if len(start_time) > 0 {
180 176
 		theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", start_time+" 00:00:00", loc)
181
-
182 177
 		if err != nil {
183 178
 			this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
184 179
 			return
@@ -196,7 +191,7 @@ func (this *NewStockApiController) GetHisDrugCodeQuery() {
196 191
 		endTime = theTime.Unix()
197 192
 	}
198 193
 
199
-	list, total, _ := service.GetHisDrugCodeQuery(orgId, startTime, endTime, limit, page, is_sale)
194
+	list, total, _ := service.GetHisDrugCodeQuery(orgId, startTime, endTime, limit, page, is_sale, is_settle)
200 195
 
201 196
 	drug, _ := service.GetAllDrugList(orgId)
202 197
 

+ 14 - 11
service/stock_service.go View File

@@ -11019,30 +11019,33 @@ func SaveDrugOpen(open models.XtDrugCodeOpen) error {
11019 11019
 	return err
11020 11020
 }
11021 11021
 
11022
-func GetHisDrugCodeQuery(orgId int64, start_time int64, end_time int64, limit int64, page int64, is_sale int64) (list []*models.HisDoctorAdviceInfo, total int64, err error) {
11022
+func GetHisDrugCodeQuery(orgId int64, start_time int64, end_time int64, limit int64, page int64, is_sale int64, is_settle int64) (list []*models.NewHisDoctorAdviceInfo, total int64, err error) {
11023 11023
 
11024
-	db := XTReadDB().Model(&models.HisDoctorAdviceInfo{}).Where("status=1")
11024
+	db := XTReadDB().Model(&models.NewHisDoctorAdviceInfo{}).Preload("NewHisPrescription", "status = 1").Where("his_doctor_advice_info.status=1")
11025
+	if is_settle == 2 {
11026
+		db = db.Joins("join his_prescription on his_prescription.id = his_doctor_advice_info.prescription_id and his_prescription.order_status = 2 and his_prescription.status = 1")
11027
+
11028
+	} else if is_settle == 1 {
11029
+		db = db.Joins("join his_prescription on his_prescription.id = his_doctor_advice_info.prescription_id and his_prescription.order_status <> 2 and his_prescription.status = 1")
11030
+	}
11025 11031
 
11026 11032
 	if orgId > 0 {
11027
-		db = db.Where("user_org_id=?", orgId)
11033
+		db = db.Where("his_doctor_advice_info.user_org_id=?", orgId)
11028 11034
 	}
11029 11035
 	if start_time > 0 {
11030
-		db = db.Where("advice_date >= ?", start_time)
11036
+		db = db.Where("his_doctor_advice_info.advice_date >= ?", start_time)
11031 11037
 	}
11032
-
11033 11038
 	if end_time > 0 {
11034
-		db = db.Where("advice_date<=?", end_time)
11039
+		db = db.Where("his_doctor_advice_info.advice_date<=?", end_time)
11035 11040
 	}
11036
-
11037 11041
 	offset := (page - 1) * limit
11038
-
11039 11042
 	if is_sale == 1 {
11040
-		db = db.Where("is_upload = 1")
11043
+		db = db.Where("his_doctor_advice_info.is_upload = 1")
11041 11044
 	}
11042 11045
 	if is_sale == 2 {
11043
-		db = db.Where("is_upload = 2 or is_upload =0")
11046
+		db = db.Where("his_doctor_advice_info.is_upload = 2 or his_doctor_advice_info.is_upload =0")
11044 11047
 	}
11045
-	err = db.Count(&total).Offset(offset).Limit(limit).Order("record_date desc").Find(&list).Error
11048
+	err = db.Count(&total).Offset(offset).Limit(limit).Order("his_doctor_advice_info.record_date desc").Find(&list).Error
11046 11049
 
11047 11050
 	return list, total, err
11048 11051
 }