aa
This commit is contained in:
@@ -348,9 +348,9 @@ func Init() {
|
||||
jdsCookie = configs[0].Value
|
||||
api.JdShopAPI.SetCookieWithStr(jdsCookie)
|
||||
}
|
||||
if configs, err := dao.QueryConfigs(dao.GetDB(), "jdsCookie2", model.ConfigTypeCookie, ""); err == nil {
|
||||
api.JdShop2API.SetCookieWithStr(configs[0].Value)
|
||||
}
|
||||
// if configs, err := dao.QueryConfigs(dao.GetDB(), "jdsCookie2", model.ConfigTypeCookie, ""); err == nil {
|
||||
// api.JdShop2API.SetCookieWithStr(configs[0].Value)
|
||||
// }
|
||||
if configs, err := dao.QueryConfigs(dao.GetDB(), "yinbaoCookie", model.ConfigTypeCookie, ""); err == nil {
|
||||
yinbaoCookie := configs[0].Value
|
||||
api.YinBaoAPI.SetCookie(".POSPALAUTH30220", yinbaoCookie)
|
||||
|
||||
@@ -5,6 +5,7 @@ import (
|
||||
"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/dao"
|
||||
"git.rosy.net.cn/jx-callback/business/partner"
|
||||
"git.rosy.net.cn/jx-callback/business/partner/putils"
|
||||
"git.rosy.net.cn/jx-callback/globals"
|
||||
@@ -37,7 +38,13 @@ func getAPI(appOrgCode string) (apiObj *jdshopapi.API) {
|
||||
if appOrgCode == "" {
|
||||
globals.SugarLogger.Warnf("getAPI appOrgCode is empty")
|
||||
}
|
||||
return partner.CurAPIManager.GetAPI(model.VendorIDJDShop, appOrgCode).(*jdshopapi.API)
|
||||
apiObj = partner.CurAPIManager.GetAPI(model.VendorIDJDShop, appOrgCode).(*jdshopapi.API)
|
||||
if appOrgCode == "2" {
|
||||
if configs, err := dao.QueryConfigs(dao.GetDB(), "jdsCookie2", model.ConfigTypeCookie, ""); err == nil {
|
||||
apiObj.SetCookieWithStr(configs[0].Value)
|
||||
}
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
func (p *PurchaseHandler) GetVendorID() int {
|
||||
@@ -47,7 +54,7 @@ func (p *PurchaseHandler) GetVendorID() int {
|
||||
func (p *PurchaseHandler) UploadImg(ctx *jxcontext.Context, vendorOrgCode, imgURL string, imgData []byte, imgName string, imgType int) (imgHint string, err error) {
|
||||
if globals.EnableJdShopWrite {
|
||||
if imgType > model.ImgTypeLocal {
|
||||
result, err := api.JdShopAPI.UploadPicture(imgData, 0, imgName)
|
||||
result, err := getAPI(vendorOrgCode).UploadPicture(imgData, 0, imgName)
|
||||
if err == nil {
|
||||
imgHint = result.PictureURL
|
||||
}
|
||||
|
||||
@@ -61,7 +61,7 @@ func (p *PurchaseHandler) AcceptOrRefuseOrder(order *model.GoodsOrder, isAcceptI
|
||||
status = model.OrderStatusAccepted
|
||||
//京东商城第二个号要自动接单
|
||||
if order.VendorOrgCode == "2" {
|
||||
err = api.JdShop2API.SetOrderStateToWait(utils.Str2Int64(order.VendorOrderID2))
|
||||
err = getAPI(order.VendorOrgCode).SetOrderStateToWait(utils.Str2Int64(order.VendorOrderID2))
|
||||
}
|
||||
} else {
|
||||
status = model.OrderStatusCanceled
|
||||
@@ -106,7 +106,7 @@ func (p *PurchaseHandler) SelfDeliverDelivering(order *model.GoodsOrder, userNam
|
||||
func (p *PurchaseHandler) SelfDeliverDelivered(order *model.GoodsOrder, userName string) (err error) {
|
||||
ChangeOrderStatus(order.VendorOrderID, model.OrderStatusFinished, "")
|
||||
if order.VendorOrgCode == "2" {
|
||||
api.JdShop2API.SetOrderStateToFinish(utils.Str2Int64(order.VendorOrderID2))
|
||||
getAPI(order.VendorOrgCode).SetOrderStateToFinish(utils.Str2Int64(order.VendorOrderID2))
|
||||
}
|
||||
return err
|
||||
}
|
||||
|
||||
@@ -100,7 +100,7 @@ func (p *PurchaseHandler) CreateStore2(db *dao.DaoDB, storeID int, userName stri
|
||||
CategoryName: jdshopapi.JdsStoreCategoryName,
|
||||
CustomerID: utils.Int2Str(store.ID),
|
||||
}
|
||||
url, _ := api.JdShop2API.UploadImageNew(data, "2659335b16e3880e367759b8fc675933.tem.png")
|
||||
url, _ := getAPI("2").UploadImageNew(data, "2659335b16e3880e367759b8fc675933.tem.png")
|
||||
ex := store.LicenceExpire
|
||||
if ex == "" {
|
||||
ex = utils.Time2Str(utils.Str2Time(store.LicenceValid).AddDate(0, 6, 0))
|
||||
@@ -112,7 +112,7 @@ func (p *PurchaseHandler) CreateStore2(db *dao.DaoDB, storeID int, userName stri
|
||||
if store.Licence != "" {
|
||||
data2, _, _ := jxutils.DownloadFileByURL(store.Licence)
|
||||
fileName := store.Licence[strings.LastIndex(store.Licence, "/")+1 : len(store.Licence)]
|
||||
url2, _ = api.JdShop2API.UploadImageNew(data2, fileName)
|
||||
url2, _ = getAPI("2").UploadImageNew(data2, fileName)
|
||||
}
|
||||
storeName := store.Name
|
||||
if strings.Contains(storeName, "(") {
|
||||
@@ -197,9 +197,9 @@ func (p *PurchaseHandler) CreateStore2(db *dao.DaoDB, storeID int, userName stri
|
||||
}
|
||||
}
|
||||
vendorStoreID, err = api.JdShopAPI.CreateEntityStore(createEntityStoreParam)
|
||||
if vendorStroeID2, err := api.JdShop2API.SubmitBasic(param); err == nil {
|
||||
if vendorStroeID2, err := getAPI("2").SubmitBasic(param); err == nil {
|
||||
time.Sleep(time.Second)
|
||||
err = api.JdShop2API.UpdateExpand(int(vendorStroeID2))
|
||||
err = getAPI("2").UpdateExpand(int(vendorStroeID2))
|
||||
var storeMap *model.StoreMap
|
||||
sql := `
|
||||
SELECT * FROM store_map WHERE deletad_at = ? AND store_id = ? AND vendor_id = ? AND vendor_org_code = ?
|
||||
|
||||
@@ -58,7 +58,7 @@ func (p *PurchaseHandler) CreateStoreSkus(ctx *jxcontext.Context, storeID int, v
|
||||
}
|
||||
}
|
||||
if v.VendorOrgCode == "2" && flag2 {
|
||||
err = api.JdShop2API.WareDoUpdate("op", utils.Int64ToStr(v.JdsWareID))
|
||||
err = getAPI(v.VendorOrgCode).WareDoUpdate("op", utils.Int64ToStr(v.JdsWareID))
|
||||
} else {
|
||||
if result.TotalItem > 0 && len(result.Data) > 0 && flag {
|
||||
//jds2
|
||||
@@ -82,7 +82,7 @@ func (p *PurchaseHandler) CreateStoreSkus(ctx *jxcontext.Context, storeID int, v
|
||||
var wareSaveSkus []*jdshopapi.WareSaveSkus
|
||||
//先把已有的规格放进去
|
||||
if v.VendorOrgCode == "2" {
|
||||
wareResult, _ := api.JdShop2API.FindWareById(wareSaveParam.WareID)
|
||||
wareResult, _ := getAPI(v.VendorOrgCode).FindWareById(wareSaveParam.WareID)
|
||||
if wareResult != nil {
|
||||
for _, v := range wareResult.Images {
|
||||
wareSaveParam.ImageMap.Num0000000000 = append(wareSaveParam.ImageMap.Num0000000000, &jdshopapi.CreateSkuParamImages{
|
||||
@@ -92,7 +92,7 @@ func (p *PurchaseHandler) CreateStoreSkus(ctx *jxcontext.Context, storeID int, v
|
||||
})
|
||||
}
|
||||
}
|
||||
skus, _, _ := api.JdShop2API.SearchSkuList2([]int{int(wareSaveParam.WareID)})
|
||||
skus, _, _ := getAPI(v.VendorOrgCode).SearchSkuList2([]int{int(wareSaveParam.WareID)})
|
||||
if len(skus) > 0 {
|
||||
for _, vv := range skus {
|
||||
sku := &jdshopapi.WareSaveSkus{
|
||||
@@ -138,8 +138,8 @@ func (p *PurchaseHandler) CreateStoreSkus(ctx *jxcontext.Context, storeID int, v
|
||||
}
|
||||
}
|
||||
//创建商品后要上架,改价,库存,门店关注商品等
|
||||
if err = api.JdShop2API.WareDoUpdate("up", utils.Int64ToStr(wareSaveParam.WareID)); err == nil {
|
||||
err = api.JdShop2API.StoreSkuBindStore(true, []string{vv.VendorSkuID}, nil)
|
||||
if err = getAPI(v.VendorOrgCode).WareDoUpdate("up", utils.Int64ToStr(wareSaveParam.WareID)); err == nil {
|
||||
err = getAPI(v.VendorOrgCode).StoreSkuBindStore(true, []string{vv.VendorSkuID}, nil)
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -181,7 +181,7 @@ func (p *PurchaseHandler) CreateStoreSkus(ctx *jxcontext.Context, storeID int, v
|
||||
} else {
|
||||
var createSkuResult []*jdshopapi.WareSaveResult
|
||||
for i := 0; i < 10; i++ {
|
||||
createSkuResult, err = api.JdShop2API.WareSave(wareSaveParam)
|
||||
createSkuResult, err = getAPI(v.VendorOrgCode).WareSave(wareSaveParam)
|
||||
if len(createSkuResult) > 0 {
|
||||
break
|
||||
}
|
||||
@@ -209,10 +209,10 @@ func (p *PurchaseHandler) CreateStoreSkus(ctx *jxcontext.Context, storeID int, v
|
||||
}
|
||||
}
|
||||
//创建商品后要上架,改价,库存,门店关注商品等
|
||||
if err = api.JdShop2API.WareDoUpdate("up", utils.Int64ToStr(wareID)); err == nil {
|
||||
if err = getAPI(v.VendorOrgCode).WareDoUpdate("up", utils.Int64ToStr(wareID)); err == nil {
|
||||
for _, vv2 := range v.StoreSkuSyncInfoJds {
|
||||
if resultAttrs[utils.Int2Str(vv2.SkuID)] != 0 {
|
||||
err = api.JdShop2API.StoreSkuBindStore(true, []string{utils.Int64ToStr(resultAttrs[utils.Int2Str(vv2.SkuID)])}, nil)
|
||||
err = getAPI(v.VendorOrgCode).StoreSkuBindStore(true, []string{utils.Int64ToStr(resultAttrs[utils.Int2Str(vv2.SkuID)])}, nil)
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -259,20 +259,20 @@ func (p *PurchaseHandler) CreateStoreSkus(ctx *jxcontext.Context, storeID int, v
|
||||
stock := vv.Stock
|
||||
price := vv.VendorPrice
|
||||
if status == model.StoreSkuBindStatusNormal {
|
||||
err = api.JdShop2API.StoreWareDoUpdate(status, storeSku.JdsID, vendorStoreID)
|
||||
err = getAPI(vv.VendorOrgCode).StoreWareDoUpdate(status, storeSku.JdsID, vendorStoreID)
|
||||
if err != nil {
|
||||
failedList = putils.GetErrMsg2FailedSingleList(storeSkuList, err, storeID, model.VendorChineseNames[model.VendorIDJDShop], "创建商品")
|
||||
return failedList, err
|
||||
}
|
||||
}
|
||||
if stock != 0 {
|
||||
err = api.JdShop2API.StoreUpdateStock(stock, storeSku.JdsID, vendorStoreID)
|
||||
err = getAPI(vv.VendorOrgCode).StoreUpdateStock(stock, storeSku.JdsID, vendorStoreID)
|
||||
if err != nil {
|
||||
failedList = putils.GetErrMsg2FailedSingleList(storeSkuList, err, storeID, model.VendorChineseNames[model.VendorIDJDShop], "创建商品")
|
||||
return failedList, err
|
||||
}
|
||||
}
|
||||
err = api.JdShop2API.StoreUpdatePrice(utils.Float64ToStr(jxutils.IntPrice2Standard(int64(price))), storeSku.JdsID, vendorStoreID)
|
||||
err = getAPI(v.VendorOrgCode).StoreUpdatePrice(utils.Float64ToStr(jxutils.IntPrice2Standard(int64(price))), storeSku.JdsID, vendorStoreID)
|
||||
}
|
||||
}
|
||||
if err != nil {
|
||||
@@ -440,7 +440,7 @@ func (p *PurchaseHandler) UpdateStoreSkus(ctx *jxcontext.Context, storeID int, v
|
||||
wareSaveSku.SkuID = utils.Str2Int64(vv.VendorSkuID)
|
||||
wareSaveSkus = append(wareSaveSkus, wareSaveSku)
|
||||
}
|
||||
api.JdShop2API.WareSave(wareSaveParam)
|
||||
getAPI("2").WareSave(wareSaveParam)
|
||||
}
|
||||
}
|
||||
if err != nil {
|
||||
@@ -462,7 +462,7 @@ func (p *PurchaseHandler) DeleteStoreSkus(ctx *jxcontext.Context, storeID int, v
|
||||
err = getAPI(v.VendorOrgCode).DeleteWare(utils.Str2Int(v.VendorSkuID2))
|
||||
}
|
||||
} else {
|
||||
err = api.JdShop2API.WareDoUpdate("down", v.VendorSkuID2)
|
||||
err = getAPI(v.VendorOrgCode).WareDoUpdate("down", v.VendorSkuID2)
|
||||
}
|
||||
}
|
||||
if err != nil {
|
||||
@@ -531,7 +531,7 @@ func (p *PurchaseHandler) UpdateStoreSkusStatus(ctx *jxcontext.Context, vendorOr
|
||||
}
|
||||
} else {
|
||||
if vendorSkuID, err := getMainStoreVendorSkuID(model.JdShopMainStoreID2, v.SkuID); err == nil && vendorSkuID != 0 {
|
||||
err = api.JdShop2API.StoreWareDoUpdate(status, vendorSkuID, vendorStoreID)
|
||||
err = getAPI(v.VendorOrgCode).StoreWareDoUpdate(status, vendorSkuID, vendorStoreID)
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -555,7 +555,7 @@ func (p *PurchaseHandler) UpdateStoreSkusPrice(ctx *jxcontext.Context, vendorOrg
|
||||
// null
|
||||
} else {
|
||||
if vendorSkuID, err := getMainStoreVendorSkuID(model.JdShopMainStoreID2, v.SkuID); err == nil && vendorSkuID != 0 {
|
||||
err = api.JdShop2API.StoreUpdatePrice(utils.Float64ToStr(jxutils.IntPrice2Standard(v.VendorPrice)), vendorSkuID, vendorStoreID)
|
||||
err = getAPI(v.VendorOrgCode).StoreUpdatePrice(utils.Float64ToStr(jxutils.IntPrice2Standard(v.VendorPrice)), vendorSkuID, vendorStoreID)
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -579,7 +579,7 @@ func (p *PurchaseHandler) UpdateStoreSkusStock(ctx *jxcontext.Context, vendorOrg
|
||||
|
||||
} else {
|
||||
if vendorSkuID, err := getMainStoreVendorSkuID(model.JdShopMainStoreID2, v.SkuID); err == nil && vendorSkuID != 0 {
|
||||
err = api.JdShop2API.StoreUpdateStock(v.Stock, vendorSkuID, vendorStoreID)
|
||||
err = getAPI(v.VendorOrgCode).StoreUpdateStock(v.Stock, vendorSkuID, vendorStoreID)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user