Merge branch 'develop' of https://gitee.com/fusenpack/fusenapi into develop
This commit is contained in:
commit
541627183b
|
@ -11,12 +11,12 @@ type OrderDetailReq struct {
|
|||
|
||||
type CreateOrderReq struct {
|
||||
CartIds []int64 `json:"cart_ids"`
|
||||
DeliveryMethod int64 `json:"delivery_method,options=[1,2]"`
|
||||
DeliveryMethod int64 `json:"delivery_method,optional,options=[1,2],default=2"`
|
||||
}
|
||||
|
||||
type CreatePrePaymentByDepositReq struct {
|
||||
OrderSn string `json:"order_sn"`
|
||||
DeliveryMethod int64 `json:"delivery_method,options=[1,2]"`
|
||||
DeliveryMethod int64 `json:"delivery_method,optional,options=[1,2],default=2"`
|
||||
DeliveryAddress *DeliveryAddress `json:"delivery_address,optional"`
|
||||
}
|
||||
|
||||
|
|
|
@ -192,7 +192,7 @@ func (l *DataTransferLogic) setConnPool(conn *websocket.Conn, userInfo *auth.Use
|
|||
userId: userInfo.UserId,
|
||||
guestId: userInfo.GuestId,
|
||||
extendRenderProperty: extendRenderProperty{
|
||||
renderChan: make(chan []byte, renderChanLen),
|
||||
renderChan: make(chan websocket_data.RenderImageReqMsg, renderChanLen),
|
||||
},
|
||||
}
|
||||
//保存连接
|
||||
|
|
|
@ -30,16 +30,26 @@ type renderProcessor struct {
|
|||
|
||||
// 云渲染属性
|
||||
type extendRenderProperty struct {
|
||||
renderChan chan []byte //渲染消息入口的缓冲队列
|
||||
renderChan chan websocket_data.RenderImageReqMsg //渲染消息入口的缓冲队列
|
||||
colorSelectedIndex int //选择颜色索引
|
||||
templateTag string //模板标签
|
||||
}
|
||||
|
||||
// 处理分发到这里的数据
|
||||
func (r *renderProcessor) allocationMessage(w *wsConnectItem, data []byte) {
|
||||
//logx.Info("开始处理渲染任务消息:", string(data))
|
||||
var renderImageData websocket_data.RenderImageReqMsg
|
||||
if err := json.Unmarshal(data, &renderImageData); err != nil {
|
||||
w.renderErrResponse(renderImageData.RenderId, renderImageData.RenderData.TemplateTag, "", "数据格式错误", renderImageData.RenderData.ProductId, w.userId, w.guestId, 0, 0, 0, 0)
|
||||
logx.Error("invalid format of websocket render image message", err)
|
||||
return
|
||||
}
|
||||
select {
|
||||
case <-w.closeChan: //已经关闭
|
||||
return
|
||||
case w.extendRenderProperty.renderChan <- data: //发入到缓冲队列
|
||||
case w.extendRenderProperty.renderChan <- renderImageData: //发入到缓冲队列
|
||||
w.extendRenderProperty.colorSelectedIndex = renderImageData.RenderData.TemplateTagColor.SelectedColorIndex
|
||||
w.extendRenderProperty.templateTag = renderImageData.RenderData.TemplateTag
|
||||
return
|
||||
}
|
||||
}
|
||||
|
@ -51,26 +61,28 @@ func (w *wsConnectItem) consumeRenderImageData() {
|
|||
logx.Error("func renderImage err:", err)
|
||||
}
|
||||
}()
|
||||
var data []byte
|
||||
for {
|
||||
select {
|
||||
case <-w.closeChan: //已关闭
|
||||
return
|
||||
case data = <-w.extendRenderProperty.renderChan: //消费数据
|
||||
w.renderImage(data)
|
||||
case data := <-w.extendRenderProperty.renderChan: //消费数据
|
||||
//属性相同则发送渲染,不同则抛弃
|
||||
if data.RenderData.TemplateTag == w.extendRenderProperty.templateTag && data.RenderData.TemplateTagColor.SelectedColorIndex == w.extendRenderProperty.colorSelectedIndex {
|
||||
w.renderImage(data)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// 执行渲染任务
|
||||
func (w *wsConnectItem) renderImage(data []byte) {
|
||||
func (w *wsConnectItem) renderImage(renderImageData websocket_data.RenderImageReqMsg) {
|
||||
//logx.Info("消费渲染数据:", string(data))
|
||||
var renderImageData websocket_data.RenderImageReqMsg
|
||||
/*var renderImageData websocket_data.RenderImageReqMsg
|
||||
if err := json.Unmarshal(data, &renderImageData); err != nil {
|
||||
w.renderErrResponse(renderImageData.RenderId, renderImageData.RenderData.TemplateTag, "", "数据格式错误", renderImageData.RenderData.ProductId, w.userId, w.guestId, 0, 0, 0, 0)
|
||||
logx.Error("invalid format of websocket render image message", err)
|
||||
return
|
||||
}
|
||||
}*/
|
||||
if renderImageData.RenderData.Logo == "" {
|
||||
w.renderErrResponse(renderImageData.RenderId, renderImageData.RenderData.TemplateTag, "", "请传入logo", renderImageData.RenderData.ProductId, w.userId, w.guestId, 0, 0, 0, 0)
|
||||
return
|
||||
|
|
|
@ -34,12 +34,12 @@ type OrderDetailReq {
|
|||
|
||||
type CreateOrderReq {
|
||||
CartIds []int64 `json:"cart_ids"`
|
||||
DeliveryMethod int64 `json:"delivery_method,options=[1,2]"`
|
||||
DeliveryMethod int64 `json:"delivery_method,optional,options=[1,2],default=2"`
|
||||
}
|
||||
|
||||
type CreatePrePaymentByDepositReq {
|
||||
OrderSn string `json:"order_sn"`
|
||||
DeliveryMethod int64 `json:"delivery_method,options=[1,2]"`
|
||||
DeliveryMethod int64 `json:"delivery_method,optional,options=[1,2],default=2"`
|
||||
DeliveryAddress *DeliveryAddress `json:"delivery_address,optional"`
|
||||
}
|
||||
|
||||
|
|
|
@ -34,6 +34,8 @@ type (
|
|||
Create(ctx context.Context, in *CreateReq) (res *CreateRes, err error)
|
||||
// 预支付--定金
|
||||
CreatePrePaymentByDeposit(ctx context.Context, in *CreatePrePaymentByDepositReq) (res *CreatePrePaymentByDepositRes, err error)
|
||||
// 预支付--定金
|
||||
CreatePrePaymentByBalance(ctx context.Context, in *CreatePrePaymentByBalanceReq) (res *CreatePrePaymentByBalanceRes, err error)
|
||||
// 列表
|
||||
List(ctx context.Context, in *ListReq) (res *ListRes, err error)
|
||||
// 详情
|
||||
|
@ -69,7 +71,7 @@ type (
|
|||
UserId int64 `json:"user_id"`
|
||||
OrderSn string `json:"order_sn"`
|
||||
DeliveryMethod int64 `json:"delivery_method"`
|
||||
DeliveryAddress *OrderAddress `json:"delivery_address"` // 收货地址
|
||||
DeliveryAddress *OrderAddress `json:"delivery_address"`
|
||||
}
|
||||
CreatePrePaymentByDepositRes struct {
|
||||
ErrorCode basic.StatusResponse
|
||||
|
@ -78,6 +80,23 @@ type (
|
|||
}
|
||||
/* 预支付--定金 */
|
||||
|
||||
/* 预支付--尾款 */
|
||||
CreatePrePaymentByBalanceReq struct {
|
||||
StripeKey string `json:"stripe_key"`
|
||||
Currency string `json:"currency"`
|
||||
Country string `json:"country"`
|
||||
UserId int64 `json:"user_id"`
|
||||
OrderSn string `json:"order_sn"`
|
||||
DeliveryMethod int64 `json:"delivery_method"`
|
||||
DeliveryAddress *OrderAddress `json:"delivery_address"`
|
||||
}
|
||||
CreatePrePaymentByBalanceRes struct {
|
||||
ErrorCode basic.StatusResponse
|
||||
OrderDetail gmodel.OrderDetail
|
||||
OrderPay OrderPay
|
||||
}
|
||||
/* 预支付--尾款 */
|
||||
|
||||
/* 下单 */
|
||||
CreateReq struct {
|
||||
ExpectedDeliveryTime time.Time `json:"expected_delivery_time"` // 预计到货时间
|
||||
|
@ -122,6 +141,11 @@ type (
|
|||
/* 列表 */
|
||||
)
|
||||
|
||||
// 预支付--尾款
|
||||
func (d *defaultOrder) CreatePrePaymentByBalance(ctx context.Context, in *CreatePrePaymentByBalanceReq) (res *CreatePrePaymentByBalanceRes, err error) {
|
||||
return nil, nil
|
||||
}
|
||||
|
||||
// 预支付--定金
|
||||
func (d *defaultOrder) CreatePrePaymentByDeposit(ctx context.Context, in *CreatePrePaymentByDepositReq) (res *CreatePrePaymentByDepositRes, err error) {
|
||||
var errorCode basic.StatusResponse
|
||||
|
@ -223,6 +247,22 @@ func (d *defaultOrder) CreatePrePaymentByDeposit(ctx context.Context, in *Create
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
if len(uOrderDetail) > 0 {
|
||||
err = fssql.MetadataOrderPATCH(d.MysqlConn, sql, in.OrderSn, gmodel.FsOrder{}, uOrderDetail, "id = ?", order.Id)
|
||||
if err != nil {
|
||||
errorCode = *basic.CodeServiceErr
|
||||
logx.Errorf("create prePayment deposit failed MetadataOrderPATCH, err: %v", err)
|
||||
return &CreatePrePaymentByDepositRes{
|
||||
ErrorCode: errorCode,
|
||||
}, result.Error
|
||||
}
|
||||
}
|
||||
|
||||
ress.OrderDetail.OrderInfo.Utime = &ntime
|
||||
ress.OrderDetail.OrderInfo.DeliveryMethod = in.DeliveryMethod
|
||||
ress.OrderDetail.DeliveryAddress = orderAddress
|
||||
|
||||
// 支付初始化
|
||||
amount := int64(ress.OrderDetailOriginal.OrderAmount.Deposit.PayAmount.Current.CurrentAmount.(float64) / float64(10))
|
||||
payConfig := &pay.Config{}
|
||||
|
@ -245,24 +285,7 @@ func (d *defaultOrder) CreatePrePaymentByDeposit(ctx context.Context, in *Create
|
|||
return &CreatePrePaymentByDepositRes{
|
||||
ErrorCode: errorCode,
|
||||
}, nil
|
||||
} else {
|
||||
//uOrderDetail["order_amount"] = map[type]type
|
||||
}
|
||||
if len(uOrderDetail) > 0 {
|
||||
err = fssql.MetadataOrderPATCH(d.MysqlConn, sql, in.OrderSn, gmodel.FsOrder{}, uOrderDetail, "id = ?", order.Id)
|
||||
if err != nil {
|
||||
errorCode = *basic.CodeServiceErr
|
||||
logx.Errorf("create prePayment deposit failed MetadataOrderPATCH, err: %v", err)
|
||||
return &CreatePrePaymentByDepositRes{
|
||||
ErrorCode: errorCode,
|
||||
}, result.Error
|
||||
}
|
||||
}
|
||||
|
||||
ress.OrderDetail.OrderInfo.Utime = &ntime
|
||||
ress.OrderDetail.OrderInfo.DeliveryMethod = in.DeliveryMethod
|
||||
ress.OrderDetail.DeliveryAddress = orderAddress
|
||||
|
||||
return &CreatePrePaymentByDepositRes{
|
||||
OrderDetail: ress.OrderDetail,
|
||||
OrderPay: OrderPay{
|
||||
|
|
|
@ -79,6 +79,7 @@ func (stripePay *Stripe) GeneratePrepayment(req *GeneratePrepaymentReq) (res *Ge
|
|||
case "intent":
|
||||
// 密钥方式
|
||||
params := &stripe.PaymentIntentParams{
|
||||
Params: stripe.Params{Metadata: map[string]string{"order_sn": req.OrderSn}},
|
||||
Amount: stripe.Int64(req.Amount),
|
||||
Currency: stripe.String(string(req.Currency)),
|
||||
PaymentMethodTypes: stripe.StringSlice([]string{
|
||||
|
|
Loading…
Reference in New Issue
Block a user