From 0178156c655df8456575c02474ad17730362cda1 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, 13 Jan 2020 18:18:58 +0800 Subject: [PATCH] =?UTF-8?q?=E8=AE=A2=E5=8D=95=E8=AF=A6=E6=83=85=E5=A2=9E?= =?UTF-8?q?=E5=8A=A0=E7=94=A8=E6=88=B7=E4=BF=A1=E6=81=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- business/jxcallback/orderman/orderman_ext.go | 15 +++++++++++++-- business/model/api.go | 10 +++++++--- 2 files changed, 20 insertions(+), 5 deletions(-) diff --git a/business/jxcallback/orderman/orderman_ext.go b/business/jxcallback/orderman/orderman_ext.go index a8cb01875..3bf0b2b45 100644 --- a/business/jxcallback/orderman/orderman_ext.go +++ b/business/jxcallback/orderman/orderman_ext.go @@ -136,11 +136,22 @@ func (c *OrderManager) GetOrderInfo(ctx *jxcontext.Context, vendorOrderID string // 这里用QueryRows而不用QueryRow的原因是用QueryRow在这种情况下不能将数据读出,很奇怪。大概的原因是QueryRow对于GoodsOrderExt这种有嵌入的struct处理有问题 num, err := db.Raw(` - SELECT t1.*, t2.status waybill_status, t2.courier_name, t2.courier_mobile + SELECT t3.*,ROUND(t3.shop_price/t3.count) avg_price, t1.*, t2.status waybill_status, t2.courier_name, t2.courier_mobile FROM goods_order t1 LEFT JOIN waybill t2 ON t1.vendor_waybill_id = t2.vendor_waybill_id AND t1.waybill_vendor_id = t2.waybill_vendor_id + JOIN ( + SELECT count(*) count,SUM(b.shop_price) - + IFNULL(SUM(c.sku_user_money+c.freight_user_money+c.afs_freight_money+c.box_money+c.tongcheng_freight_money+c.sku_box_money),0) shop_price,a.vendor_user_id,count(d.score < 3 or NULL) bad_comment_count + FROM goods_order a + JOIN order_sku b ON a.vendor_order_id = b.vendor_order_id AND a.vendor_id = b.vendor_id + LEFT JOIN afs_order c ON a.vendor_order_id = c.vendor_order_id AND c.vendor_id = a.vendor_id + LEFT JOIN jx_bad_comments d ON d.order_id = a.vendor_order_id AND d.order_flag = a.vendor_id + WHERE a.order_created_at BETWEEN ? AND NOW() + AND a.vendor_user_id = (SELECT vendor_user_id FROM goods_order WHERE vendor_order_id = ?) + GROUP BY a.vendor_user_id + )t3 ON t3.vendor_user_id = t1.vendor_user_id WHERE t1.vendor_order_id = ? AND vendor_id = ? - `, vendorOrderID, vendorID).QueryRows(&orders) + `, time.Now().AddDate(0, -1, 0), vendorOrderID, vendorOrderID, vendorID).QueryRows(&orders) if err == nil && num > 0 { order = orders[0] if isRefresh && vendorID == model.VendorIDJD { diff --git a/business/model/api.go b/business/model/api.go index 3e9cc32bb..7335631ae 100644 --- a/business/model/api.go +++ b/business/model/api.go @@ -39,9 +39,13 @@ type GoodsOrderExt struct { CityName string `json:"cityName"` PayPercentage int `json:"payPercentage"` - SkuInfo string `json:"skuInfo,omitempty"` - ShortSkuInfo `json:"-"` - SkuList []*ShortSkuInfo `json:"skuList,omitempty"` + SkuInfo string `json:"skuInfo,omitempty"` + ShortSkuInfo `json:"-"` + SkuList []*ShortSkuInfo `json:"skuList,omitempty"` + Count int `json:"count"` + ShopPrice int64 `json:"shopPrice"` + AvgPrice int64 `json:"avgPrice"` + BadCommentCount int `json:"badCommentCount"` } type OrderSkuExt struct {