陈少旭 3 miesięcy temu
rodzic
commit
496b00c3d7
2 zmienionych plików z 16 dodań i 18 usunięć
  1. 2 7
      controllers/new_stock_api_controller.go
  2. 14 11
      service/stock_service.go

+ 2 - 7
controllers/new_stock_api_controller.go Wyświetl plik

162
 func (this *NewStockApiController) GetHisDrugCodeQuery() {
162
 func (this *NewStockApiController) GetHisDrugCodeQuery() {
163
 
163
 
164
 	start_time := this.GetString("start_time")
164
 	start_time := this.GetString("start_time")
165
-
166
 	end_time := this.GetString("end_time")
165
 	end_time := this.GetString("end_time")
167
-
168
 	limit, _ := this.GetInt64("limit")
166
 	limit, _ := this.GetInt64("limit")
169
-
170
 	page, _ := this.GetInt64("page")
167
 	page, _ := this.GetInt64("page")
171
-
172
 	is_sale, _ := this.GetInt64("is_sale")
168
 	is_sale, _ := this.GetInt64("is_sale")
169
+	is_settle, _ := this.GetInt64("is_settle")
173
 
170
 
174
 	orgId := this.GetAdminUserInfo().CurrentOrgId
171
 	orgId := this.GetAdminUserInfo().CurrentOrgId
175
-
176
 	timeLayout := "2006-01-02"
172
 	timeLayout := "2006-01-02"
177
 	loc, _ := time.LoadLocation("Local")
173
 	loc, _ := time.LoadLocation("Local")
178
 	var startTime int64
174
 	var startTime int64
179
 	if len(start_time) > 0 {
175
 	if len(start_time) > 0 {
180
 		theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", start_time+" 00:00:00", loc)
176
 		theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", start_time+" 00:00:00", loc)
181
-
182
 		if err != nil {
177
 		if err != nil {
183
 			this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
178
 			this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
184
 			return
179
 			return
196
 		endTime = theTime.Unix()
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
 	drug, _ := service.GetAllDrugList(orgId)
196
 	drug, _ := service.GetAllDrugList(orgId)
202
 
197
 

+ 14 - 11
service/stock_service.go Wyświetl plik

11019
 	return err
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
 	if orgId > 0 {
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
 	if start_time > 0 {
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
 	if end_time > 0 {
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
 	offset := (page - 1) * limit
11041
 	offset := (page - 1) * limit
11038
-
11039
 	if is_sale == 1 {
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
 	if is_sale == 2 {
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
 	return list, total, err
11050
 	return list, total, err
11048
 }
11051
 }