paymentinfo.go 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133
  1. package oilsupplier
  2. import (
  3. "dashoo.cn/backend/api/business/oilsupplier/suppliercert"
  4. "dashoo.cn/backend/api/business/paymentinfo"
  5. . "dashoo.cn/backend/api/controllers"
  6. "dashoo.cn/utils"
  7. "encoding/json"
  8. "strconv"
  9. "time"
  10. )
  11. type PaymentInfoController struct {
  12. BaseController
  13. }
  14. // @Title 获取列表
  15. // @Description get user by token
  16. // @Success 200 {object} []paymentinfo.PaymentinfoList
  17. // @router /list [get]
  18. func (this *PaymentInfoController) GetEntityList() {
  19. //获取分页信息
  20. page := this.GetPageInfoForm()
  21. orderby := "p.Id"
  22. where := " 1=1 "
  23. asc := " DESC"
  24. SupplierTypeCode := this.GetString("SupplierTypeCode")
  25. SupplierName := this.GetString("SupplierName")
  26. IsPay := this.GetString("IsPay")
  27. if (IsPay != "") {
  28. where = where + " and p.IsPay = '" + IsPay +"'"
  29. }
  30. if (SupplierTypeCode != "") {
  31. where = where + " and c.SupplierTypeCode like '%" + SupplierTypeCode + "%'"
  32. }
  33. if (SupplierName != "") {
  34. where = where + " and s.SupplierName like '%" + SupplierName + "%'"
  35. }
  36. //svc := suppliercert.GetOilSupplierCertService(utils.DBE)
  37. //var list []suppliercert.OilSupplierCert
  38. var paylist []paymentinfo.PaymentinfoList
  39. svc := paymentinfo.GetPaymentService(utils.DBE)
  40. total := svc.GetPaymentinfoList( page.CurrentPage, page.Size, orderby, asc, &paylist, where)
  41. //total := svc.GetPagingEntitiesWithOrderBytbl("", page.CurrentPage, page.Size, orderby, asc, &list, where)
  42. var datainfo DataInfo
  43. datainfo.Items = paylist
  44. datainfo.CurrentItemCount = total
  45. datainfo.PageIndex = page.CurrentPage
  46. datainfo.ItemsPerPage = page.Size
  47. this.Data["json"] = &datainfo
  48. this.ServeJSON()
  49. }
  50. // @Title 获取实体
  51. // @Description 获取实体
  52. // @Success 200 {object} paymentinfo.PaymentinfoList
  53. // @router /get/:id [get]
  54. func (this *PaymentInfoController) GetEntity() {
  55. Id := this.Ctx.Input.Param(":id")
  56. var model []paymentinfo.PaymentinfoList
  57. svc := paymentinfo.GetPaymentService(utils.DBE)
  58. svc.GetPaymentinfoById(Id, &model)
  59. this.Data["json"] = &model[0]
  60. this.ServeJSON()
  61. }
  62. // @Title 修改实体
  63. // @Description 修改实体
  64. // @Param body body paymentinfo.Paymentinfo
  65. // @Success 200 {object} controllers.Request
  66. // @router /update/:id [post]
  67. func (this *PaymentInfoController) UpdateEntity() {
  68. id := this.Ctx.Input.Param(":id")
  69. var errinfo ErrorInfo
  70. if id == "" {
  71. errinfo.Message = "操作失败!请求信息不完整"
  72. errinfo.Code = -2
  73. this.Data["json"] = &errinfo
  74. this.ServeJSON()
  75. return
  76. }
  77. var model paymentinfo.OilPaymentInfo
  78. svc := paymentinfo.GetPaymentService(utils.DBE)
  79. var jsonBlob = this.Ctx.Input.RequestBody
  80. json.Unmarshal(jsonBlob, &model)
  81. model.ModifiedOn = time.Now()
  82. model.ModifiedBy = this.User.Realname
  83. model.ModifiedUserId, _ = utils.StrTo(this.User.Id).Int()
  84. cols := []string{
  85. "IsPay",
  86. "PayMode",
  87. "PayDate",
  88. "BankSerialNum",
  89. "BankName",
  90. "Remark",
  91. "ModifiedOn",
  92. "ModifiedUserId",
  93. "ModifiedBy",
  94. }
  95. _,err := svc.UpdateEntityByIdCols(id, &model, cols)
  96. if (model.IsPay == "2") {
  97. var certentity suppliercert.OilSupplierCert
  98. certentity.Status = suppliercert.STOREING_STATUS
  99. certentity.Step = 5
  100. cols = []string{
  101. "Status",
  102. "Step",
  103. }
  104. _,err = svc.UpdateEntityByIdCols(strconv.Itoa(model.SupplierCertId), &certentity, cols)
  105. }
  106. if err == nil {
  107. errinfo.Message = "修改成功!"
  108. errinfo.Code = 0
  109. this.Data["json"] = &errinfo
  110. this.ServeJSON()
  111. } else {
  112. errinfo.Message = "修改失败!" + utils.AlertProcess(err.Error())
  113. errinfo.Code = -1
  114. this.Data["json"] = &errinfo
  115. this.ServeJSON()
  116. }
  117. }