浏览代码

提交代码

陈少旭 1年前
父节点
当前提交
5bfea735da
共有 1 个文件被更改,包括 20 次插入28 次删除
  1. 20 28
      service/his_charge_service.go

+ 20 - 28
service/his_charge_service.go 查看文件

157
 		switch item_type {
157
 		switch item_type {
158
 		case 0:
158
 		case 0:
159
 			err = readDb.Table("his_order_info as oi").Select("oi.advice_id as advice_id, 0 as project_id, oi.patient_id as p_id,oi.cnt as cnt,oi.pric as pric,pp.name as p_name,drug.drug_name as item_name,drug.dose as dose,drug.dose_unit as dose_unit, drug.min_number as min_number,drug.min_unit as min_unit, drug.max_unit as max_unit,drug.id as item_id").
159
 			err = readDb.Table("his_order_info as oi").Select("oi.advice_id as advice_id, 0 as project_id, oi.patient_id as p_id,oi.cnt as cnt,oi.pric as pric,pp.name as p_name,drug.drug_name as item_name,drug.dose as dose,drug.dose_unit as dose_unit, drug.min_number as min_number,drug.min_unit as min_unit, drug.max_unit as max_unit,drug.id as item_id").
160
-				Joins("JOIN his_order o ON oi.order_number = o.number   and o.setl_time BETWEEN  ? AND ?  and o.order_status = 2 and o.status = 1", start_time_str, end_time_str).
160
+				Joins("JOIN his_order o ON oi.order_number = o.number  and FROM_UNIXTIME(o.settle_accounts_date, '%Y-%m-%d') BETWEEN ? AND ?  and o.order_status = 2 and o.status = 1", start_time_str, end_time_str).
161
 				Joins(" JOIN his_doctor_advice_info a ON oi.advice_id = a.id").
161
 				Joins(" JOIN his_doctor_advice_info a ON oi.advice_id = a.id").
162
 				Joins(" JOIN xt_patients pp on oi.patient_id = pp.id").
162
 				Joins(" JOIN xt_patients pp on oi.patient_id = pp.id").
163
 				Joins(" JOIN  xt_base_drug drug on  a.drug_id = drug.id").
163
 				Joins(" JOIN  xt_base_drug drug on  a.drug_id = drug.id").
164
-				Where("oi.advice_id > 0 and oi.user_org_id = ? and oi.`upload_date` >= ?  and oi.`upload_date` <= ?   and oi.status = 1 ", org_id, start_time, end_time).Scan(&patients).Error
164
+				Where("oi.advice_id > 0 and oi.user_org_id = ? and o.settle_accounts_date >= ?  and o.settle_accounts_date <= ?   and oi.status = 1 ", org_id, start_time, end_time).Scan(&patients).Error
165
 			break
165
 			break
166
 		case 1:
166
 		case 1:
167
 			err = readDb.Table("his_order_info as oi").Select("oi.advice_id as advice_id, 0 as project_id, oi.patient_id as p_id,oi.cnt as cnt,oi.pric as pric,pp.name as p_name,drug.drug_name as item_name,drug.dose as dose,drug.dose_unit as dose_unit, drug.min_number as min_number,drug.min_unit as min_unit, drug.max_unit as max_unit,drug.id as item_id").
167
 			err = readDb.Table("his_order_info as oi").Select("oi.advice_id as advice_id, 0 as project_id, oi.patient_id as p_id,oi.cnt as cnt,oi.pric as pric,pp.name as p_name,drug.drug_name as item_name,drug.dose as dose,drug.dose_unit as dose_unit, drug.min_number as min_number,drug.min_unit as min_unit, drug.max_unit as max_unit,drug.id as item_id").
168
-				Joins("JOIN his_order o ON oi.order_number = o.number   and o.setl_time BETWEEN  ? AND ?  and o.order_status = 2 and o.status = 1", start_time_str, end_time_str).
168
+				Joins("JOIN his_order o ON oi.order_number = o.number   and FROM_UNIXTIME(o.settle_accounts_date, '%Y-%m-%d') BETWEEN ? AND ?  and o.order_status = 2 and o.status = 1", start_time_str, end_time_str).
169
 				Joins(" JOIN his_doctor_advice_info a ON oi.advice_id = a.id").
169
 				Joins(" JOIN his_doctor_advice_info a ON oi.advice_id = a.id").
170
 				Joins(" JOIN xt_patients pp on oi.patient_id = pp.id").
170
 				Joins(" JOIN xt_patients pp on oi.patient_id = pp.id").
171
 				Joins(" JOIN  xt_base_drug drug on  a.drug_id = drug.id").
171
 				Joins(" JOIN  xt_base_drug drug on  a.drug_id = drug.id").
172
-				Where("oi.advice_id > 0 and oi.user_org_id = ? and oi.`upload_date` >= ?  and oi.`upload_date` <= ?   and oi.status = 1 ", org_id, start_time, end_time).Scan(&patients).Error
172
+				Where("oi.advice_id > 0 and oi.user_org_id = ? and  o.settle_accounts_date >= ?  and o.settle_accounts_date <= ?    and oi.status = 1 ", org_id, start_time, end_time).Scan(&patients).Error
173
 			break
173
 			break
174
 
174
 
175
 		}
175
 		}
179
 		switch item_type {
179
 		switch item_type {
180
 		case 0:
180
 		case 0:
181
 			err = readDb.Table("his_order_info as oi").Select("oi.advice_id as advice_id, 0 as project_id, oi.patient_id as p_id,oi.cnt as cnt,oi.pric as pric,pp.name as p_name,drug.drug_name as item_name,drug.dose as dose,drug.dose_unit as dose_unit, drug.min_number as min_number,drug.min_unit as min_unit, drug.max_unit as max_unit,drug.id as item_id").
181
 			err = readDb.Table("his_order_info as oi").Select("oi.advice_id as advice_id, 0 as project_id, oi.patient_id as p_id,oi.cnt as cnt,oi.pric as pric,pp.name as p_name,drug.drug_name as item_name,drug.dose as dose,drug.dose_unit as dose_unit, drug.min_number as min_number,drug.min_unit as min_unit, drug.max_unit as max_unit,drug.id as item_id").
182
-				Joins("JOIN his_order o ON oi.order_number = o.number   and o.setl_time BETWEEN  ? AND ?  and o.order_status = 2 and o.status = 1", start_time_str, end_time_str).
182
+				Joins("JOIN his_order o ON oi.order_number = o.number   and FROM_UNIXTIME(o.settle_accounts_date, '%Y-%m-%d') BETWEEN ? AND ?  and o.order_status = 2 and o.status = 1", start_time_str, end_time_str).
183
 				Joins(" JOIN his_doctor_advice_info a ON oi.advice_id = a.id").
183
 				Joins(" JOIN his_doctor_advice_info a ON oi.advice_id = a.id").
184
 				Joins(" JOIN xt_patients pp on oi.patient_id = pp.id and pp.name like ?", keyword).
184
 				Joins(" JOIN xt_patients pp on oi.patient_id = pp.id and pp.name like ?", keyword).
185
 				Joins(" JOIN  xt_base_drug drug on  a.drug_id = drug.id").
185
 				Joins(" JOIN  xt_base_drug drug on  a.drug_id = drug.id").
186
-				Where("oi.advice_id > 0 and oi.user_org_id = ? and oi.`upload_date` >= ?  and oi.`upload_date` <= ?   and oi.status = 1 ", org_id, start_time, end_time).Scan(&patients).Error
186
+				Where("oi.advice_id > 0 and oi.user_org_id = ? and o.settle_accounts_date >= ?  and o.settle_accounts_date <= ?  and oi.status = 1 ", org_id, start_time, end_time).Scan(&patients).Error
187
 
187
 
188
 			break
188
 			break
189
 		case 1:
189
 		case 1:
190
 			err = readDb.Table("his_order_info as oi").Select("oi.advice_id as advice_id, 0 as project_id, oi.patient_id as p_id,oi.cnt as cnt,oi.pric as pric,pp.name as p_name,drug.drug_name as item_name,drug.dose as dose,drug.dose_unit as dose_unit, drug.min_number as min_number,drug.min_unit as min_unit, drug.max_unit as max_unit,drug.id as item_id").
190
 			err = readDb.Table("his_order_info as oi").Select("oi.advice_id as advice_id, 0 as project_id, oi.patient_id as p_id,oi.cnt as cnt,oi.pric as pric,pp.name as p_name,drug.drug_name as item_name,drug.dose as dose,drug.dose_unit as dose_unit, drug.min_number as min_number,drug.min_unit as min_unit, drug.max_unit as max_unit,drug.id as item_id").
191
-				Joins("JOIN his_order o ON oi.order_number = o.number   and o.setl_time BETWEEN  ? AND ?  and o.order_status = 2 and o.status = 1", start_time_str, end_time_str).
191
+				Joins("JOIN his_order o ON oi.order_number = o.number   and FROM_UNIXTIME(o.settle_accounts_date, '%Y-%m-%d') BETWEEN ? AND ?  and o.order_status = 2 and o.status = 1", start_time_str, end_time_str).
192
 				Joins(" JOIN his_doctor_advice_info a ON oi.advice_id = a.id").
192
 				Joins(" JOIN his_doctor_advice_info a ON oi.advice_id = a.id").
193
 				Joins(" JOIN xt_patients pp on oi.patient_id = pp.id and pp.name like ?", keyword).
193
 				Joins(" JOIN xt_patients pp on oi.patient_id = pp.id and pp.name like ?", keyword).
194
 				Joins(" JOIN  xt_base_drug drug on  a.drug_id = drug.id").
194
 				Joins(" JOIN  xt_base_drug drug on  a.drug_id = drug.id").
195
-				Where("oi.advice_id > 0 and oi.user_org_id = ? and oi.`upload_date` >= ?  and oi.`upload_date` <= ?   and oi.status = 1 ", org_id, start_time, end_time).Scan(&patients).Error
195
+				Where("oi.advice_id > 0 and oi.user_org_id = ? and o.settle_accounts_date >= ?  and o.settle_accounts_date <= ? and oi.status = 1 ", org_id, start_time, end_time).Scan(&patients).Error
196
 
196
 
197
 			break
197
 			break
198
 
198
 
207
 		switch item_type {
207
 		switch item_type {
208
 		case 0:
208
 		case 0:
209
 			err = readDb.Table("his_order_info as oi").Select("0 as advice_id, oi.project_id as project_id, oi.patient_id as p_id,oi.cnt as cnt,oi.pric as pric,pp.name as p_name,p.type as p_type,  (case p.type  when 2 then project.project_name  when 3 then good.good_name  END) as item_name,(case p.type  when 2 then ''  when 3 then good.specification_name  END) as specification_name, p.project_id as item_id").
209
 			err = readDb.Table("his_order_info as oi").Select("0 as advice_id, oi.project_id as project_id, oi.patient_id as p_id,oi.cnt as cnt,oi.pric as pric,pp.name as p_name,p.type as p_type,  (case p.type  when 2 then project.project_name  when 3 then good.good_name  END) as item_name,(case p.type  when 2 then ''  when 3 then good.specification_name  END) as specification_name, p.project_id as item_id").
210
-				Joins("JOIN his_order o ON oi.order_number = o.number   and o.setl_time BETWEEN  ? AND ?  and o.order_status = 2 and o.status = 1", start_time_str, end_time_str).
210
+				Joins("JOIN his_order o ON oi.order_number = o.number  and FROM_UNIXTIME(o.settle_accounts_date, '%Y-%m-%d') BETWEEN ? AND ? and o.order_status = 2 and o.status = 1", start_time_str, end_time_str).
211
 				Joins(" JOIN his_prescription_project p ON oi.project_id = p.id ").
211
 				Joins(" JOIN his_prescription_project p ON oi.project_id = p.id ").
212
 				Joins(" left join xt_his_project project on  p.project_id = project.id").
212
 				Joins(" left join xt_his_project project on  p.project_id = project.id").
213
 				Joins(" left join  xt_good_information good on  p.project_id = good.id").
213
 				Joins(" left join  xt_good_information good on  p.project_id = good.id").
214
 				Joins(" JOIN xt_patients pp on oi.patient_id = pp.id").
214
 				Joins(" JOIN xt_patients pp on oi.patient_id = pp.id").
215
-				Where("oi.project_id > 0 and oi.user_org_id = ? and oi.`upload_date` >= ?  and oi.`upload_date` <= ?   and oi.status = 1 ", org_id, start_time, end_time).Scan(&patients).Error
215
+				Where("oi.project_id > 0 and oi.user_org_id = ? and o.settle_accounts_date >= ?  and o.settle_accounts_date <= ? and oi.status = 1 ", org_id, start_time, end_time).Scan(&patients).Error
216
 
216
 
217
 			//err = readDb2.Table("xt_patients as p").Select("p.id,p.user_org_id,p.name,p.lapseto,p.status").Joins("JOIN his_order AS orders ON orders.patient_id = p.id AND orders.status = 1  AND orders.ctime >= ? AND orders.ctime <= ? AND orders.user_org_id = ? AND orders.order_status = 2", start_time, end_time, org_id).Preload("HisChargeOrder", func(db *gorm.DB) *gorm.DB {
217
 			//err = readDb2.Table("xt_patients as p").Select("p.id,p.user_org_id,p.name,p.lapseto,p.status").Joins("JOIN his_order AS orders ON orders.patient_id = p.id AND orders.status = 1  AND orders.ctime >= ? AND orders.ctime <= ? AND orders.user_org_id = ? AND orders.order_status = 2", start_time, end_time, org_id).Preload("HisChargeOrder", func(db *gorm.DB) *gorm.DB {
218
 			//	return db.Select("id,user_org_id,his_patient_id,settle_accounts_date,status,number,order_status,mdtrt_id,patient_id").
218
 			//	return db.Select("id,user_org_id,his_patient_id,settle_accounts_date,status,number,order_status,mdtrt_id,patient_id").
233
 			break
233
 			break
234
 		case 2:
234
 		case 2:
235
 			err = readDb.Table("his_order_info as oi").Select("0 as advice_id, oi.project_id as project_id, oi.patient_id as p_id,oi.cnt as cnt,oi.pric as pric,pp.name as p_name,p.type as p_type,  (case p.type  when 2 then project.project_name  when 3 then good.good_name  END) as item_name,(case p.type  when 2 then ''  when 3 then good.specification_name  END) as specification_name, p.project_id as item_id").
235
 			err = readDb.Table("his_order_info as oi").Select("0 as advice_id, oi.project_id as project_id, oi.patient_id as p_id,oi.cnt as cnt,oi.pric as pric,pp.name as p_name,p.type as p_type,  (case p.type  when 2 then project.project_name  when 3 then good.good_name  END) as item_name,(case p.type  when 2 then ''  when 3 then good.specification_name  END) as specification_name, p.project_id as item_id").
236
-				Joins("JOIN his_order o ON oi.order_number = o.number   and o.setl_time BETWEEN  ? AND ?  and o.order_status = 2 and o.status = 1 ", start_time_str, end_time_str).
236
+				Joins("JOIN his_order o ON oi.order_number = o.number   and FROM_UNIXTIME(o.settle_accounts_date, '%Y-%m-%d') BETWEEN ? AND ? and o.order_status = 2 and o.status = 1 ", start_time_str, end_time_str).
237
 				Joins(" JOIN his_prescription_project p ON oi.project_id = p.id and p.type = 2").
237
 				Joins(" JOIN his_prescription_project p ON oi.project_id = p.id and p.type = 2").
238
 				Joins("left join xt_his_project project on  p.project_id = project.id").
238
 				Joins("left join xt_his_project project on  p.project_id = project.id").
239
 				Joins("left join  xt_good_information good on  p.project_id = good.id").
239
 				Joins("left join  xt_good_information good on  p.project_id = good.id").
240
 				Joins(" JOIN xt_patients pp on oi.patient_id = pp.id").
240
 				Joins(" JOIN xt_patients pp on oi.patient_id = pp.id").
241
-				Where("oi.project_id > 0 and oi.user_org_id = ? and oi.`upload_date` >= ?  and oi.`upload_date` <= ?   and oi.status = 1 ", org_id, start_time, end_time).Scan(&patients).Error
242
-
241
+				Where("oi.project_id > 0 and oi.user_org_id = ? and o.settle_accounts_date >= ?  and o.settle_accounts_date <= ?  and oi.status = 1 ", org_id, start_time, end_time).Scan(&patients).Error
243
 			break
242
 			break
244
 		case 3:
243
 		case 3:
245
 			err = readDb.Table("his_order_info as oi").Select("0 as advice_id, oi.project_id as project_id, oi.patient_id as p_id,oi.cnt as cnt,oi.pric as pric,pp.name as p_name,p.type as p_type,  (case p.type  when 2 then project.project_name  when 3 then good.good_name  END) as item_name,(case p.type  when 2 then ''  when 3 then good.specification_name  END) as specification_name, p.project_id as item_id").
244
 			err = readDb.Table("his_order_info as oi").Select("0 as advice_id, oi.project_id as project_id, oi.patient_id as p_id,oi.cnt as cnt,oi.pric as pric,pp.name as p_name,p.type as p_type,  (case p.type  when 2 then project.project_name  when 3 then good.good_name  END) as item_name,(case p.type  when 2 then ''  when 3 then good.specification_name  END) as specification_name, p.project_id as item_id").
246
-				Joins("JOIN his_order o ON oi.order_number = o.number   and o.setl_time BETWEEN  ? AND ?  and o.order_status = 2 and o.status = 1 ", start_time_str, end_time_str).
245
+				Joins("JOIN his_order o ON oi.order_number = o.number   and FROM_UNIXTIME(o.settle_accounts_date, '%Y-%m-%d') BETWEEN ? AND ? and o.order_status = 2 and o.status = 1 ", start_time_str, end_time_str).
247
 				Joins(" JOIN his_prescription_project p ON oi.project_id = p.id and p.type = 3").
246
 				Joins(" JOIN his_prescription_project p ON oi.project_id = p.id and p.type = 3").
248
 				Joins("left join xt_his_project project on  p.project_id = project.id").
247
 				Joins("left join xt_his_project project on  p.project_id = project.id").
249
 				Joins("left join  xt_good_information good on  p.project_id = good.id").
248
 				Joins("left join  xt_good_information good on  p.project_id = good.id").
250
 				Joins(" JOIN xt_patients pp on oi.patient_id = pp.id").
249
 				Joins(" JOIN xt_patients pp on oi.patient_id = pp.id").
251
-				Where("oi.project_id > 0 and oi.user_org_id = ? and oi.`upload_date` >= ?  and oi.`upload_date` <= ?   and oi.status = 1 ", org_id, start_time, end_time).Scan(&patients).Error
252
-
250
+				Where("oi.project_id > 0 and oi.user_org_id = ? and o.settle_accounts_date >= ?  and o.settle_accounts_date <= ? and oi.status = 1 ", org_id, start_time, end_time).Scan(&patients).Error
253
 			break
251
 			break
254
-
255
 		}
252
 		}
256
-
257
 	} else {
253
 	} else {
258
 		keyword := "%" + keyword + "%"
254
 		keyword := "%" + keyword + "%"
259
 		switch item_type {
255
 		switch item_type {
260
 		case 0:
256
 		case 0:
261
 			err = readDb.Table("his_order_info as oi").Select("0 as advice_id, oi.project_id as project_id, oi.patient_id as p_id,oi.cnt as cnt,oi.pric as pric,pp.name as p_name,p.type as p_type,  (case p.type  when 2 then project.project_name  when 3 then good.good_name  END) as item_name,(case p.type  when 2 then ''  when 3 then good.specification_name  END) as specification_name, p.project_id as item_id").
257
 			err = readDb.Table("his_order_info as oi").Select("0 as advice_id, oi.project_id as project_id, oi.patient_id as p_id,oi.cnt as cnt,oi.pric as pric,pp.name as p_name,p.type as p_type,  (case p.type  when 2 then project.project_name  when 3 then good.good_name  END) as item_name,(case p.type  when 2 then ''  when 3 then good.specification_name  END) as specification_name, p.project_id as item_id").
262
-				Joins("JOIN his_order o ON oi.order_number = o.number   and o.setl_time BETWEEN  ? AND ?  and o.order_status = 2 and o.status = 1", start_time_str, end_time_str).
258
+				Joins("JOIN his_order o ON oi.order_number = o.number   and FROM_UNIXTIME(o.settle_accounts_date, '%Y-%m-%d') BETWEEN ? AND ? and o.order_status = 2 and o.status = 1", start_time_str, end_time_str).
263
 				Joins(" JOIN his_prescription_project p ON oi.project_id = p.id ").
259
 				Joins(" JOIN his_prescription_project p ON oi.project_id = p.id ").
264
 				Joins("left join xt_his_project project on  p.project_id = project.id").
260
 				Joins("left join xt_his_project project on  p.project_id = project.id").
265
 				Joins("left join  xt_good_information good on  p.project_id = good.id").
261
 				Joins("left join  xt_good_information good on  p.project_id = good.id").
266
 				Joins(" JOIN xt_patients pp on oi.patient_id = pp.id and pp.name like ?", keyword).
262
 				Joins(" JOIN xt_patients pp on oi.patient_id = pp.id and pp.name like ?", keyword).
267
-				Where("oi.project_id > 0 and oi.user_org_id = ? and oi.`upload_date` >= ?  and oi.`upload_date` <= ?   and oi.status = 1 ", org_id, start_time, end_time).Scan(&patients).Error
263
+				Where("oi.project_id > 0 and oi.user_org_id = ? and o.settle_accounts_date >= ?  and o.settle_accounts_date <= ? and oi.status = 1 ", org_id, start_time, end_time).Scan(&patients).Error
268
 
264
 
269
 			break
265
 			break
270
 
266
 
271
 		case 2:
267
 		case 2:
272
 			err = readDb.Table("his_order_info as oi").Select("0 as advice_id, oi.project_id as project_id, oi.patient_id as p_id,oi.cnt as cnt,oi.pric as pric,pp.name as p_name,p.type as p_type,  (case p.type  when 2 then project.project_name  when 3 then good.good_name  END) as item_name,(case p.type  when 2 then ''  when 3 then good.specification_name  END) as specification_name, p.project_id as item_id").
268
 			err = readDb.Table("his_order_info as oi").Select("0 as advice_id, oi.project_id as project_id, oi.patient_id as p_id,oi.cnt as cnt,oi.pric as pric,pp.name as p_name,p.type as p_type,  (case p.type  when 2 then project.project_name  when 3 then good.good_name  END) as item_name,(case p.type  when 2 then ''  when 3 then good.specification_name  END) as specification_name, p.project_id as item_id").
273
-				Joins("JOIN his_order o ON oi.order_number = o.number   and o.setl_time BETWEEN  ? AND ?  and o.order_status = 2 and o.status = 1", start_time_str, end_time_str).
269
+				Joins("JOIN his_order o ON oi.order_number = o.number   and FROM_UNIXTIME(o.settle_accounts_date, '%Y-%m-%d') BETWEEN ? AND ?  and o.order_status = 2 and o.status = 1", start_time_str, end_time_str).
274
 				Joins(" JOIN his_prescription_project p ON oi.project_id = p.id and p.type = 2").
270
 				Joins(" JOIN his_prescription_project p ON oi.project_id = p.id and p.type = 2").
275
 				Joins("left join xt_his_project project on  p.project_id = project.id").
271
 				Joins("left join xt_his_project project on  p.project_id = project.id").
276
 				Joins("left join  xt_good_information good on  p.project_id = good.id").
272
 				Joins("left join  xt_good_information good on  p.project_id = good.id").
277
 				Joins(" JOIN xt_patients pp on oi.patient_id = pp.id and pp.name like ?", keyword).
273
 				Joins(" JOIN xt_patients pp on oi.patient_id = pp.id and pp.name like ?", keyword).
278
-				Where("oi.project_id > 0 and oi.user_org_id = ? and oi.`upload_date` >= ?  and oi.`upload_date` <= ?   and oi.status = 1 ", org_id, start_time, end_time).Scan(&patients).Error
274
+				Where("oi.project_id > 0 and oi.user_org_id = ? and o.settle_accounts_date >= ?  and o.settle_accounts_date <= ? and oi.status = 1 ", org_id, start_time, end_time).Scan(&patients).Error
279
 
275
 
280
 			break
276
 			break
281
 		case 3:
277
 		case 3:
282
 			err = readDb.Table("his_order_info as oi").Select("0 as advice_id, oi.project_id as project_id, oi.patient_id as p_id,oi.cnt as cnt,oi.pric as pric,pp.name as p_name,p.type as p_type,  (case p.type  when 2 then project.project_name  when 3 then good.good_name  END) as item_name,(case p.type  when 2 then ''  when 3 then good.specification_name  END) as specification_name, p.project_id as item_id").
278
 			err = readDb.Table("his_order_info as oi").Select("0 as advice_id, oi.project_id as project_id, oi.patient_id as p_id,oi.cnt as cnt,oi.pric as pric,pp.name as p_name,p.type as p_type,  (case p.type  when 2 then project.project_name  when 3 then good.good_name  END) as item_name,(case p.type  when 2 then ''  when 3 then good.specification_name  END) as specification_name, p.project_id as item_id").
283
-				Joins("JOIN his_order o ON oi.order_number = o.number   and o.setl_time BETWEEN  ? AND ?  and o.order_status = 2 and o.status = 1", start_time_str, end_time_str).
279
+				Joins("JOIN his_order o ON oi.order_number = o.number   and FROM_UNIXTIME(o.settle_accounts_date, '%Y-%m-%d') BETWEEN ? AND ?  and o.order_status = 2 and o.status = 1", start_time_str, end_time_str).
284
 				Joins(" JOIN his_prescription_project p ON oi.project_id = p.id and p.type = 3").
280
 				Joins(" JOIN his_prescription_project p ON oi.project_id = p.id and p.type = 3").
285
 				Joins("left join xt_his_project project on  p.project_id = project.id").
281
 				Joins("left join xt_his_project project on  p.project_id = project.id").
286
 				Joins("left join  xt_good_information good on  p.project_id = good.id").
282
 				Joins("left join  xt_good_information good on  p.project_id = good.id").
287
 				Joins(" JOIN xt_patients pp on oi.patient_id = pp.id and pp.name like ?", keyword).
283
 				Joins(" JOIN xt_patients pp on oi.patient_id = pp.id and pp.name like ?", keyword).
288
-				Where("oi.project_id > 0 and oi.user_org_id = ? and oi.`upload_date` >= ?  and oi.`upload_date` <= ?   and oi.status = 1 ", org_id, start_time, end_time).Scan(&patients).Error
289
-
284
+				Where("oi.project_id > 0 and oi.user_org_id = ? and o.settle_accounts_date >= ?  and o.settle_accounts_date <= ? and oi.status = 1 ", org_id, start_time, end_time).Scan(&patients).Error
290
 			break
285
 			break
291
-
292
 		}
286
 		}
293
-
294
 	}
287
 	}
295
-
296
 	return
288
 	return
297
 }
289
 }
298
 
290