3 Star 2 Fork 1

fotomxq/weeekj_core

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
克隆/下载
delete.go 2.15 KB
一键复制 编辑 原始数据 按行查看 历史
fotomxq 提交于 2025-02-05 18:52 +08:00 . 修改项目路径;
package ERPPermanentAssets
import (
"errors"
CoreSQLConfig "gitee.com/fotomxq/weeekj_core/v5/core/sql/config"
"math"
"time"
)
// ArgsCreateDelete 销毁记录参数
type ArgsCreateDelete struct {
//创建时间/盘点时间
CreateAt time.Time `db:"create_at" json:"createAt" check:"defaultTime"`
//组织ID
OrgID int64 `db:"org_id" json:"orgID" check:"id" empty:"true"`
//操作人
OrgBindID int64 `db:"org_bind_id" json:"orgBindID" check:"id"`
//资产ID
ProductID int64 `db:"product_id" json:"productID" check:"id"`
//增加或减少数量
Count int64 `db:"count" json:"count" check:"int64Than0"`
//存放地点
SavePlace string `db:"save_place" json:"savePlace"`
//备注
Des string `db:"des" json:"des" check:"des" min:"0" max:"3000" empty:"true"`
//扩展参数
Params CoreSQLConfig.FieldsConfigsType `db:"params" json:"params"`
}
// CreateDelete 销毁记录
func CreateDelete(args *ArgsCreateDelete) (errCode string, err error) {
productData := getProductByID(args.ProductID)
if productData.ID < 1 {
errCode = "err_erp_permanent_assets_product_no_data"
err = errors.New("product no data")
return
}
if args.Count > productData.Count-productData.UseCount {
errCode = "err_erp_permanent_assets_product_too_more_delete"
err = errors.New("no more count")
return
}
targetDeleteCount := productData.Count - args.Count
if targetDeleteCount < productData.UseCount {
errCode = "err_erp_permanent_assets_product_too_more_delete_use"
err = errors.New("no more use count")
return
}
err = createLog(&argsCreateLog{
CreateAt: args.CreateAt,
OrgID: args.OrgID,
OrgBindID: args.OrgBindID,
ProductID: args.ProductID,
Mode: "delete",
UseName: "",
UseOrgBindID: 0,
AllPrice: int64(math.Abs(float64(productData.NowPerPrice * args.Count))),
PerPrice: productData.NowPerPrice,
Count: args.Count,
SavePlace: "",
Des: args.Des,
Params: args.Params,
})
if err != nil {
errCode = "err_insert"
return
}
err = updateProductCount(&argsUpdateProductCount{
ID: productData.ID,
Count: targetDeleteCount,
})
if err != nil {
errCode = "err_update"
return
}
return
}
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
Go
1
https://gitee.com/fotomxq/weeekj_core.git
git@gitee.com:fotomxq/weeekj_core.git
fotomxq
weeekj_core
weeekj_core
v5.3.83

搜索帮助