manager_center_api_controller.go 52KB

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