Merge branch 'mark' of e.coding.net:rosydev/jx-callback into mark

This commit is contained in:
gazebo
2019-11-29 15:06:38 +08:00
2 changed files with 23 additions and 16 deletions

View File

@@ -11,6 +11,7 @@ import (
"mime/multipart" "mime/multipart"
"net/http" "net/http"
"regexp" "regexp"
"sort"
"strings" "strings"
"sync" "sync"
"time" "time"
@@ -49,6 +50,7 @@ var (
titleList = []string{ titleList = []string{
"用户名", "用户名",
"关联门店", "关联门店",
"状态",
} }
) )
@@ -60,6 +62,7 @@ type GetJdUsersStruct struct {
type JdUserStruct struct { type JdUserStruct struct {
UserName string `json:"用户名"` UserName string `json:"用户名"`
StoreIDs string `json:"关联门店"` StoreIDs string `json:"关联门店"`
Status string `json:"状态"`
} }
func init() { func init() {
@@ -1473,20 +1476,19 @@ func GetJdUsers(ctx *jxcontext.Context, isAsync, isContinueWhenError bool) (hint
pageNoList []int pageNoList []int
storeUserList []interface{} storeUserList []interface{}
) )
//获取京东有效的店
db := dao.GetDB() db := dao.GetDB()
//获取京东商城所有用户
_, _, toatlPage, _ := api.JdAPI.PrivilegeSearchUser(1)
for i := 1; i <= toatlPage; i++ {
pageNoList = append(pageNoList, i)
}
storeMapList, err := dao.GetStoreMapsListWithoutDisabled(db, []int{model.VendorIDJD}, model.StoreStatusDisabled) storeMapList, err := dao.GetStoreMapsListWithoutDisabled(db, []int{model.VendorIDJD}, model.StoreStatusDisabled)
for _, v := range storeMapList { for _, v := range storeMapList {
jxVendorIDsMap[v.VendorStoreID] = v.VendorStoreID jxVendorIDsMap[v.VendorStoreID] = utils.Int64ToStr(int64(v.StoreID))
} }
taskSeqFunc := func(task *tasksch.SeqTask, step int, params ...interface{}) (result interface{}, err error) { taskSeqFunc := func(task *tasksch.SeqTask, step int, params ...interface{}) (result interface{}, err error) {
switch step { switch step {
case 0: case 0:
//获取京东商城所有用户
_, _, toatlPage, _ := api.JdAPI.PrivilegeSearchUser(1)
for i := 1; i <= toatlPage; i++ {
pageNoList = append(pageNoList, i)
}
taskFunc1 := func(task *tasksch.ParallelTask, batchItemList []interface{}, params ...interface{}) (retVal interface{}, err error) { taskFunc1 := func(task *tasksch.ParallelTask, batchItemList []interface{}, params ...interface{}) (retVal interface{}, err error) {
pageNo := batchItemList[0].(int) pageNo := batchItemList[0].(int)
storeUserLists, _, _, err := api.JdAPI.PrivilegeSearchUser(pageNo) storeUserLists, _, _, err := api.JdAPI.PrivilegeSearchUser(pageNo)
@@ -1506,16 +1508,17 @@ func GetJdUsers(ctx *jxcontext.Context, isAsync, isContinueWhenError bool) (hint
if jxVendorIDsMap[v] == "" { if jxVendorIDsMap[v] == "" {
continue continue
} }
vendorStoreIDsMap[v] = v vendorStoreIDsMap[v] = jxVendorIDsMap[v]
} }
if len(vendorStoreIDsMap) == 0 { if len(vendorStoreIDsMap) == 0 {
jdStruct := JdUserStruct{vv.LoginName, ""} jdStruct := JdUserStruct{vv.LoginName, "", vv.LockStatus}
jdUsersStruct.AppendData(jdStruct) jdUsersStruct.AppendData(jdStruct)
} else { } else {
for _, m := range vendorStoreIDsMap { for _, m := range vendorStoreIDsMap {
vendorStoreIDsResult = append(vendorStoreIDsResult, m) vendorStoreIDsResult = append(vendorStoreIDsResult, m)
} }
jdStruct := JdUserStruct{vv.LoginName, strings.Join(vendorStoreIDsResult, ",")} sort.Strings(vendorStoreIDsResult[:])
jdStruct := JdUserStruct{vv.LoginName, strings.Join(vendorStoreIDsResult, ","), vv.LockStatus}
jdUsersStruct.AppendData(jdStruct) jdUsersStruct.AppendData(jdStruct)
} }
return retVal, err return retVal, err

View File

@@ -235,14 +235,15 @@ func LoadExcelByYongHui(ctx *jxcontext.Context, files []*multipart.FileHeader, i
func LoadExcelBinByYongHui(ctx *jxcontext.Context, reader io.Reader, isAsync, isContinueWhenError bool) (hint string, err error) { func LoadExcelBinByYongHui(ctx *jxcontext.Context, reader io.Reader, isAsync, isContinueWhenError bool) (hint string, err error) {
var ( var (
skuMap = make(map[string]*ExcelParam) skuMap = make(map[string]*ExcelParam)
errMsg string
costPrice float64 //成本价 costPrice float64 //成本价
goodsList []*weimobapi.GoodsInfo goodsList []*weimobapi.GoodsInfo
goodsIDListForPutAway []interface{} goodsIDListForPutAway []interface{}
isCompare bool isCompare bool
isExecute = false
) )
db := dao.GetDB() db := dao.GetDB()
taskSeqFunc := func(task *tasksch.SeqTask, step int, params ...interface{}) (result interface{}, err error) { taskSeqFunc := func(task *tasksch.SeqTask, step int, params ...interface{}) (result interface{}, err error) {
var errMsg string
switch step { switch step {
case 0: case 0:
//读取excel文件 //读取excel文件
@@ -261,6 +262,11 @@ func LoadExcelBinByYongHui(ctx *jxcontext.Context, reader io.Reader, isAsync, is
// 分类名格式为可定XX日 // 分类名格式为可定XX日
// XX为上传永辉 提供的 价格表时间 +2天 // XX为上传永辉 提供的 价格表时间 +2天
if errMsg == "" { if errMsg == "" {
isExecute = true
} else {
err = fmt.Errorf(errMsg)
}
if isExecute {
isCompare, err = UpdateClassifyAndGetLastClassify() isCompare, err = UpdateClassifyAndGetLastClassify()
} }
case 1: case 1:
@@ -326,7 +332,7 @@ func LoadExcelBinByYongHui(ctx *jxcontext.Context, reader io.Reader, isAsync, is
} else { } else {
costPrice = skuMap[spuCode].Price costPrice = skuMap[spuCode].Price
} }
if errMsg == "" { if isExecute {
_, _, _ = updateWeiMobGoods(costPrice, skuMap[spuCode].Price, skuList[0].Unit, isCompare, goodsDetail) _, _, _ = updateWeiMobGoods(costPrice, skuMap[spuCode].Price, skuList[0].Unit, isCompare, goodsDetail)
} }
} }
@@ -351,7 +357,7 @@ func LoadExcelBinByYongHui(ctx *jxcontext.Context, reader io.Reader, isAsync, is
for _, v := range batchItemList { for _, v := range batchItemList {
int64Slice = append(int64Slice, v.(int64)) int64Slice = append(int64Slice, v.(int64))
} }
if errMsg == "" { if isExecute {
PutAwayWeiMobSku(int64Slice) PutAwayWeiMobSku(int64Slice)
} }
return retVal, err return retVal, err
@@ -362,9 +368,7 @@ func LoadExcelBinByYongHui(ctx *jxcontext.Context, reader io.Reader, isAsync, is
case 4: case 4:
WriteToExcel(task, dataSuccess.dataSuccessList, dataFailed.dataFailedList) WriteToExcel(task, dataSuccess.dataSuccessList, dataFailed.dataFailedList)
} }
if errMsg != "" {
return result, errors.New(errMsg)
}
return result, err return result, err
} }
taskSeq := tasksch.NewSeqTask2("读取永辉Excel文件修改微盟商品价格可售状态-序列任务", ctx, isContinueWhenError, taskSeqFunc, 5) taskSeq := tasksch.NewSeqTask2("读取永辉Excel文件修改微盟商品价格可售状态-序列任务", ctx, isContinueWhenError, taskSeqFunc, 5)