transfer
This commit is contained in:
parent
eb6f21487a
commit
81d3966130
|
@ -33,7 +33,7 @@ func GetById(c *gin.Context) {
|
|||
Id: res.Id,
|
||||
Name: res.Name,
|
||||
Price: res.Price,
|
||||
PddUrl: res.PddUrl,
|
||||
ProductUrl: res.ProductUrl,
|
||||
Status: res.Status,
|
||||
CreatedAt: res.CreatedAt.Format(time.RFC3339),
|
||||
}
|
||||
|
@ -75,7 +75,7 @@ func Search(c *gin.Context) {
|
|||
Id: item.Id,
|
||||
Name: item.Name,
|
||||
Price: item.Price,
|
||||
PddUrl: item.PddUrl,
|
||||
ProductUrl: item.ProductUrl,
|
||||
Status: item.Status,
|
||||
CreatedAt: item.CreatedAt.Format(time.RFC3339),
|
||||
})
|
||||
|
@ -107,7 +107,7 @@ func Create(c *gin.Context) {
|
|||
product := &proMod.Product{
|
||||
Name: request.Name,
|
||||
Price: request.Price,
|
||||
PddUrl: request.PddUrl,
|
||||
ProductUrl: request.ProductUrl,
|
||||
Status: 1, //1.上架 2.下架
|
||||
}
|
||||
|
||||
|
@ -135,7 +135,7 @@ func Update(c *gin.Context) {
|
|||
product := &proMod.Product{
|
||||
Id: request.Id,
|
||||
Name: request.Name,
|
||||
PddUrl: request.PddUrl,
|
||||
ProductUrl: request.ProductUrl,
|
||||
Price: request.Price,
|
||||
}
|
||||
|
||||
|
|
|
@ -6,12 +6,13 @@ import (
|
|||
common "com.snow.auto_monitor/app/http/controllers"
|
||||
transEnt "com.snow.auto_monitor/app/http/entities/transfersys"
|
||||
orderMod "com.snow.auto_monitor/app/models/orders"
|
||||
ransServ "com.snow.auto_monitor/app/services/transfersys"
|
||||
proServ "com.snow.auto_monitor/app/services/product"
|
||||
transServ "com.snow.auto_monitor/app/services/transfersys"
|
||||
"github.com/gin-gonic/gin"
|
||||
)
|
||||
|
||||
func GetOrder(c *gin.Context) {
|
||||
item, err := ransServ.ReadGroup()
|
||||
item, err := transServ.ReadGroup()
|
||||
if err != nil {
|
||||
common.Error(c, 400, err.Error())
|
||||
return
|
||||
|
@ -19,12 +20,19 @@ func GetOrder(c *gin.Context) {
|
|||
|
||||
var response *transEnt.GetOrderResp = nil
|
||||
|
||||
product, err := proServ.GetById(item.ProductId)
|
||||
if err != nil {
|
||||
common.Error(c, 400, "产品不存在")
|
||||
return
|
||||
}
|
||||
|
||||
if item != nil {
|
||||
response = &transEnt.GetOrderResp{
|
||||
Id: item.Id,
|
||||
OrderNo: item.OrderNo,
|
||||
MerchantId: item.MerchantId,
|
||||
ProductId: item.ProductId,
|
||||
ProductUrl: product.ProductUrl,
|
||||
OutTradeNo: item.OutTradeNo,
|
||||
RechargeAccount: item.RechargeAccount,
|
||||
AccountType: item.AccountType,
|
||||
|
@ -67,7 +75,7 @@ func FinishOrder(c *gin.Context) {
|
|||
TransferStatus: int64(status),
|
||||
}
|
||||
|
||||
affected, err := ransServ.FinishOrder(orders)
|
||||
affected, err := transServ.FinishOrder(orders)
|
||||
if err != nil || affected == 0 {
|
||||
common.Error(c, 400, "无法修改已完成订单")
|
||||
return
|
||||
|
|
|
@ -8,7 +8,7 @@ type GetListByIdResp struct {
|
|||
Id int64 `json:"id" example:"1"`
|
||||
Name string `json:"name" example:"snow"`
|
||||
Price int64 `json:"price" example:"100"`
|
||||
PddUrl string `json:"pdd_url" example:"http://www.baidu.com"`
|
||||
ProductUrl string `json:"product_url" example:"http://www.baidu.com"`
|
||||
Status int64 `json:"status" example:"1"`
|
||||
CreatedAt string `json:"created_at" example:"2020-01-01 00:00:00"`
|
||||
}
|
||||
|
@ -25,7 +25,7 @@ type SearchResp struct {
|
|||
Id int64 `json:"id" example:"1"`
|
||||
Name string `json:"name" example:"snow"`
|
||||
Price int64 `json:"price" example:"100"`
|
||||
PddUrl string `json:"pdd_url" example:"http://www.baidu.com"`
|
||||
ProductUrl string `json:"product_url" example:"http://www.baidu.com"`
|
||||
Status int64 `json:"status" example:"1"`
|
||||
CreatedAt string `json:"created_at" example:"2020-01-01 00:00:00"`
|
||||
}
|
||||
|
@ -33,7 +33,7 @@ type SearchResp struct {
|
|||
type CreateReq struct {
|
||||
Name string `json:"name" validate:"required"`
|
||||
Price int64 `json:"price" validate:"required"`
|
||||
PddUrl string `json:"pdd_url" validate:"required"`
|
||||
ProductUrl string `json:"product_url" validate:"required"`
|
||||
}
|
||||
|
||||
type CreateResp struct {
|
||||
|
@ -44,7 +44,7 @@ type UpdateReq struct {
|
|||
Id int64 `json:"id" validate:"required"`
|
||||
Name string `json:"name" `
|
||||
Price int64 `json:"price" `
|
||||
PddUrl string `json:"pdd_url" `
|
||||
ProductUrl string `json:"product_url" `
|
||||
}
|
||||
|
||||
type UpdateResp struct {
|
||||
|
|
|
@ -8,6 +8,7 @@ type GetOrderResp struct {
|
|||
OrderNo string `json:"order_no"`
|
||||
MerchantId int64 `json:"merchant_id"`
|
||||
ProductId int64 `json:"product_id"`
|
||||
ProductUrl string `json:"product_url"`
|
||||
OutTradeNo string `json:"out_trade_no"`
|
||||
RechargeAccount string `json:"recharge_account"`
|
||||
AccountType int64 `json:"account_type"`
|
||||
|
|
|
@ -19,7 +19,7 @@ type Product struct {
|
|||
Id int64 `xorm:"pk autoincr"` //注:使用getOne 或者ID() 需要设置主键
|
||||
Name string
|
||||
Price int64
|
||||
PddUrl string
|
||||
ProductUrl string
|
||||
Status int64
|
||||
CreatedAt time.Time `xorm:"created"`
|
||||
}
|
||||
|
|
|
@ -34,7 +34,7 @@ create table product (
|
|||
id int primary key auto_increment,
|
||||
name varchar(255) not null,
|
||||
price int,
|
||||
pdd_url varchar(255),
|
||||
product_url varchar(255),
|
||||
status tinyint, -- 1.上架 2.下架
|
||||
created_at timestamp default current_timestamp
|
||||
);
|
||||
|
|
Loading…
Reference in New Issue