This commit is contained in:
苏尹岚
2021-03-02 10:55:36 +08:00
12 changed files with 123 additions and 44 deletions

View File

@@ -2,6 +2,7 @@ package jd
import (
"fmt"
"strings"
"git.rosy.net.cn/baseapi/platformapi/jdapi"
"git.rosy.net.cn/baseapi/utils"
@@ -155,7 +156,7 @@ func skuInfo2Param(ctx *jxcontext.Context, sku *dao.StoreSkuSyncInfo) (param *jd
param = &jdapi.OpSkuParam{
TraceID: ctx.GetTrackInfo(),
OutSkuID: utils.Int2Str(sku.SkuID),
ShopCategories: []int64{utils.Str2Int64(sku.VendorCatID)},
ShopCategories: []int64{},
CategoryID: sku.VendorVendorCatID,
BrandID: DefBrandID,
SkuName: utils.LimitUTF8StringLen(sku.SkuName, jdapi.MaxSkuNameCharCount),
@@ -167,6 +168,9 @@ func skuInfo2Param(ctx *jxcontext.Context, sku *dao.StoreSkuSyncInfo) (param *jd
Upc: sku.Upc,
// Images: jxutils.BatchString2Slice(sku.Img, sku.Img2),
}
if sku.VendorCatID != "" {
param.ShopCategories = append(param.ShopCategories, utils.Str2Int64(sku.VendorCatID))
}
if sku.ImgMix != "" {
param.Images = jxutils.BatchString2Slice(sku.ImgMix, sku.Img2, sku.Img3)
} else {
@@ -194,6 +198,21 @@ func (p *PurchaseHandler) CreateSku2(ctx *jxcontext.Context, sku *dao.StoreSkuSy
param := skuInfo2Param(ctx, sku)
if globals.EnableJdStoreWrite {
sku.VendorSkuID, err = getAPI(sku.VendorOrgCode).AddSku2(param)
if err != nil && strings.Contains(err.Error(), jdapi.ErrMustUPC) {
result, err2 := getAPI(sku.VendorOrgCode).BatchAddSkuByUPC([]*jdapi.CreateByUpcParam2{
&jdapi.CreateByUpcParam2{
OutSkuId: utils.Int2Str(sku.SkuID),
Upc: sku.Upc,
JdPrice: utils.Int64ToStr(sku.Price),
ShopCategoryID: utils.Str2Int64WithDefault((sku.VendorCatID), 0),
},
})
if err2 == nil {
sku.VendorSkuID = result.SkuID
} else {
err = err2
}
}
} else {
sku.VendorSkuID = utils.Int64ToStr(jxutils.GenFakeID())
}

View File

@@ -306,7 +306,7 @@ func BuyerCancelOrder(ctx *jxcontext.Context, orderID int64, reason string) (can
return canceled, err
}
func Pay4Order(ctx *jxcontext.Context, orderID int64, payType int, vendorPayType string) (orderPay *model.OrderPay, err error) {
func Pay4Order(ctx *jxcontext.Context, orderID int64, payType int, vendorPayType, subAppID string) (orderPay *model.OrderPay, err error) {
var (
db = dao.GetDB()
)
@@ -319,7 +319,7 @@ func Pay4Order(ctx *jxcontext.Context, orderID int64, payType int, vendorPayType
err = dao.CreateEntity(dao.GetDB(), orderPay)
}
case model.PayTypeTL:
if orderPay, err = pay4OrderByTL(ctx, order, payType, vendorPayType); err == nil && orderPay != nil {
if orderPay, err = pay4OrderByTL(ctx, order, payType, vendorPayType, subAppID); err == nil && orderPay != nil {
dao.WrapAddIDCULDEntity(orderPay, ctx.GetUserName())
err = dao.CreateEntity(dao.GetDB(), orderPay)
}
@@ -336,7 +336,7 @@ func Pay4Order(ctx *jxcontext.Context, orderID int64, payType int, vendorPayType
ActualPayPrice: priceDefendOrders[0].ActualPayPrice,
VendorID: model.VendorIDJX,
}
if orderPay, err = pay4OrderByTL(ctx, order2, payType, vendorPayType); err == nil && orderPay != nil {
if orderPay, err = pay4OrderByTL(ctx, order2, payType, vendorPayType, subAppID); err == nil && orderPay != nil {
dao.WrapAddIDCULDEntity(orderPay, ctx.GetUserName())
err = dao.CreateEntity(dao.GetDB(), orderPay)
}
@@ -344,7 +344,7 @@ func Pay4Order(ctx *jxcontext.Context, orderID int64, payType int, vendorPayType
return orderPay, err
}
func Pay4User(ctx *jxcontext.Context, thingID int, vendorOrderID string, payType int, vendorPayType string) (orderPay *model.OrderPay, err error) {
func Pay4User(ctx *jxcontext.Context, thingID int, vendorOrderID string, payType int, vendorPayType, subAppID string) (orderPay *model.OrderPay, err error) {
var (
db = dao.GetDB()
order *model.GoodsOrder
@@ -368,7 +368,7 @@ func Pay4User(ctx *jxcontext.Context, thingID int, vendorOrderID string, payType
ActualPayPrice: int64(discountCard.Price),
VendorID: model.VendorIDJX,
}
if orderPay, err = pay4OrderByTL(ctx, order, payType, vendorPayType); err == nil && orderPay != nil {
if orderPay, err = pay4OrderByTL(ctx, order, payType, vendorPayType, subAppID); err == nil && orderPay != nil {
dao.WrapAddIDCULDEntity(orderPay, ctx.GetUserName())
err = dao.CreateEntity(dao.GetDB(), orderPay)
}
@@ -398,7 +398,7 @@ func Pay4User(ctx *jxcontext.Context, thingID int, vendorOrderID string, payType
ActualPayPrice: int64(storeOrder.ActualPayPrice),
VendorID: model.VendorIDJX,
}
if orderPay, err = pay4OrderByTL(ctx, order, payType, vendorPayType); err == nil && orderPay != nil {
if orderPay, err = pay4OrderByTL(ctx, order, payType, vendorPayType, subAppID); err == nil && orderPay != nil {
dao.WrapAddIDCULDEntity(orderPay, ctx.GetUserName())
err = dao.CreateEntity(dao.GetDB(), orderPay)
}

View File

@@ -18,7 +18,7 @@ import (
"git.rosy.net.cn/jx-callback/globals/api"
)
func pay4OrderByTL(ctx *jxcontext.Context, order *model.GoodsOrder, payType int, vendorPayType string) (orderPay *model.OrderPay, err error) {
func pay4OrderByTL(ctx *jxcontext.Context, order *model.GoodsOrder, payType int, vendorPayType, subAppID string) (orderPay *model.OrderPay, err error) {
// if order.FromStoreID != 0 {
// result, _ := orderman.GetMatterStoreOrderCount(nil, order.FromStoreID)
// if !result.Flag {
@@ -31,13 +31,14 @@ func pay4OrderByTL(ctx *jxcontext.Context, order *model.GoodsOrder, payType int,
NotifyUrl: globals.TLPayNotifyURL,
Reqsn: order.VendorOrderID,
PayType: vendorPayType,
SubAppID: subAppID,
}
//暂时做兼容处理
if vendorPayType == "JSAPI" {
param.PayType = tonglianpayapi.PayTypeWxXcx
}
if vendorPayType == tonglianpayapi.PayTypeWxXcx {
if authInfo, err := ctx.GetV2AuthInfo(); err == nil && authInfo.GetAuthType() == weixin.AuthTypeMini {
if authInfo, err := ctx.GetV2AuthInfo(); err == nil && authInfo.GetAuthType() == weixin.AuthTypeMini && authInfo.GetAuthTypeID() == subAppID {
param.Acct = authInfo.GetAuthID()
}
}