diff --git a/controllers/client/good.go b/controllers/client/good.go index 65c9e67..b854c39 100644 --- a/controllers/client/good.go +++ b/controllers/client/good.go @@ -211,13 +211,6 @@ func (t *GoodCtl) Order() { } var expireAt = time.Now().Add(30 * time.Second).Unix() - res, err := pay_service.UnifiedOrder("欧轩互动-直播商品", user.Openid, int(price+int(option.PostFee*100)), - 4, userId, activity.Id, expireAt) - if err != nil { - session.Rollback() - t.CheckErr(err) - } - count, err := session.Where("is_delete=0").Count(&models.CustomerOrder{}) if err != nil { session.Rollback() @@ -231,11 +224,10 @@ func (t *GoodCtl) Order() { AreaId: area.Id, AreaName: area.Name, RehearsalId: activity.RehearsalId, - OutTradeNo: res["out_trade_no"].(string), BuyerId: user.Id, TotalAmount: float64(price)/100 + option.PostFee, PayAmount: float64(price)/100 + option.PostFee, - Status: 0, + Status: 1, Type: 1, // 直播订单 Receiver: param.Name, Address: param.Address, @@ -244,6 +236,19 @@ func (t *GoodCtl) Order() { ExpireTime: expireAt, Postage: option.PostFee, } + amount := price + int(option.PostFee*100) + if amount > 0.00 { + res, err := pay_service.UnifiedOrder("欧轩互动-直播商品", user.Openid, amount, 4, userId, + activity.Id, expireAt) + + if err != nil { + session.Rollback() + t.CheckErr(err) + } + order.OutTradeNo = res["out_trade_no"].(string) + order.Status = 0 + } + _, err = session.InsertOne(&order) if err != nil { session.Rollback() diff --git a/models/area_store.go b/models/area_store.go index 70c50a0..f57ed81 100644 --- a/models/area_store.go +++ b/models/area_store.go @@ -50,7 +50,7 @@ func (t *AreaStore) GetAreaStoreById(id int) (bool, error) { return core.GetXormAuto().Where("id=? and is_delete=0", id).Get(t) } func (t *AreaStore) GetMainAreaById(aid int) (bool, error) { - return core.GetXormAuto().Where("activity_id=? and is_main_area=1 and is_delete=0", aid).Get(t) + return core.GetXormAuto().NoAutoCondition().Where("activity_id=? and is_main_area=1 and is_delete=0", aid).Get(t) } func GetAreaStoresByActivityId(aid int) ([]*AreaStore, error) { list := make([]*AreaStore, 0)