|
@@ -0,0 +1,722 @@
|
|
1
|
+package controllers
|
|
2
|
+
|
|
3
|
+import (
|
|
4
|
+ "encoding/json"
|
|
5
|
+ "strconv"
|
|
6
|
+ "time"
|
|
7
|
+
|
|
8
|
+ "XT_New/enums"
|
|
9
|
+ "XT_New/models"
|
|
10
|
+ "XT_New/service"
|
|
11
|
+ "XT_New/utils"
|
|
12
|
+
|
|
13
|
+ "github.com/astaxie/beego"
|
|
14
|
+ "github.com/jinzhu/gorm"
|
|
15
|
+)
|
|
16
|
+
|
|
17
|
+type StockManagerV3ApiController struct {
|
|
18
|
+ BaseAuthAPIController
|
|
19
|
+}
|
|
20
|
+
|
|
21
|
+func StockManagerV3ApiRegistRouters() {
|
|
22
|
+ // 耗材入库管理
|
|
23
|
+ // 创建入库单
|
|
24
|
+ beego.Router("/v3/api/warehouse/create", &StockManagerV3ApiController{}, "post:CreateWarehouse")
|
|
25
|
+ // 修改入库单
|
|
26
|
+ beego.Router("/v3/api/warehouse/edit", &StockManagerV3ApiController{}, "post:EditWarehouse")
|
|
27
|
+
|
|
28
|
+ // 库存查询
|
|
29
|
+ // 库存明细
|
|
30
|
+ beego.Router("/v3/api/stock/detail", &StockManagerApiController{}, "get:GetWarehouseDetailList")
|
|
31
|
+
|
|
32
|
+ // beego.Router("/api/warehouse/list", &StockManagerApiController{}, "get:GetWarehouseList")
|
|
33
|
+ // beego.Router("/api/warehouse/delete", &StockManagerApiController{}, "post:DeleteWarehouse")
|
|
34
|
+ // beego.Router("/api/warehouseinfo/delete", &StockManagerApiController{}, "post:DeleteWarehouseInfo")
|
|
35
|
+ // beego.Router("/api/warehouseinfo/list", &StockManagerApiController{}, "get:GetWarehouseInfoList")
|
|
36
|
+
|
|
37
|
+ // //退货管理和其他退货管理相关接口
|
|
38
|
+ // beego.Router("/api/salesreturn/create", &StockManagerApiController{}, "post:CreateSalesReturn")
|
|
39
|
+ // beego.Router("/api/salesreturn/delete", &StockManagerApiController{}, "post:DeleteSalesReturn")
|
|
40
|
+ // beego.Router("/api/salesreturninfo/delete", &StockManagerApiController{}, "post:DeleteSalesReturnInfo")
|
|
41
|
+ // beego.Router("/api/salesreturninfo/list", &StockManagerApiController{}, "get:GetSalesReturnInfoList")
|
|
42
|
+ // beego.Router("/api/salesreturn/list", &StockManagerApiController{}, "get:GetSalesReturnList")
|
|
43
|
+ // beego.Router("/api/salesreturn/edit", &StockManagerApiController{}, "post:EditReturnInfo")
|
|
44
|
+
|
|
45
|
+ // //出库管理和其他出库管理相关接口
|
|
46
|
+ // beego.Router("/api/warehouseout/create", &StockManagerApiController{}, "post:CreateWarehouseOut")
|
|
47
|
+ // beego.Router("/api/warehouseout/delete", &StockManagerApiController{}, "post:DeleteWarehouseOut")
|
|
48
|
+ // beego.Router("/api/warehouseoutinfo/delete", &StockManagerApiController{}, "post:DeleteWarehouseOutInfo")
|
|
49
|
+ // beego.Router("/api/warehouseout/list", &StockManagerApiController{}, "get:GetWarehouseOutList")
|
|
50
|
+ // beego.Router("/api/warehouseout/edit", &StockManagerApiController{}, "post:EditWarehouseOut")
|
|
51
|
+ // beego.Router("/api/warehouseout/info", &StockManagerApiController{}, "get:GetWarehouseOutInfoList")
|
|
52
|
+
|
|
53
|
+ // //出库退库管理和其他出库退库管理相关接口
|
|
54
|
+ // beego.Router("/api/cancelstock/create", &StockManagerApiController{}, "post:CreateCancelStock")
|
|
55
|
+ // beego.Router("/api/cancelstock/list", &StockManagerApiController{}, "get:GetCancelStockList")
|
|
56
|
+ // beego.Router("/api/cancelstock/info", &StockManagerApiController{}, "get:GetCancelStockInfoList")
|
|
57
|
+ // beego.Router("/api/cancelstock/delete", &StockManagerApiController{}, "post:DeleteCancelStock")
|
|
58
|
+ // beego.Router("/api/cancelstockinfo/delete", &StockManagerApiController{}, "post:DeleteCancelStockInfo")
|
|
59
|
+ // beego.Router("/api/cancelstockinfo/edit", &StockManagerApiController{}, "post:EditCancelStock")
|
|
60
|
+ // beego.Router("/api/cancelstockinfo/config", &StockManagerApiController{}, "get:GetCancelStockConfig")
|
|
61
|
+
|
|
62
|
+ // //库存相关全局配置
|
|
63
|
+ // beego.Router("/api/stock/config", &StockManagerApiController{}, "get:GetAllConfig")
|
|
64
|
+ // beego.Router("/api/return/config", &StockManagerApiController{}, "get:GetAllSalesReturnConfig")
|
|
65
|
+
|
|
66
|
+ // //库存查询
|
|
67
|
+ // beego.Router("/api/stock/query", &StockManagerApiController{}, "get:GetQueryInfo")
|
|
68
|
+
|
|
69
|
+ // beego.Router("/api/stock/detail", &StockManagerApiController{}, "get:GetDetailInfo")
|
|
70
|
+
|
|
71
|
+ // beego.Router("/api/warehouseout/user", &StockManagerApiController{}, "get:GetUserDetailInfo")
|
|
72
|
+
|
|
73
|
+ // beego.Router("/api/warehouseout/postsearchstock", &StockManagerApiController{}, "Get:PostSearchStock")
|
|
74
|
+
|
|
75
|
+ // beego.Router("/api/warehouseout/getoutstocktotalcount", &StockManagerApiController{}, "Get:GetOutStockTotalCount")
|
|
76
|
+
|
|
77
|
+ // beego.Router("/api/good/postgoodinformation", &StockManagerApiController{}, "Post:AddGoodInformation")
|
|
78
|
+
|
|
79
|
+ // beego.Router("/api/good/postdruginformation", &StockManagerApiController{}, "Post:AddDrugInformation")
|
|
80
|
+
|
|
81
|
+ // beego.Router("/api/good/initializtion", &StockManagerApiController{}, "Get:GetInitializtion")
|
|
82
|
+
|
|
83
|
+ // beego.Router("/api/good/getwarehouseorderinfolist", &StockManagerApiController{}, "Get:GetWarehouseOrderInfolist")
|
|
84
|
+
|
|
85
|
+ // beego.Router("/api/good/postsearchgoodlist", &StockManagerApiController{}, "Get:PostSearchGoodList")
|
|
86
|
+
|
|
87
|
+ // beego.Router("/api/good/getallstocklist", &StockManagerApiController{}, "Get:GetAllStockList")
|
|
88
|
+
|
|
89
|
+ // beego.Router("/api/stock/getstocklistbyid", &StockManagerApiController{}, "Get:GetStockListById")
|
|
90
|
+ // beego.Router("/api/stock/getstockoutlist", &StockManagerApiController{}, "Get:GetStockOutList")
|
|
91
|
+
|
|
92
|
+ // beego.Router("/api/good/getstockdrugcount", &StockManagerApiController{}, "Get:GetStockDrugCount")
|
|
93
|
+
|
|
94
|
+ // beego.Router("/api/good/getorderdetialbyorderid", &StockManagerApiController{}, "Get:GetOrderDetialByOrderId")
|
|
95
|
+ // beego.Router("/api/good/getorderdetaibyid", &StockManagerApiController{}, "Get:GetOrderDetailById")
|
|
96
|
+ // beego.Router("/api/good/getsingleoutorderdetail", &StockManagerApiController{}, "Get:GetSingleOutOrderDetail")
|
|
97
|
+ // beego.Router("/api/stock/getexportstocklist", &StockManagerApiController{}, "Get:GetExprotStockList")
|
|
98
|
+ // beego.Router("/api/stock/getoutexprotlist", &StockManagerApiController{}, "Get:GetOutExprotList")
|
|
99
|
+ // beego.Router("/api/stock/getsinglecancelorder", &StockManagerApiController{}, "Get:GetSingleCancelOrder")
|
|
100
|
+ // beego.Router("/api/stock/getcancelstockorderprint", &StockManagerApiController{}, "Get:GetCancelStockOrderPrint")
|
|
101
|
+ // beego.Router("/api/stock/getstockbatchnumber", &StockManagerApiController{}, "Get:GetStockBatchNumber")
|
|
102
|
+
|
|
103
|
+ // beego.Router("/api/stock/getstockflow", &StockManagerApiController{}, "Get:GetStockFlow")
|
|
104
|
+
|
|
105
|
+ // beego.Router("/api/cancel/getcancelexportlist", &StockManagerApiController{}, "Get:GetCancelExportList")
|
|
106
|
+
|
|
107
|
+ // //耗材调价
|
|
108
|
+ // beego.Router("/api/stock/postsearchgoodwarehouselist", &StockManagerApiController{}, "Get:GetSearchGoodWarehouseList")
|
|
109
|
+ // beego.Router("/api/stock/saveadjustprice", &StockManagerApiController{}, "Post:SaveAdjuestPrice")
|
|
110
|
+ // beego.Router("/api/stock/getallstockprice", &StockManagerApiController{}, "Get:GetAllStockPrice")
|
|
111
|
+ // beego.Router("/api/stock/savecheckedprice", &StockManagerApiController{}, "Get:SaveCheckPrice")
|
|
112
|
+ // beego.Router("/api/stock/getadjustpriceinfo", &StockManagerApiController{}, "Get:GetAdjustPriceById")
|
|
113
|
+ // beego.Router("/api/stock/savereportstock", &StockManagerApiController{}, "Post:SaveReportStock")
|
|
114
|
+ // beego.Router("/api/stock/getreportstocklist", &StockManagerApiController{}, "Get:GetReportStockList")
|
|
115
|
+ // beego.Router("/api/stock/savecheckdamage", &StockManagerApiController{}, "Get:SaveCheckDamage")
|
|
116
|
+ // beego.Router("/api/stock/saveinventory", &StockManagerApiController{}, "Post:SaveInventory")
|
|
117
|
+ // beego.Router("/api/stock/getinventorylist", &StockManagerApiController{}, "Get:GetInventorylist")
|
|
118
|
+ // beego.Router("/api/stock/savecheckinventory", &StockManagerApiController{}, "Get:SaveCheckInventory")
|
|
119
|
+ // beego.Router("/api/stock/getmodifypriceDetail", &StockManagerApiController{}, "Get:GetModifyPriceDetail")
|
|
120
|
+ // beego.Router("/api/stock/updatestockprice", &StockManagerApiController{}, "Get:UpdateStockPrice")
|
|
121
|
+ // beego.Router("/api/stock/deletestockprice", &StockManagerApiController{}, "Get:DeleteStockPrice")
|
|
122
|
+ // beego.Router("/api/stock/getstockdamagedetal", &StockManagerApiController{}, "Get:GetStockDamageDetail")
|
|
123
|
+ // beego.Router("/api/sotck/modifyprice", &StockManagerApiController{}, "Get:ModifyPrice")
|
|
124
|
+ // beego.Router("/api/stock/deletestockdamage", &StockManagerApiController{}, "Get:DeleteDamage")
|
|
125
|
+ // beego.Router("/api/stock/getstockdamagebyid", &StockManagerApiController{}, "Get:GetStockDamageById")
|
|
126
|
+ // beego.Router("api/sotck/getinventorydetail", &StockManagerApiController{}, "Get:GetInventoryDetail")
|
|
127
|
+ // beego.Router("/api/stock/modifyinventory", &StockManagerApiController{}, "Get:ModifyInventory")
|
|
128
|
+ // beego.Router("/api/stock/deleteinventory", &StockManagerApiController{}, "Get:DeleteInventory")
|
|
129
|
+ // beego.Router("/api/stock/getinventorydetaillist", &StockManagerApiController{}, "Get:GetInventoryDetailList")
|
|
130
|
+ // beego.Router("/api/stock/getinventoryprintlist", &StockManagerApiController{}, "Get:GetInventoryPrintList")
|
|
131
|
+ // beego.Router("/api/stock/getinventorydetailprintlist", &StockManagerApiController{}, "Get:GetInventoryDetailPrintList")
|
|
132
|
+ // beego.Router("/api/drug/deletedrugprice", &StockManagerApiController{}, "Get:DeleteDrugPrice")
|
|
133
|
+ // beego.Router("/api/stock/getgoodwarehouselist", &StockManagerApiController{}, "Get:GetGoodWarehouseList")
|
|
134
|
+ // beego.Router("/api/stock/proofinventory", &StockManagerApiController{}, "Get:ProofInventory")
|
|
135
|
+ // beego.Router("/api/stock/getwarehousetotal", &StockManagerApiController{}, "Get:GetWarehouseTotal")
|
|
136
|
+ // beego.Router("/api/stock/getgoodinventorywarehouselist", &StockManagerApiController{}, "Get:GetGoodInventoryWarehouseList")
|
|
137
|
+ // beego.Router("/api/stock/savestockinentorylist", &StockManagerApiController{}, "Post:SaveStockInventoryList")
|
|
138
|
+ // beego.Router("/api/sotck/getdamagedetailbygoodid", &StockManagerApiController{}, "Get:GetDamageDetailByGoodId")
|
|
139
|
+ // beego.Router("/api/stock/getinventoryexportlist", &StockManagerApiController{}, "Get:GetInventoryExportList")
|
|
140
|
+
|
|
141
|
+ // //处理历史数据
|
|
142
|
+ // beego.Router("/api/stock/updatecancelstockorder", &StockManagerApiController{}, "Get:UpdateCancelStockOrder")
|
|
143
|
+
|
|
144
|
+ // beego.Router("/api/stock/getdrugdetailsummary", &StockManagerApiController{}, "Get:GetDrugDetailSummary")
|
|
145
|
+ // beego.Router("/api/stock/getgooddetialsummary", &StockManagerApiController{}, "Get:GetGoodDetailSummary")
|
|
146
|
+
|
|
147
|
+ // //库存优化接口
|
|
148
|
+ // beego.Router("/api/stock/checkwarehouseout", &StockManagerApiController{}, "Get:CheckWarehouseOut")
|
|
149
|
+ // beego.Router("/api/stock/returncheckwarehouseout", &StockManagerApiController{}, "Get:ReturnCheckWarehouseOut")
|
|
150
|
+ // beego.Router("/api/stock/tocheckwarehouseinfo", &StockManagerApiController{}, "Get:CheckWarehouseInfo")
|
|
151
|
+ // beego.Router("/api/stock/returncheckwarehouseinfo", &StockManagerApiController{}, "Get:ReturnCheckWarehouseInfo")
|
|
152
|
+ // beego.Router("/api/stock/checkstockwarehouseinfo", &StockManagerApiController{}, "Get:CheckStockWarehouseInfo")
|
|
153
|
+ // beego.Router("/api/stock/checkreturnstockwarehouseinfo", &StockManagerApiController{}, "Get:CheckReturnStockWarehouseInfo")
|
|
154
|
+ // beego.Router("/api/stock/getprintlist", &StockManagerApiController{}, "Get:GetPrintList")
|
|
155
|
+
|
|
156
|
+ // beego.Router("/api/stock/getwarehouseinfolist", &StockManagerApiController{}, "Get:GetInvetoryWarehouseInfoList")
|
|
157
|
+
|
|
158
|
+ // //结算成功后调用操作库存相关接口
|
|
159
|
+ // beego.Router("/api/settle/stock", &StockManagerApiController{}, "Get:HandleSettleStock")
|
|
160
|
+ // beego.Router("/api/settle/cancelstock", &StockManagerApiController{}, "Get:HandleRefundStock")
|
|
161
|
+
|
|
162
|
+ // beego.Router("/api/stock/getnewgoodwarehouseinfo", &StockManagerApiController{}, "Get:GetNewGoodWarehouseInfo")
|
|
163
|
+ // beego.Router("/api/stock/getnewwarehouseoutinfolist", &StockManagerApiController{}, "Get:GetNewWarehouseOutInfoList")
|
|
164
|
+
|
|
165
|
+ // beego.Router("/api/stock/getstockfloworderlist", &StockManagerApiController{}, "Get:GetStockFlowOrderList")
|
|
166
|
+
|
|
167
|
+ // beego.Router("/api/stock/getgoodpatientname", &StockManagerApiController{}, "Get:GetGoodPatientName")
|
|
168
|
+
|
|
169
|
+ // beego.Router("/api/drug/updatebasedruglisbyuserorgid", &StockManagerApiController{}, "Get:UpdateBaseDrugListByUserOrgID")
|
|
170
|
+
|
|
171
|
+ // beego.Router("/api/good/updategoodinfobyuserorgid", &StockManagerApiController{}, "Get:UpdateGoodInfoByUserOrgId")
|
|
172
|
+
|
|
173
|
+ // beego.Router("/api/good/getgoodstockinventorylist", &StockManagerApiController{}, "Get:GetGoodStockInventoryList")
|
|
174
|
+
|
|
175
|
+ // beego.Router("/api/good/getstockinventoryprintlist", &StockManagerApiController{}, "Get:GetStockInventoryPrintList")
|
|
176
|
+
|
|
177
|
+ // beego.Router("/api/good/getstockinventoymodeprintlist", &StockManagerApiController{}, "Get:GetStockInventoryModePrintList")
|
|
178
|
+}
|
|
179
|
+
|
|
180
|
+type _WarehousingInfoCreateParamModel struct {
|
|
181
|
+ StockIn []*_WarehousingInfoCreateParamStockInModel `json:"stockIn"`
|
|
182
|
+}
|
|
183
|
+
|
|
184
|
+type _WarehousingInfoCreateParamStockInModel struct {
|
|
185
|
+ ID int64 `json:"id"`
|
|
186
|
+ GoodID int64 `json:"good_id"` // 耗材id
|
|
187
|
+ GoodTypeID int64 `json:"good_type_id"`
|
|
188
|
+ WarehousingCount string `json:"warehousing_count"` // 入库数量
|
|
189
|
+ Price string `json:"price"` // 进货价
|
|
190
|
+ PackingPrice string `json:"packing_price"` // 零售价
|
|
191
|
+ ExpiryDate string `json:"expiry_date"` // 过期时间(有效期)2006-01-02
|
|
192
|
+ ProductDate string `json:"product_date"` // 生产日期 2006-01-02
|
|
193
|
+ Number string `json:"number"` // 批号
|
|
194
|
+ Remark string `json:"remark"`
|
|
195
|
+ Manufacturer int64 `json:"manufacturer"` // 生产商
|
|
196
|
+ Dealer int64 `json:"dealer"` // 经销商
|
|
197
|
+ LicenseNumber string `json:"license_number"` // 批准文号
|
|
198
|
+ RegisterNumber string `json:"register_number"` // 注册编号
|
|
199
|
+ GoodCode string `json:"good_code"` // 追溯码
|
|
200
|
+}
|
|
201
|
+
|
|
202
|
+func (c *StockManagerV3ApiController) CreateWarehouse() {
|
|
203
|
+ warehousing_time := c.GetString("warehousing_time") // 入库时间
|
|
204
|
+ stockInOrderType, _ := c.GetInt64("type", 0) // 入库单类型 1.耗材入库单 2.其他入库单(库存管理——其他管理)
|
|
205
|
+ storehouse_id, _ := c.GetInt64("storehouse_id")
|
|
206
|
+ // warehousing_info_id, _ := c.GetInt64("warehousing_info_id") // 入库单ID
|
|
207
|
+ ctime := time.Now().Unix()
|
|
208
|
+ adminUserInfo := c.GetAdminUserInfo()
|
|
209
|
+
|
|
210
|
+ // 校验参数
|
|
211
|
+ warehousingDate, parseDateErr := utils.ParseTimeStringToTime("2006-01-02", warehousing_time)
|
|
212
|
+ if parseDateErr != nil {
|
|
213
|
+ c.ErrorLog("warehousing_time(%v)解析错误:%v", warehousing_time, parseDateErr)
|
|
214
|
+ c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
|
|
215
|
+ return
|
|
216
|
+ }
|
|
217
|
+ if stockInOrderType != 1 && stockInOrderType != 2 {
|
|
218
|
+ c.ErrorLog("入库单类型不存在:type=%v", stockInOrderType)
|
|
219
|
+ c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
|
|
220
|
+ return
|
|
221
|
+ }
|
|
222
|
+ if storehouse_id <= 0 {
|
|
223
|
+ c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
|
|
224
|
+ return
|
|
225
|
+ } else {
|
|
226
|
+ _, getErr := service.FindStoreHouseByStorehouseId(storehouse_id, adminUserInfo.CurrentOrgId)
|
|
227
|
+ if getErr != nil {
|
|
228
|
+ if getErr == gorm.ErrRecordNotFound {
|
|
229
|
+ c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeStoreHouseNotExist)
|
|
230
|
+ return
|
|
231
|
+ } else {
|
|
232
|
+ c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
|
|
233
|
+ return
|
|
234
|
+ }
|
|
235
|
+ }
|
|
236
|
+ }
|
|
237
|
+
|
|
238
|
+ // 开始外部循环的事务
|
|
239
|
+ db := service.XTWriteDB()
|
|
240
|
+ tx := db.Begin()
|
|
241
|
+
|
|
242
|
+ // 在函数结束时处理事务回滚
|
|
243
|
+ defer func() {
|
|
244
|
+ if r := recover(); r != nil {
|
|
245
|
+ tx.Rollback()
|
|
246
|
+ }
|
|
247
|
+ }()
|
|
248
|
+
|
|
249
|
+ warehousingTotalCount, getErr := service.FindNewAllWarehouseTotal(adminUserInfo.CurrentOrgId, tx)
|
|
250
|
+ if getErr != nil {
|
|
251
|
+ utils.ErrorLog("获取入库单数量失败:%v", getErr)
|
|
252
|
+ c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
|
|
253
|
+ return
|
|
254
|
+ }
|
|
255
|
+ warehousingTotalCount = warehousingTotalCount + 1
|
|
256
|
+ timeStr := time.Now().Format("20060102")
|
|
257
|
+ warehousing_order := "RKD" + strconv.FormatInt(adminUserInfo.CurrentOrgId, 10) + timeStr + "000" + strconv.FormatInt(warehousingTotalCount, 10)
|
|
258
|
+ operation_time := time.Now().Unix()
|
|
259
|
+ creater := adminUserInfo.AdminUser.Id
|
|
260
|
+ warehousing := models.Warehousing{
|
|
261
|
+ WarehousingOrder: warehousing_order,
|
|
262
|
+ OperationTime: operation_time,
|
|
263
|
+ OrgId: adminUserInfo.CurrentOrgId,
|
|
264
|
+ Creater: creater,
|
|
265
|
+ Ctime: ctime,
|
|
266
|
+ Mtime: ctime,
|
|
267
|
+ Status: 1,
|
|
268
|
+ WarehousingTime: warehousingDate.Unix(),
|
|
269
|
+ Type: stockInOrderType,
|
|
270
|
+ StorehouseId: storehouse_id,
|
|
271
|
+ IsCheck: 2,
|
|
272
|
+ }
|
|
273
|
+
|
|
274
|
+ createWarehousingErr := service.AddNewSigleWarehouse(&warehousing, tx)
|
|
275
|
+ if createWarehousingErr != nil {
|
|
276
|
+ utils.ErrorLog("新增入库单失败:%v", createWarehousingErr)
|
|
277
|
+ c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
|
|
278
|
+ return
|
|
279
|
+ }
|
|
280
|
+
|
|
281
|
+ // 重新读出刚写入的入库单
|
|
282
|
+ newWarehousing, getWarehousingErr := service.FindWareHouseByIdV3(warehousing.ID)
|
|
283
|
+ if getWarehousingErr != nil {
|
|
284
|
+ tx.Rollback()
|
|
285
|
+ utils.ErrorLog("获取刚写入的入库单(id=%v)失败:%v", warehousing.ID, getWarehousingErr)
|
|
286
|
+ c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
|
|
287
|
+ return
|
|
288
|
+ }
|
|
289
|
+
|
|
290
|
+ var bodyParams _WarehousingInfoCreateParamModel
|
|
291
|
+ jsonErr := json.Unmarshal(c.Ctx.Input.RequestBody, &bodyParams)
|
|
292
|
+ if jsonErr != nil {
|
|
293
|
+ tx.Rollback()
|
|
294
|
+ utils.ErrorLog("解析入库单详情失败:%v", jsonErr.Error())
|
|
295
|
+ c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
|
|
296
|
+ return
|
|
297
|
+ }
|
|
298
|
+ // utils.InfoLog("%v", bodyParams)
|
|
299
|
+
|
|
300
|
+ if len(bodyParams.StockIn) > 0 {
|
|
301
|
+ for _, param := range bodyParams.StockIn {
|
|
302
|
+ productDateTS := int64(0)
|
|
303
|
+ if len(param.ProductDate) > 0 {
|
|
304
|
+ date, parseErr := utils.ParseTimeStringToTime("2006-01-02", param.ProductDate)
|
|
305
|
+ if parseErr == nil {
|
|
306
|
+ productDateTS = date.Unix()
|
|
307
|
+ }
|
|
308
|
+ }
|
|
309
|
+ expireDateTS := int64(0)
|
|
310
|
+ if len(param.ExpiryDate) > 0 {
|
|
311
|
+ date, parseErr := utils.ParseTimeStringToTime("2006-01-02", param.ExpiryDate)
|
|
312
|
+ if parseErr == nil {
|
|
313
|
+ expireDateTS = date.Unix()
|
|
314
|
+ }
|
|
315
|
+ }
|
|
316
|
+ warehousingCount, _ := strconv.ParseInt(param.WarehousingCount, 10, 64)
|
|
317
|
+
|
|
318
|
+ price, parseErr := strconv.ParseFloat(param.Price, 64)
|
|
319
|
+ if parseErr != nil {
|
|
320
|
+ tx.Rollback()
|
|
321
|
+ utils.ErrorLog("入库单详情入库价格格式错误(%v):%v", param.Price, parseErr)
|
|
322
|
+ c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamFormatWrong)
|
|
323
|
+ return
|
|
324
|
+ }
|
|
325
|
+ packingPrice, _ := strconv.ParseFloat(param.PackingPrice, 64)
|
|
326
|
+
|
|
327
|
+ warehouseInfo := &models.WarehousingInfo{
|
|
328
|
+ ID: 0,
|
|
329
|
+ WarehousingOrder: warehousing_order,
|
|
330
|
+ WarehousingId: newWarehousing.ID,
|
|
331
|
+ GoodId: param.GoodID,
|
|
332
|
+ Number: param.Number,
|
|
333
|
+ GoodTypeId: param.GoodTypeID,
|
|
334
|
+ ProductDate: productDateTS,
|
|
335
|
+ ExpiryDate: expireDateTS,
|
|
336
|
+ WarehousingCount: warehousingCount,
|
|
337
|
+ Price: price,
|
|
338
|
+ TotalPrice: float64(warehousingCount) * price,
|
|
339
|
+ Status: 1,
|
|
340
|
+ Ctime: warehousingDate.Unix(),
|
|
341
|
+ Mtime: warehousingDate.Unix(),
|
|
342
|
+ Remark: param.Remark,
|
|
343
|
+ OrgId: adminUserInfo.CurrentOrgId,
|
|
344
|
+ Type: stockInOrderType,
|
|
345
|
+ Manufacturer: param.Manufacturer,
|
|
346
|
+ StockCount: 0,
|
|
347
|
+ Dealer: param.Dealer,
|
|
348
|
+ LicenseNumber: param.LicenseNumber,
|
|
349
|
+ PackingPrice: packingPrice,
|
|
350
|
+ StorehouseId: storehouse_id,
|
|
351
|
+ IsCheck: 2,
|
|
352
|
+ RegisterNumber: param.RegisterNumber,
|
|
353
|
+ GoodCode: param.GoodCode,
|
|
354
|
+ }
|
|
355
|
+
|
|
356
|
+ err := service.CreatedNewWarehouseingDetail(warehouseInfo, tx)
|
|
357
|
+ if err != nil {
|
|
358
|
+ utils.ErrorLog("入库单详情创建失败:%v", err)
|
|
359
|
+ c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
|
|
360
|
+ return
|
|
361
|
+ }
|
|
362
|
+ }
|
|
363
|
+ }
|
|
364
|
+
|
|
365
|
+ // 查询入库数据
|
|
366
|
+ var details []*models.VmWarehousingInfoSix
|
|
367
|
+
|
|
368
|
+ details, getErr = service.GetNewGoodWarehouseInfoById(newWarehousing.ID, newWarehousing.OrgId, tx)
|
|
369
|
+ if getErr != nil && getErr != gorm.ErrRecordNotFound {
|
|
370
|
+ utils.ErrorLog("入库单详情创建——查询详情失败:%v", getErr)
|
|
371
|
+ c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
|
|
372
|
+ return
|
|
373
|
+ }
|
|
374
|
+
|
|
375
|
+ tx.Commit()
|
|
376
|
+
|
|
377
|
+ c.ServeSuccessJSON(map[string]interface{}{
|
|
378
|
+ "msg": "入库成功",
|
|
379
|
+ "warehousing_order": warehousing_order,
|
|
380
|
+ "info": newWarehousing,
|
|
381
|
+ "list": details,
|
|
382
|
+ })
|
|
383
|
+}
|
|
384
|
+
|
|
385
|
+func (c *StockManagerV3ApiController) EditWarehouse() {
|
|
386
|
+ warehousing_time := c.GetString("warehousing_time") // 入库时间
|
|
387
|
+ stockInOrderType, _ := c.GetInt64("type", 0) // 入库单类型 1.耗材入库单 2.其他入库单(库存管理——其他管理)
|
|
388
|
+ storehouse_id, _ := c.GetInt64("storehouse_id")
|
|
389
|
+ warehousing_id, _ := c.GetInt64("id") // 入库单ID
|
|
390
|
+ adminUserInfo := c.GetAdminUserInfo()
|
|
391
|
+
|
|
392
|
+ // 校验参数
|
|
393
|
+ warehousingDate, parseDateErr := utils.ParseTimeStringToTime("2006-01-02", warehousing_time)
|
|
394
|
+ if parseDateErr != nil {
|
|
395
|
+ c.ErrorLog("warehousing_time(%v)解析错误:%v", warehousing_time, parseDateErr)
|
|
396
|
+ c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
|
|
397
|
+ return
|
|
398
|
+ }
|
|
399
|
+ if stockInOrderType != 1 && stockInOrderType != 2 {
|
|
400
|
+ c.ErrorLog("入库单类型不存在:type=%v", stockInOrderType)
|
|
401
|
+ c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
|
|
402
|
+ return
|
|
403
|
+ }
|
|
404
|
+ if storehouse_id <= 0 {
|
|
405
|
+ c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
|
|
406
|
+ return
|
|
407
|
+ } else {
|
|
408
|
+ _, getErr := service.FindStoreHouseByStorehouseId(storehouse_id, adminUserInfo.CurrentOrgId)
|
|
409
|
+ if getErr != nil {
|
|
410
|
+ if getErr == gorm.ErrRecordNotFound {
|
|
411
|
+ c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeStoreHouseNotExist)
|
|
412
|
+ return
|
|
413
|
+ } else {
|
|
414
|
+ c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
|
|
415
|
+ return
|
|
416
|
+ }
|
|
417
|
+ }
|
|
418
|
+ }
|
|
419
|
+ var warehousing *models.Warehousing
|
|
420
|
+ if warehousing_id > 0 {
|
|
421
|
+ w, getErr := service.FindWareHouseByIdV3(warehousing_id)
|
|
422
|
+ if getErr != nil || w == nil {
|
|
423
|
+ if getErr == gorm.ErrRecordNotFound {
|
|
424
|
+ c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeWarehousingNotExist)
|
|
425
|
+ return
|
|
426
|
+ } else {
|
|
427
|
+ c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
|
|
428
|
+ return
|
|
429
|
+ }
|
|
430
|
+ }
|
|
431
|
+ warehousing = w
|
|
432
|
+
|
|
433
|
+ } else {
|
|
434
|
+ c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeWarehousingNotExist)
|
|
435
|
+ return
|
|
436
|
+ }
|
|
437
|
+
|
|
438
|
+ // 开始外部循环的事务
|
|
439
|
+ db := service.XTWriteDB()
|
|
440
|
+ tx := db.Begin()
|
|
441
|
+
|
|
442
|
+ // 在函数结束时处理事务回滚
|
|
443
|
+ defer func() {
|
|
444
|
+ if r := recover(); r != nil {
|
|
445
|
+ tx.Rollback()
|
|
446
|
+ }
|
|
447
|
+ }()
|
|
448
|
+
|
|
449
|
+ warehousing.WarehousingTime = warehousingDate.Unix()
|
|
450
|
+ warehousing.StorehouseId = storehouse_id
|
|
451
|
+ warehousing.Mtime = time.Now().Unix()
|
|
452
|
+
|
|
453
|
+ updateWarehousingErr := service.UpdateWarehousingAllValueV3WithTx(warehousing, tx)
|
|
454
|
+ if updateWarehousingErr != nil {
|
|
455
|
+ utils.ErrorLog("修改入库单(id=%v)失败:%v", warehousing_id, updateWarehousingErr)
|
|
456
|
+ c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
|
|
457
|
+ return
|
|
458
|
+ }
|
|
459
|
+
|
|
460
|
+ var bodyParams _WarehousingInfoCreateParamModel
|
|
461
|
+ jsonErr := json.Unmarshal(c.Ctx.Input.RequestBody, &bodyParams)
|
|
462
|
+ if jsonErr != nil {
|
|
463
|
+ tx.Rollback()
|
|
464
|
+ utils.ErrorLog("解析入库单详情失败:%v", jsonErr.Error())
|
|
465
|
+ c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
|
|
466
|
+ return
|
|
467
|
+ }
|
|
468
|
+
|
|
469
|
+ details, getErr := service.GetWarehousingDetailsByWarehousingIDV3(warehousing.ID, warehousing.OrgId, tx)
|
|
470
|
+ if getErr != nil && getErr != gorm.ErrRecordNotFound {
|
|
471
|
+ utils.ErrorLog("入库单详情修改——查询详情失败:%v", getErr)
|
|
472
|
+ c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
|
|
473
|
+ return
|
|
474
|
+ }
|
|
475
|
+ if details == nil {
|
|
476
|
+ details = []*models.WarehousingInfo{}
|
|
477
|
+ }
|
|
478
|
+ // utils.InfoLog("%v", details)
|
|
479
|
+ if len(bodyParams.StockIn) > 0 {
|
|
480
|
+ for _, param := range bodyParams.StockIn {
|
|
481
|
+ productDateTS := int64(0)
|
|
482
|
+ if len(param.ProductDate) > 0 {
|
|
483
|
+ date, parseErr := utils.ParseTimeStringToTime("2006-01-02", param.ProductDate)
|
|
484
|
+ if parseErr == nil {
|
|
485
|
+ productDateTS = date.Unix()
|
|
486
|
+ }
|
|
487
|
+ }
|
|
488
|
+ expireDateTS := int64(0)
|
|
489
|
+ if len(param.ExpiryDate) > 0 {
|
|
490
|
+ date, parseErr := utils.ParseTimeStringToTime("2006-01-02", param.ExpiryDate)
|
|
491
|
+ if parseErr == nil {
|
|
492
|
+ expireDateTS = date.Unix()
|
|
493
|
+ }
|
|
494
|
+ }
|
|
495
|
+ warehousingCount, _ := strconv.ParseInt(param.WarehousingCount, 10, 64)
|
|
496
|
+
|
|
497
|
+ price, parseErr := strconv.ParseFloat(param.Price, 64)
|
|
498
|
+ if parseErr != nil {
|
|
499
|
+ tx.Rollback()
|
|
500
|
+ utils.ErrorLog("入库单详情入库价格格式错误(%v):%v", param.Price, parseErr)
|
|
501
|
+ c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamFormatWrong)
|
|
502
|
+ return
|
|
503
|
+ }
|
|
504
|
+ packingPrice, _ := strconv.ParseFloat(param.PackingPrice, 64)
|
|
505
|
+
|
|
506
|
+ if param.ID == 0 {
|
|
507
|
+ warehouseInfo := &models.WarehousingInfo{
|
|
508
|
+ ID: 0,
|
|
509
|
+ WarehousingOrder: warehousing.WarehousingOrder,
|
|
510
|
+ WarehousingId: warehousing.ID,
|
|
511
|
+ GoodId: param.GoodID,
|
|
512
|
+ Number: param.Number,
|
|
513
|
+ GoodTypeId: param.GoodTypeID,
|
|
514
|
+ ProductDate: productDateTS,
|
|
515
|
+ ExpiryDate: expireDateTS,
|
|
516
|
+ WarehousingCount: warehousingCount,
|
|
517
|
+ Price: price,
|
|
518
|
+ TotalPrice: float64(warehousingCount) * price,
|
|
519
|
+ Status: 1,
|
|
520
|
+ Ctime: warehousingDate.Unix(),
|
|
521
|
+ Mtime: warehousingDate.Unix(),
|
|
522
|
+ Remark: param.Remark,
|
|
523
|
+ OrgId: adminUserInfo.CurrentOrgId,
|
|
524
|
+ Type: stockInOrderType,
|
|
525
|
+ Manufacturer: param.Manufacturer,
|
|
526
|
+ StockCount: 0,
|
|
527
|
+ Dealer: param.Dealer,
|
|
528
|
+ LicenseNumber: param.LicenseNumber,
|
|
529
|
+ PackingPrice: packingPrice,
|
|
530
|
+ StorehouseId: storehouse_id,
|
|
531
|
+ IsCheck: 2,
|
|
532
|
+ RegisterNumber: param.RegisterNumber,
|
|
533
|
+ GoodCode: param.GoodCode,
|
|
534
|
+ }
|
|
535
|
+ err := service.CreatedNewWarehouseingDetail(warehouseInfo, tx)
|
|
536
|
+ if err != nil {
|
|
537
|
+ utils.ErrorLog("入库单详情创建失败:%v", err)
|
|
538
|
+ c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
|
|
539
|
+ return
|
|
540
|
+ }
|
|
541
|
+ } else {
|
|
542
|
+ for _, detail := range details {
|
|
543
|
+ if detail.ID == param.ID {
|
|
544
|
+ detail.GoodId = param.GoodID
|
|
545
|
+ detail.Number = param.Number
|
|
546
|
+ detail.GoodTypeId = param.GoodTypeID
|
|
547
|
+ detail.ProductDate = productDateTS
|
|
548
|
+ detail.ExpiryDate = expireDateTS
|
|
549
|
+ detail.WarehousingCount = warehousingCount
|
|
550
|
+ detail.Price = price
|
|
551
|
+ detail.TotalPrice = float64(warehousingCount) * price
|
|
552
|
+ detail.Mtime = warehousingDate.Unix()
|
|
553
|
+ detail.Remark = param.Remark
|
|
554
|
+ detail.Type = stockInOrderType
|
|
555
|
+ detail.Manufacturer = param.Manufacturer
|
|
556
|
+ detail.Dealer = param.Dealer
|
|
557
|
+ detail.LicenseNumber = param.LicenseNumber
|
|
558
|
+ detail.PackingPrice = packingPrice
|
|
559
|
+ detail.StorehouseId = storehouse_id
|
|
560
|
+ detail.RegisterNumber = param.RegisterNumber
|
|
561
|
+ detail.GoodCode = param.GoodCode
|
|
562
|
+
|
|
563
|
+ err := service.UpdateWarehousingDetailV3WithTx(detail, tx)
|
|
564
|
+ if err != nil {
|
|
565
|
+ utils.ErrorLog("入库单详情修改失败:%v", err)
|
|
566
|
+ c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
|
|
567
|
+ return
|
|
568
|
+ }
|
|
569
|
+ break
|
|
570
|
+ }
|
|
571
|
+ }
|
|
572
|
+ }
|
|
573
|
+ }
|
|
574
|
+ }
|
|
575
|
+
|
|
576
|
+ // 查询入库数据
|
|
577
|
+ var detailVMs []*models.VmWarehousingInfoSix
|
|
578
|
+
|
|
579
|
+ detailVMs, getErr = service.GetNewGoodWarehouseInfoById(warehousing.ID, warehousing.OrgId, tx)
|
|
580
|
+ if getErr != nil && getErr != gorm.ErrRecordNotFound {
|
|
581
|
+ utils.ErrorLog("入库单详情创建——查询详情失败:%v", getErr)
|
|
582
|
+ c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
|
|
583
|
+ return
|
|
584
|
+ }
|
|
585
|
+
|
|
586
|
+ tx.Commit()
|
|
587
|
+
|
|
588
|
+ c.ServeSuccessJSON(map[string]interface{}{
|
|
589
|
+ "msg": "编辑成功",
|
|
590
|
+ "list": detailVMs,
|
|
591
|
+ })
|
|
592
|
+
|
|
593
|
+}
|
|
594
|
+
|
|
595
|
+func (this *StockManagerApiController) GetWarehouseDetailList() {
|
|
596
|
+ page, _ := this.GetInt64("page", 0)
|
|
597
|
+ limit, _ := this.GetInt64("limit", 0)
|
|
598
|
+ start_time := this.GetString("start_time")
|
|
599
|
+ end_time := this.GetString("end_time")
|
|
600
|
+ types, _ := this.GetInt64("type", 0) // 1.入库 2.出库 3.退货 4.退库
|
|
601
|
+ keywords := this.GetString("keywords")
|
|
602
|
+
|
|
603
|
+ manufacturer, _ := this.GetInt64("manufacturer", 0) // 生产商
|
|
604
|
+ order_type, _ := this.GetInt64("order_type", 0)
|
|
605
|
+ dealer, _ := this.GetInt64("dealer", 0) // 经销商
|
|
606
|
+
|
|
607
|
+ storehouse_id, _ := this.GetInt64("storehouse_id")
|
|
608
|
+
|
|
609
|
+ good_id, _ := this.GetInt64("good_id") // 耗材
|
|
610
|
+
|
|
611
|
+ order_way, _ := this.GetInt64("order_way") // 出库方式 0不限 1手动出库 2自动出库
|
|
612
|
+
|
|
613
|
+ // timeLayout := "2006-01-02"
|
|
614
|
+ // loc, _ := time.LoadLocation("Local")
|
|
615
|
+ var startTime int64
|
|
616
|
+ if len(start_time) > 0 {
|
|
617
|
+ theTime, err := time.Parse("2006-01-02 15:04:05", start_time+" 00:00:00")
|
|
618
|
+ if err != nil {
|
|
619
|
+ this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
|
|
620
|
+ return
|
|
621
|
+ }
|
|
622
|
+ startTime = theTime.Unix()
|
|
623
|
+ }
|
|
624
|
+ var endTime int64
|
|
625
|
+ if len(end_time) > 0 {
|
|
626
|
+ theTime, err := time.Parse("2006-01-02 15:04:05", end_time+" 23:59:59")
|
|
627
|
+ if err != nil {
|
|
628
|
+ utils.ErrorLog(err.Error())
|
|
629
|
+ this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
|
|
630
|
+ return
|
|
631
|
+ }
|
|
632
|
+ endTime = theTime.Unix()
|
|
633
|
+ }
|
|
634
|
+
|
|
635
|
+ adminUserInfo := this.GetAdminUserInfo()
|
|
636
|
+
|
|
637
|
+ var list []*models.WarehousingInfo
|
|
638
|
+ var list1 []*models.WarehouseOutInfo
|
|
639
|
+ var list2 []*models.SalesReturnInfo
|
|
640
|
+ var list3 []*models.CancelStockInfo
|
|
641
|
+
|
|
642
|
+ var total int64
|
|
643
|
+ var err error
|
|
644
|
+ var total_price float64
|
|
645
|
+ houseList, _ := service.GetAllStoreHouseList(adminUserInfo.CurrentOrgId)
|
|
646
|
+ manufacturerList, _ := service.GetAllManufacturerList(adminUserInfo.CurrentOrgId)
|
|
647
|
+ dealerList, _ := service.GetAllDealerList(adminUserInfo.CurrentOrgId)
|
|
648
|
+ patientsList, _ := service.GetAllpatient(adminUserInfo.CurrentOrgId)
|
|
649
|
+ var goodKind = "耗材种类"
|
|
650
|
+ goodKindParent, _ := service.GetDrugDataConfig(0, goodKind)
|
|
651
|
+ goodKindList, _ := service.GetParentDataConfig(goodKindParent.ID, adminUserInfo.CurrentOrgId)
|
|
652
|
+ if types == 1 {
|
|
653
|
+ list, total, err = service.FindStockInDetailList(adminUserInfo.CurrentOrgId, page, limit, startTime, endTime, keywords, manufacturer, order_type, dealer, storehouse_id, good_id)
|
|
654
|
+ _, total_price = service.GetStockInDetailTotal(adminUserInfo.CurrentOrgId, startTime, endTime, keywords, manufacturer, order_type, dealer, storehouse_id, good_id)
|
|
655
|
+
|
|
656
|
+ if err == nil {
|
|
657
|
+ this.ServeSuccessJSON(map[string]interface{}{
|
|
658
|
+ "list": list,
|
|
659
|
+ "total": total,
|
|
660
|
+ "total_price": total_price,
|
|
661
|
+ "houseList": houseList,
|
|
662
|
+ "manufacturerList": manufacturerList,
|
|
663
|
+ "dealerList": dealerList,
|
|
664
|
+ "patientsList": patientsList,
|
|
665
|
+ "goodKindList": goodKindList,
|
|
666
|
+ })
|
|
667
|
+ } else {
|
|
668
|
+ this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
|
|
669
|
+ }
|
|
670
|
+
|
|
671
|
+ } else if types == 2 {
|
|
672
|
+ list1, total, err = service.FindStockOutDetailList(adminUserInfo.CurrentOrgId, page, limit, startTime, endTime, keywords, manufacturer, order_type, dealer, storehouse_id, good_id, order_way)
|
|
673
|
+ _, total_price = service.GetStockOutDetailTotal(adminUserInfo.CurrentOrgId, startTime, endTime, keywords, manufacturer, order_type, dealer, storehouse_id, good_id, order_way)
|
|
674
|
+ if err == nil {
|
|
675
|
+ this.ServeSuccessJSON(map[string]interface{}{
|
|
676
|
+ "list": list1,
|
|
677
|
+ "total": total,
|
|
678
|
+ "total_price": total_price,
|
|
679
|
+ "houseList": houseList,
|
|
680
|
+ "manufacturerList": manufacturerList,
|
|
681
|
+ "dealerList": dealerList,
|
|
682
|
+ "patientsList": patientsList,
|
|
683
|
+ "goodKindList": goodKindList,
|
|
684
|
+ })
|
|
685
|
+ } else {
|
|
686
|
+ this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
|
|
687
|
+ }
|
|
688
|
+ } else if types == 3 {
|
|
689
|
+ list2, total, err = service.FindSalesReturnDetailList(adminUserInfo.CurrentOrgId, page, limit, startTime, endTime, keywords, manufacturer, order_type, dealer)
|
|
690
|
+
|
|
691
|
+ if err == nil {
|
|
692
|
+ this.ServeSuccessJSON(map[string]interface{}{
|
|
693
|
+ "list": list2,
|
|
694
|
+ "total": total,
|
|
695
|
+ "manufacturerList": manufacturerList,
|
|
696
|
+ "dealerList": dealerList,
|
|
697
|
+ "patientsList": patientsList,
|
|
698
|
+ "goodKindList": goodKindList,
|
|
699
|
+ })
|
|
700
|
+ } else {
|
|
701
|
+ this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
|
|
702
|
+ }
|
|
703
|
+ } else if types == 4 {
|
|
704
|
+ list3, total, err = service.FindCancelDetailList(adminUserInfo.CurrentOrgId, page, limit, startTime, endTime, keywords, manufacturer, order_type, dealer, storehouse_id, good_id)
|
|
705
|
+ listGroup, err := service.FindeCancelGroup(adminUserInfo.CurrentOrgId, startTime, endTime, keywords, manufacturer, order_type, dealer, storehouse_id, good_id)
|
|
706
|
+ if err == nil {
|
|
707
|
+ this.ServeSuccessJSON(map[string]interface{}{
|
|
708
|
+ "list": list3,
|
|
709
|
+ "total": total,
|
|
710
|
+ "listgroup": listGroup,
|
|
711
|
+ "houseList": houseList,
|
|
712
|
+ "manufacturerList": manufacturerList,
|
|
713
|
+ "dealerList": dealerList,
|
|
714
|
+ "patientsList": patientsList,
|
|
715
|
+ "goodKindList": goodKindList,
|
|
716
|
+ })
|
|
717
|
+ } else {
|
|
718
|
+ this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
|
|
719
|
+ }
|
|
720
|
+ }
|
|
721
|
+
|
|
722
|
+}
|