123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229 |
- /*
- * @description: 合同已支付相关
- * @Author: CP
- * @Date: 2020-12-22 11:45:22
- * @FilePath: \construction_management\web\api\contract_paid_api.go
- */
- package api
- import (
- "fmt"
- "github.com/kataras/iris/v12"
- "go.mod/models"
- "go.mod/web/utils"
- )
- // @Summary 获得已支付列表
- // @Tags 合同管理-支出合同
- // @Description 获得已支付列表
- // @Accept json
- // @Produce json
- // @Security ApiKeyAuth
- // @Param contractsId path string true "合同ID"
- // @Param bidsectionId path string true "标段ID"
- // @Success 200 {object} viewmodels.TreeSectionContract "{code:0成功,-1参数类错误,msg:错误信息}"
- // @Router /api/contract/paid/list [get]
- func (c *ContractApi) GetPaidList() {
- returnData, err := c.ServiceContract.ValidRuleContractPaid(c.Ctx)
- // 项目ID
- projectId, err := utils.GetProjectId(c.Ctx)
- if err != nil {
- c.Ctx.JSON(iris.Map{"code": -1, "msg": fmt.Sprintf("%s", err)})
- return
- }
- // 标段ID
- bidsectionId, err := utils.GetDecryptId(returnData.BidsectionId)
- if err != nil {
- c.Ctx.JSON(iris.Map{"code": -1, "msg": fmt.Sprintf("%s", err)})
- return
- }
- // 合同ID
- contractsId, err := utils.GetDecryptId(returnData.ContractsId)
- if err != nil {
- c.Ctx.JSON(iris.Map{"code": -1, "msg": fmt.Sprintf("%s", err)})
- return
- }
- returnList := c.ServiceContract.PaidAll(projectId, bidsectionId, contractsId, returnData.Page)
- c.Ctx.JSON(iris.Map{
- "code": 0,
- "msg": "",
- "data": returnList,
- })
- }
- // @Summary 新增已支付
- // @Tags 合同管理-支出合同
- // @Description 新增已支付
- // @Accept json
- // @Produce json
- // @Security ApiKeyAuth
- // @Param contractsId path string true "合同ID"
- // @Param bidsectionId path string true "标段ID"
- // @Param time path string true "已支付时间"
- // @Param Price path string true "已支付金额"
- // @Param Way path string true "已支付方式"
- // @Param remarks path string true "备注"
- // @Success 200 {object} viewmodels.TreeSectionContract "{code:0成功,-1参数类错误,msg:错误信息}"
- // @Router /api/contract/paid/create [post]
- func (c *ContractApi) PostPaidCreate() {
- // 验证参数
- returnData, err := c.ServiceContract.ValidRuleContractPaidAdd(c.Ctx)
- if err != nil {
- c.Ctx.JSON(iris.Map{"code": -1, "msg": fmt.Sprintf("%s", err)})
- return
- }
- // 项目ID
- projectId, err := utils.GetProjectId(c.Ctx)
- if err != nil {
- c.Ctx.JSON(iris.Map{"code": -1, "msg": fmt.Sprintf("%s", err)})
- return
- }
- // 标段ID
- bidsectionId, err := utils.GetDecryptId(returnData.BidsectionId)
- if err != nil {
- c.Ctx.JSON(iris.Map{"code": -1, "msg": fmt.Sprintf("%s", err)})
- return
- }
- // 合同ID
- contractsId, err := utils.GetDecryptId(returnData.ContractsId)
- if err != nil {
- c.Ctx.JSON(iris.Map{"code": -1, "msg": fmt.Sprintf("%s", err)})
- return
- }
- // 获得项目账号ID
- projectAccountId, err := utils.GetProjectAccountId(c.Ctx)
- if err != nil {
- c.Ctx.JSON(iris.Map{"code": -1, "msg": err})
- return
- }
- account := c.Ctx.Values().Get("account").(*models.CmProjectAccount)
- returnData.CreateUser = account.Name
- err = c.ServiceContract.PaidCreate(returnData, projectId, bidsectionId, contractsId, projectAccountId)
- contractData := c.ServiceContract.GetContract(contractsId)
- if err != nil {
- c.Ctx.JSON(iris.Map{"code": -1, "msg": fmt.Sprintf("%s", err)})
- return
- }
- c.Ctx.JSON(iris.Map{"code": 0, "msg": "新增成功", "contract": contractData})
- }
- // @Summary 更新已支付
- // @Tags 合同管理-支出合同
- // @Description 更新已支付
- // @Accept json
- // @Produce json
- // @Security ApiKeyAuth
- // @Param id path string true "已支付ID"
- // @Param contractsId path string true "合同ID"
- // @Param bidsectionId path string true "标段ID"
- // @Param time path string true "已支付时间"
- // @Param Price path string true "已支付金额"
- // @Param Way path string true "已支付方式"
- // @Param remarks path string true "备注"
- // @Success 200 {object} viewmodels.TreeSectionContract "{code:0成功,-1参数类错误,msg:错误信息}"
- // @Router /api/contract/paid/update [post]
- func (c *ContractApi) PostPaidUpdate() {
- // 验证参数
- returnData, err := c.ServiceContract.ValidRuleContractPaidAdd(c.Ctx)
- if err != nil {
- c.Ctx.JSON(iris.Map{"code": -1, "msg": fmt.Sprintf("%s", err)})
- return
- }
- // 项目ID
- projectId, err := utils.GetProjectId(c.Ctx)
- if err != nil {
- c.Ctx.JSON(iris.Map{"code": -1, "msg": fmt.Sprintf("%s", err)})
- return
- }
- // 标段ID
- bidsectionId, err := utils.GetDecryptId(returnData.BidsectionId)
- if err != nil {
- c.Ctx.JSON(iris.Map{"code": -1, "msg": fmt.Sprintf("%s", err)})
- return
- }
- // 合同ID
- contractsId, err := utils.GetDecryptId(returnData.ContractsId)
- if err != nil {
- c.Ctx.JSON(iris.Map{"code": -1, "msg": fmt.Sprintf("%s", err)})
- return
- }
- if returnData.Id == "" {
- c.Ctx.JSON(iris.Map{"code": -1, "msg": "已支付ID不能为空"})
- return
- }
- // 已支付ID
- id, err := utils.GetDecryptId(returnData.Id)
- if err != nil {
- c.Ctx.JSON(iris.Map{"code": -1, "msg": fmt.Sprintf("%s", err)})
- return
- }
- err = c.ServiceContract.PaidUpdate(returnData, projectId, bidsectionId, contractsId, id)
- if err != nil {
- c.Ctx.JSON(iris.Map{"code": -1, "msg": fmt.Sprintf("%s", err)})
- return
- }
- c.Ctx.JSON(iris.Map{"code": 0, "msg": "编辑成功"})
- }
- // @Summary 删除已支付
- // @Tags 合同管理-支出合同
- // @Description 删除已支付
- // @Accept json
- // @Produce json
- // @Security ApiKeyAuth
- // @Param id path string true "已支付ID"
- // @Param contractsId path string true "合同ID"
- // @Param bidsectionId path string true "标段ID"
- // @Success 200 {object} viewmodels.TreeSectionContract "{code:0成功,-1参数类错误,msg:错误信息}"
- // @Router /api/contract/piad/delete [delete]
- func (c *ContractApi) DeletePaidDelete() {
- // 验证参数
- returnData, err := c.ServiceContract.ValidRuleContractPaidDel(c.Ctx)
- if err != nil {
- c.Ctx.JSON(iris.Map{"code": -1, "msg": fmt.Sprintf("%s", err)})
- return
- }
- // 项目ID
- projectId, err := utils.GetProjectId(c.Ctx)
- if err != nil {
- c.Ctx.JSON(iris.Map{"code": -1, "msg": fmt.Sprintf("%s", err)})
- return
- }
- // 标段ID
- bidsectionId, err := utils.GetDecryptId(returnData.BidsectionId)
- if err != nil {
- c.Ctx.JSON(iris.Map{"code": -1, "msg": fmt.Sprintf("%s", err)})
- return
- }
- // 合同ID
- contractsId, err := utils.GetDecryptId(returnData.ContractsId)
- if err != nil {
- c.Ctx.JSON(iris.Map{"code": -1, "msg": fmt.Sprintf("%s", err)})
- return
- }
- // 回款ID
- id, err := utils.GetDecryptId(returnData.Id)
- if err != nil {
- c.Ctx.JSON(iris.Map{"code": -1, "msg": fmt.Sprintf("%s", err)})
- return
- }
- err = c.ServiceContract.PaidDelete(projectId, bidsectionId, contractsId, id)
- if err != nil {
- c.Ctx.JSON(iris.Map{"code": -1, "msg": fmt.Sprintf("%s", err)})
- return
- }
- c.Ctx.JSON(iris.Map{"code": 0, "msg": "删除成功"})
- }
|