Browse Source

押金管理

mainqaq 2 years ago
parent
commit
3ff654d1bb

+ 1 - 1
controllers/data_api_controller.go View File

@@ -1227,7 +1227,7 @@ func (c *DataApiController) CreateSingleAdviceTemplate() {
1227 1227
 		AdviceName:            advice_name,
1228 1228
 		AdviceDesc:            advice_desc,
1229 1229
 		SingleDose:            single_dose,
1230
-		SingleDoseUnit:        single_dose_unit,
1230
+		SingleDoseUnit:        service.TypeConversion02(single_dose_unit),
1231 1231
 		PrescribingNumber:     prescribing_number,
1232 1232
 		PrescribingNumberUnit: prescribing_number_unit,
1233 1233
 		DeliveryWay:           delivery_way,

+ 8 - 5
controllers/his_api_controller.go View File

@@ -4561,7 +4561,7 @@ func (c *HisApiController) GetUploadInfo() {
4561 4561
 			tx.Commit()
4562 4562
 		}
4563 4563
 	}()
4564
-	if dec_way == "true" && tmp_decimal == "0" && tmp_decimal == "" {
4564
+	if dec_way == "true" && tmp_decimal == "0" || dec_way == "true" && tmp_decimal == "" {
4565 4565
 		c.ServeFailJsonSend(enums.ErrorCodeParamWrong, "押金不能为0")
4566 4566
 		return
4567 4567
 	}
@@ -4870,10 +4870,13 @@ func (c *HisApiController) Refund() {
4870 4870
 		return
4871 4871
 	}
4872 4872
 	tmp := strconv.FormatInt(order.ID, 10)
4873
-	err = service.MoneyIncrease(orgid, order.HisPatientId, tmp, order.Decimal)
4874
-	if err != nil {
4875
-		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
4876
-		return
4873
+	//当押金不为零时产生退费记录
4874
+	if order.Decimal != 0 {
4875
+		err = service.MoneyIncrease(orgid, order.PatientId, tmp, order.Decimal)
4876
+		if err != nil {
4877
+			c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
4878
+			return
4879
+		}
4877 4880
 	}
4878 4881
 	c.ServeSuccessJSON(map[string]interface{}{
4879 4882
 		"msg": "退费成功",

+ 57 - 12
controllers/his_deposit_controller.go View File

@@ -20,6 +20,7 @@ type HisDepositApiController struct {
20 20
 
21 21
 func HisDepositApiRegistRouters() {
22 22
 	//beego.Router("/api/his/ttt", &HisDepositApiController{}, "get:TTT")                         //测试接口
23
+	beego.Router("/api/his/gethisusertoalive", &HisDepositApiController{}, "get:GetHisUserToAlive")  //获取病例中心,有效患者名称(去除了转出和死亡的)
23 24
 	beego.Router("/api/his/gethisuser", &HisDepositApiController{}, "get:GetHisUser")                //获取病例中心,有效患者名称
24 25
 	beego.Router("/api/his/adddeposit", &HisDepositApiController{}, "post:AddDeposit")               //新增押金
25 26
 	beego.Router("/api/his/getdepositcode", &HisDepositApiController{}, "get:GetDepositCode")        //获取新增押金编号
@@ -58,9 +59,27 @@ func HisDepositApiRegistRouters() {
58 59
 //	return
59 60
 //}
60 61
 
62
+//获取病例中心,有效患者名称(去除了转出和死亡的)
63
+func (this *HisDepositApiController) GetHisUserToAlive() {
64
+	orgid := this.GetAdminUserInfo().CurrentOrgId
65
+	list, err := service.GetHisUserToAlive(orgid)
66
+	if err != nil {
67
+		this.ServeFailJsonSend(enums.ErrorCodeParamWrong, err.Error())
68
+		return
69
+	}
70
+	this.ServeSuccessJSON(map[string]interface{}{
71
+		"list": list,
72
+	})
73
+	return
74
+}
75
+
61 76
 //获取病例中心,有效患者名称
62 77
 func (this *HisDepositApiController) GetHisUser() {
63 78
 	orgid := this.GetAdminUserInfo().CurrentOrgId
79
+	token := this.Ctx.Request.Header.Get("Cookie")
80
+	fmt.Println(token)
81
+	this.Ctx.SetCookie("ppp", "lilili")
82
+	this.Ctx.SetCookie("ppp01", "lilili01")
64 83
 	list, err := service.GetHisUser(orgid)
65 84
 	if err != nil {
66 85
 		this.ServeFailJsonSend(enums.ErrorCodeParamWrong, err.Error())
@@ -205,7 +224,9 @@ func (this *HisDepositApiController) RechargeDetails() {
205 224
 		}
206 225
 	}
207 226
 	if start_time == "" && end_time == "" {
208
-		stime, etime = service.GetMondayOfWeek()
227
+		//如果为空查询全部的
228
+		_, etime = service.GetMondayOfWeek()
229
+		stime = 0
209 230
 	} else {
210 231
 		stmp, _ := time.ParseInLocation(timeLayout+" 15:04:05", start_time+" 00:00:00", loc)
211 232
 		etmp, _ := time.ParseInLocation(timeLayout+" 15:04:05", end_time+" 23:59:59", loc)
@@ -259,7 +280,8 @@ func (this *HisDepositApiController) RechargeSummary() {
259 280
 		}
260 281
 	}
261 282
 	if start_time == "" && end_time == "" {
262
-		stime, etime = service.GetMondayOfWeek()
283
+		_, etime = service.GetMondayOfWeek()
284
+		stime = 0
263 285
 	} else {
264 286
 		stmp, _ := time.ParseInLocation(timeLayout+" 15:04:05", start_time+" 00:00:00", loc)
265 287
 		etmp, _ := time.ParseInLocation(timeLayout+" 15:04:05", end_time+" 23:59:59", loc)
@@ -372,6 +394,8 @@ func (this *HisDepositApiController) DepositFlow() {
372 394
 	check := map[string][]string{
373 395
 		"id":             {"must", "int", "id"},
374 396
 		"deposit_status": {"must", "int", "deposit_status"},
397
+		"page":           {"must", "string", "page"},
398
+		"limit":          {"must", "string", "limit"},
375 399
 	}
376 400
 	_, err := checks(this, &check)
377 401
 	if err != nil {
@@ -383,19 +407,23 @@ func (this *HisDepositApiController) DepositFlow() {
383 407
 	tmp, _ := service.GetHisUserName(orgid, id)
384 408
 	name := tmp.Name
385 409
 	deposit_status, _ := this.GetInt64("deposit_status", 0) //押金类型
386
-	if deposit_status > 3 {
410
+	if deposit_status > 4 {
387 411
 		utils.ErrorLog("押金类型错误,deposit_status:", deposit_status)
388 412
 		this.ServeFailJsonSend(enums.ErrorCodeParamWrong, "押金类型错误")
389 413
 		return
390 414
 	}
391 415
 	start_time := this.GetString("start_time", "") //开始时间
392 416
 	end_time := this.GetString("end_time", "")     //结束时间
417
+	page, _ := this.GetInt64("page")               //页码
418
+	limit, _ := this.GetInt64("limit")             //每一页查出来的条数
393 419
 	timeLayout := "2006-01-02"
394 420
 	loc, _ := time.LoadLocation("Local")
395 421
 	var stime int64 //开始时间
396 422
 	var etime int64 //结束时间
397 423
 	if start_time == "" && end_time == "" {
398
-		stime, etime = service.GetMonth()
424
+		//如果为空则查全部的
425
+		_, etime = service.GetMonth()
426
+		stime = 0
399 427
 	} else {
400 428
 		stmp, _ := time.ParseInLocation(timeLayout+" 15:04:05", start_time+" 00:00:00", loc)
401 429
 		etmp, _ := time.ParseInLocation(timeLayout+" 15:04:05", end_time+" 23:59:59", loc)
@@ -405,7 +433,7 @@ func (this *HisDepositApiController) DepositFlow() {
405 433
 	//获取该角色当前时间段的余额
406 434
 	decimal := service.GetMoneyforTime(id, orgid, etime)
407 435
 	//获取列表
408
-	deposirhistory, errs := service.GetFlowList(id, orgid, stime, etime, deposit_status)
436
+	deposirhistory, total, errs := service.GetFlowList(page, limit, id, orgid, stime, etime, deposit_status)
409 437
 	if errs != nil {
410 438
 		utils.ErrorLog("获取列表失败,原因为:", errs.Error())
411 439
 		this.ServeFailJsonSend(enums.ErrorCodeParamWrong, errs.Error())
@@ -423,6 +451,7 @@ func (this *HisDepositApiController) DepositFlow() {
423 451
 		"list":    deposirhistory,
424 452
 		"name":    name,
425 453
 		"decimal": decimal,
454
+		"total":   total,
426 455
 	})
427 456
 	return
428 457
 }
@@ -475,6 +504,7 @@ func (this *HisDepositApiController) GetUserList() {
475 504
 //扣费明细查询
476 505
 func (this *HisDepositApiController) DeductionDetails() {
477 506
 	orgid := this.GetAdminUserInfo().CurrentOrgId
507
+	orgid = 9675
478 508
 	timeLayout := "2006-01-02"
479 509
 	loc, _ := time.LoadLocation("Local")
480 510
 	keyword := this.GetString("keyword")
@@ -498,7 +528,8 @@ func (this *HisDepositApiController) DeductionDetails() {
498 528
 		}
499 529
 	}
500 530
 	if start_time == "" && end_time == "" {
501
-		stime, etime = service.GetMondayOfWeek()
531
+		_, etime = service.GetMondayOfWeek()
532
+		stime = 0
502 533
 	} else {
503 534
 		stmp, _ := time.ParseInLocation(timeLayout+" 15:04:05", start_time+" 00:00:00", loc)
504 535
 		etmp, _ := time.ParseInLocation(timeLayout+" 15:04:05", end_time+" 23:59:59", loc)
@@ -526,7 +557,8 @@ func (this *HisDepositApiController) DeductionDetails() {
526 557
 		details.Decimal = list[i].Deposit
527 558
 		details.ChargeDate = fmt.Sprintf(time.Unix(list[i].Ctime, 0).Format("2006-01-02 15:04:05"))
528 559
 		details.Chargetype = service.CodeToChargetype(orgid, details.Code)
529
-		details.Total = service.MedicalTotal(orgid, list[i].HisPatientId, details.Code)
560
+		details.Total = service.MedicalTotal(orgid, tmp_id)
561
+		details.ButtonShow = service.IsButtonShow(list[i].DepositCode, orgid, list[i].HisPatientId)
530 562
 		detailslist = append(detailslist, details)
531 563
 	}
532 564
 
@@ -540,6 +572,7 @@ func (this *HisDepositApiController) DeductionDetails() {
540 572
 //扣费汇总
541 573
 func (this *HisDepositApiController) DeSummary() {
542 574
 	orgid := this.GetAdminUserInfo().CurrentOrgId
575
+	orgid = 9675
543 576
 	timeLayout := "2006-01-02"
544 577
 	loc, _ := time.LoadLocation("Local")
545 578
 	keyword := this.GetString("keyword")
@@ -563,7 +596,8 @@ func (this *HisDepositApiController) DeSummary() {
563 596
 		}
564 597
 	}
565 598
 	if start_time == "" && end_time == "" {
566
-		stime, etime = service.GetMondayOfWeek()
599
+		_, etime = service.GetMondayOfWeek()
600
+		stime = 0
567 601
 	} else {
568 602
 		stmp, _ := time.ParseInLocation(timeLayout+" 15:04:05", start_time+" 00:00:00", loc)
569 603
 		etmp, _ := time.ParseInLocation(timeLayout+" 15:04:05", end_time+" 23:59:59", loc)
@@ -583,7 +617,8 @@ func (this *HisDepositApiController) DeSummary() {
583 617
 		sum = sum.Add(list[i].Deposit)
584 618
 		details.Name = namemap[list[i].HisPatientId]
585 619
 		details.Decimal = list[i].Deposit
586
-		details.Total = service.MedicalTotal(orgid, list[i].HisPatientId, list[i].DepositCode)
620
+		tmp_id, _ := strconv.ParseInt(list[i].DepositCode, 10, 64)
621
+		details.Total = service.MedicalTotal(orgid, tmp_id)
587 622
 		detailslist = append(detailslist, details)
588 623
 	}
589 624
 	maplist := make(map[string]models.DeductionSummary)
@@ -611,7 +646,7 @@ func (this *HisDepositApiController) DeSummary() {
611 646
 		Finlist = append(Finlist, maplist[tmpslice[i]])
612 647
 	}
613 648
 	this.ServeSuccessJSON(map[string]interface{}{
614
-		"list": detailslist,
649
+		"list": Finlist,
615 650
 		"sum":  sum,
616 651
 	})
617 652
 	return
@@ -835,6 +870,8 @@ func (this *HisDepositApiController) RefundList() {
835 870
 	check := map[string][]string{
836 871
 		"refundtype":  {"must", "int", "refundtype"},
837 872
 		"examinetype": {"must", "int", "examinetype"},
873
+		"page":        {"must", "string", "page"},
874
+		"limit":       {"must", "string", "limit"},
838 875
 	}
839 876
 	_, err := checks(this, &check)
840 877
 	if err != nil {
@@ -847,6 +884,8 @@ func (this *HisDepositApiController) RefundList() {
847 884
 	keyword := this.GetString("keyword")           //获取搜索框
848 885
 	refundtype, _ := this.GetInt64("refundtype")   //获取退款类型
849 886
 	examinetype, _ := this.GetInt64("examinetype") //获取审核状态
887
+	page, _ := this.GetInt64("page")               //页码
888
+	limit, _ := this.GetInt64("limit")             //每一页查出来的条数
850 889
 	start_time := this.GetString("start_time")
851 890
 	end_time := this.GetString("end_time")
852 891
 	var stime int64 //开始时间
@@ -868,6 +907,7 @@ func (this *HisDepositApiController) RefundList() {
868 907
 	}
869 908
 	if start_time == "" && end_time == "" {
870 909
 		stime, etime = service.GetMondayOfWeek()
910
+		stime = 0
871 911
 	} else {
872 912
 		stmp, _ := time.ParseInLocation(timeLayout+" 15:04:05", start_time+" 00:00:00", loc)
873 913
 		etmp, _ := time.ParseInLocation(timeLayout+" 15:04:05", end_time+" 23:59:59", loc)
@@ -875,7 +915,8 @@ func (this *HisDepositApiController) RefundList() {
875 915
 		etime = etmp.Unix()
876 916
 	}
877 917
 	depo := []models.RefundList{}
878
-	depo, err = service.RefundList(orgid, stime, etime, refundtype, examinetype, keyword, slicekey)
918
+	var total int64
919
+	depo, total, err = service.RefundList(page, limit, orgid, stime, etime, refundtype, examinetype, keyword, slicekey)
879 920
 	if err != nil {
880 921
 		utils.ErrorLog("查询失败,原因为:", err.Error())
881 922
 		this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
@@ -891,10 +932,14 @@ func (this *HisDepositApiController) RefundList() {
891 932
 		}
892 933
 		if depo[i].DepositStatus == 4 {
893 934
 			depo[i].Name = "-"
935
+			tmpcode, _ := strconv.ParseInt(depo[i].DepositCode, 10, 64)
936
+			depo[i].DepositCode = service.FindcodeToid(tmpcode)
894 937
 		}
938
+
895 939
 	}
896 940
 	this.ServeSuccessJSON(map[string]interface{}{
897
-		"list": depo,
941
+		"list":  depo,
942
+		"total": total,
898 943
 	})
899 944
 	return
900 945
 }

+ 67 - 12
controllers/his_hospital_api_controller.go View File

@@ -4,6 +4,7 @@ import (
4 4
 	"XT_New/enums"
5 5
 	"XT_New/models"
6 6
 	"XT_New/service"
7
+	"XT_New/utils"
7 8
 	"fmt"
8 9
 	"github.com/astaxie/beego"
9 10
 	"github.com/shopspring/decimal"
@@ -742,6 +743,7 @@ func (this *HisHospitalApiController) GetZHOutHospitalCheck() {
742 743
 		IsMedicineInsurance: 1,
743 744
 		PType:               1,
744 745
 		MedfeeSumamt:        total,
746
+		PsnPartAmt:          total,
745 747
 	}
746 748
 	err := service.CreateOrder(order)
747 749
 	if err != nil {
@@ -768,8 +770,41 @@ func (c *HisHospitalApiController) GetSettleInfo() {
768 770
 	private_price, _ := c.GetFloat("private_price")
769 771
 	fapiao_code := c.GetString("fapiao_code")
770 772
 	fapiao_number := c.GetString("fapiao_number")
771
-	record, _ := service.GetInHospitalRecord(in_hospital_id)
772
-	order, _ := service.GetHisOrderByID(order_id)
773
+
774
+	id, _ := c.GetInt64("patient_id")
775
+	dec_way := c.GetString("dec_way") //是否使用押金支付bool类型
776
+	tmp_decimal := c.GetString("tmp_decimal")
777
+	var decimal float64 //本次使用的押金
778
+	var errmsg error
779
+	tx := service.XTWriteDB().Begin() //开了事务
780
+	//只检测扣费函数SpendDeposit有没有返回错误,如果有则回滚所有以TX结尾的方法(去掉TX即为原先的方法)
781
+	defer func() {
782
+		if errmsg != nil {
783
+			utils.ErrorLog("事务失败,原因为: %v", errmsg.Error())
784
+			tx.Rollback()
785
+		} else {
786
+			tx.Commit()
787
+		}
788
+	}()
789
+	if dec_way == "true" && tmp_decimal == "0" || dec_way == "true" && tmp_decimal == "" {
790
+		c.ServeFailJsonSend(enums.ErrorCodeParamWrong, "押金不能为0")
791
+		return
792
+	}
793
+	if len(tmp_decimal) > 0 {
794
+		if tmp_decimal[0] == 45 {
795
+			c.ServeFailJsonSend(enums.ErrorCodeParamWrong, "押金不能为负数")
796
+			return
797
+		}
798
+	}
799
+	tt, errs := strconv.ParseFloat(tmp_decimal, 64)
800
+	if errs != nil {
801
+		c.ServeFailJsonSend(enums.ErrorCodeParamWrong, "押金金额错误")
802
+		return
803
+	}
804
+	decimal = tt
805
+
806
+	record, _ := service.GetInHospitalRecordTX(in_hospital_id, tx)
807
+	order, _ := service.GetHisOrderByIDTX(order_id, tx)
773 808
 	chrg_bchno := order.Number
774 809
 	if record.ID == 0 {
775 810
 		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
@@ -793,9 +828,21 @@ func (c *HisHospitalApiController) GetSettleInfo() {
793 828
 	order.PrivatePrice = private_price
794 829
 	order.MdtrtId = record.Number
795 830
 	order.MedfeeSumamt = order.MedfeeSumamt
831
+	order.Decimal = decimal
796 832
 	//order.SetlTime =
797
-	err := service.UpdataOrderStatusTwo(chrg_bchno, c.GetAdminUserInfo().CurrentOrgId)
798
-	err = service.UpDateOrder(order)
833
+	err := service.UpdataOrderStatusTwoTX(chrg_bchno, c.GetAdminUserInfo().CurrentOrgId, tx)
834
+	err = service.UpDateOrderTX(order, tx)
835
+	//判断是否使用了押金
836
+	if dec_way == "true" {
837
+		tmpstring := strconv.FormatInt(order.ID, 10)
838
+		//扣押金
839
+		errmsg = service.SpendDeposit(c.GetAdminUserInfo().CurrentOrgId, id, c.GetAdminUserInfo().AdminUser.Id, tmpstring, decimal)
840
+		if errmsg != nil {
841
+			c.ServeFailJsonSend(enums.ErrorCodeParamWrong, errmsg.Error())
842
+			//c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCreateOrderException)
843
+			return
844
+		}
845
+	}
799 846
 	if err == nil {
800 847
 		c.ServeSuccessJSON(map[string]interface{}{
801 848
 			"msg": "结算成功",
@@ -807,19 +854,27 @@ func (c *HisHospitalApiController) GetSettleInfo() {
807 854
 }
808 855
 func (c *HisHospitalApiController) ZHRefund() {
809 856
 	order_id, _ := c.GetInt64("order_id")
857
+	order, _ := service.GetHisOrderByID(order_id)
810 858
 	adminUser := c.GetAdminUserInfo()
811
-	var order models.HisOrder
812
-	order, _ = service.GetHisOrderByID(order_id)
813
-
859
+	orgid := c.GetAdminUserInfo().CurrentOrgId
814 860
 	err := service.UpdataHospitalOrderStatus(order_id, order.Number, adminUser.CurrentOrgId, "", "")
815
-	if err == nil {
816
-		c.ServeSuccessJSON(map[string]interface{}{
817
-			"msg": "退费成功",
818
-		})
819
-	} else {
861
+	if err != nil {
820 862
 		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
821 863
 		return
822 864
 	}
865
+	tmp := strconv.FormatInt(order.ID, 10)
866
+	//当押金不为零时产生退费记录
867
+	if order.Decimal != 0 {
868
+		err = service.MoneyIncrease(orgid, order.PatientId, tmp, order.Decimal)
869
+		if err != nil {
870
+			c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
871
+			return
872
+		}
873
+	}
874
+
875
+	c.ServeSuccessJSON(map[string]interface{}{
876
+		"msg": "退费成功",
877
+	})
823 878
 
824 879
 }
825 880
 func (this *HisHospitalApiController) GetZHOutHospitalUnCheck() {

+ 0 - 1
controllers/mobile_api_controllers/login_api_controller.go View File

@@ -148,7 +148,6 @@ func (this *LoginAPIController) LoginByPwd() {
148 148
 		token := utils.GenerateLoginToken(mobile)
149 149
 		expiration, _ := beego.AppConfig.Int64("mobile_token_expiration_second")
150 150
 		this.Ctx.SetCookie("token_cookie", token, expiration, "/")
151
-
152 151
 		var configList interface{}
153 152
 		var dict_config_list interface{}
154 153
 

+ 33 - 24
controllers/new_mobile_api_controllers/new_login_api_controller.go View File

@@ -443,38 +443,47 @@ func (this *NewLoginApiController) LoginByCs() {
443 443
 						this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
444 444
 						return
445 445
 					}
446
-					orgJSON := respJSON["data"].(map[string]interface{})["org"].(map[string]interface{})
447
-					orgJSONBytes, _ := json.Marshal(orgJSON)
448 446
 					var org models.Org
449
-					if err := json.Unmarshal(orgJSONBytes, &org); err != nil {
450
-						utils.ErrorLog("解析机构失败:%v", err)
451
-						this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
452
-						return
447
+					if respJSON["data"].(map[string]interface{})["org"] != nil {
448
+						orgJSON := respJSON["data"].(map[string]interface{})["org"].(map[string]interface{})
449
+						orgJSONBytes, _ := json.Marshal(orgJSON)
450
+						if err := json.Unmarshal(orgJSONBytes, &org); err != nil {
451
+							utils.ErrorLog("解析机构失败:%v", err)
452
+							this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
453
+							return
454
+						}
453 455
 					}
454
-					appJSON := respJSON["data"].(map[string]interface{})["app"].(map[string]interface{})
455
-					appJSONBytes, _ := json.Marshal(appJSON)
456 456
 					var app models.OrgApp
457
-					if err := json.Unmarshal(appJSONBytes, &app); err != nil {
458
-						utils.ErrorLog("解析应用失败:%v", err)
459
-						this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
460
-						return
457
+					if respJSON["data"].(map[string]interface{})["app"] != nil {
458
+						appJSON := respJSON["data"].(map[string]interface{})["app"].(map[string]interface{})
459
+						appJSONBytes, _ := json.Marshal(appJSON)
460
+						if err := json.Unmarshal(appJSONBytes, &app); err != nil {
461
+							utils.ErrorLog("解析应用失败:%v", err)
462
+							this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
463
+							return
464
+						}
461 465
 					}
462
-					appRoleJSON := respJSON["data"].(map[string]interface{})["app_role"].(map[string]interface{})
463
-					appRoleJSONBytes, _ := json.Marshal(appRoleJSON)
464 466
 					var appRole models.App_Role
465
-					if err := json.Unmarshal(appRoleJSONBytes, &appRole); err != nil {
466
-						utils.ErrorLog("解析AppRole失败:%v", err)
467
-						this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
468
-						return
467
+					if respJSON["data"].(map[string]interface{})["app_role"] != nil {
468
+						appRoleJSON := respJSON["data"].(map[string]interface{})["app_role"].(map[string]interface{})
469
+						appRoleJSONBytes, _ := json.Marshal(appRoleJSON)
470
+						if err := json.Unmarshal(appRoleJSONBytes, &appRole); err != nil {
471
+							utils.ErrorLog("解析AppRole失败:%v", err)
472
+							this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
473
+							return
474
+						}
469 475
 					}
470
-					subscibeJSON := respJSON["data"].(map[string]interface{})["subscibe"].(map[string]interface{})
471
-					subscibeJSONBytes, _ := json.Marshal(subscibeJSON)
472 476
 					var subscibe models.ServeSubscibe
473
-					if err := json.Unmarshal(subscibeJSONBytes, &subscibe); err != nil {
474
-						utils.ErrorLog("解析Subscibe失败:%v", err)
475
-						this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
476
-						return
477
+					if respJSON["data"].(map[string]interface{})["subscibe"] != nil {
478
+						subscibeJSON := respJSON["data"].(map[string]interface{})["subscibe"].(map[string]interface{})
479
+						subscibeJSONBytes, _ := json.Marshal(subscibeJSON)
480
+						if err := json.Unmarshal(subscibeJSONBytes, &subscibe); err != nil {
481
+							utils.ErrorLog("解析Subscibe失败:%v", err)
482
+							this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
483
+							return
484
+						}
477 485
 					}
486
+
478 487
 					service.GetOrgSubscibeState(&subscibe)
479 488
 					templateInfo, _ := service.GetOrgInfoTemplate(org.Id)
480 489
 

+ 26 - 0
controllers/patient_api_controller.go View File

@@ -1281,16 +1281,29 @@ func (c *PatientApiController) CreateGroupAdvice() {
1281 1281
 			singleDose, _ := strconv.ParseFloat(adviceNameM["single_dose"].(string), 64)
1282 1282
 			advice.SingleDose = singleDose
1283 1283
 		}
1284
+		if adviceNameM["single_dose"] != nil && reflect.TypeOf(adviceNameM["single_dose"]).String() == "float64" {
1285
+			singleDose := adviceNameM["single_dose"].(float64)
1286
+			advice.SingleDose = singleDose
1287
+		}
1284 1288
 
1285 1289
 		if adviceNameM["single_dose_unit"] != nil && reflect.TypeOf(adviceNameM["single_dose_unit"]).String() == "string" {
1286 1290
 			singleDoseUnit, _ := adviceNameM["single_dose_unit"].(string)
1287 1291
 			advice.SingleDoseUnit = singleDoseUnit
1288 1292
 		}
1293
+		if adviceNameM["single_dose_unit"] != nil && reflect.TypeOf(adviceNameM["single_dose_unit"]).String() == "float64" {
1294
+			tmp := adviceNameM["single_dose_unit"].(float64)
1295
+			singleDoseUnit := service.TypeConversion(tmp)
1296
+			advice.SingleDoseUnit = singleDoseUnit
1297
+		}
1289 1298
 
1290 1299
 		if adviceNameM["prescribing_number"] != nil && reflect.TypeOf(adviceNameM["prescribing_number"]).String() == "string" {
1291 1300
 			prescribingNumber, _ := strconv.ParseFloat(adviceNameM["prescribing_number"].(string), 64)
1292 1301
 			advice.PrescribingNumber = prescribingNumber
1293 1302
 		}
1303
+		if adviceNameM["prescribing_number"] != nil && reflect.TypeOf(adviceNameM["prescribing_number"]).String() == "float64" {
1304
+			prescribingNumber := adviceNameM["prescribing_number"].(float64)
1305
+			advice.PrescribingNumber = prescribingNumber
1306
+		}
1294 1307
 
1295 1308
 		if adviceNameM["prescribing_number_unit"] != nil && reflect.TypeOf(adviceNameM["prescribing_number_unit"]).String() == "string" {
1296 1309
 			prescribingNumberUnit, _ := adviceNameM["prescribing_number_unit"].(string)
@@ -3073,11 +3086,20 @@ func adviceFormData(advice *models.DoctorAdvice, data []byte, action string) (co
3073 3086
 		singleDose, _ := strconv.ParseFloat(dataBody["single_dose"].(string), 64)
3074 3087
 		advice.SingleDose = singleDose
3075 3088
 	}
3089
+	if dataBody["single_dose"] != nil && reflect.TypeOf(dataBody["single_dose"]).String() == "float64" {
3090
+		singleDose := dataBody["single_dose"].(float64)
3091
+		advice.SingleDose = singleDose
3092
+	}
3076 3093
 
3077 3094
 	if dataBody["single_dose_unit"] != nil && reflect.TypeOf(dataBody["single_dose_unit"]).String() == "string" {
3078 3095
 		singleDoseUnit, _ := dataBody["single_dose_unit"].(string)
3079 3096
 		advice.SingleDoseUnit = singleDoseUnit
3080 3097
 	}
3098
+	if dataBody["single_dose_unit"] != nil && reflect.TypeOf(dataBody["single_dose_unit"]).String() == "float64" {
3099
+		tmp := dataBody["single_dose_unit"].(float64)
3100
+		singleDoseUnit := service.TypeConversion(tmp)
3101
+		advice.SingleDoseUnit = singleDoseUnit
3102
+	}
3081 3103
 
3082 3104
 	if dataBody["drug_spec"] != nil && reflect.TypeOf(dataBody["drug_spec"]).String() == "string" {
3083 3105
 		drugSpec, _ := strconv.ParseFloat(dataBody["drug_spec"].(string), 64)
@@ -3093,6 +3115,10 @@ func adviceFormData(advice *models.DoctorAdvice, data []byte, action string) (co
3093 3115
 		prescribingNumber, _ := strconv.ParseFloat(dataBody["prescribing_number"].(string), 64)
3094 3116
 		advice.PrescribingNumber = prescribingNumber
3095 3117
 	}
3118
+	if dataBody["prescribing_number"] != nil && reflect.TypeOf(dataBody["prescribing_number"]).String() == "float64" {
3119
+		prescribingNumber := dataBody["prescribing_number"].(float64)
3120
+		advice.PrescribingNumber = prescribingNumber
3121
+	}
3096 3122
 
3097 3123
 	if dataBody["prescribing_number_unit"] != nil && reflect.TypeOf(dataBody["prescribing_number_unit"]).String() == "string" {
3098 3124
 		prescribingNumberUnit, _ := dataBody["prescribing_number_unit"].(string)

+ 1 - 0
models/his_deposit_models.go View File

@@ -131,6 +131,7 @@ type Details struct {
131 131
 	Total      decimal.Decimal `json:"total"`       //医疗费总额
132 132
 	Decimal    decimal.Decimal `json:"decimal"`     //押金支付金额
133 133
 	ChargeDate string          `json:"charge_date"` //收费日期
134
+	ButtonShow int64           `json:"button_show"` //查看详情按钮是否显示,0隐藏,1显示
134 135
 }
135 136
 
136 137
 //扣费汇总

+ 147 - 16
service/his_deposit_service.go View File

@@ -28,6 +28,12 @@ func GetHisUser(orgid int64) (hisname []models.GetHisName, err error) {
28 28
 	return
29 29
 }
30 30
 
31
+//获取his中的有效患者去除了转出和死亡的
32
+func GetHisUserToAlive(orgid int64) (hisname []models.GetHisName, err error) {
33
+	err = XTReadDB().Model(&models.GetHisName{}).Where("status = 1 and user_org_id = ? and lapseto = 1", orgid).Find(&hisname).Error
34
+	return
35
+}
36
+
31 37
 //获取his中的有效患者
32 38
 func GetHisUserName(orgid, id int64) (hisname models.GetHisName, err error) {
33 39
 	err = XTReadDB().Model(&models.GetHisName{}).Where("status = 1 and user_org_id = ? and id = ?", orgid, id).Find(&hisname).Error
@@ -203,6 +209,7 @@ func GetMonth() (int64, int64) {
203 209
 	return timeMonthStartUnix1, timeMonthEndUnix1
204 210
 }
205 211
 
212
+//获取创建者的姓名
206 213
 func GetCreateidName(id int64) string {
207 214
 	var tmp models.CreateUser
208 215
 	XTReadDB().Select("name").Where("id = ?", id).Find(&tmp)
@@ -221,14 +228,7 @@ func UpDecimalHistory(id int64) (err error) {
221 228
 			tx.Commit()
222 229
 		}
223 230
 	}()
224
-	//改状态
225
-	err = tx.Model(models.DepositHistory{}).Where("id = ?", id).Updates(map[string]interface{}{
226
-		"trial_status": 1,
227
-		"mtime":        time.Now().Unix(),
228
-	}).Error
229
-	if err != nil {
230
-		return
231
-	}
231
+
232 232
 	//查记录x2
233 233
 	var history models.DepositHistory
234 234
 	var detmp models.Deposit
@@ -240,6 +240,15 @@ func UpDecimalHistory(id int64) (err error) {
240 240
 	if err != nil {
241 241
 		return
242 242
 	}
243
+	//改状态,=====剩余押金
244
+	err = tx.Model(models.DepositHistory{}).Where("id = ?", id).Updates(map[string]interface{}{
245
+		"trial_status":    1,
246
+		"surplus_deposit": detmp.Deposit.Add(history.Deposit),
247
+		"mtime":           time.Now().Unix(),
248
+	}).Error
249
+	if err != nil {
250
+		return
251
+	}
243 252
 	//相加
244 253
 	err = tx.Model(&models.Deposit{}).Where("id = ? and status = 1", detmp.ID).Updates(map[string]interface{}{
245 254
 		"mtime":   time.Now().Unix(),
@@ -282,12 +291,13 @@ func GetMoneyforTime(id, orgid, etime int64) decimal.Decimal {
282 291
 }
283 292
 
284 293
 //押金流水
285
-func GetFlowList(id, orgid, stime, etime, deposit_status int64) (deposit []models.DepositHistory, err error) {
294
+func GetFlowList(page, limit, id, orgid, stime, etime, deposit_status int64) (deposit []models.DepositHistory, total int64, err error) {
286 295
 	s := "status = 1 and trial_status = 1 and user_org_id = ? and his_patient_id = ? and mtime >= ? and mtime <= ?"
296
+	offset := (page - 1) * limit
287 297
 	if deposit_status != 0 {
288
-		s = s + " and deposit_status = " + string(deposit_status)
298
+		s = s + " and deposit_status = " + strconv.FormatInt(deposit_status, 10)
289 299
 	}
290
-	err = XTReadDB().Model(&models.DepositHistory{}).Where(s, orgid, id, stime, etime).Order("mtime desc").Find(&deposit).Error
300
+	err = XTReadDB().Model(&models.DepositHistory{}).Where(s, orgid, id, stime, etime).Count(&total).Offset(offset).Order("mtime desc").Limit(limit).Find(&deposit).Error
291 301
 	return
292 302
 }
293 303
 
@@ -298,7 +308,7 @@ func GetUserList(page, limit, orgid int64, keyword string, slicekey []int64) (m
298 308
 	if len(keyword) > 0 {
299 309
 		db = db.Where(" his_patient_id = ? ", keyword)
300 310
 	}
301
-	err = db.Count(&total).Offset(offset).Order("mtime desc").Find(&m).Error
311
+	err = db.Count(&total).Offset(offset).Order("mtime desc").Limit(limit).Find(&m).Error
302 312
 	return
303 313
 }
304 314
 
@@ -320,17 +330,23 @@ func DeductionList(orgid, stime, etime int64, keyword string, slicekey []int64)
320 330
 }
321 331
 
322 332
 //获取医疗费总额
323
-func MedicalTotal(orgid, patient_id int64, code string) decimal.Decimal {
333
+func MedicalTotal(orgid, id int64) decimal.Decimal {
324 334
 	tmp := models.HisChargeSettleOrder{}
325
-	XTReadDB().Model(&models.HisChargeSettleOrder{}).Where("mdtrt_id = ? and patient_id = ? and user_org_id = ? and status = 1 and order_status = 2", code, patient_id, orgid).Find(&tmp)
335
+	//and status = 1 and order_status = 2
336
+	XTReadDB().Model(&models.HisChargeSettleOrder{}).Where("id = ? and user_org_id = ? ", id, orgid).Find(&tmp)
326 337
 	return decimal.NewFromFloat(tmp.MedfeeSumamt)
327 338
 }
328 339
 
329 340
 //根据就诊号查询出医收费类型
330 341
 func CodeToChargetype(orgid int64, code string) (s string) {
331 342
 	tmp := models.HisPrintPatient{}
343
+	tmp_hhcr := models.HisHospitalCheckRecordTwo{}
332 344
 	XTReadDB().Model(&models.HisPrintPatient{}).Where("number = ? and user_org_id = ?", code, orgid).Find(&tmp)
333 345
 	//tmp.BalanceAccountsType
346
+	if tmp.BalanceAccountsType == 0 {
347
+		XTReadDB().Model(&models.HisHospitalCheckRecordTwo{}).Where("number = ? and user_org_id = ?", code, orgid).Find(&tmp_hhcr)
348
+		tmp.BalanceAccountsType = tmp_hhcr.BalanceAccountsType
349
+	}
334 350
 	switch tmp.BalanceAccountsType {
335 351
 	case 1:
336 352
 		s = "医保"
@@ -351,6 +367,7 @@ func CodeToChargetype(orgid int64, code string) (s string) {
351 367
 	default:
352 368
 		s = "类型未定义"
353 369
 	}
370
+
354 371
 	return
355 372
 }
356 373
 
@@ -430,6 +447,9 @@ func RefundApplication(orgid, his_patient_id, trial_status, createid int64, code
430 447
 	tmp := models.Deposit{}
431 448
 	err = tx.Model(&models.Deposit{}).Where("his_patient_id = ? and user_org_id = ? and status = 1", his_patient_id, orgid).Find(&tmp).Error
432 449
 	if err != nil {
450
+		if err.Error() == "record not found" {
451
+			err = fmt.Errorf("没有可退押金,保存失败")
452
+		}
433 453
 		return
434 454
 	}
435 455
 	//判断是否可以退款
@@ -638,8 +658,9 @@ func ChangeRefund(orgid, his_patient_id, trial_status, id int64, code string, de
638 658
 }
639 659
 
640 660
 //退款分页
641
-func RefundList(orgid, stime, etime, refundtype, examinetype int64, keyword string, slicekey []int64) (depo []models.RefundList, err error) {
661
+func RefundList(page, limit, orgid, stime, etime, refundtype, examinetype int64, keyword string, slicekey []int64) (depo []models.RefundList, total int64, err error) {
642 662
 	db := XTReadDB().Model(&models.DepositHistory{}).Where("status = 1 and user_org_id = ? ", orgid).Where("ctime >= ? and ctime <= ?", stime, etime)
663
+	offset := (page - 1) * limit
643 664
 	//退款类型
644 665
 	switch refundtype {
645 666
 	case 0:
@@ -670,7 +691,7 @@ func RefundList(orgid, stime, etime, refundtype, examinetype int64, keyword stri
670 691
 		keyword = "%" + keyword + "%"
671 692
 		db = db.Where(tmp, keyword)
672 693
 	}
673
-	err = db.Order("ctime desc").Find(&depo).Error
694
+	err = db.Count(&total).Offset(offset).Order("ctime desc").Limit(limit).Find(&depo).Error
674 695
 	return
675 696
 
676 697
 }
@@ -747,6 +768,22 @@ func FindnumberToid(id int64) (number string) {
747 768
 	return tmp.Number
748 769
 }
749 770
 
771
+//扣费明细列表,查看详情按钮是否显示,0隐藏,1显示
772
+func IsButtonShow(code string, orgid, his_patient_id int64) (tmp int64) {
773
+	var total int
774
+	XTReadDB().Model(&models.RefundList{}).Where(" user_org_id = ? and his_patient_id = ? and deposit_code = ? and deposit_status = 4 and status = 1", orgid, his_patient_id, code).Count(&total)
775
+	if total == 0 {
776
+		return 1
777
+	} else {
778
+		//预防万一,多加一个验证
779
+		if total%2 == 0 {
780
+			return 1
781
+		} else {
782
+			return 0
783
+		}
784
+	}
785
+}
786
+
750 787
 //把其他的类型转换成decimal.Decimal类型
751 788
 func ToDecimal(i interface{}) (d decimal.Decimal, err error) {
752 789
 	switch i.(type) {
@@ -763,3 +800,97 @@ func ToDecimal(i interface{}) (d decimal.Decimal, err error) {
763 800
 	}
764 801
 	return
765 802
 }
803
+
804
+func TypeConversion(tmp float64) (s string) {
805
+	switch tmp {
806
+	case 1:
807
+		s = "g"
808
+	case 2:
809
+		s = "mg"
810
+	case 3:
811
+		s = "u"
812
+	case 4:
813
+		s = "ml"
814
+	case 5:
815
+		s = "万U"
816
+	case 6:
817
+		s = "枚"
818
+	case 7:
819
+		s = "粒"
820
+	case 8:
821
+		s = "片"
822
+	case 9:
823
+		s = "支"
824
+	case 10:
825
+		s = "μg"
826
+	case 11:
827
+		s = "iu"
828
+	case 12:
829
+		s = "包"
830
+	case 13:
831
+		s = "袋"
832
+	case 14:
833
+		s = "万"
834
+	case 15:
835
+		s = "万iu"
836
+	case 16:
837
+		s = "丸"
838
+	case 17:
839
+		s = "盒"
840
+	case 18:
841
+		s = "瓶"
842
+	case 19:
843
+		s = "瓶(袋)"
844
+	case 20:
845
+		s = "次"
846
+	}
847
+	return s
848
+}
849
+
850
+func TypeConversion02(tmp string) (s string) {
851
+	switch tmp {
852
+	case "1":
853
+		s = "g"
854
+	case "2":
855
+		s = "mg"
856
+	case "3":
857
+		s = "u"
858
+	case "4":
859
+		s = "ml"
860
+	case "5":
861
+		s = "万U"
862
+	case "6":
863
+		s = "枚"
864
+	case "7":
865
+		s = "粒"
866
+	case "8":
867
+		s = "片"
868
+	case "9":
869
+		s = "支"
870
+	case "10":
871
+		s = "μg"
872
+	case "11":
873
+		s = "iu"
874
+	case "12":
875
+		s = "包"
876
+	case "13":
877
+		s = "袋"
878
+	case "14":
879
+		s = "万"
880
+	case "15":
881
+		s = "万iu"
882
+	case "16":
883
+		s = "丸"
884
+	case "17":
885
+		s = "盒"
886
+	case "18":
887
+		s = "瓶"
888
+	case "19":
889
+		s = "瓶(袋)"
890
+	case "20":
891
+		s = "次"
892
+	default:
893
+		s = tmp
894
+	}
895
+	return s
896
+}

+ 4 - 0
service/his_hospital_service.go View File

@@ -271,6 +271,10 @@ func GetInHospitalRecord(id int64) (record models.HisHospitalCheckRecord, err er
271 271
 	err = readDb.Model(&models.HisHospitalCheckRecord{}).Where("id = ? AND status = 1", id).First(&record).Error
272 272
 	return
273 273
 }
274
+func GetInHospitalRecordTX(id int64, tx *gorm.DB) (record models.HisHospitalCheckRecord, err error) {
275
+	err = readDb.Model(&models.HisHospitalCheckRecord{}).Where("id = ? AND status = 1", id).First(&record).Error
276
+	return
277
+}
274 278
 
275 279
 func GetInHospitalRecordByNumber(number string) (record models.HisHospitalCheckRecord, err error) {
276 280
 	err = readDb.Model(&models.HisHospitalCheckRecord{}).Where("number = ? AND status = 1", number).First(&record).Error

+ 4 - 0
service/his_service.go View File

@@ -1249,6 +1249,10 @@ func UpDateOrder(order models.HisOrder) (err error) {
1249 1249
 	err = writeDb.Save(&order).Error
1250 1250
 	return
1251 1251
 }
1252
+func UpDateOrderTX(order models.HisOrder, tx *gorm.DB) (err error) {
1253
+	err = writeDb.Save(&order).Error
1254
+	return
1255
+}
1252 1256
 
1253 1257
 func UpdataOrderStatusTwo(number string, user_org_id int64) (err error) {
1254 1258
 	err = writeDb.Model(&models.HisPrescription{}).Where("status = 1 AND batch_number = ? AND user_org_id = ?", number, user_org_id).Updates(map[string]interface{}{"order_status": 2, "mtime": time.Now().Unix()}).Error

+ 10 - 0
service/role_service.go View File

@@ -593,6 +593,7 @@ func SaveFuncRolePurviewIds(orgID int64, appID int64, roleID int64, funcPurviewI
593 593
 }
594 594
 
595 595
 func ModifyAdminUserInfo(adminUserID int64, orgID int64, appID int64, name string, avatar string, newPassword string) error {
596
+
596 597
 	tx := writeUserDb.Begin()
597 598
 	editInfoErr := tx.Exec("update sgj_user_admin_role set user_name = ?, avatar = ?, mtime = ? where admin_user_id = ? and org_id = ?", name, avatar, time.Now().Unix(), adminUserID, orgID).Error
598 599
 	if editInfoErr != nil {
@@ -606,6 +607,15 @@ func ModifyAdminUserInfo(adminUserID int64, orgID int64, appID int64, name strin
606 607
 			return editPwdErr
607 608
 		}
608 609
 	}
610
+	//这里加上
611
+	err := tx.Model(&models.AdminUser{}).Where("id = ?", adminUserID).Updates(map[string]interface{}{
612
+		"mtime": time.Now().Unix(),
613
+		"name":  name,
614
+	}).Error
615
+	if err != nil {
616
+		tx.Rollback()
617
+		return err
618
+	}
609 619
 	tx.Commit()
610 620
 	return nil
611 621
 }

+ 1 - 0
service/self_drug_service.go View File

@@ -551,6 +551,7 @@ type Drugs struct {
551 551
 	Dose                  float64  `gorm:"column:dose" json:"dose" form:"dose"`
552 552
 	DoseUnit              string   `gorm:"column:dose_unit" json:"dose_unit" form:"dose_unit"`
553 553
 	MaxUnit               string   `gorm:"column:max_unit" json:"max_unit" form:"max_unit"`
554
+	DrugDoseUnit          int64    `grom:"column:drug_dose_unit" json:"drug_dose_unit" form:"drug_dose_unit"`
554 555
 }
555 556
 
556 557
 func (Drugs) TableName() string {