85 lines
2.4 KiB
Go
85 lines
2.4 KiB
Go
package rechargectrl
|
|
|
|
import (
|
|
"encoding/json"
|
|
|
|
"91porn-server/common"
|
|
"91porn-server/common/constant"
|
|
"91porn-server/common/stderr"
|
|
"91porn-server/models/l/operatorlgmod"
|
|
"91porn-server/models/v/rchgordmod"
|
|
"91porn-server/web/service/rechargeser"
|
|
|
|
"github.com/gin-gonic/gin"
|
|
"go.mongodb.org/mongo-driver/bson"
|
|
)
|
|
|
|
// OrderList doc
|
|
// @Summary 充值订单
|
|
// @Description 充值订单
|
|
// @Tags product
|
|
// @Accept mpfd,json
|
|
// @Produce json,html
|
|
// @Success 200 {string} json "{"msg": "操作成功"}"
|
|
// @Failure 400 {string} json "{"msg": "操作失败"}"
|
|
// @Router /business/order/list [get]
|
|
func OrderList(ctx *gin.Context) {
|
|
var arg struct {
|
|
common.StandQuery
|
|
rchgordmod.RchgQueryReq
|
|
}
|
|
if err := ctx.ShouldBind(&arg); err != nil {
|
|
common.ServeJSON(ctx, stderr.ErrParamError, err)
|
|
return
|
|
}
|
|
cond, opt := common.StandQueryMap(arg.StandQuery, arg.RchgQueryReq)
|
|
//兼容以前没有productType的订单
|
|
if arg.ProductType != nil && *arg.ProductType == 0 {
|
|
cond["productType"] = bson.M{"$in": bson.A{0, nil}}
|
|
}
|
|
if arg.DistrictCode != nil {
|
|
cond["districtCode"] = arg.DistrictCode
|
|
}
|
|
total, data, err := rchgordmod.FindRechargesOrders(cond, opt)
|
|
if err != nil {
|
|
common.ServeJSON(ctx, stderr.ErrDbQueryError, "")
|
|
return
|
|
}
|
|
common.ServeJSON(ctx, stderr.Success, map[string]interface{}{
|
|
"total": total,
|
|
"orders": rechargeser.BaiYuan(data),
|
|
})
|
|
}
|
|
|
|
// UpdateOrder doc
|
|
// @Summary 充值订单
|
|
// @Description 充值订单
|
|
// @Tags product
|
|
// @Accept mpfd,json
|
|
// @Produce json,html
|
|
// @Success 200 {string} json "{"msg": "操作成功"}"
|
|
// @Failure 400 {string} json "{"msg": "操作失败"}"
|
|
// @Router /recharge/order/update [get]
|
|
func UpdateOrder(ctx *gin.Context) {
|
|
manager, err := common.GetAdminAct(ctx)
|
|
if err != nil {
|
|
common.ServeJSON(ctx, stderr.AdminIDErr, err.Error())
|
|
return
|
|
}
|
|
var p struct {
|
|
ID string `json:"id" form:"id" bson:"id"`
|
|
rchgordmod.RechargeUpdateReq
|
|
}
|
|
if err = ctx.ShouldBind(&p); err != nil {
|
|
common.ServeJSON(ctx, stderr.ErrParamError, err.Error())
|
|
return
|
|
}
|
|
if err = rchgordmod.UpdateRechargeOrder(p.ID, p.RechargeUpdateReq); err != nil {
|
|
common.ServeJSON(ctx, stderr.ErrDbQueryError, err.Error())
|
|
return
|
|
}
|
|
log, _ := json.Marshal(p)
|
|
_ = operatorlgmod.RecordOperation(manager, constant.TradeManageRechargeOrder, constant.Modify, string(log), ctx.Request.URL.RequestURI())
|
|
common.ServeJSON(ctx, stderr.Success, nil)
|
|
}
|