解决冲突,合并提交
This commit is contained in:
@@ -103,10 +103,7 @@ func GetServiceInfo(ctx *jxcontext.Context) interface{} {
|
||||
func GetQiniuUploadToken(ctx *jxcontext.Context, suffix, hashCode string) (upTokenInfo map[string]interface{}, err error) {
|
||||
imgURL := ""
|
||||
if hashCode != "" {
|
||||
db := dao.GetDB()
|
||||
if skuName, err := dao.GetSkuNameByHashCode(db, hashCode); err == nil {
|
||||
imgURL = skuName.Img
|
||||
}
|
||||
imgURL, _ = GetDataResource(ctx, hashCode)
|
||||
}
|
||||
|
||||
putPolicy := storage.PutPolicy{
|
||||
@@ -123,6 +120,51 @@ func GetQiniuUploadToken(ctx *jxcontext.Context, suffix, hashCode string) (upTok
|
||||
return upTokenInfo, err
|
||||
}
|
||||
|
||||
func RegisterDataResource(ctx *jxcontext.Context, name, resourceURL, mimeType, hashCode string) (dataRes *model.DataResource, err error) {
|
||||
if model.ValideMimeTypes[mimeType] == 0 {
|
||||
return nil, fmt.Errorf("MIME type:%s非法", mimeType)
|
||||
}
|
||||
dataRes = &model.DataResource{
|
||||
Name: name,
|
||||
HashCode: hashCode,
|
||||
ResoureType: mimeType,
|
||||
MainURL: resourceURL,
|
||||
}
|
||||
vendorID := jxutils.GuessDataResourceVendor(resourceURL)
|
||||
switch vendorID {
|
||||
case model.VendorIDQiNiuCloud:
|
||||
dataRes.QiniuURL = resourceURL
|
||||
case model.VendorIDEBAI:
|
||||
dataRes.EbaiURL = resourceURL
|
||||
case model.VendorIDMTWM:
|
||||
dataRes.MtwmURL = resourceURL
|
||||
}
|
||||
|
||||
dao.WrapAddIDCULEntity(dataRes, ctx.GetUserName())
|
||||
if err = dao.CreateEntity(dao.GetDB(), dataRes); err != nil {
|
||||
dataRes = nil
|
||||
}
|
||||
return dataRes, err
|
||||
}
|
||||
|
||||
func GetDataResource(ctx *jxcontext.Context, hashCode string) (resourceURL string, err error) {
|
||||
db := dao.GetDB()
|
||||
dataRes, err := dao.GetDataResource(db, hashCode, "")
|
||||
if err != nil {
|
||||
if dao.IsNoRowsError(err) {
|
||||
skuName, err2 := dao.GetSkuNameByHashCode(db, hashCode)
|
||||
if err = err2; err == nil {
|
||||
resourceURL = skuName.Img
|
||||
} else if dao.IsNoRowsError(err) {
|
||||
err = nil
|
||||
}
|
||||
}
|
||||
} else {
|
||||
resourceURL = dataRes.MainURL
|
||||
}
|
||||
return resourceURL, err
|
||||
}
|
||||
|
||||
func GetPlaces(ctx *jxcontext.Context, keyword string, includeDisabled bool, params map[string]interface{}) ([]*model.Place, error) {
|
||||
sql := `
|
||||
SELECT *
|
||||
|
||||
@@ -4,6 +4,7 @@ import (
|
||||
"fmt"
|
||||
"testing"
|
||||
|
||||
"git.rosy.net.cn/baseapi/utils"
|
||||
"git.rosy.net.cn/jx-callback/business/jxutils/jxcontext"
|
||||
"git.rosy.net.cn/jx-callback/globals/api2"
|
||||
"git.rosy.net.cn/jx-callback/globals/testinit"
|
||||
@@ -27,3 +28,11 @@ func TestGetQiniuUploadToken(t *testing.T) {
|
||||
}
|
||||
fmt.Print(token)
|
||||
}
|
||||
|
||||
func TestGetDataResource(t *testing.T) {
|
||||
dataRes, err := GetDataResource(jxcontext.AdminCtx, "1D3E4A8259F359FB4CF47D541843950D")
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
t.Log(utils.Format4Output(dataRes, false))
|
||||
}
|
||||
|
||||
@@ -4,6 +4,7 @@ import (
|
||||
"errors"
|
||||
"fmt"
|
||||
"math"
|
||||
"sort"
|
||||
"strconv"
|
||||
"strings"
|
||||
"time"
|
||||
@@ -1561,6 +1562,28 @@ func getAllUsers4Store(ctx *jxcontext.Context, db *dao.DaoDB, store *model.Store
|
||||
return userList
|
||||
}
|
||||
|
||||
type tStoreIDList struct {
|
||||
StoreIDList []int
|
||||
StoreMap map[int]*model.Store
|
||||
}
|
||||
|
||||
func (l *tStoreIDList) Len() int {
|
||||
return len(l.StoreIDList)
|
||||
}
|
||||
|
||||
func (l *tStoreIDList) Less(i, j int) bool {
|
||||
storei := l.StoreMap[l.StoreIDList[i]]
|
||||
storej := l.StoreMap[l.StoreIDList[j]]
|
||||
if storei.CityCode == storej.CityCode {
|
||||
return storei.ID < storej.ID
|
||||
}
|
||||
return storei.CityCode < storej.CityCode
|
||||
}
|
||||
|
||||
func (l *tStoreIDList) Swap(i, j int) {
|
||||
l.StoreIDList[i], l.StoreIDList[j] = l.StoreIDList[j], l.StoreIDList[i]
|
||||
}
|
||||
|
||||
func SendAlarmVendorSnapshot(ctx *jxcontext.Context, parentTask tasksch.ITask, prevSnapshotList, curSnapshotList []*model.VendorStoreSnapshot) (err error) {
|
||||
if len(prevSnapshotList) == 0 {
|
||||
return nil
|
||||
@@ -1646,17 +1669,37 @@ func SendAlarmVendorSnapshot(ctx *jxcontext.Context, parentTask tasksch.ITask, p
|
||||
}
|
||||
|
||||
if len(userList) > 0 {
|
||||
allStores, err := dao.GetStoreList(db, nil, nil, "")
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
allStoreMap := make(map[int]*model.Store)
|
||||
for _, v := range allStores {
|
||||
allStoreMap[v.ID] = v
|
||||
}
|
||||
|
||||
const fixTitle = "门店状态变化"
|
||||
title := fmt.Sprintf("%s:%s-->%s", fixTitle, utils.Time2Str(prevSnapshotList[0].SnapshotAt), utils.Time2Str(curSnapshotList[0].SnapshotAt))
|
||||
task := tasksch.NewParallelTask("SendAlarmVendorSnapshot", tasksch.NewParallelConfig().SetIsContinueWhenError(true), ctx,
|
||||
func(task *tasksch.ParallelTask, batchItemList []interface{}, params ...interface{}) (retVal interface{}, err error) {
|
||||
user := batchItemList[0].(*model.User)
|
||||
if user.GetMobile() != "18048531223" {
|
||||
return nil, nil
|
||||
}
|
||||
var excelURL string
|
||||
if user.Type&model.UserTypeOperator != 0 {
|
||||
var dataList []map[string]interface{}
|
||||
captionList := []string{"京西门店ID", "门店名", "城市"}
|
||||
isFirstRow := true
|
||||
|
||||
storeIDList := &tStoreIDList{
|
||||
StoreMap: allStoreMap,
|
||||
}
|
||||
for storeID := range userMap[user.GetID()] {
|
||||
storeIDList.StoreIDList = append(storeIDList.StoreIDList, storeID)
|
||||
}
|
||||
sort.Sort(storeIDList)
|
||||
for _, storeID := range storeIDList.StoreIDList {
|
||||
prevAlarmMap := prevSnapshotMap2[storeID]
|
||||
curAlarmMap := curSnapshotMap2[storeID]
|
||||
data := map[string]interface{}{
|
||||
@@ -1789,7 +1832,6 @@ func SaveAndSendAlarmVendorSnapshot(ctx *jxcontext.Context, vendorIDs, storeIDs
|
||||
err = SaveStoresVendorSnapshot(db, curSnapshotAt, curSnapshotList)
|
||||
case 2:
|
||||
prevSnapshotList, err = dao.GetVendorStoreSnapshot(db, prevSnapshotAt)
|
||||
curSnapshotList, err = dao.GetVendorStoreSnapshot(db, curSnapshotAt) // 因为排序的原因,重新取一下
|
||||
case 3:
|
||||
err = SendAlarmVendorSnapshot(ctx, task, prevSnapshotList, curSnapshotList)
|
||||
}
|
||||
|
||||
@@ -20,8 +20,8 @@ func TestGetStoresVendorSnapshot(t *testing.T) {
|
||||
|
||||
func TestSendAlarmVendorSnapshot(t *testing.T) {
|
||||
db := dao.GetDB()
|
||||
prevSnapshotList, _ := dao.GetVendorStoreSnapshot(db, utils.Str2Time("2019-09-09 10:00:00"))
|
||||
curSnapshotList, _ := dao.GetVendorStoreSnapshot(db, utils.Str2Time("2019-09-09 11:00:00"))
|
||||
prevSnapshotList, _ := dao.GetVendorStoreSnapshot(db, utils.Str2Time("2019-09-17 08:00:00"))
|
||||
curSnapshotList, _ := dao.GetVendorStoreSnapshot(db, utils.Str2Time("2019-09-17 10:00:00"))
|
||||
err := SendAlarmVendorSnapshot(jxcontext.AdminCtx, nil, prevSnapshotList, curSnapshotList)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
|
||||
@@ -336,8 +336,12 @@ func syncStoreSkuNew(ctx *jxcontext.Context, parentTask tasksch.ITask, isFull bo
|
||||
offlineList = append(offlineList, bareSku)
|
||||
}
|
||||
} else {
|
||||
if sku.MergedStatus == model.SkuStatusNormal /*&& !dao.IsVendorThingIDEmpty(sku.VendorCatID)*/ {
|
||||
createList = append(createList, sku)
|
||||
if sku.MergedStatus == model.SkuStatusNormal {
|
||||
if dao.IsVendorThingIDEmpty(sku.VendorCatID) {
|
||||
globals.SugarLogger.Warnf("syncStoreSkuNew 创建门店:%d商品:%d,但没有平台分类ID", sku.StoreID, sku.SkuID)
|
||||
} else {
|
||||
createList = append(createList, sku)
|
||||
}
|
||||
}
|
||||
}
|
||||
isNeedReorder = true
|
||||
@@ -351,9 +355,13 @@ func syncStoreSkuNew(ctx *jxcontext.Context, parentTask tasksch.ITask, isFull bo
|
||||
} else {
|
||||
isAdded2Update := false
|
||||
// 修改商品信息时不改价(以免活动引起的失败),而用单独的改价来改
|
||||
if (model.IsSyncStatusUpdate(sku.StoreSkuSyncStatus) || (model.IsSyncStatusSec(sku.StoreSkuSyncStatus) && reorderHandler == nil)) && singleStoreHandler != nil {
|
||||
isAdded2Update = true
|
||||
updateList = append(updateList, calVendorPrice4StoreSku(sku, storeDetail.PricePercentagePackObj, int(storeDetail.PricePercentage)))
|
||||
if (model.IsSyncStatusUpdate(sku.StoreSkuSyncStatus) || (model.IsSyncStatusSeq(sku.StoreSkuSyncStatus) && reorderHandler == nil)) && singleStoreHandler != nil {
|
||||
if dao.IsVendorThingIDEmpty(sku.VendorCatID) {
|
||||
globals.SugarLogger.Warnf("syncStoreSkuNew 修改门店:%d商品:%d,但没有平台分类ID", sku.StoreID, sku.SkuID)
|
||||
} else {
|
||||
isAdded2Update = true
|
||||
updateList = append(updateList, calVendorPrice4StoreSku(sku, storeDetail.PricePercentagePackObj, int(storeDetail.PricePercentage)))
|
||||
}
|
||||
}
|
||||
if model.IsSyncStatusPrice(sku.StoreSkuSyncStatus) {
|
||||
bareSku = storeSkuSyncInfo2Bare(calVendorPrice4StoreSku(sku, storeDetail.PricePercentagePackObj, int(storeDetail.PricePercentage)))
|
||||
@@ -378,7 +386,7 @@ func syncStoreSkuNew(ctx *jxcontext.Context, parentTask tasksch.ITask, isFull bo
|
||||
}
|
||||
}
|
||||
}
|
||||
isNeedReorder = model.IsSyncStatusSec(sku.StoreSkuSyncStatus)
|
||||
isNeedReorder = model.IsSyncStatusSeq(sku.StoreSkuSyncStatus)
|
||||
}
|
||||
}
|
||||
if isNeedReorder && reorderHandler != nil && sku.VendorCatID != "" {
|
||||
|
||||
Reference in New Issue
Block a user