Merge branch 'develop' of https://gitee.com/fusenpack/fusenapi into develop
This commit is contained in:
commit
fa011a1670
@ -59,6 +59,7 @@ const (
|
|||||||
ORDER_STATUS_UNPAIDDEPOSIT OrderStatusCode = 0 // 0,未支付定金
|
ORDER_STATUS_UNPAIDDEPOSIT OrderStatusCode = 0 // 0,未支付定金
|
||||||
ORDER_STATUS_CLOSE OrderStatusCode = 10 // 10,订单已关闭
|
ORDER_STATUS_CLOSE OrderStatusCode = 10 // 10,订单已关闭
|
||||||
ORDER_STATUS_COMPLETE OrderStatusCode = 20 // 20,订单已完成
|
ORDER_STATUS_COMPLETE OrderStatusCode = 20 // 20,订单已完成
|
||||||
|
ORDER_STATUS_DELETE OrderStatusCode = 30 // 20,订单已删除
|
||||||
|
|
||||||
ORDER_STATUS_DIRECTMAIL_ORDERED OrderStatusCode = 10100 // 10100,直邮单--已下单
|
ORDER_STATUS_DIRECTMAIL_ORDERED OrderStatusCode = 10100 // 10100,直邮单--已下单
|
||||||
ORDER_STATUS_DIRECTMAIL_ORDEREDMAINING OrderStatusCode = 10100001 // 10100001,直邮单--已下单--尾款
|
ORDER_STATUS_DIRECTMAIL_ORDEREDMAINING OrderStatusCode = 10100001 // 10100001,直邮单--已下单--尾款
|
||||||
@ -111,6 +112,7 @@ func init() {
|
|||||||
OrderStatusMessage[ORDER_STATUS_UNPAIDDEPOSIT] = "未支付定金"
|
OrderStatusMessage[ORDER_STATUS_UNPAIDDEPOSIT] = "未支付定金"
|
||||||
OrderStatusMessage[ORDER_STATUS_CLOSE] = "订单已关闭"
|
OrderStatusMessage[ORDER_STATUS_CLOSE] = "订单已关闭"
|
||||||
OrderStatusMessage[ORDER_STATUS_COMPLETE] = "订单已完成"
|
OrderStatusMessage[ORDER_STATUS_COMPLETE] = "订单已完成"
|
||||||
|
OrderStatusMessage[ORDER_STATUS_DELETE] = "订单已删除"
|
||||||
|
|
||||||
OrderStatusMessage[ORDER_STATUS_DIRECTMAIL_ORDERED] = "直邮单--已下单"
|
OrderStatusMessage[ORDER_STATUS_DIRECTMAIL_ORDERED] = "直邮单--已下单"
|
||||||
OrderStatusMessage[ORDER_STATUS_DIRECTMAIL_ORDEREDMAINING] = "直邮单--已下单--尾款"
|
OrderStatusMessage[ORDER_STATUS_DIRECTMAIL_ORDEREDMAINING] = "直邮单--已下单--尾款"
|
||||||
|
36
server/collection/collection.go
Normal file
36
server/collection/collection.go
Normal file
@ -0,0 +1,36 @@
|
|||||||
|
package main
|
||||||
|
|
||||||
|
import (
|
||||||
|
"flag"
|
||||||
|
"fmt"
|
||||||
|
"net/http"
|
||||||
|
"time"
|
||||||
|
|
||||||
|
"fusenapi/utils/auth"
|
||||||
|
"fusenapi/utils/fsconfig"
|
||||||
|
|
||||||
|
"fusenapi/server/collection/internal/config"
|
||||||
|
"fusenapi/server/collection/internal/handler"
|
||||||
|
"fusenapi/server/collection/internal/svc"
|
||||||
|
"github.com/zeromicro/go-zero/rest"
|
||||||
|
)
|
||||||
|
|
||||||
|
var configFile = flag.String("f", "etc/collection.yaml", "the config file")
|
||||||
|
|
||||||
|
func main() {
|
||||||
|
flag.Parse()
|
||||||
|
|
||||||
|
var c config.Config
|
||||||
|
fsconfig.StartNacosConfig(*configFile, &c, nil)
|
||||||
|
|
||||||
|
c.Timeout = int64(time.Second * 15)
|
||||||
|
server := rest.MustNewServer(c.RestConf, rest.WithCustomCors(auth.FsCors, func(w http.ResponseWriter) {
|
||||||
|
}))
|
||||||
|
defer server.Stop()
|
||||||
|
|
||||||
|
ctx := svc.NewServiceContext(c)
|
||||||
|
handler.RegisterHandlers(server, ctx)
|
||||||
|
|
||||||
|
fmt.Printf("Starting server at %s:%d...\n", c.Host, c.Port)
|
||||||
|
server.Start()
|
||||||
|
}
|
10
server/collection/etc/collection.yaml
Normal file
10
server/collection/etc/collection.yaml
Normal file
@ -0,0 +1,10 @@
|
|||||||
|
Name: collection
|
||||||
|
Host: 0.0.0.0
|
||||||
|
Port: 8888
|
||||||
|
Timeout: 15000 #服务超时时间(毫秒)
|
||||||
|
SourceMysql: fsreaderwriter:XErSYmLELKMnf3Dh@tcp(fusen.cdmigcvz3rle.us-east-2.rds.amazonaws.com:3306)/fusen
|
||||||
|
SourceRabbitMq: ""
|
||||||
|
Auth:
|
||||||
|
AccessSecret: fusen2023
|
||||||
|
AccessExpire: 2592000
|
||||||
|
RefreshAfter: 1592000
|
13
server/collection/internal/config/config.go
Normal file
13
server/collection/internal/config/config.go
Normal file
@ -0,0 +1,13 @@
|
|||||||
|
package config
|
||||||
|
|
||||||
|
import (
|
||||||
|
"fusenapi/server/collection/internal/types"
|
||||||
|
"github.com/zeromicro/go-zero/rest"
|
||||||
|
)
|
||||||
|
|
||||||
|
type Config struct {
|
||||||
|
rest.RestConf
|
||||||
|
SourceMysql string
|
||||||
|
Auth types.Auth
|
||||||
|
SourceRabbitMq string
|
||||||
|
}
|
35
server/collection/internal/handler/collectproducthandler.go
Normal file
35
server/collection/internal/handler/collectproducthandler.go
Normal file
@ -0,0 +1,35 @@
|
|||||||
|
package handler
|
||||||
|
|
||||||
|
import (
|
||||||
|
"net/http"
|
||||||
|
"reflect"
|
||||||
|
|
||||||
|
"fusenapi/utils/basic"
|
||||||
|
|
||||||
|
"fusenapi/server/collection/internal/logic"
|
||||||
|
"fusenapi/server/collection/internal/svc"
|
||||||
|
"fusenapi/server/collection/internal/types"
|
||||||
|
)
|
||||||
|
|
||||||
|
func CollectProductHandler(svcCtx *svc.ServiceContext) http.HandlerFunc {
|
||||||
|
return func(w http.ResponseWriter, r *http.Request) {
|
||||||
|
|
||||||
|
var req types.CollectProductReq
|
||||||
|
userinfo, err := basic.RequestParse(w, r, svcCtx, &req)
|
||||||
|
if err != nil {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
// 创建一个业务逻辑层实例
|
||||||
|
l := logic.NewCollectProductLogic(r.Context(), svcCtx)
|
||||||
|
|
||||||
|
rl := reflect.ValueOf(l)
|
||||||
|
basic.BeforeLogic(w, r, rl)
|
||||||
|
|
||||||
|
resp := l.CollectProduct(&req, userinfo)
|
||||||
|
|
||||||
|
if !basic.AfterLogic(w, r, rl, resp) {
|
||||||
|
basic.NormalAfterLogic(w, r, resp)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
22
server/collection/internal/handler/routes.go
Normal file
22
server/collection/internal/handler/routes.go
Normal file
@ -0,0 +1,22 @@
|
|||||||
|
// Code generated by goctl. DO NOT EDIT.
|
||||||
|
package handler
|
||||||
|
|
||||||
|
import (
|
||||||
|
"net/http"
|
||||||
|
|
||||||
|
"fusenapi/server/collection/internal/svc"
|
||||||
|
|
||||||
|
"github.com/zeromicro/go-zero/rest"
|
||||||
|
)
|
||||||
|
|
||||||
|
func RegisterHandlers(server *rest.Server, serverCtx *svc.ServiceContext) {
|
||||||
|
server.AddRoutes(
|
||||||
|
[]rest.Route{
|
||||||
|
{
|
||||||
|
Method: http.MethodPost,
|
||||||
|
Path: "/api/collection/collect_product",
|
||||||
|
Handler: CollectProductHandler(serverCtx),
|
||||||
|
},
|
||||||
|
},
|
||||||
|
)
|
||||||
|
}
|
43
server/collection/internal/logic/collectproductlogic.go
Normal file
43
server/collection/internal/logic/collectproductlogic.go
Normal file
@ -0,0 +1,43 @@
|
|||||||
|
package logic
|
||||||
|
|
||||||
|
import (
|
||||||
|
"fusenapi/utils/auth"
|
||||||
|
"fusenapi/utils/basic"
|
||||||
|
|
||||||
|
"context"
|
||||||
|
|
||||||
|
"fusenapi/server/collection/internal/svc"
|
||||||
|
"fusenapi/server/collection/internal/types"
|
||||||
|
|
||||||
|
"github.com/zeromicro/go-zero/core/logx"
|
||||||
|
)
|
||||||
|
|
||||||
|
type CollectProductLogic struct {
|
||||||
|
logx.Logger
|
||||||
|
ctx context.Context
|
||||||
|
svcCtx *svc.ServiceContext
|
||||||
|
}
|
||||||
|
|
||||||
|
func NewCollectProductLogic(ctx context.Context, svcCtx *svc.ServiceContext) *CollectProductLogic {
|
||||||
|
return &CollectProductLogic{
|
||||||
|
Logger: logx.WithContext(ctx),
|
||||||
|
ctx: ctx,
|
||||||
|
svcCtx: svcCtx,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// 处理进入前逻辑w,r
|
||||||
|
// func (l *CollectProductLogic) BeforeLogic(w http.ResponseWriter, r *http.Request) {
|
||||||
|
// }
|
||||||
|
|
||||||
|
func (l *CollectProductLogic) CollectProduct(req *types.CollectProductReq, userinfo *auth.UserInfo) (resp *basic.Response) {
|
||||||
|
// 返回值必须调用Set重新返回, resp可以空指针调用 resp.SetStatus(basic.CodeOK, data)
|
||||||
|
// userinfo 传入值时, 一定不为null
|
||||||
|
|
||||||
|
return resp.SetStatus(basic.CodeOK)
|
||||||
|
}
|
||||||
|
|
||||||
|
// 处理逻辑后 w,r 如:重定向, resp 必须重新处理
|
||||||
|
// func (l *CollectProductLogic) AfterLogic(w http.ResponseWriter, r *http.Request, resp *basic.Response) {
|
||||||
|
// // httpx.OkJsonCtx(r.Context(), w, resp)
|
||||||
|
// }
|
26
server/collection/internal/svc/servicecontext.go
Normal file
26
server/collection/internal/svc/servicecontext.go
Normal file
@ -0,0 +1,26 @@
|
|||||||
|
package svc
|
||||||
|
|
||||||
|
import (
|
||||||
|
"fusenapi/initalize"
|
||||||
|
"fusenapi/model/gmodel"
|
||||||
|
"fusenapi/server/collection/internal/config"
|
||||||
|
"gorm.io/gorm"
|
||||||
|
)
|
||||||
|
|
||||||
|
type ServiceContext struct {
|
||||||
|
Config config.Config
|
||||||
|
MysqlConn *gorm.DB
|
||||||
|
AllModels *gmodel.AllModelsGen
|
||||||
|
RabbitMq *initalize.RabbitMqHandle
|
||||||
|
}
|
||||||
|
|
||||||
|
func NewServiceContext(c config.Config) *ServiceContext {
|
||||||
|
conn := initalize.InitMysql(c.SourceMysql)
|
||||||
|
|
||||||
|
return &ServiceContext{
|
||||||
|
Config: c,
|
||||||
|
MysqlConn: conn,
|
||||||
|
AllModels: gmodel.NewAllModels(initalize.InitMysql(c.SourceMysql)),
|
||||||
|
RabbitMq: initalize.InitRabbitMq(c.SourceRabbitMq, nil),
|
||||||
|
}
|
||||||
|
}
|
82
server/collection/internal/types/types.go
Normal file
82
server/collection/internal/types/types.go
Normal file
@ -0,0 +1,82 @@
|
|||||||
|
// Code generated by goctl. DO NOT EDIT.
|
||||||
|
package types
|
||||||
|
|
||||||
|
import (
|
||||||
|
"fusenapi/utils/basic"
|
||||||
|
)
|
||||||
|
|
||||||
|
type CollectProductReq struct {
|
||||||
|
ProductId int64 `json:"product_id"`
|
||||||
|
Logo string `json:"logo"`
|
||||||
|
SelectColorIndex int64 `json:"select_color_index"`
|
||||||
|
TemplateTag string `json:"template_tag"`
|
||||||
|
}
|
||||||
|
|
||||||
|
type Request struct {
|
||||||
|
}
|
||||||
|
|
||||||
|
type Response struct {
|
||||||
|
Code int `json:"code"`
|
||||||
|
Message string `json:"msg"`
|
||||||
|
Data interface{} `json:"data"`
|
||||||
|
}
|
||||||
|
|
||||||
|
type Auth struct {
|
||||||
|
AccessSecret string `json:"accessSecret"`
|
||||||
|
AccessExpire int64 `json:"accessExpire"`
|
||||||
|
RefreshAfter int64 `json:"refreshAfter"`
|
||||||
|
}
|
||||||
|
|
||||||
|
type File struct {
|
||||||
|
Filename string `fsfile:"filename"`
|
||||||
|
Header map[string][]string `fsfile:"header"`
|
||||||
|
Size int64 `fsfile:"size"`
|
||||||
|
Data []byte `fsfile:"data"`
|
||||||
|
}
|
||||||
|
|
||||||
|
type Meta struct {
|
||||||
|
TotalCount int64 `json:"total_count"`
|
||||||
|
PageCount int64 `json:"page_count"`
|
||||||
|
CurrentPage int `json:"current_page"`
|
||||||
|
PerPage int `json:"per_page"`
|
||||||
|
}
|
||||||
|
|
||||||
|
// Set 设置Response的Code和Message值
|
||||||
|
func (resp *Response) Set(Code int, Message string) *Response {
|
||||||
|
return &Response{
|
||||||
|
Code: Code,
|
||||||
|
Message: Message,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Set 设置整个Response
|
||||||
|
func (resp *Response) SetWithData(Code int, Message string, Data interface{}) *Response {
|
||||||
|
return &Response{
|
||||||
|
Code: Code,
|
||||||
|
Message: Message,
|
||||||
|
Data: Data,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// SetStatus 设置默认StatusResponse(内部自定义) 默认msg, 可以带data, data只使用一个参数
|
||||||
|
func (resp *Response) SetStatus(sr *basic.StatusResponse, data ...interface{}) *Response {
|
||||||
|
newResp := &Response{
|
||||||
|
Code: sr.Code,
|
||||||
|
}
|
||||||
|
if len(data) == 1 {
|
||||||
|
newResp.Data = data[0]
|
||||||
|
}
|
||||||
|
return newResp
|
||||||
|
}
|
||||||
|
|
||||||
|
// SetStatusWithMessage 设置默认StatusResponse(内部自定义) 非默认msg, 可以带data, data只使用一个参数
|
||||||
|
func (resp *Response) SetStatusWithMessage(sr *basic.StatusResponse, msg string, data ...interface{}) *Response {
|
||||||
|
newResp := &Response{
|
||||||
|
Code: sr.Code,
|
||||||
|
Message: msg,
|
||||||
|
}
|
||||||
|
if len(data) == 1 {
|
||||||
|
newResp.Data = data[0]
|
||||||
|
}
|
||||||
|
return newResp
|
||||||
|
}
|
35
server/order/internal/handler/deleteorderhandler.go
Normal file
35
server/order/internal/handler/deleteorderhandler.go
Normal file
@ -0,0 +1,35 @@
|
|||||||
|
package handler
|
||||||
|
|
||||||
|
import (
|
||||||
|
"net/http"
|
||||||
|
"reflect"
|
||||||
|
|
||||||
|
"fusenapi/utils/basic"
|
||||||
|
|
||||||
|
"fusenapi/server/order/internal/logic"
|
||||||
|
"fusenapi/server/order/internal/svc"
|
||||||
|
"fusenapi/server/order/internal/types"
|
||||||
|
)
|
||||||
|
|
||||||
|
func DeleteOrderHandler(svcCtx *svc.ServiceContext) http.HandlerFunc {
|
||||||
|
return func(w http.ResponseWriter, r *http.Request) {
|
||||||
|
|
||||||
|
var req types.DeleteOrderReq
|
||||||
|
userinfo, err := basic.RequestParse(w, r, svcCtx, &req)
|
||||||
|
if err != nil {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
// 创建一个业务逻辑层实例
|
||||||
|
l := logic.NewDeleteOrderLogic(r.Context(), svcCtx)
|
||||||
|
|
||||||
|
rl := reflect.ValueOf(l)
|
||||||
|
basic.BeforeLogic(w, r, rl)
|
||||||
|
|
||||||
|
resp := l.DeleteOrder(&req, userinfo)
|
||||||
|
|
||||||
|
if !basic.AfterLogic(w, r, rl, resp) {
|
||||||
|
basic.NormalAfterLogic(w, r, resp)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -27,6 +27,11 @@ func RegisterHandlers(server *rest.Server, serverCtx *svc.ServiceContext) {
|
|||||||
Path: "/api/order/create-prepayment-balance",
|
Path: "/api/order/create-prepayment-balance",
|
||||||
Handler: CreatePrePaymentByBalanceHandler(serverCtx),
|
Handler: CreatePrePaymentByBalanceHandler(serverCtx),
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
Method: http.MethodPost,
|
||||||
|
Path: "/api/order/delete",
|
||||||
|
Handler: DeleteOrderHandler(serverCtx),
|
||||||
|
},
|
||||||
{
|
{
|
||||||
Method: http.MethodGet,
|
Method: http.MethodGet,
|
||||||
Path: "/api/order/list",
|
Path: "/api/order/list",
|
||||||
|
55
server/order/internal/logic/deleteorderlogic.go
Normal file
55
server/order/internal/logic/deleteorderlogic.go
Normal file
@ -0,0 +1,55 @@
|
|||||||
|
package logic
|
||||||
|
|
||||||
|
import (
|
||||||
|
"fusenapi/service/repositories"
|
||||||
|
"fusenapi/utils/auth"
|
||||||
|
"fusenapi/utils/basic"
|
||||||
|
|
||||||
|
"context"
|
||||||
|
|
||||||
|
"fusenapi/server/order/internal/svc"
|
||||||
|
"fusenapi/server/order/internal/types"
|
||||||
|
|
||||||
|
"github.com/zeromicro/go-zero/core/logx"
|
||||||
|
)
|
||||||
|
|
||||||
|
type DeleteOrderLogic struct {
|
||||||
|
logx.Logger
|
||||||
|
ctx context.Context
|
||||||
|
svcCtx *svc.ServiceContext
|
||||||
|
}
|
||||||
|
|
||||||
|
func NewDeleteOrderLogic(ctx context.Context, svcCtx *svc.ServiceContext) *DeleteOrderLogic {
|
||||||
|
return &DeleteOrderLogic{
|
||||||
|
Logger: logx.WithContext(ctx),
|
||||||
|
ctx: ctx,
|
||||||
|
svcCtx: svcCtx,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// 处理进入前逻辑w,r
|
||||||
|
// func (l *DeleteOrderLogic) BeforeLogic(w http.ResponseWriter, r *http.Request) {
|
||||||
|
// }
|
||||||
|
|
||||||
|
func (l *DeleteOrderLogic) DeleteOrder(req *types.DeleteOrderReq, userinfo *auth.UserInfo) (resp *basic.Response) {
|
||||||
|
// 返回值必须调用Set重新返回, resp可以空指针调用 resp.SetStatus(basic.CodeOK, data)
|
||||||
|
// userinfo 传入值时, 一定不为null
|
||||||
|
if !userinfo.IsUser() {
|
||||||
|
// 如果是,返回未授权的错误码
|
||||||
|
return resp.SetStatus(basic.CodeUnAuth)
|
||||||
|
}
|
||||||
|
res, err := l.svcCtx.Repositories.NewOrder.Delete(l.ctx, &repositories.DeleteReq{
|
||||||
|
UserId: userinfo.UserId,
|
||||||
|
OrderSn: req.OrderSn,
|
||||||
|
})
|
||||||
|
|
||||||
|
if err != nil {
|
||||||
|
return resp.SetStatus(&res.ErrorCode)
|
||||||
|
}
|
||||||
|
return resp.SetStatus(basic.CodeOK)
|
||||||
|
}
|
||||||
|
|
||||||
|
// 处理逻辑后 w,r 如:重定向, resp 必须重新处理
|
||||||
|
// func (l *DeleteOrderLogic) AfterLogic(w http.ResponseWriter, r *http.Request, resp *basic.Response) {
|
||||||
|
// // httpx.OkJsonCtx(r.Context(), w, resp)
|
||||||
|
// }
|
@ -5,6 +5,10 @@ import (
|
|||||||
"fusenapi/utils/basic"
|
"fusenapi/utils/basic"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
type DeleteOrderReq struct {
|
||||||
|
OrderSn string `json:"order_sn"`
|
||||||
|
}
|
||||||
|
|
||||||
type OrderDetailReq struct {
|
type OrderDetailReq struct {
|
||||||
OrderSn string `form:"order_sn"`
|
OrderSn string `form:"order_sn"`
|
||||||
}
|
}
|
||||||
|
@ -1,15 +1,14 @@
|
|||||||
package logic
|
package logic
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"context"
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
"errors"
|
"errors"
|
||||||
"fusenapi/model/gmodel"
|
"fusenapi/model/gmodel"
|
||||||
"fusenapi/utils/auth"
|
"fusenapi/utils/auth"
|
||||||
"fusenapi/utils/basic"
|
"fusenapi/utils/basic"
|
||||||
|
"fusenapi/utils/s3url_to_s3id"
|
||||||
"gorm.io/gorm"
|
"gorm.io/gorm"
|
||||||
"strings"
|
|
||||||
|
|
||||||
"context"
|
|
||||||
|
|
||||||
"fusenapi/server/product-template-tag/internal/svc"
|
"fusenapi/server/product-template-tag/internal/svc"
|
||||||
"fusenapi/server/product-template-tag/internal/types"
|
"fusenapi/server/product-template-tag/internal/types"
|
||||||
@ -40,11 +39,10 @@ func (l *GetTemplateTagColorLogic) GetTemplateTagColor(req *types.GetTemplateTag
|
|||||||
return resp.SetStatusWithMessage(basic.CodeRequestParamsErr, "param selected_color_index is invalid")
|
return resp.SetStatusWithMessage(basic.CodeRequestParamsErr, "param selected_color_index is invalid")
|
||||||
}
|
}
|
||||||
//根据logo查询素材资源
|
//根据logo查询素材资源
|
||||||
s := strings.Split(req.Logo, "/")
|
resourceId := s3url_to_s3id.GetS3ResourceIdFormUrl(req.Logo)
|
||||||
if len(s) <= 1 {
|
if resourceId == "" {
|
||||||
return resp.SetStatusWithMessage(basic.CodeRequestParamsErr, "invalid logo")
|
return resp.SetStatusWithMessage(basic.CodeRequestParamsErr, "param logo is invalid")
|
||||||
}
|
}
|
||||||
resourceId := s[len(s)-1]
|
|
||||||
var (
|
var (
|
||||||
userMaterial *gmodel.FsUserMaterial
|
userMaterial *gmodel.FsUserMaterial
|
||||||
templateTagInfo *gmodel.FsProductTemplateTags
|
templateTagInfo *gmodel.FsProductTemplateTags
|
||||||
|
@ -130,23 +130,9 @@ func (l *GetRecommandProductListLogic) GetRecommandProductList(req *types.GetRec
|
|||||||
}
|
}
|
||||||
list := make([]types.GetRecommandProductListRsp, 0, len(recommendProductList))
|
list := make([]types.GetRecommandProductListRsp, 0, len(recommendProductList))
|
||||||
for _, v := range recommendProductList {
|
for _, v := range recommendProductList {
|
||||||
/*r := image.ThousandFaceImageFormatReq{
|
recommend := false
|
||||||
Size: int(req.Size),
|
|
||||||
IsThousandFace: 0,
|
|
||||||
Cover: *v.Cover,
|
|
||||||
CoverImg: *v.CoverImg,
|
|
||||||
CoverDefault: *v.Cover,
|
|
||||||
ProductId: v.Id,
|
|
||||||
UserId: userinfo.UserId,
|
|
||||||
}
|
|
||||||
if user.Id != 0 {
|
|
||||||
r.IsThousandFace = int(*user.IsThousandFace)
|
|
||||||
}
|
|
||||||
//千人前面处理
|
|
||||||
image.ThousandFaceImageFormat(&r)*/
|
|
||||||
isRecommend := int64(0)
|
|
||||||
if _, ok := mapRecommend[v.Id]; ok {
|
if _, ok := mapRecommend[v.Id]; ok {
|
||||||
isRecommend = 1
|
recommend = true
|
||||||
}
|
}
|
||||||
minPrice := int64(0)
|
minPrice := int64(0)
|
||||||
if minVal, ok := mapProductMinPrice[v.Id]; ok {
|
if minVal, ok := mapProductMinPrice[v.Id]; ok {
|
||||||
@ -163,7 +149,7 @@ func (l *GetRecommandProductListLogic) GetRecommandProductList(req *types.GetRec
|
|||||||
CoverImgMetadata: mapResourceMetadata[*v.CoverImg],
|
CoverImgMetadata: mapResourceMetadata[*v.CoverImg],
|
||||||
CoverDefault: []types.CoverDefaultItem{},
|
CoverDefault: []types.CoverDefaultItem{},
|
||||||
Intro: *v.Intro,
|
Intro: *v.Intro,
|
||||||
IsRecommend: isRecommend,
|
Recommend: recommend,
|
||||||
MinPrice: minPrice,
|
MinPrice: minPrice,
|
||||||
IsCustomization: *v.IsCustomization,
|
IsCustomization: *v.IsCustomization,
|
||||||
}
|
}
|
||||||
|
@ -22,7 +22,7 @@ type GetRecommandProductListRsp struct {
|
|||||||
CoverImgMetadata interface{} `json:"cover_img_metadata"`
|
CoverImgMetadata interface{} `json:"cover_img_metadata"`
|
||||||
CoverDefault []CoverDefaultItem `json:"cover_default"`
|
CoverDefault []CoverDefaultItem `json:"cover_default"`
|
||||||
Intro string `json:"intro"`
|
Intro string `json:"intro"`
|
||||||
IsRecommend int64 `json:"is_recommend"`
|
Recommend bool `json:"recommend"`
|
||||||
MinPrice int64 `json:"min_price"`
|
MinPrice int64 `json:"min_price"`
|
||||||
IsCustomization int64 `json:"is_customization"`
|
IsCustomization int64 `json:"is_customization"`
|
||||||
}
|
}
|
||||||
|
23
server_api/collection.api
Normal file
23
server_api/collection.api
Normal file
@ -0,0 +1,23 @@
|
|||||||
|
syntax = "v1"
|
||||||
|
|
||||||
|
info (
|
||||||
|
title: "collection"// TODO: add title
|
||||||
|
desc: "收藏服务"// TODO: add description
|
||||||
|
author: ""
|
||||||
|
email: ""
|
||||||
|
)
|
||||||
|
|
||||||
|
import "basic.api"
|
||||||
|
service collection {
|
||||||
|
//收藏产品
|
||||||
|
@handler CollectProductHandler
|
||||||
|
post /api/collection/collect_product(CollectProductReq) returns (response);
|
||||||
|
}
|
||||||
|
|
||||||
|
//收藏产品
|
||||||
|
type CollectProductReq {
|
||||||
|
ProductId int64 `json:"product_id"`
|
||||||
|
Logo string `json:"logo"`
|
||||||
|
SelectColorIndex int64 `json:"select_color_index"`
|
||||||
|
TemplateTag string `json:"template_tag"`
|
||||||
|
}
|
@ -20,6 +20,9 @@ service order {
|
|||||||
@handler CreatePrePaymentByBalanceHandler
|
@handler CreatePrePaymentByBalanceHandler
|
||||||
post /api/order/create-prepayment-balance(CreatePrePaymentByBalanceReq) returns (response);
|
post /api/order/create-prepayment-balance(CreatePrePaymentByBalanceReq) returns (response);
|
||||||
|
|
||||||
|
@handler DeleteOrderHandler
|
||||||
|
post /api/order/delete(DeleteOrderReq) returns (response);
|
||||||
|
|
||||||
@handler OrderListHandler
|
@handler OrderListHandler
|
||||||
get /api/order/list(OrderListReq) returns (response);
|
get /api/order/list(OrderListReq) returns (response);
|
||||||
|
|
||||||
@ -28,6 +31,10 @@ service order {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
type DeleteOrderReq {
|
||||||
|
OrderSn string `json:"order_sn"`
|
||||||
|
}
|
||||||
|
|
||||||
type OrderDetailReq {
|
type OrderDetailReq {
|
||||||
OrderSn string `form:"order_sn"`
|
OrderSn string `form:"order_sn"`
|
||||||
}
|
}
|
||||||
|
@ -65,7 +65,7 @@ type GetRecommandProductListRsp {
|
|||||||
CoverImgMetadata interface{} `json:"cover_img_metadata"`
|
CoverImgMetadata interface{} `json:"cover_img_metadata"`
|
||||||
CoverDefault []CoverDefaultItem `json:"cover_default"`
|
CoverDefault []CoverDefaultItem `json:"cover_default"`
|
||||||
Intro string `json:"intro"`
|
Intro string `json:"intro"`
|
||||||
IsRecommend int64 `json:"is_recommend"`
|
Recommend bool `json:"recommend"`
|
||||||
MinPrice int64 `json:"min_price"`
|
MinPrice int64 `json:"min_price"`
|
||||||
IsCustomization int64 `json:"is_customization"`
|
IsCustomization int64 `json:"is_customization"`
|
||||||
}
|
}
|
||||||
|
@ -9,7 +9,7 @@ import (
|
|||||||
"fusenapi/utils/curl"
|
"fusenapi/utils/curl"
|
||||||
"fusenapi/utils/file"
|
"fusenapi/utils/file"
|
||||||
"fusenapi/utils/hash"
|
"fusenapi/utils/hash"
|
||||||
"strings"
|
"fusenapi/utils/s3url_to_s3id"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/aws/aws-sdk-go/aws/session"
|
"github.com/aws/aws-sdk-go/aws/session"
|
||||||
@ -225,11 +225,10 @@ type TemplateTagColor struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (l *defaultImageHandle) LogoCombine(ctx context.Context, in *LogoCombineReq) (*LogoCombineRes, error) {
|
func (l *defaultImageHandle) LogoCombine(ctx context.Context, in *LogoCombineReq) (*LogoCombineRes, error) {
|
||||||
s := strings.Split(in.LogoUrl, "/")
|
logoResourceId := s3url_to_s3id.GetS3ResourceIdFormUrl(in.LogoUrl)
|
||||||
if len(s) <= 1 {
|
if logoResourceId == "" {
|
||||||
return nil, errors.New("无效的logo")
|
return nil, errors.New("invalid logo url")
|
||||||
}
|
}
|
||||||
logoResourceId := s[len(s)-1]
|
|
||||||
userMaterialModel := gmodel.NewFsUserMaterialModel(l.MysqlConn)
|
userMaterialModel := gmodel.NewFsUserMaterialModel(l.MysqlConn)
|
||||||
resLogoInfo, err := userMaterialModel.FindOneByLogoResourceId(ctx, logoResourceId)
|
resLogoInfo, err := userMaterialModel.FindOneByLogoResourceId(ctx, logoResourceId)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
@ -48,6 +48,8 @@ type (
|
|||||||
PaymentSuccessful(ctx context.Context, in *PaymentSuccessfulReq) (res *PaymentSuccessfulRes, err error)
|
PaymentSuccessful(ctx context.Context, in *PaymentSuccessfulReq) (res *PaymentSuccessfulRes, err error)
|
||||||
// 关闭
|
// 关闭
|
||||||
Close(ctx context.Context, in *CloseReq) (res *CloseRes, err error)
|
Close(ctx context.Context, in *CloseReq) (res *CloseRes, err error)
|
||||||
|
// 删除
|
||||||
|
Delete(ctx context.Context, in *DeleteReq) (res *DeleteRes, err error)
|
||||||
|
|
||||||
// 支付超时订单自动关闭
|
// 支付超时订单自动关闭
|
||||||
CloseList(ctx context.Context, in *CloseListReq) (res *CloseListRes, err error)
|
CloseList(ctx context.Context, in *CloseListReq) (res *CloseListRes, err error)
|
||||||
@ -83,6 +85,18 @@ type (
|
|||||||
Amount int64 `json:"amount"` // 金额
|
Amount int64 `json:"amount"` // 金额
|
||||||
Label string `json:"label"` // 标签
|
Label string `json:"label"` // 标签
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* 删除订单 */
|
||||||
|
DeleteReq struct {
|
||||||
|
UserId int64 `json:"user_id"`
|
||||||
|
OrderSn string `json:"order_sn"`
|
||||||
|
}
|
||||||
|
DeleteRes struct {
|
||||||
|
ErrorCode basic.StatusResponse
|
||||||
|
OrderSn string
|
||||||
|
}
|
||||||
|
/* 删除订单 */
|
||||||
|
|
||||||
/* 支付超时订单自动关闭 */
|
/* 支付超时订单自动关闭 */
|
||||||
CloseListReq struct {
|
CloseListReq struct {
|
||||||
Type int64 // type:1=关闭
|
Type int64 // type:1=关闭
|
||||||
@ -195,6 +209,85 @@ type (
|
|||||||
/* 列表 */
|
/* 列表 */
|
||||||
)
|
)
|
||||||
|
|
||||||
|
// 订单删除
|
||||||
|
func (d *defaultOrder) Delete(ctx context.Context, in *DeleteReq) (res *DeleteRes, err error) {
|
||||||
|
var errorCode basic.StatusResponse
|
||||||
|
err = d.MysqlConn.WithContext(ctx).Transaction(func(tx *gorm.DB) error {
|
||||||
|
var orderInfo gmodel.FsOrder
|
||||||
|
model := tx
|
||||||
|
if in.UserId != 0 {
|
||||||
|
model = model.Where("user_id = ?", in.UserId)
|
||||||
|
}
|
||||||
|
if in.OrderSn != "" {
|
||||||
|
model = model.Where("order_sn = ?", in.OrderSn)
|
||||||
|
}
|
||||||
|
result := model.Take(&orderInfo)
|
||||||
|
if result.Error != nil {
|
||||||
|
if errors.Is(result.Error, gorm.ErrRecordNotFound) {
|
||||||
|
errorCode = *basic.CodeErrOrderCreatePrePaymentInfoNoFound
|
||||||
|
} else {
|
||||||
|
errorCode = *basic.CodeServiceErr
|
||||||
|
}
|
||||||
|
logc.Errorf(ctx, "order delete failed, err: %v", err)
|
||||||
|
return result.Error
|
||||||
|
}
|
||||||
|
ress, err := d.OrderDetailHandler(ctx, &orderInfo, 0)
|
||||||
|
if err != nil {
|
||||||
|
logc.Errorf(ctx, "order delete failed DetailOrderDetailHandler,OrderSn:%s, err: %v", in.OrderSn, err)
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
if !(*orderInfo.Status == int64(constants.ORDER_STATUS_CLOSE) || (*orderInfo.DeliveryMethod == int64(constants.DELIVERYMETHODDIRECTMAIL) && *orderInfo.Status == int64(constants.ORDER_STATUS_DIRECTMAIL_ARRIVED))) {
|
||||||
|
errorCode = *basic.CodeErrOrderDeleteStatusIllegality
|
||||||
|
err = errors.New("order delete failed, status is illegality")
|
||||||
|
logc.Errorf(ctx, "order delete failed, err: %v", err)
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
// 状态链路
|
||||||
|
var ntime = time.Now().UTC()
|
||||||
|
var statusCode = constants.ORDER_STATUS_DELETE
|
||||||
|
var statusLink = append(ress.OrderDetailOriginal.StatusLink, gmodel.OrderStatus{
|
||||||
|
Ctime: &ntime,
|
||||||
|
Utime: &ntime,
|
||||||
|
StatusCode: statusCode,
|
||||||
|
StatusTitle: constants.OrderStatusMessage[statusCode],
|
||||||
|
})
|
||||||
|
statusLinkByte, err := json.Marshal(statusLink)
|
||||||
|
if err != nil {
|
||||||
|
logc.Errorf(ctx, "order delete failed Marshal statusLinkByte,OrderSn:%s, err: %v", in.OrderSn, err)
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
var table = gmodel.NewAllModels(tx).FsOrder.TableName()
|
||||||
|
var resUpdate *gorm.DB
|
||||||
|
var resUpdateSql string = fmt.Sprintf("UPDATE %s SET `utime` = '%s',`is_del` = 1", table, ntime)
|
||||||
|
resUpdate = tx.Exec(fmt.Sprintf("%s ,`status_link`= JSON_MERGE_PATCH(`status_link`,?) WHERE `id` = %d", resUpdateSql, orderInfo.Id), statusLinkByte)
|
||||||
|
|
||||||
|
err = resUpdate.Error
|
||||||
|
if err != nil {
|
||||||
|
logc.Errorf(ctx, "order delete failed Update FsOrder,OrderSn:%s, err: %v", in.OrderSn, err)
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
return nil
|
||||||
|
})
|
||||||
|
if err != nil {
|
||||||
|
logc.Errorf(ctx, "order delete failed, err: %v", err)
|
||||||
|
if errorCode.Code == 0 {
|
||||||
|
errorCode.Code = basic.CodeApiErr.Code
|
||||||
|
errorCode.Message = basic.CodeApiErr.Message
|
||||||
|
}
|
||||||
|
return &DeleteRes{
|
||||||
|
ErrorCode: errorCode,
|
||||||
|
}, err
|
||||||
|
}
|
||||||
|
|
||||||
|
return &DeleteRes{
|
||||||
|
ErrorCode: errorCode,
|
||||||
|
OrderSn: in.OrderSn,
|
||||||
|
}, err
|
||||||
|
}
|
||||||
|
|
||||||
// 订单关闭-支付超时
|
// 订单关闭-支付超时
|
||||||
func (d *defaultOrder) CloseList(ctx context.Context, in *CloseListReq) (res *CloseListRes, err error) {
|
func (d *defaultOrder) CloseList(ctx context.Context, in *CloseListReq) (res *CloseListRes, err error) {
|
||||||
var orderList []gmodel.FsOrder
|
var orderList []gmodel.FsOrder
|
||||||
@ -245,13 +338,12 @@ func (d *defaultOrder) CloseList(ctx context.Context, in *CloseListReq) (res *Cl
|
|||||||
|
|
||||||
// 关闭
|
// 关闭
|
||||||
func (d *defaultOrder) Close(ctx context.Context, in *CloseReq) (res *CloseRes, err error) {
|
func (d *defaultOrder) Close(ctx context.Context, in *CloseReq) (res *CloseRes, err error) {
|
||||||
fmt.Println(in)
|
|
||||||
var errorCode basic.StatusResponse
|
var errorCode basic.StatusResponse
|
||||||
err = d.MysqlConn.WithContext(ctx).Transaction(func(tx *gorm.DB) error {
|
err = d.MysqlConn.WithContext(ctx).Transaction(func(tx *gorm.DB) error {
|
||||||
var orderInfo gmodel.FsOrder
|
var orderInfo gmodel.FsOrder
|
||||||
model := tx.Where("status = ?", int64(constants.ORDER_STATUS_UNPAIDDEPOSIT)).Where("pay_status = ?", int(constants.ORDER_PAY_STATUS_UNPAIDDEPOSIT))
|
model := tx.Where("status = ?", int64(constants.ORDER_STATUS_UNPAIDDEPOSIT)).Where("pay_status = ?", int(constants.ORDER_PAY_STATUS_UNPAIDDEPOSIT))
|
||||||
if in.OrderSn != "" {
|
if in.OrderSn != "" {
|
||||||
model.Where("order_sn = ?", in.OrderSn)
|
model = model.Where("order_sn = ?", in.OrderSn)
|
||||||
}
|
}
|
||||||
result := model.Take(&orderInfo)
|
result := model.Take(&orderInfo)
|
||||||
if result.Error != nil {
|
if result.Error != nil {
|
||||||
@ -576,10 +668,10 @@ func (d *defaultOrder) CreatePrePaymentByBalance(ctx context.Context, in *Create
|
|||||||
var orderInfo gmodel.FsOrder
|
var orderInfo gmodel.FsOrder
|
||||||
model := d.MysqlConn.Where("is_del = ?", 0)
|
model := d.MysqlConn.Where("is_del = ?", 0)
|
||||||
if in.UserId != 0 {
|
if in.UserId != 0 {
|
||||||
model.Where("user_id = ?", in.UserId)
|
model = model.Where("user_id = ?", in.UserId)
|
||||||
}
|
}
|
||||||
if in.OrderSn != "" {
|
if in.OrderSn != "" {
|
||||||
model.Where("order_sn = ?", in.OrderSn)
|
model = model.Where("order_sn = ?", in.OrderSn)
|
||||||
}
|
}
|
||||||
result := model.Take(&orderInfo)
|
result := model.Take(&orderInfo)
|
||||||
if result.Error != nil {
|
if result.Error != nil {
|
||||||
@ -662,10 +754,10 @@ func (d *defaultOrder) CreatePrePaymentByDeposit(ctx context.Context, in *Create
|
|||||||
var orderInfo gmodel.FsOrder
|
var orderInfo gmodel.FsOrder
|
||||||
model := d.MysqlConn.Where("is_del = ?", 0)
|
model := d.MysqlConn.Where("is_del = ?", 0)
|
||||||
if in.UserId != 0 {
|
if in.UserId != 0 {
|
||||||
model.Where("user_id = ?", in.UserId)
|
model = model.Where("user_id = ?", in.UserId)
|
||||||
}
|
}
|
||||||
if in.OrderSn != "" {
|
if in.OrderSn != "" {
|
||||||
model.Where("order_sn = ?", in.OrderSn)
|
model = model.Where("order_sn = ?", in.OrderSn)
|
||||||
}
|
}
|
||||||
result := model.Take(&orderInfo)
|
result := model.Take(&orderInfo)
|
||||||
if result.Error != nil {
|
if result.Error != nil {
|
||||||
@ -818,25 +910,25 @@ func (d *defaultOrder) CreatePrePaymentByDeposit(ctx context.Context, in *Create
|
|||||||
func (d *defaultOrder) List(ctx context.Context, in *ListReq) (res *ListRes, err error) {
|
func (d *defaultOrder) List(ctx context.Context, in *ListReq) (res *ListRes, err error) {
|
||||||
var orderList []gmodel.FsOrder
|
var orderList []gmodel.FsOrder
|
||||||
model := d.MysqlConn.Model(&gmodel.FsOrder{}).Where("is_del = ?", 0)
|
model := d.MysqlConn.Model(&gmodel.FsOrder{}).Where("is_del = ?", 0)
|
||||||
// model.Where("pay_status > ?", 0)
|
model = model.Where("pay_status > ?", 0)
|
||||||
if in.UserId != 0 {
|
if in.UserId != 0 {
|
||||||
model.Where("user_id = ?", in.UserId)
|
model = model.Where("user_id = ?", in.UserId)
|
||||||
}
|
}
|
||||||
|
|
||||||
if in.DeliveryMethod != 0 {
|
if in.DeliveryMethod != 0 {
|
||||||
model.Where("delivery_method = ?", in.DeliveryMethod)
|
model = model.Where("delivery_method = ?", in.DeliveryMethod)
|
||||||
}
|
}
|
||||||
if in.OrderCycle != "" {
|
if in.OrderCycle != "" {
|
||||||
// 下单时间
|
// 下单时间
|
||||||
switch in.OrderCycle {
|
switch in.OrderCycle {
|
||||||
case "within_one_month":
|
case "within_one_month":
|
||||||
model.Where("ctime >?", time.Now().UTC().AddDate(0, -1, 0).Unix())
|
model = model.Where("ctime >?", time.Now().UTC().AddDate(0, -1, 0).Unix())
|
||||||
case "within_three_month":
|
case "within_three_month":
|
||||||
model.Where("ctime >?", time.Now().UTC().AddDate(0, -3, 0).Unix())
|
model = model.Where("ctime >?", time.Now().UTC().AddDate(0, -3, 0).Unix())
|
||||||
case "within_six_month":
|
case "within_six_month":
|
||||||
model.Where("ctime >?", time.Now().UTC().AddDate(0, -6, 0).Unix())
|
model = model.Where("ctime >?", time.Now().UTC().AddDate(0, -6, 0).Unix())
|
||||||
case "within_one_year":
|
case "within_one_year":
|
||||||
model.Where("ctime >?", time.Now().UTC().AddDate(-1, 0, 0).Unix())
|
model = model.Where("ctime >?", time.Now().UTC().AddDate(-1, 0, 0).Unix())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
var count int64
|
var count int64
|
||||||
@ -880,10 +972,10 @@ func (d *defaultOrder) Detail(ctx context.Context, in *DetailReq) (res *DetailRe
|
|||||||
var orderInfo gmodel.FsOrder
|
var orderInfo gmodel.FsOrder
|
||||||
model := d.MysqlConn.Where("is_del = ?", 0)
|
model := d.MysqlConn.Where("is_del = ?", 0)
|
||||||
if in.UserId != 0 {
|
if in.UserId != 0 {
|
||||||
model.Where("user_id = ?", in.UserId)
|
model = model.Where("user_id = ?", in.UserId)
|
||||||
}
|
}
|
||||||
if in.OrderSn != "" {
|
if in.OrderSn != "" {
|
||||||
model.Where("order_sn = ?", in.OrderSn)
|
model = model.Where("order_sn = ?", in.OrderSn)
|
||||||
}
|
}
|
||||||
result := model.Take(&orderInfo)
|
result := model.Take(&orderInfo)
|
||||||
if result.Error != nil {
|
if result.Error != nil {
|
||||||
|
@ -111,6 +111,7 @@ var (
|
|||||||
CodeErrOrderCreatePrePaymentNoUnPaid = &StatusResponse{5308, "create payment failed, order is not unpaid"}
|
CodeErrOrderCreatePrePaymentNoUnPaid = &StatusResponse{5308, "create payment failed, order is not unpaid"}
|
||||||
CodeErrOrderCreatePrePaymentPaid = &StatusResponse{5309, "create payment failed, order is paid"}
|
CodeErrOrderCreatePrePaymentPaid = &StatusResponse{5309, "create payment failed, order is paid"}
|
||||||
CodeErrOrderCreatePrePaymentTimeout = &StatusResponse{5310, "create payment failed, timeout"}
|
CodeErrOrderCreatePrePaymentTimeout = &StatusResponse{5310, "create payment failed, timeout"}
|
||||||
|
CodeErrOrderDeleteStatusIllegality = &StatusResponse{5311, "delete order failed, status is illegality"}
|
||||||
)
|
)
|
||||||
|
|
||||||
type Response struct {
|
type Response struct {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user