Merge remote-tracking branch 'origin/mark' into don
This commit is contained in:
@@ -54,10 +54,17 @@ type IUser interface {
|
||||
GetName() string
|
||||
}
|
||||
|
||||
const (
|
||||
UpdateUserTypeAdd = 1
|
||||
UpdateUserTypeDelete = 2
|
||||
UpdateUserTypeUpdate = 3
|
||||
)
|
||||
|
||||
type IUserProvider interface {
|
||||
GetUser(authID, authIDType string) (user IUser)
|
||||
UpdateUserMobile(userID string, mobile string) (err error)
|
||||
UpdateUserEmail(userID string, email string) (err error)
|
||||
UpdateUserType(userID string, userTypeMask int8, updateType int) (err error)
|
||||
// CreateUser(userID2, mobile, email, name string) (user IUser, err error)
|
||||
}
|
||||
|
||||
@@ -73,6 +80,7 @@ type IAuther interface {
|
||||
AddAuthBind(authBindEx *AuthBindEx, userName string) (err error)
|
||||
UnbindAuth(userID, authType, userName string) (err error)
|
||||
Logout(authInfo *AuthInfo) (err error)
|
||||
GetUserType() (userType int8)
|
||||
}
|
||||
|
||||
var (
|
||||
@@ -232,6 +240,7 @@ func Login(authType, authID, authIDType, authSecret string) (authInfo *AuthInfo,
|
||||
}
|
||||
if authBindEx, err = handler.VerifySecret(realAuthID, authSecret); err == nil {
|
||||
// globals.SugarLogger.Debugf("auth2 Login authBindEx:%s", utils.Format4Output(authBindEx, false))
|
||||
needAutoAddAuthBind := false
|
||||
if authBindEx == nil { // mobile, email会返回nil(表示不会新建AuthBind实体)
|
||||
user = userProvider.GetUser(authID, authIDType)
|
||||
authBindEx = &AuthBindEx{
|
||||
@@ -252,12 +261,19 @@ func Login(authType, authID, authIDType, authSecret string) (authInfo *AuthInfo,
|
||||
}
|
||||
if user != nil {
|
||||
authBindEx.UserID = user.GetID()
|
||||
needAutoAddAuthBind = true
|
||||
}
|
||||
} else if authBindEx.UserID != "" {
|
||||
user = userProvider.GetUser(authBindEx.UserID, UserIDID)
|
||||
}
|
||||
}
|
||||
authInfo = createAuthInfo(user, authBindEx)
|
||||
if needAutoAddAuthBind {
|
||||
if authers[authInfo.AuthBindInfo.Type].AddAuthBind(authInfo.AuthBindInfo, user.GetName()) == nil {
|
||||
// todo,用户类型应该要与RegisterUser一起统一处理
|
||||
userProvider.UpdateUserType(user.GetID(), handler.GetUserType(), UpdateUserTypeAdd)
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
err = ErrIllegalAuthType
|
||||
|
||||
@@ -53,6 +53,10 @@ func (a *DefAuther) Logout(authInfo *auth2.AuthInfo) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
func (a *DefAuther) GetUserType() (userType int8) {
|
||||
return model.UserTypeConsumer
|
||||
}
|
||||
|
||||
// 此函数用于联合(通过unionID)查找用户
|
||||
func (a *DefAuther) UnionFindAuthBind(curAuthType string, unionAuthTypeList []string, openID, unionID string, authDetail interface{}) (authBindEx *auth2.AuthBindEx, err error) {
|
||||
db := dao.GetDB()
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
package dingding
|
||||
|
||||
const (
|
||||
AuthTypeDingDing = "dingding"
|
||||
AuthTypeStaff = "ddstaff" // 钉钉企业登录
|
||||
AuthTypeQRCode = "ddqrcode"
|
||||
AuthTypeStaff = "ddstaff" // 钉钉企业登录
|
||||
AuthTypeQRCode = "ddqrcode"
|
||||
)
|
||||
|
||||
@@ -27,7 +27,7 @@ func (a *QRCodeAuther) VerifySecret(dummy, code string) (authBindEx *auth2.AuthB
|
||||
userQRInfo, err := api.DingDingQRCodeAPI.GetUserInfoByCode(code)
|
||||
if err == nil {
|
||||
globals.SugarLogger.Debugf("dingding qrcode VerifySecret code:%s, userQRInfo:%s", code, utils.Format4Output(userQRInfo, false))
|
||||
if authBindEx, err = a.UnionFindAuthBind(AuthTypeQRCode, []string{AuthTypeDingDing, AuthTypeStaff, AuthTypeQRCode}, userQRInfo.OpenID, userQRInfo.UnionID, userQRInfo); err == nil {
|
||||
if authBindEx, err = a.UnionFindAuthBind(AuthTypeQRCode, []string{AuthTypeStaff, AuthTypeQRCode}, userQRInfo.OpenID, userQRInfo.UnionID, userQRInfo); err == nil {
|
||||
authBindEx.UserHint = &auth2.UserBasic{
|
||||
Name: userQRInfo.Nickname,
|
||||
}
|
||||
|
||||
@@ -4,6 +4,7 @@ import (
|
||||
"git.rosy.net.cn/baseapi/utils"
|
||||
"git.rosy.net.cn/jx-callback/business/auth2"
|
||||
"git.rosy.net.cn/jx-callback/business/auth2/authprovider"
|
||||
"git.rosy.net.cn/jx-callback/business/model"
|
||||
"git.rosy.net.cn/jx-callback/globals"
|
||||
"git.rosy.net.cn/jx-callback/globals/api"
|
||||
)
|
||||
@@ -28,7 +29,7 @@ func (a *StaffAuther) VerifySecret(dummy, code string) (authBindEx *auth2.AuthBi
|
||||
if err == nil {
|
||||
userDetail, err2 := api.DingDingAPI.GetUserDetail(userID.UserID)
|
||||
if err = err2; err == nil {
|
||||
if authBindEx, err = a.UnionFindAuthBind(AuthTypeStaff, []string{AuthTypeDingDing, AuthTypeStaff, AuthTypeQRCode}, userID.UserID, utils.Interface2String(userDetail["unionid"]), userDetail); err == nil {
|
||||
if authBindEx, err = a.UnionFindAuthBind(AuthTypeStaff, []string{AuthTypeStaff, AuthTypeQRCode}, userID.UserID, utils.Interface2String(userDetail["unionid"]), userDetail); err == nil {
|
||||
authBindEx.UserHint = &auth2.UserBasic{
|
||||
UserID2: userID.UserID,
|
||||
Mobile: utils.Interface2String(userDetail["mobile"]),
|
||||
@@ -40,3 +41,7 @@ func (a *StaffAuther) VerifySecret(dummy, code string) (authBindEx *auth2.AuthBi
|
||||
}
|
||||
return authBindEx, err
|
||||
}
|
||||
|
||||
func (a *StaffAuther) GetUserType() (userType int8) {
|
||||
return model.UserTypeOperator
|
||||
}
|
||||
|
||||
@@ -6,6 +6,7 @@ import (
|
||||
"git.rosy.net.cn/baseapi/platformapi/weixinapi"
|
||||
"git.rosy.net.cn/jx-callback/business/auth2"
|
||||
"git.rosy.net.cn/jx-callback/business/auth2/authprovider"
|
||||
"git.rosy.net.cn/jx-callback/business/model"
|
||||
"git.rosy.net.cn/jx-callback/globals"
|
||||
"git.rosy.net.cn/jx-callback/globals/api"
|
||||
)
|
||||
@@ -68,3 +69,7 @@ func (a *Auther) getAPI() *weixinapi.API {
|
||||
}
|
||||
return api.WeixinAPI
|
||||
}
|
||||
|
||||
func (a *Auther) GetUserType() (userType int8) {
|
||||
return model.UserTypeStoreBoss
|
||||
}
|
||||
|
||||
@@ -8,6 +8,7 @@ import (
|
||||
"git.rosy.net.cn/baseapi/platformapi/weixinapi"
|
||||
"git.rosy.net.cn/jx-callback/business/auth2"
|
||||
"git.rosy.net.cn/jx-callback/business/auth2/authprovider"
|
||||
"git.rosy.net.cn/jx-callback/business/model"
|
||||
"git.rosy.net.cn/jx-callback/globals"
|
||||
"git.rosy.net.cn/jx-callback/globals/api"
|
||||
)
|
||||
@@ -57,6 +58,10 @@ func (a *MiniAuther) DecryptData(authInfo *auth2.AuthInfo, encryptedData, iv str
|
||||
return base64.StdEncoding.EncodeToString(decryptedData), nil
|
||||
}
|
||||
|
||||
func (a *MiniAuther) GetUserType() (userType int8) {
|
||||
return model.UserTypeStoreBoss
|
||||
}
|
||||
|
||||
func ProxySNSCode2Session(jsCode string) (sessionInfo *weixinapi.SessionInfo, err error) {
|
||||
miniApi := api.WeixinMiniAPI
|
||||
list := strings.Split(jsCode, ",")
|
||||
|
||||
@@ -1090,15 +1090,23 @@ func (c *OrderManager) AmendMissingOrders(ctx *jxcontext.Context, vendorIDs []in
|
||||
vendorIDs = append(vendorIDs, vendorID)
|
||||
}
|
||||
}
|
||||
type tDateVendorPair struct {
|
||||
QueryDate time.Time
|
||||
VendorID int
|
||||
if len(vendorIDs) == 0 {
|
||||
return "", fmt.Errorf("找不到指定的平台")
|
||||
}
|
||||
|
||||
fromDate = utils.Time2Date(fromDate)
|
||||
if utils.IsTimeZero(toDate) {
|
||||
toDate = fromDate
|
||||
}
|
||||
toDate = utils.Time2Date(toDate)
|
||||
if toDate.Sub(fromDate) > 7*24*time.Hour {
|
||||
return "", fmt.Errorf("最多一次一周,请调整时间")
|
||||
}
|
||||
|
||||
type tDateVendorPair struct {
|
||||
QueryDate time.Time
|
||||
VendorID int
|
||||
}
|
||||
var dateVendorList []*tDateVendorPair
|
||||
for _, vendorID := range vendorIDs {
|
||||
for tmpDate := fromDate; tmpDate.Sub(toDate) <= 0; tmpDate = tmpDate.Add(24 * time.Hour) {
|
||||
@@ -1114,21 +1122,21 @@ func (c *OrderManager) AmendMissingOrders(ctx *jxcontext.Context, vendorIDs []in
|
||||
}
|
||||
if len(dateVendorList) > 0 {
|
||||
var missingOrderList []*tOrderVendorPair
|
||||
db := dao.GetDB()
|
||||
vendorStoreIDMap := make(map[int]string)
|
||||
if storeID > 0 {
|
||||
for _, vendorID := range vendorIDs {
|
||||
storeDetail, err2 := dao.GetStoreDetail(db, storeID, vendorID)
|
||||
if err = err2; err != nil {
|
||||
return "", err
|
||||
}
|
||||
vendorStoreIDMap[vendorID] = storeDetail.VendorStoreID
|
||||
}
|
||||
}
|
||||
task := tasksch.NewSeqTask("AmendMissingOrders", ctx,
|
||||
func(task *tasksch.SeqTask, step int, params ...interface{}) (result interface{}, err error) {
|
||||
switch step {
|
||||
case 0:
|
||||
db := dao.GetDB()
|
||||
vendorStoreIDMap := make(map[int]string)
|
||||
if storeID > 0 {
|
||||
for _, vendorID := range vendorIDs {
|
||||
storeDetail, err2 := dao.GetStoreDetail(db, storeID, vendorID)
|
||||
if err = err2; err != nil {
|
||||
return "", err
|
||||
}
|
||||
vendorStoreIDMap[vendorID] = storeDetail.VendorStoreID
|
||||
}
|
||||
}
|
||||
task1 := tasksch.NewParallelTask("AmendMissingOrders ListOrders", tasksch.NewParallelConfig().SetIsContinueWhenError(isContinueWhenError), ctx,
|
||||
func(task *tasksch.ParallelTask, batchItemList []interface{}, params ...interface{}) (retVal interface{}, err error) {
|
||||
vendorDate := batchItemList[0].(*tDateVendorPair)
|
||||
|
||||
@@ -20,8 +20,8 @@ import (
|
||||
const (
|
||||
DefActSkuStock = 200 // 缺省活动库存
|
||||
|
||||
maxDiscount4SkuSecKill = 80
|
||||
minDiscount4SkuDirectDown = 40
|
||||
maxDiscount4SkuSecKill = 100
|
||||
minDiscount4SkuDirectDown = 0
|
||||
)
|
||||
|
||||
type ActOrderRuleParam struct {
|
||||
|
||||
@@ -1319,7 +1319,7 @@ func formatAutoSaleTime(autoSaleTime time.Time) (outAutoSaleTime time.Time) {
|
||||
}
|
||||
|
||||
// todo 应该用updateStoresSkusWithoutSync实现
|
||||
func updateStoreSkusSaleWithoutSync(ctx *jxcontext.Context, storeID int, skuBindSkuInfos []*StoreSkuBindSkuInfo, autoSaleTime time.Time, userName string) (needSyncSkus []int, err error) {
|
||||
func updateStoreSkusSaleWithoutSync(ctx *jxcontext.Context, storeID int, skuBindSkuInfos []*StoreSkuBindSkuInfo, autoSaleTime time.Time, ignoreDontSale bool, userName string) (needSyncSkus []int, err error) {
|
||||
var num int64
|
||||
db := dao.GetDB()
|
||||
needSyncIDMap := make(map[int]int)
|
||||
@@ -1345,28 +1345,31 @@ func updateStoreSkusSaleWithoutSync(ctx *jxcontext.Context, storeID int, skuBind
|
||||
autoSaleTime = formatAutoSaleTime(autoSaleTime)
|
||||
for _, skuBind := range storeSkuList {
|
||||
if v := skuBindSkuInfosMap[skuBind.SkuID]; v != nil && v.IsSale != 0 {
|
||||
if v.IsSale == 1 {
|
||||
skuBind.Status = model.StoreSkuBindStatusNormal
|
||||
} else {
|
||||
skuBind.Status = model.StoreSkuBindStatusDontSale
|
||||
}
|
||||
kvs := map[string]interface{}{
|
||||
model.FieldStatus: skuBind.Status,
|
||||
model.FieldJdSyncStatus: skuBind.JdSyncStatus | model.SyncFlagSaleMask,
|
||||
model.FieldEbaiSyncStatus: skuBind.EbaiSyncStatus | model.SyncFlagSaleMask,
|
||||
model.FieldMtwmSyncStatus: skuBind.MtwmSyncStatus | model.SyncFlagSaleMask,
|
||||
model.FieldWscSyncStatus: skuBind.WscSyncStatus | model.SyncFlagSaleMask,
|
||||
}
|
||||
if utils.IsTimeZero(autoSaleTime) || skuBind.Status == model.SkuStatusNormal {
|
||||
autoSaleTime = utils.DefaultTimeValue
|
||||
}
|
||||
kvs["AutoSaleAt"] = autoSaleTime
|
||||
if num, err = dao.UpdateEntityLogically(db, skuBind, kvs, userName, nil); err != nil {
|
||||
dao.Rollback(db)
|
||||
return nil, err
|
||||
}
|
||||
if num == 1 {
|
||||
needSyncIDMap[v.SkuID] = 1
|
||||
if !(!utils.IsTimeZero(autoSaleTime) && ignoreDontSale && skuBind.Status == model.StoreSkuBindStatusDontSale) {
|
||||
if v.IsSale == -1 || !utils.IsTimeZero(autoSaleTime) {
|
||||
skuBind.Status = model.StoreSkuBindStatusDontSale
|
||||
} else if v.IsSale == 1 {
|
||||
skuBind.Status = model.StoreSkuBindStatusNormal
|
||||
}
|
||||
kvs := map[string]interface{}{
|
||||
model.FieldStatus: skuBind.Status,
|
||||
model.FieldJdSyncStatus: skuBind.JdSyncStatus | model.SyncFlagSaleMask,
|
||||
model.FieldEbaiSyncStatus: skuBind.EbaiSyncStatus | model.SyncFlagSaleMask,
|
||||
model.FieldMtwmSyncStatus: skuBind.MtwmSyncStatus | model.SyncFlagSaleMask,
|
||||
model.FieldWscSyncStatus: skuBind.WscSyncStatus | model.SyncFlagSaleMask,
|
||||
}
|
||||
if utils.IsTimeZero(autoSaleTime) || skuBind.Status == model.SkuStatusNormal {
|
||||
kvs["AutoSaleAt"] = utils.DefaultTimeValue
|
||||
} else {
|
||||
kvs["AutoSaleAt"] = autoSaleTime
|
||||
}
|
||||
if num, err = dao.UpdateEntityLogically(db, skuBind, kvs, userName, nil); err != nil {
|
||||
dao.Rollback(db)
|
||||
return nil, err
|
||||
}
|
||||
if num == 1 {
|
||||
needSyncIDMap[v.SkuID] = 1
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1386,13 +1389,13 @@ func uniqueStoreSkuBind(skuBindSkuInfos []*StoreSkuBindSkuInfo) (outSkuBindSkuIn
|
||||
return outSkuBindSkuInfos
|
||||
}
|
||||
|
||||
func UpdateStoresSkusSale(ctx *jxcontext.Context, storeIDs []int, skuBindSkuInfos []*StoreSkuBindSkuInfo, autoSaleTime time.Time, userName string, isAsync, isContinueWhenError bool) (hint string, err error) {
|
||||
func UpdateStoresSkusSale(ctx *jxcontext.Context, storeIDs []int, skuBindSkuInfos []*StoreSkuBindSkuInfo, autoSaleTime time.Time, ignoreDontSale bool, userName string, isAsync, isContinueWhenError bool) (hint string, err error) {
|
||||
storeIDs = uniqueStoreIDs(storeIDs)
|
||||
skuBindSkuInfos = uniqueStoreSkuBind(skuBindSkuInfos)
|
||||
|
||||
var num int64
|
||||
for _, storeID := range storeIDs {
|
||||
skuIDs, err2 := updateStoreSkusSaleWithoutSync(ctx, storeID, skuBindSkuInfos, autoSaleTime, userName)
|
||||
skuIDs, err2 := updateStoreSkusSaleWithoutSync(ctx, storeID, skuBindSkuInfos, autoSaleTime, ignoreDontSale, userName)
|
||||
if err = err2; err != nil {
|
||||
return "", err
|
||||
}
|
||||
|
||||
@@ -69,6 +69,24 @@ func (*UserProvider) UpdateUserEmail(userID string, email string) (err error) {
|
||||
return err
|
||||
}
|
||||
|
||||
func (*UserProvider) UpdateUserType(userID string, userTypeMask int8, updateType int) (err error) {
|
||||
db := dao.GetDB()
|
||||
user := &model.User{
|
||||
UserID: userID,
|
||||
}
|
||||
if err = dao.GetEntity(db, user, "UserID"); err == nil {
|
||||
if updateType == auth2.UpdateUserTypeAdd {
|
||||
user.Type |= userTypeMask
|
||||
} else if updateType == auth2.UpdateUserTypeDelete {
|
||||
user.Type &= ^userTypeMask
|
||||
} else {
|
||||
user.Type = userTypeMask
|
||||
}
|
||||
_, err = dao.UpdateEntity(db, user, "Type")
|
||||
}
|
||||
return err
|
||||
}
|
||||
|
||||
// func (*UserProvider) CreateUser(userID2, mobile, email, name string) (user auth2.IUser, err error) {
|
||||
// realUser := &model.User{
|
||||
// UserID2: userID2,
|
||||
@@ -189,12 +207,16 @@ func GetStoreList4User(ctx *jxcontext.Context, mobileNum, userID string) (storeL
|
||||
return storeList, err
|
||||
}
|
||||
|
||||
func GetMyStoreListNew(ctx *jxcontext.Context) (storeList []*dao.StoreWithCityName, err error) {
|
||||
func GetMyStoreListNew(ctx *jxcontext.Context) (storeList []*dao.StoreWithCityName, errCode string, err error) {
|
||||
if !auth2.IsV2Token(ctx.GetToken()) {
|
||||
return nil, model.ErrCodeTokenIsInvalid, model.ErrTokenIsInvalid
|
||||
}
|
||||
mobileNum, userID := ctx.GetMobileAndUserID()
|
||||
if mobileNum == "" {
|
||||
return nil, fmt.Errorf("不能得到用户手机号")
|
||||
return nil, "", fmt.Errorf("不能得到用户手机号")
|
||||
}
|
||||
return GetStoreList4User(ctx, mobileNum, userID)
|
||||
storeList, err = GetStoreList4User(ctx, mobileNum, userID)
|
||||
return storeList, "", err
|
||||
}
|
||||
|
||||
func GetStoreRoleList(ctx *jxcontext.Context) (roleList []*authz.RoleInfo, err error) {
|
||||
|
||||
@@ -7,6 +7,7 @@ import (
|
||||
"git.rosy.net.cn/jx-callback/business/auth2"
|
||||
"git.rosy.net.cn/jx-callback/business/jxcallback/auth"
|
||||
"git.rosy.net.cn/jx-callback/business/model"
|
||||
"git.rosy.net.cn/jx-callback/business/model/dao"
|
||||
"git.rosy.net.cn/jx-callback/globals"
|
||||
)
|
||||
|
||||
@@ -143,7 +144,11 @@ func (ctx *Context) GetMobileAndUserID() (mobile, userID string) {
|
||||
} else {
|
||||
userInfo, err2 := auth.GetUserInfo(token)
|
||||
if err2 == nil {
|
||||
mobile = userInfo.GetAuthID()
|
||||
if mobile = userInfo.GetAuthID(); mobile != "" {
|
||||
if user, err := dao.GetUserByID(dao.GetDB(), "mobile", mobile); err == nil {
|
||||
userID = user.UserID
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return mobile, userID
|
||||
|
||||
@@ -7,10 +7,13 @@ import (
|
||||
"git.rosy.net.cn/jx-callback/business/jxutils"
|
||||
)
|
||||
|
||||
const (
|
||||
defLastHours = 24
|
||||
maxStoreHours = 48 // 最多存放小时数
|
||||
)
|
||||
|
||||
var (
|
||||
defTaskMan TaskMan
|
||||
defLastHours = 24
|
||||
maxStoreTime = 48 * time.Hour // 最多存两天时间
|
||||
defTaskMan TaskMan
|
||||
)
|
||||
|
||||
type TaskMan struct {
|
||||
@@ -39,7 +42,7 @@ func (m *TaskMan) GetTasks(taskID string, fromStatus, toStatus int, lastHours in
|
||||
}
|
||||
|
||||
func (m *TaskMan) ManageTask(task ITask) ITask {
|
||||
m.taskMap.StoreWithTimeout(task.GetID(), task, maxStoreTime)
|
||||
m.taskMap.StoreWithTimeout(task.GetID(), task, maxStoreHours*time.Hour)
|
||||
return task
|
||||
}
|
||||
|
||||
@@ -57,3 +60,15 @@ func IsTaskRunning(taskID string) bool {
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
func UnmanageTasks(taskIDs []string) {
|
||||
if len(taskIDs) == 0 {
|
||||
allTasks := GetTasks("", TaskStatusBegin, TaskStatusEnd, maxStoreHours, "")
|
||||
for _, v := range allTasks {
|
||||
taskIDs = append(taskIDs, v.GetID())
|
||||
}
|
||||
}
|
||||
for _, v := range taskIDs {
|
||||
defTaskMan.taskMap.Delete(v)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -5,6 +5,7 @@ const (
|
||||
VendorTypeUnknown = 0 // 未知
|
||||
VendorTypePurchase = 1 // 购物平台
|
||||
VendorTypeDelivery = 2 // 快递平台
|
||||
VendorTypePrinter = 3 // 网络打印机
|
||||
VendorTypeOthers = 9 // 其它
|
||||
|
||||
VendorIDUnknown = -1
|
||||
@@ -128,6 +129,35 @@ var (
|
||||
Value2Name: "Secret",
|
||||
Value3Name: "管理后台Cookie",
|
||||
},
|
||||
|
||||
// VendorIDDada: &VendorInfo{
|
||||
// Name: "达达快递",
|
||||
// OrgCodeName: "商户ID",
|
||||
// Value1Name: "app_key",
|
||||
// Value2Name: "app_secret",
|
||||
// },
|
||||
// VendorIDMTPS: &VendorInfo{
|
||||
// Name: "美团配送",
|
||||
// OrgCodeName: "自编码",
|
||||
// Value1Name: "Appkey",
|
||||
// Value2Name: "Secret",
|
||||
// },
|
||||
|
||||
// VendorIDFeiE: &VendorInfo{
|
||||
// Name: "飞鹅",
|
||||
// OrgCodeName: "User",
|
||||
// Value1Name: "Key",
|
||||
// },
|
||||
// VendorIDXiaoWM: &VendorInfo{
|
||||
// Name: "外卖管家",
|
||||
// OrgCodeName: "AppID",
|
||||
// Value1Name: "AppKey",
|
||||
// },
|
||||
// VendorIDYiLianYun: &VendorInfo{
|
||||
// Name: "易联云",
|
||||
// OrgCodeName: "ClientID",
|
||||
// Value1Name: "ClientSecret",
|
||||
// },
|
||||
}
|
||||
)
|
||||
|
||||
|
||||
@@ -158,7 +158,7 @@ type IPurchasePlatformHandler interface {
|
||||
// db *dao.DaoDB,
|
||||
type IMultipleStoresHandler interface {
|
||||
IPurchasePlatformHandler
|
||||
ReadCategories() (cats []*model.SkuCategory, err error)
|
||||
GetAllCategories(ctx *jxcontext.Context, vendorOrgCode string) (cats []*BareCategoryInfo, err error)
|
||||
|
||||
CreateCategory(db *dao.DaoDB, cat *model.SkuCategory, userName string) (err error)
|
||||
UpdateCategory(db *dao.DaoDB, cat *model.SkuCategory, userName string) error
|
||||
|
||||
@@ -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{
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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)
|
||||
}
|
||||
|
||||
11
business/partner/purchase/jd/jd_test.go
Normal file
11
business/partner/purchase/jd/jd_test.go
Normal file
@@ -0,0 +1,11 @@
|
||||
package jd
|
||||
|
||||
import (
|
||||
_ "git.rosy.net.cn/jx-callback/globals/api/apimanager"
|
||||
|
||||
"git.rosy.net.cn/jx-callback/globals/testinit"
|
||||
)
|
||||
|
||||
func init() {
|
||||
testinit.Init()
|
||||
}
|
||||
@@ -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
|
||||
}
|
||||
|
||||
@@ -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
|
||||
}
|
||||
|
||||
@@ -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
|
||||
}
|
||||
|
||||
@@ -10,13 +10,8 @@ import (
|
||||
_ "git.rosy.net.cn/jx-callback/business/jxcallback/orderman"
|
||||
"git.rosy.net.cn/jx-callback/business/model"
|
||||
"git.rosy.net.cn/jx-callback/business/partner"
|
||||
"git.rosy.net.cn/jx-callback/globals/testinit"
|
||||
)
|
||||
|
||||
func init() {
|
||||
testinit.Init()
|
||||
}
|
||||
|
||||
func TestSwitch2SelfDeliver(t *testing.T) {
|
||||
orderID := "817540316000041"
|
||||
if order, err := partner.CurOrderManager.LoadOrder(orderID, model.VendorIDJD); err == nil {
|
||||
|
||||
@@ -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
|
||||
@@ -69,34 +68,56 @@ func (p *PurchaseHandler) CreateCategory(db *dao.DaoDB, cat *model.SkuCategory,
|
||||
return err
|
||||
}
|
||||
|
||||
func (p *PurchaseHandler) ReadCategories() (cats []*model.SkuCategory, err error) {
|
||||
result, err := api.JdAPI.QueryCategoriesByOrgCode()
|
||||
if err == nil {
|
||||
cats = make([]*model.SkuCategory, len(result))
|
||||
for k, v := range result {
|
||||
cats[k] = &model.SkuCategory{
|
||||
ParentID: int(v.ParentId), // 这里是暂存,传递数据用,正确的值应该是本地的ID
|
||||
Name: v.Name,
|
||||
Level: int8(v.Level),
|
||||
Seq: v.Sort,
|
||||
JdID: v.Id,
|
||||
}
|
||||
}
|
||||
return cats, nil
|
||||
func jdCat2Jx(jdCat *jdapi.CategoryInfo) (jxCat *partner.BareCategoryInfo) {
|
||||
return &partner.BareCategoryInfo{
|
||||
VendorCatID: utils.Int64ToStr(jdCat.Id),
|
||||
Level: jdCat.Level,
|
||||
Name: jdCat.Name,
|
||||
Seq: jdCat.Sort,
|
||||
}
|
||||
return nil, err
|
||||
}
|
||||
|
||||
func (p *PurchaseHandler) GetAllCategories(ctx *jxcontext.Context, vendorOrgCode string) (cats []*partner.BareCategoryInfo, err error) {
|
||||
result, err := getAPI(vendorOrgCode).QueryCategoriesByOrgCode()
|
||||
if err == nil {
|
||||
catMap := make(map[int64]*partner.BareCategoryInfo)
|
||||
level := 1
|
||||
for {
|
||||
processedCount := 0
|
||||
for _, jdCat := range result {
|
||||
if jdCat.Level == level {
|
||||
processedCount++
|
||||
jxCat := jdCat2Jx(jdCat)
|
||||
if level == 1 {
|
||||
cats = append(cats, jxCat)
|
||||
} else {
|
||||
parentCat := catMap[jdCat.ParentId]
|
||||
if parentCat != nil {
|
||||
parentCat.Children = append(parentCat.Children, jxCat)
|
||||
}
|
||||
}
|
||||
catMap[jdCat.Id] = jxCat
|
||||
}
|
||||
}
|
||||
if processedCount == 0 {
|
||||
break
|
||||
}
|
||||
level++
|
||||
}
|
||||
}
|
||||
return cats, err
|
||||
}
|
||||
|
||||
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 +143,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 +213,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 +230,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 +309,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 +333,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 +378,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 +418,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 +438,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 +460,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 +481,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 +495,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 +508,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 +564,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 +610,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 +637,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 +661,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},
|
||||
|
||||
@@ -37,12 +37,12 @@ func TestUpdateSku(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
func TestReadCategories(t *testing.T) {
|
||||
result, err := curPurchaseHandler.ReadCategories()
|
||||
func TestGetAllCategories(t *testing.T) {
|
||||
result, err := curPurchaseHandler.GetAllCategories(jxcontext.AdminCtx, "")
|
||||
if err != nil || len(result) == 0 {
|
||||
t.Fatal(err.Error())
|
||||
}
|
||||
t.Log(result[0])
|
||||
t.Log(utils.Format4Output(result, false))
|
||||
}
|
||||
|
||||
func TestReadSku(t *testing.T) {
|
||||
|
||||
@@ -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
|
||||
}
|
||||
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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}
|
||||
}
|
||||
|
||||
@@ -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) +
|
||||
|
||||
@@ -195,6 +195,9 @@ func (c *AuthController) MiniBindWeiXin() {
|
||||
func (c *AuthController) BindMiniProgram() {
|
||||
c.callBindMiniProgram(func(params *tAuthBindMiniProgramParams) (retVal interface{}, errCode string, err error) {
|
||||
err = weixin.AutherMini.BindMiniProgram(params.Ctx, GetComposedCode(&c.Controller, params.Code))
|
||||
if err == nil {
|
||||
cms.TransferLegacyWeixins(params.Ctx.GetLoginID())
|
||||
}
|
||||
if err == auth.ErrUserNotExist {
|
||||
return retVal, model.ErrCodeUserNotExist, err
|
||||
}
|
||||
|
||||
@@ -265,7 +265,8 @@ func (c *StoreSkuController) CopyStoreSkus() {
|
||||
// @Param storeIDs formData string true "门店ID列表"
|
||||
// @Param payload formData string true "json数据,StoreSkuBindSkuInfo对象数组"
|
||||
// @Param isContinueWhenError formData bool false "单个同步失败是否继续,缺省false"
|
||||
// @Param autoSaleAt formData string false "自动可售时间"
|
||||
// @Param autoSaleAt formData string false "临时不可售到期时间"
|
||||
// @Param ignoreDontSale formData bool false "在临时不可售时,是否忽略当前是不可售的商品"
|
||||
// @Param isAsync formData bool false "是否异步操作"
|
||||
// @Success 200 {object} controllers.CallResult
|
||||
// @Failure 200 {object} controllers.CallResult
|
||||
@@ -281,7 +282,7 @@ func (c *StoreSkuController) UpdateStoresSkusSale() {
|
||||
if err != nil {
|
||||
return retVal, "", err
|
||||
}
|
||||
retVal, err = cms.UpdateStoresSkusSale(params.Ctx, storeIDs, skuBindSkuInfos, timeList[0], params.Ctx.GetUserName(), params.IsAsync, params.IsContinueWhenError)
|
||||
retVal, err = cms.UpdateStoresSkusSale(params.Ctx, storeIDs, skuBindSkuInfos, timeList[0], params.IgnoreDontSale, params.Ctx.GetUserName(), params.IsAsync, params.IsContinueWhenError)
|
||||
return retVal, "", err
|
||||
})
|
||||
}
|
||||
|
||||
@@ -3,6 +3,8 @@ package controllers
|
||||
import (
|
||||
"fmt"
|
||||
|
||||
"git.rosy.net.cn/jx-callback/business/jxutils"
|
||||
|
||||
"git.rosy.net.cn/jx-callback/business/jxutils/tasksch"
|
||||
"github.com/astaxie/beego"
|
||||
)
|
||||
@@ -54,3 +56,20 @@ func (c *TaskController) CancelTask() {
|
||||
return retVal, "", err
|
||||
})
|
||||
}
|
||||
|
||||
// @Title 取消管理任务
|
||||
// @Description 取消管理任务
|
||||
// @Param token header string true "认证token"
|
||||
// @Param taskIDs query string false "任务ID列表"
|
||||
// @Success 200 {object} controllers.CallResult
|
||||
// @Failure 200 {object} controllers.CallResult
|
||||
// @router /UnmanageTasks [put]
|
||||
func (c *TaskController) UnmanageTasks() {
|
||||
c.callUnmanageTasks(func(params *tTaskUnmanageTasksParams) (retVal interface{}, errCode string, err error) {
|
||||
var taskIDs []string
|
||||
if err = jxutils.Strings2Objs(params.TaskIDs, &taskIDs); err == nil {
|
||||
tasksch.UnmanageTasks(taskIDs)
|
||||
}
|
||||
return retVal, "", err
|
||||
})
|
||||
}
|
||||
|
||||
@@ -33,6 +33,7 @@ func (c *User2Controller) RegisterUser() {
|
||||
}
|
||||
if err == nil {
|
||||
if err = jxutils.Strings2Objs(params.Payload, &user); err == nil {
|
||||
user.Type = 0
|
||||
retVal, err = cms.RegisterUser(&user, params.MobileVerifyCode, inAuthInfo)
|
||||
}
|
||||
}
|
||||
@@ -84,8 +85,8 @@ func (c *User2Controller) GetUsers() {
|
||||
// @router /GetMyStoreList [get]
|
||||
func (c *User2Controller) GetMyStoreList() {
|
||||
c.callGetMyStoreList(func(params *tUser2GetMyStoreListParams) (retVal interface{}, errCode string, err error) {
|
||||
retVal, err = cms.GetMyStoreListNew(params.Ctx)
|
||||
return retVal, "", err
|
||||
retVal, errCode, err = cms.GetMyStoreListNew(params.Ctx)
|
||||
return retVal, errCode, err
|
||||
})
|
||||
}
|
||||
|
||||
|
||||
@@ -22,18 +22,12 @@ import (
|
||||
"git.rosy.net.cn/baseapi/platformapi/zhongwuapi"
|
||||
"git.rosy.net.cn/jx-callback/business/jxutils/cache"
|
||||
"git.rosy.net.cn/jx-callback/business/jxutils/cache/redis"
|
||||
"git.rosy.net.cn/jx-callback/business/model"
|
||||
|
||||
"github.com/astaxie/beego"
|
||||
"github.com/qiniu/api.v7/auth/qbox"
|
||||
)
|
||||
|
||||
type APIManager struct {
|
||||
}
|
||||
|
||||
var (
|
||||
curAPIManager *APIManager
|
||||
|
||||
JdAPI *jdapi.API
|
||||
JdPageAPI *jdapi.API
|
||||
ElmAPI *elmapi.API
|
||||
@@ -65,22 +59,12 @@ var (
|
||||
Cacher cache.ICacher
|
||||
)
|
||||
|
||||
func (a *APIManager) GetAPI(vendorID int, name string) (pfAPI interface{}) {
|
||||
if vendorID == model.VendorIDJD {
|
||||
pfAPI = JdAPI
|
||||
}
|
||||
return pfAPI
|
||||
}
|
||||
|
||||
func init() {
|
||||
Init() // 这里必须要调用
|
||||
}
|
||||
|
||||
// 这样写的原因是在测试时,可以重新读取配置文件
|
||||
func Init() {
|
||||
curAPIManager = &APIManager{}
|
||||
// partner.InitAPIManager(curAPIManager)
|
||||
|
||||
if !beego.AppConfig.DefaultBool("disableJd", false) {
|
||||
JdAPI = jdapi.New(beego.AppConfig.String("jdToken"), beego.AppConfig.String("jdAppKey"), beego.AppConfig.String("jdSecret"))
|
||||
cookieValue := beego.AppConfig.DefaultString("jdStorePageCookie", "")
|
||||
|
||||
33
globals/api/apimanager/apimanager.go
Normal file
33
globals/api/apimanager/apimanager.go
Normal file
@@ -0,0 +1,33 @@
|
||||
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"
|
||||
)
|
||||
|
||||
type APIManager struct {
|
||||
}
|
||||
|
||||
var (
|
||||
curAPIManager *APIManager
|
||||
)
|
||||
|
||||
func init() {
|
||||
globals.SugarLogger.Debug("init apimanager")
|
||||
curAPIManager = &APIManager{}
|
||||
partner.InitAPIManager(curAPIManager)
|
||||
}
|
||||
|
||||
func (a *APIManager) GetAPI(vendorID int, name string) (pfAPI interface{}) {
|
||||
switch vendorID {
|
||||
case model.VendorIDJD:
|
||||
pfAPI = api.JdAPI
|
||||
case model.VendorIDMTWM:
|
||||
pfAPI = api.MtwmAPI
|
||||
case model.VendorIDEBAI:
|
||||
pfAPI = api.EbaiAPI
|
||||
}
|
||||
return pfAPI
|
||||
}
|
||||
14
main.go
14
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 (
|
||||
|
||||
@@ -1609,6 +1609,15 @@ func init() {
|
||||
Filters: nil,
|
||||
Params: nil})
|
||||
|
||||
beego.GlobalControllerRouter["git.rosy.net.cn/jx-callback/controllers:TaskController"] = append(beego.GlobalControllerRouter["git.rosy.net.cn/jx-callback/controllers:TaskController"],
|
||||
beego.ControllerComments{
|
||||
Method: "UnmanageTasks",
|
||||
Router: `/UnmanageTasks`,
|
||||
AllowHTTPMethods: []string{"put"},
|
||||
MethodParams: param.Make(),
|
||||
Filters: nil,
|
||||
Params: nil})
|
||||
|
||||
beego.GlobalControllerRouter["git.rosy.net.cn/jx-callback/controllers:TempOpController"] = append(beego.GlobalControllerRouter["git.rosy.net.cn/jx-callback/controllers:TempOpController"],
|
||||
beego.ControllerComments{
|
||||
Method: "CheckSkuDiffBetweenJxAndVendor",
|
||||
|
||||
Reference in New Issue
Block a user