@@ -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") | |||
@@ -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"` | |||
@@ -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{ | |||
@@ -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" | |||
@@ -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"]+"%") | |||
@@ -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 | |||
} |
@@ -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)"` | |||
} |
@@ -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)"` | |||
} |
@@ -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) | |||
@@ -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) | |||
} | |||