From 7e45690f1f93c1139f11d05a36271e8b3196b7b1 Mon Sep 17 00:00:00 2001 From: huangjiajun <582604932@qq.com> Date: Sat, 30 Mar 2024 17:40:36 +0800 Subject: [PATCH] =?UTF-8?q?1.ipad=E7=AB=AF=E8=B0=83=E6=95=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/admin/hdl/goods/hdl_goods_list.go | 1 + app/admin/md/md_goods_list.go | 1 + app/admin/svc/svc_make_record.go | 4 +-- app/db/db_goods_list.go | 3 ++ app/db/db_order_goods_doing.go | 14 ++------- app/db/db_staff.go | 20 +++++++++++++ app/db/model/order_goods.go | 27 ++++++++++------- app/db/model/order_goods_doing.go | 23 -------------- app/ipad/svc/svc_order_make.go | 43 +++++++-------------------- app/ipad/svc/svc_responsible.go | 6 ++-- 10 files changed, 60 insertions(+), 82 deletions(-) delete mode 100644 app/db/model/order_goods_doing.go diff --git a/app/admin/hdl/goods/hdl_goods_list.go b/app/admin/hdl/goods/hdl_goods_list.go index ee8bb8f..e101f2a 100644 --- a/app/admin/hdl/goods/hdl_goods_list.go +++ b/app/admin/hdl/goods/hdl_goods_list.go @@ -12,6 +12,7 @@ import ( func GetMallGoodsList(c *gin.Context) { var args md.MallGoodsListReq args.Title = c.Query("title") + args.Name = c.Query("name") args.CategoryId = c.Query("category_id") args.SaleState = c.Query("sale_state") args.PageId = c.Query("page") diff --git a/app/admin/md/md_goods_list.go b/app/admin/md/md_goods_list.go index 2946854..46980f5 100644 --- a/app/admin/md/md_goods_list.go +++ b/app/admin/md/md_goods_list.go @@ -15,6 +15,7 @@ import ( // PageSize 每页显示记录数 type MallGoodsListReq struct { Title string `json:"title"` + Name string `json:"name"` CategoryId string `json:"category_id"` SkuCode string `json:"sku_code"` SaleState string `json:"sale_state"` diff --git a/app/admin/svc/svc_make_record.go b/app/admin/svc/svc_make_record.go index d553899..cc27d1c 100644 --- a/app/admin/svc/svc_make_record.go +++ b/app/admin/svc/svc_make_record.go @@ -27,7 +27,7 @@ func MarkRecord(c *gin.Context) { adminIds = append(adminIds, v.AdminId) } enterpriseMap := db.GetEnterpriseMore(eg, enterpriseIds) - adminMap := db.GetAdminMore(eg, adminIds) + adminMap := db.GetStaffMore(eg, adminIds) for _, v := range *list { enterpriseName := "" @@ -38,7 +38,7 @@ func MarkRecord(c *gin.Context) { } _, ok1 := adminMap[v.AdminId] if ok1 { - adminName = adminMap[v.AdminId].Memo + adminName = adminMap[v.AdminId].Name } var tmp = map[string]string{ diff --git a/app/db/db_goods_list.go b/app/db/db_goods_list.go index 0ab6c7e..fe391c9 100644 --- a/app/db/db_goods_list.go +++ b/app/db/db_goods_list.go @@ -126,6 +126,9 @@ func GetMallGoodsListLeftOnMallSku(engine *xorm.Engine, req *md.MallGoodsListReq if req.Title != "" { whereCondition += " AND mg.title LIKE '%" + req.Title + "%'" } + if req.Name != "" { + whereCondition += " AND mg.title LIKE '%" + req.Name + "%'" + } if req.SaleState == "1" { // 销售中 whereCondition = whereCondition + " AND mg.sale_state = 1" diff --git a/app/db/db_order_goods_doing.go b/app/db/db_order_goods_doing.go index 3729534..6229cc1 100644 --- a/app/db/db_order_goods_doing.go +++ b/app/db/db_order_goods_doing.go @@ -6,17 +6,9 @@ import ( "xorm.io/xorm" ) -func GetOrderGoodsByRecordId(eg *xorm.Engine, id string) *model.OrderGoodsDoing { - var order model.OrderGoodsDoing - get, err := eg.Where("record_id=?", id).Get(&order) - if get == false || err != nil { - return nil - } - return &order -} -func GetOrderGoodsDoingList(eg *xorm.Engine, param map[string]string) (*[]model.OrderGoodsDoing, int64) { - var order []model.OrderGoodsDoing - sess := eg.Where("1=1") +func GetOrderGoodsDoingList(eg *xorm.Engine, param map[string]string) (*[]model.OrderGoods, int64) { + var order []model.OrderGoods + sess := eg.Where("state!=0 and state!=5") if param["admin_name"] != "" { var data []model.Admin eg.Where("memo like ?", "%"+param["admin_name"]+"%") diff --git a/app/db/db_staff.go b/app/db/db_staff.go index 7108a00..526971f 100644 --- a/app/db/db_staff.go +++ b/app/db/db_staff.go @@ -76,3 +76,23 @@ func (staffDb *StaffDb) StaffDelete(id interface{}) (int64, error) { return Db.Where("id = ?", id).Delete(model.Staff{}) } } +func GetStaff(eg *xorm.Engine) *[]model.Staff { + var data []model.Staff + err := eg.Where("1=1").Find(&data) + if err != nil { + return nil + } + return &data +} +func GetStaffMore(eg *xorm.Engine, ids []int) map[int]model.Staff { + + data := make(map[int]model.Staff) + if len(ids) > 0 { + list := make([]model.Staff, 0) + eg.In("id", ids).Find(&list) + for _, v := range list { + data[v.Id] = v + } + } + return data +} diff --git a/app/db/model/order_goods.go b/app/db/model/order_goods.go index f212be5..8779aa6 100644 --- a/app/db/model/order_goods.go +++ b/app/db/model/order_goods.go @@ -1,14 +1,21 @@ package model +import "time" + type OrderGoods struct { - Id int `json:"id" xorm:"not null pk autoincr INT(11)"` - Oid int64 `json:"oid" xorm:"default 0 comment('订单号') BIGINT(20)"` - GoodsId int64 `json:"goods_id" xorm:"default 0 comment('商品id') BIGINT(20)"` - SkuId int64 `json:"sku_id" xorm:"default 0 comment('sku') BIGINT(20)"` - Num int `json:"num" xorm:"default 0 comment('购买数量') INT(11)"` - Price string `json:"price" xorm:"default 0.00 comment('单价') DECIMAL(20,2)"` - State int `json:"state" xorm:"default 0 comment('状态 0待制作 1制作中 2烘焙中 3分拣中 4已完成 ') INT(11)"` - SkuCode string `json:"sku_code" xorm:"VARCHAR(255)"` - GoodsTitle string `json:"goods_title" xorm:"comment('商品标题') VARCHAR(255)"` - Sku string `json:"sku" xorm:"comment('规格数据') VARCHAR(1000)"` + Id int `json:"id" xorm:"not null pk autoincr INT(11)"` + Oid int64 `json:"oid" xorm:"default 0 comment('订单号') BIGINT(20)"` + GoodsId int64 `json:"goods_id" xorm:"default 0 comment('商品id') BIGINT(20)"` + SkuId int64 `json:"sku_id" xorm:"default 0 comment('sku') BIGINT(20)"` + Num int `json:"num" xorm:"default 0 comment('购买数量') INT(11)"` + Price string `json:"price" xorm:"default 0.00 comment('单价') DECIMAL(20,2)"` + State int `json:"state" xorm:"default 0 comment('状态 0待制作 1制作中 2烘焙中 3分拣中 4已完成 ') INT(11)"` + SkuCode string `json:"sku_code" xorm:"VARCHAR(255)"` + GoodsTitle string `json:"goods_title" xorm:"comment('商品标题') VARCHAR(255)"` + Sku string `json:"sku" xorm:"comment('规格数据') VARCHAR(1000)"` + SuccessNum int `json:"success_num" xorm:"comment('完成数量') INT(11)"` + Memo string `json:"memo" xorm:"comment('制作完成备注') VARCHAR(255)"` + Time time.Time `json:"time" xorm:"DATETIME"` + AdminId int `json:"admin_id" xorm:"default 0 comment('admin 的id') INT(11)"` + EnterpriseId int `json:"enterprise_id" xorm:"default 0 comment('校企 的id') INT(11)"` } diff --git a/app/db/model/order_goods_doing.go b/app/db/model/order_goods_doing.go deleted file mode 100644 index e426056..0000000 --- a/app/db/model/order_goods_doing.go +++ /dev/null @@ -1,23 +0,0 @@ -package model - -import ( - "time" -) - -type OrderGoodsDoing struct { - Id int `json:"id" xorm:"not null pk autoincr INT(11)"` - Oid int64 `json:"oid" xorm:"default 0 comment('订单号') BIGINT(20)"` - GoodsId int64 `json:"goods_id" xorm:"default 0 comment('商品id') BIGINT(20)"` - SkuId int64 `json:"sku_id" xorm:"default 0 comment('sku') BIGINT(20)"` - Num int `json:"num" xorm:"default 0 comment('购买数量') INT(11)"` - State int `json:"state" xorm:"default 0 comment('状态 1开始制作 2制作完成烘焙开始 3烘焙完成分拣开始 4已完成 ') INT(11)"` - SkuCode string `json:"sku_code" xorm:"VARCHAR(255)"` - GoodsTitle string `json:"goods_title" xorm:"comment('商品标题') VARCHAR(255)"` - Sku string `json:"sku" xorm:"comment('规格数据') VARCHAR(1000)"` - SuccessNum int `json:"success_num" xorm:"comment('完成数量') INT(11)"` - Memo string `json:"memo" xorm:"comment('制作完成备注') VARCHAR(255)"` - Time time.Time `json:"time" xorm:"DATETIME"` - RecordId int `json:"record_id" xorm:"default 0 comment('order_goods 的id') INT(11)"` - AdminId int `json:"admin_id" xorm:"default 0 comment('admin 的id') INT(11)"` - EnterpriseId int `json:"enterprise_id" xorm:"default 0 comment('校企 的id') INT(11)"` -} diff --git a/app/ipad/svc/svc_order_make.go b/app/ipad/svc/svc_order_make.go index 1305d1b..56731d8 100644 --- a/app/ipad/svc/svc_order_make.go +++ b/app/ipad/svc/svc_order_make.go @@ -51,7 +51,7 @@ func OrderSortingEnd(c *gin.Context) { sess := eg.NewSession() defer sess.Close() sess.Begin() - order := db.GetOrderGoodsByIdSess(sess, args.Oid) + order := db.GetOrderByIdSess(sess, args.Oid) if order == nil { sess.Rollback() e.OutErr(c, 400, e.NewErr(400, "订单查找失败,请重试")) @@ -64,7 +64,7 @@ func OrderSortingEnd(c *gin.Context) { } //修改制作记录 for _, v := range args.GoodsInfo { - record := db.GetOrderGoodsByRecordId(eg, v["id"]) + record := db.GetOrderGoodsByIdSess(sess, v["id"]) record.SuccessNum = utils.StrToInt(v["num"]) record.State = 4 record.AdminId = utils.StrToInt(args.AdminId) @@ -82,7 +82,7 @@ func OrderSortingEnd(c *gin.Context) { Memo: "", SuccessNum: utils.StrToInt(v["num"]), Time: time.Now(), - RecordId: record.RecordId, + RecordId: record.Id, AdminId: utils.StrToInt(args.AdminId), } one, err := sess.InsertOne(recordFlow) @@ -127,40 +127,17 @@ func commMake(c *gin.Context, args map[string]string) { e.OutErr(c, 400, e.NewErr(400, "订单查找失败,请重试")) return } - record := db.GetOrderGoodsByRecordId(eg, args["id"]) if orderGoods.State >= state { sess.Rollback() e.OutErr(c, 400, e.NewErr(400, "该商品已在"+args["str"]+"中")) return } - if record == nil { - record = &model.OrderGoodsDoing{ - Oid: orderGoods.Oid, - GoodsId: orderGoods.GoodsId, - SkuId: orderGoods.SkuId, - Num: orderGoods.Num, - State: state, - SkuCode: orderGoods.SkuCode, - GoodsTitle: orderGoods.GoodsTitle, - Sku: orderGoods.Sku, - Time: time.Now(), - RecordId: orderGoods.Id, - EnterpriseId: order.EnterpriseId, - AdminId: utils.StrToInt(args["admin_id"]), - } - one, err := sess.InsertOne(record) - if one == 0 || err != nil { - sess.Rollback() - e.OutErr(c, 400, e.NewErr(400, "提交失败,请重试")) - return - } - } - record.SuccessNum = utils.StrToInt(args["num"]) - record.Memo = args["memo"] - record.State = state - record.AdminId = utils.StrToInt(args["admin_id"]) - record.Time = time.Now() - _, err := sess.Where("id=?", record.Id).Cols("success_num,memo,state,time").Update(record) + orderGoods.SuccessNum = utils.StrToInt(args["num"]) + orderGoods.Memo = args["memo"] + orderGoods.State = state + orderGoods.AdminId = utils.StrToInt(args["admin_id"]) + orderGoods.Time = time.Now() + _, err := sess.Where("id=?", orderGoods.Id).Cols("success_num,memo,state,time").Update(orderGoods) if err != nil { sess.Rollback() e.OutErr(c, 400, e.NewErr(400, "提交失败,请重试")) @@ -173,7 +150,7 @@ func commMake(c *gin.Context, args map[string]string) { Memo: args["memo"], SuccessNum: utils.StrToInt(args["num"]), Time: time.Now(), - RecordId: record.RecordId, + RecordId: orderGoods.Id, AdminId: utils.StrToInt(args["admin_id"]), } one, err := sess.InsertOne(recordFlow) diff --git a/app/ipad/svc/svc_responsible.go b/app/ipad/svc/svc_responsible.go index 7f7e7f6..bb071fc 100644 --- a/app/ipad/svc/svc_responsible.go +++ b/app/ipad/svc/svc_responsible.go @@ -9,12 +9,12 @@ import ( func Responsible(c *gin.Context) { list := make([]map[string]string, 0) - admin := db.GetAllAdmin(db.Db) + admin := db.GetStaff(db.Db) if admin != nil { for _, v := range *admin { var tmp = map[string]string{ - "id": utils.IntToStr(v.AdmId), - "name": v.Memo, + "id": utils.IntToStr(v.Id), + "name": v.Name, } list = append(list, tmp) }