2
3

paymentinfo.go 5.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177
  1. package oilsupplier
  2. import (
  3. "encoding/json"
  4. "strconv"
  5. "time"
  6. "dashoo.cn/backend/api/business/bankapi"
  7. "dashoo.cn/backend/api/business/oilsupplier/supplier"
  8. "dashoo.cn/backend/api/business/oilsupplier/suppliercert"
  9. "dashoo.cn/backend/api/business/paymentinfo"
  10. . "dashoo.cn/backend/api/controllers"
  11. "dashoo.cn/business2/permission"
  12. "dashoo.cn/utils"
  13. //"wayne-master/src/backend/util/integer"
  14. )
  15. type PaymentInfoController struct {
  16. BaseController
  17. }
  18. // @Title 获取列表
  19. // @Description get user by token
  20. // @Success 200 {object} []paymentinfo.PaymentinfoList
  21. // @router /list [get]
  22. func (this *PaymentInfoController) GetEntityList() {
  23. //获取分页信息
  24. page := this.GetPageInfoForm()
  25. orderby := "p.Id"
  26. where := " 1=1 "
  27. asc := " DESC"
  28. SupplierTypeCode := this.GetString("SupplierTypeCode")
  29. SupplierName := this.GetString("SupplierName")
  30. IsPay := this.GetString("IsPay")
  31. if IsPay != "" {
  32. where = where + " and p.IsPay = '" + IsPay + "'"
  33. }
  34. if SupplierTypeCode != "" {
  35. where = where + " and c.SupplierTypeCode like '%" + SupplierTypeCode + "%'"
  36. }
  37. if SupplierName != "" {
  38. where = where + " and s.SupplierName like '%" + SupplierName + "%'"
  39. }
  40. //svc := suppliercert.GetOilSupplierCertService(utils.DBE)
  41. //var list []suppliercert.OilSupplierCert
  42. svcPerm := permission.GetPermissionService(utils.DBE)
  43. isauth := svcPerm.IsAuthorized(this.User.Id, "oil_supplier.marketAccess.AllRecord")
  44. if !svcPerm.IsAdmin(this.User.Id) && !isauth {
  45. where = where + " and p.CreateUserId = '" + this.User.Id + "'"
  46. }
  47. var paylist []paymentinfo.PaymentinfoList
  48. svc := paymentinfo.GetPaymentService(utils.DBE)
  49. total := svc.GetPaymentinfoList(page.CurrentPage, page.Size, orderby, asc, &paylist, where)
  50. //total := svc.GetPagingEntitiesWithOrderBytbl("", page.CurrentPage, page.Size, orderby, asc, &list, where)
  51. var datainfo DataInfo
  52. datainfo.Items = paylist
  53. datainfo.CurrentItemCount = total
  54. datainfo.PageIndex = page.CurrentPage
  55. datainfo.ItemsPerPage = page.Size
  56. this.Data["json"] = &datainfo
  57. this.ServeJSON()
  58. }
  59. // @Title 获取列表
  60. // @Description get user by token
  61. // @Success 200 {object} []paymentinfo.PaymentinfoList
  62. // @router /get-bill-list [post]
  63. func (this *PaymentInfoController) GetBillList() {
  64. var icbcBillQueryParam bankapi.ICBCBillQueryParam
  65. var jsonBlob = this.Ctx.Input.RequestBody
  66. json.Unmarshal(jsonBlob, &icbcBillQueryParam)
  67. var supplierEntity supplier.OilSupplier
  68. supplierSvc := supplier.GetOilSupplierService(utils.DBE)
  69. supplierWhere := "1=1 and CommercialNo='" + icbcBillQueryParam.CommercialNo + "'"
  70. supplierSvc.DBE.Where(supplierWhere).Get(&supplierEntity)
  71. var billList []paymentinfo.OilPaymentInfo
  72. billWhere := "1=1 and SupplierId='" + strconv.Itoa(supplierEntity.Id) + "'"
  73. svc := paymentinfo.GetPaymentService(utils.DBE)
  74. svc.DBE.Where(billWhere).OrderBy("Id DESC").Find(&billList)
  75. //获取分页信息
  76. //page := this.GetPageInfoForm()
  77. var datainfo DataInfo
  78. datainfo.Items = billList
  79. //datainfo.CurrentItemCount = integer.Int2Int64(len(billList))
  80. // datainfo.CurrentItemCount = 10
  81. datainfo.CurrentItemCount = int64(len(billList))
  82. datainfo.PageIndex = 1
  83. datainfo.ItemsPerPage = 1000
  84. this.Data["json"] = &datainfo
  85. this.ServeJSON()
  86. }
  87. // @Title 获取实体
  88. // @Description 获取实体
  89. // @Success 200 {object} paymentinfo.PaymentinfoList
  90. // @router /get/:id [get]
  91. func (this *PaymentInfoController) GetEntity() {
  92. Id := this.Ctx.Input.Param(":id")
  93. var model []paymentinfo.PaymentinfoList
  94. svc := paymentinfo.GetPaymentService(utils.DBE)
  95. svc.GetPaymentinfoById(Id, &model)
  96. this.Data["json"] = &model[0]
  97. this.ServeJSON()
  98. }
  99. // @Title 修改实体
  100. // @Description 修改实体
  101. // @Param body body paymentinfo.Paymentinfo
  102. // @Success 200 {object} controllers.Request
  103. // @router /update/:id [post]
  104. func (this *PaymentInfoController) UpdateEntity() {
  105. id := this.Ctx.Input.Param(":id")
  106. var errinfo ErrorInfo
  107. if id == "" {
  108. errinfo.Message = "操作失败!请求信息不完整"
  109. errinfo.Code = -2
  110. this.Data["json"] = &errinfo
  111. this.ServeJSON()
  112. return
  113. }
  114. var model paymentinfo.OilPaymentInfo
  115. svc := paymentinfo.GetPaymentService(utils.DBE)
  116. var jsonBlob = this.Ctx.Input.RequestBody
  117. json.Unmarshal(jsonBlob, &model)
  118. model.ModifiedOn = time.Now()
  119. model.ModifiedBy = this.User.Realname
  120. model.ModifiedUserId, _ = utils.StrTo(this.User.Id).Int()
  121. cols := []string{
  122. "IsPay",
  123. "PayMode",
  124. "PayDate",
  125. "BankSerialNum",
  126. "BankName",
  127. "Remark",
  128. "ModifiedOn",
  129. "ModifiedUserId",
  130. "ModifiedBy",
  131. }
  132. _, err := svc.UpdateEntityByIdCols(id, &model, cols)
  133. if model.IsPay == "2" {
  134. var certentity suppliercert.OilSupplierCert
  135. certentity.Status = suppliercert.STOREING_STATUS
  136. certentity.Step = 5
  137. cols = []string{
  138. "Status",
  139. "Step",
  140. }
  141. _, err = svc.UpdateEntityByIdCols(strconv.Itoa(model.SupplierCertId), &certentity, cols)
  142. }
  143. if err == nil {
  144. errinfo.Message = "修改成功!"
  145. errinfo.Code = 0
  146. this.Data["json"] = &errinfo
  147. this.ServeJSON()
  148. } else {
  149. errinfo.Message = "修改失败!" + utils.AlertProcess(err.Error())
  150. errinfo.Code = -1
  151. this.Data["json"] = &errinfo
  152. this.ServeJSON()
  153. }
  154. }