From 4772caf080da5e385397307fd24736deadc9526b Mon Sep 17 00:00:00 2001 From: gazebo Date: Mon, 16 Dec 2019 16:17:02 +0800 Subject: [PATCH 1/3] =?UTF-8?q?Store=E6=B7=BB=E5=8A=A0AutoReplyType?= =?UTF-8?q?=EF=BC=8C=E7=94=A8=E4=BA=8E=E6=A0=87=E8=AF=86=EF=BC=88=E8=AE=A2?= =?UTF-8?q?=E5=8D=95=EF=BC=89=E8=87=AA=E5=8A=A8=E5=9B=9E=E5=A4=8D=E7=B1=BB?= =?UTF-8?q?=E5=9E=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- business/jxcallback/orderman/order_comment.go | 5 ++++- business/jxstore/cms/cms.go | 1 + business/model/store.go | 12 ++++++++++++ 3 files changed, 17 insertions(+), 1 deletion(-) diff --git a/business/jxcallback/orderman/order_comment.go b/business/jxcallback/orderman/order_comment.go index 5bdd9ed26..079ed953d 100644 --- a/business/jxcallback/orderman/order_comment.go +++ b/business/jxcallback/orderman/order_comment.go @@ -85,7 +85,10 @@ func (c *OrderManager) OnOrderComments(orderCommentList []*model.OrderComment) ( isNewComment = true if orderComment.IsReplied == 0 && time.Now().Sub(orderComment.CommentCreatedAt) < time.Duration(orderComment.ModifyDuration)*time.Hour { if storeDetail, err2 := dao.GetStoreDetail(db, orderComment.StoreID, orderComment.VendorID); err2 == nil { - c.replyOrderComment(storeDetail.VendorOrgCode, orderComment) + if storeDetail.AutoReplyType == model.AutoReplyAll || + orderComment.Score > JX_BAD_COMMENTS_MAX_LEVEL && storeDetail.AutoReplyType == model.AutoReplyGoodComment { + c.replyOrderComment(storeDetail.VendorOrgCode, orderComment) + } } } } diff --git a/business/jxstore/cms/cms.go b/business/jxstore/cms/cms.go index 59f0ecda8..eda6d1610 100644 --- a/business/jxstore/cms/cms.go +++ b/business/jxstore/cms/cms.go @@ -100,6 +100,7 @@ func InitServiceInfo(version string, buildTime time.Time, gitCommit string) { "storePriceTypeName": model.StorePriceTypeName, "payStatusName": model.PayStatusName, "refundStatusName": model.RefundStatusName, + "autoReplyTypeName": model.AutoReplyTypeName, }, } } diff --git a/business/model/store.go b/business/model/store.go index 059d21cf2..6dbdf1e33 100644 --- a/business/model/store.go +++ b/business/model/store.go @@ -49,6 +49,12 @@ const ( StoreChangePriceTypeManagedStore = 3 // 直营门店,禁止改价 ) +const ( + AutoReplyAll = 0 // 全部自动回复 + AutoReplyGoodComment = 1 // 禁止差评自动回复 + AutoReplyDisabled = 2 // 禁止自动回复 +) + var ( StoreStatusName = map[int]string{ StoreStatusDisabled: "禁用", @@ -240,6 +246,11 @@ var ( StoreChangePriceTypeBossDisabled: "普通门店禁止改价", StoreChangePriceTypeManagedStore: "直营门店禁止改价", } + AutoReplyTypeName = map[int]string{ + AutoReplyAll: "全部自动回复", + AutoReplyGoodComment: "禁止差评自动回复", + AutoReplyDisabled: "禁止自动回复", + } ) type Store struct { @@ -264,6 +275,7 @@ type Store struct { AutoEnableAt *time.Time `orm:"type(datetime);null" json:"autoEnableAt"` // 自动营业时间(临时休息用) ChangePriceType int8 `json:"changePriceType"` // 修改价格类型,即是否需要审核 SMSNotify int8 `orm:"column(sms_notify);" json:"smsNotify"` // 是否通过短信接收订单消息 + AutoReplyType int8 `json:"autoReplyType"` // 订单评价自动回复类型 PrinterDisabled int8 `orm:"default(0)" json:"printerDisabled"` // 是否禁用网络打印机 PrinterFontSize int8 `orm:"default(0)" json:"printerFontSize"` // 打印字体-1:小,0:正常,1:大 From 84f2c8930cf84f1482375190e50647f0254cff2a Mon Sep 17 00:00:00 2001 From: gazebo Date: Mon, 16 Dec 2019 16:39:39 +0800 Subject: [PATCH 2/3] =?UTF-8?q?GetEffectiveActStoreSkuInfo=E6=B7=BB?= =?UTF-8?q?=E5=8A=A0actType=E5=8F=82=E6=95=B0=20=E4=BF=AE=E5=A4=8DActStore?= =?UTF-8?q?SkuParam2Model=E4=B8=AD=E8=B0=83=E7=94=A8GetEffectiveActStoreSk?= =?UTF-8?q?uInfo=E7=9A=84bug?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- business/jxcallback/orderman/order.go | 2 +- business/jxcallback/orderman/order_afs.go | 2 +- business/jxstore/act/act.go | 2 +- business/jxstore/misc/store_score.go | 2 +- business/jxutils/jxutils_act.go | 1 + business/model/dao/act.go | 8 ++++++-- business/model/dao/act_test.go | 2 +- business/model/dao/store_sku.go | 2 +- 8 files changed, 13 insertions(+), 8 deletions(-) diff --git a/business/jxcallback/orderman/order.go b/business/jxcallback/orderman/order.go index 82e66354e..c7bbc6802 100644 --- a/business/jxcallback/orderman/order.go +++ b/business/jxcallback/orderman/order.go @@ -394,7 +394,7 @@ func updateSingleOrderEarningPrice(order *model.GoodsOrder, db *dao.DaoDB) { skuIDMap[v.SkuID] = 1 } if len(skuIDMap) > 0 { - actStoreSkuList, err := dao.GetEffectiveActStoreSkuInfo(db, 0, []int{order.VendorID}, []int{jxStoreID}, jxutils.IntMap2List(skuIDMap), order.OrderCreatedAt, order.OrderCreatedAt) + actStoreSkuList, err := dao.GetEffectiveActStoreSkuInfo(db, 0, []int{order.VendorID}, 0, []int{jxStoreID}, jxutils.IntMap2List(skuIDMap), order.OrderCreatedAt, order.OrderCreatedAt) if err != nil { globals.SugarLogger.Errorf("updateOrderSkuOtherInfo can not get sku promotion info for error:%v", err) } diff --git a/business/jxcallback/orderman/order_afs.go b/business/jxcallback/orderman/order_afs.go index f65bd0dba..72b56873a 100644 --- a/business/jxcallback/orderman/order_afs.go +++ b/business/jxcallback/orderman/order_afs.go @@ -273,7 +273,7 @@ func (c *OrderManager) updateAfsOrderSkuOtherInfo(db *dao.DaoDB, order *model.Af var actStoreSkuMap *jxutils.ActStoreSkuMap if len(skuIDMap) > 0 { if order2, err2 := c.LoadOrder(order.VendorOrderID, order.VendorID); err2 == nil { - actStoreSkuList, err := dao.GetEffectiveActStoreSkuInfo(db, 0, []int{order.VendorID}, []int{jxStoreID}, jxutils.IntMap2List(skuIDMap), order2.OrderCreatedAt, order2.OrderCreatedAt) + actStoreSkuList, err := dao.GetEffectiveActStoreSkuInfo(db, 0, []int{order.VendorID}, 0, []int{jxStoreID}, jxutils.IntMap2List(skuIDMap), order2.OrderCreatedAt, order2.OrderCreatedAt) if err != nil { globals.SugarLogger.Errorf("updateAfsOrderSkuOtherInfo can not get sku promotion info for error:%v", err) return err diff --git a/business/jxstore/act/act.go b/business/jxstore/act/act.go index f0490e7d5..d70cbefb2 100644 --- a/business/jxstore/act/act.go +++ b/business/jxstore/act/act.go @@ -113,7 +113,7 @@ func ActStoreSkuParam2Model(ctx *jxcontext.Context, db *dao.DaoDB, act *model.Ac skuIDs := jxutils.IntMap2List(skuIDMap) // 判断活动是否重叠的检查,当前忽略京东平台及所有结算信息 if !(len(vendorIDs) == 1 && vendorIDs[0] == model.VendorIDJD || act.Type == model.ActSkuFake) { - effectActStoreSkuList, err := dao.GetEffectiveActStoreSkuInfo(db, 0, vendorIDs, storeIDs, skuIDs, act.BeginAt, act.EndAt) + effectActStoreSkuList, err := dao.GetEffectiveActStoreSkuInfo(db, 0, vendorIDs, act.Type, storeIDs, skuIDs, act.BeginAt, act.EndAt) if err != nil { globals.SugarLogger.Errorf("GetEffectiveActStoreSkuInfo can not get sku promotion info for error:%v", err) return nil, nil, nil, err diff --git a/business/jxstore/misc/store_score.go b/business/jxstore/misc/store_score.go index 214d9acd3..0454e96d4 100644 --- a/business/jxstore/misc/store_score.go +++ b/business/jxstore/misc/store_score.go @@ -396,7 +396,7 @@ func ScorePromotionSku(storeInfo *cms.StoreExt) { db := dao.GetDB() beginTime := time.Now() endTime := time.Now() - actStoreSkuList, err := dao.GetEffectiveActStoreSkuInfo(db, -1, nil, []int{storeID}, nil, beginTime, endTime) + actStoreSkuList, err := dao.GetEffectiveActStoreSkuInfo(db, -1, nil, 0, []int{storeID}, nil, beginTime, endTime) finalScore := 0 if err == nil && len(actStoreSkuList) > 0 { actStoreSkuMap := make(map[int]int) diff --git a/business/jxutils/jxutils_act.go b/business/jxutils/jxutils_act.go index a2a97bde0..575e8f650 100644 --- a/business/jxutils/jxutils_act.go +++ b/business/jxutils/jxutils_act.go @@ -8,6 +8,7 @@ type ActStoreSkuMap struct { actStoreSkuMap map[int64]map[int]*model.ActStoreSku2 } +// isActPrice为true表示是活动,false表示是结算 func NewActStoreSkuMap(actStoreSkuList []*model.ActStoreSku2, isActPrice bool) (actMap *ActStoreSkuMap) { actMap = &ActStoreSkuMap{} actStoreSkuMap := make(map[int64]map[int]*model.ActStoreSku2) diff --git a/business/model/dao/act.go b/business/model/dao/act.go index 02800b6a4..c5b6f626b 100644 --- a/business/model/dao/act.go +++ b/business/model/dao/act.go @@ -369,7 +369,7 @@ func GetExistVendorActIDs(db *DaoDB, vendorID int) (vendorActIDs []string, err e return vendorActIDs, err } -func GetEffectiveActStoreSkuInfo(db *DaoDB, actID int, vendorIDs []int, storeIDs, skuIDs []int, beginAt, endAt time.Time) (actStoreSkuList []*model.ActStoreSku2, err error) { +func GetEffectiveActStoreSkuInfo(db *DaoDB, actID int, vendorIDs []int, actType int, storeIDs, skuIDs []int, beginAt, endAt time.Time) (actStoreSkuList []*model.ActStoreSku2, err error) { if utils.IsTimeZero(beginAt) { return nil, fmt.Errorf("GeActStoreSkuInfo必须指定活动开始时间") } @@ -406,9 +406,13 @@ func GetEffectiveActStoreSkuInfo(db *DaoDB, actID int, vendorIDs []int, storeIDs sqlParams = append(sqlParams, model.GetVendorMask(vendorIDs...), vendorIDs) } if actID > 0 { - sql = " AND t1.id = ?" + sql = " AND t1.act_type = ?" sqlParams = append(sqlParams, actID) } + if actType > 0 { + sql = " AND t1.type = ?" + sqlParams = append(sqlParams, actType) + } if len(storeIDs) > 0 { sql += " AND t2.store_id IN (" + GenQuestionMarks(len(storeIDs)) + ")" sqlParams = append(sqlParams, storeIDs) diff --git a/business/model/dao/act_test.go b/business/model/dao/act_test.go index 7d902cccb..687fc0298 100644 --- a/business/model/dao/act_test.go +++ b/business/model/dao/act_test.go @@ -27,7 +27,7 @@ func TestGetEffectiveActStoreSkuInfo(t *testing.T) { ToTime: utils.Str2Time("2019-08-06 12:34:56"), }, } { - result, err := GetEffectiveActStoreSkuInfo(GetDB(), v.ActID, v.VendorIDs, v.StoreIDs, v.SkuIDs, v.FromTime, v.ToTime) + result, err := GetEffectiveActStoreSkuInfo(GetDB(), v.ActID, v.VendorIDs, 0, v.StoreIDs, v.SkuIDs, v.FromTime, v.ToTime) if err != nil { t.Fatal(err) } diff --git a/business/model/dao/store_sku.go b/business/model/dao/store_sku.go index 1eab9015a..3b1461f44 100644 --- a/business/model/dao/store_sku.go +++ b/business/model/dao/store_sku.go @@ -1136,7 +1136,7 @@ func UpdateActPrice4StoreSkuNameNew(db *DaoDB, storeIDs, skuIDs []int, skuNamesI if actVendorID >= 0 { vendorIDs = []int{actVendorID} } - actStoreSkuList, err := GetEffectiveActStoreSkuInfo(db, 0, vendorIDs, storeIDs, skuIDs, time.Now(), time.Now()) + actStoreSkuList, err := GetEffectiveActStoreSkuInfo(db, 0, vendorIDs, 0, storeIDs, skuIDs, time.Now(), time.Now()) if err != nil { globals.SugarLogger.Errorf("updateActPrice4StoreSkuNameNew can not get sku promotion info for error:%v", err) return err From 7296b5cca39224b9be34b8f653c057f5788ec814 Mon Sep 17 00:00:00 2001 From: gazebo Date: Mon, 16 Dec 2019 16:46:05 +0800 Subject: [PATCH 3/3] GetEffectiveActStoreSkuInfo, ActTypeAll --- business/jxcallback/orderman/order.go | 2 +- business/jxcallback/orderman/order_afs.go | 2 +- business/jxstore/misc/store_score.go | 2 +- business/model/act.go | 1 + business/model/dao/act.go | 2 +- business/model/dao/act_test.go | 3 ++- business/model/dao/store_sku.go | 2 +- 7 files changed, 8 insertions(+), 6 deletions(-) diff --git a/business/jxcallback/orderman/order.go b/business/jxcallback/orderman/order.go index c7bbc6802..ba0da084f 100644 --- a/business/jxcallback/orderman/order.go +++ b/business/jxcallback/orderman/order.go @@ -394,7 +394,7 @@ func updateSingleOrderEarningPrice(order *model.GoodsOrder, db *dao.DaoDB) { skuIDMap[v.SkuID] = 1 } if len(skuIDMap) > 0 { - actStoreSkuList, err := dao.GetEffectiveActStoreSkuInfo(db, 0, []int{order.VendorID}, 0, []int{jxStoreID}, jxutils.IntMap2List(skuIDMap), order.OrderCreatedAt, order.OrderCreatedAt) + actStoreSkuList, err := dao.GetEffectiveActStoreSkuInfo(db, 0, []int{order.VendorID}, model.ActTypeAll, []int{jxStoreID}, jxutils.IntMap2List(skuIDMap), order.OrderCreatedAt, order.OrderCreatedAt) if err != nil { globals.SugarLogger.Errorf("updateOrderSkuOtherInfo can not get sku promotion info for error:%v", err) } diff --git a/business/jxcallback/orderman/order_afs.go b/business/jxcallback/orderman/order_afs.go index 72b56873a..776050f21 100644 --- a/business/jxcallback/orderman/order_afs.go +++ b/business/jxcallback/orderman/order_afs.go @@ -273,7 +273,7 @@ func (c *OrderManager) updateAfsOrderSkuOtherInfo(db *dao.DaoDB, order *model.Af var actStoreSkuMap *jxutils.ActStoreSkuMap if len(skuIDMap) > 0 { if order2, err2 := c.LoadOrder(order.VendorOrderID, order.VendorID); err2 == nil { - actStoreSkuList, err := dao.GetEffectiveActStoreSkuInfo(db, 0, []int{order.VendorID}, 0, []int{jxStoreID}, jxutils.IntMap2List(skuIDMap), order2.OrderCreatedAt, order2.OrderCreatedAt) + actStoreSkuList, err := dao.GetEffectiveActStoreSkuInfo(db, 0, []int{order.VendorID}, model.ActTypeAll, []int{jxStoreID}, jxutils.IntMap2List(skuIDMap), order2.OrderCreatedAt, order2.OrderCreatedAt) if err != nil { globals.SugarLogger.Errorf("updateAfsOrderSkuOtherInfo can not get sku promotion info for error:%v", err) return err diff --git a/business/jxstore/misc/store_score.go b/business/jxstore/misc/store_score.go index 0454e96d4..cf3752bf4 100644 --- a/business/jxstore/misc/store_score.go +++ b/business/jxstore/misc/store_score.go @@ -396,7 +396,7 @@ func ScorePromotionSku(storeInfo *cms.StoreExt) { db := dao.GetDB() beginTime := time.Now() endTime := time.Now() - actStoreSkuList, err := dao.GetEffectiveActStoreSkuInfo(db, -1, nil, 0, []int{storeID}, nil, beginTime, endTime) + actStoreSkuList, err := dao.GetEffectiveActStoreSkuInfo(db, -1, nil, model.ActTypeAll, []int{storeID}, nil, beginTime, endTime) finalScore := 0 if err == nil && len(actStoreSkuList) > 0 { actStoreSkuMap := make(map[int]int) diff --git a/business/model/act.go b/business/model/act.go index b4bfeee86..bc792e542 100644 --- a/business/model/act.go +++ b/business/model/act.go @@ -7,6 +7,7 @@ import ( ) const ( + ActTypeAll = -1 ActSkuFake = 0 // 假活动,只用于存储活动结算信息 ActSkuDirectDown = 3 // 兼容之前的 ActSkuSecKill = 4 // 兼容之前的 diff --git a/business/model/dao/act.go b/business/model/dao/act.go index c5b6f626b..0137b566d 100644 --- a/business/model/dao/act.go +++ b/business/model/dao/act.go @@ -409,7 +409,7 @@ func GetEffectiveActStoreSkuInfo(db *DaoDB, actID int, vendorIDs []int, actType sql = " AND t1.act_type = ?" sqlParams = append(sqlParams, actID) } - if actType > 0 { + if actType != model.ActTypeAll { sql = " AND t1.type = ?" sqlParams = append(sqlParams, actType) } diff --git a/business/model/dao/act_test.go b/business/model/dao/act_test.go index 687fc0298..be48eee2a 100644 --- a/business/model/dao/act_test.go +++ b/business/model/dao/act_test.go @@ -5,6 +5,7 @@ import ( "time" "git.rosy.net.cn/baseapi/utils" + "git.rosy.net.cn/jx-callback/business/model" ) func TestGetEffectiveActStoreSkuInfo(t *testing.T) { @@ -27,7 +28,7 @@ func TestGetEffectiveActStoreSkuInfo(t *testing.T) { ToTime: utils.Str2Time("2019-08-06 12:34:56"), }, } { - result, err := GetEffectiveActStoreSkuInfo(GetDB(), v.ActID, v.VendorIDs, 0, v.StoreIDs, v.SkuIDs, v.FromTime, v.ToTime) + result, err := GetEffectiveActStoreSkuInfo(GetDB(), v.ActID, v.VendorIDs, model.ActTypeAll, v.StoreIDs, v.SkuIDs, v.FromTime, v.ToTime) if err != nil { t.Fatal(err) } diff --git a/business/model/dao/store_sku.go b/business/model/dao/store_sku.go index 3b1461f44..d35415100 100644 --- a/business/model/dao/store_sku.go +++ b/business/model/dao/store_sku.go @@ -1136,7 +1136,7 @@ func UpdateActPrice4StoreSkuNameNew(db *DaoDB, storeIDs, skuIDs []int, skuNamesI if actVendorID >= 0 { vendorIDs = []int{actVendorID} } - actStoreSkuList, err := GetEffectiveActStoreSkuInfo(db, 0, vendorIDs, 0, storeIDs, skuIDs, time.Now(), time.Now()) + actStoreSkuList, err := GetEffectiveActStoreSkuInfo(db, 0, vendorIDs, model.ActTypeAll, storeIDs, skuIDs, time.Now(), time.Now()) if err != nil { globals.SugarLogger.Errorf("updateActPrice4StoreSkuNameNew can not get sku promotion info for error:%v", err) return err