From a2252e64877c1e334311a1173010cb0a04287814 Mon Sep 17 00:00:00 2001 From: gazebo Date: Mon, 28 Oct 2019 13:44:06 +0800 Subject: [PATCH 01/67] =?UTF-8?q?updateOrderOtherInfo=E4=B8=AD=E4=B8=8D?= =?UTF-8?q?=E7=89=B9=E6=AE=8A=E5=A4=84=E7=90=86VendorIDJX?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- business/jxcallback/orderman/order.go | 40 ++++++++------------------- business/model/dao/store.go | 16 ++++------- 2 files changed, 17 insertions(+), 39 deletions(-) diff --git a/business/jxcallback/orderman/order.go b/business/jxcallback/orderman/order.go index 8f7bee87c..b9dcf5fd7 100644 --- a/business/jxcallback/orderman/order.go +++ b/business/jxcallback/orderman/order.go @@ -385,37 +385,19 @@ func (c *OrderManager) updateOrderOtherInfo(order *model.GoodsOrder, db *dao.Dao globals.SugarLogger.Debugf("updateOrderOtherInfo orderID:%s, VendorStoreID:%s", order.VendorOrderID, order.VendorStoreID) payPercentage := 0 - if order.VendorID != model.VendorIDJX { - storeDetail, err := dao.GetStoreDetailByVendorStoreID(db, order.VendorStoreID, order.VendorID) - if err != nil { - if !dao.IsNoRowsError(err) { - globals.SugarLogger.Warnf("updateOrderOtherInfo GetStoreDetailByVendorStoreID orderID:%s, VendorStoreID:%s, error:%v", order.VendorOrderID, order.VendorStoreID, err) - return err - } - if time.Now().Sub(order.OrderCreatedAt) < 1*time.Hour { - globals.SugarLogger.Infof("updateOrderOtherInfo [运营]订单在京西与平台都找不到京西门店信息,订单:%s,平台门店ID:%s,平台:%s", order.VendorOrderID, order.VendorStoreID, model.VendorChineseNames[order.VendorID]) - } - err = nil - } else { - order.JxStoreID = storeDetail.Store.ID - payPercentage = storeDetail.PayPercentage + storeDetail, err := dao.GetStoreDetailByVendorStoreID(db, order.VendorStoreID, order.VendorID) + if err != nil { + if !dao.IsNoRowsError(err) { + globals.SugarLogger.Warnf("updateOrderOtherInfo GetStoreDetailByVendorStoreID orderID:%s, VendorStoreID:%s, error:%v", order.VendorOrderID, order.VendorStoreID, err) + return err } + if time.Now().Sub(order.OrderCreatedAt) < 1*time.Hour { + globals.SugarLogger.Infof("updateOrderOtherInfo [运营]订单在京西与平台都找不到京西门店信息,订单:%s,平台门店ID:%s,平台:%s", order.VendorOrderID, order.VendorStoreID, model.VendorChineseNames[order.VendorID]) + } + err = nil } else { - store := &model.Store{} - store.ID = order.StoreID - if err = dao.GetEntity(dao.GetDB(), store); err != nil { - if !dao.IsNoRowsError(err) { - globals.SugarLogger.Warnf("updateOrderOtherInfo GetEntity orderID:%s, VendorStoreID:%s, error:%v", order.VendorOrderID, order.VendorStoreID, err) - return err - } - if time.Now().Sub(order.OrderCreatedAt) < 1*time.Hour { - globals.SugarLogger.Infof("updateOrderOtherInfo b, [运营]订单在京西与平台都找不到京西门店信息,订单:%s,平台门店ID:%s,平台:%s", order.VendorOrderID, order.VendorStoreID, model.VendorChineseNames[order.VendorID]) - } - err = nil - } else { - payPercentage = store.PayPercentage - } - order.JxStoreID = order.StoreID + order.JxStoreID = storeDetail.Store.ID + payPercentage = storeDetail.PayPercentage } if err = c.updateOrderSkuOtherInfo(order, db, payPercentage); err == nil { jxutils.RefreshOrderSkuRelated(order) diff --git a/business/model/dao/store.go b/business/model/dao/store.go index 7aae7ec61..f6d45fc59 100644 --- a/business/model/dao/store.go +++ b/business/model/dao/store.go @@ -101,6 +101,10 @@ func getStoreDetail(db *DaoDB, storeID, vendorID int, vendorStoreID string) (sto if err = GetRow(db, storeDetail, sql, sqlParams...); err == nil { storeDetail.PricePercentagePackObj = PricePercentagePack2Obj(storeDetail.PricePercentagePackStr) storeDetail.FreightDeductionPackObj = FreightDeductionPack2Obj(storeDetail.FreightDeductionPackStr) + if vendorID == model.VendorIDJX { + storeDetail.VendorStatus = storeDetail.Status + storeDetail.PricePercentage = 100 + } return storeDetail, nil } return nil, err @@ -114,16 +118,8 @@ func GetStoreDetailByVendorStoreID(db *DaoDB, vendorStoreID string, vendorID int if vendorID != model.VendorIDJX { return getStoreDetail(db, 0, vendorID, vendorStoreID) } - store := &model.Store{} - store.ID = int(utils.Str2Int64WithDefault(vendorStoreID, 0)) - if err = GetEntity(db, store); err == nil { - // todo 还要补全其它参数 - storeDetail = &StoreDetail{ - Store: *store, - VendorStoreID: vendorStoreID, - VendorStatus: store.Status, - PricePercentage: 100, - } + if storeDetail, err = getStoreDetail(db, int(utils.Str2Int64WithDefault(vendorStoreID, 0)), vendorID, ""); err == nil { + storeDetail.VendorStoreID = vendorStoreID } return storeDetail, err } From 8281dfb19dc36be7daf6918e92fac693c97ec26a Mon Sep 17 00:00:00 2001 From: gazebo Date: Mon, 28 Oct 2019 16:19:48 +0800 Subject: [PATCH 02/67] debug CompareJxAndVendor --- business/jxstore/cms/store_sku_check.go | 22 +++++++++++++++------- 1 file changed, 15 insertions(+), 7 deletions(-) diff --git a/business/jxstore/cms/store_sku_check.go b/business/jxstore/cms/store_sku_check.go index 3cce02e21..c41e4f1ff 100644 --- a/business/jxstore/cms/store_sku_check.go +++ b/business/jxstore/cms/store_sku_check.go @@ -283,14 +283,22 @@ func CompareJxAndVendor(vendorID int, storeIDStr, vendorStoreID, storeName strin } } for skuID, vendorSkuInfo := range filterVendorSkuInfoMap { - skuIDStr := utils.Int2Str(skuID) - vendorSkuDetailName := vendorSkuInfo.SkuList[0].SkuName - vendorSkuSaleStatusName := GetSkuSaleStatusName(vendorSkuInfo.SkuList[0].Status) + if vendorSkuInfo != nil { + if len(vendorSkuInfo.SkuList) > 0 { + skuIDStr := utils.Int2Str(skuID) + vendorSkuDetailName := vendorSkuInfo.SkuList[0].SkuName + vendorSkuSaleStatusName := GetSkuSaleStatusName(vendorSkuInfo.SkuList[0].Status) - jxSkuInfo := filterJxSkuInfoMap[skuID] - if jxSkuInfo == nil { - outPutData := DiffData{storeIDStr, vendorStoreID, storeName, skuIDStr, "", "", "", "", vendorSkuDetailName, "", vendorSkuSaleStatusName} - diffData.AppendData(vendorID, outPutData) + jxSkuInfo := filterJxSkuInfoMap[skuID] + if jxSkuInfo == nil { + outPutData := DiffData{storeIDStr, vendorStoreID, storeName, skuIDStr, "", "", "", "", vendorSkuDetailName, "", vendorSkuSaleStatusName} + diffData.AppendData(vendorID, outPutData) + } + } else { + globals.SugarLogger.Warnf("CompareJxAndVendor vendorSkuInfo.SkuList:%d is nil", skuID) + } + } else { + globals.SugarLogger.Warnf("CompareJxAndVendor skuID:%d is nil", skuID) } } } From 04e65edebdad352d628fcc2b3bfe6f17276e7455 Mon Sep 17 00:00:00 2001 From: gazebo Date: Tue, 29 Oct 2019 09:42:49 +0800 Subject: [PATCH 03/67] =?UTF-8?q?GetOrders=E5=92=8CGetAfsOrders=E6=94=AF?= =?UTF-8?q?=E6=8C=81Post?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- controllers/jx_order.go | 4 ++-- routers/commentsRouter_controllers.go | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/controllers/jx_order.go b/controllers/jx_order.go index b28ab30b9..703b4571c 100644 --- a/controllers/jx_order.go +++ b/controllers/jx_order.go @@ -283,7 +283,7 @@ func (c *OrderController) ExportMTWaybills() { // @Param pageSize query int false "结果页大小(缺省为50,-1表示全部)" // @Success 200 {object} controllers.CallResult // @Failure 200 {object} controllers.CallResult -// @router /GetOrders [get] +// @router /GetOrders [get,post] func (c *OrderController) GetOrders() { c.callGetOrders(func(params *tOrderGetOrdersParams) (retVal interface{}, errCode string, err error) { var skuIDs []int @@ -335,7 +335,7 @@ func (c *OrderController) ExportOrders() { // @Param pageSize query int false "结果页大小(缺省为50,-1表示全部)" // @Success 200 {object} controllers.CallResult // @Failure 200 {object} controllers.CallResult -// @router /GetAfsOrders [get] +// @router /GetAfsOrders [get,post] func (c *OrderController) GetAfsOrders() { c.callGetAfsOrders(func(params *tOrderGetAfsOrdersParams) (retVal interface{}, errCode string, err error) { timeList, err := jxutils.BatchStr2Time(params.FromTime, params.ToTime) diff --git a/routers/commentsRouter_controllers.go b/routers/commentsRouter_controllers.go index 9345a8936..157c07787 100644 --- a/routers/commentsRouter_controllers.go +++ b/routers/commentsRouter_controllers.go @@ -796,7 +796,7 @@ func init() { beego.ControllerComments{ Method: "GetAfsOrders", Router: `/GetAfsOrders`, - AllowHTTPMethods: []string{"get"}, + AllowHTTPMethods: []string{"get","post"}, MethodParams: param.Make(), Filters: nil, Params: nil}) @@ -841,7 +841,7 @@ func init() { beego.ControllerComments{ Method: "GetOrders", Router: `/GetOrders`, - AllowHTTPMethods: []string{"get"}, + AllowHTTPMethods: []string{"get","post"}, MethodParams: param.Make(), Filters: nil, Params: nil}) From 378edfd3c98937badefdc470e483f6cb22f138aa Mon Sep 17 00:00:00 2001 From: gazebo Date: Tue, 29 Oct 2019 11:38:39 +0800 Subject: [PATCH 04/67] =?UTF-8?q?=E8=85=BE=E8=AE=AF=E6=94=AF=E4=BB=98?= =?UTF-8?q?=E5=9B=9E=E8=B0=83?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- controllers/wxpay_callback.go | 26 ++++++++++++++++++++++++++ routers/router.go | 1 + 2 files changed, 27 insertions(+) create mode 100644 controllers/wxpay_callback.go diff --git a/controllers/wxpay_callback.go b/controllers/wxpay_callback.go new file mode 100644 index 000000000..3de328fc0 --- /dev/null +++ b/controllers/wxpay_callback.go @@ -0,0 +1,26 @@ +package controllers + +import ( + "net/http" + + "git.rosy.net.cn/baseapi/platformapi/wxpay" + "github.com/astaxie/beego" +) + +type WXPayController struct { + beego.Controller +} + +func (c *WXPayController) Msg() { + if c.Ctx.Input.Method() == http.MethodPost { + var callbackResponse *wxpay.CallbackResponse + + if callbackResponse == nil { + callbackResponse = wxpay.SuccessResponse + } + c.Data["xml"] = callbackResponse + c.ServeXML() + } else { + c.Abort("404") + } +} diff --git a/routers/router.go b/routers/router.go index 9e0979e45..ab384579f 100644 --- a/routers/router.go +++ b/routers/router.go @@ -133,6 +133,7 @@ func init() { beego.AutoRouter(&controllers.WeimobController{}) beego.AutoRouter(&controllers.WeixinController{}) beego.AutoRouter(&controllers.DingDingController{}) + beego.AutoRouter(&controllers.WXPayController{}) // 如下都是用于检测存活的空接口 beego.Any("/", func(ctx *beecontext.Context) { From 84bd8d0b32a86e318b40488fd879783af330e759 Mon Sep 17 00:00:00 2001 From: gazebo Date: Tue, 29 Oct 2019 17:28:49 +0800 Subject: [PATCH 05/67] =?UTF-8?q?=E4=BC=98=E5=8C=96mtwm.ListOrders?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- business/partner/purchase/mtwm/order.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/business/partner/purchase/mtwm/order.go b/business/partner/purchase/mtwm/order.go index 6a8209a0d..271f43d54 100644 --- a/business/partner/purchase/mtwm/order.go +++ b/business/partner/purchase/mtwm/order.go @@ -579,7 +579,7 @@ func (c *PurchaseHandler) ListOrders(ctx *jxcontext.Context, parentTask tasksch. orderIDs = append(orderIDs, utils.Int64ToStr(v)) } } - if err = err2; err != nil || len(tmpOrderIDs) == 0 { + if err = err2; err != nil || len(tmpOrderIDs) < mtwmapi.MaxGap4GetOrderIdByDaySeq { err = nil break } From db1e81902f89a514071edf675039e5dffe8b1c66 Mon Sep 17 00:00:00 2001 From: gazebo Date: Tue, 29 Oct 2019 17:30:49 +0800 Subject: [PATCH 06/67] =?UTF-8?q?=E4=BF=AE=E5=A4=8DGetOrderConsigneeNumber?= =?UTF-8?q?=E4=B8=8EGetOrderCourierNumber=E4=B8=AD=E6=B2=A1=E6=9C=89?= =?UTF-8?q?=E5=AE=9E=E9=99=85=E4=BD=BF=E7=94=A8offset=E7=9A=84bug?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- business/partner/purchase/mtwm/order.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/business/partner/purchase/mtwm/order.go b/business/partner/purchase/mtwm/order.go index 271f43d54..d27769f5f 100644 --- a/business/partner/purchase/mtwm/order.go +++ b/business/partner/purchase/mtwm/order.go @@ -609,7 +609,7 @@ func (c *PurchaseHandler) ListOrders(ctx *jxcontext.Context, parentTask tasksch. func (p *PurchaseHandler) GetOrderConsigneeNumber(ctx *jxcontext.Context, storeID int, vendorStoreID string) (numberList []*partner.OrderPhoneNumberInfo, err error) { offset := 0 for { - result, err2 := api.MtwmAPI.OrderBatchPullPhoneNumber(vendorStoreID, 0, mtwmapi.MaxBatchPullPhoneNumberLimit) + result, err2 := api.MtwmAPI.OrderBatchPullPhoneNumber(vendorStoreID, offset, mtwmapi.MaxBatchPullPhoneNumberLimit) if err = err2; err == nil { for _, v := range result { v2 := &partner.OrderPhoneNumberInfo{ @@ -635,7 +635,7 @@ func (p *PurchaseHandler) GetOrderConsigneeNumber(ctx *jxcontext.Context, storeI func (p *PurchaseHandler) GetOrderCourierNumber(ctx *jxcontext.Context, storeID int, vendorStoreID string) (numberList []*partner.OrderPhoneNumberInfo, err error) { offset := 0 for { - result, err2 := api.MtwmAPI.OrderGetRiderInfoPhoneNumber(vendorStoreID, 0, mtwmapi.MaxBatchPullPhoneNumberLimit) + result, err2 := api.MtwmAPI.OrderGetRiderInfoPhoneNumber(vendorStoreID, offset, mtwmapi.MaxBatchPullPhoneNumberLimit) if err = err2; err == nil { for _, v := range result { numberList = append(numberList, &partner.OrderPhoneNumberInfo{ From bed22236009c0d6150f8f964078f472e1b4bca50 Mon Sep 17 00:00:00 2001 From: gazebo Date: Tue, 29 Oct 2019 17:54:15 +0800 Subject: [PATCH 07/67] =?UTF-8?q?OrderManager.OnOrderStatusChanged?= =?UTF-8?q?=E4=B8=AD=20=E6=9C=89=E4=BA=9B=E5=B9=B3=E5=8F=B0=EF=BC=88?= =?UTF-8?q?=E6=AF=94=E5=A6=82=E7=BE=8E=E5=9B=A2=E5=A4=96=E5=8D=96=EF=BC=89?= =?UTF-8?q?=EF=BC=8C=E5=9C=A8=E6=96=B0=E8=AE=A2=E5=8D=95=E4=BA=8B=E4=BB=B6?= =?UTF-8?q?=E6=B2=A1=E6=9C=89=E6=88=90=E5=8A=9F=E8=BF=94=E5=9B=9E=EF=BC=8C?= =?UTF-8?q?=E4=BD=86=E5=9C=A8=E9=87=8D=E5=8F=91=E8=AE=A2=E5=8D=95=E6=B6=88?= =?UTF-8?q?=E6=81=AF=E5=89=8D=EF=BC=8C=E8=AE=A2=E5=8D=95=E7=8A=B6=E6=80=81?= =?UTF-8?q?=E8=BD=AC=E6=8D=A2=EF=BC=8C=E5=88=99=E4=B8=8D=E4=BC=9A=E5=86=8D?= =?UTF-8?q?=E9=87=8D=E5=8F=91=E6=96=B0=E8=AE=A2=E5=8D=95=E4=BA=8B=E4=BB=B6?= =?UTF-8?q?=EF=BC=8C=E7=89=B9=E6=AE=8A=E5=A4=84=E7=90=86=E4=B8=80=E4=B8=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- business/jxcallback/orderman/order.go | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/business/jxcallback/orderman/order.go b/business/jxcallback/orderman/order.go index b9dcf5fd7..b1c52f003 100644 --- a/business/jxcallback/orderman/order.go +++ b/business/jxcallback/orderman/order.go @@ -11,6 +11,7 @@ import ( "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" + "git.rosy.net.cn/jx-callback/business/partner" "git.rosy.net.cn/jx-callback/globals" "github.com/astaxie/beego/orm" ) @@ -151,6 +152,17 @@ func (c *OrderManager) OnOrderAdjust(order *model.GoodsOrder, orderStatus *model } func (c *OrderManager) OnOrderStatusChanged(orderStatus *model.OrderStatus) (err error) { + // 有些平台(比如美团外卖),在新订单事件没有成功返回,但在重发订单消息前,订单状态转换,则不会再重发新订单事件,特殊处理一下 + if orderStatus.Status == model.OrderStatusAccepted { + if _, err2 := c.LoadOrder(orderStatus.VendorOrderID, orderStatus.VendorID); err2 == ErrCanNotFindOrder { + if handler := partner.GetPurchaseOrderHandlerFromVendorID(orderStatus.VendorID); handler != nil { + if order, err2 := handler.GetOrder(orderStatus.VendorOrderID); err2 == nil { + c.OnOrderNew(order, orderStatus) + } + } + } + } + db := dao.GetDB() dao.Begin(db) defer func() { From 086c4199f21369791faebedca4601f5d40c34e50 Mon Sep 17 00:00:00 2001 From: gazebo Date: Tue, 29 Oct 2019 18:25:45 +0800 Subject: [PATCH 08/67] =?UTF-8?q?=E4=BC=98=E5=8C=96mtwm.ListOrders?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- business/partner/purchase/mtwm/order.go | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/business/partner/purchase/mtwm/order.go b/business/partner/purchase/mtwm/order.go index d27769f5f..cdf04c24c 100644 --- a/business/partner/purchase/mtwm/order.go +++ b/business/partner/purchase/mtwm/order.go @@ -3,6 +3,7 @@ package mtwm import ( "errors" "fmt" + "math" "net/url" "regexp" "strings" @@ -571,19 +572,29 @@ func (c *PurchaseHandler) ListOrders(ctx *jxcontext.Context, parentTask tasksch. vendorStoreID := batchItemList[0].(string) var orderIDs []string seqStart := 1 + i := 0 for { - seqEnd := seqStart + mtwmapi.MaxGap4GetOrderIdByDaySeq - 1 - tmpOrderIDs, err2 := api.MtwmAPI.GetOrderIdByDaySeq(vendorStoreID, queryDate, seqStart, seqEnd) + batchSize := int(math.Min(math.Pow(2, float64(i)), float64(mtwmapi.MaxGap4GetOrderIdByDaySeq))) + seqEnd := seqStart + batchSize - 1 + var tmpOrderIDs []int64 + if seqStart == seqEnd { + if vendorOderID, err2 := api.MtwmAPI.GetOrderIdByDaySeqSingle(vendorStoreID, queryDate, seqStart); err2 == nil { + tmpOrderIDs = []int64{vendorOderID} + } + } else { + tmpOrderIDs, err = api.MtwmAPI.GetOrderIdByDaySeq(vendorStoreID, queryDate, seqStart, seqEnd) + } if len(tmpOrderIDs) > 0 { for _, v := range tmpOrderIDs { orderIDs = append(orderIDs, utils.Int64ToStr(v)) } } - if err = err2; err != nil || len(tmpOrderIDs) < mtwmapi.MaxGap4GetOrderIdByDaySeq { + if err != nil || len(tmpOrderIDs) < batchSize { err = nil break } seqStart = seqEnd + 1 + i++ } retVal = orderIDs return retVal, nil From 01f77b8c8c3038824a88af4dd4f72b07b64a1385 Mon Sep 17 00:00:00 2001 From: gazebo Date: Tue, 29 Oct 2019 18:40:06 +0800 Subject: [PATCH 09/67] up --- business/partner/purchase/mtwm/order.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/business/partner/purchase/mtwm/order.go b/business/partner/purchase/mtwm/order.go index cdf04c24c..82ee31b6b 100644 --- a/business/partner/purchase/mtwm/order.go +++ b/business/partner/purchase/mtwm/order.go @@ -574,7 +574,7 @@ func (c *PurchaseHandler) ListOrders(ctx *jxcontext.Context, parentTask tasksch. seqStart := 1 i := 0 for { - batchSize := int(math.Min(math.Pow(2, float64(i)), float64(mtwmapi.MaxGap4GetOrderIdByDaySeq))) + batchSize := int(math.Min(math.Pow(2, float64(i*3)), float64(mtwmapi.MaxGap4GetOrderIdByDaySeq))) seqEnd := seqStart + batchSize - 1 var tmpOrderIDs []int64 if seqStart == seqEnd { From 5fa1fa38a817e5a15c3daf5e66cc3234466fde33 Mon Sep 17 00:00:00 2001 From: gazebo Date: Wed, 30 Oct 2019 08:45:03 +0800 Subject: [PATCH 10/67] =?UTF-8?q?=E7=BE=8E=E5=9B=A2=E5=A4=96=E5=8D=96?= =?UTF-8?q?=E6=9B=B4=E6=96=B0=E5=95=86=E5=93=81=E5=9F=BA=E7=A1=80=E5=B1=9E?= =?UTF-8?q?=E6=80=A7=E6=97=B6=EF=BC=8C=E6=94=B9=E7=94=A8=E6=89=B9=E9=87=8F?= =?UTF-8?q?=E6=93=8D=E4=BD=9C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- business/partner/purchase/mtwm/store_sku2.go | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/business/partner/purchase/mtwm/store_sku2.go b/business/partner/purchase/mtwm/store_sku2.go index 1aa7f132f..a6220d317 100644 --- a/business/partner/purchase/mtwm/store_sku2.go +++ b/business/partner/purchase/mtwm/store_sku2.go @@ -37,8 +37,10 @@ func (p *PurchaseHandler) GetStoreSkusBatchSize(funcID int) (batchSize int) { batchSize = mtwmapi.MaxStoreSkuBatchSize case partner.FuncDeleteStoreSkus: batchSize = 1 // 可考虑用批量操作 - case partner.FuncCreateStoreSkus, partner.FuncUpdateStoreSkus: + case partner.FuncCreateStoreSkus: batchSize = 1 // 可考虑用批量操作 + case partner.FuncUpdateStoreSkus: + batchSize = mtwmapi.MaxStoreSkuBatchSize case partner.FuncGetStoreSkusFullInfo: batchSize = 1 } From 069db73f7b73b74fff3246bb9d819658e354911c Mon Sep 17 00:00:00 2001 From: gazebo Date: Wed, 30 Oct 2019 10:53:10 +0800 Subject: [PATCH 11/67] =?UTF-8?q?=E5=88=B7=E6=96=B0=E5=BE=AE=E7=9B=9Ftoken?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- main.go | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/main.go b/main.go index 5d61ec564..dfd8d3d20 100644 --- a/main.go +++ b/main.go @@ -122,10 +122,10 @@ func main() { // globals.SugarLogger.Errorf("RefreshElmToken failed with error:%s", err) // return // } - // if err := tasks.RefreshWeimobToken(); err != nil { - // globals.SugarLogger.Errorf("RefreshWeimobToken failed with error:%s", err) - // return - // } + if err := tasks.RefreshWeimobToken(); err != nil { + globals.SugarLogger.Errorf("RefreshWeimobToken failed with error:%s", err) + return + } if err := tasks.RefreshYilianyunToken(); err != nil { globals.SugarLogger.Errorf("RefreshYilianyunToken failed with error:%s", err) return From 1c4bf23561193c62c3d878dcc77e1d42658fd861 Mon Sep 17 00:00:00 2001 From: gazebo Date: Wed, 30 Oct 2019 11:38:34 +0800 Subject: [PATCH 12/67] =?UTF-8?q?prod=E5=90=AF=E7=94=A8=E5=BE=AE=E7=9B=9F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- conf/app.conf | 1 + 1 file changed, 1 insertion(+) diff --git a/conf/app.conf b/conf/app.conf index 362ab482a..2f344db9f 100644 --- a/conf/app.conf +++ b/conf/app.conf @@ -155,6 +155,7 @@ enableEbaiStoreWrite = true enableMtwmStoreWrite = true enableWscStoreWrite = true +disableWeimob = false weimobCallbackURL = "http://callback.jxc4.com/weimob" dingdingAgentID = 239461075 From 6d307d9150757ee8e1b2f945376338ed1c0ebefb Mon Sep 17 00:00:00 2001 From: gazebo Date: Wed, 30 Oct 2019 16:19:26 +0800 Subject: [PATCH 13/67] RefreshYilianyunToken --- business/jxutils/eventhub/eventhub.go | 4 +- .../eventhub/syseventhub/syseventhub.go | 38 ++++- business/jxutils/tasks/configrefresh.go | 161 ++++++++---------- controllers/sys.go | 21 ++- globals/globals.go | 2 + main.go | 4 - routers/commentsRouter_controllers.go | 9 + 7 files changed, 135 insertions(+), 104 deletions(-) diff --git a/business/jxutils/eventhub/eventhub.go b/business/jxutils/eventhub/eventhub.go index 422f3057c..3a4ca25f7 100644 --- a/business/jxutils/eventhub/eventhub.go +++ b/business/jxutils/eventhub/eventhub.go @@ -43,7 +43,6 @@ type EventInfo struct { type tRegisterInfo struct { notifyChan chan *EventInfo - eventCategory string eventTypeList []string criteria interface{} } @@ -177,8 +176,7 @@ func (e *EventHub) registerConsumer(eventCategory string, eventTypeList []string realEventTypeList[index] = composeEventType(eventCategory, eventType) } info := &tRegisterInfo{ - eventCategory: eventCategory, - eventTypeList: eventTypeList, + eventTypeList: realEventTypeList, notifyChan: make(chan *EventInfo, 1), criteria: criteria, } diff --git a/business/jxutils/eventhub/syseventhub/syseventhub.go b/business/jxutils/eventhub/syseventhub/syseventhub.go index 5ef2c63de..6e892522a 100644 --- a/business/jxutils/eventhub/syseventhub/syseventhub.go +++ b/business/jxutils/eventhub/syseventhub/syseventhub.go @@ -13,7 +13,8 @@ import ( const ( EventCategory = "sys" - EventTypeWXToken = "wxtoken" + EventTypeWXToken = "wxtoken" + EventTypeYLYToken = "ylytoken" ) type Hub struct { @@ -23,7 +24,7 @@ type Hub struct { type Criteria struct { } -type WXTokenInfo struct { +type TokenInfo struct { IsNew bool `json:"isNew"` Token string `json:"token"` } @@ -55,22 +56,43 @@ func (h *Hub) OnNewWXToken(token string) { }) } -func (h *Hub) GetWXToken(oldToken string, waitTime time.Duration) (tokenInfo *WXTokenInfo) { - token := api.WeixinAPI.CBGetToken() +func (h *Hub) OnNewYLYToken(token string) { + h.eventHub.PostNewEvent(EventCategory, &eventhub.EventInfo{ + Type: EventTypeYLYToken, + Data: token, + }) +} + +func (h *Hub) GetToken(tokenType, oldToken string, waitTime time.Duration) (tokenInfo *TokenInfo) { + var token string + switch tokenType { + case EventTypeWXToken: + token = api.WeixinAPI.CBGetToken() + case EventTypeYLYToken: + token = api.YilianyunAPI.GetToken() + } if token != oldToken { - tokenInfo = &WXTokenInfo{ + tokenInfo = &TokenInfo{ IsNew: false, Token: token, } } else { - eventInfo, err := h.eventHub.GetEvent(EventCategory, []string{EventTypeWXToken}, nil, waitTime) + eventInfo, err := h.eventHub.GetEvent(EventCategory, []string{tokenType}, nil, waitTime) if err == nil && eventInfo != nil { - tokenInfo = &WXTokenInfo{ + tokenInfo = &TokenInfo{ IsNew: true, Token: eventInfo.Data.(string), } } } - globals.SugarLogger.Debugf("GetWXToken tokenInfo:%s", utils.Format4Output(tokenInfo, true)) + globals.SugarLogger.Debugf("GetToken tokenInfo:%s", utils.Format4Output(tokenInfo, true)) return tokenInfo } + +func (h *Hub) GetWXToken(oldToken string, waitTime time.Duration) (tokenInfo *TokenInfo) { + return h.GetToken(EventTypeWXToken, oldToken, waitTime) +} + +func (h *Hub) GetYLYToken(oldToken string, waitTime time.Duration) (tokenInfo *TokenInfo) { + return h.GetToken(EventTypeYLYToken, oldToken, waitTime) +} diff --git a/business/jxutils/tasks/configrefresh.go b/business/jxutils/tasks/configrefresh.go index 7297ddf1d..ce071d76f 100644 --- a/business/jxutils/tasks/configrefresh.go +++ b/business/jxutils/tasks/configrefresh.go @@ -26,7 +26,6 @@ import ( const ( weixinTokenExpires = 7200 * time.Second dingdingTokenExpires = 7200 * time.Second - elmTokenExpires = 20 * 24 * 3600 * time.Second weimobTokenExpires = 7200 * time.Second yilianyunTokenExpires = 30 * 24 * 3600 * time.Second @@ -35,16 +34,6 @@ const ( minRefreshGap = 1 * time.Second ) -type ElmTokenForCompatible struct { - Error string `json:"error"` - ErrorDescription string `json:"error_description"` - AccessToken string `json:"accessToken"` - TokenType string `json:"tokenType"` - Expires int `json:"expires"` - RefreshToken string `json:"refreshToken"` - Success bool `json:"success"` -} - type CallResult struct { Code string `json:"code"` Desc string `json:"desc"` @@ -151,39 +140,10 @@ func RefreshWeixinToken() (err error) { return err } -func RefreshElmToken() (err error) { - if api.ElmAPI != nil { - err = RefreshConfig("eleme", elmTokenExpires, func() (string, string) { - if globals.IsProductEnv() { - if tokenInfo, err := api.ElmAPI.RefreshTokenIndividual(); err == nil { - tokenInfo2 := &ElmTokenForCompatible{ - Error: "", - ErrorDescription: "", - AccessToken: tokenInfo.AccessToken, - TokenType: tokenInfo.TokenType, - Expires: tokenInfo.ExpiresIn, - RefreshToken: "", - Success: true, - } - return string(utils.MustMarshal(tokenInfo2)), "" - } - } - return "", "" - }, func(value string) { - var tokenInfo ElmTokenForCompatible - err := utils.UnmarshalUseNumber([]byte(value), &tokenInfo) - if err == nil { - api.ElmAPI.SetToken(tokenInfo.AccessToken) - } - }) - } - return err -} - func RefreshWeimobToken() (err error) { if api.WeimobAPI != nil { err = RefreshConfig("weimob", weimobTokenExpires, func() (string, string) { - if globals.IsProductEnv() { + if globals.IsMainProductEnv() { if tokenInfo, err := api.WeimobAPI.RefreshTokenByRefreshToken(); err == nil { return string(utils.MustMarshal(tokenInfo)), utils.Time2Str(time.Now().Add((time.Duration(tokenInfo.ExpiresIn) - weimobTokenExpires/time.Second) * time.Second)) } @@ -230,62 +190,37 @@ func SaveWeimobToken(token *weimobapi.TokenInfo) (err error) { } func RefreshYilianyunToken() (err error) { - return RefreshConfig("yilianyun", yilianyunTokenExpires, func() (string, string) { + return RefreshConfig("yilianyun", yilianyunTokenExpires, func() (token string, expireTimeStr string) { globals.SugarLogger.Debugf("RefreshYilianyunToken RunMode:%s", beego.BConfig.RunMode) - if globals.IsProductEnv() { - if globals.IsMainProductEnv() { // 只有京西菜市刷新易联云key - if tokenInfo, err := api.YilianyunAPI.RetrieveToken(); err == nil { - return string(utils.MustMarshal(tokenInfo)), "" - } else { - globals.SugarLogger.Errorf("RefreshYilianyunToken RefreshToken failed with error:%v", err) - } + if globals.IsMainProductEnv() { // 只有京西菜市刷新易联云key + if tokenInfo, err := api.YilianyunAPI.RetrieveToken(); err == nil { + token = string(utils.MustMarshal(tokenInfo)) + } else { + globals.SugarLogger.Errorf("RefreshYilianyunToken RefreshToken failed with error:%v", err) + } + } else { + if tokenInfo := getYLYTokenFromRemote(api.YilianyunAPI.GetToken()); tokenInfo != nil { + expireTimeStr = utils.Time2Str(time.Now().Add(-yilianyunTokenExpires)) + token = tokenInfo.Token } } - return "", "" + return token, expireTimeStr }, func(value string) { + token := value var tokenInfo *yilianyunapi.TokenInfo - err := utils.UnmarshalUseNumber([]byte(value), &tokenInfo) - if err == nil { - api.YilianyunAPI.SetToken(tokenInfo.AccessToken) + if err := utils.TryUnmarshalUseNumber([]byte(value), &tokenInfo); err == nil { + token = tokenInfo.AccessToken } + syseventhub.SysEventHub.OnNewYLYToken(token) + api.YilianyunAPI.SetToken(token) }) } -func getWXTokenFromRemote(oldToken string) (tokenInfo *syseventhub.WXTokenInfo) { +func getWXTokenFromRemote(oldToken string) (tokenInfo *syseventhub.TokenInfo) { if IsGetWXTokenFromRemote() { - for { - waitSecond := 5 * 60 - globals.SugarLogger.Debugf("getWXTokenFromProd1") - response, err := http.Get(fmt.Sprintf("%s?accessKey=%s&oldToken=%s&waitSecond=%d", globals.GetWeixinTokenURL, globals.GetWeixinTokenKey, oldToken, waitSecond)) - globals.SugarLogger.Debugf("getWXTokenFromProd2 error:%v", err) - if err == nil { - defer response.Body.Close() - if response.StatusCode == http.StatusOK { - data, err2 := ioutil.ReadAll(response.Body) - if err = err2; err == nil { - var result CallResult - if err = utils.UnmarshalUseNumber(data, &result); err == nil { - if result.Code == "0" { - if result.Data != "" { - if err = utils.UnmarshalUseNumber([]byte(result.Data), &tokenInfo); err == nil && tokenInfo != nil { - globals.SugarLogger.Debugf("getWXTokenFromProd:%s", utils.Format4Output(tokenInfo, false)) - break - } - } - } else { - err = fmt.Errorf("return code is:%s", result.Code) - } - } - } - } else { - err = platformapi.ErrHTTPCodeIsNot200 - } - } - globals.SugarLogger.Infof("getWXTokenFromProd failed with error:%v", err) - if err != nil { - time.Sleep(errRefreshGap) - } - } + tokenInfo = PollingRemotEvent(globals.GetWeixinTokenURL, 0, map[string]interface{}{ + "oldToken": oldToken, + }) } return tokenInfo } @@ -293,3 +228,55 @@ func getWXTokenFromRemote(oldToken string) (tokenInfo *syseventhub.WXTokenInfo) func IsGetWXTokenFromRemote() bool { return !globals.IsMainProductEnv() && globals.GetWeixinTokenKey != "" && globals.GetWeixinTokenURL != "" } + +func PollingRemotEvent(remoteURL string, waitSecond int, params map[string]interface{}) (tokenInfo *syseventhub.TokenInfo) { + if waitSecond == 0 { + waitSecond = 5 * 60 + } + params2 := utils.MergeMaps(params, map[string]interface{}{ + "accessKey": globals.GetWeixinTokenKey, + "waitSecond": waitSecond, + }) + for { + globals.SugarLogger.Debugf("PollingRemotEvent") + response, err := http.Get(utils.GenerateGetURL(remoteURL, "", params2)) + globals.SugarLogger.Debugf("PollingRemotEvent2 error:%v", err) + if err == nil { + defer response.Body.Close() + if response.StatusCode == http.StatusOK { + data, err2 := ioutil.ReadAll(response.Body) + if err = err2; err == nil { + var result CallResult + if err = utils.UnmarshalUseNumber(data, &result); err == nil { + if result.Code == "0" { + if result.Data != "" { + if err = utils.UnmarshalUseNumber([]byte(result.Data), &tokenInfo); err == nil && tokenInfo != nil { + globals.SugarLogger.Debugf("PollingRemotEvent %s:%s", remoteURL, utils.Format4Output(tokenInfo, false)) + break + } + } + } else { + err = fmt.Errorf("return code is:%s", result.Code) + } + } + } + } else { + err = platformapi.ErrHTTPCodeIsNot200 + } + } + globals.SugarLogger.Infof("PollingRemotEvent failed with error:%v", err) + if err != nil { + time.Sleep(errRefreshGap) + } + } + return tokenInfo +} + +func getYLYTokenFromRemote(oldToken string) (tokenInfo *syseventhub.TokenInfo) { + if !globals.IsMainProductEnv() && globals.GetWeixinTokenKey != "" && globals.GetYLYTokenURL != "" { + tokenInfo = PollingRemotEvent(globals.GetYLYTokenURL, 0, map[string]interface{}{ + "oldToken": oldToken, + }) + } + return tokenInfo +} diff --git a/controllers/sys.go b/controllers/sys.go index 96d67fdc6..26ad57cce 100644 --- a/controllers/sys.go +++ b/controllers/sys.go @@ -20,8 +20,8 @@ type SysController struct { beego.Controller } -// @Title 得到京西门店信息 -// @Description 得到京西门店信息,如下条件之间是与的关系 +// @Title 得到微信token +// @Description 得到微信token // @Param accessKey query string true "假token" // @Param oldToken query string false "之前的token" // @Param waitSecond query int false "等待秒数" @@ -37,6 +37,23 @@ func (c *SysController) GetWXToken() { }) } +// @Title 得到易联云token +// @Description 得到易联云token +// @Param accessKey query string true "假token" +// @Param oldToken query string false "之前的token" +// @Param waitSecond query int false "等待秒数" +// @Success 200 {object} controllers.CallResult +// @Failure 200 {object} controllers.CallResult +// @router /GetYLYToken [get] +func (c *SysController) GetYLYToken() { + c.callGetYLYToken(func(params *tSysGetYLYTokenParams) (retVal interface{}, errCode string, err error) { + if params.AccessKey == globals.GetWeixinTokenKey { + retVal = syseventhub.SysEventHub.GetYLYToken(params.OldToken, time.Duration(params.WaitSecond)*time.Second) + } + return retVal, "", err + }) +} + // @Title 得到饿百RTF转换内容 // @Description 得到饿百RTF转换内容 // @Param imgListStr query string true "逗号分隔的图片列表可以是转义后的" diff --git a/globals/globals.go b/globals/globals.go index bb99b38ca..3bd30d243 100644 --- a/globals/globals.go +++ b/globals/globals.go @@ -40,6 +40,7 @@ var ( GetWeixinTokenURL string GetWeixinTokenKey string + GetYLYTokenURL string StoreName string @@ -82,6 +83,7 @@ func Init() { WxBackstageHost = beego.AppConfig.DefaultString("wxBackstageHost", "") GetWeixinTokenURL = beego.AppConfig.DefaultString("getWeixinTokenURL", "") + GetYLYTokenURL = beego.AppConfig.DefaultString("getYLYTokenURL", "") GetWeixinTokenKey = beego.AppConfig.DefaultString("getWeixinTokenKey", "") StoreName = beego.AppConfig.DefaultString("storeName", "京西菜市") diff --git a/main.go b/main.go index dfd8d3d20..4088c347f 100644 --- a/main.go +++ b/main.go @@ -118,10 +118,6 @@ func main() { globals.SugarLogger.Errorf("RefreshWeixinToken failed with error:%s", err) return } - // if err := tasks.RefreshElmToken(); err != nil { - // globals.SugarLogger.Errorf("RefreshElmToken failed with error:%s", err) - // return - // } if err := tasks.RefreshWeimobToken(); err != nil { globals.SugarLogger.Errorf("RefreshWeimobToken failed with error:%s", err) return diff --git a/routers/commentsRouter_controllers.go b/routers/commentsRouter_controllers.go index 157c07787..6cec894c6 100644 --- a/routers/commentsRouter_controllers.go +++ b/routers/commentsRouter_controllers.go @@ -1647,6 +1647,15 @@ func init() { Filters: nil, Params: nil}) + beego.GlobalControllerRouter["git.rosy.net.cn/jx-callback/controllers:SysController"] = append(beego.GlobalControllerRouter["git.rosy.net.cn/jx-callback/controllers:SysController"], + beego.ControllerComments{ + Method: "GetYLYToken", + Router: `/GetYLYToken`, + AllowHTTPMethods: []string{"get"}, + MethodParams: param.Make(), + Filters: nil, + Params: nil}) + beego.GlobalControllerRouter["git.rosy.net.cn/jx-callback/controllers:TaskController"] = append(beego.GlobalControllerRouter["git.rosy.net.cn/jx-callback/controllers:TaskController"], beego.ControllerComments{ Method: "CancelTask", From 07d374a02e9c02688bd606db963c48779ea810e8 Mon Sep 17 00:00:00 2001 From: gazebo Date: Wed, 30 Oct 2019 16:35:05 +0800 Subject: [PATCH 14/67] =?UTF-8?q?=E6=9E=9C=E5=9B=AD=E8=87=AA=E5=8A=A8?= =?UTF-8?q?=E5=8C=96=E6=98=93=E8=81=94=E4=BA=91key=E6=9B=B4=E6=96=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- business/jxutils/tasks/configrefresh.go | 8 ++++---- conf/app.conf | 3 +++ 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/business/jxutils/tasks/configrefresh.go b/business/jxutils/tasks/configrefresh.go index ce071d76f..d675a6919 100644 --- a/business/jxutils/tasks/configrefresh.go +++ b/business/jxutils/tasks/configrefresh.go @@ -238,9 +238,9 @@ func PollingRemotEvent(remoteURL string, waitSecond int, params map[string]inter "waitSecond": waitSecond, }) for { - globals.SugarLogger.Debugf("PollingRemotEvent") + globals.SugarLogger.Debugf("PollingRemotEvent %s", remoteURL) response, err := http.Get(utils.GenerateGetURL(remoteURL, "", params2)) - globals.SugarLogger.Debugf("PollingRemotEvent2 error:%v", err) + globals.SugarLogger.Debugf("PollingRemotEvent2 %s error:%v", remoteURL, err) if err == nil { defer response.Body.Close() if response.StatusCode == http.StatusOK { @@ -256,7 +256,7 @@ func PollingRemotEvent(remoteURL string, waitSecond int, params map[string]inter } } } else { - err = fmt.Errorf("return code is:%s", result.Code) + err = fmt.Errorf("PollingRemotEvent %s return code is:%s", remoteURL, result.Code) } } } @@ -264,7 +264,7 @@ func PollingRemotEvent(remoteURL string, waitSecond int, params map[string]inter err = platformapi.ErrHTTPCodeIsNot200 } } - globals.SugarLogger.Infof("PollingRemotEvent failed with error:%v", err) + globals.SugarLogger.Infof("PollingRemotEvent %s failed with error:%v", remoteURL, err) if err != nil { time.Sleep(errRefreshGap) } diff --git a/conf/app.conf b/conf/app.conf index 2f344db9f..c5a5e8de9 100644 --- a/conf/app.conf +++ b/conf/app.conf @@ -119,6 +119,7 @@ weixinToken = "17_roSCZgkCxhRnyFVtei0KdfHwdGP8PmLzJFhCieka4_X4_d-lgfaTxF6oIS6FE5 dbConnectStr = "root:WebServer@1@tcp(127.0.0.1:3306)/jxd_dev_0?charset=utf8mb4&loc=Local&parseTime=true" getWeixinTokenURL = "http://beta.jxc4.com/v2/sys/GetWXToken" +getYLYTokenURL = "http://beta.jxc4.com/v2/sys/GetYLYToken" [prod] EnableDocs = false @@ -215,6 +216,8 @@ dingdingQRCodeSecret = "N9dyC9qB84sauQPs4_JYrILMsG5Krqm9-PSSVJ8t9hb87rrHiFUirISx dingdingCallbackURL = "http://callback-jxgy.jxc4.com/dingding/msg" getWeixinTokenURL = "http://www.jxc4.com/v2/sys/GetWXToken" +getYLYTokenURL = "http://www.jxc4.com/v2/sys/GetYLYToken" + storeName = "京西果园" [test] From fd9b2972cec4bfe91b442761a412dde7048d65ed Mon Sep 17 00:00:00 2001 From: gazebo Date: Wed, 30 Oct 2019 16:39:43 +0800 Subject: [PATCH 15/67] =?UTF-8?q?GetOrderSkuInfo=E4=B8=AD=E8=BF=94?= =?UTF-8?q?=E5=9B=9EnameID?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- business/jxcallback/orderman/orderman_ext.go | 25 ++++++++++---------- business/model/api.go | 1 + 2 files changed, 13 insertions(+), 13 deletions(-) diff --git a/business/jxcallback/orderman/orderman_ext.go b/business/jxcallback/orderman/orderman_ext.go index ad5aca131..cc7eb3abf 100644 --- a/business/jxcallback/orderman/orderman_ext.go +++ b/business/jxcallback/orderman/orderman_ext.go @@ -96,7 +96,7 @@ func (c *OrderManager) GetOrderSkuInfo(ctx *jxcontext.Context, vendorOrderID str IF(t1.shop_price = 0, t1.sale_price, t1.shop_price) shop_price, t1.sale_price, t1.earning_price, - CAST(IF(t1.earning_price <> 0, t1.earning_price, IF(t1.shop_price <> 0 && t1.shop_price < t1.sale_price, t1.shop_price, t1.sale_price) * IF(t5.pay_percentage > 0, t5.pay_percentage, %d) / 100) AS SIGNED) real_earning_price, + CAST(IF(t1.earning_price <> 0, t1.earning_price, IF(t1.shop_price <> 0 && t1.shop_price < t1.sale_price, t1.shop_price, t1.sale_price) * IF(t5.pay_percentage > 0, t5.pay_percentage, ?) / 100) AS SIGNED) real_earning_price, t1.weight, t1.sku_type, t1.promotion_type, @@ -105,18 +105,17 @@ func (c *OrderManager) GetOrderSkuInfo(ctx *jxcontext.Context, vendorOrderID str t1.store_sub_name, t1.vendor_price, %s full_sku_name, - `, model.DefaultEarningPricePercentage, fullSkuNameSQL) - db := dao.GetDB() - err = dao.GetRows(db, &skus, sql+` - t3.img image - FROM order_sku t1 - LEFT JOIN goods_order t6 ON t6.vendor_order_id = t1.vendor_order_id AND t6.vendor_id = t1.vendor_id - LEFT JOIN store t5 ON t5.id = IF(t6.jx_store_id <> 0, t6.jx_store_id, t6.store_id) - LEFT JOIN sku t2 ON IF(t1.jx_sku_id != 0, t1.jx_sku_id, t1.sku_id) = t2.id/* AND t2.deleted_at = ?*/ - LEFT JOIN sku_name t3 ON t2.name_id = t3.id/* AND t3.deleted_at = ?*/ - WHERE t1.vendor_order_id = ? AND t1.vendor_id = ? - ORDER BY t1.sku_name - `, /*, utils.DefaultTimeValue, utils.DefaultTimeValue*/ vendorOrderID, vendorID) + t2.name_id, + t3.img image + FROM order_sku t1 + LEFT JOIN goods_order t6 ON t6.vendor_order_id = t1.vendor_order_id AND t6.vendor_id = t1.vendor_id + LEFT JOIN store t5 ON t5.id = IF(t6.jx_store_id <> 0, t6.jx_store_id, t6.store_id) + LEFT JOIN sku t2 ON IF(t1.jx_sku_id != 0, t1.jx_sku_id, t1.sku_id) = t2.id/* AND t2.deleted_at = ?*/ + LEFT JOIN sku_name t3 ON t2.name_id = t3.id/* AND t3.deleted_at = ?*/ + WHERE t1.vendor_order_id = ? AND t1.vendor_id = ? + ORDER BY t1.sku_name + `, fullSkuNameSQL) + err = dao.GetRows(dao.GetDB(), &skus, sql /*, utils.DefaultTimeValue, utils.DefaultTimeValue*/, model.DefaultEarningPricePercentage, vendorOrderID, vendorID) if err != nil { globals.SugarLogger.Infof("GetOrderSkuInfo orderID:%s vendorID:%d failed with error:%v", vendorOrderID, vendorID, err) return nil, err diff --git a/business/model/api.go b/business/model/api.go index 1a3396774..e6c6a6796 100644 --- a/business/model/api.go +++ b/business/model/api.go @@ -36,6 +36,7 @@ type GoodsOrderExt struct { type OrderSkuExt struct { OrderSku + NameID int `orm:"column(name_id)" json:"nameID"` FullSkuName string `json:"fullSkuName"` Image string `json:"image"` RealEarningPrice int64 `json:"realEarningPrice"` // 实际单品结算给门店老板钱 From 3bd84cff45115af5f3dc2aa6ea48e66d81d85af4 Mon Sep 17 00:00:00 2001 From: gazebo Date: Wed, 30 Oct 2019 17:35:35 +0800 Subject: [PATCH 16/67] =?UTF-8?q?SyncSkus=E4=B8=AD=E7=9A=84=E7=AE=A1?= =?UTF-8?q?=E7=90=86=E7=AD=96=E7=95=A5=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- business/jxstore/cms/sync.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/business/jxstore/cms/sync.go b/business/jxstore/cms/sync.go index 22f9b97f0..d7d03b007 100644 --- a/business/jxstore/cms/sync.go +++ b/business/jxstore/cms/sync.go @@ -232,7 +232,7 @@ func (v *VendorSync) SyncSku(ctx *jxcontext.Context, db *dao.DaoDB, nameID, skuI func (v *VendorSync) SyncSkus(ctx *jxcontext.Context, db *dao.DaoDB, nameIDs []int, skuIDs []int, isAsync, isContinueWhenError bool, userName string) (hint string, err error) { globals.SugarLogger.Debugf("SyncSku trackInfo:%s, nameIDs:%v, skuIDs:%v, userName:%s", ctx.GetTrackInfo(), nameIDs, skuIDs, userName) - isManagedIt := len(nameIDs) > 1 || len(nameIDs) == 0 || len(skuIDs) > 1 || len(skuIDs) == 0 + isManagedIt := !(len(nameIDs) > 0 && len(nameIDs) <= 2 || len(skuIDs) > 0 && len(skuIDs) < 8) return v.LoopMultiStoresVendors(ctx, db, fmt.Sprintf("同步商品信息, nameIDs:%v, skuIDs:%v", nameIDs, skuIDs), isAsync, isManagedIt, func(t *tasksch.ParallelTask, batchItemList []interface{}, params ...interface{}) (interface{}, error) { var resultList []interface{} From 186a543ce07b2d39d76394ded388b1b361d9588e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=8B=8F=E5=B0=B9=E5=B2=9A?= <770236076@qq.com> Date: Wed, 30 Oct 2019 17:56:50 +0800 Subject: [PATCH 17/67] =?UTF-8?q?=E7=BB=9F=E8=AE=A1=E8=AE=A2=E5=8D=95?= =?UTF-8?q?=E4=BF=A1=E6=81=AF=E6=8E=A5=E5=8F=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- business/jxstore/report/report.go | 12 +++++ business/model/dao/report.go | 77 +++++++++++++++++++++++++++ controllers/jx_report.go | 31 +++++++++++ routers/commentsRouter_controllers.go | 10 +++- routers/router.go | 5 ++ 5 files changed, 134 insertions(+), 1 deletion(-) create mode 100644 business/jxstore/report/report.go create mode 100644 business/model/dao/report.go create mode 100644 controllers/jx_report.go diff --git a/business/jxstore/report/report.go b/business/jxstore/report/report.go new file mode 100644 index 000000000..5fe22d54b --- /dev/null +++ b/business/jxstore/report/report.go @@ -0,0 +1,12 @@ +package report + +import ( + "git.rosy.net.cn/jx-callback/business/jxutils/jxcontext" + "git.rosy.net.cn/jx-callback/business/model/dao" +) + +func GetStatisticsReportForOrders(ctx *jxcontext.Context, storeIDs []int, fromDate string, toDate string) (statisticsReportForOrdersList []*dao.StatisticsReportForOrdersList, err error) { + db := dao.GetDB() + statisticsReportForOrdersList, err = dao.GetStatisticsReportForOrders(db, storeIDs, fromDate, toDate) + return statisticsReportForOrdersList, err +} diff --git a/business/model/dao/report.go b/business/model/dao/report.go new file mode 100644 index 000000000..8e253a4f9 --- /dev/null +++ b/business/model/dao/report.go @@ -0,0 +1,77 @@ +package dao + +import ( + "fmt" + "strconv" + + "git.rosy.net.cn/baseapi/utils" + "git.rosy.net.cn/jx-callback/business/model" +) + +type StatisticsReportForOrdersList struct { + StoreID int + orderCounts int + salePrice int64 + actualPayPrice int64 + shopPrice int64 + discountMoney int64 + desiredFee int64 + distanceFreightMoney int64 + waybillTipMoney int64 + totalShopMoney int64 + pmSubsidyMoney int64 + EarningPrice int64 + totalGrossProfit int64 + comGrossProfit float32 + cityManagerGrossProfit float32 +} + +func GetStatisticsReportForOrders(db *DaoDB, storeIDs []int, fromDate string, toDate string) (statisticsReportForOrdersList []*StatisticsReportForOrdersList, err error) { + //排除已取消的订单 + status := strconv.Itoa(model.OrderStatusCanceled) + sql := ` + SELECT s.*, + (totalGrossProfit*c.jx_brand_fee_factor)/(c.jx_brand_fee_factor+market_add_fee_factor) comGrossProfit, + (totalGrossProfit*c.market_add_fee_factor)/(c.jx_brand_fee_factor+market_add_fee_factor) cityManagerGrossProfit + FROM store c,( + SELECT + a.store_id storeID, + count(*) orderCounts, + sum(sale_price) salePrice, + sum(actual_pay_price) actualPayPrice, + sum(shop_price) shopPrice, + sum(discount_money) discountMoney, + sum(desired_fee) desiredFee, + sum(distance_freight_money) distanceFreightMoney, + sum(waybill_tip_money) waybillTipMoney, + sum(total_shop_money) totalShopMoney, + sum(pm_subsidy_money) pmSubsidyMoney, + sum(earning_price) EarningPrice, + sum(total_shop_money-earning_price-desired_fee-distance_freight_money-waybill_tip_money-80) totalGrossProfit + FROM goods_order a LEFT JOIN waybill b on if(a.waybill_vendor_id = -1,a.vendor_order_id,a.vendor_waybill_id) = b.vendor_waybill_id + WHERE a.status != ` + status + ` + ` + sqlParams := []interface{}{} + if fromDate != "" { + sql += "AND a.order_created_at >= date_format(?,'YYYY-MM-DD HH:MM:SS')" + sqlParams = append(sqlParams, utils.Str2Time(fromDate)) + } + if toDate != "" { + sql += "AND a.order_created_at <= date_format(?,'YYYY-MM-DD HH:MM:SS')" + sqlParams = append(sqlParams, utils.Str2Time(toDate)) + } + if len(storeIDs) > 0 { + sql += "AND a.store_id in(" + GenQuestionMarks(len(storeIDs)) + ")" + sqlParams = append(sqlParams, storeIDs) + } + sql += ` + GROUP BY a.store_id + )s + WHERE s.storeID = c.id + ` + fmt.Println(sql) + if err = GetRows(db, &statisticsReportForOrdersList, sql, sqlParams...); err == nil { + return statisticsReportForOrdersList, nil + } + return nil, err +} diff --git a/controllers/jx_report.go b/controllers/jx_report.go new file mode 100644 index 000000000..6ed9d9ef7 --- /dev/null +++ b/controllers/jx_report.go @@ -0,0 +1,31 @@ +package controllers + +import ( + "git.rosy.net.cn/jx-callback/business/jxstore/report" + "git.rosy.net.cn/jx-callback/business/jxutils" + "github.com/astaxie/beego" +) + +// 统计相关API +type ReportController struct { + beego.Controller +} + +// @Title 查询订单统计信息 +// @Description 根据门店idlist和时间范围查询 +// @Param token header string true "认证token" +// @Param storeIDs formData string true "京西门店ID列表[1,2,3]" +// @Param FromDate formData string false "开始日期(包含),格式(2006-01-02 00:00:00)" +// @Param ToDate formData string false "结束日期(包含),格式(2006-01-02 00:00:00)" +// @Success 200 {object} controllers.CallResult +// @Failure 200 {object} controllers.CallResult +// @router /StatisticsReportForOrders [post] +func (c *ReportController) StatisticsReportForOrders() { + c.callStatisticsReportForOrders(func(params *tReportStatisticsReportForOrdersParams) (retVal interface{}, errCode string, err error) { + var storeIDList []int + if err = jxutils.Strings2Objs(params.StoreIDs, &storeIDList); err == nil { + retVal, err = report.GetStatisticsReportForOrders(params.Ctx, storeIDList, params.FromDate, params.ToDate) + } + return retVal, "", err + }) +} diff --git a/routers/commentsRouter_controllers.go b/routers/commentsRouter_controllers.go index 9345a8936..ea54ac96e 100644 --- a/routers/commentsRouter_controllers.go +++ b/routers/commentsRouter_controllers.go @@ -1934,5 +1934,13 @@ func init() { 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.ControllerComments{ + Method: "StatisticsReportForOrders", + Router: `/StatisticsReportForOrders`, + AllowHTTPMethods: []string{"post"}, + MethodParams: param.Make(), + Filters: nil, + Params: nil}) } diff --git a/routers/router.go b/routers/router.go index 9e0979e45..f6453d568 100644 --- a/routers/router.go +++ b/routers/router.go @@ -121,6 +121,11 @@ func init() { &controllers.FoodRecipeController{}, ), ), + beego.NSNamespace("/report", + beego.NSInclude( + &controllers.ReportController{}, + ), + ), ) beego.AddNamespace(ns) From 48d6d5487bb85877486e18e56c3e571aa5c9b9a1 Mon Sep 17 00:00:00 2001 From: gazebo Date: Wed, 30 Oct 2019 18:00:35 +0800 Subject: [PATCH 18/67] =?UTF-8?q?=E4=BF=AE=E5=A4=8DGetPossibleVendorIDFrom?= =?UTF-8?q?VendorOrderID=E4=B8=AD=E8=AF=AF=E5=88=A4=E6=96=AD=E4=BA=AC?= =?UTF-8?q?=E4=B8=9C=E6=96=B0=E8=AE=A2=E5=8D=95=E5=8F=B7=E7=9A=84bug?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- business/jxutils/jxutils.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/business/jxutils/jxutils.go b/business/jxutils/jxutils.go index 763b78730..549df3cda 100644 --- a/business/jxutils/jxutils.go +++ b/business/jxutils/jxutils.go @@ -144,7 +144,7 @@ func GetPossibleVendorIDFromVendorOrderID(vendorOrderID string) (vendorID int) { // 改造点: // 1、订单号位数变化,由原有15位数增加1位数调整为16位数,对接商家需检查是否有对订单号位数做长度校验。 // 2、第一位数字发生变化,由原来9开头调整为当年年份后两位数如:2020年订单开头为20; - if orderIDLen == len("925265130002541") || orderIDLen == len("1925265130002541")+1 { + if orderIDLen == len("925265130002541") || orderIDLen == len("1925265130002541") { vendorID = model.VendorIDJD } else if orderIDLen == len("3022716176275221584") { // vendorID = model.VendorIDELM From b61d677ceaa893bf9cbb4fedcafa04aea1a61ccf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=8B=8F=E5=B0=B9=E5=B2=9A?= <770236076@qq.com> Date: Wed, 30 Oct 2019 18:23:01 +0800 Subject: [PATCH 19/67] =?UTF-8?q?=E7=BB=9F=E8=AE=A1=E6=8E=A5=E5=8F=A3?= =?UTF-8?q?=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- business/model/dao/report.go | 30 +++++++++++++++--------------- controllers/jx_report.go | 4 ++-- 2 files changed, 17 insertions(+), 17 deletions(-) diff --git a/business/model/dao/report.go b/business/model/dao/report.go index 8e253a4f9..5d0e9ecfa 100644 --- a/business/model/dao/report.go +++ b/business/model/dao/report.go @@ -9,21 +9,21 @@ import ( ) type StatisticsReportForOrdersList struct { - StoreID int - orderCounts int - salePrice int64 - actualPayPrice int64 - shopPrice int64 - discountMoney int64 - desiredFee int64 - distanceFreightMoney int64 - waybillTipMoney int64 - totalShopMoney int64 - pmSubsidyMoney int64 - EarningPrice int64 - totalGrossProfit int64 - comGrossProfit float32 - cityManagerGrossProfit float32 + storeID int `json:"storeID"` + orderCounts int `json:"orderCounts"` + salePrice int64 `json:"salePrice"` + actualPayPrice int64 `json:"actualPayPrice"` + shopPrice int64 `json:"shopPrice"` + discountMoney int64 `json:"discountMoney"` + desiredFee int64 `json:"desiredFee"` + distanceFreightMoney int64 `json:"distanceFreightMoney"` + waybillTipMoney int64 `json:"waybillTipMoney"` + totalShopMoney int64 `json:"totalShopMoney"` + pmSubsidyMoney int64 `json:"pmSubsidyMoney"` + earningPrice int64 `json:"earningPrice"` + totalGrossProfit int64 `json:"totalGrossProfit"` + comGrossProfit float32 `json:"comGrossProfit"` + cityManagerGrossProfit float32 `json:"cityManagerGrossProfit"` } func GetStatisticsReportForOrders(db *DaoDB, storeIDs []int, fromDate string, toDate string) (statisticsReportForOrdersList []*StatisticsReportForOrdersList, err error) { diff --git a/controllers/jx_report.go b/controllers/jx_report.go index 6ed9d9ef7..4bad3821e 100644 --- a/controllers/jx_report.go +++ b/controllers/jx_report.go @@ -15,8 +15,8 @@ type ReportController struct { // @Description 根据门店idlist和时间范围查询 // @Param token header string true "认证token" // @Param storeIDs formData string true "京西门店ID列表[1,2,3]" -// @Param FromDate formData string false "开始日期(包含),格式(2006-01-02 00:00:00)" -// @Param ToDate formData string false "结束日期(包含),格式(2006-01-02 00:00:00)" +// @Param fromDate formData string false "开始日期(包含),格式(2006-01-02 00:00:00)" +// @Param toDate formData string false "结束日期(包含),格式(2006-01-02 00:00:00)" // @Success 200 {object} controllers.CallResult // @Failure 200 {object} controllers.CallResult // @router /StatisticsReportForOrders [post] From 5c4a52636790812d559e6bc116e269d0010c0499 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=8B=8F=E5=B0=B9=E5=B2=9A?= <770236076@qq.com> Date: Wed, 30 Oct 2019 18:27:34 +0800 Subject: [PATCH 20/67] =?UTF-8?q?=E7=BB=9F=E8=AE=A1=E6=8E=A5=E5=8F=A3?= =?UTF-8?q?=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- business/model/dao/report.go | 30 +++++++++++++++--------------- 1 file changed, 15 insertions(+), 15 deletions(-) diff --git a/business/model/dao/report.go b/business/model/dao/report.go index 5d0e9ecfa..a51920457 100644 --- a/business/model/dao/report.go +++ b/business/model/dao/report.go @@ -9,21 +9,21 @@ import ( ) type StatisticsReportForOrdersList struct { - storeID int `json:"storeID"` - orderCounts int `json:"orderCounts"` - salePrice int64 `json:"salePrice"` - actualPayPrice int64 `json:"actualPayPrice"` - shopPrice int64 `json:"shopPrice"` - discountMoney int64 `json:"discountMoney"` - desiredFee int64 `json:"desiredFee"` - distanceFreightMoney int64 `json:"distanceFreightMoney"` - waybillTipMoney int64 `json:"waybillTipMoney"` - totalShopMoney int64 `json:"totalShopMoney"` - pmSubsidyMoney int64 `json:"pmSubsidyMoney"` - earningPrice int64 `json:"earningPrice"` - totalGrossProfit int64 `json:"totalGrossProfit"` - comGrossProfit float32 `json:"comGrossProfit"` - cityManagerGrossProfit float32 `json:"cityManagerGrossProfit"` + storeID int `orm:"size(255)" json:"storeID"` + orderCounts int `orm:"size(255)" json:"orderCounts"` + salePrice int64 `orm:"size(255)" json:"salePrice"` + actualPayPrice int64 `orm:"size(255)" json:"actualPayPrice"` + shopPrice int64 `orm:"size(255)" json:"shopPrice"` + discountMoney int64 `orm:"size(255)" json:"discountMoney"` + desiredFee int64 `orm:"size(255)" json:"desiredFee"` + distanceFreightMoney int64 `orm:"size(255)" json:"distanceFreightMoney"` + waybillTipMoney int64 `orm:"size(255)" json:"waybillTipMoney"` + totalShopMoney int64 `orm:"size(255)" json:"totalShopMoney"` + pmSubsidyMoney int64 `orm:"size(255)" json:"pmSubsidyMoney"` + earningPrice int64 `orm:"size(255)" json:"earningPrice"` + totalGrossProfit int64 `orm:"size(255)" json:"totalGrossProfit"` + comGrossProfit float32 `orm:"size(255)" json:"comGrossProfit"` + cityManagerGrossProfit float32 `orm:"size(255)" json:"cityManagerGrossProfit"` } func GetStatisticsReportForOrders(db *DaoDB, storeIDs []int, fromDate string, toDate string) (statisticsReportForOrdersList []*StatisticsReportForOrdersList, err error) { From ceb35801a5cae0282a2186f22656278b31386dad Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=8B=8F=E5=B0=B9=E5=B2=9A?= <770236076@qq.com> Date: Thu, 31 Oct 2019 08:54:09 +0800 Subject: [PATCH 21/67] =?UTF-8?q?=E7=BB=9F=E8=AE=A1=E8=AE=A2=E5=8D=95?= =?UTF-8?q?=E6=8E=A5=E5=8F=A3=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- business/model/dao/report.go | 32 +++++++++++++++----------------- 1 file changed, 15 insertions(+), 17 deletions(-) diff --git a/business/model/dao/report.go b/business/model/dao/report.go index a51920457..a1747140f 100644 --- a/business/model/dao/report.go +++ b/business/model/dao/report.go @@ -1,7 +1,6 @@ package dao import ( - "fmt" "strconv" "git.rosy.net.cn/baseapi/utils" @@ -9,21 +8,21 @@ import ( ) type StatisticsReportForOrdersList struct { - storeID int `orm:"size(255)" json:"storeID"` - orderCounts int `orm:"size(255)" json:"orderCounts"` - salePrice int64 `orm:"size(255)" json:"salePrice"` - actualPayPrice int64 `orm:"size(255)" json:"actualPayPrice"` - shopPrice int64 `orm:"size(255)" json:"shopPrice"` - discountMoney int64 `orm:"size(255)" json:"discountMoney"` - desiredFee int64 `orm:"size(255)" json:"desiredFee"` - distanceFreightMoney int64 `orm:"size(255)" json:"distanceFreightMoney"` - waybillTipMoney int64 `orm:"size(255)" json:"waybillTipMoney"` - totalShopMoney int64 `orm:"size(255)" json:"totalShopMoney"` - pmSubsidyMoney int64 `orm:"size(255)" json:"pmSubsidyMoney"` - earningPrice int64 `orm:"size(255)" json:"earningPrice"` - totalGrossProfit int64 `orm:"size(255)" json:"totalGrossProfit"` - comGrossProfit float32 `orm:"size(255)" json:"comGrossProfit"` - cityManagerGrossProfit float32 `orm:"size(255)" json:"cityManagerGrossProfit"` + StoreID int `orm:"column(storeID)" json:"storeID"` + OrderCounts int `orm:"column(orderCounts)" json:"orderCounts"` + SalePrice int `orm:"column(salePrice)" json:"salePrice"` + ActualPayPrice int `orm:"column(actualPayPrice)" json:"actualPayPrice"` + ShopPrice int `orm:"column(shopPrice)" json:"shopPrice"` + DiscountMoney int `orm:"column(discountMoney)" json:"discountMoney"` + DesiredFee int `orm:"column(desiredFee)" json:"desiredFee"` + DistanceFreightMoney int `orm:"column(distanceFreightMoney)" json:"distanceFreightMoney"` + WaybillTipMoney int `orm:"column(waybillTipMoney)" json:"waybillTipMoney"` + TotalShopMoney int `orm:"column(totalShopMoney)" json:"totalShopMoney"` + PmSubsidyMoney int `orm:"column(pmSubsidyMoney)" json:"pmSubsidyMoney"` + EarningPrice int `orm:"column(earningPrice)" json:"earningPrice"` + TotalGrossProfit int `orm:"column(totalGrossProfit)" json:"totalGrossProfit"` + ComGrossProfit float32 `orm:"column(comGrossProfit)" json:"comGrossProfit"` + CityManagerGrossProfit float32 `orm:"column(cityManagerGrossProfit)" json:"cityManagerGrossProfit"` } func GetStatisticsReportForOrders(db *DaoDB, storeIDs []int, fromDate string, toDate string) (statisticsReportForOrdersList []*StatisticsReportForOrdersList, err error) { @@ -69,7 +68,6 @@ func GetStatisticsReportForOrders(db *DaoDB, storeIDs []int, fromDate string, to )s WHERE s.storeID = c.id ` - fmt.Println(sql) if err = GetRows(db, &statisticsReportForOrdersList, sql, sqlParams...); err == nil { return statisticsReportForOrdersList, nil } From 5284267133ddb7fda8702bb791024cc5190dc902 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=8B=8F=E5=B0=B9=E5=B2=9A?= <770236076@qq.com> Date: Thu, 31 Oct 2019 09:08:39 +0800 Subject: [PATCH 22/67] =?UTF-8?q?=E7=BB=9F=E8=AE=A1=E8=AE=A2=E5=8D=95?= =?UTF-8?q?=E6=8E=A5=E5=8F=A3=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- business/model/dao/report.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/business/model/dao/report.go b/business/model/dao/report.go index a1747140f..d01737169 100644 --- a/business/model/dao/report.go +++ b/business/model/dao/report.go @@ -30,8 +30,8 @@ func GetStatisticsReportForOrders(db *DaoDB, storeIDs []int, fromDate string, to status := strconv.Itoa(model.OrderStatusCanceled) sql := ` SELECT s.*, - (totalGrossProfit*c.jx_brand_fee_factor)/(c.jx_brand_fee_factor+market_add_fee_factor) comGrossProfit, - (totalGrossProfit*c.market_add_fee_factor)/(c.jx_brand_fee_factor+market_add_fee_factor) cityManagerGrossProfit + if(c.jx_brand_fee_factor = 0 AND c.market_add_fee_factor = 0,totalGrossProfit,(totalGrossProfit*c.jx_brand_fee_factor)/(c.jx_brand_fee_factor+market_add_fee_factor)) comGrossProfit, + if(c.jx_brand_fee_factor = 0 AND c.market_add_fee_factor = 0,0,(totalGrossProfit*c.market_add_fee_factor)/(c.jx_brand_fee_factor+market_add_fee_factor)) cityManagerGrossProfit FROM store c,( SELECT a.store_id storeID, From bd0694ca32baaa270328ed3d015b32981e0b261a Mon Sep 17 00:00:00 2001 From: gazebo Date: Thu, 31 Oct 2019 09:30:37 +0800 Subject: [PATCH 23/67] =?UTF-8?q?=E6=AF=8F=E6=99=9A=E8=87=AA=E5=8A=A8?= =?UTF-8?q?=E5=90=8C=E6=AD=A5=E6=97=B6=EF=BC=8C=E6=8E=92=E9=99=A4=E7=A6=81?= =?UTF-8?q?=E7=94=A8=E9=97=A8=E5=BA=97?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- business/jxstore/cms/sync.go | 50 ++++++++++------------------------- business/jxstore/misc/misc.go | 6 ++--- controllers/cms_sync.go | 2 +- 3 files changed, 18 insertions(+), 40 deletions(-) diff --git a/business/jxstore/cms/sync.go b/business/jxstore/cms/sync.go index d7d03b007..750931e3e 100644 --- a/business/jxstore/cms/sync.go +++ b/business/jxstore/cms/sync.go @@ -358,7 +358,7 @@ func (v *VendorSync) SyncStoresCategory(ctx *jxcontext.Context, db *dao.DaoDB, v } // -func (v *VendorSync) SyncStoresSkus2(ctx *jxcontext.Context, db *dao.DaoDB, vendorIDs []int, storeIDs, skuIDs, excludeSkuIDs []int, setSyncStatus int, isAsync, isContinueWhenError bool) (hint string, err error) { +func (v *VendorSync) SyncStoresSkus2(ctx *jxcontext.Context, db *dao.DaoDB, vendorIDs []int, storeIDs []int, syncDisabled bool, skuIDs, excludeSkuIDs []int, setSyncStatus int, isAsync, isContinueWhenError bool) (hint string, err error) { globals.SugarLogger.Debug("SyncStoresSkus2") isManageIt := len(storeIDs) != 1 || len(skuIDs) == 0 || len(skuIDs) > 8 task, hint, err := v.LoopStoresMap2(ctx, db, fmt.Sprintf("同步门店商品信息:%v", storeIDs), isAsync, isManageIt, vendorIDs, storeIDs, @@ -373,11 +373,13 @@ func (v *VendorSync) SyncStoresSkus2(ctx *jxcontext.Context, db *dao.DaoDB, vend tasksch.NewParallelConfig().SetParallelCount(parallelCount).SetIsContinueWhenError(isContinueWhenError), ctx, func(task *tasksch.ParallelTask, batchItemList []interface{}, params ...interface{}) (retVal interface{}, err error) { storeMap := batchItemList[0].(*model.StoreMap) - if setSyncStatus != 0 { - dao.SetStoreSkuSyncStatus(db, storeMap.VendorID, []int{storeMap.StoreID}, skuIDs, setSyncStatus) - } - if _, err = v.proxySyncStoreSku(ctx, task, storeMap, nil, skuIDs, excludeSkuIDs, false, isContinueWhenError); err != nil { - globals.SugarLogger.Debugf("SyncStoresSkus2 failed2 store:%d failed with error:%v", storeMap.StoreID, err) + if syncDisabled || storeMap.Status > model.StoreStatusDisabled { + if setSyncStatus != 0 { + dao.SetStoreSkuSyncStatus(db, storeMap.VendorID, []int{storeMap.StoreID}, skuIDs, setSyncStatus) + } + if _, err = v.proxySyncStoreSku(ctx, task, storeMap, nil, skuIDs, excludeSkuIDs, false, isContinueWhenError); err != nil { + globals.SugarLogger.Debugf("SyncStoresSkus2 failed2 store:%d failed with error:%v", storeMap.StoreID, err) + } } return nil, err }, loopMapInfo.StoreMapList) @@ -387,18 +389,6 @@ func (v *VendorSync) SyncStoresSkus2(ctx *jxcontext.Context, db *dao.DaoDB, vend return nil, partner.AddVendorInfo2Err(err, loopMapInfo.VendorID) }, isContinueWhenError) if task != nil { - // if vendorErr := partner.IsErrChangePriceFailed(task.GetOriginalErr()); vendorErr != nil { - // platformList := make([]string, len(task.GetDetailErrList())) - // for k, v := range task.GetDetailErrList() { - // if vendorErr := partner.IsErrVendorError(v); vendorErr != nil { - // platformList[k] = model.VendorChineseNames[vendorErr.VendorID()] - // } else { - // platformList[k] = "未知" - // } - // } - // err = fmt.Errorf("同步价格失败\n失败平台:%s", strings.Join(platformList, ",")) - // } else { - // } err = makeSyncError(err) } return hint, err @@ -409,36 +399,22 @@ func (v *VendorSync) SyncStoresSkus(ctx *jxcontext.Context, db *dao.DaoDB, vendo if isForce { setSyncStatus = model.SyncFlagStoreSkuModifiedMask } - return v.SyncStoresSkus2(ctx, db, vendorIDs, storeIDs, skuIDs, nil, setSyncStatus, isAsync, isContinueWhenError) + return v.SyncStoresSkus2(ctx, db, vendorIDs, storeIDs, true, skuIDs, nil, setSyncStatus, isAsync, isContinueWhenError) } -// func isUseOldSyncLogic(storeMap *model.StoreMap) bool { -// return false -// return globals.IsProductEnv() && storeMap.StoreID != 102652 // 绿城四季鲜店 -// } - func (v *VendorSync) proxySyncStoreCategory(ctx *jxcontext.Context, parentTask tasksch.ITask, storeMap *model.StoreMap, nameIDs, skuIDs []int, isAsync, isContinueWhenError bool) (hint string, err error) { - // if isUseOldSyncLogic(storeMap) { - // return v.GetStoreHandler(storeMap.VendorID).(partner.ISingleStoreHandler).SyncStoreCategory(ctx, parentTask, storeMap.StoreID, isAsync) - // } return SyncStorCategories(ctx, parentTask, storeMap.VendorID, storeMap.StoreID, storeMap.VendorStoreID, nil, skuIDs, isAsync, isContinueWhenError) } func (v *VendorSync) proxySyncStoreSku(ctx *jxcontext.Context, parentTask tasksch.ITask, storeMap *model.StoreMap, nameIDs, skuIDs, excludeSkuIDs []int, isAsync, isContinueWhenError bool) (hint string, err error) { - // if isUseOldSyncLogic(storeMap) { - // return v.GetStoreHandler(storeMap.VendorID).SyncStoreSkus(ctx, parentTask, storeMap.StoreID, skuIDs, isAsync, isContinueWhenError) - // } return SyncStoreSkuNew(ctx, parentTask, storeMap.VendorID, storeMap.StoreID, storeMap.VendorStoreID, nil, skuIDs, excludeSkuIDs, isAsync, isContinueWhenError) } func (v *VendorSync) proxyFullSyncStoreSku(ctx *jxcontext.Context, parentTask tasksch.ITask, storeMap *model.StoreMap, isAsync, isContinueWhenError bool) (hint string, err error) { - // if isUseOldSyncLogic(storeMap) { - // return v.GetStoreHandler(storeMap.VendorID).FullSyncStoreSkus(ctx, parentTask, storeMap.StoreID, isAsync, isContinueWhenError) - // } return FullSyncStoreSkuNew(ctx, parentTask, storeMap.VendorID, storeMap.StoreID, storeMap.VendorStoreID, isAsync, isContinueWhenError) } -func (v *VendorSync) FullSyncStoresSkus(ctx *jxcontext.Context, db *dao.DaoDB, vendorIDs []int, storeIDs []int, isAsync, isContinueWhenError bool) (hint string, err error) { +func (v *VendorSync) FullSyncStoresSkus(ctx *jxcontext.Context, db *dao.DaoDB, vendorIDs []int, storeIDs []int, syncDisabled, isAsync, isContinueWhenError bool) (hint string, err error) { globals.SugarLogger.Debug("FullSyncStoresSkus") hint, err = v.LoopStoresMap(ctx, db, fmt.Sprintf("初始化门店商品信息:%v", storeIDs), isAsync, true, vendorIDs, storeIDs, func(t *tasksch.ParallelTask, batchItemList []interface{}, params ...interface{}) (interface{}, error) { @@ -452,8 +428,10 @@ func (v *VendorSync) FullSyncStoresSkus(ctx *jxcontext.Context, db *dao.DaoDB, v tasksch.NewParallelConfig().SetParallelCount(parallelCount).SetIsContinueWhenError(isContinueWhenError), ctx, func(task *tasksch.ParallelTask, batchItemList []interface{}, params ...interface{}) (retVal interface{}, err error) { storeMap := batchItemList[0].(*model.StoreMap) - if _, err = v.proxyFullSyncStoreSku(ctx, task, storeMap, false, isContinueWhenError); err != nil { - globals.SugarLogger.Debugf("FullSyncStoresSkus failed2 store:%d failed with error:%v", storeMap.StoreID, err) + if syncDisabled || storeMap.Status > model.StoreStatusDisabled { + if _, err = v.proxyFullSyncStoreSku(ctx, task, storeMap, false, isContinueWhenError); err != nil { + globals.SugarLogger.Debugf("FullSyncStoresSkus failed2 store:%d failed with error:%v", storeMap.StoreID, err) + } } return nil, err }, loopMapInfo.StoreMapList) diff --git a/business/jxstore/misc/misc.go b/business/jxstore/misc/misc.go index 8f62f7f92..807ba34a5 100644 --- a/business/jxstore/misc/misc.go +++ b/business/jxstore/misc/misc.go @@ -124,12 +124,12 @@ func doDailyWork() { globals.SugarLogger.Debug("doDailyWork") cms.SyncStoresCourierInfo(jxcontext.AdminCtx, nil, false, true) netprinter.RebindAllPrinters(jxcontext.AdminCtx, false, true) - // cms.CurVendorSync.FullSyncStoresSkus(jxcontext.AdminCtx, dao.GetDB(), []int{model.VendorIDJD}, nil, true, true) + // cms.CurVendorSync.FullSyncStoresSkus(jxcontext.AdminCtx, dao.GetDB(), []int{model.VendorIDJD}, nil, false, true, true) - cms.CurVendorSync.SyncStoresSkus2(jxcontext.AdminCtx, dao.GetDB(), []int{model.VendorIDJD}, nil, nil, []int{27379}, model.SyncFlagSaleMask|model.SyncFlagPriceMask, true, true) + cms.CurVendorSync.SyncStoresSkus2(jxcontext.AdminCtx, dao.GetDB(), []int{model.VendorIDJD}, nil, false, nil, []int{27379}, model.SyncFlagSaleMask|model.SyncFlagPriceMask, true, true) SaveImportantTaskID(TaskNameSyncStoreSku, SpecialTaskID) - taskID, _ := cms.CurVendorSync.SyncStoresSkus2(jxcontext.AdminCtx, dao.GetDB(), []int{model.VendorIDEBAI, model.VendorIDMTWM}, nil, nil, nil, model.SyncFlagSaleMask|model.SyncFlagPriceMask, true, true) + taskID, _ := cms.CurVendorSync.SyncStoresSkus2(jxcontext.AdminCtx, dao.GetDB(), []int{model.VendorIDEBAI, model.VendorIDMTWM}, nil, false, nil, nil, model.SyncFlagSaleMask|model.SyncFlagPriceMask, true, true) SaveImportantTaskID(TaskNameSyncStoreSku, taskID) InitEx() diff --git a/controllers/cms_sync.go b/controllers/cms_sync.go index 079ae7e04..687264cb2 100644 --- a/controllers/cms_sync.go +++ b/controllers/cms_sync.go @@ -115,7 +115,7 @@ func (c *SyncController) FullSyncStoresSkus() { if err = jxutils.Strings2Objs(params.StoreIDs, &storeIDs, params.VendorIDs, &vendorIDs); err != nil { return retVal, "", err } - retVal, err = cms.CurVendorSync.FullSyncStoresSkus(params.Ctx, db, vendorIDs, storeIDs, params.IsAsync, params.IsContinueWhenError) + retVal, err = cms.CurVendorSync.FullSyncStoresSkus(params.Ctx, db, vendorIDs, storeIDs, true, params.IsAsync, params.IsContinueWhenError) return retVal, "", err }) } From 8ed5172f35bf4cf9fc2d34e5406c98433fe71ddf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=8B=8F=E5=B0=B9=E5=B2=9A?= <770236076@qq.com> Date: Thu, 31 Oct 2019 10:25:21 +0800 Subject: [PATCH 24/67] =?UTF-8?q?=E7=BB=9F=E8=AE=A1=E8=AE=A2=E5=8D=95?= =?UTF-8?q?=E6=8E=A5=E5=8F=A3=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- business/jxstore/report/report.go | 12 ++++++++++- business/model/dao/report.go | 33 +++++++++++++++---------------- controllers/jx_report.go | 6 +++--- 3 files changed, 30 insertions(+), 21 deletions(-) diff --git a/business/jxstore/report/report.go b/business/jxstore/report/report.go index 5fe22d54b..324bd7320 100644 --- a/business/jxstore/report/report.go +++ b/business/jxstore/report/report.go @@ -1,12 +1,22 @@ package report import ( + "errors" + "fmt" + "math" + + "git.rosy.net.cn/baseapi/utils" "git.rosy.net.cn/jx-callback/business/jxutils/jxcontext" "git.rosy.net.cn/jx-callback/business/model/dao" ) func GetStatisticsReportForOrders(ctx *jxcontext.Context, storeIDs []int, fromDate string, toDate string) (statisticsReportForOrdersList []*dao.StatisticsReportForOrdersList, err error) { db := dao.GetDB() - statisticsReportForOrdersList, err = dao.GetStatisticsReportForOrders(db, storeIDs, fromDate, toDate) + fromDateParm := utils.Str2Time(fromDate) + toDateParm := utils.Str2Time(toDate) + if math.Ceil(toDateParm.Sub(fromDateParm).Hours()/24) > 92 { + return nil, errors.New(fmt.Sprintf("查询间隔时间不允许大于3个月!: 时间范围:[%v] 至 [%v]", fromDate, toDate)) + } + statisticsReportForOrdersList, err = dao.GetStatisticsReportForOrders(db, storeIDs, fromDateParm, toDateParm) return statisticsReportForOrdersList, err } diff --git a/business/model/dao/report.go b/business/model/dao/report.go index d01737169..22386fcdf 100644 --- a/business/model/dao/report.go +++ b/business/model/dao/report.go @@ -2,6 +2,7 @@ package dao import ( "strconv" + "time" "git.rosy.net.cn/baseapi/utils" "git.rosy.net.cn/jx-callback/business/model" @@ -9,14 +10,14 @@ import ( type StatisticsReportForOrdersList struct { StoreID int `orm:"column(storeID)" json:"storeID"` - OrderCounts int `orm:"column(orderCounts)" json:"orderCounts"` - SalePrice int `orm:"column(salePrice)" json:"salePrice"` - ActualPayPrice int `orm:"column(actualPayPrice)" json:"actualPayPrice"` - ShopPrice int `orm:"column(shopPrice)" json:"shopPrice"` - DiscountMoney int `orm:"column(discountMoney)" json:"discountMoney"` - DesiredFee int `orm:"column(desiredFee)" json:"desiredFee"` - DistanceFreightMoney int `orm:"column(distanceFreightMoney)" json:"distanceFreightMoney"` - WaybillTipMoney int `orm:"column(waybillTipMoney)" json:"waybillTipMoney"` + OrderCounts int `orm:"column(orderCounts)" json:"orderCounts"` //定单数 + SalePrice int `orm:"column(salePrice)" json:"salePrice"` //GMV(售卖价) + ActualPayPrice int `orm:"column(actualPayPrice)" json:"actualPayPrice"` //实付 + ShopPrice int `orm:"column(shopPrice)" json:"shopPrice"` //京西 + DiscountMoney int `orm:"column(discountMoney)" json:"discountMoney"` //优惠 + DesiredFee int `orm:"column(desiredFee)" json:"desiredFee"` //配送费 + DistanceFreightMoney int `orm:"column(distanceFreightMoney)" json:"distanceFreightMoney"` //远距离 + WaybillTipMoney int `orm:"column(waybillTipMoney)" json:"waybillTipMoney"` // TotalShopMoney int `orm:"column(totalShopMoney)" json:"totalShopMoney"` PmSubsidyMoney int `orm:"column(pmSubsidyMoney)" json:"pmSubsidyMoney"` EarningPrice int `orm:"column(earningPrice)" json:"earningPrice"` @@ -25,7 +26,7 @@ type StatisticsReportForOrdersList struct { CityManagerGrossProfit float32 `orm:"column(cityManagerGrossProfit)" json:"cityManagerGrossProfit"` } -func GetStatisticsReportForOrders(db *DaoDB, storeIDs []int, fromDate string, toDate string) (statisticsReportForOrdersList []*StatisticsReportForOrdersList, err error) { +func GetStatisticsReportForOrders(db *DaoDB, storeIDs []int, fromDate time.Time, toDate time.Time) (statisticsReportForOrdersList []*StatisticsReportForOrdersList, err error) { //排除已取消的订单 status := strconv.Itoa(model.OrderStatusCanceled) sql := ` @@ -51,16 +52,14 @@ func GetStatisticsReportForOrders(db *DaoDB, storeIDs []int, fromDate string, to WHERE a.status != ` + status + ` ` sqlParams := []interface{}{} - if fromDate != "" { - sql += "AND a.order_created_at >= date_format(?,'YYYY-MM-DD HH:MM:SS')" - sqlParams = append(sqlParams, utils.Str2Time(fromDate)) - } - if toDate != "" { - sql += "AND a.order_created_at <= date_format(?,'YYYY-MM-DD HH:MM:SS')" - sqlParams = append(sqlParams, utils.Str2Time(toDate)) + if !utils.IsTimeZero(fromDate) && !utils.IsTimeZero(toDate) { + sql += `AND a.order_created_at BETWEEN ? and ? + ` + sqlParams = append(sqlParams, fromDate, toDate) } if len(storeIDs) > 0 { - sql += "AND a.store_id in(" + GenQuestionMarks(len(storeIDs)) + ")" + sql += `AND a.store_id in(` + GenQuestionMarks(len(storeIDs)) + `) + ` sqlParams = append(sqlParams, storeIDs) } sql += ` diff --git a/controllers/jx_report.go b/controllers/jx_report.go index 4bad3821e..9450f576e 100644 --- a/controllers/jx_report.go +++ b/controllers/jx_report.go @@ -13,10 +13,10 @@ type ReportController struct { // @Title 查询订单统计信息 // @Description 根据门店idlist和时间范围查询 -// @Param token header string true "认证token" +// @Param token header string true "认证token" // @Param storeIDs formData string true "京西门店ID列表[1,2,3]" -// @Param fromDate formData string false "开始日期(包含),格式(2006-01-02 00:00:00)" -// @Param toDate formData string false "结束日期(包含),格式(2006-01-02 00:00:00)" +// @Param fromDate formData string true "开始日期(包含),格式(2006-01-02 00:00:00)" +// @Param toDate formData string true "结束日期(包含),格式(2006-01-02 00:00:00)" // @Success 200 {object} controllers.CallResult // @Failure 200 {object} controllers.CallResult // @router /StatisticsReportForOrders [post] From e587723cf5810d5b745d0962b77b4c9608f175ca Mon Sep 17 00:00:00 2001 From: gazebo Date: Thu, 31 Oct 2019 11:10:59 +0800 Subject: [PATCH 25/67] +GetWeimobToken --- .../eventhub/syseventhub/syseventhub.go | 22 +++++- business/jxutils/tasks/configrefresh.go | 68 +++++++++++-------- conf/app.conf | 5 +- controllers/sys.go | 17 +++++ globals/globals.go | 2 + routers/commentsRouter_controllers.go | 9 +++ 6 files changed, 91 insertions(+), 32 deletions(-) diff --git a/business/jxutils/eventhub/syseventhub/syseventhub.go b/business/jxutils/eventhub/syseventhub/syseventhub.go index 6e892522a..528c76973 100644 --- a/business/jxutils/eventhub/syseventhub/syseventhub.go +++ b/business/jxutils/eventhub/syseventhub/syseventhub.go @@ -13,8 +13,9 @@ import ( const ( EventCategory = "sys" - EventTypeWXToken = "wxtoken" - EventTypeYLYToken = "ylytoken" + EventTypeWXToken = "wxToken" + EventTypeYLYToken = "ylyToken" + EventTypeWeimobToken = "weimobToken" ) type Hub struct { @@ -63,6 +64,13 @@ func (h *Hub) OnNewYLYToken(token string) { }) } +func (h *Hub) OnNewWeimobToken(token string) { + h.eventHub.PostNewEvent(EventCategory, &eventhub.EventInfo{ + Type: EventTypeWeimobToken, + Data: token, + }) +} + func (h *Hub) GetToken(tokenType, oldToken string, waitTime time.Duration) (tokenInfo *TokenInfo) { var token string switch tokenType { @@ -70,6 +78,10 @@ func (h *Hub) GetToken(tokenType, oldToken string, waitTime time.Duration) (toke token = api.WeixinAPI.CBGetToken() case EventTypeYLYToken: token = api.YilianyunAPI.GetToken() + case EventTypeWeimobToken: + if weimobToken := api.WeimobAPI.GetToken(); weimobToken != nil { + token = string(utils.MustMarshal(weimobToken)) + } } if token != oldToken { tokenInfo = &TokenInfo{ @@ -85,7 +97,7 @@ func (h *Hub) GetToken(tokenType, oldToken string, waitTime time.Duration) (toke } } } - globals.SugarLogger.Debugf("GetToken tokenInfo:%s", utils.Format4Output(tokenInfo, true)) + globals.SugarLogger.Debugf("GetToken tokenType:%s tokenInfo:%s", tokenType, utils.Format4Output(tokenInfo, true)) return tokenInfo } @@ -96,3 +108,7 @@ func (h *Hub) GetWXToken(oldToken string, waitTime time.Duration) (tokenInfo *To func (h *Hub) GetYLYToken(oldToken string, waitTime time.Duration) (tokenInfo *TokenInfo) { return h.GetToken(EventTypeYLYToken, oldToken, waitTime) } + +func (h *Hub) GetWeimobToken(oldToken string, waitTime time.Duration) (tokenInfo *TokenInfo) { + return h.GetToken(EventTypeWeimobToken, oldToken, waitTime) +} diff --git a/business/jxutils/tasks/configrefresh.go b/business/jxutils/tasks/configrefresh.go index d675a6919..3f66b89b2 100644 --- a/business/jxutils/tasks/configrefresh.go +++ b/business/jxutils/tasks/configrefresh.go @@ -115,19 +115,17 @@ func RefreshWeixinToken() (err error) { if api.WeixinAPI != nil { err = RefreshConfig("wechat", weixinTokenExpires, func() (token string, expireTimeStr string) { globals.SugarLogger.Debugf("RefreshWeixinToken RunMode:%s", beego.BConfig.RunMode) - if globals.IsProductEnv() || beego.BConfig.RunMode == "alpha" { - if globals.IsMainProductEnv() { - if tokenInfo, err := api.WeixinAPI.CBRetrieveToken(); err == nil { - globals.SugarLogger.Debugf("RefreshWeixinToken tokenInfo:%s", utils.Format4Output(tokenInfo, true)) - token = tokenInfo.AccessToken - } else { - globals.SugarLogger.Errorf("RefreshWeixinToken RefreshToken failed with error:%v", err) - } + if globals.IsMainProductEnv() { + if tokenInfo, err := api.WeixinAPI.CBRetrieveToken(); err == nil { + globals.SugarLogger.Debugf("RefreshWeixinToken tokenInfo:%s", utils.Format4Output(tokenInfo, true)) + token = tokenInfo.AccessToken } else { - if tokenInfo := getWXTokenFromRemote(api.WeixinAPI.CBGetToken()); tokenInfo != nil { - expireTimeStr = utils.Time2Str(time.Now().Add(-weixinTokenExpires)) - token = tokenInfo.Token - } + globals.SugarLogger.Errorf("RefreshWeixinToken RefreshToken failed with error:%v", err) + } + } else { + if tokenInfo := getWXTokenFromRemote(api.WeixinAPI.CBGetToken()); tokenInfo != nil { + expireTimeStr = utils.Time2Str(time.Now().Add(-weixinTokenExpires)) + token = tokenInfo.Token } } return token, expireTimeStr @@ -142,17 +140,28 @@ func RefreshWeixinToken() (err error) { func RefreshWeimobToken() (err error) { if api.WeimobAPI != nil { - err = RefreshConfig("weimob", weimobTokenExpires, func() (string, string) { + err = RefreshConfig("weimob", weimobTokenExpires, func() (token string, expireTimeStr string) { + globals.SugarLogger.Debugf("RefreshWeimobToken RunMode:%s", beego.BConfig.RunMode) if globals.IsMainProductEnv() { if tokenInfo, err := api.WeimobAPI.RefreshTokenByRefreshToken(); err == nil { return string(utils.MustMarshal(tokenInfo)), utils.Time2Str(time.Now().Add((time.Duration(tokenInfo.ExpiresIn) - weimobTokenExpires/time.Second) * time.Second)) } + } else { + curToken := "" + if tokenInfo := api.WeimobAPI.GetToken(); tokenInfo != nil { + curToken = string(utils.MustMarshal(tokenInfo)) + } + if tokenInfo := getWeimobTokenFromRemote(curToken); tokenInfo != nil { + expireTimeStr = utils.Time2Str(time.Now().Add(-weimobTokenExpires)) + token = tokenInfo.Token + } } - return "", "" + return token, expireTimeStr }, func(value string) { var tokenInfo *weimobapi.TokenInfo err := utils.UnmarshalUseNumber([]byte(value), &tokenInfo) if err == nil { + syseventhub.SysEventHub.OnNewWeimobToken(string(utils.MustMarshal(tokenInfo))) api.WeimobAPI.SetToken(tokenInfo) } }) @@ -216,19 +225,6 @@ func RefreshYilianyunToken() (err error) { }) } -func getWXTokenFromRemote(oldToken string) (tokenInfo *syseventhub.TokenInfo) { - if IsGetWXTokenFromRemote() { - tokenInfo = PollingRemotEvent(globals.GetWeixinTokenURL, 0, map[string]interface{}{ - "oldToken": oldToken, - }) - } - return tokenInfo -} - -func IsGetWXTokenFromRemote() bool { - return !globals.IsMainProductEnv() && globals.GetWeixinTokenKey != "" && globals.GetWeixinTokenURL != "" -} - func PollingRemotEvent(remoteURL string, waitSecond int, params map[string]interface{}) (tokenInfo *syseventhub.TokenInfo) { if waitSecond == 0 { waitSecond = 5 * 60 @@ -272,6 +268,15 @@ func PollingRemotEvent(remoteURL string, waitSecond int, params map[string]inter return tokenInfo } +func getWXTokenFromRemote(oldToken string) (tokenInfo *syseventhub.TokenInfo) { + if !globals.IsMainProductEnv() && globals.GetWeixinTokenKey != "" && globals.GetWeixinTokenURL != "" { + tokenInfo = PollingRemotEvent(globals.GetWeixinTokenURL, 0, map[string]interface{}{ + "oldToken": oldToken, + }) + } + return tokenInfo +} + func getYLYTokenFromRemote(oldToken string) (tokenInfo *syseventhub.TokenInfo) { if !globals.IsMainProductEnv() && globals.GetWeixinTokenKey != "" && globals.GetYLYTokenURL != "" { tokenInfo = PollingRemotEvent(globals.GetYLYTokenURL, 0, map[string]interface{}{ @@ -280,3 +285,12 @@ func getYLYTokenFromRemote(oldToken string) (tokenInfo *syseventhub.TokenInfo) { } return tokenInfo } + +func getWeimobTokenFromRemote(oldToken string) (tokenInfo *syseventhub.TokenInfo) { + if !globals.IsMainProductEnv() && globals.GetWeixinTokenKey != "" && globals.GetWeimobTokenURL != "" { + tokenInfo = PollingRemotEvent(globals.GetWeimobTokenURL, 0, map[string]interface{}{ + "oldToken": oldToken, + }) + } + return tokenInfo +} diff --git a/conf/app.conf b/conf/app.conf index c5a5e8de9..692e5d9b2 100644 --- a/conf/app.conf +++ b/conf/app.conf @@ -118,8 +118,8 @@ weixinToken = "17_roSCZgkCxhRnyFVtei0KdfHwdGP8PmLzJFhCieka4_X4_d-lgfaTxF6oIS6FE5 dbConnectStr = "root:WebServer@1@tcp(127.0.0.1:3306)/jxd_dev_0?charset=utf8mb4&loc=Local&parseTime=true" -getWeixinTokenURL = "http://beta.jxc4.com/v2/sys/GetWXToken" -getYLYTokenURL = "http://beta.jxc4.com/v2/sys/GetYLYToken" +getWeixinTokenURL = "http://www.jxc4.com/v2/sys/GetWXToken" +getYLYTokenURL = "http://www.jxc4.com/v2/sys/GetYLYToken" [prod] EnableDocs = false @@ -311,5 +311,6 @@ weixinMiniAppID2 = "wx4b5930c13f8b1170" weixinMiniSecret2 = "2a57228a716ce991a52739f0ff41111d" getWeixinTokenURL = "http://www.jxc4.com/v2/sys/GetWXToken" +getWeimobTokenURL = "http://www.jxc4.com/v2/sys/GetWeimobToken" dbConnectStr = "root:WebServer@1@tcp(127.0.0.1:3306)/jxd_dev_0?charset=utf8mb4&loc=Local&parseTime=true" diff --git a/controllers/sys.go b/controllers/sys.go index 26ad57cce..4e4b66a0e 100644 --- a/controllers/sys.go +++ b/controllers/sys.go @@ -54,6 +54,23 @@ func (c *SysController) GetYLYToken() { }) } +// @Title 得到微盟token +// @Description 得到微盟token +// @Param accessKey query string true "假token" +// @Param oldToken query string false "之前的token" +// @Param waitSecond query int false "等待秒数" +// @Success 200 {object} controllers.CallResult +// @Failure 200 {object} controllers.CallResult +// @router /GetWeimobToken [get] +func (c *SysController) GetWeimobToken() { + c.callGetWeimobToken(func(params *tSysGetWeimobTokenParams) (retVal interface{}, errCode string, err error) { + if params.AccessKey == globals.GetWeixinTokenKey { + retVal = syseventhub.SysEventHub.GetWeimobToken(params.OldToken, time.Duration(params.WaitSecond)*time.Second) + } + return retVal, "", err + }) +} + // @Title 得到饿百RTF转换内容 // @Description 得到饿百RTF转换内容 // @Param imgListStr query string true "逗号分隔的图片列表可以是转义后的" diff --git a/globals/globals.go b/globals/globals.go index 3bd30d243..e615981b0 100644 --- a/globals/globals.go +++ b/globals/globals.go @@ -41,6 +41,7 @@ var ( GetWeixinTokenURL string GetWeixinTokenKey string GetYLYTokenURL string + GetWeimobTokenURL string StoreName string @@ -84,6 +85,7 @@ func Init() { GetWeixinTokenURL = beego.AppConfig.DefaultString("getWeixinTokenURL", "") GetYLYTokenURL = beego.AppConfig.DefaultString("getYLYTokenURL", "") + GetWeimobTokenURL = beego.AppConfig.DefaultString("getWeimobTokenURL", "") GetWeixinTokenKey = beego.AppConfig.DefaultString("getWeixinTokenKey", "") StoreName = beego.AppConfig.DefaultString("storeName", "京西菜市") diff --git a/routers/commentsRouter_controllers.go b/routers/commentsRouter_controllers.go index 6cec894c6..fad661d86 100644 --- a/routers/commentsRouter_controllers.go +++ b/routers/commentsRouter_controllers.go @@ -1647,6 +1647,15 @@ func init() { Filters: nil, Params: nil}) + beego.GlobalControllerRouter["git.rosy.net.cn/jx-callback/controllers:SysController"] = append(beego.GlobalControllerRouter["git.rosy.net.cn/jx-callback/controllers:SysController"], + beego.ControllerComments{ + Method: "GetWeimobToken", + Router: `/GetWeimobToken`, + AllowHTTPMethods: []string{"get"}, + MethodParams: param.Make(), + Filters: nil, + Params: nil}) + beego.GlobalControllerRouter["git.rosy.net.cn/jx-callback/controllers:SysController"] = append(beego.GlobalControllerRouter["git.rosy.net.cn/jx-callback/controllers:SysController"], beego.ControllerComments{ Method: "GetYLYToken", From af4444648eea9d2eb6c91038e73f24048f843287 Mon Sep 17 00:00:00 2001 From: gazebo Date: Thu, 31 Oct 2019 11:13:30 +0800 Subject: [PATCH 26/67] =?UTF-8?q?+weimob=5Forder.go=EF=BC=8C=E6=A0=B9?= =?UTF-8?q?=E6=8D=AE=E5=BE=AE=E7=9B=9F=E9=9B=86=E4=B8=AD=E4=BE=9B=E8=B4=A7?= =?UTF-8?q?=E8=AE=A2=E5=8D=95=E8=87=AA=E5=8A=A8=E5=85=B3=E6=B3=A8=EF=BC=8C?= =?UTF-8?q?=E4=BF=AE=E6=94=B9=E7=9B=B8=E5=BA=94=E7=9A=84=E9=97=A8=E5=BA=97?= =?UTF-8?q?=E5=95=86=E5=93=81=E4=BB=B7=E6=A0=BC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- business/cs/weimob_order.go | 68 ++++++++++++++++++++++++++++++++++ controllers/weimob_callback.go | 10 +++-- 2 files changed, 74 insertions(+), 4 deletions(-) create mode 100644 business/cs/weimob_order.go diff --git a/business/cs/weimob_order.go b/business/cs/weimob_order.go new file mode 100644 index 000000000..e5d89e979 --- /dev/null +++ b/business/cs/weimob_order.go @@ -0,0 +1,68 @@ +package cs + +import ( + "git.rosy.net.cn/baseapi/platformapi/weimobapi" + "git.rosy.net.cn/baseapi/utils" + "git.rosy.net.cn/jx-callback/business/jxstore/cms" + "git.rosy.net.cn/jx-callback/business/jxutils" + "git.rosy.net.cn/jx-callback/business/jxutils/jxcontext" + "git.rosy.net.cn/jx-callback/business/model" + "git.rosy.net.cn/jx-callback/business/model/dao" + "git.rosy.net.cn/jx-callback/globals" + "git.rosy.net.cn/jx-callback/globals/api" +) + +const ( + minCSOrderPayment = 0 // 供货订单的最小金额 + maxUnitPrice = 3000 // 为防止误填单价,限制单价最高 +) + +func OnCallbackMsg(msg *weimobapi.CallbackMsg) (response *weimobapi.CallbackResponse) { + orderID := utils.Int64ToStr(msg.OrderNo) + jxutils.CallMsgHandler(func() { + response = onOrderMsg(msg) + }, jxutils.ComposeUniversalOrderID(orderID, model.VendorIDWSC)) + return response +} + +func onOrderMsg(msg *weimobapi.CallbackMsg) (response *weimobapi.CallbackResponse) { + if msg.Event == weimobapi.MsgEventOrderStatusChange { + if orderDetail, err := api.WeimobAPI.QueryOrderDetail2(msg.OrderNo, false); err == nil { + if orderDetail.OrderStatus == weimobapi.OrderStatusFinished && orderDetail.PaymentAmount >= minCSOrderPayment { + changeStoreSkusByOrder(orderDetail) + } + } + } + return response +} + +func changeStoreSkusByOrder(order *weimobapi.OrderDetail) { + receiverMobile := order.DeliveryDetail.LogisticsDeliveryDetail.ReceiverMobile + storeList, err := dao.GetStoreList(dao.GetDB(), nil, []string{receiverMobile}, "") + if err != nil { + if len(storeList) == 1 { + var skuBindInfos []*cms.StoreSkuBindInfo + storeID := storeList[0].ID + for _, v := range order.ItemList { + nameID := int(utils.Str2Int64WithDefault(v.SkuCode, 0)) + unitPrice := v.OriginalPrice + if nameID > 0 && (unitPrice > 0 && unitPrice < maxUnitPrice) { + skuBindInfos = append(skuBindInfos, &cms.StoreSkuBindInfo{ + StoreID: storeID, + NameID: nameID, + UnitPrice: int(jxutils.StandardPrice2Int(unitPrice)), + IsFocus: 1, + IsSale: 1, + }) + } else { + globals.SugarLogger.Infof("[运营],微商城订单:%s,商品:%s没有设置正确的SkuName编码或单价,当前商家编码:%s,市场价:%s", order.OrderNo, v.SkuNum, v.SkuCode, jxutils.IntPrice2StandardString(jxutils.StandardPrice2Int(unitPrice))) + } + } + if len(skuBindInfos) > 0 { + cms.UpdateStoreSkus(jxcontext.NewWithUserName(nil, utils.LimitStringLen(utils.Int64ToStr(order.OrderNo), 32), nil, nil), storeID, skuBindInfos, true, true) + } + } else { + globals.SugarLogger.Infof("[运营],微商城订单:%s,手机:%s找不到唯一一个京西门店%d", order.OrderNo, receiverMobile, len(storeList)) + } + } +} diff --git a/controllers/weimob_callback.go b/controllers/weimob_callback.go index 8e8123ad7..7989ae264 100644 --- a/controllers/weimob_callback.go +++ b/controllers/weimob_callback.go @@ -3,6 +3,7 @@ package controllers import ( "git.rosy.net.cn/baseapi/platformapi/weimobapi" "git.rosy.net.cn/jx-callback/business/jxutils/tasks" + "git.rosy.net.cn/jx-callback/business/cs" "git.rosy.net.cn/jx-callback/globals" "git.rosy.net.cn/jx-callback/globals/api" "github.com/astaxie/beego" @@ -15,10 +16,11 @@ type WeimobController struct { func (c *WeimobController) onCallbackMsg() { if true { //c.Ctx.Input.Method() == http.MethodPost { callbackResponse := weimobapi.SuccessResponse - // msg, callbackResponse := api.WeimobAPI.GetCallbackMsg(c.Ctx.Input.RequestBody) - // if callbackResponse == nil { - // callbackResponse = wsc.OnCallbackMsg(msg) - // } + msg, callbackResponse := api.WeimobAPI.GetCallbackMsg(c.Ctx.Input.RequestBody) + if callbackResponse == nil { + // callbackResponse = wsc.OnCallbackMsg(msg) + callbackResponse = cs.OnCallbackMsg(msg) + } c.Data["json"] = callbackResponse c.ServeJSON() } else { From 5dc67bcd9ed8e8b24ef1c2fff45419af82c9d7ff Mon Sep 17 00:00:00 2001 From: gazebo Date: Thu, 31 Oct 2019 11:25:45 +0800 Subject: [PATCH 27/67] disableWeimob = false for beta --- conf/app.conf | 1 + 1 file changed, 1 insertion(+) diff --git a/conf/app.conf b/conf/app.conf index 692e5d9b2..608ab9764 100644 --- a/conf/app.conf +++ b/conf/app.conf @@ -310,6 +310,7 @@ weixinSecret = "6bbbed1443cc062c20a015a64c07a531" weixinMiniAppID2 = "wx4b5930c13f8b1170" weixinMiniSecret2 = "2a57228a716ce991a52739f0ff41111d" +disableWeimob = false getWeixinTokenURL = "http://www.jxc4.com/v2/sys/GetWXToken" getWeimobTokenURL = "http://www.jxc4.com/v2/sys/GetWeimobToken" From d066a13b65bc2534a874620d8cb91eb994219ff5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=8B=8F=E5=B0=B9=E5=B2=9A?= <770236076@qq.com> Date: Thu, 31 Oct 2019 13:33:38 +0800 Subject: [PATCH 28/67] =?UTF-8?q?=E7=BB=9F=E8=AE=A1=E8=AE=A2=E5=8D=95?= =?UTF-8?q?=E6=8E=A5=E5=8F=A3=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- business/jxstore/report/report.go | 51 ++++++++++++++++++++++++++++++- business/model/dao/report.go | 42 +++++++++++++++++++++++-- 2 files changed, 90 insertions(+), 3 deletions(-) diff --git a/business/jxstore/report/report.go b/business/jxstore/report/report.go index 324bd7320..1258a6f21 100644 --- a/business/jxstore/report/report.go +++ b/business/jxstore/report/report.go @@ -10,13 +10,62 @@ import ( "git.rosy.net.cn/jx-callback/business/model/dao" ) +var ( + storeIDsExist []int + storeIDsNotExist []int + StatisticsForOrdersExists *dao.StatisticsForOrdersExists + StatisticsForOrdersExistsStore *dao.StatisticsForOrdersExists +) + func GetStatisticsReportForOrders(ctx *jxcontext.Context, storeIDs []int, fromDate string, toDate string) (statisticsReportForOrdersList []*dao.StatisticsReportForOrdersList, err error) { + storeIDsExist = storeIDsExist[0:0] + storeIDsNotExist = storeIDsNotExist[0:0] db := dao.GetDB() fromDateParm := utils.Str2Time(fromDate) toDateParm := utils.Str2Time(toDate) + //若时间间隔大于3个月则不允许查询 if math.Ceil(toDateParm.Sub(fromDateParm).Hours()/24) > 92 { return nil, errors.New(fmt.Sprintf("查询间隔时间不允许大于3个月!: 时间范围:[%v] 至 [%v]", fromDate, toDate)) } - statisticsReportForOrdersList, err = dao.GetStatisticsReportForOrders(db, storeIDs, fromDateParm, toDateParm) + //若入参中,不存在的店则不显示,存在的店但无订单的显示0 + for _, id := range storeIDs { + StatisticsForOrdersExistsStore, err = dao.IsStoreExist(db, id) + if StatisticsForOrdersExistsStore == nil { + continue + } + StatisticsForOrdersExists, err = dao.GetStatisticsForOrdersExist(db, id) + //若该门店存在此查询条件范围内的订单 + if StatisticsForOrdersExists != nil { + storeIDsExist = append(storeIDsExist, id) + } else { + storeIDsNotExist = append(storeIDsNotExist, id) + } + } + statisticsReportForOrdersList, err = dao.GetStatisticsReportForOrders(db, storeIDsExist, fromDateParm, toDateParm) + if storeIDsNotExist != nil { + for _, v := range storeIDsNotExist { + tempStruct1 := &dao.StatisticsForOrdersExists{ + StoreID: v, + } + tempStruct2 := &dao.StatisticsReportForOrdersList{ + StatisticsForOrdersExists: *tempStruct1, + OrderCounts: 0, + SalePrice: 0, + ActualPayPrice: 0, + ShopPrice: 0, + DiscountMoney: 0, + DesiredFee: 0, + DistanceFreightMoney: 0, + WaybillTipMoney: 0, + TotalShopMoney: 0, + PmSubsidyMoney: 0, + EarningPrice: 0, + TotalGrossProfit: 0, + ComGrossProfit: 0, + CityManagerGrossProfit: 0, + } + statisticsReportForOrdersList = append(statisticsReportForOrdersList, tempStruct2) + } + } return statisticsReportForOrdersList, err } diff --git a/business/model/dao/report.go b/business/model/dao/report.go index 22386fcdf..17617df38 100644 --- a/business/model/dao/report.go +++ b/business/model/dao/report.go @@ -8,9 +8,13 @@ import ( "git.rosy.net.cn/jx-callback/business/model" ) +type StatisticsForOrdersExists struct { + StoreID int `orm:"column(storeID)" json:"storeID"` +} + type StatisticsReportForOrdersList struct { - StoreID int `orm:"column(storeID)" json:"storeID"` - OrderCounts int `orm:"column(orderCounts)" json:"orderCounts"` //定单数 + StatisticsForOrdersExists + OrderCounts int `orm:"column(orderCounts)" json:"orderCounts"` //订单数 SalePrice int `orm:"column(salePrice)" json:"salePrice"` //GMV(售卖价) ActualPayPrice int `orm:"column(actualPayPrice)" json:"actualPayPrice"` //实付 ShopPrice int `orm:"column(shopPrice)" json:"shopPrice"` //京西 @@ -26,6 +30,40 @@ type StatisticsReportForOrdersList struct { CityManagerGrossProfit float32 `orm:"column(cityManagerGrossProfit)" json:"cityManagerGrossProfit"` } +//是否存在这个门店 +func IsStoreExist(db *DaoDB, storeID int) (StatisticsForOrdersExists *StatisticsForOrdersExists, err error) { + sql := ` + SELECT * + FROM store + WHERE id = ? + ` + sqlParams := []interface{}{} + sqlParams = append(sqlParams, storeID) + + if err = GetRow(db, &StatisticsForOrdersExists, sql, sqlParams...); err == nil { + return StatisticsForOrdersExists, nil + } + return nil, err +} + +//查询条件内是否存在订单 +func GetStatisticsForOrdersExist(db *DaoDB, storeID int) (StatisticsForOrdersExists *StatisticsForOrdersExists, err error) { + sql := ` + SELECT store_id + FROM goods_order a LEFT JOIN waybill b ON IF(a.waybill_vendor_id = -1,a.vendor_order_id,a.vendor_waybill_id) = b.vendor_waybill_id + WHERE a.store_id = ? + GROUP BY a.store_id + ` + sqlParams := []interface{}{} + sqlParams = append(sqlParams, storeID) + + if err = GetRow(db, &StatisticsForOrdersExists, sql, sqlParams...); err == nil { + return StatisticsForOrdersExists, nil + } + return nil, err +} + +//查询统计订单信息 func GetStatisticsReportForOrders(db *DaoDB, storeIDs []int, fromDate time.Time, toDate time.Time) (statisticsReportForOrdersList []*StatisticsReportForOrdersList, err error) { //排除已取消的订单 status := strconv.Itoa(model.OrderStatusCanceled) From ae58b41ac64039a7f1d4d8dc9076f31053ed57d5 Mon Sep 17 00:00:00 2001 From: gazebo Date: Thu, 31 Oct 2019 14:06:14 +0800 Subject: [PATCH 29/67] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E5=BE=AE=E7=9B=9F?= =?UTF-8?q?=E5=9B=9E=E8=B0=83=E7=9A=84bug?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- business/cs/weimob_order.go | 4 ++++ controllers/weimob_callback.go | 6 ++++-- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/business/cs/weimob_order.go b/business/cs/weimob_order.go index e5d89e979..8d088336b 100644 --- a/business/cs/weimob_order.go +++ b/business/cs/weimob_order.go @@ -26,11 +26,14 @@ func OnCallbackMsg(msg *weimobapi.CallbackMsg) (response *weimobapi.CallbackResp } func onOrderMsg(msg *weimobapi.CallbackMsg) (response *weimobapi.CallbackResponse) { + globals.SugarLogger.Debugf("onOrderMsg:%s", utils.Format4Output(msg, true)) if msg.Event == weimobapi.MsgEventOrderStatusChange { if orderDetail, err := api.WeimobAPI.QueryOrderDetail2(msg.OrderNo, false); err == nil { if orderDetail.OrderStatus == weimobapi.OrderStatusFinished && orderDetail.PaymentAmount >= minCSOrderPayment { changeStoreSkusByOrder(orderDetail) } + } else { + response = weimobapi.Err2CallbackResponse(err, "") } } return response @@ -43,6 +46,7 @@ func changeStoreSkusByOrder(order *weimobapi.OrderDetail) { if len(storeList) == 1 { var skuBindInfos []*cms.StoreSkuBindInfo storeID := storeList[0].ID + globals.SugarLogger.Debugf("changeStoreSkusByOrder storeID:%d", storeID) for _, v := range order.ItemList { nameID := int(utils.Str2Int64WithDefault(v.SkuCode, 0)) unitPrice := v.OriginalPrice diff --git a/controllers/weimob_callback.go b/controllers/weimob_callback.go index 7989ae264..ff3c8b5b5 100644 --- a/controllers/weimob_callback.go +++ b/controllers/weimob_callback.go @@ -2,8 +2,8 @@ package controllers import ( "git.rosy.net.cn/baseapi/platformapi/weimobapi" - "git.rosy.net.cn/jx-callback/business/jxutils/tasks" "git.rosy.net.cn/jx-callback/business/cs" + "git.rosy.net.cn/jx-callback/business/jxutils/tasks" "git.rosy.net.cn/jx-callback/globals" "git.rosy.net.cn/jx-callback/globals/api" "github.com/astaxie/beego" @@ -15,12 +15,14 @@ type WeimobController struct { func (c *WeimobController) onCallbackMsg() { if true { //c.Ctx.Input.Method() == http.MethodPost { - callbackResponse := weimobapi.SuccessResponse msg, callbackResponse := api.WeimobAPI.GetCallbackMsg(c.Ctx.Input.RequestBody) if callbackResponse == nil { // callbackResponse = wsc.OnCallbackMsg(msg) callbackResponse = cs.OnCallbackMsg(msg) } + if callbackResponse == nil { + callbackResponse = weimobapi.SuccessResponse + } c.Data["json"] = callbackResponse c.ServeJSON() } else { From a2c3107ee06c2023b93b10bc68b050779a853479 Mon Sep 17 00:00:00 2001 From: gazebo Date: Thu, 31 Oct 2019 14:20:50 +0800 Subject: [PATCH 30/67] up --- business/cs/weimob_order.go | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/business/cs/weimob_order.go b/business/cs/weimob_order.go index 8d088336b..cdcb2e0ec 100644 --- a/business/cs/weimob_order.go +++ b/business/cs/weimob_order.go @@ -13,8 +13,8 @@ import ( ) const ( - minCSOrderPayment = 0 // 供货订单的最小金额 - maxUnitPrice = 3000 // 为防止误填单价,限制单价最高 + minCSOrderPayment = 0 // 供货订单的最小金额(单位为元) + maxUnitPrice = 3000 // 为防止误填单价,限制单价最高(单位为分) ) func OnCallbackMsg(msg *weimobapi.CallbackMsg) (response *weimobapi.CallbackResponse) { @@ -33,6 +33,7 @@ func onOrderMsg(msg *weimobapi.CallbackMsg) (response *weimobapi.CallbackRespons changeStoreSkusByOrder(orderDetail) } } else { + globals.SugarLogger.Debugf("onOrderMsg order:%s failed with err:%v", msg.OrderNo, err) response = weimobapi.Err2CallbackResponse(err, "") } } @@ -40,6 +41,7 @@ func onOrderMsg(msg *weimobapi.CallbackMsg) (response *weimobapi.CallbackRespons } func changeStoreSkusByOrder(order *weimobapi.OrderDetail) { + globals.SugarLogger.Debugf("changeStoreSkusByOrder order:%s", utils.Format4Output(order, true)) receiverMobile := order.DeliveryDetail.LogisticsDeliveryDetail.ReceiverMobile storeList, err := dao.GetStoreList(dao.GetDB(), nil, []string{receiverMobile}, "") if err != nil { @@ -64,9 +66,13 @@ func changeStoreSkusByOrder(order *weimobapi.OrderDetail) { } if len(skuBindInfos) > 0 { cms.UpdateStoreSkus(jxcontext.NewWithUserName(nil, utils.LimitStringLen(utils.Int64ToStr(order.OrderNo), 32), nil, nil), storeID, skuBindInfos, true, true) + } else { + globals.SugarLogger.Debugf("changeStoreSkusByOrder storeID:%d is empty", storeID) } } else { globals.SugarLogger.Infof("[运营],微商城订单:%s,手机:%s找不到唯一一个京西门店%d", order.OrderNo, receiverMobile, len(storeList)) } + } else { + globals.SugarLogger.Warnf("changeStoreSkusByOrder receiverMobile:%s failed with err:%v", receiverMobile, err) } } From 77ae01854fcc4e3ed9f5abb284d75842b4692fc9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=8B=8F=E5=B0=B9=E5=B2=9A?= <770236076@qq.com> Date: Thu, 31 Oct 2019 14:54:58 +0800 Subject: [PATCH 31/67] =?UTF-8?q?=E7=BB=9F=E8=AE=A1=E8=AE=A2=E5=8D=95?= =?UTF-8?q?=E6=8E=A5=E5=8F=A3=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- business/jxstore/report/report.go | 2 +- business/model/dao/report.go | 39 ++++++++++++++++++------------- 2 files changed, 24 insertions(+), 17 deletions(-) diff --git a/business/jxstore/report/report.go b/business/jxstore/report/report.go index 1258a6f21..78e13bd99 100644 --- a/business/jxstore/report/report.go +++ b/business/jxstore/report/report.go @@ -33,7 +33,7 @@ func GetStatisticsReportForOrders(ctx *jxcontext.Context, storeIDs []int, fromDa if StatisticsForOrdersExistsStore == nil { continue } - StatisticsForOrdersExists, err = dao.GetStatisticsForOrdersExist(db, id) + StatisticsForOrdersExists, err = dao.GetStatisticsForOrdersExist(db, id, fromDateParm, toDateParm) //若该门店存在此查询条件范围内的订单 if StatisticsForOrdersExists != nil { storeIDsExist = append(storeIDsExist, id) diff --git a/business/model/dao/report.go b/business/model/dao/report.go index 17617df38..b25e425ff 100644 --- a/business/model/dao/report.go +++ b/business/model/dao/report.go @@ -14,20 +14,20 @@ type StatisticsForOrdersExists struct { type StatisticsReportForOrdersList struct { StatisticsForOrdersExists - OrderCounts int `orm:"column(orderCounts)" json:"orderCounts"` //订单数 - SalePrice int `orm:"column(salePrice)" json:"salePrice"` //GMV(售卖价) - ActualPayPrice int `orm:"column(actualPayPrice)" json:"actualPayPrice"` //实付 - ShopPrice int `orm:"column(shopPrice)" json:"shopPrice"` //京西 - DiscountMoney int `orm:"column(discountMoney)" json:"discountMoney"` //优惠 - DesiredFee int `orm:"column(desiredFee)" json:"desiredFee"` //配送费 - DistanceFreightMoney int `orm:"column(distanceFreightMoney)" json:"distanceFreightMoney"` //远距离 - WaybillTipMoney int `orm:"column(waybillTipMoney)" json:"waybillTipMoney"` // - TotalShopMoney int `orm:"column(totalShopMoney)" json:"totalShopMoney"` - PmSubsidyMoney int `orm:"column(pmSubsidyMoney)" json:"pmSubsidyMoney"` - EarningPrice int `orm:"column(earningPrice)" json:"earningPrice"` - TotalGrossProfit int `orm:"column(totalGrossProfit)" json:"totalGrossProfit"` - ComGrossProfit float32 `orm:"column(comGrossProfit)" json:"comGrossProfit"` - CityManagerGrossProfit float32 `orm:"column(cityManagerGrossProfit)" json:"cityManagerGrossProfit"` + OrderCounts int `orm:"column(orderCounts)" json:"orderCounts"` //订单数 + SalePrice int `orm:"column(salePrice)" json:"salePrice"` //GMV(售卖价) + ActualPayPrice int `orm:"column(actualPayPrice)" json:"actualPayPrice"` //实付 + ShopPrice int `orm:"column(shopPrice)" json:"shopPrice"` //京西 + DiscountMoney int `orm:"column(discountMoney)" json:"discountMoney"` //优惠 + DesiredFee int `orm:"column(desiredFee)" json:"desiredFee"` //配送费 + DistanceFreightMoney int `orm:"column(distanceFreightMoney)" json:"distanceFreightMoney"` //远距离 + WaybillTipMoney int `orm:"column(waybillTipMoney)" json:"waybillTipMoney"` //小费 + TotalShopMoney int `orm:"column(totalShopMoney)" json:"totalShopMoney"` //平台结算 + PmSubsidyMoney int `orm:"column(pmSubsidyMoney)" json:"pmSubsidyMoney"` //平台补贴 + EarningPrice int `orm:"column(earningPrice)" json:"earningPrice"` //门店收益(预计收益) + TotalGrossProfit int `orm:"column(totalGrossProfit)" json:"totalGrossProfit"` //总毛利 + ComGrossProfit float32 `orm:"column(comGrossProfit)" json:"comGrossProfit"` //公司毛利 + CityManagerGrossProfit float32 `orm:"column(cityManagerGrossProfit)" json:"cityManagerGrossProfit"` //城市经理毛利 } //是否存在这个门店 @@ -47,15 +47,22 @@ func IsStoreExist(db *DaoDB, storeID int) (StatisticsForOrdersExists *Statistics } //查询条件内是否存在订单 -func GetStatisticsForOrdersExist(db *DaoDB, storeID int) (StatisticsForOrdersExists *StatisticsForOrdersExists, err error) { +func GetStatisticsForOrdersExist(db *DaoDB, storeID int, fromDate time.Time, toDate time.Time) (StatisticsForOrdersExists *StatisticsForOrdersExists, err error) { sql := ` SELECT store_id FROM goods_order a LEFT JOIN waybill b ON IF(a.waybill_vendor_id = -1,a.vendor_order_id,a.vendor_waybill_id) = b.vendor_waybill_id WHERE a.store_id = ? - GROUP BY a.store_id ` sqlParams := []interface{}{} sqlParams = append(sqlParams, storeID) + if !utils.IsTimeZero(fromDate) && !utils.IsTimeZero(toDate) { + sql += `AND a.order_created_at BETWEEN ? and ? + ` + sqlParams = append(sqlParams, fromDate, toDate) + } + sql += ` + GROUP BY a.store_id + ` if err = GetRow(db, &StatisticsForOrdersExists, sql, sqlParams...); err == nil { return StatisticsForOrdersExists, nil From 4f8ded015340f619ceec5026d9e7348f712db1f9 Mon Sep 17 00:00:00 2001 From: gazebo Date: Thu, 31 Oct 2019 15:05:55 +0800 Subject: [PATCH 32/67] =?UTF-8?q?=E5=BE=AE=E7=9B=9F=E4=B8=AD=EF=BC=8C?= =?UTF-8?q?=E6=A0=B9=E6=8D=AE=E6=B6=88=E6=81=AF=E4=B8=AD=E7=9A=84orderStat?= =?UTF-8?q?us=E5=85=88=E5=88=A4=E6=96=AD=E8=AE=A2=E5=8D=95=E7=8A=B6?= =?UTF-8?q?=E6=80=81=EF=BC=8C=E9=81=BF=E5=85=8D=E4=B8=8D=E5=BF=85=E8=A6=81?= =?UTF-8?q?=E7=9A=84QueryOrderDetail2=E7=9A=84=E8=B0=83=E7=94=A8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- business/cs/weimob_order.go | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/business/cs/weimob_order.go b/business/cs/weimob_order.go index cdcb2e0ec..32189ab8b 100644 --- a/business/cs/weimob_order.go +++ b/business/cs/weimob_order.go @@ -28,13 +28,15 @@ func OnCallbackMsg(msg *weimobapi.CallbackMsg) (response *weimobapi.CallbackResp func onOrderMsg(msg *weimobapi.CallbackMsg) (response *weimobapi.CallbackResponse) { globals.SugarLogger.Debugf("onOrderMsg:%s", utils.Format4Output(msg, true)) if msg.Event == weimobapi.MsgEventOrderStatusChange { - if orderDetail, err := api.WeimobAPI.QueryOrderDetail2(msg.OrderNo, false); err == nil { - if orderDetail.OrderStatus == weimobapi.OrderStatusFinished && orderDetail.PaymentAmount >= minCSOrderPayment { - changeStoreSkusByOrder(orderDetail) + if utils.ForceInterface2Int64(msg.MsgBody["orderStatus"]) == weimobapi.MsgOrderStatusFinished { + if orderDetail, err := api.WeimobAPI.QueryOrderDetail2(msg.OrderNo, false); err == nil { + if orderDetail.OrderStatus == weimobapi.OrderStatusFinished && orderDetail.PaymentAmount >= minCSOrderPayment { + changeStoreSkusByOrder(orderDetail) + } + } else { + globals.SugarLogger.Debugf("onOrderMsg order:%s failed with err:%v", msg.OrderNo, err) + response = weimobapi.Err2CallbackResponse(err, "") } - } else { - globals.SugarLogger.Debugf("onOrderMsg order:%s failed with err:%v", msg.OrderNo, err) - response = weimobapi.Err2CallbackResponse(err, "") } } return response @@ -43,8 +45,7 @@ func onOrderMsg(msg *weimobapi.CallbackMsg) (response *weimobapi.CallbackRespons func changeStoreSkusByOrder(order *weimobapi.OrderDetail) { globals.SugarLogger.Debugf("changeStoreSkusByOrder order:%s", utils.Format4Output(order, true)) receiverMobile := order.DeliveryDetail.LogisticsDeliveryDetail.ReceiverMobile - storeList, err := dao.GetStoreList(dao.GetDB(), nil, []string{receiverMobile}, "") - if err != nil { + if storeList, err := dao.GetStoreList(dao.GetDB(), nil, []string{receiverMobile}, ""); err == nil { if len(storeList) == 1 { var skuBindInfos []*cms.StoreSkuBindInfo storeID := storeList[0].ID From 36a505fb32040e953164e5bd7fd1e7b52891a4a7 Mon Sep 17 00:00:00 2001 From: gazebo Date: Thu, 31 Oct 2019 15:49:17 +0800 Subject: [PATCH 33/67] =?UTF-8?q?=E5=8F=AA=E6=9C=89=E5=BA=93=E4=B8=AD?= =?UTF-8?q?=E5=8F=AF=E5=94=AE=E7=9A=84=E5=95=86=E5=93=81=E6=89=8D=E5=8F=AF?= =?UTF-8?q?=E4=BB=A5=E5=85=B3=E6=B3=A8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- business/jxstore/cms/store_sku.go | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) diff --git a/business/jxstore/cms/store_sku.go b/business/jxstore/cms/store_sku.go index cc69d738d..25d9e9bf1 100644 --- a/business/jxstore/cms/store_sku.go +++ b/business/jxstore/cms/store_sku.go @@ -123,12 +123,14 @@ type StoreSkuBindInfo struct { type tStoreSkuBindAndSpec struct { model.StoreSkuBind - Name string - SpecQuality float32 - SpecUnit string - SkuNamePrice int - SkuNameUnit string - RealSkuID int `orm:"column(real_sku_id)"` + SkuStatus int + SkuNameStatus int + Name string + SpecQuality float32 + SpecUnit string + SkuNamePrice int + SkuNameUnit string + RealSkuID int `orm:"column(real_sku_id)"` } type SkuSaleInfo struct { @@ -924,12 +926,12 @@ func updateStoresSkusWithoutSync(ctx *jxcontext.Context, db *dao.DaoDB, storeIDs sql := ` SELECT t2.*, - t1.id real_sku_id, t1.spec_quality, t1.spec_unit,` + t1.id real_sku_id, t1.status sku_status, t1.spec_quality, t1.spec_unit,` if needGetExistingUnitPrice { sql += " IF(t5.unit_price > 0, t5.unit_price, t3.price) sku_name_price," } sql += ` - t3.unit sku_name_unit, t3.name + t3.unit sku_name_unit, t3.name, t3.status sku_name_status FROM sku t1 JOIN store ts ON ts.id = ? AND ts.deleted_at = ? LEFT JOIN store_sku_bind t2 ON t2.sku_id = t1.id AND t2.store_id = ts.id AND t2.deleted_at = ? @@ -982,7 +984,7 @@ func updateStoresSkusWithoutSync(ctx *jxcontext.Context, db *dao.DaoDB, storeIDs // globals.SugarLogger.Debug(utils.Format4Output(inSkuBind, false)) var skuBind *model.StoreSkuBind if v.ID == 0 { - if skuBindInfo.IsFocus == 1 { + if skuBindInfo.IsFocus == 1 && v.SkuNameStatus == model.SkuStatusNormal && v.SkuStatus == model.SkuStatusNormal { skuBind = &model.StoreSkuBind{ StoreID: storeID, SkuID: v.RealSkuID, From 85f3c9009e6f583dc9bb6f590518ee52c0756eca Mon Sep 17 00:00:00 2001 From: gazebo Date: Thu, 31 Oct 2019 16:38:36 +0800 Subject: [PATCH 34/67] =?UTF-8?q?=E5=BE=AE=E5=95=86=E5=9F=8E=E8=AE=A2?= =?UTF-8?q?=E5=8D=95=E8=87=AA=E5=8A=A8=E4=BF=AE=E6=94=B9=E9=97=A8=E5=BA=97?= =?UTF-8?q?=E4=BB=B7=E6=A0=BC=E6=97=B6=EF=BC=8C=E7=94=B5=E8=AF=9D=E5=8F=B7?= =?UTF-8?q?=E7=A0=81=E5=8C=B9=E9=85=8D=E6=97=B6=EF=BC=8C=E4=B9=9F=E8=A6=81?= =?UTF-8?q?=E6=9F=A5=E5=88=86=E7=BB=84=20=E5=A4=9A=E4=BA=8E=E4=B8=80?= =?UTF-8?q?=E4=B8=AA=E9=97=A8=E5=BA=97=E5=8C=B9=E9=85=8D=E6=97=B6=EF=BC=8C?= =?UTF-8?q?=E5=8F=AA=E5=A4=84=E7=90=86=E7=AC=AC=E4=B8=80=E4=B8=AA=EF=BC=8C?= =?UTF-8?q?=E4=B8=94=E4=B8=8D=E6=8A=A5=E9=94=99?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- business/cs/weimob_order.go | 29 +++++++++++++++++++++++++++-- business/cs/weimob_order_test.go | 24 ++++++++++++++++++++++++ 2 files changed, 51 insertions(+), 2 deletions(-) create mode 100644 business/cs/weimob_order_test.go diff --git a/business/cs/weimob_order.go b/business/cs/weimob_order.go index 32189ab8b..c5f0a0ac2 100644 --- a/business/cs/weimob_order.go +++ b/business/cs/weimob_order.go @@ -3,6 +3,7 @@ package cs import ( "git.rosy.net.cn/baseapi/platformapi/weimobapi" "git.rosy.net.cn/baseapi/utils" + "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/jxutils/jxcontext" @@ -45,8 +46,8 @@ func onOrderMsg(msg *weimobapi.CallbackMsg) (response *weimobapi.CallbackRespons func changeStoreSkusByOrder(order *weimobapi.OrderDetail) { globals.SugarLogger.Debugf("changeStoreSkusByOrder order:%s", utils.Format4Output(order, true)) receiverMobile := order.DeliveryDetail.LogisticsDeliveryDetail.ReceiverMobile - if storeList, err := dao.GetStoreList(dao.GetDB(), nil, []string{receiverMobile}, ""); err == nil { - if len(storeList) == 1 { + if storeList, err := GetStoreList4Mobile(dao.GetDB(), []string{receiverMobile}); err == nil { + if len(storeList) >= 1 { var skuBindInfos []*cms.StoreSkuBindInfo storeID := storeList[0].ID globals.SugarLogger.Debugf("changeStoreSkusByOrder storeID:%d", storeID) @@ -77,3 +78,27 @@ func changeStoreSkusByOrder(order *weimobapi.OrderDetail) { globals.SugarLogger.Warnf("changeStoreSkusByOrder receiverMobile:%s failed with err:%v", receiverMobile, err) } } + +func GetStoreList4Mobile(db *dao.DaoDB, mobileList []string) (storeList []*model.Store, err error) { + sql := ` + SELECT t1.* + FROM store t1 + WHERE t1.deleted_at = ?` + sqlParams := []interface{}{ + utils.DefaultTimeValue, + } + if len(mobileList) > 0 { + questionMarks := dao.GenQuestionMarks(len(mobileList)) + sql += " AND (t1.tel1 IN (" + questionMarks + ") OR t1.tel2 IN (" + questionMarks + `) + OR (SELECT + COUNT(*) + FROM casbin_rule t2 + JOIN user t3 ON t3.user_id = t2.v0 AND t3.mobile IN (` + questionMarks + `) + WHERE t2.v1 = CONCAT(?, t1.id) + ) > 0) + ` + sqlParams = append(sqlParams, mobileList, mobileList, mobileList, autils.NewStoreBossRole(-1).GetFullName()) + } + err = dao.GetRows(db, &storeList, sql, sqlParams...) + return storeList, err +} diff --git a/business/cs/weimob_order_test.go b/business/cs/weimob_order_test.go new file mode 100644 index 000000000..4e91a3fa6 --- /dev/null +++ b/business/cs/weimob_order_test.go @@ -0,0 +1,24 @@ +package cs + +import ( + "testing" + + "git.rosy.net.cn/baseapi/utils" + "git.rosy.net.cn/jx-callback/business/model/dao" + "git.rosy.net.cn/jx-callback/globals/api2" + "git.rosy.net.cn/jx-callback/globals/testinit" +) + +func init() { + testinit.Init() + api2.Init() +} + +func TestGetStoreList4Mobile(t *testing.T) { + storeList, err := GetStoreList4Mobile(dao.GetDB(), []string{"18180948107"}) + if err != nil { + t.Fatal(err) + } + t.Log(utils.Format4Output(storeList, false)) + t.Log(len(storeList)) +} From e1945255932c9751b870848812f9652f7baa8dfa Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=8B=8F=E5=B0=B9=E5=B2=9A?= <770236076@qq.com> Date: Thu, 31 Oct 2019 16:47:07 +0800 Subject: [PATCH 35/67] =?UTF-8?q?=E7=BB=9F=E8=AE=A1=E8=AE=A2=E5=8D=95?= =?UTF-8?q?=E6=8E=A5=E5=8F=A3=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- business/jxstore/report/report.go | 50 +---------- business/model/dao/report.go | 144 ++++++++++++++---------------- controllers/jx_report.go | 15 ++++ 3 files changed, 84 insertions(+), 125 deletions(-) diff --git a/business/jxstore/report/report.go b/business/jxstore/report/report.go index 78e13bd99..94a5bd5ff 100644 --- a/business/jxstore/report/report.go +++ b/business/jxstore/report/report.go @@ -10,16 +10,7 @@ import ( "git.rosy.net.cn/jx-callback/business/model/dao" ) -var ( - storeIDsExist []int - storeIDsNotExist []int - StatisticsForOrdersExists *dao.StatisticsForOrdersExists - StatisticsForOrdersExistsStore *dao.StatisticsForOrdersExists -) - func GetStatisticsReportForOrders(ctx *jxcontext.Context, storeIDs []int, fromDate string, toDate string) (statisticsReportForOrdersList []*dao.StatisticsReportForOrdersList, err error) { - storeIDsExist = storeIDsExist[0:0] - storeIDsNotExist = storeIDsNotExist[0:0] db := dao.GetDB() fromDateParm := utils.Str2Time(fromDate) toDateParm := utils.Str2Time(toDate) @@ -27,45 +18,6 @@ func GetStatisticsReportForOrders(ctx *jxcontext.Context, storeIDs []int, fromDa if math.Ceil(toDateParm.Sub(fromDateParm).Hours()/24) > 92 { return nil, errors.New(fmt.Sprintf("查询间隔时间不允许大于3个月!: 时间范围:[%v] 至 [%v]", fromDate, toDate)) } - //若入参中,不存在的店则不显示,存在的店但无订单的显示0 - for _, id := range storeIDs { - StatisticsForOrdersExistsStore, err = dao.IsStoreExist(db, id) - if StatisticsForOrdersExistsStore == nil { - continue - } - StatisticsForOrdersExists, err = dao.GetStatisticsForOrdersExist(db, id, fromDateParm, toDateParm) - //若该门店存在此查询条件范围内的订单 - if StatisticsForOrdersExists != nil { - storeIDsExist = append(storeIDsExist, id) - } else { - storeIDsNotExist = append(storeIDsNotExist, id) - } - } - statisticsReportForOrdersList, err = dao.GetStatisticsReportForOrders(db, storeIDsExist, fromDateParm, toDateParm) - if storeIDsNotExist != nil { - for _, v := range storeIDsNotExist { - tempStruct1 := &dao.StatisticsForOrdersExists{ - StoreID: v, - } - tempStruct2 := &dao.StatisticsReportForOrdersList{ - StatisticsForOrdersExists: *tempStruct1, - OrderCounts: 0, - SalePrice: 0, - ActualPayPrice: 0, - ShopPrice: 0, - DiscountMoney: 0, - DesiredFee: 0, - DistanceFreightMoney: 0, - WaybillTipMoney: 0, - TotalShopMoney: 0, - PmSubsidyMoney: 0, - EarningPrice: 0, - TotalGrossProfit: 0, - ComGrossProfit: 0, - CityManagerGrossProfit: 0, - } - statisticsReportForOrdersList = append(statisticsReportForOrdersList, tempStruct2) - } - } + statisticsReportForOrdersList, err = dao.GetStatisticsReportForOrders(db, storeIDs, fromDateParm, toDateParm) return statisticsReportForOrdersList, err } diff --git a/business/model/dao/report.go b/business/model/dao/report.go index b25e425ff..2fe33a08f 100644 --- a/business/model/dao/report.go +++ b/business/model/dao/report.go @@ -9,65 +9,29 @@ import ( ) type StatisticsForOrdersExists struct { - StoreID int `orm:"column(storeID)" json:"storeID"` + StoreID int `orm:"column(store_id)" json:"storeId"` } type StatisticsReportForOrdersList struct { StatisticsForOrdersExists - OrderCounts int `orm:"column(orderCounts)" json:"orderCounts"` //订单数 - SalePrice int `orm:"column(salePrice)" json:"salePrice"` //GMV(售卖价) - ActualPayPrice int `orm:"column(actualPayPrice)" json:"actualPayPrice"` //实付 - ShopPrice int `orm:"column(shopPrice)" json:"shopPrice"` //京西 - DiscountMoney int `orm:"column(discountMoney)" json:"discountMoney"` //优惠 - DesiredFee int `orm:"column(desiredFee)" json:"desiredFee"` //配送费 - DistanceFreightMoney int `orm:"column(distanceFreightMoney)" json:"distanceFreightMoney"` //远距离 - WaybillTipMoney int `orm:"column(waybillTipMoney)" json:"waybillTipMoney"` //小费 - TotalShopMoney int `orm:"column(totalShopMoney)" json:"totalShopMoney"` //平台结算 - PmSubsidyMoney int `orm:"column(pmSubsidyMoney)" json:"pmSubsidyMoney"` //平台补贴 - EarningPrice int `orm:"column(earningPrice)" json:"earningPrice"` //门店收益(预计收益) - TotalGrossProfit int `orm:"column(totalGrossProfit)" json:"totalGrossProfit"` //总毛利 - ComGrossProfit float32 `orm:"column(comGrossProfit)" json:"comGrossProfit"` //公司毛利 - CityManagerGrossProfit float32 `orm:"column(cityManagerGrossProfit)" json:"cityManagerGrossProfit"` //城市经理毛利 -} - -//是否存在这个门店 -func IsStoreExist(db *DaoDB, storeID int) (StatisticsForOrdersExists *StatisticsForOrdersExists, err error) { - sql := ` - SELECT * - FROM store - WHERE id = ? - ` - sqlParams := []interface{}{} - sqlParams = append(sqlParams, storeID) - - if err = GetRow(db, &StatisticsForOrdersExists, sql, sqlParams...); err == nil { - return StatisticsForOrdersExists, nil - } - return nil, err -} - -//查询条件内是否存在订单 -func GetStatisticsForOrdersExist(db *DaoDB, storeID int, fromDate time.Time, toDate time.Time) (StatisticsForOrdersExists *StatisticsForOrdersExists, err error) { - sql := ` - SELECT store_id - FROM goods_order a LEFT JOIN waybill b ON IF(a.waybill_vendor_id = -1,a.vendor_order_id,a.vendor_waybill_id) = b.vendor_waybill_id - WHERE a.store_id = ? - ` - sqlParams := []interface{}{} - sqlParams = append(sqlParams, storeID) - if !utils.IsTimeZero(fromDate) && !utils.IsTimeZero(toDate) { - sql += `AND a.order_created_at BETWEEN ? and ? - ` - sqlParams = append(sqlParams, fromDate, toDate) - } - sql += ` - GROUP BY a.store_id - ` - - if err = GetRow(db, &StatisticsForOrdersExists, sql, sqlParams...); err == nil { - return StatisticsForOrdersExists, nil - } - return nil, err + StoreName string `json:"name"` //门店名 + OrderCounts int `json:"orderCounts"` //订单数 + SalePrice int `json:"salePrice"` //GMV(售卖价) + ActualPayPrice int `json:"actualPayPrice"` //实付 + ShopPrice int `json:"shopPrice"` //京西 + DiscountMoney int `json:"discountMoney"` //优惠 + DesiredFee int `json:"desiredFee"` //配送费 + DistanceFreightMoney int `json:"distanceFreightMoney"` //远距离 + WaybillTipMoney int `json:"waybillTipMoney"` //小费 + TotalShopMoney int `json:"totalShopMoney"` //平台结算 + PmSubsidyMoney int `json:"pmSubsidyMoney"` //平台补贴 + EarningPrice int `json:"earningPrice"` //门店收益(预计收益) + TotalGrossProfit int `json:"totalGrossProfit"` //总毛利 + ComGrossProfit float32 `json:"comGrossProfit"` //公司毛利 + CityManagerGrossProfit float32 `json:"cityManagerGrossProfit"` //城市经理毛利 + MarketManName string `json:"marketManName"` //市场负责人 + OperatorName string `json:"operatorName"` //运营负责人 + OperatorName2 string `json:"operatorName2"` } //查询统计订单信息 @@ -75,26 +39,49 @@ func GetStatisticsReportForOrders(db *DaoDB, storeIDs []int, fromDate time.Time, //排除已取消的订单 status := strconv.Itoa(model.OrderStatusCanceled) sql := ` - SELECT s.*, - if(c.jx_brand_fee_factor = 0 AND c.market_add_fee_factor = 0,totalGrossProfit,(totalGrossProfit*c.jx_brand_fee_factor)/(c.jx_brand_fee_factor+market_add_fee_factor)) comGrossProfit, - if(c.jx_brand_fee_factor = 0 AND c.market_add_fee_factor = 0,0,(totalGrossProfit*c.market_add_fee_factor)/(c.jx_brand_fee_factor+market_add_fee_factor)) cityManagerGrossProfit - FROM store c,( - SELECT - a.store_id storeID, - count(*) orderCounts, - sum(sale_price) salePrice, - sum(actual_pay_price) actualPayPrice, - sum(shop_price) shopPrice, - sum(discount_money) discountMoney, - sum(desired_fee) desiredFee, - sum(distance_freight_money) distanceFreightMoney, - sum(waybill_tip_money) waybillTipMoney, - sum(total_shop_money) totalShopMoney, - sum(pm_subsidy_money) pmSubsidyMoney, - sum(earning_price) EarningPrice, - sum(total_shop_money-earning_price-desired_fee-distance_freight_money-waybill_tip_money-80) totalGrossProfit - FROM goods_order a LEFT JOIN waybill b on if(a.waybill_vendor_id = -1,a.vendor_order_id,a.vendor_waybill_id) = b.vendor_waybill_id - WHERE a.status != ` + status + ` + SELECT + c.id store_id, + c.name store_name, + s.orderCounts order_counts, + s.salePrice sale_price, + s.actualPayPrice actual_pay_price, + s.shopPrice shop_price, + s.discountMoney discount_money, + s.desiredFee desired_fee, + s.distanceFreightMoney distance_freight_money, + s.waybillTipMoney waybill_tip_money, + s.totalShopMoney total_shop_money, + s.pmSubsidyMoney pm_subsidy_money, + s.EarningPrice earning_price, + s.totalGrossProfit total_gross_profit, + IF(c.jx_brand_fee_factor = 0 AND c.market_add_fee_factor = 0,totalGrossProfit,(totalGrossProfit*c.jx_brand_fee_factor)/(c.jx_brand_fee_factor+market_add_fee_factor)) com_grossProfit, + IF(c.jx_brand_fee_factor = 0 AND c.market_add_fee_factor = 0,0,(totalGrossProfit*c.market_add_fee_factor)/(c.jx_brand_fee_factor+market_add_fee_factor)) city_manager_gross_profit, + IF(mm.name <> '', mm.name, mm.user_id2) market_man_name, + IF(om.name <> '', om.name, om.user_id2) operator_name, + IF(om2.name <> '', om2.name, om2.user_id2) operator_name2 + FROM store c + LEFT JOIN user mm ON mm.mobile <> '' AND mm.mobile = c.market_man_phone + LEFT JOIN user om ON om.mobile <> '' AND om.mobile = c.operator_phone + LEFT JOIN user om2 ON om2.mobile <> '' AND om2.mobile = c.operator_phone2 + LEFT JOIN + ( + SELECT + a.store_id storeID, + COUNT(*) orderCounts, + SUM(sale_price) salePrice, + SUM(actual_pay_price) actualPayPrice, + SUM(shop_price) shopPrice, + SUM(discount_money) discountMoney, + SUM(desired_fee) desiredFee, + SUM(distance_freight_money) distanceFreightMoney, + SUM(waybill_tip_money) waybillTipMoney, + SUM(total_shop_money) totalShopMoney, + SUM(pm_subsidy_money) pmSubsidyMoney, + SUM(earning_price) EarningPrice, + SUM(total_shop_money-earning_price-desired_fee-distance_freight_money-waybill_tip_money-80) totalGrossProfit + FROM goods_order a + LEFT JOIN waybill b ON IF(a.waybill_vendor_id = -1,a.vendor_order_id,a.vendor_waybill_id) = b.vendor_waybill_id + WHERE a.status != ` + status + ` ` sqlParams := []interface{}{} if !utils.IsTimeZero(fromDate) && !utils.IsTimeZero(toDate) { @@ -110,8 +97,13 @@ func GetStatisticsReportForOrders(db *DaoDB, storeIDs []int, fromDate time.Time, sql += ` GROUP BY a.store_id )s - WHERE s.storeID = c.id + ON s.storeID = c.id ` + if len(storeIDs) > 0 { + sql += `WHERE c.id IN (` + GenQuestionMarks(len(storeIDs)) + `) + ` + sqlParams = append(sqlParams, storeIDs) + } if err = GetRows(db, &statisticsReportForOrdersList, sql, sqlParams...); err == nil { return statisticsReportForOrdersList, nil } diff --git a/controllers/jx_report.go b/controllers/jx_report.go index 9450f576e..db0886210 100644 --- a/controllers/jx_report.go +++ b/controllers/jx_report.go @@ -29,3 +29,18 @@ func (c *ReportController) StatisticsReportForOrders() { return retVal, "", err }) } + +// @Title 查询售后单统计信息 +// @Description 根据门店idlist和时间范围查询 +// @Param token header string true "认证token" +// @Param storeIDs formData string true "京西门店ID列表[1,2,3]" +// @Param fromDate formData string true "开始日期(包含),格式(2006-01-02 00:00:00)" +// @Param toDate formData string true "结束日期(包含),格式(2006-01-02 00:00:00)" +// @Success 200 {object} controllers.CallResult +// @Failure 200 {object} controllers.CallResult +// @router /StatisticsReportForAfsOrders [post] +func (c *ReportController) StatisticsReportForAfsOrders() { + c.callStatisticsReportForAfsOrders(func(params *tReportStatisticsReportForAfsOrdersParams) (retVal interface{}, errCode string, err error) { + return retVal, "", err + }) +} From dca074009805b135468df03e65097259437f3291 Mon Sep 17 00:00:00 2001 From: gazebo Date: Thu, 31 Oct 2019 17:27:08 +0800 Subject: [PATCH 36/67] =?UTF-8?q?=E5=BE=AE=E5=95=86=E5=9F=8E=E8=AE=A2?= =?UTF-8?q?=E5=8D=95=E9=A9=B1=E5=8A=A8=E6=94=B9=E4=BB=B7=E7=94=A8=E6=88=90?= =?UTF-8?q?=E6=9C=AC=E4=BB=B7CostPrice?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- business/cs/weimob_order.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/business/cs/weimob_order.go b/business/cs/weimob_order.go index c5f0a0ac2..932ff1d12 100644 --- a/business/cs/weimob_order.go +++ b/business/cs/weimob_order.go @@ -53,7 +53,7 @@ func changeStoreSkusByOrder(order *weimobapi.OrderDetail) { globals.SugarLogger.Debugf("changeStoreSkusByOrder storeID:%d", storeID) for _, v := range order.ItemList { nameID := int(utils.Str2Int64WithDefault(v.SkuCode, 0)) - unitPrice := v.OriginalPrice + unitPrice := v.CostPrice if nameID > 0 && (unitPrice > 0 && unitPrice < maxUnitPrice) { skuBindInfos = append(skuBindInfos, &cms.StoreSkuBindInfo{ StoreID: storeID, From 7df7ba6242dd681b7bc79846a9b5fee790dddb99 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=8B=8F=E5=B0=B9=E5=B2=9A?= <770236076@qq.com> Date: Thu, 31 Oct 2019 17:31:40 +0800 Subject: [PATCH 37/67] =?UTF-8?q?=E5=94=AE=E5=90=8E=E5=8D=95=E7=BB=9F?= =?UTF-8?q?=E8=AE=A1=E6=8E=A5=E5=8F=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .gitignore | 1 + business/jxstore/report/report.go | 12 +++++ business/model/dao/report.go | 80 ++++++++++++++++++++++++++++++- controllers/jx_report.go | 4 ++ 4 files changed, 95 insertions(+), 2 deletions(-) diff --git a/.gitignore b/.gitignore index 093f63d3f..14f76dcee 100644 --- a/.gitignore +++ b/.gitignore @@ -14,3 +14,4 @@ param_parser.go *.o *.exe *.exe~ +.vscode diff --git a/business/jxstore/report/report.go b/business/jxstore/report/report.go index 94a5bd5ff..0538ea1ab 100644 --- a/business/jxstore/report/report.go +++ b/business/jxstore/report/report.go @@ -21,3 +21,15 @@ func GetStatisticsReportForOrders(ctx *jxcontext.Context, storeIDs []int, fromDa statisticsReportForOrdersList, err = dao.GetStatisticsReportForOrders(db, storeIDs, fromDateParm, toDateParm) return statisticsReportForOrdersList, err } + +func GetStatisticsReportForAfsOrders(ctx *jxcontext.Context, storeIDs []int, fromDate string, toDate string) (statisticsReportForOrdersList []*dao.StatisticsReportForOrdersList, err error) { + db := dao.GetDB() + fromDateParm := utils.Str2Time(fromDate) + toDateParm := utils.Str2Time(toDate) + //若时间间隔大于3个月则不允许查询 + if math.Ceil(toDateParm.Sub(fromDateParm).Hours()/24) > 92 { + return nil, errors.New(fmt.Sprintf("查询间隔时间不允许大于3个月!: 时间范围:[%v] 至 [%v]", fromDate, toDate)) + } + statisticsReportForOrdersList, err = dao.GetGetStatisticsReportForAfsOrders(db, storeIDs, fromDateParm, toDateParm) + return statisticsReportForOrdersList, err +} diff --git a/business/model/dao/report.go b/business/model/dao/report.go index 2fe33a08f..1fdf80e60 100644 --- a/business/model/dao/report.go +++ b/business/model/dao/report.go @@ -85,12 +85,88 @@ func GetStatisticsReportForOrders(db *DaoDB, storeIDs []int, fromDate time.Time, ` sqlParams := []interface{}{} if !utils.IsTimeZero(fromDate) && !utils.IsTimeZero(toDate) { - sql += `AND a.order_created_at BETWEEN ? and ? + sql += `AND a.order_created_at BETWEEN ? AND ? ` sqlParams = append(sqlParams, fromDate, toDate) } if len(storeIDs) > 0 { - sql += `AND a.store_id in(` + GenQuestionMarks(len(storeIDs)) + `) + sql += `AND a.store_id IN(` + GenQuestionMarks(len(storeIDs)) + `) + ` + sqlParams = append(sqlParams, storeIDs) + } + sql += ` + GROUP BY a.store_id + )s + ON s.storeID = c.id + ` + if len(storeIDs) > 0 { + sql += `WHERE c.id IN (` + GenQuestionMarks(len(storeIDs)) + `) + ` + sqlParams = append(sqlParams, storeIDs) + } + if err = GetRows(db, &statisticsReportForOrdersList, sql, sqlParams...); err == nil { + return statisticsReportForOrdersList, nil + } + return nil, err +} + +//查询统计售后单信息 +func GetGetStatisticsReportForAfsOrders(db *DaoDB, storeIDs []int, fromDate time.Time, toDate time.Time) (statisticsReportForOrdersList []*StatisticsReportForOrdersList, err error) { + //排除已取消的订单 + status := strconv.Itoa(model.OrderStatusCanceled) + sql := ` + SELECT + c.id store_id, + c.name store_name, + s.orderCounts order_counts, + s.salePrice sale_price, + s.actualPayPrice actual_pay_price, + s.shopPrice shop_price, + s.discountMoney discount_money, + s.desiredFee desired_fee, + s.distanceFreightMoney distance_freight_money, + s.waybillTipMoney waybill_tip_money, + s.totalShopMoney total_shop_money, + s.pmSubsidyMoney pm_subsidy_money, + s.EarningPrice earning_price, + s.totalGrossProfit total_gross_profit, + IF(c.jx_brand_fee_factor = 0 AND c.market_add_fee_factor = 0,totalGrossProfit,(totalGrossProfit*c.jx_brand_fee_factor)/(c.jx_brand_fee_factor+market_add_fee_factor)) com_grossProfit, + IF(c.jx_brand_fee_factor = 0 AND c.market_add_fee_factor = 0,0,(totalGrossProfit*c.market_add_fee_factor)/(c.jx_brand_fee_factor+market_add_fee_factor)) city_manager_gross_profit, + IF(mm.name <> '', mm.name, mm.user_id2) market_man_name, + IF(om.name <> '', om.name, om.user_id2) operator_name, + IF(om2.name <> '', om2.name, om2.user_id2) operator_name2 + FROM store c + LEFT JOIN user mm ON mm.mobile <> '' AND mm.mobile = c.market_man_phone + LEFT JOIN user om ON om.mobile <> '' AND om.mobile = c.operator_phone + LEFT JOIN user om2 ON om2.mobile <> '' AND om2.mobile = c.operator_phone2 + LEFT JOIN + ( + SELECT + a.store_id storeID, + COUNT(*) orderCounts, + SUM(sale_price) salePrice, + SUM(actual_pay_price) actualPayPrice, + SUM(shop_price) shopPrice, + SUM(discount_money) discountMoney, + SUM(afs_freight_money) desiredFee, + SUM(distance_freight_money) distanceFreightMoney, + SUM(waybill_tip_money) waybillTipMoney, + SUM(total_shop_money) totalShopMoney, + SUM(b.pm_subsidy_money) pmSubsidyMoney, + SUM(earning_price) EarningPrice, + SUM(total_shop_money-earning_price-afs_freight_money-distance_freight_money-waybill_tip_money-80) totalGrossProfit + FROM goods_order a,afs_order b + WHERE a.vendor_order_id = b.vendor_order_id + AND a.status != ` + status + ` + ` + sqlParams := []interface{}{} + if !utils.IsTimeZero(fromDate) && !utils.IsTimeZero(toDate) { + sql += `AND a.order_created_at BETWEEN ? AND ? + ` + sqlParams = append(sqlParams, fromDate, toDate) + } + if len(storeIDs) > 0 { + sql += `AND a.store_id IN(` + GenQuestionMarks(len(storeIDs)) + `) ` sqlParams = append(sqlParams, storeIDs) } diff --git a/controllers/jx_report.go b/controllers/jx_report.go index db0886210..f839a14cc 100644 --- a/controllers/jx_report.go +++ b/controllers/jx_report.go @@ -41,6 +41,10 @@ func (c *ReportController) StatisticsReportForOrders() { // @router /StatisticsReportForAfsOrders [post] func (c *ReportController) StatisticsReportForAfsOrders() { c.callStatisticsReportForAfsOrders(func(params *tReportStatisticsReportForAfsOrdersParams) (retVal interface{}, errCode string, err error) { + var storeIDList []int + if err = jxutils.Strings2Objs(params.StoreIDs, &storeIDList); err == nil { + retVal, err = report.GetStatisticsReportForAfsOrders(params.Ctx, storeIDList, params.FromDate, params.ToDate) + } return retVal, "", err }) } From 4a740c11ea0c1cfe7e041feff8ff71a5e2d3c221 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=8B=8F=E5=B0=B9=E5=B2=9A?= <770236076@qq.com> Date: Thu, 31 Oct 2019 17:33:15 +0800 Subject: [PATCH 38/67] .gitignore --- .gitignore | 1 + 1 file changed, 1 insertion(+) diff --git a/.gitignore b/.gitignore index 14f76dcee..2cfdc1b7e 100644 --- a/.gitignore +++ b/.gitignore @@ -15,3 +15,4 @@ param_parser.go *.exe *.exe~ .vscode +app.conf \ No newline at end of file From 4963b6875875ce46b129326ccd894ffc36710e35 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=8B=8F=E5=B0=B9=E5=B2=9A?= <770236076@qq.com> Date: Thu, 31 Oct 2019 17:43:50 +0800 Subject: [PATCH 39/67] =?UTF-8?q?=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .gitignore | 1 - routers/commentsRouter_controllers.go | 28 ++++++++++++++++++--------- 2 files changed, 19 insertions(+), 10 deletions(-) diff --git a/.gitignore b/.gitignore index 2cfdc1b7e..14f76dcee 100644 --- a/.gitignore +++ b/.gitignore @@ -15,4 +15,3 @@ param_parser.go *.exe *.exe~ .vscode -app.conf \ No newline at end of file diff --git a/routers/commentsRouter_controllers.go b/routers/commentsRouter_controllers.go index 5dca35224..c8a8106c4 100644 --- a/routers/commentsRouter_controllers.go +++ b/routers/commentsRouter_controllers.go @@ -972,6 +972,24 @@ func init() { 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.ControllerComments{ + Method: "StatisticsReportForAfsOrders", + Router: `/StatisticsReportForAfsOrders`, + 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.ControllerComments{ + Method: "StatisticsReportForOrders", + Router: `/StatisticsReportForOrders`, + AllowHTTPMethods: []string{"post"}, + MethodParams: param.Make(), + Filters: nil, + Params: nil}) + beego.GlobalControllerRouter["git.rosy.net.cn/jx-callback/controllers:SkuController"] = append(beego.GlobalControllerRouter["git.rosy.net.cn/jx-callback/controllers:SkuController"], beego.ControllerComments{ Method: "AddCategory", @@ -1952,13 +1970,5 @@ func init() { 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.ControllerComments{ - Method: "StatisticsReportForOrders", - Router: `/StatisticsReportForOrders`, - AllowHTTPMethods: []string{"post"}, - MethodParams: param.Make(), - Filters: nil, - Params: nil}) + } From 31b7fe33e8f368f7a4d63f4b5de4a5f66b5b685f Mon Sep 17 00:00:00 2001 From: gazebo Date: Thu, 31 Oct 2019 17:44:15 +0800 Subject: [PATCH 40/67] StoreChangePriceTypeBossDisabled --- business/cs/weimob_order.go | 3 ++- business/model/store.go | 5 +++-- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/business/cs/weimob_order.go b/business/cs/weimob_order.go index 932ff1d12..1f2afd8e6 100644 --- a/business/cs/weimob_order.go +++ b/business/cs/weimob_order.go @@ -83,9 +83,10 @@ func GetStoreList4Mobile(db *dao.DaoDB, mobileList []string) (storeList []*model sql := ` SELECT t1.* FROM store t1 - WHERE t1.deleted_at = ?` + WHERE t1.deleted_at = ? /*AND t1.change_price_type = ?*/` sqlParams := []interface{}{ utils.DefaultTimeValue, + // model.StoreChangePriceTypeBossDisabled, } if len(mobileList) > 0 { questionMarks := dao.GenQuestionMarks(len(mobileList)) diff --git a/business/model/store.go b/business/model/store.go index 9338dd8d5..2bbab4956 100644 --- a/business/model/store.go +++ b/business/model/store.go @@ -43,8 +43,9 @@ const ( ) const ( - StoreChangePriceTypeDirect = 0 - StoreChangePriceTypeNeedApprove = 1 + StoreChangePriceTypeDirect = 0 + StoreChangePriceTypeNeedApprove = 1 + StoreChangePriceTypeBossDisabled = 2 ) var ( From f4e29f719a1ace8f86406d9140ef057d442d8c67 Mon Sep 17 00:00:00 2001 From: gazebo Date: Thu, 31 Oct 2019 18:36:19 +0800 Subject: [PATCH 41/67] =?UTF-8?q?=E9=99=90=E5=88=B6=E9=97=A8=E5=BA=97?= =?UTF-8?q?=E8=80=81=E6=9D=BF=E7=9B=B4=E6=8E=A5=E4=BF=AE=E6=94=B9=E9=97=A8?= =?UTF-8?q?=E5=BA=97=E6=94=B9=E4=BB=B7=E5=B1=9E=E6=80=A7=E4=B8=BA=EF=BC=9A?= =?UTF-8?q?StoreChangePriceTypeBossDisabled=E7=9A=84=E9=97=A8=E5=BA=97?= =?UTF-8?q?=E5=95=86=E5=93=81=E4=BB=B7=E6=A0=BC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- business/jxstore/cms/store_sku.go | 16 ++++++++++++---- business/jxutils/jxcontext/jxcontext.go | 12 ++++++++++++ 2 files changed, 24 insertions(+), 4 deletions(-) diff --git a/business/jxstore/cms/store_sku.go b/business/jxstore/cms/store_sku.go index 25d9e9bf1..3f91a1525 100644 --- a/business/jxstore/cms/store_sku.go +++ b/business/jxstore/cms/store_sku.go @@ -131,6 +131,8 @@ type tStoreSkuBindAndSpec struct { SkuNamePrice int SkuNameUnit string RealSkuID int `orm:"column(real_sku_id)"` + + ChangePriceType int8 `json:"changePriceType"` // 修改价格类型,即是否需要审核 } type SkuSaleInfo struct { @@ -907,6 +909,10 @@ func updateStoresSkusWithoutSync(ctx *jxcontext.Context, db *dao.DaoDB, storeIDs // return nil, err // } // globals.SugarLogger.Debugf("updateStoresSkusWithoutSync2, storeIDs:%v, skuBindInfos:%s", storeIDs, utils.Format4Output(skuBindInfos, false)) + isUserCanDirectChangePrice := true + if user := ctx.GetFullUser(); user != nil { + isUserCanDirectChangePrice = user.Type&model.UserTypeOperator != 0 + } userName := ctx.GetUserName() needSyncIDMap := make(map[int]int) @@ -931,7 +937,8 @@ func updateStoresSkusWithoutSync(ctx *jxcontext.Context, db *dao.DaoDB, storeIDs sql += " IF(t5.unit_price > 0, t5.unit_price, t3.price) sku_name_price," } sql += ` - t3.unit sku_name_unit, t3.name, t3.status sku_name_status + t3.unit sku_name_unit, t3.name, t3.status sku_name_status, + ts.change_price_type FROM sku t1 JOIN store ts ON ts.id = ? AND ts.deleted_at = ? LEFT JOIN store_sku_bind t2 ON t2.sku_id = t1.id AND t2.store_id = ts.id AND t2.deleted_at = ? @@ -981,10 +988,11 @@ 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) // globals.SugarLogger.Debug(utils.Format4Output(inSkuBind, false)) var skuBind *model.StoreSkuBind if v.ID == 0 { - if skuBindInfo.IsFocus == 1 && v.SkuNameStatus == model.SkuStatusNormal && v.SkuStatus == model.SkuStatusNormal { + if skuBindInfo.IsFocus == 1 && v.SkuNameStatus == model.SkuStatusNormal && v.SkuStatus == model.SkuStatusNormal && isCanChangePrice { skuBind = &model.StoreSkuBind{ StoreID: storeID, SkuID: v.RealSkuID, @@ -1008,7 +1016,7 @@ func updateStoresSkusWithoutSync(ctx *jxcontext.Context, db *dao.DaoDB, storeIDs } else { skuBind = &v.StoreSkuBind - if skuBindInfo.IsFocus == -1 { + if skuBindInfo.IsFocus == -1 && isCanChangePrice { if num, err = dao.DeleteEntityLogically(db, skuBind, map[string]interface{}{ model.FieldStatus: model.StoreSkuBindStatusDeleted, model.FieldJdSyncStatus: model.SyncFlagDeletedMask, @@ -1038,7 +1046,7 @@ func updateStoresSkusWithoutSync(ctx *jxcontext.Context, db *dao.DaoDB, storeIDs setStoreSkuBindStatus(skuBind, model.SyncFlagSaleMask) updateFieldMap[model.FieldStatus] = 1 } - if skuBindInfo.UnitPrice != 0 { // 这里是否需要加此条件限制 + if skuBindInfo.UnitPrice != 0 && isCanChangePrice { // 这里是否需要加此条件限制 skuBind.UnitPrice = unitPrice skuBind.Price = jxutils.CaculateSkuPrice(unitPrice, v.SpecQuality, v.SpecUnit, v.SkuNameUnit) setStoreSkuBindStatus(skuBind, model.SyncFlagPriceMask) diff --git a/business/jxutils/jxcontext/jxcontext.go b/business/jxutils/jxcontext/jxcontext.go index 7c91a9bd3..b7a46648e 100644 --- a/business/jxutils/jxcontext/jxcontext.go +++ b/business/jxutils/jxcontext/jxcontext.go @@ -6,6 +6,7 @@ import ( "git.rosy.net.cn/jx-callback/business/auth2" "git.rosy.net.cn/jx-callback/business/model" + "git.rosy.net.cn/jx-callback/business/model/dao" "git.rosy.net.cn/jx-callback/globals" ) @@ -156,3 +157,14 @@ func (ctx *Context) GetUserID() (userID string) { } return userID } + +func (ctx *Context) GetFullUser() (user *model.User) { + token := ctx.GetToken() + authInfo, err2 := auth2.GetTokenInfo(token) + if err2 == nil { + if authInfo.TokenType == auth2.TokenTypeNormal { + user, _ = dao.GetUserByID(dao.GetDB(), "user_id", authInfo.GetID()) + } + } + return user +} From 7196b2d93b644cd1547f2e15fd15b0a8ee125c97 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=8B=8F=E5=B0=B9=E5=B2=9A?= <770236076@qq.com> Date: Thu, 31 Oct 2019 18:48:41 +0800 Subject: [PATCH 42/67] =?UTF-8?q?=E5=88=A0=E9=99=A4=E8=B0=83=E8=AF=95?= =?UTF-8?q?=E4=BF=A1=E6=81=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- business/partner/purchase/jd/store_sku2.go | 4 ---- 1 file changed, 4 deletions(-) diff --git a/business/partner/purchase/jd/store_sku2.go b/business/partner/purchase/jd/store_sku2.go index 81387c924..fc3d5f7d2 100644 --- a/business/partner/purchase/jd/store_sku2.go +++ b/business/partner/purchase/jd/store_sku2.go @@ -1,8 +1,6 @@ package jd import ( - "fmt" - "git.rosy.net.cn/baseapi/platformapi/jdapi" "git.rosy.net.cn/baseapi/utils" "git.rosy.net.cn/jx-callback/business/jxutils/jxcontext" @@ -40,9 +38,7 @@ func (p *PurchaseHandler) getStoreSkusBareInfoLimitSize(ctx *jxcontext.Context, func(task *tasksch.ParallelTask, batchItemList []interface{}, params ...interface{}) (retVal interface{}, err error) { subTaskID := batchItemList[0].(int) if subTaskID == 0 { - fmt.Println("test1:111111111") stockInfo, err = getAPI("").QueryOpenUseable(batchSkuInfoList) - fmt.Println(stockInfo) } else { priceInfo, err = getAPI("").GetStationInfoList(vendorStoreID, batchSkuList) } From 55afbf9e170a68e9fb4c0f6d91eff908427b701c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=8B=8F=E5=B0=B9=E5=B2=9A?= <770236076@qq.com> Date: Fri, 1 Nov 2019 08:59:50 +0800 Subject: [PATCH 43/67] =?UTF-8?q?=E8=AE=A2=E5=8D=95=E7=BB=9F=E8=AE=A1?= =?UTF-8?q?=E6=8E=A5=E5=8F=A3=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- business/model/dao/report.go | 114 ++++++++++++++++++----------------- 1 file changed, 58 insertions(+), 56 deletions(-) diff --git a/business/model/dao/report.go b/business/model/dao/report.go index 1fdf80e60..05b0fde9b 100644 --- a/business/model/dao/report.go +++ b/business/model/dao/report.go @@ -1,6 +1,7 @@ package dao import ( + "fmt" "strconv" "time" @@ -42,20 +43,20 @@ func GetStatisticsReportForOrders(db *DaoDB, storeIDs []int, fromDate time.Time, SELECT c.id store_id, c.name store_name, - s.orderCounts order_counts, - s.salePrice sale_price, - s.actualPayPrice actual_pay_price, - s.shopPrice shop_price, - s.discountMoney discount_money, - s.desiredFee desired_fee, - s.distanceFreightMoney distance_freight_money, - s.waybillTipMoney waybill_tip_money, - s.totalShopMoney total_shop_money, - s.pmSubsidyMoney pm_subsidy_money, - s.EarningPrice earning_price, - s.totalGrossProfit total_gross_profit, - IF(c.jx_brand_fee_factor = 0 AND c.market_add_fee_factor = 0,totalGrossProfit,(totalGrossProfit*c.jx_brand_fee_factor)/(c.jx_brand_fee_factor+market_add_fee_factor)) com_grossProfit, - IF(c.jx_brand_fee_factor = 0 AND c.market_add_fee_factor = 0,0,(totalGrossProfit*c.market_add_fee_factor)/(c.jx_brand_fee_factor+market_add_fee_factor)) city_manager_gross_profit, + s.order_counts, + s.sale_price, + s.actual_pay_price, + s.shop_price, + s.discount_money, + s.desired_fee, + s.distance_freight_money, + s.waybill_tip_money, + s.total_shop_money, + s.pm_subsidy_money, + s.earning_price, + s.total_gross_profit, + IF(c.jx_brand_fee_factor = 0 AND c.market_add_fee_factor = 0,total_gross_profit,(total_gross_profit*c.jx_brand_fee_factor)/(c.jx_brand_fee_factor+market_add_fee_factor)) com_gross_profit, + IF(c.jx_brand_fee_factor = 0 AND c.market_add_fee_factor = 0,0,(total_gross_profit*c.market_add_fee_factor)/(c.jx_brand_fee_factor+market_add_fee_factor)) city_manager_gross_profit, IF(mm.name <> '', mm.name, mm.user_id2) market_man_name, IF(om.name <> '', om.name, om.user_id2) operator_name, IF(om2.name <> '', om2.name, om2.user_id2) operator_name2 @@ -66,19 +67,19 @@ func GetStatisticsReportForOrders(db *DaoDB, storeIDs []int, fromDate time.Time, LEFT JOIN ( SELECT - a.store_id storeID, - COUNT(*) orderCounts, - SUM(sale_price) salePrice, - SUM(actual_pay_price) actualPayPrice, - SUM(shop_price) shopPrice, - SUM(discount_money) discountMoney, - SUM(desired_fee) desiredFee, - SUM(distance_freight_money) distanceFreightMoney, - SUM(waybill_tip_money) waybillTipMoney, - SUM(total_shop_money) totalShopMoney, - SUM(pm_subsidy_money) pmSubsidyMoney, - SUM(earning_price) EarningPrice, - SUM(total_shop_money-earning_price-desired_fee-distance_freight_money-waybill_tip_money-80) totalGrossProfit + a.store_id, + COUNT(*) order_counts, + SUM(sale_price) sale_price, + SUM(actual_pay_price) actual_pay_price, + SUM(shop_price) shop_price, + SUM(discount_money) discount_money, + SUM(desired_fee) desired_fee, + SUM(distance_freight_money) distance_freight_money, + SUM(waybill_tip_money) waybill_tip_money, + SUM(total_shop_money) total_shop_money, + SUM(pm_subsidy_money) pm_subsidy_money, + SUM(earning_price) earning_price, + SUM(total_shop_money-earning_price-desired_fee-distance_freight_money-waybill_tip_money-80) total_gross_profit FROM goods_order a LEFT JOIN waybill b ON IF(a.waybill_vendor_id = -1,a.vendor_order_id,a.vendor_waybill_id) = b.vendor_waybill_id WHERE a.status != ` + status + ` @@ -97,7 +98,7 @@ func GetStatisticsReportForOrders(db *DaoDB, storeIDs []int, fromDate time.Time, sql += ` GROUP BY a.store_id )s - ON s.storeID = c.id + ON s.store_id = c.id ` if len(storeIDs) > 0 { sql += `WHERE c.id IN (` + GenQuestionMarks(len(storeIDs)) + `) @@ -118,20 +119,20 @@ func GetGetStatisticsReportForAfsOrders(db *DaoDB, storeIDs []int, fromDate time SELECT c.id store_id, c.name store_name, - s.orderCounts order_counts, - s.salePrice sale_price, - s.actualPayPrice actual_pay_price, - s.shopPrice shop_price, - s.discountMoney discount_money, - s.desiredFee desired_fee, - s.distanceFreightMoney distance_freight_money, - s.waybillTipMoney waybill_tip_money, - s.totalShopMoney total_shop_money, - s.pmSubsidyMoney pm_subsidy_money, - s.EarningPrice earning_price, - s.totalGrossProfit total_gross_profit, - IF(c.jx_brand_fee_factor = 0 AND c.market_add_fee_factor = 0,totalGrossProfit,(totalGrossProfit*c.jx_brand_fee_factor)/(c.jx_brand_fee_factor+market_add_fee_factor)) com_grossProfit, - IF(c.jx_brand_fee_factor = 0 AND c.market_add_fee_factor = 0,0,(totalGrossProfit*c.market_add_fee_factor)/(c.jx_brand_fee_factor+market_add_fee_factor)) city_manager_gross_profit, + s.order_counts, + s.sale_price, + s.actual_pay_price, + s.shop_price, + s.discount_money, + s.desired_fee, + s.distance_freight_money, + s.waybill_tip_money, + s.total_shop_money, + s.pm_subsidy_money, + s.earning_price, + s.total_gross_profit, + IF(c.jx_brand_fee_factor = 0 AND c.market_add_fee_factor = 0,total_gross_profit,(total_gross_profit*c.jx_brand_fee_factor)/(c.jx_brand_fee_factor+market_add_fee_factor)) com_gross_profit, + IF(c.jx_brand_fee_factor = 0 AND c.market_add_fee_factor = 0,0,(total_gross_profit*c.market_add_fee_factor)/(c.jx_brand_fee_factor+market_add_fee_factor)) city_manager_gross_profit, IF(mm.name <> '', mm.name, mm.user_id2) market_man_name, IF(om.name <> '', om.name, om.user_id2) operator_name, IF(om2.name <> '', om2.name, om2.user_id2) operator_name2 @@ -142,19 +143,19 @@ func GetGetStatisticsReportForAfsOrders(db *DaoDB, storeIDs []int, fromDate time LEFT JOIN ( SELECT - a.store_id storeID, - COUNT(*) orderCounts, - SUM(sale_price) salePrice, - SUM(actual_pay_price) actualPayPrice, - SUM(shop_price) shopPrice, - SUM(discount_money) discountMoney, - SUM(afs_freight_money) desiredFee, - SUM(distance_freight_money) distanceFreightMoney, - SUM(waybill_tip_money) waybillTipMoney, - SUM(total_shop_money) totalShopMoney, - SUM(b.pm_subsidy_money) pmSubsidyMoney, - SUM(earning_price) EarningPrice, - SUM(total_shop_money-earning_price-afs_freight_money-distance_freight_money-waybill_tip_money-80) totalGrossProfit + a.store_id, + COUNT(*) order_counts, + SUM(sale_price) sale_price, + SUM(actual_pay_price) actual_pay_price, + SUM(shop_price) shop_price, + SUM(discount_money) discount_money, + SUM(afs_freight_money) desired_fee, + SUM(distance_freight_money) distance_freight_money, + SUM(waybill_tip_money) waybill_tip_money, + SUM(total_shop_money) total_shop_money, + SUM(b.pm_subsidy_money) pm_subsidy_money, + SUM(earning_price) earning_price, + SUM(total_shop_money-earning_price-afs_freight_money-distance_freight_money-waybill_tip_money-80) total_gross_profit FROM goods_order a,afs_order b WHERE a.vendor_order_id = b.vendor_order_id AND a.status != ` + status + ` @@ -173,13 +174,14 @@ func GetGetStatisticsReportForAfsOrders(db *DaoDB, storeIDs []int, fromDate time sql += ` GROUP BY a.store_id )s - ON s.storeID = c.id + ON s.store_id = c.id ` if len(storeIDs) > 0 { sql += `WHERE c.id IN (` + GenQuestionMarks(len(storeIDs)) + `) ` sqlParams = append(sqlParams, storeIDs) } + fmt.Println(sql) if err = GetRows(db, &statisticsReportForOrdersList, sql, sqlParams...); err == nil { return statisticsReportForOrdersList, nil } From 7d76db62dc540ea1c203f54fdbd5d23b8f5eff9f Mon Sep 17 00:00:00 2001 From: gazebo Date: Fri, 1 Nov 2019 10:40:28 +0800 Subject: [PATCH 44/67] =?UTF-8?q?dao.GetStoreSkus2=E4=B8=AD=EF=BC=8C?= =?UTF-8?q?=E5=A4=9A=E9=97=A8=E5=BA=97=E5=B9=B3=E5=8F=B0=E6=B2=A1=E6=9C=89?= =?UTF-8?q?=E6=88=90=E5=8A=9F=E5=88=9B=E5=BB=BA=E7=9A=84=E5=95=86=E5=93=81?= =?UTF-8?q?=EF=BC=8C=E4=B8=8D=E7=9B=B4=E6=8E=A5=E8=BF=87=E6=BB=A4=EF=BC=8C?= =?UTF-8?q?=E8=AE=A9=E4=B8=8A=E5=B1=82=E5=90=8C=E6=AD=A5=E6=97=B6=E6=8A=A5?= =?UTF-8?q?=E9=94=99?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- business/model/dao/store_sku.go | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/business/model/dao/store_sku.go b/business/model/dao/store_sku.go index c83416d25..d61410ad5 100644 --- a/business/model/dao/store_sku.go +++ b/business/model/dao/store_sku.go @@ -286,10 +286,11 @@ func GetStoreSkus2(db *DaoDB, vendorID, storeID int, skuIDs []int, mustDirty boo sql += " AND t1.sku_id IN (" + GenQuestionMarks(len(skuIDs)) + ")" sqlParams = append(sqlParams, skuIDs) } - if !isSingleStorePF { - sql += " AND t2.%s_id <> 0" - fmtParams = append(fmtParams, fieldPrefix) - } + // 多门店平台没有成功创建的商品,不直接过滤,让上层同步时报错 + // if !isSingleStorePF { + // sql += " AND t2.%s_id <> 0" + // fmtParams = append(fmtParams, fieldPrefix) + // } sql = fmt.Sprintf(sql, fmtParams...) sql += " ORDER BY t1.price" // globals.SugarLogger.Debug(sql) From 099fe6189f10bf9ddb724a9ea9c122e66c4482b4 Mon Sep 17 00:00:00 2001 From: gazebo Date: Fri, 1 Nov 2019 14:35:51 +0800 Subject: [PATCH 45/67] =?UTF-8?q?=E5=BD=93=E8=BE=93=E5=85=A5=E7=9A=84?= =?UTF-8?q?=E9=A5=BF=E7=99=BE=E9=97=A8=E5=BA=97ID=E4=B8=8D=E8=83=BD?= =?UTF-8?q?=E6=AD=A3=E5=B8=B8=E8=BD=AC=E4=B8=BA=E6=95=B4=E6=95=B0=E6=97=B6?= =?UTF-8?q?=EF=BC=8C=E6=8A=A5=E9=94=99?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- business/partner/purchase/ebai/store.go | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/business/partner/purchase/ebai/store.go b/business/partner/purchase/ebai/store.go index b50caaef9..d76a5c13e 100644 --- a/business/partner/purchase/ebai/store.go +++ b/business/partner/purchase/ebai/store.go @@ -80,7 +80,10 @@ func getCoordintate(data interface{}) float64 { } func (p *PurchaseHandler) ReadStore(ctx *jxcontext.Context, vendorStoreID string) (*dao.StoreDetail, error) { - baiduShopID := utils.Str2Int64(vendorStoreID) + baiduShopID := utils.Str2Int64WithDefault(vendorStoreID, 0) + if baiduShopID == 0 { + return nil, fmt.Errorf("饿百门店ID:%s非法,应该是一个整数", vendorStoreID) + } result, err := api.EbaiAPI.ShopGet("", baiduShopID) if err == nil { // globals.SugarLogger.Debug(utils.Format4Output(result, false)) From 0c2981e8f87d9ba79d31ccfbeb0a75a605ec1b45 Mon Sep 17 00:00:00 2001 From: gazebo Date: Fri, 1 Nov 2019 14:48:08 +0800 Subject: [PATCH 46/67] up --- business/model/dao/store_sku.go | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/business/model/dao/store_sku.go b/business/model/dao/store_sku.go index d61410ad5..ab244cb4a 100644 --- a/business/model/dao/store_sku.go +++ b/business/model/dao/store_sku.go @@ -287,10 +287,10 @@ func GetStoreSkus2(db *DaoDB, vendorID, storeID int, skuIDs []int, mustDirty boo sqlParams = append(sqlParams, skuIDs) } // 多门店平台没有成功创建的商品,不直接过滤,让上层同步时报错 - // if !isSingleStorePF { - // sql += " AND t2.%s_id <> 0" - // fmtParams = append(fmtParams, fieldPrefix) - // } + if !isSingleStorePF { + sql += " AND t2.%s_id <> 0" + fmtParams = append(fmtParams, fieldPrefix) + } sql = fmt.Sprintf(sql, fmtParams...) sql += " ORDER BY t1.price" // globals.SugarLogger.Debug(sql) From 28c0c5a393faf317058535b86e19573bd11e1cd0 Mon Sep 17 00:00:00 2001 From: gazebo Date: Fri, 1 Nov 2019 15:23:39 +0800 Subject: [PATCH 47/67] =?UTF-8?q?=E5=A4=9A=E9=97=A8=E5=BA=97=E5=B9=B3?= =?UTF-8?q?=E5=8F=B0=E6=B2=A1=E6=9C=89=E5=88=9B=E5=BB=BA=E7=9A=84=E5=95=86?= =?UTF-8?q?=E5=93=81=EF=BC=8C=E5=88=A0=E9=99=A4=E9=97=A8=E5=BA=97=E5=95=86?= =?UTF-8?q?=E5=93=81=E6=97=B6=E7=9A=84=E9=94=99=E8=AF=AF=E5=A4=84=E7=90=86?= =?UTF-8?q?=20=E5=9C=A8=E8=AE=BE=E7=BD=AE=E5=88=A0=E9=99=A4=E9=97=A8?= =?UTF-8?q?=E5=BA=97=E5=95=86=E5=93=81=E6=97=B6=EF=BC=8C=E5=BF=85=E9=A1=BB?= =?UTF-8?q?=E8=A6=81=E6=98=AFskuname=E6=88=96sku=E4=B8=8D=E5=AD=98?= =?UTF-8?q?=E5=9C=A8=E7=9A=84=E5=95=86=E5=93=81=E6=97=B6=E4=BC=9A=E8=AE=BE?= =?UTF-8?q?=E7=BD=AE=E5=88=A0=E9=99=A4=E6=97=A5=E6=9C=9F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- business/jxstore/cms/sync_store_sku.go | 6 ++++-- business/model/dao/store_sku.go | 8 ++++---- business/partner/partner.go | 1 - 3 files changed, 8 insertions(+), 7 deletions(-) diff --git a/business/jxstore/cms/sync_store_sku.go b/business/jxstore/cms/sync_store_sku.go index 24b9a9670..74efff588 100644 --- a/business/jxstore/cms/sync_store_sku.go +++ b/business/jxstore/cms/sync_store_sku.go @@ -238,10 +238,12 @@ func sku2Update(vendorID int, sku *dao.StoreSkuSyncInfo, syncStatus int8) (item kvs[dao.GetVendorThingIDStructField(model.VendorNames[vendorID])] = utils.Str2Int64WithDefault(sku.VendorSkuID, 0) } else if model.IsSyncStatusDelete(syncStatus) { sku.StoreSkuSyncStatus = 0 - if utils.IsTimeZero(sku.BindDeletedAt) { + if utils.IsTimeZero(sku.BindDeletedAt) && (sku.ID == 0 || sku.NameID == 0) { kvs[model.FieldDeletedAt] = time.Now() } - kvs[dao.GetVendorThingIDStructField(model.VendorNames[vendorID])] = 0 + if !dao.IsVendorThingIDEmpty(sku.VendorSkuID) && !partner.IsMultiStore(vendorID) { + kvs[dao.GetVendorThingIDStructField(model.VendorNames[vendorID])] = 0 + } } else { sku.StoreSkuSyncStatus = sku.StoreSkuSyncStatus & model.SyncFlagPriceMask } diff --git a/business/model/dao/store_sku.go b/business/model/dao/store_sku.go index ab244cb4a..d61410ad5 100644 --- a/business/model/dao/store_sku.go +++ b/business/model/dao/store_sku.go @@ -287,10 +287,10 @@ func GetStoreSkus2(db *DaoDB, vendorID, storeID int, skuIDs []int, mustDirty boo sqlParams = append(sqlParams, skuIDs) } // 多门店平台没有成功创建的商品,不直接过滤,让上层同步时报错 - if !isSingleStorePF { - sql += " AND t2.%s_id <> 0" - fmtParams = append(fmtParams, fieldPrefix) - } + // if !isSingleStorePF { + // sql += " AND t2.%s_id <> 0" + // fmtParams = append(fmtParams, fieldPrefix) + // } sql = fmt.Sprintf(sql, fmtParams...) sql += " ORDER BY t1.price" // globals.SugarLogger.Debug(sql) diff --git a/business/partner/partner.go b/business/partner/partner.go index 28dadcba3..102304630 100644 --- a/business/partner/partner.go +++ b/business/partner/partner.go @@ -265,6 +265,5 @@ func IsMultiStore(vendorID int) bool { if _, ok := GetPurchasePlatformFromVendorID(vendorID).(IMultipleStoresHandler); ok { return true } - return false } From 4d605195acd412b217cf74cbb71eb3adfa7fedd7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=8B=8F=E5=B0=B9=E5=B2=9A?= <770236076@qq.com> Date: Fri, 1 Nov 2019 15:31:29 +0800 Subject: [PATCH 48/67] =?UTF-8?q?=E8=AE=A2=E5=8D=95=E7=BB=9F=E8=AE=A1?= =?UTF-8?q?=E6=8E=A5=E5=8F=A3=E4=BF=AE=E6=94=B9=EF=BC=8C=E5=AF=B9=E6=AF=94?= =?UTF-8?q?=E5=B7=AE=E5=BC=82=E7=A8=8B=E5=BA=8F=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- business/jxstore/cms/store_sku_check.go | 148 ++++++++++++++++++++++-- business/model/dao/report.go | 44 +++---- business/model/dao/sku.go | 3 +- business/model/sku.go | 7 +- business/partner/partner.go | 1 - business/partner/purchase/jd/sku.go | 29 ----- 6 files changed, 163 insertions(+), 69 deletions(-) diff --git a/business/jxstore/cms/store_sku_check.go b/business/jxstore/cms/store_sku_check.go index 81d5e930a..e9252e32e 100644 --- a/business/jxstore/cms/store_sku_check.go +++ b/business/jxstore/cms/store_sku_check.go @@ -6,6 +6,8 @@ import ( "sync" "time" + "git.rosy.net.cn/jx-callback/business/model/dao" + "git.rosy.net.cn/baseapi" "git.rosy.net.cn/baseapi/utils" "git.rosy.net.cn/jx-callback/business/jxutils" @@ -27,8 +29,12 @@ const ( ) const ( - DatAanalyse1 = "京东商品库直接创建,正常数据" - DatAanalyse2 = "(可能无经营许可)" + DatAanalyse1 = "京东商品库直接创建,正常数据 " + DatAanalyse2 = "京东商品库未创建成功(可能无经营许可等) " + DatAanalyse3 = "商品名不同 " + DatAanalyse4 = "商品可售状态不同 " + DatAanalyse5 = "京西商品库没有,平台商品库有 " + DatAanalyse6 = "京西商品库有,平台商品库没有" ) var ( @@ -55,6 +61,16 @@ var ( "平台可售状态", "数据分析", } + + deoptTitleList = []string{ + "SkuID", + "京西商品名", + "平台商品名", + "京西可售状态", + "平台可售状态", + "数据分析", + } + statisticTitleList = []string{ "京西和平台商品状态", "待创建", @@ -75,7 +91,8 @@ var ( {"京西有,平台有", "否", "下架"}, {"京西有,平台有", "否", "上架"}, } - diffData DiffDataLock + diffData DiffDataLock + depotDiffData DeoptDiffDataLock multiStoreAllSkuInfoMap map[int]map[int]*partner.SkuNameInfo multiStoreAllSkuInfoList map[int][]*partner.StoreSkuInfo @@ -88,6 +105,20 @@ type DiffDataLock struct { locker sync.RWMutex } +type DeoptDiffDataLock struct { + diffDataMap map[int][]DepotDiffData + locker sync.RWMutex +} + +type DepotDiffData struct { + SkuID string `json:"SkuID"` + JxSkuName string `json:"京西商品名"` + VendorSkuName string `json:"平台商品名"` + JxStatus string `json:"京西可售状态"` + VendorStatus string `json:"平台可售状态"` + DatAanalyse string `json:"数据分析"` +} + type DiffData struct { JxStoreID string `json:"京西门店ID"` VendorStoreID string `json:"平台门店ID"` @@ -111,6 +142,16 @@ type StatisticData struct { Percent string `json:"占比"` } +func (d *DeoptDiffDataLock) AppendData2(vendorID int, depotDiffData DepotDiffData) { + d.locker.Lock() + defer d.locker.Unlock() + d.diffDataMap[vendorID] = append(d.diffDataMap[vendorID], depotDiffData) +} + +func (d *DeoptDiffDataLock) InitData2() { + d.diffDataMap = make(map[int][]DepotDiffData) +} + func (d *DiffDataLock) AppendData(vendorID int, diffData DiffData) { d.locker.Lock() defer d.locker.Unlock() @@ -146,7 +187,7 @@ func GetMultiStoreAllSkuInfo(ctx *jxcontext.Context, vendorMap map[int]bool) { } if partner.IsMultiStore(vendorID) { multiHandler := partner.GetPurchasePlatformFromVendorID(vendorID).(partner.IMultipleStoresHandler) - allSkuNameInfoList, err := multiHandler.GetSkusForCheck(ctx, 0, "", "") + allSkuNameInfoList, err := multiHandler.GetSkus(ctx, 0, "", "") if err != nil { baseapi.SugarLogger.Errorf("GetMultiStoreAllSkuInfo error:%v", err) } else { @@ -154,7 +195,10 @@ func GetMultiStoreAllSkuInfo(ctx *jxcontext.Context, vendorMap map[int]bool) { tempMap := make(map[int]*partner.SkuNameInfo) for _, value := range allSkuNameInfoList { for _, skuInfo := range value.SkuList { - filterCloseSkuIds = append(filterCloseSkuIds, skuInfo.SkuID) + //表示平台商品库未下架的 + if skuInfo.Status != 0 { + filterCloseSkuIds = append(filterCloseSkuIds, skuInfo.SkuID) + } tempMap[skuInfo.SkuID] = value } } @@ -186,6 +230,14 @@ func GetFilterVendorSkuInfoMap(vendorSkuInfoList []*partner.SkuNameInfo) map[int return filterVendorSkuInfoMap } +func GetFilterJxSkuInfoMap2(jxSkuInfoList []*model.SkuAndName) map[int]*model.SkuAndName { + filterVendorSkuInfoMap := make(map[int]*model.SkuAndName) + for _, value := range jxSkuInfoList { + filterVendorSkuInfoMap[value.ID] = value + } + return filterVendorSkuInfoMap +} + func GetFilterMultiStoreSkuInfoMap(vendorID int, skuInfoList []*partner.StoreSkuInfo) map[int]*partner.SkuNameInfo { allSkuInfoMap := GetMultiStoreAllSkuInfoMap(vendorID) filterSkuInfoMap := make(map[int]*partner.SkuNameInfo) @@ -318,6 +370,72 @@ func CompareJxAndVendor(vendorID int, storeIDStr, vendorStoreID, storeName strin } } +func CompareJxAndMultiVenderDepot(ctx *jxcontext.Context, vendorMap map[int]bool) { + db := dao.GetDB() + for vendorID, _ := range vendorNameList { + //filter for vendorID + if len(vendorMap) > 0 { + if _, ok := vendorMap[vendorID]; !ok { + continue + } + } + if partner.IsMultiStore(vendorID) { + multiHandler := partner.GetPurchasePlatformFromVendorID(vendorID).(partner.IMultipleStoresHandler) + allSkuNameInfoList, _ := multiHandler.GetSkus(ctx, 0, "", "") + filterVendorSkuInfoMap := GetFilterVendorSkuInfoMap(allSkuNameInfoList) + skuList, _ := dao.GetSkus(db, []int{}, []int{}, []int{}, []int{}) + filterJxSkuInfoMap2 := GetFilterJxSkuInfoMap2(skuList) + for skuid, jxSkuInfo := range filterJxSkuInfoMap2 { + reason := `` + jxSkuDetailName := jxutils.ComposeSkuName(jxSkuInfo.Prefix, jxSkuInfo.Name, jxSkuInfo.Comment, jxSkuInfo.Unit, jxSkuInfo.SpecQuality, jxSkuInfo.SpecUnit, 0) + + vendorSkuInfoMap := filterVendorSkuInfoMap[skuid] + jxSkuSaleStatus := jxSkuInfo.Status + jxSkuSaleStatusName := GetSkuSaleStatusName(jxSkuSaleStatus) + skuIDStr := utils.Int2Str(skuid) + if vendorSkuInfoMap != nil { + vendorSkuSaleStatusName := GetSkuSaleStatusName(vendorSkuInfoMap.SkuList[0].Status) + vendorSkuDetailName := vendorSkuInfoMap.SkuList[0].SkuName + isSaleStatusDiff := jxSkuSaleStatusName != vendorSkuSaleStatusName + isNameDiff := strings.Compare(jxSkuDetailName, vendorSkuDetailName) != 0 + if isNameDiff || isSaleStatusDiff { + if isNameDiff { + reason += DatAanalyse3 + } + if isSaleStatusDiff { + reason += DatAanalyse4 + } + outPutData := DepotDiffData{skuIDStr, jxSkuDetailName, vendorSkuDetailName, jxSkuSaleStatusName, vendorSkuSaleStatusName, reason} + depotDiffData.AppendData2(vendorID, outPutData) + } + } else { + outPutData := DepotDiffData{skuIDStr, jxSkuDetailName, "", jxSkuSaleStatusName, "", DatAanalyse6} + depotDiffData.AppendData2(vendorID, outPutData) + } + } + for skuID, vendorSkuInfo := range filterVendorSkuInfoMap { + if vendorSkuInfo != nil { + if len(vendorSkuInfo.SkuList) > 0 { + skuIDStr := utils.Int2Str(skuID) + vendorSkuDetailName := vendorSkuInfo.SkuList[0].SkuName + vendorSkuSaleStatusName := GetSkuSaleStatusName(vendorSkuInfo.SkuList[0].Status) + + jxSkuInfo := filterJxSkuInfoMap2[skuID] + if jxSkuInfo == nil { + outPutData := DepotDiffData{skuIDStr, "", vendorSkuDetailName, "", vendorSkuSaleStatusName, DatAanalyse5} + depotDiffData.AppendData2(vendorID, outPutData) + } + } else { + globals.SugarLogger.Warnf("CompareJxAndMultiVenderDepot vendorSkuInfo.SkuList:%d is nil", skuID) + } + } else { + globals.SugarLogger.Warnf("CompareJxAndMultiVenderDepot skuID:%d is nil", skuID) + } + } + } + } +} + //入口函数,校验本地商品京西和其他平台的差异 func CheckSkuDiffBetweenJxAndVendor(ctx *jxcontext.Context, vendorIDList []int, storeIDList []int) { startProcessTime := time.Now().Unix() @@ -338,6 +456,10 @@ func CheckSkuDiffBetweenJxAndVendor(ctx *jxcontext.Context, vendorIDList []int, //2.为multiStoreAllSkuInfoList 和 multiStoreAllSkuInfoMap 赋值 GetMultiStoreAllSkuInfo(ctx, vendorMap) case 1: + //对比京西库和多门店平台的库的信息 + depotDiffData.InitData2() + CompareJxAndMultiVenderDepot(ctx, vendorMap) + case 2: //1.获取京西本地所有门店信息 store、place、user表联查 jxStoreInfoList //2.过滤所有门店信息,只留下传进来的vendorMap,storeIDMap中对应的平台和门台信息 filterStoreList //3.判断是否多平台门店,两种情况两种处理 @@ -398,8 +520,8 @@ func CheckSkuDiffBetweenJxAndVendor(ctx *jxcontext.Context, vendorIDList []int, baseapi.SugarLogger.Debugf("CheckSkuDiffBetweenJxAndVendor taskParallel error:%v", err) } } - case 2: - WriteToExcel(task, diffData.diffDataMap) + case 3: + WriteToExcel(task, diffData.diffDataMap, depotDiffData.diffDataMap) endProcessTime := time.Now().Unix() diff := endProcessTime - startProcessTime baseapi.SugarLogger.Debugf("CheckSkuDiffBetweenJxAndVendor end time: %v", time.Now()) @@ -407,7 +529,7 @@ func CheckSkuDiffBetweenJxAndVendor(ctx *jxcontext.Context, vendorIDList []int, } return result, err } - taskSeq := tasksch.NewSeqTask("京西和平台商品差异对比-序列任务", ctx, taskSeqFunc, 3) + taskSeq := tasksch.NewSeqTask("京西和平台商品差异对比-序列任务", ctx, taskSeqFunc, 4) tasksch.HandleTask(taskSeq, nil, true).Run() } @@ -472,10 +594,18 @@ func AddStatisticSheet(sheetName string, data []DiffData) (sheet *excel.Obj2Exce return sheet } -func WriteToExcel(task *tasksch.SeqTask, data map[int][]DiffData) { +func WriteToExcel(task *tasksch.SeqTask, data map[int][]DiffData, depotData map[int][]DepotDiffData) { var sheetList []*excel.Obj2ExcelSheetConfig for key, value := range data { sheetName := vendorNameList[key] + if partner.IsMultiStore(key) { + excelConfDepot := &excel.Obj2ExcelSheetConfig{ + Title: sheetName + "商品库与京西商品库对比", + Data: depotData[key], + CaptionList: deoptTitleList, + } + sheetList = append(sheetList, excelConfDepot) + } excelConf := &excel.Obj2ExcelSheetConfig{ Title: sheetName, Data: value, diff --git a/business/model/dao/report.go b/business/model/dao/report.go index 05b0fde9b..262ef3eda 100644 --- a/business/model/dao/report.go +++ b/business/model/dao/report.go @@ -1,8 +1,6 @@ package dao import ( - "fmt" - "strconv" "time" "git.rosy.net.cn/baseapi/utils" @@ -37,8 +35,6 @@ type StatisticsReportForOrdersList struct { //查询统计订单信息 func GetStatisticsReportForOrders(db *DaoDB, storeIDs []int, fromDate time.Time, toDate time.Time) (statisticsReportForOrdersList []*StatisticsReportForOrdersList, err error) { - //排除已取消的订单 - status := strconv.Itoa(model.OrderStatusCanceled) sql := ` SELECT c.id store_id, @@ -75,24 +71,24 @@ func GetStatisticsReportForOrders(db *DaoDB, storeIDs []int, fromDate time.Time, SUM(discount_money) discount_money, SUM(desired_fee) desired_fee, SUM(distance_freight_money) distance_freight_money, - SUM(waybill_tip_money) waybill_tip_money, + SUM(IF(a.vendor_id = a.waybill_vendor_id,waybill_tip_money,0)) waybill_tip_money, SUM(total_shop_money) total_shop_money, SUM(pm_subsidy_money) pm_subsidy_money, SUM(earning_price) earning_price, SUM(total_shop_money-earning_price-desired_fee-distance_freight_money-waybill_tip_money-80) total_gross_profit FROM goods_order a LEFT JOIN waybill b ON IF(a.waybill_vendor_id = -1,a.vendor_order_id,a.vendor_waybill_id) = b.vendor_waybill_id - WHERE a.status != ` + status + ` + WHERE a.status != ? ` - sqlParams := []interface{}{} + sqlParams := []interface{}{ + model.OrderStatusCanceled, //排除已取消的订单 + } if !utils.IsTimeZero(fromDate) && !utils.IsTimeZero(toDate) { - sql += `AND a.order_created_at BETWEEN ? AND ? - ` + sql += ` AND a.order_created_at BETWEEN ? AND ?` sqlParams = append(sqlParams, fromDate, toDate) } if len(storeIDs) > 0 { - sql += `AND a.store_id IN(` + GenQuestionMarks(len(storeIDs)) + `) - ` + sql += ` AND a.store_id IN(` + GenQuestionMarks(len(storeIDs)) + `)` sqlParams = append(sqlParams, storeIDs) } sql += ` @@ -101,8 +97,7 @@ func GetStatisticsReportForOrders(db *DaoDB, storeIDs []int, fromDate time.Time, ON s.store_id = c.id ` if len(storeIDs) > 0 { - sql += `WHERE c.id IN (` + GenQuestionMarks(len(storeIDs)) + `) - ` + sql += ` WHERE c.id IN (` + GenQuestionMarks(len(storeIDs)) + `)` sqlParams = append(sqlParams, storeIDs) } if err = GetRows(db, &statisticsReportForOrdersList, sql, sqlParams...); err == nil { @@ -113,8 +108,6 @@ func GetStatisticsReportForOrders(db *DaoDB, storeIDs []int, fromDate time.Time, //查询统计售后单信息 func GetGetStatisticsReportForAfsOrders(db *DaoDB, storeIDs []int, fromDate time.Time, toDate time.Time) (statisticsReportForOrdersList []*StatisticsReportForOrdersList, err error) { - //排除已取消的订单 - status := strconv.Itoa(model.OrderStatusCanceled) sql := ` SELECT c.id store_id, @@ -151,24 +144,23 @@ func GetGetStatisticsReportForAfsOrders(db *DaoDB, storeIDs []int, fromDate time SUM(discount_money) discount_money, SUM(afs_freight_money) desired_fee, SUM(distance_freight_money) distance_freight_money, - SUM(waybill_tip_money) waybill_tip_money, + SUM(IF(a.vendor_id = a.waybill_vendor_id,waybill_tip_money,0)) waybill_tip_money, SUM(total_shop_money) total_shop_money, SUM(b.pm_subsidy_money) pm_subsidy_money, SUM(earning_price) earning_price, SUM(total_shop_money-earning_price-afs_freight_money-distance_freight_money-waybill_tip_money-80) total_gross_profit - FROM goods_order a,afs_order b - WHERE a.vendor_order_id = b.vendor_order_id - AND a.status != ` + status + ` + FROM goods_order a JOIN afs_order b ON a.vendor_order_id = b.vendor_order_id + WHERE a.status != ? ` - sqlParams := []interface{}{} + sqlParams := []interface{}{ + model.OrderStatusCanceled, //排除已取消的订单 + } if !utils.IsTimeZero(fromDate) && !utils.IsTimeZero(toDate) { - sql += `AND a.order_created_at BETWEEN ? AND ? - ` + sql += ` AND a.order_created_at BETWEEN ? AND ?` sqlParams = append(sqlParams, fromDate, toDate) } if len(storeIDs) > 0 { - sql += `AND a.store_id IN(` + GenQuestionMarks(len(storeIDs)) + `) - ` + sql += ` AND a.store_id IN(` + GenQuestionMarks(len(storeIDs)) + `)` sqlParams = append(sqlParams, storeIDs) } sql += ` @@ -177,11 +169,9 @@ func GetGetStatisticsReportForAfsOrders(db *DaoDB, storeIDs []int, fromDate time ON s.store_id = c.id ` if len(storeIDs) > 0 { - sql += `WHERE c.id IN (` + GenQuestionMarks(len(storeIDs)) + `) - ` + sql += ` WHERE c.id IN (` + GenQuestionMarks(len(storeIDs)) + `)` sqlParams = append(sqlParams, storeIDs) } - fmt.Println(sql) if err = GetRows(db, &statisticsReportForOrdersList, sql, sqlParams...); err == nil { return statisticsReportForOrdersList, nil } diff --git a/business/model/dao/sku.go b/business/model/dao/sku.go index ef57e92b6..a942ad08d 100644 --- a/business/model/dao/sku.go +++ b/business/model/dao/sku.go @@ -51,7 +51,8 @@ func DeleteSkuNamePlace(db *DaoDB, nameID int, placeCodes []int) (num int64, err func GetSkus(db *DaoDB, skuIDs, nameIDs, statuss, catIDs []int) (skuList []*model.SkuAndName, err error) { sql := ` - SELECT t1.*, t2.name, t2.unit + SELECT t1.*, + t2.name, t2.unit,t2.spec_quality,t2.spec_unit,t2.prefix FROM sku t1 JOIN sku_name t2 ON t2.id = t1.name_id AND t2.deleted_at = ? ` diff --git a/business/model/sku.go b/business/model/sku.go index e1214522f..465d2407f 100644 --- a/business/model/sku.go +++ b/business/model/sku.go @@ -236,8 +236,11 @@ type Sku struct { type SkuAndName struct { Sku - Name string - Unit string + Name string + Unit string + SpecQuality float32 + SpecUnit string + Prefix string } // func (*Sku) TableUnique() [][]string { diff --git a/business/partner/partner.go b/business/partner/partner.go index 2d8423412..28dadcba3 100644 --- a/business/partner/partner.go +++ b/business/partner/partner.go @@ -173,7 +173,6 @@ type IMultipleStoresHandler interface { // RefreshAllSkusID(ctx *jxcontext.Context, parentTask tasksch.ITask, isAsync bool) (hint string, err error) GetSkus(ctx *jxcontext.Context, skuID int, vendorSkuID, skuName string) (skuNameList []*SkuNameInfo, err error) - GetSkusForCheck(ctx *jxcontext.Context, skuID int, vendorSkuID, skuName string) (skuNameList []*SkuNameInfo, err error) } type ISingleStoreHandler interface { diff --git a/business/partner/purchase/jd/sku.go b/business/partner/purchase/jd/sku.go index abc0480e0..6b78f8b5a 100644 --- a/business/partner/purchase/jd/sku.go +++ b/business/partner/purchase/jd/sku.go @@ -604,35 +604,6 @@ func (p *PurchaseHandler) GetVendorCategories(ctx *jxcontext.Context) (vendorCat return vendorCats, err } -//为对比差异另创建了一个查询京东库的的方法,此方法不用查询图片路径,并且过滤掉了京东库上已下架的商品 -func (p *PurchaseHandler) GetSkusForCheck(ctx *jxcontext.Context, skuID int, vendorSkuID, skuName string) (skuNameList []*partner.SkuNameInfo, err error) { - param := &jdapi.QuerySkuParam{ - SkuID: utils.Str2Int64WithDefault(vendorSkuID, 0), - SkuName: skuName, - IsFilterDel: jdapi.IsFilterDelTrue, - PageNo: 1, - PageSize: jdapi.MaxSkuIDsCount4QueryListBySkuIds, - } - for { - skuList, _, err2 := getAPI("").QuerySkuInfos(param) - if err = err2; err != nil { - return nil, err - } - if len(skuList) > 0 { - for _, v := range skuList { - if v.FixedStatus != jdapi.SkuFixedStatusOffline { - skuNameList = append(skuNameList, vendorSku2Jx(v)) - } - } - } - if len(skuList) < param.PageSize { - break - } - param.PageNo++ - } - return skuNameList, err -} - func (p *PurchaseHandler) GetSkus(ctx *jxcontext.Context, skuID int, vendorSkuID, skuName string) (skuNameList []*partner.SkuNameInfo, err error) { param := &jdapi.QuerySkuParam{ SkuID: utils.Str2Int64WithDefault(vendorSkuID, 0), From 5faa752554133689dd954858532543a4161011b2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=8B=8F=E5=B0=B9=E5=B2=9A?= <770236076@qq.com> Date: Fri, 1 Nov 2019 16:11:19 +0800 Subject: [PATCH 49/67] =?UTF-8?q?=E5=AF=B9=E6=AF=94=E5=B7=AE=E5=BC=82?= =?UTF-8?q?=E7=A8=8B=E5=BA=8F=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- business/model/dao/sku.go | 3 +-- business/model/sku.go | 8 +++----- 2 files changed, 4 insertions(+), 7 deletions(-) diff --git a/business/model/dao/sku.go b/business/model/dao/sku.go index a942ad08d..34bc1fc8c 100644 --- a/business/model/dao/sku.go +++ b/business/model/dao/sku.go @@ -51,8 +51,7 @@ func DeleteSkuNamePlace(db *DaoDB, nameID int, placeCodes []int) (num int64, err func GetSkus(db *DaoDB, skuIDs, nameIDs, statuss, catIDs []int) (skuList []*model.SkuAndName, err error) { sql := ` - SELECT t1.*, - t2.name, t2.unit,t2.spec_quality,t2.spec_unit,t2.prefix + SELECT t1.*, t2.name, t2.unit, t2.prefix FROM sku t1 JOIN sku_name t2 ON t2.id = t1.name_id AND t2.deleted_at = ? ` diff --git a/business/model/sku.go b/business/model/sku.go index 465d2407f..9a06434e3 100644 --- a/business/model/sku.go +++ b/business/model/sku.go @@ -236,11 +236,9 @@ type Sku struct { type SkuAndName struct { Sku - Name string - Unit string - SpecQuality float32 - SpecUnit string - Prefix string + Name string + Unit string + Prefix string } // func (*Sku) TableUnique() [][]string { From 5457f1d2be3d9cb6719555ecbe788def5320e945 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=8B=8F=E5=B0=B9=E5=B2=9A?= <770236076@qq.com> Date: Fri, 1 Nov 2019 19:02:16 +0800 Subject: [PATCH 50/67] =?UTF-8?q?=E8=8E=B7=E5=8F=96=E4=BA=AC=E4=B8=9C?= =?UTF-8?q?=E5=BA=93=E8=BF=87=E6=BB=A4=E5=BA=93=E5=AD=98=E4=B8=BA0?= =?UTF-8?q?=E7=9A=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- business/partner/purchase/jd/store_sku2.go | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/business/partner/purchase/jd/store_sku2.go b/business/partner/purchase/jd/store_sku2.go index fc3d5f7d2..15943b0f2 100644 --- a/business/partner/purchase/jd/store_sku2.go +++ b/business/partner/purchase/jd/store_sku2.go @@ -52,7 +52,9 @@ func (p *PurchaseHandler) getStoreSkusBareInfoLimitSize(ctx *jxcontext.Context, sku := storeSkuMap[utils.Int64ToStr(v.SkuID)] sku.Status = jdStoreSkuStatus2Jx(v.Vendibility) sku.Stock = v.UsableQty - outStoreSkuList = append(outStoreSkuList, sku) + if sku.Stock > 0 { + outStoreSkuList = append(outStoreSkuList, sku) + } } for _, v := range priceInfo { sku := storeSkuMap[utils.Int64ToStr(v.SkuID)] From 7a1972680bc3db037384d3e6f59e538e5932d9c9 Mon Sep 17 00:00:00 2001 From: gazebo Date: Fri, 1 Nov 2019 21:02:00 +0800 Subject: [PATCH 51/67] =?UTF-8?q?=E6=94=B9=E4=BB=B7=E6=A0=BC=E5=8C=85?= =?UTF-8?q?=E6=97=B6=EF=BC=8C=E4=B8=8D=E7=94=A8=E4=BA=8B=E5=8A=A1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- business/jxstore/cms/cms.go | 3 +-- business/model/dao/dao.go | 2 +- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/business/jxstore/cms/cms.go b/business/jxstore/cms/cms.go index 8d6dc1eae..9aa2f3da6 100644 --- a/business/jxstore/cms/cms.go +++ b/business/jxstore/cms/cms.go @@ -336,15 +336,14 @@ func UpdateConfig(ctx *jxcontext.Context, key, configType, value string) (hint s dao.Rollback(db) return "", err } + dao.Commit(db) for _, v := range storeMapList { if _, err = dao.UpdateEntityLogicallyAndUpdateSyncStatus(db, &model.StoreSkuBind{}, nil, ctx.GetUserName(), map[string]interface{}{ model.FieldStoreID: v.StoreID, }, dao.GetSyncStatusStructField(model.VendorNames[v.VendorID]), model.SyncFlagPriceMask); err != nil { - dao.Rollback(db) return "", err } } - dao.Commit(db) case model.ConfigTypeFreightPack: dao.Commit(db) storeMapList, err := dao.GetStoresMapList(db, nil, nil, model.StoreStatusAll, model.StoreIsSyncYes, "") diff --git a/business/model/dao/dao.go b/business/model/dao/dao.go index 45f76a448..f3c3803f8 100644 --- a/business/model/dao/dao.go +++ b/business/model/dao/dao.go @@ -13,7 +13,7 @@ import ( const ( useGetRowsWhenGetRow = true - transactionWarningSeconds = 2 * 60 // 5分钟 + transactionWarningSeconds = 10 * 60 // 5分钟 ) type DaoDB struct { From 5230fa664d526725116db321cd7ee68f58a8a2ff Mon Sep 17 00:00:00 2001 From: gazebo Date: Sat, 2 Nov 2019 11:42:04 +0800 Subject: [PATCH 52/67] =?UTF-8?q?=E5=8F=96=E6=B6=88=E8=BF=90=E5=8D=95?= =?UTF-8?q?=E5=A4=B1=E8=B4=A5=E4=B8=8D=E5=86=8D=E6=8A=A5=E8=AD=A6BaseSched?= =?UTF-8?q?uler.CancelWaybill?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- business/jxcallback/scheduler/basesch/basesch.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/business/jxcallback/scheduler/basesch/basesch.go b/business/jxcallback/scheduler/basesch/basesch.go index 7b7fb4f33..0d7716a12 100644 --- a/business/jxcallback/scheduler/basesch/basesch.go +++ b/business/jxcallback/scheduler/basesch/basesch.go @@ -179,7 +179,7 @@ func (c *BaseScheduler) CancelWaybill(bill *model.Waybill, cancelReasonID int, c // 部分快递平台在取消成功后有时会不发运单取消消息过来(比如达达,904200512000442),为避免二次取消报错,添加状态判断 if c.IsReallyCallPlatformAPI && bill.OrderVendorID != bill.WaybillVendorID && bill.Status != model.WaybillStatusCanceled { if handlerInfo := partner.GetDeliveryPlatformFromVendorID(bill.WaybillVendorID); handlerInfo != nil { - if err = utils.CallFuncLogError(func() error { + if err = utils.CallFuncLogErrorWithInfo(func() error { return handlerInfo.Handler.CancelWaybill(bill, cancelReasonID, cancelReason) }, "CancelWaybill bill:%v", bill); err == nil { bill.Status = model.WaybillStatusCanceled From f344d711bf5d5990a0a310157c673b332baf8d34 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=8B=8F=E5=B0=B9=E5=B2=9A?= <770236076@qq.com> Date: Mon, 4 Nov 2019 09:48:21 +0800 Subject: [PATCH 53/67] =?UTF-8?q?=E5=AF=B9=E6=AF=94=E5=B7=AE=E5=BC=82?= =?UTF-8?q?=E7=A8=8B=E5=BA=8F=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- business/jxstore/cms/store_sku_check.go | 29 +++++++++++++++---------- 1 file changed, 18 insertions(+), 11 deletions(-) diff --git a/business/jxstore/cms/store_sku_check.go b/business/jxstore/cms/store_sku_check.go index e9252e32e..97c6a125d 100644 --- a/business/jxstore/cms/store_sku_check.go +++ b/business/jxstore/cms/store_sku_check.go @@ -29,7 +29,7 @@ const ( ) const ( - DatAanalyse1 = "京东商品库直接创建,正常数据 " + DatAanalyse1 = "京东商品库直接创建,京西无数据" DatAanalyse2 = "京东商品库未创建成功(可能无经营许可等) " DatAanalyse3 = "商品名不同 " DatAanalyse4 = "商品可售状态不同 " @@ -175,7 +175,7 @@ func GetMultiStoreAllSkuInfoList(vendorID int) []*partner.StoreSkuInfo { return multiStoreAllSkuInfoList[vendorID] } -func GetMultiStoreAllSkuInfo(ctx *jxcontext.Context, vendorMap map[int]bool) { +func GetMultiStoreAllSkuInfo(ctx *jxcontext.Context, vendorMap map[int]bool) (allSkuNameInfoList []*partner.SkuNameInfo) { InitMultiStoreData() filterCloseSkuIds = filterCloseSkuIds[0:0] for vendorID, _ := range vendorNameList { @@ -196,16 +196,17 @@ func GetMultiStoreAllSkuInfo(ctx *jxcontext.Context, vendorMap map[int]bool) { for _, value := range allSkuNameInfoList { for _, skuInfo := range value.SkuList { //表示平台商品库未下架的 - if skuInfo.Status != 0 { + if skuInfo.Status > model.SkuStatusDontSale { filterCloseSkuIds = append(filterCloseSkuIds, skuInfo.SkuID) + tempMap[skuInfo.SkuID] = value } - tempMap[skuInfo.SkuID] = value } } multiStoreAllSkuInfoMap[vendorID] = tempMap //map[平台ID][map[skuID1:SkuNameInfo1,skuID2:SkuNameInfo2]...] } } } + return allSkuNameInfoList } func GetFilterJxSkuInfoMap(jxSkuInfoList []*StoreSkuNameExt) map[int]*StoreSkuNameExt { @@ -308,6 +309,7 @@ func IsSkuCanSale(saleStatus int) bool { //storeIDStr 京西商家id ,vendorStoreID 平台商家id func CompareJxAndVendor(vendorID int, storeIDStr, vendorStoreID, storeName string, filterJxSkuInfoMap map[int]*StoreSkuNameExt, filterVendorSkuInfoMap map[int]*partner.SkuNameInfo) { for skuID, jxSkuInfo := range filterJxSkuInfoMap { + reason := `` skuIDStr := utils.Int2Str(skuID) //jxSkuDetailName : 前缀 ([荐]) + 分类名(xxx水饺) + 数量单位(约..g/份) + 注释 (补充..) jxSkuDetailName := jxutils.ComposeSkuName(jxSkuInfo.SkuName.Prefix, jxSkuInfo.SkuName.Name, jxSkuInfo.Skus2[0].Comment, jxSkuInfo.SkuName.Unit, jxSkuInfo.Skus2[0].SkuSpecQuality, jxSkuInfo.Skus2[0].SkuSpecUnit, 0) @@ -338,14 +340,20 @@ func CompareJxAndVendor(vendorID int, storeIDStr, vendorStoreID, storeName strin isNameDiff = false } if isSaleStatusDiff || isNameDiff { - outPutData := DiffData{storeIDStr, vendorStoreID, storeName, skuIDStr, syncStatus, toBeCreate, toBeDel, jxSkuDetailName, vendorSkuDetailName, jxSkuSaleStatusName, vendorSkuSaleStatusName, ""} + if isNameDiff { + reason += DatAanalyse3 + } + if isSaleStatusDiff { + reason += DatAanalyse4 + } + outPutData := DiffData{storeIDStr, vendorStoreID, storeName, skuIDStr, syncStatus, toBeCreate, toBeDel, jxSkuDetailName, vendorSkuDetailName, jxSkuSaleStatusName, vendorSkuSaleStatusName, reason} diffData.AppendData(vendorID, outPutData) } } else { if isFilterToBeCreateAndNotSale && model.IsSyncStatusNeedCreate(status) && !IsSkuCanSale(jxSkuSaleStatus) { continue } - outPutData := DiffData{storeIDStr, vendorStoreID, storeName, skuIDStr, syncStatus, toBeCreate, toBeDel, jxSkuDetailName, "", jxSkuSaleStatusName, "", ""} + outPutData := DiffData{storeIDStr, vendorStoreID, storeName, skuIDStr, syncStatus, toBeCreate, toBeDel, jxSkuDetailName, "", jxSkuSaleStatusName, "", DatAanalyse2} diffData.AppendData(vendorID, outPutData) } } @@ -370,7 +378,7 @@ func CompareJxAndVendor(vendorID int, storeIDStr, vendorStoreID, storeName strin } } -func CompareJxAndMultiVenderDepot(ctx *jxcontext.Context, vendorMap map[int]bool) { +func CompareJxAndMultiVenderDepot(ctx *jxcontext.Context, vendorMap map[int]bool, allSkuNameInfoList []*partner.SkuNameInfo) { db := dao.GetDB() for vendorID, _ := range vendorNameList { //filter for vendorID @@ -380,8 +388,6 @@ func CompareJxAndMultiVenderDepot(ctx *jxcontext.Context, vendorMap map[int]bool } } if partner.IsMultiStore(vendorID) { - multiHandler := partner.GetPurchasePlatformFromVendorID(vendorID).(partner.IMultipleStoresHandler) - allSkuNameInfoList, _ := multiHandler.GetSkus(ctx, 0, "", "") filterVendorSkuInfoMap := GetFilterVendorSkuInfoMap(allSkuNameInfoList) skuList, _ := dao.GetSkus(db, []int{}, []int{}, []int{}, []int{}) filterJxSkuInfoMap2 := GetFilterJxSkuInfoMap2(skuList) @@ -438,6 +444,7 @@ func CompareJxAndMultiVenderDepot(ctx *jxcontext.Context, vendorMap map[int]bool //入口函数,校验本地商品京西和其他平台的差异 func CheckSkuDiffBetweenJxAndVendor(ctx *jxcontext.Context, vendorIDList []int, storeIDList []int) { + var allSkuNameInfoList []*partner.SkuNameInfo startProcessTime := time.Now().Unix() baseapi.SugarLogger.Debugf("CheckSkuDiffBetweenJxAndVendor start time: %v", time.Now()) vendorMap := make(map[int]bool) @@ -454,11 +461,11 @@ func CheckSkuDiffBetweenJxAndVendor(ctx *jxcontext.Context, vendorIDList []int, //获取所有多门店平台的商品信息 //1.循环传进来的平台id,如果是多门店的平台,查询该门店京东到家平台的所有商品 //2.为multiStoreAllSkuInfoList 和 multiStoreAllSkuInfoMap 赋值 - GetMultiStoreAllSkuInfo(ctx, vendorMap) + allSkuNameInfoList = GetMultiStoreAllSkuInfo(ctx, vendorMap) case 1: //对比京西库和多门店平台的库的信息 depotDiffData.InitData2() - CompareJxAndMultiVenderDepot(ctx, vendorMap) + CompareJxAndMultiVenderDepot(ctx, vendorMap, allSkuNameInfoList) case 2: //1.获取京西本地所有门店信息 store、place、user表联查 jxStoreInfoList //2.过滤所有门店信息,只留下传进来的vendorMap,storeIDMap中对应的平台和门台信息 filterStoreList From a7aee90c6240023e5b3f1aa81c182f97784282de Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=8B=8F=E5=B0=B9=E5=B2=9A?= <770236076@qq.com> Date: Mon, 4 Nov 2019 10:54:16 +0800 Subject: [PATCH 54/67] =?UTF-8?q?=E5=AF=B9=E6=AF=94=E7=A8=8B=E5=BA=8F?= =?UTF-8?q?=E5=B7=AE=E5=BC=82=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- business/jxstore/cms/store_sku_check.go | 40 ++++++++++++++++++------- 1 file changed, 29 insertions(+), 11 deletions(-) diff --git a/business/jxstore/cms/store_sku_check.go b/business/jxstore/cms/store_sku_check.go index 97c6a125d..c6734a1f2 100644 --- a/business/jxstore/cms/store_sku_check.go +++ b/business/jxstore/cms/store_sku_check.go @@ -28,6 +28,7 @@ const ( fileExt = ".xlsx" ) +//错误类型 const ( DatAanalyse1 = "京东商品库直接创建,京西无数据" DatAanalyse2 = "京东商品库未创建成功(可能无经营许可等) " @@ -35,6 +36,7 @@ const ( DatAanalyse4 = "商品可售状态不同 " DatAanalyse5 = "京西商品库没有,平台商品库有 " DatAanalyse6 = "京西商品库有,平台商品库没有" + DatAanalyse7 = "同步状态异常" ) var ( @@ -96,8 +98,8 @@ var ( multiStoreAllSkuInfoMap map[int]map[int]*partner.SkuNameInfo multiStoreAllSkuInfoList map[int][]*partner.StoreSkuInfo - - filterCloseSkuIds []int + skuNameInfoList []*partner.SkuNameInfo + filterCloseSkuIds []int ) type DiffDataLock struct { @@ -175,7 +177,7 @@ func GetMultiStoreAllSkuInfoList(vendorID int) []*partner.StoreSkuInfo { return multiStoreAllSkuInfoList[vendorID] } -func GetMultiStoreAllSkuInfo(ctx *jxcontext.Context, vendorMap map[int]bool) (allSkuNameInfoList []*partner.SkuNameInfo) { +func GetMultiStoreAllSkuInfo(ctx *jxcontext.Context, vendorMap map[int]bool) { InitMultiStoreData() filterCloseSkuIds = filterCloseSkuIds[0:0] for vendorID, _ := range vendorNameList { @@ -188,6 +190,7 @@ func GetMultiStoreAllSkuInfo(ctx *jxcontext.Context, vendorMap map[int]bool) (al if partner.IsMultiStore(vendorID) { multiHandler := partner.GetPurchasePlatformFromVendorID(vendorID).(partner.IMultipleStoresHandler) allSkuNameInfoList, err := multiHandler.GetSkus(ctx, 0, "", "") + skuNameInfoList = allSkuNameInfoList if err != nil { baseapi.SugarLogger.Errorf("GetMultiStoreAllSkuInfo error:%v", err) } else { @@ -206,7 +209,6 @@ func GetMultiStoreAllSkuInfo(ctx *jxcontext.Context, vendorMap map[int]bool) (al } } } - return allSkuNameInfoList } func GetFilterJxSkuInfoMap(jxSkuInfoList []*StoreSkuNameExt) map[int]*StoreSkuNameExt { @@ -311,8 +313,16 @@ func CompareJxAndVendor(vendorID int, storeIDStr, vendorStoreID, storeName strin for skuID, jxSkuInfo := range filterJxSkuInfoMap { reason := `` skuIDStr := utils.Int2Str(skuID) - //jxSkuDetailName : 前缀 ([荐]) + 分类名(xxx水饺) + 数量单位(约..g/份) + 注释 (补充..) - jxSkuDetailName := jxutils.ComposeSkuName(jxSkuInfo.SkuName.Prefix, jxSkuInfo.SkuName.Name, jxSkuInfo.Skus2[0].Comment, jxSkuInfo.SkuName.Unit, jxSkuInfo.Skus2[0].SkuSpecQuality, jxSkuInfo.Skus2[0].SkuSpecUnit, 0) + var jxSkuDetailName string + //多规格商品不用比较数量单位 + if jxSkuInfo.IsSpu == 0 { + //jxSkuDetailName : 前缀 ([荐]) + 分类名(xxx水饺) + 数量单位(约..g/份) + 注释 (补充..) + jxSkuDetailName = jxutils.ComposeSkuName(jxSkuInfo.SkuName.Prefix, jxSkuInfo.SkuName.Name, jxSkuInfo.Skus2[0].Comment, jxSkuInfo.SkuName.Unit, jxSkuInfo.Skus2[0].SkuSpecQuality, jxSkuInfo.Skus2[0].SkuSpecUnit, 0) + } else { + //jxSkuDetailName : 前缀 ([荐]) + 分类名(xxx水饺) + 数量单位(约..g/份) + 注释 (补充..) + jxSkuDetailName = jxutils.ComposeSkuName(jxSkuInfo.SkuName.Prefix, jxSkuInfo.SkuName.Name, jxSkuInfo.Skus2[0].Comment, "", jxSkuInfo.Skus2[0].SkuSpecQuality, "", 0) + } + //jxSkuSaleStatus : 商品状态 ,skustatus 优先级高于 StoreSkuStatus jxSkuSaleStatus := jxutils.MergeSkuStatus(jxSkuInfo.Skus2[0].SkuStatus, jxSkuInfo.Skus2[0].StoreSkuStatus) jxSkuSaleStatusName := GetSkuSaleStatusName(jxSkuSaleStatus) @@ -349,6 +359,12 @@ func CompareJxAndVendor(vendorID int, storeIDStr, vendorStoreID, storeName strin outPutData := DiffData{storeIDStr, vendorStoreID, storeName, skuIDStr, syncStatus, toBeCreate, toBeDel, jxSkuDetailName, vendorSkuDetailName, jxSkuSaleStatusName, vendorSkuSaleStatusName, reason} diffData.AppendData(vendorID, outPutData) } + if !isSaleStatusDiff && !isNameDiff { + if status != 0 { + outPutData := DiffData{storeIDStr, vendorStoreID, storeName, skuIDStr, syncStatus, toBeCreate, toBeDel, jxSkuDetailName, vendorSkuDetailName, jxSkuSaleStatusName, vendorSkuSaleStatusName, DatAanalyse7} + diffData.AppendData(vendorID, outPutData) + } + } } else { if isFilterToBeCreateAndNotSale && model.IsSyncStatusNeedCreate(status) && !IsSkuCanSale(jxSkuSaleStatus) { continue @@ -378,7 +394,7 @@ func CompareJxAndVendor(vendorID int, storeIDStr, vendorStoreID, storeName strin } } -func CompareJxAndMultiVenderDepot(ctx *jxcontext.Context, vendorMap map[int]bool, allSkuNameInfoList []*partner.SkuNameInfo) { +func CompareJxAndMultiVenderDepot(ctx *jxcontext.Context, vendorMap map[int]bool) { db := dao.GetDB() for vendorID, _ := range vendorNameList { //filter for vendorID @@ -388,7 +404,10 @@ func CompareJxAndMultiVenderDepot(ctx *jxcontext.Context, vendorMap map[int]bool } } if partner.IsMultiStore(vendorID) { - filterVendorSkuInfoMap := GetFilterVendorSkuInfoMap(allSkuNameInfoList) + // multiHandler := partner.GetPurchasePlatformFromVendorID(vendorID).(partner.IMultipleStoresHandler) + // allSkuNameInfoList, _ := multiHandler.GetSkus(ctx, 0, "", "") + filterVendorSkuInfoMap := GetFilterVendorSkuInfoMap(skuNameInfoList) + skuNameInfoList = skuNameInfoList[0:0] skuList, _ := dao.GetSkus(db, []int{}, []int{}, []int{}, []int{}) filterJxSkuInfoMap2 := GetFilterJxSkuInfoMap2(skuList) for skuid, jxSkuInfo := range filterJxSkuInfoMap2 { @@ -444,7 +463,6 @@ func CompareJxAndMultiVenderDepot(ctx *jxcontext.Context, vendorMap map[int]bool //入口函数,校验本地商品京西和其他平台的差异 func CheckSkuDiffBetweenJxAndVendor(ctx *jxcontext.Context, vendorIDList []int, storeIDList []int) { - var allSkuNameInfoList []*partner.SkuNameInfo startProcessTime := time.Now().Unix() baseapi.SugarLogger.Debugf("CheckSkuDiffBetweenJxAndVendor start time: %v", time.Now()) vendorMap := make(map[int]bool) @@ -461,11 +479,11 @@ func CheckSkuDiffBetweenJxAndVendor(ctx *jxcontext.Context, vendorIDList []int, //获取所有多门店平台的商品信息 //1.循环传进来的平台id,如果是多门店的平台,查询该门店京东到家平台的所有商品 //2.为multiStoreAllSkuInfoList 和 multiStoreAllSkuInfoMap 赋值 - allSkuNameInfoList = GetMultiStoreAllSkuInfo(ctx, vendorMap) + GetMultiStoreAllSkuInfo(ctx, vendorMap) case 1: //对比京西库和多门店平台的库的信息 depotDiffData.InitData2() - CompareJxAndMultiVenderDepot(ctx, vendorMap, allSkuNameInfoList) + CompareJxAndMultiVenderDepot(ctx, vendorMap) case 2: //1.获取京西本地所有门店信息 store、place、user表联查 jxStoreInfoList //2.过滤所有门店信息,只留下传进来的vendorMap,storeIDMap中对应的平台和门台信息 filterStoreList From 4e277d854b6f9465fc7646794bfd28382f956691 Mon Sep 17 00:00:00 2001 From: gazebo Date: Mon, 4 Nov 2019 11:41:20 +0800 Subject: [PATCH 55/67] =?UTF-8?q?=E7=BE=8E=E5=9B=A2=E6=B4=BB=E5=8A=A8?= =?UTF-8?q?=E4=B8=8D=E8=AE=BE=E7=BD=AEsequence=EF=BC=88=E9=81=BF=E5=85=8D?= =?UTF-8?q?=E9=87=8D=E5=A4=8D=E5=90=8E=E6=8A=A5=E9=94=99=EF=BC=89?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- business/partner/purchase/mtwm/act.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/business/partner/purchase/mtwm/act.go b/business/partner/purchase/mtwm/act.go index 94bf56d4e..e70a2ca36 100644 --- a/business/partner/purchase/mtwm/act.go +++ b/business/partner/purchase/mtwm/act.go @@ -46,8 +46,8 @@ func storeSku2ActData(act *model.Act2, actStoreSku []*model.ActStoreSku2, handle SettingType: mtwmapi.SettingTypeAsPrice, ActPrice: jxutils.IntPrice2Standard(v.ActualActPrice), // DiscountCoefficient: 0, - Sequence: int(v.ActPrice), - ItemID: utils.Str2Int64WithDefault(v.VendorActID, 0), + // Sequence: int(v.ActPrice), // 此字段不允许重复 + ItemID: utils.Str2Int64WithDefault(v.VendorActID, 0), }) } } From ff525293a57e6063a12a593a92770e091e72ed5e Mon Sep 17 00:00:00 2001 From: gazebo Date: Mon, 4 Nov 2019 14:30:19 +0800 Subject: [PATCH 56/67] =?UTF-8?q?=E7=BB=93=E7=AE=97=E6=B4=BB=E5=8A=A8?= =?UTF-8?q?=E4=B8=8D=E8=A6=81=E6=B1=82=E9=97=A8=E5=BA=97=E5=85=B3=E6=B3=A8?= =?UTF-8?q?=E5=95=86=E5=93=81=20=E4=B8=8D=E8=87=AA=E5=8A=A8=E8=BF=87?= =?UTF-8?q?=E6=BB=A4=E6=B2=A1=E6=9C=89=E5=85=B3=E6=B3=A8=E7=9A=84=E5=95=86?= =?UTF-8?q?=E5=93=81=EF=BC=8C=E4=BC=9A=E6=8A=A5=E9=94=99?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- business/jxstore/act/act.go | 97 +++++++++++++++++++------------------ 1 file changed, 49 insertions(+), 48 deletions(-) diff --git a/business/jxstore/act/act.go b/business/jxstore/act/act.go index 42ef9ac13..00ecf79cd 100644 --- a/business/jxstore/act/act.go +++ b/business/jxstore/act/act.go @@ -120,49 +120,54 @@ func ActStoreSkuParam2Model(ctx *jxcontext.Context, db *dao.DaoDB, act *model.Ac storeDetail, err2 := dao.GetStoreDetail(db, storeID, vendorID) if err = err2; err == nil { for _, v := range oneStoreSkuParam { - if storeSkuInfo := storeSkuMap[jxutils.Combine2Int(v.StoreID, v.SkuID)]; storeSkuInfo != nil { - validVendorMap[vendorID] = 1 - validSkuMap[v.SkuID] = 1 - pricePercentage := jxutils.GetPricePercentage(storeDetail.PricePercentagePackObj, storeSkuInfo.Price, int(storeDetail.PricePercentage)) - actSkuMap := &model.ActStoreSkuMap{ - ActID: act.ID, - StoreID: storeID, - SkuID: v.SkuID, - VendorID: vendorID, + validVendorMap[vendorID] = 1 + validSkuMap[v.SkuID] = 1 + v.ActID = act.ID + actSkuMap := &model.ActStoreSkuMap{ + ActID: act.ID, + StoreID: storeID, + SkuID: v.SkuID, + VendorID: vendorID, - SyncStatus: model.SyncFlagNewMask, - VendorPrice: int64(jxutils.CaculateSkuVendorPrice(storeSkuInfo.Price, pricePercentage)), - } - v.OriginalPrice = actSkuMap.VendorPrice - if act.Type == model.ActSkuFake { - actSkuMap.ActualActPrice = 0 - } else { - if v.ActPrice != 0 { - actSkuMap.ActualActPrice = v.ActPrice - } else { - percentage := act.PricePercentage - if v.PricePercentage != 0 { - percentage = v.PricePercentage - } - actSkuMap.ActualActPrice = int64(jxutils.CaculateSkuVendorPrice(int(actSkuMap.VendorPrice), percentage)) - if actSkuMap.ActualActPrice > 10 { - actSkuMap.ActualActPrice = int64(math.Round(float64(actSkuMap.ActualActPrice)/10) * 10) - } - } - if actSkuMap.ActualActPrice <= 0 { - actSkuMap.ActualActPrice = 1 - } - } - if err2 := checkDiscountValidation(act.Type, int(actSkuMap.ActualActPrice*100/actSkuMap.VendorPrice)); err2 != nil { - v.ErrMsg = err2.Error() - v.ActualActPrice = actSkuMap.ActualActPrice - wrongSkuList = append(wrongSkuList, v) - } else { - dao.WrapAddIDCULDEntity(actSkuMap, ctx.GetUserName()) - actStoreSkuMapList = append(actStoreSkuMapList, actSkuMap) - } + SyncStatus: model.SyncFlagNewMask, + } + v.OriginalPrice = actSkuMap.VendorPrice + if storeSkuInfo := storeSkuMap[jxutils.Combine2Int(v.StoreID, v.SkuID)]; storeSkuInfo != nil { + jxPrice := storeSkuInfo.Price + pricePercentage := jxutils.GetPricePercentage(storeDetail.PricePercentagePackObj, jxPrice, int(storeDetail.PricePercentage)) + actSkuMap.VendorPrice = int64(jxutils.CaculateSkuVendorPrice(jxPrice, pricePercentage)) + v.OriginalPrice = int64(jxPrice) + } else if act.Type != model.ActSkuFake { + v.ErrMsg = fmt.Sprintf("门店:%d没有关注商品:%d", v.StoreID, v.SkuID) + wrongSkuList = append(wrongSkuList, v) + continue + } + if act.Type == model.ActSkuFake { + actSkuMap.ActualActPrice = 0 } else { - globals.SugarLogger.Debugf("ActStoreSkuParam2Model storeID:%d, skuID:%d没有关注", v.StoreID, v.SkuID) + if v.ActPrice != 0 { + actSkuMap.ActualActPrice = v.ActPrice + } else { + percentage := act.PricePercentage + if v.PricePercentage != 0 { + percentage = v.PricePercentage + } + actSkuMap.ActualActPrice = int64(jxutils.CaculateSkuVendorPrice(int(actSkuMap.VendorPrice), percentage)) + if actSkuMap.ActualActPrice > 10 { + actSkuMap.ActualActPrice = int64(math.Round(float64(actSkuMap.ActualActPrice)/10) * 10) + } + } + if actSkuMap.ActualActPrice <= 0 { + actSkuMap.ActualActPrice = 1 + } + } + if err2 := checkDiscountValidation(act.Type, int(actSkuMap.ActualActPrice*100/actSkuMap.VendorPrice)); err2 != nil { + v.ErrMsg = err2.Error() + v.ActualActPrice = actSkuMap.ActualActPrice + wrongSkuList = append(wrongSkuList, v) + } else { + dao.WrapAddIDCULDEntity(actSkuMap, ctx.GetUserName()) + actStoreSkuMapList = append(actStoreSkuMapList, actSkuMap) } } wholeValidVendorMap[vendorID] = 1 @@ -175,13 +180,9 @@ func ActStoreSkuParam2Model(ctx *jxcontext.Context, db *dao.DaoDB, act *model.Ac if len(wrongSkuList) == 0 { for _, v := range oneStoreSkuParam { if validSkuMap[v.SkuID] == 1 { // todo 这里是否需要判断 - if storeSkuInfo := storeSkuMap[jxutils.Combine2Int(v.StoreID, v.SkuID)]; storeSkuInfo != nil { - storeSku := &v.ActStoreSku - storeSku.ActID = act.ID - storeSku.OriginalPrice = int64(storeSkuInfo.Price) - dao.WrapAddIDCULDEntity(storeSku, ctx.GetUserName()) - actStoreSkuList = append(actStoreSkuList, storeSku) - } + storeSku := &v.ActStoreSku + dao.WrapAddIDCULDEntity(storeSku, ctx.GetUserName()) + actStoreSkuList = append(actStoreSkuList, storeSku) } } } From d2b387949f23d27caf4c12ad62aed314c553b987 Mon Sep 17 00:00:00 2001 From: gazebo Date: Mon, 4 Nov 2019 14:45:01 +0800 Subject: [PATCH 57/67] =?UTF-8?q?ActStoreSkuParam2Model=E4=B8=AD=E6=B2=A1?= =?UTF-8?q?=E6=9C=89=E5=85=B3=E6=B3=A8=E7=9A=84ActSkuFake=E6=97=B6?= =?UTF-8?q?=E8=A2=AB=E9=9B=B6=E9=99=A4=E7=9A=84=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- business/jxstore/act/act.go | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/business/jxstore/act/act.go b/business/jxstore/act/act.go index 00ecf79cd..81727c284 100644 --- a/business/jxstore/act/act.go +++ b/business/jxstore/act/act.go @@ -161,13 +161,15 @@ func ActStoreSkuParam2Model(ctx *jxcontext.Context, db *dao.DaoDB, act *model.Ac actSkuMap.ActualActPrice = 1 } } - if err2 := checkDiscountValidation(act.Type, int(actSkuMap.ActualActPrice*100/actSkuMap.VendorPrice)); err2 != nil { - v.ErrMsg = err2.Error() - v.ActualActPrice = actSkuMap.ActualActPrice - wrongSkuList = append(wrongSkuList, v) - } else { - dao.WrapAddIDCULDEntity(actSkuMap, ctx.GetUserName()) - actStoreSkuMapList = append(actStoreSkuMapList, actSkuMap) + if act.Type != model.ActSkuFake { + if err2 := checkDiscountValidation(act.Type, int(actSkuMap.ActualActPrice*100/actSkuMap.VendorPrice)); err2 != nil { + v.ErrMsg = err2.Error() + v.ActualActPrice = actSkuMap.ActualActPrice + wrongSkuList = append(wrongSkuList, v) + } else { + dao.WrapAddIDCULDEntity(actSkuMap, ctx.GetUserName()) + actStoreSkuMapList = append(actStoreSkuMapList, actSkuMap) + } } } wholeValidVendorMap[vendorID] = 1 From a186ea33bd6d423f55a0f099cd107c61b437e8ed Mon Sep 17 00:00:00 2001 From: gazebo Date: Mon, 4 Nov 2019 14:49:35 +0800 Subject: [PATCH 58/67] up --- business/jxstore/act/act.go | 2 -- 1 file changed, 2 deletions(-) diff --git a/business/jxstore/act/act.go b/business/jxstore/act/act.go index 81727c284..8b9d77067 100644 --- a/business/jxstore/act/act.go +++ b/business/jxstore/act/act.go @@ -160,8 +160,6 @@ func ActStoreSkuParam2Model(ctx *jxcontext.Context, db *dao.DaoDB, act *model.Ac if actSkuMap.ActualActPrice <= 0 { actSkuMap.ActualActPrice = 1 } - } - if act.Type != model.ActSkuFake { if err2 := checkDiscountValidation(act.Type, int(actSkuMap.ActualActPrice*100/actSkuMap.VendorPrice)); err2 != nil { v.ErrMsg = err2.Error() v.ActualActPrice = actSkuMap.ActualActPrice From e1b7f82be3e38eab6f176710a34153970fbf5c48 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=8B=8F=E5=B0=B9=E5=B2=9A?= <770236076@qq.com> Date: Mon, 4 Nov 2019 15:21:05 +0800 Subject: [PATCH 59/67] =?UTF-8?q?=E5=AF=B9=E6=AF=94=E5=B7=AE=E5=BC=82?= =?UTF-8?q?=E6=96=87=E4=BB=B6=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- business/jxstore/cms/store_sku_check.go | 71 +++++++++++++++++++------ business/model/dao/sku.go | 2 +- business/model/sku.go | 1 + 3 files changed, 56 insertions(+), 18 deletions(-) diff --git a/business/jxstore/cms/store_sku_check.go b/business/jxstore/cms/store_sku_check.go index c6734a1f2..d64ee26ff 100644 --- a/business/jxstore/cms/store_sku_check.go +++ b/business/jxstore/cms/store_sku_check.go @@ -16,7 +16,6 @@ import ( "git.rosy.net.cn/jx-callback/business/jxutils/tasksch" "git.rosy.net.cn/jx-callback/business/model" "git.rosy.net.cn/jx-callback/business/partner" - "git.rosy.net.cn/jx-callback/business/partner/putils" "git.rosy.net.cn/jx-callback/globals" ) @@ -30,13 +29,14 @@ const ( //错误类型 const ( - DatAanalyse1 = "京东商品库直接创建,京西无数据" - DatAanalyse2 = "京东商品库未创建成功(可能无经营许可等) " + DatAanalyse1 = "京西门店未关注,应删除对应的平台门店商品" + DatAanalyse2 = "平台商品库未创建成功(可能无经营许可等) " DatAanalyse3 = "商品名不同 " DatAanalyse4 = "商品可售状态不同 " DatAanalyse5 = "京西商品库没有,平台商品库有 " DatAanalyse6 = "京西商品库有,平台商品库没有" DatAanalyse7 = "同步状态异常" + DatAanalyse8 = "平台门店未关注,应添加对应的平台门店商品" ) var ( @@ -96,10 +96,11 @@ var ( diffData DiffDataLock depotDiffData DeoptDiffDataLock - multiStoreAllSkuInfoMap map[int]map[int]*partner.SkuNameInfo - multiStoreAllSkuInfoList map[int][]*partner.StoreSkuInfo - skuNameInfoList []*partner.SkuNameInfo - filterCloseSkuIds []int + multiStoreAllSkuInfoMap map[int]map[int]*partner.SkuNameInfo + multiStoreAllSkuInfoList map[int][]*partner.StoreSkuInfo + skuNameInfoList []*partner.SkuNameInfo + filterVendorDepotUnSaleSkuIds []int + filterJxDepotUnSaleSkuIds []int ) type DiffDataLock struct { @@ -177,9 +178,21 @@ func GetMultiStoreAllSkuInfoList(vendorID int) []*partner.StoreSkuInfo { return multiStoreAllSkuInfoList[vendorID] } +//过滤掉平台下架的 +func StoreSkuFullList2BareFilter(storeSkuFull []*partner.SkuNameInfo) (bareStoreSkuList []*partner.StoreSkuInfo) { + for _, v := range storeSkuFull { + for _, v2 := range v.SkuList { + if v2.Status > model.SkuStatusDontSale { + bareStoreSkuList = append(bareStoreSkuList, &v2.StoreSkuInfo) + } + } + } + return bareStoreSkuList +} + func GetMultiStoreAllSkuInfo(ctx *jxcontext.Context, vendorMap map[int]bool) { InitMultiStoreData() - filterCloseSkuIds = filterCloseSkuIds[0:0] + filterVendorDepotUnSaleSkuIds = filterVendorDepotUnSaleSkuIds[0:0] for vendorID, _ := range vendorNameList { //filter for vendorID if len(vendorMap) > 0 { @@ -194,13 +207,13 @@ func GetMultiStoreAllSkuInfo(ctx *jxcontext.Context, vendorMap map[int]bool) { if err != nil { baseapi.SugarLogger.Errorf("GetMultiStoreAllSkuInfo error:%v", err) } else { - multiStoreAllSkuInfoList[vendorID] = putils.StoreSkuFullList2Bare(allSkuNameInfoList) //map[平台ID:[]StoreSkuInfo1,StoreSkuInfo2...] + multiStoreAllSkuInfoList[vendorID] = StoreSkuFullList2BareFilter(allSkuNameInfoList) //map[平台ID:[]StoreSkuInfo1,StoreSkuInfo2...] tempMap := make(map[int]*partner.SkuNameInfo) for _, value := range allSkuNameInfoList { for _, skuInfo := range value.SkuList { //表示平台商品库未下架的 if skuInfo.Status > model.SkuStatusDontSale { - filterCloseSkuIds = append(filterCloseSkuIds, skuInfo.SkuID) + filterVendorDepotUnSaleSkuIds = append(filterVendorDepotUnSaleSkuIds, skuInfo.SkuID) tempMap[skuInfo.SkuID] = value } } @@ -311,7 +324,6 @@ func IsSkuCanSale(saleStatus int) bool { //storeIDStr 京西商家id ,vendorStoreID 平台商家id func CompareJxAndVendor(vendorID int, storeIDStr, vendorStoreID, storeName string, filterJxSkuInfoMap map[int]*StoreSkuNameExt, filterVendorSkuInfoMap map[int]*partner.SkuNameInfo) { for skuID, jxSkuInfo := range filterJxSkuInfoMap { - reason := `` skuIDStr := utils.Int2Str(skuID) var jxSkuDetailName string //多规格商品不用比较数量单位 @@ -350,6 +362,7 @@ func CompareJxAndVendor(vendorID int, storeIDStr, vendorStoreID, storeName strin isNameDiff = false } if isSaleStatusDiff || isNameDiff { + reason := "" if isNameDiff { reason += DatAanalyse3 } @@ -369,7 +382,13 @@ func CompareJxAndVendor(vendorID int, storeIDStr, vendorStoreID, storeName strin if isFilterToBeCreateAndNotSale && model.IsSyncStatusNeedCreate(status) && !IsSkuCanSale(jxSkuSaleStatus) { continue } - outPutData := DiffData{storeIDStr, vendorStoreID, storeName, skuIDStr, syncStatus, toBeCreate, toBeDel, jxSkuDetailName, "", jxSkuSaleStatusName, "", DatAanalyse2} + reason := "" + if status == 0 { + reason = DatAanalyse8 + } else { + reason = DatAanalyse2 + } + outPutData := DiffData{storeIDStr, vendorStoreID, storeName, skuIDStr, syncStatus, toBeCreate, toBeDel, jxSkuDetailName, "", jxSkuSaleStatusName, "", reason} diffData.AppendData(vendorID, outPutData) } } @@ -394,6 +413,19 @@ func CompareJxAndVendor(vendorID int, storeIDStr, vendorStoreID, storeName strin } } +func FilterJxDepotUnSaleSkuID() { + db := dao.GetDB() + filterJxDepotUnSaleSkuIds = filterJxDepotUnSaleSkuIds[0:0] + skuList, _ := dao.GetSkus(db, filterVendorDepotUnSaleSkuIds, []int{}, []int{}, []int{}) + filterJxSkuInfoMap2 := GetFilterJxSkuInfoMap2(skuList) + for skuid, jxSkuInfo := range filterJxSkuInfoMap2 { + //过滤掉平台库下架,且京西库下架的商品,为下面比较门店商品用 + if jxSkuInfo.Status != model.SkuStatusDontSale { + filterJxDepotUnSaleSkuIds = append(filterJxDepotUnSaleSkuIds, skuid) + } + } +} + func CompareJxAndMultiVenderDepot(ctx *jxcontext.Context, vendorMap map[int]bool) { db := dao.GetDB() for vendorID, _ := range vendorNameList { @@ -404,15 +436,19 @@ func CompareJxAndMultiVenderDepot(ctx *jxcontext.Context, vendorMap map[int]bool } } if partner.IsMultiStore(vendorID) { - // multiHandler := partner.GetPurchasePlatformFromVendorID(vendorID).(partner.IMultipleStoresHandler) - // allSkuNameInfoList, _ := multiHandler.GetSkus(ctx, 0, "", "") + FilterJxDepotUnSaleSkuID() filterVendorSkuInfoMap := GetFilterVendorSkuInfoMap(skuNameInfoList) skuNameInfoList = skuNameInfoList[0:0] skuList, _ := dao.GetSkus(db, []int{}, []int{}, []int{}, []int{}) filterJxSkuInfoMap2 := GetFilterJxSkuInfoMap2(skuList) for skuid, jxSkuInfo := range filterJxSkuInfoMap2 { - reason := `` - jxSkuDetailName := jxutils.ComposeSkuName(jxSkuInfo.Prefix, jxSkuInfo.Name, jxSkuInfo.Comment, jxSkuInfo.Unit, jxSkuInfo.SpecQuality, jxSkuInfo.SpecUnit, 0) + var jxSkuDetailName string + //多规格商品不用比较数量单位 + if jxSkuInfo.IsSpu == 0 { + jxSkuDetailName = jxutils.ComposeSkuName(jxSkuInfo.Prefix, jxSkuInfo.Name, jxSkuInfo.Comment, jxSkuInfo.Unit, jxSkuInfo.SpecQuality, jxSkuInfo.SpecUnit, 0) + } else { + jxSkuDetailName = jxutils.ComposeSkuName(jxSkuInfo.Prefix, jxSkuInfo.Name, jxSkuInfo.Comment, "", jxSkuInfo.SpecQuality, "", 0) + } vendorSkuInfoMap := filterVendorSkuInfoMap[skuid] jxSkuSaleStatus := jxSkuInfo.Status @@ -424,6 +460,7 @@ func CompareJxAndMultiVenderDepot(ctx *jxcontext.Context, vendorMap map[int]bool isSaleStatusDiff := jxSkuSaleStatusName != vendorSkuSaleStatusName isNameDiff := strings.Compare(jxSkuDetailName, vendorSkuDetailName) != 0 if isNameDiff || isSaleStatusDiff { + reason := "" if isNameDiff { reason += DatAanalyse3 } @@ -507,7 +544,7 @@ func CheckSkuDiffBetweenJxAndVendor(ctx *jxcontext.Context, vendorIDList []int, if isGetJxSkuInfoData == false { //only get once jx sku info list every store id isGetJxSkuInfoData = true - jxSkuInfoData, _ := GetStoreSkus(ctx, storeID, filterCloseSkuIds, true, "", true, false, map[string]interface{}{}, 0, -1) + jxSkuInfoData, _ := GetStoreSkus(ctx, storeID, filterJxDepotUnSaleSkuIds, true, "", true, false, map[string]interface{}{}, 0, -1) filterJxSkuInfoMap = GetFilterJxSkuInfoMap(jxSkuInfoData.SkuNames) //map[京西商品ID:StoreSkuNameExt] } diff --git a/business/model/dao/sku.go b/business/model/dao/sku.go index 34bc1fc8c..d48c657e2 100644 --- a/business/model/dao/sku.go +++ b/business/model/dao/sku.go @@ -51,7 +51,7 @@ func DeleteSkuNamePlace(db *DaoDB, nameID int, placeCodes []int) (num int64, err func GetSkus(db *DaoDB, skuIDs, nameIDs, statuss, catIDs []int) (skuList []*model.SkuAndName, err error) { sql := ` - SELECT t1.*, t2.name, t2.unit, t2.prefix + SELECT t1.*, t2.name, t2.unit, t2.prefix, t2.is_spu FROM sku t1 JOIN sku_name t2 ON t2.id = t1.name_id AND t2.deleted_at = ? ` diff --git a/business/model/sku.go b/business/model/sku.go index 9a06434e3..79dd52c62 100644 --- a/business/model/sku.go +++ b/business/model/sku.go @@ -239,6 +239,7 @@ type SkuAndName struct { Name string Unit string Prefix string + IsSpu int } // func (*Sku) TableUnique() [][]string { From 163087857a721d406efd17e7be0cdae5d0292660 Mon Sep 17 00:00:00 2001 From: gazebo Date: Mon, 4 Nov 2019 15:41:41 +0800 Subject: [PATCH 60/67] =?UTF-8?q?=E5=AF=B9=E5=95=86=E5=93=81=E5=90=8D?= =?UTF-8?q?=E8=BF=9B=E8=A1=8Ctrim?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- business/jxstore/cms/sku.go | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/business/jxstore/cms/sku.go b/business/jxstore/cms/sku.go index f17b43b31..f2c46b0a4 100644 --- a/business/jxstore/cms/sku.go +++ b/business/jxstore/cms/sku.go @@ -541,6 +541,7 @@ func AddSkuName(ctx *jxcontext.Context, skuNameExt *model.SkuNameExt, userName s } } + skuNameExt.Name = utils.TrimBlankChar(skuNameExt.Name) if hasSensitiveWord, err := CheckHasSensitiveWord(skuNameExt.Name); hasSensitiveWord { return nil, err } @@ -658,9 +659,12 @@ func UpdateSkuName(ctx *jxcontext.Context, nameID int, payload map[string]interf return 0, err } - newSkuName := utils.Interface2String(payload["name"]) - if hasSensitiveWord, err := CheckHasSensitiveWord(newSkuName); hasSensitiveWord { - return 0, err + if payload["name"] != nil { + newSkuName := utils.TrimBlankChar(utils.Interface2String(payload["name"])) + if hasSensitiveWord, err := CheckHasSensitiveWord(newSkuName); hasSensitiveWord { + return 0, err + } + payload["name"] = newSkuName } delete(payload, "isSpu") From a09e3379f372ec0170fd68b246cdf9e732e027ab Mon Sep 17 00:00:00 2001 From: gazebo Date: Mon, 4 Nov 2019 16:03:31 +0800 Subject: [PATCH 61/67] =?UTF-8?q?SendMsg2Somebod=E6=94=AF=E6=8C=81?= =?UTF-8?q?=E5=BB=BA=E8=AE=AEy?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- business/jxstore/cms/cms.go | 15 +++++++++++++-- controllers/cms.go | 2 +- 2 files changed, 14 insertions(+), 3 deletions(-) diff --git a/business/jxstore/cms/cms.go b/business/jxstore/cms/cms.go index 9aa2f3da6..61a09669b 100644 --- a/business/jxstore/cms/cms.go +++ b/business/jxstore/cms/cms.go @@ -28,6 +28,7 @@ import ( const ( SendMsgTypeOpenStoreRequest = "openStoreRequest" + SendMsgTypeSuggestRequest = "suggestRequest" ) var ( @@ -44,6 +45,14 @@ var ( // "徐建华", // "周扬", }, + SendMsgTypeSuggestRequest: []string{ + "石锋", + // "徐建华", + // "周扬", + }, + } + needConfirmRequestMap = map[string]int{ + SendMsgTypeOpenStoreRequest: 1, } ) @@ -162,8 +171,10 @@ func GetCoordinateDistrictCode(ctx *jxcontext.Context, lng, lat float64) (code i } func SendMsg2Somebody(ctx *jxcontext.Context, mobileNum, verifyCode, msgType, msgContent string) (err error) { - if _, err = mobile.AutherObj.VerifySecret(mobileNum, verifyCode); err != nil { - return err + if needConfirmRequestMap[msgType] == 1 { + if _, err = mobile.AutherObj.VerifySecret(mobileNum, verifyCode); err != nil { + return err + } } db := dao.GetDB() for _, v := range receiveMsgUsersMap[msgType] { diff --git a/controllers/cms.go b/controllers/cms.go index 9bd8cb168..4114e181b 100644 --- a/controllers/cms.go +++ b/controllers/cms.go @@ -223,7 +223,7 @@ func (c *CmsController) FakeNewOrder() { // @Title 发送消息给相关人员 // @Description 发送消息给相关人员 // @Param mobile formData string true "手机号" -// @Param verifyCode formData string true "验证码" +// @Param verifyCode formData string false "验证码" // @Param msgType formData string true "消息类型" // @Param msgContent formData string true "消息内容" // @Success 200 {object} controllers.CallResult From 99868cd068a586e0167c88d753b14f175a56b8c3 Mon Sep 17 00:00:00 2001 From: gazebo Date: Mon, 4 Nov 2019 17:06:31 +0800 Subject: [PATCH 62/67] =?UTF-8?q?=E4=BC=98=E5=8C=96=E4=BF=AE=E6=94=B9?= =?UTF-8?q?=E4=BB=B7=E6=A0=BC=E5=8C=85=E6=97=B6=EF=BC=8C=E6=9B=B4=E6=96=B0?= =?UTF-8?q?=E9=97=A8=E5=BA=97=E5=95=86=E5=93=81=E5=90=8C=E6=AD=A5=E7=8A=B6?= =?UTF-8?q?=E6=80=81=E7=9A=84=E9=80=9F=E5=BA=A6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- business/jxstore/cms/cms.go | 17 ++++++++++++----- business/model/dao/store_sku.go | 6 +++--- 2 files changed, 15 insertions(+), 8 deletions(-) diff --git a/business/jxstore/cms/cms.go b/business/jxstore/cms/cms.go index 61a09669b..346ca1a4f 100644 --- a/business/jxstore/cms/cms.go +++ b/business/jxstore/cms/cms.go @@ -348,13 +348,20 @@ func UpdateConfig(ctx *jxcontext.Context, key, configType, value string) (hint s return "", err } dao.Commit(db) + vendorStoreMap := make(map[int][]int) for _, v := range storeMapList { - if _, err = dao.UpdateEntityLogicallyAndUpdateSyncStatus(db, &model.StoreSkuBind{}, nil, ctx.GetUserName(), map[string]interface{}{ - model.FieldStoreID: v.StoreID, - }, dao.GetSyncStatusStructField(model.VendorNames[v.VendorID]), model.SyncFlagPriceMask); err != nil { - return "", err - } + vendorStoreMap[v.VendorID] = append(vendorStoreMap[v.VendorID], v.StoreID) } + for vendorID, storeIDs := range vendorStoreMap { + dao.SetStoreSkuSyncStatus(db, vendorID, storeIDs, nil, model.SyncFlagPriceMask) + } + // for _, v := range storeMapList { + // if _, err = dao.UpdateEntityLogicallyAndUpdateSyncStatus(db, &model.StoreSkuBind{}, nil, ctx.GetUserName(), map[string]interface{}{ + // model.FieldStoreID: v.StoreID, + // }, dao.GetSyncStatusStructField(model.VendorNames[v.VendorID]), model.SyncFlagPriceMask); err != nil { + // return "", err + // } + // } case model.ConfigTypeFreightPack: dao.Commit(db) storeMapList, err := dao.GetStoresMapList(db, nil, nil, model.StoreStatusAll, model.StoreIsSyncYes, "") diff --git a/business/model/dao/store_sku.go b/business/model/dao/store_sku.go index d61410ad5..1b0b9be91 100644 --- a/business/model/dao/store_sku.go +++ b/business/model/dao/store_sku.go @@ -380,9 +380,9 @@ func SetStoreSkuSyncStatus(db *DaoDB, vendorID int, storeIDs []int, skuIDs []int ` fmtParams = append(fmtParams, fieldPrefix) } - sql += " WHERE (t1.deleted_at = ?)" - // fmtParams = append(fmtParams, fieldPrefix) - sqlParams = append(sqlParams, utils.DefaultTimeValue) + sql += " WHERE t1.deleted_at = ? AND t1.%s_sync_status & ? = 0" + fmtParams = append(fmtParams, fieldPrefix) + sqlParams = append(sqlParams, utils.DefaultTimeValue, model.SyncFlagDeletedMask) if len(storeIDs) > 0 { sql += " AND t1.store_id IN (" + GenQuestionMarks(len(storeIDs)) + ")" sqlParams = append(sqlParams, storeIDs) From 0034be1bef1b29f5387b46d922c0463c364e832d Mon Sep 17 00:00:00 2001 From: gazebo Date: Mon, 4 Nov 2019 17:14:38 +0800 Subject: [PATCH 63/67] =?UTF-8?q?=E7=BB=93=E7=AE=97=E6=B4=BB=E5=8A=A8?= =?UTF-8?q?=E4=B8=8D=E8=AE=BE=E7=BD=AE=E5=BE=85=E5=88=9B=E5=BB=BA=E5=90=8C?= =?UTF-8?q?=E6=AD=A5=E6=A0=87=E8=AF=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- business/jxstore/act/act.go | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/business/jxstore/act/act.go b/business/jxstore/act/act.go index 8b9d77067..d84c4a540 100644 --- a/business/jxstore/act/act.go +++ b/business/jxstore/act/act.go @@ -144,6 +144,7 @@ func ActStoreSkuParam2Model(ctx *jxcontext.Context, db *dao.DaoDB, act *model.Ac } if act.Type == model.ActSkuFake { actSkuMap.ActualActPrice = 0 + actSkuMap.SyncStatus = 0 } else { if v.ActPrice != 0 { actSkuMap.ActualActPrice = v.ActPrice @@ -410,6 +411,9 @@ func CreateAct(ctx *jxcontext.Context, act *model.Act, vendorIDs []int, actRules SyncStatus: model.SyncFlagNewMask, } + if act.Type == model.ActSkuFake { + actMap.SyncStatus = 0 + } dao.WrapAddIDCULDEntity(actMap, ctx.GetUserName()) actMapList = append(actMapList, actMap) } From 6302e384632d8a34495c9557988e00615b184fa4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=8B=8F=E5=B0=B9=E5=B2=9A?= <770236076@qq.com> Date: Mon, 4 Nov 2019 17:52:34 +0800 Subject: [PATCH 64/67] =?UTF-8?q?=E5=B7=AE=E5=BC=82=E5=AF=B9=E6=AF=94?= =?UTF-8?q?=E7=A8=8B=E5=BA=8F=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- business/jxstore/cms/store_sku_check.go | 41 +++++++++++++++++-------- 1 file changed, 29 insertions(+), 12 deletions(-) diff --git a/business/jxstore/cms/store_sku_check.go b/business/jxstore/cms/store_sku_check.go index d64ee26ff..c93deca67 100644 --- a/business/jxstore/cms/store_sku_check.go +++ b/business/jxstore/cms/store_sku_check.go @@ -36,7 +36,7 @@ const ( DatAanalyse5 = "京西商品库没有,平台商品库有 " DatAanalyse6 = "京西商品库有,平台商品库没有" DatAanalyse7 = "同步状态异常" - DatAanalyse8 = "平台门店未关注,应添加对应的平台门店商品" + DatAanalyse8 = "平台门店未关注或平台门店商品库存为0,应添加对应的平台门店商品" ) var ( @@ -369,11 +369,14 @@ func CompareJxAndVendor(vendorID int, storeIDStr, vendorStoreID, storeName strin if isSaleStatusDiff { reason += DatAanalyse4 } + if status != model.SkuStatusDontSale { + reason += DatAanalyse7 + } outPutData := DiffData{storeIDStr, vendorStoreID, storeName, skuIDStr, syncStatus, toBeCreate, toBeDel, jxSkuDetailName, vendorSkuDetailName, jxSkuSaleStatusName, vendorSkuSaleStatusName, reason} diffData.AppendData(vendorID, outPutData) } if !isSaleStatusDiff && !isNameDiff { - if status != 0 { + if status != model.SkuStatusDontSale { outPutData := DiffData{storeIDStr, vendorStoreID, storeName, skuIDStr, syncStatus, toBeCreate, toBeDel, jxSkuDetailName, vendorSkuDetailName, jxSkuSaleStatusName, vendorSkuSaleStatusName, DatAanalyse7} diffData.AppendData(vendorID, outPutData) } @@ -383,11 +386,14 @@ func CompareJxAndVendor(vendorID int, storeIDStr, vendorStoreID, storeName strin continue } reason := "" - if status == 0 { + if status == model.SkuStatusDontSale { reason = DatAanalyse8 } else { reason = DatAanalyse2 } + if status != model.SkuStatusDontSale { + reason += DatAanalyse7 + } outPutData := DiffData{storeIDStr, vendorStoreID, storeName, skuIDStr, syncStatus, toBeCreate, toBeDel, jxSkuDetailName, "", jxSkuSaleStatusName, "", reason} diffData.AppendData(vendorID, outPutData) } @@ -537,15 +543,26 @@ func CheckSkuDiffBetweenJxAndVendor(ctx *jxcontext.Context, vendorIDList []int, storeIDStr := utils.Int2Str(storeID) storeName := jxStoreInfoListValue.Name if jxStoreInfoListValue.StoreMaps != nil { - isGetJxSkuInfoData := false - var filterJxSkuInfoMap map[int]*StoreSkuNameExt + var filterJxSkuInfoMapSingle map[int]*StoreSkuNameExt + var filterJxSkuInfoMapMulti map[int]*StoreSkuNameExt for _, vendorListValue := range jxStoreInfoListValue.StoreMaps { vendorID := int(utils.MustInterface2Int64(vendorListValue["vendorID"])) - - if isGetJxSkuInfoData == false { //only get once jx sku info list every store id - isGetJxSkuInfoData = true - jxSkuInfoData, _ := GetStoreSkus(ctx, storeID, filterJxDepotUnSaleSkuIds, true, "", true, false, map[string]interface{}{}, 0, -1) - filterJxSkuInfoMap = GetFilterJxSkuInfoMap(jxSkuInfoData.SkuNames) //map[京西商品ID:StoreSkuNameExt] + //京西的门店商品只取一次 + flag := false + jxSkuInfoDataSingle := &StoreSkuNamesInfo{} + jxSkuInfoDataMulti := &StoreSkuNamesInfo{} + if partner.IsMultiStore(vendorID) { + if flag == false { + jxSkuInfoDataMulti, _ = GetStoreSkus(ctx, storeID, filterJxDepotUnSaleSkuIds, true, "", true, false, map[string]interface{}{}, 0, -1) + filterJxSkuInfoMapMulti = GetFilterJxSkuInfoMap(jxSkuInfoDataMulti.SkuNames) //map[京西商品ID:StoreSkuNameExt] + flag = true + } + } else { + if flag == false { + jxSkuInfoDataSingle, _ = GetStoreSkus(ctx, storeID, []int{}, true, "", true, false, map[string]interface{}{}, 0, -1) + filterJxSkuInfoMapSingle = GetFilterJxSkuInfoMap(jxSkuInfoDataSingle.SkuNames) //map[京西商品ID:StoreSkuNameExt] + flag = true + } } vendorStoreID := utils.Interface2String(vendorListValue["vendorStoreID"]) @@ -559,7 +576,7 @@ func CheckSkuDiffBetweenJxAndVendor(ctx *jxcontext.Context, vendorIDList []int, baseapi.SugarLogger.Infof("CheckSkuDiffBetweenJxAndVendor GetStoreSkusBareInfo error:%v", err) } else if len(skuBareInfoList) > 0 { filterSkuInfoMap := GetFilterMultiStoreSkuInfoMap(vendorID, skuBareInfoList) //map[京东商品ID:SkuNameInfo] - CompareJxAndVendor(vendorID, storeIDStr, vendorStoreID, storeName, filterJxSkuInfoMap, filterSkuInfoMap) + CompareJxAndVendor(vendorID, storeIDStr, vendorStoreID, storeName, filterJxSkuInfoMapMulti, filterSkuInfoMap) } } else { singleStoreHandler := partner.GetPurchasePlatformFromVendorID(vendorID).(partner.ISingleStoreStoreSkuHandler) @@ -568,7 +585,7 @@ func CheckSkuDiffBetweenJxAndVendor(ctx *jxcontext.Context, vendorIDList []int, baseapi.SugarLogger.Infof("CheckSkuDiffBetweenJxAndVendor GetStoreSkusFullInfo error:%v", err) } else if len(vendorSkuInfoList) > 0 { filterVendorSkuInfoMap := GetFilterVendorSkuInfoMap(vendorSkuInfoList) //map[平台商品ID:SkuNameInfo] - CompareJxAndVendor(vendorID, storeIDStr, vendorStoreID, storeName, filterJxSkuInfoMap, filterVendorSkuInfoMap) + CompareJxAndVendor(vendorID, storeIDStr, vendorStoreID, storeName, filterJxSkuInfoMapSingle, filterVendorSkuInfoMap) } } } From af32f1f7bda20cc09d282076df1b386e7181c80f Mon Sep 17 00:00:00 2001 From: gazebo Date: Mon, 4 Nov 2019 18:40:49 +0800 Subject: [PATCH 65/67] =?UTF-8?q?syncStoreSkuNew=E4=B8=AD=EF=BC=8C?= =?UTF-8?q?=E5=9B=A0=E4=B8=BA=E4=BA=AC=E4=B8=9C=E5=B9=B3=E5=8F=B0=E4=BB=A5?= =?UTF-8?q?=E6=98=AF=E5=90=A6=E6=9C=89=E5=BA=93=E5=AD=98=E8=A1=A8=E7=A4=BA?= =?UTF-8?q?=E6=98=AF=E5=90=A6=E5=85=B3=E6=B3=A8=EF=BC=8C=E6=89=80=E4=BB=A5?= =?UTF-8?q?=E4=B8=8D=E8=AE=BA=E6=98=AF=E5=90=A6=E5=8F=AF=E5=94=AE=EF=BC=8C?= =?UTF-8?q?=E9=83=BD=E8=A6=81=E8=AE=BE=E7=BD=AE=E5=BA=93=E5=AD=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- business/jxstore/cms/sync_store_sku.go | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/business/jxstore/cms/sync_store_sku.go b/business/jxstore/cms/sync_store_sku.go index 74efff588..50b7801cc 100644 --- a/business/jxstore/cms/sync_store_sku.go +++ b/business/jxstore/cms/sync_store_sku.go @@ -404,6 +404,10 @@ func syncStoreSkuNew(ctx *jxcontext.Context, parentTask tasksch.ITask, isFull bo stockList = append(stockList, bareSku) } else { offlineList = append(offlineList, bareSku) + // 因为京东平台以是否有库存表示是否关注,所以不论是否可售,都要设置库存 + if singleStoreHandler == nil { + stockList = append(stockList, bareSku) + } } } } From 9cbfa6f6eff937fec26c24c260f0b341415e9566 Mon Sep 17 00:00:00 2001 From: gazebo Date: Mon, 4 Nov 2019 20:55:49 +0800 Subject: [PATCH 66/67] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E4=BB=8A=E5=A4=A9?= =?UTF-8?q?=E6=94=B9=E7=BB=93=E7=AE=97=E5=BC=95=E5=85=A5=E7=9A=84bug?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- business/jxstore/act/act.go | 30 +++++++++++++++--------------- 1 file changed, 15 insertions(+), 15 deletions(-) diff --git a/business/jxstore/act/act.go b/business/jxstore/act/act.go index d84c4a540..eef24edb7 100644 --- a/business/jxstore/act/act.go +++ b/business/jxstore/act/act.go @@ -128,24 +128,23 @@ func ActStoreSkuParam2Model(ctx *jxcontext.Context, db *dao.DaoDB, act *model.Ac StoreID: storeID, SkuID: v.SkuID, VendorID: vendorID, - - SyncStatus: model.SyncFlagNewMask, } v.OriginalPrice = actSkuMap.VendorPrice - if storeSkuInfo := storeSkuMap[jxutils.Combine2Int(v.StoreID, v.SkuID)]; storeSkuInfo != nil { + storeSkuInfo := storeSkuMap[jxutils.Combine2Int(v.StoreID, v.SkuID)] + if storeSkuInfo != nil { jxPrice := storeSkuInfo.Price pricePercentage := jxutils.GetPricePercentage(storeDetail.PricePercentagePackObj, jxPrice, int(storeDetail.PricePercentage)) actSkuMap.VendorPrice = int64(jxutils.CaculateSkuVendorPrice(jxPrice, pricePercentage)) v.OriginalPrice = int64(jxPrice) - } else if act.Type != model.ActSkuFake { - v.ErrMsg = fmt.Sprintf("门店:%d没有关注商品:%d", v.StoreID, v.SkuID) - wrongSkuList = append(wrongSkuList, v) - continue } - if act.Type == model.ActSkuFake { - actSkuMap.ActualActPrice = 0 - actSkuMap.SyncStatus = 0 - } else { + var err2 error + if act.Type != model.ActSkuFake { + if storeSkuInfo == nil { + v.ErrMsg = fmt.Sprintf("门店:%d没有关注商品:%d", v.StoreID, v.SkuID) + wrongSkuList = append(wrongSkuList, v) + continue + } + actSkuMap.SyncStatus = model.SyncFlagNewMask if v.ActPrice != 0 { actSkuMap.ActualActPrice = v.ActPrice } else { @@ -161,15 +160,16 @@ func ActStoreSkuParam2Model(ctx *jxcontext.Context, db *dao.DaoDB, act *model.Ac if actSkuMap.ActualActPrice <= 0 { actSkuMap.ActualActPrice = 1 } - if err2 := checkDiscountValidation(act.Type, int(actSkuMap.ActualActPrice*100/actSkuMap.VendorPrice)); err2 != nil { + if err2 = checkDiscountValidation(act.Type, int(actSkuMap.ActualActPrice*100/actSkuMap.VendorPrice)); err2 != nil { v.ErrMsg = err2.Error() v.ActualActPrice = actSkuMap.ActualActPrice wrongSkuList = append(wrongSkuList, v) - } else { - dao.WrapAddIDCULDEntity(actSkuMap, ctx.GetUserName()) - actStoreSkuMapList = append(actStoreSkuMapList, actSkuMap) } } + if err2 == nil { + dao.WrapAddIDCULDEntity(actSkuMap, ctx.GetUserName()) + actStoreSkuMapList = append(actStoreSkuMapList, actSkuMap) + } } wholeValidVendorMap[vendorID] = 1 } else if !dao.IsNoRowsError(err) { From 00431b701dbcc97601060fe2e5bc1e84e8ff60cb Mon Sep 17 00:00:00 2001 From: gazebo Date: Tue, 5 Nov 2019 15:20:07 +0800 Subject: [PATCH 67/67] =?UTF-8?q?=E6=B2=A1=E6=9C=89=E5=9C=A8=E6=9C=AC?= =?UTF-8?q?=E5=9C=B0=E6=89=BE=E5=88=B0=E7=9A=84=E5=95=86=E5=93=81=EF=BC=8C?= =?UTF-8?q?=E4=B9=9F=E8=A6=81=E8=AE=BE=E7=BD=AEEarningPrice?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- business/jxcallback/orderman/order.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/business/jxcallback/orderman/order.go b/business/jxcallback/orderman/order.go index b1c52f003..303536042 100644 --- a/business/jxcallback/orderman/order.go +++ b/business/jxcallback/orderman/order.go @@ -361,9 +361,9 @@ func (c *OrderManager) updateOrderSkuOtherInfo(order *model.GoodsOrder, db *dao. if skuBindInfo.Price == 0 { globals.SugarLogger.Infof("updateOrderSkuOtherInfo [运营%s]%s订单sku门店价格为零(一般原因为没有门店价格信息),orderID:%s, StoreID:%d, SkuID:%d, sku:%v", opNumStr, model.VendorChineseNames[order.VendorID], order.VendorOrderID, jxStoreID, v.JxSkuID, v) } - v.EarningPrice = jxutils.CaculateSkuEarningPrice(v.ShopPrice, v.SalePrice, storePayPercentage) } } + v.EarningPrice = jxutils.CaculateSkuEarningPrice(v.ShopPrice, v.SalePrice, storePayPercentage) if skuID := jxutils.GetSkuIDFromOrderSku(v); skuID > 0 { skuIDMap[skuID] = 1