drug_stock_api_contorller.go 70KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230
  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 StockDrugApiController struct {
  16. BaseAuthAPIController
  17. }
  18. func DrugStockManagerApiRegistRouters() {
  19. //入库管理和其他入库管理相关接口
  20. beego.Router("/api/drugwarehouse/create", &StockDrugApiController{}, "post:CreateDrugWarehouse")
  21. beego.Router("/api/drugwarehouse/list", &StockDrugApiController{}, "get:GetDrugWarehouseList")
  22. beego.Router("/api/drugwarehouse/delete", &StockDrugApiController{}, "post:DeleteDrugWarehouse")
  23. beego.Router("/api/drugwarehouseinfo/delete", &StockDrugApiController{}, "post:DeleteDrugWarehouseInfo")
  24. beego.Router("/api/drugwarehouseinfo/list", &StockDrugApiController{}, "get:GetDrugWarehouseInfoList")
  25. beego.Router("/api/drugwarehouse/edit", &StockDrugApiController{}, "post:EditDrugWarehouse")
  26. //退货管理和其他退货管理相关接口
  27. beego.Router("/api/drugsalesreturn/create", &StockDrugApiController{}, "post:CreateDrugSalesReturn")
  28. beego.Router("/api/drugsalesreturn/delete", &StockDrugApiController{}, "post:DeleteDrugSalesReturn")
  29. beego.Router("/api/drugsalesreturninfo/delete", &StockDrugApiController{}, "post:DeleteDrugSalesReturnInfo")
  30. beego.Router("/api/drugsalesreturninfo/list", &StockDrugApiController{}, "get:GetDrugSalesReturnInfoList")
  31. beego.Router("/api/drugsalesreturn/list", &StockDrugApiController{}, "get:GetDrugSalesReturnList")
  32. beego.Router("/api/drugsalesreturn/edit", &StockDrugApiController{}, "post:EditDrugReturnInfo")
  33. //出库管理和其他出库管理相关接口
  34. beego.Router("/api/drugwarehouseout/create", &StockDrugApiController{}, "post:CreateDrugWarehouseOut")
  35. beego.Router("/api/drugwarehouseout/delete", &StockDrugApiController{}, "post:DeleteDrugWarehouseOut")
  36. beego.Router("/api/drugwarehouseoutinfo/delete", &StockDrugApiController{}, "post:DeleteDrugWarehouseOutInfo")
  37. beego.Router("/api/drugwarehouseout/list", &StockDrugApiController{}, "get:GetDrugWarehouseOutList")
  38. beego.Router("/api/drugwarehouseout/edit", &StockDrugApiController{}, "post:EditDrugWarehouseOut")
  39. beego.Router("/api/drugwarehouseout/info", &StockDrugApiController{}, "get:GetDrugWarehouseOutInfoList")
  40. //出库退库管理和其他出库退库管理相关接口
  41. beego.Router("/api/drugcancelstock/create", &StockDrugApiController{}, "post:CreateDrugCancelStock")
  42. beego.Router("/api/drugcancelstock/list", &StockDrugApiController{}, "get:GetDrugCancelStockList")
  43. beego.Router("/api/drugcancelstock/info", &StockDrugApiController{}, "get:GetDrugCancelStockInfoList")
  44. beego.Router("/api/drugcancelstock/delete", &StockDrugApiController{}, "post:DeleteDrugCancelStock")
  45. beego.Router("/api/drugcancelstockinfo/delete", &StockDrugApiController{}, "post:DeleteDrugCancelStockInfo")
  46. beego.Router("/api/drugcancelstockinfo/edit", &StockDrugApiController{}, "post:EditDrugCancelStock")
  47. //beego.Router("/api/drugcancelstockinfo/config", &StockDrugApiController{}, "get:GetDrugCancelStockConfig")
  48. ////库存相关全局配置
  49. beego.Router("/api/drugstock/config", &StockDrugApiController{}, "get:GetAllConfig")
  50. //beego.Router("/api/drugreturn/config", &StockDrugApiController{}, "get:GetAllSalesReturnConfig")
  51. //
  52. ////库存查询
  53. beego.Router("/api/drugstock/query", &StockDrugApiController{}, "get:GetDrugQueryInfo")
  54. //
  55. //beego.Router("/api/drugstock/detail", &StockDrugApiController{}, "get:GetDetailInfo")
  56. //
  57. beego.Router("/api/drugwarehouseout/user", &StockDrugApiController{}, "get:GetUserDetailInfo")
  58. beego.Router("/api/drugstock/get", &StockDrugApiController{}, "get:GetAllDrugStock")
  59. beego.Router("/api/drug/getcanceldrugorderprint", &StockDrugApiController{}, "get:GetCancelDrugOrderPrint")
  60. beego.Router("/api/drug/drugcancelexportlist", &StockDrugApiController{}, "get:GetDrugCancelExportList")
  61. }
  62. func (c *StockDrugApiController) CreateDrugWarehouse() {
  63. warehousing_time := c.GetString("warehousing_time")
  64. types, _ := c.GetInt64("type", 0)
  65. ctime := time.Now().Unix()
  66. adminUserInfo := c.GetAdminUserInfo()
  67. warehousingDate, parseDateErr := utils.ParseTimeStringToTime("2006-01-02", warehousing_time)
  68. if parseDateErr != nil {
  69. c.ErrorLog("日期(%v)解析错误:%v", warehousingDate, parseDateErr)
  70. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  71. return
  72. }
  73. timeStr := time.Now().Format("2006-01-02")
  74. timeArr := strings.Split(timeStr, "-")
  75. total, _ := service.FindAllWarehouseTotal(adminUserInfo.CurrentOrgId)
  76. total = total + 1
  77. warehousing_order := "YPRKD" + strconv.FormatInt(adminUserInfo.CurrentOrgId, 10) + timeArr[0] + timeArr[1] + timeArr[2] + "000" + strconv.FormatInt(total, 10)
  78. operation_time := time.Now().Unix()
  79. creater := adminUserInfo.AdminUser.Id
  80. warehousing := models.DrugWarehouse{
  81. WarehousingOrder: warehousing_order,
  82. OperationTime: operation_time,
  83. OrgId: adminUserInfo.CurrentOrgId,
  84. Creater: creater,
  85. Ctime: ctime,
  86. Status: 1,
  87. WarehousingTime: warehousingDate.Unix(),
  88. Type: types,
  89. }
  90. service.AddSigleDrugWarehouse(&warehousing)
  91. dataBody := make(map[string]interface{}, 0)
  92. err := json.Unmarshal(c.Ctx.Input.RequestBody, &dataBody)
  93. if err != nil {
  94. utils.ErrorLog(err.Error())
  95. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  96. return
  97. }
  98. var warehousingInfo []*models.DrugWarehouseInfo
  99. var drugFlow []*models.DrugFlow
  100. if dataBody["stockIn"] != nil && reflect.TypeOf(dataBody["stockIn"]).String() == "[]interface {}" {
  101. thisStockIn, _ := dataBody["stockIn"].([]interface{})
  102. if len(thisStockIn) > 0 {
  103. for _, item := range thisStockIn {
  104. items := item.(map[string]interface{})
  105. if items["drug_id"] == nil || reflect.TypeOf(items["drug_id"]).String() != "float64" {
  106. utils.ErrorLog("drug_id")
  107. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  108. return
  109. }
  110. drug_id := int64(items["drug_id"].(float64))
  111. if items["warehousing_count"] == nil || reflect.TypeOf(items["warehousing_count"]).String() != "string" {
  112. utils.ErrorLog("warehousing_count")
  113. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  114. return
  115. }
  116. warehousing_count, _ := strconv.ParseInt(items["warehousing_count"].(string), 10, 64)
  117. if items["last_price"] == nil || reflect.TypeOf(items["last_price"]).String() != "string" {
  118. utils.ErrorLog("last_price")
  119. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  120. return
  121. }
  122. last_price, _ := strconv.ParseFloat(items["last_price"].(string), 64)
  123. total := float64(warehousing_count) * last_price
  124. retail_price_total := float64(warehousing_count) * last_price
  125. var productDates int64
  126. var expiryDates int64
  127. if items["expiry_date"] == nil || reflect.TypeOf(items["expiry_date"]).String() != "string" {
  128. expiryDates = 0
  129. } else {
  130. if len(items["expiry_date"].(string)) == 0 {
  131. expiryDates = 0
  132. } else {
  133. expiryDate, _ := items["expiry_date"].(string)
  134. expiry_date, _ := utils.ParseTimeStringToTime("2006-01-02", expiryDate)
  135. expiryDates = expiry_date.Unix()
  136. }
  137. }
  138. if items["product_date"] == nil || reflect.TypeOf(items["product_date"]).String() != "string" {
  139. productDates = 0
  140. } else {
  141. if len(items["product_date"].(string)) == 0 {
  142. productDates = 0
  143. } else {
  144. productDate, _ := items["product_date"].(string)
  145. product_date, _ := utils.ParseTimeStringToTime("2006-01-02", productDate)
  146. productDates = product_date.Unix()
  147. }
  148. }
  149. number, _ := items["number"].(string)
  150. batch_number, _ := items["batch_number"].(string)
  151. if items["max_unit"] == nil || reflect.TypeOf(items["max_unit"]).String() != "string" {
  152. utils.ErrorLog("max_unit")
  153. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  154. return
  155. }
  156. max_unit, _ := items["max_unit"].(string)
  157. if items["min_unit"] == nil || reflect.TypeOf(items["min_unit"]).String() != "string" {
  158. utils.ErrorLog("min_unit")
  159. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  160. return
  161. }
  162. min_unit, _ := items["min_unit"].(string)
  163. var remark string
  164. if items["remark"] == nil || reflect.TypeOf(items["remark"]).String() != "string" {
  165. remark = ""
  166. } else {
  167. remark = items["remark"].(string)
  168. }
  169. manufacturer := int64(items["manufacturer"].(float64))
  170. dealer := int64(items["dealer"].(float64))
  171. warehouseInfo := &models.DrugWarehouseInfo{
  172. WarehousingOrder: warehousing.WarehousingOrder,
  173. WarehousingId: warehousing.ID,
  174. DrugId: drug_id,
  175. Number: number,
  176. ProductDate: productDates,
  177. ExpiryDate: expiryDates,
  178. WarehousingCount: warehousing_count,
  179. Price: last_price,
  180. TotalPrice: total,
  181. Status: 1,
  182. Ctime: ctime,
  183. Remark: remark,
  184. OrgId: adminUserInfo.CurrentOrgId,
  185. Type: types,
  186. Manufacturer: manufacturer,
  187. Dealer: dealer,
  188. StockMaxNumber: warehousing_count,
  189. RetailTotalPrice: retail_price_total,
  190. BatchNumber: batch_number,
  191. MaxUnit: max_unit,
  192. MinUnit: min_unit,
  193. }
  194. warehousingInfo = append(warehousingInfo, warehouseInfo)
  195. drugflow := &models.DrugFlow{
  196. WarehousingOrder: warehousing.WarehousingOrder,
  197. WarehousingId: warehousing.ID,
  198. DrugId: drug_id,
  199. Number: number,
  200. ProductDate: productDates,
  201. ExpireDate: expiryDates,
  202. Count: warehousing_count,
  203. Price: last_price,
  204. Status: 1,
  205. Ctime: ctime,
  206. UserOrgId: adminUserInfo.CurrentOrgId,
  207. Manufacturer: manufacturer,
  208. Dealer: dealer,
  209. BatchNumber: batch_number,
  210. MaxUnit: max_unit,
  211. MinUnit: min_unit,
  212. ConsumableType: 1,
  213. IsEdit: 1,
  214. Creator: adminUserInfo.AdminUser.Id,
  215. IsSys: 0,
  216. }
  217. drugFlow = append(drugFlow, drugflow)
  218. }
  219. }
  220. }
  221. //创建入库单
  222. errs := service.CreateDrugWarehousingInfo(warehousingInfo)
  223. if errs == nil {
  224. //更改库存
  225. service.UpdateDrugInfo(warehousingInfo)
  226. }
  227. //创建流水单
  228. service.CreateDrugFlow(drugFlow)
  229. info, _ := service.FindLastDrugWarehousingInfo(warehousing.WarehousingOrder)
  230. if errs != nil {
  231. utils.ErrorLog(errs.Error())
  232. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCreateStockInFail)
  233. return
  234. }
  235. c.ServeSuccessJSON(map[string]interface{}{
  236. "msg": "入库成功",
  237. "warehousing_order": warehousing_order,
  238. "info": info,
  239. })
  240. }
  241. func (c *StockDrugApiController) GetDrugWarehouseList() {
  242. page, _ := c.GetInt64("page", -1)
  243. limit, _ := c.GetInt64("limit", -1)
  244. start_time := c.GetString("start_time")
  245. end_time := c.GetString("end_time")
  246. types, _ := c.GetInt64("type", 0)
  247. keywords := c.GetString("keywords")
  248. timeLayout := "2006-01-02"
  249. loc, _ := time.LoadLocation("Local")
  250. var startTime int64
  251. if len(start_time) > 0 {
  252. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", start_time+" 00:00:00", loc)
  253. if err != nil {
  254. fmt.Println(err)
  255. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  256. return
  257. }
  258. startTime = theTime.Unix()
  259. }
  260. var endTime int64
  261. if len(end_time) > 0 {
  262. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", end_time+" 23:59:59", loc)
  263. if err != nil {
  264. utils.ErrorLog(err.Error())
  265. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  266. return
  267. }
  268. endTime = theTime.Unix()
  269. }
  270. adminUserInfo := c.GetAdminUserInfo()
  271. fmt.Println("hhh2h3h23h2h32h3h2h32h32h3h2h3", keywords)
  272. //按药品名称搜索
  273. var ids []int64
  274. var idArray []int64
  275. list, _ := service.GetDrugNameByKeyword(keywords, adminUserInfo.CurrentOrgId)
  276. for _, item := range list {
  277. ids = append(ids, item.ID)
  278. }
  279. //查找入库单详情
  280. if len(ids) > 0 {
  281. info, _ := service.GetDrugWarehouseOrderDetailTwo(ids, adminUserInfo.CurrentOrgId, startTime, endTime)
  282. for _, it := range info {
  283. idArray = append(idArray, it.WarehousingId)
  284. }
  285. }
  286. warehouseList, total, err := service.FindAllDrugWarehousingListOne(adminUserInfo.CurrentOrgId, page, limit, startTime, endTime, types, keywords, idArray)
  287. if err == nil {
  288. c.ServeSuccessJSON(map[string]interface{}{
  289. "list": warehouseList,
  290. "total": total,
  291. })
  292. } else {
  293. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  294. }
  295. }
  296. func (c *StockDrugApiController) GetDrugWarehouseInfoList() {
  297. id, _ := c.GetInt64("id", 0)
  298. if id <= 0 {
  299. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  300. return
  301. }
  302. admin := c.GetAdminUserInfo()
  303. warehousing, err := service.FindDrugWarehousingById(id, admin.CurrentOrgId)
  304. manufacturerList, _ := service.GetAllManufacturerList(admin.CurrentOrgId)
  305. dealerList, _ := service.GetAllDealerList(admin.CurrentOrgId)
  306. if err != nil {
  307. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  308. return
  309. }
  310. if warehousing.ID <= 0 {
  311. return
  312. }
  313. warehousingInfo, err := service.FindDrugWarehousingInfoById(id, admin.CurrentOrgId)
  314. fmt.Println("warehousinginfo000000000000000", warehousingInfo)
  315. if err == nil {
  316. c.ServeSuccessJSON(map[string]interface{}{
  317. "info": warehousingInfo,
  318. "warehousing": warehousing,
  319. "manufacturerList": manufacturerList,
  320. "dealerList": dealerList,
  321. })
  322. } else {
  323. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  324. }
  325. }
  326. func (c *StockDrugApiController) EditDrugWarehouse() {
  327. warehousing_time := c.GetString("warehousing_time")
  328. id, _ := c.GetInt64("id", 0)
  329. types, _ := c.GetInt64("type", 0)
  330. if id == 0 {
  331. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  332. return
  333. }
  334. ctime := time.Now().Unix()
  335. mtime := time.Now().Unix()
  336. adminUserInfo := c.GetAdminUserInfo()
  337. warehousingDate, parseDateErr := utils.ParseTimeStringToTime("2006-01-02", warehousing_time)
  338. if parseDateErr != nil {
  339. c.ErrorLog("日期(%v)解析错误:%v", warehousingDate, parseDateErr)
  340. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  341. return
  342. }
  343. warehouse, _ := service.FindDrugWarehousingById(id, adminUserInfo.CurrentOrgId)
  344. warehousing := models.DrugWarehouse{
  345. WarehousingOrder: warehouse.WarehousingOrder,
  346. OrgId: adminUserInfo.CurrentOrgId,
  347. Modifier: adminUserInfo.AdminUser.Id,
  348. Mtime: mtime,
  349. Status: 1,
  350. WarehousingTime: warehousingDate.Unix(),
  351. Type: warehouse.Type,
  352. }
  353. service.EditDrugWarehousingOne(warehousing, id)
  354. dataBody := make(map[string]interface{}, 0)
  355. err := json.Unmarshal(c.Ctx.Input.RequestBody, &dataBody)
  356. if err != nil {
  357. utils.ErrorLog(err.Error())
  358. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  359. return
  360. }
  361. var warehousingInfo []*models.DrugWarehouseInfo
  362. var upDateWarehousingInfo []*models.DrugWarehouseInfo
  363. var drugFlow []*models.DrugFlow
  364. if dataBody["stockIn"] != nil && reflect.TypeOf(dataBody["stockIn"]).String() == "[]interface {}" {
  365. thisStockIn, _ := dataBody["stockIn"].([]interface{})
  366. if len(thisStockIn) > 0 {
  367. for _, item := range thisStockIn {
  368. items := item.(map[string]interface{})
  369. if items["drug_id"] == nil || reflect.TypeOf(items["drug_id"]).String() != "float64" {
  370. utils.ErrorLog("drug_id")
  371. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  372. return
  373. }
  374. drug_id := int64(items["drug_id"].(float64))
  375. if items["warehousing_count"] == nil || reflect.TypeOf(items["warehousing_count"]).String() != "string" {
  376. utils.ErrorLog("warehousing_count")
  377. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  378. return
  379. }
  380. warehousing_count, _ := strconv.ParseInt(items["warehousing_count"].(string), 10, 64)
  381. if items["price"] == nil || reflect.TypeOf(items["price"]).String() != "string" {
  382. utils.ErrorLog("price")
  383. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  384. return
  385. }
  386. price, _ := strconv.ParseFloat(items["price"].(string), 64)
  387. total := float64(warehousing_count) * price
  388. if items["last_price"] == nil || reflect.TypeOf(items["last_price"]).String() != "string" {
  389. utils.ErrorLog("last_price")
  390. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  391. return
  392. }
  393. last_price, _ := strconv.ParseFloat(items["last_price"].(string), 64)
  394. retail_price_total := float64(warehousing_count) * last_price
  395. var productDates int64
  396. var expiryDates int64
  397. if items["expiry_date"] == nil || reflect.TypeOf(items["expiry_date"]).String() != "string" {
  398. expiryDates = 0
  399. } else {
  400. if len(items["expiry_date"].(string)) == 0 {
  401. expiryDates = 0
  402. } else {
  403. expiryDate, _ := items["expiry_date"].(string)
  404. expiry_date, _ := utils.ParseTimeStringToTime("2006-01-02", expiryDate)
  405. expiryDates = expiry_date.Unix()
  406. }
  407. }
  408. if items["product_date"] == nil || reflect.TypeOf(items["product_date"]).String() != "string" {
  409. productDates = 0
  410. } else {
  411. if len(items["product_date"].(string)) == 0 {
  412. productDates = 0
  413. } else {
  414. productDate, _ := items["product_date"].(string)
  415. product_date, _ := utils.ParseTimeStringToTime("2006-01-02", productDate)
  416. productDates = product_date.Unix()
  417. }
  418. }
  419. number, _ := items["number"].(string)
  420. batch_number, _ := items["batch_number"].(string)
  421. max_unit, _ := items["max_unit"].(string)
  422. min_unit, _ := items["min_unit"].(string)
  423. var remark string
  424. if items["remark"] == nil || reflect.TypeOf(items["remark"]).String() != "string" {
  425. remark = ""
  426. } else {
  427. remark = items["remark"].(string)
  428. }
  429. if items["id"] == nil || reflect.TypeOf(items["id"]).String() != "float64" {
  430. utils.ErrorLog("id")
  431. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  432. return
  433. }
  434. id := int64(items["id"].(float64))
  435. manufacturer := int64(items["manufacturer"].(float64))
  436. dealer := int64(items["dealer"].(float64))
  437. if id == 0 {
  438. warehouseInfo := &models.DrugWarehouseInfo{
  439. WarehousingOrder: warehouse.WarehousingOrder,
  440. WarehousingId: warehouse.ID,
  441. DrugId: drug_id,
  442. Number: number,
  443. ProductDate: productDates,
  444. ExpiryDate: expiryDates,
  445. WarehousingCount: warehousing_count,
  446. Price: price,
  447. TotalPrice: total,
  448. Status: 1,
  449. Ctime: ctime,
  450. Remark: remark,
  451. OrgId: adminUserInfo.CurrentOrgId,
  452. Type: types,
  453. Manufacturer: manufacturer,
  454. Dealer: dealer,
  455. RetailPrice: last_price,
  456. RetailTotalPrice: retail_price_total,
  457. BatchNumber: batch_number,
  458. MaxUnit: max_unit,
  459. MinUnit: min_unit,
  460. }
  461. warehousingInfo = append(warehousingInfo, warehouseInfo)
  462. } else {
  463. warehouseInfo := &models.DrugWarehouseInfo{
  464. ID: id,
  465. WarehousingOrder: warehouse.WarehousingOrder,
  466. WarehousingId: warehouse.ID,
  467. DrugId: drug_id,
  468. Number: number,
  469. ProductDate: productDates,
  470. ExpiryDate: expiryDates,
  471. WarehousingCount: warehousing_count,
  472. Price: price,
  473. TotalPrice: total,
  474. Status: 1,
  475. Ctime: ctime,
  476. Remark: remark,
  477. OrgId: adminUserInfo.CurrentOrgId,
  478. Type: types,
  479. Manufacturer: manufacturer,
  480. Dealer: dealer,
  481. RetailPrice: last_price,
  482. RetailTotalPrice: retail_price_total,
  483. StockMaxNumber: warehousing_count,
  484. MaxUnit: max_unit,
  485. MinUnit: min_unit,
  486. BatchNumber: batch_number,
  487. }
  488. upDateWarehousingInfo = append(upDateWarehousingInfo, warehouseInfo)
  489. drugflow := &models.DrugFlow{
  490. WarehousingOrder: warehousing.WarehousingOrder,
  491. WarehousingId: warehousing.ID,
  492. DrugId: drug_id,
  493. Number: number,
  494. ProductDate: productDates,
  495. ExpireDate: expiryDates,
  496. Count: warehousing_count,
  497. Price: last_price,
  498. Status: 1,
  499. Ctime: ctime,
  500. UserOrgId: adminUserInfo.CurrentOrgId,
  501. Manufacturer: manufacturer,
  502. Dealer: dealer,
  503. BatchNumber: batch_number,
  504. MaxUnit: max_unit,
  505. MinUnit: min_unit,
  506. ConsumableType: 1,
  507. IsEdit: 1,
  508. Creator: adminUserInfo.AdminUser.Id,
  509. IsSys: 0,
  510. }
  511. drugFlow = append(drugFlow, drugflow)
  512. }
  513. }
  514. }
  515. }
  516. var errs error
  517. if len(warehousingInfo) > 0 {
  518. errs = service.CreateDrugWarehousingInfo(warehousingInfo)
  519. if errs == nil {
  520. service.CreateDrugFlow(drugFlow)
  521. //更改库存
  522. service.UpdateDrugInfo(warehousingInfo)
  523. }
  524. }
  525. if len(upDateWarehousingInfo) > 0 {
  526. var total int64
  527. var minNumber float64
  528. var allTotal int64
  529. for _, item := range upDateWarehousingInfo {
  530. //查询修改的记录
  531. orderInfo, _ := service.GetDrugWarehouseOrderOne(id, item.DrugId)
  532. info, _ := service.FindeDrugInfo(item.DrugId)
  533. total = orderInfo.StockMaxNumber * info.MinNumber
  534. allTotal = item.WarehousingCount*info.MinNumber - total
  535. str := strconv.FormatInt(allTotal, 10)
  536. minFloat, _ := strconv.ParseFloat(str, 64)
  537. minNumber = info.Total + minFloat
  538. lib := models.BaseDrugLib{
  539. Total: minNumber,
  540. }
  541. service.UpdateBaseDrug(&lib, item.DrugId)
  542. errs = service.UpDateDrugWarehousingInfo(item)
  543. service.CreateDrugFlow(drugFlow)
  544. }
  545. }
  546. if errs != nil {
  547. utils.ErrorLog(errs.Error())
  548. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCreateStockInFail)
  549. return
  550. }
  551. c.ServeSuccessJSON(map[string]interface{}{
  552. "msg": "编辑成功",
  553. })
  554. }
  555. func (c *StockDrugApiController) DeleteDrugWarehouse() {
  556. ids := c.GetString("ids")
  557. if len(ids) == 0 {
  558. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  559. return
  560. }
  561. idArray := strings.Split(ids, ",")
  562. err := service.DeleteDrugWarehouse(idArray)
  563. if err != nil {
  564. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDeleteFail)
  565. } else {
  566. c.ServeSuccessJSON(map[string]interface{}{
  567. "msg": "删除成功",
  568. })
  569. }
  570. }
  571. func (c *StockDrugApiController) DeleteDrugWarehouseInfo() {
  572. id, _ := c.GetInt64("id", 0)
  573. if id == 0 {
  574. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  575. return
  576. }
  577. err := service.UpDateDrugWarehouseStatus(id)
  578. if err != nil {
  579. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDeleteFail)
  580. } else {
  581. c.ServeSuccessJSON(map[string]interface{}{
  582. "msg": "删除成功",
  583. })
  584. }
  585. }
  586. func (c *StockDrugApiController) CreateDrugSalesReturn() {
  587. dealer_id, _ := c.GetInt64("dealer_id", 0)
  588. manufacturer_id, _ := c.GetInt64("manufacturer_id", 0)
  589. sales_return_time := c.GetString("time")
  590. types, _ := c.GetInt64("type", 0)
  591. salesReturnDate, parseDateErr := utils.ParseTimeStringToTime("2006-01-02", sales_return_time)
  592. if parseDateErr != nil {
  593. c.ErrorLog("日期(%v)解析错误:%v", salesReturnDate, parseDateErr)
  594. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  595. return
  596. }
  597. adminUserInfo := c.GetAdminUserInfo()
  598. operation_time := time.Now().Unix()
  599. creater := adminUserInfo.AdminUser.Id
  600. ctime := time.Now().Unix()
  601. timeStr := time.Now().Format("2006-01-02")
  602. timeArr := strings.Split(timeStr, "-")
  603. total, _ := service.FindAllSalesReturnTotal(adminUserInfo.CurrentOrgId)
  604. total = total + 1
  605. orderNumber := "YPTHD" + strconv.FormatInt(adminUserInfo.CurrentOrgId, 10) + timeArr[0] + timeArr[1] + timeArr[2] + "000" + strconv.FormatInt(total, 10)
  606. salesReturn := models.DrugSalesReturn{
  607. OrderNumber: orderNumber,
  608. OperaTime: operation_time,
  609. OrgId: adminUserInfo.CurrentOrgId,
  610. Creater: creater,
  611. Ctime: ctime,
  612. Status: 1,
  613. ReturnTime: salesReturnDate.Unix(),
  614. Dealer: dealer_id,
  615. Manufacturer: manufacturer_id,
  616. Type: types,
  617. }
  618. service.AddSigleDrugSalesReturn(&salesReturn)
  619. dataBody := make(map[string]interface{}, 0)
  620. err := json.Unmarshal(c.Ctx.Input.RequestBody, &dataBody)
  621. if err != nil {
  622. utils.ErrorLog(err.Error())
  623. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  624. return
  625. }
  626. var salesReturnInfos []*models.DrugSalesReturnInfo
  627. if dataBody["salesReturn"] != nil && reflect.TypeOf(dataBody["salesReturn"]).String() == "[]interface {}" {
  628. thisStockIn, _ := dataBody["salesReturn"].([]interface{})
  629. if len(thisStockIn) > 0 {
  630. for _, item := range thisStockIn {
  631. items := item.(map[string]interface{})
  632. if items["drug_id"] == nil || reflect.TypeOf(items["drug_id"]).String() != "float64" {
  633. utils.ErrorLog("drug_id")
  634. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  635. return
  636. }
  637. drug_id := int64(items["drug_id"].(float64))
  638. return_count, _ := items["return_count"].(string)
  639. if len(return_count) == 0 {
  640. utils.ErrorLog("len(return_count) == 0")
  641. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  642. return
  643. }
  644. count, _ := strconv.ParseInt(return_count, 10, 64)
  645. if items["price"] == nil || reflect.TypeOf(items["price"]).String() != "string" {
  646. utils.ErrorLog("price")
  647. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  648. return
  649. }
  650. price, _ := strconv.ParseFloat(items["price"].(string), 64)
  651. total := float64(count) * price
  652. if items["retail_price"] == nil || reflect.TypeOf(items["retail_price"]).String() != "string" {
  653. utils.ErrorLog("retail_price")
  654. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  655. return
  656. }
  657. retail_price, _ := strconv.ParseFloat(items["retail_price"].(string), 64)
  658. retail_price_total := float64(count) * retail_price
  659. salesReturnInfo := &models.DrugSalesReturnInfo{
  660. OrderNumber: salesReturn.OrderNumber,
  661. SalesReturnId: salesReturn.ID,
  662. DrugId: drug_id,
  663. Count: count,
  664. Price: price,
  665. Total: total,
  666. Status: 1,
  667. Ctime: ctime,
  668. OrgId: adminUserInfo.CurrentOrgId,
  669. Type: types,
  670. Manufacturer: manufacturer_id,
  671. Dealer: dealer_id,
  672. RetailPrice: retail_price,
  673. RetailTotalPrice: retail_price_total,
  674. }
  675. salesReturnInfos = append(salesReturnInfos, salesReturnInfo)
  676. }
  677. }
  678. }
  679. errs := service.CreateDrugSalesReturnInfo(salesReturnInfos)
  680. if errs != nil {
  681. utils.ErrorLog(errs.Error())
  682. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCreateReturnFail)
  683. return
  684. }
  685. c.ServeSuccessJSON(map[string]interface{}{
  686. "msg": "退货成功",
  687. })
  688. }
  689. func (c *StockDrugApiController) GetDrugSalesReturnList() {
  690. page, _ := c.GetInt64("page", -1)
  691. limit, _ := c.GetInt64("limit", -1)
  692. start_time := c.GetString("start_time")
  693. end_time := c.GetString("end_time")
  694. types, _ := c.GetInt64("type", 0)
  695. keywords := c.GetString("keywords")
  696. timeLayout := "2006-01-02"
  697. loc, _ := time.LoadLocation("Local")
  698. var startTime int64
  699. if len(start_time) > 0 {
  700. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", start_time+" 00:00:00", loc)
  701. if err != nil {
  702. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  703. return
  704. }
  705. startTime = theTime.Unix()
  706. }
  707. var endTime int64
  708. if len(end_time) > 0 {
  709. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", end_time+" 23:59:59", loc)
  710. if err != nil {
  711. utils.ErrorLog(err.Error())
  712. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  713. return
  714. }
  715. endTime = theTime.Unix()
  716. }
  717. adminUserInfo := c.GetAdminUserInfo()
  718. returnList, total, err := service.FindAllDrugReturnList(adminUserInfo.CurrentOrgId, page, limit, startTime, endTime, types, keywords)
  719. if err == nil {
  720. c.ServeSuccessJSON(map[string]interface{}{
  721. "list": returnList,
  722. "total": total,
  723. })
  724. } else {
  725. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  726. }
  727. }
  728. func (this *StockDrugApiController) DeleteDrugSalesReturn() {
  729. ids := this.GetString("ids")
  730. if len(ids) == 0 {
  731. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  732. return
  733. }
  734. idArray := strings.Split(ids, ",")
  735. err := service.DeleteDrugSalesReturn(idArray)
  736. if err != nil {
  737. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDeleteFail)
  738. } else {
  739. this.ServeSuccessJSON(map[string]interface{}{
  740. "msg": "删除成功",
  741. })
  742. }
  743. }
  744. func (this *StockDrugApiController) DeleteDrugSalesReturnInfo() {
  745. id, _ := this.GetInt64("id", 0)
  746. fmt.Println(id)
  747. if id == 0 {
  748. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  749. return
  750. }
  751. err := service.UpDateDrugSaleReturnStatus(id)
  752. if err != nil {
  753. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDeleteFail)
  754. } else {
  755. this.ServeSuccessJSON(map[string]interface{}{
  756. "msg": "删除成功",
  757. })
  758. }
  759. }
  760. func (this *StockDrugApiController) GetDrugSalesReturnInfoList() {
  761. id, _ := this.GetInt64("id", 0)
  762. adminUserInfo := this.GetAdminUserInfo()
  763. list, _ := service.FindAllDrugSalesReturnInfoById(id, adminUserInfo.CurrentOrgId)
  764. salesReturn, _ := service.FindAllDrugSalesReturnById(id, adminUserInfo.CurrentOrgId)
  765. this.ServeSuccessJSON(map[string]interface{}{
  766. "list": list,
  767. "salesReturn": salesReturn,
  768. })
  769. }
  770. func (c *StockDrugApiController) EditDrugReturnInfo() {
  771. return_time := c.GetString("return_time")
  772. id, _ := c.GetInt64("id", 0)
  773. types, _ := c.GetInt64("type", 0)
  774. manufacturer_id, _ := c.GetInt64("manufacturer_id", 0)
  775. dealer_id, _ := c.GetInt64("dealer_id", 0)
  776. if id == 0 {
  777. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  778. return
  779. }
  780. ctime := time.Now().Unix()
  781. mtime := time.Now().Unix()
  782. adminUserInfo := c.GetAdminUserInfo()
  783. returnDate, parseDateErr := utils.ParseTimeStringToTime("2006-01-02", return_time)
  784. if parseDateErr != nil {
  785. c.ErrorLog("日期(%v)解析错误:%v", returnDate, parseDateErr)
  786. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  787. return
  788. }
  789. salesReturns, _ := service.FindDrugSalesReturnById(id)
  790. sales := models.DrugSalesReturn{
  791. ID: salesReturns.ID,
  792. Mtime: mtime,
  793. ReturnTime: returnDate.Unix(),
  794. Manufacturer: manufacturer_id,
  795. Dealer: dealer_id,
  796. }
  797. service.EditDrugSaleReturn(sales)
  798. dataBody := make(map[string]interface{}, 0)
  799. err := json.Unmarshal(c.Ctx.Input.RequestBody, &dataBody)
  800. if err != nil {
  801. utils.ErrorLog(err.Error())
  802. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  803. return
  804. }
  805. var returnInfos []*models.DrugSalesReturnInfo
  806. var upDateReturnInfos []*models.DrugSalesReturnInfo
  807. if dataBody["salesReturn"] != nil && reflect.TypeOf(dataBody["salesReturn"]).String() == "[]interface {}" {
  808. thisStockIn, _ := dataBody["salesReturn"].([]interface{})
  809. if len(thisStockIn) > 0 {
  810. for _, item := range thisStockIn {
  811. items := item.(map[string]interface{})
  812. if items["drug_id"] == nil || reflect.TypeOf(items["drug_id"]).String() != "float64" {
  813. utils.ErrorLog("drug_id")
  814. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  815. return
  816. }
  817. drug_id := int64(items["drug_id"].(float64))
  818. if items["count"] == nil || reflect.TypeOf(items["count"]).String() != "string" {
  819. utils.ErrorLog("count")
  820. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  821. return
  822. }
  823. count, _ := strconv.ParseInt(items["count"].(string), 10, 64)
  824. if items["id"] == nil || reflect.TypeOf(items["id"]).String() != "float64" {
  825. utils.ErrorLog("id")
  826. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  827. return
  828. }
  829. id := int64(items["id"].(float64))
  830. if items["price"] == nil || reflect.TypeOf(items["price"]).String() != "string" {
  831. utils.ErrorLog("price")
  832. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  833. return
  834. }
  835. price, _ := strconv.ParseFloat(items["price"].(string), 64)
  836. total := float64(count) * price
  837. if items["retail_price"] == nil || reflect.TypeOf(items["retail_price"]).String() != "string" {
  838. utils.ErrorLog("retail_price")
  839. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  840. return
  841. }
  842. retail_price, _ := strconv.ParseFloat(items["retail_price"].(string), 64)
  843. retail_price_total := float64(count) * retail_price
  844. if id == 0 {
  845. returnInfo := &models.DrugSalesReturnInfo{
  846. DrugId: drug_id,
  847. Count: count,
  848. Status: 1,
  849. Ctime: ctime,
  850. OrgId: adminUserInfo.CurrentOrgId,
  851. OrderNumber: sales.OrderNumber,
  852. SalesReturnId: sales.ID,
  853. Mtime: time.Now().Unix(),
  854. Type: types,
  855. Manufacturer: manufacturer_id,
  856. Dealer: dealer_id,
  857. RetailPrice: retail_price,
  858. RetailTotalPrice: retail_price_total,
  859. Total: total,
  860. Price: price,
  861. }
  862. returnInfos = append(returnInfos, returnInfo)
  863. } else {
  864. returnInfo := &models.DrugSalesReturnInfo{
  865. ID: id,
  866. DrugId: drug_id,
  867. Count: count,
  868. Status: 1,
  869. Ctime: ctime,
  870. OrgId: adminUserInfo.CurrentOrgId,
  871. OrderNumber: sales.OrderNumber,
  872. SalesReturnId: sales.ID,
  873. Mtime: time.Now().Unix(),
  874. Type: types,
  875. Manufacturer: manufacturer_id,
  876. Dealer: dealer_id,
  877. RetailPrice: retail_price,
  878. RetailTotalPrice: retail_price_total,
  879. Total: total,
  880. Price: price,
  881. }
  882. upDateReturnInfos = append(upDateReturnInfos, returnInfo)
  883. }
  884. }
  885. }
  886. }
  887. var errs error
  888. if len(returnInfos) > 0 {
  889. errs = service.CreateDrugSalesReturnInfo(returnInfos)
  890. }
  891. if len(upDateReturnInfos) > 0 {
  892. for _, item := range upDateReturnInfos {
  893. errs = service.UpDateDrugSalesReturnInfo(item)
  894. }
  895. }
  896. if errs != nil {
  897. utils.ErrorLog(errs.Error())
  898. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCreateReturnFail)
  899. return
  900. }
  901. c.ServeSuccessJSON(map[string]interface{}{
  902. "msg": "编辑成功",
  903. })
  904. }
  905. func (c *StockDrugApiController) CreateDrugWarehouseOut() {
  906. types, _ := c.GetInt64("type", 0)
  907. ctime := time.Now().Unix()
  908. adminUserInfo := c.GetAdminUserInfo()
  909. warehousing_out_time := c.GetString("warehousing_out_time")
  910. warehousingOutDate, parseDateErr := utils.ParseTimeStringToTime("2006-01-02", warehousing_out_time)
  911. if parseDateErr != nil {
  912. c.ErrorLog("日期(%v)解析错误:%v", warehousingOutDate, parseDateErr)
  913. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  914. return
  915. }
  916. timeStr := time.Now().Format("2006-01-02")
  917. timeArr := strings.Split(timeStr, "-")
  918. total, _ := service.FindAllDrugWarehouseOut(adminUserInfo.CurrentOrgId)
  919. total = total + 1
  920. warehousing_out_order := strconv.FormatInt(adminUserInfo.CurrentOrgId, 10) + timeArr[0] + timeArr[1] + timeArr[2] + "000"
  921. number, _ := strconv.ParseInt(warehousing_out_order, 10, 64)
  922. number = number + total
  923. warehousing_out_order = "YPCKD" + strconv.FormatInt(number, 10)
  924. operation_time := time.Now().Unix()
  925. creater := adminUserInfo.AdminUser.Id
  926. warehouseOut := models.DrugWarehouseOut{
  927. WarehouseOutOrderNumber: warehousing_out_order,
  928. OperationTime: operation_time,
  929. OrgId: adminUserInfo.CurrentOrgId,
  930. Creater: creater,
  931. Ctime: ctime,
  932. Status: 1,
  933. WarehouseOutTime: warehousingOutDate.Unix(),
  934. Type: types,
  935. }
  936. dataBody := make(map[string]interface{}, 0)
  937. err := json.Unmarshal(c.Ctx.Input.RequestBody, &dataBody)
  938. if err != nil {
  939. utils.ErrorLog(err.Error())
  940. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  941. return
  942. }
  943. var warehousingOutInfo []*models.DrugWarehouseOutInfo
  944. var drugFlow []*models.DrugFlow
  945. if dataBody["stockOut"] != nil && reflect.TypeOf(dataBody["stockOut"]).String() == "[]interface {}" {
  946. thisStockIn, _ := dataBody["stockOut"].([]interface{})
  947. if len(thisStockIn) > 0 {
  948. for _, item := range thisStockIn {
  949. items := item.(map[string]interface{})
  950. if items["drug_id"] == nil || reflect.TypeOf(items["drug_id"]).String() != "float64" {
  951. utils.ErrorLog("drug_id")
  952. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  953. return
  954. }
  955. drug_id := int64(items["drug_id"].(float64))
  956. if items["count"] == nil || reflect.TypeOf(items["count"]).String() != "string" {
  957. utils.ErrorLog("count")
  958. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  959. return
  960. }
  961. if items["price"] == nil || reflect.TypeOf(items["price"]).String() != "string" {
  962. utils.ErrorLog("price")
  963. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  964. return
  965. }
  966. price, _ := strconv.ParseFloat(items["price"].(string), 64)
  967. //if items["last_price"] == nil || reflect.TypeOf(items["last_price"]).String() != "string" {
  968. // utils.ErrorLog("last_price")
  969. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  970. // return
  971. //}
  972. //last_price, _ := strconv.ParseFloat(items["last_price"].(string), 64)
  973. //fmt.Println(last_price)
  974. count, _ := strconv.ParseInt(items["count"].(string), 10, 64)
  975. total := float64(count) * price
  976. retail_price_total := float64(count) * price
  977. remark := items["remark"].(string)
  978. max_unit := items["max_unit"].(string)
  979. dealer := int64(items["dealer"].(float64))
  980. fmt.Println("dealer2222222222222222222", dealer)
  981. manufacturer := int64(items["manufacturer"].(float64))
  982. fmt.Println("manufacturer22222222222222", manufacturer)
  983. number := items["number"].(string)
  984. batch_number := items["batch_number"].(string)
  985. var productDates int64
  986. var expiryDates int64
  987. if items["expiry_date"] == nil || reflect.TypeOf(items["expiry_date"]).String() != "string" {
  988. expiryDates = 0
  989. } else {
  990. if len(items["expiry_date"].(string)) == 0 {
  991. expiryDates = 0
  992. } else {
  993. expiryDate, _ := items["expiry_date"].(string)
  994. expiry_date, _ := utils.ParseTimeStringToTime("2006-01-02", expiryDate)
  995. expiryDates = expiry_date.Unix()
  996. }
  997. }
  998. if items["product_date"] == nil || reflect.TypeOf(items["product_date"]).String() != "string" {
  999. productDates = 0
  1000. } else {
  1001. if len(items["product_date"].(string)) == 0 {
  1002. productDates = 0
  1003. } else {
  1004. productDate, _ := items["product_date"].(string)
  1005. product_date, _ := utils.ParseTimeStringToTime("2006-01-02", productDate)
  1006. productDates = product_date.Unix()
  1007. }
  1008. }
  1009. warehouseOutInfo := &models.DrugWarehouseOutInfo{
  1010. WarehouseOutOrderNumber: warehouseOut.WarehouseOutOrderNumber,
  1011. WarehouseOutId: warehouseOut.ID,
  1012. DrugId: drug_id,
  1013. Count: count,
  1014. Price: price,
  1015. TotalPrice: total,
  1016. Status: 1,
  1017. Ctime: ctime,
  1018. Remark: remark,
  1019. OrgId: adminUserInfo.CurrentOrgId,
  1020. Type: types,
  1021. Manufacturer: manufacturer,
  1022. Dealer: dealer,
  1023. RetailPrice: price,
  1024. RetailTotalPrice: retail_price_total,
  1025. CountUnit: max_unit,
  1026. ExpiryDate: expiryDates,
  1027. ProductDate: productDates,
  1028. Number: number,
  1029. BatchNumber: batch_number,
  1030. IsSys: 0,
  1031. }
  1032. warehousingOutInfo = append(warehousingOutInfo, warehouseOutInfo)
  1033. drugflow := &models.DrugFlow{
  1034. WarehouseOutId: warehouseOut.ID,
  1035. WarehouseOutOrderNumber: warehousing_out_order,
  1036. DrugId: drug_id,
  1037. Number: number,
  1038. ProductDate: productDates,
  1039. ExpireDate: expiryDates,
  1040. Count: count,
  1041. Price: price,
  1042. Status: 1,
  1043. Ctime: ctime,
  1044. UserOrgId: adminUserInfo.CurrentOrgId,
  1045. Manufacturer: manufacturer,
  1046. Dealer: dealer,
  1047. BatchNumber: batch_number,
  1048. MaxUnit: max_unit,
  1049. ConsumableType: 2,
  1050. IsEdit: 1,
  1051. Creator: adminUserInfo.AdminUser.Id,
  1052. IsSys: 0,
  1053. }
  1054. drugFlow = append(drugFlow, drugflow)
  1055. }
  1056. }
  1057. }
  1058. //调用出库逻辑
  1059. for _, item := range warehousingOutInfo {
  1060. //获取药品库存
  1061. info, _ := service.GetDrugTotalCount(item.DrugId, item.OrgId)
  1062. if item.Count > info.Count {
  1063. goodObj, _ := service.GetDrugByGoodId(item.DrugId)
  1064. c.ServeSuccessJSON(map[string]interface{}{
  1065. "msg": "1",
  1066. "drug_name": goodObj.DrugName,
  1067. "dose": goodObj.Dose,
  1068. "dose_unit": goodObj.DoseUnit,
  1069. "min_number": goodObj.MinNumber,
  1070. "min_unit": goodObj.MinUnit,
  1071. "max_unit": goodObj.MaxUnit,
  1072. })
  1073. return
  1074. } else {
  1075. service.AddSigleDrugWarehouseOut(&warehouseOut)
  1076. service.CreateDrugFlow(drugFlow)
  1077. // 出库流程
  1078. // 1.查询改药品在药品库的规格信息,并将处方里的规格进行换算(尽量将拆零单位转换成包装单位)
  1079. drup, _ := service.FindBaseDrugLibRecord(item.OrgId, item.DrugId)
  1080. if drup.ID > 0 {
  1081. prescribingNumber := item.Count
  1082. service.AutoDrugDeliverInfo(item.OrgId, prescribingNumber, &warehouseOut, &drup, item)
  1083. }
  1084. }
  1085. }
  1086. //errs := service.CreateDrugWarehousingOutInfo(warehousingOutInfo)
  1087. //info, _ := service.FindLastDrugWarehousingOutInfo(warehouseOut.WarehouseOutOrderNumber)
  1088. //if errs != nil {
  1089. // utils.ErrorLog(errs.Error())
  1090. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCreateStockOutFail)
  1091. // return
  1092. //}
  1093. c.ServeSuccessJSON(map[string]interface{}{
  1094. "msg": "2",
  1095. "drug_name": "",
  1096. "dose": "",
  1097. "dose_unit": "",
  1098. "min_number": "",
  1099. "min_unit": "",
  1100. "max_unit": "",
  1101. })
  1102. }
  1103. func (c *StockDrugApiController) GetDrugWarehouseOutList() {
  1104. page, _ := c.GetInt64("page", -1)
  1105. limit, _ := c.GetInt64("limit", -1)
  1106. start_time := c.GetString("start_time")
  1107. end_time := c.GetString("end_time")
  1108. types, _ := c.GetInt64("type", 0)
  1109. keywords := c.GetString("keywords")
  1110. timeLayout := "2006-01-02"
  1111. loc, _ := time.LoadLocation("Local")
  1112. var startTime int64
  1113. if len(start_time) > 0 {
  1114. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", start_time+" 00:00:00", loc)
  1115. if err != nil {
  1116. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  1117. return
  1118. }
  1119. startTime = theTime.Unix()
  1120. }
  1121. var endTime int64
  1122. if len(end_time) > 0 {
  1123. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", end_time+" 23:59:59", loc)
  1124. if err != nil {
  1125. utils.ErrorLog(err.Error())
  1126. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  1127. return
  1128. }
  1129. endTime = theTime.Unix()
  1130. }
  1131. adminUserInfo := c.GetAdminUserInfo()
  1132. var ids []int64
  1133. var goodids []int64
  1134. if len(keywords) > 0 {
  1135. //查询商品名称
  1136. list, _ := service.GetDrugNameByKeyword(keywords, adminUserInfo.CurrentOrgId)
  1137. for _, item := range list {
  1138. goodids = append(goodids, item.ID)
  1139. }
  1140. if len(goodids) > 0 {
  1141. //出库详情但里面查询
  1142. info, _ := service.GetDrugWarehouseOrderDetail(goodids, adminUserInfo.CurrentOrgId, startTime, endTime)
  1143. for _, it := range info {
  1144. ids = append(ids, it.WarehouseOutId)
  1145. }
  1146. }
  1147. }
  1148. warehouseOutList, total, err := service.FindAllDrugWarehouseOutListOne(adminUserInfo.CurrentOrgId, page, limit, startTime, endTime, types, keywords, ids)
  1149. fmt.Println(err)
  1150. if err == nil {
  1151. c.ServeSuccessJSON(map[string]interface{}{
  1152. "list": warehouseOutList,
  1153. "total": total,
  1154. })
  1155. } else {
  1156. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  1157. }
  1158. }
  1159. func (c *StockDrugApiController) DeleteDrugWarehouseOut() {
  1160. ids := c.GetString("ids")
  1161. if len(ids) == 0 {
  1162. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  1163. return
  1164. }
  1165. idArray := strings.Split(ids, ",")
  1166. err := service.DeleteDrugWarehouseOut(idArray)
  1167. if err != nil {
  1168. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDeleteFail)
  1169. } else {
  1170. c.ServeSuccessJSON(map[string]interface{}{
  1171. "msg": "删除成功",
  1172. })
  1173. }
  1174. }
  1175. func (this *StockDrugApiController) DeleteDrugWarehouseOutInfo() {
  1176. id, _ := this.GetInt64("id", 0)
  1177. fmt.Println(id)
  1178. if id == 0 {
  1179. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  1180. return
  1181. }
  1182. err := service.UpDateDrugWarehouseOutStatus(id)
  1183. if err != nil {
  1184. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDeleteFail)
  1185. } else {
  1186. this.ServeSuccessJSON(map[string]interface{}{
  1187. "msg": "删除成功",
  1188. })
  1189. }
  1190. }
  1191. func (c *StockDrugApiController) GetDrugWarehouseOutInfoList() {
  1192. id, _ := c.GetInt64("id", 0)
  1193. adminInfo := c.GetAdminUserInfo()
  1194. warehouseOutInfo, _ := service.FindDrugWarehouseOutInfoById(id, adminInfo.CurrentOrgId)
  1195. warehouseOut, _ := service.FindDrugWareHouseOutById(id, adminInfo.CurrentOrgId)
  1196. manulist, _ := service.GetAllManufacturerList(adminInfo.CurrentOrgId)
  1197. dealerList, _ := service.GetAllDealerList(adminInfo.CurrentOrgId)
  1198. c.ServeSuccessJSON(map[string]interface{}{
  1199. "list": warehouseOutInfo,
  1200. "info": warehouseOut,
  1201. "manulist": manulist,
  1202. "dealerList": dealerList,
  1203. })
  1204. }
  1205. func (c *StockDrugApiController) EditDrugWarehouseOut() {
  1206. warehouse_out_time := c.GetString("warehouse_out_time")
  1207. id, _ := c.GetInt64("id", 0)
  1208. types, _ := c.GetInt64("type", 0)
  1209. if id == 0 {
  1210. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  1211. return
  1212. }
  1213. ctime := time.Now().Unix()
  1214. mtime := time.Now().Unix()
  1215. adminUserInfo := c.GetAdminUserInfo()
  1216. warehouseOutDate, parseDateErr := utils.ParseTimeStringToTime("2006-01-02", warehouse_out_time)
  1217. if parseDateErr != nil {
  1218. c.ErrorLog("日期(%v)解析错误:%v", warehouseOutDate, parseDateErr)
  1219. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  1220. return
  1221. }
  1222. warehouseOut, _ := service.FindDrugWareHouseOutById(id, adminUserInfo.CurrentOrgId)
  1223. tempWarehouseOut := models.DrugWarehouseOut{
  1224. ID: warehouseOut.ID,
  1225. Mtime: mtime,
  1226. WarehouseOutTime: warehouseOutDate.Unix(),
  1227. }
  1228. service.EditDrugWarehouseOut(tempWarehouseOut)
  1229. dataBody := make(map[string]interface{}, 0)
  1230. err := json.Unmarshal(c.Ctx.Input.RequestBody, &dataBody)
  1231. if err != nil {
  1232. utils.ErrorLog(err.Error())
  1233. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  1234. return
  1235. }
  1236. var warehousingOutInfo []*models.DrugWarehouseOutInfo
  1237. var upDateWarehouseOutInfos []*models.DrugWarehouseOutInfo
  1238. //var drugFlow []*models.DrugFlow
  1239. if dataBody["stockOut"] != nil && reflect.TypeOf(dataBody["stockOut"]).String() == "[]interface {}" {
  1240. thisStockOut, _ := dataBody["stockOut"].([]interface{})
  1241. if len(thisStockOut) > 0 {
  1242. for _, item := range thisStockOut {
  1243. items := item.(map[string]interface{})
  1244. if items["drug_id"] == nil || reflect.TypeOf(items["drug_id"]).String() != "float64" {
  1245. utils.ErrorLog("drug_id")
  1246. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  1247. return
  1248. }
  1249. drug_id := int64(items["drug_id"].(float64))
  1250. if items["count"] == nil || reflect.TypeOf(items["count"]).String() != "string" {
  1251. utils.ErrorLog("count")
  1252. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  1253. return
  1254. }
  1255. count, _ := strconv.ParseInt(items["count"].(string), 10, 64)
  1256. count_unit, _ := items["count_unit"].(string)
  1257. if items["price"] == nil || reflect.TypeOf(items["price"]).String() != "string" {
  1258. utils.ErrorLog("price")
  1259. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  1260. return
  1261. }
  1262. price, _ := strconv.ParseFloat(items["price"].(string), 64)
  1263. if items["retail_price"] == nil || reflect.TypeOf(items["retail_price"]).String() != "string" {
  1264. utils.ErrorLog("retail_price")
  1265. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  1266. return
  1267. }
  1268. retail_price, _ := strconv.ParseFloat(items["retail_price"].(string), 64)
  1269. total := float64(count) * price
  1270. retail_price_total := float64(count) * retail_price
  1271. remark := items["remark"].(string)
  1272. if items["id"] == nil || reflect.TypeOf(items["id"]).String() != "float64" {
  1273. utils.ErrorLog("id")
  1274. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  1275. return
  1276. }
  1277. id := int64(items["id"].(float64))
  1278. dealer := int64(items["dealer"].(float64))
  1279. manufacturer := int64(items["manufacturer"].(float64))
  1280. batch_number := items["batch_number"].(string)
  1281. number := items["number"].(string)
  1282. var productDates int64
  1283. var expiryDates int64
  1284. if items["expiry_date"] == nil || reflect.TypeOf(items["expiry_date"]).String() != "string" {
  1285. expiryDates = 0
  1286. } else {
  1287. if len(items["expiry_date"].(string)) == 0 {
  1288. expiryDates = 0
  1289. } else {
  1290. expiryDate, _ := items["expiry_date"].(string)
  1291. expiry_date, _ := utils.ParseTimeStringToTime("2006-01-02", expiryDate)
  1292. expiryDates = expiry_date.Unix()
  1293. }
  1294. }
  1295. if items["product_date"] == nil || reflect.TypeOf(items["product_date"]).String() != "string" {
  1296. productDates = 0
  1297. } else {
  1298. if len(items["product_date"].(string)) == 0 {
  1299. productDates = 0
  1300. } else {
  1301. productDate, _ := items["product_date"].(string)
  1302. product_date, _ := utils.ParseTimeStringToTime("2006-01-02", productDate)
  1303. productDates = product_date.Unix()
  1304. }
  1305. }
  1306. if id == 0 {
  1307. warehouseOutInfo := &models.DrugWarehouseOutInfo{
  1308. WarehouseOutOrderNumber: warehouseOut.WarehouseOutOrderNumber,
  1309. WarehouseOutId: warehouseOut.ID,
  1310. DrugId: drug_id,
  1311. Count: count,
  1312. Price: price,
  1313. TotalPrice: total,
  1314. Status: 1,
  1315. Ctime: ctime,
  1316. Remark: remark,
  1317. OrgId: adminUserInfo.CurrentOrgId,
  1318. Type: types,
  1319. Manufacturer: manufacturer,
  1320. Dealer: dealer,
  1321. IsSys: 0,
  1322. SysRecordTime: 0,
  1323. RetailPrice: retail_price,
  1324. RetailTotalPrice: retail_price_total,
  1325. BatchNumber: batch_number,
  1326. Number: number,
  1327. ProductDate: productDates,
  1328. ExpiryDate: expiryDates,
  1329. CountUnit: count_unit,
  1330. }
  1331. warehousingOutInfo = append(warehousingOutInfo, warehouseOutInfo)
  1332. //drugflow := &models.DrugFlow{
  1333. // WarehousingOrder: warehousing.WarehousingOrder,
  1334. // WarehousingId: warehousing.ID,
  1335. // DrugId: drug_id,
  1336. // Number: number,
  1337. // ProductDate: productDates,
  1338. // ExpireDate: expiryDates,
  1339. // Count: warehousing_count,
  1340. // Price: last_price,
  1341. // Status: 1,
  1342. // Ctime: ctime,
  1343. // UserOrgId: adminUserInfo.CurrentOrgId,
  1344. // Manufacturer: manufacturer,
  1345. // Dealer: dealer,
  1346. // BatchNumber: batch_number,
  1347. // MaxUnit: max_unit,
  1348. // MinUnit: min_unit,
  1349. // ConsumableType: 1,
  1350. // IsEdit: 1,
  1351. // Creator: adminUserInfo.AdminUser.Id,
  1352. // IsSys:0,
  1353. //}
  1354. //
  1355. //drugFlow = append(drugFlow,drugflow)
  1356. } else {
  1357. if items["is_sys"] == nil || reflect.TypeOf(items["is_sys"]).String() != "float64" {
  1358. utils.ErrorLog("is_sys")
  1359. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  1360. return
  1361. }
  1362. is_sys := int64(items["is_sys"].(float64))
  1363. if items["sys_record_time"] == nil || reflect.TypeOf(items["sys_record_time"]).String() != "float64" {
  1364. utils.ErrorLog("sys_record_time")
  1365. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  1366. return
  1367. }
  1368. sys_record_time := int64(items["sys_record_time"].(float64))
  1369. warehouseOutInfo := &models.DrugWarehouseOutInfo{
  1370. ID: id,
  1371. WarehouseOutOrderNumber: warehouseOut.WarehouseOutOrderNumber,
  1372. WarehouseOutId: warehouseOut.ID,
  1373. DrugId: drug_id,
  1374. Count: count,
  1375. Price: price,
  1376. TotalPrice: total,
  1377. Status: 1,
  1378. Ctime: ctime,
  1379. Remark: remark,
  1380. OrgId: adminUserInfo.CurrentOrgId,
  1381. Mtime: time.Now().Unix(),
  1382. Type: types,
  1383. Manufacturer: manufacturer,
  1384. Dealer: dealer,
  1385. IsSys: is_sys,
  1386. SysRecordTime: sys_record_time,
  1387. RetailPrice: retail_price,
  1388. RetailTotalPrice: retail_price_total,
  1389. BatchNumber: batch_number,
  1390. Number: number,
  1391. ProductDate: productDates,
  1392. ExpiryDate: expiryDates,
  1393. CountUnit: count_unit,
  1394. }
  1395. upDateWarehouseOutInfos = append(upDateWarehouseOutInfos, warehouseOutInfo)
  1396. }
  1397. }
  1398. }
  1399. }
  1400. var errs error
  1401. if len(warehousingOutInfo) > 0 {
  1402. errs = service.CreateDrugWarehousingOutInfo(warehousingOutInfo)
  1403. }
  1404. if len(upDateWarehouseOutInfos) > 0 {
  1405. for _, item := range upDateWarehouseOutInfos {
  1406. errs = service.UpDateDrugWarehouseOutInfo(item)
  1407. }
  1408. }
  1409. if errs != nil {
  1410. utils.ErrorLog(errs.Error())
  1411. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCreateStockOutFail)
  1412. return
  1413. }
  1414. c.ServeSuccessJSON(map[string]interface{}{
  1415. "msg": "编辑成功",
  1416. })
  1417. }
  1418. func (c *StockDrugApiController) CreateDrugCancelStock() {
  1419. dealer_id, _ := c.GetInt64("dealer_id", 0)
  1420. manufacturer_id, _ := c.GetInt64("manufacturer_id", 0)
  1421. cancel_stock_time := c.GetString("time")
  1422. types, _ := c.GetInt64("type", 0)
  1423. cancelStockDate, parseDateErr := utils.ParseTimeStringToTime("2006-01-02", cancel_stock_time)
  1424. if parseDateErr != nil {
  1425. c.ErrorLog("日期(%v)解析错误:%v", cancelStockDate, parseDateErr)
  1426. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  1427. return
  1428. }
  1429. adminUserInfo := c.GetAdminUserInfo()
  1430. operation_time := time.Now().Unix()
  1431. creater := adminUserInfo.AdminUser.Id
  1432. ctime := time.Now().Unix()
  1433. timeStr := time.Now().Format("2006-01-02")
  1434. timeArr := strings.Split(timeStr, "-")
  1435. total, _ := service.FindAllDrugCancelStockTotal(adminUserInfo.CurrentOrgId)
  1436. total = total + 1
  1437. orderNumber := "CKTKD" + strconv.FormatInt(adminUserInfo.CurrentOrgId, 10) + timeArr[0] + timeArr[1] + timeArr[2] + "000" + strconv.FormatInt(total, 10)
  1438. cancelStock := models.DrugCancelStock{
  1439. OrderNumber: orderNumber,
  1440. OperaTime: operation_time,
  1441. OrgId: adminUserInfo.CurrentOrgId,
  1442. Creater: creater,
  1443. Ctime: ctime,
  1444. Status: 1,
  1445. ReturnTime: cancelStockDate.Unix(),
  1446. Dealer: dealer_id,
  1447. Manufacturer: manufacturer_id,
  1448. Type: types,
  1449. }
  1450. service.AddSigleDrugCancelStock(&cancelStock)
  1451. dataBody := make(map[string]interface{}, 0)
  1452. err := json.Unmarshal(c.Ctx.Input.RequestBody, &dataBody)
  1453. if err != nil {
  1454. utils.ErrorLog(err.Error())
  1455. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  1456. return
  1457. }
  1458. var cancelStockInfos []*models.DrugCancelStockInfo
  1459. if dataBody["cancelStock"] != nil && reflect.TypeOf(dataBody["cancelStock"]).String() == "[]interface {}" {
  1460. thisStockIn, _ := dataBody["cancelStock"].([]interface{})
  1461. if len(thisStockIn) > 0 {
  1462. for _, item := range thisStockIn {
  1463. items := item.(map[string]interface{})
  1464. if items["drug_id"] == nil || reflect.TypeOf(items["drug_id"]).String() != "float64" {
  1465. utils.ErrorLog("drug_id")
  1466. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  1467. return
  1468. }
  1469. drug_id := int64(items["drug_id"].(float64))
  1470. return_count, _ := items["return_count"].(string)
  1471. if len(return_count) == 0 {
  1472. utils.ErrorLog("len(return_count) == 0")
  1473. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  1474. return
  1475. }
  1476. count, _ := strconv.ParseInt(return_count, 10, 64)
  1477. if items["price"] == nil || reflect.TypeOf(items["price"]).String() != "string" {
  1478. utils.ErrorLog("price")
  1479. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  1480. return
  1481. }
  1482. price, _ := strconv.ParseFloat(items["price"].(string), 64)
  1483. total := float64(count) * price
  1484. if items["retail_price"] == nil || reflect.TypeOf(items["retail_price"]).String() != "string" {
  1485. utils.ErrorLog("retail_price")
  1486. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  1487. return
  1488. }
  1489. retail_price, _ := strconv.ParseFloat(items["retail_price"].(string), 64)
  1490. retail_price_total := float64(count) * retail_price
  1491. register_account, _ := items["register_account"].(string)
  1492. remark, _ := items["remark"].(string)
  1493. var productDates int64
  1494. var expiryDates int64
  1495. if items["expiry_date"] == nil || reflect.TypeOf(items["expiry_date"]).String() != "string" {
  1496. expiryDates = 0
  1497. } else {
  1498. if len(items["expiry_date"].(string)) == 0 {
  1499. expiryDates = 0
  1500. } else {
  1501. expiryDate, _ := items["expiry_date"].(string)
  1502. expiry_date, _ := utils.ParseTimeStringToTime("2006-01-02", expiryDate)
  1503. expiryDates = expiry_date.Unix()
  1504. }
  1505. }
  1506. if items["product_date"] == nil || reflect.TypeOf(items["product_date"]).String() != "string" {
  1507. productDates = 0
  1508. } else {
  1509. if len(items["product_date"].(string)) == 0 {
  1510. productDates = 0
  1511. } else {
  1512. productDate, _ := items["product_date"].(string)
  1513. product_date, _ := utils.ParseTimeStringToTime("2006-01-02", productDate)
  1514. productDates = product_date.Unix()
  1515. }
  1516. }
  1517. manufacturer, _ := items["manufacturer"].(string)
  1518. dealer, _ := items["dealer"].(string)
  1519. batch_number := items["batch_number"].(string)
  1520. max_unit := items["max_unit"].(string)
  1521. cancelStockInfo := &models.DrugCancelStockInfo{
  1522. OrderNumber: cancelStock.OrderNumber,
  1523. CancelStockId: cancelStock.ID,
  1524. DrugId: drug_id,
  1525. Count: count,
  1526. Status: 1,
  1527. Ctime: ctime,
  1528. OrgId: adminUserInfo.CurrentOrgId,
  1529. Type: types,
  1530. Manufacturer: manufacturer,
  1531. Dealer: dealer,
  1532. Total: total,
  1533. RetailPrice: retail_price,
  1534. RetailTotalPrice: retail_price_total,
  1535. Price: price,
  1536. RegisterAccount: register_account,
  1537. Remark: remark,
  1538. BatchNumber: batch_number,
  1539. MaxUnit: max_unit,
  1540. ProductDate: productDates,
  1541. ExpiryDate: expiryDates,
  1542. }
  1543. cancelStockInfos = append(cancelStockInfos, cancelStockInfo)
  1544. }
  1545. }
  1546. }
  1547. errs := service.CreateDrugCancelStockInfo(cancelStockInfos)
  1548. if errs != nil {
  1549. utils.ErrorLog(errs.Error())
  1550. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCancelStockFail)
  1551. return
  1552. }
  1553. c.ServeSuccessJSON(map[string]interface{}{
  1554. "msg": "退库成功",
  1555. })
  1556. }
  1557. func (c *StockDrugApiController) GetDrugCancelStockInfoList() {
  1558. id, _ := c.GetInt64("id", 0)
  1559. adminUserInfo := c.GetAdminUserInfo()
  1560. cancelStockInfoList, _ := service.FindDrugCancelStockInfoById(id, adminUserInfo.CurrentOrgId)
  1561. info, _ := service.FindCancelStockById(id, adminUserInfo.CurrentOrgId)
  1562. c.ServeSuccessJSON(map[string]interface{}{
  1563. "list": cancelStockInfoList,
  1564. "info": info,
  1565. })
  1566. }
  1567. func (c *StockDrugApiController) GetDrugCancelStockList() {
  1568. page, _ := c.GetInt64("page", -1)
  1569. limit, _ := c.GetInt64("limit", -1)
  1570. start_time := c.GetString("start_time")
  1571. end_time := c.GetString("end_time")
  1572. types, _ := c.GetInt64("type", 0)
  1573. keywords := c.GetString("keywords")
  1574. timeLayout := "2006-01-02"
  1575. loc, _ := time.LoadLocation("Local")
  1576. var startTime int64
  1577. if len(start_time) > 0 {
  1578. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", start_time+" 00:00:00", loc)
  1579. if err != nil {
  1580. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  1581. return
  1582. }
  1583. startTime = theTime.Unix()
  1584. }
  1585. var endTime int64
  1586. if len(end_time) > 0 {
  1587. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", end_time+" 23:59:59", loc)
  1588. if err != nil {
  1589. utils.ErrorLog(err.Error())
  1590. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  1591. return
  1592. }
  1593. endTime = theTime.Unix()
  1594. }
  1595. adminUserInfo := c.GetAdminUserInfo()
  1596. returnList, total, err := service.FindAllDrugCancelList(adminUserInfo.CurrentOrgId, page, limit, startTime, endTime, types, keywords)
  1597. if err == nil {
  1598. c.ServeSuccessJSON(map[string]interface{}{
  1599. "list": returnList,
  1600. "total": total,
  1601. })
  1602. } else {
  1603. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  1604. }
  1605. }
  1606. func (this *StockDrugApiController) DeleteDrugCancelStock() {
  1607. ids := this.GetString("ids")
  1608. if len(ids) == 0 {
  1609. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  1610. return
  1611. }
  1612. idArray := strings.Split(ids, ",")
  1613. err := service.DeleteDrugCancelStock(idArray)
  1614. if err != nil {
  1615. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDeleteFail)
  1616. } else {
  1617. this.ServeSuccessJSON(map[string]interface{}{
  1618. "msg": "删除成功",
  1619. })
  1620. }
  1621. }
  1622. func (this *StockDrugApiController) DeleteDrugCancelStockInfo() {
  1623. id, _ := this.GetInt64("id", 0)
  1624. fmt.Println(id)
  1625. if id == 0 {
  1626. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  1627. return
  1628. }
  1629. err := service.UpDateDrugCancleStockStatus(id)
  1630. if err != nil {
  1631. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDeleteFail)
  1632. } else {
  1633. this.ServeSuccessJSON(map[string]interface{}{
  1634. "msg": "删除成功",
  1635. })
  1636. }
  1637. }
  1638. func (c *StockDrugApiController) EditDrugCancelStock() {
  1639. cancel_time := c.GetString("cancel_time")
  1640. id, _ := c.GetInt64("id", 0)
  1641. types, _ := c.GetInt64("type", 0)
  1642. manufacturer_id, _ := c.GetInt64("manufacturer_id", 0)
  1643. dealer_id, _ := c.GetInt64("dealer_id", 0)
  1644. if id == 0 {
  1645. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  1646. return
  1647. }
  1648. ctime := time.Now().Unix()
  1649. mtime := time.Now().Unix()
  1650. adminUserInfo := c.GetAdminUserInfo()
  1651. cancelDate, parseDateErr := utils.ParseTimeStringToTime("2006-01-02", cancel_time)
  1652. if parseDateErr != nil {
  1653. c.ErrorLog("日期(%v)解析错误:%v", cancelDate, parseDateErr)
  1654. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  1655. return
  1656. }
  1657. cancelStock, _ := service.FindDrugCancelStockById(id)
  1658. tempCancelStock := models.DrugCancelStock{
  1659. ID: cancelStock.ID,
  1660. Mtime: mtime,
  1661. ReturnTime: cancelDate.Unix(),
  1662. Manufacturer: manufacturer_id,
  1663. Dealer: dealer_id,
  1664. }
  1665. service.EditDrugCancelStock(tempCancelStock)
  1666. dataBody := make(map[string]interface{}, 0)
  1667. err := json.Unmarshal(c.Ctx.Input.RequestBody, &dataBody)
  1668. if err != nil {
  1669. utils.ErrorLog(err.Error())
  1670. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  1671. return
  1672. }
  1673. var cancelStockInfos []*models.DrugCancelStockInfo
  1674. var upDateCancelStockInfos []*models.DrugCancelStockInfo
  1675. if dataBody["cancelStock"] != nil && reflect.TypeOf(dataBody["cancelStock"]).String() == "[]interface {}" {
  1676. thisCancelStock, _ := dataBody["cancelStock"].([]interface{})
  1677. if len(thisCancelStock) > 0 {
  1678. for _, item := range thisCancelStock {
  1679. items := item.(map[string]interface{})
  1680. if items["drug_id"] == nil || reflect.TypeOf(items["drug_id"]).String() != "float64" {
  1681. utils.ErrorLog("drug_id")
  1682. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  1683. return
  1684. }
  1685. drug_id := int64(items["drug_id"].(float64))
  1686. if items["count"] == nil || reflect.TypeOf(items["count"]).String() != "string" {
  1687. utils.ErrorLog("count")
  1688. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  1689. return
  1690. }
  1691. count, _ := strconv.ParseInt(items["count"].(string), 10, 64)
  1692. if items["price"] == nil || reflect.TypeOf(items["price"]).String() != "string" {
  1693. utils.ErrorLog("price")
  1694. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  1695. return
  1696. }
  1697. price, _ := strconv.ParseFloat(items["price"].(string), 64)
  1698. total := float64(count) * price
  1699. if items["retail_price"] == nil || reflect.TypeOf(items["retail_price"]).String() != "string" {
  1700. utils.ErrorLog("retail_price")
  1701. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  1702. return
  1703. }
  1704. retail_price, _ := strconv.ParseFloat(items["retail_price"].(string), 64)
  1705. retail_price_total := float64(count) * retail_price
  1706. if items["id"] == nil || reflect.TypeOf(items["id"]).String() != "float64" {
  1707. utils.ErrorLog("id")
  1708. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  1709. return
  1710. }
  1711. id := int64(items["id"].(float64))
  1712. max_unit := items["max_unit"].(string)
  1713. batch_number := items["batch_number"].(string)
  1714. register_account := items["register_account"].(string)
  1715. remark := items["remark"].(string)
  1716. manufacturer := items["manufacturer"].(string)
  1717. dealer := items["dealer"].(string)
  1718. var productDates int64
  1719. var expiryDates int64
  1720. if items["expiry_date"] == nil || reflect.TypeOf(items["expiry_date"]).String() != "string" {
  1721. expiryDates = 0
  1722. } else {
  1723. if len(items["expiry_date"].(string)) == 0 {
  1724. expiryDates = 0
  1725. } else {
  1726. expiryDate, _ := items["expiry_date"].(string)
  1727. expiry_date, _ := utils.ParseTimeStringToTime("2006-01-02", expiryDate)
  1728. expiryDates = expiry_date.Unix()
  1729. }
  1730. }
  1731. if items["product_date"] == nil || reflect.TypeOf(items["product_date"]).String() != "string" {
  1732. productDates = 0
  1733. } else {
  1734. if len(items["product_date"].(string)) == 0 {
  1735. productDates = 0
  1736. } else {
  1737. productDate, _ := items["product_date"].(string)
  1738. product_date, _ := utils.ParseTimeStringToTime("2006-01-02", productDate)
  1739. productDates = product_date.Unix()
  1740. }
  1741. }
  1742. if id == 0 {
  1743. cancelStockInfo := &models.DrugCancelStockInfo{
  1744. DrugId: drug_id,
  1745. Count: count,
  1746. Status: 1,
  1747. Ctime: ctime,
  1748. OrgId: adminUserInfo.CurrentOrgId,
  1749. OrderNumber: cancelStock.OrderNumber,
  1750. CancelStockId: cancelStock.ID,
  1751. Mtime: time.Now().Unix(),
  1752. Type: types,
  1753. RetailPrice: retail_price,
  1754. RetailTotalPrice: retail_price_total,
  1755. Price: price,
  1756. Total: total,
  1757. Manufacturer: manufacturer,
  1758. Dealer: dealer,
  1759. RegisterAccount: register_account,
  1760. MaxUnit: max_unit,
  1761. BatchNumber: batch_number,
  1762. Remark: remark,
  1763. ProductDate: productDates,
  1764. ExpiryDate: expiryDates,
  1765. }
  1766. cancelStockInfos = append(cancelStockInfos, cancelStockInfo)
  1767. } else {
  1768. cancelStockInfo := &models.DrugCancelStockInfo{
  1769. ID: id,
  1770. DrugId: drug_id,
  1771. Count: count,
  1772. Status: 1,
  1773. Ctime: ctime,
  1774. OrgId: adminUserInfo.CurrentOrgId,
  1775. OrderNumber: cancelStock.OrderNumber,
  1776. CancelStockId: cancelStock.ID,
  1777. Mtime: time.Now().Unix(),
  1778. Type: types,
  1779. RetailPrice: retail_price,
  1780. RetailTotalPrice: retail_price_total,
  1781. Price: price,
  1782. Total: total,
  1783. Manufacturer: manufacturer,
  1784. Dealer: dealer,
  1785. RegisterAccount: register_account,
  1786. MaxUnit: max_unit,
  1787. BatchNumber: batch_number,
  1788. Remark: remark,
  1789. ProductDate: productDates,
  1790. ExpiryDate: expiryDates,
  1791. }
  1792. upDateCancelStockInfos = append(upDateCancelStockInfos, cancelStockInfo)
  1793. }
  1794. }
  1795. }
  1796. }
  1797. var errs error
  1798. if len(cancelStockInfos) > 0 {
  1799. errs = service.CreateDrugCancelStockInfo(cancelStockInfos)
  1800. }
  1801. if len(upDateCancelStockInfos) > 0 {
  1802. for _, item := range upDateCancelStockInfos {
  1803. errs = service.UpDateDrugCancelStockInfo(item)
  1804. }
  1805. }
  1806. if errs != nil {
  1807. utils.ErrorLog(errs.Error())
  1808. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCreateCancelStockFail)
  1809. return
  1810. }
  1811. c.ServeSuccessJSON(map[string]interface{}{
  1812. "msg": "编辑成功",
  1813. })
  1814. }
  1815. func (c *StockDrugApiController) GetAllConfig() {
  1816. adminUserInfo := c.GetAdminUserInfo()
  1817. manufacturer, _ := service.FindAllManufacturer(adminUserInfo.CurrentOrgId)
  1818. dealer, _ := service.FindAllDealer(adminUserInfo.CurrentOrgId)
  1819. stockIns, _ := service.FindStockInNumber(adminUserInfo.CurrentOrgId)
  1820. drugs, _ := service.GetDrugs(adminUserInfo.CurrentOrgId)
  1821. c.ServeSuccessJSON(map[string]interface{}{
  1822. "manufacturer": manufacturer,
  1823. "dealer": dealer,
  1824. "drugs": drugs,
  1825. "numbers": stockIns,
  1826. })
  1827. }
  1828. func (c *StockDrugApiController) GetAllDrugStock() {
  1829. adminUserInfo := c.GetAdminUserInfo()
  1830. manufacturer_id, _ := c.GetInt64("manufacturer_id", 0)
  1831. dealer_id, _ := c.GetInt64("dealer_id", 0)
  1832. drugs, err := service.FindAllDrugByManufactureId(manufacturer_id, dealer_id, adminUserInfo.CurrentOrgId)
  1833. if err == nil {
  1834. c.ServeSuccessJSON(map[string]interface{}{
  1835. "drugs": drugs,
  1836. })
  1837. } else {
  1838. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  1839. }
  1840. }
  1841. func (c *StockDrugApiController) GetDrugQueryInfo() {
  1842. page, _ := c.GetInt64("page", -1)
  1843. limit, _ := c.GetInt64("limit", -1)
  1844. keyword := c.GetString("keyword")
  1845. drug_category, _ := c.GetInt64("drug_category")
  1846. start_time := c.GetString("start_time")
  1847. end_time := c.GetString("end_time")
  1848. timeLayout := "2006-01-02"
  1849. loc, _ := time.LoadLocation("Local")
  1850. var startTime int64
  1851. if len(start_time) > 0 {
  1852. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", start_time+" 00:00:00", loc)
  1853. if err != nil {
  1854. fmt.Println(err)
  1855. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  1856. return
  1857. }
  1858. startTime = theTime.Unix()
  1859. }
  1860. var endTime int64
  1861. if len(end_time) > 0 {
  1862. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", end_time+" 23:59:59", loc)
  1863. if err != nil {
  1864. utils.ErrorLog(err.Error())
  1865. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  1866. return
  1867. }
  1868. endTime = theTime.Unix()
  1869. }
  1870. adminUserInfo := c.GetAdminUserInfo()
  1871. list, total, err := service.FindAllDrugStockInfo(adminUserInfo.CurrentOrgId, page, limit, keyword, drug_category, startTime, endTime)
  1872. if err == nil {
  1873. c.ServeSuccessJSON(map[string]interface{}{
  1874. "list": list,
  1875. "total": total,
  1876. })
  1877. } else {
  1878. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  1879. }
  1880. }
  1881. func (this *StockDrugApiController) GetUserDetailInfo() {
  1882. order_id, _ := this.GetInt64("id")
  1883. if order_id <= 0 {
  1884. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  1885. return
  1886. }
  1887. adminUserInfo := this.GetAdminUserInfo()
  1888. userDetails, err, total := service.FindDrugStockUserDetailById(adminUserInfo.CurrentOrgId, order_id)
  1889. if err == nil {
  1890. this.ServeSuccessJSON(map[string]interface{}{
  1891. "list": userDetails,
  1892. "total": total,
  1893. })
  1894. } else {
  1895. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  1896. return
  1897. }
  1898. }
  1899. func (this *StockDrugApiController) GetCancelDrugOrderPrint() {
  1900. orderId := this.GetString("order_id")
  1901. ids := strings.Split(orderId, ",")
  1902. orgId := this.GetAdminUserInfo().CurrentOrgId
  1903. list, _ := service.GetCancelDrugOrderPrint(ids, orgId)
  1904. this.ServeSuccessJSON(map[string]interface{}{
  1905. "list": list,
  1906. })
  1907. }
  1908. func (this *StockDrugApiController) GetDrugCancelExportList() {
  1909. orderId := this.GetString("order_id")
  1910. fmt.Println("order_id2323232323223", orderId)
  1911. ids := strings.Split(orderId, ",")
  1912. orgId := this.GetAdminUserInfo().CurrentOrgId
  1913. list, _ := service.GetDrugCancelExportList(ids, orgId)
  1914. this.ServeSuccessJSON(map[string]interface{}{
  1915. "list": list,
  1916. })
  1917. }