|
@@ -9,6 +9,7 @@ import (
|
9
|
9
|
"fmt"
|
10
|
10
|
"github.com/astaxie/beego"
|
11
|
11
|
"github.com/shopspring/decimal"
|
|
12
|
+ "strconv"
|
12
|
13
|
"strings"
|
13
|
14
|
"time"
|
14
|
15
|
)
|
|
@@ -18,27 +19,45 @@ type HisDepositApiController struct {
|
18
|
19
|
}
|
19
|
20
|
|
20
|
21
|
func HisDepositApiRegistRouters() {
|
21
|
|
- beego.Router("/api/his/ttt", &HisDepositApiController{}, "get:TTT") //测试接口
|
22
|
|
- beego.Router("/api/his/gethisuser", &HisDepositApiController{}, "get:GetHisUser") //获取病例中心,有效患者名称
|
23
|
|
- beego.Router("/api/his/adddeposit", &HisDepositApiController{}, "post:AddDeposit") //新增押金
|
24
|
|
- beego.Router("/api/his/getdepositcode", &HisDepositApiController{}, "get:GetDepositCode") //获取新增押金编号
|
25
|
|
- beego.Router("/api/his/getdeletecode", &HisDepositApiController{}, "get:GetDeleteCode") //获取退款编号
|
26
|
|
- beego.Router("/api/his/rechargedetails", &HisDepositApiController{}, "get:RechargeDetails") //充值明细列表
|
27
|
|
- beego.Router("/api/his/updeposit", &HisDepositApiController{}, "get:UpDeposit") //审核
|
28
|
|
- beego.Router("/api/his/deletehistory", &HisDepositApiController{}, "get:DeleteHistory") //删除
|
29
|
|
- beego.Router("/api/his/rechargesummary", &HisDepositApiController{}, "get:RechargeSummary") //充值汇总列表
|
30
|
|
- beego.Router("/api/his/getuserlist", &HisDepositApiController{}, "get:GetUserList") //获取患者押金列表
|
31
|
|
- beego.Router("/api/his/depositflow", &HisDepositApiController{}, "get:DepositFlow") //根据患者id获取押金流水
|
32
|
|
-}
|
33
|
|
-func (this *HisDepositApiController) TTT() {
|
34
|
|
- id, _ := this.GetInt64("id")
|
35
|
|
- err := service.DelDecimalHistory(id)
|
36
|
|
- this.ServeSuccessJSON(map[string]interface{}{
|
37
|
|
- "list": err,
|
38
|
|
- })
|
39
|
|
- return
|
|
22
|
+ //beego.Router("/api/his/ttt", &HisDepositApiController{}, "get:TTT") //测试接口
|
|
23
|
+ beego.Router("/api/his/gethisuser", &HisDepositApiController{}, "get:GetHisUser") //获取病例中心,有效患者名称
|
|
24
|
+ beego.Router("/api/his/adddeposit", &HisDepositApiController{}, "post:AddDeposit") //新增押金
|
|
25
|
+ beego.Router("/api/his/getdepositcode", &HisDepositApiController{}, "get:GetDepositCode") //获取新增押金编号
|
|
26
|
+ beego.Router("/api/his/getdeletecode", &HisDepositApiController{}, "get:GetDeleteCode") //获取退款编号
|
|
27
|
+ beego.Router("/api/his/rechargedetails", &HisDepositApiController{}, "get:RechargeDetails") //充值明细列表
|
|
28
|
+ beego.Router("/api/his/updeposit", &HisDepositApiController{}, "get:UpDeposit") //押金审核
|
|
29
|
+ beego.Router("/api/his/deletehistory", &HisDepositApiController{}, "get:DeleteHistory") //押金删除
|
|
30
|
+ beego.Router("/api/his/rechargesummary", &HisDepositApiController{}, "get:RechargeSummary") //充值汇总列表
|
|
31
|
+ beego.Router("/api/his/getuserlist", &HisDepositApiController{}, "get:GetUserList") //获取患者押金列表
|
|
32
|
+ beego.Router("/api/his/depositflow", &HisDepositApiController{}, "get:DepositFlow") //根据患者id获取押金流水
|
|
33
|
+ beego.Router("/api/his/deductiondetails", &HisDepositApiController{}, "get:DeductionDetails") //扣费明细查询
|
|
34
|
+ beego.Router("/api/his/desummary", &HisDepositApiController{}, "get:DeSummary") //扣费汇总
|
|
35
|
+ beego.Router("/api/his/idtobalance", &HisDepositApiController{}, "get:IdToBalance") //根据患者id查询患者的余额
|
|
36
|
+ beego.Router("/api/his/refundapplication", &HisDepositApiController{}, "post:RefundApplication") //新增一条退款申请
|
|
37
|
+ beego.Router("/api/his/refundreview", &HisDepositApiController{}, "get:RefundReview") //退款审核通过/拒绝
|
|
38
|
+ beego.Router("/api/his/deleterefund", &HisDepositApiController{}, "get:DeleteRefund") //退款删除
|
|
39
|
+ beego.Router("/api/his/changerefund", &HisDepositApiController{}, "post:ChangeRefund") //更改退款申请
|
|
40
|
+ beego.Router("/api/his/refundlist", &HisDepositApiController{}, "get:RefundList") //退款分页
|
|
41
|
+ beego.Router("/api/his/getorgname", &HisDepositApiController{}, "get:GetorgName") //获取供应商名字
|
|
42
|
+ beego.Router("/api/his/getweektime", &HisDepositApiController{}, "get:GetWeekTime") //获取本周时间
|
|
43
|
+ beego.Router("/api/his/getmonthtime", &HisDepositApiController{}, "get:GetMonthTime") //获取本月时间
|
40
|
44
|
}
|
41
|
45
|
|
|
46
|
+//func (this *HisDepositApiController) TTT() {
|
|
47
|
+// orgid := this.GetAdminUserInfo().CurrentOrgId
|
|
48
|
+// id, _ := this.GetInt64("id")
|
|
49
|
+// code := this.GetString("code")
|
|
50
|
+// deposit,_ := this.GetInt64("depostit")
|
|
51
|
+// err := service.MoneyIncrease(orgid,id,code,deposit)
|
|
52
|
+// if err != nil {
|
|
53
|
+//
|
|
54
|
+// }
|
|
55
|
+// this.ServeSuccessJSON(map[string]interface{}{
|
|
56
|
+// "list": "成功",
|
|
57
|
+// })
|
|
58
|
+// return
|
|
59
|
+//}
|
|
60
|
+
|
42
|
61
|
//获取病例中心,有效患者名称
|
43
|
62
|
func (this *HisDepositApiController) GetHisUser() {
|
44
|
63
|
orgid := this.GetAdminUserInfo().CurrentOrgId
|
|
@@ -67,19 +86,43 @@ func (this *HisDepositApiController) AddDeposit() {
|
67
|
86
|
case dataBody["code"] == nil:
|
68
|
87
|
this.ServeFailJsonSend(enums.ErrorCodeParamWrong, "押金编号不能为空")
|
69
|
88
|
return
|
70
|
|
- case dataBody["his_patient_id"] == nil:
|
|
89
|
+ case dataBody["his_patient_id"] == nil || dataBody["his_patient_id"] == "":
|
71
|
90
|
this.ServeFailJsonSend(enums.ErrorCodeParamWrong, "患者名称不能为空")
|
72
|
91
|
return
|
73
|
|
- case dataBody["deposit"] == nil:
|
|
92
|
+ case dataBody["deposit"] == nil || dataBody["deposit"] == "":
|
74
|
93
|
this.ServeFailJsonSend(enums.ErrorCodeParamWrong, "押金金额不能为空")
|
75
|
94
|
return
|
76
|
|
- case dataBody["trial_status"] == nil:
|
|
95
|
+ case dataBody["trial_status"] == nil || dataBody["trial_status"] == "":
|
77
|
96
|
this.ServeFailJsonSend(enums.ErrorCodeParamWrong, "审核状态不能为空")
|
78
|
97
|
return
|
79
|
98
|
}
|
80
|
|
- code := dataBody["code"].(string) //押金编号
|
81
|
|
- his_patient_id := int64(dataBody["his_patient_id"].(float64)) //患者编号
|
82
|
|
- deposit := decimal.NewFromFloat(dataBody["deposit"].(float64)) //押金金额
|
|
99
|
+ code := dataBody["code"].(string) //押金编号
|
|
100
|
+ his_patient_id := int64(dataBody["his_patient_id"].(float64)) //患者编号
|
|
101
|
+ var tmps float64
|
|
102
|
+ switch dataBody["deposit"].(type) {
|
|
103
|
+ case string:
|
|
104
|
+ t_deposit := dataBody["deposit"].(string)
|
|
105
|
+ if len(t_deposit) > 0 {
|
|
106
|
+ if t_deposit[0] == 45 {
|
|
107
|
+ this.ServeFailJsonSend(enums.ErrorCodeParamWrong, "押金金额错误")
|
|
108
|
+ return
|
|
109
|
+ }
|
|
110
|
+ }
|
|
111
|
+ tt, errs := strconv.ParseFloat(t_deposit, 64)
|
|
112
|
+ if errs != nil {
|
|
113
|
+ this.ServeFailJsonSend(enums.ErrorCodeParamWrong, "押金金额错误")
|
|
114
|
+ return
|
|
115
|
+ } else {
|
|
116
|
+ tmps = tt
|
|
117
|
+ }
|
|
118
|
+ default:
|
|
119
|
+ tmps = dataBody["deposit"].(float64)
|
|
120
|
+ }
|
|
121
|
+ if tmps == 0 {
|
|
122
|
+ this.ServeFailJsonSend(enums.ErrorCodeParamWrong, "押金金额不能为0")
|
|
123
|
+ return
|
|
124
|
+ }
|
|
125
|
+ deposit := decimal.NewFromFloat(tmps) //押金金额
|
83
|
126
|
var remarks string
|
84
|
127
|
if dataBody["remarks"] == nil {
|
85
|
128
|
remarks = ""
|
|
@@ -149,11 +192,11 @@ func (this *HisDepositApiController) RechargeDetails() {
|
149
|
192
|
|
150
|
193
|
namemap := make(map[int64]string)
|
151
|
194
|
slicekey := make([]int64, 0)
|
|
195
|
+ lists, _ := service.GetHisUser(orgid)
|
|
196
|
+ for _, v := range lists {
|
|
197
|
+ namemap[v.ID] = v.Name
|
|
198
|
+ }
|
152
|
199
|
if len(keyword) > 0 {
|
153
|
|
- list, _ := service.GetHisUser(orgid)
|
154
|
|
- for _, v := range list {
|
155
|
|
- namemap[v.ID] = v.Name
|
156
|
|
- }
|
157
|
200
|
for k, v := range namemap {
|
158
|
201
|
res := strings.Contains(v, keyword)
|
159
|
202
|
if res == true {
|
|
@@ -181,6 +224,8 @@ func (this *HisDepositApiController) RechargeDetails() {
|
181
|
224
|
sum = sum.Add(list[i].Deposit)
|
182
|
225
|
}
|
183
|
226
|
list[i].Name = service.GetCreateidName(list[i].CreateId)
|
|
227
|
+ list[i].HisName = namemap[list[i].HisPatientId]
|
|
228
|
+ list[i].Starttime = fmt.Sprintf(time.Unix(list[i].Ctime, 0).Format("2006-01-02"))
|
184
|
229
|
}
|
185
|
230
|
this.ServeSuccessJSON(map[string]interface{}{
|
186
|
231
|
"list": list,
|
|
@@ -366,6 +411,13 @@ func (this *HisDepositApiController) DepositFlow() {
|
366
|
411
|
this.ServeFailJsonSend(enums.ErrorCodeParamWrong, errs.Error())
|
367
|
412
|
return
|
368
|
413
|
}
|
|
414
|
+ for i := 0; i < len(deposirhistory); i++ {
|
|
415
|
+ //如果为扣费,或退费 则把订单id变为就诊号
|
|
416
|
+ if deposirhistory[i].DepositStatus == 2 || deposirhistory[i].DepositStatus == 4 {
|
|
417
|
+ tmpcode, _ := strconv.ParseInt(deposirhistory[i].DepositCode, 10, 64)
|
|
418
|
+ deposirhistory[i].DepositCode = service.FindcodeToid(tmpcode)
|
|
419
|
+ }
|
|
420
|
+ }
|
369
|
421
|
|
370
|
422
|
this.ServeSuccessJSON(map[string]interface{}{
|
371
|
423
|
"list": deposirhistory,
|
|
@@ -375,7 +427,7 @@ func (this *HisDepositApiController) DepositFlow() {
|
375
|
427
|
return
|
376
|
428
|
}
|
377
|
429
|
|
378
|
|
-//
|
|
430
|
+//获取患者押金列表
|
379
|
431
|
func (this *HisDepositApiController) GetUserList() {
|
380
|
432
|
orgid := this.GetAdminUserInfo().CurrentOrgId
|
381
|
433
|
keyword := this.GetString("keyword")
|
|
@@ -420,6 +472,468 @@ func (this *HisDepositApiController) GetUserList() {
|
420
|
472
|
return
|
421
|
473
|
}
|
422
|
474
|
|
|
475
|
+//扣费明细查询
|
|
476
|
+func (this *HisDepositApiController) DeductionDetails() {
|
|
477
|
+ orgid := this.GetAdminUserInfo().CurrentOrgId
|
|
478
|
+ timeLayout := "2006-01-02"
|
|
479
|
+ loc, _ := time.LoadLocation("Local")
|
|
480
|
+ keyword := this.GetString("keyword")
|
|
481
|
+ start_time := this.GetString("start_time")
|
|
482
|
+ end_time := this.GetString("end_time")
|
|
483
|
+ var stime int64 //开始时间
|
|
484
|
+ var etime int64 //结束时间
|
|
485
|
+
|
|
486
|
+ namemap := make(map[int64]string)
|
|
487
|
+ slicekey := make([]int64, 0)
|
|
488
|
+ lists, _ := service.GetHisUser(orgid)
|
|
489
|
+ for _, v := range lists {
|
|
490
|
+ namemap[v.ID] = v.Name
|
|
491
|
+ }
|
|
492
|
+ if len(keyword) > 0 {
|
|
493
|
+ for k, v := range namemap {
|
|
494
|
+ res := strings.Contains(v, keyword)
|
|
495
|
+ if res == true {
|
|
496
|
+ slicekey = append(slicekey, k)
|
|
497
|
+ }
|
|
498
|
+ }
|
|
499
|
+ }
|
|
500
|
+ if start_time == "" && end_time == "" {
|
|
501
|
+ stime, etime = service.GetMondayOfWeek()
|
|
502
|
+ } else {
|
|
503
|
+ 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)
|
|
505
|
+ stime = stmp.Unix()
|
|
506
|
+ etime = etmp.Unix()
|
|
507
|
+ }
|
|
508
|
+ list, err := service.DeductionList(orgid, stime, etime, keyword, slicekey)
|
|
509
|
+ if err != nil {
|
|
510
|
+ utils.ErrorLog(err.Error())
|
|
511
|
+ this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
|
|
512
|
+ return
|
|
513
|
+ }
|
|
514
|
+
|
|
515
|
+ var sum decimal.Decimal
|
|
516
|
+ var detailslist []models.Details
|
|
517
|
+ var details models.Details
|
|
518
|
+ for i := 0; i < len(list); i++ {
|
|
519
|
+ sum = sum.Add(list[i].Deposit)
|
|
520
|
+ tmp_id, _ := strconv.ParseInt(list[i].DepositCode, 10, 64)
|
|
521
|
+ details.ID = tmp_id
|
|
522
|
+ details.Code = service.FindcodeToid(tmp_id)
|
|
523
|
+ details.NameId = list[i].HisPatientId
|
|
524
|
+ details.Name = namemap[list[i].HisPatientId]
|
|
525
|
+ details.Number = service.FindnumberToid(tmp_id)
|
|
526
|
+ details.Decimal = list[i].Deposit
|
|
527
|
+ 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)
|
|
529
|
+ details.Total = service.MedicalTotal(orgid, list[i].HisPatientId, details.Code)
|
|
530
|
+ detailslist = append(detailslist, details)
|
|
531
|
+ }
|
|
532
|
+
|
|
533
|
+ this.ServeSuccessJSON(map[string]interface{}{
|
|
534
|
+ "list": detailslist,
|
|
535
|
+ "sum": sum,
|
|
536
|
+ })
|
|
537
|
+ return
|
|
538
|
+}
|
|
539
|
+
|
|
540
|
+//扣费汇总
|
|
541
|
+func (this *HisDepositApiController) DeSummary() {
|
|
542
|
+ orgid := this.GetAdminUserInfo().CurrentOrgId
|
|
543
|
+ timeLayout := "2006-01-02"
|
|
544
|
+ loc, _ := time.LoadLocation("Local")
|
|
545
|
+ keyword := this.GetString("keyword")
|
|
546
|
+ start_time := this.GetString("start_time")
|
|
547
|
+ end_time := this.GetString("end_time")
|
|
548
|
+ var stime int64 //开始时间
|
|
549
|
+ var etime int64 //结束时间
|
|
550
|
+
|
|
551
|
+ namemap := make(map[int64]string)
|
|
552
|
+ slicekey := make([]int64, 0)
|
|
553
|
+ lists, _ := service.GetHisUser(orgid)
|
|
554
|
+ for _, v := range lists {
|
|
555
|
+ namemap[v.ID] = v.Name
|
|
556
|
+ }
|
|
557
|
+ if len(keyword) > 0 {
|
|
558
|
+ for k, v := range namemap {
|
|
559
|
+ res := strings.Contains(v, keyword)
|
|
560
|
+ if res == true {
|
|
561
|
+ slicekey = append(slicekey, k)
|
|
562
|
+ }
|
|
563
|
+ }
|
|
564
|
+ }
|
|
565
|
+ if start_time == "" && end_time == "" {
|
|
566
|
+ stime, etime = service.GetMondayOfWeek()
|
|
567
|
+ } else {
|
|
568
|
+ 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)
|
|
570
|
+ stime = stmp.Unix()
|
|
571
|
+ etime = etmp.Unix()
|
|
572
|
+ }
|
|
573
|
+ list, err := service.DeductionList(orgid, stime, etime, keyword, slicekey)
|
|
574
|
+ if err != nil {
|
|
575
|
+ utils.ErrorLog(err.Error())
|
|
576
|
+ this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
|
|
577
|
+ return
|
|
578
|
+ }
|
|
579
|
+ var sum decimal.Decimal
|
|
580
|
+ var detailslist []models.DeductionSummary
|
|
581
|
+ var details models.DeductionSummary
|
|
582
|
+ for i := 0; i < len(list); i++ {
|
|
583
|
+ sum = sum.Add(list[i].Deposit)
|
|
584
|
+ details.Name = namemap[list[i].HisPatientId]
|
|
585
|
+ details.Decimal = list[i].Deposit
|
|
586
|
+ details.Total = service.MedicalTotal(orgid, list[i].HisPatientId, list[i].DepositCode)
|
|
587
|
+ detailslist = append(detailslist, details)
|
|
588
|
+ }
|
|
589
|
+ maplist := make(map[string]models.DeductionSummary)
|
|
590
|
+ Finlist := []models.DeductionSummary{}
|
|
591
|
+ tmpslice := make([]string, 0)
|
|
592
|
+ for i := 0; i < len(detailslist); i++ {
|
|
593
|
+ if k, ok := maplist[detailslist[i].Name]; ok {
|
|
594
|
+ k.Total = k.Total.Add(detailslist[i].Total)
|
|
595
|
+ k.Decimal = k.Decimal.Add(detailslist[i].Decimal)
|
|
596
|
+ maplist[detailslist[i].Name] = models.DeductionSummary{
|
|
597
|
+ detailslist[i].Name,
|
|
598
|
+ k.Total,
|
|
599
|
+ k.Decimal,
|
|
600
|
+ }
|
|
601
|
+ } else {
|
|
602
|
+ maplist[detailslist[i].Name] = models.DeductionSummary{
|
|
603
|
+ detailslist[i].Name,
|
|
604
|
+ detailslist[i].Total,
|
|
605
|
+ detailslist[i].Decimal,
|
|
606
|
+ }
|
|
607
|
+ tmpslice = append(tmpslice, detailslist[i].Name)
|
|
608
|
+ }
|
|
609
|
+ }
|
|
610
|
+ for i := 0; i < len(tmpslice); i++ {
|
|
611
|
+ Finlist = append(Finlist, maplist[tmpslice[i]])
|
|
612
|
+ }
|
|
613
|
+ this.ServeSuccessJSON(map[string]interface{}{
|
|
614
|
+ "list": detailslist,
|
|
615
|
+ "sum": sum,
|
|
616
|
+ })
|
|
617
|
+ return
|
|
618
|
+}
|
|
619
|
+
|
|
620
|
+//根据患者id查询患者的余额
|
|
621
|
+func (this *HisDepositApiController) IdToBalance() {
|
|
622
|
+ check := map[string][]string{
|
|
623
|
+ "his_patient_id": {"must", "int", "his_patient_id"},
|
|
624
|
+ }
|
|
625
|
+ _, err := checks(this, &check)
|
|
626
|
+ if err != nil {
|
|
627
|
+ this.ServeFailJsonSend(enums.ErrorCodeParamWrong, err.Error())
|
|
628
|
+ return
|
|
629
|
+ }
|
|
630
|
+ orgid := this.GetAdminUserInfo().CurrentOrgId
|
|
631
|
+ his_patient_id, _ := this.GetInt64("his_patient_id")
|
|
632
|
+ tmp := service.GetUserMoney(his_patient_id, orgid)
|
|
633
|
+ this.ServeSuccessJSON(map[string]interface{}{
|
|
634
|
+ "list": tmp,
|
|
635
|
+ })
|
|
636
|
+ return
|
|
637
|
+}
|
|
638
|
+
|
|
639
|
+//新增一条退款申请
|
|
640
|
+func (this *HisDepositApiController) RefundApplication() {
|
|
641
|
+ orgid := this.GetAdminUserInfo().CurrentOrgId
|
|
642
|
+ createid := this.GetAdminUserInfo().AdminUser.Id
|
|
643
|
+ dataBody := make(map[string]interface{}, 0)
|
|
644
|
+ err := json.Unmarshal(this.Ctx.Input.RequestBody, &dataBody)
|
|
645
|
+ if err != nil {
|
|
646
|
+ utils.ErrorLog(err.Error())
|
|
647
|
+ this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
|
|
648
|
+ return
|
|
649
|
+ }
|
|
650
|
+ switch {
|
|
651
|
+ case dataBody["code"] == nil:
|
|
652
|
+ this.ServeFailJsonSend(enums.ErrorCodeParamWrong, "申请编号不能为空")
|
|
653
|
+ return
|
|
654
|
+ case dataBody["his_patient_id"] == nil:
|
|
655
|
+ this.ServeFailJsonSend(enums.ErrorCodeParamWrong, "患者名称不能为空")
|
|
656
|
+ return
|
|
657
|
+ case dataBody["deposit"] == nil || dataBody["deposit"] == "":
|
|
658
|
+ this.ServeFailJsonSend(enums.ErrorCodeParamWrong, "退款金额不能为空")
|
|
659
|
+ return
|
|
660
|
+ case dataBody["trial_status"] == nil:
|
|
661
|
+ this.ServeFailJsonSend(enums.ErrorCodeParamWrong, "审核状态不能为空")
|
|
662
|
+ return
|
|
663
|
+ }
|
|
664
|
+ code := dataBody["code"].(string) //申请编号
|
|
665
|
+ his_patient_id := int64(dataBody["his_patient_id"].(float64)) //患者编号
|
|
666
|
+ //deposit := decimal.NewFromFloat(dataBody["deposit"].(float64)) //退款金额
|
|
667
|
+ var tmps float64
|
|
668
|
+ switch dataBody["deposit"].(type) {
|
|
669
|
+ case string:
|
|
670
|
+ t_deposit := dataBody["deposit"].(string)
|
|
671
|
+ if len(t_deposit) > 0 {
|
|
672
|
+ if t_deposit[0] == 45 {
|
|
673
|
+ this.ServeFailJsonSend(enums.ErrorCodeParamWrong, "退款金额错误")
|
|
674
|
+ return
|
|
675
|
+ }
|
|
676
|
+ }
|
|
677
|
+ tt, errs := strconv.ParseFloat(t_deposit, 64)
|
|
678
|
+ if errs != nil {
|
|
679
|
+ this.ServeFailJsonSend(enums.ErrorCodeParamWrong, "退款金额错误")
|
|
680
|
+ return
|
|
681
|
+ } else {
|
|
682
|
+ tmps = tt
|
|
683
|
+ }
|
|
684
|
+ default:
|
|
685
|
+ tmps = dataBody["deposit"].(float64)
|
|
686
|
+ }
|
|
687
|
+ if tmps == 0 {
|
|
688
|
+ this.ServeFailJsonSend(enums.ErrorCodeParamWrong, "退款金额不能为0")
|
|
689
|
+ return
|
|
690
|
+ }
|
|
691
|
+ deposit := decimal.NewFromFloat(tmps) //押金金额
|
|
692
|
+ trial_status := int64(dataBody["trial_status"].(float64)) //审核状态
|
|
693
|
+
|
|
694
|
+ err = service.RefundApplication(orgid, his_patient_id, trial_status, createid, code, deposit)
|
|
695
|
+ if err != nil {
|
|
696
|
+ this.ServeFailJsonSend(enums.ErrorCodeParamWrong, err.Error())
|
|
697
|
+ return
|
|
698
|
+ }
|
|
699
|
+ this.ServeSuccessJSON(map[string]interface{}{
|
|
700
|
+ "list": "新增成功",
|
|
701
|
+ })
|
|
702
|
+ return
|
|
703
|
+
|
|
704
|
+}
|
|
705
|
+
|
|
706
|
+//退款审核通过/拒绝
|
|
707
|
+func (this *HisDepositApiController) RefundReview() {
|
|
708
|
+ check := map[string][]string{
|
|
709
|
+ "ids": {"must", "string", "ids"},
|
|
710
|
+ "trial_status": {"must", "int", "trial_status"},
|
|
711
|
+ }
|
|
712
|
+ _, err := checks(this, &check)
|
|
713
|
+ if err != nil {
|
|
714
|
+ this.ServeFailJsonSend(enums.ErrorCodeParamWrong, err.Error())
|
|
715
|
+ return
|
|
716
|
+ }
|
|
717
|
+ orgid := this.GetAdminUserInfo().CurrentOrgId
|
|
718
|
+ ids := this.GetString("ids") //很多id
|
|
719
|
+
|
|
720
|
+ trial_status, _ := this.GetInt64("trial_status")
|
|
721
|
+ if trial_status != 1 && trial_status != 2 {
|
|
722
|
+ this.ServeFailJsonSend(enums.ErrorCodeParamWrong, "参数trial_status值错误")
|
|
723
|
+ return
|
|
724
|
+ }
|
|
725
|
+ err = service.RefundReviewMore(orgid, trial_status, ids)
|
|
726
|
+ if err != nil {
|
|
727
|
+ this.ServeFailJsonSend(enums.ErrorCodeParamWrong, err.Error())
|
|
728
|
+ return
|
|
729
|
+ }
|
|
730
|
+ var tmplist string
|
|
731
|
+ if trial_status == 1 {
|
|
732
|
+ tmplist = "审核通过"
|
|
733
|
+ } else {
|
|
734
|
+ tmplist = "审核拒绝"
|
|
735
|
+ }
|
|
736
|
+ this.ServeSuccessJSON(map[string]interface{}{
|
|
737
|
+ "list": tmplist,
|
|
738
|
+ })
|
|
739
|
+ return
|
|
740
|
+}
|
|
741
|
+
|
|
742
|
+//退款删除
|
|
743
|
+func (this *HisDepositApiController) DeleteRefund() {
|
|
744
|
+ check := map[string][]string{
|
|
745
|
+ "id": {"must", "int", "id"},
|
|
746
|
+ }
|
|
747
|
+ _, err := checks(this, &check)
|
|
748
|
+ if err != nil {
|
|
749
|
+ this.ServeFailJsonSend(enums.ErrorCodeParamWrong, err.Error())
|
|
750
|
+ return
|
|
751
|
+ }
|
|
752
|
+ orgid := this.GetAdminUserInfo().CurrentOrgId
|
|
753
|
+ id, _ := this.GetInt64("id")
|
|
754
|
+ err = service.DeleteRefund(orgid, id)
|
|
755
|
+ if err != nil {
|
|
756
|
+ this.ServeFailJsonSend(enums.ErrorCodeParamWrong, err.Error())
|
|
757
|
+ return
|
|
758
|
+ }
|
|
759
|
+ this.ServeSuccessJSON(map[string]interface{}{
|
|
760
|
+ "list": "删除成功",
|
|
761
|
+ })
|
|
762
|
+ return
|
|
763
|
+}
|
|
764
|
+
|
|
765
|
+//更改退款申请
|
|
766
|
+func (this *HisDepositApiController) ChangeRefund() {
|
|
767
|
+ orgid := this.GetAdminUserInfo().CurrentOrgId
|
|
768
|
+ dataBody := make(map[string]interface{}, 0)
|
|
769
|
+ err := json.Unmarshal(this.Ctx.Input.RequestBody, &dataBody)
|
|
770
|
+ if err != nil {
|
|
771
|
+ utils.ErrorLog(err.Error())
|
|
772
|
+ this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
|
|
773
|
+ return
|
|
774
|
+ }
|
|
775
|
+ switch {
|
|
776
|
+ case dataBody["id"] == nil:
|
|
777
|
+ this.ServeFailJsonSend(enums.ErrorCodeParamWrong, "id不能为空")
|
|
778
|
+ return
|
|
779
|
+ case dataBody["code"] == nil:
|
|
780
|
+ this.ServeFailJsonSend(enums.ErrorCodeParamWrong, "申请编号不能为空")
|
|
781
|
+ return
|
|
782
|
+ case dataBody["his_patient_id"] == nil:
|
|
783
|
+ this.ServeFailJsonSend(enums.ErrorCodeParamWrong, "患者名称不能为空")
|
|
784
|
+ return
|
|
785
|
+ case dataBody["deposit"] == nil || dataBody["deposit"] == "":
|
|
786
|
+ this.ServeFailJsonSend(enums.ErrorCodeParamWrong, "退款金额不能为空")
|
|
787
|
+ return
|
|
788
|
+ case dataBody["trial_status"] == nil:
|
|
789
|
+ this.ServeFailJsonSend(enums.ErrorCodeParamWrong, "审核状态不能为空")
|
|
790
|
+ return
|
|
791
|
+ }
|
|
792
|
+ id := int64(dataBody["id"].(float64))
|
|
793
|
+ code := dataBody["code"].(string) //申请编号
|
|
794
|
+ his_patient_id := int64(dataBody["his_patient_id"].(float64)) //患者编号
|
|
795
|
+ //deposit := decimal.NewFromFloat(dataBody["deposit"].(float64)) //退款金额
|
|
796
|
+ var tmps float64
|
|
797
|
+ switch dataBody["deposit"].(type) {
|
|
798
|
+ case string:
|
|
799
|
+ t_deposit := dataBody["deposit"].(string)
|
|
800
|
+ if len(t_deposit) > 0 {
|
|
801
|
+ if t_deposit[0] == 45 {
|
|
802
|
+ this.ServeFailJsonSend(enums.ErrorCodeParamWrong, "退款金额错误")
|
|
803
|
+ return
|
|
804
|
+ }
|
|
805
|
+ }
|
|
806
|
+ tt, errs := strconv.ParseFloat(t_deposit, 64)
|
|
807
|
+ if errs != nil {
|
|
808
|
+ this.ServeFailJsonSend(enums.ErrorCodeParamWrong, "退款金额错误")
|
|
809
|
+ return
|
|
810
|
+ } else {
|
|
811
|
+ tmps = tt
|
|
812
|
+ }
|
|
813
|
+ default:
|
|
814
|
+ tmps = dataBody["deposit"].(float64)
|
|
815
|
+ }
|
|
816
|
+ if tmps == 0 {
|
|
817
|
+ this.ServeFailJsonSend(enums.ErrorCodeParamWrong, "退款金额不能为0")
|
|
818
|
+ return
|
|
819
|
+ }
|
|
820
|
+ deposit := decimal.NewFromFloat(tmps) //押金金额
|
|
821
|
+ trial_status := int64(dataBody["trial_status"].(float64)) //审核状态
|
|
822
|
+ err = service.ChangeRefund(orgid, his_patient_id, trial_status, id, code, deposit)
|
|
823
|
+ if err != nil {
|
|
824
|
+ this.ServeFailJsonSend(enums.ErrorCodeParamWrong, err.Error())
|
|
825
|
+ return
|
|
826
|
+ }
|
|
827
|
+ this.ServeSuccessJSON(map[string]interface{}{
|
|
828
|
+ "list": "保存成功",
|
|
829
|
+ })
|
|
830
|
+ return
|
|
831
|
+}
|
|
832
|
+
|
|
833
|
+//退款分页
|
|
834
|
+func (this *HisDepositApiController) RefundList() {
|
|
835
|
+ check := map[string][]string{
|
|
836
|
+ "refundtype": {"must", "int", "refundtype"},
|
|
837
|
+ "examinetype": {"must", "int", "examinetype"},
|
|
838
|
+ }
|
|
839
|
+ _, err := checks(this, &check)
|
|
840
|
+ if err != nil {
|
|
841
|
+ this.ServeFailJsonSend(enums.ErrorCodeParamWrong, err.Error())
|
|
842
|
+ return
|
|
843
|
+ }
|
|
844
|
+ orgid := this.GetAdminUserInfo().CurrentOrgId
|
|
845
|
+ timeLayout := "2006-01-02"
|
|
846
|
+ loc, _ := time.LoadLocation("Local")
|
|
847
|
+ keyword := this.GetString("keyword") //获取搜索框
|
|
848
|
+ refundtype, _ := this.GetInt64("refundtype") //获取退款类型
|
|
849
|
+ examinetype, _ := this.GetInt64("examinetype") //获取审核状态
|
|
850
|
+ start_time := this.GetString("start_time")
|
|
851
|
+ end_time := this.GetString("end_time")
|
|
852
|
+ var stime int64 //开始时间
|
|
853
|
+ var etime int64 //结束时间
|
|
854
|
+
|
|
855
|
+ namemap := make(map[int64]string)
|
|
856
|
+ slicekey := make([]int64, 0)
|
|
857
|
+ lists, _ := service.GetHisUser(orgid)
|
|
858
|
+ for _, v := range lists {
|
|
859
|
+ namemap[v.ID] = v.Name
|
|
860
|
+ }
|
|
861
|
+ if len(keyword) > 0 {
|
|
862
|
+ for k, v := range namemap {
|
|
863
|
+ res := strings.Contains(v, keyword)
|
|
864
|
+ if res == true {
|
|
865
|
+ slicekey = append(slicekey, k)
|
|
866
|
+ }
|
|
867
|
+ }
|
|
868
|
+ }
|
|
869
|
+ if start_time == "" && end_time == "" {
|
|
870
|
+ stime, etime = service.GetMondayOfWeek()
|
|
871
|
+ } else {
|
|
872
|
+ 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)
|
|
874
|
+ stime = stmp.Unix()
|
|
875
|
+ etime = etmp.Unix()
|
|
876
|
+ }
|
|
877
|
+ depo := []models.RefundList{}
|
|
878
|
+ depo, err = service.RefundList(orgid, stime, etime, refundtype, examinetype, keyword, slicekey)
|
|
879
|
+ if err != nil {
|
|
880
|
+ utils.ErrorLog("查询失败,原因为:", err.Error())
|
|
881
|
+ this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
|
|
882
|
+ return
|
|
883
|
+ }
|
|
884
|
+ for i := 0; i < len(depo); i++ {
|
|
885
|
+ depo[i].Name = service.GetCreateidName(depo[i].CreateId)
|
|
886
|
+ depo[i].HisName = namemap[depo[i].HisPatientId]
|
|
887
|
+ if depo[i].Mtime > depo[i].Ctime {
|
|
888
|
+ depo[i].Starttime = fmt.Sprintf(time.Unix(depo[i].Mtime, 0).Format("2006-01-02 15:04:05"))
|
|
889
|
+ } else {
|
|
890
|
+ depo[i].Starttime = fmt.Sprintf(time.Unix(depo[i].Ctime, 0).Format("2006-01-02 15:04:05"))
|
|
891
|
+ }
|
|
892
|
+ if depo[i].DepositStatus == 4 {
|
|
893
|
+ depo[i].Name = "-"
|
|
894
|
+ }
|
|
895
|
+ }
|
|
896
|
+ this.ServeSuccessJSON(map[string]interface{}{
|
|
897
|
+ "list": depo,
|
|
898
|
+ })
|
|
899
|
+ return
|
|
900
|
+}
|
|
901
|
+
|
|
902
|
+func (this *HisDepositApiController) GetorgName() {
|
|
903
|
+ orgid := this.GetAdminUserInfo().CurrentOrgId
|
|
904
|
+ name := service.GetorgName(orgid)
|
|
905
|
+ this.ServeSuccessJSON(map[string]interface{}{
|
|
906
|
+ "list": name,
|
|
907
|
+ })
|
|
908
|
+ return
|
|
909
|
+}
|
|
910
|
+
|
|
911
|
+//获取本月时间
|
|
912
|
+func (this *HisDepositApiController) GetMonthTime() {
|
|
913
|
+ stime, etime := service.GetMonth()
|
|
914
|
+ srart_time := fmt.Sprintf(time.Unix(stime, 0).Format("2006-01-02"))
|
|
915
|
+ end_time := fmt.Sprintf(time.Unix(etime, 0).Format("2006-01-02"))
|
|
916
|
+
|
|
917
|
+ this.ServeSuccessJSON(map[string]interface{}{
|
|
918
|
+ "srart_time": srart_time,
|
|
919
|
+ "end_time": end_time,
|
|
920
|
+ })
|
|
921
|
+ return
|
|
922
|
+}
|
|
923
|
+
|
|
924
|
+//获取本周时间
|
|
925
|
+func (this *HisDepositApiController) GetWeekTime() {
|
|
926
|
+ stime, etime := service.GetMondayOfWeek()
|
|
927
|
+ srart_time := fmt.Sprintf(time.Unix(stime, 0).Format("2006-01-02"))
|
|
928
|
+ end_time := fmt.Sprintf(time.Unix(etime, 0).Format("2006-01-02"))
|
|
929
|
+
|
|
930
|
+ this.ServeSuccessJSON(map[string]interface{}{
|
|
931
|
+ "srart_time": srart_time,
|
|
932
|
+ "end_time": end_time,
|
|
933
|
+ })
|
|
934
|
+ return
|
|
935
|
+}
|
|
936
|
+
|
423
|
937
|
//判断前端参数是否为空
|
424
|
938
|
func checks(this *HisDepositApiController, m *map[string][]string) (map[string]string, error) {
|
425
|
939
|
tmp := make(map[string]string)
|