Merge branch 'jdshop' of e.coding.net:rosydev/jx-callback into jdshop
This commit is contained in:
@@ -148,6 +148,7 @@ func InitServiceInfo(version string, buildTime time.Time, gitCommit string) {
|
||||
"operateType": model.OperateTypeName,
|
||||
"thingType": model.ThingTypeName,
|
||||
"apiFunctionName": model.ApiFunctionName,
|
||||
"vendorStatus": model.VendorStatus,
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1519,6 +1519,7 @@ func AddStoreCourierMap(ctx *jxcontext.Context, db *dao.DaoDB, storeID, vendorID
|
||||
func addStoreCourierMap(ctx *jxcontext.Context, db *dao.DaoDB, storeID, vendorID int, storeCourierMap *model.StoreCourierMap, isNeedUpdateRemote bool) (outStoreCourierMap *model.StoreCourierMap, err error) {
|
||||
storeCourierMap.StoreID = storeID
|
||||
storeCourierMap.VendorID = vendorID
|
||||
storeCourierMap.VendorStatus = storeCourierMap.Status
|
||||
globals.SugarLogger.Debugf("addStoreCourierMap %s, storeCourierMap:%s, isNeedUpdateRemote:%t", model.VendorChineseNames[vendorID], utils.Format4Output(storeCourierMap, true), isNeedUpdateRemote)
|
||||
|
||||
if handler := partner.GetDeliveryPlatformFromVendorID(vendorID); handler != nil {
|
||||
@@ -1564,7 +1565,8 @@ func DeleteStoreCourierMap(ctx *jxcontext.Context, db *dao.DaoDB, storeID, vendo
|
||||
}
|
||||
storeCourierMap := &model.StoreCourierMap{}
|
||||
num, err = dao.DeleteEntityLogically(db, storeCourierMap, map[string]interface{}{
|
||||
model.FieldStatus: model.StoreStatusDisabled,
|
||||
model.FieldStatus: model.StoreStatusDisabled,
|
||||
model.FieldVendorStatus: model.StoreStatusDisabled,
|
||||
}, userName, map[string]interface{}{
|
||||
model.FieldStoreID: storeID,
|
||||
model.FieldVendorID: vendorID,
|
||||
|
||||
@@ -2471,7 +2471,12 @@ func GetTopSkusByStoreIDs(ctx *jxcontext.Context, storeIDs []int) (storeSkuNameE
|
||||
func GetTopSkusByCityCode(ctx *jxcontext.Context, cityCode, storeID int) (skuNameAndPlaceList []*dao.SkuNameAndPlace, err error) {
|
||||
db := dao.GetDB()
|
||||
orderCreate := time.Now().AddDate(0, -1, 0)
|
||||
skuNameAndPlace, err := dao.GetTopSkusByCityCode(db, cityCode, orderCreate)
|
||||
var skuNameAndPlace []*dao.SkuNameAndPlace
|
||||
if cityCode > 0 {
|
||||
skuNameAndPlace, err = dao.GetTopSkusByCityCode(db, cityCode, orderCreate)
|
||||
} else {
|
||||
skuNameAndPlace, err = dao.GetTopSkusByNoCityCode(db)
|
||||
}
|
||||
if storeID > 0 {
|
||||
var skuNameList []*model.SkuName
|
||||
//不可售的商品nameID列表
|
||||
@@ -3350,7 +3355,8 @@ func AutoFocusStoreSkusForTopSkus(ctx *jxcontext.Context, isAsync, isContinueWhe
|
||||
for _, name := range skuName {
|
||||
skuNameMap[name.ID] = name.ID
|
||||
}
|
||||
skuNameAndPlaceList, err2 := GetTopSkusByCityCode(ctx, v.CityCode, 0)
|
||||
skuNameAndPlaceList, err2 := GetTopSkusByCityCode(ctx, 0, 0)
|
||||
//skuNameAndPlaceList, err2 := GetTopSkusByCityCode(ctx, v.CityCode, 0)
|
||||
if err2 != nil {
|
||||
return retVal, err2
|
||||
}
|
||||
|
||||
@@ -2,9 +2,6 @@ package cms
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"git.rosy.net.cn/baseapi/platformapi/mtpsapi"
|
||||
"git.rosy.net.cn/jx-callback/globals/api"
|
||||
"strconv"
|
||||
"strings"
|
||||
"sync"
|
||||
"time"
|
||||
@@ -562,91 +559,92 @@ func CompareJxAndMultiVenderDepot(ctx *jxcontext.Context, vendorMap map[int]bool
|
||||
}
|
||||
|
||||
func StoreOpenAll(ctx *jxcontext.Context) {
|
||||
globals.SugarLogger.Debug("StoreOpenAll skuID is start")
|
||||
/*获取美团门店信息*/
|
||||
StoreInfoList, _ := api.MtpsAPI.GetStoreStatusAll()
|
||||
StoreInfoList2 := make(map[string]string)
|
||||
for _, store := range StoreInfoList {
|
||||
for _, data := range store.DataList {
|
||||
StoreInfoList2[data.OuterPoiID] = data.PoiName
|
||||
}
|
||||
}
|
||||
db := dao.GetDB()
|
||||
/*比较营业状态*/
|
||||
/*把获取的京西状态和名称存一下*/
|
||||
StoreCourierList, _ := dao.GetStoreCourierList(db, []int{}, model.StoreStatusAll, model.StoreStatusAll)
|
||||
/*循环美团*/
|
||||
for _, StoreInfoList1 := range StoreInfoList {
|
||||
for _, StoreInfoList11 := range StoreInfoList1.DataList {
|
||||
/*循环京西*/
|
||||
for _, StoreCourierList1 := range StoreCourierList {
|
||||
/*只比较美团*/
|
||||
if StoreCourierList1.VendorID != model.VendorIDMTPS {
|
||||
continue
|
||||
}
|
||||
/*如果门店ID相同的时候进入判断,一个门店只用判断一次就行*/
|
||||
if StoreCourierList1.VendorStoreID == StoreInfoList11.OuterPoiID {
|
||||
if StoreCourierList1.Status != StoreInfoList11.OpenType {
|
||||
sl := make(map[string]interface{})
|
||||
sl["vendorStoreID"] = StoreInfoList11.OuterPoiID
|
||||
sl["status"] = StoreInfoList11.OpenType
|
||||
sl["vendorStatus"] = StoreInfoList11.OpenType
|
||||
globals.SugarLogger.Debugf("被修改配送状态的VendorStoreID是:%s,名称是:%s,美团状态是:%s,本地状态是:%s",
|
||||
StoreInfoList11.OuterPoiID, StoreInfoList11.PoiName, strconv.Itoa(StoreInfoList11.OpenType), strconv.Itoa(StoreCourierList1.Status))
|
||||
UpdateStoreCourierMap(ctx, nil, StoreCourierList1.StoreID, StoreCourierList1.VendorID, sl, ctx.GetUserName())
|
||||
break
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
/* 美团配送的门店是否存在,调用美团配送的api(有可能接了),查询京西门店对应的美团配送门店是否存在,若不存在则要在京西这边解绑美团配送门店
|
||||
怎么解绑可以在网页上门店管理那点一下看看调的什么接口,传的什么参数*/
|
||||
/*获取所有门店信息*/
|
||||
//test:
|
||||
for _, StoreCourierList1 := range StoreCourierList {
|
||||
diff := false
|
||||
StoreLists, _ := dao.GetStoreList(db, []int{StoreCourierList1.StoreID}, nil, nil, nil, "")
|
||||
if StoreLists == nil {
|
||||
globals.SugarLogger.Debugf("StoreID为:%s,在store表未找到", StoreCourierList1.StoreID)
|
||||
continue
|
||||
}
|
||||
if StoreCourierList1.VendorID != model.VendorIDMTPS || StoreCourierList1.VendorStoreID == "" {
|
||||
continue
|
||||
}
|
||||
if StoreCourierList1.Status == model.StoreStatusDisabled || StoreCourierList1.Status == model.StoreStatusClosed {
|
||||
continue
|
||||
}
|
||||
/*京西不为空,容错*/
|
||||
//if {
|
||||
/*调用API获取美团的商店信息*/
|
||||
MTPSInfo := new(mtpsapi.ShopInfo)
|
||||
MTPSInfo, _ = api.MtpsAPI.ShopQuery(StoreCourierList1.VendorStoreID)
|
||||
if MTPSInfo == nil {
|
||||
globals.SugarLogger.Debug("美团未找到该门店," + StoreLists[0].Name + strconv.Itoa(StoreCourierList1.StoreID) + " 被解绑,关联的ID为:" + StoreCourierList1.VendorStoreID)
|
||||
diff = true
|
||||
}
|
||||
if MTPSInfo != nil && MTPSInfo.ShopName == "" {
|
||||
MTPSInfo.ShopName = StoreInfoList2[MTPSInfo.ShopID]
|
||||
}
|
||||
if MTPSInfo != nil && MTPSInfo.ShopLng != StoreCourierList1.Lng && MTPSInfo.ShopLat == StoreCourierList1.Lat {
|
||||
/*平台上但是坐标不同,解绑*/
|
||||
globals.SugarLogger.Debug("商店与美团配送上的坐标不同," + StoreLists[0].Name + strconv.Itoa(StoreCourierList1.StoreID) + " 被解绑,关联的ID为:" + StoreCourierList1.VendorStoreID)
|
||||
if _, err := DeleteStoreCourierMap(ctx, db, StoreCourierList1.StoreID, StoreCourierList1.VendorID, ctx.GetUserName()); err != nil {
|
||||
globals.SugarLogger.Debug(err.Error())
|
||||
return
|
||||
}
|
||||
diff = true
|
||||
}
|
||||
if diff {
|
||||
if _, err := DeleteStoreCourierMap(ctx, db, StoreCourierList1.StoreID, StoreCourierList1.VendorID, ctx.GetUserName()); err != nil {
|
||||
globals.SugarLogger.Debug(err.Error())
|
||||
return
|
||||
}
|
||||
//break test
|
||||
}
|
||||
}
|
||||
globals.SugarLogger.Debug("StoreOpenAll skuID is Complete")
|
||||
AutoFocusStoreSkusForTopSkus(ctx, true, true)
|
||||
//globals.SugarLogger.Debug("StoreOpenAll skuID is start")
|
||||
///*获取美团门店信息*/
|
||||
//StoreInfoList, _ := api.MtpsAPI.GetStoreStatusAll()
|
||||
//StoreInfoList2 := make(map[string]string)
|
||||
//for _, store := range StoreInfoList {
|
||||
// for _, data := range store.DataList {
|
||||
// StoreInfoList2[data.OuterPoiID] = data.PoiName
|
||||
// }
|
||||
//}
|
||||
//db := dao.GetDB()
|
||||
///*比较营业状态*/
|
||||
///*把获取的京西状态和名称存一下*/
|
||||
//StoreCourierList, _ := dao.GetStoreCourierList(db, []int{}, model.StoreStatusAll, model.StoreStatusAll)
|
||||
///*循环美团*/
|
||||
//for _, StoreInfoList1 := range StoreInfoList {
|
||||
// for _, StoreInfoList11 := range StoreInfoList1.DataList {
|
||||
// /*循环京西*/
|
||||
// for _, StoreCourierList1 := range StoreCourierList {
|
||||
// /*只比较美团*/
|
||||
// if StoreCourierList1.VendorID != model.VendorIDMTPS {
|
||||
// continue
|
||||
// }
|
||||
// /*如果门店ID相同的时候进入判断,一个门店只用判断一次就行*/
|
||||
// if StoreCourierList1.VendorStoreID == StoreInfoList11.OuterPoiID {
|
||||
// if StoreCourierList1.Status != StoreInfoList11.OpenType {
|
||||
// sl := make(map[string]interface{})
|
||||
// sl["vendorStoreID"] = StoreInfoList11.OuterPoiID
|
||||
// sl["status"] = StoreInfoList11.OpenType
|
||||
// sl["vendorStatus"] = StoreInfoList11.OpenType
|
||||
// globals.SugarLogger.Debugf("被修改配送状态的VendorStoreID是:%s,名称是:%s,美团状态是:%s,本地状态是:%s",
|
||||
// StoreInfoList11.OuterPoiID, StoreInfoList11.PoiName, strconv.Itoa(StoreInfoList11.OpenType), strconv.Itoa(StoreCourierList1.Status))
|
||||
// UpdateStoreCourierMap(ctx, nil, StoreCourierList1.StoreID, StoreCourierList1.VendorID, sl, ctx.GetUserName())
|
||||
// break
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
//}
|
||||
///* 美团配送的门店是否存在,调用美团配送的api(有可能接了),查询京西门店对应的美团配送门店是否存在,若不存在则要在京西这边解绑美团配送门店
|
||||
// 怎么解绑可以在网页上门店管理那点一下看看调的什么接口,传的什么参数*/
|
||||
///*获取所有门店信息*/
|
||||
////test:
|
||||
//for _, StoreCourierList1 := range StoreCourierList {
|
||||
// diff := false
|
||||
// StoreLists, _ := dao.GetStoreList(db, []int{StoreCourierList1.StoreID}, nil, nil, nil, "")
|
||||
// if StoreLists == nil {
|
||||
// globals.SugarLogger.Debugf("StoreID为:%s,在store表未找到", StoreCourierList1.StoreID)
|
||||
// continue
|
||||
// }
|
||||
// if StoreCourierList1.VendorID != model.VendorIDMTPS || StoreCourierList1.VendorStoreID == "" {
|
||||
// continue
|
||||
// }
|
||||
// if StoreCourierList1.Status == model.StoreStatusDisabled || StoreCourierList1.Status == model.StoreStatusClosed {
|
||||
// continue
|
||||
// }
|
||||
// /*京西不为空,容错*/
|
||||
// //if {
|
||||
// /*调用API获取美团的商店信息*/
|
||||
// MTPSInfo := new(mtpsapi.ShopInfo)
|
||||
// MTPSInfo, _ = api.MtpsAPI.ShopQuery(StoreCourierList1.VendorStoreID)
|
||||
// if MTPSInfo == nil {
|
||||
// globals.SugarLogger.Debug("美团未找到该门店," + StoreLists[0].Name + strconv.Itoa(StoreCourierList1.StoreID) + " 被解绑,关联的ID为:" + StoreCourierList1.VendorStoreID)
|
||||
// diff = true
|
||||
// }
|
||||
// if MTPSInfo != nil && MTPSInfo.ShopName == "" {
|
||||
// MTPSInfo.ShopName = StoreInfoList2[MTPSInfo.ShopID]
|
||||
// }
|
||||
// if MTPSInfo != nil && MTPSInfo.ShopLng != StoreCourierList1.Lng && MTPSInfo.ShopLat == StoreCourierList1.Lat {
|
||||
// /*平台上但是坐标不同,解绑*/
|
||||
// globals.SugarLogger.Debug("商店与美团配送上的坐标不同," + StoreLists[0].Name + strconv.Itoa(StoreCourierList1.StoreID) + " 被解绑,关联的ID为:" + StoreCourierList1.VendorStoreID)
|
||||
// if _, err := DeleteStoreCourierMap(ctx, db, StoreCourierList1.StoreID, StoreCourierList1.VendorID, ctx.GetUserName()); err != nil {
|
||||
// globals.SugarLogger.Debug(err.Error())
|
||||
// return
|
||||
// }
|
||||
// diff = true
|
||||
// }
|
||||
// if diff {
|
||||
// if _, err := DeleteStoreCourierMap(ctx, db, StoreCourierList1.StoreID, StoreCourierList1.VendorID, ctx.GetUserName()); err != nil {
|
||||
// globals.SugarLogger.Debug(err.Error())
|
||||
// return
|
||||
// }
|
||||
// //break test
|
||||
// }
|
||||
//}
|
||||
//globals.SugarLogger.Debug("StoreOpenAll skuID is Complete")
|
||||
}
|
||||
|
||||
//func StoreOpenAll(ctx *jxcontext.Context) {
|
||||
|
||||
@@ -200,6 +200,10 @@ var (
|
||||
AfsAppealTypeReturnAndRefund: "退款", // 这个其实是退货退款,强制显示成退款
|
||||
AfsAppealTypeNewGoods: "退款.", // 这个其实是重发商品,强制显示成退款
|
||||
}
|
||||
VendorStatus = map[int]string{
|
||||
0: "休息",
|
||||
1: "营业",
|
||||
}
|
||||
)
|
||||
|
||||
const (
|
||||
|
||||
@@ -998,8 +998,8 @@ func GetStoreSkusByNameIDs(db *DaoDB, storeIDs []int, nameID int) (skuList []*St
|
||||
sqlParams = append(sqlParams, storeIDs)
|
||||
}
|
||||
sql += ` AND a.status != ?
|
||||
ORDER BY a.updated_at DESC
|
||||
`
|
||||
ORDER BY a.updated_at DESC
|
||||
`
|
||||
sqlParams = append(sqlParams, model.SkuStatusDeleted)
|
||||
err = GetRows(db, &skuList, sql, sqlParams...)
|
||||
return skuList, err
|
||||
@@ -1672,6 +1672,18 @@ func GetStoreSkuAuditLight(db *DaoDB, storeIDs, nameIDs []int, status int) (stor
|
||||
return storeSkuAudit, err
|
||||
}
|
||||
|
||||
func GetTopSkusByNoCityCode(db *DaoDB) (skuNameAndPlace []*SkuNameAndPlace, err error) {
|
||||
var skuName1 []model.SkuName
|
||||
_, err = db.Db.QueryTable("sku_name").Filter("best_seller", "1").All(&skuName1)
|
||||
for k, _ := range skuName1 {
|
||||
skuNameAndPlace1 := &SkuNameAndPlace{
|
||||
SkuName: skuName1[k],
|
||||
}
|
||||
skuNameAndPlace = append(skuNameAndPlace, skuNameAndPlace1)
|
||||
}
|
||||
return skuNameAndPlace, err
|
||||
}
|
||||
|
||||
func GetStoreSkuHistory(db *DaoDB, storeIDs, skuIDs []int, status int, snapShot time.Time) (storeSkuHistory []*model.StoreSkuBindHistory, err error) {
|
||||
sql := `
|
||||
SELECT a.*
|
||||
|
||||
@@ -51,7 +51,8 @@ const (
|
||||
FieldActID = "ActID"
|
||||
FieldVendorActID = "VendorActID"
|
||||
|
||||
FieldSkuSeq = "Seq"
|
||||
FieldSkuSeq = "Seq"
|
||||
FieldVendorStatus = "VendorStatus"
|
||||
)
|
||||
|
||||
type ModelIDCUL struct {
|
||||
|
||||
@@ -194,6 +194,7 @@ type SkuName struct {
|
||||
YbNameSuffix string `json:"ybNameSuffix"` //银豹商品后缀
|
||||
JdsStockSwitch int8 `orm:"default(1)" json:"jdsStockSwitch"` //京东商城总库存
|
||||
PreparationTime int `orm:"default(1)" json:"preparationTime"` //商品准备时长
|
||||
BestSeller int `json:"bestSeller"` //畅销品 0不是 1是
|
||||
}
|
||||
|
||||
func (*SkuName) TableUnique() [][]string {
|
||||
|
||||
@@ -499,7 +499,7 @@ func (c *StoreSkuController) GetTopSkusByStoreIDs() {
|
||||
// @Title 根据城市信息查找推荐商品(按销量)
|
||||
// @Description 根据城市信息查找推荐商品(按销量)
|
||||
// @Param token header string true "认证token"
|
||||
// @Param cityCode query int true "城市id"
|
||||
// @Param cityCode query int false "城市id"
|
||||
// @Param storeID query int false "门店id"
|
||||
// @Success 200 {object} controllers.CallResult
|
||||
// @Failure 200 {object} controllers.CallResult
|
||||
|
||||
Reference in New Issue
Block a user