소스 검색

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

28169 7 달 전
부모
커밋
36bd59018a
4개의 변경된 파일82개의 추가작업 그리고 15개의 파일을 삭제
  1. 0 3
      controllers/his_charge_api_controller.go
  2. 13 12
      controllers/statistics_api_controller.go
  3. 15 0
      models/his_charge_models.go
  4. 54 0
      service/his_deposit_service.go

+ 0 - 3
controllers/his_charge_api_controller.go 파일 보기

@@ -453,7 +453,6 @@ func (c *HisChargeApiController) GetPrescriptionStatisticsDetail() {
453 453
 
454 454
 	date1, _ := time.Parse("2006-01-02", start_time)
455 455
 	date2, _ := time.Parse("2006-01-02", end_time)
456
-
457 456
 	// 计算日期间隔
458 457
 	duration := date2.Sub(date1)
459 458
 
@@ -461,12 +460,10 @@ func (c *HisChargeApiController) GetPrescriptionStatisticsDetail() {
461 460
 	oneMonthDuration := 30 * 24 * time.Hour
462 461
 
463 462
 	if duration <= oneMonthDuration {
464
-
465 463
 	} else {
466 464
 		c.ServeFailJSONWithSGJErrorCode(enums.ErrorTimeCodeParamWrong)
467 465
 		return
468 466
 	}
469
-
470 467
 	adminUser := c.GetAdminUserInfo()
471 468
 	timeLayout := "2006-01-02"
472 469
 	loc, _ := time.LoadLocation("Local")

+ 13 - 12
controllers/statistics_api_controller.go 파일 보기

@@ -327,25 +327,30 @@ func (c *StatisticsApiController) GetDialysisTotalDetail() {
327 327
 			weeks := groupByWeek(dates)
328 328
 			//var uniqueFields []map[string]interface{}
329 329
 			var uniqueFields []map[string]interface{}
330
-
330
+			// 加载中国标准时间(UTC+8)
331
+			chinaLoc, err := time.LoadLocation("Asia/Shanghai")
332
+			if err != nil {
333
+				fmt.Println("加载中国时区出错:", err)
334
+				return
335
+			}
331 336
 			for _, week := range weeks {
332
-				// 解析字符串时显式指定时区为 UTC
333
-				t, err := time.Parse("2006-01-02 15:04:05 -0700 MST", week[0].String())
337
+				// 解析时间字符串并转换为中国标准时间
338
+				t, err := time.ParseInLocation("2006-01-02 15:04:05 -0700 MST", week[0].String(), chinaLoc)
334 339
 				if err != nil {
335 340
 					fmt.Println("解析时间出错:", err)
336 341
 					return
337 342
 				}
338
-				// 解析字符串时显式指定时区为 UTC
339
-				t2, err := time.Parse("2006-01-02 15:04:05 -0700 MST", week[len(week)-1].String())
343
+
344
+				t2, err := time.ParseInLocation("2006-01-02 15:04:05 -0700 MST", week[len(week)-1].String(), chinaLoc)
340 345
 				if err != nil {
341 346
 					fmt.Println("解析时间出错:", err)
342 347
 					return
343 348
 				}
344
-				//dynamicFields := make([]map[string]interface{}, 0)
349
+
350
+				// 获取数据
345 351
 				list, _ := service.GetDialysisStats(t.Unix(), t2.Unix(), mode, c.GetAdminUserInfo().CurrentOrgId, time_way)
346
-				//fmt.Println(aa)
352
+
347 353
 				var dynamicFields []map[string]interface{}
348
-				//var uniqueFields []map[string]interface{}
349 354
 				for _, result := range list {
350 355
 					nb := result["日期"].([]byte)
351 356
 					name := string(nb)
@@ -408,10 +413,6 @@ func (c *StatisticsApiController) GetDialysisTotalDetail() {
408 413
 					if _, ok := seen[value]; !ok {
409 414
 						seen[value] = struct{}{}
410 415
 						uniqueFields = append(uniqueFields, field)
411
-
412
-						//// 对字段进行排序,有值的排在前面
413
-						//sortedField := sortFieldsByValue(field)
414
-						//uniqueFields = append(uniqueFields, sortedField)
415 416
 					}
416 417
 				}
417 418
 			}

+ 15 - 0
models/his_charge_models.go 파일 보기

@@ -94,6 +94,17 @@ func (SettlePatient) TableName() string {
94 94
 	return "xt_patients"
95 95
 }
96 96
 
97
+type OrderHisPatient struct {
98
+	ID        int64  `gorm:"column:id" json:"id" form:"id"`
99
+	PatientId int64  `gorm:"column:patient_id" json:"patient_id" form:"patient_id"`
100
+	Number    string `gorm:"column:number" json:"number" form:"number"`
101
+	SickType  int64  `gorm:"column:sick_type" json:"sick_type" form:"sick_type"`
102
+}
103
+
104
+func (OrderHisPatient) TableName() string {
105
+	return "his_patient"
106
+}
107
+
97 108
 type HisChargeOrder struct {
98 109
 	ID                 int64   `gorm:"column:id" json:"id" form:"id"`
99 110
 	UserOrgId          int64   `gorm:"column:user_org_id" json:"user_org_id" form:"user_org_id"`
@@ -196,6 +207,10 @@ type HisChargeSettleOrder struct {
196 207
 	IsUploadDiagnose  int64 `gorm:"column:is_upload_diagnose" json:"is_upload_diagnose" form:"is_upload_diagnose"`
197 208
 	IsUploadOrderInfo int64 `gorm:"column:is_upload_order_info" json:"is_upload_order_info" form:"is_upload_order_info"`
198 209
 	IsUploadSuccess   int64 `gorm:"column:is_upload_success" json:"is_upload_success" form:"is_upload_success"`
210
+
211
+	SickName string `gorm:"sick_name" json:"sick_name" form:"sick_name"`
212
+
213
+	//OrderHisPatient OrderHisPatient `gorm:"ForeignKey:Number;AssociationForeignKey:MdtrtId" json:"his"`
199 214
 }
200 215
 
201 216
 func (HisChargeSettleOrder) TableName() string {

+ 54 - 0
service/his_deposit_service.go 파일 보기

@@ -445,6 +445,60 @@ func SpendDeposit(orgid, his_user_id, create_id int64, code string, deposit inte
445 445
 	return
446 446
 }
447 447
 
448
+func SpendDepositTwo(orgid, his_user_id, create_id int64, code string, deposit interface{}, ctime int64) (err error) {
449
+	tmp_deposit := decimal.Decimal{} //本次患者使用的押金
450
+	tmp_deposit, err = ToDecimal(deposit)
451
+	if err != nil {
452
+		return
453
+	}
454
+	////开事务
455
+	//tx := XTWriteDB().Begin()
456
+	//defer func() {
457
+	//	if err != nil {
458
+	//		utils.ErrorLog("事务失败,原因为: %v", err.Error())
459
+	//		tx.Rollback()
460
+	//	} else {
461
+	//		tx.Commit()
462
+	//	}
463
+	//}()
464
+	//查询患者押金
465
+	tmp := models.Deposit{}
466
+	err = readDb.Model(&models.Deposit{}).Where("his_patient_id = ? and user_org_id = ? and status = 1", his_user_id, orgid).Find(&tmp).Error
467
+	if err != nil {
468
+		err = fmt.Errorf("押金余额不足")
469
+		return
470
+	}
471
+	//判断能否扣除
472
+	if tmp.Deposit.Cmp(tmp_deposit) == -1 {
473
+		err = fmt.Errorf("押金余额不足")
474
+		return
475
+	}
476
+	//扣除患者押金
477
+	err = readDb.Model(&models.Deposit{}).Where("id = ? and status = 1", tmp.ID).Updates(map[string]interface{}{
478
+		"mtime":   time.Now().Unix(),
479
+		"deposit": tmp.Deposit.Sub(tmp_deposit),
480
+	}).Error
481
+	if err != nil {
482
+		return
483
+	}
484
+	//生成一条历史记录
485
+	dehistory := models.DepositHistory{
486
+		UserOrgId:      orgid,
487
+		HisPatientId:   his_user_id,
488
+		DepositCode:    code,
489
+		Deposit:        tmp_deposit,
490
+		SurplusDeposit: tmp.Deposit.Sub(tmp_deposit),
491
+		DepositStatus:  2,
492
+		Status:         1,
493
+		CreateId:       create_id,
494
+		Ctime:          ctime,
495
+		Mtime:          time.Now().Unix(),
496
+		TrialStatus:    1,
497
+	}
498
+	err = readDb.Create(&dehistory).Error
499
+	return
500
+}
501
+
448 502
 // 新增一条退款申请
449 503
 func RefundApplication(orgid, his_patient_id, trial_status, createid int64, code string, deposit decimal.Decimal) (err error) {
450 504
 	//开事务