manager_center_api_controller.go 52KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653
  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. "github.com/jinzhu/gorm"
  11. "reflect"
  12. "strconv"
  13. "time"
  14. )
  15. type ManagerCenterApiController struct {
  16. BaseAuthAPIController
  17. }
  18. func ManagerCenterRegistRouters() {
  19. //药品基础库
  20. beego.Router("/api/basedruglib/create", &ManagerCenterApiController{}, "post:CreateBaseDrugLib")
  21. beego.Router("/api/basedruglib/edit", &ManagerCenterApiController{}, "post:EditBaseDrugLib")
  22. beego.Router("/api/basedruglib/get", &ManagerCenterApiController{}, "get:GetBaseDrugLib")
  23. beego.Router("/api/basedruglib/list", &ManagerCenterApiController{}, "get:GetBaseDrugLibList")
  24. beego.Router("/api/medicineinsurancepercent/create", &ManagerCenterApiController{}, "post:CreateMedicineInsurancePercent")
  25. beego.Router("/api/drugunitsafeguard/create", &ManagerCenterApiController{}, "post:CreateDrugUnitSafeguard")
  26. beego.Router("/api/medicineinsurancepercent/get", &ManagerCenterApiController{}, "get:GetMedicineInsurancePercent")
  27. //beego.Router("/api/drugunitsafeguard/get", &ManagerCenterApiController{}, "get:GetDrugUnitSafeguard")
  28. beego.Router("/api/drug/basedruglib", &ManagerCenterApiController{}, "get:DeleteBaseDrugById")
  29. //专项字典
  30. beego.Router("/api/dictionary/getconfiglist", &ManagerCenterApiController{}, "get,post:GetConfigList")
  31. beego.Router("/api/dictionary/createconfig", &ManagerCenterApiController{}, "Post:CreateConfig")
  32. beego.Router("/api/dictionary/createchildconfig", &ManagerCenterApiController{}, "Post:CreateChildConfig")
  33. beego.Router("/api/dictionary/updatechildconfig", &ManagerCenterApiController{}, "Post:UpdateChildConfig")
  34. beego.Router("/api/dictionary/deletechildconfig", &ManagerCenterApiController{}, "Post:DeleteChildConfig")
  35. beego.Router("/api/dictionary/updatetemplate", &ManagerCenterApiController{}, "Post:UpdateTemplate")
  36. //经销商
  37. beego.Router("/api/stock/dealer/create", &ManagerCenterApiController{}, "post:CreateDealer")
  38. beego.Router("/api/stock/dealer/modify", &ManagerCenterApiController{}, "post:ModifyDealer")
  39. beego.Router("/api/stock/dealer/list", &ManagerCenterApiController{}, "get:GetDealersList")
  40. beego.Router("/api/stock/dealer/delete", &ManagerCenterApiController{}, "post:DeleteDealer")
  41. beego.Router("/api/stock/dealer/get", &ManagerCenterApiController{}, "get:GetDealer")
  42. //厂商
  43. beego.Router("/api/stock/manufacturer/create", &ManagerCenterApiController{}, "post:CreateManufacturer")
  44. beego.Router("/api/stock/manufacturer/modify", &ManagerCenterApiController{}, "post:ModifyManufacturer")
  45. beego.Router("/api/stock/manufacturer/list", &ManagerCenterApiController{}, "get:GetManufacturerList")
  46. beego.Router("/api/stock/manufacturer/delete", &ManagerCenterApiController{}, "post:DeleteManufacturer")
  47. beego.Router("/api/stock/manufacturer/get", &ManagerCenterApiController{}, "get:GetManufacturer")
  48. beego.Router("/api/stock/good/info/create", &ManagerCenterApiController{}, "post:CreateGoodInfo")
  49. beego.Router("/api/stock/good/info/modify", &ManagerCenterApiController{}, "post:ModifyGoodInfo")
  50. beego.Router("/api/stock/good/info/list", &ManagerCenterApiController{}, "get:GetGoodInfoList")
  51. beego.Router("/api/info/delete", &ManagerCenterApiController{}, "post:DeleteGoodInfo")
  52. beego.Router("/api/stock/good/info/get", &ManagerCenterApiController{}, "get:GetGoodInfoByGoodId")
  53. beego.Router("/api/stock/good/info", &ManagerCenterApiController{}, "get:GetGoodInfoById")
  54. }
  55. func (c *ManagerCenterApiController) CreateBaseDrugLib() {
  56. drug_name := c.GetString("drug_name")
  57. fmt.Println("0000000")
  58. fmt.Println(drug_name)
  59. pinyin := c.GetString("pinyin")
  60. wubi := c.GetString("wubi")
  61. drug_alias := c.GetString("drug_alias")
  62. drug_alias_pinyin := c.GetString("drug_alias_pinyin")
  63. drug_alias_wubi := c.GetString("drug_alias_wubi")
  64. drug_category, _ := c.GetInt64("drug_category")
  65. drug_spec := c.GetString("drug_spec")
  66. drug_type, _ := c.GetInt64("drug_type")
  67. drug_stock_limit := c.GetString("drug_stock_limit")
  68. drug_origin_place := c.GetString("drug_origin_place")
  69. drug_dosage_form, _ := c.GetInt64("drug_dosage_form")
  70. medical_insurance_level, _ := c.GetInt64("medical_insurance_level")
  71. max_unit := c.GetString("max_unit")
  72. min_unit := c.GetString("min_unit")
  73. unit_matrixing := c.GetString("unit_matrixing")
  74. retail_price, _ := c.GetFloat("retail_price")
  75. last_price, _ := c.GetFloat("last_price")
  76. drug_control, _ := c.GetInt64("drug_control")
  77. number := c.GetString("number")
  78. drug_classify := c.GetString("drug_classify")
  79. drug_dose, _ := c.GetFloat("drug_dose")
  80. drug_dose_unit, _ := c.GetInt64("drug_dose_unit")
  81. medical_insurance_number := c.GetString("medical_insurance_number")
  82. manufacturer, _ := c.GetInt64("manufacturer")
  83. pharmacology_category, _ := c.GetInt64("pharmacology_category")
  84. statistics_category, _ := c.GetInt64("statistics_category")
  85. code := c.GetString("code")
  86. is_special_diseases, _ := c.GetInt64("is_special_diseases")
  87. is_record, _ := c.GetInt64("is_record")
  88. agent := c.GetString("agent")
  89. drug_status := c.GetString("drug_status")
  90. limit_remark := c.GetString("limit_remark")
  91. delivery_way := c.GetString("delivery_way")
  92. execution_frequency := c.GetString("execution_frequency")
  93. single_dose, _ := c.GetFloat("single_dose")
  94. prescribing_number, _ := c.GetFloat("prescribing_number")
  95. label, _ := c.GetInt64("label")
  96. sort, _ := c.GetInt64("sort")
  97. is_use_doctor_advice, _ := c.GetInt64("is_use_doctor_advice")
  98. is_default, _ := c.GetInt64("is_default")
  99. is_charge_predict, _ := c.GetInt64("is_charge_predict")
  100. is_statistics_work, _ := c.GetInt64("is_statistics_work")
  101. is_charge_use, _ := c.GetInt64("is_charge_use")
  102. adminInfo := c.GetAdminUserInfo()
  103. drugLib := &models.BaseDrugLib{
  104. DrugName: drug_name,
  105. Pinyin: pinyin,
  106. Wubi: wubi,
  107. DrugAlias: drug_alias,
  108. DrugAliasPinyin: drug_alias_pinyin,
  109. DrugAliasWubi: drug_alias_wubi,
  110. DrugCategory: drug_category,
  111. DrugSpec: drug_spec,
  112. DrugType: drug_type,
  113. DrugStockLimit: drug_stock_limit,
  114. DrugOriginPlace: drug_origin_place,
  115. MedicalInsuranceLevel: medical_insurance_level,
  116. DrugDosageForm: drug_dosage_form,
  117. MaxUnit: max_unit,
  118. MinUnit: min_unit,
  119. UnitMatrixing: unit_matrixing,
  120. RetailPrice: retail_price,
  121. LastPrice: last_price,
  122. DrugControl: drug_control,
  123. Number: number,
  124. DrugClassify: drug_classify,
  125. DrugDose: drug_dose,
  126. DrugDoseUnit: drug_dose_unit,
  127. MedicalInsuranceNumber: medical_insurance_number,
  128. Manufacturer: manufacturer,
  129. PharmacologyCategory: pharmacology_category,
  130. StatisticsCategory: statistics_category,
  131. Code: code,
  132. IsSpecialDiseases: is_special_diseases,
  133. IsRecord: is_record,
  134. Agent: agent,
  135. DrugStatus: drug_status,
  136. LimitRemark: limit_remark,
  137. DeliveryWay: delivery_way,
  138. ExecutionFrequency: execution_frequency,
  139. SingleDose: single_dose,
  140. PrescribingNumber: prescribing_number,
  141. Label: label,
  142. Sort: sort,
  143. IsUseDoctorAdvice: is_use_doctor_advice,
  144. IsDefault: is_default,
  145. IsChargePredict: is_charge_predict,
  146. IsStatisticsWork: is_statistics_work,
  147. IsChargeUse: is_charge_use,
  148. OrgId: adminInfo.CurrentOrgId,
  149. Status: 1,
  150. Ctime: time.Now().Unix(),
  151. Mtime: time.Now().Unix(),
  152. }
  153. total := service.FindAllDrugLibRecordTotal(adminInfo.CurrentOrgId)
  154. drug_code := strconv.FormatInt(total+1, 10)
  155. drug_code = "54000000" + drug_code
  156. drugLib.DrugCode = drug_code
  157. count := service.FindBaseDrugLibRecordCount(drugLib)
  158. if count == 0 {
  159. err := service.CreateBaseDrugLib(drugLib)
  160. if err == nil {
  161. c.ServeSuccessJSON(map[string]interface{}{
  162. "msg": "创建成功",
  163. })
  164. } else {
  165. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  166. return
  167. }
  168. return
  169. } else {
  170. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDrugRepeatDataException)
  171. return
  172. }
  173. }
  174. func (c *ManagerCenterApiController) EditBaseDrugLib() {
  175. id, _ := c.GetInt64("id")
  176. drug_name := c.GetString("drug_name")
  177. pinyin := c.GetString("pinyin")
  178. wubi := c.GetString("wubi")
  179. drug_alias := c.GetString("drug_alias")
  180. drug_alias_pinyin := c.GetString("drug_alias_pinyin")
  181. drug_alias_wubi := c.GetString("drug_alias_wubi")
  182. drug_category, _ := c.GetInt64("drug_category")
  183. drug_spec := c.GetString("drug_spec")
  184. drug_type, _ := c.GetInt64("drug_type")
  185. drug_stock_limit := c.GetString("drug_stock_limit")
  186. drug_origin_place := c.GetString("drug_origin_place")
  187. drug_dosage_form, _ := c.GetInt64("drug_dosage_form")
  188. medical_insurance_level, _ := c.GetInt64("medical_insurance_level")
  189. max_unit := c.GetString("max_unit")
  190. min_unit := c.GetString("min_unit")
  191. unit_matrixing := c.GetString("unit_matrixing")
  192. retail_price, _ := c.GetFloat("retail_price")
  193. last_price, _ := c.GetFloat("last_price")
  194. drug_control, _ := c.GetInt64("drug_control")
  195. number := c.GetString("number")
  196. drug_classify := c.GetString("drug_classify")
  197. drug_dose, _ := c.GetFloat("drug_dose")
  198. drug_dose_unit, _ := c.GetInt64("drug_dose_unit")
  199. medical_insurance_number := c.GetString("medical_insurance_number")
  200. manufacturer, _ := c.GetInt64("manufacturer")
  201. pharmacology_category, _ := c.GetInt64("pharmacology_category")
  202. statistics_category, _ := c.GetInt64("statistics_category")
  203. code := c.GetString("code")
  204. is_special_diseases, _ := c.GetInt64("is_special_diseases")
  205. is_record, _ := c.GetInt64("is_record")
  206. agent := c.GetString("agent")
  207. drug_status := c.GetString("drug_status")
  208. limit_remark := c.GetString("limit_remark")
  209. delivery_way := c.GetString("delivery_way")
  210. execution_frequency := c.GetString("execution_frequency")
  211. single_dose, _ := c.GetFloat("single_dose")
  212. prescribing_number, _ := c.GetFloat("prescribing_number")
  213. label, _ := c.GetInt64("label")
  214. sort, _ := c.GetInt64("sort")
  215. is_use_doctor_advice, _ := c.GetInt64("is_use_doctor_advice")
  216. is_default, _ := c.GetInt64("is_default")
  217. is_charge_predict, _ := c.GetInt64("is_charge_predict")
  218. is_statistics_work, _ := c.GetInt64("is_statistics_work")
  219. is_charge_use, _ := c.GetInt64("is_charge_use")
  220. drug_code := c.GetString("drug_code")
  221. //unit := c.GetString("unit")
  222. adminInfo := c.GetAdminUserInfo()
  223. drug, _ := service.FindBaseDrugLibRecord(adminInfo.CurrentOrgId, id)
  224. drugLib := &models.BaseDrugLib{
  225. ID: id,
  226. DrugName: drug_name,
  227. Pinyin: pinyin,
  228. Wubi: wubi,
  229. DrugAlias: drug_alias,
  230. DrugAliasPinyin: drug_alias_pinyin,
  231. DrugAliasWubi: drug_alias_wubi,
  232. DrugCategory: drug_category,
  233. DrugSpec: drug_spec,
  234. DrugType: drug_type,
  235. DrugStockLimit: drug_stock_limit,
  236. DrugOriginPlace: drug_origin_place,
  237. MedicalInsuranceLevel: medical_insurance_level,
  238. DrugDosageForm: drug_dosage_form,
  239. MaxUnit: max_unit,
  240. MinUnit: min_unit,
  241. UnitMatrixing: unit_matrixing,
  242. RetailPrice: retail_price,
  243. LastPrice: last_price,
  244. DrugControl: drug_control,
  245. Number: number,
  246. DrugClassify: drug_classify,
  247. DrugDose: drug_dose,
  248. DrugDoseUnit: drug_dose_unit,
  249. MedicalInsuranceNumber: medical_insurance_number,
  250. Manufacturer: manufacturer,
  251. PharmacologyCategory: pharmacology_category,
  252. StatisticsCategory: statistics_category,
  253. Code: code,
  254. IsSpecialDiseases: is_special_diseases,
  255. IsRecord: is_record,
  256. Agent: agent,
  257. DrugStatus: drug_status,
  258. LimitRemark: limit_remark,
  259. DeliveryWay: delivery_way,
  260. ExecutionFrequency: execution_frequency,
  261. SingleDose: single_dose,
  262. PrescribingNumber: prescribing_number,
  263. Label: label,
  264. Sort: sort,
  265. IsUseDoctorAdvice: is_use_doctor_advice,
  266. IsDefault: is_default,
  267. IsChargePredict: is_charge_predict,
  268. IsStatisticsWork: is_statistics_work,
  269. IsChargeUse: is_charge_use,
  270. OrgId: adminInfo.CurrentOrgId,
  271. Status: 1,
  272. Ctime: drug.Ctime,
  273. Mtime: time.Now().Unix(),
  274. DrugCode: drug_code,
  275. }
  276. err := service.UpdateBaseDrugLib(drugLib)
  277. //查询是否存在
  278. _, errOne := service.GetDrugNameIsExist(id, adminInfo.CurrentOrgId)
  279. if errOne == gorm.ErrRecordNotFound {
  280. fmt.Println("进来了吗")
  281. c.ServeSuccessJSON(map[string]interface{}{
  282. "msg": "修改成功",
  283. })
  284. return
  285. } else if errOne == nil {
  286. //修改xt_drug_name 表
  287. drugName := models.XtDrugName{
  288. DrugName: drug_name,
  289. }
  290. service.UpdatedDrugName(id, adminInfo.CurrentOrgId, &drugName)
  291. }
  292. //查询是否存在
  293. _, errTwo := service.GetStandNameIsExist(id, adminInfo.CurrentOrgId)
  294. if errTwo == gorm.ErrRecordNotFound {
  295. fmt.Println("进来了吗1")
  296. c.ServeSuccessJSON(map[string]interface{}{
  297. "msg": "修改成功",
  298. })
  299. return
  300. } else if errTwo == nil {
  301. //修改规格xt_stand_name表
  302. standName := models.XtStandName{
  303. DrugName: drug_name,
  304. DrugSpec: drug_spec,
  305. DrugStockLimit: drug_stock_limit,
  306. MinUnit: min_unit,
  307. }
  308. service.UpdateStandName(id, adminInfo.CurrentOrgId, &standName)
  309. }
  310. _, errThree := service.GetSelfMedicalIsExist(id, adminInfo.CurrentOrgId)
  311. if errThree == gorm.ErrRecordNotFound {
  312. fmt.Println("进来了吗2")
  313. c.ServeSuccessJSON(map[string]interface{}{
  314. "msg": "修改成功",
  315. })
  316. return
  317. } else if errThree == nil {
  318. //修改药品表
  319. medical := models.XtSelfMedical{
  320. DrugName: drug_name,
  321. DrugSpec: drug_spec,
  322. ExecutionFrequency: execution_frequency,
  323. PrescribingNumber: prescribing_number,
  324. DeliveryWay: delivery_way,
  325. SingleDose: single_dose,
  326. MinUnit: min_unit,
  327. }
  328. service.UpdateSelfMedical(id, adminInfo.CurrentOrgId, &medical)
  329. }
  330. _, errFour := service.GetSelfStosckIsExist(id, adminInfo.CurrentOrgId)
  331. if errFour == gorm.ErrRecordNotFound {
  332. fmt.Println("进来了吗3")
  333. c.ServeSuccessJSON(map[string]interface{}{
  334. "msg": "修改成功",
  335. })
  336. return
  337. } else if errFour == nil {
  338. stock := models.XtSelfStock{
  339. DrugSpec: drug_spec,
  340. DrugName: drug_name,
  341. MinUnit: min_unit,
  342. }
  343. service.UpdatedSelfStock(&stock, id, adminInfo.CurrentOrgId)
  344. }
  345. _, errFive := service.GetOutSelfOutStockIsExist(id, adminInfo.CurrentOrgId)
  346. if errFive == gorm.ErrRecordNotFound {
  347. fmt.Println("进来了吗4")
  348. c.ServeSuccessJSON(map[string]interface{}{
  349. "msg": "修改成功",
  350. })
  351. return
  352. } else if errFive == nil {
  353. outStock := models.XtSelfOutStock{
  354. DrugName: drug_name,
  355. DrugSpec: drug_spec,
  356. }
  357. //修改出库表
  358. service.UpdatedOutSelfStock(&outStock, id, adminInfo.CurrentOrgId)
  359. }
  360. _, errSix := service.GetDoctorAdviceIsExist(id, adminInfo.CurrentOrgId)
  361. if errSix == gorm.ErrRecordNotFound {
  362. fmt.Println("进来了吗5")
  363. c.ServeSuccessJSON(map[string]interface{}{
  364. "msg": "修改成功",
  365. })
  366. return
  367. } else if errSix == nil {
  368. //查询未执行的医嘱
  369. advice := models.DoctorAdvice{
  370. AdviceName: drug_name,
  371. AdviceDesc: drug_spec,
  372. DeliveryWay: delivery_way,
  373. ExecutionFrequency: execution_frequency,
  374. SingleDose: single_dose,
  375. SingleDoseUnit: min_unit,
  376. }
  377. service.UpdateNoExcuteDoctorAdvice(id, adminInfo.CurrentOrgId, &advice)
  378. }
  379. _, errSeven := service.GetDoctorAdviceTemplateIsExist(id, adminInfo.CurrentOrgId)
  380. if errSeven == gorm.ErrRecordNotFound {
  381. fmt.Println("进来了吗6")
  382. c.ServeSuccessJSON(map[string]interface{}{
  383. "msg": "修改成功",
  384. })
  385. return
  386. } else if errSeven == nil {
  387. //修改医嘱模板
  388. template := models.DoctorAdviceTemplate{
  389. AdviceName: drug_name,
  390. AdviceDesc: drug_spec,
  391. DeliveryWay: delivery_way,
  392. ExecutionFrequency: execution_frequency,
  393. SingleDose: single_dose,
  394. SingleDoseUnit: min_unit,
  395. }
  396. service.UpdatedDoctorAdviceTemplate(id, adminInfo.CurrentOrgId, &template)
  397. }
  398. if err == nil {
  399. c.ServeSuccessJSON(map[string]interface{}{
  400. "msg": "修改成功",
  401. })
  402. return
  403. } else {
  404. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  405. return
  406. }
  407. }
  408. func (c *ManagerCenterApiController) GetBaseDrugLib() {
  409. id, _ := c.GetInt64("id")
  410. adminInfo := c.GetAdminUserInfo()
  411. drug, err := service.FindBaseDrugLibRecord(adminInfo.CurrentOrgId, id)
  412. if err == nil {
  413. c.ServeSuccessJSON(map[string]interface{}{
  414. "drug": drug,
  415. })
  416. return
  417. } else {
  418. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  419. return
  420. }
  421. }
  422. func (c *ManagerCenterApiController) GetBaseDrugLibList() {
  423. page, _ := c.GetInt64("page", 1)
  424. limit, _ := c.GetInt64("limit", 10)
  425. is_use, _ := c.GetInt64("is_use", 0)
  426. is_charge, _ := c.GetInt64("is_charge", 0)
  427. is_inject, _ := c.GetInt64("is_inject", 0)
  428. keyword := c.GetString("keyword")
  429. adminInfo := c.GetAdminUserInfo()
  430. if page <= 0 {
  431. page = 1
  432. }
  433. if limit <= 0 {
  434. limit = 10
  435. }
  436. list, total, _ := service.GetBaseDrugLibList(adminInfo.CurrentOrgId, keyword, page, limit, is_use, is_charge, is_inject)
  437. c.ServeSuccessJSON(map[string]interface{}{
  438. "list": list,
  439. "total": total,
  440. })
  441. return
  442. }
  443. func (c *ManagerCenterApiController) CreateMedicineInsurancePercent() {
  444. module, _ := c.GetInt64("module", 0)
  445. adminInfo := c.GetAdminUserInfo()
  446. dataBody := make(map[string]interface{}, 0)
  447. err := json.Unmarshal(c.Ctx.Input.RequestBody, &dataBody)
  448. if err != nil {
  449. utils.ErrorLog(err.Error())
  450. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  451. return
  452. }
  453. var mips []*models.MedicineInsurancePercentage
  454. var errs error
  455. record_time := time.Now().Unix()
  456. if dataBody["mip"] != nil && reflect.TypeOf(dataBody["mip"]).String() == "[]interface {}" {
  457. mip_map, _ := dataBody["mip"].([]interface{})
  458. if len(mip_map) > 0 {
  459. for _, item := range mip_map {
  460. items := item.(map[string]interface{})
  461. if items["type_id"] == nil || reflect.TypeOf(items["type_id"]).String() != "float64" {
  462. utils.ErrorLog("type_id")
  463. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  464. return
  465. }
  466. type_id := int64(items["type_id"].(float64))
  467. if items["medicine_insurance_type"] == nil || reflect.TypeOf(items["medicine_insurance_type"]).String() != "float64" {
  468. utils.ErrorLog("medicine_insurance_type")
  469. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  470. return
  471. }
  472. types := int64(items["medicine_insurance_type"].(float64))
  473. if items["percent"] == nil || reflect.TypeOf(items["percent"]).String() != "string" {
  474. utils.ErrorLog("percent")
  475. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  476. return
  477. }
  478. percent, _ := strconv.ParseFloat(items["percent"].(string), 64)
  479. //percent := items["percent"].(float64)
  480. mip_temp := &models.MedicineInsurancePercentage{
  481. TypeId: type_id,
  482. Status: 1,
  483. Ctime: time.Now().Unix(),
  484. Mtime: time.Now().Unix(),
  485. RecordTime: record_time,
  486. MedicineInsuranceType: types,
  487. UserOrgId: adminInfo.CurrentOrgId,
  488. Percent: percent,
  489. Module: module,
  490. GoodId: 0,
  491. }
  492. mips = append(mips, mip_temp)
  493. }
  494. }
  495. for _, item := range mips {
  496. errs = service.CreateMedicineInsurancePercentage(item)
  497. }
  498. }
  499. if errs == nil {
  500. c.ServeSuccessJSON(map[string]interface{}{
  501. "msg": "添加成功",
  502. })
  503. return
  504. } else {
  505. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  506. return
  507. }
  508. }
  509. func (c *ManagerCenterApiController) CreateDrugUnitSafeguard() {
  510. }
  511. //GetPatientsList 取配置信息列表
  512. func (c *ManagerCenterApiController) GetConfigList() {
  513. adminUserInfo := c.GetAdminUserInfo()
  514. configList, _ := service.GetDictionaryConfigList(adminUserInfo.CurrentOrgId)
  515. c.ServeSuccessJSON(map[string]interface{}{
  516. "configlist": configList,
  517. })
  518. return
  519. }
  520. //CreateConfig 创建配置信息
  521. func (c *ManagerCenterApiController) CreateConfig() {
  522. adminUserInfo := c.GetAdminUserInfo()
  523. var dataconfig models.DictionaryDataconfig
  524. var resultConfig models.DictionaryConfigViewModel
  525. code := dictionaryConfigFormData(&dataconfig, c.Ctx.Input.RequestBody)
  526. if code > 0 {
  527. c.ServeFailJSONWithSGJErrorCode(code)
  528. return
  529. }
  530. // 验证关键字段的值是否重复
  531. thisConfig, _ := service.FindDictionaryConfigByTitle(dataconfig.Module, dataconfig.FieldName, adminUserInfo.CurrentOrgId)
  532. if thisConfig.ID > 0 {
  533. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeFieldExist)
  534. return
  535. }
  536. fieldValue := service.GetDictionaryChildValue(dataconfig.Module, dataconfig.ParentId, adminUserInfo.CurrentOrgId)
  537. dataconfig.Value = fieldValue + 1
  538. dataBody := make(map[string]interface{}, 0)
  539. err := json.Unmarshal(c.Ctx.Input.RequestBody, &dataBody)
  540. if err != nil {
  541. utils.ErrorLog(err.Error())
  542. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  543. return
  544. }
  545. dataconfig.OrgId = adminUserInfo.CurrentOrgId
  546. dataconfig.CreateUserId = adminUserInfo.AdminUser.Id
  547. dataconfig.Status = 1
  548. dataconfig.CreatedTime = time.Now().Format("2006-01-02 15:04:05")
  549. dataconfig.UpdatedTime = time.Now().Format("2006-01-02 15:04:05")
  550. dataconfig.Remark = string(dataBody["remark"].(string))
  551. if dataBody["order"] != nil {
  552. dataconfig.Order = int64(dataBody["order"].(float64))
  553. } else {
  554. dataconfig.Order = 0
  555. }
  556. err = service.CreateDictionaryConfig(&dataconfig)
  557. if err != nil {
  558. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCreateConfig)
  559. return
  560. } else {
  561. resultConfig.ID = dataconfig.ID
  562. resultConfig.Module = dataconfig.Module
  563. resultConfig.Name = dataconfig.Name
  564. resultConfig.OrgId = dataconfig.OrgId
  565. resultConfig.ParentId = dataconfig.ParentId
  566. resultConfig.FieldName = dataconfig.FieldName
  567. resultConfig.CreateUserId = dataconfig.CreateUserId
  568. resultConfig.Title = dataconfig.Title
  569. resultConfig.Content = dataconfig.Content
  570. }
  571. c.ServeSuccessJSON(map[string]interface{}{
  572. "dataconfig": resultConfig,
  573. "msg": "ok",
  574. })
  575. return
  576. }
  577. func (c *ManagerCenterApiController) UpdateTemplate() {
  578. adminUserInfo := c.GetAdminUserInfo()
  579. var dataconfig models.DictionaryDataconfig
  580. code := dictionaryConfigFormData(&dataconfig, c.Ctx.Input.RequestBody)
  581. if code > 0 {
  582. c.ServeFailJSONWithSGJErrorCode(code)
  583. return
  584. }
  585. dataBody := make(map[string]interface{}, 0)
  586. err := json.Unmarshal(c.Ctx.Input.RequestBody, &dataBody)
  587. if err != nil {
  588. utils.ErrorLog(err.Error())
  589. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  590. return
  591. }
  592. dataconfig.OrgId = adminUserInfo.CurrentOrgId
  593. dataconfig.CreateUserId = adminUserInfo.AdminUser.Id
  594. dataconfig.Status = 1
  595. dataconfig.CreatedTime = time.Now().Format("2006-01-02 15:04:05")
  596. dataconfig.UpdatedTime = time.Now().Format("2006-01-02 15:04:05")
  597. dataconfig.Remark = string(dataBody["remark"].(string))
  598. if dataBody["order"] != nil {
  599. dataconfig.Order = int64(dataBody["order"].(float64))
  600. } else {
  601. dataconfig.Order = 0
  602. }
  603. // 验证关键字段的值是否重复
  604. // cur_id := int64(dataBody["id"].(float64))
  605. // thisConfig,_:=service.FindConfigByTitleForUpdate(dataconfig.Module, dataconfig.Title,dataconfig.OrgId,cur_id)
  606. // if thisConfig.ID >0 {
  607. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeFieldExist)
  608. // return
  609. // }
  610. configOrgId := int64(dataBody["org_id"].(float64))
  611. if configOrgId == 0 {
  612. dataconfig.DeleteIdSystem = int64(dataBody["id"].(float64))
  613. err := service.CreateDictionaryConfig(&dataconfig)
  614. if err != nil {
  615. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCreateConfig)
  616. return
  617. }
  618. } else {
  619. dataconfig.ID = int64(dataBody["id"].(float64))
  620. err = service.UpdateDictionaryTemplate(&dataconfig)
  621. if err != nil {
  622. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeUpdateConfig)
  623. return
  624. }
  625. }
  626. c.ServeSuccessJSON(map[string]interface{}{
  627. "dataconfig": dataconfig,
  628. "msg": "ok",
  629. })
  630. return
  631. }
  632. func (c *ManagerCenterApiController) UpdateChildConfig() {
  633. adminUserInfo := c.GetAdminUserInfo()
  634. var dataconfig models.DictionaryDataconfig
  635. code := dictionaryConfigChildFormData(&dataconfig, c.Ctx.Input.RequestBody)
  636. if code > 0 {
  637. c.ServeFailJSONWithSGJErrorCode(code)
  638. return
  639. }
  640. dataBody := make(map[string]interface{}, 0)
  641. err := json.Unmarshal(c.Ctx.Input.RequestBody, &dataBody)
  642. if err != nil {
  643. utils.ErrorLog(err.Error())
  644. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  645. return
  646. }
  647. dataconfig.OrgId = adminUserInfo.CurrentOrgId
  648. dataconfig.CreateUserId = adminUserInfo.AdminUser.Id
  649. dataconfig.Status = 1
  650. dataconfig.Value = int(int64(dataBody["value"].(float64)))
  651. dataconfig.CreatedTime = time.Now().Format("2006-01-02 15:04:05")
  652. dataconfig.UpdatedTime = time.Now().Format("2006-01-02 15:04:05")
  653. dataconfig.Remark = string(dataBody["remark"].(string))
  654. dataconfig.Order = int64(dataBody["orders"].(float64))
  655. fmt.Println("dataconfitg------", dataconfig.Order)
  656. //if dataBody["orders"] != nil {
  657. // dataconfig.Order = int64(dataBody["orders"].(float64))
  658. // fmt.Println("dataconfig",dataconfig.Order)
  659. //} else {
  660. // dataconfig.Order = 0
  661. //}
  662. configOrgId := int64(dataBody["org_id"].(float64))
  663. // 验证关键字段的值是否重复
  664. // configId := int64(dataBody["id"].(float64))
  665. // thisConfig,_:=service.FindConfigByNameForUpdate(dataconfig.Module, dataconfig.Name,dataconfig.ParentId,dataconfig.OrgId,configId)
  666. // if thisConfig.ID >0 {
  667. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeFieldExist)
  668. // return
  669. // }
  670. if configOrgId == 0 {
  671. dataconfig.DeleteIdSystem = int64(dataBody["id"].(float64))
  672. err := service.CreateDictionaryConfig(&dataconfig)
  673. if err != nil {
  674. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCreateConfig)
  675. return
  676. }
  677. } else {
  678. dataconfig.ID = int64(dataBody["id"].(float64))
  679. err = service.UpdateDictionaryChildConfig(&dataconfig)
  680. if err != nil {
  681. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeUpdateConfig)
  682. return
  683. }
  684. }
  685. c.ServeSuccessJSON(map[string]interface{}{
  686. "dataconfig": dataconfig,
  687. "msg": "ok",
  688. })
  689. return
  690. }
  691. func (c *ManagerCenterApiController) DeleteChildConfig() {
  692. adminUserInfo := c.GetAdminUserInfo()
  693. var dataconfig models.DictionaryDataconfig
  694. code := dictionaryConfigChildFormData(&dataconfig, c.Ctx.Input.RequestBody)
  695. if code > 0 {
  696. c.ServeFailJSONWithSGJErrorCode(code)
  697. return
  698. }
  699. dataBody := make(map[string]interface{}, 0)
  700. err := json.Unmarshal(c.Ctx.Input.RequestBody, &dataBody)
  701. if err != nil {
  702. utils.ErrorLog(err.Error())
  703. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  704. return
  705. }
  706. dataconfig.OrgId = adminUserInfo.CurrentOrgId
  707. dataconfig.CreateUserId = adminUserInfo.AdminUser.Id
  708. dataconfig.Status = 0
  709. dataconfig.Value = int(int64(dataBody["value"].(float64)))
  710. dataconfig.CreatedTime = time.Now().Format("2006-01-02 15:04:05")
  711. dataconfig.UpdatedTime = time.Now().Format("2006-01-02 15:04:05")
  712. dataconfig.Remark = string(dataBody["remark"].(string))
  713. if dataBody["order"] != nil {
  714. dataconfig.Order = int64(dataBody["order"].(float64))
  715. } else {
  716. dataconfig.Order = 0
  717. }
  718. configOrgId := int64(dataBody["org_id"].(float64))
  719. if configOrgId == 0 {
  720. dataconfig.DeleteIdSystem = int64(dataBody["id"].(float64))
  721. err := service.CreateDictionaryConfig(&dataconfig)
  722. if err != nil {
  723. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCreateConfig)
  724. return
  725. }
  726. } else {
  727. dataconfig.ID = int64(dataBody["id"].(float64))
  728. err := service.DeleteDictionaryChildConfig(&dataconfig)
  729. if err != nil {
  730. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeUpdateConfig)
  731. return
  732. }
  733. }
  734. c.ServeSuccessJSON(map[string]interface{}{
  735. "dataconfig": dataconfig,
  736. "msg": "ok",
  737. })
  738. return
  739. }
  740. //CreateChildConfig 创建子配置信息
  741. func (c *ManagerCenterApiController) CreateChildConfig() {
  742. adminUserInfo := c.GetAdminUserInfo()
  743. var dataconfig models.DictionaryDataconfig
  744. code := dictionaryConfigChildFormData(&dataconfig, c.Ctx.Input.RequestBody)
  745. if code > 0 {
  746. c.ServeFailJSONWithSGJErrorCode(code)
  747. return
  748. }
  749. dataBody := make(map[string]interface{}, 0)
  750. err := json.Unmarshal(c.Ctx.Input.RequestBody, &dataBody)
  751. if err != nil {
  752. utils.ErrorLog(err.Error())
  753. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  754. return
  755. }
  756. dataconfig.OrgId = adminUserInfo.CurrentOrgId
  757. dataconfig.CreateUserId = adminUserInfo.AdminUser.Id
  758. dataconfig.Status = 1
  759. dataconfig.CreatedTime = time.Now().Format("2006-01-02 15:04:05")
  760. dataconfig.UpdatedTime = time.Now().Format("2006-01-02 15:04:05")
  761. dataconfig.Remark = string(dataBody["remark"].(string))
  762. if dataBody["order"] != nil {
  763. dataconfig.Order = int64(dataBody["order"].(float64))
  764. } else {
  765. dataconfig.Order = 0
  766. }
  767. // 验证关键字段的值是否重复
  768. // thisConfig,_:=service.FindConfigByName(dataconfig.Module, dataconfig.Name,dataconfig.ParentId,dataconfig.OrgId)
  769. // if thisConfig.ID >0 {
  770. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeFieldExist)
  771. // return
  772. // }
  773. fieldValue := service.GetDictionaryChildValue(dataconfig.Module, dataconfig.ParentId, dataconfig.OrgId)
  774. dataconfig.Value = fieldValue + 1
  775. err = service.CreateDictionaryConfig(&dataconfig)
  776. if err != nil {
  777. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCreateConfig)
  778. return
  779. }
  780. c.ServeSuccessJSON(map[string]interface{}{
  781. "dataconfig": dataconfig,
  782. "msg": "ok",
  783. })
  784. return
  785. }
  786. func dictionaryConfigFormData(dataconfig *models.DictionaryDataconfig, data []byte) (code int) {
  787. configBody := make(map[string]interface{}, 0)
  788. err := json.Unmarshal(data, &configBody)
  789. utils.InfoLog(string(data))
  790. if err != nil {
  791. utils.ErrorLog(err.Error())
  792. code = enums.ErrorCodeParamWrong
  793. return
  794. }
  795. if configBody["module"] == nil || reflect.TypeOf(configBody["module"]).String() != "string" {
  796. utils.ErrorLog("module")
  797. code = enums.ErrorCodeParamWrong
  798. return
  799. }
  800. module, _ := configBody["module"].(string)
  801. if len(module) == 0 {
  802. utils.ErrorLog("len(module) == 0")
  803. code = enums.ErrorCodeParamWrong
  804. return
  805. }
  806. dataconfig.Module = module
  807. if module == "education" || module == "summary" || module == "course_disease" || module == "rescue_record" || module == "nursing_record" || module == "special_record" {
  808. if configBody["title"] == nil || reflect.TypeOf(configBody["title"]).String() != "string" {
  809. utils.ErrorLog("title")
  810. code = enums.ErrorCodeParamWrong
  811. return
  812. }
  813. title, _ := configBody["title"].(string)
  814. if len(title) == 0 {
  815. utils.ErrorLog("len(title) == 0")
  816. code = enums.ErrorCodeParamWrong
  817. return
  818. }
  819. dataconfig.Title = title
  820. if configBody["content"] == nil || reflect.TypeOf(configBody["content"]).String() != "string" {
  821. utils.ErrorLog("content")
  822. code = enums.ErrorCodeParamWrong
  823. return
  824. }
  825. content, _ := configBody["content"].(string)
  826. if len(content) == 0 {
  827. utils.ErrorLog("len(content) == 0")
  828. code = enums.ErrorCodeParamWrong
  829. return
  830. }
  831. dataconfig.Content = content
  832. } else {
  833. if configBody["name"] == nil || reflect.TypeOf(configBody["name"]).String() != "string" {
  834. utils.ErrorLog("name")
  835. code = enums.ErrorCodeParamWrong
  836. return
  837. }
  838. name, _ := configBody["name"].(string)
  839. if len(name) == 0 {
  840. utils.ErrorLog("len(name) == 0")
  841. code = enums.ErrorCodeParamWrong
  842. return
  843. }
  844. dataconfig.Name = name
  845. if configBody["field_name"] == nil || reflect.TypeOf(configBody["field_name"]).String() != "string" {
  846. utils.ErrorLog("field_name")
  847. code = enums.ErrorCodeParamWrong
  848. return
  849. }
  850. field_name, _ := configBody["field_name"].(string)
  851. if len(field_name) == 0 {
  852. utils.ErrorLog("len(field_name) == 0")
  853. code = enums.ErrorCodeParamWrong
  854. return
  855. }
  856. dataconfig.FieldName = field_name
  857. }
  858. return
  859. }
  860. func dictionaryConfigChildFormData(dataconfig *models.DictionaryDataconfig, data []byte) (code int) {
  861. configBody := make(map[string]interface{}, 0)
  862. err := json.Unmarshal(data, &configBody)
  863. utils.InfoLog(string(data))
  864. if err != nil {
  865. utils.ErrorLog(err.Error())
  866. code = enums.ErrorCodeParamWrong
  867. return
  868. }
  869. if configBody["module"] == nil || reflect.TypeOf(configBody["module"]).String() != "string" {
  870. utils.ErrorLog("module")
  871. code = enums.ErrorCodeParamWrong
  872. return
  873. }
  874. module, _ := configBody["module"].(string)
  875. if len(module) == 0 {
  876. utils.ErrorLog("len(module) == 0")
  877. code = enums.ErrorCodeParamWrong
  878. return
  879. }
  880. dataconfig.Module = module
  881. if module == "education" || module == "summary" {
  882. if configBody["title"] == nil || reflect.TypeOf(configBody["title"]).String() != "string" {
  883. utils.ErrorLog("title")
  884. code = enums.ErrorCodeParamWrong
  885. return
  886. }
  887. title, _ := configBody["title"].(string)
  888. if len(title) == 0 {
  889. utils.ErrorLog("len(title) == 0")
  890. code = enums.ErrorCodeParamWrong
  891. return
  892. }
  893. dataconfig.Title = title
  894. if configBody["content"] == nil || reflect.TypeOf(configBody["content"]).String() != "string" {
  895. utils.ErrorLog("content")
  896. code = enums.ErrorCodeParamWrong
  897. return
  898. }
  899. content, _ := configBody["content"].(string)
  900. if len(content) == 0 {
  901. utils.ErrorLog("len(content) == 0")
  902. code = enums.ErrorCodeParamWrong
  903. return
  904. }
  905. dataconfig.Content = content
  906. } else {
  907. if configBody["parent_id"] == nil || reflect.TypeOf(configBody["parent_id"]).String() != "float64" {
  908. utils.ErrorLog("module")
  909. code = enums.ErrorCodeParamWrong
  910. return
  911. }
  912. parent_id := int64(configBody["parent_id"].(float64))
  913. if parent_id <= 0 {
  914. utils.ErrorLog("parent_id <= 0")
  915. code = enums.ErrorCodeParamWrong
  916. return
  917. }
  918. dataconfig.ParentId = parent_id
  919. if configBody["name"] == nil || reflect.TypeOf(configBody["name"]).String() != "string" {
  920. utils.ErrorLog("name")
  921. code = enums.ErrorCodeParamWrong
  922. return
  923. }
  924. name, _ := configBody["name"].(string)
  925. if len(name) == 0 {
  926. utils.ErrorLog("len(name) == 0")
  927. code = enums.ErrorCodeParamWrong
  928. return
  929. }
  930. dataconfig.Name = name
  931. }
  932. return
  933. }
  934. func (c *ManagerCenterApiController) CreateDealer() {
  935. dealer_name := c.GetString("dealer_name")
  936. contact := c.GetString("contact")
  937. contact_phone := c.GetString("contact_phone")
  938. platform_number := c.GetString("platform_number")
  939. email := c.GetString("email")
  940. contact_address := c.GetString("contact_address")
  941. remark := c.GetString("remark")
  942. pinyin := c.GetString("pinyin")
  943. wubi := c.GetString("wubi")
  944. if len(dealer_name) <= 0 {
  945. utils.ErrorLog("len(dealer_name) == 0")
  946. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  947. return
  948. }
  949. adminUserInfo := c.GetAdminUserInfo()
  950. total := service.FindAllDealerTotal(adminUserInfo.CurrentOrgId)
  951. totalStr := strconv.FormatInt(total+1, 10)
  952. code := "1000" + totalStr
  953. dealer := models.Dealer{
  954. DealerName: dealer_name,
  955. Contact: contact,
  956. ContactPhone: contact_phone,
  957. ContactAddress: contact_address,
  958. DealerCode: code,
  959. Ctime: time.Now().Unix(),
  960. Mtime: time.Now().Unix(),
  961. Remark: remark,
  962. Creater: adminUserInfo.AdminUser.Id,
  963. Email: email,
  964. PlatformNumber: platform_number,
  965. OrgId: adminUserInfo.CurrentOrgId,
  966. Status: 1,
  967. PinYin: pinyin,
  968. WuBi: wubi,
  969. }
  970. err, dealers := service.AddSigleDealer(&dealer)
  971. if err == nil {
  972. c.ServeSuccessJSON(map[string]interface{}{
  973. "dealer": dealers,
  974. })
  975. } else {
  976. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  977. }
  978. }
  979. func (c *ManagerCenterApiController) ModifyDealer() {
  980. id, _ := c.GetInt64("id", 0)
  981. dealer_name := c.GetString("dealer_name")
  982. contact := c.GetString("contact")
  983. contact_phone := c.GetString("contact_phone")
  984. platform_number := c.GetString("platform_number")
  985. dealer_code := c.GetString("dealer_code")
  986. email := c.GetString("email")
  987. contact_address := c.GetString("contact_address")
  988. remark := c.GetString("remark")
  989. pinyin := c.GetString("pinyin")
  990. wubi := c.GetString("wubi")
  991. if id <= 0 {
  992. utils.ErrorLog("id == 0")
  993. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  994. return
  995. }
  996. if len(dealer_name) <= 0 {
  997. utils.ErrorLog("len(dealer_name) == 0")
  998. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  999. return
  1000. }
  1001. adminUserInfo := c.GetAdminUserInfo()
  1002. dealer := models.Dealer{
  1003. ID: id,
  1004. DealerName: dealer_name,
  1005. Contact: contact,
  1006. ContactPhone: contact_phone,
  1007. ContactAddress: contact_address,
  1008. Mtime: time.Now().Unix(),
  1009. DealerCode: dealer_code,
  1010. Remark: remark,
  1011. Creater: adminUserInfo.AdminUser.Id,
  1012. Email: email,
  1013. PlatformNumber: platform_number,
  1014. Modifier: adminUserInfo.AdminUser.Id,
  1015. OrgId: adminUserInfo.CurrentOrgId,
  1016. Status: 1,
  1017. PinYin: pinyin,
  1018. WuBi: wubi,
  1019. }
  1020. err := service.ModifyDealer(&dealer)
  1021. if err == nil {
  1022. c.ServeSuccessJSON(map[string]interface{}{
  1023. "dealer": dealer,
  1024. })
  1025. } else {
  1026. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  1027. }
  1028. }
  1029. func (c *ManagerCenterApiController) GetDealersList() {
  1030. page, _ := c.GetInt64("page", 1)
  1031. limit, _ := c.GetInt64("limit", 7)
  1032. adminUserInfo := c.GetAdminUserInfo()
  1033. deales, total, err := service.FindAllDealerList(adminUserInfo.CurrentOrgId, page, limit)
  1034. if err == nil {
  1035. c.ServeSuccessJSON(map[string]interface{}{
  1036. "dealer": deales,
  1037. "total": total,
  1038. })
  1039. } else {
  1040. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  1041. }
  1042. }
  1043. func (c *ManagerCenterApiController) DeleteDealer() {
  1044. id, _ := c.GetInt64("id", 0)
  1045. total, _ := service.FindStockInByDealerId(id)
  1046. if total > 0 {
  1047. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDeleteDealerWrong)
  1048. return
  1049. }
  1050. err := service.DeleteDealerById(id)
  1051. if err == nil {
  1052. c.ServeSuccessJSON(map[string]interface{}{
  1053. "msg": "删除成功",
  1054. })
  1055. } else {
  1056. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  1057. }
  1058. }
  1059. func (c *ManagerCenterApiController) GetDealer() {
  1060. id, _ := c.GetInt64("id", 0)
  1061. dealer, err := service.FindDealerById(id)
  1062. if err == nil {
  1063. c.ServeSuccessJSON(map[string]interface{}{
  1064. "dealer": dealer,
  1065. })
  1066. } else {
  1067. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  1068. }
  1069. }
  1070. func (c *ManagerCenterApiController) CreateManufacturer() {
  1071. manufacturer_name := c.GetString("manufacturer_name")
  1072. contact := c.GetString("contact")
  1073. contact_phone := c.GetString("contact_phone")
  1074. platform_number := c.GetString("platform_number")
  1075. email := c.GetString("email")
  1076. contact_address := c.GetString("contact_address")
  1077. remark := c.GetString("remark")
  1078. pinyin := c.GetString("pinyin")
  1079. wubi := c.GetString("wubi")
  1080. if len(manufacturer_name) <= 0 {
  1081. utils.ErrorLog("len(manufacturer_name) == 0")
  1082. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  1083. return
  1084. }
  1085. adminUserInfo := c.GetAdminUserInfo()
  1086. total := service.FindManufacturerTotal(adminUserInfo.CurrentOrgId)
  1087. totalStr := strconv.FormatInt(total+1, 10)
  1088. code := "2000" + totalStr
  1089. manufacturer := models.Manufacturer{
  1090. ManufacturerName: manufacturer_name,
  1091. Contact: contact,
  1092. ContactPhone: contact_phone,
  1093. ContactAddress: contact_address,
  1094. Ctime: time.Now().Unix(),
  1095. Mtime: time.Now().Unix(),
  1096. Remark: remark,
  1097. Creater: adminUserInfo.AdminUser.Id,
  1098. Email: email,
  1099. PlatformNumber: platform_number,
  1100. OrgId: adminUserInfo.CurrentOrgId,
  1101. Status: 1,
  1102. ManufacturerCode: code,
  1103. PinYin: pinyin,
  1104. WuBi: wubi,
  1105. }
  1106. err, manufacturers := service.AddSigleManufacturer(&manufacturer)
  1107. if err == nil {
  1108. c.ServeSuccessJSON(map[string]interface{}{
  1109. "manufacturer": manufacturers,
  1110. })
  1111. } else {
  1112. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  1113. }
  1114. }
  1115. func (c *ManagerCenterApiController) ModifyManufacturer() {
  1116. id, _ := c.GetInt64("id", 0)
  1117. manufacturer_name := c.GetString("manufacturer_name")
  1118. contact := c.GetString("contact")
  1119. contact_phone := c.GetString("contact_phone")
  1120. platform_number := c.GetString("platform_number")
  1121. email := c.GetString("email")
  1122. contact_address := c.GetString("contact_address")
  1123. remark := c.GetString("remark")
  1124. manufacturer_code := c.GetString("manufacturer_code")
  1125. pinyin := c.GetString("pinyin")
  1126. wubi := c.GetString("wubi")
  1127. if id <= 0 {
  1128. utils.ErrorLog("id == 0")
  1129. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  1130. return
  1131. }
  1132. if len(manufacturer_name) <= 0 {
  1133. utils.ErrorLog("len(manufacturer_name) == 0")
  1134. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  1135. return
  1136. }
  1137. adminUserInfo := c.GetAdminUserInfo()
  1138. manufacturer := models.Manufacturer{
  1139. ID: id,
  1140. ManufacturerName: manufacturer_name,
  1141. Contact: contact,
  1142. ContactPhone: contact_phone,
  1143. ContactAddress: contact_address,
  1144. Mtime: time.Now().Unix(),
  1145. Remark: remark,
  1146. Creater: adminUserInfo.AdminUser.Id,
  1147. Email: email,
  1148. PlatformNumber: platform_number,
  1149. Modifier: adminUserInfo.AdminUser.Id,
  1150. OrgId: adminUserInfo.CurrentOrgId,
  1151. ManufacturerCode: manufacturer_code,
  1152. Status: 1,
  1153. PinYin: pinyin,
  1154. WuBi: wubi,
  1155. }
  1156. err := service.ModifyManufacturer(&manufacturer)
  1157. if err == nil {
  1158. c.ServeSuccessJSON(map[string]interface{}{
  1159. "manufacturer": manufacturer,
  1160. })
  1161. } else {
  1162. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  1163. }
  1164. }
  1165. func (c *ManagerCenterApiController) GetManufacturerList() {
  1166. page, _ := c.GetInt64("page", 1)
  1167. limit, _ := c.GetInt64("limit", 10)
  1168. adminUserInfo := c.GetAdminUserInfo()
  1169. manufacturer, total, err := service.FindAllManufacturerList(adminUserInfo.CurrentOrgId, page, limit)
  1170. if err == nil {
  1171. c.ServeSuccessJSON(map[string]interface{}{
  1172. "manufacturer": manufacturer,
  1173. "total": total,
  1174. })
  1175. } else {
  1176. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  1177. }
  1178. }
  1179. func (c *ManagerCenterApiController) DeleteManufacturer() {
  1180. id, _ := c.GetInt64("id", 0)
  1181. total, _ := service.FindStockInByManufacturerId(id)
  1182. if total > 0 {
  1183. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDeleteManufacturerWrong)
  1184. return
  1185. }
  1186. err := service.DeleteManufacturerById(id)
  1187. if err == nil {
  1188. c.ServeSuccessJSON(map[string]interface{}{
  1189. "msg": "删除成功",
  1190. })
  1191. } else {
  1192. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  1193. }
  1194. }
  1195. func (c *ManagerCenterApiController) GetManufacturer() {
  1196. id, _ := c.GetInt64("id", 0)
  1197. manufacturer, err := service.FindManufacturerById(id)
  1198. if err == nil {
  1199. c.ServeSuccessJSON(map[string]interface{}{
  1200. "manufacturer": manufacturer,
  1201. })
  1202. } else {
  1203. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  1204. }
  1205. }
  1206. func (c *ManagerCenterApiController) GetAllDealer() {
  1207. adminUserInfo := c.GetAdminUserInfo()
  1208. dealer, err := service.FindAllDealer(adminUserInfo.CurrentOrgId)
  1209. if err == nil {
  1210. c.ServeSuccessJSON(map[string]interface{}{
  1211. "dealer": dealer,
  1212. })
  1213. } else {
  1214. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  1215. }
  1216. }
  1217. func (c *ManagerCenterApiController) GetAllManufacturer() {
  1218. adminUserInfo := c.GetAdminUserInfo()
  1219. manufacturer, err := service.FindAllManufacturer(adminUserInfo.CurrentOrgId)
  1220. if err == nil {
  1221. c.ServeSuccessJSON(map[string]interface{}{
  1222. "manufacturer": manufacturer,
  1223. })
  1224. } else {
  1225. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  1226. }
  1227. }
  1228. func (c *ManagerCenterApiController) CreateGoodInfo() {
  1229. good_id, _ := c.GetInt64("good_id", 0)
  1230. specification_name := c.GetString("specification_name")
  1231. good_unit, _ := c.GetInt64("good_unit", -1)
  1232. buy_price, _ := c.GetFloat("buy_price", 0)
  1233. sell_price, _ := c.GetFloat("sell_price", 0)
  1234. remark := c.GetString("remark")
  1235. manufacturer, _ := c.GetInt64("manufacturer", 0)
  1236. dealer, _ := c.GetInt64("dealer", 0)
  1237. expiry_date_warn_day_count, _ := c.GetInt64("expiry_date_warn_day_count", 0)
  1238. stock_warn_count, _ := c.GetInt64("stock_warn_count", 0)
  1239. is_reuse, _ := c.GetInt64("is_reuse", 0)
  1240. good_name := c.GetString("good_name")
  1241. pinyin := c.GetString("pinyin")
  1242. wubi := c.GetString("wubi")
  1243. good_kind, _ := c.GetInt64("good_kind", 0)
  1244. medical_insurance_level, _ := c.GetInt64("medical_insurance_level", 0)
  1245. retail_price, _ := c.GetFloat("retail_price", 0)
  1246. medical_insurance_number := c.GetString("medical_insurance_number")
  1247. is_special_diseases, _ := c.GetInt64("is_special_diseases", 0)
  1248. is_record, _ := c.GetInt64("is_record")
  1249. statistics_category, _ := c.GetInt64("statistics_category")
  1250. good_status := c.GetString("good_status")
  1251. default_count, _ := c.GetInt64("default_count")
  1252. sign, _ := c.GetInt64("sign")
  1253. is_default, _ := c.GetInt64("is_default")
  1254. is_charge_use, _ := c.GetInt64("is_charge_use")
  1255. is_charge_predict, _ := c.GetInt64("is_charge_predict")
  1256. is_statistics_work, _ := c.GetInt64("is_statistics_work")
  1257. sort, _ := c.GetInt64("sort")
  1258. is_doctor_use, _ := c.GetInt64("is_doctor_use")
  1259. agent := c.GetString("agent")
  1260. good_number := c.GetString("good_number")
  1261. adminUserInfo := c.GetAdminUserInfo()
  1262. totals := service.FindGoodInfoByName(specification_name, adminUserInfo.CurrentOrgId, good_id)
  1263. if totals > 0 {
  1264. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeGoodInfoNameExistError)
  1265. return
  1266. }
  1267. total := service.FindAllGoodInfoTotal(adminUserInfo.CurrentOrgId)
  1268. code := strconv.FormatInt(total+1, 10)
  1269. code = "24000000" + code
  1270. goodInfo := models.GoodInfo{
  1271. GoodCode: code,
  1272. SpecificationName: specification_name,
  1273. GoodTypeId: good_id,
  1274. GoodUnit: good_unit,
  1275. BuyPrice: buy_price,
  1276. SellPrice: sell_price,
  1277. Remark: remark,
  1278. Ctime: time.Now().Unix(),
  1279. Manufacturer: manufacturer,
  1280. Dealer: dealer,
  1281. ExpiryDateWarnDayCount: expiry_date_warn_day_count,
  1282. StockWarnCount: stock_warn_count,
  1283. IsReuse: is_reuse,
  1284. Status: 1,
  1285. OrgId: adminUserInfo.CurrentOrgId,
  1286. Creater: adminUserInfo.AdminUser.Id,
  1287. GoodName: good_name,
  1288. Pinyin: pinyin,
  1289. Wubi: wubi,
  1290. GoodKind: good_kind,
  1291. MedicalInsuranceNumber: medical_insurance_number,
  1292. IsSpecialDiseases: is_special_diseases,
  1293. IsRecord: is_record,
  1294. StatisticsCategory: statistics_category,
  1295. GoodStatus: good_status,
  1296. DefaultCount: default_count,
  1297. Sign: sign,
  1298. IsDefault: is_default,
  1299. IsChargeUse: is_charge_use,
  1300. IsChargePredict: is_charge_predict,
  1301. IsStatisticsWork: is_statistics_work,
  1302. Sort: sort,
  1303. IsDoctorUse: is_doctor_use,
  1304. Agent: agent,
  1305. GoodNumber: good_number,
  1306. MedicalInsuranceLevel: medical_insurance_level,
  1307. RetailPrice: retail_price,
  1308. }
  1309. err, goodInfos := service.AddSigleGoodInfo(&goodInfo)
  1310. if err == nil {
  1311. c.ServeSuccessJSON(map[string]interface{}{
  1312. "goodInfo": goodInfos,
  1313. })
  1314. } else {
  1315. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  1316. }
  1317. }
  1318. func (c *ManagerCenterApiController) ModifyGoodInfo() {
  1319. id, _ := c.GetInt64("id", 0)
  1320. good_id, _ := c.GetInt64("good_id", 0)
  1321. specification_name := c.GetString("specification_name")
  1322. good_unit, _ := c.GetInt64("good_unit", -1)
  1323. buy_price, _ := c.GetFloat("buy_price", 0)
  1324. sell_price, _ := c.GetFloat("sell_price", 0)
  1325. remark := c.GetString("remark")
  1326. manufacturer, _ := c.GetInt64("manufacturer", 0)
  1327. dealer, _ := c.GetInt64("dealer", 0)
  1328. expiry_date_warn_day_count, _ := c.GetInt64("expiry_date_warn_day_count", 0)
  1329. stock_warn_count, _ := c.GetInt64("stock_warn_count", 0)
  1330. is_reuse, _ := c.GetInt64("is_reuse", 0)
  1331. code := c.GetString("good_code")
  1332. good_name := c.GetString("good_name")
  1333. pinyin := c.GetString("pinyin")
  1334. wubi := c.GetString("wubi")
  1335. good_kind, _ := c.GetInt64("good_kind", 0)
  1336. medical_insurance_level, _ := c.GetInt64("medical_insurance_level", 0)
  1337. retail_price, _ := c.GetFloat("retail_price", 0)
  1338. medical_insurance_number := c.GetString("medical_insurance_number")
  1339. is_special_diseases, _ := c.GetInt64("is_special_diseases", 0)
  1340. is_record, _ := c.GetInt64("is_record")
  1341. statistics_category, _ := c.GetInt64("statistics_category")
  1342. good_status := c.GetString("good_status")
  1343. default_count, _ := c.GetInt64("default_count")
  1344. sign, _ := c.GetInt64("sign")
  1345. is_default, _ := c.GetInt64("is_default")
  1346. is_charge_use, _ := c.GetInt64("is_charge_use")
  1347. is_charge_predict, _ := c.GetInt64("is_charge_predict")
  1348. is_statistics_work, _ := c.GetInt64("is_statistics_work")
  1349. sort, _ := c.GetInt64("sort")
  1350. is_doctor_use, _ := c.GetInt64("is_doctor_use")
  1351. agent := c.GetString("agent")
  1352. good_number := c.GetString("good_number")
  1353. adminUserInfo := c.GetAdminUserInfo()
  1354. goodInfo := models.GoodInfo{
  1355. ID: id,
  1356. GoodCode: code,
  1357. SpecificationName: specification_name,
  1358. GoodTypeId: good_id,
  1359. GoodUnit: good_unit,
  1360. BuyPrice: buy_price,
  1361. SellPrice: sell_price,
  1362. Remark: remark,
  1363. Mtime: time.Now().Unix(),
  1364. Manufacturer: manufacturer,
  1365. Dealer: dealer,
  1366. ExpiryDateWarnDayCount: expiry_date_warn_day_count,
  1367. StockWarnCount: stock_warn_count,
  1368. IsReuse: is_reuse,
  1369. Status: 1,
  1370. OrgId: adminUserInfo.CurrentOrgId,
  1371. Modifier: adminUserInfo.AdminUser.Id,
  1372. GoodName: good_name,
  1373. Pinyin: pinyin,
  1374. Wubi: wubi,
  1375. GoodKind: good_kind,
  1376. MedicalInsuranceNumber: medical_insurance_number,
  1377. IsSpecialDiseases: is_special_diseases,
  1378. IsRecord: is_record,
  1379. StatisticsCategory: statistics_category,
  1380. GoodStatus: good_status,
  1381. DefaultCount: default_count,
  1382. Sign: sign,
  1383. IsDefault: is_default,
  1384. IsChargeUse: is_charge_use,
  1385. IsChargePredict: is_charge_predict,
  1386. IsStatisticsWork: is_statistics_work,
  1387. Sort: sort,
  1388. IsDoctorUse: is_doctor_use,
  1389. Agent: agent,
  1390. GoodNumber: good_number,
  1391. MedicalInsuranceLevel: medical_insurance_level,
  1392. RetailPrice: retail_price,
  1393. }
  1394. err, goodInfos := service.ModifyGoodInfo(&goodInfo)
  1395. if err == nil {
  1396. c.ServeSuccessJSON(map[string]interface{}{
  1397. "goodInfo": goodInfos,
  1398. })
  1399. } else {
  1400. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  1401. }
  1402. }
  1403. func (c *ManagerCenterApiController) GetGoodInfoList() {
  1404. page, _ := c.GetInt64("page", 1)
  1405. limit, _ := c.GetInt64("limit", 7)
  1406. keyword := c.GetString("keyword")
  1407. is_use, _ := c.GetInt64("is_use")
  1408. is_charge, _ := c.GetInt64("is_charge")
  1409. good_kind, _ := c.GetInt64("good_kind")
  1410. adminUserInfo := c.GetAdminUserInfo()
  1411. goodInfos, total, err := service.FindGoodInfoList(adminUserInfo.CurrentOrgId, page, limit, keyword, is_use, is_charge, good_kind)
  1412. if err == nil {
  1413. c.ServeSuccessJSON(map[string]interface{}{
  1414. "list": goodInfos,
  1415. "total": total,
  1416. })
  1417. } else {
  1418. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  1419. }
  1420. }
  1421. func (c *ManagerCenterApiController) DeleteGoodInfo() {
  1422. id, _ := c.GetInt64("id", 0)
  1423. adminUserInfo := c.GetAdminUserInfo()
  1424. total, _ := service.FindWarehouseInfoTotalByGoodId(id)
  1425. total2, _ := service.FindWarehouseOutInfoTotalByGoodId(id)
  1426. if total > 0 {
  1427. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDeleteGoodInfoFail)
  1428. return
  1429. }
  1430. if total2 > 0 {
  1431. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDeleteGoodInfoFail)
  1432. return
  1433. }
  1434. err := service.DeleteGoodInfoById(id, adminUserInfo.AdminUser.Id)
  1435. if err == nil {
  1436. c.ServeSuccessJSON(map[string]interface{}{
  1437. "msg": "删除成功",
  1438. })
  1439. } else {
  1440. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  1441. }
  1442. }
  1443. func (c *ManagerCenterApiController) GetGoodInfoByGoodId() {
  1444. id, _ := c.GetInt64("id", 0)
  1445. goodInfo, err := service.FindGoodInfoByGoodId(id)
  1446. if err == nil {
  1447. c.ServeSuccessJSON(map[string]interface{}{
  1448. "list": goodInfo,
  1449. })
  1450. } else {
  1451. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  1452. }
  1453. }
  1454. func (c *ManagerCenterApiController) GetGoodInfoById() {
  1455. id, _ := c.GetInt64("id", 0)
  1456. goodInfo, err := service.FindGoodInfoById(id)
  1457. if err == nil {
  1458. c.ServeSuccessJSON(map[string]interface{}{
  1459. "goodInfo": goodInfo,
  1460. })
  1461. } else {
  1462. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  1463. }
  1464. }
  1465. func (c *ManagerCenterApiController) GetMedicineInsurancePercent() {
  1466. adminUser := c.GetAdminUserInfo()
  1467. type_id, _ := c.GetInt64("type_id", 0)
  1468. module, _ := c.GetInt64("module", 0)
  1469. mip, err := service.GetLastMedicineInsurance(adminUser.CurrentOrgId, type_id, module)
  1470. if err == nil {
  1471. c.ServeSuccessJSON(map[string]interface{}{
  1472. "mip": mip,
  1473. })
  1474. } else {
  1475. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  1476. }
  1477. }
  1478. func (c *ManagerCenterApiController) DeleteBaseDrugById() {
  1479. id, _ := c.GetInt64("id")
  1480. //查询入库单
  1481. _, errcode := service.GetDrugWareoutInfo(id)
  1482. if errcode == gorm.ErrRecordNotFound {
  1483. //查询出库单
  1484. _, errcodes := service.GetDrugWareOutById(id)
  1485. if errcodes == gorm.ErrRecordNotFound {
  1486. //删除
  1487. service.DeleteBaseDrugById(id)
  1488. returnData := make(map[string]interface{}, 0)
  1489. returnData["msg"] = "ok"
  1490. c.ServeSuccessJSON(returnData)
  1491. return
  1492. } else if errcodes == nil {
  1493. c.ServeFailJsonSend(enums.ErrorCodeDataException, "已出库")
  1494. return
  1495. }
  1496. } else if errcode == nil {
  1497. c.ServeFailJsonSend(enums.ErrorCodeDataException, "已入库")
  1498. return
  1499. }
  1500. }