Merge remote-tracking branch 'origin/mark' into don
This commit is contained in:
@@ -240,7 +240,6 @@ func Login(authType, authID, authIDType, authSecret string) (authInfo *AuthInfo,
|
|||||||
}
|
}
|
||||||
if authBindEx, err = handler.VerifySecret(realAuthID, authSecret); err == nil {
|
if authBindEx, err = handler.VerifySecret(realAuthID, authSecret); err == nil {
|
||||||
// globals.SugarLogger.Debugf("auth2 Login authBindEx:%s", utils.Format4Output(authBindEx, false))
|
// globals.SugarLogger.Debugf("auth2 Login authBindEx:%s", utils.Format4Output(authBindEx, false))
|
||||||
needAutoAddAuthBind := false
|
|
||||||
if authBindEx == nil { // mobile, email会返回nil(表示不会新建AuthBind实体)
|
if authBindEx == nil { // mobile, email会返回nil(表示不会新建AuthBind实体)
|
||||||
user = userProvider.GetUser(authID, authIDType)
|
user = userProvider.GetUser(authID, authIDType)
|
||||||
authBindEx = &AuthBindEx{
|
authBindEx = &AuthBindEx{
|
||||||
@@ -261,19 +260,12 @@ func Login(authType, authID, authIDType, authSecret string) (authInfo *AuthInfo,
|
|||||||
}
|
}
|
||||||
if user != nil {
|
if user != nil {
|
||||||
authBindEx.UserID = user.GetID()
|
authBindEx.UserID = user.GetID()
|
||||||
needAutoAddAuthBind = true
|
|
||||||
}
|
}
|
||||||
} else if authBindEx.UserID != "" {
|
} else if authBindEx.UserID != "" {
|
||||||
user = userProvider.GetUser(authBindEx.UserID, UserIDID)
|
user = userProvider.GetUser(authBindEx.UserID, UserIDID)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
authInfo = createAuthInfo(user, authBindEx)
|
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 {
|
} else {
|
||||||
err = ErrIllegalAuthType
|
err = ErrIllegalAuthType
|
||||||
@@ -316,6 +308,7 @@ func AddAuthBind(user IUser, newAuthInfo *AuthInfo) (err error) {
|
|||||||
err = userProvider.UpdateUserEmail(user.GetID(), newAuthInfo.AuthBindInfo.AuthID)
|
err = userProvider.UpdateUserEmail(user.GetID(), newAuthInfo.AuthBindInfo.AuthID)
|
||||||
} else {
|
} else {
|
||||||
newAuthInfo.AuthBindInfo.UserID = user.GetID()
|
newAuthInfo.AuthBindInfo.UserID = user.GetID()
|
||||||
|
authers[newAuthInfo.AuthBindInfo.Type].UnbindAuth(user.GetID(), newAuthInfo.GetAuthType(), user.GetName())
|
||||||
err = authers[newAuthInfo.AuthBindInfo.Type].AddAuthBind(newAuthInfo.AuthBindInfo, user.GetName())
|
err = authers[newAuthInfo.AuthBindInfo.Type].AddAuthBind(newAuthInfo.AuthBindInfo, user.GetName())
|
||||||
}
|
}
|
||||||
return err
|
return err
|
||||||
|
|||||||
@@ -277,6 +277,13 @@ func (c *OrderManager) updateOrderSkuOtherInfo(order *model.GoodsOrder, db *dao.
|
|||||||
LEFT JOIN store_sku_bind t2 ON t1.id = t2.sku_id AND t2.deleted_at = ? AND t2.store_id = ?
|
LEFT JOIN store_sku_bind t2 ON t1.id = t2.sku_id AND t2.deleted_at = ? AND t2.store_id = ?
|
||||||
WHERE t1.deleted_at = ? AND %s.%s_id IN (-1, ` + dao.GenQuestionMarks(len(vendorSkuIDs)) + ")"
|
WHERE t1.deleted_at = ? AND %s.%s_id IN (-1, ` + dao.GenQuestionMarks(len(vendorSkuIDs)) + ")"
|
||||||
sql = fmt.Sprintf(sql, tableName, fieldPrefix, tableName, fieldPrefix)
|
sql = fmt.Sprintf(sql, tableName, fieldPrefix, tableName, fieldPrefix)
|
||||||
|
if order.VendorID == model.VendorIDJX {
|
||||||
|
sql = `
|
||||||
|
SELECT t1.id vendor_sku_id, t1.id sku_id, t2.price, t1.weight
|
||||||
|
FROM sku t1
|
||||||
|
LEFT JOIN store_sku_bind t2 ON t1.id = t2.sku_id AND t2.deleted_at = ? AND t2.store_id = ?
|
||||||
|
WHERE t1.deleted_at = ? AND t1.id IN (-1, ` + dao.GenQuestionMarks(len(vendorSkuIDs)) + ")"
|
||||||
|
}
|
||||||
var skuInfos []*tStoreSkuBindAndVendorSkuID
|
var skuInfos []*tStoreSkuBindAndVendorSkuID
|
||||||
if err = dao.GetRows(db, &skuInfos, sql, utils.DefaultTimeValue, jxStoreID, utils.DefaultTimeValue, vendorSkuIDs); err != nil {
|
if err = dao.GetRows(db, &skuInfos, sql, utils.DefaultTimeValue, jxStoreID, utils.DefaultTimeValue, vendorSkuIDs); err != nil {
|
||||||
globals.SugarLogger.Errorf("updateOrderSkuOtherInfo can not get sku info for orderID:%s, error:%v", order.VendorOrderID, err)
|
globals.SugarLogger.Errorf("updateOrderSkuOtherInfo can not get sku info for orderID:%s, error:%v", order.VendorOrderID, err)
|
||||||
@@ -290,12 +297,6 @@ func (c *OrderManager) updateOrderSkuOtherInfo(order *model.GoodsOrder, db *dao.
|
|||||||
// var skuPriceMap map[int64]*dao.PromotionStoreSku
|
// var skuPriceMap map[int64]*dao.PromotionStoreSku
|
||||||
var actStoreSkuMap *jxutils.ActStoreSkuMap
|
var actStoreSkuMap *jxutils.ActStoreSkuMap
|
||||||
if len(skuIDMap) > 0 {
|
if len(skuIDMap) > 0 {
|
||||||
// skuPriceMap, err = dao.GetPromotionSkuPriceMap(db, model.VendorIDJX, []int{jxStoreID}, jxutils.IntMap2List(skuIDMap), order.OrderCreatedAt, order.OrderCreatedAt)
|
|
||||||
// if err != nil {
|
|
||||||
// globals.SugarLogger.Errorf("updateOrderSkuOtherInfo can not get sku promotion info for orderID:%s, error:%v", order.VendorOrderID, err)
|
|
||||||
// return err
|
|
||||||
// }
|
|
||||||
|
|
||||||
actStoreSkuList, err := dao.GetEffectiveActStoreSkuInfo(db, 0, []int{order.VendorID}, []int{jxStoreID}, jxutils.IntMap2List(skuIDMap), order.OrderCreatedAt, order.OrderCreatedAt)
|
actStoreSkuList, err := dao.GetEffectiveActStoreSkuInfo(db, 0, []int{order.VendorID}, []int{jxStoreID}, jxutils.IntMap2List(skuIDMap), order.OrderCreatedAt, order.OrderCreatedAt)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
globals.SugarLogger.Errorf("updateOrderSkuOtherInfo can not get sku promotion info for error:%v", err)
|
globals.SugarLogger.Errorf("updateOrderSkuOtherInfo can not get sku promotion info for error:%v", err)
|
||||||
|
|||||||
@@ -16,7 +16,7 @@ import (
|
|||||||
|
|
||||||
func TransferLegacyWeixins(mobile string) (err error) {
|
func TransferLegacyWeixins(mobile string) (err error) {
|
||||||
globals.SugarLogger.Debugf("TransferLegacyWeixins mobile:%s", mobile)
|
globals.SugarLogger.Debugf("TransferLegacyWeixins mobile:%s", mobile)
|
||||||
if !globals.EnableWXAuth2 {
|
if !globals.EnableWXAuth2 || globals.DisableWXAuth1 {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
remark4Transfer := "transfer"
|
remark4Transfer := "transfer"
|
||||||
|
|||||||
@@ -1436,6 +1436,7 @@ func GetStoresVendorSnapshot(ctx *jxcontext.Context, parentTask tasksch.ITask, v
|
|||||||
CloseTime2: store.CloseTime2,
|
CloseTime2: store.CloseTime2,
|
||||||
|
|
||||||
DeliveryType: store.DeliveryType,
|
DeliveryType: store.DeliveryType,
|
||||||
|
StoreName: store.OriginalName,
|
||||||
}}
|
}}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1445,7 +1446,6 @@ func GetStoresVendorSnapshot(ctx *jxcontext.Context, parentTask tasksch.ITask, v
|
|||||||
tasksch.HandleTask(task, parentTask, true).Run()
|
tasksch.HandleTask(task, parentTask, true).Run()
|
||||||
resultList, err := task.GetResult(0)
|
resultList, err := task.GetResult(0)
|
||||||
if len(resultList) > 0 {
|
if len(resultList) > 0 {
|
||||||
err = nil // 强制忽略
|
|
||||||
for _, v := range resultList {
|
for _, v := range resultList {
|
||||||
dao.WrapAddIDCULDEntity(v, ctx.GetUserName())
|
dao.WrapAddIDCULDEntity(v, ctx.GetUserName())
|
||||||
vendorStoreSnapshotList = append(vendorStoreSnapshotList, v.(*model.VendorStoreSnapshot))
|
vendorStoreSnapshotList = append(vendorStoreSnapshotList, v.(*model.VendorStoreSnapshot))
|
||||||
@@ -1478,11 +1478,11 @@ func updateVendorStoreStatusBySnapshot(db *dao.DaoDB, curSnapshotList []*model.V
|
|||||||
}()
|
}()
|
||||||
for _, v := range storeMapList {
|
for _, v := range storeMapList {
|
||||||
if snapshot := snapshotMap[jxutils.Combine2Int(v.StoreID, v.VendorID)]; snapshot != nil &&
|
if snapshot := snapshotMap[jxutils.Combine2Int(v.StoreID, v.VendorID)]; snapshot != nil &&
|
||||||
(v.Status != snapshot.Status || v.DeliveryType != snapshot.DeliveryType) {
|
(v.Status != snapshot.Status || v.DeliveryType != snapshot.DeliveryType || v.StoreName != snapshot.StoreName) {
|
||||||
v.Status = snapshot.Status
|
v.Status = snapshot.Status
|
||||||
v.DeliveryType = snapshot.DeliveryType
|
v.DeliveryType = snapshot.DeliveryType
|
||||||
v.LastOperator = model.AdminName
|
v.StoreName = snapshot.StoreName
|
||||||
if _, err = dao.UpdateEntity(db, v, model.FieldLastOperator, model.FieldUpdatedAt, model.FieldStatus, "DeliveryType"); err != nil {
|
if _, err = dao.UpdateEntity(db, v, model.FieldStatus, "DeliveryType", "StoreName"); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1740,8 +1740,9 @@ func SaveAndSendAlarmVendorSnapshot(ctx *jxcontext.Context, vendorIDs, storeIDs
|
|||||||
prevSnapshotAt := getCurrentSnapshotAt(curSnapshotAt.Add(-1 * time.Second))
|
prevSnapshotAt := getCurrentSnapshotAt(curSnapshotAt.Add(-1 * time.Second))
|
||||||
db := dao.GetDB()
|
db := dao.GetDB()
|
||||||
var curSnapshotList, prevSnapshotList []*model.VendorStoreSnapshot
|
var curSnapshotList, prevSnapshotList []*model.VendorStoreSnapshot
|
||||||
task := tasksch.NewSeqTask("SaveAndSendAlarmVendorSnapshot", ctx,
|
task := tasksch.NewParallelTask("SaveAndSendAlarmVendorSnapshot", tasksch.NewParallelConfig().SetIsContinueWhenError(true).SetParallelCount(1), ctx,
|
||||||
func(task *tasksch.SeqTask, step int, params ...interface{}) (result interface{}, err error) {
|
func(task *tasksch.ParallelTask, batchItemList []interface{}, params ...interface{}) (retVal interface{}, err error) {
|
||||||
|
step := batchItemList[0].(int)
|
||||||
switch step {
|
switch step {
|
||||||
case 0:
|
case 0:
|
||||||
curSnapshotList, err = GetStoresVendorSnapshot(ctx, task, vendorIDs, storeIDs)
|
curSnapshotList, err = GetStoresVendorSnapshot(ctx, task, vendorIDs, storeIDs)
|
||||||
@@ -1758,7 +1759,7 @@ func SaveAndSendAlarmVendorSnapshot(ctx *jxcontext.Context, vendorIDs, storeIDs
|
|||||||
err = SendAlarmVendorSnapshot(ctx, task, prevSnapshotList, curSnapshotList)
|
err = SendAlarmVendorSnapshot(ctx, task, prevSnapshotList, curSnapshotList)
|
||||||
}
|
}
|
||||||
return nil, err
|
return nil, err
|
||||||
}, 4)
|
}, []int{0, 1, 2, 3})
|
||||||
tasksch.ManageTask(task).Run()
|
tasksch.ManageTask(task).Run()
|
||||||
if !isAsync {
|
if !isAsync {
|
||||||
_, err = task.GetResult(0)
|
_, err = task.GetResult(0)
|
||||||
|
|||||||
@@ -464,41 +464,6 @@ func GetStoreAndSkuIDsFromInfo(skuNamesInfo *StoreSkuNamesInfo) (storeIDs, skuID
|
|||||||
return jxutils.IntMap2List(storeIDMap), jxutils.IntMap2List(skuIDMap)
|
return jxutils.IntMap2List(storeIDMap), jxutils.IntMap2List(skuIDMap)
|
||||||
}
|
}
|
||||||
|
|
||||||
// func updateActPrice4StoreSkuName(db *dao.DaoDB, storeIDs, skuIDs []int, skuNamesInfo *StoreSkuNamesInfo) (err error) {
|
|
||||||
// // 活动商品信息
|
|
||||||
// jxSkuPriceMap, err := dao.GetPromotionSkuPriceMap(db, model.VendorIDJX, storeIDs, skuIDs, time.Now(), time.Now())
|
|
||||||
// if err != nil {
|
|
||||||
// globals.SugarLogger.Errorf("updateActPrice4StoreSkuName can not get sku promotion info for error:%v", err)
|
|
||||||
// return err
|
|
||||||
// }
|
|
||||||
// jdSkuPriceMap, err2 := dao.GetPromotionSkuPriceMap(db, model.VendorIDJD, storeIDs, skuIDs, time.Now(), time.Now())
|
|
||||||
// if err = err2; err != nil {
|
|
||||||
// globals.SugarLogger.Errorf("updateActPrice4StoreSkuName can not get sku promotion info for error:%v", err)
|
|
||||||
// return err
|
|
||||||
// }
|
|
||||||
// for _, skuName := range skuNamesInfo.SkuNames {
|
|
||||||
// if len(skuName.Skus2) > 0 {
|
|
||||||
// for _, v := range skuName.Skus2 {
|
|
||||||
// index := dao.GenSkuPriceMapKey(skuName.StoreID, v.SkuID)
|
|
||||||
// if jdSkuPriceMap[index] != nil {
|
|
||||||
// v.ActPrice = jdSkuPriceMap[index].Price
|
|
||||||
// }
|
|
||||||
// if jxSkuPriceMap[index] != nil {
|
|
||||||
// v.EarningPrice = jxSkuPriceMap[index].EarningPrice
|
|
||||||
// }
|
|
||||||
|
|
||||||
// v.RealEarningPrice = v.EarningPrice
|
|
||||||
// if v.RealEarningPrice == 0 {
|
|
||||||
// v.RealEarningPrice = int(jxutils.CaculateSkuEarningPrice(int64(v.BindPrice), int64(v.BindPrice), skuName.PayPercentage))
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
// } else {
|
|
||||||
// skuName.UnitPrice = skuName.Price
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
// return err
|
|
||||||
// }
|
|
||||||
|
|
||||||
// 根据已经部分关注的商品,得到已经存在的门店商品单价
|
// 根据已经部分关注的商品,得到已经存在的门店商品单价
|
||||||
func updateUnitPrice4StoreSkuNameNew(db *dao.DaoDB, skuNamesInfo *StoreSkuNamesInfo) (err error) {
|
func updateUnitPrice4StoreSkuNameNew(db *dao.DaoDB, skuNamesInfo *StoreSkuNamesInfo) (err error) {
|
||||||
storeIDMap := make(map[int]int)
|
storeIDMap := make(map[int]int)
|
||||||
@@ -523,11 +488,6 @@ func updateUnitPrice4StoreSkuNameNew(db *dao.DaoDB, skuNamesInfo *StoreSkuNamesI
|
|||||||
}
|
}
|
||||||
|
|
||||||
func updateActPrice4StoreSkuNameNew(db *dao.DaoDB, storeIDs, skuIDs []int, skuNamesInfo *StoreSkuNamesInfo) (err error) {
|
func updateActPrice4StoreSkuNameNew(db *dao.DaoDB, storeIDs, skuIDs []int, skuNamesInfo *StoreSkuNamesInfo) (err error) {
|
||||||
// jxSkuPriceMap, err := dao.GetPromotionSkuPriceMap(db, model.VendorIDJX, storeIDs, skuIDs, time.Now(), time.Now())
|
|
||||||
// if err != nil {
|
|
||||||
// globals.SugarLogger.Errorf("updateActPrice4StoreSkuNameNew can not get sku promotion info for error:%v", err)
|
|
||||||
// return err
|
|
||||||
// }
|
|
||||||
if len(skuIDs) == 0 {
|
if len(skuIDs) == 0 {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
@@ -621,233 +581,6 @@ func updateSaleInfo4StoreSkuName(ctx *jxcontext.Context, db *dao.DaoDB, storeIDs
|
|||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
// 商品不可售,直接排除
|
|
||||||
// 如果门店商品是可售状态,那么会忽略区域限制。否则有区域限制
|
|
||||||
// func GetStoresSkusOld(ctx *jxcontext.Context, storeIDs, skuIDs []int, isFocus bool, keyword string, isBySku bool, params map[string]interface{}, offset, pageSize int) (skuNamesInfo *StoreSkuNamesInfo, err error) {
|
|
||||||
// db := dao.GetDB()
|
|
||||||
// sql, sqlParams, err := getGetStoresSkusBaseSQL(db, storeIDs, skuIDs, isFocus, keyword, isBySku, params)
|
|
||||||
// if err != nil {
|
|
||||||
// return nil, err
|
|
||||||
// }
|
|
||||||
// sql += `
|
|
||||||
// GROUP BY
|
|
||||||
// t1.id,
|
|
||||||
// t1.created_at,
|
|
||||||
// t1.updated_at,
|
|
||||||
// t1.last_operator,
|
|
||||||
// t1.deleted_at,
|
|
||||||
// t1.prefix,
|
|
||||||
// t1.name,
|
|
||||||
// t1.brand_id,
|
|
||||||
// t1.category_id,
|
|
||||||
// t1.is_global,
|
|
||||||
// t1.unit,
|
|
||||||
// t1.price,
|
|
||||||
// t1.img,
|
|
||||||
// t1.elm_img_hash_code,
|
|
||||||
// t3.id,
|
|
||||||
// t3.name,
|
|
||||||
// t3.pay_percentage`
|
|
||||||
// if isBySku {
|
|
||||||
// sql += `,
|
|
||||||
// t2.id`
|
|
||||||
// }
|
|
||||||
// sqlData := `
|
|
||||||
// SELECT
|
|
||||||
// SQL_CALC_FOUND_ROWS
|
|
||||||
// t1.id,
|
|
||||||
// t1.created_at,
|
|
||||||
// t1.updated_at,
|
|
||||||
// t1.last_operator,
|
|
||||||
// t1.deleted_at,
|
|
||||||
// t1.prefix,
|
|
||||||
// t1.name,
|
|
||||||
// t1.brand_id,
|
|
||||||
// t1.category_id,
|
|
||||||
// t1.is_global,
|
|
||||||
// t1.unit,
|
|
||||||
// t1.price,
|
|
||||||
// t1.img,
|
|
||||||
// t1.elm_img_hash_code,
|
|
||||||
// t3.id store_id,
|
|
||||||
// t3.name store_name,
|
|
||||||
// t3.pay_percentage,
|
|
||||||
// CONCAT("[", GROUP_CONCAT(DISTINCT CONCAT('{"id":', t2.id, ',"comment":"', t2.comment, '","status":', t2.status, ',"createdAt":"',
|
|
||||||
// CONCAT(REPLACE(IF(t4.created_at IS NULL, '1970-01-01 00:00:00', t4.created_at)," ","T"),"+08:00"), '","updatedAt":"', CONCAT(REPLACE(IF(t4.updated_at IS NULL, '1970-01-01 00:00:00', t4.updated_at)," ","T"),"+08:00"),
|
|
||||||
// '","lastOperator":"', IF(t4.last_operator IS NULL, '', t4.last_operator), '","specQuality":', t2.spec_quality, ',"specUnit":"', t2.spec_unit, '","weight":', t2.weight,
|
|
||||||
// ',"categoryID":', t2.category_id, ',"nameID":', t2.name_id, ',"subStoreID":', IF(t4.sub_store_id IS NULL, 0, t4.sub_store_id),
|
|
||||||
// ',"price":', IF(t4.price IS NULL, 0, t4.price), ',"unitPrice":', IF(t4.unit_price IS NULL, t1.price, t4.unit_price),
|
|
||||||
// ',"storeSkuStatus":', IF(t4.status IS NULL, 0, t4.status),
|
|
||||||
// ',"jdID":', t2.jd_id, ',"jdSyncStatus":', IF(t4.jd_sync_status IS NULL, 0, t4.jd_sync_status),
|
|
||||||
// ',"ebaiID":', IF(t4.ebai_id IS NULL, 0, t4.ebai_id), ',"ebaiSyncStatus":', IF(t4.ebai_sync_status IS NULL, 0, t4.ebai_sync_status),
|
|
||||||
// ',"mtwmID":', IF(t4.mtwm_id IS NULL, 0, t4.mtwm_id), ',"mtwmSyncStatus":', IF(t4.mtwm_sync_status IS NULL, 0, t4.mtwm_sync_status),
|
|
||||||
// ',"wscID":', IF(t4.wsc_id IS NULL, 0, t4.wsc_id), ',"wscSyncStatus":', IF(t4.wsc_sync_status IS NULL, 0, t4.wsc_sync_status),
|
|
||||||
// "}")), "]") skus_str
|
|
||||||
// ` + sql + `
|
|
||||||
// ORDER BY t1.id DESC
|
|
||||||
// LIMIT ? OFFSET ?`
|
|
||||||
// pageSize = jxutils.FormalizePageSize(pageSize)
|
|
||||||
// sqlOffset := offset
|
|
||||||
// sqlPageSize := pageSize
|
|
||||||
// isSaleInfo := params["stFromTime"] != nil
|
|
||||||
// if isSaleInfo {
|
|
||||||
// sqlOffset = 0
|
|
||||||
// sqlPageSize = jxutils.FormalizePageSize(-1)
|
|
||||||
// }
|
|
||||||
// sqlParams = append(sqlParams, sqlPageSize, sqlOffset)
|
|
||||||
// skuNamesInfo = &StoreSkuNamesInfo{}
|
|
||||||
// // globals.SugarLogger.Debug(sqlData)
|
|
||||||
// dao.Begin(db)
|
|
||||||
// defer func() {
|
|
||||||
// if r := recover(); r != nil {
|
|
||||||
// dao.Rollback(db)
|
|
||||||
// panic(r)
|
|
||||||
// }
|
|
||||||
// }()
|
|
||||||
// // globals.SugarLogger.Debug(sqlData, sqlParams)
|
|
||||||
// if err = dao.GetRows(db, &skuNamesInfo.SkuNames, sqlData, sqlParams...); err == nil {
|
|
||||||
// skuNamesInfo.TotalCount = dao.GetLastTotalRowCount(db)
|
|
||||||
// dao.Commit(db)
|
|
||||||
|
|
||||||
// // 活动商品信息
|
|
||||||
// jxSkuPriceMap, err2 := dao.GetPromotionSkuPriceMap(db, model.VendorIDJX, storeIDs, skuIDs, time.Now(), time.Now())
|
|
||||||
// if err = err2; err != nil {
|
|
||||||
// globals.SugarLogger.Errorf("GetStoresSkus can not get sku promotion info for error:%v", err)
|
|
||||||
// return nil, err
|
|
||||||
// }
|
|
||||||
// jdSkuPriceMap, err2 := dao.GetPromotionSkuPriceMap(db, model.VendorIDJD, storeIDs, skuIDs, time.Now(), time.Now())
|
|
||||||
// if err = err2; err != nil {
|
|
||||||
// globals.SugarLogger.Errorf("GetStoresSkus can not get sku promotion info for error:%v", err)
|
|
||||||
// return nil, err
|
|
||||||
// }
|
|
||||||
// for _, skuName := range skuNamesInfo.SkuNames {
|
|
||||||
// if skuName.SkusStr != "" {
|
|
||||||
// if err = utils.UnmarshalUseNumber([]byte(skuName.SkusStr), &skuName.Skus); err != nil {
|
|
||||||
// return nil, err
|
|
||||||
// }
|
|
||||||
// if len(skuName.Skus) > 0 {
|
|
||||||
// skuName.UnitPrice = int(utils.MustInterface2Int64(skuName.Skus[0]["unitPrice"]))
|
|
||||||
// for _, v := range skuName.Skus {
|
|
||||||
// index := dao.GenSkuPriceMapKey(skuName.StoreID, int(utils.MustInterface2Int64(v["id"])))
|
|
||||||
// if jdSkuPriceMap[index] != nil {
|
|
||||||
// v["actPrice"] = jdSkuPriceMap[index].Price
|
|
||||||
// } else {
|
|
||||||
// v["actPrice"] = 0
|
|
||||||
// }
|
|
||||||
|
|
||||||
// earningPrice := 0
|
|
||||||
// if jxSkuPriceMap[index] != nil {
|
|
||||||
// earningPrice = jxSkuPriceMap[index].EarningPrice
|
|
||||||
// }
|
|
||||||
// v["earningPrice"] = earningPrice
|
|
||||||
|
|
||||||
// realEarningPrice := earningPrice
|
|
||||||
// if realEarningPrice == 0 {
|
|
||||||
// shopPrice := utils.Interface2Int64WithDefault(v["price"], 0)
|
|
||||||
// realEarningPrice = int(jxutils.CaculateSkuEarningPrice(shopPrice, shopPrice, skuName.PayPercentage))
|
|
||||||
// }
|
|
||||||
// v["realEarningPrice"] = realEarningPrice
|
|
||||||
|
|
||||||
// delete(v, "unitPrice")
|
|
||||||
// }
|
|
||||||
// } else {
|
|
||||||
// skuName.UnitPrice = skuName.Price
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
// if isSaleInfo {
|
|
||||||
// var (
|
|
||||||
// saleInfoList []*SkuSaleInfo
|
|
||||||
// skuIDs []int
|
|
||||||
// timeList []time.Time
|
|
||||||
// fromCount, toCount int
|
|
||||||
// )
|
|
||||||
// saleInfoMap := make(map[int64]*SkuSaleInfo)
|
|
||||||
// for _, skuName := range skuNamesInfo.SkuNames {
|
|
||||||
// for _, sku := range skuName.Skus {
|
|
||||||
// skuIDs = append(skuIDs, int(utils.MustInterface2Int64(sku["id"])))
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
// toTimeStr := ""
|
|
||||||
// if params["stToTime"] != nil {
|
|
||||||
// toTimeStr = params["stToTime"].(string)
|
|
||||||
// }
|
|
||||||
// if timeList, err = jxutils.BatchStr2Time(params["stFromTime"].(string), toTimeStr); err != nil {
|
|
||||||
// return nil, err
|
|
||||||
// }
|
|
||||||
// if params["stFromCount"] != nil {
|
|
||||||
// fromCount = params["stFromCount"].(int)
|
|
||||||
// }
|
|
||||||
// toCount = math.MaxInt32
|
|
||||||
// if params["stToCount"] != nil {
|
|
||||||
// toCount = params["stToCount"].(int)
|
|
||||||
// }
|
|
||||||
// // 不能用SQL筛除,否则不能区分是没有销量,还是不在条件中
|
|
||||||
// if saleInfoList, err = GetStoresSkusSaleInfo(ctx, storeIDs, skuIDs, timeList[0], timeList[1], 0, math.MaxInt32); err != nil {
|
|
||||||
// return nil, err
|
|
||||||
// }
|
|
||||||
// for _, saleInfo := range saleInfoList {
|
|
||||||
// saleInfoMap[int64(saleInfo.StoreID)*100000+int64(saleInfo.SkuID)] = saleInfo
|
|
||||||
// }
|
|
||||||
// var newSkuNames []*StoreSkuNameExt
|
|
||||||
// for _, skuName := range skuNamesInfo.SkuNames {
|
|
||||||
// var newSkus []map[string]interface{}
|
|
||||||
// storeID2 := int64(skuName.StoreID) * 100000
|
|
||||||
// for _, sku := range skuName.Skus {
|
|
||||||
// saleInfo := saleInfoMap[storeID2+utils.MustInterface2Int64(sku["id"])]
|
|
||||||
// if saleInfo == nil && fromCount == 0 {
|
|
||||||
// saleInfo = &SkuSaleInfo{}
|
|
||||||
// }
|
|
||||||
// if saleInfo != nil && saleInfo.Count >= fromCount && saleInfo.Count <= toCount {
|
|
||||||
// sku["times"] = saleInfo.Times
|
|
||||||
// sku["count"] = saleInfo.Count
|
|
||||||
// newSkus = append(newSkus, sku)
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
// if len(newSkus) > 0 {
|
|
||||||
// skuName.Skus = newSkus
|
|
||||||
// newSkuNames = append(newSkuNames, skuName)
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
// skuNamesInfo.TotalCount = len(newSkuNames)
|
|
||||||
// skuNamesInfo.SkuNames = nil
|
|
||||||
// if offset < skuNamesInfo.TotalCount {
|
|
||||||
// endIndex := offset + pageSize
|
|
||||||
// if endIndex > skuNamesInfo.TotalCount {
|
|
||||||
// endIndex = skuNamesInfo.TotalCount
|
|
||||||
// }
|
|
||||||
// skuNamesInfo.SkuNames = newSkuNames[offset:endIndex]
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
// if globals.EnablePendingChange {
|
|
||||||
// if isGetOpRequest, ok := params["isGetOpRequest"].(bool); ok && isGetOpRequest {
|
|
||||||
// nameIDs := make([]int, len(skuNamesInfo.SkuNames))
|
|
||||||
// for k, skuName := range skuNamesInfo.SkuNames {
|
|
||||||
// nameIDs[k] = skuName.ID
|
|
||||||
// }
|
|
||||||
// pagedInfo, err2 := GetStoreOpRequests(ctx, utils.DefaultTimeValue, utils.DefaultTimeValue, "", storeIDs, nameIDs, nil, []int{model.RequestStatusNew}, 0, -1)
|
|
||||||
// if err = err2; err != nil {
|
|
||||||
// return nil, err
|
|
||||||
// }
|
|
||||||
// requestList := pagedInfo.Data.([]*StoreOpRequestInfo)
|
|
||||||
// requestMap := make(map[int]*StoreOpRequestInfo)
|
|
||||||
// for _, requestOp := range requestList {
|
|
||||||
// requestMap[requestOp.ItemID] = requestOp
|
|
||||||
// }
|
|
||||||
// for _, skuName := range skuNamesInfo.SkuNames {
|
|
||||||
// if requestOp := requestMap[skuName.ID]; requestOp != nil {
|
|
||||||
// skuName.PendingUnitPrice = requestOp.IntParam1
|
|
||||||
// skuName.PendingOpType = requestOp.Type
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
// } else {
|
|
||||||
// dao.Rollback(db)
|
|
||||||
// }
|
|
||||||
// return skuNamesInfo, err
|
|
||||||
// }
|
|
||||||
|
|
||||||
func getValidStoreVendorMap(db *dao.DaoDB, storeIDs []int) (realVendorMap map[int]int, err error) {
|
func getValidStoreVendorMap(db *dao.DaoDB, storeIDs []int) (realVendorMap map[int]int, err error) {
|
||||||
storeMapList, err := dao.GetStoresMapList(db, nil, storeIDs, model.StoreStatusAll, model.StoreIsSyncYes, "")
|
storeMapList, err := dao.GetStoresMapList(db, nil, storeIDs, model.StoreStatusAll, model.StoreIsSyncYes, "")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|||||||
30
business/jxstore/cms/sync2.go
Normal file
30
business/jxstore/cms/sync2.go
Normal file
@@ -0,0 +1,30 @@
|
|||||||
|
package cms
|
||||||
|
|
||||||
|
import (
|
||||||
|
"git.rosy.net.cn/jx-callback/business/jxutils/jxcontext"
|
||||||
|
"git.rosy.net.cn/jx-callback/business/jxutils/tasksch"
|
||||||
|
)
|
||||||
|
|
||||||
|
func SyncCategories(ctx *jxcontext.Context, parentTask tasksch.ITask, vendorIDs []int, appOrgCodes []string, catIDs []int, isAsync bool) (hint string, err error) {
|
||||||
|
// if len(vendorIDs) == 0 {
|
||||||
|
// vendorIDs = partner.GetMultiStoreVendorIDs()
|
||||||
|
// }
|
||||||
|
// vendorOrgCodeList := apimanager.CurAPIManager.GetVendorOrgCodeList(vendorIDs, appOrgCodes)
|
||||||
|
// task := tasksch.NewParallelTask("同步商家分类", nil, ctx,
|
||||||
|
// func(task *tasksch.ParallelTask, batchItemList []interface{}, params ...interface{}) (retVal interface{}, err error) {
|
||||||
|
// vendorOrgCodePair := batchItemList[0].(*apimanager.VendorOrgCodePair)
|
||||||
|
// if handler := partner.GetPurchasePlatformFromVendorID(vendorOrgCodePair.VendorID); handler != nil {
|
||||||
|
// }
|
||||||
|
// return retVal, err
|
||||||
|
// }, vendorOrgCodeList)
|
||||||
|
// tasksch.HandleTask(task, parentTask, len(catIDs) > 0).Run()
|
||||||
|
// if isAsync {
|
||||||
|
// hint = task.GetID()
|
||||||
|
// } else {
|
||||||
|
// resultList, err2 := task.GetResult(0)
|
||||||
|
// if err = err2; err == nil {
|
||||||
|
// hint = utils.Int2Str(len(resultList))
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
return hint, err
|
||||||
|
}
|
||||||
@@ -179,6 +179,8 @@ func (*ActStoreSkuMap) TableIndex() [][]string {
|
|||||||
type ActStoreSku2 struct {
|
type ActStoreSku2 struct {
|
||||||
MapID int `orm:"column(map_id)"`
|
MapID int `orm:"column(map_id)"`
|
||||||
|
|
||||||
|
Type int `json:"type"`
|
||||||
|
|
||||||
ActStoreSku
|
ActStoreSku
|
||||||
VendorID int `orm:"column(vendor_id)" json:"vendorID"`
|
VendorID int `orm:"column(vendor_id)" json:"vendorID"`
|
||||||
|
|
||||||
|
|||||||
@@ -63,6 +63,7 @@ var (
|
|||||||
VendorIDELM: "Elm",
|
VendorIDELM: "Elm",
|
||||||
VendorIDEBAI: "Ebai",
|
VendorIDEBAI: "Ebai",
|
||||||
VendorIDWSC: "Wsc",
|
VendorIDWSC: "Wsc",
|
||||||
|
VendorIDJX: "Jx",
|
||||||
|
|
||||||
VendorIDDada: "Dada",
|
VendorIDDada: "Dada",
|
||||||
VendorIDMTPS: "Mtps",
|
VendorIDMTPS: "Mtps",
|
||||||
@@ -86,6 +87,7 @@ var (
|
|||||||
VendorIDELM: "饿了么",
|
VendorIDELM: "饿了么",
|
||||||
VendorIDEBAI: "饿百新零售",
|
VendorIDEBAI: "饿百新零售",
|
||||||
VendorIDWSC: "微盟微商城",
|
VendorIDWSC: "微盟微商城",
|
||||||
|
VendorIDJX: "京西自营",
|
||||||
|
|
||||||
VendorIDDada: "达达众包",
|
VendorIDDada: "达达众包",
|
||||||
VendorIDMTPS: "美团配送",
|
VendorIDMTPS: "美团配送",
|
||||||
|
|||||||
@@ -358,6 +358,7 @@ func GetEffectiveActStoreSkuInfo(db *DaoDB, actID int, vendorIDs []int, storeIDs
|
|||||||
}
|
}
|
||||||
sql := `
|
sql := `
|
||||||
SELECT
|
SELECT
|
||||||
|
t1.type,
|
||||||
t2.*,
|
t2.*,
|
||||||
t3.actual_act_price, t3.sync_status, t3.vendor_price, t3.vendor_id
|
t3.actual_act_price, t3.sync_status, t3.vendor_price, t3.vendor_id
|
||||||
FROM act t1
|
FROM act t1
|
||||||
|
|||||||
@@ -91,7 +91,21 @@ func GetStoreDetail(db *DaoDB, storeID, vendorID int) (storeDetail *StoreDetail,
|
|||||||
}
|
}
|
||||||
|
|
||||||
func GetStoreDetailByVendorStoreID(db *DaoDB, vendorStoreID string, vendorID int) (storeDetail *StoreDetail, err error) {
|
func GetStoreDetailByVendorStoreID(db *DaoDB, vendorStoreID string, vendorID int) (storeDetail *StoreDetail, err error) {
|
||||||
|
if vendorID != model.VendorIDJX {
|
||||||
return getStoreDetail(db, 0, vendorID, vendorStoreID)
|
return getStoreDetail(db, 0, vendorID, vendorStoreID)
|
||||||
|
}
|
||||||
|
store := &model.Store{}
|
||||||
|
store.ID = int(utils.Str2Int64WithDefault(vendorStoreID, 0))
|
||||||
|
if err = GetEntity(db, store); err == nil {
|
||||||
|
// todo 还要补全其它参数
|
||||||
|
storeDetail = &StoreDetail{
|
||||||
|
Store: *store,
|
||||||
|
VendorStoreID: vendorStoreID,
|
||||||
|
VendorStatus: store.Status,
|
||||||
|
PricePercentage: 100,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return storeDetail, err
|
||||||
}
|
}
|
||||||
|
|
||||||
func GetPossibleStoresByPlaceName(db *DaoDB, cityName, provinceName string) (storeList []*StoreDetail, err error) {
|
func GetPossibleStoresByPlaceName(db *DaoDB, cityName, provinceName string) (storeList []*StoreDetail, err error) {
|
||||||
|
|||||||
@@ -30,9 +30,9 @@ type GoodsOrder struct {
|
|||||||
ConsigneeMobile string `orm:"size(32)" json:"consigneeMobile"`
|
ConsigneeMobile string `orm:"size(32)" json:"consigneeMobile"`
|
||||||
ConsigneeMobile2 string `orm:"size(32)" json:"consigneeMobile2"`
|
ConsigneeMobile2 string `orm:"size(32)" json:"consigneeMobile2"`
|
||||||
ConsigneeAddress string `orm:"size(255)" json:"consigneeAddress"`
|
ConsigneeAddress string `orm:"size(255)" json:"consigneeAddress"`
|
||||||
CoordinateType int `json:"-"`
|
CoordinateType int `json:"coordinateType"`
|
||||||
ConsigneeLng int `json:"-"` // 坐标 * (10的六次方)
|
ConsigneeLng int `json:"consigneeLng"` // 坐标 * (10的六次方)
|
||||||
ConsigneeLat int `json:"-"` // 坐标 * (10的六次方)
|
ConsigneeLat int `json:"consigneeLat"` // 坐标 * (10的六次方)
|
||||||
SkuCount int `json:"skuCount"` // 商品类别数量,即有多少种商品(注意在某些情况下,相同SKU的商品由于售价不同,也会当成不同商品在这个值里)
|
SkuCount int `json:"skuCount"` // 商品类别数量,即有多少种商品(注意在某些情况下,相同SKU的商品由于售价不同,也会当成不同商品在这个值里)
|
||||||
GoodsCount int `json:"goodsCount"` // 商品个数
|
GoodsCount int `json:"goodsCount"` // 商品个数
|
||||||
Status int `json:"status"` // 参见OrderStatus*相关的常量定义
|
Status int `json:"status"` // 参见OrderStatus*相关的常量定义
|
||||||
|
|||||||
@@ -170,6 +170,7 @@ type SkuCategoryMap struct {
|
|||||||
VendorOrgCode string `orm:"size(32)" json:"vendorOrgCode"` // 同一平台下不同的商户代码,如果只有一个,可以为空
|
VendorOrgCode string `orm:"size(32)" json:"vendorOrgCode"` // 同一平台下不同的商户代码,如果只有一个,可以为空
|
||||||
|
|
||||||
VendorCatID string `orm:"size(32);column(vendor_cat_id)" json:"vendorCatID"`
|
VendorCatID string `orm:"size(32);column(vendor_cat_id)" json:"vendorCatID"`
|
||||||
|
SyncStatus int8 `orm:"default(2)"`
|
||||||
}
|
}
|
||||||
|
|
||||||
func (*SkuCategoryMap) TableUnique() [][]string {
|
func (*SkuCategoryMap) TableUnique() [][]string {
|
||||||
|
|||||||
@@ -357,6 +357,7 @@ type StoreMap struct {
|
|||||||
VendorID int `orm:"column(vendor_id)" json:"vendorID"`
|
VendorID int `orm:"column(vendor_id)" json:"vendorID"`
|
||||||
VendorStoreID string `orm:"column(vendor_store_id);size(48)" json:"vendorStoreID"`
|
VendorStoreID string `orm:"column(vendor_store_id);size(48)" json:"vendorStoreID"`
|
||||||
Status int `json:"status"` // 取值同Store.Status
|
Status int `json:"status"` // 取值同Store.Status
|
||||||
|
StoreName string `orm:"size(255)" json:"storeName"` // 平台门店的名字
|
||||||
|
|
||||||
PricePercentage int16 `orm:"default(100)" json:"pricePercentage"` // todo 厂商价格相对于本地价格的百分比,这个字段的修改会比较特殊,因为可能需要刷新厂商价格
|
PricePercentage int16 `orm:"default(100)" json:"pricePercentage"` // todo 厂商价格相对于本地价格的百分比,这个字段的修改会比较特殊,因为可能需要刷新厂商价格
|
||||||
PricePercentagePack string `orm:"size(32)" json:"pricePercentagePack"` //
|
PricePercentagePack string `orm:"size(32)" json:"pricePercentagePack"` //
|
||||||
@@ -410,6 +411,7 @@ type VendorStoreSnapshot struct {
|
|||||||
OpenTime2 int16 `json:"openTime2"` // 格式同上
|
OpenTime2 int16 `json:"openTime2"` // 格式同上
|
||||||
CloseTime2 int16 `json:"closeTime2"` // 格式同上
|
CloseTime2 int16 `json:"closeTime2"` // 格式同上
|
||||||
DeliveryType int8 `orm:"default(0)" json:"deliveryType"` // 配送类型
|
DeliveryType int8 `orm:"default(0)" json:"deliveryType"` // 配送类型
|
||||||
|
StoreName string `orm:"size(255)" json:"storeName"` // 平台门店的名字
|
||||||
}
|
}
|
||||||
|
|
||||||
func (*VendorStoreSnapshot) TableUnique() [][]string {
|
func (*VendorStoreSnapshot) TableUnique() [][]string {
|
||||||
|
|||||||
@@ -1,7 +1,8 @@
|
|||||||
package partner
|
package partner
|
||||||
|
|
||||||
type IAPIManager interface {
|
type IAPIManager interface {
|
||||||
GetAPI(vendorID int, orgCode string) interface{}
|
GetAPI(vendorID int, appOrgCode string) interface{}
|
||||||
|
GetAppOrgCodeList(vendorID int) (appOrgCodeList []string)
|
||||||
}
|
}
|
||||||
|
|
||||||
var (
|
var (
|
||||||
|
|||||||
@@ -96,7 +96,7 @@ func (c *PurchaseHandler) RefreshComment(fromTime, toTime time.Time) (err error)
|
|||||||
|
|
||||||
func (c *PurchaseHandler) ReplyOrderComment(ctx *jxcontext.Context, orderComment *model.OrderComment, replyComment string) (err error) {
|
func (c *PurchaseHandler) ReplyOrderComment(ctx *jxcontext.Context, orderComment *model.OrderComment, replyComment string) (err error) {
|
||||||
if orderComment.VendorStoreID != "" && orderComment.UserCommentID != "" {
|
if orderComment.VendorStoreID != "" && orderComment.UserCommentID != "" {
|
||||||
if globals.ReallyReplyComment {
|
if globals.EnableEbaiStoreWrite {
|
||||||
err = api.EbaiAPI.OrderRatesReply("", utils.Str2Int64(orderComment.VendorStoreID), orderComment.UserCommentID, replyComment)
|
err = api.EbaiAPI.OrderRatesReply("", utils.Str2Int64(orderComment.VendorStoreID), orderComment.UserCommentID, replyComment)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -25,8 +25,8 @@ func init() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func getAPI(orgCode string) (apiObj *jdapi.API) {
|
func getAPI(appOrgCode string) (apiObj *jdapi.API) {
|
||||||
return partner.CurAPIManager.GetAPI(model.VendorIDJD, orgCode).(*jdapi.API)
|
return partner.CurAPIManager.GetAPI(model.VendorIDJD, appOrgCode).(*jdapi.API)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c *PurchaseHandler) GetVendorID() int {
|
func (c *PurchaseHandler) GetVendorID() int {
|
||||||
|
|||||||
@@ -42,7 +42,7 @@ func (c *PurchaseHandler) onOrderComment2(msg *jdapi.CallbackOrderMsg) (err erro
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (c *PurchaseHandler) ReplyOrderComment(ctx *jxcontext.Context, orderComment *model.OrderComment, replyComment string) (err error) {
|
func (c *PurchaseHandler) ReplyOrderComment(ctx *jxcontext.Context, orderComment *model.OrderComment, replyComment string) (err error) {
|
||||||
if globals.ReallyReplyComment {
|
if globals.EnableJdStoreWrite {
|
||||||
err = getAPI("").OrgReplyComment(utils.Str2Int64(orderComment.VendorOrderID), orderComment.VendorStoreID, replyComment, ctx.GetUserName())
|
err = getAPI("").OrgReplyComment(utils.Str2Int64(orderComment.VendorOrderID), orderComment.VendorStoreID, replyComment, ctx.GetUserName())
|
||||||
}
|
}
|
||||||
return err
|
return err
|
||||||
|
|||||||
11
business/partner/purchase/jx/act.go
Normal file
11
business/partner/purchase/jx/act.go
Normal file
@@ -0,0 +1,11 @@
|
|||||||
|
package jx
|
||||||
|
|
||||||
|
import (
|
||||||
|
"git.rosy.net.cn/jx-callback/business/jxutils/jxcontext"
|
||||||
|
"git.rosy.net.cn/jx-callback/business/jxutils/tasksch"
|
||||||
|
"git.rosy.net.cn/jx-callback/business/model"
|
||||||
|
)
|
||||||
|
|
||||||
|
func (c *PurchaseHandler) SyncAct(ctx *jxcontext.Context, parentTask tasksch.ITask, act *model.Act2, actOrderRules []*model.ActOrderRule, actStoreSkuList []*model.ActStoreSku2) (err error) {
|
||||||
|
return err
|
||||||
|
}
|
||||||
36
business/partner/purchase/jx/callback.go
Normal file
36
business/partner/purchase/jx/callback.go
Normal file
@@ -0,0 +1,36 @@
|
|||||||
|
package jx
|
||||||
|
|
||||||
|
import "fmt"
|
||||||
|
|
||||||
|
const (
|
||||||
|
appKey = "4A86853D-E4B6-454E-940A-B68ECDA2B73E"
|
||||||
|
|
||||||
|
MsgTypeOrder = "order"
|
||||||
|
SubMsgTypeOrderNew = "newOrder"
|
||||||
|
SubMsgTypeOrderAdjust = "adjustOrder"
|
||||||
|
SubMsgTypeOrderApplyCancel = "applyCancel"
|
||||||
|
// SubMsgTypeOrderApplayRefund = "applyRefund"
|
||||||
|
)
|
||||||
|
|
||||||
|
type CallbackResponse struct {
|
||||||
|
Code int `json:"code"`
|
||||||
|
Data string `json:"data"`
|
||||||
|
}
|
||||||
|
|
||||||
|
type CallbackMsg struct {
|
||||||
|
AppKey string `json:"appKey"`
|
||||||
|
MsgType string `json:"msgType"`
|
||||||
|
SubMsgType string `json:"subMsgType"`
|
||||||
|
ThingID string `json:"thingID"`
|
||||||
|
Data string `json:"data"`
|
||||||
|
}
|
||||||
|
|
||||||
|
func OnCallbackMsg(msg *CallbackMsg) (retVal, errCode string, err error) {
|
||||||
|
if msg.AppKey != appKey {
|
||||||
|
return retVal, errCode, fmt.Errorf("无效的AppKey:%s", msg.AppKey)
|
||||||
|
}
|
||||||
|
if msg.MsgType == MsgTypeOrder {
|
||||||
|
retVal, errCode, err = CurPurchaseHandler.OnOrderMsg(msg)
|
||||||
|
}
|
||||||
|
return retVal, errCode, err
|
||||||
|
}
|
||||||
32
business/partner/purchase/jx/jx.go
Normal file
32
business/partner/purchase/jx/jx.go
Normal file
@@ -0,0 +1,32 @@
|
|||||||
|
package jx
|
||||||
|
|
||||||
|
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"
|
||||||
|
)
|
||||||
|
|
||||||
|
type PurchaseHandler struct {
|
||||||
|
partner.BasePurchasePlatform
|
||||||
|
}
|
||||||
|
|
||||||
|
var (
|
||||||
|
CurPurchaseHandler *PurchaseHandler
|
||||||
|
)
|
||||||
|
|
||||||
|
func init() {
|
||||||
|
globals.SugarLogger.Debug("init jx")
|
||||||
|
if true {
|
||||||
|
CurPurchaseHandler = new(PurchaseHandler)
|
||||||
|
partner.RegisterPurchasePlatform(CurPurchaseHandler)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func (c *PurchaseHandler) GetVendorID() int {
|
||||||
|
return model.VendorIDJX
|
||||||
|
}
|
||||||
|
|
||||||
|
func (p *PurchaseHandler) UploadImg(ctx *jxcontext.Context, imgURL string, imgData []byte, imgName string) (imgHint string, err error) {
|
||||||
|
return imgHint, err
|
||||||
|
}
|
||||||
52
business/partner/purchase/jx/jx_test.go
Normal file
52
business/partner/purchase/jx/jx_test.go
Normal file
@@ -0,0 +1,52 @@
|
|||||||
|
package jx
|
||||||
|
|
||||||
|
import (
|
||||||
|
"testing"
|
||||||
|
|
||||||
|
_ "git.rosy.net.cn/jx-callback/business/jxcallback/orderman"
|
||||||
|
|
||||||
|
"git.rosy.net.cn/baseapi/utils"
|
||||||
|
"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 TestBuildNewJxOrder(t *testing.T) {
|
||||||
|
order, err := partner.CurOrderManager.LoadOrder("920931913000041", model.VendorIDJD)
|
||||||
|
if err != nil {
|
||||||
|
t.Fatal(err)
|
||||||
|
}
|
||||||
|
order.VendorID = model.VendorIDJX
|
||||||
|
order.VendorStoreID = utils.Int2Str(order.StoreID)
|
||||||
|
for _, sku := range order.Skus {
|
||||||
|
sku.VendorID = model.VendorIDJX
|
||||||
|
sku.VendorSkuID = utils.Int2Str(sku.SkuID)
|
||||||
|
}
|
||||||
|
order2 := &Data4Neworder{
|
||||||
|
GoodsOrder: *order,
|
||||||
|
Skus: order.Skus,
|
||||||
|
}
|
||||||
|
msg := &CallbackMsg{
|
||||||
|
AppKey: appKey,
|
||||||
|
MsgType: MsgTypeOrder,
|
||||||
|
SubMsgType: SubMsgTypeOrderNew,
|
||||||
|
ThingID: order.VendorOrderID,
|
||||||
|
Data: utils.Format4Output(order2, true),
|
||||||
|
}
|
||||||
|
t.Logf("\n%s", msg.AppKey)
|
||||||
|
t.Logf("\n%s", msg.MsgType)
|
||||||
|
t.Logf("\n%s", msg.SubMsgType)
|
||||||
|
t.Logf("\n%s", msg.ThingID)
|
||||||
|
t.Logf("\n%s", msg.Data)
|
||||||
|
|
||||||
|
var order3 *model.GoodsOrder
|
||||||
|
err = utils.UnmarshalUseNumber([]byte(msg.Data), &order3)
|
||||||
|
if err != nil {
|
||||||
|
t.Fatal(err)
|
||||||
|
}
|
||||||
|
t.Log(order3.OrderCreatedAt)
|
||||||
|
}
|
||||||
120
business/partner/purchase/jx/order.go
Normal file
120
business/partner/purchase/jx/order.go
Normal file
@@ -0,0 +1,120 @@
|
|||||||
|
package jx
|
||||||
|
|
||||||
|
import (
|
||||||
|
"time"
|
||||||
|
|
||||||
|
"git.rosy.net.cn/baseapi/utils"
|
||||||
|
"git.rosy.net.cn/jx-callback/business/jxutils"
|
||||||
|
"git.rosy.net.cn/jx-callback/business/jxutils/jxcontext"
|
||||||
|
"git.rosy.net.cn/jx-callback/business/jxutils/tasksch"
|
||||||
|
"git.rosy.net.cn/jx-callback/business/model"
|
||||||
|
"git.rosy.net.cn/jx-callback/business/partner"
|
||||||
|
"git.rosy.net.cn/jx-callback/globals"
|
||||||
|
)
|
||||||
|
|
||||||
|
type Data4Neworder struct {
|
||||||
|
model.GoodsOrder
|
||||||
|
Skus []*model.OrderSku `json:"skus"`
|
||||||
|
}
|
||||||
|
|
||||||
|
func (c *PurchaseHandler) OnOrderMsg(msg *CallbackMsg) (retVal, errCode string, err error) {
|
||||||
|
jxutils.CallMsgHandler(func() {
|
||||||
|
retVal, errCode, err = c.onOrderMsg(msg)
|
||||||
|
}, jxutils.ComposeUniversalOrderID(msg.ThingID, c.GetVendorID()))
|
||||||
|
return retVal, errCode, err
|
||||||
|
}
|
||||||
|
|
||||||
|
func (c *PurchaseHandler) onOrderMsg(msg *CallbackMsg) (retVal, errCode string, err error) {
|
||||||
|
if msg.SubMsgType == SubMsgTypeOrderNew || msg.SubMsgType == SubMsgTypeOrderAdjust {
|
||||||
|
var order *Data4Neworder
|
||||||
|
if err = utils.UnmarshalUseNumber([]byte(msg.Data), &order); err == nil {
|
||||||
|
retVal, errCode, err = c.onOrderNew(msg, order)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return retVal, errCode, err
|
||||||
|
}
|
||||||
|
|
||||||
|
func (c *PurchaseHandler) onOrderNew(msg *CallbackMsg, order *Data4Neworder) (retVal, errCode string, err error) {
|
||||||
|
globals.SugarLogger.Debugf("onOrderNew orderID:%s", msg.ThingID)
|
||||||
|
order.GoodsOrder.Skus = order.Skus
|
||||||
|
orderStatus := model.Order2Status(&order.GoodsOrder)
|
||||||
|
if msg.SubMsgType == SubMsgTypeOrderNew {
|
||||||
|
err = partner.CurOrderManager.OnOrderNew(&order.GoodsOrder, orderStatus)
|
||||||
|
} else {
|
||||||
|
err = partner.CurOrderManager.OnOrderAdjust(&order.GoodsOrder, orderStatus)
|
||||||
|
}
|
||||||
|
return retVal, errCode, err
|
||||||
|
}
|
||||||
|
|
||||||
|
func (c *PurchaseHandler) Map2Order(orderData map[string]interface{}) (order *model.GoodsOrder) {
|
||||||
|
return order
|
||||||
|
}
|
||||||
|
|
||||||
|
func (c *PurchaseHandler) GetOrder(orderID string) (order *model.GoodsOrder, err error) {
|
||||||
|
return order, err
|
||||||
|
}
|
||||||
|
|
||||||
|
func (c *PurchaseHandler) AcceptOrRefuseOrder(order *model.GoodsOrder, isAcceptIt bool, userName string) (err error) {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
func (c *PurchaseHandler) PickupGoods(order *model.GoodsOrder, isSelfDelivery bool, userName string) (err error) {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
func (p *PurchaseHandler) AcceptOrRefuseFailedGetOrder(ctx *jxcontext.Context, order *model.GoodsOrder, isAcceptIt bool) (err error) {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
func (p *PurchaseHandler) CallCourier(ctx *jxcontext.Context, order *model.GoodsOrder) (err error) { // 拣货失败后再次招唤平台配送
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
func (p *PurchaseHandler) ConfirmReceiveGoods(ctx *jxcontext.Context, order *model.GoodsOrder) (err error) { // 投递失败后确认收到退货
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
func (c *PurchaseHandler) Swtich2SelfDeliver(order *model.GoodsOrder, userName string) (err error) {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
func (c *PurchaseHandler) Swtich2SelfDelivered(order *model.GoodsOrder, userName string) (err error) {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
func (c *PurchaseHandler) SelfDeliverDelivering(order *model.GoodsOrder, userName string) (err error) {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
// 京东送达接口都是一样的
|
||||||
|
func (c *PurchaseHandler) SelfDeliverDelivered(order *model.GoodsOrder, userName string) (err error) {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
func (c *PurchaseHandler) GetOrderRealMobile(ctx *jxcontext.Context, order *model.GoodsOrder) (mobile string, err error) {
|
||||||
|
return mobile, err
|
||||||
|
}
|
||||||
|
|
||||||
|
func (c *PurchaseHandler) AgreeOrRefuseCancel(ctx *jxcontext.Context, order *model.GoodsOrder, isAgree bool, reason string) (err error) {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
func (c *PurchaseHandler) CancelOrder(ctx *jxcontext.Context, order *model.GoodsOrder, reason string) (err error) {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
func (c *PurchaseHandler) AdjustOrder(ctx *jxcontext.Context, order *model.GoodsOrder, removedSkuList []*model.OrderSku, reason string) (err error) {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
func (c *PurchaseHandler) ListOrders(ctx *jxcontext.Context, parentTask tasksch.ITask, queryDate time.Time, vendorStoreID string) (vendorOrderIDs []string, err error) {
|
||||||
|
return vendorOrderIDs, err
|
||||||
|
}
|
||||||
|
|
||||||
|
func (c *PurchaseHandler) GetWaybillTip(ctx *jxcontext.Context, order *model.GoodsOrder) (tipFee int64, err error) {
|
||||||
|
return tipFee, err
|
||||||
|
}
|
||||||
|
|
||||||
|
func (c *PurchaseHandler) AddWaybillTip(ctx *jxcontext.Context, order *model.GoodsOrder, tipFee2Add int64) (err error) {
|
||||||
|
return err
|
||||||
|
}
|
||||||
38
business/partner/purchase/jx/order_afs.go
Normal file
38
business/partner/purchase/jx/order_afs.go
Normal file
@@ -0,0 +1,38 @@
|
|||||||
|
package jx
|
||||||
|
|
||||||
|
import (
|
||||||
|
"git.rosy.net.cn/jx-callback/business/jxutils"
|
||||||
|
"git.rosy.net.cn/jx-callback/business/jxutils/jxcontext"
|
||||||
|
"git.rosy.net.cn/jx-callback/business/model"
|
||||||
|
)
|
||||||
|
|
||||||
|
func (c *PurchaseHandler) OnAfsOrderMsg(msg *CallbackMsg) (retVal *CallbackResponse) {
|
||||||
|
jxutils.CallMsgHandlerAsync(func() {
|
||||||
|
retVal = c.onAfsOrderMsg(msg)
|
||||||
|
}, jxutils.ComposeUniversalOrderID(msg.ThingID, c.GetVendorID()))
|
||||||
|
return retVal
|
||||||
|
}
|
||||||
|
|
||||||
|
func (c *PurchaseHandler) onAfsOrderMsg(msg *CallbackMsg) (retVal *CallbackResponse) {
|
||||||
|
return retVal
|
||||||
|
}
|
||||||
|
|
||||||
|
// 审核售后单申请
|
||||||
|
func (c *PurchaseHandler) AgreeOrRefuseRefund(ctx *jxcontext.Context, order *model.AfsOrder, approveType int, reason string) (err error) {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
// 确认收到退货
|
||||||
|
func (c *PurchaseHandler) ConfirmReceivedReturnGoods(ctx *jxcontext.Context, order *model.AfsOrder) (err error) {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
// 发起全款退款
|
||||||
|
func (c *PurchaseHandler) RefundOrder(ctx *jxcontext.Context, order *model.GoodsOrder, reason string) (err error) {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
// 发起部分退款
|
||||||
|
func (c *PurchaseHandler) PartRefundOrder(ctx *jxcontext.Context, order *model.GoodsOrder, refundSkuList []*model.OrderSku, reason string) (err error) {
|
||||||
|
return err
|
||||||
|
}
|
||||||
10
business/partner/purchase/jx/order_comment.go
Normal file
10
business/partner/purchase/jx/order_comment.go
Normal file
@@ -0,0 +1,10 @@
|
|||||||
|
package jx
|
||||||
|
|
||||||
|
import (
|
||||||
|
"git.rosy.net.cn/jx-callback/business/jxutils/jxcontext"
|
||||||
|
"git.rosy.net.cn/jx-callback/business/model"
|
||||||
|
)
|
||||||
|
|
||||||
|
func (c *PurchaseHandler) ReplyOrderComment(ctx *jxcontext.Context, orderComment *model.OrderComment, replyComment string) (err error) {
|
||||||
|
return err
|
||||||
|
}
|
||||||
59
business/partner/purchase/jx/sku.go
Normal file
59
business/partner/purchase/jx/sku.go
Normal file
@@ -0,0 +1,59 @@
|
|||||||
|
package jx
|
||||||
|
|
||||||
|
// 这里函数取得的信息,除了与自身实体相关的ID(比如PARENT ID),都已经转换成了本地ID了
|
||||||
|
|
||||||
|
import (
|
||||||
|
"git.rosy.net.cn/jx-callback/business/jxutils/jxcontext"
|
||||||
|
"git.rosy.net.cn/jx-callback/business/jxutils/tasksch"
|
||||||
|
"git.rosy.net.cn/jx-callback/business/model"
|
||||||
|
"git.rosy.net.cn/jx-callback/business/model/dao"
|
||||||
|
"git.rosy.net.cn/jx-callback/business/partner"
|
||||||
|
)
|
||||||
|
|
||||||
|
func (p *PurchaseHandler) CreateCategory(db *dao.DaoDB, cat *model.SkuCategory, userName string) (err error) {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
func (p *PurchaseHandler) GetAllCategories(ctx *jxcontext.Context, vendorOrgCode string) (cats []*partner.BareCategoryInfo, err error) {
|
||||||
|
return cats, err
|
||||||
|
}
|
||||||
|
|
||||||
|
func (p *PurchaseHandler) UpdateCategory(db *dao.DaoDB, cat *model.SkuCategory, userName string) error {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (p *PurchaseHandler) DeleteCategory(db *dao.DaoDB, cat *model.SkuCategory, userName string) error {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (p *PurchaseHandler) ReorderCategories(db *dao.DaoDB, parentCatID int, userName string) (err error) {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
func (p *PurchaseHandler) CreateSku(db *dao.DaoDB, sku *model.Sku, userName string) (err error) {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
func (p *PurchaseHandler) ReadSku(vendorSkuID string) (skuNameExt *model.SkuNameExt, err error) {
|
||||||
|
return skuNameExt, err
|
||||||
|
}
|
||||||
|
|
||||||
|
func (p *PurchaseHandler) UpdateSku(db *dao.DaoDB, sku *model.Sku, userName string) (err error) {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
func (p *PurchaseHandler) DeleteSku(db *dao.DaoDB, sku *model.Sku, userName string) (err error) {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
func (p *PurchaseHandler) RefreshAllSkusID(ctx *jxcontext.Context, parentTask tasksch.ITask, isAsync bool) (hint string, err error) {
|
||||||
|
return hint, err
|
||||||
|
}
|
||||||
|
|
||||||
|
func (p *PurchaseHandler) GetVendorCategories(ctx *jxcontext.Context) (vendorCats []*model.SkuVendorCategory, err error) {
|
||||||
|
return vendorCats, err
|
||||||
|
}
|
||||||
|
|
||||||
|
func (p *PurchaseHandler) GetSkus(ctx *jxcontext.Context, skuID int, vendorSkuID, skuName string) (skuNameList []*partner.SkuNameInfo, err error) {
|
||||||
|
return skuNameList, err
|
||||||
|
}
|
||||||
40
business/partner/purchase/jx/store.go
Normal file
40
business/partner/purchase/jx/store.go
Normal file
@@ -0,0 +1,40 @@
|
|||||||
|
package jx
|
||||||
|
|
||||||
|
import (
|
||||||
|
"git.rosy.net.cn/jx-callback/business/jxutils/jxcontext"
|
||||||
|
"git.rosy.net.cn/jx-callback/business/jxutils/tasksch"
|
||||||
|
"git.rosy.net.cn/jx-callback/business/model/dao"
|
||||||
|
)
|
||||||
|
|
||||||
|
func (p *PurchaseHandler) ReadStore(ctx *jxcontext.Context, vendorStoreID string) (storeDetail *dao.StoreDetail, err error) {
|
||||||
|
return storeDetail, err
|
||||||
|
}
|
||||||
|
|
||||||
|
// stoerIDs为nil表示所有
|
||||||
|
func (p *PurchaseHandler) UpdateStore(db *dao.DaoDB, storeID int, userName string) (err error) {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
func (p *PurchaseHandler) RefreshAllStoresID(ctx *jxcontext.Context, parentTask tasksch.ITask, isAsync bool) (hint string, err error) {
|
||||||
|
return hint, err
|
||||||
|
}
|
||||||
|
|
||||||
|
func (p *PurchaseHandler) GetStoreStatus(ctx *jxcontext.Context, storeID int, vendorStoreID string) (storeStatus int, err error) {
|
||||||
|
return storeStatus, err
|
||||||
|
}
|
||||||
|
|
||||||
|
func (c *PurchaseHandler) UpdateStoreStatus(ctx *jxcontext.Context, storeID int, vendorStoreID string, status int) (err error) {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
func (c *PurchaseHandler) UpdateStoreOpTime(ctx *jxcontext.Context, storeID int, vendorStoreID string, opTimeList []int16) (err error) {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
func (c *PurchaseHandler) GetAllStoresVendorID(ctx *jxcontext.Context) (vendorStoreIDs []string, err error) {
|
||||||
|
return vendorStoreIDs, err
|
||||||
|
}
|
||||||
|
|
||||||
|
func (c *PurchaseHandler) UpdateStoreCustomID(ctx *jxcontext.Context, vendorStoreID string, storeID int64) (err error) {
|
||||||
|
return err
|
||||||
|
}
|
||||||
28
business/partner/purchase/jx/store_sku2.go
Normal file
28
business/partner/purchase/jx/store_sku2.go
Normal file
@@ -0,0 +1,28 @@
|
|||||||
|
package jx
|
||||||
|
|
||||||
|
import (
|
||||||
|
"git.rosy.net.cn/jx-callback/business/jxutils/jxcontext"
|
||||||
|
"git.rosy.net.cn/jx-callback/business/jxutils/tasksch"
|
||||||
|
"git.rosy.net.cn/jx-callback/business/partner"
|
||||||
|
)
|
||||||
|
|
||||||
|
func (p *PurchaseHandler) GetStoreSkusBatchSize(funcID int) (batchSize int) {
|
||||||
|
batchSize = 1
|
||||||
|
return batchSize
|
||||||
|
}
|
||||||
|
|
||||||
|
func (p *PurchaseHandler) GetStoreSkusBareInfo(ctx *jxcontext.Context, parentTask tasksch.ITask, storeID int, vendorStoreID string, inStoreSkuList []*partner.StoreSkuInfo) (outStoreSkuList []*partner.StoreSkuInfo, err error) {
|
||||||
|
return outStoreSkuList, err
|
||||||
|
}
|
||||||
|
|
||||||
|
func (p *PurchaseHandler) UpdateStoreSkusStatus(ctx *jxcontext.Context, storeID int, vendorStoreID string, storeSkuList []*partner.StoreSkuInfo, status int) (successList []*partner.StoreSkuInfo, err error) {
|
||||||
|
return successList, err
|
||||||
|
}
|
||||||
|
|
||||||
|
func (p *PurchaseHandler) UpdateStoreSkusPrice(ctx *jxcontext.Context, storeID int, vendorStoreID string, storeSkuList []*partner.StoreSkuInfo) (successList []*partner.StoreSkuInfo, err error) {
|
||||||
|
return successList, err
|
||||||
|
}
|
||||||
|
|
||||||
|
func (p *PurchaseHandler) UpdateStoreSkusStock(ctx *jxcontext.Context, storeID int, vendorStoreID string, storeSkuList []*partner.StoreSkuInfo) (successList []*partner.StoreSkuInfo, err error) {
|
||||||
|
return successList, err
|
||||||
|
}
|
||||||
33
controllers/jxshop_callback.go
Normal file
33
controllers/jxshop_callback.go
Normal file
@@ -0,0 +1,33 @@
|
|||||||
|
package controllers
|
||||||
|
|
||||||
|
import (
|
||||||
|
"git.rosy.net.cn/jx-callback/business/partner/purchase/jx"
|
||||||
|
"github.com/astaxie/beego"
|
||||||
|
)
|
||||||
|
|
||||||
|
type JxShopController struct {
|
||||||
|
beego.Controller
|
||||||
|
}
|
||||||
|
|
||||||
|
// @Title 京西自营商城消息回调接口
|
||||||
|
// @Description 京西自营商城消息回调接口
|
||||||
|
// @Param appKey formData string true "AppKey"
|
||||||
|
// @Param msgType formData string true "消息类型"
|
||||||
|
// @Param subMsgType formData string false "子消息类型"
|
||||||
|
// @Param thingID formData string false "消息对应的事物ID"
|
||||||
|
// @Param data formData string false "详细"
|
||||||
|
// @Success 200 {object} controllers.CallResult
|
||||||
|
// @Failure 200 {object} controllers.CallResult
|
||||||
|
// @router /JxMsg [post]
|
||||||
|
func (c *JxShopController) JxMsg(msgType string) {
|
||||||
|
c.callJxMsg(func(params *tJxshopJxMsgParams) (retVal interface{}, errCode string, err error) {
|
||||||
|
retVal, errCode, err = jx.OnCallbackMsg(&jx.CallbackMsg{
|
||||||
|
AppKey: params.AppKey,
|
||||||
|
MsgType: params.MsgType,
|
||||||
|
SubMsgType: params.SubMsgType,
|
||||||
|
ThingID: params.ThingID,
|
||||||
|
Data: params.Data,
|
||||||
|
})
|
||||||
|
return retVal, "", err
|
||||||
|
})
|
||||||
|
}
|
||||||
@@ -1,26 +1,32 @@
|
|||||||
package apimanager
|
package apimanager
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"git.rosy.net.cn/jx-callback/business/jxutils"
|
||||||
"git.rosy.net.cn/jx-callback/business/model"
|
"git.rosy.net.cn/jx-callback/business/model"
|
||||||
"git.rosy.net.cn/jx-callback/business/partner"
|
"git.rosy.net.cn/jx-callback/business/partner"
|
||||||
"git.rosy.net.cn/jx-callback/globals"
|
"git.rosy.net.cn/jx-callback/globals"
|
||||||
"git.rosy.net.cn/jx-callback/globals/api"
|
"git.rosy.net.cn/jx-callback/globals/api"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
type VendorOrgCodePair struct {
|
||||||
|
VendorID int
|
||||||
|
AppOrgCode string
|
||||||
|
}
|
||||||
|
|
||||||
type APIManager struct {
|
type APIManager struct {
|
||||||
}
|
}
|
||||||
|
|
||||||
var (
|
var (
|
||||||
curAPIManager *APIManager
|
CurAPIManager *APIManager
|
||||||
)
|
)
|
||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
globals.SugarLogger.Debug("init apimanager")
|
globals.SugarLogger.Debug("init apimanager")
|
||||||
curAPIManager = &APIManager{}
|
CurAPIManager = &APIManager{}
|
||||||
partner.InitAPIManager(curAPIManager)
|
partner.InitAPIManager(CurAPIManager)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (a *APIManager) GetAPI(vendorID int, name string) (pfAPI interface{}) {
|
func (a *APIManager) GetAPI(vendorID int, appOrgCode string) (pfAPI interface{}) {
|
||||||
switch vendorID {
|
switch vendorID {
|
||||||
case model.VendorIDJD:
|
case model.VendorIDJD:
|
||||||
pfAPI = api.JdAPI
|
pfAPI = api.JdAPI
|
||||||
@@ -31,3 +37,32 @@ func (a *APIManager) GetAPI(vendorID int, name string) (pfAPI interface{}) {
|
|||||||
}
|
}
|
||||||
return pfAPI
|
return pfAPI
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (a *APIManager) GetAppOrgCodeList(vendorID int) (appOrgCodeList []string) {
|
||||||
|
switch vendorID {
|
||||||
|
case model.VendorIDJD:
|
||||||
|
appOrgCodeList = []string{"320406"}
|
||||||
|
case model.VendorIDMTWM:
|
||||||
|
case model.VendorIDEBAI:
|
||||||
|
}
|
||||||
|
return appOrgCodeList
|
||||||
|
}
|
||||||
|
|
||||||
|
func (a *APIManager) GetVendorOrgCodeList(vendorIDs []int, appOrgCodes []string) (vendorOrgCodeList []*VendorOrgCodePair) {
|
||||||
|
if len(vendorIDs) == 0 {
|
||||||
|
vendorIDs = partner.GetMultiStoreVendorIDs()
|
||||||
|
}
|
||||||
|
appOrgCodeMap := jxutils.StringList2Map(appOrgCodes)
|
||||||
|
for _, vendorID := range vendorIDs {
|
||||||
|
tmpOrgCodeList := a.GetAppOrgCodeList(vendorID)
|
||||||
|
for _, v := range tmpOrgCodeList {
|
||||||
|
if len(appOrgCodes) == 0 || appOrgCodeMap[v] == 1 {
|
||||||
|
vendorOrgCodeList = append(vendorOrgCodeList, &VendorOrgCodePair{
|
||||||
|
VendorID: vendorID,
|
||||||
|
AppOrgCode: v,
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return vendorOrgCodeList
|
||||||
|
}
|
||||||
|
|||||||
@@ -32,7 +32,7 @@ func Init() {
|
|||||||
orm.RegisterModel(&model.Store{}, &model.StoreSub{}, &model.StoreMap{}, &model.StoreCourierMap{})
|
orm.RegisterModel(&model.Store{}, &model.StoreSub{}, &model.StoreMap{}, &model.StoreCourierMap{})
|
||||||
orm.RegisterModel(&model.SkuVendorCategory{}, &model.StoreSkuCategoryMap{}, &model.SkuName{}, &model.Sku{}, &model.SkuNamePlaceBind{}, &model.StoreSkuBind{})
|
orm.RegisterModel(&model.SkuVendorCategory{}, &model.StoreSkuCategoryMap{}, &model.SkuName{}, &model.Sku{}, &model.SkuNamePlaceBind{}, &model.StoreSkuBind{})
|
||||||
orm.RegisterModel(&model.SkuCategory{})
|
orm.RegisterModel(&model.SkuCategory{})
|
||||||
// orm.RegisterModel(&model.DurableTask{}, &model.DurableTaskItem{})
|
// orm.RegisterModel(&model.SkuCategoryMap{})
|
||||||
|
|
||||||
orm.RegisterModel(&model.AuthBind{}, &model.User{})
|
orm.RegisterModel(&model.AuthBind{}, &model.User{})
|
||||||
|
|
||||||
|
|||||||
@@ -17,7 +17,6 @@ const (
|
|||||||
var (
|
var (
|
||||||
ReallyCallPlatformAPI bool
|
ReallyCallPlatformAPI bool
|
||||||
ReallySendWeixinMsg bool
|
ReallySendWeixinMsg bool
|
||||||
ReallyReplyComment bool
|
|
||||||
|
|
||||||
SugarLogger *zap.SugaredLogger
|
SugarLogger *zap.SugaredLogger
|
||||||
|
|
||||||
@@ -62,7 +61,6 @@ func Init() {
|
|||||||
SugarLogger.Infof("globals RunMode=%s", beego.BConfig.RunMode)
|
SugarLogger.Infof("globals RunMode=%s", beego.BConfig.RunMode)
|
||||||
ReallyCallPlatformAPI = (beego.BConfig.RunMode != "dev" && beego.BConfig.RunMode != "test")
|
ReallyCallPlatformAPI = (beego.BConfig.RunMode != "dev" && beego.BConfig.RunMode != "test")
|
||||||
ReallySendWeixinMsg = ReallyCallPlatformAPI && IsProductEnv()
|
ReallySendWeixinMsg = ReallyCallPlatformAPI && IsProductEnv()
|
||||||
ReallyReplyComment = ReallyCallPlatformAPI && IsProductEnv()
|
|
||||||
|
|
||||||
AliKey = beego.AppConfig.DefaultString("aliKey", "")
|
AliKey = beego.AppConfig.DefaultString("aliKey", "")
|
||||||
AliSecret = beego.AppConfig.DefaultString("aliSecret", "")
|
AliSecret = beego.AppConfig.DefaultString("aliSecret", "")
|
||||||
@@ -89,7 +87,7 @@ func Init() {
|
|||||||
StoreName = beego.AppConfig.DefaultString("storeName", "京西菜市")
|
StoreName = beego.AppConfig.DefaultString("storeName", "京西菜市")
|
||||||
|
|
||||||
EnableWXAuth2 = true // beego.BConfig.RunMode == "beta"
|
EnableWXAuth2 = true // beego.BConfig.RunMode == "beta"
|
||||||
DisableWXAuth1 = false
|
DisableWXAuth1 = true
|
||||||
}
|
}
|
||||||
|
|
||||||
func IsCallbackAlwaysReturnSuccess() bool {
|
func IsCallbackAlwaysReturnSuccess() bool {
|
||||||
|
|||||||
@@ -592,6 +592,17 @@ func init() {
|
|||||||
Filters: nil,
|
Filters: nil,
|
||||||
Params: nil})
|
Params: nil})
|
||||||
|
|
||||||
|
beego.GlobalControllerRouter["git.rosy.net.cn/jx-callback/controllers:JxShopController"] = append(beego.GlobalControllerRouter["git.rosy.net.cn/jx-callback/controllers:JxShopController"],
|
||||||
|
beego.ControllerComments{
|
||||||
|
Method: "JxMsg",
|
||||||
|
Router: `/JxMsg`,
|
||||||
|
AllowHTTPMethods: []string{"post"},
|
||||||
|
MethodParams: param.Make(
|
||||||
|
param.New("msgType", param.IsRequired),
|
||||||
|
),
|
||||||
|
Filters: nil,
|
||||||
|
Params: nil})
|
||||||
|
|
||||||
beego.GlobalControllerRouter["git.rosy.net.cn/jx-callback/controllers:MsgController"] = append(beego.GlobalControllerRouter["git.rosy.net.cn/jx-callback/controllers:MsgController"],
|
beego.GlobalControllerRouter["git.rosy.net.cn/jx-callback/controllers:MsgController"] = append(beego.GlobalControllerRouter["git.rosy.net.cn/jx-callback/controllers:MsgController"],
|
||||||
beego.ControllerComments{
|
beego.ControllerComments{
|
||||||
Method: "GetStoreMessageStatuses",
|
Method: "GetStoreMessageStatuses",
|
||||||
|
|||||||
@@ -111,6 +111,11 @@ func init() {
|
|||||||
&controllers.ActController{},
|
&controllers.ActController{},
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
|
beego.NSNamespace("/jxshop",
|
||||||
|
beego.NSInclude(
|
||||||
|
&controllers.JxShopController{},
|
||||||
|
),
|
||||||
|
),
|
||||||
)
|
)
|
||||||
beego.AddNamespace(ns)
|
beego.AddNamespace(ns)
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user