From 39712e48b60821b5da11dae705ffed6082d9a08a Mon Sep 17 00:00:00 2001 From: tommy <3405129587@qq.com> Date: Tue, 28 Apr 2020 14:29:01 +0800 Subject: [PATCH] order no to sub --- controllers/client/good.go | 8 ++++---- models/customer_order_sub.go | 8 ++++---- test/pay_test.go | 5 +++-- 3 files changed, 11 insertions(+), 10 deletions(-) diff --git a/controllers/client/good.go b/controllers/client/good.go index 39a6748..558207f 100644 --- a/controllers/client/good.go +++ b/controllers/client/good.go @@ -81,16 +81,16 @@ func (t *GoodCtl) ListOrder() { orders, err := models.GetCustomerOrdersByActivityId(uid, activity.Id, activity.RehearsalId, areaId, statusList, t.Page, t.PageSize) t.CheckErr(err) - outTradeNos := make([]string, 0) + orderNos := make([]string, 0) for _, order := range orders { - outTradeNos = append(outTradeNos, order.OutTradeNo) + orderNos = append(orderNos, order.OrderNo) } - subs, err := models.GetCustomerOrderSubByOutTradeNos(outTradeNos...) + subs, err := models.GetCustomerOrderSubByOrderNos(orderNos...) t.CheckErr(err) for index, order := range orders { order.ServicePhone = option.MainServicePhone for _, sub := range subs { - if order.OutTradeNo == sub["out_trade_no"] { + if order.OrderNo == sub["order_no"] { orders[index].SubOrders = append(orders[index].SubOrders, sub) } } diff --git a/models/customer_order_sub.go b/models/customer_order_sub.go index c85d7e1..9b57400 100644 --- a/models/customer_order_sub.go +++ b/models/customer_order_sub.go @@ -32,11 +32,11 @@ func (t *CustomerOrderSub) Alias(n string) string { return fmt.Sprintf("%s as %s", t.TableName(), n) } -func GetCustomerOrderSubByOutTradeNos(outTradeNos ...string) (subs []map[string]string, err error) { +func GetCustomerOrderSubByOrderNos(orderNos ...string) (subs []map[string]string, err error) { err = core.GetXormAuto().Table(new(CustomerOrderSub)).Alias("s"). - Select("s.out_trade_no, s.goods_id, s.goods_num, s.good_name, s.good_price, g.goods_pic_url").Join("left", - new(CustomerGoods).Alias("g"), "g.id=s.goods_id"). - Where("s.is_delete=0").In("s.out_trade_no", outTradeNos). + Select("s.order_no, s.goods_id, s.goods_num, s.good_name, s.good_price, g.goods_pic_url"). + Join("left", new(CustomerGoods).Alias("g"), "g.id=s.goods_id"). + Where("s.is_delete=0").In("s.order_no", orderNos). Desc("s.created_at").Find(&subs) return } diff --git a/test/pay_test.go b/test/pay_test.go index 8f39e1c..9f7d1af 100644 --- a/test/pay_test.go +++ b/test/pay_test.go @@ -26,10 +26,10 @@ func TestSendRedPack(t *testing.T) { func TestQueryOrder(t *testing.T) { //outTradeNo := "Dn13Gl6A6dB6aOae7syqtXSwUvCZ3mta" - outTradeNo := "jGrqipGJdcxQz4uwSTQqrtnJ4rJE6Mx9" + outTradeNo := "6PM9n5WDSX47frNfQ9OxWEKe8u6ChBos" res, err := pay_service.OrderQuery(outTradeNo) fmt.Println(err) - fmt.Printf("%+v\n", res) + fmt.Printf("%+v\n", res.Query) } func TestClose(t *testing.T) { @@ -91,4 +91,5 @@ func TestMy(t *testing.T) { distance LIMIT 100; ` + fmt.Print(a) }