contract_paid_api.go 7.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228
  1. /*
  2. * @description: 合同已支付相关
  3. * @Author: CP
  4. * @Date: 2020-12-22 11:45:22
  5. * @FilePath: \construction_management\web\api\contract_paid_api.go
  6. */
  7. package api
  8. import (
  9. "fmt"
  10. "github.com/kataras/iris/v12"
  11. "go.mod/web/utils"
  12. "go.mod/web/viewmodels"
  13. )
  14. // @Summary 获得已支付列表
  15. // @Tags 合同管理-支出合同
  16. // @Description 获得已支付列表
  17. // @Accept json
  18. // @Produce json
  19. // @Security ApiKeyAuth
  20. // @Param contractsId path string true "合同ID"
  21. // @Param bidsectionId path string true "标段ID"
  22. // @Success 200 {object} viewmodels.TreeSectionContract "{code:0成功,-1参数类错误,msg:错误信息}"
  23. // @Router /api/contract/paid/list [get]
  24. func (c *ContractApi) GetPaidList() {
  25. returnData, err := c.ServiceContract.ValidRuleContractPaid(c.Ctx)
  26. // 项目ID
  27. projectId, err := utils.GetProjectId(c.Ctx)
  28. if err != nil {
  29. c.Ctx.JSON(iris.Map{"code": -1, "msg": fmt.Sprintf("%s", err)})
  30. return
  31. }
  32. // 标段ID
  33. bidsectionId, err := utils.GetDecryptId(returnData.BidsectionId)
  34. if err != nil {
  35. c.Ctx.JSON(iris.Map{"code": -1, "msg": fmt.Sprintf("%s", err)})
  36. return
  37. }
  38. // 合同ID
  39. contractsId, err := utils.GetDecryptId(returnData.ContractsId)
  40. if err != nil {
  41. c.Ctx.JSON(iris.Map{"code": -1, "msg": fmt.Sprintf("%s", err)})
  42. return
  43. }
  44. returnList := c.ServiceContract.PaidAll(projectId, bidsectionId, contractsId, returnData.Page)
  45. c.Ctx.JSON(iris.Map{
  46. "code": 0,
  47. "msg": "",
  48. "data": returnList,
  49. })
  50. }
  51. // @Summary 新增已支付
  52. // @Tags 合同管理-支出合同
  53. // @Description 新增已支付
  54. // @Accept json
  55. // @Produce json
  56. // @Security ApiKeyAuth
  57. // @Param contractsId path string true "合同ID"
  58. // @Param bidsectionId path string true "标段ID"
  59. // @Param time path string true "已支付时间"
  60. // @Param Price path string true "已支付金额"
  61. // @Param Way path string true "已支付方式"
  62. // @Param remarks path string true "备注"
  63. // @Success 200 {object} viewmodels.TreeSectionContract "{code:0成功,-1参数类错误,msg:错误信息}"
  64. // @Router /api/contract/paid/create [post]
  65. func (c *ContractApi) PostPaidCreate() {
  66. // 验证参数
  67. returnData, err := c.ServiceContract.ValidRuleContractPaidAdd(c.Ctx)
  68. if err != nil {
  69. c.Ctx.JSON(iris.Map{"code": -1, "msg": fmt.Sprintf("%s", err)})
  70. return
  71. }
  72. // 项目ID
  73. projectId, err := utils.GetProjectId(c.Ctx)
  74. if err != nil {
  75. c.Ctx.JSON(iris.Map{"code": -1, "msg": fmt.Sprintf("%s", err)})
  76. return
  77. }
  78. // 标段ID
  79. bidsectionId, err := utils.GetDecryptId(returnData.BidsectionId)
  80. if err != nil {
  81. c.Ctx.JSON(iris.Map{"code": -1, "msg": fmt.Sprintf("%s", err)})
  82. return
  83. }
  84. // 合同ID
  85. contractsId, err := utils.GetDecryptId(returnData.ContractsId)
  86. if err != nil {
  87. c.Ctx.JSON(iris.Map{"code": -1, "msg": fmt.Sprintf("%s", err)})
  88. return
  89. }
  90. // 获得项目账号ID
  91. projectAccountId, err := utils.GetProjectAccountId(c.Ctx)
  92. if err != nil {
  93. c.Ctx.JSON(iris.Map{"code": -1, "msg": err})
  94. return
  95. }
  96. account := c.Ctx.Values().Get("account").(*viewmodels.ProjectAccount)
  97. returnData.CreateUser = account.Account
  98. err = c.ServiceContract.PaidCreate(returnData, projectId, bidsectionId, contractsId, projectAccountId)
  99. if err != nil {
  100. c.Ctx.JSON(iris.Map{"code": -1, "msg": fmt.Sprintf("%s", err)})
  101. return
  102. }
  103. c.Ctx.JSON(iris.Map{"code": 0, "msg": "新增成功"})
  104. }
  105. // @Summary 更新已支付
  106. // @Tags 合同管理-支出合同
  107. // @Description 更新已支付
  108. // @Accept json
  109. // @Produce json
  110. // @Security ApiKeyAuth
  111. // @Param id path string true "已支付ID"
  112. // @Param contractsId path string true "合同ID"
  113. // @Param bidsectionId path string true "标段ID"
  114. // @Param time path string true "已支付时间"
  115. // @Param Price path string true "已支付金额"
  116. // @Param Way path string true "已支付方式"
  117. // @Param remarks path string true "备注"
  118. // @Success 200 {object} viewmodels.TreeSectionContract "{code:0成功,-1参数类错误,msg:错误信息}"
  119. // @Router /api/contract/paid/update [post]
  120. func (c *ContractApi) PostPaidUpdate() {
  121. // 验证参数
  122. returnData, err := c.ServiceContract.ValidRuleContractPaidAdd(c.Ctx)
  123. if err != nil {
  124. c.Ctx.JSON(iris.Map{"code": -1, "msg": fmt.Sprintf("%s", err)})
  125. return
  126. }
  127. // 项目ID
  128. projectId, err := utils.GetProjectId(c.Ctx)
  129. if err != nil {
  130. c.Ctx.JSON(iris.Map{"code": -1, "msg": fmt.Sprintf("%s", err)})
  131. return
  132. }
  133. // 标段ID
  134. bidsectionId, err := utils.GetDecryptId(returnData.BidsectionId)
  135. if err != nil {
  136. c.Ctx.JSON(iris.Map{"code": -1, "msg": fmt.Sprintf("%s", err)})
  137. return
  138. }
  139. // 合同ID
  140. contractsId, err := utils.GetDecryptId(returnData.ContractsId)
  141. if err != nil {
  142. c.Ctx.JSON(iris.Map{"code": -1, "msg": fmt.Sprintf("%s", err)})
  143. return
  144. }
  145. if returnData.Id == "" {
  146. c.Ctx.JSON(iris.Map{"code": -1, "msg": "回款ID不能为空"})
  147. return
  148. }
  149. // 回款ID
  150. id, err := utils.GetDecryptId(returnData.Id)
  151. if err != nil {
  152. c.Ctx.JSON(iris.Map{"code": -1, "msg": fmt.Sprintf("%s", err)})
  153. return
  154. }
  155. err = c.ServiceContract.PaidUpdate(returnData, projectId, bidsectionId, contractsId, id)
  156. if err != nil {
  157. c.Ctx.JSON(iris.Map{"code": -1, "msg": fmt.Sprintf("%s", err)})
  158. return
  159. }
  160. c.Ctx.JSON(iris.Map{"code": 0, "msg": "编辑成功"})
  161. }
  162. // @Summary 删除已支付
  163. // @Tags 合同管理-支出合同
  164. // @Description 删除已支付
  165. // @Accept json
  166. // @Produce json
  167. // @Security ApiKeyAuth
  168. // @Param id path string true "已支付ID"
  169. // @Param contractsId path string true "合同ID"
  170. // @Param bidsectionId path string true "标段ID"
  171. // @Success 200 {object} viewmodels.TreeSectionContract "{code:0成功,-1参数类错误,msg:错误信息}"
  172. // @Router /api/contract/piad/delete [delete]
  173. func (c *ContractApi) DeletePaidDelete() {
  174. // 验证参数
  175. returnData, err := c.ServiceContract.ValidRuleContractPaidDel(c.Ctx)
  176. if err != nil {
  177. c.Ctx.JSON(iris.Map{"code": -1, "msg": fmt.Sprintf("%s", err)})
  178. return
  179. }
  180. // 项目ID
  181. projectId, err := utils.GetProjectId(c.Ctx)
  182. if err != nil {
  183. c.Ctx.JSON(iris.Map{"code": -1, "msg": fmt.Sprintf("%s", err)})
  184. return
  185. }
  186. // 标段ID
  187. bidsectionId, err := utils.GetDecryptId(returnData.BidsectionId)
  188. if err != nil {
  189. c.Ctx.JSON(iris.Map{"code": -1, "msg": fmt.Sprintf("%s", err)})
  190. return
  191. }
  192. // 合同ID
  193. contractsId, err := utils.GetDecryptId(returnData.ContractsId)
  194. if err != nil {
  195. c.Ctx.JSON(iris.Map{"code": -1, "msg": fmt.Sprintf("%s", err)})
  196. return
  197. }
  198. // 回款ID
  199. id, err := utils.GetDecryptId(returnData.Id)
  200. if err != nil {
  201. c.Ctx.JSON(iris.Map{"code": -1, "msg": fmt.Sprintf("%s", err)})
  202. return
  203. }
  204. err = c.ServiceContract.PaidDelete(projectId, bidsectionId, contractsId, id)
  205. if err != nil {
  206. c.Ctx.JSON(iris.Map{"code": -1, "msg": fmt.Sprintf("%s", err)})
  207. return
  208. }
  209. c.Ctx.JSON(iris.Map{"code": 0, "msg": "删除成功"})
  210. }