|
@@ -1,8 +1,17 @@
|
1
|
1
|
package controllers
|
2
|
2
|
|
3
|
3
|
import (
|
|
4
|
+ "XT_New/enums"
|
|
5
|
+ "XT_New/models"
|
4
|
6
|
"XT_New/service"
|
|
7
|
+ "XT_New/utils"
|
|
8
|
+ "encoding/json"
|
|
9
|
+ "fmt"
|
5
|
10
|
"github.com/astaxie/beego"
|
|
11
|
+ "reflect"
|
|
12
|
+ "strconv"
|
|
13
|
+ "strings"
|
|
14
|
+ "time"
|
6
|
15
|
)
|
7
|
16
|
|
8
|
17
|
type SupplyOrderApiController struct {
|
|
@@ -12,6 +21,10 @@ type SupplyOrderApiController struct {
|
12
|
21
|
func SupplyOrderApiRegistRouters() {
|
13
|
22
|
|
14
|
23
|
beego.Router("/api/supply/getinitorder", &SupplyOrderApiController{}, "get:GetInitOrder")
|
|
24
|
+ beego.Router("/api/supply/savepurchaseorder", &SupplyOrderApiController{}, "post:SavePurchaseOrder")
|
|
25
|
+ beego.Router("/api/supply/getallsupply", &SupplyOrderApiController{}, "get:GetAllSupply")
|
|
26
|
+ beego.Router("/api/supply/getallpurchaseorderlist", &SupplyOrderApiController{}, "get:GetAllPurchaseOrderList")
|
|
27
|
+ beego.Router("/api/supply/updatepurchaseorder", &SupplyOrderApiController{}, "Post:UpdatePurchaseOrder")
|
15
|
28
|
}
|
16
|
29
|
|
17
|
30
|
func (this *SupplyOrderApiController) GetInitOrder() {
|
|
@@ -41,3 +54,502 @@ func (this *SupplyOrderApiController) GetInitOrder() {
|
41
|
54
|
})
|
42
|
55
|
return
|
43
|
56
|
}
|
|
57
|
+
|
|
58
|
+func (this *SupplyOrderApiController) SavePurchaseOrder() {
|
|
59
|
+
|
|
60
|
+ supplier_id, _ := this.GetInt64("supplier_name")
|
|
61
|
+ start_time := this.GetString("start_time")
|
|
62
|
+ end_time := this.GetString("end_time")
|
|
63
|
+ timeLayout := "2006-01-02"
|
|
64
|
+ loc, _ := time.LoadLocation("Local")
|
|
65
|
+ var startTime int64
|
|
66
|
+ if len(start_time) > 0 {
|
|
67
|
+ theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", start_time+" 00:00:00", loc)
|
|
68
|
+ if err != nil {
|
|
69
|
+ this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
|
|
70
|
+ return
|
|
71
|
+ }
|
|
72
|
+ startTime = theTime.Unix()
|
|
73
|
+ }
|
|
74
|
+ var endTime int64
|
|
75
|
+ if len(end_time) > 0 {
|
|
76
|
+ theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", end_time+" 23:59:59", loc)
|
|
77
|
+ if err != nil {
|
|
78
|
+ utils.ErrorLog(err.Error())
|
|
79
|
+ this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
|
|
80
|
+ return
|
|
81
|
+ }
|
|
82
|
+ endTime = theTime.Unix()
|
|
83
|
+ }
|
|
84
|
+
|
|
85
|
+ rate_of_concession := this.GetString("rate_of_concession")
|
|
86
|
+ rate_of_concession_float, _ := strconv.ParseFloat(rate_of_concession, 64)
|
|
87
|
+ discount_amount := this.GetString("discount_amount")
|
|
88
|
+ discount_amount_float, _ := strconv.ParseFloat(discount_amount, 64)
|
|
89
|
+ fmt.Println("supplier_id23323232323232", supplier_id, startTime, endTime, rate_of_concession, rate_of_concession_float, discount_amount, discount_amount_float)
|
|
90
|
+ dataBody := make(map[string]interface{}, 0)
|
|
91
|
+ err := json.Unmarshal(this.Ctx.Input.RequestBody, &dataBody)
|
|
92
|
+ if err != nil {
|
|
93
|
+ utils.ErrorLog(err.Error())
|
|
94
|
+ this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
|
|
95
|
+ return
|
|
96
|
+ }
|
|
97
|
+
|
|
98
|
+ //生成订货单
|
|
99
|
+ timeStr := time.Now().Format("2006-01-02")
|
|
100
|
+ timeArr := strings.Split(timeStr, "-")
|
|
101
|
+ orgId := this.GetAdminUserInfo().CurrentOrgId
|
|
102
|
+ total, _ := service.FindAllSupplyOrder(orgId)
|
|
103
|
+ total = total + 1
|
|
104
|
+ warehousing_order := "CGDD" + timeArr[0] + timeArr[1] + timeArr[2] + "00" + strconv.FormatInt(total, 10)
|
|
105
|
+ recordDateStr := time.Now().Format("2006-01-02")
|
|
106
|
+ recordDate, parseDateErr := utils.ParseTimeStringToTime("2006-01-02", recordDateStr)
|
|
107
|
+ fmt.Scan("parseDateErr", parseDateErr)
|
|
108
|
+ record_date := recordDate.Unix()
|
|
109
|
+ info := models.SupplierWarehouseInfo{
|
|
110
|
+ Number: warehousing_order,
|
|
111
|
+ UserOrgId: orgId,
|
|
112
|
+ Creater: this.GetAdminUserInfo().AdminUser.Id,
|
|
113
|
+ Ctime: time.Now().Unix(),
|
|
114
|
+ Mtime: 0,
|
|
115
|
+ Status: 1,
|
|
116
|
+ RecordDate: record_date,
|
|
117
|
+ IsCheck: 2,
|
|
118
|
+ RateOfConcession: rate_of_concession_float,
|
|
119
|
+ DiscountAmount: discount_amount_float,
|
|
120
|
+ DocumentDate: startTime,
|
|
121
|
+ DeliveryDate: endTime,
|
|
122
|
+ SupplierId: supplier_id,
|
|
123
|
+ }
|
|
124
|
+ err = service.CreateSupplyWarehouse(info)
|
|
125
|
+ warehouseInfo, _ := service.FindLastSupplyWarehouseInfo(orgId)
|
|
126
|
+ var warehousingInfo []*models.SupplierWarehousingInfoOrder
|
|
127
|
+ if dataBody["stockIn"] != nil && reflect.TypeOf(dataBody["stockIn"]).String() == "[]interface {}" {
|
|
128
|
+ thisStockIn, _ := dataBody["stockIn"].([]interface{})
|
|
129
|
+ if len(thisStockIn) > 0 {
|
|
130
|
+ for _, item := range thisStockIn {
|
|
131
|
+ items := item.(map[string]interface{})
|
|
132
|
+
|
|
133
|
+ if items["id"] == nil || reflect.TypeOf(items["id"]).String() != "float64" {
|
|
134
|
+ utils.ErrorLog("id")
|
|
135
|
+ this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
|
|
136
|
+ return
|
|
137
|
+ }
|
|
138
|
+ id := int64(items["id"].(float64))
|
|
139
|
+
|
|
140
|
+ if items["supply_count"] == nil || reflect.TypeOf(items["supply_count"]).String() != "float64" {
|
|
141
|
+ utils.ErrorLog("supply_count")
|
|
142
|
+ this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
|
|
143
|
+ return
|
|
144
|
+ }
|
|
145
|
+ supply_count := int64(items["supply_count"].(float64))
|
|
146
|
+
|
|
147
|
+ if items["supply_license_number"] == nil || reflect.TypeOf(items["supply_license_number"]).String() != "string" {
|
|
148
|
+ utils.ErrorLog("supply_license_number")
|
|
149
|
+ this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
|
|
150
|
+ return
|
|
151
|
+ }
|
|
152
|
+
|
|
153
|
+ supply_license_number := items["supply_license_number"].(string)
|
|
154
|
+
|
|
155
|
+ if items["supply_price"] == nil || reflect.TypeOf(items["supply_price"]).String() != "string" {
|
|
156
|
+ utils.ErrorLog("supply_price")
|
|
157
|
+ this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
|
|
158
|
+ return
|
|
159
|
+ }
|
|
160
|
+ supply_price := items["supply_price"].(string)
|
|
161
|
+
|
|
162
|
+ supply_price_float, _ := strconv.ParseFloat(supply_price, 64)
|
|
163
|
+
|
|
164
|
+ if items["supply_remake"] == nil || reflect.TypeOf(items["supply_remake"]).String() != "string" {
|
|
165
|
+ utils.ErrorLog("supply_remake")
|
|
166
|
+ this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
|
|
167
|
+ return
|
|
168
|
+ }
|
|
169
|
+
|
|
170
|
+ supply_remake := items["supply_remake"].(string)
|
|
171
|
+
|
|
172
|
+ if items["supply_total_price"] == nil || reflect.TypeOf(items["supply_total_price"]).String() != "string" {
|
|
173
|
+ utils.ErrorLog("supply_total_price")
|
|
174
|
+ this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
|
|
175
|
+ return
|
|
176
|
+ }
|
|
177
|
+ supply_total_price := items["supply_total_price"].(string)
|
|
178
|
+
|
|
179
|
+ supply_total_price_float, _ := strconv.ParseFloat(supply_total_price, 64)
|
|
180
|
+ if items["type"] == nil || reflect.TypeOf(items["type"]).String() != "float64" {
|
|
181
|
+ utils.ErrorLog("type")
|
|
182
|
+ this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
|
|
183
|
+ return
|
|
184
|
+ }
|
|
185
|
+ is_source := int64(items["type"].(float64))
|
|
186
|
+
|
|
187
|
+ if items["supply_type"] == nil || reflect.TypeOf(items["supply_type"]).String() != "string" {
|
|
188
|
+ utils.ErrorLog("supply_type")
|
|
189
|
+ this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
|
|
190
|
+ return
|
|
191
|
+ }
|
|
192
|
+
|
|
193
|
+ supply_type := items["supply_type"].(string)
|
|
194
|
+
|
|
195
|
+ if items["supply_specification_name"] == nil || reflect.TypeOf(items["supply_specification_name"]).String() != "string" {
|
|
196
|
+ utils.ErrorLog("supply_specification_name")
|
|
197
|
+ this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
|
|
198
|
+ return
|
|
199
|
+ }
|
|
200
|
+
|
|
201
|
+ supply_specification_name := items["supply_specification_name"].(string)
|
|
202
|
+
|
|
203
|
+ if items["supply_total"] == nil || reflect.TypeOf(items["supply_total"]).String() != "string" {
|
|
204
|
+ utils.ErrorLog("supply_total")
|
|
205
|
+ this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
|
|
206
|
+ return
|
|
207
|
+ }
|
|
208
|
+
|
|
209
|
+ supply_total := items["supply_total"].(string)
|
|
210
|
+
|
|
211
|
+ if items["supply_manufacturer"] == nil || reflect.TypeOf(items["supply_manufacturer"]).String() != "string" {
|
|
212
|
+ utils.ErrorLog("supply_manufacturer")
|
|
213
|
+ this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
|
|
214
|
+ return
|
|
215
|
+ }
|
|
216
|
+
|
|
217
|
+ supply_manufacturer := items["supply_manufacturer"].(string)
|
|
218
|
+
|
|
219
|
+ if items["name"] == nil || reflect.TypeOf(items["name"]).String() != "string" {
|
|
220
|
+ utils.ErrorLog("name")
|
|
221
|
+ this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
|
|
222
|
+ return
|
|
223
|
+ }
|
|
224
|
+
|
|
225
|
+ name := items["name"].(string)
|
|
226
|
+
|
|
227
|
+ order := models.SupplierWarehousingInfoOrder{
|
|
228
|
+ OrderNumber: warehousing_order,
|
|
229
|
+ IsSource: is_source,
|
|
230
|
+ Count: supply_count,
|
|
231
|
+ Price: supply_price_float,
|
|
232
|
+ Amount: supply_total_price_float,
|
|
233
|
+ Remark: supply_remake,
|
|
234
|
+ UserOrgId: orgId,
|
|
235
|
+ Ctime: time.Now().Unix(),
|
|
236
|
+ Status: 1,
|
|
237
|
+ Mtime: 0,
|
|
238
|
+ WarehousingId: warehouseInfo.ID,
|
|
239
|
+ ProjectId: id,
|
|
240
|
+ SupplyLicenseNumber: supply_license_number,
|
|
241
|
+ SupplyType: supply_type,
|
|
242
|
+ SupplySpecificationName: supply_specification_name,
|
|
243
|
+ SupplyTotal: supply_total,
|
|
244
|
+ SupplyManufacturer: supply_manufacturer,
|
|
245
|
+ Name: name,
|
|
246
|
+ }
|
|
247
|
+
|
|
248
|
+ warehousingInfo = append(warehousingInfo, &order)
|
|
249
|
+ }
|
|
250
|
+ }
|
|
251
|
+ }
|
|
252
|
+
|
|
253
|
+ for _, item := range warehousingInfo {
|
|
254
|
+ err = service.CreateSupplyWarehousingOrder(item)
|
|
255
|
+ }
|
|
256
|
+
|
|
257
|
+ //查询
|
|
258
|
+ orderInfo, err := service.GetSupplyWarehousingOrderInfo(warehouseInfo.ID)
|
|
259
|
+ if err == nil {
|
|
260
|
+ this.ServeSuccessJSON(map[string]interface{}{
|
|
261
|
+ "order": warehousingInfo,
|
|
262
|
+ "warehouseInfo": warehouseInfo,
|
|
263
|
+ "orderInfo": orderInfo,
|
|
264
|
+ })
|
|
265
|
+ } else {
|
|
266
|
+ this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
|
|
267
|
+ }
|
|
268
|
+}
|
|
269
|
+
|
|
270
|
+func (this *SupplyOrderApiController) GetAllSupply() {
|
|
271
|
+
|
|
272
|
+ orgId := this.GetAdminUserInfo().CurrentOrgId
|
|
273
|
+ appId := this.GetAdminUserInfo().CurrentAppId
|
|
274
|
+ supplyList, err := service.GetSupplierList(orgId)
|
|
275
|
+ doctorList, err := service.GetAllDoctor(orgId, appId)
|
|
276
|
+ if err == nil {
|
|
277
|
+ this.ServeSuccessJSON(map[string]interface{}{
|
|
278
|
+ "supplyList": supplyList,
|
|
279
|
+ "doctorList": doctorList,
|
|
280
|
+ })
|
|
281
|
+ } else {
|
|
282
|
+ this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
|
|
283
|
+ }
|
|
284
|
+}
|
|
285
|
+
|
|
286
|
+func (this *SupplyOrderApiController) GetAllPurchaseOrderList() {
|
|
287
|
+
|
|
288
|
+ check_id, _ := this.GetInt64("check_id")
|
|
289
|
+ start_time := this.GetString("start_time")
|
|
290
|
+ end_time := this.GetString("end_time")
|
|
291
|
+ timeLayout := "2006-01-02"
|
|
292
|
+ loc, _ := time.LoadLocation("Local")
|
|
293
|
+ var startTime int64
|
|
294
|
+ if len(start_time) > 0 {
|
|
295
|
+ theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", start_time+" 00:00:00", loc)
|
|
296
|
+ if err != nil {
|
|
297
|
+ this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
|
|
298
|
+ return
|
|
299
|
+ }
|
|
300
|
+ startTime = theTime.Unix()
|
|
301
|
+ }
|
|
302
|
+ var endTime int64
|
|
303
|
+ if len(end_time) > 0 {
|
|
304
|
+ theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", end_time+" 23:59:59", loc)
|
|
305
|
+ if err != nil {
|
|
306
|
+ utils.ErrorLog(err.Error())
|
|
307
|
+ this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
|
|
308
|
+ return
|
|
309
|
+ }
|
|
310
|
+ endTime = theTime.Unix()
|
|
311
|
+ }
|
|
312
|
+ keyword := this.GetString("keyword")
|
|
313
|
+
|
|
314
|
+ page, _ := this.GetInt64("page")
|
|
315
|
+
|
|
316
|
+ limit, _ := this.GetInt64("limit")
|
|
317
|
+ orgId := this.GetAdminUserInfo().CurrentOrgId
|
|
318
|
+ list, total, err := service.GetAllPurchaseOrderList(check_id, startTime, endTime, keyword, page, limit, orgId)
|
|
319
|
+ if err == nil {
|
|
320
|
+ this.ServeSuccessJSON(map[string]interface{}{
|
|
321
|
+ "list": list,
|
|
322
|
+ "total": total,
|
|
323
|
+ })
|
|
324
|
+ } else {
|
|
325
|
+ this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
|
|
326
|
+ }
|
|
327
|
+}
|
|
328
|
+
|
|
329
|
+func (this *SupplyOrderApiController) UpdatePurchaseOrder() {
|
|
330
|
+ supplier_id, _ := this.GetInt64("supplier_name")
|
|
331
|
+ start_time := this.GetString("start_time")
|
|
332
|
+ end_time := this.GetString("end_time")
|
|
333
|
+ timeLayout := "2006-01-02"
|
|
334
|
+ loc, _ := time.LoadLocation("Local")
|
|
335
|
+ var startTime int64
|
|
336
|
+ if len(start_time) > 0 {
|
|
337
|
+ theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", start_time+" 00:00:00", loc)
|
|
338
|
+ if err != nil {
|
|
339
|
+ this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
|
|
340
|
+ return
|
|
341
|
+ }
|
|
342
|
+ startTime = theTime.Unix()
|
|
343
|
+ }
|
|
344
|
+ var endTime int64
|
|
345
|
+ if len(end_time) > 0 {
|
|
346
|
+ theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", end_time+" 23:59:59", loc)
|
|
347
|
+ if err != nil {
|
|
348
|
+ utils.ErrorLog(err.Error())
|
|
349
|
+ this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
|
|
350
|
+ return
|
|
351
|
+ }
|
|
352
|
+ endTime = theTime.Unix()
|
|
353
|
+ }
|
|
354
|
+
|
|
355
|
+ rate_of_concession := this.GetString("rate_of_concession")
|
|
356
|
+ rate_of_concession_float, _ := strconv.ParseFloat(rate_of_concession, 64)
|
|
357
|
+ discount_amount := this.GetString("discount_amount")
|
|
358
|
+ discount_amount_float, _ := strconv.ParseFloat(discount_amount, 64)
|
|
359
|
+ warehousing_id, _ := this.GetInt64("id")
|
|
360
|
+ number := this.GetString("number")
|
|
361
|
+ fmt.Println("supplier_id23323232323232", supplier_id, startTime, endTime, rate_of_concession, rate_of_concession_float, discount_amount, discount_amount_float)
|
|
362
|
+ orgId := this.GetAdminUserInfo().CurrentOrgId
|
|
363
|
+ info := models.SupplierWarehouseInfo{
|
|
364
|
+ RateOfConcession: rate_of_concession_float,
|
|
365
|
+ DiscountAmount: discount_amount_float,
|
|
366
|
+ DocumentDate: startTime,
|
|
367
|
+ DeliveryDate: endTime,
|
|
368
|
+ SupplierId: supplier_id,
|
|
369
|
+ Mtime: time.Now().Unix(),
|
|
370
|
+ }
|
|
371
|
+ service.ModefySupplyWarehouseInfo(warehousing_id, info)
|
|
372
|
+ dataBody := make(map[string]interface{}, 0)
|
|
373
|
+ err := json.Unmarshal(this.Ctx.Input.RequestBody, &dataBody)
|
|
374
|
+ if err != nil {
|
|
375
|
+ utils.ErrorLog(err.Error())
|
|
376
|
+ this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
|
|
377
|
+ return
|
|
378
|
+ }
|
|
379
|
+ var warehousingInfo []*models.SupplierWarehousingInfoOrder
|
|
380
|
+ var updateWarehousingInfo []*models.SupplierWarehousingInfoOrder
|
|
381
|
+ if dataBody["stockIn"] != nil && reflect.TypeOf(dataBody["stockIn"]).String() == "[]interface {}" {
|
|
382
|
+ thisStockIn, _ := dataBody["stockIn"].([]interface{})
|
|
383
|
+ if len(thisStockIn) > 0 {
|
|
384
|
+ for _, item := range thisStockIn {
|
|
385
|
+ items := item.(map[string]interface{})
|
|
386
|
+
|
|
387
|
+ if items["id"] == nil || reflect.TypeOf(items["id"]).String() != "float64" {
|
|
388
|
+ utils.ErrorLog("id")
|
|
389
|
+ this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
|
|
390
|
+ return
|
|
391
|
+ }
|
|
392
|
+ id := int64(items["id"].(float64))
|
|
393
|
+
|
|
394
|
+ if items["project_id"] == nil || reflect.TypeOf(items["project_id"]).String() != "float64" {
|
|
395
|
+ utils.ErrorLog("project_id")
|
|
396
|
+ this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
|
|
397
|
+ return
|
|
398
|
+ }
|
|
399
|
+ project_id := int64(items["project_id"].(float64))
|
|
400
|
+
|
|
401
|
+ if items["supply_count"] == nil || reflect.TypeOf(items["supply_count"]).String() != "float64" {
|
|
402
|
+ utils.ErrorLog("supply_count")
|
|
403
|
+ this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
|
|
404
|
+ return
|
|
405
|
+ }
|
|
406
|
+ supply_count := int64(items["supply_count"].(float64))
|
|
407
|
+
|
|
408
|
+ if items["supply_license_number"] == nil || reflect.TypeOf(items["supply_license_number"]).String() != "string" {
|
|
409
|
+ utils.ErrorLog("supply_license_number")
|
|
410
|
+ this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
|
|
411
|
+ return
|
|
412
|
+ }
|
|
413
|
+
|
|
414
|
+ supply_license_number := items["supply_license_number"].(string)
|
|
415
|
+
|
|
416
|
+ if items["supply_price"] == nil || reflect.TypeOf(items["supply_price"]).String() != "string" {
|
|
417
|
+ utils.ErrorLog("supply_price")
|
|
418
|
+ this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
|
|
419
|
+ return
|
|
420
|
+ }
|
|
421
|
+ supply_price := items["supply_price"].(string)
|
|
422
|
+
|
|
423
|
+ supply_price_float, _ := strconv.ParseFloat(supply_price, 64)
|
|
424
|
+
|
|
425
|
+ if items["supply_remake"] == nil || reflect.TypeOf(items["supply_remake"]).String() != "string" {
|
|
426
|
+ utils.ErrorLog("supply_remake")
|
|
427
|
+ this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
|
|
428
|
+ return
|
|
429
|
+ }
|
|
430
|
+
|
|
431
|
+ supply_remake := items["supply_remake"].(string)
|
|
432
|
+
|
|
433
|
+ if items["supply_total_price"] == nil || reflect.TypeOf(items["supply_total_price"]).String() != "string" {
|
|
434
|
+ utils.ErrorLog("supply_total_price")
|
|
435
|
+ this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
|
|
436
|
+ return
|
|
437
|
+ }
|
|
438
|
+ supply_total_price := items["supply_total_price"].(string)
|
|
439
|
+
|
|
440
|
+ supply_total_price_float, _ := strconv.ParseFloat(supply_total_price, 64)
|
|
441
|
+ if items["is_source"] == nil || reflect.TypeOf(items["is_source"]).String() != "float64" {
|
|
442
|
+ utils.ErrorLog("is_source")
|
|
443
|
+ this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
|
|
444
|
+ return
|
|
445
|
+ }
|
|
446
|
+ is_source := int64(items["is_source"].(float64))
|
|
447
|
+
|
|
448
|
+ if items["supply_type"] == nil || reflect.TypeOf(items["supply_type"]).String() != "string" {
|
|
449
|
+ utils.ErrorLog("supply_type")
|
|
450
|
+ this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
|
|
451
|
+ return
|
|
452
|
+ }
|
|
453
|
+
|
|
454
|
+ supply_type := items["supply_type"].(string)
|
|
455
|
+
|
|
456
|
+ if items["supply_specification_name"] == nil || reflect.TypeOf(items["supply_specification_name"]).String() != "string" {
|
|
457
|
+ utils.ErrorLog("supply_specification_name")
|
|
458
|
+ this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
|
|
459
|
+ return
|
|
460
|
+ }
|
|
461
|
+
|
|
462
|
+ supply_specification_name := items["supply_specification_name"].(string)
|
|
463
|
+
|
|
464
|
+ if items["supply_total"] == nil || reflect.TypeOf(items["supply_total"]).String() != "string" {
|
|
465
|
+ utils.ErrorLog("supply_total")
|
|
466
|
+ this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
|
|
467
|
+ return
|
|
468
|
+ }
|
|
469
|
+
|
|
470
|
+ supply_total := items["supply_total"].(string)
|
|
471
|
+
|
|
472
|
+ if items["supply_manufacturer"] == nil || reflect.TypeOf(items["supply_manufacturer"]).String() != "string" {
|
|
473
|
+ utils.ErrorLog("supply_manufacturer")
|
|
474
|
+ this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
|
|
475
|
+ return
|
|
476
|
+ }
|
|
477
|
+
|
|
478
|
+ supply_manufacturer := items["supply_manufacturer"].(string)
|
|
479
|
+
|
|
480
|
+ if items["name"] == nil || reflect.TypeOf(items["name"]).String() != "string" {
|
|
481
|
+ utils.ErrorLog("name")
|
|
482
|
+ this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
|
|
483
|
+ return
|
|
484
|
+ }
|
|
485
|
+
|
|
486
|
+ name := items["name"].(string)
|
|
487
|
+
|
|
488
|
+ if id > 0 {
|
|
489
|
+ order := models.SupplierWarehousingInfoOrder{
|
|
490
|
+ ID: id,
|
|
491
|
+ IsSource: is_source,
|
|
492
|
+ Count: supply_count,
|
|
493
|
+ Price: supply_price_float,
|
|
494
|
+ Amount: supply_total_price_float,
|
|
495
|
+ Remark: supply_remake,
|
|
496
|
+ Ctime: time.Now().Unix(),
|
|
497
|
+ Status: 1,
|
|
498
|
+ Mtime: 0,
|
|
499
|
+ ProjectId: project_id,
|
|
500
|
+ SupplyLicenseNumber: supply_license_number,
|
|
501
|
+ SupplyType: supply_type,
|
|
502
|
+ SupplySpecificationName: supply_specification_name,
|
|
503
|
+ SupplyTotal: supply_total,
|
|
504
|
+ SupplyManufacturer: supply_manufacturer,
|
|
505
|
+ Name: name,
|
|
506
|
+ }
|
|
507
|
+
|
|
508
|
+ updateWarehousingInfo = append(updateWarehousingInfo, &order)
|
|
509
|
+ }
|
|
510
|
+
|
|
511
|
+ if id == 0 {
|
|
512
|
+
|
|
513
|
+ order := models.SupplierWarehousingInfoOrder{
|
|
514
|
+ OrderNumber: number,
|
|
515
|
+ IsSource: is_source,
|
|
516
|
+ Count: supply_count,
|
|
517
|
+ Price: supply_price_float,
|
|
518
|
+ Amount: supply_total_price_float,
|
|
519
|
+ Remark: supply_remake,
|
|
520
|
+ UserOrgId: orgId,
|
|
521
|
+ Ctime: time.Now().Unix(),
|
|
522
|
+ Status: 1,
|
|
523
|
+ Mtime: 0,
|
|
524
|
+ WarehousingId: warehousing_id,
|
|
525
|
+ ProjectId: id,
|
|
526
|
+ SupplyLicenseNumber: supply_license_number,
|
|
527
|
+ SupplyType: supply_type,
|
|
528
|
+ SupplySpecificationName: supply_specification_name,
|
|
529
|
+ SupplyTotal: supply_total,
|
|
530
|
+ SupplyManufacturer: supply_manufacturer,
|
|
531
|
+ Name: name,
|
|
532
|
+ }
|
|
533
|
+ warehousingInfo = append(warehousingInfo, &order)
|
|
534
|
+ }
|
|
535
|
+
|
|
536
|
+ }
|
|
537
|
+ }
|
|
538
|
+ if len(warehousingInfo) > 0 {
|
|
539
|
+ for _, item := range warehousingInfo {
|
|
540
|
+ service.CreateSupplyWarehousingOrder(item)
|
|
541
|
+ }
|
|
542
|
+
|
|
543
|
+ }
|
|
544
|
+ if len(updateWarehousingInfo) > 0 {
|
|
545
|
+ for _, item := range updateWarehousingInfo {
|
|
546
|
+ service.ModifySupplyWarehouseOrder(item)
|
|
547
|
+ }
|
|
548
|
+
|
|
549
|
+ }
|
|
550
|
+ this.ServeSuccessJSON(map[string]interface{}{
|
|
551
|
+ "warehousingInfo": warehousingInfo,
|
|
552
|
+ })
|
|
553
|
+
|
|
554
|
+ }
|
|
555
|
+}
|