瀏覽代碼

押金管理

mainqaq 2 年之前
父節點
當前提交
3ff654d1bb

+ 1 - 1
controllers/data_api_controller.go 查看文件

1227
 		AdviceName:            advice_name,
1227
 		AdviceName:            advice_name,
1228
 		AdviceDesc:            advice_desc,
1228
 		AdviceDesc:            advice_desc,
1229
 		SingleDose:            single_dose,
1229
 		SingleDose:            single_dose,
1230
-		SingleDoseUnit:        single_dose_unit,
1230
+		SingleDoseUnit:        service.TypeConversion02(single_dose_unit),
1231
 		PrescribingNumber:     prescribing_number,
1231
 		PrescribingNumber:     prescribing_number,
1232
 		PrescribingNumberUnit: prescribing_number_unit,
1232
 		PrescribingNumberUnit: prescribing_number_unit,
1233
 		DeliveryWay:           delivery_way,
1233
 		DeliveryWay:           delivery_way,

+ 8 - 5
controllers/his_api_controller.go 查看文件

4561
 			tx.Commit()
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
 		c.ServeFailJsonSend(enums.ErrorCodeParamWrong, "押金不能为0")
4565
 		c.ServeFailJsonSend(enums.ErrorCodeParamWrong, "押金不能为0")
4566
 		return
4566
 		return
4567
 	}
4567
 	}
4870
 		return
4870
 		return
4871
 	}
4871
 	}
4872
 	tmp := strconv.FormatInt(order.ID, 10)
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
 	c.ServeSuccessJSON(map[string]interface{}{
4881
 	c.ServeSuccessJSON(map[string]interface{}{
4879
 		"msg": "退费成功",
4882
 		"msg": "退费成功",

+ 57 - 12
controllers/his_deposit_controller.go 查看文件

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

+ 67 - 12
controllers/his_hospital_api_controller.go 查看文件

4
 	"XT_New/enums"
4
 	"XT_New/enums"
5
 	"XT_New/models"
5
 	"XT_New/models"
6
 	"XT_New/service"
6
 	"XT_New/service"
7
+	"XT_New/utils"
7
 	"fmt"
8
 	"fmt"
8
 	"github.com/astaxie/beego"
9
 	"github.com/astaxie/beego"
9
 	"github.com/shopspring/decimal"
10
 	"github.com/shopspring/decimal"
742
 		IsMedicineInsurance: 1,
743
 		IsMedicineInsurance: 1,
743
 		PType:               1,
744
 		PType:               1,
744
 		MedfeeSumamt:        total,
745
 		MedfeeSumamt:        total,
746
+		PsnPartAmt:          total,
745
 	}
747
 	}
746
 	err := service.CreateOrder(order)
748
 	err := service.CreateOrder(order)
747
 	if err != nil {
749
 	if err != nil {
768
 	private_price, _ := c.GetFloat("private_price")
770
 	private_price, _ := c.GetFloat("private_price")
769
 	fapiao_code := c.GetString("fapiao_code")
771
 	fapiao_code := c.GetString("fapiao_code")
770
 	fapiao_number := c.GetString("fapiao_number")
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
 	chrg_bchno := order.Number
808
 	chrg_bchno := order.Number
774
 	if record.ID == 0 {
809
 	if record.ID == 0 {
775
 		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
810
 		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
793
 	order.PrivatePrice = private_price
828
 	order.PrivatePrice = private_price
794
 	order.MdtrtId = record.Number
829
 	order.MdtrtId = record.Number
795
 	order.MedfeeSumamt = order.MedfeeSumamt
830
 	order.MedfeeSumamt = order.MedfeeSumamt
831
+	order.Decimal = decimal
796
 	//order.SetlTime =
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
 	if err == nil {
846
 	if err == nil {
800
 		c.ServeSuccessJSON(map[string]interface{}{
847
 		c.ServeSuccessJSON(map[string]interface{}{
801
 			"msg": "结算成功",
848
 			"msg": "结算成功",
807
 }
854
 }
808
 func (c *HisHospitalApiController) ZHRefund() {
855
 func (c *HisHospitalApiController) ZHRefund() {
809
 	order_id, _ := c.GetInt64("order_id")
856
 	order_id, _ := c.GetInt64("order_id")
857
+	order, _ := service.GetHisOrderByID(order_id)
810
 	adminUser := c.GetAdminUserInfo()
858
 	adminUser := c.GetAdminUserInfo()
811
-	var order models.HisOrder
812
-	order, _ = service.GetHisOrderByID(order_id)
813
-
859
+	orgid := c.GetAdminUserInfo().CurrentOrgId
814
 	err := service.UpdataHospitalOrderStatus(order_id, order.Number, adminUser.CurrentOrgId, "", "")
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
 		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
862
 		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
821
 		return
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
 func (this *HisHospitalApiController) GetZHOutHospitalUnCheck() {
880
 func (this *HisHospitalApiController) GetZHOutHospitalUnCheck() {

+ 0 - 1
controllers/mobile_api_controllers/login_api_controller.go 查看文件

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

+ 33 - 24
controllers/new_mobile_api_controllers/new_login_api_controller.go 查看文件

443
 						this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
443
 						this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
444
 						return
444
 						return
445
 					}
445
 					}
446
-					orgJSON := respJSON["data"].(map[string]interface{})["org"].(map[string]interface{})
447
-					orgJSONBytes, _ := json.Marshal(orgJSON)
448
 					var org models.Org
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
 					var app models.OrgApp
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
 					var appRole models.App_Role
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
 					var subscibe models.ServeSubscibe
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
 					service.GetOrgSubscibeState(&subscibe)
487
 					service.GetOrgSubscibeState(&subscibe)
479
 					templateInfo, _ := service.GetOrgInfoTemplate(org.Id)
488
 					templateInfo, _ := service.GetOrgInfoTemplate(org.Id)
480
 
489
 

+ 26 - 0
controllers/patient_api_controller.go 查看文件

1281
 			singleDose, _ := strconv.ParseFloat(adviceNameM["single_dose"].(string), 64)
1281
 			singleDose, _ := strconv.ParseFloat(adviceNameM["single_dose"].(string), 64)
1282
 			advice.SingleDose = singleDose
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
 		if adviceNameM["single_dose_unit"] != nil && reflect.TypeOf(adviceNameM["single_dose_unit"]).String() == "string" {
1289
 		if adviceNameM["single_dose_unit"] != nil && reflect.TypeOf(adviceNameM["single_dose_unit"]).String() == "string" {
1286
 			singleDoseUnit, _ := adviceNameM["single_dose_unit"].(string)
1290
 			singleDoseUnit, _ := adviceNameM["single_dose_unit"].(string)
1287
 			advice.SingleDoseUnit = singleDoseUnit
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
 		if adviceNameM["prescribing_number"] != nil && reflect.TypeOf(adviceNameM["prescribing_number"]).String() == "string" {
1299
 		if adviceNameM["prescribing_number"] != nil && reflect.TypeOf(adviceNameM["prescribing_number"]).String() == "string" {
1291
 			prescribingNumber, _ := strconv.ParseFloat(adviceNameM["prescribing_number"].(string), 64)
1300
 			prescribingNumber, _ := strconv.ParseFloat(adviceNameM["prescribing_number"].(string), 64)
1292
 			advice.PrescribingNumber = prescribingNumber
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
 		if adviceNameM["prescribing_number_unit"] != nil && reflect.TypeOf(adviceNameM["prescribing_number_unit"]).String() == "string" {
1308
 		if adviceNameM["prescribing_number_unit"] != nil && reflect.TypeOf(adviceNameM["prescribing_number_unit"]).String() == "string" {
1296
 			prescribingNumberUnit, _ := adviceNameM["prescribing_number_unit"].(string)
1309
 			prescribingNumberUnit, _ := adviceNameM["prescribing_number_unit"].(string)
3073
 		singleDose, _ := strconv.ParseFloat(dataBody["single_dose"].(string), 64)
3086
 		singleDose, _ := strconv.ParseFloat(dataBody["single_dose"].(string), 64)
3074
 		advice.SingleDose = singleDose
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
 	if dataBody["single_dose_unit"] != nil && reflect.TypeOf(dataBody["single_dose_unit"]).String() == "string" {
3094
 	if dataBody["single_dose_unit"] != nil && reflect.TypeOf(dataBody["single_dose_unit"]).String() == "string" {
3078
 		singleDoseUnit, _ := dataBody["single_dose_unit"].(string)
3095
 		singleDoseUnit, _ := dataBody["single_dose_unit"].(string)
3079
 		advice.SingleDoseUnit = singleDoseUnit
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
 	if dataBody["drug_spec"] != nil && reflect.TypeOf(dataBody["drug_spec"]).String() == "string" {
3104
 	if dataBody["drug_spec"] != nil && reflect.TypeOf(dataBody["drug_spec"]).String() == "string" {
3083
 		drugSpec, _ := strconv.ParseFloat(dataBody["drug_spec"].(string), 64)
3105
 		drugSpec, _ := strconv.ParseFloat(dataBody["drug_spec"].(string), 64)
3093
 		prescribingNumber, _ := strconv.ParseFloat(dataBody["prescribing_number"].(string), 64)
3115
 		prescribingNumber, _ := strconv.ParseFloat(dataBody["prescribing_number"].(string), 64)
3094
 		advice.PrescribingNumber = prescribingNumber
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
 	if dataBody["prescribing_number_unit"] != nil && reflect.TypeOf(dataBody["prescribing_number_unit"]).String() == "string" {
3123
 	if dataBody["prescribing_number_unit"] != nil && reflect.TypeOf(dataBody["prescribing_number_unit"]).String() == "string" {
3098
 		prescribingNumberUnit, _ := dataBody["prescribing_number_unit"].(string)
3124
 		prescribingNumberUnit, _ := dataBody["prescribing_number_unit"].(string)

+ 1 - 0
models/his_deposit_models.go 查看文件

131
 	Total      decimal.Decimal `json:"total"`       //医疗费总额
131
 	Total      decimal.Decimal `json:"total"`       //医疗费总额
132
 	Decimal    decimal.Decimal `json:"decimal"`     //押金支付金额
132
 	Decimal    decimal.Decimal `json:"decimal"`     //押金支付金额
133
 	ChargeDate string          `json:"charge_date"` //收费日期
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 查看文件

28
 	return
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
 //获取his中的有效患者
37
 //获取his中的有效患者
32
 func GetHisUserName(orgid, id int64) (hisname models.GetHisName, err error) {
38
 func GetHisUserName(orgid, id int64) (hisname models.GetHisName, err error) {
33
 	err = XTReadDB().Model(&models.GetHisName{}).Where("status = 1 and user_org_id = ? and id = ?", orgid, id).Find(&hisname).Error
39
 	err = XTReadDB().Model(&models.GetHisName{}).Where("status = 1 and user_org_id = ? and id = ?", orgid, id).Find(&hisname).Error
203
 	return timeMonthStartUnix1, timeMonthEndUnix1
209
 	return timeMonthStartUnix1, timeMonthEndUnix1
204
 }
210
 }
205
 
211
 
212
+//获取创建者的姓名
206
 func GetCreateidName(id int64) string {
213
 func GetCreateidName(id int64) string {
207
 	var tmp models.CreateUser
214
 	var tmp models.CreateUser
208
 	XTReadDB().Select("name").Where("id = ?", id).Find(&tmp)
215
 	XTReadDB().Select("name").Where("id = ?", id).Find(&tmp)
221
 			tx.Commit()
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
 	//查记录x2
232
 	//查记录x2
233
 	var history models.DepositHistory
233
 	var history models.DepositHistory
234
 	var detmp models.Deposit
234
 	var detmp models.Deposit
240
 	if err != nil {
240
 	if err != nil {
241
 		return
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
 	err = tx.Model(&models.Deposit{}).Where("id = ? and status = 1", detmp.ID).Updates(map[string]interface{}{
253
 	err = tx.Model(&models.Deposit{}).Where("id = ? and status = 1", detmp.ID).Updates(map[string]interface{}{
245
 		"mtime":   time.Now().Unix(),
254
 		"mtime":   time.Now().Unix(),
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
 	s := "status = 1 and trial_status = 1 and user_org_id = ? and his_patient_id = ? and mtime >= ? and mtime <= ?"
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
 	if deposit_status != 0 {
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
 	return
301
 	return
292
 }
302
 }
293
 
303
 
298
 	if len(keyword) > 0 {
308
 	if len(keyword) > 0 {
299
 		db = db.Where(" his_patient_id = ? ", keyword)
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
 	return
312
 	return
303
 }
313
 }
304
 
314
 
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
 	tmp := models.HisChargeSettleOrder{}
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
 	return decimal.NewFromFloat(tmp.MedfeeSumamt)
337
 	return decimal.NewFromFloat(tmp.MedfeeSumamt)
327
 }
338
 }
328
 
339
 
329
 //根据就诊号查询出医收费类型
340
 //根据就诊号查询出医收费类型
330
 func CodeToChargetype(orgid int64, code string) (s string) {
341
 func CodeToChargetype(orgid int64, code string) (s string) {
331
 	tmp := models.HisPrintPatient{}
342
 	tmp := models.HisPrintPatient{}
343
+	tmp_hhcr := models.HisHospitalCheckRecordTwo{}
332
 	XTReadDB().Model(&models.HisPrintPatient{}).Where("number = ? and user_org_id = ?", code, orgid).Find(&tmp)
344
 	XTReadDB().Model(&models.HisPrintPatient{}).Where("number = ? and user_org_id = ?", code, orgid).Find(&tmp)
333
 	//tmp.BalanceAccountsType
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
 	switch tmp.BalanceAccountsType {
350
 	switch tmp.BalanceAccountsType {
335
 	case 1:
351
 	case 1:
336
 		s = "医保"
352
 		s = "医保"
351
 	default:
367
 	default:
352
 		s = "类型未定义"
368
 		s = "类型未定义"
353
 	}
369
 	}
370
+
354
 	return
371
 	return
355
 }
372
 }
356
 
373
 
430
 	tmp := models.Deposit{}
447
 	tmp := models.Deposit{}
431
 	err = tx.Model(&models.Deposit{}).Where("his_patient_id = ? and user_org_id = ? and status = 1", his_patient_id, orgid).Find(&tmp).Error
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
 	if err != nil {
449
 	if err != nil {
450
+		if err.Error() == "record not found" {
451
+			err = fmt.Errorf("没有可退押金,保存失败")
452
+		}
433
 		return
453
 		return
434
 	}
454
 	}
435
 	//判断是否可以退款
455
 	//判断是否可以退款
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
 	db := XTReadDB().Model(&models.DepositHistory{}).Where("status = 1 and user_org_id = ? ", orgid).Where("ctime >= ? and ctime <= ?", stime, etime)
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
 	switch refundtype {
665
 	switch refundtype {
645
 	case 0:
666
 	case 0:
670
 		keyword = "%" + keyword + "%"
691
 		keyword = "%" + keyword + "%"
671
 		db = db.Where(tmp, keyword)
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
 	return
695
 	return
675
 
696
 
676
 }
697
 }
747
 	return tmp.Number
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
 //把其他的类型转换成decimal.Decimal类型
787
 //把其他的类型转换成decimal.Decimal类型
751
 func ToDecimal(i interface{}) (d decimal.Decimal, err error) {
788
 func ToDecimal(i interface{}) (d decimal.Decimal, err error) {
752
 	switch i.(type) {
789
 	switch i.(type) {
763
 	}
800
 	}
764
 	return
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 查看文件

271
 	err = readDb.Model(&models.HisHospitalCheckRecord{}).Where("id = ? AND status = 1", id).First(&record).Error
271
 	err = readDb.Model(&models.HisHospitalCheckRecord{}).Where("id = ? AND status = 1", id).First(&record).Error
272
 	return
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
 func GetInHospitalRecordByNumber(number string) (record models.HisHospitalCheckRecord, err error) {
279
 func GetInHospitalRecordByNumber(number string) (record models.HisHospitalCheckRecord, err error) {
276
 	err = readDb.Model(&models.HisHospitalCheckRecord{}).Where("number = ? AND status = 1", number).First(&record).Error
280
 	err = readDb.Model(&models.HisHospitalCheckRecord{}).Where("number = ? AND status = 1", number).First(&record).Error

+ 4 - 0
service/his_service.go 查看文件

1249
 	err = writeDb.Save(&order).Error
1249
 	err = writeDb.Save(&order).Error
1250
 	return
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
 func UpdataOrderStatusTwo(number string, user_org_id int64) (err error) {
1257
 func UpdataOrderStatusTwo(number string, user_org_id int64) (err error) {
1254
 	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
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 查看文件

593
 }
593
 }
594
 
594
 
595
 func ModifyAdminUserInfo(adminUserID int64, orgID int64, appID int64, name string, avatar string, newPassword string) error {
595
 func ModifyAdminUserInfo(adminUserID int64, orgID int64, appID int64, name string, avatar string, newPassword string) error {
596
+
596
 	tx := writeUserDb.Begin()
597
 	tx := writeUserDb.Begin()
597
 	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
 	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
 	if editInfoErr != nil {
599
 	if editInfoErr != nil {
606
 			return editPwdErr
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
 	tx.Commit()
619
 	tx.Commit()
610
 	return nil
620
 	return nil
611
 }
621
 }

+ 1 - 0
service/self_drug_service.go 查看文件

551
 	Dose                  float64  `gorm:"column:dose" json:"dose" form:"dose"`
551
 	Dose                  float64  `gorm:"column:dose" json:"dose" form:"dose"`
552
 	DoseUnit              string   `gorm:"column:dose_unit" json:"dose_unit" form:"dose_unit"`
552
 	DoseUnit              string   `gorm:"column:dose_unit" json:"dose_unit" form:"dose_unit"`
553
 	MaxUnit               string   `gorm:"column:max_unit" json:"max_unit" form:"max_unit"`
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
 func (Drugs) TableName() string {
557
 func (Drugs) TableName() string {