| | |
| | | package v1 |
| | | |
| | | import ( |
| | | "aps_crm/constvar" |
| | | "aps_crm/model" |
| | | "aps_crm/model/request" |
| | | "aps_crm/model/response" |
| | |
| | | "aps_crm/pkg/ecode" |
| | | "aps_crm/pkg/structx" |
| | | "aps_crm/service" |
| | | "aps_crm/utils" |
| | | "github.com/gin-gonic/gin" |
| | | "strconv" |
| | | ) |
| | |
| | | |
| | | if err != nil { |
| | | ctx.Fail(ecode.ParamsErr) |
| | | return |
| | | } |
| | | count, err := model.NewInvoiceSearch().SetNumber(invoice.Number).Count() |
| | | if err != nil { |
| | | ctx.FailWithMsg(ecode.UnknownErr, "编码验证失败") |
| | | return |
| | | } |
| | | if count > 0 { |
| | | ctx.FailWithMsg(ecode.UnknownErr, "编码已存在") |
| | | return |
| | | } |
| | | |
| | |
| | | // @Tags 销售发票 |
| | | // @Summary 获取销售发票列表 |
| | | // @Produce application/json |
| | | // @Param object query request.GetInvoiceList true "参数" |
| | | // @Param object body request.GetInvoiceList true "参数" |
| | | // @Success 200 {object} response.ListResponse{data=[]model.Invoice} |
| | | // @Router /api/invoice/list [get] |
| | | // @Router /api/invoice/list [post] |
| | | func (s *InvoiceApi) List(c *gin.Context) { |
| | | var params request.GetInvoiceList |
| | | ctx, ok := contextx.NewContext(c, ¶ms) |
| | |
| | | return |
| | | } |
| | | |
| | | invoice, total, errCode := service.NewInvoiceService().GetInvoiceList() |
| | | userInfo := utils.GetUserInfo(c) |
| | | if userInfo.UserType == constvar.UserTypeSub { |
| | | params.PrincipalIds = userInfo.SubUserIds |
| | | } |
| | | |
| | | invoice, total, errCode := service.NewInvoiceService().GetInvoiceList(params) |
| | | if errCode != ecode.OK { |
| | | ctx.Fail(errCode) |
| | | return |