From ed8b123e1f540dacfc706178d4b37588b12dfd4b 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, 7 Aug 2020 09:39:39 +0800 Subject: [PATCH] =?UTF-8?q?=E6=A0=B9=E6=8D=AE=E6=97=B6=E9=97=B4=EF=BC=8C?= =?UTF-8?q?=E6=97=A5=E6=9C=9F=EF=BC=8C=E6=AF=94=E4=BE=8B=E8=BF=94=E5=9B=9E?= =?UTF-8?q?=E8=A6=81=E5=8A=A0=E5=85=A5=E8=B4=AD=E7=89=A9=E8=BD=A6=E7=9A=84?= =?UTF-8?q?=E5=95=86=E5=93=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- business/model/dao/dao_order.go | 33 ++++++++++++++++--- business/partner/purchase/jx/localjx/order.go | 6 ++-- controllers/jx_order2.go | 3 +- 3 files changed, 33 insertions(+), 9 deletions(-) diff --git a/business/model/dao/dao_order.go b/business/model/dao/dao_order.go index 30921e28e..0f1c6e031 100644 --- a/business/model/dao/dao_order.go +++ b/business/model/dao/dao_order.go @@ -1346,9 +1346,32 @@ func GetAfsOrdersByPage(db *DaoDB, vendorOrderID, afsOrderID, userID string, fro return afsOrderList, totalCount, err } -func GetSupplySupportStoreSkus(db *DaoDB, fromDate, toDate time.Time, fromStoreID, storeID int) (storeSkuBind []*model.StoreSkuBind, err error) { - // sql := ` - - // ` - return storeSkuBind, err +func GetSupplySupportStoreSkus(db *DaoDB, fromDate, toDate time.Time, fromStoreID, storeID int, percentage float64) (orderSkus []*model.OrderSku, err error) { + sql := ` + SELECT c.sku_id,CEIL(c.count) count,CEIL(c.count) * d.jx_price sale_price + FROM + ( + SELECT a.sku_id,SUM(a.count * ? ) count FROM order_sku a + JOIN goods_order b ON b.vendor_order_id = a.vendor_order_id AND a.vendor_id = b.vendor_id + WHERE b.order_created_at > ? + AND b.order_created_at < ? + AND a.sku_id <> ? + AND IF(b.store_id = 0,b.jx_store_id,b.store_id) = ? + GROUP BY 1 + )c + JOIN store_sku_bind d ON d.store_id = ? AND d.sku_id = c.sku_id AND d.deleted_at = ? + ORDER BY c.count desc + ` + sqlParams := []interface{}{ + percentage, + fromDate, + toDate, + 6039481, //葱姜蒜 + fromStoreID, + storeID, utils.DefaultTimeValue, + } + if err = GetRows(db, &orderSkus, sql, sqlParams); err == nil { + return orderSkus, err + } + return orderSkus, err } diff --git a/business/partner/purchase/jx/localjx/order.go b/business/partner/purchase/jx/localjx/order.go index bf86f98da..bda3862f5 100644 --- a/business/partner/purchase/jx/localjx/order.go +++ b/business/partner/purchase/jx/localjx/order.go @@ -1788,10 +1788,10 @@ func buildJxOrderInfo(order *model.GoodsOrder, orderSkus []*model.OrderSku) (jxO return jxOrder } -func GetSupplySupportStoreSkus(ctx *jxcontext.Context, fromDate, toDate string, fromStoreID, storeID int) (storeSkuBinds []*model.StoreSkuBind, err error) { +func GetSupplySupportStoreSkus(ctx *jxcontext.Context, fromDate, toDate string, fromStoreID, storeID int, percentage string) (orderSkus []*model.OrderSku, err error) { var ( db = dao.GetDB() ) - storeSkuBinds, err = dao.GetSupplySupportStoreSkus(db, utils.Str2Time(fromDate), utils.Str2Time(toDate), fromStoreID, storeID) - return storeSkuBinds, err + orderSkus, err = dao.GetSupplySupportStoreSkus(db, utils.Str2Time(fromDate), utils.Str2Time(toDate), fromStoreID, storeID, utils.Str2Float64(percentage)) + return orderSkus, err } diff --git a/controllers/jx_order2.go b/controllers/jx_order2.go index 082b85541..2e24eff2a 100644 --- a/controllers/jx_order2.go +++ b/controllers/jx_order2.go @@ -230,12 +230,13 @@ func (c *JxOrderController) SendFailedMatterOrder() { // @Param toDate query string false "结束日期(包含),格式(2006-01-02),如果订单号为空此项必须要求" // @Param fromStoreID query int false "进货门店ID" // @Param storeID query int false "货源门店ID" +// @Param percentage query string false "销量比例,1,1.05,1.1" // @Success 200 {object} controllers.CallResult // @Failure 200 {object} controllers.CallResult // @router /GetSupplySupportStoreSkus [get] func (c *JxOrderController) GetSupplySupportStoreSkus() { c.callGetSupplySupportStoreSkus(func(params *tJxorderGetSupplySupportStoreSkusParams) (retVal interface{}, errCode string, err error) { - retVal, err = localjx.GetSupplySupportStoreSkus(params.Ctx, params.FromDate, params.ToDate, params.FromStoreID, params.StoreID) + retVal, err = localjx.GetSupplySupportStoreSkus(params.Ctx, params.FromDate, params.ToDate, params.FromStoreID, params.StoreID, params.Percentage) return retVal, "", err }) }