| | |
| | | package purchase |
| | | |
| | | import ( |
| | | "fmt" |
| | | "github.com/gin-gonic/gin" |
| | | "github.com/mitchellh/mapstructure" |
| | | "go.uber.org/zap" |
| | |
| | | purchaserequest "srm/model/purchase/request" |
| | | "strconv" |
| | | "strings" |
| | | "time" |
| | | |
| | | //"srm/model/purchase" |
| | | |
| | |
| | | purchaseRecord.Status = purchase.OrderStatusConfirmed |
| | | purchaseRecord.HandledBy = "admin" |
| | | purchaseRecord.Creator = "admin" |
| | | purchaseRecord.Number = fmt.Sprintf("CG%v", time.Now().Unix()) |
| | | |
| | | if !purchaseRecord.WholeDiscountType.IsValid(purchaseRecord.TotalPrice, purchaseRecord.WholeDiscount) { |
| | | response.FailWithMessage("整单折扣数值不正确", c) |
| | |
| | | "description": "主键ID", |
| | | "type": "integer" |
| | | }, |
| | | "invoiceAmount": { |
| | | "description": "已收票金额", |
| | | "type": "number" |
| | | }, |
| | | "name": { |
| | | "description": "采购名称", |
| | | "type": "string" |
| | |
| | | "orderType": { |
| | | "description": "单据类型", |
| | | "type": "string" |
| | | }, |
| | | "paidAmount": { |
| | | "description": "已付金额", |
| | | "type": "number" |
| | | }, |
| | | "phone": { |
| | | "description": "联系人电话", |
| | |
| | | "description": "备注", |
| | | "type": "string" |
| | | }, |
| | | "shouldPayAmount": { |
| | | "description": "应付金额", |
| | | "type": "number" |
| | | }, |
| | | "signingDate": { |
| | | "description": "签约日期", |
| | | "type": "string" |
| | |
| | | }, |
| | | "totalPrice": { |
| | | "description": "价税合计", |
| | | "type": "number" |
| | | }, |
| | | "unInvoiceAmount": { |
| | | "description": "未收票金额", |
| | | "type": "number" |
| | | }, |
| | | "warehouse": { |
| | |
| | | "purchase.WholeDiscountType": { |
| | | "type": "integer", |
| | | "enum": [ |
| | | 0, |
| | | 1, |
| | | 2 |
| | | ], |
| | | "x-enum-comments": { |
| | | "WholeDiscountTypeDefault": "无折扣", |
| | | "WholeDiscountTypeDiscount": "直接降价", |
| | | "WholeDiscountTypePercent": "百分比降价" |
| | | }, |
| | | "x-enum-varnames": [ |
| | | "WholeDiscountTypeDefault", |
| | | "WholeDiscountTypePercent", |
| | | "WholeDiscountTypeDiscount" |
| | | ] |
| | |
| | | "description": "主键ID", |
| | | "type": "integer" |
| | | }, |
| | | "invoiceAmount": { |
| | | "description": "已收票金额", |
| | | "type": "number" |
| | | }, |
| | | "name": { |
| | | "description": "采购名称", |
| | | "type": "string" |
| | |
| | | "orderType": { |
| | | "description": "单据类型", |
| | | "type": "string" |
| | | }, |
| | | "paidAmount": { |
| | | "description": "已付金额", |
| | | "type": "number" |
| | | }, |
| | | "phone": { |
| | | "description": "联系人电话", |
| | |
| | | "description": "备注", |
| | | "type": "string" |
| | | }, |
| | | "shouldPayAmount": { |
| | | "description": "应付金额", |
| | | "type": "number" |
| | | }, |
| | | "signingDate": { |
| | | "description": "签约日期", |
| | | "type": "string" |
| | |
| | | }, |
| | | "totalPrice": { |
| | | "description": "价税合计", |
| | | "type": "number" |
| | | }, |
| | | "unInvoiceAmount": { |
| | | "description": "未收票金额", |
| | | "type": "number" |
| | | }, |
| | | "warehouse": { |
| | |
| | | "purchase.WholeDiscountType": { |
| | | "type": "integer", |
| | | "enum": [ |
| | | 0, |
| | | 1, |
| | | 2 |
| | | ], |
| | | "x-enum-comments": { |
| | | "WholeDiscountTypeDefault": "无折扣", |
| | | "WholeDiscountTypeDiscount": "直接降价", |
| | | "WholeDiscountTypePercent": "百分比降价" |
| | | }, |
| | | "x-enum-varnames": [ |
| | | "WholeDiscountTypeDefault", |
| | | "WholeDiscountTypePercent", |
| | | "WholeDiscountTypeDiscount" |
| | | ] |
| | |
| | | id: |
| | | description: 主键ID |
| | | type: integer |
| | | invoiceAmount: |
| | | description: 已收票金额 |
| | | type: number |
| | | name: |
| | | description: 采购名称 |
| | | type: string |
| | |
| | | orderType: |
| | | description: 单据类型 |
| | | type: string |
| | | paidAmount: |
| | | description: 已付金额 |
| | | type: number |
| | | phone: |
| | | description: 联系人电话 |
| | | type: string |
| | |
| | | remark: |
| | | description: 备注 |
| | | type: string |
| | | shouldPayAmount: |
| | | description: 应付金额 |
| | | type: number |
| | | signingDate: |
| | | description: 签约日期 |
| | | type: string |
| | |
| | | type: integer |
| | | totalPrice: |
| | | description: 价税合计 |
| | | type: number |
| | | unInvoiceAmount: |
| | | description: 未收票金额 |
| | | type: number |
| | | warehouse: |
| | | description: 收货仓库 |
| | |
| | | type: object |
| | | purchase.WholeDiscountType: |
| | | enum: |
| | | - 0 |
| | | - 1 |
| | | - 2 |
| | | type: integer |
| | | x-enum-comments: |
| | | WholeDiscountTypeDefault: 无折扣 |
| | | WholeDiscountTypeDiscount: 直接降价 |
| | | WholeDiscountTypePercent: 百分比降价 |
| | | x-enum-varnames: |
| | | - WholeDiscountTypeDefault |
| | | - WholeDiscountTypePercent |
| | | - WholeDiscountTypeDiscount |
| | | purchaserequest.AddPurchase: |
| | |
| | | PriceAdjustmentType PriceAdjustmentType `json:"priceAdjustmentType" form:"priceAdjustmentType" gorm:"type:decimal(12,2);not null;default '';comment:价格调整"` //价格调整类型 |
| | | PriceAdjustment decimal.Decimal `json:"priceAdjustment" form:"priceAdjustment" gorm:"type:decimal(12,2);not null;default '';comment:价格调整"` //价格调整值 |
| | | RealTotalPrice decimal.Decimal `json:"realTotalPrice" form:"realTotalPrice" gorm:"type:decimal(12,2);not null;default '';comment:最终价格"` //最终价格 |
| | | InvoiceAmount decimal.Decimal `json:"invoiceAmount" form:"invoiceAmount" gorm:"type:decimal(12,2);not null;default '';comment:已收票金额"` //已收票金额 |
| | | UnInvoiceAmount decimal.Decimal `json:"unInvoiceAmount" form:"unInvoiceAmount" gorm:"type:decimal(12,2);not null;default '';comment:未收票金额"` //未收票金额 |
| | | ShouldPayAmount decimal.Decimal `json:"shouldPayAmount" form:"shouldPayAmount" gorm:"type:decimal(12,2);not null;default '';comment:应付金额"` //应付金额 |
| | | PaidAmount decimal.Decimal `json:"paidAmount" form:"paidAmount" gorm:"type:decimal(12,2);not null;default '';comment:已付金额"` //已付金额 |
| | | } |
| | | |
| | | type OrderStatus int |
| | |
| | | if !realTotalPrice.Equal(record.RealTotalPrice) { |
| | | return errors.New("最终价格计算错误") |
| | | } |
| | | record.UnInvoiceAmount = record.RealTotalPrice |
| | | record.ShouldPayAmount = record.RealTotalPrice |
| | | |
| | | err = tx.Create(&record).Error |
| | | if err != nil { |
| | | return err |