Merge remote-tracking branch 'origin/mark' into su
This commit is contained in:
@@ -157,7 +157,7 @@ func getFixedTokenName(token string) *AuthInfo {
|
||||
}
|
||||
|
||||
func createAuthInfo(user IUser, authBindInfo *AuthBindEx) (authInfo *AuthInfo) {
|
||||
token, tokenType := createToken(user)
|
||||
token, tokenType := createToken(user, authBindInfo)
|
||||
expireDuration := DefTokenDuration
|
||||
authInfo = &AuthInfo{
|
||||
AuthBindInfo: authBindInfo,
|
||||
@@ -378,9 +378,9 @@ func ClearUserToken(userID string) {
|
||||
|
||||
/////////////
|
||||
|
||||
func createToken(user IUser) (token string, tokenType int) {
|
||||
func createToken(user IUser, authBindInfo *AuthBindEx) (token string, tokenType int) {
|
||||
userID := TokenUserEmpty
|
||||
userName := TokenUserEmpty
|
||||
userName := authBindInfo.AuthID
|
||||
tokenType = TokenTypeOnlyAuth
|
||||
if user != nil {
|
||||
userID = user.GetID()
|
||||
@@ -392,8 +392,9 @@ func createToken(user IUser) (token string, tokenType int) {
|
||||
TokenVer,
|
||||
userID,
|
||||
time.Now().Format("20060102-150405"),
|
||||
userName,
|
||||
authBindInfo.Type,
|
||||
utils.GetUUID(),
|
||||
userName,
|
||||
}, TokenTypeSep), tokenType
|
||||
}
|
||||
|
||||
@@ -404,7 +405,7 @@ func GetTokenType(token string) (tokenType int) {
|
||||
tokenType = TokenTypeNone
|
||||
if token != "" {
|
||||
tokenPartList := strings.Split(token, TokenTypeSep)
|
||||
if (len(tokenPartList) == 1) || (len(tokenPartList) == 6 && tokenPartList[2] != TokenUserEmpty) {
|
||||
if (len(tokenPartList) == 1) || (len(tokenPartList) >= 6 && tokenPartList[2] != TokenUserEmpty) {
|
||||
tokenType = TokenTypeNormal
|
||||
} else {
|
||||
tokenType = TokenTypeOnlyAuth
|
||||
|
||||
@@ -655,6 +655,9 @@ func (c *OrderManager) GetStoresOrderSaleInfoNew(ctx *jxcontext.Context, storeID
|
||||
}
|
||||
saleInfo.ActualPayPrice += v.ActualPayPrice
|
||||
saleInfo.Count++
|
||||
|
||||
saleInfo.DistanceFreightMoney += v.DistanceFreightMoney
|
||||
saleInfo.WaybillTipMoney += v.WaybillTipMoney
|
||||
}
|
||||
orderMap[universalOrderID].SkuCount += v.Count
|
||||
|
||||
|
||||
@@ -1042,7 +1042,7 @@ func updateStoresSkusWithoutSync(ctx *jxcontext.Context, db *dao.DaoDB, storeIDs
|
||||
}
|
||||
setStoreSkuBindStatus(skuBind, model.SyncFlagNewMask)
|
||||
dao.WrapAddIDCULDEntity(skuBind, userName)
|
||||
globals.SugarLogger.Debug(utils.Format4Output(skuBind, false))
|
||||
// globals.SugarLogger.Debug(utils.Format4Output(skuBind, false))
|
||||
if deletedSku := dao.GetDeletedStoreSkuBind(db, skuBind.StoreID, skuBind.SkuID); deletedSku == nil {
|
||||
if err = dao.CreateEntity(db, skuBind); err != nil {
|
||||
dao.Rollback(db)
|
||||
@@ -2841,9 +2841,8 @@ func FocusStoreSkusByExcelBin(ctx *jxcontext.Context, reader io.Reader, isAsync,
|
||||
taskFunc := func(task *tasksch.ParallelTask, batchItemList []interface{}, params ...interface{}) (retVal interface{}, err error) {
|
||||
store := batchItemList[0].(*model.Store)
|
||||
var (
|
||||
skuBindInfos []*StoreSkuBindInfo
|
||||
skuNameMap = make(map[int]int)
|
||||
skuInfoMap = make(map[int][]*StoreSkuBindSkuInfo)
|
||||
skuNameMap = make(map[int]int)
|
||||
skuInfoMap = make(map[int][]*StoreSkuBindSkuInfo)
|
||||
)
|
||||
for _, v := range skuList {
|
||||
var (
|
||||
@@ -2877,29 +2876,26 @@ func FocusStoreSkusByExcelBin(ctx *jxcontext.Context, reader io.Reader, isAsync,
|
||||
}
|
||||
for k, v := range skuNameMap {
|
||||
skuBindInfo := &StoreSkuBindInfo{
|
||||
StoreID: store.ID,
|
||||
NameID: k,
|
||||
UnitPrice: v,
|
||||
IsFocus: 1,
|
||||
IsSale: 1,
|
||||
Skus: skuInfoMap[k],
|
||||
}
|
||||
skuBindInfos = append(skuBindInfos, skuBindInfo)
|
||||
retVal = []*StoreSkuBindInfo{skuBindInfo}
|
||||
}
|
||||
tUpdate := &tUpdateStoresSkus{
|
||||
StoreID: store.ID,
|
||||
SkuBindInfos: skuBindInfos,
|
||||
}
|
||||
retVal = []*tUpdateStoresSkus{tUpdate}
|
||||
return retVal, err
|
||||
}
|
||||
taskParallel := tasksch.NewParallelTask("根据skuID关注商品", tasksch.NewParallelConfig().SetIsContinueWhenError(isContinueWhenError), ctx, taskFunc, storeList)
|
||||
tasksch.HandleTask(taskParallel, task, true).Run()
|
||||
result1, _ = taskParallel.GetResult(0)
|
||||
case 2:
|
||||
var skuBindInfos []*StoreSkuBindInfo
|
||||
for _, v := range result1 {
|
||||
tUpdate := v.(*tUpdateStoresSkus)
|
||||
UpdateStoresSkus(ctx, []int{tUpdate.StoreID}, tUpdate.SkuBindInfos, false, isAsync, isContinueWhenError)
|
||||
skuBindInfos = append(skuBindInfos, v.(*StoreSkuBindInfo))
|
||||
}
|
||||
UpdateStoresSkusByBind(ctx, skuBindInfos, true, true)
|
||||
}
|
||||
return result, err
|
||||
}
|
||||
@@ -2954,7 +2950,6 @@ func FocusStoreSkusBySku(ctx *jxcontext.Context, skuIDs []int, isAsync, isContin
|
||||
case 1:
|
||||
taskFunc := func(task *tasksch.ParallelTask, batchItemList []interface{}, params ...interface{}) (retVal interface{}, err error) {
|
||||
store := batchItemList[0].(*model.Store)
|
||||
var skuBindInfos []*StoreSkuBindInfo
|
||||
for k, v := range skuNameMap {
|
||||
var price int
|
||||
focusList, _ := dao.GetStoreSkuBindByNameID(db, store.ID, k, model.StoreSkuBindStatusNormal)
|
||||
@@ -2980,23 +2975,19 @@ func FocusStoreSkusBySku(ctx *jxcontext.Context, skuIDs []int, isAsync, isContin
|
||||
IsFocus: 1,
|
||||
Skus: v,
|
||||
}
|
||||
skuBindInfos = append(skuBindInfos, skuBindInfo)
|
||||
retVal = []*StoreSkuBindInfo{skuBindInfo}
|
||||
}
|
||||
tUpdate := &tUpdateStoresSkus{
|
||||
StoreID: store.ID,
|
||||
SkuBindInfos: skuBindInfos,
|
||||
}
|
||||
retVal = []*tUpdateStoresSkus{tUpdate}
|
||||
return retVal, err
|
||||
}
|
||||
taskParallel := tasksch.NewParallelTask("根据skuID部分关注商品", tasksch.NewParallelConfig().SetIsContinueWhenError(isContinueWhenError), ctx, taskFunc, storeList)
|
||||
tasksch.HandleTask(taskParallel, task, true).Run()
|
||||
result1, _ = taskParallel.GetResult(0)
|
||||
case 2:
|
||||
var skuBindInfos []*StoreSkuBindInfo
|
||||
for _, v := range result1 {
|
||||
tUpdate := v.(*tUpdateStoresSkus)
|
||||
UpdateStoresSkusByBind(ctx, tUpdate.SkuBindInfos, isAsync, isContinueWhenError)
|
||||
skuBindInfos = append(skuBindInfos, v.(*StoreSkuBindInfo))
|
||||
}
|
||||
UpdateStoresSkusByBind(ctx, skuBindInfos, isAsync, isContinueWhenError)
|
||||
}
|
||||
return result, err
|
||||
}
|
||||
@@ -3013,12 +3004,12 @@ func FocusStoreSkusBySku(ctx *jxcontext.Context, skuIDs []int, isAsync, isContin
|
||||
|
||||
func AutoFocusStoreSkusWithoutFocusForTopSkus(ctx *jxcontext.Context) (err error) {
|
||||
db := dao.GetDB()
|
||||
var skuBindInfoList []*StoreSkuBindInfo
|
||||
storeList, err := dao.GetStoreList(db, nil, nil, "")
|
||||
for _, v := range storeList {
|
||||
var (
|
||||
skuName []*model.SkuName
|
||||
skuNameMap = make(map[int]int)
|
||||
skuBindInfoList []*StoreSkuBindInfo
|
||||
skuName []*model.SkuName
|
||||
skuNameMap = make(map[int]int)
|
||||
)
|
||||
sql := `
|
||||
SELECT DISTINCT a.name_id id
|
||||
@@ -3053,12 +3044,13 @@ func AutoFocusStoreSkusWithoutFocusForTopSkus(ctx *jxcontext.Context) (err error
|
||||
payPercentage = v.PayPercentage
|
||||
}
|
||||
if len(skuNameAndPlaceList) > 0 {
|
||||
for _, v := range skuNameAndPlaceList {
|
||||
if skuNameMap[v.ID] != 0 {
|
||||
priceReferList, err := dao.GetPriceReferSnapshotNoPage(db, []int{v.CityCode}, nil, []int{v.ID}, utils.Time2Date(time.Now().AddDate(0, 0, -1)))
|
||||
for _, vv := range skuNameAndPlaceList {
|
||||
if skuNameMap[vv.ID] != 0 {
|
||||
priceReferList, err := dao.GetPriceReferSnapshotNoPage(db, []int{vv.CityCode}, nil, []int{vv.ID}, utils.Time2Date(time.Now().AddDate(0, 0, -1)))
|
||||
if err == nil && len(priceReferList) > 0 {
|
||||
storeSkuBindInfo := &StoreSkuBindInfo{
|
||||
NameID: v.ID,
|
||||
StoreID: v.ID,
|
||||
NameID: vv.ID,
|
||||
UnitPrice: priceReferList[0].MidUnitPrice * payPercentage / 100,
|
||||
IsFocus: 1,
|
||||
IsSale: 0,
|
||||
@@ -3068,8 +3060,8 @@ func AutoFocusStoreSkusWithoutFocusForTopSkus(ctx *jxcontext.Context) (err error
|
||||
}
|
||||
}
|
||||
}
|
||||
UpdateStoreSkus(ctx, v.ID, skuBindInfoList, true, true)
|
||||
}
|
||||
UpdateStoresSkusByBind(ctx, skuBindInfoList, true, true)
|
||||
return err
|
||||
}
|
||||
|
||||
|
||||
@@ -16,22 +16,27 @@ const (
|
||||
)
|
||||
|
||||
type StoresOrderSaleInfo struct {
|
||||
StoreID int `orm:"column(store_id)" json:"storeID"`
|
||||
VendorID int `orm:"column(vendor_id)" json:"vendorID"`
|
||||
Status int `json:"status"`
|
||||
StoreID int `orm:"column(store_id)" json:"storeID"`
|
||||
VendorID int `orm:"column(vendor_id)" json:"vendorID"`
|
||||
Status int `json:"status"`
|
||||
|
||||
Count int `json:"count"`
|
||||
ShopPrice int64 `json:"shopPrice"`
|
||||
VendorPrice int64 `json:"vendorPrice"`
|
||||
SalePrice int64 `json:"salePrice"`
|
||||
ActualPayPrice int64 `json:"actualPayPrice"`
|
||||
|
||||
EarningPrice int64 `json:"earningPrice"` // 预估结算给门店老板的钱
|
||||
EarningPrice int64 `json:"earningPrice"` // 预估结算给门店老板的钱
|
||||
DistanceFreightMoney int64 `json:"distanceFreightMoney"` // 商户承担的远距离配送费(当前只有京东到家有值)
|
||||
WaybillTipMoney int64 `json:"waybillTipMoney"` // 京西加的平台配送小费
|
||||
}
|
||||
|
||||
type OrderSkuWithActualPayPrice struct {
|
||||
model.OrderSku
|
||||
|
||||
ActualPayPrice int64 `json:"actualPayPrice"` // 单位为分 顾客实际支付
|
||||
ActualPayPrice int64 `json:"actualPayPrice"` // 单位为分 顾客实际支付
|
||||
DistanceFreightMoney int64 `json:"distanceFreightMoney"` // 商户承担的远距离配送费(当前只有京东到家有值)
|
||||
WaybillTipMoney int64 `json:"waybillTipMoney"` // 京西加的平台配送小费
|
||||
|
||||
StoreID int `orm:"column(store_id)" json:"storeID"` // 外部系统里记录的 jxstoreid
|
||||
Status int `json:"status"` // 参见OrderStatus*相关的常量定义
|
||||
@@ -345,7 +350,7 @@ func GetStoreOrderSkuList(db *DaoDB, storeIDs []int, finishedAtBegin, finishedAt
|
||||
// order_finished_at
|
||||
sql := `
|
||||
SELECT t1.*,
|
||||
t2.actual_pay_price, t2.status, IF(t2.jx_store_id > 0, t2.jx_store_id, t2.store_id) store_id,
|
||||
IF(t2.jx_store_id > 0, t2.jx_store_id, t2.store_id) store_id, t2.status, t2.actual_pay_price, t2.distance_freight_money, t2.waybill_tip_money,
|
||||
t3.pay_percentage
|
||||
FROM order_sku t1
|
||||
JOIN goods_order t2 ON t2.vendor_order_id = t1.vendor_order_id AND t2.vendor_id = t1.vendor_id
|
||||
|
||||
Reference in New Issue
Block a user