From f710444cbf07c0c13b69f168b41384687f281a8c Mon Sep 17 00:00:00 2001 From: gazebo Date: Mon, 11 Nov 2019 10:11:43 +0800 Subject: [PATCH 01/18] =?UTF-8?q?Store.ChangePriceType=E6=96=B0=E5=A2=9ESt?= =?UTF-8?q?oreChangePriceTypeManagedStore?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- business/jxstore/cms/cms.go | 1 + business/jxstore/cms/store_sku.go | 4 ++-- business/jxutils/jxutils.go | 7 +++++++ business/model/store.go | 25 ++++++++++++++++--------- 4 files changed, 26 insertions(+), 11 deletions(-) diff --git a/business/jxstore/cms/cms.go b/business/jxstore/cms/cms.go index a37152192..1364ad65b 100644 --- a/business/jxstore/cms/cms.go +++ b/business/jxstore/cms/cms.go @@ -97,6 +97,7 @@ func InitServiceInfo(version string, buildTime time.Time, gitCommit string) { "configTypeName": model.ConfigTypeName, "autoSaleAt": AutoSaleAtStr, "userTypeName": model.UserTypeName, + "storePriceTypeName": model.StorePriceTypeName, }, } } diff --git a/business/jxstore/cms/store_sku.go b/business/jxstore/cms/store_sku.go index 4df3422c2..f9e8bf733 100644 --- a/business/jxstore/cms/store_sku.go +++ b/business/jxstore/cms/store_sku.go @@ -988,7 +988,7 @@ func updateStoresSkusWithoutSync(ctx *jxcontext.Context, db *dao.DaoDB, storeIDs for _, v := range allBinds { var num int64 inSkuBind := inSkuBinsMap[v.RealSkuID] - isCanChangePrice := (isUserCanDirectChangePrice || v.ChangePriceType != model.StoreChangePriceTypeBossDisabled) + isCanChangePrice := (isUserCanDirectChangePrice || jxutils.TranslateStorePriceType(v.ChangePriceType) != model.StoreChangePriceTypeBossDisabled) // globals.SugarLogger.Debug(utils.Format4Output(inSkuBind, false)) var skuBind *model.StoreSkuBind if v.ID == 0 { @@ -1448,7 +1448,7 @@ func shouldPendingStorePriceChange(ctx *jxcontext.Context, storeID int, skuBindI if err = dao.GetEntity(db, store); err != nil { return false, err } - return store.ChangePriceType == model.StoreChangePriceTypeNeedApprove, nil + return jxutils.TranslateStorePriceType(store.ChangePriceType) == model.StoreChangePriceTypeNeedApprove, nil } } return false, nil diff --git a/business/jxutils/jxutils.go b/business/jxutils/jxutils.go index 0fe81a89c..b0469f187 100644 --- a/business/jxutils/jxutils.go +++ b/business/jxutils/jxutils.go @@ -798,3 +798,10 @@ func Point2StoreDistance(lng, lat float64, intStoreLng, intStoreLat int, deliver } return distance } + +func TranslateStorePriceType(storePriceType int8) int8 { + if storePriceType == model.StoreChangePriceTypeManagedStore { + storePriceType = model.StoreChangePriceTypeBossDisabled + } + return storePriceType +} diff --git a/business/model/store.go b/business/model/store.go index 43541594f..6319b6cad 100644 --- a/business/model/store.go +++ b/business/model/store.go @@ -43,9 +43,10 @@ const ( ) const ( - StoreChangePriceTypeDirect = 0 - StoreChangePriceTypeNeedApprove = 1 - StoreChangePriceTypeBossDisabled = 2 + StoreChangePriceTypeDirect = 0 // 普通门店 + StoreChangePriceTypeNeedApprove = 1 // 改价需要审核,暂时没用 + StoreChangePriceTypeBossDisabled = 2 // 完全禁止改价 + StoreChangePriceTypeManagedStore = 3 // 直营门店,禁止改价 ) var ( @@ -234,6 +235,11 @@ var ( StoreAuditStatusOnline: "上线", StoreAuditStatusRejected: "拒绝", } + StorePriceTypeName = map[int]string{ + StoreChangePriceTypeDirect: "可直接改价", + StoreChangePriceTypeBossDisabled: "禁止改价", + StoreChangePriceTypeManagedStore: "直营门店", + } ) type Store struct { @@ -258,12 +264,13 @@ type Store struct { AutoEnableAt *time.Time `orm:"type(datetime);null" json:"autoEnableAt"` // 自动营业时间(临时休息用) ChangePriceType int8 `json:"changePriceType"` // 修改价格类型,即是否需要审核 SMSNotify int8 `orm:"column(sms_notify);" json:"smsNotify"` // 是否通过短信接收订单消息 - PrinterDisabled int8 `orm:"default(0)" json:"printerDisabled"` // 是否禁用网络打印机 - PrinterFontSize int8 `orm:"default(0)" json:"printerFontSize"` // 打印字体-1:小,0:正常,1:大 - PrinterVendorID int `orm:"column(printer_vendor_id);" json:"printerVendorID"` - PrinterSN string `orm:"size(32);column(printer_sn);index" json:"printerSN"` - PrinterKey string `orm:"size(64)" json:"printerKey"` - PrinterBindInfo string `orm:"size(1024)" json:"-"` + + PrinterDisabled int8 `orm:"default(0)" json:"printerDisabled"` // 是否禁用网络打印机 + PrinterFontSize int8 `orm:"default(0)" json:"printerFontSize"` // 打印字体-1:小,0:正常,1:大 + PrinterVendorID int `orm:"column(printer_vendor_id);" json:"printerVendorID"` + PrinterSN string `orm:"size(32);column(printer_sn);index" json:"printerSN"` + PrinterKey string `orm:"size(64)" json:"printerKey"` + PrinterBindInfo string `orm:"size(1024)" json:"-"` IDCardFront string `orm:"size(255);column(id_card_front)" json:"idCardFront"` IDCardBack string `orm:"size(255);column(id_card_back)" json:"idCardBack"` From 71b01c44f981db2916c5c8a1c06e33dbd8815f28 Mon Sep 17 00:00:00 2001 From: gazebo Date: Mon, 11 Nov 2019 11:59:27 +0800 Subject: [PATCH 02/18] =?UTF-8?q?=E7=BE=8E=E5=9B=A2=E8=AF=84=E4=BB=B7?= =?UTF-8?q?=E8=87=AA=E5=8A=A8=E5=9B=9E=E5=A4=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- business/jxutils/weixinmsg/weixinmsg.go | 2 +- business/model/dao/store.go | 2 + .../partner/purchase/ebai/order_comment.go | 8 +- .../partner/purchase/mtwm/order_comment.go | 96 ++++++++++++------- main.go | 2 + 5 files changed, 68 insertions(+), 42 deletions(-) diff --git a/business/jxutils/weixinmsg/weixinmsg.go b/business/jxutils/weixinmsg/weixinmsg.go index 524ee428b..c23d6ec36 100644 --- a/business/jxutils/weixinmsg/weixinmsg.go +++ b/business/jxutils/weixinmsg/weixinmsg.go @@ -417,7 +417,7 @@ func PushJDBadCommentToWeiXin(comment *legacymodel.JxBadComments, isBadComment b orderInfo = fmt.Sprintf("%s第%d号订单, %s", model.VendorChineseNames[int(utils.Str2Int64WithDefault(comment.OrderFlag, 0))], order.OrderSeq, comment.OrderId) consigneeName = order.ConsigneeName } else { - orderInfo = fmt.Sprintf("%s订单, %s", model.VendorChineseNames[int(utils.Str2Int64WithDefault(comment.OrderFlag, 0))], comment.OrderId) + orderInfo = fmt.Sprintf("%s订单, %s", model.VendorChineseNames[int(utils.Str2Int64WithDefault(comment.OrderFlag, 0))] /*comment.OrderId*/, "") } data := map[string]interface{}{ "first": map[string]interface{}{ diff --git a/business/model/dao/store.go b/business/model/dao/store.go index 4f9b313af..c9a63b540 100644 --- a/business/model/dao/store.go +++ b/business/model/dao/store.go @@ -183,10 +183,12 @@ func GetStoresMapList(db *DaoDB, vendorIDs, storeIDs []int, status, isSync int, sql := ` SELECT t1.* FROM store_map t1 + JOIN store t2 ON t2.id = t1.store_id AND t2.deleted_at = ? WHERE t1.deleted_at = ? ` sqlParams := []interface{}{ utils.DefaultTimeValue, + utils.DefaultTimeValue, } if len(vendorIDs) > 0 { sql += " AND t1.vendor_id IN (" + GenQuestionMarks(len(vendorIDs)) + ")" diff --git a/business/partner/purchase/ebai/order_comment.go b/business/partner/purchase/ebai/order_comment.go index 28a76014c..8a49a1e5c 100644 --- a/business/partner/purchase/ebai/order_comment.go +++ b/business/partner/purchase/ebai/order_comment.go @@ -22,11 +22,9 @@ const ( ) func (c *PurchaseHandler) StartRefreshComment() { - if globals.ReallyCallPlatformAPI { - utils.AfterFuncWithRecover(5*time.Second, func() { - c.refreshCommentOnce() - }) - } + utils.AfterFuncWithRecover(5*time.Second, func() { + c.refreshCommentOnce() + }) } func (c *PurchaseHandler) refreshCommentOnce() { diff --git a/business/partner/purchase/mtwm/order_comment.go b/business/partner/purchase/mtwm/order_comment.go index d64162e12..f6d824f7c 100644 --- a/business/partner/purchase/mtwm/order_comment.go +++ b/business/partner/purchase/mtwm/order_comment.go @@ -6,6 +6,7 @@ import ( "git.rosy.net.cn/baseapi/platformapi/mtwmapi" "git.rosy.net.cn/jx-callback/business/jxutils/tasksch" + "git.rosy.net.cn/jx-callback/business/partner" "git.rosy.net.cn/baseapi/utils" "git.rosy.net.cn/jx-callback/business/jxutils/jxcontext" @@ -16,17 +17,15 @@ import ( ) const ( - RefreshCommentTime = 36 * time.Hour + RefreshCommentTime = 3 * 24 * time.Hour // 此值必须大于24小时 RefreshCommentTimeInterval = 60 * time.Minute BAD_COMMENTS_MAX_MODIFY_TIME = 24 // 小时 ) func (c *PurchaseHandler) StartRefreshComment() { - if globals.ReallyCallPlatformAPI { - utils.AfterFuncWithRecover(5*time.Second, func() { - c.refreshCommentOnce() - }) - } + utils.AfterFuncWithRecover(5*time.Second, func() { + c.refreshCommentOnce() + }) } func (c *PurchaseHandler) refreshCommentOnce() { @@ -37,42 +36,67 @@ func (c *PurchaseHandler) refreshCommentOnce() { } func (c *PurchaseHandler) RefreshComment(fromTime, toTime time.Time) (err error) { - if globals.EnableMtwmStoreWrite { - storeMapList, err2 := dao.GetStoresMapList(dao.GetDB(), []int{model.VendorIDMTWM}, nil, model.StoreStatusAll, model.StoreIsSyncAll, "") - if err = err2; err != nil { - return err - } - task := tasksch.NewParallelTask("mtwm RefreshComment", nil, jxcontext.AdminCtx, - func(task *tasksch.ParallelTask, batchItemList []interface{}, params ...interface{}) (retVal interface{}, err error) { - storeMap := batchItemList[0].(*model.StoreMap) - startDateStr := time.Now().Format("20060102") - endDateStr := time.Now().Add(-RefreshCommentTime).Format("20060102") - commentList, err2 := api.MtwmAPI.CommentQuery(storeMap.VendorStoreID, startDateStr, endDateStr, 0, 0, mtwmapi.CommentReplyStatusAll) - if err = err2; err != nil { - return nil, err - } - return commentList, nil - }, storeMapList) - task.Run() - resultList, err2 := task.GetResult(0) - if err = err2; err != nil { - return err - } - var orderCommentList []*model.OrderComment - for _, result := range resultList { - mtwmComment := result.(*mtwmapi.OrderComment) - orderComment := &model.OrderComment{ - VendorID: model.VendorIDMTWM, - TagList: mtwmComment.CommentLables, - Score: int8(mtwmComment.FoodCommentScore), + storeMapList, err2 := dao.GetStoresMapList(dao.GetDB(), []int{model.VendorIDMTWM}, nil, model.StoreStatusAll, model.StoreIsSyncYes, "") + if err = err2; err != nil { + return err + } + task := tasksch.NewParallelTask("mtwm RefreshComment", nil, jxcontext.AdminCtx, + func(task *tasksch.ParallelTask, batchItemList []interface{}, params ...interface{}) (retVal interface{}, err error) { + storeMap := batchItemList[0].(*model.StoreMap) + endDateStr := time.Now().Add(-24 * time.Hour).Format("20060102") + startDateStr := time.Now().Add(-RefreshCommentTime).Format("20060102") + commentList, err2 := api.MtwmAPI.CommentQuery(storeMap.VendorStoreID, startDateStr, endDateStr, 0, 0, mtwmapi.CommentReplyStatusAll) + + var orderCommentList []*model.OrderComment + if err = err2; err != nil { + return nil, err } - orderCommentList = append(orderCommentList, orderComment) - } + for _, mtwmComment := range commentList { + createdTime, err := utils.TryStr2Time(mtwmComment.CommentTime) + if err == nil { + orderComment := &model.OrderComment{ + VendorOrderID: utils.Int64ToStr(mtwmComment.CommentID), // 美团评价不能得到订单号,以评价ID代替 + VendorID: model.VendorIDMTWM, + UserCommentID: utils.Int64ToStr(mtwmComment.CommentID), + VendorStoreID: storeMap.VendorStoreID, + TagList: mtwmComment.CommentLables, + Score: int8(mtwmComment.FoodCommentScore), + ModifyDuration: BAD_COMMENTS_MAX_MODIFY_TIME, + OriginalMsg: string(utils.MustMarshal(mtwmComment)), + IsReplied: int8(mtwmComment.ReplyStatus), + } + if orderComment.IsReplied == 0 { + orderComment.Content = mtwmComment.CommentContent + orderComment.CommentCreatedAt = createdTime + } else { + orderComment.Content = mtwmComment.AddComment + if updatedTime, err := utils.TryStr2Time(mtwmComment.CommentTime); err == nil { + orderComment.CommentCreatedAt = updatedTime + } + } + orderCommentList = append(orderCommentList, orderComment) + } + } + return orderCommentList, nil + }, storeMapList) + task.Run() + resultList, err2 := task.GetResult(0) + if err = err2; err != nil { + return err + } + var orderCommentList []*model.OrderComment + for _, result := range resultList { + orderComment := result.(*model.OrderComment) + orderCommentList = append(orderCommentList, orderComment) + } + if len(orderCommentList) > 0 { + err = partner.CurOrderManager.OnOrderComments(orderCommentList) } return err } func (c *PurchaseHandler) ReplyOrderComment(ctx *jxcontext.Context, orderComment *model.OrderComment, replyComment string) (err error) { + globals.SugarLogger.Debugf("mtwm ReplyOrderComment, orderComment:%s, replyComment:%s", utils.Format4Output(orderComment, true), replyComment) if globals.EnableMtwmStoreWrite { err = api.MtwmAPI.CommentAddReply(orderComment.VendorStoreID, utils.Str2Int64(orderComment.UserCommentID), replyComment) } diff --git a/main.go b/main.go index 4088c347f..85b9dafa2 100644 --- a/main.go +++ b/main.go @@ -21,6 +21,7 @@ import ( "git.rosy.net.cn/jx-callback/business/jxstore/misc" "git.rosy.net.cn/jx-callback/business/jxutils/tasks" "git.rosy.net.cn/jx-callback/business/partner/purchase/ebai" + "git.rosy.net.cn/jx-callback/business/partner/purchase/mtwm" "git.rosy.net.cn/jx-callback/globals" "git.rosy.net.cn/jx-callback/globals/api" "git.rosy.net.cn/jx-callback/globals/api2" @@ -66,6 +67,7 @@ func Init() { if globals.IsProductEnv() { ebai.CurPurchaseHandler.StartRefreshComment() + mtwm.CurPurchaseHandler.StartRefreshComment() } misc.Init() } From 2cb74791e51cc16f406fe22db8ddcfa61054559a Mon Sep 17 00:00:00 2001 From: gazebo Date: Mon, 11 Nov 2019 13:58:56 +0800 Subject: [PATCH 03/18] =?UTF-8?q?OnOrderComments=E4=B8=AD=E6=89=BE?= =?UTF-8?q?=E4=B8=8D=E5=88=B0=E8=AE=A2=E5=8D=95=E6=97=B6=EF=BC=8C=E8=A6=81?= =?UTF-8?q?=E7=94=A8GetStoreDetailByVendorStoreID=E6=9D=A5=E6=9B=B4?= =?UTF-8?q?=E6=96=B0=E9=97=A8=E5=BA=97ID?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- business/jxcallback/orderman/order_comment.go | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/business/jxcallback/orderman/order_comment.go b/business/jxcallback/orderman/order_comment.go index d5dfcbe67..8560f8f40 100644 --- a/business/jxcallback/orderman/order_comment.go +++ b/business/jxcallback/orderman/order_comment.go @@ -107,6 +107,10 @@ func (c *OrderManager) OnOrderComments(orderCommentList []*model.OrderComment) ( } else { orderComment.ConsigneeMobile = order.ConsigneeMobile } + } else { + if storeDetail, err := dao.GetStoreDetailByVendorStoreID(db, orderComment.VendorStoreID, orderComment.VendorID); err == nil { + orderComment.StoreID = storeDetail.ID + } } if orderComment.StoreID > 0 { comment2.Jxstoreid = utils.Int2Str(orderComment.StoreID) From b0856aee475283ceab04250a8e8c66b4b6418c66 Mon Sep 17 00:00:00 2001 From: gazebo Date: Mon, 11 Nov 2019 14:31:46 +0800 Subject: [PATCH 04/18] up --- business/jxcallback/orderman/order_comment.go | 2 +- business/partner/purchase/mtwm/order_comment.go | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/business/jxcallback/orderman/order_comment.go b/business/jxcallback/orderman/order_comment.go index 8560f8f40..484d5ea7d 100644 --- a/business/jxcallback/orderman/order_comment.go +++ b/business/jxcallback/orderman/order_comment.go @@ -83,7 +83,7 @@ func (c *OrderManager) OnOrderComments(orderCommentList []*model.OrderComment) ( if dao.IsNoRowsError(err) { err = nil isNewComment = true - if orderComment.IsReplied == 0 && time.Now().Sub(orderComment.CommentCreatedAt) < MAX_REAPLY_TIME { + if orderComment.IsReplied == 0 && time.Now().Sub(orderComment.CommentCreatedAt) < time.Duration(orderComment.ModifyDuration)*time.Hour { c.replyOrderComment(orderComment) } } diff --git a/business/partner/purchase/mtwm/order_comment.go b/business/partner/purchase/mtwm/order_comment.go index f6d824f7c..b72d1195f 100644 --- a/business/partner/purchase/mtwm/order_comment.go +++ b/business/partner/purchase/mtwm/order_comment.go @@ -17,9 +17,9 @@ import ( ) const ( - RefreshCommentTime = 3 * 24 * time.Hour // 此值必须大于24小时 + RefreshCommentTime = 7 * 24 * time.Hour // 此值必须大于24小时 RefreshCommentTimeInterval = 60 * time.Minute - BAD_COMMENTS_MAX_MODIFY_TIME = 24 // 小时 + BAD_COMMENTS_MAX_MODIFY_TIME = 24 * 6 // 小时 ) func (c *PurchaseHandler) StartRefreshComment() { From 88b02419551e11218c5bfa02e40761e55159a3e5 Mon Sep 17 00:00:00 2001 From: gazebo Date: Mon, 11 Nov 2019 14:36:14 +0800 Subject: [PATCH 05/18] up --- business/jxstore/cms/store.go | 2 +- business/model/order.go | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/business/jxstore/cms/store.go b/business/jxstore/cms/store.go index fd96c1695..ec1a05806 100644 --- a/business/jxstore/cms/store.go +++ b/business/jxstore/cms/store.go @@ -770,8 +770,8 @@ func UpdateStore(ctx *jxcontext.Context, storeID int, payload map[string]interfa } } else { dao.Commit(db) - notifyStoreOperatorChanged(store, valid["operatorPhone"]) } + notifyStoreOperatorChanged(store, valid["operatorPhone"]) } } else { globals.SugarLogger.Debugf("UpdateStore track:%s, store:%s", ctx.GetTrackInfo(), utils.Format4Output(store, true)) diff --git a/business/model/order.go b/business/model/order.go index 600446e87..b11836029 100644 --- a/business/model/order.go +++ b/business/model/order.go @@ -245,7 +245,7 @@ type OrderComment struct { UserCommentID string `orm:"column(user_comment_id);size(48)" json:"userCommentID"` IsReplied int8 Status int8 - ModifyDuration int8 // 改评价的小时数 + ModifyDuration int16 // 改评价的小时数 TagList string Score int8 From 281e2b436ad5d87de89d585d5ecd5f5496a52fef Mon Sep 17 00:00:00 2001 From: gazebo Date: Mon, 11 Nov 2019 16:34:18 +0800 Subject: [PATCH 06/18] =?UTF-8?q?=E7=BE=8E=E5=9B=A2=E5=A4=96=E5=8D=96?= =?UTF-8?q?=E8=AF=84=E4=BB=B7=E6=AD=A3=E7=A1=AE=E8=AE=BE=E7=BD=AETagList?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- business/partner/purchase/mtwm/order_comment.go | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/business/partner/purchase/mtwm/order_comment.go b/business/partner/purchase/mtwm/order_comment.go index b72d1195f..f68ab3e2d 100644 --- a/business/partner/purchase/mtwm/order_comment.go +++ b/business/partner/purchase/mtwm/order_comment.go @@ -1,6 +1,7 @@ package mtwm import ( + "strings" "time" "git.rosy.net.cn/baseapi/platformapi/mtwmapi" @@ -35,6 +36,13 @@ func (c *PurchaseHandler) refreshCommentOnce() { }) } +func formalizeTagList(mtwmTagList string) (outTagList string) { + if mtwmTagList != "" { + outTagList = string(utils.Format4Output(strings.Split(mtwmTagList, ","), true)) + } + return outTagList +} + func (c *PurchaseHandler) RefreshComment(fromTime, toTime time.Time) (err error) { storeMapList, err2 := dao.GetStoresMapList(dao.GetDB(), []int{model.VendorIDMTWM}, nil, model.StoreStatusAll, model.StoreIsSyncYes, "") if err = err2; err != nil { @@ -59,7 +67,7 @@ func (c *PurchaseHandler) RefreshComment(fromTime, toTime time.Time) (err error) VendorID: model.VendorIDMTWM, UserCommentID: utils.Int64ToStr(mtwmComment.CommentID), VendorStoreID: storeMap.VendorStoreID, - TagList: mtwmComment.CommentLables, + TagList: formalizeTagList(mtwmComment.CommentLables), Score: int8(mtwmComment.FoodCommentScore), ModifyDuration: BAD_COMMENTS_MAX_MODIFY_TIME, OriginalMsg: string(utils.MustMarshal(mtwmComment)), From e763aac526500393902a26203a999f8daa801f78 Mon Sep 17 00:00:00 2001 From: gazebo Date: Mon, 11 Nov 2019 16:50:21 +0800 Subject: [PATCH 07/18] =?UTF-8?q?=E6=96=B0=E5=A2=9E=E4=BF=AE=E6=94=B9?= =?UTF-8?q?=E7=94=A8=E6=88=B7=E6=89=8B=E6=9C=BA=E5=8F=B7=E4=B8=BA=E5=BE=AE?= =?UTF-8?q?=E4=BF=A1=E7=BB=91=E5=AE=9A=E7=9A=84=E6=89=8B=E6=9C=BA=E5=8F=B7?= =?UTF-8?q?=EF=BC=8Cuser2/UpdateUserByMiniInfo?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../auth2/authprovider/weixin/weixin_mini.go | 28 ++++++++++++++--- controllers/auth2.go | 29 ----------------- controllers/cms_user2.go | 31 +++++++++++++++++++ routers/commentsRouter_controllers.go | 18 +++++------ 4 files changed, 63 insertions(+), 43 deletions(-) diff --git a/business/auth2/authprovider/weixin/weixin_mini.go b/business/auth2/authprovider/weixin/weixin_mini.go index bd95fb882..dcdc778ee 100644 --- a/business/auth2/authprovider/weixin/weixin_mini.go +++ b/business/auth2/authprovider/weixin/weixin_mini.go @@ -2,6 +2,7 @@ package weixin import ( "errors" + "fmt" "strings" "git.rosy.net.cn/baseapi/platformapi/weixinapi" @@ -44,12 +45,29 @@ func (a *MiniAuther) VerifySecret(dummy, jsCode string) (authBindEx *auth2.AuthB } // 特殊接口 -func (a *MiniAuther) DecryptData(authInfo *auth2.AuthInfo, encryptedData, iv string) (decryptedDataBase64 string, err error) { - globals.SugarLogger.Debugf("weixin mini DecryptData encryptedData:%s, iv:%s", encryptedData, iv) - if authInfo.AuthBindInfo.Type != AuthTypeMini { - return "", ErrAuthTypeShouldBeMini +func (a *MiniAuther) DecryptData(authInfo *auth2.AuthInfo, jsCode, encryptedData, iv string) (decryptedDataBase64 string, err error) { + globals.SugarLogger.Debugf("weixin mini DecryptData jsCode:%s, encryptedData:%s, iv:%s", jsCode, encryptedData, iv) + var sessionKey string + if jsCode != "" { + sessionInfo, err := ProxySNSCode2Session(jsCode) + if err == nil { + if authBindEx, err := a.UnionFindAuthBind(AuthTypeMini, []string{AuthTypeMini}, sessionInfo.OpenID, "", nil); err == nil { + if authBindEx.UserID != authInfo.GetID() { + return "", fmt.Errorf("jsCode与token不匹配") + } + } else { + return "", err + } + sessionKey = sessionInfo.SessionKey + } else { + return "", err + } + } else { + if authInfo.AuthBindInfo.Type != AuthTypeMini { + return "", ErrAuthTypeShouldBeMini + } + sessionKey = authInfo.AuthBindInfo.UserData.(string) } - sessionKey := authInfo.AuthBindInfo.UserData.(string) decryptedData, err := ProxySNSDecodeMiniProgramData(encryptedData, sessionKey, iv) if err != nil { return "", err diff --git a/controllers/auth2.go b/controllers/auth2.go index da3e17101..b769865ea 100644 --- a/controllers/auth2.go +++ b/controllers/auth2.go @@ -6,7 +6,6 @@ import ( "net/http" "strings" - "git.rosy.net.cn/baseapi/platformapi/weixinapi" "git.rosy.net.cn/baseapi/utils" "git.rosy.net.cn/jx-callback/business/auth2" "git.rosy.net.cn/jx-callback/business/auth2/authprovider/dingding" @@ -14,7 +13,6 @@ import ( "git.rosy.net.cn/jx-callback/business/auth2/authprovider/password" "git.rosy.net.cn/jx-callback/business/auth2/authprovider/weixin" "git.rosy.net.cn/jx-callback/business/model" - "git.rosy.net.cn/jx-callback/business/model/dao" "git.rosy.net.cn/jx-callback/globals" "github.com/astaxie/beego" ) @@ -297,30 +295,3 @@ func (c *Auth2Controller) ChangePassword() { return retVal, "", err }) } - -// @Title 解密小程序数据 -// @Description 解密小程序数据 -// @Param token header string true "认证token" -// @Param data formData string true "加密数据" -// @Param iv formData string true "iv" -// @Success 200 {object} controllers.CallResult -// @Failure 200 {object} controllers.CallResult -// @router /MiniDecryptData [post] -func (c *Auth2Controller) MiniDecryptData() { - c.callMiniDecryptData(func(params *tAuth2MiniDecryptDataParams) (retVal interface{}, errCode string, err error) { - authInfo, err := params.Ctx.GetV2AuthInfo() - if err == nil { - decryptedDataBase64, err2 := weixin.AutherObjMini.DecryptData(authInfo, params.Data, params.Iv) - if err = err2; err == nil { - var userInfo *weixinapi.MiniUserInfo - if err = utils.UnmarshalUseNumber([]byte(decryptedDataBase64), &userInfo); err == nil { - if user := params.Ctx.GetFullUser(); user != nil { - user.Avatar = userInfo.AvatarURL - dao.UpdateEntity(dao.GetDB(), user, "Avatar") - } - } - } - } - return retVal, "", err - }) -} diff --git a/controllers/cms_user2.go b/controllers/cms_user2.go index 71698ec13..b7e0423ff 100644 --- a/controllers/cms_user2.go +++ b/controllers/cms_user2.go @@ -1,13 +1,16 @@ package controllers import ( + "git.rosy.net.cn/baseapi/platformapi/weixinapi" "git.rosy.net.cn/baseapi/utils" "git.rosy.net.cn/jx-callback/business/auth2" + "git.rosy.net.cn/jx-callback/business/auth2/authprovider/weixin" "git.rosy.net.cn/jx-callback/business/authz" "git.rosy.net.cn/jx-callback/business/authz/autils" "git.rosy.net.cn/jx-callback/business/jxstore/cms" "git.rosy.net.cn/jx-callback/business/jxutils" "git.rosy.net.cn/jx-callback/business/model" + "git.rosy.net.cn/jx-callback/business/model/dao" "github.com/astaxie/beego" ) @@ -374,3 +377,31 @@ func (c *User2Controller) GetSelfInfo() { return retVal, "", err }) } + +// @Title 根据小程序jsCode修改用户信息 +// @Description 根据小程序jsCode修改用户信息 +// @Param token header string true "认证token" +// @Param jsCode query string true "小程序jsCode" +// @Param data query string true "加密数据" +// @Param iv query string true "iv" +// @Success 200 {object} controllers.CallResult +// @Failure 200 {object} controllers.CallResult +// @router /UpdateUserByMiniInfo [put] +func (c *Auth2Controller) UpdateUserByMiniInfo() { + c.callUpdateUserByMiniInfo(func(params *tAuth2UpdateUserByMiniInfoParams) (retVal interface{}, errCode string, err error) { + authInfo, err := params.Ctx.GetV2AuthInfo() + if err == nil { + decryptedDataBase64, err2 := weixin.AutherObjMini.DecryptData(authInfo, params.JsCode, params.Data, params.Iv) + if err = err2; err == nil { + var userInfo *weixinapi.MiniUserInfo + if err = utils.UnmarshalUseNumber([]byte(decryptedDataBase64), &userInfo); err == nil { + if user := params.Ctx.GetFullUser(); user != nil { + user.Avatar = userInfo.AvatarURL + dao.UpdateEntity(dao.GetDB(), user, "Avatar") + } + } + } + } + return retVal, "", err + }) +} diff --git a/routers/commentsRouter_controllers.go b/routers/commentsRouter_controllers.go index ae2d5f7d9..8f3d116fd 100644 --- a/routers/commentsRouter_controllers.go +++ b/routers/commentsRouter_controllers.go @@ -151,15 +151,6 @@ func init() { Filters: nil, Params: nil}) - beego.GlobalControllerRouter["git.rosy.net.cn/jx-callback/controllers:Auth2Controller"] = append(beego.GlobalControllerRouter["git.rosy.net.cn/jx-callback/controllers:Auth2Controller"], - beego.ControllerComments{ - Method: "MiniDecryptData", - Router: `/MiniDecryptData`, - AllowHTTPMethods: []string{"post"}, - MethodParams: param.Make(), - Filters: nil, - Params: nil}) - beego.GlobalControllerRouter["git.rosy.net.cn/jx-callback/controllers:Auth2Controller"] = append(beego.GlobalControllerRouter["git.rosy.net.cn/jx-callback/controllers:Auth2Controller"], beego.ControllerComments{ Method: "RemoveAuthBind", @@ -178,6 +169,15 @@ func init() { Filters: nil, Params: nil}) + beego.GlobalControllerRouter["git.rosy.net.cn/jx-callback/controllers:Auth2Controller"] = append(beego.GlobalControllerRouter["git.rosy.net.cn/jx-callback/controllers:Auth2Controller"], + beego.ControllerComments{ + Method: "UpdateUserByMiniInfo", + Router: `/UpdateUserByMiniInfo`, + AllowHTTPMethods: []string{"put"}, + MethodParams: param.Make(), + Filters: nil, + Params: nil}) + beego.GlobalControllerRouter["git.rosy.net.cn/jx-callback/controllers:Auth2Controller"] = append(beego.GlobalControllerRouter["git.rosy.net.cn/jx-callback/controllers:Auth2Controller"], beego.ControllerComments{ Method: "WeixinMPOAuth2", From ef5e755544638b11b501c09af5590feb5ca4c47d Mon Sep 17 00:00:00 2001 From: gazebo Date: Mon, 11 Nov 2019 17:33:19 +0800 Subject: [PATCH 08/18] =?UTF-8?q?TmpGetJxBadComments=E6=B7=BB=E5=8A=A0?= =?UTF-8?q?=E5=8F=AF=E9=80=89=E5=8F=82=E6=95=B0keyword?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- business/jxstore/cms/store.go | 9 ++++++++- controllers/cms_store.go | 9 +++++---- 2 files changed, 13 insertions(+), 5 deletions(-) diff --git a/business/jxstore/cms/store.go b/business/jxstore/cms/store.go index ec1a05806..368aed932 100644 --- a/business/jxstore/cms/store.go +++ b/business/jxstore/cms/store.go @@ -1123,7 +1123,7 @@ func TmpGetJxBadCommentsNo(ctx *jxcontext.Context, storeID int) (count int, err return count, err } -func TmpGetJxBadCommentsByStoreId(ctx *jxcontext.Context, storeIDs []int, offset, pageSize, commentType int, fromTime, toTime time.Time) (retVal map[string]interface{}, err error) { +func TmpGetJxBadCommentsByStoreId(ctx *jxcontext.Context, keyword string, storeIDs []int, offset, pageSize, commentType int, fromTime, toTime time.Time) (retVal map[string]interface{}, err error) { db := dao.GetDB() sql := ` SELECT SQL_CALC_FOUND_ROWS @@ -1136,6 +1136,13 @@ func TmpGetJxBadCommentsByStoreId(ctx *jxcontext.Context, storeIDs []int, offset WHERE 1 = 1 ` sqlParams := []interface{}{} + if keyword != "" { + keywordLike := "%" + keyword + "%" + sql += ` + AND (t1.order_id LIKE ? OR t1.jxstoreid LIKE ? OR t1.userphone LIKE ? OR t1.scorecontent LIKE ? OR t1.vendertags LIKE ? OR t1.updated_scorecontent LIKE ? + OR t1.updated_vendertags LIKE ? OR t2.name LIKE ?)` + sqlParams = append(sqlParams, keywordLike, keywordLike, keywordLike, keywordLike, keywordLike, keywordLike, keywordLike, keywordLike) + } if len(storeIDs) > 0 { sql += " AND t1.jxstoreid IN (" + dao.GenQuestionMarks(len(storeIDs)) + ")" sqlParams = append(sqlParams, storeIDs) diff --git a/controllers/cms_store.go b/controllers/cms_store.go index e7636d1a7..22d1b4420 100644 --- a/controllers/cms_store.go +++ b/controllers/cms_store.go @@ -237,7 +237,7 @@ func (c *StoreController) TmpGetJxBadCommentsByStoreId() { if err = err2; err == nil { pageSize := jxutils.FormalizePageSize(params.Size) offset := (params.Page - 1) * pageSize - retVal, err = cms.TmpGetJxBadCommentsByStoreId(params.Ctx, []int{params.JxStoreId}, offset, pageSize, params.Type, timeList[0], timeList[1]) + retVal, err = cms.TmpGetJxBadCommentsByStoreId(params.Ctx, "", []int{params.JxStoreId}, offset, pageSize, params.Type, timeList[0], timeList[1]) } return retVal, "", err }) @@ -247,11 +247,12 @@ func (c *StoreController) TmpGetJxBadCommentsByStoreId() { // @Description 得到门店评价列表(多店) // @Param token header string true "认证token" // @Param type query int true "评论类型,0:差评,1:所有,2:已解决" +// @Param keyword query string false "关键字" // @Param storeIDs query string false "门店I列表" -// @Param offset query int false "起始页,从1开始" -// @Param pageSize query int false "页大小(-1表示无限大)" // @Param fromTime query string false "创建起始时间" // @Param toTime query string false "创建结束时间" +// @Param offset query int false "起始页,从1开始" +// @Param pageSize query int false "页大小(-1表示无限大)" // @Success 200 {object} controllers.CallResult // @Failure 200 {object} controllers.CallResult // @router /TmpGetJxBadComments [get] @@ -261,7 +262,7 @@ func (c *StoreController) TmpGetJxBadComments() { if err = jxutils.Strings2Objs(params.StoreIDs, &storeIDs); err == nil { timeList, err2 := jxutils.BatchStr2Time(params.FromTime, params.ToTime) if err = err2; err == nil { - retVal, err = cms.TmpGetJxBadCommentsByStoreId(params.Ctx, storeIDs, params.Offset, params.PageSize, params.Type, timeList[0], timeList[1]) + retVal, err = cms.TmpGetJxBadCommentsByStoreId(params.Ctx, params.Keyword, storeIDs, params.Offset, params.PageSize, params.Type, timeList[0], timeList[1]) } } return retVal, "", err From 3bc450baa257f2fd7b6bcb9e7f51ff0ec3c110f2 Mon Sep 17 00:00:00 2001 From: gazebo Date: Mon, 11 Nov 2019 17:41:14 +0800 Subject: [PATCH 09/18] up --- controllers/cms_user2.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/controllers/cms_user2.go b/controllers/cms_user2.go index b7e0423ff..a5fd05b5f 100644 --- a/controllers/cms_user2.go +++ b/controllers/cms_user2.go @@ -391,7 +391,7 @@ func (c *Auth2Controller) UpdateUserByMiniInfo() { c.callUpdateUserByMiniInfo(func(params *tAuth2UpdateUserByMiniInfoParams) (retVal interface{}, errCode string, err error) { authInfo, err := params.Ctx.GetV2AuthInfo() if err == nil { - decryptedDataBase64, err2 := weixin.AutherObjMini.DecryptData(authInfo, params.JsCode, params.Data, params.Iv) + decryptedDataBase64, err2 := weixin.AutherObjMini.DecryptData(authInfo, GetComposedCode(&c.Controller, params.JsCode), params.Data, params.Iv) if err = err2; err == nil { var userInfo *weixinapi.MiniUserInfo if err = utils.UnmarshalUseNumber([]byte(decryptedDataBase64), &userInfo); err == nil { From 2e02d058404a87a887b1c5bebdcb80d93080509c Mon Sep 17 00:00:00 2001 From: gazebo Date: Mon, 11 Nov 2019 18:23:02 +0800 Subject: [PATCH 10/18] up --- business/auth2/authprovider/weixin/weixin_mini.go | 1 + 1 file changed, 1 insertion(+) diff --git a/business/auth2/authprovider/weixin/weixin_mini.go b/business/auth2/authprovider/weixin/weixin_mini.go index dcdc778ee..cd6e4510e 100644 --- a/business/auth2/authprovider/weixin/weixin_mini.go +++ b/business/auth2/authprovider/weixin/weixin_mini.go @@ -68,6 +68,7 @@ func (a *MiniAuther) DecryptData(authInfo *auth2.AuthInfo, jsCode, encryptedData } sessionKey = authInfo.AuthBindInfo.UserData.(string) } + globals.SugarLogger.Debugf("weixin mini DecryptData2 jsCode:%s, encryptedData:%s, iv:%s, sessionKey:%s", jsCode, encryptedData, iv, sessionKey) decryptedData, err := ProxySNSDecodeMiniProgramData(encryptedData, sessionKey, iv) if err != nil { return "", err From 977f08b13ad78d69e02a1c115e6a8de242d7f443 Mon Sep 17 00:00:00 2001 From: gazebo Date: Mon, 11 Nov 2019 18:29:44 +0800 Subject: [PATCH 11/18] up --- controllers/cms_user2.go | 1 + 1 file changed, 1 insertion(+) diff --git a/controllers/cms_user2.go b/controllers/cms_user2.go index a5fd05b5f..e29f7ebef 100644 --- a/controllers/cms_user2.go +++ b/controllers/cms_user2.go @@ -393,6 +393,7 @@ func (c *Auth2Controller) UpdateUserByMiniInfo() { if err == nil { decryptedDataBase64, err2 := weixin.AutherObjMini.DecryptData(authInfo, GetComposedCode(&c.Controller, params.JsCode), params.Data, params.Iv) if err = err2; err == nil { + retVal = decryptedDataBase64 var userInfo *weixinapi.MiniUserInfo if err = utils.UnmarshalUseNumber([]byte(decryptedDataBase64), &userInfo); err == nil { if user := params.Ctx.GetFullUser(); user != nil { From 5cf7e75aaf79bc01f552a3ee5a819b217ab0aeaf Mon Sep 17 00:00:00 2001 From: gazebo Date: Tue, 12 Nov 2019 09:29:19 +0800 Subject: [PATCH 12/18] =?UTF-8?q?UpdateUserByMiniInfo=E4=B8=AD=E6=9B=B4?= =?UTF-8?q?=E6=96=B0=E5=A4=B4=E5=83=8F=E6=88=96=E6=89=8B=E6=9C=BA=E5=8F=B7?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- business/auth2/authprovider/weixin/weixin_mini.go | 2 +- controllers/cms_user2.go | 11 ++++++++--- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/business/auth2/authprovider/weixin/weixin_mini.go b/business/auth2/authprovider/weixin/weixin_mini.go index cd6e4510e..6e079b7ee 100644 --- a/business/auth2/authprovider/weixin/weixin_mini.go +++ b/business/auth2/authprovider/weixin/weixin_mini.go @@ -68,7 +68,6 @@ func (a *MiniAuther) DecryptData(authInfo *auth2.AuthInfo, jsCode, encryptedData } sessionKey = authInfo.AuthBindInfo.UserData.(string) } - globals.SugarLogger.Debugf("weixin mini DecryptData2 jsCode:%s, encryptedData:%s, iv:%s, sessionKey:%s", jsCode, encryptedData, iv, sessionKey) decryptedData, err := ProxySNSDecodeMiniProgramData(encryptedData, sessionKey, iv) if err != nil { return "", err @@ -94,6 +93,7 @@ func ProxySNSCode2Session(jsCode string) (sessionInfo *weixinapi.SessionInfo, er } func ProxySNSDecodeMiniProgramData(encryptedData, sessionKey, iv string) (decryptedData []byte, err error) { + globals.SugarLogger.Debugf("ProxySNSDecodeMiniProgramData, encryptedData:%s, sessionKey:%s, iv:%s", encryptedData, sessionKey, iv) decryptedData, err = api.WeixinMiniAPI.SNSDecodeMiniProgramData(encryptedData, sessionKey, iv) return decryptedData, err } diff --git a/controllers/cms_user2.go b/controllers/cms_user2.go index e29f7ebef..71cd2d452 100644 --- a/controllers/cms_user2.go +++ b/controllers/cms_user2.go @@ -393,12 +393,17 @@ func (c *Auth2Controller) UpdateUserByMiniInfo() { if err == nil { decryptedDataBase64, err2 := weixin.AutherObjMini.DecryptData(authInfo, GetComposedCode(&c.Controller, params.JsCode), params.Data, params.Iv) if err = err2; err == nil { - retVal = decryptedDataBase64 var userInfo *weixinapi.MiniUserInfo if err = utils.UnmarshalUseNumber([]byte(decryptedDataBase64), &userInfo); err == nil { + retVal = userInfo if user := params.Ctx.GetFullUser(); user != nil { - user.Avatar = userInfo.AvatarURL - dao.UpdateEntity(dao.GetDB(), user, "Avatar") + if userInfo.AvatarURL != "" { + user.Avatar = userInfo.AvatarURL + } + if userInfo.PurePhoneNumber != "" { + user.Mobile = utils.String2Pointer(userInfo.PurePhoneNumber) + } + dao.UpdateEntity(dao.GetDB(), user) } } } From 89e39071e85d1a8da1b8b5ab862beae3067aaff7 Mon Sep 17 00:00:00 2001 From: gazebo Date: Tue, 12 Nov 2019 10:32:53 +0800 Subject: [PATCH 13/18] =?UTF-8?q?GetStoreListByLocation=E8=BF=94=E5=9B=9E?= =?UTF-8?q?=E8=90=A5=E4=B8=9A=E6=97=B6=E9=97=B4=E5=8F=8A=E9=97=A8=E5=BA=97?= =?UTF-8?q?=E7=8A=B6=E6=80=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- business/jxstore/cms/store.go | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/business/jxstore/cms/store.go b/business/jxstore/cms/store.go index 368aed932..5f2160e21 100644 --- a/business/jxstore/cms/store.go +++ b/business/jxstore/cms/store.go @@ -67,6 +67,11 @@ type Store4User struct { OriginalName string `orm:"-" json:"originalName"` Name string `orm:"size(255)" json:"name"` + OpenTime1 int16 `json:"openTime1"` // 930就表示9点半,用两个的原因是为了支持中午休息,1与2的时间段不能交叉,为0表示没有 + CloseTime1 int16 `json:"closeTime1"` // 格式同上 + OpenTime2 int16 `json:"openTime2"` // 格式同上 + CloseTime2 int16 `json:"closeTime2"` // 格式同上 + Status int `json:"status"` CityCode int `orm:"default(0);null" json:"cityCode"` // todo ? DistrictCode int `orm:"default(0);null" json:"districtCode"` // todo ? Address string `orm:"size(255)" json:"address"` From d96f50058fabe0d6d33ad1d9a8d78974ed561887 Mon Sep 17 00:00:00 2001 From: gazebo Date: Tue, 12 Nov 2019 11:00:25 +0800 Subject: [PATCH 14/18] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E5=8F=96=E6=B6=88?= =?UTF-8?q?=E7=BB=93=E7=AE=97=E6=B4=BB=E5=8A=A8=E6=97=B6=E7=9A=84bug?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- business/jxstore/act/act.go | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/business/jxstore/act/act.go b/business/jxstore/act/act.go index 9e78f07e1..f887f9a35 100644 --- a/business/jxstore/act/act.go +++ b/business/jxstore/act/act.go @@ -105,6 +105,7 @@ func ActStoreSkuParam2Model(ctx *jxcontext.Context, db *dao.DaoDB, act *model.Ac } storeIDs := jxutils.IntMap2List(storeIDMap) 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) if err != nil { @@ -150,7 +151,7 @@ func ActStoreSkuParam2Model(ctx *jxcontext.Context, db *dao.DaoDB, act *model.Ac v.OriginalPrice = int64(jxPrice) } var err2 error - if act.Type != model.ActSkuFake { + if act.Type != model.ActSkuFake { // 非结算,要计算实际活动价格 if storeSkuInfo == nil { v.ErrMsg = fmt.Sprintf("门店:%d没有关注商品:%d", v.StoreID, v.SkuID) wrongSkuList = append(wrongSkuList, v) @@ -697,11 +698,13 @@ func DeleteActStoreSkuBind(ctx *jxcontext.Context, db *dao.DaoDB, actID int, act syncStatus = model.SyncFlagDeletedMask } syncStatus |= act.SyncStatus - if _, err = dao.UpdateEntityLogically(db, partner.Act2ActMap(act), - map[string]interface{}{ - model.FieldSyncStatus: syncStatus, - }, ctx.GetUserName(), nil); err != nil { - return err + if act.Type != model.ActSkuFake { + if _, err = dao.UpdateEntityLogically(db, partner.Act2ActMap(act), + map[string]interface{}{ + model.FieldSyncStatus: syncStatus, + }, ctx.GetUserName(), nil); err != nil { + return err + } } } if isDeleteAll != isNeedCancelAct { @@ -709,7 +712,7 @@ func DeleteActStoreSkuBind(ctx *jxcontext.Context, db *dao.DaoDB, actID int, act } } - if isNeedCancelAct && act.Type != model.ActSkuFake { + if isNeedCancelAct { act := &model.Act{} act.ID = actID if _, err = dao.UpdateEntityLogically(db, act, From a2a5ae7e50511fcb8d4240ab4626160ed26065ca Mon Sep 17 00:00:00 2001 From: gazebo Date: Tue, 12 Nov 2019 11:12:56 +0800 Subject: [PATCH 15/18] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E7=BB=93=E7=AE=97?= =?UTF-8?q?=E6=B4=BB=E5=8A=A8=E6=97=B6=EF=BC=8C=E4=B8=8D=E5=BA=94=E8=AF=A5?= =?UTF-8?q?=E8=AE=BE=E7=BD=AE=E5=90=8C=E6=AD=A5=E6=A0=87=E5=BF=97?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- business/jxstore/act/act.go | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/business/jxstore/act/act.go b/business/jxstore/act/act.go index f887f9a35..60b6aa224 100644 --- a/business/jxstore/act/act.go +++ b/business/jxstore/act/act.go @@ -282,12 +282,14 @@ func AddActStoreSkuBind(ctx *jxcontext.Context, db *dao.DaoDB, actID int, actSto if err = addActStoreSkuBind(ctx, db, actStoreSkuList, actStoreSkuMapList); err != nil { return err } - for _, act := range actMap { - if _, err = dao.UpdateEntityLogically(db, partner.Act2ActMap(act), - map[string]interface{}{ - model.FieldSyncStatus: act.SyncStatus | model.SyncFlagModifiedMask, - }, ctx.GetUserName(), nil); err != nil { - return err + if act.Type != model.ActSkuFake { + for _, act := range actMap { + if _, err = dao.UpdateEntityLogically(db, partner.Act2ActMap(act), + map[string]interface{}{ + model.FieldSyncStatus: act.SyncStatus | model.SyncFlagModifiedMask, + }, ctx.GetUserName(), nil); err != nil { + return err + } } } dao.Commit(db) From 18ff115fc6760ea5be98e16f7403e96f14e44b82 Mon Sep 17 00:00:00 2001 From: gazebo Date: Tue, 12 Nov 2019 11:30:26 +0800 Subject: [PATCH 16/18] =?UTF-8?q?SkuNamePrefixNames=E4=B8=AD=E5=8E=BB?= =?UTF-8?q?=E9=99=A4=E2=80=9C=E9=B1=BC=E8=85=A5=E8=8D=89=E2=80=9D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- business/model/sku.go | 1 - 1 file changed, 1 deletion(-) diff --git a/business/model/sku.go b/business/model/sku.go index 79dd52c62..cc8036ce2 100644 --- a/business/model/sku.go +++ b/business/model/sku.go @@ -74,7 +74,6 @@ var ( "长条", "鲜活宰杀", "惠", - "鱼腥草", "冰冻", "思念", "散装", From ca3404dd77850d8b783c40636125a4d5fb0c975d Mon Sep 17 00:00:00 2001 From: gazebo Date: Tue, 12 Nov 2019 14:02:42 +0800 Subject: [PATCH 17/18] up --- business/model/store_sku.go | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/business/model/store_sku.go b/business/model/store_sku.go index d27b76d4b..310697fcc 100644 --- a/business/model/store_sku.go +++ b/business/model/store_sku.go @@ -45,7 +45,7 @@ type StoreSkuCategoryMap struct { // ElmID int64 `orm:"column(elm_id);index"` EbaiID int64 `orm:"column(ebai_id);index"` - MtwmID string `orm:"column(mtwm_id);index;size(16)"` // 美团外卖没有ID,保存名字 + MtwmID string `orm:"column(mtwm_id);index;size(16)"` // WscID int64 `orm:"column(wsc_id);index"` // ElmSyncStatus int8 `orm:"default(2)"` @@ -95,7 +95,7 @@ type StoreSkuBind struct { // ElmID int64 `orm:"column(elm_id);index"` EbaiID int64 `orm:"column(ebai_id);index"` - MtwmID int64 `orm:"column(mtwm_id)"` // 这个也不是必须的,只是为了DAO取数据语句一致 + MtwmID int64 `orm:"column(mtwm_id)"` // WscID int64 `orm:"column(wsc_id);index"` // 表示微盟skuId // WscID2 int64 `orm:"column(wsc_id2);index"` // 表示微盟goodsId @@ -108,6 +108,7 @@ type StoreSkuBind struct { JdPrice int `json:"jdPrice"` EbaiPrice int `json:"ebaiPrice"` MtwmPrice int `json:"mtwmPrice"` + // JxPrice int `json:"jxPrice"` // WscPrice int `json:"wscPrice"` AutoSaleAt time.Time `orm:"type(datetime);null" json:"autoSaleAt"` From 0b82b6a0991f420ce9ba3ca617da1ae384ece1e0 Mon Sep 17 00:00:00 2001 From: gazebo Date: Tue, 12 Nov 2019 14:59:14 +0800 Subject: [PATCH 18/18] =?UTF-8?q?!!!=E4=BF=AE=E6=94=B9=E7=BE=8E=E5=9B=A2?= =?UTF-8?q?=E8=AE=A2=E5=8D=95=E7=9A=84=E9=80=BB=E8=BE=91=EF=BC=8C=E4=B8=8D?= =?UTF-8?q?=E5=9C=A8=E7=94=A8=E6=8E=A5=E5=8F=97=E8=AE=A2=E5=8D=95=E5=BD=93?= =?UTF-8?q?=E6=88=90=E6=8B=A3=E8=B4=A7=E5=AE=8C=E6=88=90=EF=BC=8C=E4=BD=BF?= =?UTF-8?q?=E7=94=A8order/preparationMealComplete=E4=B8=BA=E5=AE=9E?= =?UTF-8?q?=E9=99=85=E6=8B=A3=E8=B4=A7?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- business/partner/purchase/mtwm/order.go | 83 +++++++++++++---------- business/partner/purchase/mtwm/waybill.go | 15 +--- 2 files changed, 47 insertions(+), 51 deletions(-) diff --git a/business/partner/purchase/mtwm/order.go b/business/partner/purchase/mtwm/order.go index 82ee31b6b..df3076aa1 100644 --- a/business/partner/purchase/mtwm/order.go +++ b/business/partner/purchase/mtwm/order.go @@ -11,7 +11,6 @@ import ( "git.rosy.net.cn/baseapi/platformapi/mtwmapi" "git.rosy.net.cn/baseapi/utils" - "git.rosy.net.cn/jx-callback/business/jxcallback/scheduler" "git.rosy.net.cn/jx-callback/business/jxutils" "git.rosy.net.cn/jx-callback/business/jxutils/jxcontext" "git.rosy.net.cn/jx-callback/business/jxutils/tasksch" @@ -23,9 +22,9 @@ import ( ) const ( - FakeMsgTypeOrderReceived = "orderReceived" - FakeMsgTypeOrderDelivering = "orderDelivering" + FakeMsgType = "fakeMsgType" + fakeFinishedPickup = "fake_finished_pickup" fakeUserApplyCancel = "fake_user_apply_cancel" fakeMerchantAgreeApplyCancel = "fake_merchant_agree_apply_cancel" fakeRefuseUserApplyCancel = "fake_refuse_user_apply_cancel" @@ -38,11 +37,11 @@ const ( ) const ( - // pickupOrderDelay = 260 * time.Second - pickupOrderDelay = 1 * time.Second +// pickupOrderDelay = 260 * time.Second +// pickupOrderDelay = 1 * time.Second - callDeliveryDelay = 10 * time.Minute - callDeliveryDelayGap = 30 +// callDeliveryDelay = 10 * time.Minute +// callDeliveryDelayGap = 30 ) var ( @@ -53,13 +52,16 @@ var ( VendorStatus2StatusMap = map[string]int{ mtwmapi.OrderStatusUserCommitted: model.OrderStatusUnknown, mtwmapi.OrderStatusNew: model.OrderStatusNew, - mtwmapi.OrderStatusReceived: model.OrderStatusAccepted, - mtwmapi.OrderStatusAccepted: model.OrderStatusFinishedPickup, - mtwmapi.OrderStatusDelivering: model.OrderStatusDelivering, - mtwmapi.OrderStatusDelivered: model.OrderStatusUnknown, // 以mtwmapi.OrderStatusFinished为结束状态,这个当成一个中间状态(且很少看到这个状态) - mtwmapi.OrderStatusFinished: model.OrderStatusFinished, - mtwmapi.OrderStatusCanceled: model.OrderStatusCanceled, + // mtwmapi.OrderStatusReceived: model.OrderStatusAccepted, + // mtwmapi.OrderStatusAccepted: model.OrderStatusFinishedPickup, + mtwmapi.OrderStatusAccepted: model.OrderStatusAccepted, + mtwmapi.OrderStatusDelivering: model.OrderStatusDelivering, + mtwmapi.OrderStatusDelivered: model.OrderStatusUnknown, // 以mtwmapi.OrderStatusFinished为结束状态,这个当成一个中间状态(且很少看到这个状态) + mtwmapi.OrderStatusFinished: model.OrderStatusFinished, + mtwmapi.OrderStatusCanceled: model.OrderStatusCanceled, + + fakeFinishedPickup: model.OrderStatusFinishedPickup, fakeOrderAdjustFinished: model.OrderStatusAdjust, fakeRefuseUserApplyCancel: model.OrderStatusUnlocked, fakeUserApplyCancel: model.OrderStatusApplyCancel, @@ -142,9 +144,10 @@ func (p *PurchaseHandler) Map2Order(orderData map[string]interface{}) (order *mo if openUID > 0 { order.VendorUserID = utils.Int64ToStr(openUID) } - if utils.IsTimeZero(order.PickDeadline) && !utils.IsTimeZero(order.StatusTime) { - order.PickDeadline = order.StatusTime.Add(pickupOrderDelay) // 美团外卖要求在5分钟内拣货,不然订单会被取消 - } + // 不设置最晚拣货时间,以缺省值为准 + // if utils.IsTimeZero(order.PickDeadline) && !utils.IsTimeZero(order.StatusTime) { + // order.PickDeadline = order.StatusTime.Add(pickupOrderDelay) // 美团外卖要求在5分钟内拣货,不然订单会被取消 + // } order.Status = p.getStatusFromVendorStatus(order.VendorStatus) if utils.IsTimeZero(order.ExpectedDeliveredTime) { order.BusinessType = model.BusinessTypeImmediate @@ -347,7 +350,7 @@ func (c *PurchaseHandler) callbackMsg2Status(msg *mtwmapi.CallbackMsg) (orderSta case mtwmapi.MsgTypeOrderCanceled: vendorStatus = mtwmapi.OrderStatusCanceled remark = msg.FormData.Get("reason") - case mtwmapi.MsgTypeNewOrder, FakeMsgTypeOrderReceived, mtwmapi.MsgTypeOrderAccepted, FakeMsgTypeOrderDelivering, mtwmapi.MsgTypeOrderFinished: + case FakeMsgType, mtwmapi.MsgTypeNewOrder, mtwmapi.MsgTypeOrderAccepted, mtwmapi.MsgTypeOrderFinished: vendorStatus = msg.FormData.Get("status") statusTime = utils.Str2Int64(msg.FormData.Get("utime")) case mtwmapi.MsgTypeOrderRefund, mtwmapi.MsgTypeOrderPartialRefund: @@ -414,11 +417,15 @@ func (c *PurchaseHandler) AcceptOrRefuseOrder(order *model.GoodsOrder, isAcceptI globals.SugarLogger.Debugf("mtwm AcceptOrRefuseOrder orderID:%s, isAcceptIt:%t", order.VendorOrderID, isAcceptIt) if isAcceptIt { if globals.EnableMtwmStoreWrite { - err = api.MtwmAPI.OrderReceived(utils.Str2Int64(order.VendorOrderID)) - } - if err == nil { - c.postFakeMsg(order.VendorOrderID, FakeMsgTypeOrderReceived, mtwmapi.OrderStatusReceived) + // err = api.MtwmAPI.OrderReceived(utils.Str2Int64(order.VendorOrderID)) + err = api.MtwmAPI.OrderConfirm(utils.Str2Int64(order.VendorOrderID)) + if err != nil { + globals.SugarLogger.Warnf("mtwm AcceptOrRefuseOrder orderID:%s failed with err:%v", order.VendorOrderID, err) + } } + // if err == nil { + // c.postFakeMsg(order.VendorOrderID, FakeMsgType, mtwmapi.OrderStatusReceived) + // } } else { if globals.EnableMtwmStoreWrite { err = c.CancelOrder(jxcontext.AdminCtx, order, "bu") @@ -430,9 +437,11 @@ func (c *PurchaseHandler) AcceptOrRefuseOrder(order *model.GoodsOrder, isAcceptI func (c *PurchaseHandler) PickupGoods(order *model.GoodsOrder, isSelfDelivery bool, userName string) (err error) { globals.SugarLogger.Debugf("mtwm PickupGoods orderID:%s, isSelfDelivery:%t", order.VendorOrderID, isSelfDelivery) if globals.EnableMtwmStoreWrite { - err = api.MtwmAPI.OrderConfirm(utils.Str2Int64(order.VendorOrderID)) - } else { - c.postFakeMsg(order.VendorOrderID, mtwmapi.MsgTypeOrderAccepted, mtwmapi.OrderStatusAccepted) + // err = api.MtwmAPI.OrderConfirm(utils.Str2Int64(order.VendorOrderID)) + err = api.MtwmAPI.PreparationMealComplete(utils.Str2Int64(order.VendorOrderID)) + } + if err == nil { + c.postFakeMsg(order.VendorOrderID, FakeMsgType, fakeFinishedPickup) } return err } @@ -495,19 +504,19 @@ func (c *PurchaseHandler) GetOrderRealMobile(ctx *jxcontext.Context, order *mode return mobile, err } -func (c *PurchaseHandler) GetStatusActionTimeout(order *model.GoodsOrder, statusType, status int) (params *partner.StatusActionParams) { - if statusType == scheduler.TimerStatusTypeOrder && status == model.OrderStatusAccepted { - params = &partner.StatusActionParams{ // PickDeadline没有设置时才有效,美团外卖要求在5分钟内拣货,不然订单会被取消 - Timeout: pickupOrderDelay, - } - } else if statusType == scheduler.TimerStatusTypeOrder && status == model.OrderStatusFinishedPickup { - params = &partner.StatusActionParams{ // 立即达订单有效,自配送延时召唤配送 - Timeout: callDeliveryDelay, - TimeoutGap: callDeliveryDelayGap, - } - } - return params -} +// func (c *PurchaseHandler) GetStatusActionTimeout(order *model.GoodsOrder, statusType, status int) (params *partner.StatusActionParams) { +// if statusType == scheduler.TimerStatusTypeOrder && status == model.OrderStatusAccepted { +// params = &partner.StatusActionParams{ // PickDeadline没有设置时才有效,美团外卖要求在5分钟内拣货,不然订单会被取消 +// Timeout: pickupOrderDelay, +// } +// } else if statusType == scheduler.TimerStatusTypeOrder && status == model.OrderStatusFinishedPickup { +// params = &partner.StatusActionParams{ // 立即达订单有效,自配送延时召唤配送 +// Timeout: callDeliveryDelay, +// TimeoutGap: callDeliveryDelayGap, +// } +// } +// return params +// } func (c *PurchaseHandler) AgreeOrRefuseCancel(ctx *jxcontext.Context, order *model.GoodsOrder, isAgree bool, reason string) (err error) { if globals.EnableMtwmStoreWrite { diff --git a/business/partner/purchase/mtwm/waybill.go b/business/partner/purchase/mtwm/waybill.go index be3b39f66..4c44081a6 100644 --- a/business/partner/purchase/mtwm/waybill.go +++ b/business/partner/purchase/mtwm/waybill.go @@ -1,9 +1,6 @@ package mtwm import ( - "net/url" - "time" - "git.rosy.net.cn/baseapi/platformapi/mtwmapi" "git.rosy.net.cn/baseapi/utils" "git.rosy.net.cn/jx-callback/business/model" @@ -33,17 +30,7 @@ func (c *PurchaseHandler) onWaybillMsg(msg *mtwmapi.CallbackMsg) (response *mtwm waybill := c.callbackMsg2Waybill(msg) err := partner.CurOrderManager.OnWaybillStatusChanged(waybill) if err == nil && waybill.Status == model.WaybillStatusDelivering { - msg := &mtwmapi.CallbackMsg{ - Cmd: FakeMsgTypeOrderDelivering, - FormData: url.Values{}, - } - msg.FormData.Set("timestamp", utils.Int64ToStr(time.Now().Unix())) - msg.FormData.Set("utime", msg.FormData.Get("timestamp")) - msg.FormData.Set(mtwmapi.KeyOrderID, waybill.VendorOrderID) - msg.FormData.Set("status", mtwmapi.OrderStatusDelivering) - utils.CallFuncAsync(func() { - c.onOrderMsg(msg) - }) + c.postFakeMsg(waybill.VendorOrderID, FakeMsgType, mtwmapi.OrderStatusDelivering) } return mtwmapi.Err2CallbackResponse(err, "") }