diff --git a/business/partner/purchase/jd/act.go b/business/partner/purchase/jd/act.go index 0ecd8b470..abb75b513 100644 --- a/business/partner/purchase/jd/act.go +++ b/business/partner/purchase/jd/act.go @@ -10,7 +10,6 @@ import ( "git.rosy.net.cn/jx-callback/business/jxutils" "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/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) { if globals.EnableJdStoreWrite { if promotionType == model.ActSkuDirectDown { - return api.JdAPI.CreatePromotionInfosSingle(name, beginDate, endDate, outInfoId, advertising, traceId) + return getAPI("").CreatePromotionInfosSingle(name, beginDate, endDate, outInfoId, advertising, traceId) } else { - return api.JdAPI.CreatePromotionInfosLimitTime(name, beginDate, endDate, outInfoId, advertising, traceId) + return getAPI("").CreatePromotionInfosLimitTime(name, beginDate, endDate, outInfoId, advertising, traceId) } } else { 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) { if globals.EnableJdStoreWrite { 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 { - return api.JdAPI.CreatePromotionRulesLimitTime(infoId, outInfoId, limitDevice, limitPin, limitCount, limitDaily, traceId) + return getAPI("").CreatePromotionRulesLimitTime(infoId, outInfoId, limitDevice, limitPin, limitCount, limitDaily, traceId) } } return err @@ -90,9 +89,9 @@ func CreatePromotionSku(promotionType int, infoId int64, outInfoId string, skus var tmpSkusResult []*jdapi.PromotionSku var tmpErr error if promotionType == model.ActSkuDirectDown { - tmpSkusResult, tmpErr = api.JdAPI.CreatePromotionSkuSingle(infoId, outInfoId, batchSkus, traceId) + tmpSkusResult, tmpErr = getAPI("").CreatePromotionSkuSingle(infoId, outInfoId, batchSkus, traceId) } else { - tmpSkusResult, tmpErr = api.JdAPI.CreatePromotionSkuLimitTime(infoId, outInfoId, batchSkus, traceId) + tmpSkusResult, tmpErr = getAPI("").CreatePromotionSkuLimitTime(infoId, outInfoId, batchSkus, traceId) } if err = tmpErr; err != nil { break @@ -108,9 +107,9 @@ func CancelPromotionSku(promotionType int, infoId int64, outInfoId string, skus for _, batchSkus := range splitPromotionSku(skus, jdapi.MaxPromotionSkuCount) { var tmpErr error if promotionType == model.ActSkuDirectDown { - tmpErr = api.JdAPI.CancelPromotionSkuSingle(infoId, outInfoId, batchSkus, traceId) + tmpErr = getAPI("").CancelPromotionSkuSingle(infoId, outInfoId, batchSkus, traceId) } else { - tmpErr = api.JdAPI.CancelPromotionSkuLimitTime(infoId, outInfoId, batchSkus, traceId) + tmpErr = getAPI("").CancelPromotionSkuLimitTime(infoId, outInfoId, batchSkus, traceId) } if err = tmpErr; err != nil { 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) { if globals.EnableJdStoreWrite { if promotionType == model.ActSkuDirectDown { - return api.JdAPI.ConfirmPromotionSingle(infoId, outInfoId, traceId) + return getAPI("").ConfirmPromotionSingle(infoId, outInfoId, traceId) } else { - return api.JdAPI.ConfirmPromotionLimitTime(infoId, outInfoId, traceId) + return getAPI("").ConfirmPromotionLimitTime(infoId, outInfoId, traceId) } } 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) { if globals.EnableJdStoreWrite { if promotionType == model.ActSkuDirectDown { - return api.JdAPI.CancelPromotionSingle(infoId, outInfoId, traceId) + return getAPI("").CancelPromotionSingle(infoId, outInfoId, traceId) } else { - return api.JdAPI.CancelPromotionLimitTime(infoId, outInfoId, traceId) + return getAPI("").CancelPromotionLimitTime(infoId, outInfoId, traceId) } } 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) { if globals.EnableJdStoreWrite { if promotionType == model.ActSkuDirectDown { - return api.JdAPI.AdjustPromotionTimeSingle(infoId, outInfoId, endDate, traceId) + return getAPI("").AdjustPromotionTimeSingle(infoId, outInfoId, endDate, traceId) } else { - return api.JdAPI.AdjustPromotionTimeLimitTime(infoId, outInfoId, endDate, traceId) + return getAPI("").AdjustPromotionTimeLimitTime(infoId, outInfoId, endDate, traceId) } } 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) { if globals.EnableJdStoreWrite { if promotionType == model.ActSkuDirectDown { - return api.JdAPI.AdjustPromotionSkuSingle(infoId, outInfoId, skus, traceId) + return getAPI("").AdjustPromotionSkuSingle(infoId, outInfoId, skus, traceId) } else { - return api.JdAPI.AdjustPromotionSkuLimitTime(infoId, outInfoId, skus, traceId) + return getAPI("").AdjustPromotionSkuLimitTime(infoId, outInfoId, skus, traceId) } } 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) { - result, err := api.JdAPI.QueryPromotionInfo(utils.Str2Int64(promotionID)) + result, err := getAPI("").QueryPromotionInfo(utils.Str2Int64(promotionID)) if err == nil && len(result.SkuResultList) > 0 { act = &model.Act2{ Act: model.Act{ diff --git a/business/partner/purchase/jd/financial.go b/business/partner/purchase/jd/financial.go index 31d638164..96782346e 100644 --- a/business/partner/purchase/jd/financial.go +++ b/business/partner/purchase/jd/financial.go @@ -6,7 +6,6 @@ import ( "git.rosy.net.cn/jx-callback/business/model" "git.rosy.net.cn/jx-callback/business/partner" "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) { @@ -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 { // 如果是正向单 order, err2 := partner.CurOrderManager.LoadOrder(msg.BillID, model.VendorIDJD) if err = err2; err == nil { - orderData, err2 := api.JdAPI.QuerySingleOrder(msg.BillID) + orderData, err2 := getAPI("").QuerySingleOrder(msg.BillID) if err = err2; err == nil { orderFinancial, err2 := curPurchaseHandler.OrderDetail2Financial(orderData, false, order) if err = err2; err == nil { @@ -38,7 +37,7 @@ func (p *PurchaseHandler) onFinancialMsg(msg *jdapi.CallbackOrderMsg) (retVal *j err = nil } } 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 { 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)) } - order1, err2 := api.JdAPI.OrderShoudSettlementService(orderFinancial.VendorOrderID) + order1, err2 := getAPI("").OrderShoudSettlementService(orderFinancial.VendorOrderID) if err = err2; err == nil { orderFinancial.ShopMoney = utils.Interface2Int64WithDefault(order1["settlementAmount"], 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 } else { 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 diff --git a/business/partner/purchase/jd/jd.go b/business/partner/purchase/jd/jd.go index 4be74098d..aefdc075e 100644 --- a/business/partner/purchase/jd/jd.go +++ b/business/partner/purchase/jd/jd.go @@ -6,7 +6,7 @@ import ( "git.rosy.net.cn/jx-callback/business/jxutils/jxcontext" "git.rosy.net.cn/jx-callback/business/model" "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 { @@ -18,7 +18,8 @@ var ( ) func init() { - if api.JdAPI != nil { + globals.SugarLogger.Debug("init jd") + if getAPI("") != nil { curPurchaseHandler = new(PurchaseHandler) partner.RegisterPurchasePlatform(curPurchaseHandler) } diff --git a/business/partner/purchase/jd/order.go b/business/partner/purchase/jd/order.go index fd0e13505..e8e67e6ac 100644 --- a/business/partner/purchase/jd/order.go +++ b/business/partner/purchase/jd/order.go @@ -48,7 +48,7 @@ func (c *PurchaseHandler) updateOrderFinancialInfo(orderID string) (err error) { VendorOrderID: orderID, VendorID: model.VendorIDJD, } - orderSettlement, err := api.JdAPI.OrderShoudSettlementService2(orderID) + orderSettlement, err := getAPI("").OrderShoudSettlementService2(orderID) if err == nil { if orderSettlement != nil { updateOrderBySettleMent(order, orderSettlement) @@ -112,16 +112,16 @@ func (c *PurchaseHandler) getOrder(orderID string) (order *model.GoodsOrder, ord taskIndex := batchItemList[0].(int) switch taskIndex { case 0: - orderMap, err = api.JdAPI.QuerySingleOrder(orderID) + orderMap, err = getAPI("").QuerySingleOrder(orderID) if err == nil { order = c.Map2Order(orderMap) - realMobile, _ = api.JdAPI.GetRealMobile4Order(orderID, order.VendorStoreID) + realMobile, _ = getAPI("").GetRealMobile4Order(orderID, order.VendorStoreID) if realMobile != "" { order.ConsigneeMobile2 = jxutils.FormalizeMobile(realMobile) } } case 1: - orderSettlement, _ = api.JdAPI.OrderShoudSettlementService2(orderID) + orderSettlement, _ = getAPI("").OrderShoudSettlementService2(orderID) } return nil, err }, []int{0, 1}) @@ -130,11 +130,11 @@ func (c *PurchaseHandler) getOrder(orderID string) (order *model.GoodsOrder, ord if order != nil && orderSettlement != nil { 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) // order = c.Map2Order(orderMap) // 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) // order.ConsigneeMobile2 = jxutils.FormalizeMobile(realMobile) // } 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) { globals.SugarLogger.Debugf("jd AcceptOrRefuseOrder orderID:%s, isAcceptIt:%t", order.VendorOrderID, isAcceptIt) if globals.EnableStoreWrite { - err = api.JdAPI.OrderAcceptOperate(order.VendorOrderID, isAcceptIt, userName) + err = getAPI("").OrderAcceptOperate(order.VendorOrderID, isAcceptIt, userName) } else { 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) { globals.SugarLogger.Debugf("jd PickupGoods orderID:%s, isSelfDelivery:%t", order.VendorOrderID, isSelfDelivery) if !isSelfDelivery && globals.EnableJdStoreWrite { - _, err = api.JdAPI.OrderJDZBDelivery(order.VendorOrderID, userName) + _, err = getAPI("").OrderJDZBDelivery(order.VendorOrderID, userName) } else { 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) { if globals.EnableJdStoreWrite { - err = api.JdAPI.ReceiveFailedAudit(order.VendorOrderID, isAcceptIt, ctx.GetUserName(), "") + err = getAPI("").ReceiveFailedAudit(order.VendorOrderID, isAcceptIt, ctx.GetUserName(), "") } return err } func (p *PurchaseHandler) CallCourier(ctx *jxcontext.Context, order *model.GoodsOrder) (err error) { // 拣货失败后再次招唤平台配送 if globals.EnableJdStoreWrite { - err = api.JdAPI.UrgeDispatching(order.VendorOrderID, ctx.GetUserName()) + err = getAPI("").UrgeDispatching(order.VendorOrderID, ctx.GetUserName()) } return err } func (p *PurchaseHandler) ConfirmReceiveGoods(ctx *jxcontext.Context, order *model.GoodsOrder) (err error) { // 投递失败后确认收到退货 if globals.EnableJdStoreWrite { - err = api.JdAPI.ConfirmReceiveGoods(order.VendorOrderID) + err = getAPI("").ConfirmReceiveGoods(order.VendorOrderID) } 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) { globals.SugarLogger.Debugf("jd Swtich2SelfDeliver orderID:%s", order.VendorOrderID) if globals.EnableJdStoreWrite { - _, err = api.JdAPI.ModifySellerDelivery(order.VendorOrderID, userName) + _, err = getAPI("").ModifySellerDelivery(order.VendorOrderID, userName) if err != nil { if errWithCode, ok := err.(*utils.ErrorWithCode); ok && errWithCode.Level() == 1 { 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) { globals.SugarLogger.Debugf("jd Swtich2SelfDelivered orderID:%s", order.VendorOrderID) if globals.EnableJdStoreWrite { - _, err = api.JdAPI.DeliveryEndOrder(order.VendorOrderID, userName) + _, err = getAPI("").DeliveryEndOrder(order.VendorOrderID, userName) } 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) { globals.SugarLogger.Debugf("jd SelfDeliverDelivering orderID:%s", order.VendorOrderID) if globals.EnableJdStoreWrite { - _, err = api.JdAPI.OrderSerllerDelivery(order.VendorOrderID, userName) + _, err = getAPI("").OrderSerllerDelivery(order.VendorOrderID, userName) } 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) { - mobile, err = api.JdAPI.GetRealMobile4Order(order.VendorOrderID, order.VendorStoreID) + mobile, err = getAPI("").GetRealMobile4Order(order.VendorOrderID, order.VendorStoreID) return mobile, err } func (c *PurchaseHandler) AgreeOrRefuseCancel(ctx *jxcontext.Context, order *model.GoodsOrder, isAgree bool, reason string) (err error) { if globals.EnableJdStoreWrite { - err = api.JdAPI.OrderCancelOperate(order.VendorOrderID, isAgree, ctx.GetUserName(), reason) + err = getAPI("").OrderCancelOperate(order.VendorOrderID, isAgree, ctx.GetUserName(), reason) } 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) { if globals.EnableJdStoreWrite { 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 { err = fmt.Errorf("取消订单失败,京东取消订单是要先转为自送再处理,转自送失败:%v", err1) } @@ -415,7 +415,7 @@ func (c *PurchaseHandler) AdjustOrder(ctx *jxcontext.Context, order *model.Goods }) } if globals.EnableJdStoreWrite { - err = api.JdAPI.AdjustOrder(order.VendorOrderID, ctx.GetUserName(), reason, oaosAdjustDTOList) + err = getAPI("").AdjustOrder(order.VendorOrderID, ctx.GetUserName(), reason, oaosAdjustDTOList) } return err } @@ -434,7 +434,7 @@ func (c *PurchaseHandler) ListOrders(ctx *jxcontext.Context, parentTask tasksch. if vendorStoreID != "" { queryParam.DeliveryStationNo = vendorStoreID } - orderList, _, err := api.JdAPI.OrderQuery2(queryParam) + orderList, _, err := getAPI("").OrderQuery2(queryParam) if err == nil { vendorOrderIDs = make([]string, len(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) { - orderInfo, err := api.JdAPI.QuerySingleOrder2(order.VendorOrderID) + orderInfo, err := getAPI("").QuerySingleOrder2(order.VendorOrderID) if err == nil { tip2Add := int(tipFee) - orderInfo.Tips if tip2Add != 0 { 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) { - orderInfo, err := api.JdAPI.QuerySingleOrder2(order.VendorOrderID) + orderInfo, err := getAPI("").QuerySingleOrder2(order.VendorOrderID) if err == nil { 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) { if globals.EnableJdStoreWrite { - err = api.JdAPI.OrderAddTips(order.VendorOrderID, int(tipFee2Add), ctx.GetUserName()) + err = getAPI("").OrderAddTips(order.VendorOrderID, int(tipFee2Add), ctx.GetUserName()) } return err } diff --git a/business/partner/purchase/jd/order_afs.go b/business/partner/purchase/jd/order_afs.go index bc9c2faf5..e3ecc3803 100644 --- a/business/partner/purchase/jd/order_afs.go +++ b/business/partner/purchase/jd/order_afs.go @@ -8,7 +8,6 @@ import ( "git.rosy.net.cn/jx-callback/business/model" "git.rosy.net.cn/jx-callback/business/partner" "git.rosy.net.cn/jx-callback/globals" - "git.rosy.net.cn/jx-callback/globals/api" ) var ( @@ -67,7 +66,7 @@ func (c *PurchaseHandler) OnAfsOrderMsg(msg *jdapi.CallbackOrderMsg) (retVal *jd } 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 { status := c.callbackAfsMsg2Status(msg, afsInfo) 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) { 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 } @@ -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) { if globals.EnableJdStoreWrite { - err = api.JdAPI.ConfirmReceipt(order.AfsOrderID, ctx.GetUserName()) + err = getAPI("").ConfirmReceipt(order.AfsOrderID, ctx.GetUserName()) } 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) { 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 } diff --git a/business/partner/purchase/jd/order_comment.go b/business/partner/purchase/jd/order_comment.go index 24637011a..2b20a5b7c 100644 --- a/business/partner/purchase/jd/order_comment.go +++ b/business/partner/purchase/jd/order_comment.go @@ -7,7 +7,6 @@ import ( "git.rosy.net.cn/jx-callback/business/model" "git.rosy.net.cn/jx-callback/business/partner" "git.rosy.net.cn/jx-callback/globals" - "git.rosy.net.cn/jx-callback/globals/api" ) const ( @@ -16,7 +15,7 @@ const ( func (c *PurchaseHandler) onOrderComment2(msg *jdapi.CallbackOrderMsg) (err error) { intOrderID := utils.Str2Int64(msg.BillID) - result, err := api.JdAPI.GetCommentByOrderId(intOrderID) + result, err := getAPI("").GetCommentByOrderId(intOrderID) if err == nil { globals.SugarLogger.Debugf("onOrderComment comment:%s", utils.Format4Output(result, true)) 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) { 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 } diff --git a/business/partner/purchase/jd/sku.go b/business/partner/purchase/jd/sku.go index 248664076..02da3175b 100644 --- a/business/partner/purchase/jd/sku.go +++ b/business/partner/purchase/jd/sku.go @@ -15,7 +15,6 @@ import ( "git.rosy.net.cn/jx-callback/business/model/dao" "git.rosy.net.cn/jx-callback/business/partner" "git.rosy.net.cn/jx-callback/globals" - "git.rosy.net.cn/jx-callback/globals/api" "github.com/astaxie/beego" ) @@ -59,7 +58,7 @@ func (p *PurchaseHandler) CreateCategory(db *dao.DaoDB, cat *model.SkuCategory, } } 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 jdID := utils.Str2Int64WithDefault(result, 0); jdID != 0 { 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) { - result, err := api.JdAPI.QueryCategoriesByOrgCode() + result, err := getAPI("").QueryCategoriesByOrgCode() if err == nil { cats = make([]*model.SkuCategory, len(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 { if globals.EnableStoreWrite { - return api.JdAPI.UpdateShopCategory(cat.JdID, cat.Name) + return getAPI("").UpdateShopCategory(cat.JdID, cat.Name) } return nil } func (p *PurchaseHandler) DeleteCategory(db *dao.DaoDB, cat *model.SkuCategory, userName string) error { if globals.EnableStoreWrite { - return api.JdAPI.DelShopCategory(cat.JdID) + return getAPI("").DelShopCategory(cat.JdID) } return nil } @@ -122,7 +121,7 @@ func (p *PurchaseHandler) ReorderCategories(db *dao.DaoDB, parentCatID int, user jdCatIDs[k] = v.JdID } if globals.EnableStoreWrite { - err = api.JdAPI.ChangeShopCategoryOrder(parentJDID, jdCatIDs) + err = getAPI("").ChangeShopCategoryOrder(parentJDID, jdCatIDs) } } 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) { if skuExt.IsSpu == 0 { 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 jdSkuID := jdapi.GetJdSkuIDFromError(err); jdSkuID > 0 { 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) { jdSkuID := utils.Str2Int64(vendorSkuID) - skuList, _, err := api.JdAPI.QuerySkuInfos(&jdapi.QuerySkuParam{ + skuList, _, err := getAPI("").QuerySkuInfos(&jdapi.QuerySkuParam{ SkuID: jdSkuID, }) if err == nil { if len(skuList) >= 1 { skuNameExt = &model.SkuNameExt{} - if imgList, err2 := api.JdAPI.QueryListBySkuIds(&jdapi.QueryListBySkuIdsParam{ + if imgList, err2 := getAPI("").QueryListBySkuIds(&jdapi.QueryListBySkuIdsParam{ SkuIDs: []int64{jdSkuID}, }); err2 == nil && len(imgList) > 0 { 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) if skuExt.IsSpu == 0 { if globals.EnableStoreWrite { - vendorSkuID, err = api.JdAPI.UpdateSku(utils.Int2Str(sku.ID), params) + vendorSkuID, err = getAPI("").UpdateSku(utils.Int2Str(sku.ID), params) } } else { 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 skuExt.IsSpu == 0 { if globals.EnableStoreWrite { - _, err = api.JdAPI.UpdateSku(utils.Int2Str(sku.ID), params) + _, err = getAPI("").UpdateSku(utils.Int2Str(sku.ID), params) } } else { _, 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)) if globals.EnableStoreWrite { - _, err = api.JdAPI.BatchUpdateOutSkuId(skuPairs) + _, err = getAPI("").BatchUpdateOutSkuId(skuPairs) } return nil, err }, skuPairs) @@ -397,7 +396,7 @@ func (p *PurchaseHandler) syncSkuNameAsSpu(db *dao.DaoDB, sku *model.Sku, skuExt spuAddParams, skuAddParams := splitAddParams(addParams) if !jxutils.IsEmptyID(skuNameJdID) && sku.JdSyncStatus&model.SyncFlagDeletedMask != 0 { // 删除SKU 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 { @@ -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就是最后删的那个 updateFields = append(updateFields, model.FieldJdSyncStatus) if globals.EnableStoreWrite { - if err = api.JdAPI.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)) + if err = getAPI("").UpdateSpu(utils.Int2Str(skuExt.ID), utils.Params2Map(jdapi.KeyFixedStatus, jdapi.SkuFixedStatusOffline)); err == nil { + 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) updateFields = append(updateFields, model.FieldJdSyncStatus) 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 { skuExt.JdID = vendorSpuID // skuNameJdID = skuExt.JdID // 这个是故意去掉的,这样之后的首次SKU修改操作就会被忽略,下一条语句也就可以不用了 @@ -460,7 +459,7 @@ func (p *PurchaseHandler) syncSkuNameAsSpu(db *dao.DaoDB, sku *model.Sku, skuExt }, spuAddParams) updateFields = append(updateFields, model.FieldJdSyncStatus) if globals.EnableStoreWrite { - err = api.JdAPI.UpdateSpu(utils.Int2Str(skuExt.ID), params) + err = getAPI("").UpdateSpu(utils.Int2Str(skuExt.ID), params) } } 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 sku.JdSyncStatus&model.SyncFlagNewMask != 0 { // 非首次新增SKU 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 { 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.KeySkuPrice] = price 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 { skuIndex := sku.SkuIndex if skuIndex > 0 { 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) - 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) { - cats, err := api.JdAPI.QueryChildCategoriesForOP(pid) + cats, err := getAPI("").QueryChildCategoriesForOP(pid) if err != nil { return nil, err } @@ -589,7 +588,7 @@ func (p *PurchaseHandler) GetSkus(ctx *jxcontext.Context, skuID int, vendorSkuID PageSize: jdapi.MaxSkuIDsCount4QueryListBySkuIds, // 为了同时取图,这个值不要大于jdapi.MaxSkuIDsCount4QueryListBySkuIds } for { - skuList, _, err2 := api.JdAPI.QuerySkuInfos(param) + skuList, _, err2 := getAPI("").QuerySkuInfos(param) if err = err2; err != nil { return nil, err } @@ -616,7 +615,7 @@ func setSkuNameListPic(skuNameList []*partner.SkuNameInfo) []*partner.SkuNameInf } imgMap := make(map[int64]*jdapi.ImgHandleQueryResult) - if imgList, err2 := api.JdAPI.QueryListBySkuIds(&jdapi.QueryListBySkuIdsParam{ + if imgList, err2 := getAPI("").QueryListBySkuIds(&jdapi.QueryListBySkuIdsParam{ SkuIDs: jdSkuIDs, }); err2 == nil { for _, v := range imgList { @@ -640,7 +639,7 @@ func setSkuNameListPic(skuNameList []*partner.SkuNameInfo) []*partner.SkuNameInf task := tasksch.NewParallelTask("jd setSkuNameListPic", nil, jxcontext.AdminCtx, func(task *tasksch.ParallelTask, batchItemList []interface{}, params ...interface{}) (retVal interface{}, err error) { jdSkuID := batchItemList[0].(int64) - imgList, err := api.JdAPI.GetSkuPageImageInfo(jdSkuID) + imgList, err := getAPI("").GetSkuPageImageInfo(jdSkuID) if err == nil && len(imgList) > 0 { retVal = [][]string{ []string{utils.Int64ToStr(jdSkuID), imgList[0].Big}, diff --git a/business/partner/purchase/jd/store.go b/business/partner/purchase/jd/store.go index 65ddab394..c1107769d 100644 --- a/business/partner/purchase/jd/store.go +++ b/business/partner/purchase/jd/store.go @@ -33,7 +33,7 @@ type tJdStoreInfo struct { } 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 { retVal := &dao.StoreDetail{ 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)) - result, err2 := api.JdAPI.GetDeliveryRangeByStationNo(vendorStoreID) + result, err2 := getAPI("").GetDeliveryRangeByStationNo(vendorStoreID) if err = err2; err == nil { retVal.DeliveryRangeType = int8(utils.MustInterface2Int64(result["deliveryRangeType"])) 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)) 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 } } @@ -161,11 +161,11 @@ func (p *PurchaseHandler) UpdateStore(db *dao.DaoDB, storeID int, userName strin // params := map[string]interface{}{ // "yn": 1, // } -// return api.JdAPI.UpdateStoreInfo4Open(vendorStoreID, userName, params) +// return getAPI("").UpdateStoreInfo4Open(vendorStoreID, userName, params) // } // func (p *PurchaseHandler) EnableAutoAcceptOrder(vendorStoreID string, isEnabled bool) error { -// _, err := api.JdAPI.UpdateStoreConfig4Open(vendorStoreID, isEnabled) +// _, err := getAPI("").UpdateStoreConfig4Open(vendorStoreID, isEnabled) // return err // } @@ -174,7 +174,7 @@ func (p *PurchaseHandler) UpdateStore(db *dao.DaoDB, storeID int, userName strin // "closeStatus": 0, // "storeNotice": "", // } -// return api.JdAPI.UpdateStoreInfo4Open(vendorStoreID, userName, params) +// return getAPI("").UpdateStoreInfo4Open(vendorStoreID, userName, params) // } // 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, // "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 } if globals.EnableJdStoreWrite { - err = api.JdAPI.UpdateStoreInfo4Open(store.VendorStoreID, ctx.GetUserName(), storeParams) + err = getAPI("").UpdateStoreInfo4Open(store.VendorStoreID, ctx.GetUserName(), storeParams) } return nil, err }, 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) { - result, err := api.JdAPI.GetStoreInfoByStationNo(vendorStoreID) + result, err := getAPI("").GetStoreInfoByStationNo(vendorStoreID) if err == nil { 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) { _, closeStatus := JxStoreStatus2JdStatus(status) if globals.EnableJdStoreWrite { - err = api.JdAPI.UpdateStoreInfo4Open(vendorStoreID, ctx.GetUserName(), map[string]interface{}{ + err = getAPI("").UpdateStoreInfo4Open(vendorStoreID, ctx.GetUserName(), map[string]interface{}{ "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) { params := fillOpTimeParams(nil, opTimeList) if globals.EnableJdStoreWrite { - err = api.JdAPI.UpdateStoreInfo4Open(vendorStoreID, ctx.GetUserName(), params) + err = getAPI("").UpdateStoreInfo4Open(vendorStoreID, ctx.GetUserName(), params) } return err } func (c *PurchaseHandler) GetAllStoresVendorID(ctx *jxcontext.Context) (vendorStoreIDs []string, err error) { - vendorStoreIDs, err = api.JdAPI.GetStationsByVenderId() + vendorStoreIDs, err = getAPI("").GetStationsByVenderId() return vendorStoreIDs, err } diff --git a/business/partner/purchase/jd/store_sku.go b/business/partner/purchase/jd/store_sku.go index fe416f748..fb89788e5 100644 --- a/business/partner/purchase/jd/store_sku.go +++ b/business/partner/purchase/jd/store_sku.go @@ -83,7 +83,7 @@ package jd // // todo 以下可以优化为并行操作 // // globals.SugarLogger.Debug(utils.Format4Output(skuVendibilityList, false), utils.Format4Output(skuPriceInfoList, false), utils.Format4Output(skuStockList, false)) // 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 // } else { // if !isPartialFailed { @@ -94,9 +94,9 @@ package jd // } // if (err == nil || isContinueWhenError) && len(skuStockList) > 0 { // 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 { -// _, err = api.JdAPI.BatchUpdateCurrentQtys(ctx.GetTrackInfo(), "", stationNo, skuStockList, ctx.GetUserName()) +// _, err = getAPI("").BatchUpdateCurrentQtys(ctx.GetTrackInfo(), "", stationNo, skuStockList, ctx.GetUserName()) // } // if err == nil { // syncMask |= model.SyncFlagNewMask | model.SyncFlagDeletedMask @@ -109,9 +109,9 @@ package jd // } // if (err == nil || isContinueWhenError) && len(skuPriceInfoList) > 0 { // 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 { -// _, err = api.JdAPI.UpdateVendorStationPrice(ctx.GetTrackInfo(), "", stationNo, skuPriceInfoList) +// _, err = getAPI("").UpdateVendorStationPrice(ctx.GetTrackInfo(), "", stationNo, skuPriceInfoList) // } // if err == nil { // syncMask |= model.SyncFlagPriceMask diff --git a/business/partner/purchase/jd/store_sku2.go b/business/partner/purchase/jd/store_sku2.go index ec790bd9f..6ef9a9c6d 100644 --- a/business/partner/purchase/jd/store_sku2.go +++ b/business/partner/purchase/jd/store_sku2.go @@ -10,7 +10,6 @@ import ( "git.rosy.net.cn/jx-callback/business/partner" "git.rosy.net.cn/jx-callback/business/partner/putils" "git.rosy.net.cn/jx-callback/globals" - "git.rosy.net.cn/jx-callback/globals/api" ) 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) { subTaskID := batchItemList[0].(int) if subTaskID == 0 { - stockInfo, err = api.JdAPI.QueryOpenUseable(batchSkuInfoList) + stockInfo, err = getAPI("").QueryOpenUseable(batchSkuInfoList) } else { - priceInfo, err = api.JdAPI.GetStationInfoList(vendorStoreID, batchSkuList) + priceInfo, err = getAPI("").GetStationInfoList(vendorStoreID, batchSkuList) } return nil, err }, []int{0, 1}) @@ -119,7 +118,7 @@ func (p *PurchaseHandler) UpdateStoreSkusStatus(ctx *jxcontext.Context, storeID }) } 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) { 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) { if len(storeSkuList) == 1 { 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 { var skuPriceInfoList []*jdapi.SkuPriceInfo @@ -141,7 +140,7 @@ func (p *PurchaseHandler) UpdateStoreSkusPrice(ctx *jxcontext.Context, storeID i }) } 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) { 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) { if len(storeSkuList) == 1 { 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 { var skuStockList []*jdapi.SkuStock @@ -164,7 +163,7 @@ func (p *PurchaseHandler) UpdateStoreSkusStock(ctx *jxcontext.Context, storeID i }) } 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) { 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) if storeSku.VendorSkuID != "" && storeSku.StoreSkuStatus == model.SkuStatusNormal { 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 { retVal = []int{1} } diff --git a/business/partner/purchase/jd/waybill.go b/business/partner/purchase/jd/waybill.go index 43926cd76..7065b71fa 100644 --- a/business/partner/purchase/jd/waybill.go +++ b/business/partner/purchase/jd/waybill.go @@ -22,7 +22,7 @@ func (c *PurchaseHandler) onWaybillMsg(msg *jdapi.CallbackDeliveryStatusMsg) (re order.Status = model.WaybillStatusNew case jdapi.DeliveryStatusAccepted: // todo 性能问题,暂时取消调用 - // if result, err := api.JdAPI.QuerySingleOrder(msg.OrderID); err == nil { + // if result, err := getAPI("").QuerySingleOrder(msg.OrderID); err == nil { // // 默认配送费=订单应付运费(orderReceivableFreight) // //订单应付运费为未优惠前应付运费(满免优惠,运费优惠券,VIP免基础运费,用户小费)ps:用户小费是用户给配送员的小费 // order.DesiredFee = utils.Interface2Int64WithDefault(result["orderReceivableFreight"], 0) + diff --git a/globals/api/apimanager/apimanager.go b/globals/api/apimanager/apimanager.go index b8a724239..b4f9236e6 100644 --- a/globals/api/apimanager/apimanager.go +++ b/globals/api/apimanager/apimanager.go @@ -3,6 +3,7 @@ package apimanager import ( "git.rosy.net.cn/jx-callback/business/model" "git.rosy.net.cn/jx-callback/business/partner" + "git.rosy.net.cn/jx-callback/globals" "git.rosy.net.cn/jx-callback/globals/api" ) @@ -14,6 +15,7 @@ var ( ) func init() { + globals.SugarLogger.Debug("init apimanager") curAPIManager = &APIManager{} partner.InitAPIManager(curAPIManager) } diff --git a/main.go b/main.go index 38a15bf05..ab9db37e4 100644 --- a/main.go +++ b/main.go @@ -3,11 +3,18 @@ package main import ( "flag" "fmt" + "net/http" + _ "net/http/pprof" "os" "time" + "github.com/astaxie/beego" + "git.rosy.net.cn/baseapi/platformapi/dingdingapi" "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/scheduler/defsch" // 导入缺省订单调度器 "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/api2" "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/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/weimob/wsc" - "net/http" - _ "net/http/pprof" - _ "git.rosy.net.cn/jx-callback/business/jxstore/act" - "github.com/astaxie/beego" + + _ "git.rosy.net.cn/jx-callback/routers" ) var (