668 lines
16 KiB
Go
668 lines
16 KiB
Go
package controller
|
|
|
|
import (
|
|
"encoding/json"
|
|
"errors"
|
|
"fmt"
|
|
"github.com/codinl/go-logger"
|
|
"github.com/gin-gonic/gin"
|
|
"golang.org/x/sync/errgroup"
|
|
"io/ioutil"
|
|
"mh-server/kuaidi"
|
|
"mh-server/lib/auth"
|
|
"mh-server/lib/status"
|
|
"mh-server/lib/wxpay"
|
|
"mh-server/model"
|
|
"sync"
|
|
|
|
"time"
|
|
)
|
|
|
|
//func checkout(response http.ResponseWriter, request *http.Request) {
|
|
//func WxMsg(c *gin.Context) {
|
|
// // 获取参数
|
|
// signature := c.PostForm("signature")
|
|
// timestamp := c.PostForm("timestamp")
|
|
// nonce := c.PostForm("nonce")
|
|
// echostr := c.PostForm("echostr")
|
|
//
|
|
// //timestamp := request.FormValue("echostr")
|
|
// //nonce := request.FormValue("nonce")
|
|
// //echostr := request.FormValue("echostr")
|
|
//
|
|
// //将token、timestamp、nonce三个参数进行字典序排序
|
|
// var tempArray = []string{TOKEN, timestamp, nonce}
|
|
// sort.Strings(tempArray)
|
|
//
|
|
// //将三个参数字符串拼接成一个字符串进行sha1加密
|
|
// var sha1String string = ""
|
|
// for _, v := range tempArray {
|
|
// sha1String += v
|
|
// }
|
|
//
|
|
// h := sha1.New()
|
|
// h.Write([]byte(sha1String))
|
|
// sha1String = hex.EncodeToString(h.Sum([]byte("")))
|
|
//
|
|
// //获得加密后的字符串可与signature对比
|
|
// if sha1String == signature {
|
|
// _, err := c.Writer.Write([]byte(echostr))
|
|
// if err != nil {
|
|
// fmt.Println("响应失败。。。")
|
|
// }
|
|
// } else {
|
|
// fmt.Println("验证失败")
|
|
// }
|
|
//}
|
|
|
|
func OrderList(c *gin.Context) {
|
|
req := struct {
|
|
Page int `json:"page"`
|
|
PageSize int `json:"page_size"`
|
|
}{
|
|
Page: 1,
|
|
PageSize: 10,
|
|
}
|
|
if c.ShouldBindJSON(&req) != nil {
|
|
logger.Error("ShouldBindJSON err")
|
|
RespJson(c, status.BadRequest, nil)
|
|
return
|
|
}
|
|
uc := auth.GetCurrentUser(c)
|
|
if uc == nil {
|
|
logger.Error("uc is nil")
|
|
RespJson(c, status.Unauthorized, nil)
|
|
return
|
|
}
|
|
orderList, totalPage, err := model.GetOrderList(uint64(uc.Uid), req.Page, req.PageSize) // TODO
|
|
if err != nil {
|
|
logger.Error("err:", err)
|
|
RespJson(c, status.InternalServerError, nil)
|
|
return
|
|
}
|
|
|
|
ret := map[string]interface{}{
|
|
"order_list": orderList,
|
|
"cur_page": req.Page,
|
|
"total_page": totalPage,
|
|
}
|
|
RespOK(c, ret)
|
|
return
|
|
}
|
|
|
|
func OrderInfo(c *gin.Context) {
|
|
req := struct {
|
|
OrderId uint32 `json:"order_id"`
|
|
}{}
|
|
if c.ShouldBindJSON(&req) != nil {
|
|
logger.Error("ShouldBindJSON err")
|
|
RespJson(c, status.BadRequest, nil)
|
|
return
|
|
}
|
|
order := model.Order{}
|
|
order.ID = req.OrderId
|
|
info, err := order.Info()
|
|
if err != nil {
|
|
logger.Error("err:", err)
|
|
RespJson(c, status.InternalServerError, nil)
|
|
return
|
|
}
|
|
|
|
RespOK(c, info)
|
|
return
|
|
}
|
|
|
|
func OrderExpress(c *gin.Context) {
|
|
req := struct {
|
|
ExpressCompanyNo string `json:"express_company_no"`
|
|
ExpressNo string `json:"express_no"`
|
|
}{}
|
|
if c.ShouldBindJSON(&req) != nil {
|
|
logger.Error("ShouldBindJSON err")
|
|
RespJson(c, status.BadRequest, nil)
|
|
return
|
|
}
|
|
fmt.Println("CompanyNo:", req.ExpressCompanyNo)
|
|
fmt.Println("Num:", req.ExpressNo)
|
|
|
|
expressInfo, err := kuaidi.ExpressInfo(req.ExpressCompanyNo, req.ExpressNo)
|
|
if err != nil {
|
|
logger.Error("err:", err)
|
|
RespJson(c, status.InternalServerError, nil)
|
|
return
|
|
}
|
|
|
|
RespOK(c, expressInfo)
|
|
return
|
|
}
|
|
|
|
func WXPaySuccess(c *gin.Context) {
|
|
//fbConfig := model.GetFBConfig()
|
|
//if fbConfig.AssistanceValidityTerm == 0 {
|
|
// logger.Error(errors.New("get assistance_validity_term err"))
|
|
// RespJson(c, status.DBOperateError, nil)
|
|
// return
|
|
//}
|
|
|
|
//assistanceValidityTerm := time.Unix(time.Now().Unix()+int64(fbConfig.AssistanceValidityTerm), 0)
|
|
//ret := map[string]interface{}{
|
|
// "assistance_validity_term": assistanceValidityTerm,
|
|
// "postage": fbConfig.Postage,
|
|
//}
|
|
//RespOK(c, ret)
|
|
}
|
|
|
|
var orderCreateLocker sync.Mutex
|
|
|
|
// 创建订单
|
|
func OrderCreate(c *gin.Context) {
|
|
//type Goods struct {
|
|
// Price uint32 `json:"price"`
|
|
//}
|
|
|
|
req := struct {
|
|
GameCardId uint64 `json:"game_card_id"`
|
|
StoreId uint64 `json:"store_id"`
|
|
UserAddressId uint64 `json:"user_address_id"`
|
|
Price uint32 `json:"price"`
|
|
DeliveryType uint8 `json:"delivery_type"` // 取货方式
|
|
ExpressFee uint32 `json:"express_fee"`
|
|
}{}
|
|
|
|
bodyString, err := ioutil.ReadAll(c.Request.Body)
|
|
if err != nil {
|
|
logger.Error(errors.New("OrderCreate ReadAll req err"))
|
|
RespJson(c, status.BadRequest, nil)
|
|
return
|
|
}
|
|
|
|
//bodyString := strings.Replace(string(body), "\"[", "[", -1)
|
|
//bodyString = strings.Replace(string(bodyString), "]\"", "]", -1)
|
|
//bodyString = strings.Replace(string(bodyString), "\\", "", -1)
|
|
logger.Info("bodyString:", string(bodyString))
|
|
|
|
err = json.Unmarshal([]byte(bodyString), &req)
|
|
if err != nil {
|
|
logger.Error(errors.New("OrderCreate Unmarshal req err"))
|
|
RespJson(c, status.InternalServerError, nil)
|
|
return
|
|
}
|
|
//if err := c.ShouldBindJSON(&req);err != nil {
|
|
// logger.Error(err)
|
|
// RespJson(c,status.BadRequest,nil)
|
|
// return
|
|
//}
|
|
|
|
fmt.Println("商品下单 req:", req)
|
|
|
|
//uc := &struct {
|
|
// Uid uint32 `json:"uid"`
|
|
//}{}
|
|
uc := auth.GetCurrentUser(c)
|
|
if uc == nil {
|
|
logger.Error("uc is nil")
|
|
RespJson(c, status.BadRequest, nil)
|
|
return
|
|
}
|
|
//uc.Uid = 62389201
|
|
user := model.GetUserByUid(uc.Uid)
|
|
if user == nil {
|
|
logger.Error(errors.New("GetUserByUid err"))
|
|
RespJson(c, status.InternalServerError, nil)
|
|
return
|
|
}
|
|
|
|
if user.MemberLevel == 1 {
|
|
logger.Error(errors.New("user level 1"))
|
|
RespJson(c, status.NotMember, nil)
|
|
return
|
|
}
|
|
|
|
model.UnPayOrderSetCancel(user.Uid)
|
|
|
|
orderCreateLocker.Lock()
|
|
defer orderCreateLocker.Unlock()
|
|
|
|
unreturnedOrders, err := model.IsHaveUnreturnedOrders(uc.Uid)
|
|
if err != nil {
|
|
logger.Error("err:", err)
|
|
RespJson(c, status.InternalServerError, nil)
|
|
return
|
|
}
|
|
if unreturnedOrders {
|
|
logger.Error("unreturnedOrders")
|
|
RespJson(c, status.HaveUnreturnedOrders, nil)
|
|
return
|
|
}
|
|
|
|
online, err := model.IsGameCardOnline(uint32(req.GameCardId))
|
|
if err != nil {
|
|
logger.Error("err:", err)
|
|
RespJson(c, status.InternalServerError, nil)
|
|
return
|
|
}
|
|
if !online {
|
|
logger.Error("unreturnedOrders")
|
|
RespJson(c, status.GoodsSoldOut, nil)
|
|
return
|
|
}
|
|
if req.DeliveryType == 1 {
|
|
|
|
}
|
|
reqJson, _ := json.Marshal(&req)
|
|
fmt.Println("reqJson:", string(reqJson))
|
|
|
|
// TODO 邮费
|
|
orderSn := model.GetOrderSn()
|
|
|
|
order := model.Order{
|
|
Uid: uint64(uc.Uid),
|
|
GameCardId: req.GameCardId,
|
|
StoreId: req.StoreId,
|
|
UserAddressId: req.UserAddressId,
|
|
DeliveryType: req.DeliveryType,
|
|
Count: 1,
|
|
PickupCode: model.GetPickupCode(), // TODO 取货码
|
|
CardStatus: model.OrderCardStatusUnPick,
|
|
PayStatus: model.PayStatusUnPay,
|
|
PayTime: time.Now(),
|
|
OrderSn: orderSn,
|
|
PayPrice: req.Price,
|
|
Postage: req.ExpressFee,
|
|
}
|
|
|
|
//tx := model.TransactionBegin()
|
|
////TODO 以支付成功作为订单下单成功的依据,不是订单创建 已修改
|
|
var gameCardGoodsStock model.GameCardGoodsStock
|
|
err = model.NewGameCardGoodsStockQuerySet(model.DB).StoreIdEq(req.StoreId).GameCardIdEq(req.GameCardId).One(&gameCardGoodsStock)
|
|
if err != nil {
|
|
logger.Error("err:", err)
|
|
RespJson(c, status.InternalServerError, nil)
|
|
return
|
|
}
|
|
if gameCardGoodsStock.RentStock <= 0 {
|
|
logger.Error("order stock out ")
|
|
RespJson(c, status.OrderStockOut, nil)
|
|
return
|
|
}
|
|
|
|
fmt.Println("PayPrice:", order.PayPrice)
|
|
if req.Price == 0 {
|
|
order.PayStatus = model.PayStatusPaid
|
|
fmt.Println("orderId:", order.PayStatus)
|
|
err = order.OrderCreate()
|
|
if err != nil {
|
|
logger.Error("err:", err)
|
|
RespJson(c, status.InternalServerError, nil)
|
|
return
|
|
}
|
|
|
|
// 减库存
|
|
sql := fmt.Sprintf("UPDATE game_card_goods_stock SET rent_stock= rent_stock-1 WHERE store_id=%d AND game_card_id=%d;", req.StoreId, req.GameCardId)
|
|
fmt.Println("sql:", sql)
|
|
err = model.DB.Exec(sql).Error
|
|
if err != nil {
|
|
logger.Errorf("err:", err)
|
|
RespJson(c, status.InternalServerError, nil)
|
|
return
|
|
}
|
|
|
|
ret := map[string]interface{}{
|
|
"web_pay": "",
|
|
"order_id": order.ID,
|
|
}
|
|
RespOK(c, ret)
|
|
return
|
|
}
|
|
|
|
begin := model.DB.Begin()
|
|
//err = order.OrderCreate()
|
|
//if err != nil {
|
|
// logger.Error("err:", err)
|
|
// RespJson(c, status.InternalServerError, nil)
|
|
// return
|
|
//}
|
|
err = order.Create(begin)
|
|
if err != nil {
|
|
begin.Rollback()
|
|
logger.Error("err:", err)
|
|
RespJson(c, status.InternalServerError, nil)
|
|
return
|
|
}
|
|
|
|
// 减库存
|
|
sql := fmt.Sprintf("UPDATE game_card_goods_stock SET rent_stock= rent_stock-1 WHERE store_id=%d AND game_card_id=%d;", req.StoreId, req.GameCardId)
|
|
fmt.Println("sql:", sql)
|
|
err = begin.Exec(sql).Error
|
|
if err != nil {
|
|
begin.Rollback()
|
|
logger.Errorf("err:", err)
|
|
RespJson(c, status.InternalServerError, nil)
|
|
return
|
|
}
|
|
err = begin.Commit().Error
|
|
if err != nil {
|
|
begin.Rollback()
|
|
logger.Errorf("err:", err)
|
|
RespJson(c, status.InternalServerError, nil)
|
|
return
|
|
}
|
|
|
|
orderId := fmt.Sprintf("%d", order.ID)
|
|
//orderId = "100000"
|
|
fmt.Println("orderId", orderId)
|
|
fmt.Println("Price", req.Price)
|
|
fmt.Println("WxOpenID", user.WxOpenID)
|
|
fmt.Println("WxPayRentCard", wxpay.WxPayRentCard)
|
|
webPay, err := wxpay.WebPay(order.OrderSn, req.Price, user.WxOpenID, "N", wxpay.WxPayRentCard)
|
|
if err != nil {
|
|
logger.Error(errors.New("WebPay err"))
|
|
RespJson(c, status.InternalServerError, nil)
|
|
return
|
|
}
|
|
|
|
//num, err := model.NewOrderQuerySet(model.DB).IDEq(order.ID).GetUpdater().
|
|
// SetOutTradeNo(webPay.NonceStr).SetMchid(config.AppConfig.WxMchID).UpdateNum()
|
|
//if err != nil {
|
|
// logger.Error("err:", err)
|
|
// RespJson(c, status.InternalServerError, nil)
|
|
// return
|
|
//}
|
|
//if num == 0 {
|
|
// logger.Error("UpdateNum is 0")
|
|
// RespJson(c, status.InternalServerError, nil)
|
|
// return
|
|
//}
|
|
|
|
err = model.UserOpenMemberRecord{Uid: uc.Uid, OpenNo: orderSn, OrderId: order.ID}.Insert()
|
|
if err != nil {
|
|
logger.Error(errors.New("WebPay err"))
|
|
RespJson(c, status.InternalServerError, nil)
|
|
return
|
|
}
|
|
|
|
ret := map[string]interface{}{
|
|
"web_pay": webPay,
|
|
"order_id": order.ID,
|
|
}
|
|
|
|
RespOK(c, ret)
|
|
}
|
|
|
|
const (
|
|
PayStatusUnPay = 1 // 未支付
|
|
PayStatusPaid = 2 // 已支付
|
|
|
|
OrderCardStatusUnPick = 1 // 待取货中
|
|
OrderCardStatusPlaying = 2 // 游玩中
|
|
OrderCardStatusReturning = 3 // 归还中
|
|
OrderCardStatusCompleted = 4 // 已完成
|
|
OrderCardStatusCancel = 5 // 已取消
|
|
OrderCardStatusRefund = 6 // 已退款
|
|
)
|
|
|
|
// 创建订单
|
|
func OrderPay(c *gin.Context) {
|
|
req := struct {
|
|
OrderId uint32 `json:"order_id"`
|
|
//StoreId uint64 `json:"store_id"`
|
|
//UserAddressId uint64 `json:"user_address_id"`
|
|
//Price uint32 `json:"price"`
|
|
//DeliveryType uint8 `json:"delivery_type"` // 取货方式
|
|
//ExpressFee uint32 `json:"express_fee"`
|
|
//
|
|
}{}
|
|
if err := c.ShouldBindJSON(&req); err != nil {
|
|
logger.Error("ShouldBindJSON err:", err)
|
|
RespJson(c, status.BadRequest, nil)
|
|
return
|
|
}
|
|
var order model.Order
|
|
err := model.NewOrderQuerySet(model.DB).IDEq(req.OrderId).One(&order)
|
|
if err != nil {
|
|
logger.Error("Order err:", err)
|
|
RespJson(c, status.InternalServerError, nil)
|
|
return
|
|
}
|
|
if order.PayStatus != PayStatusUnPay || order.CardStatus != OrderCardStatusUnPick || order.CreatedAt.Add(30*time.Minute).Before(time.Now()) {
|
|
//if order.PayStatus != PayStatusUnPay || order.CardStatus != OrderCardStatusUnPick || order.CreatedAt.Add(3*time.Minute).Before(time.Now()) {
|
|
logger.Error("Order err:", err)
|
|
RespJson(c, status.InternalServerError, nil)
|
|
return
|
|
}
|
|
//orderId := fmt.Sprintf("%d", order.ID)
|
|
var user model.User
|
|
err = model.NewUserQuerySet(model.DB).UidEq(uint32(order.Uid)).One(&user)
|
|
if err != nil {
|
|
logger.Error("Order err:", err)
|
|
RespJson(c, status.InternalServerError, nil)
|
|
return
|
|
}
|
|
webPay, err := wxpay.WebPay(order.OrderSn, order.PayPrice, user.WxOpenID, "N", wxpay.WxPayRentCard)
|
|
if err != nil {
|
|
logger.Error(errors.New("WebPay err"))
|
|
RespJson(c, status.InternalServerError, nil)
|
|
return
|
|
}
|
|
ret := map[string]interface{}{
|
|
"web_pay": webPay,
|
|
"order_id": order.ID,
|
|
}
|
|
RespOK(c, ret)
|
|
}
|
|
|
|
func OrderAmount(c *gin.Context) {
|
|
req := struct {
|
|
StoreId uint32 `json:"store_id" binding:"required"`
|
|
UserAddressId uint32 `json:"user_address_id" binding:"required"`
|
|
Price uint32 `json:"price" `
|
|
}{}
|
|
if err := c.ShouldBindJSON(&req); err != nil {
|
|
logger.Error("ShouldBindJSON err:", err)
|
|
RespJson(c, status.BadRequest, nil)
|
|
return
|
|
}
|
|
|
|
var (
|
|
eg errgroup.Group
|
|
userAddress = &model.UserAddress{}
|
|
store = &model.Store{}
|
|
)
|
|
|
|
eg.Go(func() error {
|
|
store.ID = req.StoreId
|
|
err := store.Info()
|
|
if err != nil {
|
|
logger.Error("err:", err)
|
|
}
|
|
return nil
|
|
})
|
|
|
|
eg.Go(func() error {
|
|
userAddress.ID = req.UserAddressId
|
|
err := userAddress.Info()
|
|
if err != nil {
|
|
logger.Error("err:", err)
|
|
}
|
|
return nil
|
|
})
|
|
|
|
if err := eg.Wait(); err != nil {
|
|
logger.Error("err:", err)
|
|
//fmt.Println("Successfully fetched all URLs.")
|
|
RespJson(c, status.InternalServerError, nil)
|
|
return
|
|
}
|
|
|
|
expressFee := model.ExpressFeeProvince
|
|
//if userAddress.Province != "广东省" {
|
|
if userAddress.Province != store.Province {
|
|
expressFee = model.ExpressFeeOutsideProvince
|
|
}
|
|
|
|
ret := map[string]interface{}{
|
|
"total_amount": req.Price + uint32(expressFee),
|
|
"express_fee": expressFee,
|
|
}
|
|
RespOK(c, ret)
|
|
return
|
|
}
|
|
|
|
//func WXPay(c *gin.Context) {
|
|
// req := struct {
|
|
// //TotalFee uint32 `json:"total_fee"`
|
|
// AddressId uint32 `json:"address_id"`
|
|
// OrderSn string `json:"order_sn"`
|
|
// }{}
|
|
// if err := c.ShouldBindJSON(&req); err != nil {
|
|
// logger.Error(err)
|
|
// RespJson(c, status.BadRequest, nil)
|
|
// return
|
|
// }
|
|
//
|
|
// uc := auth.GetCurrentUser(c)
|
|
// if uc == nil {
|
|
// RespJson(c, status.Unauthorized, nil)
|
|
// return
|
|
// }
|
|
//
|
|
// //user := model.GetUserByUid(uc.Uid)
|
|
//
|
|
// var order model.Order
|
|
// //TODO 支付金额 地址id
|
|
// err := model.NewOrderQuerySet(model.DB).OrderSnEq(req.OrderSn).One(&order)
|
|
// if err != nil {
|
|
// logger.Error(err)
|
|
// RespJson(c, status.DBOperateError, nil)
|
|
// return
|
|
// }
|
|
//
|
|
// //if err := model.NewFBOrderQuerySet(model.DB).OrderSnEq(req.OrderSn).GetUpdater().
|
|
// // SetAddressId(req.AddressId).Update(); err != nil {
|
|
// // logger.Error(err)
|
|
// // RespJson(c, status.DBOperateError, nil)
|
|
// // return
|
|
// //}
|
|
// //
|
|
// //var sextuple *wxpay.Sextuple
|
|
// //sextuple, err = wxpay.FBXiaoChengXuPay(order.PayPrice, req.OrderSn, model.FB_WX_PAY_TYPE, user.WxOpenID)
|
|
// //if err != nil {
|
|
// // logger.Error(err)
|
|
// // RespJson(c, status.InternalServerError, nil)
|
|
// // return
|
|
// //}
|
|
//
|
|
// //RespOK(c, sextuple)
|
|
//}
|
|
|
|
func ConfirmReceipt(c *gin.Context) {
|
|
req := struct {
|
|
OrderId uint32 `json:"order_id"`
|
|
GameCardId uint32 `json:"game_card_id"`
|
|
}{}
|
|
if c.ShouldBindJSON(&req) != nil {
|
|
RespJson(c, status.BadRequest, nil)
|
|
return
|
|
}
|
|
uc := auth.GetCurrentUser(c)
|
|
if uc == nil {
|
|
logger.Error("uc is nil")
|
|
RespJson(c, status.Unauthorized, nil)
|
|
return
|
|
}
|
|
|
|
order := model.Order{Uid: uint64(uc.Uid)}
|
|
order.ID = req.OrderId
|
|
order.GameCardId = uint64(req.GameCardId)
|
|
order.CardStatus = model.OrderCardStatusPlaying
|
|
info, err := order.Modify()
|
|
if err != nil {
|
|
logger.Error("err:", err)
|
|
RespJson(c, status.InternalServerError, nil)
|
|
return
|
|
}
|
|
|
|
RespOK(c, info)
|
|
return
|
|
}
|
|
|
|
func ExpressCompanyList(c *gin.Context) {
|
|
company := &model.ExpressCompany{}
|
|
list, err := company.List()
|
|
if err != nil {
|
|
logger.Error("err:", err)
|
|
RespJson(c, status.InternalServerError, nil)
|
|
return
|
|
}
|
|
RespOK(c, list)
|
|
return
|
|
}
|
|
|
|
func OrderRevert(c *gin.Context) {
|
|
order := &model.Order{}
|
|
if c.ShouldBindJSON(order) != nil {
|
|
logger.Error("ShouldBindJSON err")
|
|
RespJson(c, status.BadRequest, nil)
|
|
return
|
|
}
|
|
//order := model.Order{}
|
|
//order.ID = req.OrderId
|
|
info, err := order.Revert()
|
|
if err != nil {
|
|
logger.Error("err:", err)
|
|
RespJson(c, status.OrderCompleted, nil)
|
|
return
|
|
}
|
|
|
|
RespOK(c, info)
|
|
return
|
|
}
|
|
|
|
func OrderRevertCancel(c *gin.Context) {
|
|
order := &model.Order{}
|
|
if c.ShouldBindJSON(order) != nil {
|
|
logger.Error("ShouldBindJSON err")
|
|
RespJson(c, status.BadRequest, nil)
|
|
return
|
|
}
|
|
//order := model.Order{}
|
|
//order.ID = req.OrderId
|
|
info, err := order.RevertCancel()
|
|
if err != nil {
|
|
logger.Error("err:", err)
|
|
RespJson(c, status.OrderCompleted, nil)
|
|
return
|
|
}
|
|
|
|
RespOK(c, info)
|
|
return
|
|
}
|
|
|
|
func OrderCancel(c *gin.Context) {
|
|
req := struct {
|
|
OrderId uint32 `json:"order_id"`
|
|
}{}
|
|
if c.ShouldBindJSON(&req) != nil {
|
|
logger.Error("ShouldBindJSON err")
|
|
RespJson(c, status.BadRequest, nil)
|
|
return
|
|
}
|
|
//uc := auth.GetCurrentUser(c)
|
|
//if uc == nil {
|
|
// logger.Error("uc is nil")
|
|
// RespJson(c, status.Unauthorized, nil)
|
|
// return
|
|
//}
|
|
order := model.Order{}
|
|
order.ID = req.OrderId
|
|
err := order.Cancel()
|
|
if err != nil {
|
|
logger.Error("err:", err)
|
|
RespJson(c, status.OrderDelivered, nil)
|
|
return
|
|
}
|
|
|
|
RespOK(c, nil)
|
|
return
|
|
}
|