1
This commit is contained in:
@@ -4,6 +4,7 @@ import (
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"git.rosy.net.cn/baseapi/platformapi/ebaiapi"
|
||||
"git.rosy.net.cn/baseapi/platformapi/jdapi"
|
||||
product_addV2_request "git.rosy.net.cn/baseapi/platformapi/tiktok_shop/sdk-golang/api/product_addV2/request"
|
||||
"git.rosy.net.cn/baseapi/platformapi/tiktok_shop/tiktok_api"
|
||||
"git.rosy.net.cn/jx-callback/business/jxutils"
|
||||
@@ -61,8 +62,8 @@ func CopyOnStoreSkuToOther(ctx *jxcontext.Context, fromStoreId, toStoreId string
|
||||
_, copySkuErr, err = CopyMtToEBai(ctx, fromStore, toStore, isAsync, offSet)
|
||||
case 31: // 饿了么到美团
|
||||
_, copySkuErr, err = CopyEBaiToMt(ctx, fromStore, toStore, isAsync, offSet)
|
||||
case 10: // 美团到京东
|
||||
|
||||
case 30: // 饿百到京东
|
||||
_, copySkuErr, err = CopyEBaiToJd(ctx, fromStore, toStore, isAsync, offSet)
|
||||
default:
|
||||
return nil, fmt.Errorf("暂时还不支持")
|
||||
}
|
||||
@@ -1214,6 +1215,138 @@ func BatchInitSkuEBai2Mt(ctx *jxcontext.Context, fromSku []*ebaiapi.SkuInfo, toA
|
||||
|
||||
//#endregion
|
||||
|
||||
//#region 饿百复制到京东
|
||||
|
||||
func CopyEBaiToJd(ctx *jxcontext.Context, fromStore, toStore *dao.StoreDetail, isAsync bool, offSet int) (hint string, errList []string, err error) {
|
||||
var api = api.EbaiAPI
|
||||
var toApi *jdapi.API = partner.CurAPIManager.GetAPI(model.VendorIDJD, toStore.VendorOrgCode).(*jdapi.API)
|
||||
|
||||
taskName := fmt.Sprintf("将饿百平台门店[%s],分类和商品复制到[%s]", fromStore.VendorStoreID, toStore.VendorStoreID)
|
||||
config := tasksch.NewParallelConfig().SetParallelCount(1).SetIsContinueWhenError(false)
|
||||
work := func(task *tasksch.ParallelTask, batchItemList []interface{}, params ...interface{}) (retVal interface{}, err error) {
|
||||
step := batchItemList[0].(int)
|
||||
switch step {
|
||||
case 1:
|
||||
// 京东商品分类不做同步
|
||||
//fromCategoryList, err := api.ShopCategoryGet(utils.Int2Str(fromStore.ID))
|
||||
//if err != nil {
|
||||
// return nil, err
|
||||
//}
|
||||
//for _, v := range fromCategoryList {
|
||||
// categoryErr := toApi.RetailCatUpdate(toStore.VendorStoreID, v.Name, &mtwmapi.Param4UpdateCat{
|
||||
// CategoryCode: utils.Int64ToStr(v.CategoryID),
|
||||
// Sequence: v.Rank,
|
||||
// })
|
||||
// if categoryErr != nil {
|
||||
// globals.SugarLogger.Debugf("err := RetailCatUpdate : %v", categoryErr)
|
||||
// }
|
||||
// if v.Children != nil && len(v.Children) != 0 {
|
||||
// for _, c := range v.Children {
|
||||
// if err3 := toApi.RetailCatUpdate(toStore.VendorStoreID, v.Name, &mtwmapi.Param4UpdateCat{
|
||||
// CategoryNameOrigin: v.Name,
|
||||
// SecondaryCategoryCode: utils.Int64ToStr(c.CategoryID),
|
||||
// SecondaryCategoryName: c.Name,
|
||||
// Sequence: c.Rank,
|
||||
// }); err3 != nil {
|
||||
// globals.SugarLogger.Debugf("err := RetailCatUpdate Children : %v", err3)
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
//}
|
||||
|
||||
case 2:
|
||||
i := offSet
|
||||
for {
|
||||
// 同步商品
|
||||
fromFoodList, err1 := api.SkuList(utils.Int2Str(fromStore.ID), &ebaiapi.SkuListParams{
|
||||
Page: i,
|
||||
})
|
||||
if len(fromFoodList.List) == 0 || fromFoodList == nil {
|
||||
return nil, fmt.Errorf("fromFoodList 为空 %s ,i:= %d", utils.Format4Output(err1, false), i)
|
||||
}
|
||||
|
||||
err := BatchInitSkuEBai2Jd(ctx, fromFoodList.List, toApi, toStore.VendorStoreID, i)
|
||||
if err != nil {
|
||||
globals.SugarLogger.Debugf("BatchInitData : %v", err)
|
||||
}
|
||||
globals.SugarLogger.Debugf("==========页数[%d],数据长度[%d]", i, len(fromFoodList.List))
|
||||
if len(fromFoodList.List) < 100 {
|
||||
break
|
||||
}
|
||||
i++
|
||||
}
|
||||
}
|
||||
return
|
||||
}
|
||||
task := tasksch.NewParallelTask(taskName, config, ctx, work, []int{1, 2})
|
||||
tasksch.HandleTask(task, nil, true).Run()
|
||||
if !isAsync {
|
||||
_, err = task.GetResult(0)
|
||||
hint = "1"
|
||||
} else {
|
||||
hint = task.ID
|
||||
}
|
||||
|
||||
globals.SugarLogger.Debugf("======errrList := %s", utils.Format4Output(errList, false))
|
||||
return hint, errList, err
|
||||
|
||||
}
|
||||
|
||||
func BatchInitSkuEBai2Jd(ctx *jxcontext.Context, fromSku []*ebaiapi.SkuInfo, toApi *jdapi.API, vendorStoreID string, offset int) []error {
|
||||
errList := make([]error, 0, 0)
|
||||
for _, storeSku := range fromSku {
|
||||
param := &jdapi.OpSkuParam{
|
||||
TraceID: ctx.GetTrackInfo(),
|
||||
//ShopCategories: []int64{},
|
||||
//CategoryID: utils.Str2Int64(catMaps[0].JdID),
|
||||
CategoryID: 291, // 暂无分类
|
||||
BrandID: 35247,
|
||||
SkuName: storeSku.Name,
|
||||
SkuPrice: storeSku.SalePrice,
|
||||
Weight: float64(jxutils.IntWeight2Float(utils.Str2Int(storeSku.Weight))),
|
||||
FixedStatus: 1,
|
||||
IsSale: -1,
|
||||
Upc: storeSku.Upc,
|
||||
}
|
||||
if storeSku.CustomSkuId != "" {
|
||||
param.OutSkuID = storeSku.CustomSkuId
|
||||
} else {
|
||||
param.OutSkuID = utils.Int64ToStr(storeSku.SkuId)
|
||||
}
|
||||
photos := make([]string, 0, len(storeSku.Photos))
|
||||
for _, v := range storeSku.Photos {
|
||||
photos = append(photos, v.Url)
|
||||
}
|
||||
param.Images = photos
|
||||
//param.ShopCategories = append(param.ShopCategories, 16578930) // 暂无分类
|
||||
if storeSku.Rtf != "" {
|
||||
param.ProductDesc = fmt.Sprintf(`<img src="%s" alt="一张图片" />`, storeSku.Rtf)
|
||||
}
|
||||
skuID, err := toApi.AddSku2(param)
|
||||
if err != nil {
|
||||
errList = append(errList, err)
|
||||
}
|
||||
if skuID != "" {
|
||||
toApi.UpdateCurrentQty(ctx.GetTrackInfo(), vendorStoreID, utils.Str2Int64(skuID), storeSku.LeftNum)
|
||||
SaleStatus := []*jdapi.QueryStockRequest{
|
||||
&jdapi.QueryStockRequest{
|
||||
StationNo: vendorStoreID,
|
||||
SkuId: utils.Str2Int64(skuID),
|
||||
//DoSale: mtSku.IsSoldOut,
|
||||
},
|
||||
}
|
||||
if storeSku.Status == "1" {
|
||||
SaleStatus[0].DoSale = 0
|
||||
} else {
|
||||
SaleStatus[0].DoSale = 1
|
||||
}
|
||||
toApi.UpdateVendibility(ctx.GetTrackInfo(), SaleStatus)
|
||||
}
|
||||
}
|
||||
|
||||
return errList
|
||||
}
|
||||
|
||||
//#endregion
|
||||
|
||||
////#region 同步活动
|
||||
|
||||
@@ -2,7 +2,6 @@ package dao
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"git.rosy.net.cn/jx-callback/globals"
|
||||
"regexp"
|
||||
"strconv"
|
||||
"time"
|
||||
@@ -1147,8 +1146,6 @@ func GetOrders(db *DaoDB, ids []int64, isIncludeSku, isIncludeFake bool, fromDat
|
||||
sqlParams = append(sqlParams, pageSize, offset)
|
||||
txDB, _ := Begin(db)
|
||||
defer Commit(db, txDB)
|
||||
globals.SugarLogger.Debugf("------sql := %s", sql)
|
||||
globals.SugarLogger.Debugf("------sql := %s", utils.Format4Output(sqlParams, false))
|
||||
if err = GetRowsTx(txDB, &orders, sql, sqlParams...); err == nil {
|
||||
totalCount = GetLastTotalRowCount2(db, txDB)
|
||||
}
|
||||
|
||||
@@ -156,11 +156,12 @@ func (c *PurchaseHandler) onAfsOrderMsg(msg *mtwmapi.CallbackMsg) (retVal *mtwma
|
||||
//直接就来一个新的售后单,并且还是售后完成的
|
||||
if orderStatus.Status == model.AfsOrderStatusFinished {
|
||||
afsOrder.AfsFinishedAt = afsOrder.AfsCreatedAt
|
||||
afsOrder.Status = model.AfsOrderStatusFinished
|
||||
}
|
||||
// 补丁,这种类型的退款申请,不会在推送退款成功消息,直接将售后单标记为完成
|
||||
if strings.Contains(afsOrder.ReasonDesc, "商家开通极速退款服务,用户申请系统自动通过") {
|
||||
afsOrder.Status = model.AfsOrderStatusFinished
|
||||
afsOrder.AfsFinishedAt = time.Now()
|
||||
afsOrder.Status = model.AfsOrderStatusFinished
|
||||
}
|
||||
}
|
||||
err = partner.CurOrderManager.OnAfsOrderNew(afsOrder, orderStatus)
|
||||
|
||||
@@ -2,10 +2,7 @@ package controllers
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"git.rosy.net.cn/baseapi/platformapi/dingdingapi"
|
||||
"git.rosy.net.cn/baseapi/platformapi/mtwmapi"
|
||||
"git.rosy.net.cn/jx-callback/business/jxutils/ddmsg"
|
||||
"git.rosy.net.cn/jx-callback/business/model"
|
||||
"git.rosy.net.cn/jx-callback/business/model/dao"
|
||||
"git.rosy.net.cn/jx-callback/business/partner/purchase/mtwm"
|
||||
@@ -37,9 +34,7 @@ func (c *MtwmController) onCallbackMsg(msgType string) {
|
||||
json.Unmarshal([]byte(msg.FormData.Get("pick_up_data")), &finishedPickup)
|
||||
vendorStoreId = finishedPickup.AppPoiCode
|
||||
}
|
||||
if vendorStoreId == "" && msgType != "skuDelete" {
|
||||
ddmsg.SendUserMessage(dingdingapi.MsgTyeText, "2452A93EEB9111EC9B06525400E86DC0", "美团菜市推果园,果园退超市未找到门店", fmt.Sprintf("美团菜市推果园,获取平台门店ID异常cmd:%s,storeId:%s", msgType, vendorStoreId))
|
||||
}
|
||||
|
||||
if _, have := MTWMVendorStoreIDMap.Load(vendorStoreId); vendorStoreId != "" && !have {
|
||||
storeDetail, _ := dao.GetStoreDetailByVendorStoreID(dao.GetDB(), vendorStoreId, model.VendorIDMTWM, "")
|
||||
if storeDetail == nil {
|
||||
|
||||
Reference in New Issue
Block a user