- fixed a bug in defsch.init, replace LoadOrder with GetOrder.

- dynamic table name for legacy order related table.
This commit is contained in:
gazebo
2018-07-23 17:30:22 +08:00
parent 96d8e7b2fa
commit 479ce46200
18 changed files with 253 additions and 80 deletions

View File

@@ -1,6 +1,7 @@
package mtps
import (
"errors"
"math"
"git.rosy.net.cn/baseapi/platformapi/mtpsapi"
@@ -12,9 +13,14 @@ import (
"git.rosy.net.cn/jx-callback/business/scheduler"
"git.rosy.net.cn/jx-callback/globals"
"git.rosy.net.cn/jx-callback/globals/api"
"github.com/astaxie/beego"
"github.com/astaxie/beego/orm"
)
var (
ErrCanNotFindMTPSStore = errors.New("不能找到美团配送站点配置")
)
type WaybillController struct {
}
@@ -158,19 +164,19 @@ func (c *WaybillController) CreateWaybill(order *model.GoodsOrder) (err error) {
}
if billParams.DeliveryID, err = c.getDeliveryID(order, db); err == nil {
if billParams.ShopID, err = c.getMTPSShopID(order, db); err == nil {
globals.SugarLogger.Debug(billParams.ShopID)
goods := &mtpsapi.GoodsDetail{
Goods: []*mtpsapi.GoodsItem{},
}
for _, sku := range order.Skus {
goodItem := &mtpsapi.GoodsItem{
GoodCount: sku.Count,
GoodName: sku.SkuName,
GoodPrice: jxutils.IntPrice2Standard(sku.SalePrice),
GoodUnit: "", //这个应该不是必须的商品名里已经有UNIT的字样了
}
goodItem.GoodName, goodItem.GoodUnit = jxutils.SplitSkuName(sku.SkuName)
goods.Goods = append(goods.Goods, goodItem)
}
addParams := utils.Params2Map("note", order.BuyerComment, "good_detail", string(utils.MustMarshal(goods)))
addParams := utils.Params2Map("note", order.BuyerComment, "goods_detail", string(utils.MustMarshal(goods)))
_, err = api.MtpsAPI.CreateOrderByShop(billParams, addParams)
}
}
@@ -209,10 +215,16 @@ func (c *WaybillController) getMTPSShopID(order *model.GoodsOrder, db orm.Ormer)
var lists []orm.ParamsList
JxStoreID := jxutils.GetJxStoreIDFromOrder(order)
num, err := db.Raw(sql, JxStoreID).ValuesList(&lists)
if err != nil && num == 1 {
if err == nil && num == 1 {
retVal = lists[0][0].(string)
if beego.BConfig.RunMode == "dev" {
retVal = "test_0001"
}
} else {
globals.SugarLogger.Errorf("getMTPSShopID can not find mtps store info for orderID:%s, store:%d", order.VendorOrderID, JxStoreID)
globals.SugarLogger.Errorf("getMTPSShopID can not find mtps store info for orderID:%s, store:%d, num:%d, error:%v", order.VendorOrderID, JxStoreID, num, err)
if err == nil {
err = ErrCanNotFindMTPSStore
}
}
return retVal, err
}