1
This commit is contained in:
@@ -1,85 +1,89 @@
|
|||||||
package cms
|
package cms
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"fmt"
|
||||||
|
"git.rosy.net.cn/baseapi/utils"
|
||||||
|
"git.rosy.net.cn/jx-callback/business/jxutils/jxcontext"
|
||||||
"git.rosy.net.cn/jx-callback/business/model"
|
"git.rosy.net.cn/jx-callback/business/model"
|
||||||
|
"git.rosy.net.cn/jx-callback/business/partner"
|
||||||
|
"git.rosy.net.cn/jx-callback/business/partner/purchase/mtwm"
|
||||||
)
|
)
|
||||||
|
|
||||||
//
|
// GetMtSkuDetailInfo 获取美团商品信息,暂时只支持美团
|
||||||
//// GetMtSkuDetailInfo 获取美团商品信息,暂时只支持美团
|
func GetMtSkuDetailInfo(ctx *jxcontext.Context, vendorOrderID string, vendorSkuName string) (outSkuNameExt *model.SkuNameExt, err error) {
|
||||||
//func GetMtSkuDetailInfo(ctx *jxcontext.Context, vendorOrderID string, vendorSkuName string) (outSkuNameExt *model.SkuNameExt, err error) {
|
orderDetail, err := partner.CurOrderManager.LoadOrder(vendorOrderID, model.VendorIDMTWM)
|
||||||
// orderDetail, err := partner.CurOrderManager.LoadOrder(vendorOrderID, model.VendorIDMTWM)
|
if err != nil {
|
||||||
// if err != nil {
|
return nil, err
|
||||||
// return nil, err
|
}
|
||||||
// }
|
|
||||||
//
|
// 获取订单详情
|
||||||
// // 获取订单详情
|
mtApi := mtwm.GetAPI(orderDetail.VendorOrgCode, orderDetail.JxStoreID, orderDetail.VendorStoreID)
|
||||||
// mtApi := mtwm.GetAPI(orderDetail.VendorOrgCode, orderDetail.JxStoreID, orderDetail.VendorStoreID)
|
mtOrderDetail, err := mtApi.OrderGetOrderDetail(utils.Str2Int64(vendorOrderID), false)
|
||||||
// mtOrderDetail, err := mtApi.OrderGetOrderDetail(utils.Str2Int64(vendorOrderID), false)
|
if err != nil {
|
||||||
// if err != nil {
|
return nil, err
|
||||||
// return nil, err
|
}
|
||||||
// }
|
var detail []map[string]interface{}
|
||||||
// var detail []map[string]interface{}
|
if err = utils.UnmarshalUseNumber([]byte(mtOrderDetail["detail"].(string)), &detail); err != nil {
|
||||||
// if err = utils.UnmarshalUseNumber([]byte(mtOrderDetail["detail"].(string)), &detail); err != nil {
|
return nil, err
|
||||||
// return nil, err
|
}
|
||||||
// }
|
|
||||||
//
|
mtCode := ""
|
||||||
// mtCode := ""
|
for _, product := range detail {
|
||||||
// for _, product := range detail {
|
if product["food_name"].(string) == vendorSkuName {
|
||||||
// if product["food_name"].(string) == vendorSkuName {
|
if product["app_food_code"].(string) == "" {
|
||||||
// if product["app_food_code"].(string) == "" {
|
return nil, fmt.Errorf("[%s] 未获取到商品的美团code,无法创建商品", vendorSkuName)
|
||||||
// return nil, fmt.Errorf("[%s] 未获取到商品的美团code,无法创建商品", vendorSkuName)
|
}
|
||||||
// }
|
mtCode = product["app_food_code"].(string)
|
||||||
// mtCode = product["app_food_code"].(string)
|
break
|
||||||
// break
|
}
|
||||||
// }
|
}
|
||||||
// }
|
if mtCode == "" {
|
||||||
// if mtCode == "" {
|
return nil, fmt.Errorf("[%s] 未获取到商品的美团code,无法创建商品", vendorSkuName)
|
||||||
// return nil, fmt.Errorf("[%s] 未获取到商品的美团code,无法创建商品", vendorSkuName)
|
}
|
||||||
// }
|
|
||||||
//
|
// 获取美团商品详情
|
||||||
// // 获取美团商品详情
|
mtSkuDetail, err := mtApi.RetailGet(orderDetail.VendorStoreID, mtCode)
|
||||||
// mtSkuDetail, err := mtApi.RetailGet(orderDetail.VendorStoreID, mtCode)
|
if err != nil {
|
||||||
// if err != nil {
|
return nil, err
|
||||||
// return nil, err
|
}
|
||||||
// }
|
|
||||||
//
|
skuName := &model.SkuNameExt{
|
||||||
// skuName := &model.SkuNameExt{
|
SkuName: model.SkuName{
|
||||||
// SkuName: model.SkuName{
|
Prefix: "",
|
||||||
// Prefix: "",
|
Name: mtSkuDetail.Name,
|
||||||
// Name: mtSkuDetail.Name,
|
Upc: utils.String2Pointer(mtSkuDetail.UpcCode),
|
||||||
// Upc: utils.String2Pointer(mtSkuDetail.UpcCode),
|
Status: 1,
|
||||||
// Status: 1,
|
CategoryID: 291, // ?
|
||||||
// CategoryID: 291, // ?
|
IsGlobal: 1,
|
||||||
// IsGlobal: 1,
|
Unit: mtSkuDetail.Unit,
|
||||||
// Unit: mtSkuDetail.Unit,
|
Price: utils.Float64TwoInt(mtSkuDetail.Price * float64(100)),
|
||||||
// Price: utils.Float64TwoInt(mtSkuDetail.Price * float64(100)),
|
DescImg: mtSkuDetail.PictureContents,
|
||||||
// DescImg: mtSkuDetail.PictureContents,
|
},
|
||||||
// },
|
Skus: nil,
|
||||||
// Skus: nil,
|
}
|
||||||
// }
|
|
||||||
//
|
skus := make([]*model.SkuWithVendor, 0, 0)
|
||||||
// skus := make([]*model.SkuWithVendor, 0, 0)
|
for _, mtSks := range mtSkuDetail.SkuList {
|
||||||
// for _, mtSks := range mtSkuDetail.SkuList {
|
sku := &model.SkuWithVendor{
|
||||||
// sku := &model.SkuWithVendor{
|
Sku: &model.Sku{
|
||||||
// Sku: &model.Sku{
|
MinOrderCount: utils.Str2Int(mtSks.MinOrderCount),
|
||||||
// MinOrderCount: utils.Str2Int(mtSks.MinOrderCount),
|
LadderBoxNum: utils.Str2Int(mtSks.LadderBoxNum),
|
||||||
// LadderBoxNum: utils.Str2Int(mtSks.LadderBoxNum),
|
LadderBoxPrice: utils.Float64TwoInt(utils.Str2Float64(mtSks.Price) * float64(100)),
|
||||||
// LadderBoxPrice: utils.Float64TwoInt(utils.Str2Float64(mtSks.Price) * float64(100)),
|
SpecQuality: float32(utils.Str2Float64(mtSks.Weight)),
|
||||||
// SpecQuality: utils.Str2Int(mtSks.Weight),
|
Weight: utils.Str2Int(mtSks.Weight),
|
||||||
// Weight: utils.Str2Int(mtSks.Weight),
|
SpecUnit: mtSks.Unit,
|
||||||
// SpecUnit: mtSks.Unit,
|
Status: 1,
|
||||||
// Status: 1,
|
Comment: "",
|
||||||
// Comment: "",
|
EclpID: "",
|
||||||
// EclpID: "",
|
},
|
||||||
// },
|
}
|
||||||
// }
|
skus = append(skus, sku)
|
||||||
// skus = append(skus, sku)
|
}
|
||||||
// }
|
skuName.Skus = skus
|
||||||
// skuName.Skus = skus
|
|
||||||
//
|
mTImg2Jx(skuName, mtSkuDetail.PictureList)
|
||||||
// mTImg2Jx(skuName, mtSkuDetail.PictureList)
|
return AddSkuName(ctx, skuName, ctx.GetUserName())
|
||||||
// return AddSkuName(ctx, skuName, ctx.GetUserName())
|
}
|
||||||
//}
|
|
||||||
|
|
||||||
func mTImg2Jx(sku *model.SkuNameExt, pictureList []string) {
|
func mTImg2Jx(sku *model.SkuNameExt, pictureList []string) {
|
||||||
switch len(pictureList) {
|
switch len(pictureList) {
|
||||||
|
|||||||
@@ -2,8 +2,6 @@ package jd
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"git.rosy.net.cn/baseapi/platformapi/jdapi"
|
"git.rosy.net.cn/baseapi/platformapi/jdapi"
|
||||||
"git.rosy.net.cn/baseapi/utils"
|
|
||||||
"git.rosy.net.cn/jx-callback/globals"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
func OnOrderMsg(msg *jdapi.CallbackOrderMsg, a *jdapi.API) (retVal *jdapi.CallbackResponse) {
|
func OnOrderMsg(msg *jdapi.CallbackOrderMsg, a *jdapi.API) (retVal *jdapi.CallbackResponse) {
|
||||||
@@ -23,7 +21,6 @@ func OnWaybillMsg(msg *jdapi.CallbackDeliveryStatusMsg) (retVal *jdapi.CallbackR
|
|||||||
func OnStoreMsg(msg *jdapi.CallbackOrderMsg) (retVal *jdapi.CallbackResponse) {
|
func OnStoreMsg(msg *jdapi.CallbackOrderMsg) (retVal *jdapi.CallbackResponse) {
|
||||||
if CurPurchaseHandler != nil {
|
if CurPurchaseHandler != nil {
|
||||||
retVal = CurPurchaseHandler.OnStoreMsg(AppKey2OrgCode(msg.AppKey), msg)
|
retVal = CurPurchaseHandler.OnStoreMsg(AppKey2OrgCode(msg.AppKey), msg)
|
||||||
globals.SugarLogger.Debugf("retVal========= %s", utils.Format4Output(retVal, false))
|
|
||||||
}
|
}
|
||||||
return retVal
|
return retVal
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -230,7 +230,6 @@ func (p *PurchaseHandler) DeleteStore(db *dao.DaoDB, storeID int, userName strin
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (p *PurchaseHandler) UpdateStore(db *dao.DaoDB, storeID int, userName string) (err error) {
|
func (p *PurchaseHandler) UpdateStore(db *dao.DaoDB, storeID int, userName string) (err error) {
|
||||||
globals.SugarLogger.Debugf("=========storeID := %s", utils.Format4Output(storeID, false))
|
|
||||||
if db == nil {
|
if db == nil {
|
||||||
db = dao.GetDB()
|
db = dao.GetDB()
|
||||||
}
|
}
|
||||||
@@ -280,9 +279,7 @@ func (p *PurchaseHandler) UpdateStore(db *dao.DaoDB, storeID int, userName strin
|
|||||||
params["address"] = storeDetail.YbStorePrefix
|
params["address"] = storeDetail.YbStorePrefix
|
||||||
}
|
}
|
||||||
|
|
||||||
globals.SugarLogger.Debugf("=========data := %s", utils.Format4Output(params, false))
|
|
||||||
if globals.EnableMtwmStoreWrite {
|
if globals.EnableMtwmStoreWrite {
|
||||||
globals.SugarLogger.Debugf("=========data := %s", utils.Format4Output(1111111, false))
|
|
||||||
errList.AddErr(mtapi.PoiSave(storeDetail.VendorStoreID, params))
|
errList.AddErr(mtapi.PoiSave(storeDetail.VendorStoreID, params))
|
||||||
}
|
}
|
||||||
if storeDetail.SyncStatus&(model.SyncFlagNewMask|model.SyncFlagStoreStatus) != 0 {
|
if storeDetail.SyncStatus&(model.SyncFlagNewMask|model.SyncFlagStoreStatus) != 0 {
|
||||||
|
|||||||
@@ -207,14 +207,14 @@ func (c *SkuController) AddSkuName() {
|
|||||||
// @Title 获取美团商品信息添加到本地
|
// @Title 获取美团商品信息添加到本地
|
||||||
// @Description 获取美团商品信息添加到本地
|
// @Description 获取美团商品信息添加到本地
|
||||||
// @Param token header string true "认证token"
|
// @Param token header string true "认证token"
|
||||||
// @Param orderSkuID formData int true "本地商品存储id"
|
// @Param vendorSkuName formData string true "平台商品名称"
|
||||||
// @Param vendorOrderID formData string true "订单id"
|
// @Param vendorOrderID formData string true "订单id"
|
||||||
// @Success 200 {object} controllers.CallResult
|
// @Success 200 {object} controllers.CallResult
|
||||||
// @Failure 200 {object} controllers.CallResult
|
// @Failure 200 {object} controllers.CallResult
|
||||||
// @router /MTSku2Local [post]
|
// @router /MTSku2Local [post]
|
||||||
func (c *SkuController) MTSku2Local() {
|
func (c *SkuController) MTSku2Local() {
|
||||||
c.callMTSku2Local(func(params *tSkuMTSku2LocalParams) (retVal interface{}, errCode string, err error) {
|
c.callMTSku2Local(func(params *tSkuMTSku2LocalParams) (retVal interface{}, errCode string, err error) {
|
||||||
|
retVal, err = cms.GetMtSkuDetailInfo(params.Ctx, params.VendorOrderID, params.VendorSkuName)
|
||||||
return retVal, "", err
|
return retVal, "", err
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user