1.修改查询收付款列表接口,默认所有门店都返回系统内置收款方式;
2.修改库存导入接口时间格式校验错误时的提示信息。
This commit is contained in:
parent
ae2d54b2fa
commit
b9186b3dfe
|
@ -171,6 +171,13 @@ func CashierList(c *gin.Context) {
|
|||
return
|
||||
}
|
||||
|
||||
if req.StoreId != 0 { // 门店id非空时进行校验
|
||||
if !models.IsExistingStoreById(int(req.StoreId)) {
|
||||
app.Error(c, http.StatusBadRequest, errors.New("该门店id不存在,请传正确的门店id"), "该门店id不存在,请传正确的门店id")
|
||||
return
|
||||
}
|
||||
}
|
||||
|
||||
list, err := models.GetAccountList(int(req.StoreId), req.PageSize, req.PageIndex)
|
||||
if err != nil {
|
||||
app.Error(c, http.StatusBadRequest, err, err.Error())
|
||||
|
|
|
@ -282,10 +282,10 @@ func GetAccountList(storeId, pageSize, pageIndex int) (*ErpCashierListResp, erro
|
|||
limit := pageSize
|
||||
|
||||
//resp.Total = int(count)/pageSize + 1
|
||||
var categories []ErpCashier
|
||||
var cashiers []ErpCashier
|
||||
|
||||
if storeId == 0 { // 只查询账号信息
|
||||
err = qs.Order("id DESC").Offset(offset).Limit(limit).Find(&categories).Error
|
||||
err = qs.Order("id DESC").Offset(offset).Limit(limit).Find(&cashiers).Error
|
||||
} else { // 查询账号信息及其关联的门店
|
||||
var storeCashiers []ErpStoreCashier
|
||||
err = qs.Order("erp_cashier_id DESC").Offset(offset).Limit(limit).Find(&storeCashiers).Error
|
||||
|
@ -298,7 +298,7 @@ func GetAccountList(storeId, pageSize, pageIndex int) (*ErpCashierListResp, erro
|
|||
Type: v.Type,
|
||||
}
|
||||
temp.Model.ID = v.ErpCashierId
|
||||
categories = append(categories, temp)
|
||||
cashiers = append(cashiers, temp)
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -307,7 +307,19 @@ func GetAccountList(storeId, pageSize, pageIndex int) (*ErpCashierListResp, erro
|
|||
return nil, fmt.Errorf("query err:%v", err)
|
||||
}
|
||||
|
||||
resp.List = categories
|
||||
if storeId != 0 {
|
||||
//添加默认的账号信息
|
||||
defaultCashier, err := setDefaultCashier()
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
for _, item := range defaultCashier {
|
||||
cashiers = append(cashiers, item)
|
||||
}
|
||||
}
|
||||
|
||||
resp.List = cashiers
|
||||
|
||||
//跟之前保持一致
|
||||
resp.Total = int(count)
|
||||
|
@ -317,6 +329,18 @@ func GetAccountList(storeId, pageSize, pageIndex int) (*ErpCashierListResp, erro
|
|||
return &resp, nil
|
||||
}
|
||||
|
||||
// 添加默认的收付款账号信息
|
||||
func setDefaultCashier() ([]ErpCashier, error) {
|
||||
var cashierList []ErpCashier
|
||||
err := orm.Eloquent.Table("erp_cashier").Order("id DESC").Where("id IN (1,2,3,4)").
|
||||
Find(&cashierList).Error
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return cashierList, nil
|
||||
}
|
||||
|
||||
// GetAccountDetail 查询账号详情
|
||||
func GetAccountDetail(cashierId int) (*ErpCashierDetail, error) {
|
||||
// 查账号信息
|
||||
|
|
|
@ -464,7 +464,7 @@ func checkStockExcel(sheetCols [][]string) error {
|
|||
if sheetCols[7][i] != "" {
|
||||
parsedTime, err := time.Parse("2006/1/2", sheetCols[7][i])
|
||||
if err != nil {
|
||||
return errors.New("第" + strconv.Itoa(i+1) + "行入库时间格式错误,应为YYYY-MM-DD")
|
||||
return errors.New("第" + strconv.Itoa(i+1) + "行入库时间格式错误,请设置单元格格式为日期:YYYY/MM/DD")
|
||||
}
|
||||
// 格式化时间为指定格式
|
||||
formattedTime := parsedTime.Format(DateTimeFormat)
|
||||
|
@ -576,6 +576,16 @@ func isExistingStore(storeName string) bool {
|
|||
return count > 0
|
||||
}
|
||||
|
||||
func IsExistingStoreById(storeId int) bool {
|
||||
// 实现门店是否存在的逻辑
|
||||
var count int64
|
||||
orm.Eloquent.Debug().Model(&Store{}).
|
||||
Where("id = ?", storeId).
|
||||
Count(&count)
|
||||
|
||||
return count > 0
|
||||
}
|
||||
|
||||
func isExistingSupplier(supplierName string) bool {
|
||||
// 实现供应商是否存在的逻辑
|
||||
var count int64
|
||||
|
|
Loading…
Reference in New Issue
Block a user