38 lines
874 B
Go
38 lines
874 B
Go
package controllers
|
|
|
|
import (
|
|
"net/http"
|
|
"psi/constant"
|
|
"psi/database"
|
|
"psi/service"
|
|
"psi/utils"
|
|
"strconv"
|
|
|
|
"github.com/gin-gonic/gin"
|
|
)
|
|
|
|
type WangdianApi struct{}
|
|
|
|
func (i *WangdianApi) CreatePurchaseOrder(c *gin.Context) {
|
|
raw := c.PostForm("purchase_order_id")
|
|
if raw == "" {
|
|
raw = c.Query("purchase_order_id")
|
|
}
|
|
purchaseOrderID, err := strconv.ParseInt(raw, 10, 64)
|
|
if err != nil || purchaseOrderID <= 0 {
|
|
utils.FailWithRequestLog(constant.LoggerChannelRequest, "参数错误: purchase_order_id 必须为正整数", nil, c, nil)
|
|
return
|
|
}
|
|
|
|
resp, err := service.PushPurchaseOrder(purchaseOrderID, database.GetDB(c))
|
|
if err != nil {
|
|
utils.FailWithRequestLog(constant.LoggerChannelWork, "推送采购单到旺店通失败: "+err.Error(), err, c, nil)
|
|
return
|
|
}
|
|
|
|
c.JSON(http.StatusOK, gin.H{
|
|
"code": resp.Code,
|
|
"message": resp.Message,
|
|
})
|
|
}
|