|
|
@ -7,6 +7,7 @@ import ( |
|
|
|
"hudongzhuanjia/models" |
|
|
|
pay_service "hudongzhuanjia/services/pay" |
|
|
|
"hudongzhuanjia/utils/code" |
|
|
|
"strings" |
|
|
|
"time" |
|
|
|
) |
|
|
|
|
|
|
@ -46,28 +47,38 @@ func (t *GoodCtl) ListGood() { |
|
|
|
|
|
|
|
goods, err := models.GetGoodsByActivityId(activityId, areaId) |
|
|
|
t.CheckErr(err) |
|
|
|
//
|
|
|
|
//for index := range goods {
|
|
|
|
// goods[index].GoodType = option.PostFeeType
|
|
|
|
// goods[index].Postage = option.PostFee
|
|
|
|
//}
|
|
|
|
|
|
|
|
for index := range goods { |
|
|
|
goods[index].GoodType = option.PostFeeType |
|
|
|
goods[index].Postage = option.PostFee |
|
|
|
} |
|
|
|
t.JSON(goods) |
|
|
|
return |
|
|
|
} |
|
|
|
|
|
|
|
func (t *GoodCtl) ListOrder() { |
|
|
|
activityId := t.MustGetInt64("activity_id") |
|
|
|
status := t.MustGetInt("status") |
|
|
|
status := t.MustGet("status") |
|
|
|
areaId := t.MustGetInt64("area_id") |
|
|
|
uid := t.MustGetUID() |
|
|
|
|
|
|
|
statusList := strings.Split(status, ",") |
|
|
|
|
|
|
|
activity := new(models.Activity) |
|
|
|
exist, err := models.GetById(activity, activityId) |
|
|
|
t.CheckErr(err) |
|
|
|
t.Assert(exist, code.MSG_ACTIVITY_NOT_EXIST, "互动不存在") |
|
|
|
|
|
|
|
option := new(models.CustomerOrderOption) |
|
|
|
exist, err = option.GetByActivityId(activityId) |
|
|
|
t.CheckErr(err) |
|
|
|
if !exist { |
|
|
|
t.JSON([]interface{}{}) |
|
|
|
return |
|
|
|
} |
|
|
|
|
|
|
|
orders, err := models.GetCustomerOrdersByActivityId(uid, activity.Id, activity.RehearsalId, |
|
|
|
areaId, status, t.Page, t.PageSize) |
|
|
|
areaId, statusList, t.Page, t.PageSize) |
|
|
|
t.CheckErr(err) |
|
|
|
outTradeNos := make([]string, 0) |
|
|
|
for _, order := range orders { |
|
|
@ -76,6 +87,7 @@ func (t *GoodCtl) ListOrder() { |
|
|
|
subs, err := models.GetCustomerOrderSubByOutTradeNos(outTradeNos) |
|
|
|
t.CheckErr(err) |
|
|
|
for index, order := range orders { |
|
|
|
order.ServicePhone = option.MainServicePhone |
|
|
|
for _, sub := range subs { |
|
|
|
if order.OutTradeNo == sub["out_trade_no"] { |
|
|
|
orders[index].SubOrders = append(orders[index].SubOrders, sub) |
|
|
@ -182,7 +194,7 @@ func (t *GoodCtl) Order() { |
|
|
|
t.CheckErr(err) |
|
|
|
} |
|
|
|
|
|
|
|
order := &models.CustomerOrder{ |
|
|
|
order := models.CustomerOrder{ |
|
|
|
IsDelete: false, |
|
|
|
CreatedAt: time.Now(), |
|
|
|
UpdatedAt: time.Now(), |
|
|
@ -209,14 +221,14 @@ func (t *GoodCtl) Order() { |
|
|
|
//ExpressName: "",
|
|
|
|
//ExpressNo: "",
|
|
|
|
//CancelTime: time.Time{},
|
|
|
|
AutoReceiveTime: time.Now().AddDate(0, 0, 15), |
|
|
|
//AutoReceiveTime: time.Now().AddDate(0, 0, 15),
|
|
|
|
//OrderTime: time.Now(),
|
|
|
|
//Good: nil,
|
|
|
|
//User: nil,
|
|
|
|
//OrderEntryPersonName: "",
|
|
|
|
//SubOrders: nil,
|
|
|
|
} |
|
|
|
_, err = session.InsertOne(order) |
|
|
|
_, err = session.InsertOne(&order) |
|
|
|
if err != nil { |
|
|
|
session.Rollback() |
|
|
|
t.CheckErr(err) |
|
|
@ -259,13 +271,14 @@ func (t *GoodCtl) RefundOrder() { |
|
|
|
} else if order.Status == 3 { |
|
|
|
_, err = order.UpdateStatusBy(outTradeNo, 3, 7) |
|
|
|
} else { |
|
|
|
t.ERROR("订单完成状态不能申请退款", code.MSG_CUSTOMER_ORDER_ERROR) |
|
|
|
t.ERROR("订单非已支付或者已发货状态不能申请退款", code.MSG_CUSTOMER_ORDER_ERROR) |
|
|
|
return |
|
|
|
} |
|
|
|
t.CheckErr(err) |
|
|
|
t.SUCCESS("成功申请退款") |
|
|
|
} |
|
|
|
|
|
|
|
// 取消订单
|
|
|
|
func (t *GoodCtl) CancelOrder() { |
|
|
|
outTradeNo := t.MustGet("out_trade_no") |
|
|
|
|
|
|
@ -280,3 +293,18 @@ func (t *GoodCtl) CancelOrder() { |
|
|
|
t.CheckErr(err) |
|
|
|
t.SUCCESS("成功取消订单") |
|
|
|
} |
|
|
|
|
|
|
|
func (t *GoodCtl) VerifyOrder() { |
|
|
|
outTradeNo := t.MustGet("out_trade_no") |
|
|
|
|
|
|
|
order := new(models.CustomerOrder) |
|
|
|
exist, err := order.GetByOutTradeNO(outTradeNo) |
|
|
|
t.CheckErr(err) |
|
|
|
t.Assert(exist, code.MSG_CUSTOMER_ORDER_NOT_EXIST, "用户订单不存在") |
|
|
|
if order.Status != 3 && order.Status != 1 { |
|
|
|
t.ERROR("非已支付或已发货状态不能确认", code.MSG_CUSTOMER_ORDER_ERROR) |
|
|
|
} |
|
|
|
_, err = order.UpdateStatusBy(outTradeNo, 3, 4) |
|
|
|
t.CheckErr(err) |
|
|
|
t.SUCCESS("成功确认已收货") |
|
|
|
} |