From f754f9ccd25820a772d8a698f9c2e8b0de33fa28 Mon Sep 17 00:00:00 2001 From: chenlin Date: Fri, 14 Jun 2024 15:15:39 +0800 Subject: [PATCH] =?UTF-8?q?=E5=BC=80=E5=8F=91v1.4.1=E9=9C=80=E6=B1=82?= =?UTF-8?q?=EF=BC=9A=20=EF=BC=881=EF=BC=89=E4=BC=98=E5=8C=96=E9=87=87?= =?UTF-8?q?=E8=B4=AD=E9=9C=80=E6=B1=82=E6=8E=A5=E5=8F=A3=EF=BC=8C=E5=A2=9E?= =?UTF-8?q?=E5=8A=A0=E5=85=A5=E5=8F=82=E5=8C=BA=E5=88=86=E5=BA=97=E5=91=98?= =?UTF-8?q?=E5=92=8C=E9=87=87=E8=B4=AD=E8=A7=86=E8=A7=92=EF=BC=9B=20?= =?UTF-8?q?=EF=BC=882=EF=BC=89=E4=BC=98=E5=8C=96=E4=BE=9B=E5=BA=94?= =?UTF-8?q?=E5=95=86=E6=8E=A5=E5=8F=A3=EF=BC=8C=E5=BC=80=E6=88=B7=E8=A1=8C?= =?UTF-8?q?=E6=94=B9=E6=88=90=E5=88=97=E8=A1=A8=EF=BC=9B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/admin/apis/basic/supplier.go | 70 +++-- app/admin/apis/decision/decision.go | 2 +- app/admin/apis/inventorymanage/allot.go | 3 +- app/admin/apis/purchasemanage/purchase.go | 6 +- app/admin/models/commodity.go | 36 ++- app/admin/models/erp_order.go | 22 +- app/admin/models/inventory_report.go | 18 +- app/admin/models/purchase.go | 316 +++++++++++++++++++--- app/admin/models/store.go | 3 +- app/admin/models/supplier.go | 51 ++-- app/admin/models/sysuser.go | 10 + docs/docs.go | 114 ++++++-- docs/swagger.json | 114 ++++++-- docs/swagger.yaml | 93 +++++-- 14 files changed, 695 insertions(+), 163 deletions(-) diff --git a/app/admin/apis/basic/supplier.go b/app/admin/apis/basic/supplier.go index 86ccfd2..4261640 100644 --- a/app/admin/apis/basic/supplier.go +++ b/app/admin/apis/basic/supplier.go @@ -1,6 +1,7 @@ package basic import ( + "encoding/json" "errors" "fmt" "github.com/gin-gonic/gin" @@ -14,26 +15,27 @@ import ( ) type SupplierCreateRequest struct { - Name string `json:"name" validate:"required"` //供应商名称 - Contact string `json:"contact" validate:"required"` //联系人 - Tel string `json:"tel" validate:"required"` //手机号 - Address string `json:"address" validate:"required"` //地址 - OpeningBank string `json:"opening_bank" validate:"required"` //开户行 - AccountHolder string `json:"account_holder"` //开户人 - BankAccount string `json:"bank_account" validate:"required"` //银行卡号 - PaymentCycle uint32 `json:"payment_cycle" validate:"required"` //支付周期 - TaxNumber string `json:"tax_number"` //税点 - Landline string `json:"landline"` //固话 - Email string `json:"email"` //邮箱 - CompanyWebsite string `json:"company_website"` //网站 - Province string `json:"province" validate:"required"` //省份 - City string `json:"city" validate:"required"` //城市 - Area string `json:"area" validate:"required"` //地区 + Name string `json:"name" validate:"required"` // 供应商名称 + Contact string `json:"contact"` // 联系人 + Tel string `json:"tel"` // 手机号 + Address string `json:"address"` // 地址 + OpeningBank string `json:"opening_bank"` // 开户行 + AccountHolder string `json:"account_holder"` // 开户人 + BankAccount string `json:"bank_account"` // 银行卡号 + PaymentCycle uint32 `json:"payment_cycle" ` // 支付周期 + TaxNumber string `json:"tax_number"` // 税点 + Landline string `json:"landline"` // 固话 + Email string `json:"email"` // 邮箱 + CompanyWebsite string `json:"company_website"` // 网站 + Province string `json:"province"` // 省份 + City string `json:"city"` // 城市 + Area string `json:"area"` // 地区 + BankList []models.SupplierBankInfo `json:"bank_list" validate:"required"` // 开户银行信息列表 } // SupplierCreate 添加供应商 // @Summary 创建供应商 -// @Tags 供应商管理 +// @Tags 供应商管理,V1.4.1 // @Produce json // @Accept json // @Param request body SupplierCreateRequest true "供应商模型" @@ -72,6 +74,17 @@ func SupplierCreate(c *gin.Context) { AccountHolder: req.AccountHolder, } + if len(req.BankList) != 0 { + // 将 BankList 转换为 JSON 字符串 + bankDataJSON, err := json.Marshal(req.BankList) + if err != nil { + tools.HasError(err, "数据解析失败", 500) + } + supplier.BankData = string(bankDataJSON) + } else { + supplier.BankData = "" + } + err = orm.Eloquent.Create(supplier).Error if err != nil { logger.Error("[SupplierCreate]:create supplier err", logger.Field("err", err)) @@ -90,7 +103,7 @@ type SupplierUpdateRequest struct { // SupplierUpdate 更新供应商 // @Summary 更新供应商 -// @Tags 供应商管理 +// @Tags 供应商管理,V1.4.1 // @Produce json // @Accept json // @Param request body SupplierUpdateRequest true "供应商模型" @@ -119,6 +132,18 @@ func SupplierUpdate(c *gin.Context) { Area: req.Area, AccountHolder: req.AccountHolder, } + + if len(req.BankList) != 0 { + // 将 BankList 转换为 JSON 字符串 + bankDataJSON, err := json.Marshal(req.BankList) + if err != nil { + tools.HasError(err, "数据解析失败", 500) + } + supplier.BankData = string(bankDataJSON) + } else { + supplier.BankData = "" + } + err := orm.Eloquent.Where("id", req.Id).Updates(supplier).Error if err != nil { logger.Error("update supplier err :", logger.Field("err", err), logger.Field("s", supplier)) @@ -136,7 +161,7 @@ type SupplierListRequest struct { // SupplierList 供应商列表 // @Summary 供应商列表 -// @Tags 供应商管理 +// @Tags 供应商管理,V1.4.1 // @Produce json // @Accept json // @Param request body SupplierListRequest true "供应商查询模型" @@ -165,7 +190,7 @@ func SupplierList(c *gin.Context) { // SupplierDetail 供应商详情 // @Summary 供应商详情 -// @Tags 供应商管理 +// @Tags 供应商管理,V1.4.1 // @Produce json // @Param id path int true "供应商id" // @Success 200 {object} models.Supplier @@ -181,13 +206,18 @@ func SupplierDetail(c *gin.Context) { return } + if supplier.BankData != "" { + supplier.BankList = models.DeserializeBankData(supplier.BankData) + supplier.BankData = "" + } + app.OK(c, supplier, "ok") return } // SupplierDel 删除供应商 // @Summary 删除供应商 -// @Tags 供应商管理 +// @Tags 供应商管理,V1.4.1 // @Produce json // @Param id path int true "供应商id" // @Success 200 {object} app.Response diff --git a/app/admin/apis/decision/decision.go b/app/admin/apis/decision/decision.go index 0779ded..877c782 100644 --- a/app/admin/apis/decision/decision.go +++ b/app/admin/apis/decision/decision.go @@ -11,7 +11,7 @@ import ( // ErpDecisionReport 进销存报表 // @Summary 进销存报表 -// @Tags 决策中心, V1.4.0 +// @Tags 决策中心,V1.4.0 // @Produce json // @Accept json // @Param request body models.ErpDecisionReportReq true "进销存报表模型" diff --git a/app/admin/apis/inventorymanage/allot.go b/app/admin/apis/inventorymanage/allot.go index c4b9559..f49a438 100644 --- a/app/admin/apis/inventorymanage/allot.go +++ b/app/admin/apis/inventorymanage/allot.go @@ -281,8 +281,7 @@ func InventoryAllotDetail(c *gin.Context) { // 校验入参门店是否包含在用户所有门店中,是否过期 if !(tools.GetRoleName(c) == "admin" || tools.GetRoleName(c) == "系统管理员") { - if !models.CheckUserStore(allotOrder.ReceiveStoreId, sysUser) && - !models.CheckUserStore(allotOrder.DeliverStoreId, sysUser) { + if !models.CheckUserStore(allotOrder.DeliverStoreId, sysUser) { app.Error(c, http.StatusInternalServerError, errors.New("操作失败:您没有该门店权限"), "操作失败:您没有该门店权限") return diff --git a/app/admin/apis/purchasemanage/purchase.go b/app/admin/apis/purchasemanage/purchase.go index 6e7a27f..7e769fc 100644 --- a/app/admin/apis/purchasemanage/purchase.go +++ b/app/admin/apis/purchasemanage/purchase.go @@ -670,7 +670,7 @@ func ErpPurchaseExecute(c *gin.Context) { // ErpPurchaseDemandCreate 创建采购需求 // @Summary 创建采购需求 -// @Tags 采购需求, V1.3.0 +// @Tags 采购需求,V1.4.1 // @Produce json // @Accept json // @Param request body models.CreateErpPurchaseDemandReq true "创建采购需求模型" @@ -704,7 +704,7 @@ func ErpPurchaseDemandCreate(c *gin.Context) { // ErpPurchaseDemandGet 获取采购需求 // @Summary 获取采购需求 -// @Tags 采购需求, V1.3.0 +// @Tags 采购需求,V1.4.1 // @Produce json // @Accept json // @Param request body models.GetErpPurchaseDemandReq true "获取采购需求模型" @@ -731,7 +731,7 @@ func ErpPurchaseDemandGet(c *gin.Context) { // ErpPurchaseDemandFinish 完成采购需求 // @Summary 完成采购需求 -// @Tags 采购需求, V1.3.0 +// @Tags 采购需求,V1.4.1 // @Produce json // @Accept json // @Param request body models.FinishErpPurchaseDemandReq true "完成采购需求模型" diff --git a/app/admin/models/commodity.go b/app/admin/models/commodity.go index 4321c6e..bc37cf7 100644 --- a/app/admin/models/commodity.go +++ b/app/admin/models/commodity.go @@ -357,7 +357,7 @@ func (m *ErpCommodityListReq) List() (*ErpCommodityListResp, error) { } // 按商品编号进行排序 - SortCommodities(commodities) + SortCommoditiesAsc(commodities) if m.IsExport == 1 { listExport, err := ErpCommodityListExport(commodities) @@ -430,8 +430,8 @@ func SortStockCommodities(commodities []ErpStock) { sort.SliceStable(commodities, less) } -// SortCommodities 对商品数组进行排序 -func SortCommodities(commodities []ErpCommodity) { +// SortCommoditiesAsc 对商品数组进行排序(升序) +func SortCommoditiesAsc(commodities []ErpCommodity) { // 定义排序函数 less := func(i, j int) bool { // 解析商品编号,提取分类编号和商品编号的数字部分 @@ -460,6 +460,36 @@ func SortCommodities(commodities []ErpCommodity) { sort.SliceStable(commodities, less) } +// SortCommoditiesDesc 对商品数组进行排序(降序) +func SortCommoditiesDesc(commodities []ErpCommodity) { + // 定义排序函数 + less := func(i, j int) bool { + // 解析商品编号,提取分类编号和商品编号的数字部分 + catNumI, subCatNumI, threeSubCatNumI, itemNumI := parseSerialNumber(commodities[i].SerialNumber) + catNumJ, subCatNumJ, threeSubCatNumJ, itemNumJ := parseSerialNumber(commodities[j].SerialNumber) + + // 按照分类编号从大到小排序 + if catNumI != catNumJ { + return catNumI > catNumJ + } + + // 如果分类编号相同,按照具体分类下的商品编号递增排序 + if subCatNumI != subCatNumJ { + return subCatNumI > subCatNumJ + } + + if threeSubCatNumI != threeSubCatNumJ { + return threeSubCatNumI > threeSubCatNumJ + } + + // 如果具体分类编号也相同,按照商品编号递增排序 + return itemNumI > itemNumJ + } + + // 调用排序函数进行排序 + sort.SliceStable(commodities, less) +} + // SortReportByAllotDataCommodities 对商品数组进行排序 func SortReportByAllotDataCommodities(commodities []ReportByAllotData) { // 定义排序函数 diff --git a/app/admin/models/erp_order.go b/app/admin/models/erp_order.go index e1fa39e..f7f09de 100644 --- a/app/admin/models/erp_order.go +++ b/app/admin/models/erp_order.go @@ -391,17 +391,18 @@ type ErpOrderReceiptDataResp struct { Time time.Time `json:"time"` // 审核时间 CollectS string `json:"collectS"` // 收银人员:制单人 ChandiseObj map[string]TableData `json:"chandiseObj"` // 商品信息 - TotalRetailP float64 `json:"totalRetailP"` //零售价合计 - TotalNum uint32 `json:"totalNum"` //数量合计 - TotalAmount float64 `json:"totalAmount"` //零售优惠总金额 - MembersAmount float64 `json:"membersAmount"` //会员优惠总金额 - IntegrationAmount float64 `json:"integrationAmount"` //积分抵扣总金额 - ToDealWith float64 `json:"toDealWith"` //零售价合计 - 零售优惠总额 - 会员优惠总和 - 积分抵扣总额 + TotalRetailP float64 `json:"totalRetailP"` // 零售价合计 + TotalNum uint32 `json:"totalNum"` // 数量合计 + TotalAmount float64 `json:"totalAmount"` // 零售优惠总金额 + MembersAmount float64 `json:"membersAmount"` // 会员优惠总金额 + IntegrationAmount float64 `json:"integrationAmount"` // 积分抵扣总金额 + ToDealWith float64 `json:"toDealWith"` // 零售价合计 - 零售优惠总额 - 会员优惠总和 - 积分抵扣总额 ModeOfPayment map[string]ErpOrderCashier `json:"modeOfPayment"` // 支付信息 - ActualPayment float64 `json:"actualPayment"` //所有支付方式金额总和 - Tel string `json:"tel"` //买家电话 - StoreTel string `json:"storeTel"` //卖家电话 - StoreAddress string `json:"storeAddress"` //店铺地址 + ActualPayment float64 `json:"actualPayment"` // 所有支付方式金额总和 + Tel string `json:"tel"` // 买家电话 + StoreTel string `json:"storeTel"` // 卖家电话 + StoreAddress string `json:"storeAddress"` // 店铺地址 + Uid int `json:"uid"` // 用户id } type TableData struct { @@ -3723,6 +3724,7 @@ func QueryReceiptData(req *ErpOrderDeleteReq, c *gin.Context) (*ErpOrderReceiptD resp.ModeOfPayment = cashierMap resp.ActualPayment = order.TotalAmount resp.Tel = order.Tel + resp.Uid = order.Uid resp.StoreTel = storeInfo.Tel resp.StoreAddress = storeInfo.Address diff --git a/app/admin/models/inventory_report.go b/app/admin/models/inventory_report.go index d7df793..b5740f5 100644 --- a/app/admin/models/inventory_report.go +++ b/app/admin/models/inventory_report.go @@ -796,24 +796,26 @@ func (m *InventoryReportByAllotReq) ReportAllotList(c *gin.Context) (*InventoryR // 按照商品编号排序 SortReportByAllotDataCommodities(summaryList) - // 计算分页所需的切片索引 - startIndex := page * m.PageSize - endIndex := (page + 1) * m.PageSize - if endIndex > len(summaryList) { - endIndex = len(summaryList) - } - resp.Total = len(summaryList) resp.TotalAllotCount = nTotalAllotCount resp.TotalAllotAmount = nTotalAllotAmount - resp.List = summaryList[startIndex:endIndex] if m.IsExport == 1 { + resp.List = summaryList resp.ExportUrl, err = reportAllotExport(resp) if err != nil { return nil, err } resp.List = []ReportByAllotData{} + } else { + // 计算分页所需的切片索引 + startIndex := page * m.PageSize + endIndex := (page + 1) * m.PageSize + if endIndex > len(summaryList) { + endIndex = len(summaryList) + } + + resp.List = summaryList[startIndex:endIndex] } return resp, nil diff --git a/app/admin/models/purchase.go b/app/admin/models/purchase.go index eebaa50..de873f0 100644 --- a/app/admin/models/purchase.go +++ b/app/admin/models/purchase.go @@ -241,6 +241,7 @@ type ErpPurchaseDemand struct { ErpCommodityId uint32 `json:"erp_commodity_id" gorm:"index"` // 商品id ErpCommoditySerialNumber string `json:"erp_commodity_serial_number"` // 商品编号 ErpCommodityName string `json:"erp_commodity_name" gorm:"index"` // 商品名称 + ErpSupplierId uint32 `json:"erp_supplier_id" gorm:"index"` // 主供应商id StoreId uint32 `json:"store_id"` // 门店id StoreName string `json:"store_name"` // 门店名称 Count uint32 `json:"count"` // 需采购数量 @@ -263,6 +264,7 @@ type ErpPurchaseDemandRemark struct { // GetErpPurchaseDemandReq 获取采购需求入参 type GetErpPurchaseDemandReq struct { + ErpSupplierId uint32 `json:"erp_supplier_id"` // 主供应商id ErpCategoryId uint32 `json:"erp_category_id"` // 商品分类id ErpCommoditySerialNumber string `json:"erp_commodity_serial_number"` // 商品编号 ErpCommodityName string `json:"erp_commodity_name"` // 商品名称 @@ -270,10 +272,15 @@ type GetErpPurchaseDemandReq struct { PageIndex int `json:"pageIndex"` // 页码 PageSize int `json:"pageSize"` // 每页展示数据条数 IsExport uint32 `json:"is_export"` // 1-导出 + CallType int `json:"call_type"` // 调用类型:1-采购视角;2-店员视角 + SortField string `json:"sort_field"` // 排序字段:主供应商 erp_supplier_id; 商品编号 erp_commodity_serial_number + SortType string `json:"sort_type"` // 排序类型:desc 降序、asc 升序 } // DemandData 采购需求数据 type DemandData struct { + ErpSupplierId uint32 `json:"erp_supplier_id"` // 主供应商id + ErpSupplierName string `json:"erp_supplier_name" gorm:"-"` // 主供应商名称 ErpCommodityID uint32 `json:"erp_commodity_id"` // 商品id ErpCommoditySerialNumber string `json:"erp_commodity_serial_number"` // 商品编号 ErpCommodityName string `json:"erp_commodity_name"` // 商品名称 @@ -307,6 +314,7 @@ type CreateErpPurchaseDemandReq struct { ErpCommodityID uint32 `json:"erp_commodity_id"` // 商品id ErpCommoditySerialNumber string `json:"erp_commodity_serial_number"` // 商品编号 ErpCommodityName string `json:"erp_commodity_name"` // 商品名称 + ErpSupplierId uint32 `json:"erp_supplier_id"` // 主供应商id Remark string `json:"remark"` // 备注 List []struct { StoreID uint32 `json:"store_id"` // 门店id @@ -1118,7 +1126,7 @@ func InventoryErpPurchase(req *ErpPurchaseInventoryReq, c *gin.Context) error { } } - err = checkPurchaseInventory(req) + err = checkPurchaseInventory(req, true) if err != nil { logger.Error("checkPurchaseInventoryReq err:", logger.Field("err", err)) return err @@ -1490,7 +1498,7 @@ func InventoryErpPurchaseUpdateRejectStock(gdb *gorm.DB, list []ErpPurchaseInven } // 校验入参数据,执行数量是否超过总数;串码商品的串码是否重复 -func checkPurchaseInventory(req *ErpPurchaseInventoryReq) error { +func checkPurchaseInventory(req *ErpPurchaseInventoryReq, imeiCheckFlag bool) error { // 查询现有的零售订单信息 var commodities []ErpPurchaseCommodity err := orm.Eloquent.Table("erp_purchase_commodity").Where("erp_purchase_order_id = ?", req.ErpPurchaseOrderId).Find(&commodities).Error @@ -1506,6 +1514,12 @@ func checkPurchaseInventory(req *ErpPurchaseInventoryReq) error { } countMap[inventory.ErpCommodityId] += inventory.Count + if imeiCheckFlag { + if inventory.IMEIType != NoIMEICommodity && inventory.IMEI == "" { + return fmt.Errorf("商品[%s]串码为空", inventory.ErpCommodityName) + } + } + // 如果该商品是串码商品,判断其串码是否会重复 if inventory.IMEI != "" { exist, err := QueryRecordExist(fmt.Sprintf("SELECT * FROM erp_stock_commodity WHERE FIND_IN_SET(%s, imei) > 0", inventory.IMEI)) @@ -1614,7 +1628,7 @@ func ExecuteErpPurchase(req *ErpPurchaseExecuteReq, c *gin.Context) (*ErpPurchas PurchaseType: req.PurchaseType, Inventories: req.Inventories, } - err = checkPurchaseInventory(reqParam) + err = checkPurchaseInventory(reqParam, false) if err != nil { logger.Error("checkPurchaseInventoryReq err:", logger.Field("err", err)) return nil, err @@ -1698,6 +1712,7 @@ func CreateErpPurchaseDemand(req *CreateErpPurchaseDemandReq, sysUser *SysUser) demandInfo.ErpCommodityId = req.ErpCommodityID demandInfo.ErpCommoditySerialNumber = req.ErpCommoditySerialNumber demandInfo.ErpCommodityName = req.ErpCommodityName + demandInfo.ErpSupplierId = req.ErpSupplierId demandInfo.State = ErpDemandStateWait // 待采购 for _, v := range req.List { demandInfo.StoreId = v.StoreID @@ -2460,6 +2475,9 @@ func getErpPurchaseDemandAll(req *GetErpPurchaseDemandReq, c *gin.Context) (*Get if req.ErpCommodityName != "" { qs = qs.Where("name=?", req.ErpCommodityName) } + if req.ErpSupplierId != 0 { + qs = qs.Where("erp_supplier_id=?", req.ErpSupplierId) + } var count int64 if err := qs.Count(&count).Error; err != nil { @@ -2473,8 +2491,46 @@ func getErpPurchaseDemandAll(req *GetErpPurchaseDemandReq, c *gin.Context) (*Get return resp, err } - // 按商品编号进行排序 - SortCommodities(commodities) + if req.SortField == "erp_commodity_serial_number" { + switch req.SortType { + case "desc": + SortCommoditiesDesc(commodities) + case "asc": + SortCommoditiesAsc(commodities) + default: + SortCommoditiesAsc(commodities) + } + } else { + // 商品编号排序 + SortCommoditiesAsc(commodities) + } + + if req.CallType != 2 { + if req.SortField == "erp_supplier_id" { + switch req.SortType { + case "desc": + // 排序规则:主供应商id大 + sort.Slice(commodities, func(i, j int) bool { + return commodities[i].ErpSupplierId > commodities[j].ErpSupplierId + }) + case "asc": + // 排序规则:主供应商id小 + sort.Slice(commodities, func(i, j int) bool { + return commodities[i].ErpSupplierId < commodities[j].ErpSupplierId + }) + default: + // 排序规则:主供应商id小 + sort.Slice(commodities, func(i, j int) bool { + return commodities[i].ErpSupplierId < commodities[j].ErpSupplierId + }) + } + } else { + // 排序规则:主供应商id小 + sort.Slice(commodities, func(i, j int) bool { + return commodities[i].ErpSupplierId < commodities[j].ErpSupplierId + }) + } + } // 批量查询门店信息 stores, err := GetOnlineStores(c) @@ -2505,7 +2561,11 @@ func getErpPurchaseDemandAll(req *GetErpPurchaseDemandReq, c *gin.Context) (*Get if len(demandDataList) == 0 { return nil, errors.New("未查询到数据") } - resp.ExportUrl, err = demandDataExport(demandDataList) + if req.CallType == 2 { // 店员视角 + resp.ExportUrl, err = demandDataExportOnShopAssistant(demandDataList) + } else { // 采购视角 + resp.ExportUrl, err = demandDataExport(demandDataList) + } if err != nil { return nil, err } @@ -2572,6 +2632,9 @@ func getErpPurchaseDemandHide(req *GetErpPurchaseDemandReq, c *gin.Context) (*Ge if req.ErpCommodityName != "" { qs = qs.Where("name=?", req.ErpCommodityName) } + if req.ErpSupplierId != 0 { + qs = qs.Where("erp_supplier_id=?", req.ErpSupplierId) + } var count int64 if err := qs.Count(&count).Error; err != nil { @@ -2580,16 +2643,20 @@ func getErpPurchaseDemandHide(req *GetErpPurchaseDemandReq, c *gin.Context) (*Ge } var commodities []ErpCommodity - if req.IsExport == 1 { // 导出excel - err := qs.Order("id DESC").Find(&commodities).Error - if err != nil && err != RecordNotFound { - return resp, err - } - } else { - err := qs.Order("id DESC").Offset(page * req.PageSize).Limit(req.PageSize).Find(&commodities).Error - if err != nil && err != RecordNotFound { - return resp, err - } + //if req.IsExport == 1 { // 导出excel + // err := qs.Order("id DESC").Find(&commodities).Error + // if err != nil && err != RecordNotFound { + // return resp, err + // } + //} else { + // err := qs.Order("id DESC").Offset(page * req.PageSize).Limit(req.PageSize).Find(&commodities).Error + // if err != nil && err != RecordNotFound { + // return resp, err + // } + //} + err = qs.Order("id DESC").Find(&commodities).Error + if err != nil && err != RecordNotFound { + return resp, err } // 匹配商品id,有则继续查询返回数据,没有则不返回 @@ -2606,6 +2673,48 @@ func getErpPurchaseDemandHide(req *GetErpPurchaseDemandReq, c *gin.Context) (*Ge if len(matchedCommodities) == 0 { resp.List = nil } else { + // 排序 + if req.SortField == "erp_commodity_serial_number" { + switch req.SortType { + case "desc": + SortCommoditiesDesc(matchedCommodities) + case "asc": + SortCommoditiesAsc(matchedCommodities) + default: + SortCommoditiesAsc(matchedCommodities) + } + } else { + // 商品编号排序 + SortCommoditiesAsc(matchedCommodities) + } + + if req.CallType != 2 { + if req.SortField == "erp_supplier_id" { + switch req.SortType { + case "desc": + // 排序规则:主供应商id大 + sort.Slice(matchedCommodities, func(i, j int) bool { + return matchedCommodities[i].ErpSupplierId > matchedCommodities[j].ErpSupplierId + }) + case "asc": + // 排序规则:主供应商id小 + sort.Slice(matchedCommodities, func(i, j int) bool { + return matchedCommodities[i].ErpSupplierId < matchedCommodities[j].ErpSupplierId + }) + default: + // 排序规则:主供应商id小 + sort.Slice(matchedCommodities, func(i, j int) bool { + return matchedCommodities[i].ErpSupplierId < matchedCommodities[j].ErpSupplierId + }) + } + } else { + // 排序规则:主供应商id小 + sort.Slice(matchedCommodities, func(i, j int) bool { + return matchedCommodities[i].ErpSupplierId < matchedCommodities[j].ErpSupplierId + }) + } + } + // 批量查询门店信息 stores, err := GetOnlineStores(c) if err != nil { @@ -2635,12 +2744,22 @@ func getErpPurchaseDemandHide(req *GetErpPurchaseDemandReq, c *gin.Context) (*Ge if len(demandDataList) == 0 { return nil, errors.New("未查询到数据") } - resp.ExportUrl, err = demandDataExport(demandDataList) + if req.CallType == 2 { // 店员视角 + resp.ExportUrl, err = demandDataExportOnShopAssistant(demandDataList) + } else { // 采购视角 + resp.ExportUrl, err = demandDataExport(demandDataList) + } if err != nil { return nil, err } } else { - resp.List = demandDataList + // 计算分页所需的切片索引 + startIndex := page * req.PageSize + endIndex := (page + 1) * req.PageSize + if endIndex > len(demandDataList) { + endIndex = len(demandDataList) + } + resp.List = demandDataList[startIndex:endIndex] resp.Total = int64(len(matchedCommodities)) } } @@ -2660,6 +2779,8 @@ func convertToDemandData(commodity ErpCommodity, stores []Store) (DemandData, er } demandData := DemandData{ + ErpSupplierId: commodity.ErpSupplierId, + ErpSupplierName: commodity.ErpSupplierName, ErpCommodityID: commodity.ID, ErpCommoditySerialNumber: commodity.SerialNumber, ErpCommodityName: commodity.Name, @@ -3014,7 +3135,7 @@ func UpdateRetailPrice(begin *gorm.DB, commodityId uint32, retailPrice float64) return nil } -// 导出采购需求excel +// 导出采购需求excel-采购视角 func demandDataExport(list []DemandData) (string, error) { file := excelize.NewFile() fSheet := "Sheet1" @@ -3024,7 +3145,7 @@ func demandDataExport(list []DemandData) (string, error) { fmt.Println("url fileName:", url+fileName) // 组合标题栏第一行数据 - title1 := []interface{}{"商品编号", "商品名称", "商品分类", "指导零售价", "最近采购价"} + title1 := []interface{}{"主供应商", "商品名称", "商品编号", "商品分类", "指导零售价", "最近采购价"} storeCount := len(list[0].StoreList) var mergeCells []string // 存储需要合并的单元格范围 @@ -3036,8 +3157,8 @@ func demandDataExport(list []DemandData) (string, error) { for i := 0; i < storeCount; i++ { // 计算每个商户名称的起始和结束单元格 - startCol, _ := excelize.ColumnNumberToName(6 + i*3) // 从第6列开始,每个商户占3列 - endCol, _ := excelize.ColumnNumberToName(8 + i*3) + startCol, _ := excelize.ColumnNumberToName(7 + i*3) // 从第7列开始,每个商户占3列 + endCol, _ := excelize.ColumnNumberToName(9 + i*3) mergeCell := startCol + "1:" + endCol + "1" mergeCells = append(mergeCells, mergeCell) } @@ -3053,7 +3174,7 @@ func demandDataExport(list []DemandData) (string, error) { } // 组合标题栏第二行数据 - title2 := []interface{}{"商品编号", "商品名称", "商品分类", "指导零售价", "最近采购价"} + title2 := []interface{}{"主供应商", "商品名称", "商品编号", "商品分类", "指导零售价", "最近采购价"} for _, _ = range list[0].StoreList { title2 = append(title2, "上月销售数") title2 = append(title2, "库存数量") @@ -3083,8 +3204,9 @@ func demandDataExport(list []DemandData) (string, error) { nExcelStartRow := 0 for i := 0; i < len(list); i++ { row = []interface{}{ - list[i].ErpCommoditySerialNumber, // 商品编号 + list[i].ErpSupplierName, // 主供应商名称 list[i].ErpCommodityName, // 商品名称 + list[i].ErpCommoditySerialNumber, // 商品编号 list[i].ErpCategoryName, // 商品分类名称 list[i].RetailPrice, // 指导零售价 list[i].LastWholesalePrice, // 最近采购价 @@ -3111,7 +3233,7 @@ func demandDataExport(list []DemandData) (string, error) { } // 合并 "需采购总数量","需采购总金额" 和 "备注" 列的单元格 - strTotalCountCol, strTotalAmountCol, strRemarkCol := computeExtraColumns("E", storeCount) + strTotalCountCol, strTotalAmountCol, strRemarkCol := computeExtraColumns("F", storeCount) _ = file.MergeCell(fSheet, strTotalCountCol+"1", strTotalCountCol+"2") _ = file.MergeCell(fSheet, strTotalAmountCol+"1", strTotalAmountCol+"2") _ = file.MergeCell(fSheet, strRemarkCol+"1", strRemarkCol+"2") @@ -3132,6 +3254,123 @@ func demandDataExport(list []DemandData) (string, error) { _ = file.MergeCell(fSheet, "C1", "C2") _ = file.MergeCell(fSheet, "D1", "D2") _ = file.MergeCell(fSheet, "E1", "E2") + _ = file.MergeCell(fSheet, "F1", "F2") + + fmt.Println("save fileName:", config.ExportConfig.Path+fileName) + if err := file.SaveAs(config.ExportConfig.Path + fileName); err != nil { + fmt.Println(err) + } + return url + fileName, nil +} + +// 导出采购需求excel-店员视角 +func demandDataExportOnShopAssistant(list []DemandData) (string, error) { + file := excelize.NewFile() + fSheet := "Sheet1" + + url := ExportUrl + fileName := time.Now().Format(TimeFormat) + "采购需求" + ".xlsx" + fmt.Println("url fileName:", url+fileName) + + // 组合标题栏第一行数据 + title1 := []interface{}{"商品名称", "商品编号", "商品分类", "指导零售价"} + storeCount := len(list[0].StoreList) + var mergeCells []string // 存储需要合并的单元格范围 + + for _, v := range list[0].StoreList { + for i := 0; i < 3; i++ { + title1 = append(title1, v.StoreName) + } + } + + for i := 0; i < storeCount; i++ { + // 计算每个商户名称的起始和结束单元格 + startCol, _ := excelize.ColumnNumberToName(5 + i*3) // 从第5列开始,每个商户占3列 + endCol, _ := excelize.ColumnNumberToName(7 + i*3) + mergeCell := startCol + "1:" + endCol + "1" + mergeCells = append(mergeCells, mergeCell) + } + + title1 = append(title1, "备注") + + // 合并单元格 + for _, mergeCell := range mergeCells { + startCell, endCell := splitMergeCellCoordinates(mergeCell) + _ = file.MergeCell(fSheet, startCell, endCell) + } + + // 组合标题栏第二行数据 + title2 := []interface{}{"商品名称", "商品编号", "商品分类", "指导零售价"} + for _, _ = range list[0].StoreList { + title2 = append(title2, "上月销售数") + title2 = append(title2, "库存数量") + title2 = append(title2, "需采购数") + } + title2 = append(title2, "备注") + + for i, _ := range title1 { + cell, _ := excelize.CoordinatesToCellName(1+i, 1) + err := file.SetCellValue(fSheet, cell, title1[i]) + if err != nil { + logger.Error("file set value err:", logger.Field("err", err)) + } + } + + for i, _ := range title2 { + cell, _ := excelize.CoordinatesToCellName(1+i, 2) + err := file.SetCellValue(fSheet, cell, title2[i]) + if err != nil { + logger.Error("file set value err:", logger.Field("err", err)) + } + } + + var row []interface{} + nExcelStartRow := 0 + for i := 0; i < len(list); i++ { + row = []interface{}{ + list[i].ErpCommodityName, // 商品名称 + list[i].ErpCommoditySerialNumber, // 商品编号 + list[i].ErpCategoryName, // 商品分类名称 + list[i].RetailPrice, // 指导零售价 + } + + for _, v := range list[i].StoreList { + row = append(row, v.LastMonthSales) // 上月销售数 + row = append(row, v.StockCount) // 库存数量 + row = append(row, v.NeedCount) // 需采购数 + } + + row = append(row, list[i].Remark) // 备注 + + for j, _ := range row { + cell, _ := excelize.CoordinatesToCellName(1+j, nExcelStartRow+3) + err := file.SetCellValue(fSheet, cell, row[j]) + if err != nil { + logger.Error("file set value err:", logger.Field("err", err)) + } + } + nExcelStartRow++ + } + + // 合并 "需采购总数量","需采购总金额" 和 "备注" 列的单元格 + strTotalCountCol, _, _ := computeExtraColumns("D", storeCount) + _ = file.MergeCell(fSheet, strTotalCountCol+"1", strTotalCountCol+"2") + + // 设置所有单元格的样式: 居中、加边框 + style, _ := file.NewStyle(`{"alignment":{"horizontal":"center","vertical":"center"}, + "border":[{"type":"left","color":"000000","style":1}, + {"type":"top","color":"000000","style":1}, + {"type":"right","color":"000000","style":1}, + {"type":"bottom","color":"000000","style":1}]}`) + + endRow := fmt.Sprintf(strTotalCountCol+"%d", nExcelStartRow+2) + // 应用样式到整个表格 + _ = file.SetCellStyle("Sheet1", "A1", endRow, style) + + _ = file.MergeCell(fSheet, "A1", "A2") + _ = file.MergeCell(fSheet, "B1", "B2") + _ = file.MergeCell(fSheet, "C1", "C2") + _ = file.MergeCell(fSheet, "D1", "D2") fmt.Println("save fileName:", config.ExportConfig.Path+fileName) if err := file.SaveAs(config.ExportConfig.Path + fileName); err != nil { @@ -5048,26 +5287,27 @@ func GetReportBySupplier(req *ErpPurchaseReportBySupplierReq, c *gin.Context) ( return false // 默认情况下相等 }) - // 分页处理 - startIdx := (resp.PageIndex - 1) * resp.PageSize - endIdx := resp.PageIndex * resp.PageSize - - // 确保不超出索引范围 - if startIdx >= len(mergedData) { - resp.List = []PurchaseReportData{} - } else if endIdx > len(mergedData) { - resp.List = mergedData[startIdx:] - } else { - resp.List = mergedData[startIdx:endIdx] - } - if req.IsExport == 1 { + resp.List = mergedData filePath, err := reportBySupplierExport(resp) if err != nil { return nil, err } resp = &ErpPurchaseReportBySupplierResp{} resp.ExportUrl = filePath + } else { + // 分页处理 + startIdx := (resp.PageIndex - 1) * resp.PageSize + endIdx := resp.PageIndex * resp.PageSize + + // 确保不超出索引范围 + if startIdx >= len(mergedData) { + resp.List = []PurchaseReportData{} + } else if endIdx > len(mergedData) { + resp.List = mergedData[startIdx:] + } else { + resp.List = mergedData[startIdx:endIdx] + } } return resp, nil diff --git a/app/admin/models/store.go b/app/admin/models/store.go index 141b5de..4c3414f 100644 --- a/app/admin/models/store.go +++ b/app/admin/models/store.go @@ -114,7 +114,8 @@ func (m *GetStoreReq) List() ([]Store, int64, error) { // } // m.CooperativeBusinessId = sysUser.CooperativeBusinessId //} - qs := orm.Eloquent.Table("store").Where("member_service = ?", 1) + //qs := orm.Eloquent.Table("store").Where("member_service = ?", 1) + qs := orm.Eloquent.Table("store") if m.Name != "" { qs = qs.Where("name LIKE '%" + m.Name + "%'") } diff --git a/app/admin/models/supplier.go b/app/admin/models/supplier.go index 3b2924d..1ccefc1 100644 --- a/app/admin/models/supplier.go +++ b/app/admin/models/supplier.go @@ -11,23 +11,32 @@ import ( type Supplier struct { Model - Number string `json:"number" gorm:"index"` //编号 - Name string `json:"name"` //供应商名称 - Contact string `json:"contact"` //联系人 - Tel string `json:"tel"` //手机号 - Province string `json:"province"` //省 - City string `json:"city"` //市 - Area string `json:"area"` //区 - Address string `json:"address"` //详细地址 - AccountHolder string `json:"account_holder"` //开户人 - OpeningBank string `json:"opening_bank"` //开户银行 - BankAccount string `json:"bank_account"` //银行账号 - PaymentCycle uint32 `json:"payment_cycle"` //支付周期 - TaxNumber string `json:"tax_number"` //税号 - Landline string `json:"landline"` //固定电话 - Email string `json:"email"` //邮件 - CompanyWebsite string `json:"company_website"` //网站 - CooperativeBusinessId uint32 `json:"cooperative_business_id"` //合作商id + Number string `json:"number" gorm:"index"` // 编号 + Name string `json:"name"` // 供应商名称 + Province string `json:"province"` // 省 + City string `json:"city"` // 市 + Area string `json:"area"` // 区 + Address string `json:"address"` // 详细地址 + Contact string `json:"contact"` // 联系人 + Tel string `json:"tel"` // 手机号 + Landline string `json:"landline"` // 座机电话 + Email string `json:"email"` // 电子邮件 + CompanyWebsite string `json:"company_website"` // 公司网址 + PaymentCycle uint32 `json:"payment_cycle"` // 付款周期/天 + TaxNumber string `json:"tax_number"` // 税号 + CooperativeBusinessId uint32 `json:"cooperative_business_id"` // 合作商id + AccountHolder string `json:"account_holder"` // 开户人 + OpeningBank string `json:"opening_bank"` // 开户银行 + BankAccount string `json:"bank_account"` // 银行账号 + BankData string `gorm:"type:json" json:"bank_data,omitempty"` // 开户银行信息 + BankList []SupplierBankInfo `json:"bank_list" gorm:"-" ` // 开户银行信息列表 +} + +// SupplierBankInfo 开户银行信息列表 +type SupplierBankInfo struct { + AccountHolder string `json:"account_holder"` // 开户人 + OpeningBank string `json:"opening_bank"` // 开户银行 + BankAccount string `json:"bank_account"` // 银行账号 } func (s *Supplier) TableName() string { @@ -75,5 +84,13 @@ func GetSupplier(req GetSupplierRequest) ([]*Supplier, error) { return nil, err } + // 反序列化 BankData + for i, v := range list { + if list[i].BankData != "" { + list[i].BankList = DeserializeBankData(v.BankData) + list[i].BankData = "" + } + } + return list, nil } diff --git a/app/admin/models/sysuser.go b/app/admin/models/sysuser.go index b847b27..6b6c94d 100644 --- a/app/admin/models/sysuser.go +++ b/app/admin/models/sysuser.go @@ -340,6 +340,16 @@ func deserializeStoreData(storeData string) []StoreInfo { return StoreData } +// DeserializeBankData 反序列化 BankData +func DeserializeBankData(bankData string) []SupplierBankInfo { + var BankData []SupplierBankInfo + if err := json.Unmarshal([]byte(bankData), &BankData); err != nil { + // 可以根据实际情况处理反序列化失败的情况 + log.Println("反序列化 BankData 失败:", err) + } + return BankData +} + // 加密 func (e *SysUser) Encrypt() (err error) { if e.Password == "" { diff --git a/docs/docs.go b/docs/docs.go index 884c845..08f2fb7 100644 --- a/docs/docs.go +++ b/docs/docs.go @@ -1151,8 +1151,7 @@ const docTemplate = `{ "application/json" ], "tags": [ - "决策中心", - "V1.4.0" + "决策中心,V1.4.0" ], "summary": "进销存报表", "parameters": [ @@ -2286,8 +2285,7 @@ const docTemplate = `{ "application/json" ], "tags": [ - "采购需求", - "V1.3.0" + "采购需求,V1.4.1" ], "summary": "创建采购需求", "parameters": [ @@ -2320,8 +2318,7 @@ const docTemplate = `{ "application/json" ], "tags": [ - "采购需求", - "V1.3.0" + "采购需求,V1.4.1" ], "summary": "完成采购需求", "parameters": [ @@ -2354,8 +2351,7 @@ const docTemplate = `{ "application/json" ], "tags": [ - "采购需求", - "V1.3.0" + "采购需求,V1.4.1" ], "summary": "获取采购需求", "parameters": [ @@ -5246,7 +5242,7 @@ const docTemplate = `{ "application/json" ], "tags": [ - "供应商管理" + "供应商管理,V1.4.1" ], "summary": "创建供应商", "parameters": [ @@ -5276,7 +5272,7 @@ const docTemplate = `{ "application/json" ], "tags": [ - "供应商管理" + "供应商管理,V1.4.1" ], "summary": "删除供应商", "parameters": [ @@ -5304,7 +5300,7 @@ const docTemplate = `{ "application/json" ], "tags": [ - "供应商管理" + "供应商管理,V1.4.1" ], "summary": "供应商详情", "parameters": [ @@ -5335,7 +5331,7 @@ const docTemplate = `{ "application/json" ], "tags": [ - "供应商管理" + "供应商管理,V1.4.1" ], "summary": "供应商列表", "parameters": [ @@ -5371,7 +5367,7 @@ const docTemplate = `{ "application/json" ], "tags": [ - "供应商管理" + "供应商管理,V1.4.1" ], "summary": "更新供应商", "parameters": [ @@ -6300,6 +6296,13 @@ const docTemplate = `{ "description": "银行卡号", "type": "string" }, + "bank_list": { + "description": "开户银行信息列表", + "type": "array", + "items": { + "$ref": "#/definitions/models.SupplierBankInfo" + } + }, "city": { "description": "城市", "type": "string" @@ -6391,6 +6394,13 @@ const docTemplate = `{ "description": "银行卡号", "type": "string" }, + "bank_list": { + "description": "开户银行信息列表", + "type": "array", + "items": { + "$ref": "#/definitions/models.SupplierBankInfo" + } + }, "city": { "description": "城市", "type": "string" @@ -7432,6 +7442,10 @@ const docTemplate = `{ "description": "商品编号", "type": "string" }, + "erp_supplier_id": { + "description": "主供应商id", + "type": "integer" + }, "list": { "type": "array", "items": { @@ -7648,6 +7662,10 @@ const docTemplate = `{ "description": "商品编号", "type": "string" }, + "erp_supplier_id": { + "description": "主供应商id", + "type": "integer" + }, "last_wholesale_price": { "description": "最近采购价", "type": "number" @@ -9007,11 +9025,11 @@ const docTemplate = `{ }, "staff_cost_price": { "description": "员工成本价加价(如:加价50,不是加价后的价格)", - "type": "integer" + "type": "number" }, "staff_price": { "description": "员工成本价", - "type": "integer" + "type": "number" }, "staff_profit": { "description": "员工毛利:实际零售价-员工成本价;如果为退货订单,则为实际退货价-员工成本价", @@ -9023,7 +9041,7 @@ const docTemplate = `{ }, "wholesale_price": { "description": "指导采购价", - "type": "integer" + "type": "number" } } }, @@ -9320,6 +9338,10 @@ const docTemplate = `{ "totalRetailP": { "description": "零售价合计", "type": "number" + }, + "uid": { + "description": "用户id", + "type": "integer" } } }, @@ -11545,6 +11567,10 @@ const docTemplate = `{ "models.GetErpPurchaseDemandReq": { "type": "object", "properties": { + "call_type": { + "description": "调用类型:1-采购视角;2-店员视角", + "type": "integer" + }, "erp_category_id": { "description": "商品分类id", "type": "integer" @@ -11557,6 +11583,10 @@ const docTemplate = `{ "description": "商品编号", "type": "string" }, + "erp_supplier_id": { + "description": "主供应商id", + "type": "integer" + }, "hide_flag": { "description": "隐藏标记(默认关闭):ON-开启,隐藏无采购需求的商品,OFF-关闭,展示所有", "type": "string" @@ -11572,6 +11602,14 @@ const docTemplate = `{ "pageSize": { "description": "每页展示数据条数", "type": "integer" + }, + "sort_field": { + "description": "排序字段:主供应商 erp_supplier_id; 商品编号 erp_commodity_serial_number", + "type": "string" + }, + "sort_type": { + "description": "排序类型:desc 降序、asc 升序", + "type": "string" } } }, @@ -12996,6 +13034,10 @@ const docTemplate = `{ "description": "描述", "type": "string" }, + "erp_order_id": { + "description": "零售订单id", + "type": "integer" + }, "event": { "description": "事件", "type": "string" @@ -14537,6 +14579,10 @@ const docTemplate = `{ "description": "商品名称", "type": "string" }, + "commodity_serial_number": { + "description": "商品编号", + "type": "string" + }, "count": { "description": "数量", "type": "integer" @@ -15045,12 +15091,23 @@ const docTemplate = `{ "description": "银行账号", "type": "string" }, + "bank_data": { + "description": "开户银行信息", + "type": "string" + }, + "bank_list": { + "description": "开户银行信息列表", + "type": "array", + "items": { + "$ref": "#/definitions/models.SupplierBankInfo" + } + }, "city": { "description": "市", "type": "string" }, "company_website": { - "description": "网站", + "description": "公司网址", "type": "string" }, "contact": { @@ -15066,7 +15123,7 @@ const docTemplate = `{ "type": "string" }, "email": { - "description": "邮件", + "description": "电子邮件", "type": "string" }, "id": { @@ -15074,7 +15131,7 @@ const docTemplate = `{ "type": "integer" }, "landline": { - "description": "固定电话", + "description": "座机电话", "type": "string" }, "name": { @@ -15090,7 +15147,7 @@ const docTemplate = `{ "type": "string" }, "payment_cycle": { - "description": "支付周期", + "description": "付款周期/天", "type": "integer" }, "province": { @@ -15107,6 +15164,23 @@ const docTemplate = `{ } } }, + "models.SupplierBankInfo": { + "type": "object", + "properties": { + "account_holder": { + "description": "开户人", + "type": "string" + }, + "bank_account": { + "description": "银行账号", + "type": "string" + }, + "opening_bank": { + "description": "开户银行", + "type": "string" + } + } + }, "models.SysCategory": { "type": "object", "properties": { diff --git a/docs/swagger.json b/docs/swagger.json index 1a76ce3..5d60b2c 100644 --- a/docs/swagger.json +++ b/docs/swagger.json @@ -1140,8 +1140,7 @@ "application/json" ], "tags": [ - "决策中心", - "V1.4.0" + "决策中心,V1.4.0" ], "summary": "进销存报表", "parameters": [ @@ -2275,8 +2274,7 @@ "application/json" ], "tags": [ - "采购需求", - "V1.3.0" + "采购需求,V1.4.1" ], "summary": "创建采购需求", "parameters": [ @@ -2309,8 +2307,7 @@ "application/json" ], "tags": [ - "采购需求", - "V1.3.0" + "采购需求,V1.4.1" ], "summary": "完成采购需求", "parameters": [ @@ -2343,8 +2340,7 @@ "application/json" ], "tags": [ - "采购需求", - "V1.3.0" + "采购需求,V1.4.1" ], "summary": "获取采购需求", "parameters": [ @@ -5235,7 +5231,7 @@ "application/json" ], "tags": [ - "供应商管理" + "供应商管理,V1.4.1" ], "summary": "创建供应商", "parameters": [ @@ -5265,7 +5261,7 @@ "application/json" ], "tags": [ - "供应商管理" + "供应商管理,V1.4.1" ], "summary": "删除供应商", "parameters": [ @@ -5293,7 +5289,7 @@ "application/json" ], "tags": [ - "供应商管理" + "供应商管理,V1.4.1" ], "summary": "供应商详情", "parameters": [ @@ -5324,7 +5320,7 @@ "application/json" ], "tags": [ - "供应商管理" + "供应商管理,V1.4.1" ], "summary": "供应商列表", "parameters": [ @@ -5360,7 +5356,7 @@ "application/json" ], "tags": [ - "供应商管理" + "供应商管理,V1.4.1" ], "summary": "更新供应商", "parameters": [ @@ -6289,6 +6285,13 @@ "description": "银行卡号", "type": "string" }, + "bank_list": { + "description": "开户银行信息列表", + "type": "array", + "items": { + "$ref": "#/definitions/models.SupplierBankInfo" + } + }, "city": { "description": "城市", "type": "string" @@ -6380,6 +6383,13 @@ "description": "银行卡号", "type": "string" }, + "bank_list": { + "description": "开户银行信息列表", + "type": "array", + "items": { + "$ref": "#/definitions/models.SupplierBankInfo" + } + }, "city": { "description": "城市", "type": "string" @@ -7421,6 +7431,10 @@ "description": "商品编号", "type": "string" }, + "erp_supplier_id": { + "description": "主供应商id", + "type": "integer" + }, "list": { "type": "array", "items": { @@ -7637,6 +7651,10 @@ "description": "商品编号", "type": "string" }, + "erp_supplier_id": { + "description": "主供应商id", + "type": "integer" + }, "last_wholesale_price": { "description": "最近采购价", "type": "number" @@ -8996,11 +9014,11 @@ }, "staff_cost_price": { "description": "员工成本价加价(如:加价50,不是加价后的价格)", - "type": "integer" + "type": "number" }, "staff_price": { "description": "员工成本价", - "type": "integer" + "type": "number" }, "staff_profit": { "description": "员工毛利:实际零售价-员工成本价;如果为退货订单,则为实际退货价-员工成本价", @@ -9012,7 +9030,7 @@ }, "wholesale_price": { "description": "指导采购价", - "type": "integer" + "type": "number" } } }, @@ -9309,6 +9327,10 @@ "totalRetailP": { "description": "零售价合计", "type": "number" + }, + "uid": { + "description": "用户id", + "type": "integer" } } }, @@ -11534,6 +11556,10 @@ "models.GetErpPurchaseDemandReq": { "type": "object", "properties": { + "call_type": { + "description": "调用类型:1-采购视角;2-店员视角", + "type": "integer" + }, "erp_category_id": { "description": "商品分类id", "type": "integer" @@ -11546,6 +11572,10 @@ "description": "商品编号", "type": "string" }, + "erp_supplier_id": { + "description": "主供应商id", + "type": "integer" + }, "hide_flag": { "description": "隐藏标记(默认关闭):ON-开启,隐藏无采购需求的商品,OFF-关闭,展示所有", "type": "string" @@ -11561,6 +11591,14 @@ "pageSize": { "description": "每页展示数据条数", "type": "integer" + }, + "sort_field": { + "description": "排序字段:主供应商 erp_supplier_id; 商品编号 erp_commodity_serial_number", + "type": "string" + }, + "sort_type": { + "description": "排序类型:desc 降序、asc 升序", + "type": "string" } } }, @@ -12985,6 +13023,10 @@ "description": "描述", "type": "string" }, + "erp_order_id": { + "description": "零售订单id", + "type": "integer" + }, "event": { "description": "事件", "type": "string" @@ -14526,6 +14568,10 @@ "description": "商品名称", "type": "string" }, + "commodity_serial_number": { + "description": "商品编号", + "type": "string" + }, "count": { "description": "数量", "type": "integer" @@ -15034,12 +15080,23 @@ "description": "银行账号", "type": "string" }, + "bank_data": { + "description": "开户银行信息", + "type": "string" + }, + "bank_list": { + "description": "开户银行信息列表", + "type": "array", + "items": { + "$ref": "#/definitions/models.SupplierBankInfo" + } + }, "city": { "description": "市", "type": "string" }, "company_website": { - "description": "网站", + "description": "公司网址", "type": "string" }, "contact": { @@ -15055,7 +15112,7 @@ "type": "string" }, "email": { - "description": "邮件", + "description": "电子邮件", "type": "string" }, "id": { @@ -15063,7 +15120,7 @@ "type": "integer" }, "landline": { - "description": "固定电话", + "description": "座机电话", "type": "string" }, "name": { @@ -15079,7 +15136,7 @@ "type": "string" }, "payment_cycle": { - "description": "支付周期", + "description": "付款周期/天", "type": "integer" }, "province": { @@ -15096,6 +15153,23 @@ } } }, + "models.SupplierBankInfo": { + "type": "object", + "properties": { + "account_holder": { + "description": "开户人", + "type": "string" + }, + "bank_account": { + "description": "银行账号", + "type": "string" + }, + "opening_bank": { + "description": "开户银行", + "type": "string" + } + } + }, "models.SysCategory": { "type": "object", "properties": { diff --git a/docs/swagger.yaml b/docs/swagger.yaml index 09d1bfa..812c385 100644 --- a/docs/swagger.yaml +++ b/docs/swagger.yaml @@ -135,6 +135,11 @@ definitions: bank_account: description: 银行卡号 type: string + bank_list: + description: 开户银行信息列表 + items: + $ref: '#/definitions/models.SupplierBankInfo' + type: array city: description: 城市 type: string @@ -203,6 +208,11 @@ definitions: bank_account: description: 银行卡号 type: string + bank_list: + description: 开户银行信息列表 + items: + $ref: '#/definitions/models.SupplierBankInfo' + type: array city: description: 城市 type: string @@ -968,6 +978,9 @@ definitions: erp_commodity_serial_number: description: 商品编号 type: string + erp_supplier_id: + description: 主供应商id + type: integer list: items: properties: @@ -1126,6 +1139,9 @@ definitions: erp_commodity_serial_number: description: 商品编号 type: string + erp_supplier_id: + description: 主供应商id + type: integer last_wholesale_price: description: 最近采购价 type: number @@ -2120,10 +2136,10 @@ definitions: type: number staff_cost_price: description: 员工成本价加价(如:加价50,不是加价后的价格) - type: integer + type: number staff_price: description: 员工成本价 - type: integer + type: number staff_profit: description: 员工毛利:实际零售价-员工成本价;如果为退货订单,则为实际退货价-员工成本价 type: number @@ -2132,7 +2148,7 @@ definitions: type: number wholesale_price: description: 指导采购价 - type: integer + type: number type: object models.ErpOrderCreateReq: properties: @@ -2349,6 +2365,9 @@ definitions: totalRetailP: description: 零售价合计 type: number + uid: + description: 用户id + type: integer type: object models.ErpOrderRetailDetailReq: properties: @@ -3962,6 +3981,9 @@ definitions: type: object models.GetErpPurchaseDemandReq: properties: + call_type: + description: 调用类型:1-采购视角;2-店员视角 + type: integer erp_category_id: description: 商品分类id type: integer @@ -3971,6 +3993,9 @@ definitions: erp_commodity_serial_number: description: 商品编号 type: string + erp_supplier_id: + description: 主供应商id + type: integer hide_flag: description: 隐藏标记(默认关闭):ON-开启,隐藏无采购需求的商品,OFF-关闭,展示所有 type: string @@ -3983,6 +4008,12 @@ definitions: pageSize: description: 每页展示数据条数 type: integer + sort_field: + description: 排序字段:主供应商 erp_supplier_id; 商品编号 erp_commodity_serial_number + type: string + sort_type: + description: 排序类型:desc 降序、asc 升序 + type: string type: object models.GetErpPurchaseDemandResp: properties: @@ -5007,6 +5038,9 @@ definitions: describe: description: 描述 type: string + erp_order_id: + description: 零售订单id + type: integer event: description: 事件 type: string @@ -6108,6 +6142,9 @@ definitions: commodity_name: description: 商品名称 type: string + commodity_serial_number: + description: 商品编号 + type: string count: description: 数量 type: integer @@ -6476,11 +6513,19 @@ definitions: bank_account: description: 银行账号 type: string + bank_data: + description: 开户银行信息 + type: string + bank_list: + description: 开户银行信息列表 + items: + $ref: '#/definitions/models.SupplierBankInfo' + type: array city: description: 市 type: string company_website: - description: 网站 + description: 公司网址 type: string contact: description: 联系人 @@ -6492,13 +6537,13 @@ definitions: description: 创建时间 type: string email: - description: 邮件 + description: 电子邮件 type: string id: description: 数据库记录编号 type: integer landline: - description: 固定电话 + description: 座机电话 type: string name: description: 供应商名称 @@ -6510,7 +6555,7 @@ definitions: description: 开户银行 type: string payment_cycle: - description: 支付周期 + description: 付款周期/天 type: integer province: description: 省 @@ -6522,6 +6567,18 @@ definitions: description: 手机号 type: string type: object + models.SupplierBankInfo: + properties: + account_holder: + description: 开户人 + type: string + bank_account: + description: 银行账号 + type: string + opening_bank: + description: 开户银行 + type: string + type: object models.SysCategory: properties: createBy: @@ -8402,8 +8459,7 @@ paths: $ref: '#/definitions/models.ErpDecisionReportResp' summary: 进销存报表 tags: - - 决策中心 - - V1.4.0 + - 决策中心,V1.4.0 /api/v1/dept: post: consumes: @@ -9119,8 +9175,7 @@ paths: $ref: '#/definitions/app.Response' summary: 创建采购需求 tags: - - 采购需求 - - V1.3.0 + - 采购需求,V1.4.1 /api/v1/erp_purchase/demand/finish: post: consumes: @@ -9141,8 +9196,7 @@ paths: $ref: '#/definitions/app.Response' summary: 完成采购需求 tags: - - 采购需求 - - V1.3.0 + - 采购需求,V1.4.1 /api/v1/erp_purchase/demand/get: post: consumes: @@ -9163,8 +9217,7 @@ paths: $ref: '#/definitions/models.GetErpPurchaseDemandResp' summary: 获取采购需求 tags: - - 采购需求 - - V1.3.0 + - 采购需求,V1.4.1 /api/v1/erp_purchase/detail: post: consumes: @@ -11004,7 +11057,7 @@ paths: $ref: '#/definitions/models.Supplier' summary: 创建供应商 tags: - - 供应商管理 + - 供应商管理,V1.4.1 /api/v1/supplier/delete/{id}: delete: parameters: @@ -11022,7 +11075,7 @@ paths: $ref: '#/definitions/app.Response' summary: 删除供应商 tags: - - 供应商管理 + - 供应商管理,V1.4.1 /api/v1/supplier/detail/{id}: get: parameters: @@ -11040,7 +11093,7 @@ paths: $ref: '#/definitions/models.Supplier' summary: 供应商详情 tags: - - 供应商管理 + - 供应商管理,V1.4.1 /api/v1/supplier/list: post: consumes: @@ -11063,7 +11116,7 @@ paths: type: array summary: 供应商列表 tags: - - 供应商管理 + - 供应商管理,V1.4.1 /api/v1/supplier/update: post: consumes: @@ -11084,7 +11137,7 @@ paths: $ref: '#/definitions/app.Response' summary: 更新供应商 tags: - - 供应商管理 + - 供应商管理,V1.4.1 /api/v1/sys/tables/info: post: consumes: