增加品牌
This commit is contained in:
parent
e620d092fc
commit
209d2033c1
|
@ -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)
|
||||
|
|
|
@ -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)))
|
||||
}
|
||||
|
|
|
@ -36,6 +36,7 @@ type Orders struct {
|
|||
type OrdersProductsList struct {
|
||||
Orders `xorm:"extends"`
|
||||
MainImage string `xorm:"'main_image' varchar(255)"`
|
||||
Brand string `xorm:"'brand'"`
|
||||
}
|
||||
|
||||
// 表名
|
||||
|
|
|
@ -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 {
|
||||
|
|
Loading…
Reference in New Issue