From 16f445bd6009e78fe6e2903116c2f8bfe639529a Mon Sep 17 00:00:00 2001 From: richboo111 Date: Wed, 16 Aug 2023 13:57:18 +0800 Subject: [PATCH 1/5] 1 --- business/jxstore/cms/store.go | 29 +++++++++++++---------- business/partner/delivery/sfps/waybill.go | 6 ++++- 2 files changed, 21 insertions(+), 14 deletions(-) diff --git a/business/jxstore/cms/store.go b/business/jxstore/cms/store.go index 075d740b8..895e91bfd 100644 --- a/business/jxstore/cms/store.go +++ b/business/jxstore/cms/store.go @@ -132,19 +132,19 @@ type VendorStoreExcel struct { //门店信息 type StoreInfo struct { - StoreID int `json:"storeID"` //门店ID - StoreName string `json:"storeName"` //门店名字 - OpenTime1 int16 `json:"openTime1"` // 930就表示9点半,用两个的原因是为了支持中午休息,1与2的时间段不能交叉,为0表示没有 - CloseTime1 int16 `json:"closeTime1"` // 营业时间 1 - OpenTime2 int16 `json:"openTime2"` // 营业时间2 - CloseTime2 int16 `json:"closeTime2"` - Status int `json:"status"` //门店是否营业 - Distance int `json:"distance"` //店铺与定位 直线距离 - Address string `json:"address"` //门店地址 - BrandID int `orm:"column(brand_id)" json:"brandID"` //品牌ID - BrandName string `json:"brandName"` //品牌名字 - BrandLogo string `json:"brandLogo"` //品牌logo - //WeeklyScore int `json:"weeklyScore"` //店铺每周评分 + StoreID int `json:"storeID"` //门店ID + StoreName string `json:"storeName"` //门店名字 + OpenTime1 int16 `json:"openTime1"` // 930就表示9点半,用两个的原因是为了支持中午休息,1与2的时间段不能交叉,为0表示没有 + CloseTime1 int16 `json:"closeTime1"` // 营业时间 1 + OpenTime2 int16 `json:"openTime2"` // 营业时间2 + CloseTime2 int16 `json:"closeTime2"` + Status int `json:"status"` //门店是否营业 + Distance int `json:"distance"` //店铺与定位 直线距离 + Address string `json:"address"` //门店地址 + BrandID int `orm:"column(brand_id)" json:"brandID"` //品牌ID + BrandName string `json:"brandName"` //品牌名字 + BrandLogo string `json:"brandLogo"` //品牌logo + StoreWeeklyScore int `json:"storeWeeklyScore"` //店铺每周评分 } //门店减免策略 @@ -5925,6 +5925,9 @@ func GetHomePageByLocation(ctx *jxcontext.Context, lng, lat float64, needWalkDis if err != nil { return nil, "获取门店品牌信息失败", err } + //获取门店每周评分 + //storeScore, err := misc.GetWeeklyStoreScore(v.ID, 0) + storeInfo := StoreInfo{ StoreID: v.ID, StoreName: v.Name, diff --git a/business/partner/delivery/sfps/waybill.go b/business/partner/delivery/sfps/waybill.go index 78cf28e38..177a500c8 100644 --- a/business/partner/delivery/sfps/waybill.go +++ b/business/partner/delivery/sfps/waybill.go @@ -208,14 +208,18 @@ func (d DeliveryHandler) CancelWaybill(bill *model.Waybill, cancelReasonID int, deductionFee, err := api.SfPsAPI.PreCancelOrder(bill.VendorWaybillID) if deductionFee == 0 || err != nil { money = 0 + } else { + money = utils.Float64TwoInt64(deductionFee) } - money = utils.Float64TwoInt64(deductionFee) + globals.SugarLogger.Debugf("CancelWaybill money=%d", money) if err = api.SfPsAPI.CancelOrder(bill.VendorWaybillID); err != nil { return err } bill.Status = model.WaybillStatusCanceled bill.Remark = cancelReason bill.DesiredFee = money //取消成功才赋值违约金 + globals.SugarLogger.Debugf("CancelWaybill bill=%s", utils.Format4Output(bill, false)) + partner.CurOrderManager.OnWaybillStatusChanged(bill) return nil } From faa6b2eef8ca75cf71e2a6e28732cd11ab159e5d Mon Sep 17 00:00:00 2001 From: richboo111 Date: Wed, 16 Aug 2023 14:24:47 +0800 Subject: [PATCH 2/5] 1 --- business/jxcallback/orderman/waybill.go | 5 +++++ business/partner/delivery/sfps/waybill.go | 1 + 2 files changed, 6 insertions(+) diff --git a/business/jxcallback/orderman/waybill.go b/business/jxcallback/orderman/waybill.go index 73722a7b3..5bc0e0a68 100644 --- a/business/jxcallback/orderman/waybill.go +++ b/business/jxcallback/orderman/waybill.go @@ -156,6 +156,11 @@ func (w *OrderManager) OnWaybillStatusChanged(bill *model.Waybill) (err error) { if bill.ActualFee > 0 { addParams["actual_fee"] = bill.ActualFee } + //单独增加顺丰派送取消运单修改配送费逻辑 + if bill.Status == model.WaybillStatusCanceled && bill.WaybillVendorID == model.VendorIDSFPS { + addParams["desired_fee"] = bill.DesiredFee + addParams["actual_fee"] = bill.ActualFee + } } if bill.CourierMobile != "" { addParams["courier_name"] = bill.CourierName diff --git a/business/partner/delivery/sfps/waybill.go b/business/partner/delivery/sfps/waybill.go index 177a500c8..5612c0d56 100644 --- a/business/partner/delivery/sfps/waybill.go +++ b/business/partner/delivery/sfps/waybill.go @@ -218,6 +218,7 @@ func (d DeliveryHandler) CancelWaybill(bill *model.Waybill, cancelReasonID int, bill.Status = model.WaybillStatusCanceled bill.Remark = cancelReason bill.DesiredFee = money //取消成功才赋值违约金 + bill.ActualFee = money globals.SugarLogger.Debugf("CancelWaybill bill=%s", utils.Format4Output(bill, false)) partner.CurOrderManager.OnWaybillStatusChanged(bill) From a6ed45e5319408bb58b32eef58fdf758ba7e3f02 Mon Sep 17 00:00:00 2001 From: richboo111 Date: Wed, 16 Aug 2023 14:48:15 +0800 Subject: [PATCH 3/5] 1 --- business/jxcallback/orderman/waybill.go | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/business/jxcallback/orderman/waybill.go b/business/jxcallback/orderman/waybill.go index 5bc0e0a68..c720a0680 100644 --- a/business/jxcallback/orderman/waybill.go +++ b/business/jxcallback/orderman/waybill.go @@ -156,11 +156,11 @@ func (w *OrderManager) OnWaybillStatusChanged(bill *model.Waybill) (err error) { if bill.ActualFee > 0 { addParams["actual_fee"] = bill.ActualFee } - //单独增加顺丰派送取消运单修改配送费逻辑 - if bill.Status == model.WaybillStatusCanceled && bill.WaybillVendorID == model.VendorIDSFPS { - addParams["desired_fee"] = bill.DesiredFee - addParams["actual_fee"] = bill.ActualFee - } + } + //单独增加顺丰派送取消运单修改配送费逻辑 + if bill.WaybillVendorID == model.VendorIDSFPS && bill.Status == model.WaybillStatusCanceled { + addParams["desired_fee"] = bill.DesiredFee + addParams["actual_fee"] = bill.ActualFee } if bill.CourierMobile != "" { addParams["courier_name"] = bill.CourierName From a02e067870aba2f0b2e33c2e408ec8f0adbbc8c0 Mon Sep 17 00:00:00 2001 From: richboo111 Date: Wed, 16 Aug 2023 15:15:46 +0800 Subject: [PATCH 4/5] 1 --- business/jxstore/cms/store.go | 30 ++++++++++++++++++------------ 1 file changed, 18 insertions(+), 12 deletions(-) diff --git a/business/jxstore/cms/store.go b/business/jxstore/cms/store.go index 895e91bfd..464d1fc3f 100644 --- a/business/jxstore/cms/store.go +++ b/business/jxstore/cms/store.go @@ -14,6 +14,8 @@ import ( "strings" "time" + "git.rosy.net.cn/jx-callback/business/jxstore/misc" + "git.rosy.net.cn/baseapi/platformapi/tao_vegetable" "git.rosy.net.cn/jx-callback/business/partner/purchase/mtwm" @@ -5900,6 +5902,7 @@ func GetHomePageByLocation(ctx *jxcontext.Context, lng, lat float64, needWalkDis //获取门店信息 var ( storeID []int + storeScore = 0 storeInfos []StoreInfo storeDeductionInfo StoreDeductionInfo storeDeductionInfos []StoreDeductionInfo @@ -5926,20 +5929,23 @@ func GetHomePageByLocation(ctx *jxcontext.Context, lng, lat float64, needWalkDis return nil, "获取门店品牌信息失败", err } //获取门店每周评分 - //storeScore, err := misc.GetWeeklyStoreScore(v.ID, 0) + if scores, err := misc.GetWeeklyStoreScore(v.ID, 0); err == nil && len(scores) > 0 { + storeScore = scores[0].TotalScore + } storeInfo := StoreInfo{ - StoreID: v.ID, - StoreName: v.Name, - OpenTime1: v.OpenTime1, - CloseTime1: v.CloseTime1, - OpenTime2: v.OpenTime2, - CloseTime2: v.CloseTime2, - Status: v.Status, - Distance: v.Distance, - Address: v.Address, - BrandName: brandInfos.Name, - BrandLogo: brandInfos.Logo, + StoreID: v.ID, + StoreName: v.Name, + OpenTime1: v.OpenTime1, + CloseTime1: v.CloseTime1, + OpenTime2: v.OpenTime2, + CloseTime2: v.CloseTime2, + Status: v.Status, + Distance: v.Distance, + Address: v.Address, + BrandName: brandInfos.Name, + BrandLogo: brandInfos.Logo, + StoreWeeklyScore: storeScore, } storeInfos = append(storeInfos, storeInfo) //获取门店减免策略 From fceea25e750bb2a041edcd4e78260384566c736b Mon Sep 17 00:00:00 2001 From: richboo111 Date: Wed, 16 Aug 2023 15:23:28 +0800 Subject: [PATCH 5/5] 1 --- business/jxstore/cms/store.go | 126 +++++++++++++++++++++++++++++++++- 1 file changed, 123 insertions(+), 3 deletions(-) diff --git a/business/jxstore/cms/store.go b/business/jxstore/cms/store.go index 464d1fc3f..32dde01f5 100644 --- a/business/jxstore/cms/store.go +++ b/business/jxstore/cms/store.go @@ -14,8 +14,6 @@ import ( "strings" "time" - "git.rosy.net.cn/jx-callback/business/jxstore/misc" - "git.rosy.net.cn/baseapi/platformapi/tao_vegetable" "git.rosy.net.cn/jx-callback/business/partner/purchase/mtwm" @@ -5929,7 +5927,7 @@ func GetHomePageByLocation(ctx *jxcontext.Context, lng, lat float64, needWalkDis return nil, "获取门店品牌信息失败", err } //获取门店每周评分 - if scores, err := misc.GetWeeklyStoreScore(v.ID, 0); err == nil && len(scores) > 0 { + if scores, err := GetWeeklyStoreScore(v.ID, 0); err == nil && len(scores) > 0 { storeScore = scores[0].TotalScore } @@ -6460,3 +6458,125 @@ func GetVendorStoreBind(vendorStoreId string, vendorId int) (int, error) { func BindJxPrintToStore(storeId int64, printSn, printKey string) error { return dao.BindJXPrintToStore(storeId, printSn, printKey) } + +var ( + storeScoreFieldName = []string{ + model.FieldStoreOpenTime, + model.FieldSaleSkuCount, + model.FieldAveragePickupTime, + model.FieldBadCommentOrder, + model.FieldUnfinishOrder, + model.FieldAbsentGoodsOrder, + model.FieldPromotionSku, + model.FieldFullVendor, + model.FieldStoreRange, + model.FieldSaleSkuPrice, + } +) + +func GetWeeklyStoreScore(storeID, weekIndexParam int) (outWeeklyStoreScoreDataList []*model.WeeklyStoreScore, err error) { + db := dao.GetDB() + storeScoreList, err := dao.GetWeeklyStoreScoreList(db, storeID, 1) + if err == nil && len(storeScoreList) > 0 { + weeklyStoreScoreDataList := []*model.WeeklyStoreScore{} + weekDataList := SplitToSingleWeekDataList(storeScoreList) + for weekIndex, weekData := range weekDataList { + weeklyData := &model.WeeklyStoreScore{} + weeklyData.ID = weekIndex + weeklyData.ItemTotalScore = 10 + weeklyData.StoreID = storeID + weeklyStoreScoreDataList = append(weeklyStoreScoreDataList, weeklyData) + weekDataCount := len(weekData) + for dayIndex, dayData := range weekData { + for _, fieldName := range storeScoreFieldName { + srcFieldValue := refutil.GetObjFieldByName(dayData, fieldName).(int) + destFieldValue := refutil.GetObjFieldByName(weeklyData, fieldName).(int) + refutil.SetObjFieldByName(weeklyData, fieldName, destFieldValue+srcFieldValue) + } + if weekDataCount == 1 { + weeklyData.BeginTime = dayData.ScoreDate + weeklyData.EndTime = dayData.ScoreDate + } else { + if dayIndex == 0 { + weeklyData.EndTime = dayData.ScoreDate + } else if dayIndex == weekDataCount-1 { + weeklyData.BeginTime = dayData.ScoreDate + } + } + weeklyData.StoreName = dayData.StoreName + } + for _, fieldName := range storeScoreFieldName { + destFieldValue := refutil.GetObjFieldByName(weeklyData, fieldName).(int) + refutil.SetObjFieldByName(weeklyData, fieldName, int(math.Round(float64(destFieldValue)/float64(weekDataCount)))) + } + for _, fieldName := range storeScoreFieldName { + srcFieldValue := refutil.GetObjFieldByName(weeklyData, fieldName).(int) + destFieldValue := refutil.GetObjFieldByName(weeklyData, model.FieldTotalScore).(int) + refutil.SetObjFieldByName(weeklyData, model.FieldTotalScore, destFieldValue+srcFieldValue) + } + weeklyData.Level = GetStoreScoreLevel(weeklyData.TotalScore) + } + if weekIndexParam == -1 { + outWeeklyStoreScoreDataList = weeklyStoreScoreDataList + } else { + //fmt.Println("testss", utils.Format4Output(weeklyStoreScoreDataList, false)) + outWeeklyStoreScoreDataList = []*model.WeeklyStoreScore{weeklyStoreScoreDataList[weekIndexParam]} + } + } + + return outWeeklyStoreScoreDataList, err +} +func SplitToSingleWeekDataList(storeScoreList []*model.StoreScoreEx) (weekDataList [][]*model.StoreScoreEx) { + singleWeekData := []*model.StoreScoreEx{} + weekIndex := 0 + for _, value := range storeScoreList { + if weekIndex == 0 { + weekIndex = Time2Week(value.ScoreDate) + } + if weekIndex == Time2Week(value.ScoreDate) { + singleWeekData = append(singleWeekData, value) + } else { + weekDataList = append(weekDataList, singleWeekData) + singleWeekData = []*model.StoreScoreEx{} + weekIndex = 0 + singleWeekData = append(singleWeekData, value) + } + } + if len(singleWeekData) > 0 { + weekDataList = append(weekDataList, singleWeekData) + } + + return weekDataList +} +func GetStoreScoreLevel(score int) int { + level := 0 + if score >= 90 { + level = 1 + } else if score >= 80 { + level = 2 + } else if score >= 70 { + level = 3 + } + + return level +} + +func Time2Week(t time.Time) int { + yearDay := t.YearDay() + yearFirstDay := t.AddDate(0, 0, -yearDay+1) + firstDayInWeek := int(yearFirstDay.Weekday()) + + firstWeekDays := 1 + if firstDayInWeek != 0 { + firstWeekDays = 7 - firstDayInWeek + 1 + } + var week int + if yearDay <= firstWeekDays { + week = 1 + } else { + tempWeek := (float64(yearDay) - float64(firstWeekDays)) / float64(7) + week = int(math.Ceil(tempWeek)) + 1 + } + + return week +}