- 京东handler不直接依赖api.JdAPI

This commit is contained in:
gazebo
2019-08-28 14:25:29 +08:00
parent da6fdd4c8e
commit cf4202a41b
13 changed files with 113 additions and 112 deletions

View File

@@ -10,7 +10,6 @@ import (
"git.rosy.net.cn/jx-callback/business/jxutils" "git.rosy.net.cn/jx-callback/business/jxutils"
"git.rosy.net.cn/jx-callback/globals" "git.rosy.net.cn/jx-callback/globals"
"git.rosy.net.cn/jx-callback/globals/api"
"git.rosy.net.cn/baseapi/platformapi/jdapi" "git.rosy.net.cn/baseapi/platformapi/jdapi"
"git.rosy.net.cn/baseapi/utils" "git.rosy.net.cn/baseapi/utils"
@@ -63,9 +62,9 @@ func jdSkuActStatus2Jx(jdActState int) int {
func CreatePromotionInfos(promotionType int, name string, beginDate, endDate time.Time, outInfoId, advertising, traceId string) (infoId int64, err error) { func CreatePromotionInfos(promotionType int, name string, beginDate, endDate time.Time, outInfoId, advertising, traceId string) (infoId int64, err error) {
if globals.EnableJdStoreWrite { if globals.EnableJdStoreWrite {
if promotionType == model.ActSkuDirectDown { if promotionType == model.ActSkuDirectDown {
return api.JdAPI.CreatePromotionInfosSingle(name, beginDate, endDate, outInfoId, advertising, traceId) return getAPI("").CreatePromotionInfosSingle(name, beginDate, endDate, outInfoId, advertising, traceId)
} else { } else {
return api.JdAPI.CreatePromotionInfosLimitTime(name, beginDate, endDate, outInfoId, advertising, traceId) return getAPI("").CreatePromotionInfosLimitTime(name, beginDate, endDate, outInfoId, advertising, traceId)
} }
} else { } else {
infoId = jxutils.GenFakeID() infoId = jxutils.GenFakeID()
@@ -76,9 +75,9 @@ func CreatePromotionInfos(promotionType int, name string, beginDate, endDate tim
func CreatePromotionRules(promotionType int, infoId int64, outInfoId string, limitDevice, limitPin, limitCount, limitDaily int, traceId string) (err error) { func CreatePromotionRules(promotionType int, infoId int64, outInfoId string, limitDevice, limitPin, limitCount, limitDaily int, traceId string) (err error) {
if globals.EnableJdStoreWrite { if globals.EnableJdStoreWrite {
if promotionType == model.ActSkuDirectDown { if promotionType == model.ActSkuDirectDown {
return api.JdAPI.CreatePromotionRulesSingle(infoId, outInfoId, limitDevice, limitPin, limitCount, limitDaily, traceId) return getAPI("").CreatePromotionRulesSingle(infoId, outInfoId, limitDevice, limitPin, limitCount, limitDaily, traceId)
} else { } else {
return api.JdAPI.CreatePromotionRulesLimitTime(infoId, outInfoId, limitDevice, limitPin, limitCount, limitDaily, traceId) return getAPI("").CreatePromotionRulesLimitTime(infoId, outInfoId, limitDevice, limitPin, limitCount, limitDaily, traceId)
} }
} }
return err return err
@@ -90,9 +89,9 @@ func CreatePromotionSku(promotionType int, infoId int64, outInfoId string, skus
var tmpSkusResult []*jdapi.PromotionSku var tmpSkusResult []*jdapi.PromotionSku
var tmpErr error var tmpErr error
if promotionType == model.ActSkuDirectDown { if promotionType == model.ActSkuDirectDown {
tmpSkusResult, tmpErr = api.JdAPI.CreatePromotionSkuSingle(infoId, outInfoId, batchSkus, traceId) tmpSkusResult, tmpErr = getAPI("").CreatePromotionSkuSingle(infoId, outInfoId, batchSkus, traceId)
} else { } else {
tmpSkusResult, tmpErr = api.JdAPI.CreatePromotionSkuLimitTime(infoId, outInfoId, batchSkus, traceId) tmpSkusResult, tmpErr = getAPI("").CreatePromotionSkuLimitTime(infoId, outInfoId, batchSkus, traceId)
} }
if err = tmpErr; err != nil { if err = tmpErr; err != nil {
break break
@@ -108,9 +107,9 @@ func CancelPromotionSku(promotionType int, infoId int64, outInfoId string, skus
for _, batchSkus := range splitPromotionSku(skus, jdapi.MaxPromotionSkuCount) { for _, batchSkus := range splitPromotionSku(skus, jdapi.MaxPromotionSkuCount) {
var tmpErr error var tmpErr error
if promotionType == model.ActSkuDirectDown { if promotionType == model.ActSkuDirectDown {
tmpErr = api.JdAPI.CancelPromotionSkuSingle(infoId, outInfoId, batchSkus, traceId) tmpErr = getAPI("").CancelPromotionSkuSingle(infoId, outInfoId, batchSkus, traceId)
} else { } else {
tmpErr = api.JdAPI.CancelPromotionSkuLimitTime(infoId, outInfoId, batchSkus, traceId) tmpErr = getAPI("").CancelPromotionSkuLimitTime(infoId, outInfoId, batchSkus, traceId)
} }
if err = tmpErr; err != nil { if err = tmpErr; err != nil {
break break
@@ -123,9 +122,9 @@ func CancelPromotionSku(promotionType int, infoId int64, outInfoId string, skus
func ConfirmPromotion(promotionType int, infoId int64, outInfoId, traceId string) (err error) { func ConfirmPromotion(promotionType int, infoId int64, outInfoId, traceId string) (err error) {
if globals.EnableJdStoreWrite { if globals.EnableJdStoreWrite {
if promotionType == model.ActSkuDirectDown { if promotionType == model.ActSkuDirectDown {
return api.JdAPI.ConfirmPromotionSingle(infoId, outInfoId, traceId) return getAPI("").ConfirmPromotionSingle(infoId, outInfoId, traceId)
} else { } else {
return api.JdAPI.ConfirmPromotionLimitTime(infoId, outInfoId, traceId) return getAPI("").ConfirmPromotionLimitTime(infoId, outInfoId, traceId)
} }
} }
return err return err
@@ -134,9 +133,9 @@ func ConfirmPromotion(promotionType int, infoId int64, outInfoId, traceId string
func CancelPromotion(promotionType int, infoId int64, outInfoId, traceId string) (err error) { func CancelPromotion(promotionType int, infoId int64, outInfoId, traceId string) (err error) {
if globals.EnableJdStoreWrite { if globals.EnableJdStoreWrite {
if promotionType == model.ActSkuDirectDown { if promotionType == model.ActSkuDirectDown {
return api.JdAPI.CancelPromotionSingle(infoId, outInfoId, traceId) return getAPI("").CancelPromotionSingle(infoId, outInfoId, traceId)
} else { } else {
return api.JdAPI.CancelPromotionLimitTime(infoId, outInfoId, traceId) return getAPI("").CancelPromotionLimitTime(infoId, outInfoId, traceId)
} }
} }
return err return err
@@ -145,9 +144,9 @@ func CancelPromotion(promotionType int, infoId int64, outInfoId, traceId string)
func AdjustPromotionTime(promotionType int, infoId int64, outInfoId string, endDate time.Time, traceId string) (err error) { func AdjustPromotionTime(promotionType int, infoId int64, outInfoId string, endDate time.Time, traceId string) (err error) {
if globals.EnableJdStoreWrite { if globals.EnableJdStoreWrite {
if promotionType == model.ActSkuDirectDown { if promotionType == model.ActSkuDirectDown {
return api.JdAPI.AdjustPromotionTimeSingle(infoId, outInfoId, endDate, traceId) return getAPI("").AdjustPromotionTimeSingle(infoId, outInfoId, endDate, traceId)
} else { } else {
return api.JdAPI.AdjustPromotionTimeLimitTime(infoId, outInfoId, endDate, traceId) return getAPI("").AdjustPromotionTimeLimitTime(infoId, outInfoId, endDate, traceId)
} }
} }
return err return err
@@ -156,9 +155,9 @@ func AdjustPromotionTime(promotionType int, infoId int64, outInfoId string, endD
func AdjustPromotionSku(promotionType int, infoId int64, outInfoId string, skus []*jdapi.PromotionSku, traceId string) (skusResult []*jdapi.PromotionSku, err error) { func AdjustPromotionSku(promotionType int, infoId int64, outInfoId string, skus []*jdapi.PromotionSku, traceId string) (skusResult []*jdapi.PromotionSku, err error) {
if globals.EnableJdStoreWrite { if globals.EnableJdStoreWrite {
if promotionType == model.ActSkuDirectDown { if promotionType == model.ActSkuDirectDown {
return api.JdAPI.AdjustPromotionSkuSingle(infoId, outInfoId, skus, traceId) return getAPI("").AdjustPromotionSkuSingle(infoId, outInfoId, skus, traceId)
} else { } else {
return api.JdAPI.AdjustPromotionSkuLimitTime(infoId, outInfoId, skus, traceId) return getAPI("").AdjustPromotionSkuLimitTime(infoId, outInfoId, skus, traceId)
} }
} }
return skusResult, err return skusResult, err
@@ -327,7 +326,7 @@ func (c *PurchaseHandler) onActMsg(msg *jdapi.CallbackOrderMsg) (retVal *jdapi.C
} }
func getActFromJD(promotionID string) (act *model.Act2, actStoreSkuList []*model.ActStoreSku2, err error) { func getActFromJD(promotionID string) (act *model.Act2, actStoreSkuList []*model.ActStoreSku2, err error) {
result, err := api.JdAPI.QueryPromotionInfo(utils.Str2Int64(promotionID)) result, err := getAPI("").QueryPromotionInfo(utils.Str2Int64(promotionID))
if err == nil && len(result.SkuResultList) > 0 { if err == nil && len(result.SkuResultList) > 0 {
act = &model.Act2{ act = &model.Act2{
Act: model.Act{ Act: model.Act{

View File

@@ -6,7 +6,6 @@ import (
"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"
"git.rosy.net.cn/jx-callback/globals" "git.rosy.net.cn/jx-callback/globals"
"git.rosy.net.cn/jx-callback/globals/api"
) )
func (p *PurchaseHandler) OnFinancialMsg(msg *jdapi.CallbackOrderMsg) (retVal *jdapi.CallbackResponse) { func (p *PurchaseHandler) OnFinancialMsg(msg *jdapi.CallbackOrderMsg) (retVal *jdapi.CallbackResponse) {
@@ -23,7 +22,7 @@ func (p *PurchaseHandler) onFinancialMsg(msg *jdapi.CallbackOrderMsg) (retVal *j
if msg.StatusID == jdapi.OrderStatusPayFinishedSettle || msg.StatusID == jdapi.OrderStatusTipChanged || msg.StatusID == jdapi.OrderStatusAdjustSettle || msg.StatusID == jdapi.OrderStatusSwitch2SelfSettle { // 如果是正向单 if msg.StatusID == jdapi.OrderStatusPayFinishedSettle || msg.StatusID == jdapi.OrderStatusTipChanged || msg.StatusID == jdapi.OrderStatusAdjustSettle || msg.StatusID == jdapi.OrderStatusSwitch2SelfSettle { // 如果是正向单
order, err2 := partner.CurOrderManager.LoadOrder(msg.BillID, model.VendorIDJD) order, err2 := partner.CurOrderManager.LoadOrder(msg.BillID, model.VendorIDJD)
if err = err2; err == nil { if err = err2; err == nil {
orderData, err2 := api.JdAPI.QuerySingleOrder(msg.BillID) orderData, err2 := getAPI("").QuerySingleOrder(msg.BillID)
if err = err2; err == nil { if err = err2; err == nil {
orderFinancial, err2 := curPurchaseHandler.OrderDetail2Financial(orderData, false, order) orderFinancial, err2 := curPurchaseHandler.OrderDetail2Financial(orderData, false, order)
if err = err2; err == nil { if err = err2; err == nil {
@@ -38,7 +37,7 @@ func (p *PurchaseHandler) onFinancialMsg(msg *jdapi.CallbackOrderMsg) (retVal *j
err = nil err = nil
} }
} else if msg.StatusID == jdapi.AfsServiceStateRefundSuccess || msg.StatusID == jdapi.AfsServiceStateReturnGoodsSuccess { // 如果是退款单 } else if msg.StatusID == jdapi.AfsServiceStateRefundSuccess || msg.StatusID == jdapi.AfsServiceStateReturnGoodsSuccess { // 如果是退款单
orderData, err2 := api.JdAPI.GetAfsService(msg.BillID) orderData, err2 := getAPI("").GetAfsService(msg.BillID)
if err = err2; err == nil { if err = err2; err == nil {
err = partner.CurOrderManager.SaveAfsOrderFinancialInfo(curPurchaseHandler.AfsOrderDetail2Financial(orderData)) err = partner.CurOrderManager.SaveAfsOrderFinancialInfo(curPurchaseHandler.AfsOrderDetail2Financial(orderData))
} }
@@ -152,7 +151,7 @@ func (p *PurchaseHandler) OrderDetail2Financial(orderData map[string]interface{}
} }
globals.SugarLogger.Debug(utils.Format4Output(orderFinancial.Discounts, false)) globals.SugarLogger.Debug(utils.Format4Output(orderFinancial.Discounts, false))
} }
order1, err2 := api.JdAPI.OrderShoudSettlementService(orderFinancial.VendorOrderID) order1, err2 := getAPI("").OrderShoudSettlementService(orderFinancial.VendorOrderID)
if err = err2; err == nil { if err = err2; err == nil {
orderFinancial.ShopMoney = utils.Interface2Int64WithDefault(order1["settlementAmount"], 0) orderFinancial.ShopMoney = utils.Interface2Int64WithDefault(order1["settlementAmount"], 0)
orderFinancial.PmMoney += utils.Interface2Int64WithDefault(order1["goodsCommission"], 0) orderFinancial.PmMoney += utils.Interface2Int64WithDefault(order1["goodsCommission"], 0)
@@ -163,7 +162,7 @@ func (p *PurchaseHandler) OrderDetail2Financial(orderData map[string]interface{}
orderFinancial.PmSubsidyMoney = utils.Interface2Int64WithDefault(order1["platOrderGoodsDiscountMoney"], 0) + orderFinancial.PmSkuSubsidyMoney orderFinancial.PmSubsidyMoney = utils.Interface2Int64WithDefault(order1["platOrderGoodsDiscountMoney"], 0) + orderFinancial.PmSkuSubsidyMoney
} else { } else {
if !isFromOrderDetail { if !isFromOrderDetail {
// globals.SugarLogger.Warnf("jd OrderDetail2Financial, orderID:%s is not found from api.JdAPI.OrderShoudSettlementService, err:%v", orderFinancial.VendorOrderID, err) // globals.SugarLogger.Warnf("jd OrderDetail2Financial, orderID:%s is not found from getAPI("").OrderShoudSettlementService, err:%v", orderFinancial.VendorOrderID, err)
} }
} }
return orderFinancial, err return orderFinancial, err

View File

@@ -6,7 +6,7 @@ import (
"git.rosy.net.cn/jx-callback/business/jxutils/jxcontext" "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"
"git.rosy.net.cn/jx-callback/globals/api" "git.rosy.net.cn/jx-callback/globals"
) )
type PurchaseHandler struct { type PurchaseHandler struct {
@@ -18,7 +18,8 @@ var (
) )
func init() { func init() {
if api.JdAPI != nil { globals.SugarLogger.Debug("init jd")
if getAPI("") != nil {
curPurchaseHandler = new(PurchaseHandler) curPurchaseHandler = new(PurchaseHandler)
partner.RegisterPurchasePlatform(curPurchaseHandler) partner.RegisterPurchasePlatform(curPurchaseHandler)
} }

View File

@@ -48,7 +48,7 @@ func (c *PurchaseHandler) updateOrderFinancialInfo(orderID string) (err error) {
VendorOrderID: orderID, VendorOrderID: orderID,
VendorID: model.VendorIDJD, VendorID: model.VendorIDJD,
} }
orderSettlement, err := api.JdAPI.OrderShoudSettlementService2(orderID) orderSettlement, err := getAPI("").OrderShoudSettlementService2(orderID)
if err == nil { if err == nil {
if orderSettlement != nil { if orderSettlement != nil {
updateOrderBySettleMent(order, orderSettlement) updateOrderBySettleMent(order, orderSettlement)
@@ -112,16 +112,16 @@ func (c *PurchaseHandler) getOrder(orderID string) (order *model.GoodsOrder, ord
taskIndex := batchItemList[0].(int) taskIndex := batchItemList[0].(int)
switch taskIndex { switch taskIndex {
case 0: case 0:
orderMap, err = api.JdAPI.QuerySingleOrder(orderID) orderMap, err = getAPI("").QuerySingleOrder(orderID)
if err == nil { if err == nil {
order = c.Map2Order(orderMap) order = c.Map2Order(orderMap)
realMobile, _ = api.JdAPI.GetRealMobile4Order(orderID, order.VendorStoreID) realMobile, _ = getAPI("").GetRealMobile4Order(orderID, order.VendorStoreID)
if realMobile != "" { if realMobile != "" {
order.ConsigneeMobile2 = jxutils.FormalizeMobile(realMobile) order.ConsigneeMobile2 = jxutils.FormalizeMobile(realMobile)
} }
} }
case 1: case 1:
orderSettlement, _ = api.JdAPI.OrderShoudSettlementService2(orderID) orderSettlement, _ = getAPI("").OrderShoudSettlementService2(orderID)
} }
return nil, err return nil, err
}, []int{0, 1}) }, []int{0, 1})
@@ -130,11 +130,11 @@ func (c *PurchaseHandler) getOrder(orderID string) (order *model.GoodsOrder, ord
if order != nil && orderSettlement != nil { if order != nil && orderSettlement != nil {
updateOrderBySettleMent(order, orderSettlement) updateOrderBySettleMent(order, orderSettlement)
} }
// if orderMap, err = api.JdAPI.QuerySingleOrder(orderID); err == nil { // if orderMap, err = getAPI("").QuerySingleOrder(orderID); err == nil {
// globals.SugarLogger.Debugf("jd getOrder2 orderID:%s", orderID) // globals.SugarLogger.Debugf("jd getOrder2 orderID:%s", orderID)
// order = c.Map2Order(orderMap) // order = c.Map2Order(orderMap)
// if jxutils.IsMobileFake(order.ConsigneeMobile) { // if jxutils.IsMobileFake(order.ConsigneeMobile) {
// if realMobile, err := api.JdAPI.GetRealMobile4Order(orderID, order.VendorStoreID); err == nil { // 故意强制忽略取不到真实手机号错误 // if realMobile, err := getAPI("").GetRealMobile4Order(orderID, order.VendorStoreID); err == nil { // 故意强制忽略取不到真实手机号错误
// globals.SugarLogger.Debugf("jd getOrder3 orderID:%s", orderID) // globals.SugarLogger.Debugf("jd getOrder3 orderID:%s", orderID)
// order.ConsigneeMobile2 = jxutils.FormalizeMobile(realMobile) // order.ConsigneeMobile2 = jxutils.FormalizeMobile(realMobile)
// } else { // } else {
@@ -297,7 +297,7 @@ func (c *PurchaseHandler) getStatusFromVendorStatus(vendorStatus string) int {
func (c *PurchaseHandler) AcceptOrRefuseOrder(order *model.GoodsOrder, isAcceptIt bool, userName string) (err error) { func (c *PurchaseHandler) AcceptOrRefuseOrder(order *model.GoodsOrder, isAcceptIt bool, userName string) (err error) {
globals.SugarLogger.Debugf("jd AcceptOrRefuseOrder orderID:%s, isAcceptIt:%t", order.VendorOrderID, isAcceptIt) globals.SugarLogger.Debugf("jd AcceptOrRefuseOrder orderID:%s, isAcceptIt:%t", order.VendorOrderID, isAcceptIt)
if globals.EnableStoreWrite { if globals.EnableStoreWrite {
err = api.JdAPI.OrderAcceptOperate(order.VendorOrderID, isAcceptIt, userName) err = getAPI("").OrderAcceptOperate(order.VendorOrderID, isAcceptIt, userName)
} else { } else {
c.postFakeMsg(order.VendorOrderID, jdapi.StatusIDWaitOutStore) c.postFakeMsg(order.VendorOrderID, jdapi.StatusIDWaitOutStore)
} }
@@ -307,7 +307,7 @@ func (c *PurchaseHandler) AcceptOrRefuseOrder(order *model.GoodsOrder, isAcceptI
func (c *PurchaseHandler) PickupGoods(order *model.GoodsOrder, isSelfDelivery bool, userName string) (err error) { func (c *PurchaseHandler) PickupGoods(order *model.GoodsOrder, isSelfDelivery bool, userName string) (err error) {
globals.SugarLogger.Debugf("jd PickupGoods orderID:%s, isSelfDelivery:%t", order.VendorOrderID, isSelfDelivery) globals.SugarLogger.Debugf("jd PickupGoods orderID:%s, isSelfDelivery:%t", order.VendorOrderID, isSelfDelivery)
if !isSelfDelivery && globals.EnableJdStoreWrite { if !isSelfDelivery && globals.EnableJdStoreWrite {
_, err = api.JdAPI.OrderJDZBDelivery(order.VendorOrderID, userName) _, err = getAPI("").OrderJDZBDelivery(order.VendorOrderID, userName)
} else { } else {
c.postFakeMsg(order.VendorOrderID, jdapi.OrderStatusFinishedPickup) c.postFakeMsg(order.VendorOrderID, jdapi.OrderStatusFinishedPickup)
} }
@@ -316,21 +316,21 @@ func (c *PurchaseHandler) PickupGoods(order *model.GoodsOrder, isSelfDelivery bo
func (p *PurchaseHandler) AcceptOrRefuseFailedGetOrder(ctx *jxcontext.Context, order *model.GoodsOrder, isAcceptIt bool) (err error) { func (p *PurchaseHandler) AcceptOrRefuseFailedGetOrder(ctx *jxcontext.Context, order *model.GoodsOrder, isAcceptIt bool) (err error) {
if globals.EnableJdStoreWrite { if globals.EnableJdStoreWrite {
err = api.JdAPI.ReceiveFailedAudit(order.VendorOrderID, isAcceptIt, ctx.GetUserName(), "") err = getAPI("").ReceiveFailedAudit(order.VendorOrderID, isAcceptIt, ctx.GetUserName(), "")
} }
return err return err
} }
func (p *PurchaseHandler) CallCourier(ctx *jxcontext.Context, order *model.GoodsOrder) (err error) { // 拣货失败后再次招唤平台配送 func (p *PurchaseHandler) CallCourier(ctx *jxcontext.Context, order *model.GoodsOrder) (err error) { // 拣货失败后再次招唤平台配送
if globals.EnableJdStoreWrite { if globals.EnableJdStoreWrite {
err = api.JdAPI.UrgeDispatching(order.VendorOrderID, ctx.GetUserName()) err = getAPI("").UrgeDispatching(order.VendorOrderID, ctx.GetUserName())
} }
return err return err
} }
func (p *PurchaseHandler) ConfirmReceiveGoods(ctx *jxcontext.Context, order *model.GoodsOrder) (err error) { // 投递失败后确认收到退货 func (p *PurchaseHandler) ConfirmReceiveGoods(ctx *jxcontext.Context, order *model.GoodsOrder) (err error) { // 投递失败后确认收到退货
if globals.EnableJdStoreWrite { if globals.EnableJdStoreWrite {
err = api.JdAPI.ConfirmReceiveGoods(order.VendorOrderID) err = getAPI("").ConfirmReceiveGoods(order.VendorOrderID)
} }
return err return err
} }
@@ -338,7 +338,7 @@ func (p *PurchaseHandler) ConfirmReceiveGoods(ctx *jxcontext.Context, order *mod
func (c *PurchaseHandler) Swtich2SelfDeliver(order *model.GoodsOrder, userName string) (err error) { func (c *PurchaseHandler) Swtich2SelfDeliver(order *model.GoodsOrder, userName string) (err error) {
globals.SugarLogger.Debugf("jd Swtich2SelfDeliver orderID:%s", order.VendorOrderID) globals.SugarLogger.Debugf("jd Swtich2SelfDeliver orderID:%s", order.VendorOrderID)
if globals.EnableJdStoreWrite { if globals.EnableJdStoreWrite {
_, err = api.JdAPI.ModifySellerDelivery(order.VendorOrderID, userName) _, err = getAPI("").ModifySellerDelivery(order.VendorOrderID, userName)
if err != nil { if err != nil {
if errWithCode, ok := err.(*utils.ErrorWithCode); ok && errWithCode.Level() == 1 { if errWithCode, ok := err.(*utils.ErrorWithCode); ok && errWithCode.Level() == 1 {
globals.SugarLogger.Infof("Swtich2SelfDeliver failed with error:%v try get current status", err) globals.SugarLogger.Infof("Swtich2SelfDeliver failed with error:%v try get current status", err)
@@ -359,7 +359,7 @@ func (c *PurchaseHandler) Swtich2SelfDeliver(order *model.GoodsOrder, userName s
func (c *PurchaseHandler) Swtich2SelfDelivered(order *model.GoodsOrder, userName string) (err error) { func (c *PurchaseHandler) Swtich2SelfDelivered(order *model.GoodsOrder, userName string) (err error) {
globals.SugarLogger.Debugf("jd Swtich2SelfDelivered orderID:%s", order.VendorOrderID) globals.SugarLogger.Debugf("jd Swtich2SelfDelivered orderID:%s", order.VendorOrderID)
if globals.EnableJdStoreWrite { if globals.EnableJdStoreWrite {
_, err = api.JdAPI.DeliveryEndOrder(order.VendorOrderID, userName) _, err = getAPI("").DeliveryEndOrder(order.VendorOrderID, userName)
} }
return err return err
} }
@@ -367,7 +367,7 @@ func (c *PurchaseHandler) Swtich2SelfDelivered(order *model.GoodsOrder, userName
func (c *PurchaseHandler) SelfDeliverDelivering(order *model.GoodsOrder, userName string) (err error) { func (c *PurchaseHandler) SelfDeliverDelivering(order *model.GoodsOrder, userName string) (err error) {
globals.SugarLogger.Debugf("jd SelfDeliverDelivering orderID:%s", order.VendorOrderID) globals.SugarLogger.Debugf("jd SelfDeliverDelivering orderID:%s", order.VendorOrderID)
if globals.EnableJdStoreWrite { if globals.EnableJdStoreWrite {
_, err = api.JdAPI.OrderSerllerDelivery(order.VendorOrderID, userName) _, err = getAPI("").OrderSerllerDelivery(order.VendorOrderID, userName)
} }
return err return err
} }
@@ -382,13 +382,13 @@ func (c *PurchaseHandler) SelfDeliverDelivered(order *model.GoodsOrder, userName
} }
func (c *PurchaseHandler) GetOrderRealMobile(ctx *jxcontext.Context, order *model.GoodsOrder) (mobile string, err error) { func (c *PurchaseHandler) GetOrderRealMobile(ctx *jxcontext.Context, order *model.GoodsOrder) (mobile string, err error) {
mobile, err = api.JdAPI.GetRealMobile4Order(order.VendorOrderID, order.VendorStoreID) mobile, err = getAPI("").GetRealMobile4Order(order.VendorOrderID, order.VendorStoreID)
return mobile, err return mobile, err
} }
func (c *PurchaseHandler) AgreeOrRefuseCancel(ctx *jxcontext.Context, order *model.GoodsOrder, isAgree bool, reason string) (err error) { func (c *PurchaseHandler) AgreeOrRefuseCancel(ctx *jxcontext.Context, order *model.GoodsOrder, isAgree bool, reason string) (err error) {
if globals.EnableJdStoreWrite { if globals.EnableJdStoreWrite {
err = api.JdAPI.OrderCancelOperate(order.VendorOrderID, isAgree, ctx.GetUserName(), reason) err = getAPI("").OrderCancelOperate(order.VendorOrderID, isAgree, ctx.GetUserName(), reason)
} }
return err return err
} }
@@ -396,7 +396,7 @@ func (c *PurchaseHandler) AgreeOrRefuseCancel(ctx *jxcontext.Context, order *mod
func (c *PurchaseHandler) CancelOrder(ctx *jxcontext.Context, order *model.GoodsOrder, reason string) (err error) { func (c *PurchaseHandler) CancelOrder(ctx *jxcontext.Context, order *model.GoodsOrder, reason string) (err error) {
if globals.EnableJdStoreWrite { if globals.EnableJdStoreWrite {
err1 := c.Swtich2SelfDeliver(order, ctx.GetUserName()) err1 := c.Swtich2SelfDeliver(order, ctx.GetUserName())
if err = api.JdAPI.CancelAndRefund(order.VendorOrderID, ctx.GetUserName(), reason); err != nil { if err = getAPI("").CancelAndRefund(order.VendorOrderID, ctx.GetUserName(), reason); err != nil {
if err1 != nil { if err1 != nil {
err = fmt.Errorf("取消订单失败,京东取消订单是要先转为自送再处理,转自送失败:%v", err1) err = fmt.Errorf("取消订单失败,京东取消订单是要先转为自送再处理,转自送失败:%v", err1)
} }
@@ -415,7 +415,7 @@ func (c *PurchaseHandler) AdjustOrder(ctx *jxcontext.Context, order *model.Goods
}) })
} }
if globals.EnableJdStoreWrite { if globals.EnableJdStoreWrite {
err = api.JdAPI.AdjustOrder(order.VendorOrderID, ctx.GetUserName(), reason, oaosAdjustDTOList) err = getAPI("").AdjustOrder(order.VendorOrderID, ctx.GetUserName(), reason, oaosAdjustDTOList)
} }
return err return err
} }
@@ -434,7 +434,7 @@ func (c *PurchaseHandler) ListOrders(ctx *jxcontext.Context, parentTask tasksch.
if vendorStoreID != "" { if vendorStoreID != "" {
queryParam.DeliveryStationNo = vendorStoreID queryParam.DeliveryStationNo = vendorStoreID
} }
orderList, _, err := api.JdAPI.OrderQuery2(queryParam) orderList, _, err := getAPI("").OrderQuery2(queryParam)
if err == nil { if err == nil {
vendorOrderIDs = make([]string, len(orderList)) vendorOrderIDs = make([]string, len(orderList))
for k, v := range orderList { for k, v := range orderList {
@@ -445,12 +445,12 @@ func (c *PurchaseHandler) ListOrders(ctx *jxcontext.Context, parentTask tasksch.
} }
func (c *PurchaseHandler) UpdateWaybillTip(ctx *jxcontext.Context, order *model.GoodsOrder, tipFee int64) (err error) { func (c *PurchaseHandler) UpdateWaybillTip(ctx *jxcontext.Context, order *model.GoodsOrder, tipFee int64) (err error) {
orderInfo, err := api.JdAPI.QuerySingleOrder2(order.VendorOrderID) orderInfo, err := getAPI("").QuerySingleOrder2(order.VendorOrderID)
if err == nil { if err == nil {
tip2Add := int(tipFee) - orderInfo.Tips tip2Add := int(tipFee) - orderInfo.Tips
if tip2Add != 0 { if tip2Add != 0 {
if globals.EnableJdStoreWrite { if globals.EnableJdStoreWrite {
err = api.JdAPI.OrderAddTips(order.VendorOrderID, tip2Add, ctx.GetUserName()) err = getAPI("").OrderAddTips(order.VendorOrderID, tip2Add, ctx.GetUserName())
} }
} }
} }
@@ -458,7 +458,7 @@ func (c *PurchaseHandler) UpdateWaybillTip(ctx *jxcontext.Context, order *model.
} }
func (c *PurchaseHandler) GetWaybillTip(ctx *jxcontext.Context, order *model.GoodsOrder) (tipFee int64, err error) { func (c *PurchaseHandler) GetWaybillTip(ctx *jxcontext.Context, order *model.GoodsOrder) (tipFee int64, err error) {
orderInfo, err := api.JdAPI.QuerySingleOrder2(order.VendorOrderID) orderInfo, err := getAPI("").QuerySingleOrder2(order.VendorOrderID)
if err == nil { if err == nil {
tipFee = int64(orderInfo.Tips) tipFee = int64(orderInfo.Tips)
} }
@@ -467,7 +467,7 @@ func (c *PurchaseHandler) GetWaybillTip(ctx *jxcontext.Context, order *model.Goo
func (c *PurchaseHandler) AddWaybillTip(ctx *jxcontext.Context, order *model.GoodsOrder, tipFee2Add int64) (err error) { func (c *PurchaseHandler) AddWaybillTip(ctx *jxcontext.Context, order *model.GoodsOrder, tipFee2Add int64) (err error) {
if globals.EnableJdStoreWrite { if globals.EnableJdStoreWrite {
err = api.JdAPI.OrderAddTips(order.VendorOrderID, int(tipFee2Add), ctx.GetUserName()) err = getAPI("").OrderAddTips(order.VendorOrderID, int(tipFee2Add), ctx.GetUserName())
} }
return err return err
} }

View File

@@ -8,7 +8,6 @@ import (
"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"
"git.rosy.net.cn/jx-callback/globals" "git.rosy.net.cn/jx-callback/globals"
"git.rosy.net.cn/jx-callback/globals/api"
) )
var ( var (
@@ -67,7 +66,7 @@ func (c *PurchaseHandler) OnAfsOrderMsg(msg *jdapi.CallbackOrderMsg) (retVal *jd
} }
func (c *PurchaseHandler) onAfsOrderMsg(msg *jdapi.CallbackOrderMsg) (retVal *jdapi.CallbackResponse) { func (c *PurchaseHandler) onAfsOrderMsg(msg *jdapi.CallbackOrderMsg) (retVal *jdapi.CallbackResponse) {
afsInfo, err := api.JdAPI.GetAfsService2(msg.BillID) afsInfo, err := getAPI("").GetAfsService2(msg.BillID)
if err == nil { if err == nil {
status := c.callbackAfsMsg2Status(msg, afsInfo) status := c.callbackAfsMsg2Status(msg, afsInfo)
if partner.CurOrderManager.GetStatusDuplicatedCount(status) > 0 { if partner.CurOrderManager.GetStatusDuplicatedCount(status) > 0 {
@@ -182,7 +181,7 @@ func (c *PurchaseHandler) buildAfsOrder(afsInfo *jdapi.AfsServiceResponse) (afsO
// 审核售后单申请 // 审核售后单申请
func (c *PurchaseHandler) AgreeOrRefuseRefund(ctx *jxcontext.Context, order *model.AfsOrder, approveType int, reason string) (err error) { func (c *PurchaseHandler) AgreeOrRefuseRefund(ctx *jxcontext.Context, order *model.AfsOrder, approveType int, reason string) (err error) {
if globals.EnableJdStoreWrite { if globals.EnableJdStoreWrite {
err = api.JdAPI.AfsOpenApprove(order.AfsOrderID, afsApproveTypeMap[approveType], reason, ctx.GetUserName()) err = getAPI("").AfsOpenApprove(order.AfsOrderID, afsApproveTypeMap[approveType], reason, ctx.GetUserName())
} }
return err return err
} }
@@ -190,7 +189,7 @@ func (c *PurchaseHandler) AgreeOrRefuseRefund(ctx *jxcontext.Context, order *mod
// 确认收到退货 // 确认收到退货
func (c *PurchaseHandler) ConfirmReceivedReturnGoods(ctx *jxcontext.Context, order *model.AfsOrder) (err error) { func (c *PurchaseHandler) ConfirmReceivedReturnGoods(ctx *jxcontext.Context, order *model.AfsOrder) (err error) {
if globals.EnableJdStoreWrite { if globals.EnableJdStoreWrite {
err = api.JdAPI.ConfirmReceipt(order.AfsOrderID, ctx.GetUserName()) err = getAPI("").ConfirmReceipt(order.AfsOrderID, ctx.GetUserName())
} }
return err return err
} }
@@ -218,7 +217,7 @@ func (c *PurchaseHandler) RefundOrder(ctx *jxcontext.Context, order *model.Goods
// 发起部分退款 // 发起部分退款
func (c *PurchaseHandler) PartRefundOrder(ctx *jxcontext.Context, order *model.GoodsOrder, refundSkuList []*model.OrderSku, reason string) (err error) { func (c *PurchaseHandler) PartRefundOrder(ctx *jxcontext.Context, order *model.GoodsOrder, refundSkuList []*model.OrderSku, reason string) (err error) {
if globals.EnableJdStoreWrite { if globals.EnableJdStoreWrite {
_, err = api.JdAPI.AfsSubmit(order.VendorOrderID, ctx.GetUserName(), utils.Int2Str(jdapi.AfsReasonWrongPurchase), reason, "", order.ConsigneeName, order.ConsigneeMobile, order.ConsigneeAddress, orderSkus2AfsSkus(refundSkuList)) _, err = getAPI("").AfsSubmit(order.VendorOrderID, ctx.GetUserName(), utils.Int2Str(jdapi.AfsReasonWrongPurchase), reason, "", order.ConsigneeName, order.ConsigneeMobile, order.ConsigneeAddress, orderSkus2AfsSkus(refundSkuList))
} }
return err return err
} }

View File

@@ -7,7 +7,6 @@ import (
"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"
"git.rosy.net.cn/jx-callback/globals" "git.rosy.net.cn/jx-callback/globals"
"git.rosy.net.cn/jx-callback/globals/api"
) )
const ( const (
@@ -16,7 +15,7 @@ const (
func (c *PurchaseHandler) onOrderComment2(msg *jdapi.CallbackOrderMsg) (err error) { func (c *PurchaseHandler) onOrderComment2(msg *jdapi.CallbackOrderMsg) (err error) {
intOrderID := utils.Str2Int64(msg.BillID) intOrderID := utils.Str2Int64(msg.BillID)
result, err := api.JdAPI.GetCommentByOrderId(intOrderID) result, err := getAPI("").GetCommentByOrderId(intOrderID)
if err == nil { if err == nil {
globals.SugarLogger.Debugf("onOrderComment comment:%s", utils.Format4Output(result, true)) globals.SugarLogger.Debugf("onOrderComment comment:%s", utils.Format4Output(result, true))
orderCommend := &model.OrderComment{ orderCommend := &model.OrderComment{
@@ -44,7 +43,7 @@ func (c *PurchaseHandler) onOrderComment2(msg *jdapi.CallbackOrderMsg) (err erro
func (c *PurchaseHandler) ReplyOrderComment(ctx *jxcontext.Context, orderComment *model.OrderComment, replyComment string) (err error) { func (c *PurchaseHandler) ReplyOrderComment(ctx *jxcontext.Context, orderComment *model.OrderComment, replyComment string) (err error) {
if globals.ReallyReplyComment { if globals.ReallyReplyComment {
err = api.JdAPI.OrgReplyComment(utils.Str2Int64(orderComment.VendorOrderID), orderComment.VendorStoreID, replyComment, ctx.GetUserName()) err = getAPI("").OrgReplyComment(utils.Str2Int64(orderComment.VendorOrderID), orderComment.VendorStoreID, replyComment, ctx.GetUserName())
} }
return err return err
} }

View File

@@ -15,7 +15,6 @@ import (
"git.rosy.net.cn/jx-callback/business/model/dao" "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"
"git.rosy.net.cn/jx-callback/globals" "git.rosy.net.cn/jx-callback/globals"
"git.rosy.net.cn/jx-callback/globals/api"
"github.com/astaxie/beego" "github.com/astaxie/beego"
) )
@@ -59,7 +58,7 @@ func (p *PurchaseHandler) CreateCategory(db *dao.DaoDB, cat *model.SkuCategory,
} }
} }
if globals.EnableStoreWrite { if globals.EnableStoreWrite {
result, err2 := api.JdAPI.AddShopCategory(jdPid, cat.Name, int(cat.Level), cat.Seq, userName) result, err2 := getAPI("").AddShopCategory(jdPid, cat.Name, int(cat.Level), cat.Seq, userName)
if err = err2; err == nil { if err = err2; err == nil {
if jdID := utils.Str2Int64WithDefault(result, 0); jdID != 0 { if jdID := utils.Str2Int64WithDefault(result, 0); jdID != 0 {
cat.JdID = jdID cat.JdID = jdID
@@ -70,7 +69,7 @@ func (p *PurchaseHandler) CreateCategory(db *dao.DaoDB, cat *model.SkuCategory,
} }
func (p *PurchaseHandler) ReadCategories() (cats []*model.SkuCategory, err error) { func (p *PurchaseHandler) ReadCategories() (cats []*model.SkuCategory, err error) {
result, err := api.JdAPI.QueryCategoriesByOrgCode() result, err := getAPI("").QueryCategoriesByOrgCode()
if err == nil { if err == nil {
cats = make([]*model.SkuCategory, len(result)) cats = make([]*model.SkuCategory, len(result))
for k, v := range result { for k, v := range result {
@@ -89,14 +88,14 @@ func (p *PurchaseHandler) ReadCategories() (cats []*model.SkuCategory, err error
func (p *PurchaseHandler) UpdateCategory(db *dao.DaoDB, cat *model.SkuCategory, userName string) error { func (p *PurchaseHandler) UpdateCategory(db *dao.DaoDB, cat *model.SkuCategory, userName string) error {
if globals.EnableStoreWrite { if globals.EnableStoreWrite {
return api.JdAPI.UpdateShopCategory(cat.JdID, cat.Name) return getAPI("").UpdateShopCategory(cat.JdID, cat.Name)
} }
return nil return nil
} }
func (p *PurchaseHandler) DeleteCategory(db *dao.DaoDB, cat *model.SkuCategory, userName string) error { func (p *PurchaseHandler) DeleteCategory(db *dao.DaoDB, cat *model.SkuCategory, userName string) error {
if globals.EnableStoreWrite { if globals.EnableStoreWrite {
return api.JdAPI.DelShopCategory(cat.JdID) return getAPI("").DelShopCategory(cat.JdID)
} }
return nil return nil
} }
@@ -122,7 +121,7 @@ func (p *PurchaseHandler) ReorderCategories(db *dao.DaoDB, parentCatID int, user
jdCatIDs[k] = v.JdID jdCatIDs[k] = v.JdID
} }
if globals.EnableStoreWrite { if globals.EnableStoreWrite {
err = api.JdAPI.ChangeShopCategoryOrder(parentJDID, jdCatIDs) err = getAPI("").ChangeShopCategoryOrder(parentJDID, jdCatIDs)
} }
} }
return err return err
@@ -192,7 +191,7 @@ func (p *PurchaseHandler) CreateSku(db *dao.DaoDB, sku *model.Sku, userName stri
return p.cuSku(db, sku, func(skuExt *tSkuInfoExt, price int, skuName string, shopCategories []int64, addParams map[string]interface{}) (vendorSkuID string, err error) { return p.cuSku(db, sku, func(skuExt *tSkuInfoExt, price int, skuName string, shopCategories []int64, addParams map[string]interface{}) (vendorSkuID string, err error) {
if skuExt.IsSpu == 0 { if skuExt.IsSpu == 0 {
if globals.EnableStoreWrite { if globals.EnableStoreWrite {
vendorSkuID, err = api.JdAPI.AddSku(utils.Int2Str(sku.ID), skuExt.JdCategoryID, shopCategories, skuExt.BrandID, skuName, price, jxutils.IntWeight2Float(sku.Weight), []string{skuExt.Img}, jxStatus2jdStatus(sku.Status), true, addParams) vendorSkuID, err = getAPI("").AddSku(utils.Int2Str(sku.ID), skuExt.JdCategoryID, shopCategories, skuExt.BrandID, skuName, price, jxutils.IntWeight2Float(sku.Weight), []string{skuExt.Img}, jxStatus2jdStatus(sku.Status), true, addParams)
if err != nil { if err != nil {
if jdSkuID := jdapi.GetJdSkuIDFromError(err); jdSkuID > 0 { if jdSkuID := jdapi.GetJdSkuIDFromError(err); jdSkuID > 0 {
vendorSkuID = utils.Int64ToStr(jdSkuID) vendorSkuID = utils.Int64ToStr(jdSkuID)
@@ -209,13 +208,13 @@ func (p *PurchaseHandler) CreateSku(db *dao.DaoDB, sku *model.Sku, userName stri
func (p *PurchaseHandler) ReadSku(vendorSkuID string) (skuNameExt *model.SkuNameExt, err error) { func (p *PurchaseHandler) ReadSku(vendorSkuID string) (skuNameExt *model.SkuNameExt, err error) {
jdSkuID := utils.Str2Int64(vendorSkuID) jdSkuID := utils.Str2Int64(vendorSkuID)
skuList, _, err := api.JdAPI.QuerySkuInfos(&jdapi.QuerySkuParam{ skuList, _, err := getAPI("").QuerySkuInfos(&jdapi.QuerySkuParam{
SkuID: jdSkuID, SkuID: jdSkuID,
}) })
if err == nil { if err == nil {
if len(skuList) >= 1 { if len(skuList) >= 1 {
skuNameExt = &model.SkuNameExt{} skuNameExt = &model.SkuNameExt{}
if imgList, err2 := api.JdAPI.QueryListBySkuIds(&jdapi.QueryListBySkuIdsParam{ if imgList, err2 := getAPI("").QueryListBySkuIds(&jdapi.QueryListBySkuIdsParam{
SkuIDs: []int64{jdSkuID}, SkuIDs: []int64{jdSkuID},
}); err2 == nil && len(imgList) > 0 { }); err2 == nil && len(imgList) > 0 {
skuNameExt.Img = imgList[0].SourceImgURL skuNameExt.Img = imgList[0].SourceImgURL
@@ -288,7 +287,7 @@ func (p *PurchaseHandler) UpdateSku(db *dao.DaoDB, sku *model.Sku, userName stri
params[jdapi.KeyFixedStatus] = jxStatus2jdStatus(sku.Status) params[jdapi.KeyFixedStatus] = jxStatus2jdStatus(sku.Status)
if skuExt.IsSpu == 0 { if skuExt.IsSpu == 0 {
if globals.EnableStoreWrite { if globals.EnableStoreWrite {
vendorSkuID, err = api.JdAPI.UpdateSku(utils.Int2Str(sku.ID), params) vendorSkuID, err = getAPI("").UpdateSku(utils.Int2Str(sku.ID), params)
} }
} else { } else {
vendorSkuID, err = p.syncSkuNameAsSpu(db, sku, skuExt, price, skuName, shopCategories, addParams) vendorSkuID, err = p.syncSkuNameAsSpu(db, sku, skuExt, price, skuName, shopCategories, addParams)
@@ -312,7 +311,7 @@ func (p *PurchaseHandler) DeleteSku(db *dao.DaoDB, sku *model.Sku, userName stri
if err == nil { if err == nil {
if skuExt.IsSpu == 0 { if skuExt.IsSpu == 0 {
if globals.EnableStoreWrite { if globals.EnableStoreWrite {
_, err = api.JdAPI.UpdateSku(utils.Int2Str(sku.ID), params) _, err = getAPI("").UpdateSku(utils.Int2Str(sku.ID), params)
} }
} else { } else {
_, err = p.syncSkuNameAsSpu(db, sku, &skuExt, 0, "", nil, nil) _, err = p.syncSkuNameAsSpu(db, sku, &skuExt, 0, "", nil, nil)
@@ -357,7 +356,7 @@ func (p *PurchaseHandler) RefreshAllSkusID(ctx *jxcontext.Context, parentTask ta
} }
globals.SugarLogger.Debug(utils.Format4Output(skuPairs, false)) globals.SugarLogger.Debug(utils.Format4Output(skuPairs, false))
if globals.EnableStoreWrite { if globals.EnableStoreWrite {
_, err = api.JdAPI.BatchUpdateOutSkuId(skuPairs) _, err = getAPI("").BatchUpdateOutSkuId(skuPairs)
} }
return nil, err return nil, err
}, skuPairs) }, skuPairs)
@@ -397,7 +396,7 @@ func (p *PurchaseHandler) syncSkuNameAsSpu(db *dao.DaoDB, sku *model.Sku, skuExt
spuAddParams, skuAddParams := splitAddParams(addParams) spuAddParams, skuAddParams := splitAddParams(addParams)
if !jxutils.IsEmptyID(skuNameJdID) && sku.JdSyncStatus&model.SyncFlagDeletedMask != 0 { // 删除SKU if !jxutils.IsEmptyID(skuNameJdID) && sku.JdSyncStatus&model.SyncFlagDeletedMask != 0 { // 删除SKU
if globals.EnableStoreWrite { if globals.EnableStoreWrite {
err = api.JdAPI.UpdateSkuBaseInfo(utils.Int2Str(skuExt.ID), utils.Int2Str(sku.ID), utils.Params2Map(jdapi.KeyFixedStatus, jdapi.SkuFixedStatusDeleted)) err = getAPI("").UpdateSkuBaseInfo(utils.Int2Str(skuExt.ID), utils.Int2Str(sku.ID), utils.Params2Map(jdapi.KeyFixedStatus, jdapi.SkuFixedStatusDeleted))
} }
} }
if err == nil { if err == nil {
@@ -417,8 +416,8 @@ func (p *PurchaseHandler) syncSkuNameAsSpu(db *dao.DaoDB, sku *model.Sku, skuExt
if count.Ct <= 1 && sku.JdSyncStatus&model.SyncFlagDeletedMask != 0 { // 1就是最后删的那个 if count.Ct <= 1 && sku.JdSyncStatus&model.SyncFlagDeletedMask != 0 { // 1就是最后删的那个
updateFields = append(updateFields, model.FieldJdSyncStatus) updateFields = append(updateFields, model.FieldJdSyncStatus)
if globals.EnableStoreWrite { if globals.EnableStoreWrite {
if err = api.JdAPI.UpdateSpu(utils.Int2Str(skuExt.ID), utils.Params2Map(jdapi.KeyFixedStatus, jdapi.SkuFixedStatusOffline)); err == nil { if err = getAPI("").UpdateSpu(utils.Int2Str(skuExt.ID), utils.Params2Map(jdapi.KeyFixedStatus, jdapi.SkuFixedStatusOffline)); err == nil {
err = api.JdAPI.UpdateSpu(utils.Int2Str(skuExt.ID), utils.Params2Map(jdapi.KeyFixedStatus, jdapi.SkuFixedStatusDeleted)) err = getAPI("").UpdateSpu(utils.Int2Str(skuExt.ID), utils.Params2Map(jdapi.KeyFixedStatus, jdapi.SkuFixedStatusDeleted))
} }
} }
} }
@@ -439,7 +438,7 @@ func (p *PurchaseHandler) syncSkuNameAsSpu(db *dao.DaoDB, sku *model.Sku, skuExt
skus[0] = utils.MergeMaps(skus[0], skuAddParams) skus[0] = utils.MergeMaps(skus[0], skuAddParams)
updateFields = append(updateFields, model.FieldJdSyncStatus) updateFields = append(updateFields, model.FieldJdSyncStatus)
if globals.EnableStoreWrite { if globals.EnableStoreWrite {
vendorSpuID, skuPairs, err2 := api.JdAPI.AddSpu(utils.Int2Str(skuExt.ID), skuExt.JdCategoryID, shopCategories, skuExt.BrandID, spuName, []string{skuExt.Img}, jxStatus2jdStatus(skuExt.Status), spuAddParams, skus) vendorSpuID, skuPairs, err2 := getAPI("").AddSpu(utils.Int2Str(skuExt.ID), skuExt.JdCategoryID, shopCategories, skuExt.BrandID, spuName, []string{skuExt.Img}, jxStatus2jdStatus(skuExt.Status), spuAddParams, skus)
if err = err2; err == nil { if err = err2; err == nil {
skuExt.JdID = vendorSpuID skuExt.JdID = vendorSpuID
// skuNameJdID = skuExt.JdID // 这个是故意去掉的这样之后的首次SKU修改操作就会被忽略下一条语句也就可以不用了 // skuNameJdID = skuExt.JdID // 这个是故意去掉的这样之后的首次SKU修改操作就会被忽略下一条语句也就可以不用了
@@ -460,7 +459,7 @@ func (p *PurchaseHandler) syncSkuNameAsSpu(db *dao.DaoDB, sku *model.Sku, skuExt
}, spuAddParams) }, spuAddParams)
updateFields = append(updateFields, model.FieldJdSyncStatus) updateFields = append(updateFields, model.FieldJdSyncStatus)
if globals.EnableStoreWrite { if globals.EnableStoreWrite {
err = api.JdAPI.UpdateSpu(utils.Int2Str(skuExt.ID), params) err = getAPI("").UpdateSpu(utils.Int2Str(skuExt.ID), params)
} }
} }
if err == nil { if err == nil {
@@ -474,7 +473,7 @@ func (p *PurchaseHandler) syncSkuNameAsSpu(db *dao.DaoDB, sku *model.Sku, skuExt
if err == nil && !jxutils.IsEmptyID(skuNameJdID) { if err == nil && !jxutils.IsEmptyID(skuNameJdID) {
if sku.JdSyncStatus&model.SyncFlagNewMask != 0 { // 非首次新增SKU if sku.JdSyncStatus&model.SyncFlagNewMask != 0 { // 非首次新增SKU
if globals.EnableStoreWrite { if globals.EnableStoreWrite {
vendorSkuID2, err2 := api.JdAPI.AppendSku(utils.Int2Str(skuExt.ID), utils.Int2Str(sku.ID), skuName, price, jxutils.IntWeight2Float(sku.Weight), []string{skuExt.Img}, jxStatus2jdStatus(sku.Status), true, composeSkuSpec(sku.SpecQuality, sku.SpecUnit, skuExt.Unit), skuAddParams) vendorSkuID2, err2 := getAPI("").AppendSku(utils.Int2Str(skuExt.ID), utils.Int2Str(sku.ID), skuName, price, jxutils.IntWeight2Float(sku.Weight), []string{skuExt.Img}, jxStatus2jdStatus(sku.Status), true, composeSkuSpec(sku.SpecQuality, sku.SpecUnit, skuExt.Unit), skuAddParams)
if err = err2; err == nil { if err = err2; err == nil {
vendorSkuID = utils.Int64ToStr(vendorSkuID2) vendorSkuID = utils.Int64ToStr(vendorSkuID2)
} }
@@ -487,13 +486,13 @@ func (p *PurchaseHandler) syncSkuNameAsSpu(db *dao.DaoDB, sku *model.Sku, skuExt
params[jdapi.KeyWeight] = jxutils.IntWeight2Float(sku.Weight) params[jdapi.KeyWeight] = jxutils.IntWeight2Float(sku.Weight)
params[jdapi.KeySkuPrice] = price params[jdapi.KeySkuPrice] = price
if globals.EnableStoreWrite { if globals.EnableStoreWrite {
err = api.JdAPI.UpdateSkuBaseInfo(utils.Int2Str(skuExt.ID), utils.Int2Str(sku.ID), utils.MergeMaps(params, skuAddParams)) err = getAPI("").UpdateSkuBaseInfo(utils.Int2Str(skuExt.ID), utils.Int2Str(sku.ID), utils.MergeMaps(params, skuAddParams))
if sku.JdSyncStatus&model.SyncFlagSpecMask != 0 { if sku.JdSyncStatus&model.SyncFlagSpecMask != 0 {
skuIndex := sku.SkuIndex skuIndex := sku.SkuIndex
if skuIndex > 0 { if skuIndex > 0 {
saleAttrValue := composeSkuSpec(sku.SpecQuality, sku.SpecUnit, skuExt.Unit) saleAttrValue := composeSkuSpec(sku.SpecQuality, sku.SpecUnit, skuExt.Unit)
globals.SugarLogger.Debugf("syncSkuNameAsSpu outSuperId:%d, saleAttrId:%d, saleAttrValueId:%d, saleAttrValueName:%s", skuExt.ID, jdapi.SaleAttrIDBase, jdapi.SaleAttrValueIDBase+skuIndex-1, saleAttrValue) globals.SugarLogger.Debugf("syncSkuNameAsSpu outSuperId:%d, saleAttrId:%d, saleAttrValueId:%d, saleAttrValueName:%s", skuExt.ID, jdapi.SaleAttrIDBase, jdapi.SaleAttrValueIDBase+skuIndex-1, saleAttrValue)
err = api.JdAPI.UpdateSpuSaleAttr(utils.Int2Str(skuExt.ID), utils.Int2Str(jdapi.SaleAttrIDBase), "", utils.Int2Str(jdapi.SaleAttrValueIDBase+skuIndex-1), saleAttrValue) err = getAPI("").UpdateSpuSaleAttr(utils.Int2Str(skuExt.ID), utils.Int2Str(jdapi.SaleAttrIDBase), "", utils.Int2Str(jdapi.SaleAttrValueIDBase+skuIndex-1), saleAttrValue)
} }
} }
} }
@@ -543,7 +542,7 @@ func jxStatus2jdStatus(jxStatus int) (jdStatus int) {
} }
func (p *PurchaseHandler) getVendorCategories(level int, pid int64) (vendorCats []*model.SkuVendorCategory, err error) { func (p *PurchaseHandler) getVendorCategories(level int, pid int64) (vendorCats []*model.SkuVendorCategory, err error) {
cats, err := api.JdAPI.QueryChildCategoriesForOP(pid) cats, err := getAPI("").QueryChildCategoriesForOP(pid)
if err != nil { if err != nil {
return nil, err return nil, err
} }
@@ -589,7 +588,7 @@ func (p *PurchaseHandler) GetSkus(ctx *jxcontext.Context, skuID int, vendorSkuID
PageSize: jdapi.MaxSkuIDsCount4QueryListBySkuIds, // 为了同时取图这个值不要大于jdapi.MaxSkuIDsCount4QueryListBySkuIds PageSize: jdapi.MaxSkuIDsCount4QueryListBySkuIds, // 为了同时取图这个值不要大于jdapi.MaxSkuIDsCount4QueryListBySkuIds
} }
for { for {
skuList, _, err2 := api.JdAPI.QuerySkuInfos(param) skuList, _, err2 := getAPI("").QuerySkuInfos(param)
if err = err2; err != nil { if err = err2; err != nil {
return nil, err return nil, err
} }
@@ -616,7 +615,7 @@ func setSkuNameListPic(skuNameList []*partner.SkuNameInfo) []*partner.SkuNameInf
} }
imgMap := make(map[int64]*jdapi.ImgHandleQueryResult) imgMap := make(map[int64]*jdapi.ImgHandleQueryResult)
if imgList, err2 := api.JdAPI.QueryListBySkuIds(&jdapi.QueryListBySkuIdsParam{ if imgList, err2 := getAPI("").QueryListBySkuIds(&jdapi.QueryListBySkuIdsParam{
SkuIDs: jdSkuIDs, SkuIDs: jdSkuIDs,
}); err2 == nil { }); err2 == nil {
for _, v := range imgList { for _, v := range imgList {
@@ -640,7 +639,7 @@ func setSkuNameListPic(skuNameList []*partner.SkuNameInfo) []*partner.SkuNameInf
task := tasksch.NewParallelTask("jd setSkuNameListPic", nil, jxcontext.AdminCtx, task := tasksch.NewParallelTask("jd setSkuNameListPic", nil, jxcontext.AdminCtx,
func(task *tasksch.ParallelTask, batchItemList []interface{}, params ...interface{}) (retVal interface{}, err error) { func(task *tasksch.ParallelTask, batchItemList []interface{}, params ...interface{}) (retVal interface{}, err error) {
jdSkuID := batchItemList[0].(int64) jdSkuID := batchItemList[0].(int64)
imgList, err := api.JdAPI.GetSkuPageImageInfo(jdSkuID) imgList, err := getAPI("").GetSkuPageImageInfo(jdSkuID)
if err == nil && len(imgList) > 0 { if err == nil && len(imgList) > 0 {
retVal = [][]string{ retVal = [][]string{
[]string{utils.Int64ToStr(jdSkuID), imgList[0].Big}, []string{utils.Int64ToStr(jdSkuID), imgList[0].Big},

View File

@@ -33,7 +33,7 @@ type tJdStoreInfo struct {
} }
func (p *PurchaseHandler) ReadStore(ctx *jxcontext.Context, vendorStoreID string) (*dao.StoreDetail, error) { func (p *PurchaseHandler) ReadStore(ctx *jxcontext.Context, vendorStoreID string) (*dao.StoreDetail, error) {
result, err := api.JdAPI.GetStoreInfoByStationNo(vendorStoreID) result, err := getAPI("").GetStoreInfoByStationNo(vendorStoreID)
if err == nil { if err == nil {
retVal := &dao.StoreDetail{ retVal := &dao.StoreDetail{
Store: model.Store{ Store: model.Store{
@@ -82,7 +82,7 @@ func (p *PurchaseHandler) ReadStore(ctx *jxcontext.Context, vendorStoreID string
} }
retVal.ID = int(utils.Str2Int64WithDefault(utils.Interface2String(result["outSystemId"]), 0)) retVal.ID = int(utils.Str2Int64WithDefault(utils.Interface2String(result["outSystemId"]), 0))
result, err2 := api.JdAPI.GetDeliveryRangeByStationNo(vendorStoreID) result, err2 := getAPI("").GetDeliveryRangeByStationNo(vendorStoreID)
if err = err2; err == nil { if err = err2; err == nil {
retVal.DeliveryRangeType = int8(utils.MustInterface2Int64(result["deliveryRangeType"])) retVal.DeliveryRangeType = int8(utils.MustInterface2Int64(result["deliveryRangeType"]))
if retVal.DeliveryRangeType == model.DeliveryRangeTypePolygon { if retVal.DeliveryRangeType == model.DeliveryRangeTypePolygon {
@@ -147,7 +147,7 @@ func (p *PurchaseHandler) UpdateStore(db *dao.DaoDB, storeID int, userName strin
} }
globals.SugarLogger.Debug(utils.Format4Output(params, false)) globals.SugarLogger.Debug(utils.Format4Output(params, false))
if globals.EnableJdStoreWrite { if globals.EnableJdStoreWrite {
if err = api.JdAPI.UpdateStoreInfo4Open(store.VendorStoreID, store.RealLastOperator, params); err != nil { if err = getAPI("").UpdateStoreInfo4Open(store.VendorStoreID, store.RealLastOperator, params); err != nil {
return err return err
} }
} }
@@ -161,11 +161,11 @@ func (p *PurchaseHandler) UpdateStore(db *dao.DaoDB, storeID int, userName strin
// params := map[string]interface{}{ // params := map[string]interface{}{
// "yn": 1, // "yn": 1,
// } // }
// return api.JdAPI.UpdateStoreInfo4Open(vendorStoreID, userName, params) // return getAPI("").UpdateStoreInfo4Open(vendorStoreID, userName, params)
// } // }
// func (p *PurchaseHandler) EnableAutoAcceptOrder(vendorStoreID string, isEnabled bool) error { // func (p *PurchaseHandler) EnableAutoAcceptOrder(vendorStoreID string, isEnabled bool) error {
// _, err := api.JdAPI.UpdateStoreConfig4Open(vendorStoreID, isEnabled) // _, err := getAPI("").UpdateStoreConfig4Open(vendorStoreID, isEnabled)
// return err // return err
// } // }
@@ -174,7 +174,7 @@ func (p *PurchaseHandler) UpdateStore(db *dao.DaoDB, storeID int, userName strin
// "closeStatus": 0, // "closeStatus": 0,
// "storeNotice": "", // "storeNotice": "",
// } // }
// return api.JdAPI.UpdateStoreInfo4Open(vendorStoreID, userName, params) // return getAPI("").UpdateStoreInfo4Open(vendorStoreID, userName, params)
// } // }
// func (p *PurchaseHandler) CloseStore(vendorStoreID, closeNotice, userName string) error { // func (p *PurchaseHandler) CloseStore(vendorStoreID, closeNotice, userName string) error {
@@ -182,7 +182,7 @@ func (p *PurchaseHandler) UpdateStore(db *dao.DaoDB, storeID int, userName strin
// "closeStatus": 1, // "closeStatus": 1,
// "storeNotice": closeNotice, // "storeNotice": closeNotice,
// } // }
// return api.JdAPI.UpdateStoreInfo4Open(vendorStoreID, userName, params) // return getAPI("").UpdateStoreInfo4Open(vendorStoreID, userName, params)
// } // }
/////////////////////// ///////////////////////
@@ -233,7 +233,7 @@ func (p *PurchaseHandler) RefreshAllStoresID(ctx *jxcontext.Context, parentTask
storeParams["outSystemId"] = store.VendorStoreID storeParams["outSystemId"] = store.VendorStoreID
} }
if globals.EnableJdStoreWrite { if globals.EnableJdStoreWrite {
err = api.JdAPI.UpdateStoreInfo4Open(store.VendorStoreID, ctx.GetUserName(), storeParams) err = getAPI("").UpdateStoreInfo4Open(store.VendorStoreID, ctx.GetUserName(), storeParams)
} }
return nil, err return nil, err
}, stores) }, stores)
@@ -288,7 +288,7 @@ func JdDeliveryType2Jx(deliveryType int) int8 {
} }
func (p *PurchaseHandler) GetStoreStatus(ctx *jxcontext.Context, storeID int, vendorStoreID string) (storeStatus int, err error) { func (p *PurchaseHandler) GetStoreStatus(ctx *jxcontext.Context, storeID int, vendorStoreID string) (storeStatus int, err error) {
result, err := api.JdAPI.GetStoreInfoByStationNo(vendorStoreID) result, err := getAPI("").GetStoreInfoByStationNo(vendorStoreID)
if err == nil { if err == nil {
storeStatus = JdStoreStatus2JxStatus(result["yn"], result["closeStatus"]) storeStatus = JdStoreStatus2JxStatus(result["yn"], result["closeStatus"])
} }
@@ -316,7 +316,7 @@ func (c *PurchaseHandler) OnStoreMsg(msg *jdapi.CallbackOrderMsg) (response *jda
func (c *PurchaseHandler) UpdateStoreStatus(ctx *jxcontext.Context, storeID int, vendorStoreID string, status int) (err error) { func (c *PurchaseHandler) UpdateStoreStatus(ctx *jxcontext.Context, storeID int, vendorStoreID string, status int) (err error) {
_, closeStatus := JxStoreStatus2JdStatus(status) _, closeStatus := JxStoreStatus2JdStatus(status)
if globals.EnableJdStoreWrite { if globals.EnableJdStoreWrite {
err = api.JdAPI.UpdateStoreInfo4Open(vendorStoreID, ctx.GetUserName(), map[string]interface{}{ err = getAPI("").UpdateStoreInfo4Open(vendorStoreID, ctx.GetUserName(), map[string]interface{}{
"closeStatus": closeStatus, "closeStatus": closeStatus,
}) })
} }
@@ -348,13 +348,13 @@ func fillOpTimeParams(params map[string]interface{}, opTimeList []int16) map[str
func (c *PurchaseHandler) UpdateStoreOpTime(ctx *jxcontext.Context, storeID int, vendorStoreID string, opTimeList []int16) (err error) { func (c *PurchaseHandler) UpdateStoreOpTime(ctx *jxcontext.Context, storeID int, vendorStoreID string, opTimeList []int16) (err error) {
params := fillOpTimeParams(nil, opTimeList) params := fillOpTimeParams(nil, opTimeList)
if globals.EnableJdStoreWrite { if globals.EnableJdStoreWrite {
err = api.JdAPI.UpdateStoreInfo4Open(vendorStoreID, ctx.GetUserName(), params) err = getAPI("").UpdateStoreInfo4Open(vendorStoreID, ctx.GetUserName(), params)
} }
return err return err
} }
func (c *PurchaseHandler) GetAllStoresVendorID(ctx *jxcontext.Context) (vendorStoreIDs []string, err error) { func (c *PurchaseHandler) GetAllStoresVendorID(ctx *jxcontext.Context) (vendorStoreIDs []string, err error) {
vendorStoreIDs, err = api.JdAPI.GetStationsByVenderId() vendorStoreIDs, err = getAPI("").GetStationsByVenderId()
return vendorStoreIDs, err return vendorStoreIDs, err
} }

View File

@@ -83,7 +83,7 @@ package jd
// // todo 以下可以优化为并行操作 // // todo 以下可以优化为并行操作
// // globals.SugarLogger.Debug(utils.Format4Output(skuVendibilityList, false), utils.Format4Output(skuPriceInfoList, false), utils.Format4Output(skuStockList, false)) // // globals.SugarLogger.Debug(utils.Format4Output(skuVendibilityList, false), utils.Format4Output(skuPriceInfoList, false), utils.Format4Output(skuStockList, false))
// if len(skuVendibilityList) > 0 { // if len(skuVendibilityList) > 0 {
// if _, err = api.JdAPI.BatchUpdateVendibility(ctx.GetTrackInfo(), "", stationNo, skuVendibilityList, ctx.GetUserName()); err == nil { // if _, err = getAPI("").BatchUpdateVendibility(ctx.GetTrackInfo(), "", stationNo, skuVendibilityList, ctx.GetUserName()); err == nil {
// syncMask |= model.SyncFlagSaleMask // syncMask |= model.SyncFlagSaleMask
// } else { // } else {
// if !isPartialFailed { // if !isPartialFailed {
@@ -94,9 +94,9 @@ package jd
// } // }
// if (err == nil || isContinueWhenError) && len(skuStockList) > 0 { // if (err == nil || isContinueWhenError) && len(skuStockList) > 0 {
// if len(skuStockList) == 1 { // if len(skuStockList) == 1 {
// err = api.JdAPI.UpdateCurrentQty(ctx.GetTrackInfo(), stationNo, utils.Str2Int64WithDefault(vendorSkuID4Qty, 0), skuStockList[0].StockQty) // err = getAPI("").UpdateCurrentQty(ctx.GetTrackInfo(), stationNo, utils.Str2Int64WithDefault(vendorSkuID4Qty, 0), skuStockList[0].StockQty)
// } else { // } else {
// _, err = api.JdAPI.BatchUpdateCurrentQtys(ctx.GetTrackInfo(), "", stationNo, skuStockList, ctx.GetUserName()) // _, err = getAPI("").BatchUpdateCurrentQtys(ctx.GetTrackInfo(), "", stationNo, skuStockList, ctx.GetUserName())
// } // }
// if err == nil { // if err == nil {
// syncMask |= model.SyncFlagNewMask | model.SyncFlagDeletedMask // syncMask |= model.SyncFlagNewMask | model.SyncFlagDeletedMask
@@ -109,9 +109,9 @@ package jd
// } // }
// if (err == nil || isContinueWhenError) && len(skuPriceInfoList) > 0 { // if (err == nil || isContinueWhenError) && len(skuPriceInfoList) > 0 {
// if len(skuPriceInfoList) == 1 { // if len(skuPriceInfoList) == 1 {
// _, err = api.JdAPI.UpdateStationPrice(ctx.GetTrackInfo(), utils.Str2Int64WithDefault(vendorSkuID4Price, 0), stationNo, skuPriceInfoList[0].Price) // _, err = getAPI("").UpdateStationPrice(ctx.GetTrackInfo(), utils.Str2Int64WithDefault(vendorSkuID4Price, 0), stationNo, skuPriceInfoList[0].Price)
// } else { // } else {
// _, err = api.JdAPI.UpdateVendorStationPrice(ctx.GetTrackInfo(), "", stationNo, skuPriceInfoList) // _, err = getAPI("").UpdateVendorStationPrice(ctx.GetTrackInfo(), "", stationNo, skuPriceInfoList)
// } // }
// if err == nil { // if err == nil {
// syncMask |= model.SyncFlagPriceMask // syncMask |= model.SyncFlagPriceMask

View File

@@ -10,7 +10,6 @@ import (
"git.rosy.net.cn/jx-callback/business/partner" "git.rosy.net.cn/jx-callback/business/partner"
"git.rosy.net.cn/jx-callback/business/partner/putils" "git.rosy.net.cn/jx-callback/business/partner/putils"
"git.rosy.net.cn/jx-callback/globals" "git.rosy.net.cn/jx-callback/globals"
"git.rosy.net.cn/jx-callback/globals/api"
) )
func (p *PurchaseHandler) GetStoreSkusBatchSize(funcID int) (batchSize int) { func (p *PurchaseHandler) GetStoreSkusBatchSize(funcID int) (batchSize int) {
@@ -39,9 +38,9 @@ func (p *PurchaseHandler) getStoreSkusBareInfoLimitSize(ctx *jxcontext.Context,
func(task *tasksch.ParallelTask, batchItemList []interface{}, params ...interface{}) (retVal interface{}, err error) { func(task *tasksch.ParallelTask, batchItemList []interface{}, params ...interface{}) (retVal interface{}, err error) {
subTaskID := batchItemList[0].(int) subTaskID := batchItemList[0].(int)
if subTaskID == 0 { if subTaskID == 0 {
stockInfo, err = api.JdAPI.QueryOpenUseable(batchSkuInfoList) stockInfo, err = getAPI("").QueryOpenUseable(batchSkuInfoList)
} else { } else {
priceInfo, err = api.JdAPI.GetStationInfoList(vendorStoreID, batchSkuList) priceInfo, err = getAPI("").GetStationInfoList(vendorStoreID, batchSkuList)
} }
return nil, err return nil, err
}, []int{0, 1}) }, []int{0, 1})
@@ -119,7 +118,7 @@ func (p *PurchaseHandler) UpdateStoreSkusStatus(ctx *jxcontext.Context, storeID
}) })
} }
if globals.EnableJdStoreWrite { if globals.EnableJdStoreWrite {
responseList, err2 := api.JdAPI.BatchUpdateVendibility(ctx.GetTrackInfo(), "", vendorStoreID, skuVendibilityList, ctx.GetUserName()) responseList, err2 := getAPI("").BatchUpdateVendibility(ctx.GetTrackInfo(), "", vendorStoreID, skuVendibilityList, ctx.GetUserName())
if err = err2; isErrPartialFailed(err) { if err = err2; isErrPartialFailed(err) {
successList = putils.UnselectStoreSkuListBySkuIDs(storeSkuList, utils.StringSlice2Int(getStrOutSkuIDs(responseList, false))) successList = putils.UnselectStoreSkuListBySkuIDs(storeSkuList, utils.StringSlice2Int(getStrOutSkuIDs(responseList, false)))
} }
@@ -130,7 +129,7 @@ func (p *PurchaseHandler) UpdateStoreSkusStatus(ctx *jxcontext.Context, storeID
func (p *PurchaseHandler) UpdateStoreSkusPrice(ctx *jxcontext.Context, storeID int, vendorStoreID string, storeSkuList []*partner.StoreSkuInfo) (successList []*partner.StoreSkuInfo, err error) { func (p *PurchaseHandler) UpdateStoreSkusPrice(ctx *jxcontext.Context, storeID int, vendorStoreID string, storeSkuList []*partner.StoreSkuInfo) (successList []*partner.StoreSkuInfo, err error) {
if len(storeSkuList) == 1 { if len(storeSkuList) == 1 {
if globals.EnableJdStoreWrite { if globals.EnableJdStoreWrite {
_, err = api.JdAPI.UpdateStationPrice(ctx.GetTrackInfo(), utils.Str2Int64WithDefault(storeSkuList[0].VendorSkuID, 0), vendorStoreID, int(storeSkuList[0].VendorPrice)) _, err = getAPI("").UpdateStationPrice(ctx.GetTrackInfo(), utils.Str2Int64WithDefault(storeSkuList[0].VendorSkuID, 0), vendorStoreID, int(storeSkuList[0].VendorPrice))
} }
} else { } else {
var skuPriceInfoList []*jdapi.SkuPriceInfo var skuPriceInfoList []*jdapi.SkuPriceInfo
@@ -141,7 +140,7 @@ func (p *PurchaseHandler) UpdateStoreSkusPrice(ctx *jxcontext.Context, storeID i
}) })
} }
if globals.EnableJdStoreWrite { if globals.EnableJdStoreWrite {
responseList, err2 := api.JdAPI.UpdateVendorStationPrice(ctx.GetTrackInfo(), "", vendorStoreID, skuPriceInfoList) responseList, err2 := getAPI("").UpdateVendorStationPrice(ctx.GetTrackInfo(), "", vendorStoreID, skuPriceInfoList)
if err = err2; isErrPartialFailed(err) { if err = err2; isErrPartialFailed(err) {
successList = putils.UnselectStoreSkuListBySkuIDs(storeSkuList, utils.StringSlice2Int(getStrOutSkuIDs(responseList, false))) successList = putils.UnselectStoreSkuListBySkuIDs(storeSkuList, utils.StringSlice2Int(getStrOutSkuIDs(responseList, false)))
} }
@@ -153,7 +152,7 @@ func (p *PurchaseHandler) UpdateStoreSkusPrice(ctx *jxcontext.Context, storeID i
func (p *PurchaseHandler) UpdateStoreSkusStock(ctx *jxcontext.Context, storeID int, vendorStoreID string, storeSkuList []*partner.StoreSkuInfo) (successList []*partner.StoreSkuInfo, err error) { func (p *PurchaseHandler) UpdateStoreSkusStock(ctx *jxcontext.Context, storeID int, vendorStoreID string, storeSkuList []*partner.StoreSkuInfo) (successList []*partner.StoreSkuInfo, err error) {
if len(storeSkuList) == 1 { if len(storeSkuList) == 1 {
if globals.EnableJdStoreWrite { if globals.EnableJdStoreWrite {
err = api.JdAPI.UpdateCurrentQty(ctx.GetTrackInfo(), vendorStoreID, utils.Str2Int64WithDefault(storeSkuList[0].VendorSkuID, 0), storeSkuList[0].Stock) err = getAPI("").UpdateCurrentQty(ctx.GetTrackInfo(), vendorStoreID, utils.Str2Int64WithDefault(storeSkuList[0].VendorSkuID, 0), storeSkuList[0].Stock)
} }
} else { } else {
var skuStockList []*jdapi.SkuStock var skuStockList []*jdapi.SkuStock
@@ -164,7 +163,7 @@ func (p *PurchaseHandler) UpdateStoreSkusStock(ctx *jxcontext.Context, storeID i
}) })
} }
if globals.EnableJdStoreWrite { if globals.EnableJdStoreWrite {
responseList, err2 := api.JdAPI.BatchUpdateCurrentQtys(ctx.GetTrackInfo(), "", vendorStoreID, skuStockList, ctx.GetUserName()) responseList, err2 := getAPI("").BatchUpdateCurrentQtys(ctx.GetTrackInfo(), "", vendorStoreID, skuStockList, ctx.GetUserName())
if err = err2; isErrPartialFailed(err) { if err = err2; isErrPartialFailed(err) {
successList = putils.UnselectStoreSkuListBySkuIDs(storeSkuList, utils.StringSlice2Int(getStrOutSkuIDs(responseList, false))) successList = putils.UnselectStoreSkuListBySkuIDs(storeSkuList, utils.StringSlice2Int(getStrOutSkuIDs(responseList, false)))
} }
@@ -189,7 +188,7 @@ func (p *PurchaseHandler) SyncStoreProducts(ctx *jxcontext.Context, parentTask t
storeSku := batchItemList[0].(*dao.StoreSkuSyncInfo) storeSku := batchItemList[0].(*dao.StoreSkuSyncInfo)
if storeSku.VendorSkuID != "" && storeSku.StoreSkuStatus == model.SkuStatusNormal { if storeSku.VendorSkuID != "" && storeSku.StoreSkuStatus == model.SkuStatusNormal {
if globals.EnableJdStoreWrite { if globals.EnableJdStoreWrite {
synchronized, err2 := api.JdAPI.SyncProduct(storeDetail.VendorStoreID, storeSku.VendorSkuID) synchronized, err2 := getAPI("").SyncProduct(storeDetail.VendorStoreID, storeSku.VendorSkuID)
if err = err2; err == nil && synchronized { if err = err2; err == nil && synchronized {
retVal = []int{1} retVal = []int{1}
} }

View File

@@ -22,7 +22,7 @@ func (c *PurchaseHandler) onWaybillMsg(msg *jdapi.CallbackDeliveryStatusMsg) (re
order.Status = model.WaybillStatusNew order.Status = model.WaybillStatusNew
case jdapi.DeliveryStatusAccepted: case jdapi.DeliveryStatusAccepted:
// todo 性能问题,暂时取消调用 // todo 性能问题,暂时取消调用
// if result, err := api.JdAPI.QuerySingleOrder(msg.OrderID); err == nil { // if result, err := getAPI("").QuerySingleOrder(msg.OrderID); err == nil {
// // 默认配送费=订单应付运费(orderReceivableFreight) // // 默认配送费=订单应付运费(orderReceivableFreight)
// //订单应付运费为未优惠前应付运费(满免优惠运费优惠券VIP免基础运费用户小费)ps用户小费是用户给配送员的小费 // //订单应付运费为未优惠前应付运费(满免优惠运费优惠券VIP免基础运费用户小费)ps用户小费是用户给配送员的小费
// order.DesiredFee = utils.Interface2Int64WithDefault(result["orderReceivableFreight"], 0) + // order.DesiredFee = utils.Interface2Int64WithDefault(result["orderReceivableFreight"], 0) +

View File

@@ -3,6 +3,7 @@ package apimanager
import ( import (
"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"
"git.rosy.net.cn/jx-callback/globals"
"git.rosy.net.cn/jx-callback/globals/api" "git.rosy.net.cn/jx-callback/globals/api"
) )
@@ -14,6 +15,7 @@ var (
) )
func init() { func init() {
globals.SugarLogger.Debug("init apimanager")
curAPIManager = &APIManager{} curAPIManager = &APIManager{}
partner.InitAPIManager(curAPIManager) partner.InitAPIManager(curAPIManager)
} }

14
main.go
View File

@@ -3,11 +3,18 @@ package main
import ( import (
"flag" "flag"
"fmt" "fmt"
"net/http"
_ "net/http/pprof"
"os" "os"
"time" "time"
"github.com/astaxie/beego"
"git.rosy.net.cn/baseapi/platformapi/dingdingapi" "git.rosy.net.cn/baseapi/platformapi/dingdingapi"
"git.rosy.net.cn/baseapi/utils" "git.rosy.net.cn/baseapi/utils"
_ "git.rosy.net.cn/jx-callback/globals/api/apimanager"
"git.rosy.net.cn/jx-callback/business/jxcallback/orderman" "git.rosy.net.cn/jx-callback/business/jxcallback/orderman"
"git.rosy.net.cn/jx-callback/business/jxcallback/scheduler/defsch" // 导入缺省订单调度器 "git.rosy.net.cn/jx-callback/business/jxcallback/scheduler/defsch" // 导入缺省订单调度器
"git.rosy.net.cn/jx-callback/business/jxstore/cms" "git.rosy.net.cn/jx-callback/business/jxstore/cms"
@@ -18,7 +25,6 @@ import (
"git.rosy.net.cn/jx-callback/globals/api" "git.rosy.net.cn/jx-callback/globals/api"
"git.rosy.net.cn/jx-callback/globals/api2" "git.rosy.net.cn/jx-callback/globals/api2"
"git.rosy.net.cn/jx-callback/globals/beegodb" "git.rosy.net.cn/jx-callback/globals/beegodb"
_ "git.rosy.net.cn/jx-callback/routers"
_ "git.rosy.net.cn/jx-callback/business/partner/printer/feie" _ "git.rosy.net.cn/jx-callback/business/partner/printer/feie"
_ "git.rosy.net.cn/jx-callback/business/partner/printer/xiaowm" _ "git.rosy.net.cn/jx-callback/business/partner/printer/xiaowm"
@@ -31,11 +37,9 @@ import (
_ "git.rosy.net.cn/jx-callback/business/partner/purchase/mtwm" _ "git.rosy.net.cn/jx-callback/business/partner/purchase/mtwm"
_ "git.rosy.net.cn/jx-callback/business/partner/purchase/weimob/wsc" _ "git.rosy.net.cn/jx-callback/business/partner/purchase/weimob/wsc"
"net/http"
_ "net/http/pprof"
_ "git.rosy.net.cn/jx-callback/business/jxstore/act" _ "git.rosy.net.cn/jx-callback/business/jxstore/act"
"github.com/astaxie/beego"
_ "git.rosy.net.cn/jx-callback/routers"
) )
var ( var (