@@ -5,6 +5,7 @@ type GoodsPayParam struct { | |||||
EnterpriseId string `json:"enterprise_id"` | EnterpriseId string `json:"enterprise_id"` | ||||
BuyInfo BuyInfo `json:"buy_info"` | BuyInfo BuyInfo `json:"buy_info"` | ||||
Oid string `json:"oid"` | Oid string `json:"oid"` | ||||
MakeDate string `json:"make_date"` | |||||
} | } | ||||
type BuyInfo struct { | type BuyInfo struct { | ||||
Name string `json:"name"` | Name string `json:"name"` | ||||
@@ -64,6 +64,7 @@ func OrderList(c *gin.Context) { | |||||
"inside_name": insideEnterpriseName, | "inside_name": insideEnterpriseName, | ||||
"enterprise_id": v.EnterpriseId, | "enterprise_id": v.EnterpriseId, | ||||
"company_id": companyId, | "company_id": companyId, | ||||
"make_date": utils.TimeParseDateStd1(v.MakeDate), | |||||
} | } | ||||
data = append(data, tmp) | data = append(data, tmp) | ||||
} | } | ||||
@@ -129,6 +130,7 @@ func OrderExport(c *gin.Context) { | |||||
tmp["date"] = v.CreateAt.Format("2006-01-02") | tmp["date"] = v.CreateAt.Format("2006-01-02") | ||||
tmp["send_date"] = gjson.Get(v.BuyInfo, "date").String() | tmp["send_date"] = gjson.Get(v.BuyInfo, "date").String() | ||||
tmp["goods_name"] = vv.GoodsTitle | tmp["goods_name"] = vv.GoodsTitle | ||||
tmp["make_date"] = utils.TimeParseDateStd1(vv.MakeDate) | |||||
tmp["ord_no"] = vv.OrdNo | tmp["ord_no"] = vv.OrdNo | ||||
tmp["goods_type"] = utils.IntToStr(vv.GoodsType) | tmp["goods_type"] = utils.IntToStr(vv.GoodsType) | ||||
skuData := make([]md.Sku, 0) | skuData := make([]md.Sku, 0) | ||||
@@ -178,6 +180,7 @@ func OrderExport(c *gin.Context) { | |||||
v3["goods_name"], | v3["goods_name"], | ||||
v3["sku_str"], | v3["sku_str"], | ||||
v3["num"], | v3["num"], | ||||
v3["make_date"], | |||||
}) | }) | ||||
xlsx.SetRowHeight("Sheet1", j, 18) | xlsx.SetRowHeight("Sheet1", j, 18) | ||||
if utils.StrToInt(v3["goods_type"]) == 0 { | if utils.StrToInt(v3["goods_type"]) == 0 { | ||||
@@ -332,7 +335,7 @@ func OrderCancel(c *gin.Context) { | |||||
continue | continue | ||||
} | } | ||||
//判断有没有的扣 | //判断有没有的扣 | ||||
all := db.GetOrderGoodsMakeStockAll(sess, v.GoodsId, v.SkuId, 0) | |||||
all := db.GetOrderGoodsMakeStockAllByDate(sess, v.GoodsId, v.SkuId, 0, v.MakeDate) | |||||
if all == nil { | if all == nil { | ||||
sess.Rollback() | sess.Rollback() | ||||
e.OutErr(c, 400, e.NewErr(400, "订单取消失败")) | e.OutErr(c, 400, e.NewErr(400, "订单取消失败")) | ||||
@@ -491,6 +494,7 @@ func OrderDetail(c *gin.Context) { | |||||
"address": gjson.Get(order.BuyInfo, "address").String(), | "address": gjson.Get(order.BuyInfo, "address").String(), | ||||
"time": gjson.Get(order.BuyInfo, "time").String(), | "time": gjson.Get(order.BuyInfo, "time").String(), | ||||
"create_at": order.CreateAt.Format("2006-01-02 15:04:05"), | "create_at": order.CreateAt.Format("2006-01-02 15:04:05"), | ||||
"make_date": utils.TimeParseDateStd1(order.MakeDate), | |||||
"enterprise_name": enterpriseName, | "enterprise_name": enterpriseName, | ||||
"enterprise_id": order.EnterpriseId, | "enterprise_id": order.EnterpriseId, | ||||
"company_id": "", | "company_id": "", | ||||
@@ -552,6 +556,7 @@ func OrderOutput(c *gin.Context) { | |||||
tmp["date"] = v.CreateAt.Format("2006-01-02") | tmp["date"] = v.CreateAt.Format("2006-01-02") | ||||
tmp["send_date"] = gjson.Get(v.BuyInfo, "date").String() | tmp["send_date"] = gjson.Get(v.BuyInfo, "date").String() | ||||
tmp["goods_name"] = vv.GoodsTitle | tmp["goods_name"] = vv.GoodsTitle | ||||
tmp["make_date"] = utils.TimeParseDateStd1(vv.MakeDate) | |||||
tmp["ord_no"] = vv.OrdNo | tmp["ord_no"] = vv.OrdNo | ||||
tmp["goods_type"] = utils.IntToStr(vv.GoodsType) | tmp["goods_type"] = utils.IntToStr(vv.GoodsType) | ||||
skuData := make([]md.Sku, 0) | skuData := make([]md.Sku, 0) | ||||
@@ -601,6 +606,7 @@ func OrderOutput(c *gin.Context) { | |||||
v3["goods_name"], | v3["goods_name"], | ||||
v3["sku_str"], | v3["sku_str"], | ||||
v3["num"], | v3["num"], | ||||
v3["make_date"], | |||||
}) | }) | ||||
xlsx.SetRowHeight("Sheet1", j, 18) | xlsx.SetRowHeight("Sheet1", j, 18) | ||||
if utils.StrToInt(v3["goods_type"]) == 0 { | if utils.StrToInt(v3["goods_type"]) == 0 { | ||||
@@ -725,7 +731,7 @@ func OrderEditNum(c *gin.Context) { | |||||
isHasSku := 0 | isHasSku := 0 | ||||
if orderGoods.SkuId != utils.StrToInt64(args["sku_id"]) { | if orderGoods.SkuId != utils.StrToInt64(args["sku_id"]) { | ||||
//判断有没有的扣 | //判断有没有的扣 | ||||
all := db.GetOrderGoodsMakeStockAll(sess, orderGoods.GoodsId, orderGoods.SkuId, 0) | |||||
all := db.GetOrderGoodsMakeStockAllByDate(sess, orderGoods.GoodsId, orderGoods.SkuId, 0, orderGoods.MakeDate) | |||||
if all == nil { | if all == nil { | ||||
sess.Rollback() | sess.Rollback() | ||||
e.OutErr(c, 400, e.NewErr(400, "修改失败")) | e.OutErr(c, 400, e.NewErr(400, "修改失败")) | ||||
@@ -798,7 +804,7 @@ func OrderEditNum(c *gin.Context) { | |||||
} | } | ||||
if isHasSku == 0 { | if isHasSku == 0 { | ||||
//判断有没有的扣 | //判断有没有的扣 | ||||
all := db.GetOrderGoodsMakeStockAll(sess, orderGoods.GoodsId, orderGoods.SkuId, 0) | |||||
all := db.GetOrderGoodsMakeStockAllByDate(sess, orderGoods.GoodsId, orderGoods.SkuId, 0, orderGoods.MakeDate) | |||||
if all == nil { | if all == nil { | ||||
sess.Rollback() | sess.Rollback() | ||||
e.OutErr(c, 400, e.NewErr(400, "修改失败")) | e.OutErr(c, 400, e.NewErr(400, "修改失败")) | ||||
@@ -932,6 +938,7 @@ func OrderAddSku(c *gin.Context) { | |||||
State: 1, | State: 1, | ||||
IsNew: 1, | IsNew: 1, | ||||
OrdNo: order.OrdNo, | OrdNo: order.OrdNo, | ||||
MakeDate: order.MakeDate, | |||||
} | } | ||||
err := Total(sess, tmp) | err := Total(sess, tmp) | ||||
if err != nil { | if err != nil { | ||||
@@ -978,7 +985,7 @@ func commAdd(sess *xorm.Session, num string, orderGoods *model.OrderGoods) (floa | |||||
orderGoods1.Num = utils.StrToInt(num) | orderGoods1.Num = utils.StrToInt(num) | ||||
sess.InsertOne(orderGoods1) | sess.InsertOne(orderGoods1) | ||||
//判断有没有的扣 | //判断有没有的扣 | ||||
all1 := db.GetOrderGoodsMakeStockAll(sess, orderGoods1.GoodsId, orderGoods1.SkuId, 0) | |||||
all1 := db.GetOrderGoodsMakeStockAllByDate(sess, orderGoods1.GoodsId, orderGoods1.SkuId, 0, orderGoods1.MakeDate) | |||||
if all1 == nil { | if all1 == nil { | ||||
return 0, e.NewErr(400, "修改失败") | return 0, e.NewErr(400, "修改失败") | ||||
} | } | ||||
@@ -1045,7 +1052,7 @@ func OrderAddNum(c *gin.Context) { | |||||
orderGoods1.Num = num | orderGoods1.Num = num | ||||
sess.InsertOne(orderGoods1) | sess.InsertOne(orderGoods1) | ||||
//判断有没有的扣 | //判断有没有的扣 | ||||
all1 := db.GetOrderGoodsMakeStockAll(sess, orderGoods1.GoodsId, orderGoods1.SkuId, 0) | |||||
all1 := db.GetOrderGoodsMakeStockAllByDate(sess, orderGoods1.GoodsId, orderGoods1.SkuId, 0, orderGoods1.MakeDate) | |||||
if all1 == nil { | if all1 == nil { | ||||
sess.Rollback() | sess.Rollback() | ||||
e.OutErr(c, 400, e.NewErr(400, "修改失败")) | e.OutErr(c, 400, e.NewErr(400, "修改失败")) | ||||
@@ -1125,7 +1132,7 @@ func OrderDeductNum(c *gin.Context) { | |||||
orderGoods1.Num = num | orderGoods1.Num = num | ||||
sess.InsertOne(orderGoods1) | sess.InsertOne(orderGoods1) | ||||
//判断有没有的扣 | //判断有没有的扣 | ||||
all1 := db.GetOrderGoodsMakeStockAll(sess, orderGoods1.GoodsId, orderGoods1.SkuId, 0) | |||||
all1 := db.GetOrderGoodsMakeStockAllByDate(sess, orderGoods1.GoodsId, orderGoods1.SkuId, 0, orderGoods1.MakeDate) | |||||
if all1 == nil { | if all1 == nil { | ||||
sess.Rollback() | sess.Rollback() | ||||
e.OutErr(c, 400, e.NewErr(400, "修改失败")) | e.OutErr(c, 400, e.NewErr(400, "修改失败")) | ||||
@@ -59,6 +59,7 @@ func GoodsPayCreate(c *gin.Context) { | |||||
State: 1, | State: 1, | ||||
Date: utils.StrToInt(strings.ReplaceAll(req.BuyInfo.Date, "-", "")), | Date: utils.StrToInt(strings.ReplaceAll(req.BuyInfo.Date, "-", "")), | ||||
OrdNo: "AP" + time.Now().Format("20060102") + i, | OrdNo: "AP" + time.Now().Format("20060102") + i, | ||||
MakeDate: utils.StrToInt(strings.ReplaceAll(req.MakeDate, "-", "")), | |||||
} | } | ||||
one, err := sess.InsertOne(&order) | one, err := sess.InsertOne(&order) | ||||
if one == 0 || err != nil { | if one == 0 || err != nil { | ||||
@@ -92,6 +93,7 @@ func GoodsPayCreate(c *gin.Context) { | |||||
State: 1, | State: 1, | ||||
IsNew: 1, | IsNew: 1, | ||||
OrdNo: "AP" + time.Now().Format("20060102") + i, | OrdNo: "AP" + time.Now().Format("20060102") + i, | ||||
MakeDate: utils.StrToInt(strings.ReplaceAll(req.MakeDate, "-", "")), | |||||
} | } | ||||
goodsTotal[tmp.GoodsId] += tmp.Num | goodsTotal[tmp.GoodsId] += tmp.Num | ||||
orderGoods = append(orderGoods, tmp) | orderGoods = append(orderGoods, tmp) | ||||
@@ -155,7 +157,7 @@ func commCalc(c *gin.Context, req md.GoodsPayParam) (float64, map[string]string) | |||||
// 统计数量 | // 统计数量 | ||||
func Total(sess *xorm.Session, tmp model.OrderGoods) error { | func Total(sess *xorm.Session, tmp model.OrderGoods) error { | ||||
stock := db.GetOrderGoodsMakeStock(sess, tmp.GoodsId, tmp.SkuId) | |||||
stock := db.GetOrderGoodsMakeStockByDate(sess, tmp.GoodsId, tmp.SkuId, tmp.MakeDate) | |||||
if stock == nil { | if stock == nil { | ||||
return errors.New("下单失败") | return errors.New("下单失败") | ||||
} | } | ||||
@@ -217,12 +217,12 @@ func LeftDataForSorting() (resp []md.LeftDataForMakeResp, err error) { | |||||
} | } | ||||
//1、查找不等于4 5 | //1、查找不等于4 5 | ||||
today := utils.GetTimeRange("today") | |||||
if time.Now().Hour() < 2 { | |||||
today = utils.GetTimeRange("yesterday") | |||||
} | |||||
sysCfgDb := db.SysCfgDb{} | |||||
sysCfgDb.Set() | |||||
now := CommDate() | |||||
var orders []model.Order | var orders []model.Order | ||||
err = engine.Where(" state != 4 and state != 5 and create_at>=?", time.Unix(today["start"], 0).Format("2006-01-02 15:04:05")).Find(&orders) | |||||
err = engine.Where(" state != 4 and state != 5 and make_date=?", now).Find(&orders) | |||||
if err != nil { | if err != nil { | ||||
return | return | ||||
} | } | ||||
@@ -423,12 +423,9 @@ func NewSortingCate() []map[string]string { | |||||
} | } | ||||
//1、查找不等于4 5 | //1、查找不等于4 5 | ||||
today := utils.GetTimeRange("today") | |||||
if time.Now().Hour() < 2 { | |||||
today = utils.GetTimeRange("yesterday") | |||||
} | |||||
now := CommDate() | |||||
var orders []model.Order | var orders []model.Order | ||||
err = engine.Where(" state != 4 and state != 5 and create_at>=?", time.Unix(today["start"], 0).Format("2006-01-02 15:04:05")).Find(&orders) | |||||
err = engine.Where(" state != 4 and state != 5 and make_date=?", now).Find(&orders) | |||||
if err != nil { | if err != nil { | ||||
return res | return res | ||||
} | } | ||||
@@ -518,12 +515,9 @@ func NewSortingGoodsCate() []map[string]string { | |||||
engine := db.Db | engine := db.Db | ||||
//1、查找不等于4 5 | //1、查找不等于4 5 | ||||
today := utils.GetTimeRange("today") | |||||
if time.Now().Hour() < 2 { | |||||
today = utils.GetTimeRange("yesterday") | |||||
} | |||||
now := CommDate() | |||||
var orders []model.Order | var orders []model.Order | ||||
err := engine.Where(" state != 4 and state != 5 and create_at>=? ", time.Unix(today["start"], 0).Format("2006-01-02 15:04:05")).Find(&orders) | |||||
err := engine.Where(" state != 4 and state != 5 and make_date=? ", now).Find(&orders) | |||||
if err != nil { | if err != nil { | ||||
return res | return res | ||||
} | } | ||||
@@ -535,8 +529,8 @@ func NewSortingGoodsCate() []map[string]string { | |||||
} | } | ||||
oIds = append(oIds, utils.Int64ToStr(v.Oid)) | oIds = append(oIds, utils.Int64ToStr(v.Oid)) | ||||
} | } | ||||
sql := `SELECT SUM(num) as num,SUM(success_num) as success_num,goods_title,sku,goods_id,sku_id FROM order_goods WHERE oid in (%s) and goods_type=0 GROUP BY goods_id,sku_id` | |||||
sql = fmt.Sprintf(sql, strings.Join(oIds, ",")) | |||||
sql := `SELECT SUM(num) as num,SUM(success_num) as success_num,goods_title,sku,goods_id,sku_id FROM order_goods WHERE oid in (%s) and goods_type=0 and make_date=%s GROUP BY goods_id,sku_id` | |||||
sql = fmt.Sprintf(sql, strings.Join(oIds, ","), now) | |||||
nativeString, err := db.QueryNativeString(engine, sql) | nativeString, err := db.QueryNativeString(engine, sql) | ||||
for _, v := range nativeString { | for _, v := range nativeString { | ||||
skuData := make([]md2.Sku, 0) | skuData := make([]md2.Sku, 0) | ||||
@@ -580,12 +574,10 @@ func NewSortingGoodsData(arg map[string]string) []map[string]string { | |||||
enterpriseMap[v.Id] = v | enterpriseMap[v.Id] = v | ||||
} | } | ||||
//1、查找不等于4 5 | //1、查找不等于4 5 | ||||
today := utils.GetTimeRange("today") | |||||
if time.Now().Hour() < 2 { | |||||
today = utils.GetTimeRange("yesterday") | |||||
} | |||||
now := CommDate() | |||||
var orders []model.Order | var orders []model.Order | ||||
err = engine.Where(" state != 4 and state != 5 and create_at>=? ", time.Unix(today["start"], 0).Format("2006-01-02 15:04:05")).Find(&orders) | |||||
err = engine.Where(" state != 4 and state != 5 and make_date=? ", now).Find(&orders) | |||||
if err != nil { | if err != nil { | ||||
return res | return res | ||||
} | } | ||||
@@ -597,8 +589,8 @@ func NewSortingGoodsData(arg map[string]string) []map[string]string { | |||||
} | } | ||||
oIds = append(oIds, utils.Int64ToStr(v.Oid)) | oIds = append(oIds, utils.Int64ToStr(v.Oid)) | ||||
} | } | ||||
sql := `SELECT SUM(num) as num,SUM(success_num) as success_num,goods_title,sku,goods_id,sku_id,enterprise_id FROM order_goods WHERE oid in (%s) and goods_id=%s and goods_type=0 and sku_id=%s GROUP BY enterprise_id` | |||||
sql = fmt.Sprintf(sql, strings.Join(oIds, ","), arg["goods_id"], arg["sku_id"]) | |||||
sql := `SELECT SUM(num) as num,SUM(success_num) as success_num,goods_title,sku,goods_id,sku_id,enterprise_id FROM order_goods WHERE oid in (%s) and goods_id=%s and goods_type=0 and sku_id=%s and make_date=%s GROUP BY enterprise_id` | |||||
sql = fmt.Sprintf(sql, strings.Join(oIds, ","), arg["goods_id"], arg["sku_id"], now) | |||||
nativeString, err := db.QueryNativeString(engine, sql) | nativeString, err := db.QueryNativeString(engine, sql) | ||||
for _, v := range nativeString { | for _, v := range nativeString { | ||||
skuData := make([]md2.Sku, 0) | skuData := make([]md2.Sku, 0) | ||||
@@ -3,14 +3,17 @@ package svc | |||||
import ( | import ( | ||||
"applet/app/admin/md" | "applet/app/admin/md" | ||||
"applet/app/db" | "applet/app/db" | ||||
"applet/app/db/model" | |||||
"applet/app/e" | "applet/app/e" | ||||
"applet/app/utils" | "applet/app/utils" | ||||
"encoding/json" | "encoding/json" | ||||
"github.com/gin-gonic/gin" | "github.com/gin-gonic/gin" | ||||
"time" | |||||
) | ) | ||||
func CommMakingData(c *gin.Context, args map[string]string) { | func CommMakingData(c *gin.Context, args map[string]string) { | ||||
eg := db.Db | eg := db.Db | ||||
args["now"] = CommDate() | |||||
data, _ := db.GetOrderGoodsMakeStockByBigData(eg, args) | data, _ := db.GetOrderGoodsMakeStockByBigData(eg, args) | ||||
list := make([]map[string]string, 0) | list := make([]map[string]string, 0) | ||||
if data != nil { | if data != nil { | ||||
@@ -25,16 +28,39 @@ func CommMakingData(c *gin.Context, args map[string]string) { | |||||
tmp["num"] = utils.IntToStr(v.WaitMakeNum) | tmp["num"] = utils.IntToStr(v.WaitMakeNum) | ||||
tmp["state_str"] = "制作中" | tmp["state_str"] = "制作中" | ||||
tmp["state"] = "1" | tmp["state"] = "1" | ||||
if v.WaitMakeNum == 0 { | |||||
tmp["state"] = "4" | |||||
tmp["state_str"] = "制作完成" | |||||
} | |||||
if v.GoodsType == 2 { | |||||
tmp["state"] = "4" | |||||
tmp["state_str"] = "无需制作" | |||||
} | |||||
if v.GoodsType == 1 { //判断主单做完了就显示完成 | |||||
count, _ := eg.Where("gid=? and sku_id=? and goods_type=0 and make_date=?", v.Gid, v.SkuId, v.MakeDate).Count(&model.OrderGoodsMakeStock{}) | |||||
if count == 0 { | |||||
tmp["state"] = "4" | |||||
tmp["state_str"] = "制作完成" | |||||
} | |||||
} | |||||
} | } | ||||
if args["state"] == "2" { | if args["state"] == "2" { | ||||
tmp["num"] = utils.IntToStr(v.WaitBakingNum) | tmp["num"] = utils.IntToStr(v.WaitBakingNum) | ||||
tmp["state_str"] = "烘焙中" | tmp["state_str"] = "烘焙中" | ||||
tmp["state"] = "2" | tmp["state"] = "2" | ||||
if v.WaitBakingNum == 0 { | |||||
tmp["state"] = "4" | |||||
tmp["state_str"] = "烘焙完成" | |||||
} | |||||
} | } | ||||
if args["state"] == "3" { | if args["state"] == "3" { | ||||
tmp["num"] = utils.IntToStr(v.WaitSortingNum) | tmp["num"] = utils.IntToStr(v.WaitSortingNum) | ||||
tmp["state_str"] = "分拣中" | tmp["state_str"] = "分拣中" | ||||
tmp["state"] = "3" | tmp["state"] = "3" | ||||
if v.WaitSortingNum == 0 { | |||||
tmp["state"] = "4" | |||||
tmp["state_str"] = "分拣完成" | |||||
} | |||||
} | } | ||||
skuData := make([]md.Sku, 0) | skuData := make([]md.Sku, 0) | ||||
json.Unmarshal([]byte(v.Sku), &skuData) | json.Unmarshal([]byte(v.Sku), &skuData) | ||||
@@ -52,3 +78,13 @@ func CommMakingData(c *gin.Context, args map[string]string) { | |||||
e.OutSuc(c, list, nil) | e.OutSuc(c, list, nil) | ||||
return | return | ||||
} | } | ||||
func CommDate() string { | |||||
sysCfgDb := db.SysCfgDb{} | |||||
sysCfgDb.Set() | |||||
beforeHourShowOrder, _ := sysCfgDb.SysCfgGetOne("before_hour_show_order") | |||||
today := utils.GetTimeRange("today") | |||||
if utils.StrToInt(beforeHourShowOrder.Val) > time.Now().Hour() { | |||||
today = utils.GetTimeRange("yesterday") | |||||
} | |||||
return time.Unix(today["start"], 0).Format("20060102") | |||||
} |
@@ -29,7 +29,7 @@ func GetOrderGoodsListByIpad(eg *xorm.Engine, param map[string]string) (*[]model | |||||
} | } | ||||
size := utils.StrToInt(param["limit"]) | size := utils.StrToInt(param["limit"]) | ||||
start := (utils.StrToInt(param["page"]) - 1) * size | start := (utils.StrToInt(param["page"]) - 1) * size | ||||
count, err := sess.Limit(size, start).OrderBy("id asc").FindAndCount(&order) | |||||
count, err := sess.Limit(size, start).OrderBy("make_date asc,id asc").FindAndCount(&order) | |||||
if err != nil { | if err != nil { | ||||
return nil, count | return nil, count | ||||
} | } | ||||
@@ -24,7 +24,7 @@ func GetOrderGoodsMakeStockByIpad(eg *xorm.Engine, param map[string]string) (*[] | |||||
} | } | ||||
size := utils.StrToInt(param["limit"]) | size := utils.StrToInt(param["limit"]) | ||||
start := (utils.StrToInt(param["page"]) - 1) * size | start := (utils.StrToInt(param["page"]) - 1) * size | ||||
count, err := sess.Limit(size, start).OrderBy("id asc").FindAndCount(&order) | |||||
count, err := sess.Limit(size, start).OrderBy("make_date asc,id asc").FindAndCount(&order) | |||||
if err != nil { | if err != nil { | ||||
return nil, count | return nil, count | ||||
} | } | ||||
@@ -33,17 +33,19 @@ func GetOrderGoodsMakeStockByIpad(eg *xorm.Engine, param map[string]string) (*[] | |||||
func GetOrderGoodsMakeStockByBigData(eg *xorm.Engine, param map[string]string) (*[]model.OrderGoodsMakeStock, int64) { | func GetOrderGoodsMakeStockByBigData(eg *xorm.Engine, param map[string]string) (*[]model.OrderGoodsMakeStock, int64) { | ||||
var order []model.OrderGoodsMakeStock | var order []model.OrderGoodsMakeStock | ||||
sess := eg.Where("1=1") | sess := eg.Where("1=1") | ||||
if param["now"] != "" { | |||||
sess.And("make_date=?", param["now"]) | |||||
} | |||||
if param["state"] == "1" { | if param["state"] == "1" { | ||||
sess.And("wait_make_num >0") | |||||
sess.And("wait_make_num >=0") | |||||
} else { | } else { | ||||
sess.And("goods_type =0") | sess.And("goods_type =0") | ||||
} | } | ||||
if param["state"] == "2" { | if param["state"] == "2" { | ||||
sess.And("wait_baking_num >0") | |||||
sess.And("wait_make_num =0 and wait_baking_num >=0") | |||||
} | } | ||||
if param["state"] == "3" { | if param["state"] == "3" { | ||||
sess.And("wait_sorting_num >0") | |||||
sess.And("wait_baking_num =0 and wait_sorting_num >=0") | |||||
} | } | ||||
if param["keyword"] != "" { | if param["keyword"] != "" { | ||||
sess.And("goods_title like ?", "%"+param["keyword"]+"%") | sess.And("goods_title like ?", "%"+param["keyword"]+"%") | ||||
@@ -73,6 +75,14 @@ func GetOrderGoodsMakeStock(sess *xorm.Session, gid, skuId int64) *model.OrderGo | |||||
} | } | ||||
return &data | return &data | ||||
} | } | ||||
func GetOrderGoodsMakeStockById(sess *xorm.Session, id int64) *model.OrderGoodsMakeStock { | |||||
var data model.OrderGoodsMakeStock | |||||
get, err := sess.Where("id=? ", id).Get(&data) | |||||
if err != nil || get == false { | |||||
return nil | |||||
} | |||||
return &data | |||||
} | |||||
func GetOrderGoodsMakeStockAll(sess *xorm.Session, gid, skuId int64, goodsType int) *model.OrderGoodsMakeStock { | func GetOrderGoodsMakeStockAll(sess *xorm.Session, gid, skuId int64, goodsType int) *model.OrderGoodsMakeStock { | ||||
var data model.OrderGoodsMakeStock | var data model.OrderGoodsMakeStock | ||||
get, err := sess.Where("gid=? and sku_id=? and goods_type=?", gid, skuId, goodsType).Get(&data) | get, err := sess.Where("gid=? and sku_id=? and goods_type=?", gid, skuId, goodsType).Get(&data) | ||||
@@ -82,3 +92,31 @@ func GetOrderGoodsMakeStockAll(sess *xorm.Session, gid, skuId int64, goodsType i | |||||
return &data | return &data | ||||
} | } | ||||
func GetOrderGoodsMakeStockAllByDate(sess *xorm.Session, gid, skuId int64, goodsType int, date int) *model.OrderGoodsMakeStock { | |||||
var data model.OrderGoodsMakeStock | |||||
get, err := sess.Where("gid=? and sku_id=? and goods_type=? and make_date=?", gid, skuId, goodsType, date).Get(&data) | |||||
if err != nil || get == false { | |||||
return nil | |||||
} | |||||
return &data | |||||
} | |||||
func GetOrderGoodsMakeStockByDate(sess *xorm.Session, gid, skuId int64, date int) *model.OrderGoodsMakeStock { | |||||
var data model.OrderGoodsMakeStock | |||||
get, err := sess.Where("gid=? and sku_id=? and make_date=?", gid, skuId, date).Get(&data) | |||||
if err != nil { | |||||
return nil | |||||
} | |||||
if get == false { | |||||
data = model.OrderGoodsMakeStock{ | |||||
Gid: gid, | |||||
SkuId: skuId, | |||||
MakeDate: date, | |||||
} | |||||
insert, err := sess.Insert(&data) | |||||
if insert == 0 || err != nil { | |||||
return nil | |||||
} | |||||
} | |||||
return &data | |||||
} |
@@ -67,6 +67,10 @@ func GetOrderList(eg *xorm.Engine, param map[string]string) (*[]model.Order, int | |||||
param["date"] = strings.ReplaceAll(param["date"], "-", "") | param["date"] = strings.ReplaceAll(param["date"], "-", "") | ||||
sess.And("date = ?", param["date"]) | sess.And("date = ?", param["date"]) | ||||
} | } | ||||
if param["make_date"] != "" { | |||||
param["date"] = strings.ReplaceAll(param["date"], "-", "") | |||||
sess.And("make_date = ?", param["date"]) | |||||
} | |||||
if param["enterprise_name"] != "" { | if param["enterprise_name"] != "" { | ||||
var enterprise []model.Enterprise | var enterprise []model.Enterprise | ||||
eg.Where("name like ?", "%"+param["enterprise_name"]+"%").Find(&enterprise) | eg.Where("name like ?", "%"+param["enterprise_name"]+"%").Find(&enterprise) | ||||
@@ -198,7 +202,7 @@ func GetOrderListByIpad(eg *xorm.Engine, param map[string]string) (*[]model.Orde | |||||
} | } | ||||
size := utils.StrToInt(param["limit"]) | size := utils.StrToInt(param["limit"]) | ||||
start := (utils.StrToInt(param["page"]) - 1) * size | start := (utils.StrToInt(param["page"]) - 1) * size | ||||
count, err := sess.Limit(size, start).OrderBy("create_at desc,id desc").FindAndCount(&order) | |||||
count, err := sess.Limit(size, start).OrderBy("make_date asc,id asc").FindAndCount(&order) | |||||
if err != nil { | if err != nil { | ||||
return nil, count | return nil, count | ||||
} | } | ||||
@@ -17,4 +17,5 @@ type Order struct { | |||||
BuyPhone string `json:"buy_phone" xorm:"comment('购买人手机') VARCHAR(20)"` | BuyPhone string `json:"buy_phone" xorm:"comment('购买人手机') VARCHAR(20)"` | ||||
EnterpriseName string `json:"enterprise_name" xorm:"comment('校企名称') VARCHAR(20)"` | EnterpriseName string `json:"enterprise_name" xorm:"comment('校企名称') VARCHAR(20)"` | ||||
OrdNo string `json:"ord_no" xorm:"comment('') VARCHAR(255)"` | OrdNo string `json:"ord_no" xorm:"comment('') VARCHAR(255)"` | ||||
MakeDate int `json:"make_date" xorm:"comment('') default 0 INT(11)"` | |||||
} | } |
@@ -24,4 +24,5 @@ type OrderGoods struct { | |||||
AdminId int `json:"admin_id" xorm:"default 0 comment('admin 的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)"` | EnterpriseId int `json:"enterprise_id" xorm:"default 0 comment('校企 的id') INT(11)"` | ||||
GoodsType int `json:"goods_type" xorm:"default 0 comment('') INT(11)"` | GoodsType int `json:"goods_type" xorm:"default 0 comment('') INT(11)"` | ||||
MakeDate int `json:"make_date" xorm:"comment('') default 0 INT(11)"` | |||||
} | } |
@@ -12,4 +12,5 @@ type OrderGoodsMakeStock struct { | |||||
WaitSortingNum int `json:"wait_sorting_num" xorm:"default 0 comment('待分拣') INT(11)"` | WaitSortingNum int `json:"wait_sorting_num" xorm:"default 0 comment('待分拣') INT(11)"` | ||||
SuccessNum int `json:"success_num" xorm:"default 0 comment('已分拣') INT(11)"` | SuccessNum int `json:"success_num" xorm:"default 0 comment('已分拣') INT(11)"` | ||||
GoodsType int `json:"goods_type" xorm:"default 0 comment('') INT(11)"` | GoodsType int `json:"goods_type" xorm:"default 0 comment('') INT(11)"` | ||||
MakeDate int `json:"make_date" xorm:"comment('') default 0 INT(11)"` | |||||
} | } |
@@ -45,6 +45,7 @@ func OrderGoods(c *gin.Context) { | |||||
"oid": utils.Int64ToStr(v.Oid), | "oid": utils.Int64ToStr(v.Oid), | ||||
"id": utils.IntToStr(v.Id), | "id": utils.IntToStr(v.Id), | ||||
"num": utils.IntToStr(v.Num), | "num": utils.IntToStr(v.Num), | ||||
"make_date": utils.TimeParseDateStd1(v.MakeDate), | |||||
"success_num": utils.IntToStr(v.SuccessNum), | "success_num": utils.IntToStr(v.SuccessNum), | ||||
"state_str": stateArr[v.State], | "state_str": stateArr[v.State], | ||||
"btn_str": btnArr[v.State], | "btn_str": btnArr[v.State], | ||||
@@ -113,6 +114,7 @@ func SortingOrderGoods(c *gin.Context) { | |||||
"success_num": utils.IntToStr(v.SuccessNum), | "success_num": utils.IntToStr(v.SuccessNum), | ||||
"need_num": utils.IntToStr(v.Num - v.SuccessNum), | "need_num": utils.IntToStr(v.Num - v.SuccessNum), | ||||
"enterprise_name": enterpriseName, | "enterprise_name": enterpriseName, | ||||
"make_date": utils.TimeParseDateStd1(v.MakeDate), | |||||
} | } | ||||
list = append(list, tmp) | list = append(list, tmp) | ||||
} | } | ||||
@@ -7,6 +7,7 @@ type OrderSorting struct { | |||||
} | } | ||||
type NewOrderSorting struct { | type NewOrderSorting struct { | ||||
Gid string `json:"gid"` | Gid string `json:"gid"` | ||||
Id string `json:"id"` | |||||
SkuId string `json:"sku_id"` | SkuId string `json:"sku_id"` | ||||
AdminId string `json:"admin_id"` | AdminId string `json:"admin_id"` | ||||
OrderInfo []map[string]string `json:"goods_info"` | OrderInfo []map[string]string `json:"goods_info"` | ||||
@@ -35,6 +35,7 @@ func Order(c *gin.Context) { | |||||
} | } | ||||
var tmp = map[string]string{ | var tmp = map[string]string{ | ||||
"oid": utils.Int64ToStr(v.Oid), | "oid": utils.Int64ToStr(v.Oid), | ||||
"make_date": utils.TimeParseDateStd1(v.MakeDate), | |||||
"id": utils.IntToStr(v.Id), | "id": utils.IntToStr(v.Id), | ||||
"state_str": stateArr[v.State], | "state_str": stateArr[v.State], | ||||
"btn_str": btnArr[v.State], | "btn_str": btnArr[v.State], | ||||
@@ -42,7 +43,6 @@ func Order(c *gin.Context) { | |||||
"enterprise_name": enterpriseName, | "enterprise_name": enterpriseName, | ||||
"time": v.CreateAt.Format("2006-01-02 15:04:05"), | "time": v.CreateAt.Format("2006-01-02 15:04:05"), | ||||
} | } | ||||
list = append(list, tmp) | list = append(list, tmp) | ||||
} | } | ||||
} | } | ||||
@@ -72,6 +72,7 @@ func StateOrder(c *gin.Context) { | |||||
"id": utils.IntToStr(v.Id), | "id": utils.IntToStr(v.Id), | ||||
"gid": utils.Int64ToStr(v.Gid), | "gid": utils.Int64ToStr(v.Gid), | ||||
"sku_id": utils.Int64ToStr(v.SkuId), | "sku_id": utils.Int64ToStr(v.SkuId), | ||||
"make_date": utils.TimeParseDateStd1(v.MakeDate), | |||||
"num": "", | "num": "", | ||||
"state_str": "", | "state_str": "", | ||||
"btn_str": "", | "btn_str": "", | ||||
@@ -55,7 +55,7 @@ func NewOrderSortingEnd(c *gin.Context) { | |||||
e.OutErr(c, 400, e.NewErr(400, "提交失败,请重试")) | e.OutErr(c, 400, e.NewErr(400, "提交失败,请重试")) | ||||
return | return | ||||
} | } | ||||
makeRecord := db.GetOrderGoodsMakeStock(sess, utils.StrToInt64(args.Gid), utils.StrToInt64(args.SkuId)) | |||||
makeRecord := db.GetOrderGoodsMakeStockByDate(sess, utils.StrToInt64(args.Gid), utils.StrToInt64(args.SkuId), record.MakeDate) | |||||
if utils.StrToInt(v["num"]) > makeRecord.WaitSortingNum { | if utils.StrToInt(v["num"]) > makeRecord.WaitSortingNum { | ||||
sess.Rollback() | sess.Rollback() | ||||
e.OutErr(c, 400, e.NewErr(400, record.GoodsTitle+",数量只能提交"+utils.IntToStr(makeRecord.WaitSortingNum)+"个")) | e.OutErr(c, 400, e.NewErr(400, record.GoodsTitle+",数量只能提交"+utils.IntToStr(makeRecord.WaitSortingNum)+"个")) | ||||
@@ -105,15 +105,12 @@ func commNewMake(c *gin.Context, args map[string]string) { | |||||
defer sess.Close() | defer sess.Close() | ||||
sess.Begin() | sess.Begin() | ||||
state := utils.StrToInt(args["state"]) | state := utils.StrToInt(args["state"]) | ||||
orderGoods := db.GetOrderGoodsMakeStock(sess, utils.StrToInt64(args["gid"]), utils.StrToInt64(args["sku_id"])) | |||||
orderGoods := db.GetOrderGoodsMakeStockById(sess, utils.StrToInt64(args["id"])) | |||||
if orderGoods == nil { | if orderGoods == nil { | ||||
sess.Rollback() | sess.Rollback() | ||||
e.OutErr(c, 400, e.NewErr(400, "订单查找失败,请重试")) | e.OutErr(c, 400, e.NewErr(400, "订单查找失败,请重试")) | ||||
return | return | ||||
} | } | ||||
WaitMakeNum := orderGoods.WaitMakeNum | WaitMakeNum := orderGoods.WaitMakeNum | ||||
if state == 2 { //制作完成 | if state == 2 { //制作完成 | ||||
if utils.StrToInt(args["num"]) > orderGoods.WaitMakeNum { | if utils.StrToInt(args["num"]) > orderGoods.WaitMakeNum { | ||||
@@ -147,7 +144,6 @@ func commNewMake(c *gin.Context, args map[string]string) { | |||||
return | return | ||||
} | } | ||||
//写入流程记录 | //写入流程记录 | ||||
var recordFlow = &model.OrderGoodsDoingFlow{ | var recordFlow = &model.OrderGoodsDoingFlow{ | ||||
Num: WaitMakeNum, | Num: WaitMakeNum, | ||||
State: state, | State: state, | ||||
@@ -74,6 +74,10 @@ func TimeParseDateStd(src string) time.Time { | |||||
t, _ := TimeParse("2006-01-02", src) | t, _ := TimeParse("2006-01-02", src) | ||||
return t | return t | ||||
} | } | ||||
func TimeParseDateStd1(src int) string { | |||||
t, _ := TimeParse("20060102", IntToStr(src)) | |||||
return t.Format("2006-01-02") | |||||
} | |||||
func TimeStdParseUnix(src string) int64 { | func TimeStdParseUnix(src string) int64 { | ||||
t, err := TimeParse("2006-01-02 15:04:05", src) | t, err := TimeParse("2006-01-02 15:04:05", src) | ||||
if err != nil { | if err != nil { | ||||