From 209d2033c10936984ae7df54d0636e517d9a9188 Mon Sep 17 00:00:00 2001 From: "qiyunfanbo126.com" <815699> Date: Mon, 30 Sep 2024 15:43:48 +0800 Subject: [PATCH] =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E5=93=81=E7=89=8C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/http/controllers/front/OrderController.go | 6 +++--- app/http/entities/front/Order.go | 8 ++++++-- app/models/ordersmodel/orders.go | 1 + app/services/OrderService.go | 10 +++++----- 4 files changed, 15 insertions(+), 10 deletions(-) diff --git a/app/http/controllers/front/OrderController.go b/app/http/controllers/front/OrderController.go index b01e757..d3d3961 100644 --- a/app/http/controllers/front/OrderController.go +++ b/app/http/controllers/front/OrderController.go @@ -45,7 +45,7 @@ func OrderList(c *gin.Context) { func OrderQuery(c *gin.Context) { var request = controllers.GetRequest(c).(*front.OrderQueryRequest) orderId, _ := strconv.Atoi(request.OrderId) - order := ordersmodel.Orders{} + order := ordersmodel.OrdersProductsList{} order.Id = orderId order.OrderNo = request.OrderNo order.UserId = controllers.GetUserId(c) @@ -57,7 +57,7 @@ func OrderQuery(c *gin.Context) { } if has { if order.State < common.ORDER_STATUS_PAY && order.VoucherLink == "" { - _, rsp := services.YouChuOrderQuery(order) + _, rsp := services.YouChuOrderQuery(order.Orders) utils.Log(nil, "三方订单查询", rsp) if rsp.OrderSta == "03" { err := services.OrdersUpdateService(front.OrdersUpdateRequest{Id: order.Id, Status: common.ORDER_STATUS_PAY, OrgTxnSeq: rsp.OrderNo}) @@ -79,7 +79,7 @@ func OrderQuery(c *gin.Context) { func OrderState(c *gin.Context) { var request = controllers.GetRequest(c).(*front.OrderQueryRequest) orderId, _ := strconv.Atoi(request.OrderId) - order := ordersmodel.Orders{} + order := ordersmodel.OrdersProductsList{} order.Id = orderId order.OrderNo = request.OrderNo order.UserId = controllers.GetUserId(c) diff --git a/app/http/entities/front/Order.go b/app/http/entities/front/Order.go index 6e9cabd..2a3440c 100644 --- a/app/http/entities/front/Order.go +++ b/app/http/entities/front/Order.go @@ -36,6 +36,7 @@ type OrderListResponse struct { CreateTime string `json:"create_time"` NotifyUrl string `json:"notify_url"` ExchangeTime string `json:"exchange_time"` + Brand string `json:"brand"` } func (p *OrderListResponse) ResponseFromDb(l ordersmodel.OrdersProductsList) { @@ -45,6 +46,7 @@ func (p *OrderListResponse) ResponseFromDb(l ordersmodel.OrdersProductsList) { p.ExchangeTime = l.ExchangeTime.Format(time.DateTime) p.UserId = l.UserId p.CustNo = l.CustNo + p.Brand = l.Brand p.Price = l.Price p.ProductId = l.ProductId p.ProductName = l.ProductName @@ -78,13 +80,15 @@ type OrderQueryResponse struct { CreateTime string `json:"create_time"` NotifyUrl string `json:"notify_url"` ExchangeTime string `json:"exchange_time"` + Brand string `json:"brand"` } -func (p *OrderQueryResponse) ResponseFromDb(l ordersmodel.Orders) { - utils.EntityCopy(p, &l) +func (p *OrderQueryResponse) ResponseFromDb(l ordersmodel.OrdersProductsList) { + utils.EntityCopy(p, &l.Orders) p.NotifyUrl = config.GetConf().YouChu.NotifyUrl p.CreateTime = l.CreateTime.Format("2006-01-02 15:04:05") p.ExchangeTime = l.ExchangeTime.Format(time.DateTime) + p.Brand = l.Brand if l.VoucherLink != "" { p.VoucherLink = string(encrypt.AesDecryptCBC(l.VoucherLink, []byte(config.GetConf().OpenApiMarketConfig.SecretKey))) } diff --git a/app/models/ordersmodel/orders.go b/app/models/ordersmodel/orders.go index 31c3be2..7b47f69 100644 --- a/app/models/ordersmodel/orders.go +++ b/app/models/ordersmodel/orders.go @@ -36,6 +36,7 @@ type Orders struct { type OrdersProductsList struct { Orders `xorm:"extends"` MainImage string `xorm:"'main_image' varchar(255)"` + Brand string `xorm:"'brand'"` } // 表名 diff --git a/app/services/OrderService.go b/app/services/OrderService.go index 8c2bfea..1049956 100644 --- a/app/services/OrderService.go +++ b/app/services/OrderService.go @@ -105,13 +105,13 @@ func OrderQueryService(userId int, OrderRequest *front.OrderListRequest) (code i conn = conn.And(builder.Eq{"a.state": OrderRequest.State}) } count, err := repo.Where(conn).Alias("a"). - Join("INNER", "products b", "a.product_id = b.id").Select("a.*,b.main_image"). + Join("INNER", "products b", "a.product_id = b.id").Select("a.*,b.main_image,b.brand"). Desc("id").Limit(OrderRequest.PageSize, (OrderRequest.Page-1)*OrderRequest.PageSize).FindAndCount(&data) code = handErr(err) return } -func OrderDetailService(order *ordersmodel.Orders) (has bool, err error) { +func OrderDetailService(order *ordersmodel.OrdersProductsList) (has bool, err error) { repo := ordersmodel.GetInstance().GetDb() conn := builder.NewCond() if config.GetConf().Debug == false { @@ -123,7 +123,7 @@ func OrderDetailService(order *ordersmodel.Orders) (has bool, err error) { if order.OrderNo != "" { conn = conn.And(builder.Eq{"order_no": order.OrderNo}) } - return repo.Where(conn).Get(order) + return repo.Where(conn).Alias("a").Join("INNER", "products b", "a.product_id = b.id").Select("a.*,b.main_image,b.brand").Get(order) } func OrdersUpdateService(req front.OrdersUpdateRequest) (err error) { @@ -158,7 +158,7 @@ func OrderRefundService(userId int, orderId int) (code int) { return errorcode.SystemError } } - order := ordersmodel.Orders{} + order := ordersmodel.OrdersProductsList{} order.Id = orderId has, err := OrderDetailService(&order) if err != nil || !has { @@ -167,7 +167,7 @@ func OrderRefundService(userId int, orderId int) (code int) { if order.State != common.ORDER_STATUS_FAIL { return errorcode.OrderNOTAuthREFUND } - code, response := YouChuOrderRefund(order) + code, response := YouChuOrderRefund(order.Orders) if code != errorcode.Success { return code } else {