supply_order_api_contorller.go 20KB

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