Kaynağa Gözat

1.下单规则更新

master
huangjiajun 6 ay önce
ebeveyn
işleme
e6c8bd1f1f
10 değiştirilmiş dosya ile 294 ekleme ve 52 silme
  1. +6
    -0
      app/admin/hdl/order/hdl_order_list.go
  2. +224
    -16
      app/admin/svc/order/svc_order_list.go
  3. +9
    -1
      app/admin/svc/order/svc_order_pay.go
  4. +8
    -3
      app/admin/svc/svc_data_statisstics.go
  5. +26
    -20
      app/bigData/hdl/hdl_making_data.go
  6. +5
    -3
      app/db/db_order_goods_make_stock.go
  7. +1
    -0
      app/db/model/order.go
  8. +3
    -0
      app/db/model/order_goods.go
  9. +1
    -0
      app/db/model/order_goods_make_stock.go
  10. +11
    -9
      app/router/admin_router.go

+ 6
- 0
app/admin/hdl/order/hdl_order_list.go Dosyayı Görüntüle

@@ -37,3 +37,9 @@ func OrderEditNum(c *gin.Context) {
func OrderDel(c *gin.Context) {
order.OrderDel(c)
}
func OrderAddNum(c *gin.Context) {
order.OrderAddNum(c)
}
func OrderDeductNum(c *gin.Context) {
order.OrderDeductNum(c)
}

+ 224
- 16
app/admin/svc/order/svc_order_list.go Dosyayı Görüntüle

@@ -45,6 +45,7 @@ func OrderList(c *gin.Context) {
}
var tmp = map[string]string{
"buy_phone": v1.BuyPhone,
"ord_no": v1.OrdNo,
"oid": utils.Int64ToStr(v1.Oid),
"id": utils.IntToStr(v1.Id),
"amount": v1.Amount,
@@ -105,7 +106,7 @@ func OrderExport(c *gin.Context) {
}
//TODO:: 查找 `order_goods`
var orderGoods []model.OrderGoods
err := eg.Where("oid = ?", v.Oid).Find(&orderGoods)
err := eg.Where("oid = ? and goods_type=0", v.Oid).Find(&orderGoods)
if err != nil {
e.OutErr(c, e.ERR_DB_ORM, err)
return
@@ -113,6 +114,7 @@ func OrderExport(c *gin.Context) {
for _, vv := range orderGoods {
data[enterpriseName][v.Oid]["date"] = v.CreateAt.Format("2006-01-02")
data[enterpriseName][v.Oid]["goods_name"] = vv.GoodsTitle
data[enterpriseName][v.Oid]["ord_no"] = vv.OrdNo
skuData := make([]md.Sku, 0)
json.Unmarshal([]byte(vv.Sku), &skuData)
skuStr := ""
@@ -139,9 +141,12 @@ func OrderExport(c *gin.Context) {
for k, v := range data {
var total = 0
for kk, vv := range v {
if vv["ord_no"] == "" {
vv["ord_no"] = utils.Int64ToStr(kk)
}
xlsx.SetSheetRow("Sheet1", "A"+strconv.Itoa(j), &[]interface{}{
vv["date"],
utils.Int64ToStr(kk),
vv["ord_no"],
k,
vv["goods_name"],
vv["sku_str"],
@@ -190,7 +195,7 @@ func JudgePackageOrdOrdState(ord *model.Order) *model.Order {
return ord
}
//1、判断是否有 `制作中` 有一个就是制作中
count1, err := db.Db.Where("oid =?", ord.Oid).And("state =?", 1).Count(&model.OrderGoods{})
count1, err := db.Db.Where("oid =?", ord.Oid).And("state =? and goods_type=?", 1, 0).Count(&model.OrderGoods{})
if err != nil {
return ord
}
@@ -214,7 +219,7 @@ func JudgePackageOrdOrdState(ord *model.Order) *model.Order {
ordState = 3
}
//4、判断是否有 `已完成` 要全部已完成
count4, err := db.Db.Where("oid =?", ord.Oid).And("state =?", 4).Count(&model.OrderGoods{})
count4, err := db.Db.Where("oid =?", ord.Oid).And("state =? and goods_type=?", 4, 0).Count(&model.OrderGoods{})
if err != nil {
return ord
}
@@ -292,8 +297,11 @@ func OrderCancel(c *gin.Context) {
goods := db.GetOrderGoodsByIds(sess, args["oid"])
if goods != nil {
for _, v := range *goods {
if v.GoodsType > 0 {
continue
}
//判断有没有的扣
all := db.GetOrderGoodsMakeStockAll(sess, v.GoodsId, v.SkuId)
all := db.GetOrderGoodsMakeStockAll(sess, v.GoodsId, v.SkuId, 0)
if all == nil {
sess.Rollback()
e.OutErr(c, 400, e.NewErr(400, "订单取消失败"))
@@ -373,9 +381,15 @@ func OrderDetail(c *gin.Context) {
skuList = append(skuList, skuItem)
}
}
firstNum := utils.IntToStr(v.FirstNum)
if v.GoodsType > 0 {
firstNum = ""
}
tmp := map[string]interface{}{
"goods_img": "",
"id": utils.IntToStr(v.Id),
"goods_type": utils.IntToStr(v.GoodsType),
"first_num": firstNum,
"sku_id": utils.Int64ToStr(v.SkuId),
"goods_id": utils.Int64ToStr(v.GoodsId),
"num": utils.IntToStr(v.Num),
@@ -483,7 +497,7 @@ func OrderOutput(c *gin.Context) {
}
//TODO:: 查找 `order_goods`
var orderGoods []model.OrderGoods
err := eg.Where("oid = ?", v.Oid).Find(&orderGoods)
err := eg.Where("oid = ? and goods_type=0", v.Oid).Find(&orderGoods)
if err != nil {
e.OutErr(c, e.ERR_DB_ORM, err)
return
@@ -492,6 +506,7 @@ func OrderOutput(c *gin.Context) {
data[enterpriseName][v.Oid]["date"] = v.CreateAt.Format("2006-01-02")
data[enterpriseName][v.Oid]["send_date"] = gjson.Get(v.BuyInfo, "date").String()
data[enterpriseName][v.Oid]["goods_name"] = vv.GoodsTitle
data[enterpriseName][v.Oid]["ord_no"] = vv.OrdNo
skuData := make([]md.Sku, 0)
json.Unmarshal([]byte(vv.Sku), &skuData)
skuStr := ""
@@ -518,9 +533,12 @@ func OrderOutput(c *gin.Context) {
for k, v := range data {
var total = 0
for kk, vv := range v {
if vv["ord_no"] == "" {
vv["ord_no"] = utils.Int64ToStr(kk)
}
xlsx.SetSheetRow("Sheet1", "A"+strconv.Itoa(j), &[]interface{}{
vv["date"],
utils.Int64ToStr(kk),
vv["ord_no"],
k,
vv["goods_name"],
vv["sku_str"],
@@ -645,7 +663,7 @@ func OrderEditNum(c *gin.Context) {
isHasSku := 0
if orderGoods.SkuId != utils.StrToInt64(args["sku_id"]) {
//判断有没有的扣
all := db.GetOrderGoodsMakeStockAll(sess, orderGoods.GoodsId, orderGoods.SkuId)
all := db.GetOrderGoodsMakeStockAll(sess, orderGoods.GoodsId, orderGoods.SkuId, 0)
if all == nil {
sess.Rollback()
e.OutErr(c, 400, e.NewErr(400, "修改失败"))
@@ -683,11 +701,18 @@ func OrderEditNum(c *gin.Context) {
db.QueryNativeStringSess(sess, sqlSecond)
//重新计算价格
tmp := orderGoodsSku
oldNum := orderGoodsSku.Num
orderGoodsSku.Num += utils.StrToInt(args["num"])
orderGoodsSku.OldNum += utils.StrToInt(args["num"])
order.Amount = utils.Float64ToStr(utils.StrToFloat64(order.Amount) + utils.StrToFloat64(args["num"])*utils.StrToFloat64(orderGoodsSku.Price))
if utils.StrToFloat64(args["price"]) > 0 && utils.StrToFloat64(args["price"]) != utils.StrToFloat64(orderGoodsSku.Price) {
order.Amount = utils.Float64ToStr(utils.StrToFloat64(order.Amount) - float64(oldNum)*utils.StrToFloat64(orderGoodsSku.Price))
orderGoodsSku.Price = args["price"]
order.Amount = utils.Float64ToStr(utils.StrToFloat64(order.Amount) + float64(orderGoodsSku.Num)*utils.StrToFloat64(orderGoodsSku.Price))
} else {
order.Amount = utils.Float64ToStr(utils.StrToFloat64(order.Amount) + utils.StrToFloat64(args["num"])*utils.StrToFloat64(orderGoodsSku.Price))
}
orderGoodsSku.DeductMemo = args["memo"]
_, err = sess.Where("id=?", orderGoodsSku.Id).Cols("num,memo,old_num").Update(orderGoodsSku)
_, err = sess.Where("id=?", orderGoodsSku.Id).Cols("num,memo,old_num,price").Update(orderGoodsSku)
if err != nil {
sess.Rollback()
e.OutErr(c, 400, e.NewErr(400, "修改失败"))
@@ -711,7 +736,7 @@ func OrderEditNum(c *gin.Context) {
}
if isHasSku == 0 {
//判断有没有的扣
all := db.GetOrderGoodsMakeStockAll(sess, orderGoods.GoodsId, orderGoods.SkuId)
all := db.GetOrderGoodsMakeStockAll(sess, orderGoods.GoodsId, orderGoods.SkuId, 0)
if all == nil {
sess.Rollback()
e.OutErr(c, 400, e.NewErr(400, "修改失败"))
@@ -725,15 +750,27 @@ func OrderEditNum(c *gin.Context) {
return
}
num = orderGoods.Num - utils.StrToInt(args["num"])
all.WaitMakeNum -= orderGoods.Num
order.Amount = utils.Float64ToStr(utils.StrToFloat64(order.Amount) - float64(num)*utils.StrToFloat64(orderGoods.Price))
all.WaitMakeNum -= num
if utils.StrToFloat64(args["price"]) > 0 && utils.StrToFloat64(args["price"]) != utils.StrToFloat64(orderGoods.Price) {
order.Amount = utils.Float64ToStr(utils.StrToFloat64(order.Amount) - float64(orderGoods.Num)*utils.StrToFloat64(orderGoods.Price))
orderGoods.Price = args["price"]
order.Amount = utils.Float64ToStr(utils.StrToFloat64(order.Amount) + float64(utils.StrToInt(args["num"]))*utils.StrToFloat64(orderGoods.Price))
} else {
order.Amount = utils.Float64ToStr(utils.StrToFloat64(order.Amount) - float64(num)*utils.StrToFloat64(orderGoods.Price))
}
//销量扣除
sqlSecond := `UPDATE goods SET sale=sale-%d WHERE id=%d`
sqlSecond = fmt.Sprintf(sqlSecond, num, orderGoods.GoodsId)
db.QueryNativeStringSess(sess, sqlSecond)
} else {
all.WaitMakeNum += orderGoods.Num
order.Amount = utils.Float64ToStr(utils.StrToFloat64(order.Amount) + float64(num)*utils.StrToFloat64(orderGoods.Price))
all.WaitMakeNum += num
if utils.StrToFloat64(args["price"]) > 0 && utils.StrToFloat64(args["price"]) != utils.StrToFloat64(orderGoods.Price) {
order.Amount = utils.Float64ToStr(utils.StrToFloat64(order.Amount) - float64(orderGoods.Num)*utils.StrToFloat64(orderGoods.Price))
orderGoods.Price = args["price"]
order.Amount = utils.Float64ToStr(utils.StrToFloat64(order.Amount) + float64(num)*utils.StrToFloat64(orderGoods.Price))
} else {
order.Amount = utils.Float64ToStr(utils.StrToFloat64(order.Amount) + float64(num)*utils.StrToFloat64(orderGoods.Price))
}
//销量增加
sqlSecond := `UPDATE goods SET sale=sale+%d WHERE id=%d`
sqlSecond = fmt.Sprintf(sqlSecond, num, orderGoods.GoodsId)
@@ -748,7 +785,7 @@ func OrderEditNum(c *gin.Context) {
orderGoods.OldNum = orderGoods.Num
orderGoods.Num = utils.StrToInt(args["num"])
orderGoods.DeductMemo = args["memo"]
_, err = sess.Where("id=?", orderGoods.Id).Cols("num,sku_code,sku_id,sku,memo,old_num").Update(orderGoods)
_, err = sess.Where("id=?", orderGoods.Id).Cols("num,sku_code,sku_id,sku,memo,old_num,price").Update(orderGoods)
if err != nil {
sess.Rollback()
e.OutErr(c, 400, e.NewErr(400, "修改失败"))
@@ -765,3 +802,174 @@ func OrderEditNum(c *gin.Context) {
e.OutSuc(c, "success", nil)
return
}
func OrderAddNum(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
order := db.GetOrderById(eg, args["oid"])
if order == nil {
e.OutErr(c, 400, e.NewErr(400, "订单不存在"))
return
}
order = JudgePackageOrdOrdState(order)
if order.State == 5 {
e.OutErr(c, 400, e.NewErr(400, "订单已取消,不能修改"))
return
}
sess := eg.NewSession()
defer sess.Close()
sess.Begin()
num := utils.StrToInt(args["num"])

orderGoods := db.GetOrderGoodsByIdSess(sess, args["id"])
orderGoods.OldNum = orderGoods.Num
orderGoods.Num += utils.StrToInt(args["num"])
_, err := sess.Where("id=?", orderGoods.Id).Cols("num,sku_code,sku_id,sku,old_num,price").Update(orderGoods)
if err != nil {
sess.Rollback()
e.OutErr(c, 400, e.NewErr(400, "修改失败"))
return
}
orderGoods1 := orderGoods
orderGoods1.Id = 0
orderGoods1.GoodsTitle = "(新增)" + orderGoods1.GoodsTitle
orderGoods1.IsNew = 1
orderGoods1.GoodsType = 1
orderGoods1.Num = num
sess.InsertOne(orderGoods1)
//判断有没有的扣
all1 := db.GetOrderGoodsMakeStockAll(sess, orderGoods1.GoodsId, orderGoods1.SkuId, 0)
if all1 == nil {
sess.Rollback()
e.OutErr(c, 400, e.NewErr(400, "修改失败"))
return
}
all1.WaitMakeNum += num
_, err = sess.Where("id=?", all1.Id).Cols("wait_make_num").Update(all1)
if err != nil {
sess.Rollback()
e.OutErr(c, 400, e.NewErr(400, "修改失败"))
return
}
all := all1
all.Id = 0
all.WaitBakingNum = 0
all.WaitMakeNum = num
all.WaitSortingNum = 0
all.GoodsTitle = orderGoods1.GoodsTitle
all.GoodsType = 1
_, err = sess.InsertOne(all)
if err != nil {
sess.Rollback()
e.OutErr(c, 400, e.NewErr(400, "修改失败"))
return
}
order.Amount = utils.Float64ToStr(utils.StrToFloat64(order.Amount) + float64(num)*utils.StrToFloat64(orderGoods1.Price))
//销量增加
sqlSecond := `UPDATE goods SET sale=sale+%d WHERE id=%d`
sqlSecond = fmt.Sprintf(sqlSecond, num, orderGoods1.GoodsId)
db.QueryNativeStringSess(sess, sqlSecond)
_, err = sess.Where("id=?", order.Id).Cols("amount").Update(order)
if err != nil {
sess.Rollback()
e.OutErr(c, 400, e.NewErr(400, "修改失败"))
return
}

sess.Commit()
e.OutSuc(c, "success", nil)
return
}
func OrderDeductNum(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
order := db.GetOrderById(eg, args["oid"])
if order == nil {
e.OutErr(c, 400, e.NewErr(400, "订单不存在"))
return
}
order = JudgePackageOrdOrdState(order)
if order.State == 5 {
e.OutErr(c, 400, e.NewErr(400, "订单已取消,不能修改"))
return
}
sess := eg.NewSession()
defer sess.Close()
sess.Begin()
num := utils.StrToInt(args["num"])
orderGoods := db.GetOrderGoodsByIdSess(sess, args["id"])
orderGoods.OldNum = orderGoods.Num
orderGoods.Num -= utils.StrToInt(args["num"])
_, err := sess.Where("id=?", orderGoods.Id).Cols("num,sku_code,sku_id,sku,old_num,price").Update(orderGoods)
if err != nil {
sess.Rollback()
e.OutErr(c, 400, e.NewErr(400, "修改失败"))
return
}
orderGoods1 := orderGoods
orderGoods1.Id = 0
orderGoods1.GoodsTitle = "(减少)" + orderGoods1.GoodsTitle
orderGoods1.IsNew = 1
orderGoods1.GoodsType = 2
orderGoods1.Num = num
sess.InsertOne(orderGoods1)
//判断有没有的扣
all1 := db.GetOrderGoodsMakeStockAll(sess, orderGoods1.GoodsId, orderGoods1.SkuId, 0)
if all1 == nil {
sess.Rollback()
e.OutErr(c, 400, e.NewErr(400, "修改失败"))
return
}
if all1.WaitMakeNum < num {
sess.Rollback()
e.OutErr(c, 400, e.NewErr(400, "订单已经在制作,减少数量失败"))
return
}
all1.WaitMakeNum -= num
_, err = sess.Where("id=?", all1.Id).Cols("wait_make_num").Update(all1)
if err != nil {
sess.Rollback()
e.OutErr(c, 400, e.NewErr(400, "修改失败"))
return
}
all := all1
all.Id = 0
all.WaitBakingNum = 0
all.WaitMakeNum = num
all.WaitSortingNum = 0
all.GoodsTitle = orderGoods1.GoodsTitle
all.GoodsType = 2
_, err = sess.InsertOne(all)
if err != nil {
sess.Rollback()
e.OutErr(c, 400, e.NewErr(400, "修改失败"))
return
}
order.Amount = utils.Float64ToStr(utils.StrToFloat64(order.Amount) - float64(num)*utils.StrToFloat64(orderGoods1.Price))
//销量减少
sqlSecond := `UPDATE goods SET sale=sale-%d WHERE id=%d`
sqlSecond = fmt.Sprintf(sqlSecond, num, orderGoods1.GoodsId)
db.QueryNativeStringSess(sess, sqlSecond)
if err != nil {
sess.Rollback()
e.OutErr(c, 400, e.NewErr(400, "修改失败"))
return
}
_, err = sess.Where("id=?", order.Id).Cols("amount").Update(order)
if err != nil {
sess.Rollback()
e.OutErr(c, 400, e.NewErr(400, "修改失败"))
return
}

sess.Commit()
e.OutSuc(c, "success", nil)
return
}

+ 9
- 1
app/admin/svc/order/svc_order_pay.go Dosyayı Görüntüle

@@ -43,7 +43,12 @@ func GoodsPayCreate(c *gin.Context) {
sess := db.Db.NewSession()
defer sess.Close()
sess.Begin()

today := utils.GetTimeRange("today")
count, _ := sess.Where("create_at>=?", time.Unix(today["start"], 0).Format("2006-01-02 15:04:05")).Count(&model.Order{})
i := utils.IntToStr(int(count + 1))
if utils.StrToInt(i) < 100 {
i = "00" + i
}
var order = model.Order{
Oid: utils.StrToInt64(utils.OrderUUID(utils.StrToInt(req.EnterpriseId))),
CreateAt: time.Now(),
@@ -53,6 +58,7 @@ func GoodsPayCreate(c *gin.Context) {
Amount: utils.Float64ToStr(amount),
State: 1,
Date: utils.StrToInt(strings.ReplaceAll(req.BuyInfo.Date, "-", "")),
OrdNo: "AP" + time.Now().Format("20060102") + i,
}
one, err := sess.InsertOne(&order)
if one == 0 || err != nil {
@@ -80,10 +86,12 @@ func GoodsPayCreate(c *gin.Context) {
SkuCode: skuMap[utils.StrToInt64(v.SkuId)].SkuCode,
Sku: skuMap[utils.StrToInt64(v.SkuId)].Sku,
Num: utils.StrToInt(v.Num),
FirstNum: utils.StrToInt(v.Num),
Price: skuPrice[v.SkuId],
EnterpriseId: utils.StrToInt(req.EnterpriseId),
State: 1,
IsNew: 1,
OrdNo: "AP" + time.Now().Format("20060102") + i,
}
goodsTotal[tmp.GoodsId] += tmp.Num
orderGoods = append(orderGoods, tmp)


+ 8
- 3
app/admin/svc/svc_data_statisstics.go Dosyayı Görüntüle

@@ -53,7 +53,7 @@ func DataStatisticsExport(req md.DataStatisticsExportReq) {
}
//TODO:: 查找 `order_goods`
var orderGoods []model.OrderGoods
err := eg.Where("oid = ?", v.Oid).Find(&orderGoods)
err := eg.Where("oid = ? and goods_type=0", v.Oid).Find(&orderGoods)
if err != nil {
logx.Error(err)
println("<<<<DataStatisticsExport111111>>>>>Error:::", err.Error())
@@ -156,7 +156,7 @@ func DataStatisticsExport(req md.DataStatisticsExportReq) {
}
//TODO:: 查找 `order_goods`
var orderGoods []model.OrderGoods
err := eg.Where("oid = ?", v.Oid).Find(&orderGoods)
err := eg.Where("oid = ? and goods_type=0", v.Oid).Find(&orderGoods)
if err != nil {
logx.Error(err)
println("<<<<DataStatisticsExport111111>>>>>Error:::", err.Error())
@@ -165,6 +165,8 @@ func DataStatisticsExport(req md.DataStatisticsExportReq) {
for _, vv := range orderGoods {
data[enterpriseName][v.Oid]["date"] = v.CreateAt.Format("2006-01-02")
data[enterpriseName][v.Oid]["goods_name"] = vv.GoodsTitle
data[enterpriseName][v.Oid]["ord_no"] = vv.OrdNo

skuData := make([]md.Sku, 0)
json.Unmarshal([]byte(vv.Sku), &skuData)
skuStr := ""
@@ -194,10 +196,13 @@ func DataStatisticsExport(req md.DataStatisticsExportReq) {
j := 7 //表头前三行被占用了,只能从第四行开始
var total, totalAmount float64
for kk, vv := range v {
if vv["ord_no"] == "" {
vv["ord_no"] = utils.Int64ToStr(kk)
}
amount := utils.StrToFloat64(vv["num"]) * utils.StrToFloat64(vv["price"])
xlsx.SetSheetRow(k, "A"+strconv.Itoa(j), &[]interface{}{
vv["date"],
utils.Int64ToStr(kk),
vv["ord_no"],
k,
vv["goods_name"],
vv["sku_str"],


+ 26
- 20
app/bigData/hdl/hdl_making_data.go Dosyayı Görüntüle

@@ -58,35 +58,41 @@ func NewOrderInfoNotice(c *gin.Context) {
if cfg != nil {
str = cfg.Val
}
skuDatas := make(map[int64]map[string]string, 0)
skuDatas := make(map[int64]map[int]map[string]string, 0)
for _, v := range data {
_, ok := skuDatas[v.SkuId]
if ok == false {
skuDatas[v.SkuId] = make(map[string]string)
skuDatas[v.SkuId] = make(map[int]map[string]string)
}
skuDatas[v.SkuId]["goods_title"] = v.GoodsTitle
skuDatas[v.SkuId]["sku"] = v.Sku
skuDatas[v.SkuId]["count"] = utils.IntToStr(utils.StrToInt(skuDatas[v.SkuId]["count"]) + v.Num)
_, ok1 := skuDatas[v.SkuId][v.GoodsType]
if ok1 == false {
skuDatas[v.SkuId][v.GoodsType] = make(map[string]string)
}
skuDatas[v.SkuId][v.GoodsType]["goods_title"] = v.GoodsTitle
skuDatas[v.SkuId][v.GoodsType]["sku"] = v.Sku
skuDatas[v.SkuId][v.GoodsType]["count"] = utils.IntToStr(utils.StrToInt(skuDatas[v.SkuId][v.GoodsType]["count"]) + v.Num)
}
res := make([]map[string]string, 0)
for _, v := range skuDatas {
skuData := make([]md.Sku, 0)
json.Unmarshal([]byte(v["sku"]), &skuData)
skuStr := ""
for _, v1 := range skuData {
if skuStr != "" {
skuStr += ";"
for _, v1 := range v {
skuData := make([]md.Sku, 0)
json.Unmarshal([]byte(v1["sku"]), &skuData)
skuStr := ""
for _, v2 := range skuData {
if skuStr != "" {
skuStr += ";"
}
skuStr += v2.Value
}
skuStr += v1.Value
}
tip := str
tip = strings.ReplaceAll(tip, "[商品名称]", v["goods_title"])
tip = strings.ReplaceAll(tip, "[规格]", skuStr)
tip = strings.ReplaceAll(tip, "[数量]", v["count"])
tmp := map[string]string{
"str": tip,
tip := str
tip = strings.ReplaceAll(tip, "[商品名称]", v1["goods_title"])
tip = strings.ReplaceAll(tip, "[规格]", skuStr)
tip = strings.ReplaceAll(tip, "[数量]", v1["count"])
tmp := map[string]string{
"str": tip,
}
res = append(res, tmp)
}
res = append(res, tmp)
}
for _, v := range data {
v.IsNew = 0


+ 5
- 3
app/db/db_order_goods_make_stock.go Dosyayı Görüntüle

@@ -8,7 +8,7 @@ import (

func GetOrderGoodsMakeStockByIpad(eg *xorm.Engine, param map[string]string) (*[]model.OrderGoodsMakeStock, int64) {
var order []model.OrderGoodsMakeStock
sess := eg.Where("1=1")
sess := eg.Where("goods_type=0")

if param["state"] == "1" {
sess.And("wait_make_num >0")
@@ -36,6 +36,8 @@ func GetOrderGoodsMakeStockByBigData(eg *xorm.Engine, param map[string]string) (

if param["state"] == "1" {
sess.And("wait_make_num >0")
} else {
sess.And("goods_type =0")
}
if param["state"] == "2" {
sess.And("wait_baking_num >0")
@@ -71,9 +73,9 @@ func GetOrderGoodsMakeStock(sess *xorm.Session, gid, skuId int64) *model.OrderGo
}
return &data
}
func GetOrderGoodsMakeStockAll(sess *xorm.Session, gid, skuId int64) *model.OrderGoodsMakeStock {
func GetOrderGoodsMakeStockAll(sess *xorm.Session, gid, skuId int64, goodsType int) *model.OrderGoodsMakeStock {
var data model.OrderGoodsMakeStock
get, err := sess.Where("gid=? and sku_id=?", gid, skuId).Get(&data)
get, err := sess.Where("gid=? and sku_id=? and goods_type=?", gid, skuId, goodsType).Get(&data)
if err != nil || get == false {
return nil
}


+ 1
- 0
app/db/model/order.go Dosyayı Görüntüle

@@ -16,4 +16,5 @@ type Order struct {
Amount string `json:"amount" xorm:"default 0.00 comment('付款金额') DECIMAL(20,2)"`
BuyPhone string `json:"buy_phone" xorm:"comment('购买人手机') VARCHAR(20)"`
EnterpriseName string `json:"enterprise_name" xorm:"comment('校企名称') VARCHAR(20)"`
OrdNo string `json:"ord_no" xorm:"comment('') VARCHAR(255)"`
}

+ 3
- 0
app/db/model/order_goods.go Dosyayı Görüntüle

@@ -8,6 +8,7 @@ type OrderGoods struct {
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)"`
FirstNum int `json:"first_num" xorm:"default 0 comment('购买数量') INT(11)"`
OldNum int `json:"old_num" xorm:"default 0 comment('购买数量') INT(11)"`
IsNew int `json:"is_new" xorm:"default 0 comment('购买数量') INT(11)"`
Price string `json:"price" xorm:"default 0.00 comment('单价') DECIMAL(20,2)"`
@@ -18,7 +19,9 @@ type OrderGoods struct {
GoodsTitle string `json:"goods_title" xorm:"comment('商品标题') VARCHAR(255)"`
SuccessNum int `json:"success_num" xorm:"comment('完成数量') INT(11)"`
Memo string `json:"memo" xorm:"comment('制作完成备注') VARCHAR(255)"`
OrdNo string `json:"ord_no" 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)"`
GoodsType int `json:"goods_type" xorm:"default 0 comment('') INT(11)"`
}

+ 1
- 0
app/db/model/order_goods_make_stock.go Dosyayı Görüntüle

@@ -11,4 +11,5 @@ type OrderGoodsMakeStock struct {
WaitBakingNum int `json:"wait_baking_num" xorm:"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)"`
GoodsType int `json:"goods_type" xorm:"default 0 comment('') INT(11)"`
}

+ 11
- 9
app/router/admin_router.go Dosyayı Görüntüle

@@ -136,15 +136,17 @@ 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("/makeRecord", orderHdl.MarkRecord) //制作记录
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("/addNum", orderHdl.OrderAddNum) //用户订单增加数量
r.POST("/deductNum", orderHdl.OrderDeductNum) //用户订单减少数量
r.POST("/makeRecord", orderHdl.MarkRecord) //制作记录
}

func rDataStatistics(r *gin.RouterGroup) {


Yükleniyor…
İptal
Kaydet