@ -66,7 +66,8 @@ func (t *GoodCtl) ListOrder() {
t . CheckErr ( err )
t . Assert ( exist , code . MSG_ACTIVITY_NOT_EXIST , "互动不存在" )
orders , err := models . GetCustomerOrdersByActivityId ( uid , activity . Id , activity . RehearsalId , areaId , status )
orders , err := models . GetCustomerOrdersByActivityId ( uid , activity . Id , activity . RehearsalId ,
areaId , status , t . Page , t . PageSize )
t . CheckErr ( err )
outTradeNos := make ( [ ] string , 0 )
for _ , order := range orders {
@ -76,7 +77,7 @@ func (t *GoodCtl) ListOrder() {
t . CheckErr ( err )
for index , order := range orders {
for _ , sub := range subs {
if order . OutTradeNo == sub . OutTradeNo {
if order . OutTradeNo == sub [ "out_trade_no" ] {
orders [ index ] . SubOrders = append ( orders [ index ] . SubOrders , sub )
}
}
@ -85,12 +86,12 @@ func (t *GoodCtl) ListOrder() {
}
type OrderParam struct {
ActivityId int64 ` json:"activity_id" `
AreaId int64 ` json:"area_id" `
Name string ` json:"name" `
Phone string ` json:"phone" `
Address string ` json:"address" `
Goods interface { } ` json:"goods" `
ActivityId int64 ` json:"activity_id" `
AreaId int64 ` json:"area_id" `
Name string ` json:"name" `
Phone string ` json:"phone" `
Address string ` json:"address" `
Goods [ ] map [ string ] int ` json:"goods" `
}
// 下订单
@ -141,7 +142,7 @@ func (t *GoodCtl) Order() {
subOrders := make ( [ ] * models . CustomerOrderSub , 0 )
var price = 0
for _ , g := range g oods {
for _ , g := range param . G oods {
good := new ( models . CustomerGoods )
exist , err = session . Where ( "is_delete=0 and id=?" , g [ "id" ] ) . Get ( good )
if err != nil || ! exist {
@ -181,23 +182,40 @@ func (t *GoodCtl) Order() {
t . CheckErr ( err )
}
order := new ( models . CustomerOrder )
order . AreaId = param . AreaId
order . AreaName = area . Name
order . RehearsalId = activity . RehearsalId
order . BuyerId = userId
order . ActivityId = activity . Id
order . TotalAmount = float64 ( price ) / 100 + option . PostFee
order . PayAmount = order . TotalAmount
order . OutTradeNo = res [ "out_trade_no" ] . ( string )
order . Address = param . Address
order . Receiver = param . Name
order . Phone = param . Phone
order . Postage = option . PostFee
order . Status = 0
order . IsDelete = false
order . CreatedAt = time . Now ( )
order . UpdatedAt = time . Now ( )
order := & models . CustomerOrder {
IsDelete : false ,
CreatedAt : time . Now ( ) ,
UpdatedAt : time . Now ( ) ,
//UserPrizeId: , // 奖品
ActivityId : activity . Id ,
AreaId : area . Id ,
AreaName : area . Name ,
RehearsalId : activity . RehearsalId ,
OutTradeNo : res [ "out_trade_no" ] . ( string ) ,
//OrderEntryPersonId: ,
BuyerId : user . Id ,
//GoodsId: ,
//GoodsName: "",
//GoodsNum: 0,
TotalAmount : float64 ( price ) / 100 + option . PostFee ,
PayAmount : float64 ( price ) / 100 + option . PostFee ,
Status : 0 ,
Receiver : param . Name ,
Address : param . Address ,
Phone : param . Phone ,
IsDrawCash : 0 ,
Postage : option . PostFee ,
//ExpressId: 0,
//ExpressName: "",
//ExpressNo: "",
//CancelTime: time.Time{},
AutoReceiveTime : time . Now ( ) . AddDate ( 0 , 0 , 15 ) ,
//OrderTime: time.Now(),
//Good: nil,
//User: nil,
//OrderEntryPersonName: "",
//SubOrders: nil,
}
_ , err = session . InsertOne ( order )
if err != nil {
session . Rollback ( )