205 lines
5.8 KiB
Go
205 lines
5.8 KiB
Go
|
package gdydmanage
|
||
|
|
||
|
import (
|
||
|
"fmt"
|
||
|
"github.com/gin-gonic/gin"
|
||
|
"github.com/go-admin-team/go-admin-core/logger"
|
||
|
"go-admin/app/admin/models"
|
||
|
"go-admin/common/apis"
|
||
|
"go-admin/tools/app"
|
||
|
"net/http"
|
||
|
)
|
||
|
|
||
|
type GDYDDeployService struct {
|
||
|
apis.Api
|
||
|
}
|
||
|
|
||
|
// CreateOrder 商品订单生成
|
||
|
// @Summary 商品订单生成
|
||
|
// @Tags 2025-广东移动
|
||
|
// @Produce json
|
||
|
// @Accept json
|
||
|
// @Param request body models.CreateProductOrderCKCommIDReq true "商品订单生成"
|
||
|
// @Success 200 {object} models.CommonResponse
|
||
|
// @Router /api/v1/mmAdWeb/create_order [post]
|
||
|
func (e GDYDDeployService) CreateOrder(c *gin.Context) {
|
||
|
fmt.Println("CreateOrder-start")
|
||
|
logger.Info("CreateOrder-start")
|
||
|
|
||
|
err := e.MakeContext(c).MakeOrm().Errors
|
||
|
if err != nil {
|
||
|
e.Logger.Error(err)
|
||
|
app.Error(c, http.StatusInternalServerError, err, "初始化失败")
|
||
|
return
|
||
|
}
|
||
|
|
||
|
// 绑定请求体
|
||
|
var req models.CreateProductOrderCKCommIDReq
|
||
|
if err := c.ShouldBindJSON(&req); err != nil {
|
||
|
logger.Error("请求参数绑定失败:", err)
|
||
|
app.Error(c, http.StatusBadRequest, err, "参数错误")
|
||
|
return
|
||
|
}
|
||
|
|
||
|
resp, err := models.DoSecurePostRequest(models.CreateOrderUrl, req.UserInfo.ServerNum, &req)
|
||
|
if err != nil {
|
||
|
logger.Error("CreateOrder error:", err)
|
||
|
app.Error(c, http.StatusBadRequest, err, err.Error())
|
||
|
return
|
||
|
}
|
||
|
|
||
|
//resp, err := models.SendCreateProductOrderCKCommIDRequest(&req)
|
||
|
//if err != nil {
|
||
|
// logger.Error("CreateOrder error:", err)
|
||
|
// app.Error(c, http.StatusBadRequest, err, err.Error())
|
||
|
// return
|
||
|
//}
|
||
|
|
||
|
fmt.Println("CreateOrder-end")
|
||
|
logger.Info("CreateOrder-end")
|
||
|
app.MiGuOK(c, resp)
|
||
|
}
|
||
|
|
||
|
// ApplySmsCode 申请短信验证码
|
||
|
// @Summary 申请短信验证码
|
||
|
// @Tags 2025-广东移动
|
||
|
// @Produce json
|
||
|
// @Accept json
|
||
|
// @Param request body models.ApplySmsCodeReq true "申请短信验证码"
|
||
|
// @Success 200 {object} models.CommonResponse
|
||
|
// @Router /api/v1/mmAdWeb/apply_sms_code [post]
|
||
|
func (e GDYDDeployService) ApplySmsCode(c *gin.Context) {
|
||
|
logger.Info("ApplySmsCode-start")
|
||
|
fmt.Println("ApplySmsCode-start")
|
||
|
|
||
|
err := e.MakeContext(c).MakeOrm().Errors
|
||
|
if err != nil {
|
||
|
logger.Error("Init error:", err)
|
||
|
app.Error(c, http.StatusInternalServerError, err, "初始化失败")
|
||
|
return
|
||
|
}
|
||
|
|
||
|
// 绑定请求体
|
||
|
var req models.ApplySmsCodeReq
|
||
|
if err := c.ShouldBindJSON(&req); err != nil {
|
||
|
logger.Error("请求参数绑定失败:", err)
|
||
|
app.Error(c, http.StatusBadRequest, err, "参数错误")
|
||
|
return
|
||
|
}
|
||
|
|
||
|
// 设置默认 OrderID 为 "0" 如果未指定
|
||
|
if req.OrderID == "" {
|
||
|
req.OrderID = "0"
|
||
|
}
|
||
|
|
||
|
//// 发起请求
|
||
|
//resp, err := models.SendApplySmsCodeRequest(&req)
|
||
|
//if err != nil {
|
||
|
// logger.Error("SendApplySmsCodeRequest error:", err)
|
||
|
// app.Error(c, http.StatusBadRequest, err, "短信验证码申请失败")
|
||
|
// return
|
||
|
//}
|
||
|
|
||
|
resp, err := models.DoSecurePostRequest(models.ApplySmsCodeUrl, req.MobileNo, &req)
|
||
|
if err != nil {
|
||
|
logger.Error("CreateOrder error:", err)
|
||
|
app.Error(c, http.StatusBadRequest, err, err.Error())
|
||
|
return
|
||
|
}
|
||
|
|
||
|
fmt.Println("ApplySmsCode-end")
|
||
|
logger.Info("ApplySmsCode-end")
|
||
|
|
||
|
app.MiGuOK(c, resp)
|
||
|
}
|
||
|
|
||
|
// CheckSmsCodeAndCommitOrder 短信验证及订单提交
|
||
|
// @Summary 短信验证及订单提交
|
||
|
// @Tags 2025-广东移动
|
||
|
// @Produce json
|
||
|
// @Accept json
|
||
|
// @Param request body models.CheckSmsCodeAndCommitOrderReq true "短信验证及订单提交"
|
||
|
// @Success 200 {object} models.CommonResponse
|
||
|
// @Router /api/v1/mmAdWeb/commit_order [post]
|
||
|
func (e GDYDDeployService) CheckSmsCodeAndCommitOrder(c *gin.Context) {
|
||
|
logger.Info("CheckSmsCodeAndCommitOrder-start")
|
||
|
fmt.Println("CheckSmsCodeAndCommitOrder-start")
|
||
|
|
||
|
err := e.MakeContext(c).MakeOrm().Errors
|
||
|
if err != nil {
|
||
|
logger.Error("初始化失败:", err)
|
||
|
app.Error(c, http.StatusInternalServerError, err, "初始化失败")
|
||
|
return
|
||
|
}
|
||
|
|
||
|
var req models.CheckSmsCodeAndCommitOrderReq
|
||
|
if err := c.ShouldBindJSON(&req); err != nil {
|
||
|
logger.Error("请求参数解析失败:", err)
|
||
|
app.Error(c, http.StatusBadRequest, err, "请求参数错误")
|
||
|
return
|
||
|
}
|
||
|
|
||
|
//resp, err := models.SendCheckSmsCodeAndCommitOrderRequest(&req)
|
||
|
//if err != nil {
|
||
|
// logger.Error("SendCheckSmsCodeAndCommitOrderRequest error:", err)
|
||
|
// app.Error(c, http.StatusBadRequest, err, "短信校验提交失败")
|
||
|
// return
|
||
|
//}
|
||
|
|
||
|
resp, err := models.DoSecurePostRequest(models.CheckSmsCodeCommitOrderUrl, req.ServerNum, &req)
|
||
|
if err != nil {
|
||
|
logger.Error("CreateOrder error:", err)
|
||
|
app.Error(c, http.StatusBadRequest, err, err.Error())
|
||
|
return
|
||
|
}
|
||
|
|
||
|
fmt.Println("CheckSmsCodeAndCommitOrder-end")
|
||
|
logger.Infof("CheckSmsCodeAndCommitOrder-end")
|
||
|
app.MiGuOK(c, resp)
|
||
|
}
|
||
|
|
||
|
// QueryOrder 查询订单状态
|
||
|
// @Summary 查询订单状态
|
||
|
// @Tags 2025-广东移动
|
||
|
// @Produce json
|
||
|
// @Accept json
|
||
|
// @Param request body models.QueryOrderReq true "查询订单状态"
|
||
|
// @Success 200 {object} models.CommonResponse
|
||
|
// @Router /api/v1/mmAdWeb/query_order [post]
|
||
|
func (e GDYDDeployService) QueryOrder(c *gin.Context) {
|
||
|
logger.Info("QueryOrder - start")
|
||
|
fmt.Println("QueryOrder - start")
|
||
|
|
||
|
err := e.MakeContext(c).MakeOrm().Errors
|
||
|
if err != nil {
|
||
|
logger.Error("初始化失败:", err)
|
||
|
app.Error(c, http.StatusInternalServerError, err, "初始化失败")
|
||
|
return
|
||
|
}
|
||
|
|
||
|
var req models.QueryOrderReq
|
||
|
if err := c.ShouldBindJSON(&req); err != nil {
|
||
|
logger.Error("请求参数解析失败:", err)
|
||
|
app.Error(c, http.StatusBadRequest, err, "请求参数错误")
|
||
|
return
|
||
|
}
|
||
|
|
||
|
//resp, err := models.SendQueryOrderRequest(&req)
|
||
|
//if err != nil {
|
||
|
// logger.Error("SendQueryOrderRequest error:", err)
|
||
|
// app.Error(c, http.StatusBadRequest, err, "订单状态查询失败")
|
||
|
// return
|
||
|
//}
|
||
|
|
||
|
resp, err := models.DoSecurePostRequest(models.QueryOrderUrl, req.ServerNum, &req)
|
||
|
if err != nil {
|
||
|
logger.Error("CreateOrder error:", err)
|
||
|
app.Error(c, http.StatusBadRequest, err, err.Error())
|
||
|
return
|
||
|
}
|
||
|
|
||
|
fmt.Println("QueryOrder - end")
|
||
|
logger.Infof("QueryOrder - end")
|
||
|
app.MiGuOK(c, resp)
|
||
|
}
|