Browse Source

Merge branch '20230223_xt_api_new_branch' of http://git.shengws.com/csx/XT_New into 20230223_xt_api_new_branch

28169 1 month ago
parent
commit
32811d451d
2 changed files with 18 additions and 22 deletions
  1. 3 8
      controllers/new_stock_api_controller.go
  2. 15 14
      service/stock_service.go

+ 3 - 8
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,8 +191,8 @@ 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)
200
-	fmt.Println("totla------------------------", total)
194
+	list, total, _ := service.GetHisDrugCodeQuery(orgId, startTime, endTime, limit, page, is_sale, is_settle)
195
+
201 196
 	drug, _ := service.GetAllDrugList(orgId)
202 197
 
203 198
 	codeConfig, _ := service.GetDrugCodeConfig(orgId)

+ 15 - 14
service/stock_service.go View File

@@ -11019,32 +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
-	offset := (page - 1) * limit
11025
-	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
+	}
11026 11031
 
11027 11032
 	if orgId > 0 {
11028
-		db = db.Where("user_org_id=?", orgId)
11033
+		db = db.Where("his_doctor_advice_info.user_org_id=?", orgId)
11029 11034
 	}
11030 11035
 	if start_time > 0 {
11031
-		db = db.Where("advice_date >= ?", start_time)
11036
+		db = db.Where("his_doctor_advice_info.advice_date >= ?", start_time)
11032 11037
 	}
11033
-
11034 11038
 	if end_time > 0 {
11035
-		db = db.Where("advice_date<=?", end_time)
11039
+		db = db.Where("his_doctor_advice_info.advice_date<=?", end_time)
11036 11040
 	}
11037
-
11041
+	offset := (page - 1) * limit
11038 11042
 	if is_sale == 1 {
11039
-		db = db.Where("is_upload = 1")
11043
+		db = db.Where("his_doctor_advice_info.is_upload = 1")
11040 11044
 	}
11041 11045
 	if is_sale == 2 {
11042
-		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")
11043 11047
 	}
11044
-
11045
-	err = db.Count(&total).Error
11046
-
11047
-	err = db.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
11048 11049
 
11049 11050
 	return list, total, err
11050 11051
 }