From 7e3904b5fafbd6db71e6a13f698284e3e934a64a Mon Sep 17 00:00:00 2001 From: huangjiajun <582604932@qq.com> Date: Thu, 28 Mar 2024 16:22:26 +0800 Subject: [PATCH 1/2] =?UTF-8?q?1.ipad=E7=AB=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/admin/hdl/order/hdl_make_record.go | 13 ++ app/admin/svc/order/svc_order_list.go | 13 +- app/admin/svc/svc_make_record.go | 68 ++++++++ app/db/db_admin.go | 21 +++ app/db/db_enterprise.go | 20 +++ app/db/db_order_goods_doing.go | 54 +++++++ app/db/db_order_goods_list.go | 45 ++++++ app/db/db_order_list.go | 41 +++-- app/db/model/order.go | 2 +- app/db/model/order_goods.go | 10 +- app/db/model/order_goods_doing.go | 23 +++ app/db/model/order_goods_doing_flow.go | 16 ++ app/ipad/hdl/hdl_demo.go | 12 ++ app/ipad/hdl/hdl_login.go | 59 +++++++ app/ipad/hdl/hdl_order.go | 23 +++ app/ipad/hdl/hdl_order_goods.go | 70 +++++++++ app/ipad/hdl/hdl_order_make.go | 19 +++ app/ipad/hdl/hdl_responsible.go | 10 ++ app/ipad/lib/auth/auth.go | 6 +- app/ipad/lib/auth/base.go | 6 +- app/ipad/md/md_app_redis_key.go | 2 +- app/ipad/md/md_login.go | 22 +-- app/ipad/md/md_order.go | 7 + app/ipad/mw/mw_auth.go | 30 ++++ app/ipad/svc/svc_auth.go | 30 ++-- app/ipad/svc/svc_login.go | 5 +- app/ipad/svc/svc_order.go | 46 ++++++ app/ipad/svc/svc_order_goods.go | 7 + app/ipad/svc/svc_order_make.go | 206 +++++++++++++++++++++++++ app/ipad/svc/svc_responsible.go | 24 +++ app/router/admin_router.go | 17 +- app/router/ipad_router.go | 17 +- 32 files changed, 858 insertions(+), 86 deletions(-) create mode 100644 app/admin/hdl/order/hdl_make_record.go create mode 100644 app/admin/svc/svc_make_record.go create mode 100644 app/db/db_order_goods_doing.go create mode 100644 app/db/db_order_goods_list.go create mode 100644 app/db/model/order_goods_doing.go create mode 100644 app/db/model/order_goods_doing_flow.go create mode 100644 app/ipad/hdl/hdl_demo.go create mode 100644 app/ipad/hdl/hdl_login.go create mode 100644 app/ipad/hdl/hdl_order.go create mode 100644 app/ipad/hdl/hdl_order_goods.go create mode 100644 app/ipad/hdl/hdl_order_make.go create mode 100644 app/ipad/hdl/hdl_responsible.go create mode 100644 app/ipad/md/md_order.go create mode 100644 app/ipad/mw/mw_auth.go create mode 100644 app/ipad/svc/svc_order.go create mode 100644 app/ipad/svc/svc_order_goods.go create mode 100644 app/ipad/svc/svc_order_make.go create mode 100644 app/ipad/svc/svc_responsible.go diff --git a/app/admin/hdl/order/hdl_make_record.go b/app/admin/hdl/order/hdl_make_record.go new file mode 100644 index 0000000..99bebbe --- /dev/null +++ b/app/admin/hdl/order/hdl_make_record.go @@ -0,0 +1,13 @@ +package order + +import ( + "applet/app/admin/svc" + "github.com/gin-gonic/gin" +) + +func MarkRecord(c *gin.Context) { + svc.MarkRecord(c) +} +func MarkRecordFlow(c *gin.Context) { + svc.MarkRecordFlow(c) +} diff --git a/app/admin/svc/order/svc_order_list.go b/app/admin/svc/order/svc_order_list.go index b542c32..cb7f6c6 100644 --- a/app/admin/svc/order/svc_order_list.go +++ b/app/admin/svc/order/svc_order_list.go @@ -23,19 +23,12 @@ func OrderList(c *gin.Context) { list, total := db.GetOrderList(eg, args) data := make([]map[string]string, 0) if list != nil { - stateArr := []string{"待制作", "制作中", "烘焙中", "分拣中", "已完成", "已取消"} + stateArr := []string{"待制作", "制作中", "制作完成", "烘焙完成", "分拣完成", "已取消"} enterpriseIds := make([]int, 0) for _, v := range *list { enterpriseIds = append(enterpriseIds, v.EnterpriseId) } - enterpriseMap := make(map[int]model.Enterprise) - if len(enterpriseIds) > 0 { - enterpriseData := make([]model.Enterprise, 0) - eg.In("id", enterpriseIds).Find(&enterpriseData) - for _, v := range enterpriseData { - enterpriseMap[v.Id] = v - } - } + enterpriseMap := db.GetEnterpriseMore(eg, enterpriseIds) for _, v := range *list { v1 := JudgePackageOrdOrdState(&v) isCanCancel := "1" @@ -264,7 +257,7 @@ func OrderDetail(c *gin.Context) { if skuStr != "" { skuStr += ";" } - skuStr += v1.Name + ":" + v1.Value + skuStr += v1.Value } tmp["sku_str"] = skuStr diff --git a/app/admin/svc/svc_make_record.go b/app/admin/svc/svc_make_record.go new file mode 100644 index 0000000..8fe0a58 --- /dev/null +++ b/app/admin/svc/svc_make_record.go @@ -0,0 +1,68 @@ +package svc + +import ( + "applet/app/db" + "applet/app/e" + "applet/app/utils" + "github.com/gin-gonic/gin" +) + +func MarkRecord(c *gin.Context) { + var args map[string]string + if err := c.ShouldBindJSON(&args); err != nil { + e.OutErr(c, e.ERR_INVALID_ARGS, err) + return + } + eg := db.Db + list, total := db.GetOrderGoodsDoingList(eg, args) + data := make([]map[string]string, 0) + if list != nil { + stateArr := []string{"待制作", "制作中", "制作完成", "烘焙完成", "分拣完成", "已取消"} + enterpriseIds := make([]int, 0) + adminIds := make([]int, 0) + for _, v := range *list { + enterpriseIds = append(enterpriseIds, v.EnterpriseId) + adminIds = append(adminIds, v.AdminId) + } + enterpriseMap := db.GetEnterpriseMore(eg, enterpriseIds) + adminMap := db.GetAdminMore(eg, adminIds) + + for _, v := range *list { + enterpriseName := "" + adminName := "" + _, ok := enterpriseMap[v.EnterpriseId] + if ok { + enterpriseName = enterpriseMap[v.EnterpriseId].Name + } + _, ok1 := adminMap[v.AdminId] + if ok1 { + adminName = adminMap[v.AdminId].Memo + } + var tmp = map[string]string{ + "oid": utils.Int64ToStr(v.Oid), + "id": utils.IntToStr(v.Id), + "state_str": stateArr[v.State], + "state": utils.IntToStr(v.State), + "time": v.Time.Format("2006-01-02 15:04:05"), + "enterprise_name": enterpriseName, + "sku_str": v.Sku, + "goods_title": v.GoodsTitle, + "memo": v.Memo, + "admin_name": adminName, + "num": utils.IntToStr(v.Num), + "success_num": utils.IntToStr(v.SuccessNum), + } + data = append(data, tmp) + } + } + + res := map[string]interface{}{ + "total": total, + "list": data, + } + e.OutSuc(c, res, nil) + return +} +func MarkRecordFlow(c *gin.Context) { + +} diff --git a/app/db/db_admin.go b/app/db/db_admin.go index c921f5f..134ad03 100644 --- a/app/db/db_admin.go +++ b/app/db/db_admin.go @@ -120,3 +120,24 @@ func (adminDb *AdminDb) AdminInsert(m *model.Admin) (int64, error) { } return insertAffected, nil } + +func GetAllAdmin(eg *xorm.Engine) *[]model.Admin { + var data []model.Admin + err := eg.Where("is_super_administrator=?", 0).Find(&data) + if err != nil { + return nil + } + return &data +} +func GetAdminMore(eg *xorm.Engine, ids []int) map[int]model.Admin { + + data := make(map[int]model.Admin) + if len(ids) > 0 { + list := make([]model.Admin, 0) + eg.In("id", ids).Find(&list) + for _, v := range list { + data[v.AdmId] = v + } + } + return data +} diff --git a/app/db/db_enterprise.go b/app/db/db_enterprise.go index 6991974..0be7a5f 100644 --- a/app/db/db_enterprise.go +++ b/app/db/db_enterprise.go @@ -76,3 +76,23 @@ func (enterpriseDb *EnterpriseDb) EnterpriseUpdate(m *model.Enterprise, columns } return affected, nil } +func GetEnterpriseMore(eg *xorm.Engine, enterpriseIds []int) map[int]model.Enterprise { + + enterpriseMap := make(map[int]model.Enterprise) + if len(enterpriseIds) > 0 { + enterpriseData := make([]model.Enterprise, 0) + eg.In("id", enterpriseIds).Find(&enterpriseData) + for _, v := range enterpriseData { + enterpriseMap[v.Id] = v + } + } + return enterpriseMap +} +func GetEnterpriseList(eg *xorm.Engine) *[]model.Enterprise { + var data []model.Enterprise + err := eg.Where("1=1").Find(&data) + if err != nil { + return nil + } + return &data +} diff --git a/app/db/db_order_goods_doing.go b/app/db/db_order_goods_doing.go new file mode 100644 index 0000000..fb0ba20 --- /dev/null +++ b/app/db/db_order_goods_doing.go @@ -0,0 +1,54 @@ +package db + +import ( + "applet/app/db/model" + "applet/app/utils" + "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") + if param["enterprise_name"] != "" { + var data []model.Enterprise + eg.Where("name like ?", "%"+param["enterprise_name"]+"%") + ids := []int{-1} + for _, v := range data { + ids = append(ids, v.Id) + } + sess.In("enterprise_id", ids) + } + if param["oid"] != "" { + sess.And("oid like ?", "%"+param["oid"]+"%") + } + if param["state"] != "" { + sess.And("state =?", param["state"]) + } + if param["admin_id"] != "" { + sess.And("admin_id =?", param["admin_id"]) + } + if param["goods_title"] != "" { + sess.And("goods_title like ?", "%"+param["goods_title"]+"%") + } + if param["start_time"] != "" { + sess.And("time>=?", param["start_time"]) + } + if param["end_time"] != "" { + sess.And("time<=?", param["end_time"]) + } + size := utils.StrToInt(param["limit"]) + start := (utils.StrToInt(param["page"]) - 1) * size + count, err := sess.Limit(size, start).OrderBy("time desc,id desc").FindAndCount(&order) + if err != nil { + return nil, count + } + return &order, count +} diff --git a/app/db/db_order_goods_list.go b/app/db/db_order_goods_list.go new file mode 100644 index 0000000..b2cc48c --- /dev/null +++ b/app/db/db_order_goods_list.go @@ -0,0 +1,45 @@ +package db + +import ( + "applet/app/db/model" + "applet/app/utils" + "xorm.io/xorm" +) + +func GetOrderGoodsListByIpad(eg *xorm.Engine, param map[string]string) (*[]model.OrderGoods, int64) { + var order []model.OrderGoods + sess := eg.Where("state!=5") + + if param["oid"] != "" { + sess.And("oid = ?", param["oid"]) + } + if param["state"] != "" { + sess.And("state =?", param["state"]) + } + if param["keyword"] != "" { + sess.And("goods_title like ?", "%"+param["keyword"]+"%") + } + size := utils.StrToInt(param["limit"]) + start := (utils.StrToInt(param["page"]) - 1) * size + count, err := sess.Limit(size, start).OrderBy("id asc").FindAndCount(&order) + if err != nil { + return nil, count + } + return &order, count +} +func GetOrderGoodsById(eg *xorm.Engine, id string) *model.OrderGoods { + var order model.OrderGoods + get, err := eg.Where("id=?", id).Get(&order) + if get == false || err != nil { + return nil + } + return &order +} +func GetOrderGoodsByIdSess(sess *xorm.Session, id string) *model.OrderGoods { + var order model.OrderGoods + get, err := sess.Where("id=?", id).Get(&order) + if get == false || err != nil { + return nil + } + return &order +} diff --git a/app/db/db_order_list.go b/app/db/db_order_list.go index d35c0f2..5ff66f1 100644 --- a/app/db/db_order_list.go +++ b/app/db/db_order_list.go @@ -3,6 +3,7 @@ package db import ( "applet/app/db/model" "applet/app/utils" + "github.com/syyongx/php2go" "xorm.io/xorm" ) @@ -14,9 +15,9 @@ func GetOrderById(eg *xorm.Engine, id string) *model.Order { } return &order } -func GetOrderGoodsById(eg *xorm.Engine, id string) *model.OrderGoods { - var order model.OrderGoods - get, err := eg.Where("id=?", id).Get(&order) +func GetOrderByIdSess(sess *xorm.Session, id string) *model.Order { + var order model.Order + get, err := sess.Where("oid=?", id).Get(&order) if get == false || err != nil { return nil } @@ -31,14 +32,6 @@ func GetOrderGoodsBySkuId(eg *xorm.Engine, oid, skuId string) *model.OrderGoods return &order } -func GetOrderGoodsByIdSess(sess *xorm.Session, id string) *model.OrderGoods { - var order model.OrderGoods - get, err := sess.Where("id=?", id).Get(&order) - if get == false || err != nil { - return nil - } - return &order -} func GetOrderGoodsBySkuIdSess(sess *xorm.Session, oid, skuId string) *model.OrderGoods { var order model.OrderGoods get, err := sess.Where("oid=? and sku_id=?", oid, skuId).Get(&order) @@ -57,7 +50,7 @@ func GetOrderList(eg *xorm.Engine, param map[string]string) (*[]model.Order, int sess.And("oid like ?", "%"+param["oid"]+"%") } if param["state"] != "" { - sess.And("state =", param["state"]) + sess.And("state =?", param["state"]) } if param["goods_title"] != "" { var orderGoods []model.OrderGoods @@ -76,3 +69,27 @@ func GetOrderList(eg *xorm.Engine, param map[string]string) (*[]model.Order, int } return &order, count } +func GetOrderListByIpad(eg *xorm.Engine, param map[string]string) (*[]model.Order, int64) { + var order []model.Order + sess := eg.Where("state!=5") + + if param["keyword"] != "" { + var data []model.Enterprise + eg.Where("name like ?", "%"+param["keyword"]+"%").Find(&data) + ids := []string{"-1"} + for _, v := range data { + ids = append(ids, utils.IntToStr(v.Id)) + } + sess.And("enterprise_id in (?) or oid like ?", php2go.Implode(",", ids), "%"+param["keyword"]+"%") + } + if param["state"] != "" { + sess.And("state =?", param["state"]) + } + size := utils.StrToInt(param["limit"]) + start := (utils.StrToInt(param["page"]) - 1) * size + count, err := sess.Limit(size, start).OrderBy("id asc").FindAndCount(&order) + if err != nil { + return nil, count + } + return &order, count +} diff --git a/app/db/model/order.go b/app/db/model/order.go index 371b90c..e904a5c 100644 --- a/app/db/model/order.go +++ b/app/db/model/order.go @@ -13,5 +13,5 @@ type Order struct { EnterpriseId int `json:"enterprise_id" xorm:"default 0 comment('校企id') INT(11)"` BuyInfo string `json:"buy_info" xorm:"comment('购买人信息 json') VARCHAR(2000)"` Amount string `json:"amount" xorm:"default 0.00 comment('付款金额') DECIMAL(20,2)"` - BuyPhone string `json:"buy_phone" xorm:"comment('购买人手机 ') VARCHAR(20)"` + BuyPhone string `json:"buy_phone" xorm:"comment('购买人手机') VARCHAR(20)"` } diff --git a/app/db/model/order_goods.go b/app/db/model/order_goods.go index 27595bc..f212be5 100644 --- a/app/db/model/order_goods.go +++ b/app/db/model/order_goods.go @@ -3,12 +3,12 @@ package model 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') INT(11)"` - SkuId int64 `json:"sku_id" xorm:"default 0 comment('sku') INT(255)"` + 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)"` - SkuCode string `json:"sku_code" xorm:"default 0.00 comment('') VARCHAR(255)"` - Sku string `json:"sku_code" xorm:"default 0.00 comment('') VARCHAR(255)"` - GoodsTitle string `json:"goods_title" xorm:"default 0.00 comment('') VARCHAR(255)"` 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)"` } diff --git a/app/db/model/order_goods_doing.go b/app/db/model/order_goods_doing.go new file mode 100644 index 0000000..e426056 --- /dev/null +++ b/app/db/model/order_goods_doing.go @@ -0,0 +1,23 @@ +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/db/model/order_goods_doing_flow.go b/app/db/model/order_goods_doing_flow.go new file mode 100644 index 0000000..7848cb3 --- /dev/null +++ b/app/db/model/order_goods_doing_flow.go @@ -0,0 +1,16 @@ +package model + +import ( + "time" +) + +type OrderGoodsDoingFlow struct { + Id int `json:"id" xorm:"not null pk autoincr INT(11)"` + Num int `json:"num" xorm:"default 0 comment('购买数量') INT(11)"` + State int `json:"state" xorm:"default 0 comment('状态 1开始制作 2制作完成烘焙开始 3烘焙完成分拣开始 4已完成 ') INT(11)"` + 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_doing 的id') INT(11)"` + AdminId int `json:"admin_id" xorm:"default 0 comment('admin 的id') INT(11)"` +} diff --git a/app/ipad/hdl/hdl_demo.go b/app/ipad/hdl/hdl_demo.go new file mode 100644 index 0000000..5fa37f6 --- /dev/null +++ b/app/ipad/hdl/hdl_demo.go @@ -0,0 +1,12 @@ +package hdl + +import ( + "applet/app/e" + "github.com/gin-gonic/gin" +) + +// Demo 测试 +func Demo(c *gin.Context) { + e.OutSuc(c, "success", nil) + return +} diff --git a/app/ipad/hdl/hdl_login.go b/app/ipad/hdl/hdl_login.go new file mode 100644 index 0000000..9385da4 --- /dev/null +++ b/app/ipad/hdl/hdl_login.go @@ -0,0 +1,59 @@ +package hdl + +import ( + "applet/app/e" + "applet/app/enum" + "applet/app/ipad/lib/validate" + "applet/app/ipad/md" + "applet/app/ipad/svc" + svc2 "applet/app/svc" + "applet/app/utils" + "fmt" + "github.com/gin-gonic/gin" +) + +func Login(c *gin.Context) { + var req md.LoginReq + err := c.ShouldBindJSON(&req) + if err != nil { + err = validate.HandleValidateErr(err) + err1 := err.(e.E) + e.OutErr(c, err1.Code, err1.Error()) + return + } + sysCfg := svc2.SysCfgFind(enum.ProductionWorkshopAccount, enum.ProductionWorkshopPassword) + if sysCfg[enum.ProductionWorkshopAccount] == "" || sysCfg[enum.ProductionWorkshopPassword] == "" { + e.OutErr(c, e.ERR_NO_DATA, "用户信息不存在") + return + } + + if sysCfg[enum.ProductionWorkshopAccount] != req.Account || sysCfg[enum.ProductionWorkshopPassword] != req.Password { + e.OutErr(c, e.ERR_NO_DATA, "账号或密码错误") + return + } + + ip := utils.GetIP(c.Request) + key := fmt.Sprintf(md.UserJwtTokenKey, ip) + token, err := svc.HandleLoginToken(key, &md.User{ + Account: req.Account, + Password: req.Password, + }) + if err != nil { + e.OutErr(c, e.ERR, err.Error()) + return + } + e.OutSuc(c, md.LoginResponse{ + Token: token, + }, nil) + return +} + +func UserInfo(c *gin.Context) { + //1、获取用户信息 + userInfo := svc.GetUser(c) + + e.OutSuc(c, map[string]interface{}{ + "user_info": userInfo, + }, nil) + return +} diff --git a/app/ipad/hdl/hdl_order.go b/app/ipad/hdl/hdl_order.go new file mode 100644 index 0000000..7f71ae8 --- /dev/null +++ b/app/ipad/hdl/hdl_order.go @@ -0,0 +1,23 @@ +package hdl + +import ( + "applet/app/e" + "applet/app/ipad/svc" + "github.com/gin-gonic/gin" +) + +func OrderCate(c *gin.Context) { + var res = []map[string]string{ + {"name": "全部", "id": ""}, + {"name": "待制作", "id": "0"}, + {"name": "制作中", "id": "1"}, + {"name": "待烘焙", "id": "2"}, + {"name": "待分拣", "id": "3"}, + {"name": "已完成", "id": "4"}, + } + e.OutSuc(c, res, nil) + return +} +func Order(c *gin.Context) { + svc.Order(c) +} diff --git a/app/ipad/hdl/hdl_order_goods.go b/app/ipad/hdl/hdl_order_goods.go new file mode 100644 index 0000000..99d0b51 --- /dev/null +++ b/app/ipad/hdl/hdl_order_goods.go @@ -0,0 +1,70 @@ +package hdl + +import ( + "applet/app/admin/md" + "applet/app/db" + "applet/app/e" + "applet/app/svc" + "applet/app/utils" + "encoding/json" + "github.com/gin-gonic/gin" +) + +func OrderGoods(c *gin.Context) { + var args map[string]string + if err := c.ShouldBindJSON(&args); err != nil { + e.OutErr(c, e.ERR_INVALID_ARGS, err) + return + } + eg := db.Db + data, _ := db.GetOrderGoodsListByIpad(eg, args) + list := make([]map[string]string, 0) + if data != nil { + gids := make([]int64, 0) + for _, v := range *data { + gids = append(gids, v.GoodsId) + } + goodsMap := db.GetGoodsMore(eg, gids) + scheme, host, subDomain, moreSubDomain := svc.ImageBucketNew(c) + var tmpMap interface{} + stateArr := []string{"待制作", "制作中", "烘焙中", "分拣中", "已完成", "已取消"} + btnArr := []string{"开始制作", "制作中", "制作完成", "烘焙完成", "分拣完成", "已取消"} + for _, v := range *data { + var tmp = map[string]string{ + "oid": utils.Int64ToStr(v.Oid), + "id": utils.IntToStr(v.Id), + "num": utils.IntToStr(v.Num), + "state_str": stateArr[v.State], + "btn_str": btnArr[v.State], + "goods_title": v.GoodsTitle, + "goods_img": "", + "state": utils.IntToStr(v.State), + } + // 商品主图 + if goodsMap[v.GoodsId].ImageList != "" { + utils.Unserialize([]byte(goodsMap[v.GoodsId].ImageList), &tmpMap) + var imageListUrlTmp []string + for _, v := range tmpMap.([]interface{}) { + imageListUrlTmp = append(imageListUrlTmp, svc.ImageFormatWithBucketNew(scheme, host, subDomain, moreSubDomain, v.(string))) + } + if imageListUrlTmp != nil { + tmp["goods_img"] = imageListUrlTmp[0] + } + } + skuData := make([]md.Sku, 0) + json.Unmarshal([]byte(v.Sku), &skuData) + skuStr := "" + for _, v1 := range skuData { + if skuStr != "" { + skuStr += ";" + } + skuStr += v1.Value + } + tmp["sku_str"] = skuStr + list = append(list, tmp) + } + } + + e.OutSuc(c, list, nil) + return +} diff --git a/app/ipad/hdl/hdl_order_make.go b/app/ipad/hdl/hdl_order_make.go new file mode 100644 index 0000000..4a6ae21 --- /dev/null +++ b/app/ipad/hdl/hdl_order_make.go @@ -0,0 +1,19 @@ +package hdl + +import ( + "applet/app/ipad/svc" + "github.com/gin-gonic/gin" +) + +func OrderMakeBegin(c *gin.Context) { + svc.OrderMakeBegin(c) +} +func OrderMakeEnd(c *gin.Context) { + svc.OrderMakeEnd(c) +} +func OrderBakingEnd(c *gin.Context) { + svc.OrderBakingEnd(c) +} +func OrderSortingEnd(c *gin.Context) { + svc.OrderSortingEnd(c) +} diff --git a/app/ipad/hdl/hdl_responsible.go b/app/ipad/hdl/hdl_responsible.go new file mode 100644 index 0000000..183978a --- /dev/null +++ b/app/ipad/hdl/hdl_responsible.go @@ -0,0 +1,10 @@ +package hdl + +import ( + "applet/app/ipad/svc" + "github.com/gin-gonic/gin" +) + +func Responsible(c *gin.Context) { + svc.Responsible(c) +} diff --git a/app/ipad/lib/auth/auth.go b/app/ipad/lib/auth/auth.go index 662eda1..903a68f 100644 --- a/app/ipad/lib/auth/auth.go +++ b/app/ipad/lib/auth/auth.go @@ -7,11 +7,11 @@ import ( ) // GenToken 生成JWT -func GenToken(userId int, username string) (string, error) { +func GenToken(account, password string) (string, error) { // 创建一个我们自己的声明 c := JWTUser{ - UserId: userId, - Username: username, + Account: account, + Password: password, StandardClaims: jwt.StandardClaims{ ExpiresAt: time.Now().Add(TokenExpireDuration).Unix(), // 过期时间 Issuer: "bakery", // 签发人 diff --git a/app/ipad/lib/auth/base.go b/app/ipad/lib/auth/base.go index 9a85e81..ff1c346 100644 --- a/app/ipad/lib/auth/base.go +++ b/app/ipad/lib/auth/base.go @@ -9,11 +9,11 @@ import ( // TokenExpireDuration is jwt 过期时间 const TokenExpireDuration = time.Hour * 4380 -var Secret = []byte("bakery_customer") +var Secret = []byte("bakery_big_data") // JWTUser 如果想要保存更多信息,都可以添加到这个结构体中 type JWTUser struct { - UserId int `json:"user_id"` - Username string `json:"username"` + Account string `json:"account"` + Password string `json:"password"` jwt.StandardClaims } diff --git a/app/ipad/md/md_app_redis_key.go b/app/ipad/md/md_app_redis_key.go index 72dde4d..4a19581 100644 --- a/app/ipad/md/md_app_redis_key.go +++ b/app/ipad/md/md_app_redis_key.go @@ -2,6 +2,6 @@ package md // 缓存key统一管理 const ( - UserJwtTokenKey = "%s:bakery_user_jwt_token:%s" // jwt, 占位符:ip, user:id + UserJwtTokenKey = "%s:bakery_production_workshop_user_jwt_token" // jwt, 占位符:ip, user:id JwtTokenCacheTime = 3600 * 24 * 1 ) diff --git a/app/ipad/md/md_login.go b/app/ipad/md/md_login.go index 9d5f2b7..bccdb11 100644 --- a/app/ipad/md/md_login.go +++ b/app/ipad/md/md_login.go @@ -1,23 +1,15 @@ package md type LoginReq struct { - Phone string `json:"phone" binding:"required" label:"登录手机号"` + Account string `json:"account" binding:"required" label:"账号"` + Password string `json:"password" binding:"required" label:"密码"` } -type LoginResponse struct { - Token string `json:"token"` -} - -type WxAppletLoginResponse struct { - OpenId string `json:"open_id"` - UnionId string `json:"union_id"` +type User struct { + Account string `json:"account" label:"账号"` + Password string `json:"password" label:"密码"` } -type RegisterReq struct { - UserId string `json:"user_id" label:"支付宝用户的唯一userId"` - OpenId string `json:"open_id" label:"微信小程序openid"` - UnionId string `json:"union_id" label:"微信unionId"` - Nickname string `json:"nickname" label:"支付宝昵称"` - Avatar string `json:"avatar" label:"支付宝头像"` - Phone string `json:"phone" binding:"required" label:"手机号"` +type LoginResponse struct { + Token string `json:"token"` } diff --git a/app/ipad/md/md_order.go b/app/ipad/md/md_order.go new file mode 100644 index 0000000..16f2d52 --- /dev/null +++ b/app/ipad/md/md_order.go @@ -0,0 +1,7 @@ +package md + +type OrderSorting struct { + Oid string `json:"oid"` + AdminId string `json:"admin_id"` + GoodsInfo []map[string]string `json:"goods_info"` +} diff --git a/app/ipad/mw/mw_auth.go b/app/ipad/mw/mw_auth.go new file mode 100644 index 0000000..4761493 --- /dev/null +++ b/app/ipad/mw/mw_auth.go @@ -0,0 +1,30 @@ +package mw + +import ( + "applet/app/bigData/svc" + "applet/app/e" + "github.com/gin-gonic/gin" +) + +// 检查权限, 签名等等 +func ProductionWorkshopAuth(c *gin.Context) { + user, err := svc.CheckUser(c) + if err != nil { + switch err.(type) { + case e.E: + err1 := err.(e.E) + e.OutErr(c, err1.Code, err1.Error()) + return + default: + e.OutErr(c, e.ERR_UNAUTHORIZED, err.Error()) + return + } + } + if user == nil { + e.OutErr(c, e.ERR_NOT_AUTH, "当前用户信息失效") + return + } + // 将当前请求的username信息保存到请求的上下文c上 + c.Set("user", user) + c.Next() +} diff --git a/app/ipad/svc/svc_auth.go b/app/ipad/svc/svc_auth.go index 07418d7..b1609f8 100644 --- a/app/ipad/svc/svc_auth.go +++ b/app/ipad/svc/svc_auth.go @@ -1,33 +1,25 @@ package svc import ( - "applet/app/db" - "applet/app/db/model" + "applet/app/bigData/md" "applet/app/ipad/lib/auth" "errors" "github.com/gin-gonic/gin" "strings" - "time" ) -func GetUser(c *gin.Context) *model.User { +func GetUser(c *gin.Context) *md.User { user, _ := c.Get("user") if user == nil { - return &model.User{ - Id: 0, - UserId: "", - Nickname: "", - Avatar: "", - Phone: "", - Memo: "", - CreateAt: time.Now().Format("2006-01-02 15:04:05"), - UpdateAt: time.Now().Format("2006-01-02 15:04:05"), + return &md.User{ + Account: "", + Password: "", } } - return user.(*model.User) + return user.(*md.User) } -func CheckUser(c *gin.Context) (*model.User, error) { +func CheckUser(c *gin.Context) (*md.User, error) { token := c.GetHeader("Authorization") if token == "" { return nil, errors.New("token not exist") @@ -44,11 +36,9 @@ func CheckUser(c *gin.Context) (*model.User, error) { } // 获取user - userDb := db.UserDb{} - userDb.Set() - user, err := userDb.GetUser(mc.UserId) - if err != nil { - return nil, err + user := &md.User{ + Account: mc.Account, + Password: mc.Password, } return user, nil } diff --git a/app/ipad/svc/svc_login.go b/app/ipad/svc/svc_login.go index a21e4df..546e3c9 100644 --- a/app/ipad/svc/svc_login.go +++ b/app/ipad/svc/svc_login.go @@ -1,14 +1,13 @@ package svc import ( - "applet/app/db/model" "applet/app/ipad/lib/auth" "applet/app/ipad/md" "applet/app/utils/cache" "applet/app/utils/logx" ) -func HandleLoginToken(cacheKey string, user *model.User) (string, error) { +func HandleLoginToken(cacheKey string, user *md.User) (string, error) { // 获取之前生成的token token, err := cache.GetString(cacheKey) if err != nil { @@ -17,7 +16,7 @@ func HandleLoginToken(cacheKey string, user *model.User) (string, error) { // 没有获取到 if err != nil || token == "" { // 生成token - token, err = auth.GenToken(user.Id, user.Phone) + token, err = auth.GenToken(user.Account, user.Password) if err != nil { return "", err } diff --git a/app/ipad/svc/svc_order.go b/app/ipad/svc/svc_order.go new file mode 100644 index 0000000..1107460 --- /dev/null +++ b/app/ipad/svc/svc_order.go @@ -0,0 +1,46 @@ +package svc + +import ( + "applet/app/db" + "applet/app/e" + "applet/app/utils" + "github.com/gin-gonic/gin" +) + +func Order(c *gin.Context) { + var args map[string]string + if err := c.ShouldBindJSON(&args); err != nil { + e.OutErr(c, e.ERR_INVALID_ARGS, err) + return + } + eg := db.Db + data, _ := db.GetOrderListByIpad(eg, args) + list := make([]map[string]string, 0) + if data != nil { + enterpriseIds := make([]int, 0) + for _, v := range *data { + enterpriseIds = append(enterpriseIds, v.EnterpriseId) + } + enterpriseMap := db.GetEnterpriseMore(eg, enterpriseIds) + stateArr := []string{"待制作", "制作中", "烘焙中", "分拣中", "已完成", "已取消"} + btnArr := []string{"进入制作", "进入制作", "进入制作", "开始分拣", "分拣完成", "已取消"} + for _, v := range *data { + enterpriseName := "" + _, ok := enterpriseMap[v.EnterpriseId] + if ok { + enterpriseName = enterpriseMap[v.EnterpriseId].Name + } + var tmp = map[string]string{ + "oid": utils.Int64ToStr(v.Oid), + "id": utils.IntToStr(v.Id), + "state_str": stateArr[v.State], + "btn_str": btnArr[v.State], + "state": utils.IntToStr(v.State), + "enterprise_name": enterpriseName, + } + list = append(list, tmp) + } + } + e.OutSuc(c, list, nil) + return +} diff --git a/app/ipad/svc/svc_order_goods.go b/app/ipad/svc/svc_order_goods.go new file mode 100644 index 0000000..ad01965 --- /dev/null +++ b/app/ipad/svc/svc_order_goods.go @@ -0,0 +1,7 @@ +package svc + +import "github.com/gin-gonic/gin" + +func OrderGoods(c *gin.Context) { + +} diff --git a/app/ipad/svc/svc_order_make.go b/app/ipad/svc/svc_order_make.go new file mode 100644 index 0000000..ea1900d --- /dev/null +++ b/app/ipad/svc/svc_order_make.go @@ -0,0 +1,206 @@ +package svc + +import ( + "applet/app/db" + "applet/app/db/model" + "applet/app/e" + "applet/app/ipad/md" + "applet/app/utils" + "github.com/gin-gonic/gin" + "time" +) + +func OrderMakeBegin(c *gin.Context) { + var args map[string]string + if err := c.ShouldBindJSON(&args); err != nil { + e.OutErr(c, e.ERR_INVALID_ARGS, err) + return + } + args["state"] = "1" + args["str"] = "制作" + commMake(c, args) +} +func OrderMakeEnd(c *gin.Context) { + var args map[string]string + if err := c.ShouldBindJSON(&args); err != nil { + e.OutErr(c, e.ERR_INVALID_ARGS, err) + return + } + args["state"] = "2" + args["str"] = "烘焙" + commMake(c, args) +} + +func OrderBakingEnd(c *gin.Context) { + var args map[string]string + if err := c.ShouldBindJSON(&args); err != nil { + e.OutErr(c, e.ERR_INVALID_ARGS, err) + return + } + args["state"] = "3" + args["str"] = "烘焙" + commMake(c, args) +} +func OrderSortingEnd(c *gin.Context) { + var args md.OrderSorting + if err := c.ShouldBindJSON(&args); err != nil { + e.OutErr(c, e.ERR_INVALID_ARGS, err) + return + } + eg := db.Db + sess := eg.NewSession() + defer sess.Close() + sess.Begin() + order := db.GetOrderGoodsByIdSess(sess, args.Oid) + if order == nil { + sess.Rollback() + e.OutErr(c, 400, e.NewErr(400, "订单查找失败,请重试")) + return + } + if order.State == 4 { + sess.Rollback() + e.OutErr(c, 400, e.NewErr(400, "订单已分拣完成")) + return + } + //修改制作记录 + for _, v := range args.GoodsInfo { + record := db.GetOrderGoodsByRecordId(eg, v["id"]) + record.SuccessNum = utils.StrToInt(v["num"]) + record.State = 4 + record.AdminId = utils.StrToInt(args.AdminId) + record.Time = time.Now() + _, err := sess.Where("id=?", record.Id).Cols("success_num,state,time").Update(record) + if err != nil { + sess.Rollback() + e.OutErr(c, 400, e.NewErr(400, "提交失败,请重试")) + return + } + //写入流程记录 + var recordFlow = &model.OrderGoodsDoingFlow{ + Num: record.Num, + State: 4, + Memo: "", + SuccessNum: utils.StrToInt(v["num"]), + Time: time.Now(), + RecordId: record.RecordId, + AdminId: utils.StrToInt(args.AdminId), + } + one, err := sess.InsertOne(recordFlow) + if one == 0 || err != nil { + sess.Rollback() + e.OutErr(c, 400, e.NewErr(400, "开始制作失败,请重试")) + return + } + } + //判断大订单 要不要改状态 + count, _ := sess.Where("oid=?", order.Oid).Count(&model.OrderGoods{}) + countEnd, _ := sess.Where("oid=? and state=?", order.Oid, 4).Count(&model.OrderGoods{}) + if countEnd == count { + _, err := sess.Where("oid=?", order.Oid).Cols("state").Update(&model.Order{State: 4}) + if err != nil { + sess.Rollback() + e.OutErr(c, 400, e.NewErr(400, "提交失败,请重试")) + return + } + } + sess.Commit() + e.OutSuc(c, "success", nil) + return +} + +func commMake(c *gin.Context, args map[string]string) { + eg := db.Db + sess := eg.NewSession() + defer sess.Close() + sess.Begin() + state := utils.StrToInt(args["state"]) + + orderGoods := db.GetOrderGoodsByIdSess(sess, args["id"]) + if orderGoods == nil { + sess.Rollback() + e.OutErr(c, 400, e.NewErr(400, "订单查找失败,请重试")) + return + } + order := db.GetOrderByIdSess(sess, utils.Int64ToStr(orderGoods.Oid)) + if order == nil { + sess.Rollback() + 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) + if err != nil { + sess.Rollback() + e.OutErr(c, 400, e.NewErr(400, "提交失败,请重试")) + return + } + //写入流程记录 + var recordFlow = &model.OrderGoodsDoingFlow{ + Num: orderGoods.Num, + State: state, + Memo: args["memo"], + SuccessNum: utils.StrToInt(args["num"]), + Time: time.Now(), + RecordId: record.RecordId, + AdminId: utils.StrToInt(args["admin_id"]), + } + one, err := sess.InsertOne(recordFlow) + if one == 0 || err != nil { + sess.Rollback() + e.OutErr(c, 400, e.NewErr(400, "开始制作失败,请重试")) + return + } + orderGoods.State = state + update, err := sess.Where("id=?", orderGoods.Id).Cols("state").Update(&orderGoods) + if update == 0 || err != nil { + sess.Rollback() + e.OutErr(c, 400, e.NewErr(400, "提交失败,请重试")) + return + } + //判断大订单 要不要改状态 + count, _ := sess.Where("oid=?", orderGoods.Oid).Count(&model.OrderGoods{}) + countEnd, _ := sess.Where("oid=? and state=?", orderGoods.Oid, state).Count(&model.OrderGoods{}) + if countEnd == count { + _, err = sess.Where("oid=?", orderGoods.Oid).Cols("state").Update(&model.Order{State: state}) + if err != nil { + sess.Rollback() + e.OutErr(c, 400, e.NewErr(400, "提交失败,请重试")) + return + } + } + sess.Commit() + e.OutSuc(c, "success", nil) + return +} diff --git a/app/ipad/svc/svc_responsible.go b/app/ipad/svc/svc_responsible.go new file mode 100644 index 0000000..7f7e7f6 --- /dev/null +++ b/app/ipad/svc/svc_responsible.go @@ -0,0 +1,24 @@ +package svc + +import ( + "applet/app/db" + "applet/app/e" + "applet/app/utils" + "github.com/gin-gonic/gin" +) + +func Responsible(c *gin.Context) { + list := make([]map[string]string, 0) + admin := db.GetAllAdmin(db.Db) + if admin != nil { + for _, v := range *admin { + var tmp = map[string]string{ + "id": utils.IntToStr(v.AdmId), + "name": v.Memo, + } + list = append(list, tmp) + } + } + e.OutSuc(c, list, nil) + return +} diff --git a/app/router/admin_router.go b/app/router/admin_router.go index c7d00ba..a20054c 100644 --- a/app/router/admin_router.go +++ b/app/router/admin_router.go @@ -130,14 +130,15 @@ func rGoodsPay(r *gin.RouterGroup) { r.POST("/create", orderHdl.GoodsPayCreate) //商品下单 } func rOrder(r *gin.RouterGroup) { - r.POST("/list", orderHdl.OrderList) //用户订单 - r.POST("/total", orderHdl.OrderTotal) //用户订单统计 - r.POST("/cancel", orderHdl.OrderCancel) //用户订单取消 - r.POST("/detail", orderHdl.OrderDetail) //用户订单详情 - r.POST("/output", orderHdl.OrderOutput) //用户订单导出 - r.POST("/del", orderHdl.OrderDel) //用户订单商品删除 - r.POST("/edit", orderHdl.OrderEdit) //用户订单修改购买人信息 - r.POST("/editNum", orderHdl.OrderEditNum) //用户订单修改订单数 + r.POST("/list", orderHdl.OrderList) //用户订单 + r.POST("/total", orderHdl.OrderTotal) //用户订单统计 + r.POST("/cancel", orderHdl.OrderCancel) //用户订单取消 + r.POST("/detail", orderHdl.OrderDetail) //用户订单详情 + r.POST("/output", orderHdl.OrderOutput) //用户订单导出 + r.POST("/del", orderHdl.OrderDel) //用户订单商品删除 + r.POST("/edit", orderHdl.OrderEdit) //用户订单修改购买人信息 + r.POST("/editNum", orderHdl.OrderEditNum) //用户订单修改订单数 + r.POST("/makeRecord", orderHdl.MarkRecord) //制作记录 } func AdminRoute(r *gin.RouterGroup) { r.GET("/demo", hdl.Demo) diff --git a/app/router/ipad_router.go b/app/router/ipad_router.go index 5ac95f3..8d65fc1 100644 --- a/app/router/ipad_router.go +++ b/app/router/ipad_router.go @@ -1,15 +1,22 @@ package router import ( + "applet/app/ipad/hdl" "applet/app/ipad/mw" "github.com/gin-gonic/gin" ) func IpadInit(r *gin.RouterGroup) { - rTest(r.Group("/test")) - r.Use(mw.Auth) //检测登录状态 + r.POST("/login", hdl.Login) + r.Use(mw.Auth) //检测登录状态 + r.GET("order/cate", hdl.OrderCate) //订单类目 + r.POST("order/list", hdl.Order) //订单 + r.GET("order/goods/cate", hdl.OrderCate) //订单商品类目 + r.POST("order/goods/list", hdl.OrderGoods) //订单商品 + r.GET("responsible", hdl.Responsible) //负责人 + r.POST("order/make/begin", hdl.OrderMakeBegin) //订单开始制作 + r.POST("order/make/end", hdl.OrderMakeEnd) //订单制作完成 + r.POST("order/baking/end", hdl.OrderBakingEnd) //订单烘焙完成 + r.POST("order/sorting/end", hdl.OrderSortingEnd) //订单分拣完成 } - -func rTest(r *gin.RouterGroup) { -} From c00453c571ae0df63f28778077ccdaa98e3dc524 Mon Sep 17 00:00:00 2001 From: huangjiajun <582604932@qq.com> Date: Thu, 28 Mar 2024 16:38:28 +0800 Subject: [PATCH 2/2] =?UTF-8?q?1.ipad=E7=AB=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/db/db_order_goods_doing.go | 14 +++++++------- app/db/db_order_list.go | 14 +++++++------- 2 files changed, 14 insertions(+), 14 deletions(-) diff --git a/app/db/db_order_goods_doing.go b/app/db/db_order_goods_doing.go index fb0ba20..94d312f 100644 --- a/app/db/db_order_goods_doing.go +++ b/app/db/db_order_goods_doing.go @@ -17,14 +17,14 @@ func GetOrderGoodsByRecordId(eg *xorm.Engine, id string) *model.OrderGoodsDoing func GetOrderGoodsDoingList(eg *xorm.Engine, param map[string]string) (*[]model.OrderGoodsDoing, int64) { var order []model.OrderGoodsDoing sess := eg.Where("1=1") - if param["enterprise_name"] != "" { - var data []model.Enterprise - eg.Where("name like ?", "%"+param["enterprise_name"]+"%") + if param["admin_name"] != "" { + var data []model.Admin + eg.Where("memo like ?", "%"+param["admin_name"]+"%") ids := []int{-1} for _, v := range data { - ids = append(ids, v.Id) + ids = append(ids, v.AdmId) } - sess.In("enterprise_id", ids) + sess.In("admin_id", ids) } if param["oid"] != "" { sess.And("oid like ?", "%"+param["oid"]+"%") @@ -32,8 +32,8 @@ func GetOrderGoodsDoingList(eg *xorm.Engine, param map[string]string) (*[]model. if param["state"] != "" { sess.And("state =?", param["state"]) } - if param["admin_id"] != "" { - sess.And("admin_id =?", param["admin_id"]) + if param["enterprise_id"] != "" { + sess.And("enterprise_id =?", param["enterprise_id"]) } if param["goods_title"] != "" { sess.And("goods_title like ?", "%"+param["goods_title"]+"%") diff --git a/app/db/db_order_list.go b/app/db/db_order_list.go index 5ff66f1..6b87346 100644 --- a/app/db/db_order_list.go +++ b/app/db/db_order_list.go @@ -52,14 +52,14 @@ func GetOrderList(eg *xorm.Engine, param map[string]string) (*[]model.Order, int if param["state"] != "" { sess.And("state =?", param["state"]) } - if param["goods_title"] != "" { - var orderGoods []model.OrderGoods - eg.Where("goods_title like ?", "%"+param["goods_title"]+"%").Find(&orderGoods) - oids := []int64{-1} - for _, v := range orderGoods { - oids = append(oids, v.Oid) + if param["enterprise_name"] != "" { + var enterprise []model.Enterprise + eg.Where("name like ?", "%"+param["enterprise_name"]+"%").Find(&enterprise) + oids := []int{-1} + for _, v := range enterprise { + oids = append(oids, v.Id) } - sess.In("oid", oids) + sess.In("enterprise_id", oids) } size := utils.StrToInt(param["limit"]) start := (utils.StrToInt(param["page"]) - 1) * size