Merge branch 'mark' of e.coding.net:rosydev/jx-callback into mark
This commit is contained in:
@@ -752,6 +752,64 @@ func RefreshOrdersWithoutJxStoreID(ctx *jxcontext.Context, fromDate, toDate stri
|
|||||||
return hint, err
|
return hint, err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func GetOrdersSupplement(ctx *jxcontext.Context, storIDs, vendorIDs []int, vendorOrderID, fromTime, toTime string, status, stype, IsReverse, offset, pageSize int) (pageInfo *model.PagedInfo, err error) {
|
||||||
|
var (
|
||||||
|
db = dao.GetDB()
|
||||||
|
fromTimeP time.Time
|
||||||
|
toTimeP time.Time
|
||||||
|
)
|
||||||
|
if fromTime != "" {
|
||||||
|
fromTimeP = utils.Str2Time(fromTime)
|
||||||
|
}
|
||||||
|
if toTime != "" {
|
||||||
|
toTimeP = utils.Str2Time(toTime)
|
||||||
|
}
|
||||||
|
if fromTimeP.After(toTimeP) {
|
||||||
|
return nil, fmt.Errorf("时间范围不合法!开始时间:[%v],结束时间:[%v]", fromTimeP, toTimeP)
|
||||||
|
}
|
||||||
|
result, totalCount, err := dao.GetOrdersSupplement(db, storIDs, vendorIDs, vendorOrderID, fromTimeP, toTimeP, status, stype, IsReverse, offset, pageSize)
|
||||||
|
pageInfo = &model.PagedInfo{
|
||||||
|
Data: result,
|
||||||
|
TotalCount: totalCount,
|
||||||
|
}
|
||||||
|
return pageInfo, err
|
||||||
|
}
|
||||||
|
|
||||||
|
func AddUpdateOrdersSupplement(ctx *jxcontext.Context, ordersSupplement *model.OrderSupplementFee) (num int64, err error) {
|
||||||
|
var (
|
||||||
|
db = dao.GetDB()
|
||||||
|
id = ordersSupplement.ID
|
||||||
|
)
|
||||||
|
now := time.Now()
|
||||||
|
ordersSupplement.SupplementTime = &now
|
||||||
|
defer func() {
|
||||||
|
if r := recover(); r != nil || err != nil {
|
||||||
|
dao.Rollback(db)
|
||||||
|
if r != nil {
|
||||||
|
panic(r)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}()
|
||||||
|
if id > 0 {
|
||||||
|
if ordersSupplement.Status == 1 {
|
||||||
|
return 0, fmt.Errorf("已结账的扣款信息不允许修改!门店ID:[%v],订单号:[%v]", ordersSupplement.StoreID, ordersSupplement.VendorOrderID)
|
||||||
|
}
|
||||||
|
ordersSupplement.UpdatedAt = time.Now()
|
||||||
|
ordersSupplement.LastOperator = ctx.GetUserName()
|
||||||
|
if ordersSupplement.Status == -1 {
|
||||||
|
ordersSupplement.DeletedAt = time.Now()
|
||||||
|
} else {
|
||||||
|
ordersSupplement.DeletedAt = utils.DefaultTimeValue
|
||||||
|
}
|
||||||
|
num, err = dao.UpdateEntity(db, ordersSupplement)
|
||||||
|
} else {
|
||||||
|
dao.WrapAddIDCULDEntity(ordersSupplement, ctx.GetUserName())
|
||||||
|
err = dao.CreateEntity(db, ordersSupplement)
|
||||||
|
}
|
||||||
|
dao.Commit(db)
|
||||||
|
return num, err
|
||||||
|
}
|
||||||
|
|
||||||
func RefreshOrdersPriceInfo(ctx *jxcontext.Context, fromTime, toTime time.Time, isAsync, isContinueWhenError bool) (hint string, err error) {
|
func RefreshOrdersPriceInfo(ctx *jxcontext.Context, fromTime, toTime time.Time, isAsync, isContinueWhenError bool) (hint string, err error) {
|
||||||
if utils.IsTimeZero(fromTime) {
|
if utils.IsTimeZero(fromTime) {
|
||||||
return "", fmt.Errorf("必须指定起始时间")
|
return "", fmt.Errorf("必须指定起始时间")
|
||||||
|
|||||||
@@ -140,6 +140,7 @@ func InitServiceInfo(version string, buildTime time.Time, gitCommit string) {
|
|||||||
"refundStatusName": model.RefundStatusName,
|
"refundStatusName": model.RefundStatusName,
|
||||||
"autoReplyTypeName": model.AutoReplyTypeName,
|
"autoReplyTypeName": model.AutoReplyTypeName,
|
||||||
"complaintReasons": model.ComplaintReasons,
|
"complaintReasons": model.ComplaintReasons,
|
||||||
|
"supplementType": model.SupplementTypeName,
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2595,7 +2595,7 @@ func CreateStorePriceScore(ctx *jxcontext.Context) (err error) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}()
|
}()
|
||||||
priceReferSnapshotDeleteHis := &model.StorePriceScoreSnapshot{SnapshotAt: snapshotAt.AddDate(0, -1, 0)}
|
priceReferSnapshotDeleteHis := &model.StorePriceScoreSnapshot{SnapshotAt: snapshotAt.AddDate(0, 0, -7)}
|
||||||
priceReferSnapshotDelete := &model.StorePriceScoreSnapshot{SnapshotAt: snapshotAt}
|
priceReferSnapshotDelete := &model.StorePriceScoreSnapshot{SnapshotAt: snapshotAt}
|
||||||
dao.DeleteEntity(db, priceReferSnapshotDeleteHis, "SnapshotAt")
|
dao.DeleteEntity(db, priceReferSnapshotDeleteHis, "SnapshotAt")
|
||||||
dao.DeleteEntity(db, priceReferSnapshotDelete, "SnapshotAt")
|
dao.DeleteEntity(db, priceReferSnapshotDelete, "SnapshotAt")
|
||||||
|
|||||||
@@ -154,6 +154,11 @@ type DataLock struct {
|
|||||||
locker sync.RWMutex
|
locker sync.RWMutex
|
||||||
}
|
}
|
||||||
|
|
||||||
|
type tUpdateStoresSkus struct {
|
||||||
|
StoreID int
|
||||||
|
SkuBindInfos []*StoreSkuBindInfo
|
||||||
|
}
|
||||||
|
|
||||||
const (
|
const (
|
||||||
maxStoreNameBind = 10000 // 最大门店SkuName bind个数
|
maxStoreNameBind = 10000 // 最大门店SkuName bind个数
|
||||||
maxStoreNameBind2 = 10000 // 最大门店乘SkuName个数
|
maxStoreNameBind2 = 10000 // 最大门店乘SkuName个数
|
||||||
@@ -2243,9 +2248,9 @@ func GetTopSkusByCityCode(ctx *jxcontext.Context, cityCode, storeID int) (skuNam
|
|||||||
}
|
}
|
||||||
for _, v := range skuNameAndPlace {
|
for _, v := range skuNameAndPlace {
|
||||||
if skuNameMap[v.ID] != nil {
|
if skuNameMap[v.ID] != nil {
|
||||||
midPrice, _ := dao.GetMidPriceByNameID(db, cityCode, v.ID, utils.Time2Date(time.Now().AddDate(0, 0, -1)))
|
priceReferList, _, _ := dao.GetPriceReferSnapshot(db, []int{cityCode}, nil, v.ID, utils.Time2Date(time.Now().AddDate(0, 0, -1)), 0, 9999)
|
||||||
if midPrice != 0 {
|
if len(priceReferList) > 0 {
|
||||||
v.Price = midPrice
|
v.Price = priceReferList[0].MidUnitPrice
|
||||||
}
|
}
|
||||||
v.Type = skuNameMap[v.ID].BrandID
|
v.Type = skuNameMap[v.ID].BrandID
|
||||||
skuNameAndPlaceList = append(skuNameAndPlaceList, v)
|
skuNameAndPlaceList = append(skuNameAndPlaceList, v)
|
||||||
@@ -2310,7 +2315,39 @@ func GetTopCategoriesByStoreIDs(ctx *jxcontext.Context, storeIDs []int) (skuCate
|
|||||||
|
|
||||||
func RefershStoreSkusMidPrice(ctx *jxcontext.Context, storeIDs []int) (err error) {
|
func RefershStoreSkusMidPrice(ctx *jxcontext.Context, storeIDs []int) (err error) {
|
||||||
db := dao.GetDB()
|
db := dao.GetDB()
|
||||||
_, err = dao.RefershStoreSkusMidPrice(db, storeIDs)
|
if len(storeIDs) == 0 {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
for _, v := range storeIDs {
|
||||||
|
var skuBindInfos []*StoreSkuBindInfo
|
||||||
|
store, err := dao.GetStoreDetail(db, v, -1)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
var payPercentage int
|
||||||
|
if store.PayPercentage < 50 {
|
||||||
|
payPercentage = 70
|
||||||
|
} else {
|
||||||
|
payPercentage = store.PayPercentage
|
||||||
|
}
|
||||||
|
storeSkuList, err := dao.GetStoresSkusInfo(db, []int{v}, nil)
|
||||||
|
for _, storeSku := range storeSkuList {
|
||||||
|
priceReferList, err := dao.GetPriceReferSnapshotNoPage(db, []int{store.CityCode}, []int{storeSku.SkuID}, nil, utils.Time2Date(time.Now().AddDate(0, 0, -1)))
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
if len(priceReferList) > 0 {
|
||||||
|
if storeSku.UnitPrice > priceReferList[0].MidUnitPrice*payPercentage/100 {
|
||||||
|
skuBindInfo := &StoreSkuBindInfo{
|
||||||
|
NameID: priceReferList[0].NameID,
|
||||||
|
UnitPrice: priceReferList[0].MidUnitPrice * payPercentage / 100,
|
||||||
|
}
|
||||||
|
skuBindInfos = append(skuBindInfos, skuBindInfo)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
updateStoresSkusWithoutSync(ctx, db, []int{v}, skuBindInfos, false)
|
||||||
|
}
|
||||||
if err == nil {
|
if err == nil {
|
||||||
CreateStorePriceScore(ctx)
|
CreateStorePriceScore(ctx)
|
||||||
}
|
}
|
||||||
@@ -2760,22 +2797,20 @@ func FocusStoreSkusByExcel(ctx *jxcontext.Context, files []*multipart.FileHeader
|
|||||||
|
|
||||||
func FocusStoreSkusByExcelBin(ctx *jxcontext.Context, reader io.Reader, isAsync, isContinueWhenError bool) (hint string, err error) {
|
func FocusStoreSkusByExcelBin(ctx *jxcontext.Context, reader io.Reader, isAsync, isContinueWhenError bool) (hint string, err error) {
|
||||||
var (
|
var (
|
||||||
skuMap = make(map[int]int)
|
skuMap = make(map[int]int)
|
||||||
skuNameMap = make(map[int]int)
|
db = dao.GetDB()
|
||||||
skuBindInfos []*StoreSkuBindInfo
|
skuIDs []int
|
||||||
db = dao.GetDB()
|
result1 []interface{}
|
||||||
storeIDs []int
|
|
||||||
skuIDs []int
|
|
||||||
)
|
)
|
||||||
sheetParam := &SheetParam{
|
sheetParam := &SheetParam{
|
||||||
OutSkuIDCol: 1,
|
OutSkuIDCol: 1,
|
||||||
SkuPriceCol: 3,
|
SkuPriceCol: 3,
|
||||||
SkuRow: 1,
|
SkuRow: 1,
|
||||||
}
|
}
|
||||||
// xlsx, err := excelize.OpenFile("111.xlsx")
|
|
||||||
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:
|
||||||
|
// xlsx, err := excelize.OpenFile("111.xlsx")
|
||||||
xlsx, err := excelize.OpenReader(reader)
|
xlsx, err := excelize.OpenReader(reader)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return result, err
|
return result, err
|
||||||
@@ -2792,43 +2827,72 @@ func FocusStoreSkusByExcelBin(ctx *jxcontext.Context, reader io.Reader, isAsync,
|
|||||||
skuIDs = append(skuIDs, k)
|
skuIDs = append(skuIDs, k)
|
||||||
}
|
}
|
||||||
skuList, err := dao.GetSkus(db, skuIDs, nil, nil, nil)
|
skuList, err := dao.GetSkus(db, skuIDs, nil, nil, nil)
|
||||||
|
storeList, err := dao.GetStoreList(db, nil, nil, "")
|
||||||
if err != nil && len(skuList) == 0 {
|
if err != nil && len(skuList) == 0 {
|
||||||
return result, err
|
return result, err
|
||||||
}
|
}
|
||||||
for _, v := range skuList {
|
taskFunc := func(task *tasksch.ParallelTask, batchItemList []interface{}, params ...interface{}) (retVal interface{}, err error) {
|
||||||
|
store := batchItemList[0].(*model.Store)
|
||||||
var (
|
var (
|
||||||
price int
|
skuBindInfos []*StoreSkuBindInfo
|
||||||
specQuality float64
|
skuNameMap = make(map[int]int)
|
||||||
|
skuInfoMap = make(map[int][]*StoreSkuBindSkuInfo)
|
||||||
)
|
)
|
||||||
if v.Unit == model.SpecialUnit {
|
for _, v := range skuList {
|
||||||
if v.SpecUnit == model.SpecUnitNames[1] || v.SpecUnit == model.SpecUnitNames[2] {
|
var (
|
||||||
specQuality = float64(v.SpecQuality) * 1000
|
price int
|
||||||
|
specQuality float64
|
||||||
|
)
|
||||||
|
focusList, _ := dao.GetStoreSkuBindByNameID(db, store.ID, v.NameID, model.StoreSkuBindStatusNormal)
|
||||||
|
//有关注过
|
||||||
|
if len(focusList) > 0 {
|
||||||
|
price = focusList[0].UnitPrice
|
||||||
|
skuInfoMap[v.NameID] = append(skuInfoMap[v.NameID], &StoreSkuBindSkuInfo{
|
||||||
|
SkuID: v.ID,
|
||||||
|
IsSale: 1,
|
||||||
|
})
|
||||||
|
skuNameMap[v.NameID] = price
|
||||||
} else {
|
} else {
|
||||||
specQuality = float64(v.SpecQuality)
|
if v.Unit == model.SpecialUnit {
|
||||||
|
if v.SpecUnit == model.SpecUnitNames[1] || v.SpecUnit == model.SpecUnitNames[2] {
|
||||||
|
specQuality = float64(v.SpecQuality) * 1000
|
||||||
|
} else {
|
||||||
|
specQuality = float64(v.SpecQuality)
|
||||||
|
}
|
||||||
|
price = int(utils.Float64TwoInt64(utils.Int2Float64(model.SpecialSpecQuality) / specQuality * utils.Int2Float64(skuMap[v.ID])))
|
||||||
|
} else {
|
||||||
|
price = skuMap[v.ID]
|
||||||
|
}
|
||||||
|
if skuNameMap[v.NameID] < price {
|
||||||
|
skuNameMap[v.NameID] = price
|
||||||
|
}
|
||||||
}
|
}
|
||||||
price = int(utils.Float64TwoInt64(utils.Int2Float64(model.SpecialSpecQuality) / specQuality * utils.Int2Float64(skuMap[v.ID])))
|
|
||||||
} else {
|
|
||||||
price = skuMap[v.ID]
|
|
||||||
}
|
}
|
||||||
if skuNameMap[v.NameID] < price {
|
for k, v := range skuNameMap {
|
||||||
skuNameMap[v.NameID] = price
|
skuBindInfo := &StoreSkuBindInfo{
|
||||||
|
NameID: k,
|
||||||
|
UnitPrice: v,
|
||||||
|
IsFocus: 1,
|
||||||
|
IsSale: 1,
|
||||||
|
Skus: skuInfoMap[k],
|
||||||
|
}
|
||||||
|
skuBindInfos = append(skuBindInfos, skuBindInfo)
|
||||||
}
|
}
|
||||||
}
|
tUpdate := &tUpdateStoresSkus{
|
||||||
for k, v := range skuNameMap {
|
StoreID: store.ID,
|
||||||
skuBindInfo := &StoreSkuBindInfo{
|
SkuBindInfos: skuBindInfos,
|
||||||
NameID: k,
|
|
||||||
UnitPrice: v,
|
|
||||||
IsFocus: 1,
|
|
||||||
IsSale: 1,
|
|
||||||
}
|
}
|
||||||
skuBindInfos = append(skuBindInfos, skuBindInfo)
|
retVal = []*tUpdateStoresSkus{tUpdate}
|
||||||
}
|
return retVal, err
|
||||||
storeList, err := dao.GetStoreList(db, nil, nil, "")
|
|
||||||
for _, v := range storeList {
|
|
||||||
storeIDs = append(storeIDs, v.ID)
|
|
||||||
}
|
}
|
||||||
|
taskParallel := tasksch.NewParallelTask("根据skuID关注商品", tasksch.NewParallelConfig().SetIsContinueWhenError(isContinueWhenError), ctx, taskFunc, storeList)
|
||||||
|
tasksch.HandleTask(taskParallel, task, true).Run()
|
||||||
|
result1, _ = taskParallel.GetResult(0)
|
||||||
case 2:
|
case 2:
|
||||||
UpdateStoresSkus(ctx, storeIDs, skuBindInfos, false, isAsync, isContinueWhenError)
|
for _, v := range result1 {
|
||||||
|
tUpdate := v.(*tUpdateStoresSkus)
|
||||||
|
UpdateStoresSkus(ctx, []int{tUpdate.StoreID}, tUpdate.SkuBindInfos, false, isAsync, isContinueWhenError)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return result, err
|
return result, err
|
||||||
}
|
}
|
||||||
@@ -2861,9 +2925,9 @@ func GetCellForFocusStoreSkus(db *dao.DaoDB, rowNum int, row []string, sheetPara
|
|||||||
|
|
||||||
func FocusStoreSkusBySku(ctx *jxcontext.Context, skuIDs []int, isAsync, isContinueWhenError bool) (hint string, err error) {
|
func FocusStoreSkusBySku(ctx *jxcontext.Context, skuIDs []int, isAsync, isContinueWhenError bool) (hint string, err error) {
|
||||||
var (
|
var (
|
||||||
skuBindInfos []*StoreSkuBindInfo
|
skuNameMap = make(map[int][]*StoreSkuBindSkuInfo)
|
||||||
skuNameMap = make(map[int][]*StoreSkuBindSkuInfo)
|
storeIDs []int
|
||||||
storeIDs []int
|
result1 []interface{}
|
||||||
)
|
)
|
||||||
db := dao.GetDB()
|
db := dao.GetDB()
|
||||||
skuList, err := dao.GetSkus(db, skuIDs, nil, nil, nil)
|
skuList, err := dao.GetSkus(db, skuIDs, nil, nil, nil)
|
||||||
@@ -2883,26 +2947,42 @@ 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 {
|
||||||
midPrice, _ := dao.GetMidPriceByNameID(db, store.CityCode, k, utils.Time2Date(time.Now().AddDate(0, 0, -1)))
|
var price int
|
||||||
|
focusList, _ := dao.GetStoreSkuBindByNameID(db, store.ID, k, model.StoreSkuBindStatusNormal)
|
||||||
|
//有关注过
|
||||||
|
if len(focusList) > 0 {
|
||||||
|
price = focusList[0].UnitPrice
|
||||||
|
} else {
|
||||||
|
priceReferList, _, _ := dao.GetPriceReferSnapshot(db, []int{store.CityCode}, nil, k, utils.Time2Date(time.Now().AddDate(0, 0, -1)), 0, 9999)
|
||||||
|
if len(priceReferList) > 0 {
|
||||||
|
price = priceReferList[0].MidUnitPrice
|
||||||
|
}
|
||||||
|
}
|
||||||
skuBindInfo := &StoreSkuBindInfo{
|
skuBindInfo := &StoreSkuBindInfo{
|
||||||
NameID: k,
|
NameID: k,
|
||||||
UnitPrice: midPrice,
|
UnitPrice: price,
|
||||||
IsFocus: 1,
|
IsFocus: 1,
|
||||||
Skus: v,
|
Skus: v,
|
||||||
}
|
}
|
||||||
retVal = []*StoreSkuBindInfo{skuBindInfo}
|
skuBindInfos = append(skuBindInfos, 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)
|
||||||
for _, v := range result1 {
|
|
||||||
skuBindInfos = append(skuBindInfos, v.(*StoreSkuBindInfo))
|
|
||||||
}
|
|
||||||
case 2:
|
case 2:
|
||||||
UpdateStoresSkus(ctx, storeIDs, skuBindInfos, false, isAsync, isContinueWhenError)
|
for _, v := range result1 {
|
||||||
|
tUpdate := v.(*tUpdateStoresSkus)
|
||||||
|
UpdateStoresSkus(ctx, []int{tUpdate.StoreID}, tUpdate.SkuBindInfos, false, isAsync, isContinueWhenError)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return result, err
|
return result, err
|
||||||
}
|
}
|
||||||
@@ -2917,6 +2997,63 @@ func FocusStoreSkusBySku(ctx *jxcontext.Context, skuIDs []int, isAsync, isContin
|
|||||||
return hint, err
|
return hint, err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func AutoFocusStoreSkusWithoutFocus(ctx *jxcontext.Context, skuIDs []int, isSync bool) (err error) {
|
||||||
|
var (
|
||||||
|
nameMap = make(map[int]*StoreSkuBindInfo)
|
||||||
|
)
|
||||||
|
db := dao.GetDB()
|
||||||
|
storeList, err := dao.GetStoreList(db, nil, nil, "")
|
||||||
|
for _, v := range storeList {
|
||||||
|
storeSkuList, _ := dao.GetStoreSkusAndSkuName(db, []int{v.ID}, skuIDs, nil)
|
||||||
|
for _, vv := range storeSkuList {
|
||||||
|
if nameMap[vv.ID] != nil {
|
||||||
|
nameMap[vv.ID].Skus = append(nameMap[vv.ID].Skus, &StoreSkuBindSkuInfo{
|
||||||
|
SkuID: vv.SkuID,
|
||||||
|
})
|
||||||
|
} else {
|
||||||
|
skuBindInfo := &StoreSkuBindInfo{
|
||||||
|
UnitPrice: vv.UnitPrice,
|
||||||
|
NameID: vv.ID,
|
||||||
|
StoreID: v.ID,
|
||||||
|
Skus: []*StoreSkuBindSkuInfo{},
|
||||||
|
}
|
||||||
|
nameMap[vv.ID] = skuBindInfo
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
for _, v := range nameMap {
|
||||||
|
var skuBindInfoList []*StoreSkuBindInfo
|
||||||
|
skuBindInfoResult := &StoreSkuBindInfo{
|
||||||
|
NameID: v.NameID,
|
||||||
|
UnitPrice: v.UnitPrice,
|
||||||
|
IsFocus: 1,
|
||||||
|
}
|
||||||
|
var skuBindSkuList []*StoreSkuBindSkuInfo
|
||||||
|
skuMap := make(map[int]int)
|
||||||
|
skuList, _ := dao.GetSkus(db, nil, []int{v.NameID}, nil, nil)
|
||||||
|
if len(v.Skus) != len(skuList) {
|
||||||
|
for _, skus := range v.Skus {
|
||||||
|
skuMap[skus.SkuID] = 1
|
||||||
|
}
|
||||||
|
for _, vv := range skuList {
|
||||||
|
if skuMap[vv.ID] != 1 {
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
skuBindSkuList = append(skuBindSkuList, &StoreSkuBindSkuInfo{
|
||||||
|
SkuID: vv.ID,
|
||||||
|
IsSale: 0,
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}
|
||||||
|
skuBindInfoList = append(skuBindInfoList, skuBindInfoResult)
|
||||||
|
if isSync {
|
||||||
|
UpdateStoreSkus(ctx, v.StoreID, skuBindInfoList, true, true)
|
||||||
|
} else {
|
||||||
|
updateStoresSkusWithoutSync(ctx, db, []int{v.StoreID}, skuBindInfoList, false)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return err
|
||||||
|
}
|
||||||
func UpdateStoreSkuNamePrice(ctx *jxcontext.Context, storeID, nameID, unitPrice int, isAsync bool) (hint string, err error) {
|
func UpdateStoreSkuNamePrice(ctx *jxcontext.Context, storeID, nameID, unitPrice int, isAsync bool) (hint string, err error) {
|
||||||
// db := dao.GetDB()
|
// db := dao.GetDB()
|
||||||
// skuList, err := dao.GetSkus(db, nil, []int{nameID}, nil, nil)
|
// skuList, err := dao.GetSkus(db, nil, []int{nameID}, nil, nil)
|
||||||
|
|||||||
9
business/jxstore/event/event.go
Normal file
9
business/jxstore/event/event.go
Normal file
@@ -0,0 +1,9 @@
|
|||||||
|
package event
|
||||||
|
|
||||||
|
func AddOperateEvent() {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
func AddOperateEventDetail() {
|
||||||
|
|
||||||
|
}
|
||||||
@@ -141,7 +141,7 @@ func Init() {
|
|||||||
cms.CurVendorSync.ChangeStoreSkuSaleStatus(jxcontext.AdminCtx, 0, true, true)
|
cms.CurVendorSync.ChangeStoreSkuSaleStatus(jxcontext.AdminCtx, 0, true, true)
|
||||||
}, ChangeStoreSkuSaleStatusList)
|
}, ChangeStoreSkuSaleStatusList)
|
||||||
ScheduleTimerFunc("BeginSavePriceRefer", func() {
|
ScheduleTimerFunc("BeginSavePriceRefer", func() {
|
||||||
report.BeginSavePriceRefer(jxcontext.AdminCtx, nil, nil)
|
report.BeginSavePriceRefer(jxcontext.AdminCtx, nil, nil, true, true)
|
||||||
}, priceReferTimeList)
|
}, priceReferTimeList)
|
||||||
ScheduleTimerFunc("CreateStorePriceScore", func() {
|
ScheduleTimerFunc("CreateStorePriceScore", func() {
|
||||||
cms.CreateStorePriceScore(jxcontext.AdminCtx)
|
cms.CreateStorePriceScore(jxcontext.AdminCtx)
|
||||||
|
|||||||
@@ -4,9 +4,10 @@ import (
|
|||||||
"errors"
|
"errors"
|
||||||
"fmt"
|
"fmt"
|
||||||
"math"
|
"math"
|
||||||
|
"sort"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"git.rosy.net.cn/jx-callback/globals"
|
"git.rosy.net.cn/jx-callback/business/jxutils/tasksch"
|
||||||
|
|
||||||
"git.rosy.net.cn/baseapi/utils"
|
"git.rosy.net.cn/baseapi/utils"
|
||||||
"git.rosy.net.cn/jx-callback/business/jxutils/jxcontext"
|
"git.rosy.net.cn/jx-callback/business/jxutils/jxcontext"
|
||||||
@@ -14,6 +15,14 @@ import (
|
|||||||
"git.rosy.net.cn/jx-callback/business/model/dao"
|
"git.rosy.net.cn/jx-callback/business/model/dao"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
type tStoreSkuBindAndSkuName struct {
|
||||||
|
CityCode int
|
||||||
|
StoreID int `orm:"column(store_id)"`
|
||||||
|
NameID int `orm:"column(name_id)"`
|
||||||
|
UnitPrice int
|
||||||
|
UnitPriceList []int
|
||||||
|
}
|
||||||
|
|
||||||
func GetStatisticsReportForOrders(ctx *jxcontext.Context, storeIDs []int, fromDate string, toDate string) (statisticsReportForOrdersList []*dao.StatisticsReportForOrdersList, err error) {
|
func GetStatisticsReportForOrders(ctx *jxcontext.Context, storeIDs []int, fromDate string, toDate string) (statisticsReportForOrdersList []*dao.StatisticsReportForOrdersList, err error) {
|
||||||
db := dao.GetDB()
|
db := dao.GetDB()
|
||||||
fromDateParm := utils.Str2Time(fromDate)
|
fromDateParm := utils.Str2Time(fromDate)
|
||||||
@@ -44,7 +53,7 @@ func StatisticsReportForStoreSkusPrice(ctx *jxcontext.Context, cityCodes, skuIDs
|
|||||||
if snapDate != "" {
|
if snapDate != "" {
|
||||||
snapDateParam = utils.Str2Time(snapDate)
|
snapDateParam = utils.Str2Time(snapDate)
|
||||||
}
|
}
|
||||||
priceReferSnapshot, totalCount, err := dao.GetPriceReferSnapshot(db, cityCodes, skuIDs, snapDateParam, offset, pageSize)
|
priceReferSnapshot, totalCount, err := dao.GetPriceReferSnapshot(db, cityCodes, skuIDs, 0, snapDateParam, offset, pageSize)
|
||||||
pagedInfo = &model.PagedInfo{
|
pagedInfo = &model.PagedInfo{
|
||||||
Data: priceReferSnapshot,
|
Data: priceReferSnapshot,
|
||||||
TotalCount: totalCount,
|
TotalCount: totalCount,
|
||||||
@@ -52,33 +61,179 @@ func StatisticsReportForStoreSkusPrice(ctx *jxcontext.Context, cityCodes, skuIDs
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
func BeginSavePriceRefer(ctx *jxcontext.Context, cityCodes, skuIDs []int) (err error) {
|
func BeginSavePriceRefer(ctx *jxcontext.Context, cityCodes, skuIDs []int, isAsync, isContinueWhenError bool) (hint string, err error) {
|
||||||
|
var priceReferSnapshotList []*model.PriceReferSnapshot
|
||||||
db := dao.GetDB()
|
db := dao.GetDB()
|
||||||
snapshotAt := utils.Time2Date(time.Now().AddDate(0, 0, -1))
|
snapshotAt := utils.Time2Date(time.Now().AddDate(0, 0, -1))
|
||||||
priceReferSnapshot, err := dao.GetStatisticsReportForStoreSkusPrice(db, cityCodes, skuIDs)
|
taskSeqFunc := func(task *tasksch.SeqTask, step int, params ...interface{}) (result interface{}, err error) {
|
||||||
if len(priceReferSnapshot) > 0 {
|
switch step {
|
||||||
dao.Begin(db)
|
case 0:
|
||||||
defer func() {
|
priceReferSnapshot, err := dao.GetStatisticsReportForStoreSkusPrice(db, cityCodes, skuIDs)
|
||||||
if r := recover(); r != nil || err != nil {
|
if len(priceReferSnapshot) > 0 {
|
||||||
dao.Rollback(db)
|
dao.Begin(db)
|
||||||
if r != nil {
|
defer func() {
|
||||||
panic(r)
|
if r := recover(); r != nil || err != nil {
|
||||||
|
dao.Rollback(db)
|
||||||
|
if r != nil {
|
||||||
|
panic(r)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}()
|
||||||
|
dao.DeletePriceReferHistory(db, utils.Time2Date(snapshotAt.AddDate(0, 0, -7)))
|
||||||
|
priceReferSnapshotDelete := &model.PriceReferSnapshot{SnapshotAt: snapshotAt}
|
||||||
|
dao.DeleteEntity(db, priceReferSnapshotDelete, "SnapshotAt")
|
||||||
|
taskFunc := func(task *tasksch.ParallelTask, batchItemList []interface{}, params ...interface{}) (retVal interface{}, err error) {
|
||||||
|
v := batchItemList[0].(*model.PriceReferSnapshot)
|
||||||
|
dao.WrapAddIDCULDEntity(v, ctx.GetUserName())
|
||||||
|
v.SnapshotAt = snapshotAt
|
||||||
|
err = dao.CreateEntity(db, v)
|
||||||
|
return retVal, err
|
||||||
|
}
|
||||||
|
taskParallel := tasksch.NewParallelTask("生成价格统计", tasksch.NewParallelConfig(), ctx, taskFunc, priceReferSnapshot)
|
||||||
|
tasksch.HandleTask(taskParallel, task, true).Run()
|
||||||
|
_, err = taskParallel.GetResult(0)
|
||||||
|
dao.Commit(db)
|
||||||
|
}
|
||||||
|
case 1:
|
||||||
|
priceReferSnapshotList, err = dao.GetPriceReferSnapshotNoPage(db, nil, nil, nil, snapshotAt)
|
||||||
|
var (
|
||||||
|
citySkuMap = make(map[int]map[int][]int)
|
||||||
|
resultMap = make(map[int]map[int]*model.PriceReferSnapshot)
|
||||||
|
)
|
||||||
|
storeList, err := dao.GetStoreList(db, nil, nil, "")
|
||||||
|
if err != nil {
|
||||||
|
return result, err
|
||||||
|
}
|
||||||
|
for _, v := range storeList {
|
||||||
|
var tList []*tStoreSkuBindAndSkuName
|
||||||
|
sql := `
|
||||||
|
SELECT DISTINCT b.city_code, a.store_id, Round(a.unit_price/IF(b.pay_percentage < 50 , 70, b.pay_percentage) * 100) AS unit_price, c.name_id
|
||||||
|
FROM store_sku_bind a
|
||||||
|
JOIN store b ON b.id = a.store_id AND b.deleted_at = ? AND b.status != ?
|
||||||
|
JOIN sku c ON c.id = a.sku_id
|
||||||
|
WHERE a.store_id = ?
|
||||||
|
AND c.name_id NOT IN(
|
||||||
|
SELECT b.name_id
|
||||||
|
FROM store_sku_bind a
|
||||||
|
JOIN sku b ON a.sku_id = b.id AND b.deleted_at = ?
|
||||||
|
WHERE a.deleted_at = ?
|
||||||
|
AND a.store_id = ?
|
||||||
|
AND b.name_id NOT IN(SELECT DISTINCT b.name_id
|
||||||
|
FROM store_sku_bind a
|
||||||
|
JOIN sku b ON a.sku_id = b.id AND b.deleted_at = ?
|
||||||
|
WHERE a.deleted_at = ?
|
||||||
|
AND a.store_id = ?
|
||||||
|
AND a.status = ?)
|
||||||
|
)
|
||||||
|
AND a.deleted_at = ?
|
||||||
|
`
|
||||||
|
sqlParams := []interface{}{
|
||||||
|
utils.DefaultTimeValue,
|
||||||
|
model.StoreStatusDisabled,
|
||||||
|
v.ID,
|
||||||
|
utils.DefaultTimeValue,
|
||||||
|
utils.DefaultTimeValue,
|
||||||
|
v.ID,
|
||||||
|
utils.DefaultTimeValue,
|
||||||
|
utils.DefaultTimeValue,
|
||||||
|
v.ID,
|
||||||
|
model.StoreSkuBindStatusNormal,
|
||||||
|
utils.DefaultTimeValue,
|
||||||
|
}
|
||||||
|
dao.GetRows(db, &tList, sql, sqlParams...)
|
||||||
|
skuNameMap := make(map[int][]int)
|
||||||
|
if len(tList) > 0 {
|
||||||
|
for _, vv := range tList {
|
||||||
|
skuNameMap[vv.NameID] = append(skuNameMap[vv.NameID], vv.UnitPrice)
|
||||||
|
}
|
||||||
|
if citySkuMap[v.CityCode] != nil {
|
||||||
|
for nameID, unitPriceList := range skuNameMap {
|
||||||
|
if citySkuMap[v.CityCode][nameID] != nil {
|
||||||
|
citySkuMap[v.CityCode][nameID] = append(citySkuMap[v.CityCode][nameID], unitPriceList...)
|
||||||
|
} else {
|
||||||
|
citySkuMap[v.CityCode][nameID] = unitPriceList
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
citySkuMap[v.CityCode] = skuNameMap
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}()
|
for k1, v := range citySkuMap {
|
||||||
priceReferSnapshotDeleteHis := &model.PriceReferSnapshot{SnapshotAt: snapshotAt.AddDate(0, -1, 0)}
|
skuNameMap := make(map[int]*model.PriceReferSnapshot)
|
||||||
priceReferSnapshotDelete := &model.PriceReferSnapshot{SnapshotAt: snapshotAt}
|
for k2, _ := range v {
|
||||||
dao.DeleteEntity(db, priceReferSnapshotDeleteHis, "SnapshotAt")
|
var midUnitPrice int
|
||||||
dao.DeleteEntity(db, priceReferSnapshotDelete, "SnapshotAt")
|
var avgUnitPrice int
|
||||||
for _, v := range priceReferSnapshot {
|
sort.Ints(v[k2])
|
||||||
dao.WrapAddIDCULDEntity(v, ctx.GetUserName())
|
if len(v[k2])%2 == 0 {
|
||||||
v.SnapshotAt = snapshotAt
|
midUnitPrice = v[k2][len(v[k2])/2-1]
|
||||||
if err = dao.CreateEntity(db, v); err != nil {
|
} else {
|
||||||
return err
|
midUnitPrice = v[k2][len(v[k2])/2]
|
||||||
|
}
|
||||||
|
for _, vv := range v[k2] {
|
||||||
|
avgUnitPrice += vv
|
||||||
|
}
|
||||||
|
skuNameMap[k2] = &model.PriceReferSnapshot{
|
||||||
|
MidUnitPrice: midUnitPrice,
|
||||||
|
MaxUnitPrice: v[k2][len(v[k2])-1],
|
||||||
|
MinUnitPrice: v[k2][0],
|
||||||
|
AvgUnitPrice: avgUnitPrice / len(v[k2]),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
resultMap[k1] = skuNameMap
|
||||||
}
|
}
|
||||||
|
dao.Begin(db)
|
||||||
|
defer func() {
|
||||||
|
if r := recover(); r != nil || err != nil {
|
||||||
|
dao.Rollback(db)
|
||||||
|
if r != nil {
|
||||||
|
panic(r)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}()
|
||||||
|
if len(priceReferSnapshotList) > 0 {
|
||||||
|
for _, v := range priceReferSnapshotList {
|
||||||
|
if resultMap[v.CityCode][v.NameID] != nil {
|
||||||
|
v.MidUnitPrice = resultMap[v.CityCode][v.NameID].MidUnitPrice
|
||||||
|
v.MaxUnitPrice = resultMap[v.CityCode][v.NameID].MaxUnitPrice
|
||||||
|
v.AvgUnitPrice = resultMap[v.CityCode][v.NameID].AvgUnitPrice
|
||||||
|
v.MinUnitPrice = resultMap[v.CityCode][v.NameID].MinUnitPrice
|
||||||
|
dao.UpdateEntity(db, v, "MidUnitPrice", "MaxUnitPrice", "MinUnitPrice", "AvgUnitPrice")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
dao.Commit(db)
|
||||||
|
case 2:
|
||||||
|
dao.Begin(db)
|
||||||
|
defer func() {
|
||||||
|
if r := recover(); r != nil || err != nil {
|
||||||
|
dao.Rollback(db)
|
||||||
|
if r != nil {
|
||||||
|
panic(r)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}()
|
||||||
|
if len(priceReferSnapshotList) > 0 {
|
||||||
|
for _, v := range priceReferSnapshotList {
|
||||||
|
result, _ := dao.GetPriceReferPrice(db, v.CityCode, v.SkuID, snapshotAt)
|
||||||
|
v.MaxPrice = result.MaxPrice
|
||||||
|
v.MinPrice = result.MinPrice
|
||||||
|
v.AvgPrice = result.AvgPrice
|
||||||
|
v.MidPrice = result.MidPrice
|
||||||
|
dao.UpdateEntity(db, v, "MidPrice", "MaxPrice", "MinPrice", "AvgPrice")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
dao.Commit(db)
|
||||||
}
|
}
|
||||||
dao.Commit(db)
|
return result, err
|
||||||
globals.SugarLogger.Debugf("CreatePriceRefer")
|
|
||||||
}
|
}
|
||||||
return err
|
taskSeq := tasksch.NewSeqTask2("生成每日价格统计", ctx, isContinueWhenError, taskSeqFunc, 3)
|
||||||
|
tasksch.HandleTask(taskSeq, nil, true).Run()
|
||||||
|
if !isAsync {
|
||||||
|
_, err = taskSeq.GetResult(0)
|
||||||
|
hint = "1"
|
||||||
|
} else {
|
||||||
|
hint = taskSeq.GetID()
|
||||||
|
}
|
||||||
|
return hint, err
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -100,6 +100,11 @@ var (
|
|||||||
ComplaintReasons71: "骑手提前点击取货/送达",
|
ComplaintReasons71: "骑手提前点击取货/送达",
|
||||||
}
|
}
|
||||||
|
|
||||||
|
SupplementTypeName = map[int]string{
|
||||||
|
BadAppraiseSupplement: "差评退款",
|
||||||
|
Coupon: "优惠券",
|
||||||
|
}
|
||||||
|
|
||||||
MultiStoresVendorMap = map[int]int{
|
MultiStoresVendorMap = map[int]int{
|
||||||
VendorIDJD: 1,
|
VendorIDJD: 1,
|
||||||
VendorIDMTWM: 0,
|
VendorIDMTWM: 0,
|
||||||
@@ -231,6 +236,11 @@ const (
|
|||||||
ComplaintReasons71 = 71 //"骑手提前点击取货/送达",
|
ComplaintReasons71 = 71 //"骑手提前点击取货/送达",
|
||||||
)
|
)
|
||||||
|
|
||||||
|
const (
|
||||||
|
BadAppraiseSupplement = 1 //差评退款
|
||||||
|
Coupon = 2 //优惠券
|
||||||
|
)
|
||||||
|
|
||||||
const (
|
const (
|
||||||
WaybillStatusRefuseFailedGetGoods = -70
|
WaybillStatusRefuseFailedGetGoods = -70
|
||||||
WaybillStatusUnknown = 0
|
WaybillStatusUnknown = 0
|
||||||
|
|||||||
@@ -1053,7 +1053,7 @@ func GetWayBillByOrderID(db *DaoDB, orderStatus, vendorID, waybillVendorID int,
|
|||||||
return wayBillList, err
|
return wayBillList, err
|
||||||
}
|
}
|
||||||
|
|
||||||
func GetOrdersSupplement(db *DaoDB, storIDs, vendorIDs []int, vendorOrderID string, fromTime, toTime time.Time, status, stype, offset, pageSize int) (orderSupplementFee []*model.OrderSupplementFee, totalCount int, err error) {
|
func GetOrdersSupplement(db *DaoDB, storIDs, vendorIDs []int, vendorOrderID string, fromTime, toTime time.Time, status, stype, IsReverse, offset, pageSize int) (orderSupplementFee []*model.OrderSupplementFee, totalCount int, err error) {
|
||||||
sql := `
|
sql := `
|
||||||
SELECT SQL_CALC_FOUND_ROWS *
|
SELECT SQL_CALC_FOUND_ROWS *
|
||||||
FROM order_supplement_fee
|
FROM order_supplement_fee
|
||||||
@@ -1076,7 +1076,7 @@ func GetOrdersSupplement(db *DaoDB, storIDs, vendorIDs []int, vendorOrderID stri
|
|||||||
sqlParams = append(sqlParams, storIDs)
|
sqlParams = append(sqlParams, storIDs)
|
||||||
}
|
}
|
||||||
if len(vendorIDs) > 0 {
|
if len(vendorIDs) > 0 {
|
||||||
sql += " AND store_id IN (" + GenQuestionMarks(len(vendorIDs)) + ")"
|
sql += " AND vendor_id IN (" + GenQuestionMarks(len(vendorIDs)) + ")"
|
||||||
sqlParams = append(sqlParams, vendorIDs)
|
sqlParams = append(sqlParams, vendorIDs)
|
||||||
}
|
}
|
||||||
if vendorOrderID != "" {
|
if vendorOrderID != "" {
|
||||||
@@ -1087,10 +1087,15 @@ func GetOrdersSupplement(db *DaoDB, storIDs, vendorIDs []int, vendorOrderID stri
|
|||||||
sql += " AND status = ?"
|
sql += " AND status = ?"
|
||||||
sqlParams = append(sqlParams, status)
|
sqlParams = append(sqlParams, status)
|
||||||
}
|
}
|
||||||
if stype >= 0 {
|
if stype > 0 {
|
||||||
sql += " AND type = ?"
|
sql += " AND type = ?"
|
||||||
sqlParams = append(sqlParams, stype)
|
sqlParams = append(sqlParams, stype)
|
||||||
}
|
}
|
||||||
|
if IsReverse == -1 {
|
||||||
|
sql += " AND link_id = 0"
|
||||||
|
} else if IsReverse == 1 {
|
||||||
|
sql += " AND link_id <> 0"
|
||||||
|
}
|
||||||
sql += `
|
sql += `
|
||||||
LIMIT ? OFFSET ?`
|
LIMIT ? OFFSET ?`
|
||||||
sqlParams = append(sqlParams, pageSize, offset)
|
sqlParams = append(sqlParams, pageSize, offset)
|
||||||
|
|||||||
@@ -36,8 +36,11 @@ type StatisticsReportForOrdersList struct {
|
|||||||
|
|
||||||
type PriceReferSnapshotExt struct {
|
type PriceReferSnapshotExt struct {
|
||||||
model.PriceReferSnapshot
|
model.PriceReferSnapshot
|
||||||
CityName string `json:"cityName"`
|
CityName string `json:"cityName"`
|
||||||
SkuName string `json:"skuName"`
|
SkuName string `json:"skuName"`
|
||||||
|
SpecQuality float32
|
||||||
|
Unit string
|
||||||
|
SpecUnit string
|
||||||
}
|
}
|
||||||
|
|
||||||
//查询统计订单信息
|
//查询统计订单信息
|
||||||
@@ -187,11 +190,7 @@ func GetGetStatisticsReportForAfsOrders(db *DaoDB, storeIDs []int, fromDate time
|
|||||||
|
|
||||||
func GetStatisticsReportForStoreSkusPrice(db *DaoDB, cityCodes, skuIDs []int) (priceReferSnapshot []*model.PriceReferSnapshot, err error) {
|
func GetStatisticsReportForStoreSkusPrice(db *DaoDB, cityCodes, skuIDs []int) (priceReferSnapshot []*model.PriceReferSnapshot, err error) {
|
||||||
sql := `
|
sql := `
|
||||||
SELECT b.city_code,a.sku_id,
|
SELECT b.city_code,a.sku_id,c.name_id,
|
||||||
ROUND(MAX(a.price/IF(b.pay_percentage=0,100,b.pay_percentage)*100)) max_price,
|
|
||||||
ROUND(MIN(a.price/IF(b.pay_percentage=0,100,b.pay_percentage)*100)) min_price,
|
|
||||||
ROUND(AVG(a.price/IF(b.pay_percentage=0,100,b.pay_percentage)*100)) avg_price,
|
|
||||||
ROUND(SUBSTRING_INDEX(SUBSTRING_INDEX(GROUP_CONCAT((a.price/IF(b.pay_percentage=0,100,b.pay_percentage))*100 ORDER BY (a.price/IF(b.pay_percentage=0,100,b.pay_percentage))*100),',',Count(1)/2),',',-1)) mid_price,
|
|
||||||
MAX(a.jd_price) max_jd_price,
|
MAX(a.jd_price) max_jd_price,
|
||||||
MIN(a.jd_price) min_jd_price,
|
MIN(a.jd_price) min_jd_price,
|
||||||
ROUND(AVG(a.jd_price)) avg_jd_price,
|
ROUND(AVG(a.jd_price)) avg_jd_price,
|
||||||
@@ -212,6 +211,7 @@ func GetStatisticsReportForStoreSkusPrice(db *DaoDB, cityCodes, skuIDs []int) (p
|
|||||||
t1.avg_vendor_price
|
t1.avg_vendor_price
|
||||||
FROM store_sku_bind a
|
FROM store_sku_bind a
|
||||||
JOIN store b ON a.store_id = b.id AND b.deleted_at = ? AND b.status != ?
|
JOIN store b ON a.store_id = b.id AND b.deleted_at = ? AND b.status != ?
|
||||||
|
JOIN sku c ON a.sku_id = c.id
|
||||||
LEFT JOIN (
|
LEFT JOIN (
|
||||||
SELECT SUM(t1.count),t1.sku_id,MAX(t1.sale_price) max_sale_price,MIN(t1.sale_price) min_sale_price,ROUND(AVG(t1.sale_price)) avg_sale_price,MAX(t1.vendor_price) max_vendor_price,MIN(t1.vendor_price) min_vendor_price,ROUND(AVG(t1.vendor_price)) avg_vendor_price
|
SELECT SUM(t1.count),t1.sku_id,MAX(t1.sale_price) max_sale_price,MIN(t1.sale_price) min_sale_price,ROUND(AVG(t1.sale_price)) avg_sale_price,MAX(t1.vendor_price) max_vendor_price,MIN(t1.vendor_price) min_vendor_price,ROUND(AVG(t1.vendor_price)) avg_vendor_price
|
||||||
FROM order_sku t1
|
FROM order_sku t1
|
||||||
@@ -219,14 +219,12 @@ func GetStatisticsReportForStoreSkusPrice(db *DaoDB, cityCodes, skuIDs []int) (p
|
|||||||
GROUP BY 2
|
GROUP BY 2
|
||||||
)t1 ON t1.sku_id = a.sku_id
|
)t1 ON t1.sku_id = a.sku_id
|
||||||
WHERE a.deleted_at = ?
|
WHERE a.deleted_at = ?
|
||||||
AND a.status = ?
|
|
||||||
`
|
`
|
||||||
sqlParams := []interface{}{
|
sqlParams := []interface{}{
|
||||||
utils.DefaultTimeValue,
|
utils.DefaultTimeValue,
|
||||||
model.StoreStatusDisabled,
|
model.StoreStatusDisabled,
|
||||||
time.Now().AddDate(0, -1, 0),
|
time.Now().AddDate(0, -1, 0),
|
||||||
utils.DefaultTimeValue,
|
utils.DefaultTimeValue,
|
||||||
model.SkuStatusNormal,
|
|
||||||
}
|
}
|
||||||
if len(skuIDs) > 0 {
|
if len(skuIDs) > 0 {
|
||||||
sql += " AND a.sku_id IN (" + GenQuestionMarks(len(skuIDs)) + ")"
|
sql += " AND a.sku_id IN (" + GenQuestionMarks(len(skuIDs)) + ")"
|
||||||
@@ -236,14 +234,14 @@ func GetStatisticsReportForStoreSkusPrice(db *DaoDB, cityCodes, skuIDs []int) (p
|
|||||||
sql += " AND b.city_code IN (" + GenQuestionMarks(len(cityCodes)) + ")"
|
sql += " AND b.city_code IN (" + GenQuestionMarks(len(cityCodes)) + ")"
|
||||||
sqlParams = append(sqlParams, cityCodes)
|
sqlParams = append(sqlParams, cityCodes)
|
||||||
}
|
}
|
||||||
sql += " GROUP BY 1,2"
|
sql += " GROUP BY 1,2,3"
|
||||||
if err = GetRows(db, &priceReferSnapshot, sql, sqlParams...); err == nil {
|
if err = GetRows(db, &priceReferSnapshot, sql, sqlParams...); err == nil {
|
||||||
return priceReferSnapshot, nil
|
return priceReferSnapshot, nil
|
||||||
}
|
}
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
func GetPriceReferSnapshot(db *DaoDB, cityCodes, skuIDs []int, snapDate time.Time, offset, pageSize int) (priceReferSnapshot []*PriceReferSnapshotExt, totalCount int, err error) {
|
func GetPriceReferSnapshot(db *DaoDB, cityCodes, skuIDs []int, skuNameID int, snapDate time.Time, offset, pageSize int) (priceReferSnapshot []*PriceReferSnapshotExt, totalCount int, err error) {
|
||||||
sql := `
|
sql := `
|
||||||
SELECT SQL_CALC_FOUND_ROWS a.*,b.name city_name
|
SELECT SQL_CALC_FOUND_ROWS a.*,b.name city_name
|
||||||
FROM price_refer_snapshot a
|
FROM price_refer_snapshot a
|
||||||
@@ -254,6 +252,10 @@ func GetPriceReferSnapshot(db *DaoDB, cityCodes, skuIDs []int, snapDate time.Tim
|
|||||||
sqlParams := []interface{}{
|
sqlParams := []interface{}{
|
||||||
utils.DefaultTimeValue,
|
utils.DefaultTimeValue,
|
||||||
}
|
}
|
||||||
|
if skuNameID > 0 {
|
||||||
|
sql += " AND a.name_id = ?"
|
||||||
|
sqlParams = append(sqlParams, skuNameID)
|
||||||
|
}
|
||||||
if len(skuIDs) > 0 {
|
if len(skuIDs) > 0 {
|
||||||
sql += " AND a.sku_id IN (" + GenQuestionMarks(len(skuIDs)) + ")"
|
sql += " AND a.sku_id IN (" + GenQuestionMarks(len(skuIDs)) + ")"
|
||||||
sqlParams = append(sqlParams, skuIDs)
|
sqlParams = append(sqlParams, skuIDs)
|
||||||
@@ -284,3 +286,44 @@ func GetPriceReferSnapshot(db *DaoDB, cityCodes, skuIDs []int, snapDate time.Tim
|
|||||||
}
|
}
|
||||||
return priceReferSnapshot, totalCount, err
|
return priceReferSnapshot, totalCount, err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func GetPriceReferSnapshotNoPage(db *DaoDB, cityCodes, skuIDs, skuNameIDs []int, snapDate time.Time) (priceReferSnapshot []*model.PriceReferSnapshot, err error) {
|
||||||
|
sql := `
|
||||||
|
SELECT a.*
|
||||||
|
FROM price_refer_snapshot a
|
||||||
|
WHERE 1=1
|
||||||
|
AND a.deleted_at = ?
|
||||||
|
`
|
||||||
|
sqlParams := []interface{}{
|
||||||
|
utils.DefaultTimeValue,
|
||||||
|
}
|
||||||
|
if len(skuNameIDs) > 0 {
|
||||||
|
sql += " AND a.name_id IN (" + GenQuestionMarks(len(skuNameIDs)) + ")"
|
||||||
|
sqlParams = append(sqlParams, skuNameIDs)
|
||||||
|
}
|
||||||
|
if len(skuIDs) > 0 {
|
||||||
|
sql += " AND a.sku_id IN (" + GenQuestionMarks(len(skuIDs)) + ")"
|
||||||
|
sqlParams = append(sqlParams, skuIDs)
|
||||||
|
}
|
||||||
|
if len(cityCodes) > 0 {
|
||||||
|
sql += " AND a.city_code IN (" + GenQuestionMarks(len(cityCodes)) + ")"
|
||||||
|
sqlParams = append(sqlParams, cityCodes)
|
||||||
|
}
|
||||||
|
if !utils.IsTimeZero(snapDate) {
|
||||||
|
sql += " AND a.snapshot_at = ?"
|
||||||
|
sqlParams = append(sqlParams, snapDate)
|
||||||
|
}
|
||||||
|
err = GetRows(db, &priceReferSnapshot, sql, sqlParams...)
|
||||||
|
return priceReferSnapshot, err
|
||||||
|
}
|
||||||
|
|
||||||
|
func DeletePriceReferHistory(db *DaoDB, snapDate time.Time) (num int64, err error) {
|
||||||
|
sql := `
|
||||||
|
DELETE FROM price_refer_snapshot
|
||||||
|
WHERE snapshot_at <= ?
|
||||||
|
`
|
||||||
|
sqlParams := []interface{}{
|
||||||
|
snapDate,
|
||||||
|
}
|
||||||
|
return ExecuteSQL(db, sql, sqlParams...)
|
||||||
|
}
|
||||||
|
|||||||
@@ -504,7 +504,7 @@ func GetStorePriceScore(db *DaoDB, storeIDs, vendorIDs []int, fromScore, toScore
|
|||||||
FROM store_price_score_snapshot a
|
FROM store_price_score_snapshot a
|
||||||
JOIN store b ON b.id = a.store_id
|
JOIN store b ON b.id = a.store_id
|
||||||
JOIN place e ON e.code = b.city_code
|
JOIN place e ON e.code = b.city_code
|
||||||
JOIN (SELECT a.store_id, count(d.type = ? OR NULL) direct_down_count, count(d.type = ? OR NULL) sec_kill_count
|
LEFT JOIN (SELECT a.store_id, count(d.type = ? OR NULL) direct_down_count, count(d.type = ? OR NULL) sec_kill_count
|
||||||
FROM store_sku_bind a
|
FROM store_sku_bind a
|
||||||
LEFT JOIN act_store_sku b ON a.store_id = b.store_id AND b.sku_id = a.sku_id
|
LEFT JOIN act_store_sku b ON a.store_id = b.store_id AND b.sku_id = a.sku_id
|
||||||
LEFT JOIN act_map c ON c.act_id = b.act_id
|
LEFT JOIN act_map c ON c.act_id = b.act_id
|
||||||
@@ -567,16 +567,15 @@ func GetStorePriceScore(db *DaoDB, storeIDs, vendorIDs []int, fromScore, toScore
|
|||||||
|
|
||||||
func GetStorePriceScoreSnapshot(db *DaoDB, snapDate time.Time) (storePriceScoreSnapshot []*model.StorePriceScoreSnapshot, err error) {
|
func GetStorePriceScoreSnapshot(db *DaoDB, snapDate time.Time) (storePriceScoreSnapshot []*model.StorePriceScoreSnapshot, err error) {
|
||||||
sql := `
|
sql := `
|
||||||
SELECT c.store_id,ROUND(count(c.price <= a.mid_price or NULL)/count(*)*100,2) score
|
SELECT c.store_id,ROUND(count(c.unit_price/IF(d.pay_percentage < 50 , 70, d.pay_percentage) <= a.mid_unit_price or NULL)/count(*)*100,2) score
|
||||||
FROM price_refer_snapshot a
|
FROM price_refer_snapshot a
|
||||||
JOIN store_sku_bind c ON c.sku_id = a.sku_id AND c.status = 1 AND c.deleted_at = ?
|
JOIN store_sku_bind c ON c.sku_id = a.sku_id AND c.status = ? AND c.deleted_at = ?
|
||||||
JOIN store d ON c.store_id = d.id AND d.city_code = a.city_code AND d.deleted_at = ? AND d.status != ?
|
JOIN store d ON c.store_id = d.id AND d.city_code = a.city_code AND d.deleted_at = ? AND d.status != ?
|
||||||
WHERE 1=1
|
WHERE 1=1
|
||||||
`
|
`
|
||||||
sqlParams := []interface{}{
|
sqlParams := []interface{}{
|
||||||
utils.DefaultTimeValue,
|
model.StoreSkuBindStatusNormal, utils.DefaultTimeValue,
|
||||||
utils.DefaultTimeValue,
|
utils.DefaultTimeValue, model.StoreStatusDisabled,
|
||||||
model.StoreStatusDisabled,
|
|
||||||
}
|
}
|
||||||
if !utils.IsTimeZero(snapDate) {
|
if !utils.IsTimeZero(snapDate) {
|
||||||
sql += " AND a.snapshot_at = ?"
|
sql += " AND a.snapshot_at = ?"
|
||||||
|
|||||||
@@ -132,6 +132,7 @@ type StoreSkuNameExt struct {
|
|||||||
|
|
||||||
PendingOpType int8 `json:"pendingOpType"` // 取值同 StoreOpRequest.Type
|
PendingOpType int8 `json:"pendingOpType"` // 取值同 StoreOpRequest.Type
|
||||||
PendingUnitPrice int `json:"pendingUnitPrice"` // 这个是待审核的价格申请
|
PendingUnitPrice int `json:"pendingUnitPrice"` // 这个是待审核的价格申请
|
||||||
|
Status int
|
||||||
}
|
}
|
||||||
|
|
||||||
// GetStoreSkus用
|
// GetStoreSkus用
|
||||||
@@ -1228,30 +1229,6 @@ func GetStoreSkuCategories(db *DaoDB, storeID, parentID int) (catList []*model.S
|
|||||||
return catList, err
|
return catList, err
|
||||||
}
|
}
|
||||||
|
|
||||||
func RefershStoreSkusMidPrice(db *DaoDB, storeIDs []int) (count int64, err error) {
|
|
||||||
sql := `
|
|
||||||
UPDATE store_sku_bind a
|
|
||||||
JOIN store d ON d.id = a.store_id
|
|
||||||
JOIN price_refer_snapshot b ON a.sku_id = b.sku_id AND b.snapshot_at = ? AND d.city_code = b.city_code
|
|
||||||
SET a.price = (b.mid_price*IF(d.pay_percentage=0,100,d.pay_percentage))/100
|
|
||||||
WHERE 1=1
|
|
||||||
`
|
|
||||||
sqlParams := []interface{}{
|
|
||||||
utils.Time2Date(time.Now().AddDate(0, 0, -1)),
|
|
||||||
}
|
|
||||||
if len(storeIDs) > 0 {
|
|
||||||
sql += " AND a.store_id IN (" + GenQuestionMarks(len(storeIDs)) + ")"
|
|
||||||
sqlParams = append(sqlParams, storeIDs)
|
|
||||||
}
|
|
||||||
sql += `
|
|
||||||
AND (a.price/IF(d.pay_percentage=0,100,d.pay_percentage))*100 > b.mid_price
|
|
||||||
AND a.deleted_at = ?
|
|
||||||
AND a.status = ?
|
|
||||||
`
|
|
||||||
sqlParams = append(sqlParams, utils.DefaultTimeValue, model.SkuStatusNormal)
|
|
||||||
return ExecuteSQL(db, sql, sqlParams)
|
|
||||||
}
|
|
||||||
|
|
||||||
func GetStoreSkuNamePrice(db *DaoDB) (storeSkuNamePriceList []*model.StoreSkuNamePrice, err error) {
|
func GetStoreSkuNamePrice(db *DaoDB) (storeSkuNamePriceList []*model.StoreSkuNamePrice, err error) {
|
||||||
sql := `
|
sql := `
|
||||||
SELECT *
|
SELECT *
|
||||||
@@ -1390,49 +1367,103 @@ func GetDeletedStoreSkuBind(db *DaoDB, storeID, skuID int) (storeSkuBind *model.
|
|||||||
return storeSkuBind
|
return storeSkuBind
|
||||||
}
|
}
|
||||||
|
|
||||||
func GetMidPriceByNameID(db *DaoDB, cityCode, skuNameID int, snapDate time.Time) (midPrice int, err error) {
|
func GetStoreSkuBindByNameID(db *DaoDB, storeID, nameID, status int) (storeSkuBind []*model.StoreSkuBind, err error) {
|
||||||
|
sql := `
|
||||||
|
SELECT c.*
|
||||||
|
FROM sku a
|
||||||
|
JOIN store_sku_bind c ON c.sku_id = a.id
|
||||||
|
WHERE c.store_id = ?
|
||||||
|
AND a.name_id = ?
|
||||||
|
AND c.deleted_at = ?
|
||||||
|
AND a.deleted_at = ?
|
||||||
|
AND c.status = ?
|
||||||
|
`
|
||||||
|
sqlParams := []interface{}{
|
||||||
|
storeID,
|
||||||
|
nameID,
|
||||||
|
utils.DefaultTimeValue,
|
||||||
|
utils.DefaultTimeValue,
|
||||||
|
status,
|
||||||
|
}
|
||||||
|
err = GetRows(db, &storeSkuBind, sql, sqlParams...)
|
||||||
|
return storeSkuBind, err
|
||||||
|
}
|
||||||
|
|
||||||
|
func GetPriceReferPrice(db *DaoDB, cityCode int, skuID int, snapDate time.Time) (result *PriceReferSnapshotExt, err error) {
|
||||||
var (
|
var (
|
||||||
sku []*model.SkuAndName
|
pRefer *PriceReferSnapshotExt
|
||||||
skuMap = make(map[int]int)
|
priceRefer = &PriceReferSnapshotExt{}
|
||||||
)
|
)
|
||||||
sql := `
|
sql := `
|
||||||
SELECT a.mid_price price, a.sku_id id, b.spec_quality, c.unit, b.spec_unit
|
SELECT a.max_unit_price, a.min_unit_price, a.avg_unit_price, a.mid_unit_price, a.sku_id id, b.spec_quality, c.unit, b.spec_unit
|
||||||
FROM price_refer_snapshot a
|
FROM price_refer_snapshot a
|
||||||
JOIN sku b ON a.sku_id = b.id
|
JOIN sku b ON a.sku_id = b.id
|
||||||
JOIN sku_name c ON c.id = b.name_id
|
JOIN sku_name c ON c.id = b.name_id
|
||||||
WHERE c.id = ?
|
WHERE 1=1
|
||||||
AND a.snapshot_at = ?
|
AND a.snapshot_at = ?
|
||||||
AND a.city_code = ?
|
AND a.city_code = ?
|
||||||
`
|
`
|
||||||
sqlParams := []interface{}{
|
sqlParams := []interface{}{
|
||||||
skuNameID,
|
|
||||||
snapDate,
|
snapDate,
|
||||||
cityCode,
|
cityCode,
|
||||||
}
|
}
|
||||||
err = GetRows(db, &sku, sql, sqlParams...)
|
if skuID > 0 {
|
||||||
if err != nil {
|
sql += " AND a.sku_id = ?"
|
||||||
return 0, err
|
sqlParams = append(sqlParams, skuID)
|
||||||
}
|
}
|
||||||
if len(sku) > 0 {
|
err = GetRow(db, &pRefer, sql, sqlParams...)
|
||||||
for _, v := range sku {
|
if err != nil {
|
||||||
var (
|
return nil, err
|
||||||
price int
|
}
|
||||||
specQuality float64
|
if pRefer != nil {
|
||||||
)
|
var (
|
||||||
if v.Unit == model.SpecialUnit {
|
specQuality float64
|
||||||
if v.SpecUnit == model.SpecUnitNames[1] || v.SpecUnit == model.SpecUnitNames[2] {
|
)
|
||||||
specQuality = float64(v.SpecQuality) * 1000
|
if pRefer.Unit == model.SpecialUnit {
|
||||||
} else {
|
if pRefer.SpecUnit == model.SpecUnitNames[1] || pRefer.SpecUnit == model.SpecUnitNames[2] {
|
||||||
specQuality = float64(v.SpecQuality)
|
specQuality = float64(pRefer.SpecQuality) * 1000
|
||||||
}
|
|
||||||
price = int(utils.Float64TwoInt64(utils.Int2Float64(model.SpecialSpecQuality) / specQuality * utils.Int2Float64(v.Price)))
|
|
||||||
} else {
|
} else {
|
||||||
price = v.Price
|
specQuality = float64(pRefer.SpecQuality)
|
||||||
}
|
|
||||||
if skuMap[skuNameID] < price {
|
|
||||||
skuMap[skuNameID] = price
|
|
||||||
}
|
}
|
||||||
|
priceRefer.MaxPrice = int(utils.Float64TwoInt64(specQuality / utils.Int2Float64(model.SpecialSpecQuality) * utils.Int2Float64(pRefer.MaxUnitPrice)))
|
||||||
|
priceRefer.MinPrice = int(utils.Float64TwoInt64(specQuality / utils.Int2Float64(model.SpecialSpecQuality) * utils.Int2Float64(pRefer.MinUnitPrice)))
|
||||||
|
priceRefer.AvgPrice = int(utils.Float64TwoInt64(specQuality / utils.Int2Float64(model.SpecialSpecQuality) * utils.Int2Float64(pRefer.AvgUnitPrice)))
|
||||||
|
priceRefer.MidPrice = int(utils.Float64TwoInt64(specQuality / utils.Int2Float64(model.SpecialSpecQuality) * utils.Int2Float64(pRefer.MidUnitPrice)))
|
||||||
|
} else {
|
||||||
|
priceRefer.MaxPrice = pRefer.MaxUnitPrice
|
||||||
|
priceRefer.MinPrice = pRefer.MinUnitPrice
|
||||||
|
priceRefer.AvgPrice = pRefer.AvgUnitPrice
|
||||||
|
priceRefer.MidPrice = pRefer.MidUnitPrice
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return skuMap[skuNameID], err
|
return priceRefer, err
|
||||||
|
}
|
||||||
|
|
||||||
|
func GetStoreSkusAndSkuName(db *DaoDB, storeIDs, skuIDs, nameIDs []int) (storeSkuNameExt []*StoreSkuNameExt, err error) {
|
||||||
|
sql := `
|
||||||
|
SELECT a.*,c.id
|
||||||
|
FROM store_sku_bind a
|
||||||
|
JOIN sku b ON b.id = a.sku_id AND b.deleted_at = ?
|
||||||
|
JOIN sku_name c ON c.id = b.name_id AND c.deleted_at = ?
|
||||||
|
WHERE a.deleted_at = ?
|
||||||
|
`
|
||||||
|
sqlParams := []interface{}{
|
||||||
|
utils.DefaultTimeValue,
|
||||||
|
utils.DefaultTimeValue,
|
||||||
|
utils.DefaultTimeValue,
|
||||||
|
}
|
||||||
|
if len(storeIDs) > 0 {
|
||||||
|
sql += " AND a.store_id IN (" + GenQuestionMarks(len(storeIDs)) + ")"
|
||||||
|
sqlParams = append(sqlParams, storeIDs)
|
||||||
|
}
|
||||||
|
if len(skuIDs) > 0 {
|
||||||
|
sql += " AND a.sku_id IN (" + GenQuestionMarks(len(skuIDs)) + ")"
|
||||||
|
sqlParams = append(sqlParams, skuIDs)
|
||||||
|
}
|
||||||
|
if len(nameIDs) > 0 {
|
||||||
|
sql += " AND b.name_id IN (" + GenQuestionMarks(len(nameIDs)) + ")"
|
||||||
|
sqlParams = append(sqlParams, nameIDs)
|
||||||
|
}
|
||||||
|
err = GetRows(db, &storeSkuNameExt, sql, sqlParams...)
|
||||||
|
return storeSkuNameExt, err
|
||||||
}
|
}
|
||||||
|
|||||||
35
business/model/event.go
Normal file
35
business/model/event.go
Normal file
@@ -0,0 +1,35 @@
|
|||||||
|
package model
|
||||||
|
|
||||||
|
import "time"
|
||||||
|
|
||||||
|
type OperateEvent struct {
|
||||||
|
ID int64 `orm:"column(id)" json:"id"`
|
||||||
|
CreatedAt time.Time `orm:"auto_now_add;type(datetime)" json:"createdAt"`
|
||||||
|
LastOperator string `orm:"size(32)" json:"lastOperator"` // 最后操作员
|
||||||
|
AccessUUID string `orm:"column(access_uuid)" json:"accessUUID"`
|
||||||
|
UserID string `orm:"column(user_id)" json:"userID"`
|
||||||
|
APIFunction string `orm:"column(api_function)" json:"apiFunction"`
|
||||||
|
}
|
||||||
|
|
||||||
|
func (v *OperateEvent) TableIndex() [][]string {
|
||||||
|
return [][]string{
|
||||||
|
[]string{"AccessUUID", "UserID"},
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
type OperateEventDetail struct {
|
||||||
|
ID int64 `orm:"column(id)" json:"id"`
|
||||||
|
OperateType int `json:"operateType"` // 1为修改,2为新增,4为删除
|
||||||
|
ThingID int `orm:"column(thing_id)" json:"thingID"`
|
||||||
|
ThingType int `json:"thingType"` //各字段类型
|
||||||
|
StoreID int `orm:"column(store_id)" json:"storeID"`
|
||||||
|
AccessUUID string `orm:"column(access_uuid)" json:"accessUUID"`
|
||||||
|
BeforeData string `orm:"size(32)" json:"beforeData"`
|
||||||
|
AfterData string `orm:"size(32)" json:"afterData"`
|
||||||
|
}
|
||||||
|
|
||||||
|
func (v *OperateEventDetail) TableIndex() [][]string {
|
||||||
|
return [][]string{
|
||||||
|
[]string{"AccessUUID", "ThingID", "StoreID"},
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -346,7 +346,22 @@ type OrderPayRefund struct {
|
|||||||
|
|
||||||
type OrderSupplementFee struct {
|
type OrderSupplementFee struct {
|
||||||
ModelIDCULD
|
ModelIDCULD
|
||||||
VendorOrderID string `orm:"column(vendor_order_id);index;size(48)" json:"vendorOrderID"`
|
StoreID int `orm:"column(store_id)" json:"storeID"`
|
||||||
|
VendorOrderID *string `orm:"column(vendor_order_id);size(48)" json:"vendorOrderID"`
|
||||||
|
VendorID *string `orm:"column(vendor_id)" json:"vendorID"`
|
||||||
|
Status int `json:"status"` //账单状态,若已结账则不允许再修改 ,暂时 0为未结账,1为已结账,-1为作废
|
||||||
|
LinkID int `orm:"column(link_id)" json:"linkID"` //作为冲账标志关联某条扣款记录
|
||||||
|
SupplementTime *time.Time `orm:"type(datetime);null" json:"supplementTime"`
|
||||||
|
Type int `json:"type"` //扣款类型,1为差评订单补贴,2为优惠券
|
||||||
|
SupplementFee int `json:"supplementFee"` //扣款金额
|
||||||
|
BillID string `orm:"column(bill_id);size(48)" json:"billID"` //账单ID
|
||||||
|
Comment string `orm:"size(255)" json:"comment"`
|
||||||
|
}
|
||||||
|
|
||||||
|
func (v *OrderSupplementFee) TableIndex() [][]string {
|
||||||
|
return [][]string{
|
||||||
|
[]string{"StoreID", "VendorOrderID", "SupplementTime"},
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// 判断是否是购买平台自有物流
|
// 判断是否是购买平台自有物流
|
||||||
|
|||||||
@@ -444,10 +444,15 @@ type PriceReferSnapshot struct {
|
|||||||
SnapshotAt time.Time `orm:"type(datetime)" json:"snapshotAt"` // 这个不同于CreatedAt,SnapshotAt是逻辑上的时间,CreatedAt是实际存储的时间
|
SnapshotAt time.Time `orm:"type(datetime)" json:"snapshotAt"` // 这个不同于CreatedAt,SnapshotAt是逻辑上的时间,CreatedAt是实际存储的时间
|
||||||
CityCode int `json:"cityCode"`
|
CityCode int `json:"cityCode"`
|
||||||
SkuID int `orm:"column(sku_id)" json:"skuId"`
|
SkuID int `orm:"column(sku_id)" json:"skuId"`
|
||||||
|
NameID int `orm:"column(name_id)" json:"nameID"`
|
||||||
MaxPrice int `json:"maxPrice"`
|
MaxPrice int `json:"maxPrice"`
|
||||||
MinPrice int `json:"minPrice"`
|
MinPrice int `json:"minPrice"`
|
||||||
AvgPrice int `json:"avgPrice"`
|
AvgPrice int `json:"avgPrice"`
|
||||||
MidPrice int `json:"midPrice"`
|
MidPrice int `json:"midPrice"`
|
||||||
|
MaxUnitPrice int `json:"maxUnitPrice"`
|
||||||
|
MinUnitPrice int `json:"minUnitPrice"`
|
||||||
|
AvgUnitPrice int `json:"avgUnitPrice"`
|
||||||
|
MidUnitPrice int `json:"midUnitPrice"`
|
||||||
MaxJdPrice int `json:"maxJdPrice"`
|
MaxJdPrice int `json:"maxJdPrice"`
|
||||||
MinJdPrice int `json:"minJdPrice"`
|
MinJdPrice int `json:"minJdPrice"`
|
||||||
AvgJdPrice int `json:"avgJdPrice"`
|
AvgJdPrice int `json:"avgJdPrice"`
|
||||||
|
|||||||
@@ -926,6 +926,49 @@ func (c *OrderController) ComplaintRider() {
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// @Title 查询门店订单扣款记录
|
||||||
|
// @Description 查询门店订单扣款记录
|
||||||
|
// @Param token header string true "认证token"
|
||||||
|
// @Param storeIDs query string false "门店ID列表"
|
||||||
|
// @Param vendorOrderID query string false "订单ID"
|
||||||
|
// @Param vendorIDs query string false "订单所属厂商ID列表"
|
||||||
|
// @Param fromTime query string false "开始日期(包含),格式(2006-01-02),如果订单号为空此项必须要求"
|
||||||
|
// @Param toTime query string false "结束日期(包含),格式(2006-01-02),如果订单号为空此项必须要求"
|
||||||
|
// @Param status query int false "账单状态,0是未结账,1是已结账"
|
||||||
|
// @Param type query int false "扣款类型,1为差评补贴,2为优惠券"
|
||||||
|
// @Param isReverse query int false "只查冲账记录,0为默认都查,1为只查冲账,-1为不查冲账"
|
||||||
|
// @Param offset query int false "结果起始序号(以0开始,缺省为0)"
|
||||||
|
// @Param pageSize query int false "结果页大小(缺省为50,-1表示全部)"
|
||||||
|
// @Success 200 {object} controllers.CallResult
|
||||||
|
// @Failure 200 {object} controllers.CallResult
|
||||||
|
// @router /GetOrdersSupplement [get]
|
||||||
|
func (c *OrderController) GetOrdersSupplement() {
|
||||||
|
var vendorIDList, storeIDList []int
|
||||||
|
c.callGetOrdersSupplement(func(params *tOrderGetOrdersSupplementParams) (retVal interface{}, errCode string, err error) {
|
||||||
|
if err = jxutils.Strings2Objs(params.VendorIDs, &vendorIDList, params.StoreIDs, &storeIDList); err == nil {
|
||||||
|
retVal, err = orderman.GetOrdersSupplement(params.Ctx, storeIDList, vendorIDList, params.VendorOrderID, params.FromTime, params.ToTime, params.Status, params.Type, params.IsReverse, params.Offset, params.PageSize)
|
||||||
|
}
|
||||||
|
return retVal, "", err
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
// @Title 新增修改扣款记录
|
||||||
|
// @Description 新增修改扣款记录
|
||||||
|
// @Param token header string true "认证token"
|
||||||
|
// @Param payload formData string true "json数据,格式为OrdersSupplement"
|
||||||
|
// @Success 200 {object} controllers.CallResult
|
||||||
|
// @Failure 200 {object} controllers.CallResult
|
||||||
|
// @router /AddUpdateOrdersSupplement [post]
|
||||||
|
func (c *OrderController) AddUpdateOrdersSupplement() {
|
||||||
|
c.callAddUpdateOrdersSupplement(func(params *tOrderAddUpdateOrdersSupplementParams) (retVal interface{}, errCode string, err error) {
|
||||||
|
ordersSupplement := &model.OrderSupplementFee{}
|
||||||
|
if err = utils.UnmarshalUseNumber([]byte(params.Payload), ordersSupplement); err == nil {
|
||||||
|
retVal, err = orderman.AddUpdateOrdersSupplement(params.Ctx, ordersSupplement)
|
||||||
|
}
|
||||||
|
return retVal, "", err
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
// @Title 重新计算订单结算信息
|
// @Title 重新计算订单结算信息
|
||||||
// @Description 重新计算订单结算信息
|
// @Description 重新计算订单结算信息
|
||||||
// @Param token header string true "认证token"
|
// @Param token header string true "认证token"
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
package controllers
|
package controllers
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"git.rosy.net.cn/jx-callback/business/jxstore/cms"
|
||||||
"git.rosy.net.cn/jx-callback/business/jxstore/report"
|
"git.rosy.net.cn/jx-callback/business/jxstore/report"
|
||||||
"git.rosy.net.cn/jx-callback/business/jxutils"
|
"git.rosy.net.cn/jx-callback/business/jxutils"
|
||||||
"github.com/astaxie/beego"
|
"github.com/astaxie/beego"
|
||||||
@@ -78,7 +79,20 @@ func (c *ReportController) StatisticsReportForStoreSkusPrice() {
|
|||||||
// @router /PriceRefer [post]
|
// @router /PriceRefer [post]
|
||||||
func (c *ReportController) PriceRefer() {
|
func (c *ReportController) PriceRefer() {
|
||||||
c.callPriceRefer(func(params *tReportPriceReferParams) (retVal interface{}, errCode string, err error) {
|
c.callPriceRefer(func(params *tReportPriceReferParams) (retVal interface{}, errCode string, err error) {
|
||||||
report.BeginSavePriceRefer(params.Ctx, nil, nil)
|
report.BeginSavePriceRefer(params.Ctx, nil, nil, true, true)
|
||||||
|
return retVal, "", err
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
// @Title 自动关注商品(针对后加的商品规格未关注)
|
||||||
|
// @Description 自动关注商品(针对后加的商品规格未关注)
|
||||||
|
// @Param token header string true "认证token"
|
||||||
|
// @Success 200 {object} controllers.CallResult
|
||||||
|
// @Failure 200 {object} controllers.CallResult
|
||||||
|
// @router /AutoFocusStoreSkus [post]
|
||||||
|
func (c *ReportController) AutoFocusStoreSkus() {
|
||||||
|
c.callAutoFocusStoreSkus(func(params *tReportAutoFocusStoreSkusParams) (retVal interface{}, errCode string, err error) {
|
||||||
|
cms.AutoFocusStoreSkusWithoutFocus(params.Ctx, nil, false)
|
||||||
return retVal, "", err
|
return retVal, "", err
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -41,6 +41,9 @@ func Init() {
|
|||||||
orm.RegisterModel(&model.PriceReferSnapshot{})
|
orm.RegisterModel(&model.PriceReferSnapshot{})
|
||||||
orm.RegisterModel(&model.StorePriceScoreSnapshot{})
|
orm.RegisterModel(&model.StorePriceScoreSnapshot{})
|
||||||
orm.RegisterModel(&model.StoreSkuNamePrice{})
|
orm.RegisterModel(&model.StoreSkuNamePrice{})
|
||||||
|
orm.RegisterModel(&model.OrderSupplementFee{})
|
||||||
|
orm.RegisterModel(&model.OperateEvent{})
|
||||||
|
orm.RegisterModel(&model.OperateEventDetail{})
|
||||||
|
|
||||||
// orm.RegisterModel(&model.ActivityForSku{})
|
// orm.RegisterModel(&model.ActivityForSku{})
|
||||||
// orm.RegisterModel(&legacymodel.JxBadComments2{})
|
// orm.RegisterModel(&legacymodel.JxBadComments2{})
|
||||||
|
|||||||
@@ -720,6 +720,15 @@ func init() {
|
|||||||
Filters: nil,
|
Filters: nil,
|
||||||
Params: nil})
|
Params: nil})
|
||||||
|
|
||||||
|
beego.GlobalControllerRouter["git.rosy.net.cn/jx-callback/controllers:OrderController"] = append(beego.GlobalControllerRouter["git.rosy.net.cn/jx-callback/controllers:OrderController"],
|
||||||
|
beego.ControllerComments{
|
||||||
|
Method: "AddUpdateOrdersSupplement",
|
||||||
|
Router: `/AddUpdateOrdersSupplement`,
|
||||||
|
AllowHTTPMethods: []string{"post"},
|
||||||
|
MethodParams: param.Make(),
|
||||||
|
Filters: nil,
|
||||||
|
Params: nil})
|
||||||
|
|
||||||
beego.GlobalControllerRouter["git.rosy.net.cn/jx-callback/controllers:OrderController"] = append(beego.GlobalControllerRouter["git.rosy.net.cn/jx-callback/controllers:OrderController"],
|
beego.GlobalControllerRouter["git.rosy.net.cn/jx-callback/controllers:OrderController"] = append(beego.GlobalControllerRouter["git.rosy.net.cn/jx-callback/controllers:OrderController"],
|
||||||
beego.ControllerComments{
|
beego.ControllerComments{
|
||||||
Method: "AdjustOrder",
|
Method: "AdjustOrder",
|
||||||
@@ -936,6 +945,15 @@ func init() {
|
|||||||
Filters: nil,
|
Filters: nil,
|
||||||
Params: nil})
|
Params: nil})
|
||||||
|
|
||||||
|
beego.GlobalControllerRouter["git.rosy.net.cn/jx-callback/controllers:OrderController"] = append(beego.GlobalControllerRouter["git.rosy.net.cn/jx-callback/controllers:OrderController"],
|
||||||
|
beego.ControllerComments{
|
||||||
|
Method: "GetOrdersSupplement",
|
||||||
|
Router: `/GetOrdersSupplement`,
|
||||||
|
AllowHTTPMethods: []string{"get"},
|
||||||
|
MethodParams: param.Make(),
|
||||||
|
Filters: nil,
|
||||||
|
Params: nil})
|
||||||
|
|
||||||
beego.GlobalControllerRouter["git.rosy.net.cn/jx-callback/controllers:OrderController"] = append(beego.GlobalControllerRouter["git.rosy.net.cn/jx-callback/controllers:OrderController"],
|
beego.GlobalControllerRouter["git.rosy.net.cn/jx-callback/controllers:OrderController"] = append(beego.GlobalControllerRouter["git.rosy.net.cn/jx-callback/controllers:OrderController"],
|
||||||
beego.ControllerComments{
|
beego.ControllerComments{
|
||||||
Method: "GetPrinterStatus",
|
Method: "GetPrinterStatus",
|
||||||
@@ -1098,6 +1116,15 @@ func init() {
|
|||||||
Filters: nil,
|
Filters: nil,
|
||||||
Params: nil})
|
Params: nil})
|
||||||
|
|
||||||
|
beego.GlobalControllerRouter["git.rosy.net.cn/jx-callback/controllers:ReportController"] = append(beego.GlobalControllerRouter["git.rosy.net.cn/jx-callback/controllers:ReportController"],
|
||||||
|
beego.ControllerComments{
|
||||||
|
Method: "AutoFocusStoreSkus",
|
||||||
|
Router: `/AutoFocusStoreSkus`,
|
||||||
|
AllowHTTPMethods: []string{"post"},
|
||||||
|
MethodParams: param.Make(),
|
||||||
|
Filters: nil,
|
||||||
|
Params: nil})
|
||||||
|
|
||||||
beego.GlobalControllerRouter["git.rosy.net.cn/jx-callback/controllers:ReportController"] = append(beego.GlobalControllerRouter["git.rosy.net.cn/jx-callback/controllers:ReportController"],
|
beego.GlobalControllerRouter["git.rosy.net.cn/jx-callback/controllers:ReportController"] = append(beego.GlobalControllerRouter["git.rosy.net.cn/jx-callback/controllers:ReportController"],
|
||||||
beego.ControllerComments{
|
beego.ControllerComments{
|
||||||
Method: "PriceRefer",
|
Method: "PriceRefer",
|
||||||
|
|||||||
Reference in New Issue
Block a user