|
@@ -2,7 +2,9 @@ package controllers
|
2
|
2
|
|
3
|
3
|
import (
|
4
|
4
|
"XT_New/enums"
|
|
5
|
+ "XT_New/models"
|
5
|
6
|
"XT_New/service"
|
|
7
|
+ "XT_New/utils"
|
6
|
8
|
"github.com/astaxie/beego"
|
7
|
9
|
"time"
|
8
|
10
|
)
|
|
@@ -18,6 +20,168 @@ func HisChargeApiRegistRouters() {
|
18
|
20
|
beego.Router("/api/his/inspectionlist/get", &HisChargeApiController{}, "get:GetHisInspectionList")
|
19
|
21
|
beego.Router("/api/his/inspectioninfo/get", &HisChargeApiController{}, "get:GetHisInspectionInfo")
|
20
|
22
|
|
|
23
|
+ //发票
|
|
24
|
+ beego.Router("/api/fapiao/create", &HisChargeApiController{}, "post:CreateFaPiaoRecord")
|
|
25
|
+ beego.Router("/api/fapiao/modify", &HisChargeApiController{}, "post:ModifyFaPiaoRecord")
|
|
26
|
+ beego.Router("/api/fapiao/list", &HisChargeApiController{}, "get:GetFaPiaoRecordList")
|
|
27
|
+ beego.Router("/api/fapiao/delete", &HisChargeApiController{}, "post:DeleteFaPiaoRecord")
|
|
28
|
+ beego.Router("/api/fapiao", &HisChargeApiController{}, "get:GetFaPiaoRecord")
|
|
29
|
+ beego.Router("/api/fapiao/is_use", &HisChargeApiController{}, "post:UpdateFaPiaoRecordIsUse")
|
|
30
|
+
|
|
31
|
+}
|
|
32
|
+
|
|
33
|
+func (c *HisChargeApiController) UpdateFaPiaoRecordIsUse() {
|
|
34
|
+ id, _ := c.GetInt64("id", 0)
|
|
35
|
+ is_use, _ := c.GetInt64("is_use")
|
|
36
|
+ if id <= 0 {
|
|
37
|
+ utils.ErrorLog("id == 0")
|
|
38
|
+ c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
|
|
39
|
+ return
|
|
40
|
+ }
|
|
41
|
+
|
|
42
|
+ record, _ := service.FindFapiaoById(id)
|
|
43
|
+ adminUserInfo := c.GetAdminUserInfo()
|
|
44
|
+ service.UpdateFapiaoIsUse(adminUserInfo.CurrentOrgId)
|
|
45
|
+ records := models.HisFapiaoRecord{
|
|
46
|
+ ID: id,
|
|
47
|
+ FapiaoCode: record.FapiaoCode,
|
|
48
|
+ FapiaoNumber: record.FapiaoNumber,
|
|
49
|
+ Ctime: time.Now().Unix(),
|
|
50
|
+ Mtime: time.Now().Unix(),
|
|
51
|
+ UserOrgId: adminUserInfo.CurrentOrgId,
|
|
52
|
+ Status: 1,
|
|
53
|
+ IsUse: is_use,
|
|
54
|
+ }
|
|
55
|
+ err := service.ModifyFapiao(&records)
|
|
56
|
+ if err == nil {
|
|
57
|
+ c.ServeSuccessJSON(map[string]interface{}{
|
|
58
|
+ "fapiao_record": records,
|
|
59
|
+ })
|
|
60
|
+ } else {
|
|
61
|
+ c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
|
|
62
|
+ }
|
|
63
|
+}
|
|
64
|
+func (c *HisChargeApiController) CreateFaPiaoRecord() {
|
|
65
|
+ fapiao_code := c.GetString("fapiao_code")
|
|
66
|
+ fapiao_number := c.GetString("fapiao_number")
|
|
67
|
+ if len(fapiao_code) <= 0 {
|
|
68
|
+ utils.ErrorLog("len(fapiao_code) == 0")
|
|
69
|
+
|
|
70
|
+ c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
|
|
71
|
+ return
|
|
72
|
+ }
|
|
73
|
+
|
|
74
|
+ if len(fapiao_number) <= 0 {
|
|
75
|
+ utils.ErrorLog("len(fapiao_number) == 0")
|
|
76
|
+ c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
|
|
77
|
+ return
|
|
78
|
+ }
|
|
79
|
+
|
|
80
|
+ adminUserInfo := c.GetAdminUserInfo()
|
|
81
|
+
|
|
82
|
+ record := models.HisFapiaoRecord{
|
|
83
|
+ FapiaoCode: fapiao_code,
|
|
84
|
+ FapiaoNumber: fapiao_number,
|
|
85
|
+ Ctime: time.Now().Unix(),
|
|
86
|
+ Mtime: time.Now().Unix(),
|
|
87
|
+ UserOrgId: adminUserInfo.CurrentOrgId,
|
|
88
|
+ Status: 1,
|
|
89
|
+ IsUse: 0,
|
|
90
|
+ }
|
|
91
|
+
|
|
92
|
+ err, records := service.AddSigleFapiaoRecord(&record)
|
|
93
|
+ if err == nil {
|
|
94
|
+ c.ServeSuccessJSON(map[string]interface{}{
|
|
95
|
+ "fapiao_record": records,
|
|
96
|
+ })
|
|
97
|
+
|
|
98
|
+ } else {
|
|
99
|
+ c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
|
|
100
|
+
|
|
101
|
+ }
|
|
102
|
+
|
|
103
|
+}
|
|
104
|
+func (c *HisChargeApiController) ModifyFaPiaoRecord() {
|
|
105
|
+ id, _ := c.GetInt64("id", 0)
|
|
106
|
+ fapiao_code := c.GetString("fapiao_code")
|
|
107
|
+ fapiao_number := c.GetString("fapiao_number")
|
|
108
|
+
|
|
109
|
+ if id <= 0 {
|
|
110
|
+ utils.ErrorLog("id == 0")
|
|
111
|
+ c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
|
|
112
|
+ return
|
|
113
|
+ }
|
|
114
|
+
|
|
115
|
+ if len(fapiao_code) <= 0 {
|
|
116
|
+ utils.ErrorLog("len(fapiao_code) == 0")
|
|
117
|
+ c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
|
|
118
|
+ return
|
|
119
|
+ }
|
|
120
|
+
|
|
121
|
+ if len(fapiao_number) <= 0 {
|
|
122
|
+ utils.ErrorLog("len(fapiao_number) == 0")
|
|
123
|
+ c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
|
|
124
|
+ return
|
|
125
|
+ }
|
|
126
|
+
|
|
127
|
+ record, _ := service.FindFapiaoById(id)
|
|
128
|
+ adminUserInfo := c.GetAdminUserInfo()
|
|
129
|
+ records := models.HisFapiaoRecord{
|
|
130
|
+ ID: id,
|
|
131
|
+ FapiaoCode: fapiao_code,
|
|
132
|
+ FapiaoNumber: fapiao_number,
|
|
133
|
+ Ctime: time.Now().Unix(),
|
|
134
|
+ Mtime: time.Now().Unix(),
|
|
135
|
+ UserOrgId: adminUserInfo.CurrentOrgId,
|
|
136
|
+ Status: 1,
|
|
137
|
+ IsUse: record.IsUse,
|
|
138
|
+ }
|
|
139
|
+
|
|
140
|
+ err := service.ModifyFapiao(&records)
|
|
141
|
+
|
|
142
|
+ if err == nil {
|
|
143
|
+ c.ServeSuccessJSON(map[string]interface{}{
|
|
144
|
+ "fapiao_record": records,
|
|
145
|
+ })
|
|
146
|
+ } else {
|
|
147
|
+ c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
|
|
148
|
+ }
|
|
149
|
+}
|
|
150
|
+func (c *HisChargeApiController) GetFaPiaoRecordList() {
|
|
151
|
+ page, _ := c.GetInt64("page", 1)
|
|
152
|
+ limit, _ := c.GetInt64("limit", 7)
|
|
153
|
+ adminUserInfo := c.GetAdminUserInfo()
|
|
154
|
+ fapiaoRecord, total, err := service.FindAllFapiaoList(adminUserInfo.CurrentOrgId, page, limit)
|
|
155
|
+ if err == nil {
|
|
156
|
+ c.ServeSuccessJSON(map[string]interface{}{
|
|
157
|
+ "fapiao_record": fapiaoRecord,
|
|
158
|
+ "total": total,
|
|
159
|
+ })
|
|
160
|
+ } else {
|
|
161
|
+ c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
|
|
162
|
+ }
|
|
163
|
+}
|
|
164
|
+func (c *HisChargeApiController) DeleteFaPiaoRecord() {
|
|
165
|
+ id, _ := c.GetInt64("id", 0)
|
|
166
|
+ err := service.DeleteFapiaoById(id)
|
|
167
|
+ if err == nil {
|
|
168
|
+ c.ServeSuccessJSON(map[string]interface{}{
|
|
169
|
+ "msg": "删除成功",
|
|
170
|
+ })
|
|
171
|
+ } else {
|
|
172
|
+ c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
|
|
173
|
+ }
|
|
174
|
+}
|
|
175
|
+func (c *HisChargeApiController) GetFaPiaoRecord() {
|
|
176
|
+ id, _ := c.GetInt64("id", 0)
|
|
177
|
+ fapiaoRecord, err := service.FindFapiaoById(id)
|
|
178
|
+ if err == nil {
|
|
179
|
+ c.ServeSuccessJSON(map[string]interface{}{
|
|
180
|
+ "fapiao_record": fapiaoRecord,
|
|
181
|
+ })
|
|
182
|
+ } else {
|
|
183
|
+ c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
|
|
184
|
+ }
|
21
|
185
|
}
|
22
|
186
|
|
23
|
187
|
func (c *HisChargeApiController) GetChargeStatisticsDetail() {
|