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