manager_center_api_controller.go 60KB

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