custom_api_controller.go 35KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135
  1. package admin_api_controllers
  2. import (
  3. "XT_Admin_Api/enums"
  4. "XT_Admin_Api/models"
  5. "XT_Admin_Api/service"
  6. "fmt"
  7. "time"
  8. )
  9. type CustomAPIController struct {
  10. AdminBaseAPIAuthController
  11. }
  12. func (this *CustomAPIController) CheckCustom() {
  13. id, _ := this.GetInt64("id")
  14. ci, _ := service.FindCustomInfoByIDTwo(id)
  15. if ci.ID == 0 {
  16. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  17. return
  18. }
  19. ci.IsCheck = 1
  20. ci.CheckPerson = this.GetAdminInfo().Name
  21. err := service.SaveCustomTwo(ci)
  22. if err != nil {
  23. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  24. return
  25. }
  26. this.ServeSuccessJSON(map[string]interface{}{
  27. "msg": "审核成功",
  28. })
  29. }
  30. func (this *CustomAPIController) CreateCustom() {
  31. name := this.GetString("name")
  32. //xtOrgID := this.GetString("xt_org_id")
  33. customType, _ := this.GetInt64("custom_type")
  34. salesperson := this.GetString("salesperson")
  35. signTime := this.GetString("sign_time")
  36. contractPrice := this.GetString("contract_price")
  37. softwarePrice := this.GetString("software_price")
  38. hardwarePrice := this.GetString("hardware_price")
  39. yearCostPrice := this.GetString("year_cost_price")
  40. address := this.GetString("address")
  41. isImplement, _ := this.GetInt64("is_implement")
  42. lisStatus, _ := this.GetInt64("lis_status")
  43. lisContact := this.GetString("lis_contact")
  44. lisTime := this.GetString("lis_time")
  45. lisRemark := this.GetString("lis_remark")
  46. qcStatus, _ := this.GetInt64("qc_status")
  47. ybStatus, _ := this.GetInt64("yb_status")
  48. remark := this.GetString("remark")
  49. weightScaleStatus, _ := this.GetInt64("weight_scale_status")
  50. weightScaleBrand := this.GetString("weight_scale_brand")
  51. weightScaleRemark := this.GetString("weight_scale_remark")
  52. sphygmomanometerStatus, _ := this.GetInt64("sphygmomanometer_status")
  53. sphygmomanometerBrand := this.GetString("sphygmomanometer_brand")
  54. sphygmomanometerRemark := this.GetString("sphygmomanometer_remark")
  55. scannerStatus, _ := this.GetInt64("scanner_status")
  56. scannerBrand := this.GetString("scanner_brand")
  57. scannerRemark := this.GetString("scanner_remark")
  58. facialRecognitionDeviceStatus, _ := this.GetInt64("facial_recognition_device_status")
  59. facialRecognitionDeviceBrand := this.GetString("facial_recognition_device_brand")
  60. facialRecognitionDeviceRemark := this.GetString("facial_recognition_device_remark")
  61. printerStatus, _ := this.GetInt64("printer_status")
  62. printerBrand := this.GetString("printer_brand")
  63. printerRemark := this.GetString("printer_remark")
  64. hardwareRemark := this.GetString("hardware_remark")
  65. implement_time := this.GetString("implement_time")
  66. implement_person := this.GetString("implement_person")
  67. implement_remark := this.GetString("implement_remark")
  68. yb_time := this.GetString("yb_time")
  69. yb_person := this.GetString("yb_person")
  70. yb_remark := this.GetString("yb_remark")
  71. qc_time := this.GetString("qc_time")
  72. qc_person := this.GetString("qc_person")
  73. qc_remark := this.GetString("qc_remark")
  74. client_remark := this.GetString("client_remark")
  75. topline_time := this.GetString("topline_time")
  76. kyyChargeCustom := &models.KyyChargeCustom{
  77. ImplementTime: implement_time,
  78. ImplementPerson: implement_person,
  79. ImplementRemark: implement_remark,
  80. YbTime: yb_time,
  81. YbRemark: yb_remark,
  82. YbPerson: yb_person,
  83. QcTime: qc_time,
  84. QcPerson: qc_person,
  85. QcRemark: qc_remark,
  86. Name: name,
  87. Status: 1,
  88. Ctime: time.Now().Unix(),
  89. Mtime: time.Now().Unix(),
  90. Creator: 0,
  91. Modifier: 0,
  92. CustomType: customType,
  93. Salesperson: salesperson,
  94. SignTime: signTime,
  95. ContractPrice: contractPrice,
  96. SoftwarePrice: softwarePrice,
  97. HardwarePrice: hardwarePrice,
  98. YearCostPrice: yearCostPrice,
  99. Address: address,
  100. IsImplement: isImplement,
  101. LisStatus: lisStatus,
  102. LisContact: lisContact,
  103. LisTime: lisTime,
  104. LisRemark: lisRemark,
  105. QcStatus: qcStatus,
  106. YbStatus: ybStatus,
  107. Remark: remark,
  108. WeightScaleStatus: weightScaleStatus,
  109. WeightScaleBrand: weightScaleBrand,
  110. WeightScaleRemark: weightScaleRemark,
  111. SphygmomanometerStatus: sphygmomanometerStatus,
  112. SphygmomanometerBrand: sphygmomanometerBrand,
  113. SphygmomanometerRemark: sphygmomanometerRemark,
  114. ScannerStatus: scannerStatus,
  115. ScannerBrand: scannerBrand,
  116. ScannerRemark: scannerRemark,
  117. FacialRecognitionDeviceStatus: facialRecognitionDeviceStatus,
  118. FacialRecognitionDeviceBrand: facialRecognitionDeviceBrand,
  119. FacialRecognitionDeviceRemark: facialRecognitionDeviceRemark,
  120. PrinterStatus: printerStatus,
  121. PrinterBrand: printerBrand,
  122. PrinterRemark: printerRemark,
  123. HardwareRemark: hardwareRemark,
  124. ClientRemark: client_remark,
  125. ToplineTime: topline_time,
  126. }
  127. //custom, _ := service.FindCustomInfo(xtOrgID)
  128. //if custom.ID > 0 {
  129. // this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNameException)
  130. // return
  131. //}
  132. err := service.CreateCustom(kyyChargeCustom)
  133. if err == nil {
  134. this.ServeSuccessJSON(map[string]interface{}{
  135. "custom": kyyChargeCustom,
  136. })
  137. }
  138. }
  139. func (this *CustomAPIController) GetCustomList() {
  140. list, _ := service.GetAllCustoms()
  141. this.ServeSuccessJSON(map[string]interface{}{
  142. "list": list,
  143. })
  144. }
  145. // func (this *CustomAPIController) DeleteAdmin() {
  146. // id, _ := this.GetInt64("id")
  147. // err := service.DeleteAdmin(id)
  148. // if err == nil {
  149. // this.ServeSuccessJSON(map[string]interface{}{
  150. // "msg": "删除成功",
  151. // })
  152. // }
  153. // }
  154. func (this *CustomAPIController) ModifyCustom() {
  155. id, _ := this.GetInt64("id")
  156. module, _ := this.GetInt64("module")
  157. custom, _ := service.FindCustomInfoByIDTwo(id)
  158. switch module {
  159. case 1: //编辑基本信息
  160. name := this.GetString("name")
  161. customType, _ := this.GetInt64("custom_type")
  162. salesperson := this.GetString("salesperson")
  163. signTime := this.GetString("sign_time")
  164. contractPrice := this.GetString("contract_price")
  165. softwarePrice := this.GetString("software_price")
  166. hardwarePrice := this.GetString("hardware_price")
  167. yearCostPrice := this.GetString("year_cost_price")
  168. address := this.GetString("address")
  169. client_remark := this.GetString("client_remark")
  170. topline_time := this.GetString("topline_time")
  171. custom.CustomType = customType
  172. custom.Salesperson = salesperson
  173. custom.SignTime = signTime
  174. custom.ContractPrice = contractPrice
  175. custom.SoftwarePrice = softwarePrice
  176. custom.HardwarePrice = hardwarePrice
  177. custom.YearCostPrice = yearCostPrice
  178. custom.Address = address
  179. custom.Name = name
  180. custom.ID = id
  181. custom.Mtime = time.Now().Unix()
  182. custom.ClientRemark = client_remark
  183. custom.ToplineTime = topline_time
  184. err := service.UpdateCustomTwo(custom)
  185. if err != nil {
  186. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  187. return
  188. }
  189. this.ServeSuccessJSON(map[string]interface{}{
  190. "msg": "修改成功",
  191. })
  192. break
  193. case 2: //编辑实施信息
  194. isImplement, _ := this.GetInt64("is_implement")
  195. implementTime := this.GetString("implement_time")
  196. implementPerson := this.GetString("implement_person")
  197. implementRemark := this.GetString("implement_remark")
  198. custom.IsImplement = isImplement
  199. custom.ImplementTime = implementTime
  200. custom.ImplementPerson = implementPerson
  201. custom.ImplementRemark = implementRemark
  202. custom.ID = id
  203. custom.Mtime = time.Now().Unix()
  204. err := service.UpdateCustomTwo(custom)
  205. if err != nil {
  206. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  207. return
  208. }
  209. this.ServeSuccessJSON(map[string]interface{}{
  210. "msg": "修改成功",
  211. })
  212. break
  213. case 3: //编辑LIS对接
  214. lisStatus, _ := this.GetInt64("lis_status")
  215. lisContact := this.GetString("lis_contact")
  216. lisTime := this.GetString("lis_time")
  217. lisRemark := this.GetString("lis_remark")
  218. custom.LisStatus = lisStatus
  219. custom.LisTime = lisTime
  220. custom.LisRemark = lisRemark
  221. custom.LisContact = lisContact
  222. custom.ID = id
  223. custom.Mtime = time.Now().Unix()
  224. err := service.UpdateCustomTwo(custom)
  225. if err != nil {
  226. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  227. return
  228. }
  229. this.ServeSuccessJSON(map[string]interface{}{
  230. "msg": "修改成功",
  231. })
  232. break
  233. case 4: //编辑医保对接
  234. ybStatus, _ := this.GetInt64("yb_status")
  235. ybPerson := this.GetString("yb_person")
  236. ybTime := this.GetString("yb_time")
  237. ybRemark := this.GetString("yb_remark")
  238. custom.YbStatus = ybStatus
  239. custom.YbPerson = ybPerson
  240. custom.YbTime = ybTime
  241. custom.YbRemark = ybRemark
  242. custom.ID = id
  243. custom.Mtime = time.Now().Unix()
  244. err := service.UpdateCustomTwo(custom)
  245. if err != nil {
  246. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  247. return
  248. }
  249. this.ServeSuccessJSON(map[string]interface{}{
  250. "msg": "修改成功",
  251. })
  252. break
  253. case 5: //编辑质控对接
  254. qcStatus, _ := this.GetInt64("qc_status")
  255. qcPerson := this.GetString("qc_person")
  256. qcTime := this.GetString("qc_time")
  257. qcRemark := this.GetString("qc_remark")
  258. custom.QcStatus = qcStatus
  259. custom.QcPerson = qcPerson
  260. custom.QcTime = qcTime
  261. custom.QcRemark = qcRemark
  262. custom.ID = id
  263. custom.Mtime = time.Now().Unix()
  264. err := service.UpdateCustomTwo(custom)
  265. if err != nil {
  266. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  267. return
  268. }
  269. this.ServeSuccessJSON(map[string]interface{}{
  270. "msg": "修改成功",
  271. })
  272. break
  273. case 6: //编辑备注
  274. remark := this.GetString("remark")
  275. custom.Remark = remark
  276. custom.ID = id
  277. custom.Mtime = time.Now().Unix()
  278. err := service.UpdateCustomTwo(custom)
  279. if err != nil {
  280. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  281. return
  282. }
  283. this.ServeSuccessJSON(map[string]interface{}{
  284. "msg": "修改成功",
  285. })
  286. break
  287. case 7: //编辑硬件信息
  288. weightScaleStatus, _ := this.GetInt64("weight_scale_status")
  289. weightScaleBrand := this.GetString("weight_scale_brand")
  290. weightScaleRemark := this.GetString("weight_scale_remark")
  291. sphygmomanometerStatus, _ := this.GetInt64("sphygmomanometer_status")
  292. sphygmomanometerBrand := this.GetString("sphygmomanometer_brand")
  293. sphygmomanometerRemark := this.GetString("sphygmomanometer_remark")
  294. scannerStatus, _ := this.GetInt64("scanner_status")
  295. scannerBrand := this.GetString("scanner_brand")
  296. scannerRemark := this.GetString("scanner_remark")
  297. facialRecognitionDeviceStatus, _ := this.GetInt64("facial_recognition_device_status")
  298. facialRecognitionDeviceBrand := this.GetString("facial_recognition_device_brand")
  299. facialRecognitionDeviceRemark := this.GetString("facial_recognition_device_remark")
  300. printerStatus, _ := this.GetInt64("printer_status")
  301. printerBrand := this.GetString("printer_brand")
  302. printerRemark := this.GetString("printer_remark")
  303. hardwareRemark := this.GetString("hardware_remark")
  304. custom.WeightScaleStatus = weightScaleStatus
  305. custom.WeightScaleBrand = weightScaleBrand
  306. custom.WeightScaleRemark = weightScaleRemark
  307. custom.SphygmomanometerStatus = sphygmomanometerStatus
  308. custom.SphygmomanometerBrand = sphygmomanometerBrand
  309. custom.SphygmomanometerRemark = sphygmomanometerRemark
  310. custom.ScannerStatus = scannerStatus
  311. custom.ScannerBrand = scannerBrand
  312. custom.ScannerRemark = scannerRemark
  313. custom.FacialRecognitionDeviceStatus = facialRecognitionDeviceStatus
  314. custom.FacialRecognitionDeviceBrand = facialRecognitionDeviceBrand
  315. custom.FacialRecognitionDeviceRemark = facialRecognitionDeviceRemark
  316. custom.PrinterStatus = printerStatus
  317. custom.PrinterBrand = printerBrand
  318. custom.PrinterRemark = printerRemark
  319. custom.HardwareRemark = hardwareRemark
  320. custom.ID = id
  321. custom.Mtime = time.Now().Unix()
  322. err := service.UpdateCustomTwo(custom)
  323. if err != nil {
  324. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  325. return
  326. }
  327. this.ServeSuccessJSON(map[string]interface{}{
  328. "msg": "修改成功",
  329. })
  330. break
  331. }
  332. }
  333. func (this *CustomAPIController) GetCustom() {
  334. id, _ := this.GetInt64("id")
  335. custom, _ := service.FindCustomInfoByID(id)
  336. if custom.ID == 0 {
  337. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  338. return
  339. }
  340. this.ServeSuccessJSON(map[string]interface{}{
  341. "custom": custom,
  342. })
  343. }
  344. func (this *CustomAPIController) CreatePaymentCollection() {
  345. customID, _ := this.GetInt64("custom_id")
  346. customName := this.GetString("custom_name")
  347. paymentCollectionType, _ := this.GetInt64("payment_collection_type")
  348. paymentCollectionSumAmt := this.GetString("payment_collection_sumamt")
  349. softwareSumAmt := this.GetString("software_sumamt")
  350. hardwareSumAmt := this.GetString("hardware_sumamt")
  351. paymentCollectionDate := this.GetString("payment_collection_date")
  352. paymentCollectionRole := this.GetString("payment_collection_role")
  353. url := this.GetString("url")
  354. remark := this.GetString("remark")
  355. ctime := time.Now().Unix()
  356. mtime := time.Now().Unix()
  357. // 创建 KyyChargePaymentCollection 对象,并设置每个字段的值
  358. paymentCollection := models.KyyChargePaymentCollection{
  359. CustomId: customID,
  360. CustomName: customName,
  361. PaymentCollectionType: paymentCollectionType,
  362. PaymentCollectionSumamt: paymentCollectionSumAmt,
  363. SoftwareSumamt: softwareSumAmt,
  364. HardwareSumamt: hardwareSumAmt,
  365. PaymentCollectionDate: paymentCollectionDate,
  366. PaymentCollectionRole: paymentCollectionRole,
  367. Url: url,
  368. Remark: remark,
  369. Ctime: ctime,
  370. Mtime: mtime,
  371. Creator: 0,
  372. Modifier: 0,
  373. Status: 1,
  374. }
  375. err := service.CreateChargePaymentCollection(&paymentCollection)
  376. if err != nil {
  377. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  378. return
  379. }
  380. this.ServeSuccessJSON(map[string]interface{}{
  381. "paymentCollection": paymentCollection,
  382. })
  383. }
  384. func (this *CustomAPIController) GetPaymentCollectionList() {
  385. list, _ := service.GetAllPaymentCollections()
  386. this.ServeSuccessJSON(map[string]interface{}{
  387. "list": list,
  388. })
  389. }
  390. func (this *CustomAPIController) GetPaymentCollection() {
  391. id, _ := this.GetInt64("id")
  392. pc, _ := service.FindPaymentCollectionInfo(id)
  393. if pc.ID == 0 {
  394. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  395. return
  396. }
  397. this.ServeSuccessJSON(map[string]interface{}{
  398. "pc": pc,
  399. })
  400. }
  401. func (this *CustomAPIController) EditPaymentCollection() {
  402. id, _ := this.GetInt64("id")
  403. paymentCollectionType, _ := this.GetInt64("payment_collection_type")
  404. paymentCollectionSumAmt := this.GetString("payment_collection_sumamt")
  405. softwareSumAmt := this.GetString("software_sumamt")
  406. hardwareSumAmt := this.GetString("hardware_sumamt")
  407. paymentCollectionDate := this.GetString("payment_collection_date")
  408. paymentCollectionRole := this.GetString("payment_collection_role")
  409. url := this.GetString("url")
  410. remark := this.GetString("remark")
  411. mtime := time.Now().Unix()
  412. cpc, _ := service.FindPaymentCollectionInfo(id)
  413. if cpc.ID == 0 {
  414. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  415. return
  416. }
  417. cpc.PaymentCollectionType = paymentCollectionType
  418. cpc.PaymentCollectionSumamt = paymentCollectionSumAmt
  419. cpc.SoftwareSumamt = softwareSumAmt
  420. cpc.HardwareSumamt = hardwareSumAmt
  421. cpc.PaymentCollectionDate = paymentCollectionDate
  422. cpc.PaymentCollectionRole = paymentCollectionRole
  423. cpc.Url = url
  424. cpc.Remark = remark
  425. cpc.Mtime = mtime
  426. err := service.CreateChargePaymentCollection(&cpc)
  427. if err != nil {
  428. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  429. return
  430. }
  431. this.ServeSuccessJSON(map[string]interface{}{
  432. "cpc": cpc,
  433. })
  434. }
  435. func (this *CustomAPIController) DeleteCustom() {
  436. id, _ := this.GetInt64("id")
  437. ct, _ := service.FindCustomInfoByIDTwo(id)
  438. if ct.ID == 0 {
  439. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  440. return
  441. }
  442. ct.Status = 0
  443. err := service.SaveCustomTwo(ct)
  444. if err != nil {
  445. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  446. return
  447. }
  448. this.ServeSuccessJSON(map[string]interface{}{
  449. "msg": "删除成功",
  450. })
  451. }
  452. func (this *CustomAPIController) DeletePaymentCollection() {
  453. id, _ := this.GetInt64("id")
  454. cpc, _ := service.FindPaymentCollectionInfo(id)
  455. if cpc.ID == 0 {
  456. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  457. return
  458. }
  459. cpc.Status = 0
  460. err := service.SaveChargePaymentCollection(&cpc)
  461. if err != nil {
  462. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  463. return
  464. }
  465. this.ServeSuccessJSON(map[string]interface{}{
  466. "msg": "删除成功",
  467. })
  468. }
  469. func (this *CustomAPIController) CheckPaymentCollection() {
  470. id, _ := this.GetInt64("id")
  471. cpc, _ := service.FindPaymentCollectionInfo(id)
  472. if cpc.ID == 0 {
  473. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  474. return
  475. }
  476. cpc.IsCheck = 1
  477. cpc.CheckPerson = this.GetAdminInfo().Name
  478. err := service.SaveChargePaymentCollection(&cpc)
  479. if err != nil {
  480. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  481. return
  482. }
  483. this.ServeSuccessJSON(map[string]interface{}{
  484. "msg": "审核成功",
  485. })
  486. }
  487. func (this *CustomAPIController) CreateContactInfo() {
  488. customID, _ := this.GetInt64("custom_id")
  489. contactName := this.GetString("contact_name")
  490. contactPhone := this.GetString("contact_phone")
  491. contactDuties := this.GetString("contact_duties")
  492. isDecision := this.GetString("is_decision")
  493. remark := this.GetString("remark")
  494. contact_way := this.GetString("contact_way")
  495. ctime := time.Now().Unix()
  496. mtime := time.Now().Unix()
  497. // 创建 KyyChargeContact 对象,并设置每个字段的值
  498. contact := models.KyyChargeContact{
  499. ID: 0,
  500. CustomId: customID,
  501. ContactName: contactName,
  502. ContactPhone: contactPhone,
  503. ContactDuties: contactDuties,
  504. IsDecision: isDecision,
  505. Remark: remark,
  506. Ctime: ctime,
  507. Mtime: mtime,
  508. Status: 1,
  509. Creator: 0,
  510. Modifier: 0,
  511. IsCheck: 0,
  512. ContactWay: contact_way,
  513. }
  514. err := service.SaveChargeContact(&contact)
  515. if err != nil {
  516. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  517. return
  518. }
  519. this.ServeSuccessJSON(map[string]interface{}{
  520. "contact": contact,
  521. })
  522. }
  523. func (this *CustomAPIController) GetContactInfoList() {
  524. list, _ := service.GetAllChargeContacts()
  525. this.ServeSuccessJSON(map[string]interface{}{
  526. "list": list,
  527. })
  528. }
  529. func (this *CustomAPIController) GetContactInfo() {
  530. id, _ := this.GetInt64("id")
  531. cc, _ := service.FindChargeContactInfo(id)
  532. if cc.ID == 0 {
  533. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  534. return
  535. }
  536. this.ServeSuccessJSON(map[string]interface{}{
  537. "contact_info": cc,
  538. })
  539. }
  540. func (this *CustomAPIController) EditContactInfo() {
  541. id, _ := this.GetInt64("id")
  542. contactName := this.GetString("contact_name")
  543. contactPhone := this.GetString("contact_phone")
  544. contactDuties := this.GetString("contact_duties")
  545. isDecision := this.GetString("is_decision")
  546. remark := this.GetString("remark")
  547. mtime := time.Now().Unix()
  548. chargeContact, _ := service.FindChargeContactInfo(id)
  549. if chargeContact.ID == 0 {
  550. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  551. return
  552. }
  553. chargeContact.ContactName = contactName
  554. chargeContact.ContactPhone = contactPhone
  555. chargeContact.ContactDuties = contactDuties
  556. chargeContact.IsDecision = isDecision
  557. chargeContact.Remark = remark
  558. chargeContact.Remark = remark
  559. chargeContact.Mtime = mtime
  560. err := service.SaveChargeContact(&chargeContact)
  561. if err != nil {
  562. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  563. return
  564. }
  565. this.ServeSuccessJSON(map[string]interface{}{
  566. "contact": chargeContact,
  567. })
  568. }
  569. func (this *CustomAPIController) DeleteContactInfo() {
  570. id, _ := this.GetInt64("id")
  571. cc, _ := service.FindChargeContactInfo(id)
  572. if cc.ID == 0 {
  573. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  574. return
  575. }
  576. cc.Status = 0
  577. err := service.SaveChargeContact(&cc)
  578. if err != nil {
  579. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  580. return
  581. }
  582. this.ServeSuccessJSON(map[string]interface{}{
  583. "msg": "删除成功",
  584. })
  585. }
  586. func (this *CustomAPIController) CheckContactInfo() {
  587. id, _ := this.GetInt64("id")
  588. chargeContact, _ := service.FindChargeContactInfo(id)
  589. if chargeContact.ID == 0 {
  590. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  591. return
  592. }
  593. chargeContact.IsCheck = 1
  594. chargeContact.CheckPerson = this.GetAdminInfo().Name
  595. err := service.SaveChargeContact(&chargeContact)
  596. if err != nil {
  597. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  598. return
  599. }
  600. this.ServeSuccessJSON(map[string]interface{}{
  601. "msg": "审核成功",
  602. })
  603. }
  604. func (this *CustomAPIController) CreateContractInfo() {
  605. customID, _ := this.GetInt64("custom_id")
  606. code := this.GetString("code")
  607. name := this.GetString("name")
  608. sumamt := this.GetString("sumamt")
  609. custom_name := this.GetString("custom_name")
  610. start_time := this.GetString("start_time")
  611. end_time := this.GetString("end_time")
  612. signing_person := this.GetString("signing_person")
  613. wordFileURL := this.GetString("word_file_url")
  614. pdfFileURL := this.GetString("pdf_file_url")
  615. remark := this.GetString("remark")
  616. ctime := time.Now().Unix()
  617. mtime := time.Now().Unix()
  618. // 创建 KyyChargeContract 对象,并设置每个字段的值
  619. contract := models.KyyChargeContract{
  620. CustomId: customID,
  621. Code: code,
  622. Name: name,
  623. Sumamt: sumamt,
  624. StartTime: start_time,
  625. EndTime: end_time,
  626. SigningPerson: signing_person,
  627. WordFileUrl: wordFileURL,
  628. PdfFileUrl: pdfFileURL,
  629. CustomName: custom_name,
  630. Remark: remark,
  631. Ctime: ctime,
  632. Mtime: mtime,
  633. Status: 1,
  634. }
  635. err := service.SaveChargeContract(&contract)
  636. if err != nil {
  637. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  638. return
  639. }
  640. this.ServeSuccessJSON(map[string]interface{}{
  641. "msg": "创建成功",
  642. })
  643. }
  644. func (this *CustomAPIController) GetContractInfoList() {
  645. list, _ := service.GetAllChargeContracts()
  646. this.ServeSuccessJSON(map[string]interface{}{
  647. "list": list,
  648. })
  649. }
  650. func (this *CustomAPIController) GetContractInfo() {
  651. id, _ := this.GetInt64("id")
  652. cc, _ := service.FindChargeContractInfo(id)
  653. if cc.ID == 0 {
  654. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  655. return
  656. }
  657. this.ServeSuccessJSON(map[string]interface{}{
  658. "charge_contract": cc,
  659. })
  660. }
  661. func (this *CustomAPIController) EditContractInfo() {
  662. id, _ := this.GetInt64("id")
  663. code := this.GetString("code")
  664. name := this.GetString("name")
  665. customName := this.GetString("custom_name")
  666. sumamt := this.GetString("sumamt")
  667. startTime := this.GetString("start_time")
  668. endTime := this.GetString("end_time")
  669. signingPerson := this.GetString("signing_person")
  670. wordFileURL := this.GetString("word_file_url")
  671. pdfFileURL := this.GetString("pdf_file_url")
  672. remark := this.GetString("remark")
  673. mtime := time.Now().Unix()
  674. chargeContract, _ := service.FindChargeContractInfo(id)
  675. if chargeContract.ID == 0 {
  676. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  677. return
  678. }
  679. chargeContract.Code = code
  680. chargeContract.Name = name
  681. chargeContract.CustomName = customName
  682. chargeContract.Sumamt = sumamt
  683. chargeContract.StartTime = startTime
  684. chargeContract.EndTime = endTime
  685. chargeContract.SigningPerson = signingPerson
  686. chargeContract.WordFileUrl = wordFileURL
  687. chargeContract.PdfFileUrl = pdfFileURL
  688. chargeContract.Remark = remark
  689. chargeContract.Mtime = mtime
  690. err := service.SaveChargeContract(&chargeContract)
  691. if err != nil {
  692. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  693. return
  694. }
  695. this.ServeSuccessJSON(map[string]interface{}{
  696. "msg": "修改成功",
  697. })
  698. }
  699. func (this *CustomAPIController) DeleteContractInfo() {
  700. id, _ := this.GetInt64("id")
  701. cc, _ := service.FindChargeContractInfo(id)
  702. if cc.ID == 0 {
  703. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  704. return
  705. }
  706. cc.Status = 0
  707. err := service.SaveChargeContract(&cc)
  708. if err != nil {
  709. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  710. return
  711. }
  712. this.ServeSuccessJSON(map[string]interface{}{
  713. "msg": "删除成功",
  714. })
  715. }
  716. func (this *CustomAPIController) CheckContractInfo() {
  717. id, _ := this.GetInt64("id")
  718. chargeContract, _ := service.FindChargeContractInfo(id)
  719. if chargeContract.ID == 0 {
  720. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  721. return
  722. }
  723. chargeContract.CheckPerson = this.GetAdminInfo().Name
  724. chargeContract.IsCheck = 1
  725. err := service.SaveChargeContract(&chargeContract)
  726. if err != nil {
  727. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  728. return
  729. }
  730. this.ServeSuccessJSON(map[string]interface{}{
  731. "msg": "审核成功",
  732. })
  733. }
  734. func (this *CustomAPIController) CreateFollowInfo() {
  735. ctime := time.Now().Unix()
  736. mtime := time.Now().Unix()
  737. customID, _ := this.GetInt64("custom_id")
  738. desc := this.GetString("desc")
  739. // 创建 KyyChargeFollow 对象,并设置每个字段的值
  740. follow := models.KyyChargeFollow{
  741. Ctime: ctime,
  742. Mtime: mtime,
  743. Creator: this.GetAdminInfo().ID,
  744. CustomId: customID,
  745. Desc: desc,
  746. Status: 1,
  747. }
  748. err := service.SaveChargeFollow(&follow)
  749. if err != nil {
  750. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  751. return
  752. }
  753. this.ServeSuccessJSON(map[string]interface{}{
  754. "follow": follow,
  755. })
  756. }
  757. func (this *CustomAPIController) GetFollowInfoList() {
  758. list, _ := service.GetAllChargeFollow()
  759. this.ServeSuccessJSON(map[string]interface{}{
  760. "list": list,
  761. })
  762. }
  763. func (this *CustomAPIController) GetFollowInfo() {
  764. id, _ := this.GetInt64("id")
  765. follow, _ := service.FindChargeFollowInfo(id)
  766. if follow.ID == 0 {
  767. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  768. return
  769. }
  770. this.ServeSuccessJSON(map[string]interface{}{
  771. "follow": follow,
  772. })
  773. }
  774. func (this *CustomAPIController) EditFollowInfo() {
  775. id, _ := this.GetInt64("id")
  776. desc := this.GetString("desc")
  777. chargeFollow, _ := service.FindChargeFollowInfo(id)
  778. chargeFollow.Desc = desc
  779. chargeFollow.Mtime = time.Now().Unix()
  780. err := service.SaveChargeFollow(&chargeFollow)
  781. if err != nil {
  782. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  783. return
  784. }
  785. this.ServeSuccessJSON(map[string]interface{}{
  786. "follow": chargeFollow,
  787. })
  788. }
  789. func (this *CustomAPIController) DeleteFollowInfo() {
  790. id, _ := this.GetInt64("id")
  791. follow, _ := service.FindChargeFollowInfo(id)
  792. if follow.ID == 0 {
  793. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  794. return
  795. }
  796. follow.Status = 0
  797. err := service.SaveChargeFollow(&follow)
  798. if err != nil {
  799. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  800. return
  801. }
  802. this.ServeSuccessJSON(map[string]interface{}{
  803. "msg": "删除成功",
  804. })
  805. }
  806. func (this *CustomAPIController) CheckFollowInfo() {
  807. id, _ := this.GetInt64("id")
  808. follow, _ := service.FindChargeFollowInfoTwo(id)
  809. if len(follow) == 0 {
  810. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  811. return
  812. }
  813. var ids []int64
  814. for _, item := range follow {
  815. ids = append(ids, item.ID)
  816. }
  817. err := service.CheckChargeFollowTwo(ids)
  818. if err != nil {
  819. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  820. return
  821. }
  822. this.ServeSuccessJSON(map[string]interface{}{
  823. "msg": "审核成功",
  824. })
  825. }
  826. func (this *CustomAPIController) CreateDemandInfo() {
  827. demandType, _ := this.GetInt64("demand_type")
  828. demandDesc := this.GetString("demand_desc")
  829. demandStatus, _ := this.GetInt64("demand_status")
  830. demandCreator := this.GetString("demand_creator")
  831. demandCreateDate := this.GetString("demand_create_date")
  832. demandDirector := this.GetString("demand_director")
  833. ctime := time.Now().Unix()
  834. mtime := time.Now().Unix()
  835. customID, _ := this.GetInt64("custom_id")
  836. demandFinishDate := this.GetString("demand_finish_date")
  837. demandDetail := this.GetString("demand_detail")
  838. // 创建 KyyChargeDemand 对象,并设置每个字段的值
  839. demand := models.KyyChargeDemand{
  840. DemandType: demandType,
  841. DemandDesc: demandDesc,
  842. DemandStatus: demandStatus,
  843. DemandCreator: demandCreator,
  844. DemandCreateDate: demandCreateDate,
  845. DemandDirector: demandDirector,
  846. Ctime: ctime,
  847. Mtime: mtime,
  848. Status: 1,
  849. CustomId: customID,
  850. DemandFinishDate: demandFinishDate,
  851. DemandDetail: demandDetail,
  852. }
  853. err := service.SaveChargeDemand(&demand)
  854. if err != nil {
  855. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  856. return
  857. }
  858. this.ServeSuccessJSON(map[string]interface{}{
  859. "demand": demand,
  860. })
  861. }
  862. func (this *CustomAPIController) GetDemandInfoList() {
  863. list, _ := service.GetAllChargeDemand()
  864. this.ServeSuccessJSON(map[string]interface{}{
  865. "list": list,
  866. })
  867. }
  868. func (this *CustomAPIController) GetDemandInfo() {
  869. id, _ := this.GetInt64("id")
  870. cd, _ := service.FindChargeDemandInfo(id)
  871. if cd.ID == 0 {
  872. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  873. return
  874. }
  875. this.ServeSuccessJSON(map[string]interface{}{
  876. "charge_demand": cd,
  877. })
  878. }
  879. func (this *CustomAPIController) EditDemandInfo() {
  880. id, _ := this.GetInt64("id")
  881. demandType, _ := this.GetInt64("demand_type")
  882. demandDesc := this.GetString("demand_desc")
  883. demandStatus, _ := this.GetInt64("demand_status")
  884. demandCreator := this.GetString("demand_creator")
  885. demandCreateDate := this.GetString("demand_create_date")
  886. demandFinishDate := this.GetString("demand_finish_date")
  887. demandDetail := this.GetString("demand_detail")
  888. demandDirector := this.GetString("demand_director")
  889. cd, _ := service.FindChargeDemandInfo(id)
  890. cd.DemandType = demandType
  891. cd.DemandDesc = demandDesc
  892. cd.DemandStatus = demandStatus
  893. cd.DemandCreator = demandCreator
  894. cd.DemandCreateDate = demandCreateDate
  895. cd.DemandFinishDate = demandFinishDate
  896. cd.DemandDirector = demandDirector
  897. cd.DemandDetail = demandDetail
  898. cd.Mtime = time.Now().Unix()
  899. err := service.SaveChargeDemand(&cd)
  900. if err != nil {
  901. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  902. return
  903. }
  904. this.ServeSuccessJSON(map[string]interface{}{
  905. "demand": cd,
  906. })
  907. }
  908. func (this *CustomAPIController) DeleteDemandInfo() {
  909. id, _ := this.GetInt64("id")
  910. cd, _ := service.FindChargeDemandInfo(id)
  911. if cd.ID == 0 {
  912. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  913. return
  914. }
  915. cd.Status = 0
  916. err := service.SaveChargeDemand(&cd)
  917. if err != nil {
  918. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  919. return
  920. }
  921. this.ServeSuccessJSON(map[string]interface{}{
  922. "msg": "删除成功",
  923. })
  924. }
  925. func (this *CustomAPIController) CheckDemandInfo() {
  926. id, _ := this.GetInt64("id")
  927. cd, _ := service.FindChargeDemandInfo(id)
  928. if cd.ID == 0 {
  929. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  930. return
  931. }
  932. cd.IsCheck = 1
  933. //chargeContract
  934. cd.CheckPerson = this.GetAdminInfo().Name
  935. err := service.SaveChargeDemand(&cd)
  936. if err != nil {
  937. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  938. return
  939. }
  940. this.ServeSuccessJSON(map[string]interface{}{
  941. "msg": "审核成功",
  942. })
  943. }
  944. func (this *CustomAPIController) CreateRenewalInfo() {
  945. types, _ := this.GetInt64("type")
  946. startTime := this.GetString("start_time")
  947. endTime := this.GetString("end_time")
  948. signingPersonal := this.GetString("signing_personal")
  949. customID, _ := this.GetInt64("custom_id")
  950. signTime := this.GetString("sign_time")
  951. checkPersonal := this.GetString("check_personal")
  952. ctime := time.Now().Format("2006-01-02 15:04:05") // 使用当前时间
  953. mtime := time.Now().Format("2006-01-02 15:04:05") // 使用当前时间
  954. remark := this.GetString("remark")
  955. // 创建 KyyChargeRenewal 对象,并设置每个字段的值
  956. renewal := models.KyyChargeRenewal{
  957. Type: types,
  958. StartTime: startTime,
  959. EndTime: endTime,
  960. SigningPersonal: signingPersonal,
  961. CustomId: customID,
  962. SignTime: signTime,
  963. CheckPersonal: checkPersonal,
  964. Ctime: ctime,
  965. Mtime: mtime,
  966. Status: 1,
  967. Remark: remark,
  968. }
  969. err := service.SaveChargeRenewal(&renewal)
  970. if err != nil {
  971. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  972. return
  973. }
  974. this.ServeSuccessJSON(map[string]interface{}{
  975. "renewal": renewal,
  976. })
  977. }
  978. func (this *CustomAPIController) GetRenewalInfoList() {
  979. list, _ := service.GetAllChargeRenewal()
  980. this.ServeSuccessJSON(map[string]interface{}{
  981. "list": list,
  982. })
  983. }
  984. func (this *CustomAPIController) GetRenewalInfo() {
  985. id, _ := this.GetInt64("id")
  986. cr, _ := service.FindChargeRenewalInfo(id)
  987. if cr.ID == 0 {
  988. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  989. return
  990. }
  991. this.ServeSuccessJSON(map[string]interface{}{
  992. "charge_renewal": cr,
  993. })
  994. }
  995. func (this *CustomAPIController) EditRenewalInfo() {
  996. types, _ := this.GetInt64("type")
  997. id, _ := this.GetInt64("id")
  998. startTime := this.GetString("start_time")
  999. endTime := this.GetString("end_time")
  1000. signingPersonal := this.GetString("signing_personal")
  1001. customID, _ := this.GetInt64("custom_id")
  1002. signTime := this.GetString("sign_time")
  1003. remark := this.GetString("remark")
  1004. checkPersonal := this.GetString("check_personal")
  1005. mtime := time.Now().Format("2006-01-02 15:04:05") // 使用当前时间
  1006. cr, _ := service.FindChargeRenewalInfo(id)
  1007. if cr.ID == 0 {
  1008. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  1009. return
  1010. }
  1011. cr.Type = types
  1012. cr.CustomId = customID
  1013. cr.StartTime = startTime
  1014. cr.EndTime = endTime
  1015. cr.SigningPersonal = signingPersonal
  1016. cr.SignTime = signTime
  1017. cr.Mtime = mtime
  1018. cr.Remark = remark
  1019. cr.CheckPersonal = checkPersonal
  1020. err := service.SaveChargeRenewal(&cr)
  1021. if err != nil {
  1022. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  1023. return
  1024. }
  1025. this.ServeSuccessJSON(map[string]interface{}{
  1026. "cr": cr,
  1027. })
  1028. }
  1029. func (this *CustomAPIController) DeleteRenewalInfo() {
  1030. id, _ := this.GetInt64("id")
  1031. cr, _ := service.FindChargeRenewalInfo(id)
  1032. if cr.ID == 0 {
  1033. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  1034. return
  1035. }
  1036. cr.Status = 0
  1037. err := service.SaveChargeRenewal(&cr)
  1038. if err != nil {
  1039. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  1040. return
  1041. }
  1042. this.ServeSuccessJSON(map[string]interface{}{
  1043. "msg": "删除成功",
  1044. })
  1045. }
  1046. func (this *CustomAPIController) CheckRenewalInfo() {
  1047. id, _ := this.GetInt64("id")
  1048. cr, _ := service.FindChargeRenewalInfo(id)
  1049. if cr.ID == 0 {
  1050. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  1051. return
  1052. }
  1053. cr.IsCheck = 1
  1054. cr.CheckPerson = this.GetAdminInfo().Name
  1055. err := service.SaveChargeRenewal(&cr)
  1056. if err != nil {
  1057. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  1058. return
  1059. }
  1060. this.ServeSuccessJSON(map[string]interface{}{
  1061. "msg": "审核成功",
  1062. })
  1063. }
  1064. func (c *CustomAPIController) GetQNUpToken() {
  1065. redisClient := service.RedisClient()
  1066. defer redisClient.Close()
  1067. token, err := redisClient.Get("qn_token").Result()
  1068. if err != nil {
  1069. defer fmt.Println(err)
  1070. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeGetQiniuUpToken)
  1071. return
  1072. }
  1073. c.ServeSuccessJSON(map[string]interface{}{
  1074. "uptoken": token,
  1075. })
  1076. return
  1077. }