feat:新增api
This commit is contained in:
parent
e0a851ba25
commit
6606173050
23
model/gmodel/fs_cloud_deliver_every_tmp_old_gen.go
Normal file
23
model/gmodel/fs_cloud_deliver_every_tmp_old_gen.go
Normal file
|
@ -0,0 +1,23 @@
|
|||
package gmodel
|
||||
|
||||
import (
|
||||
"gorm.io/gorm"
|
||||
)
|
||||
|
||||
// fs_cloud_deliver_every_tmp_old
|
||||
type FsCloudDeliverEveryTmpOld struct {
|
||||
Id int64 `gorm:"primary_key;default:0;auto_increment;" json:"id"` //
|
||||
AdminId *int64 `gorm:"default:0;" json:"admin_id"` // 管理员
|
||||
CloudId *int64 `gorm:"default:0;" json:"cloud_id"` // 云仓ID 暂且只有一个默认为 1
|
||||
OrderDetailTemplateSn *string `gorm:"default:'';" json:"order_detail_template_sn"` //
|
||||
Num *int64 `gorm:"default:0;" json:"num"` // 发货数量
|
||||
Ctime *int64 `gorm:"default:0;" json:"ctime"` // 添加时间
|
||||
}
|
||||
type FsCloudDeliverEveryTmpOldModel struct {
|
||||
db *gorm.DB
|
||||
name string
|
||||
}
|
||||
|
||||
func NewFsCloudDeliverEveryTmpOldModel(db *gorm.DB) *FsCloudDeliverEveryTmpOldModel {
|
||||
return &FsCloudDeliverEveryTmpOldModel{db: db, name: "fs_cloud_deliver_every_tmp_old"}
|
||||
}
|
2
model/gmodel/fs_cloud_deliver_every_tmp_old_logic.go
Normal file
2
model/gmodel/fs_cloud_deliver_every_tmp_old_logic.go
Normal file
|
@ -0,0 +1,2 @@
|
|||
package gmodel
|
||||
// TODO: 使用model的属性做你想做的
|
28
model/gmodel/fs_cloud_deliver_tmp_old_gen.go
Normal file
28
model/gmodel/fs_cloud_deliver_tmp_old_gen.go
Normal file
|
@ -0,0 +1,28 @@
|
|||
package gmodel
|
||||
|
||||
import (
|
||||
"gorm.io/gorm"
|
||||
)
|
||||
|
||||
// fs_cloud_deliver_tmp_old
|
||||
type FsCloudDeliverTmpOld struct {
|
||||
Id int64 `gorm:"primary_key;default:0;auto_increment;" json:"id"` // id
|
||||
CloudId *int64 `gorm:"default:0;" json:"cloud_id"` // 云仓id
|
||||
UserId *int64 `gorm:"default:0;" json:"user_id"` // 用户id
|
||||
AdminId *int64 `gorm:"default:0;" json:"admin_id"` // 操作员id
|
||||
DeliveryType *int64 `gorm:"default:1;" json:"delivery_type"` // 发货公司 之后配置,默认1
|
||||
Fee *int64 `gorm:"default:0;" json:"fee"` // 价格
|
||||
AddressId *int64 `gorm:"default:0;" json:"address_id"` // 地址
|
||||
Ctime *int64 `gorm:"default:0;" json:"ctime"` // 创建时间
|
||||
IsDeliver *int64 `gorm:"default:0;" json:"is_deliver"` // 0未发货,1已发货
|
||||
IsEnd *int64 `gorm:"default:0;" json:"is_end"` // 0未完成,1已完成
|
||||
DeliverId *int64 `gorm:"default:0;" json:"deliver_id"` // 发货总表id
|
||||
}
|
||||
type FsCloudDeliverTmpOldModel struct {
|
||||
db *gorm.DB
|
||||
name string
|
||||
}
|
||||
|
||||
func NewFsCloudDeliverTmpOldModel(db *gorm.DB) *FsCloudDeliverTmpOldModel {
|
||||
return &FsCloudDeliverTmpOldModel{db: db, name: "fs_cloud_deliver_tmp_old"}
|
||||
}
|
2
model/gmodel/fs_cloud_deliver_tmp_old_logic.go
Normal file
2
model/gmodel/fs_cloud_deliver_tmp_old_logic.go
Normal file
|
@ -0,0 +1,2 @@
|
|||
package gmodel
|
||||
// TODO: 使用model的属性做你想做的
|
20
model/gmodel/fs_cloud_old_gen.go
Normal file
20
model/gmodel/fs_cloud_old_gen.go
Normal file
|
@ -0,0 +1,20 @@
|
|||
package gmodel
|
||||
|
||||
import (
|
||||
"gorm.io/gorm"
|
||||
)
|
||||
|
||||
// fs_cloud_old 云仓表
|
||||
type FsCloudOld struct {
|
||||
Id int64 `gorm:"primary_key;default:0;auto_increment;" json:"id"` // id
|
||||
Address *string `gorm:"default:'';" json:"address"` // 云仓地址
|
||||
Title *string `gorm:"default:'';" json:"title"` // 云仓名称
|
||||
}
|
||||
type FsCloudOldModel struct {
|
||||
db *gorm.DB
|
||||
name string
|
||||
}
|
||||
|
||||
func NewFsCloudOldModel(db *gorm.DB) *FsCloudOldModel {
|
||||
return &FsCloudOldModel{db: db, name: "fs_cloud_old"}
|
||||
}
|
2
model/gmodel/fs_cloud_old_logic.go
Normal file
2
model/gmodel/fs_cloud_old_logic.go
Normal file
|
@ -0,0 +1,2 @@
|
|||
package gmodel
|
||||
// TODO: 使用model的属性做你想做的
|
23
model/gmodel/fs_cloud_pick_up_detail_old_gen.go
Normal file
23
model/gmodel/fs_cloud_pick_up_detail_old_gen.go
Normal file
|
@ -0,0 +1,23 @@
|
|||
package gmodel
|
||||
|
||||
import (
|
||||
"gorm.io/gorm"
|
||||
)
|
||||
|
||||
// fs_cloud_pick_up_detail_old 云仓提货单-详情
|
||||
type FsCloudPickUpDetailOld struct {
|
||||
Id int64 `gorm:"primary_key;default:0;auto_increment;" json:"id"` // Id
|
||||
PickId *int64 `gorm:"index;default:0;" json:"pick_id"` // 提货单id
|
||||
StockId *int64 `gorm:"default:0;" json:"stock_id"` // 用户云仓记录id
|
||||
Num *int64 `gorm:"default:0;" json:"num"` // 提取数量
|
||||
Boxes *int64 `gorm:"default:0;" json:"boxes"` // 提取箱数
|
||||
Ctime *int64 `gorm:"default:0;" json:"ctime"` // 添加时间
|
||||
}
|
||||
type FsCloudPickUpDetailOldModel struct {
|
||||
db *gorm.DB
|
||||
name string
|
||||
}
|
||||
|
||||
func NewFsCloudPickUpDetailOldModel(db *gorm.DB) *FsCloudPickUpDetailOldModel {
|
||||
return &FsCloudPickUpDetailOldModel{db: db, name: "fs_cloud_pick_up_detail_old"}
|
||||
}
|
2
model/gmodel/fs_cloud_pick_up_detail_old_logic.go
Normal file
2
model/gmodel/fs_cloud_pick_up_detail_old_logic.go
Normal file
|
@ -0,0 +1,2 @@
|
|||
package gmodel
|
||||
// TODO: 使用model的属性做你想做的
|
28
model/gmodel/fs_cloud_pick_up_old_gen.go
Normal file
28
model/gmodel/fs_cloud_pick_up_old_gen.go
Normal file
|
@ -0,0 +1,28 @@
|
|||
package gmodel
|
||||
|
||||
import (
|
||||
"gorm.io/gorm"
|
||||
)
|
||||
|
||||
// fs_cloud_pick_up_old 云仓提货单
|
||||
type FsCloudPickUpOld struct {
|
||||
Id int64 `gorm:"primary_key;default:0;auto_increment;" json:"id"` // Id
|
||||
UserId *int64 `gorm:"index;default:0;" json:"user_id"` // 用户id
|
||||
TrackNum *string `gorm:"default:'';" json:"track_num"` // 运输号
|
||||
AddressId *int64 `gorm:"default:0;" json:"address_id"` // 地址id
|
||||
AddressInfo *string `gorm:"default:'';" json:"address_info"` // 地址信息 json
|
||||
Status *int64 `gorm:"default:0;" json:"status"` // 运输状态 1 draw 2shipping 3ups 4arrival
|
||||
Ctime *int64 `gorm:"default:0;" json:"ctime"` // 添加时间
|
||||
ShippingTime *int64 `gorm:"default:0;" json:"shipping_time"` // 发货时间
|
||||
UpsTime *int64 `gorm:"default:0;" json:"ups_time"` // 提货时间
|
||||
ArrivalTime *int64 `gorm:"default:0;" json:"arrival_time"` // 到达时间
|
||||
UpsSn *string `gorm:"default:'';" json:"ups_sn"` // 运输单号
|
||||
}
|
||||
type FsCloudPickUpOldModel struct {
|
||||
db *gorm.DB
|
||||
name string
|
||||
}
|
||||
|
||||
func NewFsCloudPickUpOldModel(db *gorm.DB) *FsCloudPickUpOldModel {
|
||||
return &FsCloudPickUpOldModel{db: db, name: "fs_cloud_pick_up_old"}
|
||||
}
|
2
model/gmodel/fs_cloud_pick_up_old_logic.go
Normal file
2
model/gmodel/fs_cloud_pick_up_old_logic.go
Normal file
|
@ -0,0 +1,2 @@
|
|||
package gmodel
|
||||
// TODO: 使用model的属性做你想做的
|
22
model/gmodel/fs_cloud_receive_every_old_gen.go
Normal file
22
model/gmodel/fs_cloud_receive_every_old_gen.go
Normal file
|
@ -0,0 +1,22 @@
|
|||
package gmodel
|
||||
|
||||
import (
|
||||
"gorm.io/gorm"
|
||||
)
|
||||
|
||||
// fs_cloud_receive_every_old
|
||||
type FsCloudReceiveEveryOld struct {
|
||||
Id int64 `gorm:"primary_key;default:0;auto_increment;" json:"id"` //
|
||||
DeliveryId *int64 `gorm:"index;default:0;" json:"delivery_id"` // 云仓收货单id
|
||||
OrderDetailTemplateSn *string `gorm:"index;default:'';" json:"order_detail_template_sn"` //
|
||||
Num *int64 `gorm:"default:0;" json:"num"` // 收到的数量
|
||||
Ctime *int64 `gorm:"default:0;" json:"ctime"` // 添加时间
|
||||
}
|
||||
type FsCloudReceiveEveryOldModel struct {
|
||||
db *gorm.DB
|
||||
name string
|
||||
}
|
||||
|
||||
func NewFsCloudReceiveEveryOldModel(db *gorm.DB) *FsCloudReceiveEveryOldModel {
|
||||
return &FsCloudReceiveEveryOldModel{db: db, name: "fs_cloud_receive_every_old"}
|
||||
}
|
2
model/gmodel/fs_cloud_receive_every_old_logic.go
Normal file
2
model/gmodel/fs_cloud_receive_every_old_logic.go
Normal file
|
@ -0,0 +1,2 @@
|
|||
package gmodel
|
||||
// TODO: 使用model的属性做你想做的
|
26
model/gmodel/fs_cloud_receive_old_gen.go
Normal file
26
model/gmodel/fs_cloud_receive_old_gen.go
Normal file
|
@ -0,0 +1,26 @@
|
|||
package gmodel
|
||||
|
||||
import (
|
||||
"gorm.io/gorm"
|
||||
)
|
||||
|
||||
// fs_cloud_receive_old 云仓接收工厂总单
|
||||
type FsCloudReceiveOld struct {
|
||||
Id int64 `gorm:"primary_key;default:0;auto_increment;" json:"id"` //
|
||||
CloudId *int64 `gorm:"index;default:0;" json:"cloud_id"` // 入库云仓id
|
||||
AdminId *int64 `gorm:"index;default:0;" json:"admin_id"` // 操作员id
|
||||
UserId *int64 `gorm:"index;default:0;" json:"user_id"` // 用户id
|
||||
OrderId *int64 `gorm:"index;default:0;" json:"order_id"` // 入库云仓的订单
|
||||
Fee *int64 `gorm:"default:0;" json:"fee"` // 运费
|
||||
Delivery *string `gorm:"default:'';" json:"delivery"` //
|
||||
Ctime *int64 `gorm:"default:0;" json:"ctime"` // 创建时间
|
||||
Status *int64 `gorm:"default:0;" json:"status"` // 0未收到 1收到
|
||||
}
|
||||
type FsCloudReceiveOldModel struct {
|
||||
db *gorm.DB
|
||||
name string
|
||||
}
|
||||
|
||||
func NewFsCloudReceiveOldModel(db *gorm.DB) *FsCloudReceiveOldModel {
|
||||
return &FsCloudReceiveOldModel{db: db, name: "fs_cloud_receive_old"}
|
||||
}
|
2
model/gmodel/fs_cloud_receive_old_logic.go
Normal file
2
model/gmodel/fs_cloud_receive_old_logic.go
Normal file
|
@ -0,0 +1,2 @@
|
|||
package gmodel
|
||||
// TODO: 使用model的属性做你想做的
|
26
model/gmodel/fs_cloud_render_log_old_gen.go
Normal file
26
model/gmodel/fs_cloud_render_log_old_gen.go
Normal file
|
@ -0,0 +1,26 @@
|
|||
package gmodel
|
||||
|
||||
import (
|
||||
"gorm.io/gorm"
|
||||
)
|
||||
|
||||
// fs_cloud_render_log_old 云渲染日志表
|
||||
type FsCloudRenderLogOld struct {
|
||||
Id int64 `gorm:"primary_key;default:0;auto_increment;" json:"id"` // ID
|
||||
UserId *int64 `gorm:"default:0;" json:"user_id"` // 用户id
|
||||
PostData *string `gorm:"default:'';" json:"post_data"` //
|
||||
PostUrl *string `gorm:"default:'';" json:"post_url"` //
|
||||
Title *string `gorm:"index;default:'';" json:"title"` //
|
||||
Time *int64 `gorm:"default:0;" json:"time"` // 所用时间
|
||||
Result *string `gorm:"default:'';" json:"result"` //
|
||||
Tag *string `gorm:"index;default:'';" json:"tag"` // 标识
|
||||
Ctime *int64 `gorm:"default:0;" json:"ctime"` // 添加时间
|
||||
}
|
||||
type FsCloudRenderLogOldModel struct {
|
||||
db *gorm.DB
|
||||
name string
|
||||
}
|
||||
|
||||
func NewFsCloudRenderLogOldModel(db *gorm.DB) *FsCloudRenderLogOldModel {
|
||||
return &FsCloudRenderLogOldModel{db: db, name: "fs_cloud_render_log_old"}
|
||||
}
|
2
model/gmodel/fs_cloud_render_log_old_logic.go
Normal file
2
model/gmodel/fs_cloud_render_log_old_logic.go
Normal file
|
@ -0,0 +1,2 @@
|
|||
package gmodel
|
||||
// TODO: 使用model的属性做你想做的
|
25
model/gmodel/fs_cloud_user_apply_back_old_gen.go
Normal file
25
model/gmodel/fs_cloud_user_apply_back_old_gen.go
Normal file
|
@ -0,0 +1,25 @@
|
|||
package gmodel
|
||||
|
||||
import (
|
||||
"gorm.io/gorm"
|
||||
)
|
||||
|
||||
// fs_cloud_user_apply_back_old 该表废弃
|
||||
type FsCloudUserApplyBackOld struct {
|
||||
Id int64 `gorm:"primary_key;default:0;auto_increment;" json:"id"` //
|
||||
UserHash *string `gorm:"default:'';" json:"user_hash"` //
|
||||
OrderDetailTemplateId *int64 `gorm:"default:0;" json:"order_detail_template_id"` // 详情modelID
|
||||
Num *int64 `gorm:"default:0;" json:"num"` // 发货数量
|
||||
AddressTo *string `gorm:"default:'';" json:"address_to"` // 收获地址
|
||||
Ctime *int64 `gorm:"default:0;" json:"ctime"` // 添加时间
|
||||
StorageFee *int64 `gorm:"default:0;" json:"storage_fee"` // 存储费用
|
||||
Status *int64 `gorm:"default:0;" json:"status"` // 状态位 是否已发货 是否处理 是否删除 是否推送
|
||||
}
|
||||
type FsCloudUserApplyBackOldModel struct {
|
||||
db *gorm.DB
|
||||
name string
|
||||
}
|
||||
|
||||
func NewFsCloudUserApplyBackOldModel(db *gorm.DB) *FsCloudUserApplyBackOldModel {
|
||||
return &FsCloudUserApplyBackOldModel{db: db, name: "fs_cloud_user_apply_back_old"}
|
||||
}
|
2
model/gmodel/fs_cloud_user_apply_back_old_logic.go
Normal file
2
model/gmodel/fs_cloud_user_apply_back_old_logic.go
Normal file
|
@ -0,0 +1,2 @@
|
|||
package gmodel
|
||||
// TODO: 使用model的属性做你想做的
|
27
model/gmodel/fs_order_affiliate_old_gen.go
Normal file
27
model/gmodel/fs_order_affiliate_old_gen.go
Normal file
|
@ -0,0 +1,27 @@
|
|||
package gmodel
|
||||
|
||||
import (
|
||||
"gorm.io/gorm"
|
||||
)
|
||||
|
||||
// fs_order_affiliate_old 订单附属表-流程控制时间等
|
||||
type FsOrderAffiliateOld struct {
|
||||
Id int64 `gorm:"primary_key;default:0;auto_increment;" json:"id"` // id
|
||||
OrderId *int64 `gorm:"unique_key;default:0;" json:"order_id"` // 订单id
|
||||
SureTime *int64 `gorm:"default:0;" json:"sure_time"` // 确认时间
|
||||
ProductTime *int64 `gorm:"default:0;" json:"product_time"` // 生产时间
|
||||
ProductEndtime *int64 `gorm:"default:0;" json:"product_endtime"` // 生成完成时间
|
||||
DeliverTime *int64 `gorm:"default:0;" json:"deliver_time"` // 发货时间
|
||||
UpsDeliverTime *int64 `gorm:"default:0;" json:"ups_deliver_time"` // ups发货时间
|
||||
UpsTime *int64 `gorm:"default:0;" json:"ups_time"` // UPS提货时间
|
||||
ArrivalTime *int64 `gorm:"default:0;" json:"arrival_time"` // 到达云仓的时间
|
||||
RecevieTime *int64 `gorm:"default:0;" json:"recevie_time"` // 云仓收货时间
|
||||
}
|
||||
type FsOrderAffiliateOldModel struct {
|
||||
db *gorm.DB
|
||||
name string
|
||||
}
|
||||
|
||||
func NewFsOrderAffiliateOldModel(db *gorm.DB) *FsOrderAffiliateOldModel {
|
||||
return &FsOrderAffiliateOldModel{db: db, name: "fs_order_affiliate_old"}
|
||||
}
|
2
model/gmodel/fs_order_affiliate_old_logic.go
Normal file
2
model/gmodel/fs_order_affiliate_old_logic.go
Normal file
|
@ -0,0 +1,2 @@
|
|||
package gmodel
|
||||
// TODO: 使用model的属性做你想做的
|
41
model/gmodel/fs_order_detail_old_gen.go
Normal file
41
model/gmodel/fs_order_detail_old_gen.go
Normal file
|
@ -0,0 +1,41 @@
|
|||
package gmodel
|
||||
|
||||
import (
|
||||
"gorm.io/gorm"
|
||||
)
|
||||
|
||||
// fs_order_detail_old 订单详细表
|
||||
type FsOrderDetailOld struct {
|
||||
Id int64 `gorm:"primary_key;default:0;auto_increment;" json:"id"` //
|
||||
Sn *string `gorm:"unique_key;default:'';" json:"sn"` // 唯一编码
|
||||
OrderId *int64 `gorm:"index;default:0;" json:"order_id"` // 订单ID
|
||||
UserId *int64 `gorm:"default:0;" json:"user_id"` // 用户ID
|
||||
FactoryId *int64 `gorm:"default:0;" json:"factory_id"` // 工厂ID
|
||||
OrderDetailTemplateId *int64 `gorm:"default:0;" json:"order_detail_template_id"` // 详情templateID
|
||||
ProductId *int64 `gorm:"default:0;" json:"product_id"` // 产品ID
|
||||
BuyNum *int64 `gorm:"default:0;" json:"buy_num"` // 购买数量
|
||||
PushNum *int64 `gorm:"default:0;" json:"push_num"` // 已发数量
|
||||
Amount *int64 `gorm:"default:0;" json:"amount"` // 单价
|
||||
Cover *string `gorm:"default:'';" json:"cover"` // 截图
|
||||
Ctime *int64 `gorm:"default:0;" json:"ctime"` // 添加时间
|
||||
Status *int64 `gorm:"default:0;" json:"status"` // 状态位 是否推送到厂家 是否生产完成 是否发货完成
|
||||
OptionalId *int64 `gorm:"default:0;" json:"optional_id"` // 选项ID
|
||||
OptionalTitle *string `gorm:"default:'';" json:"optional_title"` // 选项名称
|
||||
OptionPrice *int64 `gorm:"default:0;" json:"option_price"` // 配件价格
|
||||
IsTofactory *int64 `gorm:"default:0;" json:"is_tofactory"` // 是否推送到工厂
|
||||
IsProduct *int64 `gorm:"default:0;" json:"is_product"` // 是否生产中
|
||||
IsProductCompletion *int64 `gorm:"default:0;" json:"is_product_completion"` // 是否生产完成
|
||||
IsCloud *int64 `gorm:"default:0;" json:"is_cloud"` // 是否是云仓订单
|
||||
IsTocloud *int64 `gorm:"default:0;" json:"is_tocloud"` // 是否已发云仓(云仓单要发货到云仓,直接发到用户的不需要发到云仓)
|
||||
IsDeliver *int64 `gorm:"default:0;" json:"is_deliver"` // 是否已发货
|
||||
IsEnd *int64 `gorm:"default:0;" json:"is_end"` // 是否完成订单(签收)
|
||||
CartId *int64 `gorm:"index;default:0;" json:"cart_id"` // 购物车编号
|
||||
}
|
||||
type FsOrderDetailOldModel struct {
|
||||
db *gorm.DB
|
||||
name string
|
||||
}
|
||||
|
||||
func NewFsOrderDetailOldModel(db *gorm.DB) *FsOrderDetailOldModel {
|
||||
return &FsOrderDetailOldModel{db: db, name: "fs_order_detail_old"}
|
||||
}
|
2
model/gmodel/fs_order_detail_old_logic.go
Normal file
2
model/gmodel/fs_order_detail_old_logic.go
Normal file
|
@ -0,0 +1,2 @@
|
|||
package gmodel
|
||||
// TODO: 使用model的属性做你想做的
|
28
model/gmodel/fs_order_detail_template_old_gen.go
Normal file
28
model/gmodel/fs_order_detail_template_old_gen.go
Normal file
|
@ -0,0 +1,28 @@
|
|||
package gmodel
|
||||
|
||||
import (
|
||||
"gorm.io/gorm"
|
||||
)
|
||||
|
||||
// fs_order_detail_template_old 订单模板详细表
|
||||
type FsOrderDetailTemplateOld struct {
|
||||
Id int64 `gorm:"primary_key;default:0;auto_increment;" json:"id"` //
|
||||
Sn *string `gorm:"unique_key;default:'';" json:"sn"` // 唯一编码
|
||||
ProductId *int64 `gorm:"index;default:0;" json:"product_id"` // 产品ID
|
||||
ModelId *int64 `gorm:"default:0;" json:"model_id"` // 模型ID
|
||||
TemplateId *int64 `gorm:"index;default:0;" json:"template_id"` // 模板ID
|
||||
MaterialId *int64 `gorm:"index;default:0;" json:"material_id"` // 材质id
|
||||
SizeId *int64 `gorm:"index;default:0;" json:"size_id"` // 尺寸id
|
||||
EachBoxNum *int64 `gorm:"default:0;" json:"each_box_num"` // 每一箱的个数
|
||||
EachBoxWeight *float64 `gorm:"default:0.00;" json:"each_box_weight"` // 每一箱的重量 单位KG
|
||||
DesignId *int64 `gorm:"index;default:0;" json:"design_id"` // 设计ID
|
||||
Ctime *int64 `gorm:"default:0;" json:"ctime"` // 添加时间
|
||||
}
|
||||
type FsOrderDetailTemplateOldModel struct {
|
||||
db *gorm.DB
|
||||
name string
|
||||
}
|
||||
|
||||
func NewFsOrderDetailTemplateOldModel(db *gorm.DB) *FsOrderDetailTemplateOldModel {
|
||||
return &FsOrderDetailTemplateOldModel{db: db, name: "fs_order_detail_template_old"}
|
||||
}
|
2
model/gmodel/fs_order_detail_template_old_logic.go
Normal file
2
model/gmodel/fs_order_detail_template_old_logic.go
Normal file
|
@ -0,0 +1,2 @@
|
|||
package gmodel
|
||||
// TODO: 使用model的属性做你想做的
|
|
@ -5,44 +5,17 @@ import (
|
|||
"time"
|
||||
)
|
||||
|
||||
// fs_order
|
||||
// fs_order 订单表
|
||||
type FsOrder struct {
|
||||
Id int64 `gorm:"primary_key;default:0;auto_increment;" json:"id"` //
|
||||
Sn *string `gorm:"unique_key;default:'';" json:"sn"` // 订单编号 FS211224OL2XDKNP
|
||||
Id int64 `gorm:"primary_key;default:0;auto_increment;" json:"id"` // 订单ID
|
||||
UserId *int64 `gorm:"index;default:0;" json:"user_id"` // 用户ID
|
||||
SellerUserId *int64 `gorm:"default:0;" json:"seller_user_id"` // 销售员ID 0:自主下单
|
||||
TotalAmount *int64 `gorm:"default:0;" json:"total_amount"` // 总价
|
||||
PayedAmount *int64 `gorm:"default:0;" json:"payed_amount"` // 已支付金额
|
||||
PayMethod *int64 `gorm:"default:0;" json:"pay_method"` // 支付方式 1paypal 2strip
|
||||
Ctime *int64 `gorm:"default:0;" json:"ctime"` // 添加时间
|
||||
Utime *int64 `gorm:"default:0;" json:"utime"` // 更新时间
|
||||
Ptime *int64 `gorm:"default:0;" json:"ptime"` // 最后一次 支付时间(可能多次支付)
|
||||
AddressId *int64 `gorm:"index;default:0;" json:"address_id"` // 地址ID或者云仓ID
|
||||
DeliveryMethod *int64 `gorm:"default:0;" json:"delivery_method"` // 配送方式 1:直接发货到收获地址 2:云仓
|
||||
CustomerMark *string `gorm:"default:'';" json:"customer_mark"` // 客户备注
|
||||
Mark *string `gorm:"default:'';" json:"mark"` // 后台订单备注
|
||||
AddressInfo *string `gorm:"default:'';" json:"address_info"` // 详细地址信息JSON
|
||||
IsSup *int64 `gorm:"default:0;" json:"is_sup"` // 0不是补货 1是补货
|
||||
Status *int64 `gorm:"default:0;" json:"status"` // 状态位(0:未支付,1:部分支付,2:支付完成,3:部分生产,4:部分生产完成,5:全部生产,6:全部生产完成,7:部分发货,8:发货完成,9:完成订单,10:取消订单,11:退款中,12:退款完成,13:订单已删除,14:订单已关闭)
|
||||
IsPartPay *int64 `gorm:"default:0;" json:"is_part_pay"` // 是否部分支付(0:否,1:是)
|
||||
IsPayCompleted *int64 `gorm:"default:0;" json:"is_pay_completed"` // 是否支付完成(0:否,1:是)
|
||||
IsPartProduct *int64 `gorm:"default:0;" json:"is_part_product"` // 是否部分生产(0:否,1:是)
|
||||
IsPartProductCompleted *int64 `gorm:"default:0;" json:"is_part_product_completed"` // 是否部分生产完成(0:否,1:是)
|
||||
IsAllProduct *int64 `gorm:"default:0;" json:"is_all_product"` // 是否全部生产(0:否,1:是)
|
||||
IsAllProductCompleted *int64 `gorm:"default:0;" json:"is_all_product_completed"` // 是否全部生产完成(0:否,1:是)
|
||||
IsPartDelivery *int64 `gorm:"default:0;" json:"is_part_delivery"` // 是否部分发货(0:否,1:是)
|
||||
IsDeliveryCompleted *int64 `gorm:"default:0;" json:"is_delivery_completed"` // 是否发货完成(0:否,1:是)
|
||||
IsComplated *int64 `gorm:"default:0;" json:"is_complated"` // 是否完成订单(0:否,1:是)
|
||||
IsCancel *int64 `gorm:"default:0;" json:"is_cancel"` // 是否取消订单(0:否,1:是)
|
||||
IsRefunding *int64 `gorm:"default:0;" json:"is_refunding"` // 是否退款中(0:否,1:是)
|
||||
IsRefunded *int64 `gorm:"default:0;" json:"is_refunded"` // 是否退款完成(0:否,1:是)
|
||||
IsDeleted *int64 `gorm:"default:0;" json:"is_deleted"` // 是否删除(0:否,1:是)
|
||||
RefundReasonId *int64 `gorm:"default:0;" json:"refund_reason_id"` // 取消订单原因ID
|
||||
RefundReason *string `gorm:"default:'';" json:"refund_reason"` // 取消订单原因
|
||||
TsTime *time.Time `gorm:"default:'0000-00-00 00:00:00';" json:"ts_time"` //
|
||||
IsSure *int64 `gorm:"default:0;" json:"is_sure"` // 是否确认订单 1确认0未确认
|
||||
DeliverSn *string `gorm:"default:'';" json:"deliver_sn"` // 发货单号
|
||||
EmailTime *int64 `gorm:"default:0;" json:"email_time"` // 邮件发送时间
|
||||
DeliveryMethod *int64 `gorm:"index;default:0;" json:"delivery_method"` // 物流类型
|
||||
OrderNo *string `gorm:"index;default:'';" json:"order_no"` //
|
||||
OrderSource *string `gorm:"default:'';" json:"order_source"` //
|
||||
Status *int64 `gorm:"index;default:0;" json:"status"` // 订单状态
|
||||
Metadata *[]byte `gorm:"default:'';" json:"metadata"` //
|
||||
Ctime *time.Time `gorm:"default:'0000-00-00 00:00:00';" json:"ctime"` //
|
||||
Utime *time.Time `gorm:"default:'0000-00-00 00:00:00';" json:"utime"` //
|
||||
}
|
||||
type FsOrderModel struct {
|
||||
db *gorm.DB
|
||||
|
|
54
model/gmodel/fs_order_old_gen.go
Normal file
54
model/gmodel/fs_order_old_gen.go
Normal file
|
@ -0,0 +1,54 @@
|
|||
package gmodel
|
||||
|
||||
import (
|
||||
"gorm.io/gorm"
|
||||
"time"
|
||||
)
|
||||
|
||||
// fs_order_old
|
||||
type FsOrderOld struct {
|
||||
Id int64 `gorm:"primary_key;default:0;auto_increment;" json:"id"` //
|
||||
Sn *string `gorm:"unique_key;default:'';" json:"sn"` // 订单编号 FS211224OL2XDKNP
|
||||
UserId *int64 `gorm:"index;default:0;" json:"user_id"` // 用户ID
|
||||
SellerUserId *int64 `gorm:"default:0;" json:"seller_user_id"` // 销售员ID 0:自主下单
|
||||
TotalAmount *int64 `gorm:"default:0;" json:"total_amount"` // 总价
|
||||
PayedAmount *int64 `gorm:"default:0;" json:"payed_amount"` // 已支付金额
|
||||
PayMethod *int64 `gorm:"default:0;" json:"pay_method"` // 支付方式 1paypal 2strip
|
||||
Ctime *int64 `gorm:"default:0;" json:"ctime"` // 添加时间
|
||||
Utime *int64 `gorm:"default:0;" json:"utime"` // 更新时间
|
||||
Ptime *int64 `gorm:"default:0;" json:"ptime"` // 最后一次 支付时间(可能多次支付)
|
||||
AddressId *int64 `gorm:"index;default:0;" json:"address_id"` // 地址ID或者云仓ID
|
||||
DeliveryMethod *int64 `gorm:"default:0;" json:"delivery_method"` // 配送方式 1:直接发货到收获地址 2:云仓
|
||||
CustomerMark *string `gorm:"default:'';" json:"customer_mark"` // 客户备注
|
||||
Mark *string `gorm:"default:'';" json:"mark"` // 后台订单备注
|
||||
AddressInfo *string `gorm:"default:'';" json:"address_info"` // 详细地址信息JSON
|
||||
IsSup *int64 `gorm:"default:0;" json:"is_sup"` // 0不是补货 1是补货
|
||||
Status *int64 `gorm:"default:0;" json:"status"` // 状态位(0:未支付,1:部分支付,2:支付完成,3:部分生产,4:部分生产完成,5:全部生产,6:全部生产完成,7:部分发货,8:发货完成,9:完成订单,10:取消订单,11:退款中,12:退款完成,13:订单已删除,14:订单已关闭)
|
||||
IsPartPay *int64 `gorm:"default:0;" json:"is_part_pay"` // 是否部分支付(0:否,1:是)
|
||||
IsPayCompleted *int64 `gorm:"default:0;" json:"is_pay_completed"` // 是否支付完成(0:否,1:是)
|
||||
IsPartProduct *int64 `gorm:"default:0;" json:"is_part_product"` // 是否部分生产(0:否,1:是)
|
||||
IsPartProductCompleted *int64 `gorm:"default:0;" json:"is_part_product_completed"` // 是否部分生产完成(0:否,1:是)
|
||||
IsAllProduct *int64 `gorm:"default:0;" json:"is_all_product"` // 是否全部生产(0:否,1:是)
|
||||
IsAllProductCompleted *int64 `gorm:"default:0;" json:"is_all_product_completed"` // 是否全部生产完成(0:否,1:是)
|
||||
IsPartDelivery *int64 `gorm:"default:0;" json:"is_part_delivery"` // 是否部分发货(0:否,1:是)
|
||||
IsDeliveryCompleted *int64 `gorm:"default:0;" json:"is_delivery_completed"` // 是否发货完成(0:否,1:是)
|
||||
IsComplated *int64 `gorm:"default:0;" json:"is_complated"` // 是否完成订单(0:否,1:是)
|
||||
IsCancel *int64 `gorm:"default:0;" json:"is_cancel"` // 是否取消订单(0:否,1:是)
|
||||
IsRefunding *int64 `gorm:"default:0;" json:"is_refunding"` // 是否退款中(0:否,1:是)
|
||||
IsRefunded *int64 `gorm:"default:0;" json:"is_refunded"` // 是否退款完成(0:否,1:是)
|
||||
IsDeleted *int64 `gorm:"default:0;" json:"is_deleted"` // 是否删除(0:否,1:是)
|
||||
RefundReasonId *int64 `gorm:"default:0;" json:"refund_reason_id"` // 取消订单原因ID
|
||||
RefundReason *string `gorm:"default:'';" json:"refund_reason"` // 取消订单原因
|
||||
TsTime *time.Time `gorm:"default:'0000-00-00 00:00:00';" json:"ts_time"` //
|
||||
IsSure *int64 `gorm:"default:0;" json:"is_sure"` // 是否确认订单 1确认0未确认
|
||||
DeliverSn *string `gorm:"default:'';" json:"deliver_sn"` // 发货单号
|
||||
EmailTime *int64 `gorm:"default:0;" json:"email_time"` // 邮件发送时间
|
||||
}
|
||||
type FsOrderOldModel struct {
|
||||
db *gorm.DB
|
||||
name string
|
||||
}
|
||||
|
||||
func NewFsOrderOldModel(db *gorm.DB) *FsOrderOldModel {
|
||||
return &FsOrderOldModel{db: db, name: "fs_order_old"}
|
||||
}
|
2
model/gmodel/fs_order_old_logic.go
Normal file
2
model/gmodel/fs_order_old_logic.go
Normal file
|
@ -0,0 +1,2 @@
|
|||
package gmodel
|
||||
// TODO: 使用model的属性做你想做的
|
22
model/gmodel/fs_order_remark_old_gen.go
Normal file
22
model/gmodel/fs_order_remark_old_gen.go
Normal file
|
@ -0,0 +1,22 @@
|
|||
package gmodel
|
||||
|
||||
import (
|
||||
"gorm.io/gorm"
|
||||
)
|
||||
|
||||
// fs_order_remark_old 订单备注表
|
||||
type FsOrderRemarkOld struct {
|
||||
Id int64 `gorm:"primary_key;default:0;auto_increment;" json:"id"` // id
|
||||
OrderId *int64 `gorm:"index;default:0;" json:"order_id"` // 订单id
|
||||
Remark *string `gorm:"default:'';" json:"remark"` // 订单备注
|
||||
AdminId *int64 `gorm:"default:0;" json:"admin_id"` // 后台操作人员
|
||||
Ctime *int64 `gorm:"default:0;" json:"ctime"` // 添加时间
|
||||
}
|
||||
type FsOrderRemarkOldModel struct {
|
||||
db *gorm.DB
|
||||
name string
|
||||
}
|
||||
|
||||
func NewFsOrderRemarkOldModel(db *gorm.DB) *FsOrderRemarkOldModel {
|
||||
return &FsOrderRemarkOldModel{db: db, name: "fs_order_remark_old"}
|
||||
}
|
2
model/gmodel/fs_order_remark_old_logic.go
Normal file
2
model/gmodel/fs_order_remark_old_logic.go
Normal file
|
@ -0,0 +1,2 @@
|
|||
package gmodel
|
||||
// TODO: 使用model的属性做你想做的
|
25
model/gmodel/fs_order_trade_event_gen.go
Normal file
25
model/gmodel/fs_order_trade_event_gen.go
Normal file
|
@ -0,0 +1,25 @@
|
|||
package gmodel
|
||||
|
||||
import (
|
||||
"gorm.io/gorm"
|
||||
"time"
|
||||
)
|
||||
|
||||
// fs_order_trade_event 订单交易事件表
|
||||
type FsOrderTradeEvent struct {
|
||||
Id int64 `gorm:"primary_key;default:0;auto_increment;" json:"id"` // 订单交易ID
|
||||
PayMethod *int64 `gorm:"default:0;" json:"pay_method"` // 支付方式:1=stripe,2=paypal
|
||||
EventId *string `gorm:"default:'';" json:"event_id"` //
|
||||
EventType *string `gorm:"default:'';" json:"event_type"` //
|
||||
EventData *[]byte `gorm:"default:'';" json:"event_data"` //
|
||||
Ctime *time.Time `gorm:"default:'0000-00-00 00:00:00';" json:"ctime"` //
|
||||
Utime *time.Time `gorm:"default:'0000-00-00 00:00:00';" json:"utime"` //
|
||||
}
|
||||
type FsOrderTradeEventModel struct {
|
||||
db *gorm.DB
|
||||
name string
|
||||
}
|
||||
|
||||
func NewFsOrderTradeEventModel(db *gorm.DB) *FsOrderTradeEventModel {
|
||||
return &FsOrderTradeEventModel{db: db, name: "fs_order_trade_event"}
|
||||
}
|
2
model/gmodel/fs_order_trade_event_logic.go
Normal file
2
model/gmodel/fs_order_trade_event_logic.go
Normal file
|
@ -0,0 +1,2 @@
|
|||
package gmodel
|
||||
// TODO: 使用model的属性做你想做的
|
36
model/gmodel/fs_order_trade_gen.go
Normal file
36
model/gmodel/fs_order_trade_gen.go
Normal file
|
@ -0,0 +1,36 @@
|
|||
package gmodel
|
||||
|
||||
import (
|
||||
"gorm.io/gorm"
|
||||
"time"
|
||||
)
|
||||
|
||||
// fs_order_trade 订单交易表
|
||||
type FsOrderTrade struct {
|
||||
Id int64 `gorm:"primary_key;default:0;auto_increment;" json:"id"` // 订单交易ID
|
||||
UserId *int64 `gorm:"index;default:0;" json:"user_id"` // 用户ID
|
||||
OrderNo *string `gorm:"default:'';" json:"order_no"` //
|
||||
OrderSource *string `gorm:"default:'';" json:"order_source"` //
|
||||
TradeNo *string `gorm:"index;default:'';" json:"trade_no"` //
|
||||
PayAmount *int64 `gorm:"default:0;" json:"pay_amount"` // 支付金额 (分)
|
||||
PayStatus *int64 `gorm:"default:0;" json:"pay_status"` // 支付状态:1=未成功,2=已成功
|
||||
PaymentMethod *int64 `gorm:"default:0;" json:"payment_method"` // 支付方式:1=stripe,2=paypal
|
||||
PayStage *int64 `gorm:"default:0;" json:"pay_stage"` // 支付阶段:1=首付,2=尾款
|
||||
RefundStatus *int64 `gorm:"default:0;" json:"refund_status"` // 退款状态:1=未退款,2=已退款
|
||||
CardNo *string `gorm:"default:'';" json:"card_no"` //
|
||||
CardBrand *string `gorm:"default:'';" json:"card_brand"` //
|
||||
Country *string `gorm:"default:'';" json:"country"` //
|
||||
Currency *string `gorm:"default:'';" json:"currency"` //
|
||||
Metadata *[]byte `gorm:"default:'';" json:"metadata"` //
|
||||
Ctime *time.Time `gorm:"default:'0000-00-00 00:00:00';" json:"ctime"` //
|
||||
Utime *time.Time `gorm:"default:'0000-00-00 00:00:00';" json:"utime"` //
|
||||
PayTitle *string `gorm:"default:'';" json:"pay_title"` //
|
||||
}
|
||||
type FsOrderTradeModel struct {
|
||||
db *gorm.DB
|
||||
name string
|
||||
}
|
||||
|
||||
func NewFsOrderTradeModel(db *gorm.DB) *FsOrderTradeModel {
|
||||
return &FsOrderTradeModel{db: db, name: "fs_order_trade"}
|
||||
}
|
2
model/gmodel/fs_order_trade_logic.go
Normal file
2
model/gmodel/fs_order_trade_logic.go
Normal file
|
@ -0,0 +1,2 @@
|
|||
package gmodel
|
||||
// TODO: 使用model的属性做你想做的
|
|
@ -17,8 +17,6 @@ type FsShoppingCart struct {
|
|||
PurchaseQuantity *int64 `gorm:"default:0;" json:"purchase_quantity"` // 购买数量
|
||||
Snapshot *string `gorm:"default:'';" json:"snapshot"` //
|
||||
IsHighlyCustomized *int64 `gorm:"default:0;" json:"is_highly_customized"` // 是否高度定制 0非 1是(针对客人高度定制只能后台增加如购物车)
|
||||
Status *int64 `gorm:"default:0;" json:"status"` // 0未下单 1已下单
|
||||
IsEffective *int64 `gorm:"default:1;" json:"is_effective"` // 是否有效 0非 1是(针对对购物车下单,此前数据表更失效)
|
||||
Ctime *time.Time `gorm:"default:'0000-00-00 00:00:00';" json:"ctime"` //
|
||||
Utime *time.Time `gorm:"default:'0000-00-00 00:00:00';" json:"utime"` //
|
||||
}
|
||||
|
|
|
@ -7,7 +7,6 @@ type AllModelsGen struct {
|
|||
CasbinRule *CasbinRuleModel // casbin_rule
|
||||
FsAddress *FsAddressModel // fs_address 用户地址表
|
||||
FsAdminApi *FsAdminApiModel // fs_admin_api 后台--接口表
|
||||
FsAdminAuthRole *FsAdminAuthRoleModel // fs_admin_auth_role 后台--角色表
|
||||
FsAdminDepartment *FsAdminDepartmentModel // fs_admin_department 后台--部门表
|
||||
FsAdminMenu *FsAdminMenuModel // fs_admin_menu 后台--菜单表
|
||||
FsAdminRole *FsAdminRoleModel // fs_admin_role 后台--角色表
|
||||
|
@ -23,15 +22,15 @@ type AllModelsGen struct {
|
|||
FsCardGroup *FsCardGroupModel // fs_card_group 卡号分组表
|
||||
FsCart *FsCartModel // fs_cart 购物车
|
||||
FsChangeCode *FsChangeCodeModel // fs_change_code 忘记密码code表
|
||||
FsCloud *FsCloudModel // fs_cloud 云仓表
|
||||
FsCloudDeliverEveryTmp *FsCloudDeliverEveryTmpModel // fs_cloud_deliver_every_tmp
|
||||
FsCloudDeliverTmp *FsCloudDeliverTmpModel // fs_cloud_deliver_tmp
|
||||
FsCloudPickUp *FsCloudPickUpModel // fs_cloud_pick_up 云仓提货单
|
||||
FsCloudPickUpDetail *FsCloudPickUpDetailModel // fs_cloud_pick_up_detail 云仓提货单-详情
|
||||
FsCloudReceive *FsCloudReceiveModel // fs_cloud_receive 云仓接收工厂总单
|
||||
FsCloudReceiveEvery *FsCloudReceiveEveryModel // fs_cloud_receive_every
|
||||
FsCloudRenderLog *FsCloudRenderLogModel // fs_cloud_render_log 云渲染日志表
|
||||
FsCloudUserApplyBack *FsCloudUserApplyBackModel // fs_cloud_user_apply_back 该表废弃
|
||||
FsCloudDeliverEveryTmpOld *FsCloudDeliverEveryTmpOldModel // fs_cloud_deliver_every_tmp_old
|
||||
FsCloudDeliverTmpOld *FsCloudDeliverTmpOldModel // fs_cloud_deliver_tmp_old
|
||||
FsCloudOld *FsCloudOldModel // fs_cloud_old 云仓表
|
||||
FsCloudPickUpDetailOld *FsCloudPickUpDetailOldModel // fs_cloud_pick_up_detail_old 云仓提货单-详情
|
||||
FsCloudPickUpOld *FsCloudPickUpOldModel // fs_cloud_pick_up_old 云仓提货单
|
||||
FsCloudReceiveEveryOld *FsCloudReceiveEveryOldModel // fs_cloud_receive_every_old
|
||||
FsCloudReceiveOld *FsCloudReceiveOldModel // fs_cloud_receive_old 云仓接收工厂总单
|
||||
FsCloudRenderLogOld *FsCloudRenderLogOldModel // fs_cloud_render_log_old 云渲染日志表
|
||||
FsCloudUserApplyBackOld *FsCloudUserApplyBackOldModel // fs_cloud_user_apply_back_old 该表废弃
|
||||
FsContact *FsContactModel // fs_contact 该表暂未使用
|
||||
FsContactService *FsContactServiceModel // fs_contact_service
|
||||
FsCoupon *FsCouponModel // fs_coupon 代金券(暂未使用)
|
||||
|
@ -55,11 +54,14 @@ type AllModelsGen struct {
|
|||
FsMenu *FsMenuModel // fs_menu 后台菜单
|
||||
FsMerchantCategory *FsMerchantCategoryModel // fs_merchant_category 商户类型表
|
||||
FsMigration *FsMigrationModel // fs_migration 版本库
|
||||
FsOrder *FsOrderModel // fs_order
|
||||
FsOrderAffiliate *FsOrderAffiliateModel // fs_order_affiliate 订单附属表-流程控制时间等
|
||||
FsOrderDetail *FsOrderDetailModel // fs_order_detail 订单详细表
|
||||
FsOrderDetailTemplate *FsOrderDetailTemplateModel // fs_order_detail_template 订单模板详细表
|
||||
FsOrderRemark *FsOrderRemarkModel // fs_order_remark 订单备注表
|
||||
FsOrder *FsOrderModel // fs_order 订单表
|
||||
FsOrderAffiliateOld *FsOrderAffiliateOldModel // fs_order_affiliate_old 订单附属表-流程控制时间等
|
||||
FsOrderDetailOld *FsOrderDetailOldModel // fs_order_detail_old 订单详细表
|
||||
FsOrderDetailTemplateOld *FsOrderDetailTemplateOldModel // fs_order_detail_template_old 订单模板详细表
|
||||
FsOrderOld *FsOrderOldModel // fs_order_old
|
||||
FsOrderRemarkOld *FsOrderRemarkOldModel // fs_order_remark_old 订单备注表
|
||||
FsOrderTrade *FsOrderTradeModel // fs_order_trade 订单交易表
|
||||
FsOrderTradeEvent *FsOrderTradeEventModel // fs_order_trade_event 订单交易事件表
|
||||
FsPay *FsPayModel // fs_pay 支付记录
|
||||
FsPayEvent *FsPayEventModel // fs_pay_event 支付回调事件日志
|
||||
FsProduct *FsProductModel // fs_product 产品表
|
||||
|
@ -114,7 +116,6 @@ func NewAllModels(gdb *gorm.DB) *AllModelsGen {
|
|||
CasbinRule: NewCasbinRuleModel(gdb),
|
||||
FsAddress: NewFsAddressModel(gdb),
|
||||
FsAdminApi: NewFsAdminApiModel(gdb),
|
||||
FsAdminAuthRole: NewFsAdminAuthRoleModel(gdb),
|
||||
FsAdminDepartment: NewFsAdminDepartmentModel(gdb),
|
||||
FsAdminMenu: NewFsAdminMenuModel(gdb),
|
||||
FsAdminRole: NewFsAdminRoleModel(gdb),
|
||||
|
@ -130,15 +131,15 @@ func NewAllModels(gdb *gorm.DB) *AllModelsGen {
|
|||
FsCardGroup: NewFsCardGroupModel(gdb),
|
||||
FsCart: NewFsCartModel(gdb),
|
||||
FsChangeCode: NewFsChangeCodeModel(gdb),
|
||||
FsCloud: NewFsCloudModel(gdb),
|
||||
FsCloudDeliverEveryTmp: NewFsCloudDeliverEveryTmpModel(gdb),
|
||||
FsCloudDeliverTmp: NewFsCloudDeliverTmpModel(gdb),
|
||||
FsCloudPickUp: NewFsCloudPickUpModel(gdb),
|
||||
FsCloudPickUpDetail: NewFsCloudPickUpDetailModel(gdb),
|
||||
FsCloudReceive: NewFsCloudReceiveModel(gdb),
|
||||
FsCloudReceiveEvery: NewFsCloudReceiveEveryModel(gdb),
|
||||
FsCloudRenderLog: NewFsCloudRenderLogModel(gdb),
|
||||
FsCloudUserApplyBack: NewFsCloudUserApplyBackModel(gdb),
|
||||
FsCloudDeliverEveryTmpOld: NewFsCloudDeliverEveryTmpOldModel(gdb),
|
||||
FsCloudDeliverTmpOld: NewFsCloudDeliverTmpOldModel(gdb),
|
||||
FsCloudOld: NewFsCloudOldModel(gdb),
|
||||
FsCloudPickUpDetailOld: NewFsCloudPickUpDetailOldModel(gdb),
|
||||
FsCloudPickUpOld: NewFsCloudPickUpOldModel(gdb),
|
||||
FsCloudReceiveEveryOld: NewFsCloudReceiveEveryOldModel(gdb),
|
||||
FsCloudReceiveOld: NewFsCloudReceiveOldModel(gdb),
|
||||
FsCloudRenderLogOld: NewFsCloudRenderLogOldModel(gdb),
|
||||
FsCloudUserApplyBackOld: NewFsCloudUserApplyBackOldModel(gdb),
|
||||
FsContact: NewFsContactModel(gdb),
|
||||
FsContactService: NewFsContactServiceModel(gdb),
|
||||
FsCoupon: NewFsCouponModel(gdb),
|
||||
|
@ -163,10 +164,13 @@ func NewAllModels(gdb *gorm.DB) *AllModelsGen {
|
|||
FsMerchantCategory: NewFsMerchantCategoryModel(gdb),
|
||||
FsMigration: NewFsMigrationModel(gdb),
|
||||
FsOrder: NewFsOrderModel(gdb),
|
||||
FsOrderAffiliate: NewFsOrderAffiliateModel(gdb),
|
||||
FsOrderDetail: NewFsOrderDetailModel(gdb),
|
||||
FsOrderDetailTemplate: NewFsOrderDetailTemplateModel(gdb),
|
||||
FsOrderRemark: NewFsOrderRemarkModel(gdb),
|
||||
FsOrderAffiliateOld: NewFsOrderAffiliateOldModel(gdb),
|
||||
FsOrderDetailOld: NewFsOrderDetailOldModel(gdb),
|
||||
FsOrderDetailTemplateOld: NewFsOrderDetailTemplateOldModel(gdb),
|
||||
FsOrderOld: NewFsOrderOldModel(gdb),
|
||||
FsOrderRemarkOld: NewFsOrderRemarkOldModel(gdb),
|
||||
FsOrderTrade: NewFsOrderTradeModel(gdb),
|
||||
FsOrderTradeEvent: NewFsOrderTradeEventModel(gdb),
|
||||
FsPay: NewFsPayModel(gdb),
|
||||
FsPayEvent: NewFsPayEventModel(gdb),
|
||||
FsProduct: NewFsProductModel(gdb),
|
||||
|
|
|
@ -1,10 +1,8 @@
|
|||
package logic
|
||||
|
||||
import (
|
||||
"fusenapi/model/gmodel"
|
||||
"fusenapi/utils/auth"
|
||||
"fusenapi/utils/basic"
|
||||
"fusenapi/utils/collect"
|
||||
|
||||
"context"
|
||||
|
||||
|
@ -12,7 +10,6 @@ import (
|
|||
"fusenapi/server/home-user-auth/internal/types"
|
||||
|
||||
"github.com/zeromicro/go-zero/core/logx"
|
||||
"gorm.io/gorm"
|
||||
)
|
||||
|
||||
type UserContactServiceLogic struct {
|
||||
|
@ -33,36 +30,36 @@ func (l *UserContactServiceLogic) UserContactService(req *types.RequestContactSe
|
|||
// 返回值必须调用Set重新返回, resp可以空指针调用 resp.SetStatus(basic.CodeOK, data)
|
||||
// userinfo 传入值时, 一定不为null
|
||||
|
||||
if !userinfo.IsUser() {
|
||||
return resp.SetStatus(basic.CodeUnAuth)
|
||||
}
|
||||
// if !userinfo.IsUser() {
|
||||
// return resp.SetStatus(basic.CodeUnAuth)
|
||||
// }
|
||||
|
||||
cs := gmodel.FsContactService{
|
||||
UserId: &userinfo.UserId,
|
||||
}
|
||||
collect.LoadJsonTag(&cs, &req)
|
||||
// cs := gmodel.FsContactService{
|
||||
// UserId: &userinfo.UserId,
|
||||
// }
|
||||
// collect.LoadJsonTag(&cs, &req)
|
||||
|
||||
switch req.Type {
|
||||
case "order":
|
||||
_, err := l.svcCtx.AllModels.FsOrder.FindOneAndCreateServiceContact(l.ctx, userinfo.UserId, req.RelationID, &cs)
|
||||
if err != nil {
|
||||
if err == gorm.ErrRecordNotFound {
|
||||
return resp.SetStatus(basic.CodeOrderNotFoundErr)
|
||||
}
|
||||
return resp.SetStatus(basic.CodeDbSqlErr)
|
||||
}
|
||||
case "cloud":
|
||||
_, err := l.svcCtx.AllModels.FsCloudPickUp.GetCloudPickUpByIDAndUserID(l.ctx, userinfo.UserId, req.RelationID, &cs)
|
||||
if err != nil {
|
||||
if err == gorm.ErrRecordNotFound {
|
||||
return resp.SetStatus(basic.CodeCloudOrderNotFoundErr)
|
||||
}
|
||||
return resp.SetStatus(basic.CodeDbSqlErr)
|
||||
}
|
||||
return
|
||||
default:
|
||||
return resp.SetStatusWithMessage(basic.CodeRequestParamsErr, "type is unknown")
|
||||
}
|
||||
// switch req.Type {
|
||||
// case "order":
|
||||
// _, err := l.svcCtx.AllModels.FsOrder.FindOneAndCreateServiceContact(l.ctx, userinfo.UserId, req.RelationID, &cs)
|
||||
// if err != nil {
|
||||
// if err == gorm.ErrRecordNotFound {
|
||||
// return resp.SetStatus(basic.CodeOrderNotFoundErr)
|
||||
// }
|
||||
// return resp.SetStatus(basic.CodeDbSqlErr)
|
||||
// }
|
||||
// case "cloud":
|
||||
// _, err := l.svcCtx.AllModels.FsCloudPickUp.GetCloudPickUpByIDAndUserID(l.ctx, userinfo.UserId, req.RelationID, &cs)
|
||||
// if err != nil {
|
||||
// if err == gorm.ErrRecordNotFound {
|
||||
// return resp.SetStatus(basic.CodeCloudOrderNotFoundErr)
|
||||
// }
|
||||
// return resp.SetStatus(basic.CodeDbSqlErr)
|
||||
// }
|
||||
// return
|
||||
// default:
|
||||
// return resp.SetStatusWithMessage(basic.CodeRequestParamsErr, "type is unknown")
|
||||
// }
|
||||
|
||||
return resp.SetStatus(basic.CodeOK, cs)
|
||||
return resp.SetStatus(basic.CodeOK)
|
||||
}
|
||||
|
|
|
@ -1,23 +1,15 @@
|
|||
package logic
|
||||
|
||||
import (
|
||||
"errors"
|
||||
"fusenapi/constants"
|
||||
"fusenapi/model/gmodel"
|
||||
"fusenapi/utils/auth"
|
||||
"fusenapi/utils/basic"
|
||||
"time"
|
||||
|
||||
"context"
|
||||
|
||||
"fusenapi/server/home-user-auth/internal/svc"
|
||||
"fusenapi/server/home-user-auth/internal/types"
|
||||
|
||||
"github.com/stripe/stripe-go/v74"
|
||||
"github.com/stripe/stripe-go/v74/client"
|
||||
|
||||
"github.com/zeromicro/go-zero/core/logx"
|
||||
"gorm.io/gorm"
|
||||
)
|
||||
|
||||
type UserOderDeleteLogic struct {
|
||||
|
@ -38,109 +30,109 @@ func (l *UserOderDeleteLogic) UserOderDelete(req *types.RequestOrderId, userinfo
|
|||
// 返回值必须调用Set重新返回, resp可以空指针调用 resp.SetStatus(basic.CodeOK, data)
|
||||
// userinfo 传入值时, 一定不为null
|
||||
|
||||
if !userinfo.IsUser() {
|
||||
return resp.SetStatus(basic.CodeUnAuth) // 如果不是用户信息, 返回未授权错误
|
||||
}
|
||||
// if !userinfo.IsUser() {
|
||||
// return resp.SetStatus(basic.CodeUnAuth) // 如果不是用户信息, 返回未授权错误
|
||||
// }
|
||||
|
||||
//订单id
|
||||
orderId := req.OrderId
|
||||
if orderId < 1 {
|
||||
return resp.SetStatus(basic.CodeRequestParamsErr)
|
||||
}
|
||||
// //订单id
|
||||
// orderId := req.OrderId
|
||||
// if orderId < 1 {
|
||||
// return resp.SetStatus(basic.CodeRequestParamsErr)
|
||||
// }
|
||||
|
||||
m := l.svcCtx.AllModels.FsOrder
|
||||
order, err := m.FindOne(l.ctx, userinfo.UserId, orderId)
|
||||
if err != nil {
|
||||
if errors.Is(err, gorm.ErrRecordNotFound) {
|
||||
return resp.SetStatus(basic.CodeOrderNotFoundErr)
|
||||
}
|
||||
logx.Error(err)
|
||||
return resp.SetStatus(basic.CodeDbSqlErr)
|
||||
}
|
||||
// m := l.svcCtx.AllModels.FsOrder
|
||||
// order, err := m.FindOne(l.ctx, userinfo.UserId, orderId)
|
||||
// if err != nil {
|
||||
// if errors.Is(err, gorm.ErrRecordNotFound) {
|
||||
// return resp.SetStatus(basic.CodeOrderNotFoundErr)
|
||||
// }
|
||||
// logx.Error(err)
|
||||
// return resp.SetStatus(basic.CodeDbSqlErr)
|
||||
// }
|
||||
|
||||
if auth.CheckValueRange[constants.Order](
|
||||
constants.Order(*order.Status),
|
||||
constants.STATUS_NEW_NOT_PAY,
|
||||
constants.STATUS_NEW_PAY_COMPLETED,
|
||||
constants.STATUS_NEW_PART_PAY,
|
||||
) {
|
||||
return resp.SetStatus(basic.CodeOrderNotCancelledErr)
|
||||
}
|
||||
// if auth.CheckValueRange[constants.Order](
|
||||
// constants.Order(*order.Status),
|
||||
// constants.STATUS_NEW_NOT_PAY,
|
||||
// constants.STATUS_NEW_PAY_COMPLETED,
|
||||
// constants.STATUS_NEW_PART_PAY,
|
||||
// ) {
|
||||
// return resp.SetStatus(basic.CodeOrderNotCancelledErr)
|
||||
// }
|
||||
|
||||
if *order.IsPayCompleted == 1 &&
|
||||
time.Now().After(time.Unix(*order.Ctime, 0).Add(48*time.Hour)) {
|
||||
return resp.SetStatus(basic.CodeOrderNotCancelledErr)
|
||||
}
|
||||
// if *order.IsPayCompleted == 1 &&
|
||||
// time.Now().After(time.Unix(*order.Ctime, 0).Add(48*time.Hour)) {
|
||||
// return resp.SetStatus(basic.CodeOrderNotCancelledErr)
|
||||
// }
|
||||
|
||||
uOrder := &gmodel.FsOrder{
|
||||
Id: orderId,
|
||||
}
|
||||
// uOrder := &gmodel.FsOrder{
|
||||
// Id: orderId,
|
||||
// }
|
||||
|
||||
var (
|
||||
isCancel int64 = 1
|
||||
ustatus int64 = int64(constants.STATUS_NEW_CANCEL)
|
||||
)
|
||||
// 修改取消状态和取消原因
|
||||
uOrder.Status = &ustatus
|
||||
uOrder.IsCancel = &isCancel
|
||||
uOrder.RefundReasonId = &req.RefundReasonId
|
||||
uOrder.RefundReason = &req.RefundReason
|
||||
// var (
|
||||
// isCancel int64 = 1
|
||||
// ustatus int64 = int64(constants.STATUS_NEW_CANCEL)
|
||||
// )
|
||||
// // 修改取消状态和取消原因
|
||||
// uOrder.Status = &ustatus
|
||||
// uOrder.IsCancel = &isCancel
|
||||
// uOrder.RefundReasonId = &req.RefundReasonId
|
||||
// uOrder.RefundReason = &req.RefundReason
|
||||
|
||||
err = m.Update(l.ctx, uOrder)
|
||||
if err != nil {
|
||||
logx.Error(err)
|
||||
return resp.SetStatus(basic.CodeDbUpdateErr)
|
||||
}
|
||||
// err = m.Update(l.ctx, uOrder)
|
||||
// if err != nil {
|
||||
// logx.Error(err)
|
||||
// return resp.SetStatus(basic.CodeDbUpdateErr)
|
||||
// }
|
||||
|
||||
var (
|
||||
IsRefund int64 = 0
|
||||
CreatedAt = time.Now().UTC().Unix()
|
||||
)
|
||||
// var (
|
||||
// IsRefund int64 = 0
|
||||
// CreatedAt = time.Now().UTC().Unix()
|
||||
// )
|
||||
|
||||
refund := &gmodel.FsRefundReason{
|
||||
IsRefund: &IsRefund,
|
||||
RefundReasonId: &req.RefundReasonId,
|
||||
RefundReason: &req.RefundReason,
|
||||
OrderId: &order.Id,
|
||||
CreatedAt: &CreatedAt,
|
||||
}
|
||||
// refund := &gmodel.FsRefundReason{
|
||||
// IsRefund: &IsRefund,
|
||||
// RefundReasonId: &req.RefundReasonId,
|
||||
// RefundReason: &req.RefundReason,
|
||||
// OrderId: &order.Id,
|
||||
// CreatedAt: &CreatedAt,
|
||||
// }
|
||||
|
||||
mFsRefundReason := gmodel.NewFsRefundReasonModel(l.svcCtx.MysqlConn)
|
||||
err = mFsRefundReason.Create(l.ctx, refund)
|
||||
if err != nil {
|
||||
logx.Error(err)
|
||||
return resp.SetStatus(basic.CodeDbSqlErr)
|
||||
}
|
||||
// mFsRefundReason := gmodel.NewFsRefundReasonModel(l.svcCtx.MysqlConn)
|
||||
// err = mFsRefundReason.Create(l.ctx, refund)
|
||||
// if err != nil {
|
||||
// logx.Error(err)
|
||||
// return resp.SetStatus(basic.CodeDbSqlErr)
|
||||
// }
|
||||
|
||||
// 退款
|
||||
// 调用第三方接口发起退款
|
||||
// // 退款
|
||||
// // 调用第三方接口发起退款
|
||||
|
||||
config := &stripe.BackendConfig{
|
||||
MaxNetworkRetries: stripe.Int64(0), // Zero retries
|
||||
}
|
||||
// config := &stripe.BackendConfig{
|
||||
// MaxNetworkRetries: stripe.Int64(0), // Zero retries
|
||||
// }
|
||||
|
||||
sc := &client.API{}
|
||||
sc.Init(l.svcCtx.Config.Stripe.SK, &stripe.Backends{
|
||||
API: stripe.GetBackendWithConfig(stripe.APIBackend, config),
|
||||
Uploads: stripe.GetBackendWithConfig(stripe.UploadsBackend, config),
|
||||
})
|
||||
// ['order_number' => $order->sn, 'is_refund' => 0, 'pay_status' => 1]
|
||||
payM := l.svcCtx.AllModels.FsPay
|
||||
// sc := &client.API{}
|
||||
// sc.Init(l.svcCtx.Config.Stripe.SK, &stripe.Backends{
|
||||
// API: stripe.GetBackendWithConfig(stripe.APIBackend, config),
|
||||
// Uploads: stripe.GetBackendWithConfig(stripe.UploadsBackend, config),
|
||||
// })
|
||||
// // ['order_number' => $order->sn, 'is_refund' => 0, 'pay_status' => 1]
|
||||
// payM := l.svcCtx.AllModels.FsPay
|
||||
|
||||
// 查询支付信息
|
||||
pays, err := payM.GetOrderPayList(l.ctx, *order.Sn, 1, 0)
|
||||
for _, pay := range pays {
|
||||
sc.Refunds.New(&stripe.RefundParams{
|
||||
PaymentIntent: pay.TradeNo,
|
||||
})
|
||||
}
|
||||
if err != nil {
|
||||
if errors.Is(err, gorm.ErrRecordNotFound) {
|
||||
return resp.SetStatus(basic.CodeApiErr)
|
||||
}
|
||||
}
|
||||
// // 查询支付信息
|
||||
// pays, err := payM.GetOrderPayList(l.ctx, *order.Sn, 1, 0)
|
||||
// for _, pay := range pays {
|
||||
// sc.Refunds.New(&stripe.RefundParams{
|
||||
// PaymentIntent: pay.TradeNo,
|
||||
// })
|
||||
// }
|
||||
// if err != nil {
|
||||
// if errors.Is(err, gorm.ErrRecordNotFound) {
|
||||
// return resp.SetStatus(basic.CodeApiErr)
|
||||
// }
|
||||
// }
|
||||
|
||||
return resp.SetStatus(basic.CodePayCancelOk, uOrder)
|
||||
return resp.SetStatus(basic.CodePayCancelOk)
|
||||
|
||||
// return ResponseError(500, "Cancellation failure")
|
||||
|
||||
|
|
|
@ -1,13 +1,8 @@
|
|||
package logic
|
||||
|
||||
import (
|
||||
"errors"
|
||||
"fusenapi/constants"
|
||||
"fusenapi/model/gmodel"
|
||||
"fusenapi/utils/auth"
|
||||
"fusenapi/utils/basic"
|
||||
"fusenapi/utils/handlers"
|
||||
"time"
|
||||
|
||||
"context"
|
||||
|
||||
|
@ -15,7 +10,6 @@ import (
|
|||
"fusenapi/server/home-user-auth/internal/types"
|
||||
|
||||
"github.com/zeromicro/go-zero/core/logx"
|
||||
"gorm.io/gorm"
|
||||
)
|
||||
|
||||
type UserOrderCancelLogic struct {
|
||||
|
@ -36,93 +30,93 @@ func (l *UserOrderCancelLogic) UserOrderCancel(req *types.UserOrderCancelReq, us
|
|||
// 返回值必须调用Set重新返回, resp可以空指针调用 resp.SetStatus(basic.CodeOK, data)
|
||||
// userinfo 传入值时, 一定不为null
|
||||
|
||||
if userinfo == nil || userinfo.UserId == 0 {
|
||||
return resp.SetStatusWithMessage(basic.CodeDbRecordNotFoundErr, "order not found")
|
||||
}
|
||||
// if userinfo == nil || userinfo.UserId == 0 {
|
||||
// return resp.SetStatusWithMessage(basic.CodeDbRecordNotFoundErr, "order not found")
|
||||
// }
|
||||
|
||||
//查询订单信息
|
||||
orderModel := gmodel.NewFsOrderModel(l.svcCtx.MysqlConn)
|
||||
orderInfo, err := orderModel.FindOne(l.ctx, userinfo.UserId, req.ID)
|
||||
if err != nil {
|
||||
if errors.Is(err, gorm.ErrRecordNotFound) {
|
||||
return resp.SetStatusWithMessage(basic.CodeDbRecordNotFoundErr, "the order is not exists")
|
||||
}
|
||||
logx.Error(err)
|
||||
return resp.SetStatus(basic.CodeServiceErr, "failed to get order info")
|
||||
}
|
||||
// //查询订单信息
|
||||
// orderModel := gmodel.NewFsOrderModel(l.svcCtx.MysqlConn)
|
||||
// orderInfo, err := orderModel.FindOne(l.ctx, userinfo.UserId, req.ID)
|
||||
// if err != nil {
|
||||
// if errors.Is(err, gorm.ErrRecordNotFound) {
|
||||
// return resp.SetStatusWithMessage(basic.CodeDbRecordNotFoundErr, "the order is not exists")
|
||||
// }
|
||||
// logx.Error(err)
|
||||
// return resp.SetStatus(basic.CodeServiceErr, "failed to get order info")
|
||||
// }
|
||||
|
||||
// 判断订单状态
|
||||
var notCancelStatusMap = make(map[int64]struct{}, 3)
|
||||
notCancelStatusMap[int64(constants.STATUS_NEW_NOT_PAY)] = struct{}{}
|
||||
notCancelStatusMap[int64(constants.STATUS_NEW_PART_PAY)] = struct{}{}
|
||||
notCancelStatusMap[int64(constants.STATUS_NEW_PAY_COMPLETED)] = struct{}{}
|
||||
_, ok := notCancelStatusMap[int64(*orderInfo.Status)]
|
||||
if !ok {
|
||||
return resp.SetStatusWithMessage(basic.CodeOrderNotCancelledErr, "the order status not cancle")
|
||||
}
|
||||
// // 判断订单状态
|
||||
// var notCancelStatusMap = make(map[int64]struct{}, 3)
|
||||
// notCancelStatusMap[int64(constants.STATUS_NEW_NOT_PAY)] = struct{}{}
|
||||
// notCancelStatusMap[int64(constants.STATUS_NEW_PART_PAY)] = struct{}{}
|
||||
// notCancelStatusMap[int64(constants.STATUS_NEW_PAY_COMPLETED)] = struct{}{}
|
||||
// _, ok := notCancelStatusMap[int64(*orderInfo.Status)]
|
||||
// if !ok {
|
||||
// return resp.SetStatusWithMessage(basic.CodeOrderNotCancelledErr, "the order status not cancle")
|
||||
// }
|
||||
|
||||
var cancelTime int64 = time.Now().UTC().Unix() - (*orderInfo.Ctime + int64(constants.CANCLE_ORDER_EXPIRE))
|
||||
// 第一次支付成功后48小时后不能进行取消操作
|
||||
if *orderInfo.IsPayCompleted == 1 && cancelTime > 0 {
|
||||
return resp.SetStatusWithMessage(basic.CodeOrderNotCancelledErr, "The current order cannot be cancelled")
|
||||
}
|
||||
// var cancelTime int64 = time.Now().UTC().Unix() - (*orderInfo.Ctime + int64(constants.CANCLE_ORDER_EXPIRE))
|
||||
// // 第一次支付成功后48小时后不能进行取消操作
|
||||
// if *orderInfo.IsPayCompleted == 1 && cancelTime > 0 {
|
||||
// return resp.SetStatusWithMessage(basic.CodeOrderNotCancelledErr, "The current order cannot be cancelled")
|
||||
// }
|
||||
|
||||
// 修改订单--取消状态和取消原因
|
||||
*orderInfo.Status = int64(constants.STATUS_NEW_CANCEL)
|
||||
*orderInfo.IsCancel = 1
|
||||
orderInfo.RefundReasonId = &req.RefundReasonId
|
||||
orderInfo.RefundReason = &req.RefundReason
|
||||
// // 修改订单--取消状态和取消原因
|
||||
// *orderInfo.Status = int64(constants.STATUS_NEW_CANCEL)
|
||||
// *orderInfo.IsCancel = 1
|
||||
// orderInfo.RefundReasonId = &req.RefundReasonId
|
||||
// orderInfo.RefundReason = &req.RefundReason
|
||||
|
||||
var nowTime = time.Now().UTC().Unix()
|
||||
var payList []handlers.PayInfo
|
||||
// 事务处理
|
||||
ctx := l.ctx
|
||||
err = l.svcCtx.MysqlConn.Transaction(func(tx *gorm.DB) error {
|
||||
// 修改订单信息
|
||||
orderModelTS := gmodel.NewFsOrderModel(tx)
|
||||
err = orderModelTS.RBUpdate(ctx, orderInfo)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
// 新增退款记录
|
||||
var isRefund int64 = 0
|
||||
refundReasonModelTS := gmodel.NewFsRefundReasonModel(tx)
|
||||
refundReasonModelTS.RBCreateOrUpdate(ctx, &gmodel.FsRefundReason{
|
||||
IsRefund: &isRefund,
|
||||
RefundReasonId: &req.RefundReasonId,
|
||||
RefundReason: &req.RefundReason,
|
||||
OrderId: &orderInfo.Id,
|
||||
CreatedAt: &nowTime,
|
||||
})
|
||||
// 退款申请
|
||||
// 退款申请--查询支付信息
|
||||
fsPayModelTS := gmodel.NewFsPayModel(tx)
|
||||
rbFsPay := fsPayModelTS.RowSelectBuilder(nil).Where("order_number = ?", orderInfo.Sn).Where("pay_status =?", constants.PAYSTATUS_SUCCESS).Where("is_refund =?", 0)
|
||||
payInfoList, err := fsPayModelTS.FindAll(ctx, rbFsPay, nil, "")
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
for _, payInfo := range payInfoList {
|
||||
var key string
|
||||
if *payInfo.PaymentMethod == int64(constants.PAYMETHOD_STRIPE) {
|
||||
key = l.svcCtx.Config.PayConfig.Stripe.Key
|
||||
}
|
||||
payList = append(payList, handlers.PayInfo{
|
||||
TradeNo: *payInfo.TradeNo,
|
||||
PaymentMethod: *payInfo.PaymentMethod,
|
||||
Key: key,
|
||||
})
|
||||
}
|
||||
return nil
|
||||
})
|
||||
// 退款申请--调取第三方接口发起退款
|
||||
handlers.PayRefundHandler(&handlers.PayRefundHandlerReq{
|
||||
PayInfoList: payList,
|
||||
})
|
||||
if err != nil {
|
||||
logx.Error(err)
|
||||
return resp.SetStatusWithMessage(basic.CodeOrderCancelledNotOk, "the order cancle failed")
|
||||
}
|
||||
// var nowTime = time.Now().UTC().Unix()
|
||||
// var payList []handlers.PayInfo
|
||||
// // 事务处理
|
||||
// ctx := l.ctx
|
||||
// err = l.svcCtx.MysqlConn.Transaction(func(tx *gorm.DB) error {
|
||||
// // 修改订单信息
|
||||
// orderModelTS := gmodel.NewFsOrderModel(tx)
|
||||
// err = orderModelTS.RBUpdate(ctx, orderInfo)
|
||||
// if err != nil {
|
||||
// return err
|
||||
// }
|
||||
// // 新增退款记录
|
||||
// var isRefund int64 = 0
|
||||
// refundReasonModelTS := gmodel.NewFsRefundReasonModel(tx)
|
||||
// refundReasonModelTS.RBCreateOrUpdate(ctx, &gmodel.FsRefundReason{
|
||||
// IsRefund: &isRefund,
|
||||
// RefundReasonId: &req.RefundReasonId,
|
||||
// RefundReason: &req.RefundReason,
|
||||
// OrderId: &orderInfo.Id,
|
||||
// CreatedAt: &nowTime,
|
||||
// })
|
||||
// // 退款申请
|
||||
// // 退款申请--查询支付信息
|
||||
// fsPayModelTS := gmodel.NewFsPayModel(tx)
|
||||
// rbFsPay := fsPayModelTS.RowSelectBuilder(nil).Where("order_number = ?", orderInfo.Sn).Where("pay_status =?", constants.PAYSTATUS_SUCCESS).Where("is_refund =?", 0)
|
||||
// payInfoList, err := fsPayModelTS.FindAll(ctx, rbFsPay, nil, "")
|
||||
// if err != nil {
|
||||
// return err
|
||||
// }
|
||||
// for _, payInfo := range payInfoList {
|
||||
// var key string
|
||||
// if *payInfo.PaymentMethod == int64(constants.PAYMETHOD_STRIPE) {
|
||||
// key = l.svcCtx.Config.PayConfig.Stripe.Key
|
||||
// }
|
||||
// payList = append(payList, handlers.PayInfo{
|
||||
// TradeNo: *payInfo.TradeNo,
|
||||
// PaymentMethod: *payInfo.PaymentMethod,
|
||||
// Key: key,
|
||||
// })
|
||||
// }
|
||||
// return nil
|
||||
// })
|
||||
// // 退款申请--调取第三方接口发起退款
|
||||
// handlers.PayRefundHandler(&handlers.PayRefundHandlerReq{
|
||||
// PayInfoList: payList,
|
||||
// })
|
||||
// if err != nil {
|
||||
// logx.Error(err)
|
||||
// return resp.SetStatusWithMessage(basic.CodeOrderCancelledNotOk, "the order cancle failed")
|
||||
// }
|
||||
|
||||
return resp.SetStatus(basic.CodeOK)
|
||||
}
|
||||
|
|
|
@ -1,9 +1,6 @@
|
|||
package logic
|
||||
|
||||
import (
|
||||
"errors"
|
||||
"fusenapi/constants"
|
||||
"fusenapi/model/gmodel"
|
||||
"fusenapi/utils/auth"
|
||||
"fusenapi/utils/basic"
|
||||
|
||||
|
@ -13,7 +10,6 @@ import (
|
|||
"fusenapi/server/home-user-auth/internal/types"
|
||||
|
||||
"github.com/zeromicro/go-zero/core/logx"
|
||||
"gorm.io/gorm"
|
||||
)
|
||||
|
||||
type UserOrderDeleteLogic struct {
|
||||
|
@ -43,36 +39,36 @@ func (l *UserOrderDeleteLogic) UserOrderDelete(req *types.UserOrderDeleteReq, us
|
|||
// 返回值必须调用Set重新返回, resp可以空指针调用 resp.SetStatus(basic.CodeOK, data)
|
||||
// userinfo 传入值时, 一定不为null
|
||||
|
||||
if userinfo == nil || userinfo.UserId == 0 {
|
||||
return resp.SetStatusWithMessage(basic.CodeDbRecordNotFoundErr, "order not found")
|
||||
}
|
||||
// if userinfo == nil || userinfo.UserId == 0 {
|
||||
// return resp.SetStatusWithMessage(basic.CodeDbRecordNotFoundErr, "order not found")
|
||||
// }
|
||||
|
||||
orderModel := gmodel.NewFsOrderModel(l.svcCtx.MysqlConn)
|
||||
orderInfo, err := orderModel.FindOne(l.ctx, userinfo.UserId, req.ID)
|
||||
// orderModel := gmodel.NewFsOrderModel(l.svcCtx.MysqlConn)
|
||||
// orderInfo, err := orderModel.FindOne(l.ctx, userinfo.UserId, req.ID)
|
||||
|
||||
if err != nil {
|
||||
if errors.Is(err, gorm.ErrRecordNotFound) {
|
||||
return resp.SetStatusWithMessage(basic.CodeDbRecordNotFoundErr, "order not found")
|
||||
}
|
||||
logx.Error(err)
|
||||
return resp.SetStatusWithMessage(basic.CodeServiceErr, "failed to get order info")
|
||||
}
|
||||
// if err != nil {
|
||||
// if errors.Is(err, gorm.ErrRecordNotFound) {
|
||||
// return resp.SetStatusWithMessage(basic.CodeDbRecordNotFoundErr, "order not found")
|
||||
// }
|
||||
// logx.Error(err)
|
||||
// return resp.SetStatusWithMessage(basic.CodeServiceErr, "failed to get order info")
|
||||
// }
|
||||
|
||||
updateStatusMap := make(map[constants.Order]struct{}, 4)
|
||||
updateStatusMap[constants.STATUS_NEW_COMPLETED] = struct{}{}
|
||||
updateStatusMap[constants.STATUS_NEW_CANCEL] = struct{}{}
|
||||
updateStatusMap[constants.STATUS_NEW_REFUNDED] = struct{}{}
|
||||
updateStatusMap[constants.STATUS_NEW_CLOSE] = struct{}{}
|
||||
if _, ok := updateStatusMap[constants.Order(*orderInfo.Status)]; !ok {
|
||||
return resp.SetStatusWithMessage(basic.CodeDbRecordNotFoundErr, "order not found")
|
||||
}
|
||||
*orderInfo.Status = int64(constants.STATUS_NEW_DELETE)
|
||||
*orderInfo.IsDeleted = 1
|
||||
err = orderModel.Update(l.ctx, orderInfo)
|
||||
if err != nil {
|
||||
logx.Error(err)
|
||||
return resp.SetStatusWithMessage(basic.CodeServiceErr, "fail to delete")
|
||||
}
|
||||
// updateStatusMap := make(map[constants.Order]struct{}, 4)
|
||||
// updateStatusMap[constants.STATUS_NEW_COMPLETED] = struct{}{}
|
||||
// updateStatusMap[constants.STATUS_NEW_CANCEL] = struct{}{}
|
||||
// updateStatusMap[constants.STATUS_NEW_REFUNDED] = struct{}{}
|
||||
// updateStatusMap[constants.STATUS_NEW_CLOSE] = struct{}{}
|
||||
// if _, ok := updateStatusMap[constants.Order(*orderInfo.Status)]; !ok {
|
||||
// return resp.SetStatusWithMessage(basic.CodeDbRecordNotFoundErr, "order not found")
|
||||
// }
|
||||
// *orderInfo.Status = int64(constants.STATUS_NEW_DELETE)
|
||||
// *orderInfo.IsDeleted = 1
|
||||
// err = orderModel.Update(l.ctx, orderInfo)
|
||||
// if err != nil {
|
||||
// logx.Error(err)
|
||||
// return resp.SetStatusWithMessage(basic.CodeServiceErr, "fail to delete")
|
||||
// }
|
||||
|
||||
return resp.SetStatus(basic.CodeOK)
|
||||
}
|
||||
|
|
|
@ -1,20 +1,8 @@
|
|||
package logic
|
||||
|
||||
import (
|
||||
"errors"
|
||||
"fmt"
|
||||
"fusenapi/constants"
|
||||
"fusenapi/model/gmodel"
|
||||
"fusenapi/utils/auth"
|
||||
"fusenapi/utils/basic"
|
||||
"fusenapi/utils/configs"
|
||||
"fusenapi/utils/image"
|
||||
"strings"
|
||||
|
||||
"fusenapi/utils/format"
|
||||
"fusenapi/utils/order"
|
||||
"math"
|
||||
"time"
|
||||
|
||||
"context"
|
||||
|
||||
|
@ -22,7 +10,6 @@ import (
|
|||
"fusenapi/server/home-user-auth/internal/types"
|
||||
|
||||
"github.com/zeromicro/go-zero/core/logx"
|
||||
"gorm.io/gorm"
|
||||
)
|
||||
|
||||
type UserOrderListLogic struct {
|
||||
|
@ -43,263 +30,264 @@ func (l *UserOrderListLogic) UserOrderList(req *types.UserOrderListReq, userinfo
|
|||
// 返回值必须调用Set重新返回, resp可以空指针调用 resp.SetStatus(basic.CodeOK, data)
|
||||
// userinfo 传入值时, 一定不为null
|
||||
|
||||
size := req.Size
|
||||
// size := req.Size
|
||||
|
||||
if size > 0 {
|
||||
size = int64(image.GetCurrentSize(uint32(size)))
|
||||
}
|
||||
// if size > 0 {
|
||||
// size = int64(image.GetCurrentSize(uint32(size)))
|
||||
// }
|
||||
|
||||
orderDetailModel := gmodel.NewFsOrderDetailModel(l.svcCtx.MysqlConn)
|
||||
orderDetailTemplateModel := gmodel.NewFsOrderDetailTemplateModel(l.svcCtx.MysqlConn)
|
||||
fsProductDesignModel := gmodel.NewFsProductDesignModel(l.svcCtx.MysqlConn)
|
||||
orderModel := gmodel.NewFsOrderModel(l.svcCtx.MysqlConn)
|
||||
rowBuilder := orderModel.RowSelectBuilder(nil)
|
||||
if userinfo == nil || userinfo.UserId == 0 {
|
||||
return resp.SetStatusWithMessage(basic.CodeDbRecordNotFoundErr, "order not found")
|
||||
}
|
||||
// orderDetailModel := gmodel.NewFsOrderDetailModel(l.svcCtx.MysqlConn)
|
||||
// orderDetailTemplateModel := gmodel.NewFsOrderDetailTemplateModel(l.svcCtx.MysqlConn)
|
||||
// fsProductDesignModel := gmodel.NewFsProductDesignModel(l.svcCtx.MysqlConn)
|
||||
// orderModel := gmodel.NewFsOrderModel(l.svcCtx.MysqlConn)
|
||||
// rowBuilder := orderModel.RowSelectBuilder(nil)
|
||||
// if userinfo == nil || userinfo.UserId == 0 {
|
||||
// return resp.SetStatusWithMessage(basic.CodeDbRecordNotFoundErr, "order not found")
|
||||
// }
|
||||
|
||||
// 查询条件
|
||||
var page = req.Page
|
||||
var pageSize = req.PageSize
|
||||
var listRes []*gmodel.FsOrderRel
|
||||
rowBuilder = rowBuilder.Where("user_id =?", userinfo.UserId).Where("status <> ?", constants.STATUS_NEW_NOT_PAY).Where("status <>?", constants.STATUS_NEW_DELETE)
|
||||
// // 查询条件
|
||||
// var page = req.Page
|
||||
// var pageSize = req.PageSize
|
||||
// var listRes []*gmodel.FsOrderRel
|
||||
// rowBuilder = rowBuilder.Where("user_id =?", userinfo.UserId).Where("status <> ?", constants.STATUS_NEW_NOT_PAY).Where("status <>?", constants.STATUS_NEW_DELETE)
|
||||
|
||||
// 根据时间来查询不同范围的订单
|
||||
switch req.Time {
|
||||
case 1:
|
||||
rowBuilder = rowBuilder.Where("ctime >?", time.Now().UTC().AddDate(0, -1, 0).Unix())
|
||||
case 2:
|
||||
rowBuilder = rowBuilder.Where("ctime >?", time.Now().UTC().AddDate(0, -3, 0).Unix())
|
||||
case 3:
|
||||
rowBuilder = rowBuilder.Where("ctime >?", time.Now().UTC().AddDate(0, -6, 0).Unix())
|
||||
case 4:
|
||||
rowBuilder = rowBuilder.Where("ctime >?", time.Now().UTC().AddDate(-1, 0, 0).Unix())
|
||||
default:
|
||||
}
|
||||
// // 根据时间来查询不同范围的订单
|
||||
// switch req.Time {
|
||||
// case 1:
|
||||
// rowBuilder = rowBuilder.Where("ctime >?", time.Now().UTC().AddDate(0, -1, 0).Unix())
|
||||
// case 2:
|
||||
// rowBuilder = rowBuilder.Where("ctime >?", time.Now().UTC().AddDate(0, -3, 0).Unix())
|
||||
// case 3:
|
||||
// rowBuilder = rowBuilder.Where("ctime >?", time.Now().UTC().AddDate(0, -6, 0).Unix())
|
||||
// case 4:
|
||||
// rowBuilder = rowBuilder.Where("ctime >?", time.Now().UTC().AddDate(-1, 0, 0).Unix())
|
||||
// default:
|
||||
// }
|
||||
|
||||
//按照订单状态查询不同的订单
|
||||
if req.Status != -1 {
|
||||
switch req.Status {
|
||||
case 1:
|
||||
rowBuilder = rowBuilder.Where("status in ?", [3]constants.Order{constants.STATUS_NEW_PART_PAY, constants.STATUS_NEW_PAY_COMPLETED, constants.STATUS_NEW_SURE})
|
||||
case 2:
|
||||
rowBuilder = rowBuilder.Where("status in ?", [2]constants.Order{constants.STATUS_NEW_PRODUTING, constants.STATUS_NEW_PRODUT_COMPLETED})
|
||||
case 3:
|
||||
rowBuilder = rowBuilder.Where("status in ?", [2]constants.Order{constants.STATUS_NEW_DELIVER, constants.STATUS_NEW_UPS})
|
||||
case 4:
|
||||
rowBuilder = rowBuilder.Where("status =?", constants.STATUS_NEW_ARRIVAL)
|
||||
case 5:
|
||||
rowBuilder = rowBuilder.Where("status =?", constants.STATUS_NEW_COMPLETED).Where("delivery_method =?", constants.DELIVERY_METHOD_ADDRESS)
|
||||
case 7:
|
||||
rowBuilder = rowBuilder.Where("status in ?", [3]constants.Order{constants.STATUS_NEW_CANCEL, constants.STATUS_NEW_REFUNDED, constants.STATUS_NEW_REFUNDING})
|
||||
case 8:
|
||||
rowBuilder = rowBuilder.Where("status =?", constants.STATUS_NEW_COMPLETED).Where("delivery_method =?", constants.DELIVERY_METHOD_CLOUD)
|
||||
}
|
||||
}
|
||||
// //按照订单状态查询不同的订单
|
||||
// if req.Status != -1 {
|
||||
// switch req.Status {
|
||||
// case 1:
|
||||
// rowBuilder = rowBuilder.Where("status in ?", [3]constants.Order{constants.STATUS_NEW_PART_PAY, constants.STATUS_NEW_PAY_COMPLETED, constants.STATUS_NEW_SURE})
|
||||
// case 2:
|
||||
// rowBuilder = rowBuilder.Where("status in ?", [2]constants.Order{constants.STATUS_NEW_PRODUTING, constants.STATUS_NEW_PRODUT_COMPLETED})
|
||||
// case 3:
|
||||
// rowBuilder = rowBuilder.Where("status in ?", [2]constants.Order{constants.STATUS_NEW_DELIVER, constants.STATUS_NEW_UPS})
|
||||
// case 4:
|
||||
// rowBuilder = rowBuilder.Where("status =?", constants.STATUS_NEW_ARRIVAL)
|
||||
// case 5:
|
||||
// rowBuilder = rowBuilder.Where("status =?", constants.STATUS_NEW_COMPLETED).Where("delivery_method =?", constants.DELIVERY_METHOD_ADDRESS)
|
||||
// case 7:
|
||||
// rowBuilder = rowBuilder.Where("status in ?", [3]constants.Order{constants.STATUS_NEW_CANCEL, constants.STATUS_NEW_REFUNDED, constants.STATUS_NEW_REFUNDING})
|
||||
// case 8:
|
||||
// rowBuilder = rowBuilder.Where("status =?", constants.STATUS_NEW_COMPLETED).Where("delivery_method =?", constants.DELIVERY_METHOD_CLOUD)
|
||||
// }
|
||||
// }
|
||||
|
||||
// 查询总数
|
||||
total, err := orderModel.FindCount(l.ctx, rowBuilder, nil)
|
||||
if err != nil {
|
||||
if errors.Is(err, gorm.ErrRecordNotFound) {
|
||||
return resp.SetStatusWithMessage(basic.CodeDbRecordNotFoundErr, "order not found")
|
||||
}
|
||||
logx.Error(err)
|
||||
return resp.SetStatusWithMessage(basic.CodeServiceErr, "failed to get order info")
|
||||
}
|
||||
// // 查询总数
|
||||
// total, err := orderModel.FindCount(l.ctx, rowBuilder, nil)
|
||||
// if err != nil {
|
||||
// if errors.Is(err, gorm.ErrRecordNotFound) {
|
||||
// return resp.SetStatusWithMessage(basic.CodeDbRecordNotFoundErr, "order not found")
|
||||
// }
|
||||
// logx.Error(err)
|
||||
// return resp.SetStatusWithMessage(basic.CodeServiceErr, "failed to get order info")
|
||||
// }
|
||||
|
||||
// 查询数据
|
||||
if total > 0 {
|
||||
rowBuilder = rowBuilder.Preload("FsOrderAffiliateInfo").Preload("FsOrderDetails", func(dbPreload *gorm.DB) *gorm.DB {
|
||||
return dbPreload.Table(orderDetailModel.TableName()).Preload("FsOrderDetailTemplateInfo", func(dbPreload *gorm.DB) *gorm.DB {
|
||||
return dbPreload.Table(orderDetailTemplateModel.TableName()).Preload("FsProductDesignInfo", func(dbPreload *gorm.DB) *gorm.DB {
|
||||
return dbPreload.Table(fsProductDesignModel.TableName()).Preload("OptionData").Preload("TemplateData")
|
||||
}).Preload("FsProductSizeInfo")
|
||||
}).Preload("FsProductInfo")
|
||||
})
|
||||
listRes, err = orderModel.FindPageListByPage(l.ctx, rowBuilder, &page, &pageSize, nil, "")
|
||||
}
|
||||
// // 查询数据
|
||||
// if total > 0 {
|
||||
// rowBuilder = rowBuilder.Preload("FsOrderAffiliateInfo").Preload("FsOrderDetails", func(dbPreload *gorm.DB) *gorm.DB {
|
||||
// return dbPreload.Table(orderDetailModel.TableName()).Preload("FsOrderDetailTemplateInfo", func(dbPreload *gorm.DB) *gorm.DB {
|
||||
// return dbPreload.Table(orderDetailTemplateModel.TableName()).Preload("FsProductDesignInfo", func(dbPreload *gorm.DB) *gorm.DB {
|
||||
// return dbPreload.Table(fsProductDesignModel.TableName()).Preload("OptionData").Preload("TemplateData")
|
||||
// }).Preload("FsProductSizeInfo")
|
||||
// }).Preload("FsProductInfo")
|
||||
// })
|
||||
// listRes, err = orderModel.FindPageListByPage(l.ctx, rowBuilder, &page, &pageSize, nil, "")
|
||||
// }
|
||||
|
||||
if err != nil {
|
||||
if errors.Is(err, gorm.ErrRecordNotFound) {
|
||||
return resp.SetStatusWithMessage(basic.CodeDbRecordNotFoundErr, "order not found")
|
||||
}
|
||||
logx.Error(err)
|
||||
return resp.SetStatusWithMessage(basic.CodeServiceErr, "failed to get order info")
|
||||
}
|
||||
listResLen := len(listRes)
|
||||
// if err != nil {
|
||||
// if errors.Is(err, gorm.ErrRecordNotFound) {
|
||||
// return resp.SetStatusWithMessage(basic.CodeDbRecordNotFoundErr, "order not found")
|
||||
// }
|
||||
// logx.Error(err)
|
||||
// return resp.SetStatusWithMessage(basic.CodeServiceErr, "failed to get order info")
|
||||
// }
|
||||
// listResLen := len(listRes)
|
||||
|
||||
var respList []types.Items
|
||||
if listResLen > 0 {
|
||||
// 获取订单时间配置
|
||||
orderTimeConfig, err := configs.GetOrderTimeConfig(l.ctx, l.svcCtx.MysqlConn)
|
||||
if err != nil {
|
||||
return resp.SetStatusWithMessage(basic.CodeServiceErr, "failed to get config time info")
|
||||
}
|
||||
|
||||
// 数据处理
|
||||
for _, item := range listRes {
|
||||
var pbData types.Items
|
||||
pbData.ID = item.Id
|
||||
pbData.Sn = *item.Sn
|
||||
pbData.UserID = *item.UserId
|
||||
pbData.TotalAmount = *item.TotalAmount
|
||||
pbData.Ctime = format.TimeIntToFormat(*item.Ctime)
|
||||
pbData.Status = *item.Status
|
||||
pbData.DeliveryMethod = *item.DeliveryMethod
|
||||
pbData.TsTime = format.TimeToFormat(*item.TsTime)
|
||||
pbData.IsPayCompleted = *item.IsPayCompleted
|
||||
pbData.DeliverSn = *item.DeliverSn
|
||||
|
||||
var pcsBox int64
|
||||
var pcs int64
|
||||
var productList []types.Product
|
||||
|
||||
var surplusAt int64
|
||||
|
||||
//如果是部分支付状态,那么取消订单倒计时2天
|
||||
if *item.Status == int64(constants.STATUS_NEW_PART_PAY) {
|
||||
surplusAt = (*item.Ctime + int64(constants.CANCLE_ORDER_EXPIRE)) - time.Now().UTC().Unix()
|
||||
if surplusAt < 0 {
|
||||
surplusAt = 0
|
||||
}
|
||||
}
|
||||
|
||||
fsOrderAffiliateInfo := item.FsOrderAffiliateInfo
|
||||
|
||||
var sureTime int64
|
||||
var productTime int64
|
||||
var ProductEndtime int64
|
||||
var deliverTime int64
|
||||
var upsDeliverTime int64
|
||||
var upsTime int64
|
||||
var arrivalTime int64
|
||||
var recevieTime int64
|
||||
if fsOrderAffiliateInfo.Id > 0 {
|
||||
sureTime = *fsOrderAffiliateInfo.SureTime
|
||||
productTime = *fsOrderAffiliateInfo.ProductTime
|
||||
ProductEndtime = *fsOrderAffiliateInfo.ProductEndtime
|
||||
deliverTime = *fsOrderAffiliateInfo.DeliverTime
|
||||
upsDeliverTime = *fsOrderAffiliateInfo.UpsDeliverTime
|
||||
upsTime = *fsOrderAffiliateInfo.UpsTime
|
||||
arrivalTime = *fsOrderAffiliateInfo.ArrivalTime
|
||||
recevieTime = *fsOrderAffiliateInfo.RecevieTime
|
||||
}
|
||||
|
||||
var getOrderStatusAndLogisticsReq = order.GetOrderStatusAndLogisticsReq{
|
||||
OrderStatus: constants.Order(*item.Status),
|
||||
DeliveryMethod: constants.DeliveryMethod(*item.DeliveryMethod),
|
||||
IsPayCompleted: *item.IsAllProductCompleted,
|
||||
OrderCtime: *item.Ctime,
|
||||
|
||||
SureTime: sureTime,
|
||||
ProductTime: productTime,
|
||||
ProductEndtime: ProductEndtime,
|
||||
DeliverTime: deliverTime,
|
||||
UpsDeliverTime: upsDeliverTime,
|
||||
UpsTime: upsTime,
|
||||
ArrivalTime: arrivalTime,
|
||||
RecevieTime: recevieTime,
|
||||
|
||||
WebSetTimeInfo: orderTimeConfig,
|
||||
}
|
||||
|
||||
statusAndLogisticsRes := order.GetOrderStatusAndLogistics(getOrderStatusAndLogisticsReq)
|
||||
|
||||
// 流程控制
|
||||
var statusTime []types.StatusTime
|
||||
for _, itemTimes := range statusAndLogisticsRes.Times {
|
||||
statusTime = append(statusTime, types.StatusTime{
|
||||
Key: itemTimes.Key,
|
||||
Time: itemTimes.Time,
|
||||
})
|
||||
}
|
||||
pbData.StatusTimes = statusTime
|
||||
pbData.LogisticsStatus = int64(statusAndLogisticsRes.LogisticsStatus)
|
||||
pbData.Status = int64(statusAndLogisticsRes.OrderStatus)
|
||||
|
||||
var isStopMax int64
|
||||
if len(item.FsOrderDetails) > 0 {
|
||||
for _, fsOrderDetailItem := range item.FsOrderDetails {
|
||||
|
||||
fsOrderDetailBuyNum := *fsOrderDetailItem.FsOrderDetail.BuyNum
|
||||
fsOrderDetailEachBoxNum := *fsOrderDetailItem.FsOrderDetailTemplateInfo.EachBoxNum
|
||||
pcs = pcs + fsOrderDetailBuyNum
|
||||
pcsBoxNum := fsOrderDetailBuyNum / fsOrderDetailEachBoxNum
|
||||
var csBoxNumF int64
|
||||
if (fsOrderDetailBuyNum % fsOrderDetailEachBoxNum) > 0 {
|
||||
csBoxNumF = 1
|
||||
}
|
||||
pcsBox = pcsBox + pcsBoxNum + csBoxNumF
|
||||
|
||||
productCover := *fsOrderDetailItem.Cover
|
||||
// 尺寸
|
||||
if size >= 200 {
|
||||
coverArr := strings.Split(*fsOrderDetailItem.Cover, ".")
|
||||
if len(coverArr) < 2 {
|
||||
return resp.SetStatusWithMessage(basic.CodeServiceErr, "cover split slice item count is less than 2")
|
||||
}
|
||||
productCover = fmt.Sprintf("%s_%d.%s", coverArr[0], req.Size, coverArr[1])
|
||||
}
|
||||
|
||||
// 判断stop
|
||||
var isStop int64
|
||||
if fsOrderDetailItem.FsOrderDetailTemplateInfo.FsProductDesignInfo.OptionData.Id != 0 {
|
||||
// 尺寸或者模板下架
|
||||
if fsOrderDetailItem.FsOrderDetailTemplateInfo.FsProductDesignInfo.Id != 0 {
|
||||
isStop = 1
|
||||
} else {
|
||||
isStop = 3
|
||||
}
|
||||
} else {
|
||||
if fsOrderDetailItem.FsOrderDetailTemplateInfo.FsProductDesignInfo.Id != 0 {
|
||||
isStop = 1
|
||||
}
|
||||
}
|
||||
|
||||
// 判断产品是否下架
|
||||
if *fsOrderDetailItem.FsProductInfo.IsShelf == 0 || *fsOrderDetailItem.FsProductInfo.IsDel == 1 {
|
||||
isStop = 2
|
||||
}
|
||||
if isStop > isStopMax {
|
||||
isStopMax = isStop
|
||||
}
|
||||
|
||||
productList = append(productList, types.Product{
|
||||
Cover: productCover,
|
||||
Fitting: *fsOrderDetailItem.OptionalTitle,
|
||||
OptionPrice: *fsOrderDetailItem.OptionPrice,
|
||||
OrderDetailTemplateId: *fsOrderDetailItem.OrderDetailTemplateId,
|
||||
OrderId: *fsOrderDetailItem.OrderId,
|
||||
Pcs: fsOrderDetailBuyNum,
|
||||
PcsBox: pcsBox,
|
||||
Price: *fsOrderDetailItem.FsOrderDetail.Amount,
|
||||
ProductId: *fsOrderDetailItem.OptionPrice,
|
||||
Title: *fsOrderDetailItem.FsProductInfo.Title,
|
||||
Size: *fsOrderDetailItem.FsOrderDetailTemplateInfo.FsProductSizeInfo.Capacity,
|
||||
IsStop: isStop,
|
||||
})
|
||||
}
|
||||
pbData.ProductList = productList
|
||||
}
|
||||
|
||||
pbData.IsStop = isStopMax
|
||||
pbData.PcsBox = pcsBox
|
||||
pbData.Pcs = pcs
|
||||
pbData.SurplusAt = surplusAt
|
||||
pbData.Deposit = *item.TotalAmount / 2
|
||||
pbData.Remaining = pbData.Deposit
|
||||
respList = append(respList, pbData)
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
return resp.SetStatusWithMessage(basic.CodeOK, "success", types.UserOrderListRsp{
|
||||
Items: respList,
|
||||
Meta: types.Meta{
|
||||
TotalCount: total,
|
||||
PageCount: int64(math.Ceil(float64(total) / float64(pageSize))),
|
||||
CurrentPage: int(page),
|
||||
PerPage: int(pageSize),
|
||||
},
|
||||
})
|
||||
// var respList []types.Items
|
||||
// if listResLen > 0 {
|
||||
// // 获取订单时间配置
|
||||
// orderTimeConfig, err := configs.GetOrderTimeConfig(l.ctx, l.svcCtx.MysqlConn)
|
||||
// if err != nil {
|
||||
// return resp.SetStatusWithMessage(basic.CodeServiceErr, "failed to get config time info")
|
||||
// }
|
||||
|
||||
// // 数据处理
|
||||
// for _, item := range listRes {
|
||||
// var pbData types.Items
|
||||
// pbData.ID = item.Id
|
||||
// pbData.Sn = *item.Sn
|
||||
// pbData.UserID = *item.UserId
|
||||
// pbData.TotalAmount = *item.TotalAmount
|
||||
// pbData.Ctime = format.TimeIntToFormat(*item.Ctime)
|
||||
// pbData.Status = *item.Status
|
||||
// pbData.DeliveryMethod = *item.DeliveryMethod
|
||||
// pbData.TsTime = format.TimeToFormat(*item.TsTime)
|
||||
// pbData.IsPayCompleted = *item.IsPayCompleted
|
||||
// pbData.DeliverSn = *item.DeliverSn
|
||||
|
||||
// var pcsBox int64
|
||||
// var pcs int64
|
||||
// var productList []types.Product
|
||||
|
||||
// var surplusAt int64
|
||||
|
||||
// //如果是部分支付状态,那么取消订单倒计时2天
|
||||
// if *item.Status == int64(constants.STATUS_NEW_PART_PAY) {
|
||||
// surplusAt = (*item.Ctime + int64(constants.CANCLE_ORDER_EXPIRE)) - time.Now().UTC().Unix()
|
||||
// if surplusAt < 0 {
|
||||
// surplusAt = 0
|
||||
// }
|
||||
// }
|
||||
|
||||
// fsOrderAffiliateInfo := item.FsOrderAffiliateInfo
|
||||
|
||||
// var sureTime int64
|
||||
// var productTime int64
|
||||
// var ProductEndtime int64
|
||||
// var deliverTime int64
|
||||
// var upsDeliverTime int64
|
||||
// var upsTime int64
|
||||
// var arrivalTime int64
|
||||
// var recevieTime int64
|
||||
// if fsOrderAffiliateInfo.Id > 0 {
|
||||
// sureTime = *fsOrderAffiliateInfo.SureTime
|
||||
// productTime = *fsOrderAffiliateInfo.ProductTime
|
||||
// ProductEndtime = *fsOrderAffiliateInfo.ProductEndtime
|
||||
// deliverTime = *fsOrderAffiliateInfo.DeliverTime
|
||||
// upsDeliverTime = *fsOrderAffiliateInfo.UpsDeliverTime
|
||||
// upsTime = *fsOrderAffiliateInfo.UpsTime
|
||||
// arrivalTime = *fsOrderAffiliateInfo.ArrivalTime
|
||||
// recevieTime = *fsOrderAffiliateInfo.RecevieTime
|
||||
// }
|
||||
|
||||
// var getOrderStatusAndLogisticsReq = order.GetOrderStatusAndLogisticsReq{
|
||||
// OrderStatus: constants.Order(*item.Status),
|
||||
// DeliveryMethod: constants.DeliveryMethod(*item.DeliveryMethod),
|
||||
// IsPayCompleted: *item.IsAllProductCompleted,
|
||||
// OrderCtime: *item.Ctime,
|
||||
|
||||
// SureTime: sureTime,
|
||||
// ProductTime: productTime,
|
||||
// ProductEndtime: ProductEndtime,
|
||||
// DeliverTime: deliverTime,
|
||||
// UpsDeliverTime: upsDeliverTime,
|
||||
// UpsTime: upsTime,
|
||||
// ArrivalTime: arrivalTime,
|
||||
// RecevieTime: recevieTime,
|
||||
|
||||
// WebSetTimeInfo: orderTimeConfig,
|
||||
// }
|
||||
|
||||
// statusAndLogisticsRes := order.GetOrderStatusAndLogistics(getOrderStatusAndLogisticsReq)
|
||||
|
||||
// // 流程控制
|
||||
// var statusTime []types.StatusTime
|
||||
// for _, itemTimes := range statusAndLogisticsRes.Times {
|
||||
// statusTime = append(statusTime, types.StatusTime{
|
||||
// Key: itemTimes.Key,
|
||||
// Time: itemTimes.Time,
|
||||
// })
|
||||
// }
|
||||
// pbData.StatusTimes = statusTime
|
||||
// pbData.LogisticsStatus = int64(statusAndLogisticsRes.LogisticsStatus)
|
||||
// pbData.Status = int64(statusAndLogisticsRes.OrderStatus)
|
||||
|
||||
// var isStopMax int64
|
||||
// if len(item.FsOrderDetails) > 0 {
|
||||
// for _, fsOrderDetailItem := range item.FsOrderDetails {
|
||||
|
||||
// fsOrderDetailBuyNum := *fsOrderDetailItem.FsOrderDetail.BuyNum
|
||||
// fsOrderDetailEachBoxNum := *fsOrderDetailItem.FsOrderDetailTemplateInfo.EachBoxNum
|
||||
// pcs = pcs + fsOrderDetailBuyNum
|
||||
// pcsBoxNum := fsOrderDetailBuyNum / fsOrderDetailEachBoxNum
|
||||
// var csBoxNumF int64
|
||||
// if (fsOrderDetailBuyNum % fsOrderDetailEachBoxNum) > 0 {
|
||||
// csBoxNumF = 1
|
||||
// }
|
||||
// pcsBox = pcsBox + pcsBoxNum + csBoxNumF
|
||||
|
||||
// productCover := *fsOrderDetailItem.Cover
|
||||
// // 尺寸
|
||||
// if size >= 200 {
|
||||
// coverArr := strings.Split(*fsOrderDetailItem.Cover, ".")
|
||||
// if len(coverArr) < 2 {
|
||||
// return resp.SetStatusWithMessage(basic.CodeServiceErr, "cover split slice item count is less than 2")
|
||||
// }
|
||||
// productCover = fmt.Sprintf("%s_%d.%s", coverArr[0], req.Size, coverArr[1])
|
||||
// }
|
||||
|
||||
// // 判断stop
|
||||
// var isStop int64
|
||||
// if fsOrderDetailItem.FsOrderDetailTemplateInfo.FsProductDesignInfo.OptionData.Id != 0 {
|
||||
// // 尺寸或者模板下架
|
||||
// if fsOrderDetailItem.FsOrderDetailTemplateInfo.FsProductDesignInfo.Id != 0 {
|
||||
// isStop = 1
|
||||
// } else {
|
||||
// isStop = 3
|
||||
// }
|
||||
// } else {
|
||||
// if fsOrderDetailItem.FsOrderDetailTemplateInfo.FsProductDesignInfo.Id != 0 {
|
||||
// isStop = 1
|
||||
// }
|
||||
// }
|
||||
|
||||
// // 判断产品是否下架
|
||||
// if *fsOrderDetailItem.FsProductInfo.IsShelf == 0 || *fsOrderDetailItem.FsProductInfo.IsDel == 1 {
|
||||
// isStop = 2
|
||||
// }
|
||||
// if isStop > isStopMax {
|
||||
// isStopMax = isStop
|
||||
// }
|
||||
|
||||
// productList = append(productList, types.Product{
|
||||
// Cover: productCover,
|
||||
// Fitting: *fsOrderDetailItem.OptionalTitle,
|
||||
// OptionPrice: *fsOrderDetailItem.OptionPrice,
|
||||
// OrderDetailTemplateId: *fsOrderDetailItem.OrderDetailTemplateId,
|
||||
// OrderId: *fsOrderDetailItem.OrderId,
|
||||
// Pcs: fsOrderDetailBuyNum,
|
||||
// PcsBox: pcsBox,
|
||||
// Price: *fsOrderDetailItem.FsOrderDetail.Amount,
|
||||
// ProductId: *fsOrderDetailItem.OptionPrice,
|
||||
// Title: *fsOrderDetailItem.FsProductInfo.Title,
|
||||
// Size: *fsOrderDetailItem.FsOrderDetailTemplateInfo.FsProductSizeInfo.Capacity,
|
||||
// IsStop: isStop,
|
||||
// })
|
||||
// }
|
||||
// pbData.ProductList = productList
|
||||
// }
|
||||
|
||||
// pbData.IsStop = isStopMax
|
||||
// pbData.PcsBox = pcsBox
|
||||
// pbData.Pcs = pcs
|
||||
// pbData.SurplusAt = surplusAt
|
||||
// pbData.Deposit = *item.TotalAmount / 2
|
||||
// pbData.Remaining = pbData.Deposit
|
||||
// respList = append(respList, pbData)
|
||||
// }
|
||||
|
||||
// }
|
||||
|
||||
// return resp.SetStatusWithMessage(basic.CodeOK, "success", types.UserOrderListRsp{
|
||||
// Items: respList,
|
||||
// Meta: types.Meta{
|
||||
// TotalCount: total,
|
||||
// PageCount: int64(math.Ceil(float64(total) / float64(pageSize))),
|
||||
// CurrentPage: int(page),
|
||||
// PerPage: int(pageSize),
|
||||
// },
|
||||
// })
|
||||
return resp.SetStatusWithMessage(basic.CodeOK, "success")
|
||||
}
|
||||
|
|
|
@ -1,13 +1,8 @@
|
|||
package logic
|
||||
|
||||
import (
|
||||
"errors"
|
||||
"fusenapi/constants"
|
||||
"fusenapi/model/gmodel"
|
||||
"fusenapi/utils/auth"
|
||||
"fusenapi/utils/basic"
|
||||
"fusenapi/utils/pay"
|
||||
"time"
|
||||
|
||||
"context"
|
||||
|
||||
|
@ -15,7 +10,6 @@ import (
|
|||
"fusenapi/server/pay/internal/types"
|
||||
|
||||
"github.com/zeromicro/go-zero/core/logx"
|
||||
"gorm.io/gorm"
|
||||
)
|
||||
|
||||
type OrderPaymentIntentLogic struct {
|
||||
|
@ -45,143 +39,143 @@ func (l *OrderPaymentIntentLogic) OrderPaymentIntent(req *types.OrderPaymentInte
|
|||
// 返回值必须调用Set重新返回, resp可以空指针调用 resp.SetStatus(basic.CodeOK, data)
|
||||
// userinfo 传入值时, 一定不为null
|
||||
|
||||
if userinfo == nil || userinfo.UserId == 0 {
|
||||
return resp.SetStatusWithMessage(basic.CodeDbRecordNotFoundErr, "order not found")
|
||||
}
|
||||
// if userinfo == nil || userinfo.UserId == 0 {
|
||||
// return resp.SetStatusWithMessage(basic.CodeDbRecordNotFoundErr, "order not found")
|
||||
// }
|
||||
|
||||
// 查询订单数据
|
||||
orderModel := gmodel.NewFsOrderModel(l.svcCtx.MysqlConn)
|
||||
orderInfo, err := orderModel.FindOneBySn(l.ctx, userinfo.UserId, req.Sn)
|
||||
// // 查询订单数据
|
||||
// orderModel := gmodel.NewFsOrderModel(l.svcCtx.MysqlConn)
|
||||
// orderInfo, err := orderModel.FindOneBySn(l.ctx, userinfo.UserId, req.Sn)
|
||||
|
||||
if err != nil {
|
||||
if errors.Is(err, gorm.ErrRecordNotFound) {
|
||||
return resp.SetStatusWithMessage(basic.CodeDbRecordNotFoundErr, "order not found")
|
||||
}
|
||||
logx.Error(err)
|
||||
return resp.SetStatusWithMessage(basic.CodeServiceErr, "failed to get order info")
|
||||
}
|
||||
// if err != nil {
|
||||
// if errors.Is(err, gorm.ErrRecordNotFound) {
|
||||
// return resp.SetStatusWithMessage(basic.CodeDbRecordNotFoundErr, "order not found")
|
||||
// }
|
||||
// logx.Error(err)
|
||||
// return resp.SetStatusWithMessage(basic.CodeServiceErr, "failed to get order info")
|
||||
// }
|
||||
|
||||
// 校验订单状态
|
||||
if *orderInfo.IsCancel == 1 {
|
||||
return resp.SetStatusWithMessage(basic.CodeServiceErr, "order cancelled")
|
||||
}
|
||||
// // 校验订单状态
|
||||
// if *orderInfo.IsCancel == 1 {
|
||||
// return resp.SetStatusWithMessage(basic.CodeServiceErr, "order cancelled")
|
||||
// }
|
||||
|
||||
// 校验地址信息
|
||||
addressModel := gmodel.NewFsAddressModel(l.svcCtx.MysqlConn)
|
||||
_, err = addressModel.GetOne(l.ctx, req.AddressId, userinfo.UserId)
|
||||
// // 校验地址信息
|
||||
// addressModel := gmodel.NewFsAddressModel(l.svcCtx.MysqlConn)
|
||||
// _, err = addressModel.GetOne(l.ctx, req.AddressId, userinfo.UserId)
|
||||
|
||||
if err != nil {
|
||||
if errors.Is(err, gorm.ErrRecordNotFound) {
|
||||
return resp.SetStatusWithMessage(basic.CodeDbRecordNotFoundErr, "address not found")
|
||||
}
|
||||
logx.Error(err)
|
||||
return resp.SetStatusWithMessage(basic.CodeServiceErr, "failed to get address info")
|
||||
}
|
||||
// if err != nil {
|
||||
// if errors.Is(err, gorm.ErrRecordNotFound) {
|
||||
// return resp.SetStatusWithMessage(basic.CodeDbRecordNotFoundErr, "address not found")
|
||||
// }
|
||||
// logx.Error(err)
|
||||
// return resp.SetStatusWithMessage(basic.CodeServiceErr, "failed to get address info")
|
||||
// }
|
||||
|
||||
// 校验订单支付信息
|
||||
if *orderInfo.IsPayCompleted == 1 {
|
||||
return resp.SetStatusWithMessage(basic.CodeServiceErr, "order is pay completed")
|
||||
}
|
||||
// // 校验订单支付信息
|
||||
// if *orderInfo.IsPayCompleted == 1 {
|
||||
// return resp.SetStatusWithMessage(basic.CodeServiceErr, "order is pay completed")
|
||||
// }
|
||||
|
||||
// 判断订单状态以及该支付金额
|
||||
var nowAt int64 = time.Now().UTC().Unix()
|
||||
var payAmount int64
|
||||
if *orderInfo.Status == int64(constants.STATUS_NEW_NOT_PAY) {
|
||||
payAmount = *orderInfo.TotalAmount / 2
|
||||
*orderInfo.DeliveryMethod = req.DeliveryMethod
|
||||
*orderInfo.AddressId = req.AddressId
|
||||
*orderInfo.PayMethod = req.PayMethod
|
||||
} else {
|
||||
payAmount = *orderInfo.TotalAmount - *orderInfo.TotalAmount/2
|
||||
}
|
||||
// // 判断订单状态以及该支付金额
|
||||
// var nowAt int64 = time.Now().UTC().Unix()
|
||||
// var payAmount int64
|
||||
// if *orderInfo.Status == int64(constants.STATUS_NEW_NOT_PAY) {
|
||||
// payAmount = *orderInfo.TotalAmount / 2
|
||||
// *orderInfo.DeliveryMethod = req.DeliveryMethod
|
||||
// *orderInfo.AddressId = req.AddressId
|
||||
// *orderInfo.PayMethod = req.PayMethod
|
||||
// } else {
|
||||
// payAmount = *orderInfo.TotalAmount - *orderInfo.TotalAmount/2
|
||||
// }
|
||||
|
||||
payConfig := &pay.Config{}
|
||||
var generatePrepaymentReq = &pay.GeneratePrepaymentReq{
|
||||
OrderSn: req.Sn,
|
||||
ProductName: "支付标题",
|
||||
Amount: payAmount,
|
||||
Currency: "eur",
|
||||
Quantity: 1,
|
||||
ProductDescription: "支付描述",
|
||||
}
|
||||
// payConfig := &pay.Config{}
|
||||
// var generatePrepaymentReq = &pay.GeneratePrepaymentReq{
|
||||
// OrderSn: req.Sn,
|
||||
// ProductName: "支付标题",
|
||||
// Amount: payAmount,
|
||||
// Currency: "eur",
|
||||
// Quantity: 1,
|
||||
// ProductDescription: "支付描述",
|
||||
// }
|
||||
|
||||
var resData types.OrderPaymentIntentRes
|
||||
// 事务处理
|
||||
ctx := l.ctx
|
||||
err = l.svcCtx.MysqlConn.Transaction(func(connGorm *gorm.DB) error {
|
||||
// 支付记录--处理 //支付记录改为一条订单多条,分首款尾款
|
||||
var payStatus int64 = 0
|
||||
var orderSource int64 = 1
|
||||
var payStage int64
|
||||
var fspay *gmodel.FsPay
|
||||
newFsPayModel := gmodel.NewFsPayModel(connGorm)
|
||||
if *orderInfo.Status == int64(constants.STATUS_NEW_NOT_PAY) {
|
||||
fspay, err = newFsPayModel.RBGetListByOrderNumberStage(ctx, *orderInfo.Sn, 1)
|
||||
if err != nil {
|
||||
if !errors.Is(err, gorm.ErrRecordNotFound) {
|
||||
return err
|
||||
}
|
||||
}
|
||||
payStage = 1
|
||||
} else {
|
||||
fspay, err = newFsPayModel.RBGetListByOrderNumberStage(ctx, *orderInfo.Sn, 2)
|
||||
if err != nil {
|
||||
if !errors.Is(err, gorm.ErrRecordNotFound) {
|
||||
return err
|
||||
}
|
||||
}
|
||||
payStage = 2
|
||||
}
|
||||
// var resData types.OrderPaymentIntentRes
|
||||
// // 事务处理
|
||||
// ctx := l.ctx
|
||||
// err = l.svcCtx.MysqlConn.Transaction(func(connGorm *gorm.DB) error {
|
||||
// // 支付记录--处理 //支付记录改为一条订单多条,分首款尾款
|
||||
// var payStatus int64 = 0
|
||||
// var orderSource int64 = 1
|
||||
// var payStage int64
|
||||
// var fspay *gmodel.FsPay
|
||||
// newFsPayModel := gmodel.NewFsPayModel(connGorm)
|
||||
// if *orderInfo.Status == int64(constants.STATUS_NEW_NOT_PAY) {
|
||||
// fspay, err = newFsPayModel.RBGetListByOrderNumberStage(ctx, *orderInfo.Sn, 1)
|
||||
// if err != nil {
|
||||
// if !errors.Is(err, gorm.ErrRecordNotFound) {
|
||||
// return err
|
||||
// }
|
||||
// }
|
||||
// payStage = 1
|
||||
// } else {
|
||||
// fspay, err = newFsPayModel.RBGetListByOrderNumberStage(ctx, *orderInfo.Sn, 2)
|
||||
// if err != nil {
|
||||
// if !errors.Is(err, gorm.ErrRecordNotFound) {
|
||||
// return err
|
||||
// }
|
||||
// }
|
||||
// payStage = 2
|
||||
// }
|
||||
|
||||
// 支付预付--生成
|
||||
if constants.PayMethod(req.PayMethod) == constants.PAYMETHOD_STRIPE {
|
||||
payConfig.Stripe.Key = l.svcCtx.Config.PayConfig.Stripe.Key
|
||||
generatePrepaymentReq.SuccessURL = l.svcCtx.Config.PayConfig.Stripe.SuccessURL
|
||||
generatePrepaymentReq.CancelURL = l.svcCtx.Config.PayConfig.Stripe.CancelURL
|
||||
}
|
||||
payDriver := pay.NewPayDriver(req.PayMethod, payConfig)
|
||||
prepaymentRes, err := payDriver.GeneratePrepayment(generatePrepaymentReq)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
// // 支付预付--生成
|
||||
// if constants.PayMethod(req.PayMethod) == constants.PAYMETHOD_STRIPE {
|
||||
// payConfig.Stripe.Key = l.svcCtx.Config.PayConfig.Stripe.Key
|
||||
// generatePrepaymentReq.SuccessURL = l.svcCtx.Config.PayConfig.Stripe.SuccessURL
|
||||
// generatePrepaymentReq.CancelURL = l.svcCtx.Config.PayConfig.Stripe.CancelURL
|
||||
// }
|
||||
// payDriver := pay.NewPayDriver(req.PayMethod, payConfig)
|
||||
// prepaymentRes, err := payDriver.GeneratePrepayment(generatePrepaymentReq)
|
||||
// if err != nil {
|
||||
// return err
|
||||
// }
|
||||
|
||||
// 订单信息--修改
|
||||
err = gmodel.NewFsOrderModel(connGorm).RBUpdate(ctx, orderInfo)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
// // 订单信息--修改
|
||||
// err = gmodel.NewFsOrderModel(connGorm).RBUpdate(ctx, orderInfo)
|
||||
// if err != nil {
|
||||
// return err
|
||||
// }
|
||||
|
||||
if fspay == nil {
|
||||
fspay = &gmodel.FsPay{
|
||||
UserId: orderInfo.UserId,
|
||||
OrderNumber: orderInfo.Sn,
|
||||
CreatedAt: &nowAt,
|
||||
}
|
||||
} else {
|
||||
fspay.UpdatedAt = &nowAt
|
||||
}
|
||||
fspay.PayAmount = &payAmount
|
||||
fspay.PayStage = &payStage
|
||||
//fspay.TradeNo = &prepaymentRes.TradeNo
|
||||
fspay.PaymentMethod = &req.PayMethod
|
||||
fspay.OrderSource = &orderSource
|
||||
fspay.PayStatus = &payStatus
|
||||
// if fspay == nil {
|
||||
// fspay = &gmodel.FsPay{
|
||||
// UserId: orderInfo.UserId,
|
||||
// OrderNumber: orderInfo.Sn,
|
||||
// CreatedAt: &nowAt,
|
||||
// }
|
||||
// } else {
|
||||
// fspay.UpdatedAt = &nowAt
|
||||
// }
|
||||
// fspay.PayAmount = &payAmount
|
||||
// fspay.PayStage = &payStage
|
||||
// //fspay.TradeNo = &prepaymentRes.TradeNo
|
||||
// fspay.PaymentMethod = &req.PayMethod
|
||||
// fspay.OrderSource = &orderSource
|
||||
// fspay.PayStatus = &payStatus
|
||||
|
||||
_, err = newFsPayModel.RBCreateOrUpdate(ctx, fspay)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
resData.RedirectUrl = prepaymentRes.URL
|
||||
resData.ClientSecret = prepaymentRes.ClientSecret
|
||||
|
||||
return nil
|
||||
})
|
||||
|
||||
if err != nil {
|
||||
logx.Error(err)
|
||||
return resp.SetStatusWithMessage(basic.CodeServiceErr, "failed to make payment")
|
||||
}
|
||||
|
||||
return resp.SetStatusWithMessage(basic.CodeOK, "success", resData)
|
||||
// _, err = newFsPayModel.RBCreateOrUpdate(ctx, fspay)
|
||||
// if err != nil {
|
||||
// return err
|
||||
// }
|
||||
|
||||
// resData.RedirectUrl = prepaymentRes.URL
|
||||
// resData.ClientSecret = prepaymentRes.ClientSecret
|
||||
|
||||
// return nil
|
||||
// })
|
||||
|
||||
// if err != nil {
|
||||
// logx.Error(err)
|
||||
// return resp.SetStatusWithMessage(basic.CodeServiceErr, "failed to make payment")
|
||||
// }
|
||||
|
||||
return resp.SetStatusWithMessage(basic.CodeOK, "success")
|
||||
}
|
||||
|
|
|
@ -1,13 +1,9 @@
|
|||
package logic
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"errors"
|
||||
"fusenapi/constants"
|
||||
"fusenapi/model/gmodel"
|
||||
"fusenapi/utils/auth"
|
||||
"fusenapi/utils/basic"
|
||||
"time"
|
||||
|
||||
"context"
|
||||
|
||||
|
@ -15,9 +11,7 @@ import (
|
|||
"fusenapi/server/pay/internal/types"
|
||||
|
||||
"github.com/stripe/stripe-go/v74"
|
||||
"github.com/stripe/stripe-go/v74/webhook"
|
||||
"github.com/zeromicro/go-zero/core/logx"
|
||||
"gorm.io/gorm"
|
||||
)
|
||||
|
||||
type StripeWebhookLogic struct {
|
||||
|
@ -48,97 +42,97 @@ func (l *StripeWebhookLogic) StripeWebhook(req *types.StripeWebhookReq, userinfo
|
|||
// 返回值必须调用Set重新返回, resp可以空指针调用 resp.SetStatus(basic.CodeOK, data)
|
||||
// userinfo 传入值时, 一定不为null
|
||||
|
||||
stripe.Key = l.svcCtx.Config.PayConfig.Stripe.Key
|
||||
event := stripe.Event{}
|
||||
// stripe.Key = l.svcCtx.Config.PayConfig.Stripe.Key
|
||||
// event := stripe.Event{}
|
||||
|
||||
if err := json.Unmarshal(req.Payload, &event); err != nil {
|
||||
logx.Error(err)
|
||||
return resp.SetStatusWithMessage(basic.CodeAesCbcDecryptionErr, "pay notify Unmarshal fail")
|
||||
}
|
||||
|
||||
endpointSecret := l.svcCtx.Config.PayConfig.Stripe.EndpointSecret
|
||||
signatureHeader := req.StripeSignature
|
||||
event, err := webhook.ConstructEvent(req.Payload, signatureHeader, endpointSecret)
|
||||
if err != nil {
|
||||
logx.Error(err)
|
||||
return resp.SetStatusWithMessage(basic.CodeAesCbcDecryptionErr, "Webhook signature verification failed")
|
||||
}
|
||||
|
||||
// 新增支付回调事件日志
|
||||
var payMethod = int64(constants.PAYMETHOD_STRIPE)
|
||||
var nowTime = time.Now().UTC().Unix()
|
||||
var eventData = string(event.Data.Raw)
|
||||
var fsPayEvent = &gmodel.FsPayEvent{
|
||||
PayMethod: &payMethod,
|
||||
EventId: &event.ID,
|
||||
EventType: &event.Type,
|
||||
EventData: &eventData,
|
||||
EventCreated: &event.Created,
|
||||
Ip: &req.RemoteAddr,
|
||||
CreatedAt: &nowTime,
|
||||
}
|
||||
l.HandlePayEventCreate(fsPayEvent)
|
||||
|
||||
// Unmarshal the event data into an appropriate struct depending on its Type
|
||||
switch event.Type {
|
||||
case "charge.succeeded":
|
||||
// var charge stripe.Charge
|
||||
// err := json.Unmarshal(event.Data.Raw, &charge)
|
||||
// if err != nil {
|
||||
// if err := json.Unmarshal(req.Payload, &event); err != nil {
|
||||
// logx.Error(err)
|
||||
// return resp.SetStatusWithMessage(basic.CodeAesCbcDecryptionErr, "pay notify Unmarshal fail event.Type charge.succeeded")
|
||||
// return resp.SetStatusWithMessage(basic.CodeAesCbcDecryptionErr, "pay notify Unmarshal fail")
|
||||
// }
|
||||
|
||||
case "checkout.session.completed":
|
||||
// checkout checkout.session.completed 处理逻辑
|
||||
// var session stripe.CheckoutSession
|
||||
// err := json.Unmarshal(event.Data.Raw, &session)
|
||||
// endpointSecret := l.svcCtx.Config.PayConfig.Stripe.EndpointSecret
|
||||
// signatureHeader := req.StripeSignature
|
||||
// event, err := webhook.ConstructEvent(req.Payload, signatureHeader, endpointSecret)
|
||||
// if err != nil {
|
||||
// logx.Error(err)
|
||||
// return resp.SetStatusWithMessage(basic.CodeAesCbcDecryptionErr, "Webhook signature verification failed")
|
||||
// }
|
||||
|
||||
// // 新增支付回调事件日志
|
||||
// var payMethod = int64(constants.PAYMETHOD_STRIPE)
|
||||
// var nowTime = time.Now().UTC().Unix()
|
||||
// var eventData = string(event.Data.Raw)
|
||||
// var fsPayEvent = &gmodel.FsPayEvent{
|
||||
// PayMethod: &payMethod,
|
||||
// EventId: &event.ID,
|
||||
// EventType: &event.Type,
|
||||
// EventData: &eventData,
|
||||
// EventCreated: &event.Created,
|
||||
// Ip: &req.RemoteAddr,
|
||||
// CreatedAt: &nowTime,
|
||||
// }
|
||||
// l.HandlePayEventCreate(fsPayEvent)
|
||||
|
||||
// // Unmarshal the event data into an appropriate struct depending on its Type
|
||||
// switch event.Type {
|
||||
// case "charge.succeeded":
|
||||
// // var charge stripe.Charge
|
||||
// // err := json.Unmarshal(event.Data.Raw, &charge)
|
||||
// // if err != nil {
|
||||
// // logx.Error(err)
|
||||
// // return resp.SetStatusWithMessage(basic.CodeAesCbcDecryptionErr, "pay notify Unmarshal fail event.Type charge.succeeded")
|
||||
// // }
|
||||
|
||||
// case "checkout.session.completed":
|
||||
// // checkout checkout.session.completed 处理逻辑
|
||||
// // var session stripe.CheckoutSession
|
||||
// // err := json.Unmarshal(event.Data.Raw, &session)
|
||||
// // if err != nil {
|
||||
// // logx.Error(err)
|
||||
// // return resp.SetStatusWithMessage(basic.CodeAesCbcDecryptionErr, "pay notify Unmarshal fail event.Type payment_intent.succeeded")
|
||||
// // }
|
||||
// // fmt.Println("checkout.session.completed")
|
||||
// // err = l.handlePaymentSessionCompleted(session.ID, session.PaymentIntent.ID)
|
||||
// // if err != nil {
|
||||
// // return resp.SetStatusWithMessage(basic.CodeAesCbcDecryptionErr, "checkout.session.completed fail")
|
||||
// // }
|
||||
// case "payment_intent.succeeded":
|
||||
// var paymentIntent stripe.PaymentIntent
|
||||
// err := json.Unmarshal(event.Data.Raw, &paymentIntent)
|
||||
// if err != nil {
|
||||
// logx.Errorf("err:%+v,desc:%s", err, "pay notify Unmarshal fail event.Type payment_intent.succeeded")
|
||||
// return resp.SetStatusWithMessage(basic.CodeAesCbcDecryptionErr, "pay notify Unmarshal fail event.Type payment_intent.succeeded")
|
||||
// }
|
||||
// fmt.Println("checkout.session.completed")
|
||||
// err = l.handlePaymentSessionCompleted(session.ID, session.PaymentIntent.ID)
|
||||
// err = l.HandlePaymentIntentSucceeded(&paymentIntent)
|
||||
// if err != nil {
|
||||
// return resp.SetStatusWithMessage(basic.CodeAesCbcDecryptionErr, "checkout.session.completed fail")
|
||||
// logx.Errorf("err:%+v,desc:%s", err, "pay notify handle payment_intent.succeeded")
|
||||
// return resp.SetStatusWithMessage(basic.CodePaybackNotOk, "pay notify handle payment_intent.succeeded")
|
||||
// }
|
||||
// case "payment_method.attached":
|
||||
// var paymentMethod stripe.PaymentMethod
|
||||
// err := json.Unmarshal(event.Data.Raw, &paymentMethod)
|
||||
// if err != nil {
|
||||
// logx.Error(err)
|
||||
// return resp.SetStatusWithMessage(basic.CodeAesCbcDecryptionErr, "pay notify Unmarshal fail event.Type payment_method.attached")
|
||||
// }
|
||||
// case "charge.refunded":
|
||||
// var chargeRefunded stripe.Charge
|
||||
// err := json.Unmarshal(event.Data.Raw, &chargeRefunded)
|
||||
// if err != nil {
|
||||
// logx.Errorf("err:%+v,desc:%s", err, "pay notify Unmarshal fail event.Type charge.refunded")
|
||||
// return resp.SetStatusWithMessage(basic.CodeAesCbcDecryptionErr, "pay notify Unmarshal fail event.Type charge.refunded")
|
||||
// }
|
||||
// err = l.HandleChargeRefunded(&chargeRefunded)
|
||||
// if err != nil {
|
||||
// logx.Errorf("err:%+v,desc:%s", err, "pay notify handle charge.refunded")
|
||||
// return resp.SetStatusWithMessage(basic.CodeAesCbcDecryptionErr, "pay notify handle charge.refunded")
|
||||
// }
|
||||
case "payment_intent.succeeded":
|
||||
var paymentIntent stripe.PaymentIntent
|
||||
err := json.Unmarshal(event.Data.Raw, &paymentIntent)
|
||||
if err != nil {
|
||||
logx.Errorf("err:%+v,desc:%s", err, "pay notify Unmarshal fail event.Type payment_intent.succeeded")
|
||||
return resp.SetStatusWithMessage(basic.CodeAesCbcDecryptionErr, "pay notify Unmarshal fail event.Type payment_intent.succeeded")
|
||||
}
|
||||
err = l.HandlePaymentIntentSucceeded(&paymentIntent)
|
||||
if err != nil {
|
||||
logx.Errorf("err:%+v,desc:%s", err, "pay notify handle payment_intent.succeeded")
|
||||
return resp.SetStatusWithMessage(basic.CodePaybackNotOk, "pay notify handle payment_intent.succeeded")
|
||||
}
|
||||
case "payment_method.attached":
|
||||
var paymentMethod stripe.PaymentMethod
|
||||
err := json.Unmarshal(event.Data.Raw, &paymentMethod)
|
||||
if err != nil {
|
||||
logx.Error(err)
|
||||
return resp.SetStatusWithMessage(basic.CodeAesCbcDecryptionErr, "pay notify Unmarshal fail event.Type payment_method.attached")
|
||||
}
|
||||
case "charge.refunded":
|
||||
var chargeRefunded stripe.Charge
|
||||
err := json.Unmarshal(event.Data.Raw, &chargeRefunded)
|
||||
if err != nil {
|
||||
logx.Errorf("err:%+v,desc:%s", err, "pay notify Unmarshal fail event.Type charge.refunded")
|
||||
return resp.SetStatusWithMessage(basic.CodeAesCbcDecryptionErr, "pay notify Unmarshal fail event.Type charge.refunded")
|
||||
}
|
||||
err = l.HandleChargeRefunded(&chargeRefunded)
|
||||
if err != nil {
|
||||
logx.Errorf("err:%+v,desc:%s", err, "pay notify handle charge.refunded")
|
||||
return resp.SetStatusWithMessage(basic.CodeAesCbcDecryptionErr, "pay notify handle charge.refunded")
|
||||
}
|
||||
|
||||
// ... handle other event types
|
||||
default:
|
||||
logx.Error("Unhandled event")
|
||||
return resp.SetStatusWithMessage(basic.CodeAesCbcDecryptionErr, "pay notify Unmarshal fail event.Type Unhandled")
|
||||
}
|
||||
// // ... handle other event types
|
||||
// default:
|
||||
// logx.Error("Unhandled event")
|
||||
// return resp.SetStatusWithMessage(basic.CodeAesCbcDecryptionErr, "pay notify Unmarshal fail event.Type Unhandled")
|
||||
// }
|
||||
|
||||
return resp.SetStatus(basic.CodeOK)
|
||||
}
|
||||
|
@ -151,62 +145,62 @@ func (l *StripeWebhookLogic) HandlePayEventCreate(fsPayEvent *gmodel.FsPayEvent)
|
|||
|
||||
// 退款成功
|
||||
func (l *StripeWebhookLogic) HandleChargeRefunded(chargeRefunded *stripe.Charge) (err error) {
|
||||
// 退款成功
|
||||
if chargeRefunded.Status == "succeeded" {
|
||||
ctx := l.ctx
|
||||
err = l.svcCtx.MysqlConn.Transaction(func(connGorm *gorm.DB) error {
|
||||
// 查询支付记录
|
||||
payModelT := gmodel.NewFsPayModel(connGorm)
|
||||
payModelTRSB := payModelT.BuilderTrans(nil)
|
||||
payModelTRSB1 := payModelTRSB.Where("trade_no = ?", chargeRefunded.PaymentIntent.ID).Where("pay_status = ?", constants.PAYSTATUS_SUCCESS).Where("is_refund = ?", 0)
|
||||
payInfo, err := payModelT.FindOneByQuery(ctx, payModelTRSB1, nil)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
// 更新支付记录
|
||||
*payInfo.IsRefund = 1
|
||||
_, err = payModelT.RBCreateOrUpdate(ctx, payInfo)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
// 获取是否还有未退款的数据
|
||||
payModelTRSB2 := payModelTRSB.Where("order_number = ?", payInfo.OrderNumber).Where("pay_status = ?", constants.PAYSTATUS_SUCCESS).Where("is_refund = ?", 0)
|
||||
count, err := payModelT.FindCount(l.ctx, payModelTRSB2, nil)
|
||||
if count == 0 {
|
||||
// 退款完成更新订单状态
|
||||
orderModelT := gmodel.NewFsOrderModel(connGorm)
|
||||
orderModelTRSB := orderModelT.BuilderTrans(nil).Where("sn =?", payInfo.OrderNumber)
|
||||
orderInfoRel, err := orderModelT.FindOneByQuery(ctx, orderModelTRSB, nil)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
var isRefunded int64 = 1
|
||||
var isRefunding int64 = 1
|
||||
var orderStatus int64 = int64(constants.STATUS_NEW_REFUNDED)
|
||||
var orderInfo = &gmodel.FsOrder{}
|
||||
orderInfo.Id = orderInfoRel.Id
|
||||
orderInfo.IsRefunded = &isRefunded
|
||||
orderInfo.IsRefunding = &isRefunding
|
||||
orderInfo.Status = &orderStatus
|
||||
orderModelT.Update(ctx, orderInfo)
|
||||
// // 退款成功
|
||||
// if chargeRefunded.Status == "succeeded" {
|
||||
// ctx := l.ctx
|
||||
// err = l.svcCtx.MysqlConn.Transaction(func(connGorm *gorm.DB) error {
|
||||
// // 查询支付记录
|
||||
// payModelT := gmodel.NewFsPayModel(connGorm)
|
||||
// payModelTRSB := payModelT.BuilderTrans(nil)
|
||||
// payModelTRSB1 := payModelTRSB.Where("trade_no = ?", chargeRefunded.PaymentIntent.ID).Where("pay_status = ?", constants.PAYSTATUS_SUCCESS).Where("is_refund = ?", 0)
|
||||
// payInfo, err := payModelT.FindOneByQuery(ctx, payModelTRSB1, nil)
|
||||
// if err != nil {
|
||||
// return err
|
||||
// }
|
||||
// // 更新支付记录
|
||||
// *payInfo.IsRefund = 1
|
||||
// _, err = payModelT.RBCreateOrUpdate(ctx, payInfo)
|
||||
// if err != nil {
|
||||
// return err
|
||||
// }
|
||||
// // 获取是否还有未退款的数据
|
||||
// payModelTRSB2 := payModelTRSB.Where("order_number = ?", payInfo.OrderNumber).Where("pay_status = ?", constants.PAYSTATUS_SUCCESS).Where("is_refund = ?", 0)
|
||||
// count, err := payModelT.FindCount(l.ctx, payModelTRSB2, nil)
|
||||
// if count == 0 {
|
||||
// // 退款完成更新订单状态
|
||||
// orderModelT := gmodel.NewFsOrderModel(connGorm)
|
||||
// orderModelTRSB := orderModelT.BuilderTrans(nil).Where("sn =?", payInfo.OrderNumber)
|
||||
// orderInfoRel, err := orderModelT.FindOneByQuery(ctx, orderModelTRSB, nil)
|
||||
// if err != nil {
|
||||
// return err
|
||||
// }
|
||||
// var isRefunded int64 = 1
|
||||
// var isRefunding int64 = 1
|
||||
// var orderStatus int64 = int64(constants.STATUS_NEW_REFUNDED)
|
||||
// var orderInfo = &gmodel.FsOrder{}
|
||||
// orderInfo.Id = orderInfoRel.Id
|
||||
// orderInfo.IsRefunded = &isRefunded
|
||||
// orderInfo.IsRefunding = &isRefunding
|
||||
// orderInfo.Status = &orderStatus
|
||||
// orderModelT.Update(ctx, orderInfo)
|
||||
|
||||
// 记录退款原因
|
||||
refundReasonModelT := gmodel.NewFsRefundReasonModel(connGorm)
|
||||
refundReasonModelTRSB := refundReasonModelT.BuilderTrans(nil)
|
||||
refundReasonModelTRSB1 := refundReasonModelTRSB.Where("order_id =?", orderInfoRel.Id)
|
||||
refundReasonInfo, err := refundReasonModelT.FindOneByQuery(ctx, refundReasonModelTRSB1, nil)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
*refundReasonInfo.IsRefund = 1
|
||||
_, err = refundReasonModelT.RBCreateOrUpdate(ctx, refundReasonInfo)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
return err
|
||||
})
|
||||
}
|
||||
// // 记录退款原因
|
||||
// refundReasonModelT := gmodel.NewFsRefundReasonModel(connGorm)
|
||||
// refundReasonModelTRSB := refundReasonModelT.BuilderTrans(nil)
|
||||
// refundReasonModelTRSB1 := refundReasonModelTRSB.Where("order_id =?", orderInfoRel.Id)
|
||||
// refundReasonInfo, err := refundReasonModelT.FindOneByQuery(ctx, refundReasonModelTRSB1, nil)
|
||||
// if err != nil {
|
||||
// return err
|
||||
// }
|
||||
// *refundReasonInfo.IsRefund = 1
|
||||
// _, err = refundReasonModelT.RBCreateOrUpdate(ctx, refundReasonInfo)
|
||||
// if err != nil {
|
||||
// return err
|
||||
// }
|
||||
// }
|
||||
// return err
|
||||
// })
|
||||
// }
|
||||
return err
|
||||
}
|
||||
|
||||
|
@ -234,160 +228,160 @@ func (l *StripeWebhookLogic) HandleChargeRefunded(chargeRefunded *stripe.Charge)
|
|||
|
||||
// 付款成功
|
||||
func (l *StripeWebhookLogic) HandlePaymentIntentSucceeded(paymentIntent *stripe.PaymentIntent) error {
|
||||
orderSn, ok := paymentIntent.Metadata["order_sn"]
|
||||
if !ok || orderSn == "" {
|
||||
return errors.New("order_sn not found")
|
||||
}
|
||||
// orderSn, ok := paymentIntent.Metadata["order_sn"]
|
||||
// if !ok || orderSn == "" {
|
||||
// return errors.New("order_sn not found")
|
||||
// }
|
||||
|
||||
// 查询支付记录
|
||||
payModel := gmodel.NewFsPayModel(l.svcCtx.MysqlConn)
|
||||
rsbPay := payModel.RowSelectBuilder(nil)
|
||||
rsbPay = rsbPay.Where("order_number = ?", orderSn).Where("pay_status = ?", constants.PAYSTATUS_UNSUCCESS)
|
||||
payInfo, err := payModel.FindOneByQuery(l.ctx, rsbPay, nil)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
// // 查询支付记录
|
||||
// payModel := gmodel.NewFsPayModel(l.svcCtx.MysqlConn)
|
||||
// rsbPay := payModel.RowSelectBuilder(nil)
|
||||
// rsbPay = rsbPay.Where("order_number = ?", orderSn).Where("pay_status = ?", constants.PAYSTATUS_UNSUCCESS)
|
||||
// payInfo, err := payModel.FindOneByQuery(l.ctx, rsbPay, nil)
|
||||
// if err != nil {
|
||||
// return err
|
||||
// }
|
||||
|
||||
//订单信息
|
||||
orderDetailTemplateModel := gmodel.NewFsOrderDetailTemplateModel(l.svcCtx.MysqlConn)
|
||||
orderModel := gmodel.NewFsOrderModel(l.svcCtx.MysqlConn)
|
||||
fsOrderDetailModel := gmodel.NewFsOrderDetailModel(l.svcCtx.MysqlConn)
|
||||
fsProductDesignModel := gmodel.NewFsProductDesignModel(l.svcCtx.MysqlConn)
|
||||
// //订单信息
|
||||
// orderDetailTemplateModel := gmodel.NewFsOrderDetailTemplateModel(l.svcCtx.MysqlConn)
|
||||
// orderModel := gmodel.NewFsOrderModel(l.svcCtx.MysqlConn)
|
||||
// fsOrderDetailModel := gmodel.NewFsOrderDetailModel(l.svcCtx.MysqlConn)
|
||||
// fsProductDesignModel := gmodel.NewFsProductDesignModel(l.svcCtx.MysqlConn)
|
||||
|
||||
rsbOrder := orderModel.RowSelectBuilder(nil)
|
||||
rsbOrder = rsbOrder.Where("sn =?", orderSn).Preload("FsOrderDetails")
|
||||
rsbOrder = rsbOrder.Preload("FsOrderDetails", func(dbPreload *gorm.DB) *gorm.DB {
|
||||
return dbPreload.Table(fsOrderDetailModel.TableName()).Preload("FsOrderDetailTemplateInfo", func(dbPreload *gorm.DB) *gorm.DB {
|
||||
return dbPreload.Table(orderDetailTemplateModel.TableName()).Preload("FsProductDesignInfo", func(dbPreload *gorm.DB) *gorm.DB {
|
||||
return dbPreload.Table(fsProductDesignModel.TableName())
|
||||
})
|
||||
})
|
||||
})
|
||||
fsOrderRelInfo, err := orderModel.FindOneByQuery(l.ctx, rsbOrder, nil)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
// rsbOrder := orderModel.RowSelectBuilder(nil)
|
||||
// rsbOrder = rsbOrder.Where("sn =?", orderSn).Preload("FsOrderDetails")
|
||||
// rsbOrder = rsbOrder.Preload("FsOrderDetails", func(dbPreload *gorm.DB) *gorm.DB {
|
||||
// return dbPreload.Table(fsOrderDetailModel.TableName()).Preload("FsOrderDetailTemplateInfo", func(dbPreload *gorm.DB) *gorm.DB {
|
||||
// return dbPreload.Table(orderDetailTemplateModel.TableName()).Preload("FsProductDesignInfo", func(dbPreload *gorm.DB) *gorm.DB {
|
||||
// return dbPreload.Table(fsProductDesignModel.TableName())
|
||||
// })
|
||||
// })
|
||||
// })
|
||||
// fsOrderRelInfo, err := orderModel.FindOneByQuery(l.ctx, rsbOrder, nil)
|
||||
// if err != nil {
|
||||
// return err
|
||||
// }
|
||||
|
||||
var designIds []int64
|
||||
var cartIds []int64
|
||||
if len(fsOrderRelInfo.FsOrderDetails) > 0 {
|
||||
for _, fsOrderDetail := range fsOrderRelInfo.FsOrderDetails {
|
||||
if fsOrderDetail.FsOrderDetailTemplateInfo.FsProductDesignInfo.Id != 0 {
|
||||
designIds = append(designIds, fsOrderDetail.FsOrderDetailTemplateInfo.FsProductDesignInfo.Id)
|
||||
}
|
||||
cartIds = append(cartIds, *fsOrderDetail.CartId)
|
||||
}
|
||||
}
|
||||
// var designIds []int64
|
||||
// var cartIds []int64
|
||||
// if len(fsOrderRelInfo.FsOrderDetails) > 0 {
|
||||
// for _, fsOrderDetail := range fsOrderRelInfo.FsOrderDetails {
|
||||
// if fsOrderDetail.FsOrderDetailTemplateInfo.FsProductDesignInfo.Id != 0 {
|
||||
// designIds = append(designIds, fsOrderDetail.FsOrderDetailTemplateInfo.FsProductDesignInfo.Id)
|
||||
// }
|
||||
// cartIds = append(cartIds, *fsOrderDetail.CartId)
|
||||
// }
|
||||
// }
|
||||
|
||||
var nowTime int64 = time.Now().UTC().Unix()
|
||||
// var nowTime int64 = time.Now().UTC().Unix()
|
||||
|
||||
// 支付成功
|
||||
if paymentIntent.Status == "succeeded" {
|
||||
var card string
|
||||
var brand string
|
||||
if paymentIntent.LatestCharge.PaymentMethodDetails != nil {
|
||||
if paymentIntent.LatestCharge.PaymentMethodDetails.Card != nil {
|
||||
if paymentIntent.LatestCharge.PaymentMethodDetails.Card.Last4 != "" {
|
||||
card = paymentIntent.LatestCharge.PaymentMethodDetails.Card.Last4
|
||||
}
|
||||
if paymentIntent.LatestCharge.PaymentMethodDetails.Card.Brand != "" {
|
||||
brand = string(paymentIntent.LatestCharge.PaymentMethodDetails.Card.Brand)
|
||||
}
|
||||
}
|
||||
}
|
||||
// // 支付成功
|
||||
// if paymentIntent.Status == "succeeded" {
|
||||
// var card string
|
||||
// var brand string
|
||||
// if paymentIntent.LatestCharge.PaymentMethodDetails != nil {
|
||||
// if paymentIntent.LatestCharge.PaymentMethodDetails.Card != nil {
|
||||
// if paymentIntent.LatestCharge.PaymentMethodDetails.Card.Last4 != "" {
|
||||
// card = paymentIntent.LatestCharge.PaymentMethodDetails.Card.Last4
|
||||
// }
|
||||
// if paymentIntent.LatestCharge.PaymentMethodDetails.Card.Brand != "" {
|
||||
// brand = string(paymentIntent.LatestCharge.PaymentMethodDetails.Card.Brand)
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
|
||||
ctx := l.ctx
|
||||
err = l.svcCtx.MysqlConn.Transaction(func(connGorm *gorm.DB) error {
|
||||
// 更新支付信息
|
||||
payModelT := gmodel.NewFsPayModel(connGorm)
|
||||
*payInfo.PayStatus = 1
|
||||
*payInfo.PayTime = nowTime
|
||||
*payInfo.CardNo = card
|
||||
*payInfo.Brand = brand
|
||||
*payInfo.TradeNo = paymentIntent.ID
|
||||
_, err = payModelT.RBCreateOrUpdate(ctx, payInfo)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
// ctx := l.ctx
|
||||
// err = l.svcCtx.MysqlConn.Transaction(func(connGorm *gorm.DB) error {
|
||||
// // 更新支付信息
|
||||
// payModelT := gmodel.NewFsPayModel(connGorm)
|
||||
// *payInfo.PayStatus = 1
|
||||
// *payInfo.PayTime = nowTime
|
||||
// *payInfo.CardNo = card
|
||||
// *payInfo.Brand = brand
|
||||
// *payInfo.TradeNo = paymentIntent.ID
|
||||
// _, err = payModelT.RBCreateOrUpdate(ctx, payInfo)
|
||||
// if err != nil {
|
||||
// return err
|
||||
// }
|
||||
|
||||
// 更新设计数据
|
||||
productDesignModelT := gmodel.NewFsProductDesignModel(connGorm)
|
||||
productDesignModelTRSB := productDesignModelT.BuilderTrans(ctx, nil)
|
||||
var isPay int64 = 1
|
||||
err = productDesignModelT.RBUpdateByIds(productDesignModelTRSB, designIds, &gmodel.FsProductDesign{IsPay: &isPay})
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
// // 更新设计数据
|
||||
// productDesignModelT := gmodel.NewFsProductDesignModel(connGorm)
|
||||
// productDesignModelTRSB := productDesignModelT.BuilderTrans(ctx, nil)
|
||||
// var isPay int64 = 1
|
||||
// err = productDesignModelT.RBUpdateByIds(productDesignModelTRSB, designIds, &gmodel.FsProductDesign{IsPay: &isPay})
|
||||
// if err != nil {
|
||||
// return err
|
||||
// }
|
||||
|
||||
var orderInfo = &gmodel.FsOrder{}
|
||||
var orderStatus int64
|
||||
var orderIsPartPay int64
|
||||
var orderPayedAmount int64
|
||||
var orderIsPayCompleted int64
|
||||
// 支付记录是首款
|
||||
if *payInfo.PayStage == int64(constants.PAYSTAGE_DEPOSIT) {
|
||||
orderStatus = int64(constants.STATUS_NEW_PART_PAY)
|
||||
orderIsPartPay = 1
|
||||
orderInfo.IsPartPay = &orderIsPartPay
|
||||
orderPayedAmount = paymentIntent.Amount
|
||||
// var orderInfo = &gmodel.FsOrder{}
|
||||
// var orderStatus int64
|
||||
// var orderIsPartPay int64
|
||||
// var orderPayedAmount int64
|
||||
// var orderIsPayCompleted int64
|
||||
// // 支付记录是首款
|
||||
// if *payInfo.PayStage == int64(constants.PAYSTAGE_DEPOSIT) {
|
||||
// orderStatus = int64(constants.STATUS_NEW_PART_PAY)
|
||||
// orderIsPartPay = 1
|
||||
// orderInfo.IsPartPay = &orderIsPartPay
|
||||
// orderPayedAmount = paymentIntent.Amount
|
||||
|
||||
// 删除购物车
|
||||
cartModelT := gmodel.NewFsCartModel(connGorm)
|
||||
cartModelTRSB := cartModelT.BuilderTrans(ctx, nil)
|
||||
err = cartModelT.RBDeleteCartsByIds(cartModelTRSB, cartIds)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
// // 删除购物车
|
||||
// cartModelT := gmodel.NewFsCartModel(connGorm)
|
||||
// cartModelTRSB := cartModelT.BuilderTrans(ctx, nil)
|
||||
// err = cartModelT.RBDeleteCartsByIds(cartModelTRSB, cartIds)
|
||||
// if err != nil {
|
||||
// return err
|
||||
// }
|
||||
// }
|
||||
|
||||
// 支付记录是尾款
|
||||
if *payInfo.PayStage == int64(constants.PAYSTAGE_REMAINING) {
|
||||
if *fsOrderRelInfo.Status < int64(constants.STATUS_NEW_PAY_COMPLETED) {
|
||||
orderStatus = int64(constants.STATUS_NEW_PAY_COMPLETED)
|
||||
}
|
||||
orderIsPayCompleted = 1
|
||||
orderInfo.IsPayCompleted = &orderIsPayCompleted
|
||||
orderPayedAmount = *fsOrderRelInfo.PayedAmount + paymentIntent.Amount
|
||||
}
|
||||
// // 支付记录是尾款
|
||||
// if *payInfo.PayStage == int64(constants.PAYSTAGE_REMAINING) {
|
||||
// if *fsOrderRelInfo.Status < int64(constants.STATUS_NEW_PAY_COMPLETED) {
|
||||
// orderStatus = int64(constants.STATUS_NEW_PAY_COMPLETED)
|
||||
// }
|
||||
// orderIsPayCompleted = 1
|
||||
// orderInfo.IsPayCompleted = &orderIsPayCompleted
|
||||
// orderPayedAmount = *fsOrderRelInfo.PayedAmount + paymentIntent.Amount
|
||||
// }
|
||||
|
||||
// 更新订单信息
|
||||
orderInfo.Id = fsOrderRelInfo.Id
|
||||
orderInfo.Status = &orderStatus
|
||||
orderInfo.Ptime = &nowTime
|
||||
orderInfo.PayedAmount = &orderPayedAmount
|
||||
orderModelT := gmodel.NewFsOrderModel(connGorm)
|
||||
err = orderModelT.RBUpdate(ctx, orderInfo)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
return err
|
||||
})
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
// // 更新订单信息
|
||||
// orderInfo.Id = fsOrderRelInfo.Id
|
||||
// orderInfo.Status = &orderStatus
|
||||
// orderInfo.Ptime = &nowTime
|
||||
// orderInfo.PayedAmount = &orderPayedAmount
|
||||
// orderModelT := gmodel.NewFsOrderModel(connGorm)
|
||||
// err = orderModelT.RBUpdate(ctx, orderInfo)
|
||||
// if err != nil {
|
||||
// return err
|
||||
// }
|
||||
// return err
|
||||
// })
|
||||
// if err != nil {
|
||||
// return err
|
||||
// }
|
||||
|
||||
//千人千面的处理
|
||||
// $renderServer = (new RenderService());
|
||||
// $renderServer->thousandsFacesV2($order->id);
|
||||
// //清除用户最新的设计
|
||||
// $cache = \Yii::$app->cache;
|
||||
// $cache->delete(CacheConfigHelper::LAST_DESIGN . $order->user_id);
|
||||
// //缓存最新订单编号
|
||||
// $cache->set(CacheConfigHelper::USER_ORDERNO . $order->user_id, $order->sn);
|
||||
// //千人千面的处理
|
||||
// // $renderServer = (new RenderService());
|
||||
// // $renderServer->thousandsFacesV2($order->id);
|
||||
// // //清除用户最新的设计
|
||||
// // $cache = \Yii::$app->cache;
|
||||
// // $cache->delete(CacheConfigHelper::LAST_DESIGN . $order->user_id);
|
||||
// // //缓存最新订单编号
|
||||
// // $cache->set(CacheConfigHelper::USER_ORDERNO . $order->user_id, $order->sn);
|
||||
|
||||
// //查询用户邮箱信息
|
||||
// $user = \api\models\User::find()->where(['id' => $order->user_id])->one();
|
||||
// $redisData = [
|
||||
// 'key' => 'receipt_download',
|
||||
// 'param' => [
|
||||
// 'email' => $user->email,
|
||||
// 'order_id' => $order->id,
|
||||
// 'pay_id' => $pay->id,
|
||||
// 'type' => 1,//付款成功为1
|
||||
// ]
|
||||
// ];
|
||||
// Email::timely($redisData);
|
||||
}
|
||||
// // //查询用户邮箱信息
|
||||
// // $user = \api\models\User::find()->where(['id' => $order->user_id])->one();
|
||||
// // $redisData = [
|
||||
// // 'key' => 'receipt_download',
|
||||
// // 'param' => [
|
||||
// // 'email' => $user->email,
|
||||
// // 'order_id' => $order->id,
|
||||
// // 'pay_id' => $pay->id,
|
||||
// // 'type' => 1,//付款成功为1
|
||||
// // ]
|
||||
// // ];
|
||||
// // Email::timely($redisData);
|
||||
// }
|
||||
|
||||
// 订单记录
|
||||
return nil
|
||||
|
|
|
@ -2,11 +2,10 @@ package logic
|
|||
|
||||
import (
|
||||
"context"
|
||||
"encoding/json"
|
||||
"errors"
|
||||
"fusenapi/constants"
|
||||
"fusenapi/utils/auth"
|
||||
"fusenapi/utils/basic"
|
||||
|
||||
"gorm.io/gorm"
|
||||
|
||||
"fusenapi/server/product/internal/svc"
|
||||
|
@ -47,64 +46,64 @@ func (l *GetLastProductDesignLogic) GetLastProductDesign(req *types.Request, use
|
|||
return resp.SetStatusWithMessage(basic.CodeOK, "success:IsOpenRender switch is closed")
|
||||
}
|
||||
//查询用户最近下单成功的数据
|
||||
orderInfo, err := l.svcCtx.AllModels.FsOrder.FindLastSuccessOneOrder(l.ctx, user.Id, int64(constants.STATUS_NEW_NOT_PAY))
|
||||
if err != nil {
|
||||
if errors.Is(err, gorm.ErrRecordNotFound) {
|
||||
return resp.SetStatusWithMessage(basic.CodeDbRecordNotFoundErr, "none of order is found")
|
||||
}
|
||||
logx.Error(err)
|
||||
return resp.SetStatusAddMessage(basic.CodeDbSqlErr, "failed to get your last order")
|
||||
}
|
||||
// orderInfo, err := l.svcCtx.AllModels.FsOrder.FindLastSuccessOneOrder(l.ctx, user.Id, int64(constants.STATUS_NEW_NOT_PAY))
|
||||
// if err != nil {
|
||||
// if errors.Is(err, gorm.ErrRecordNotFound) {
|
||||
// return resp.SetStatusWithMessage(basic.CodeDbRecordNotFoundErr, "none of order is found")
|
||||
// }
|
||||
// logx.Error(err)
|
||||
// return resp.SetStatusAddMessage(basic.CodeDbSqlErr, "failed to get your last order")
|
||||
// }
|
||||
//获取该订单相关设计信息
|
||||
orderDetail, err := l.svcCtx.AllModels.FsOrderDetail.GetOneOrderDetailByOrderId(l.ctx, orderInfo.Id)
|
||||
if err != nil {
|
||||
if errors.Is(err, gorm.ErrRecordNotFound) {
|
||||
return resp.SetStatusWithMessage(basic.CodeDbRecordNotFoundErr, "order detail is not found")
|
||||
}
|
||||
logx.Error(err)
|
||||
return resp.SetStatusAddMessage(basic.CodeDbSqlErr, "failed to get order detail")
|
||||
}
|
||||
//获取设计模板详情,便于获得design_id
|
||||
orderDetailTemplate, err := l.svcCtx.AllModels.FsOrderDetailTemplate.FindOne(l.ctx, *orderDetail.OrderDetailTemplateId)
|
||||
if err != nil {
|
||||
if errors.Is(err, gorm.ErrRecordNotFound) {
|
||||
return resp.SetStatusWithMessage(basic.CodeDbRecordNotFoundErr, "order detail template is not found")
|
||||
}
|
||||
logx.Error(err)
|
||||
return resp.SetStatusWithMessage(basic.CodeDbSqlErr, "failed to get order detail template")
|
||||
}
|
||||
// orderDetail, err := l.svcCtx.AllModels.FsOrderDetail.GetOneOrderDetailByOrderId(l.ctx, orderInfo.Id)
|
||||
// if err != nil {
|
||||
// if errors.Is(err, gorm.ErrRecordNotFound) {
|
||||
// return resp.SetStatusWithMessage(basic.CodeDbRecordNotFoundErr, "order detail is not found")
|
||||
// }
|
||||
// logx.Error(err)
|
||||
// return resp.SetStatusAddMessage(basic.CodeDbSqlErr, "failed to get order detail")
|
||||
// }
|
||||
// //获取设计模板详情,便于获得design_id
|
||||
// orderDetailTemplate, err := l.svcCtx.AllModels.FsOrderDetailTemplate.FindOne(l.ctx, *orderDetail.OrderDetailTemplateId)
|
||||
// if err != nil {
|
||||
// if errors.Is(err, gorm.ErrRecordNotFound) {
|
||||
// return resp.SetStatusWithMessage(basic.CodeDbRecordNotFoundErr, "order detail template is not found")
|
||||
// }
|
||||
// logx.Error(err)
|
||||
// return resp.SetStatusWithMessage(basic.CodeDbSqlErr, "failed to get order detail template")
|
||||
// }
|
||||
//最后一次设计不存在,则不返回该设计相关数据
|
||||
if *orderDetailTemplate.DesignId <= 0 {
|
||||
return resp.SetStatusWithMessage(basic.CodeOK, "success:last design id is not set")
|
||||
}
|
||||
// if *orderDetailTemplate.DesignId <= 0 {
|
||||
// return resp.SetStatusWithMessage(basic.CodeOK, "success:last design id is not set")
|
||||
// }
|
||||
//获取设计数据
|
||||
productDesign, err := l.svcCtx.AllModels.FsProductDesign.FindOne(l.ctx, *orderDetailTemplate.DesignId, user.Id)
|
||||
if err != nil {
|
||||
if errors.Is(err, gorm.ErrRecordNotFound) {
|
||||
return resp.SetStatusWithMessage(basic.CodeDbRecordNotFoundErr, "product design is not found")
|
||||
}
|
||||
logx.Error(err)
|
||||
return resp.SetStatusWithMessage(basic.CodeDbSqlErr, "failed to get product design")
|
||||
}
|
||||
var info interface{}
|
||||
if productDesign.Info != nil && *productDesign.Info != "" {
|
||||
if err := json.Unmarshal([]byte(*productDesign.Info), &info); err != nil {
|
||||
logx.Error(err)
|
||||
return nil
|
||||
}
|
||||
}
|
||||
var logoColor interface{}
|
||||
if productDesign.LogoColor != nil && *productDesign.LogoColor != "" {
|
||||
if err := json.Unmarshal([]byte(*productDesign.LogoColor), &logoColor); err != nil {
|
||||
logx.Error(err)
|
||||
return nil
|
||||
}
|
||||
}
|
||||
// productDesign, err := l.svcCtx.AllModels.FsProductDesign.FindOne(l.ctx, *orderDetailTemplate.DesignId, user.Id)
|
||||
// if err != nil {
|
||||
// if errors.Is(err, gorm.ErrRecordNotFound) {
|
||||
// return resp.SetStatusWithMessage(basic.CodeDbRecordNotFoundErr, "product design is not found")
|
||||
// }
|
||||
// logx.Error(err)
|
||||
// return resp.SetStatusWithMessage(basic.CodeDbSqlErr, "failed to get product design")
|
||||
// }
|
||||
// var info interface{}
|
||||
// if productDesign.Info != nil && *productDesign.Info != "" {
|
||||
// if err := json.Unmarshal([]byte(*productDesign.Info), &info); err != nil {
|
||||
// logx.Error(err)
|
||||
// return nil
|
||||
// }
|
||||
// }
|
||||
// var logoColor interface{}
|
||||
// if productDesign.LogoColor != nil && *productDesign.LogoColor != "" {
|
||||
// if err := json.Unmarshal([]byte(*productDesign.LogoColor), &logoColor); err != nil {
|
||||
// logx.Error(err)
|
||||
// return nil
|
||||
// }
|
||||
// }
|
||||
return resp.SetStatusWithMessage(basic.CodeOK, "success", types.GetLastProductDesignRsp{
|
||||
Id: productDesign.Id,
|
||||
OptionalId: *productDesign.OptionalId,
|
||||
SizeId: *productDesign.SizeId,
|
||||
LogoColor: logoColor,
|
||||
Info: info,
|
||||
Id: 1,
|
||||
OptionalId: 1,
|
||||
SizeId: 1,
|
||||
LogoColor: 1,
|
||||
Info: nil,
|
||||
})
|
||||
}
|
||||
|
|
|
@ -8,10 +8,11 @@ import (
|
|||
"fusenapi/utils/basic"
|
||||
"fusenapi/utils/format"
|
||||
"fusenapi/utils/step_price"
|
||||
"gorm.io/gorm"
|
||||
"sort"
|
||||
"strings"
|
||||
|
||||
"gorm.io/gorm"
|
||||
|
||||
"context"
|
||||
|
||||
"fusenapi/server/product/internal/svc"
|
||||
|
|
|
@ -14,10 +14,11 @@ import (
|
|||
"fusenapi/utils/format"
|
||||
"fusenapi/utils/image"
|
||||
"fusenapi/utils/step_price"
|
||||
"gorm.io/gorm"
|
||||
"strconv"
|
||||
"strings"
|
||||
|
||||
"gorm.io/gorm"
|
||||
|
||||
"fusenapi/server/product/internal/svc"
|
||||
"fusenapi/server/product/internal/types"
|
||||
|
||||
|
@ -460,66 +461,66 @@ func (l *GetProductInfoLogic) getRenderDesign(clientNo string) interface{} {
|
|||
// 获取用户最新设计
|
||||
func (l *GetProductInfoLogic) getLastDesign(userInfo gmodel.FsUser) interface{} {
|
||||
//查询用户最近下单成功的数据
|
||||
orderInfo, err := l.svcCtx.AllModels.FsOrder.FindLastSuccessOneOrder(l.ctx, userInfo.Id, int64(constants.STATUS_NEW_NOT_PAY))
|
||||
if err != nil {
|
||||
if errors.Is(err, gorm.ErrRecordNotFound) {
|
||||
return nil
|
||||
}
|
||||
logx.Error(err)
|
||||
return nil
|
||||
}
|
||||
// orderInfo, err := l.svcCtx.AllModels.FsOrder.FindLastSuccessOneOrder(l.ctx, userInfo.Id, int64(constants.STATUS_NEW_NOT_PAY))
|
||||
// if err != nil {
|
||||
// if errors.Is(err, gorm.ErrRecordNotFound) {
|
||||
// return nil
|
||||
// }
|
||||
// logx.Error(err)
|
||||
// return nil
|
||||
// }
|
||||
//获取该订单相关设计信息
|
||||
orderDetail, err := l.svcCtx.AllModels.FsOrderDetail.GetOneOrderDetailByOrderId(l.ctx, orderInfo.Id)
|
||||
if err != nil {
|
||||
if errors.Is(err, gorm.ErrRecordNotFound) {
|
||||
return nil
|
||||
}
|
||||
logx.Error(err)
|
||||
return nil
|
||||
}
|
||||
//获取设计模板详情,便于获得design_id
|
||||
orderDetailTemplate, err := l.svcCtx.AllModels.FsOrderDetailTemplate.FindOne(l.ctx, *orderDetail.OrderDetailTemplateId)
|
||||
if err != nil {
|
||||
if errors.Is(err, gorm.ErrRecordNotFound) {
|
||||
return nil
|
||||
}
|
||||
logx.Error(err)
|
||||
return nil
|
||||
}
|
||||
// orderDetail, err := l.svcCtx.AllModels.FsOrderDetail.GetOneOrderDetailByOrderId(l.ctx, orderInfo.Id)
|
||||
// if err != nil {
|
||||
// if errors.Is(err, gorm.ErrRecordNotFound) {
|
||||
// return nil
|
||||
// }
|
||||
// logx.Error(err)
|
||||
// return nil
|
||||
// }
|
||||
// //获取设计模板详情,便于获得design_id
|
||||
// orderDetailTemplate, err := l.svcCtx.AllModels.FsOrderDetailTemplate.FindOne(l.ctx, *orderDetail.OrderDetailTemplateId)
|
||||
// if err != nil {
|
||||
// if errors.Is(err, gorm.ErrRecordNotFound) {
|
||||
// return nil
|
||||
// }
|
||||
// logx.Error(err)
|
||||
// return nil
|
||||
// }
|
||||
//若没打开了个性化渲染按钮或者最后一次设计不存在,则不返回该设计相关数据
|
||||
if *userInfo.IsOpenRender != 1 || *orderDetailTemplate.DesignId <= 0 {
|
||||
return nil
|
||||
}
|
||||
//获取设计数据
|
||||
productDesign, err := l.svcCtx.AllModels.FsProductDesign.FindOne(l.ctx, *orderDetailTemplate.DesignId, userInfo.Id)
|
||||
if err != nil {
|
||||
if errors.Is(err, gorm.ErrRecordNotFound) {
|
||||
return nil
|
||||
}
|
||||
logx.Error(err)
|
||||
return nil
|
||||
}
|
||||
var info interface{}
|
||||
if productDesign.Info != nil && *productDesign.Info != "" {
|
||||
if err := json.Unmarshal([]byte(*productDesign.Info), &info); err != nil {
|
||||
logx.Error(err)
|
||||
return nil
|
||||
}
|
||||
}
|
||||
var logoColor interface{}
|
||||
if productDesign.LogoColor != nil && *productDesign.LogoColor != "" {
|
||||
if err := json.Unmarshal([]byte(*productDesign.LogoColor), &logoColor); err != nil {
|
||||
logx.Error(err)
|
||||
return nil
|
||||
}
|
||||
}
|
||||
// if *userInfo.IsOpenRender != 1 || *orderDetailTemplate.DesignId <= 0 {
|
||||
// return nil
|
||||
// }
|
||||
// //获取设计数据
|
||||
// productDesign, err := l.svcCtx.AllModels.FsProductDesign.FindOne(l.ctx, *orderDetailTemplate.DesignId, userInfo.Id)
|
||||
// if err != nil {
|
||||
// if errors.Is(err, gorm.ErrRecordNotFound) {
|
||||
// return nil
|
||||
// }
|
||||
// logx.Error(err)
|
||||
// return nil
|
||||
// }
|
||||
// var info interface{}
|
||||
// if productDesign.Info != nil && *productDesign.Info != "" {
|
||||
// if err := json.Unmarshal([]byte(*productDesign.Info), &info); err != nil {
|
||||
// logx.Error(err)
|
||||
// return nil
|
||||
// }
|
||||
// }
|
||||
// var logoColor interface{}
|
||||
// if productDesign.LogoColor != nil && *productDesign.LogoColor != "" {
|
||||
// if err := json.Unmarshal([]byte(*productDesign.LogoColor), &logoColor); err != nil {
|
||||
// logx.Error(err)
|
||||
// return nil
|
||||
// }
|
||||
// }
|
||||
return map[string]interface{}{
|
||||
"id": productDesign.Id,
|
||||
"info": info,
|
||||
"logo_color": logoColor,
|
||||
"material_id": *productDesign.MaterialId,
|
||||
"optional_id": *productDesign.OptionalId,
|
||||
"size_id": *productDesign.SizeId,
|
||||
"id": 1,
|
||||
"info": 1,
|
||||
"logo_color": 1,
|
||||
"material_id": 1,
|
||||
"optional_id": 1,
|
||||
"size_id": 1,
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -2,14 +2,14 @@ package logic
|
|||
|
||||
import (
|
||||
"errors"
|
||||
"fusenapi/constants"
|
||||
"fusenapi/model/gmodel"
|
||||
"fusenapi/utils/auth"
|
||||
"fusenapi/utils/basic"
|
||||
"fusenapi/utils/color_list"
|
||||
"gorm.io/gorm"
|
||||
"strings"
|
||||
|
||||
"gorm.io/gorm"
|
||||
|
||||
"context"
|
||||
|
||||
"fusenapi/server/product/internal/svc"
|
||||
|
@ -126,28 +126,28 @@ func (l *GetRenderSettingByPidLogic) checkRenderDesign(clientNo string) (bool, e
|
|||
// 查询是否存在最新设计
|
||||
func (l *GetRenderSettingByPidLogic) checkLastDesignExists(userId int64) (bool, error) {
|
||||
//查询用户最近下单成功的数据
|
||||
orderInfo, err := l.svcCtx.AllModels.FsOrder.FindLastSuccessOneOrder(l.ctx, userId, int64(constants.STATUS_NEW_NOT_PAY))
|
||||
if err != nil {
|
||||
if errors.Is(err, gorm.ErrRecordNotFound) {
|
||||
return false, nil
|
||||
}
|
||||
return false, err
|
||||
}
|
||||
// orderInfo, err := l.svcCtx.AllModels.FsOrder.FindLastSuccessOneOrder(l.ctx, userId, int64(constants.STATUS_NEW_NOT_PAY))
|
||||
// if err != nil {
|
||||
// if errors.Is(err, gorm.ErrRecordNotFound) {
|
||||
// return false, nil
|
||||
// }
|
||||
// return false, err
|
||||
// }
|
||||
//获取该订单相关设计信息
|
||||
orderDetail, err := l.svcCtx.AllModels.FsOrderDetail.GetOneOrderDetailByOrderId(l.ctx, orderInfo.Id)
|
||||
if err != nil {
|
||||
if errors.Is(err, gorm.ErrRecordNotFound) {
|
||||
// orderDetail, err := l.svcCtx.AllModels.FsOrderDetail.GetOneOrderDetailByOrderId(l.ctx, orderInfo.Id)
|
||||
// if err != nil {
|
||||
// if errors.Is(err, gorm.ErrRecordNotFound) {
|
||||
// return false, nil
|
||||
// }
|
||||
// return false, err
|
||||
// }
|
||||
// //获取设计模板详情,便于获得design_id
|
||||
// orderDetailTemplate, err := l.svcCtx.AllModels.FsOrderDetailTemplate.FindOne(l.ctx, *orderDetail.OrderDetailTemplateId)
|
||||
// if err != nil {
|
||||
// if errors.Is(err, gorm.ErrRecordNotFound) {
|
||||
// return false, nil
|
||||
// }
|
||||
// return false, err
|
||||
// }
|
||||
return false, nil
|
||||
}
|
||||
return false, err
|
||||
}
|
||||
//获取设计模板详情,便于获得design_id
|
||||
orderDetailTemplate, err := l.svcCtx.AllModels.FsOrderDetailTemplate.FindOne(l.ctx, *orderDetail.OrderDetailTemplateId)
|
||||
if err != nil {
|
||||
if errors.Is(err, gorm.ErrRecordNotFound) {
|
||||
return false, nil
|
||||
}
|
||||
return false, err
|
||||
}
|
||||
return *orderDetailTemplate.DesignId > 0, nil
|
||||
}
|
||||
|
|
|
@ -33,7 +33,6 @@ type File {
|
|||
Data []byte `fsfile:"data"`
|
||||
}
|
||||
|
||||
|
||||
// 统一分页
|
||||
type Meta struct {
|
||||
TotalCount int64 `json:"totalCount"`
|
||||
|
@ -41,3 +40,185 @@ type Meta struct {
|
|||
CurrentPage int `json:"currentPage"`
|
||||
PerPage int `json:"perPage"`
|
||||
}
|
||||
|
||||
type ProductLogoResource struct {
|
||||
ResourceID string `json:"resource_id"`
|
||||
ResourceType string `json:"resource_type"`
|
||||
ResourceURL string `json:"resource_url"`
|
||||
Metadata map[string]int64erface{} `json:"metadata"`
|
||||
}
|
||||
type ProductSnapshot struct {
|
||||
}
|
||||
type TemplateInfo struct {
|
||||
TemplateJSON string `json:"template_json"`
|
||||
TemplateTag string `json:"template_tag"`
|
||||
}
|
||||
type ModelInfo struct {
|
||||
ModelJSON string `json:"model_json"`
|
||||
}
|
||||
type FittingInfo struct {
|
||||
FittingJSON string `json:"fitting_json"`
|
||||
}
|
||||
type SizeInfo struct {
|
||||
Inch string `json:"inch"`
|
||||
Cm string `json:"cm"`
|
||||
}
|
||||
type UserDiyInformation struct {
|
||||
Phone string `json:"phone"`
|
||||
Address string `json:"address"`
|
||||
Website string `json:"website"`
|
||||
Qrcode string `json:"qrcode"`
|
||||
Slogan string `json:"slogan"`
|
||||
}
|
||||
type Snapshot struct {
|
||||
Logo string `json:"logo"`
|
||||
CombineImage string `json:"combine_image"`
|
||||
RenderImage string `json:"render_image"`
|
||||
TemplateInfo TemplateInfo `json:"template_info"`
|
||||
ModelInfo ModelInfo `json:"model_info"`
|
||||
FittingInfo FittingInfo `json:"fitting_info"`
|
||||
SizeInfo SizeInfo `json:"size_info"`
|
||||
UserDiyInformation UserDiyInformation `json:"user_diy_information"`
|
||||
}
|
||||
type ShoppingCartSnapshot struct {
|
||||
ID int64 `json:"id"`
|
||||
UserID int64 `json:"user_id"`
|
||||
ProductID int64 `json:"product_id"`
|
||||
TemplateID int64 `json:"template_id"`
|
||||
ModelID int64 `json:"model_id"`
|
||||
SizeID int64 `json:"size_id"`
|
||||
FittingID int64 `json:"fitting_id"`
|
||||
PurchaseQuantity int64 `json:"purchase_quantity"`
|
||||
Snapshot Snapshot `json:"snapshot"`
|
||||
IsHighlyCustomized int64 `json:"is_highly_customized"`
|
||||
Ctime string `json:"ctime"`
|
||||
Utime string `json:"utime"`
|
||||
}
|
||||
type OrderProduct struct {
|
||||
ProductID string `json:"product_id"`
|
||||
ProductName string `json:"product_name"`
|
||||
ProductPrice string `json:"product_price"`
|
||||
ProductLogo string `json:"product_logo"`
|
||||
ProductLogoResource ProductLogoResource `json:"product_logo_resource"`
|
||||
ProductSnapshot ProductSnapshot `json:"product_snapshot"`
|
||||
Number int64 `json:"number"`
|
||||
Amount string `json:"amount"`
|
||||
Unit string `json:"unit"`
|
||||
ExpectedDeliveryTime string `json:"expected_delivery_time"`
|
||||
ShoppingCartSnapshot ShoppingCartSnapshot `json:"shopping_cart_snapshot"`
|
||||
}
|
||||
type Children struct {
|
||||
}
|
||||
type Status struct {
|
||||
StatusCode int64 `json:"status_code"`
|
||||
StatusTitle string `json:"status_title"`
|
||||
ExpectedTime string `json:"expected_time"`
|
||||
Ctime string `json:"ctime"`
|
||||
Utime string `json:"utime"`
|
||||
Metadata map[string]int64erface{} `json:"metadata"`
|
||||
Children []Children `json:"children"`
|
||||
}
|
||||
type OrderStatus struct {
|
||||
StatusCode int64 `json:"status_code"`
|
||||
StatusTitle string `json:"status_title"`
|
||||
ExpectedTime string `json:"expected_time"`
|
||||
Ctime string `json:"ctime"`
|
||||
Utime string `json:"utime"`
|
||||
Metadata map[string]int64erface{} `json:"metadata"`
|
||||
Children []Children `json:"children"`
|
||||
}
|
||||
type OrderInfo struct {
|
||||
OrderNo string `json:"order_no"`
|
||||
DeliveryMethod int64 `json:"delivery_method"`
|
||||
Ctime string `json:"ctime"`
|
||||
Utime string `json:"utime"`
|
||||
Status OrderStatus `json:"status"`
|
||||
StatusLink []OrderStatus `json:"status_link"`
|
||||
Metadata map[string]int64erface{} `json:"metadata"`
|
||||
}
|
||||
type Subtotal struct {
|
||||
Currency string `json:"currency"`
|
||||
Current string `json:"current"`
|
||||
Initiate string `json:"initiate"`
|
||||
Change string `json:"change"`
|
||||
ChangeRemark string `json:"change_remark"`
|
||||
Metadata map[string]int64erface{} `json:"metadata"`
|
||||
}
|
||||
type ShippingFee struct {
|
||||
Currency string `json:"currency"`
|
||||
Current string `json:"current"`
|
||||
Initiate string `json:"initiate"`
|
||||
Change string `json:"change"`
|
||||
ChangeRemark string `json:"change_remark"`
|
||||
Metadata map[string]int64erface{} `json:"metadata"`
|
||||
}
|
||||
type Tax struct {
|
||||
Currency string `json:"currency"`
|
||||
Current string `json:"current"`
|
||||
Initiate string `json:"initiate"`
|
||||
Change string `json:"change"`
|
||||
ChangeRemark string `json:"change_remark"`
|
||||
Metadata map[string]int64erface{} `json:"metadata"`
|
||||
}
|
||||
type Discount struct {
|
||||
Currency string `json:"currency"`
|
||||
Current string `json:"current"`
|
||||
Initiate string `json:"initiate"`
|
||||
Change string `json:"change"`
|
||||
ChangeRemark string `json:"change_remark"`
|
||||
Metadata map[string]int64erface{} `json:"metadata"`
|
||||
}
|
||||
type Total struct {
|
||||
Currency string `json:"currency"`
|
||||
Current string `json:"current"`
|
||||
Initiate string `json:"initiate"`
|
||||
Change string `json:"change"`
|
||||
ChangeRemark string `json:"change_remark"`
|
||||
Metadata map[string]int64erface{} `json:"metadata"`
|
||||
}
|
||||
type PayStatus struct {
|
||||
StatusCode int64 `json:"status_code"`
|
||||
StatusTitle string `json:"status_title"`
|
||||
Metadata map[string]int64erface{} `json:"metadata"`
|
||||
}
|
||||
|
||||
type PayAmount struct {
|
||||
Currency string `json:"currency"`
|
||||
Current string `json:"current"`
|
||||
Initiate string `json:"initiate"`
|
||||
Change string `json:"change"`
|
||||
ChangeRemark string `json:"change_remark"`
|
||||
Metadata map[string]int64erface{} `json:"metadata"`
|
||||
}
|
||||
type Deposit struct {
|
||||
TradeNo string `json:"trade_no"`
|
||||
Status Status `json:"status"`
|
||||
StatusLink []PayStatus `json:"status_link"`
|
||||
PayTime string `json:"pay_time"`
|
||||
PayAmount PayAmount `json:"pay_amount"`
|
||||
PayMethod string `json:"pay_method"`
|
||||
Metadata map[string]int64erface{} `json:"metadata"`
|
||||
}
|
||||
type RemainingBalance struct {
|
||||
TradeNo string `json:"trade_no"`
|
||||
Status PayStatus `json:"status"`
|
||||
StatusLink []PayStatus `json:"status_link"`
|
||||
PayTime string `json:"pay_time"`
|
||||
PayAmount PayAmount `json:"pay_amount"`
|
||||
PayMethod string `json:"pay_method"`
|
||||
Metadata map[string]int64erface{} `json:"metadata"`
|
||||
}
|
||||
type OrderAmount struct {
|
||||
Subtotal Subtotal `json:"subtotal"`
|
||||
ShippingFee ShippingFee `json:"shipping_fee"`
|
||||
Tax Tax `json:"tax"`
|
||||
Discount Discount `json:"discount"`
|
||||
Total Total `json:"total"`
|
||||
Deposit Deposit `json:"deposit"`
|
||||
RemainingBalance RemainingBalance `json:"remaining_balance"`
|
||||
}
|
||||
type DeliveryAddres struct {
|
||||
Address string `json:"address"`
|
||||
Name string `json:"name"`
|
||||
Mobile string `json:"mobile"`
|
||||
}
|
217
server_api/orders.api
Normal file
217
server_api/orders.api
Normal file
|
@ -0,0 +1,217 @@
|
|||
syntax = "v1"
|
||||
|
||||
info (
|
||||
title: "订单模块"
|
||||
desc: "订单相关"
|
||||
author: ""
|
||||
email: ""
|
||||
)
|
||||
|
||||
import "basic.api"
|
||||
|
||||
service orders {
|
||||
|
||||
@handler CreateOrderHandler
|
||||
post /api/orders/create(CreateOrderReq) returns (response);
|
||||
|
||||
@handler CreatePrePaymentHandler
|
||||
post /api/orders/create-prepayment(OrderRefundReq) returns (response);
|
||||
|
||||
@handler OrderListHandler
|
||||
post /api/orders/list(OrderListReq) returns (response);
|
||||
|
||||
}
|
||||
|
||||
type CreateOrderReq struct {
|
||||
CartIds []int64 `json:"cart_ids"`
|
||||
DeliveryMethod string `json:"delivery_method"`
|
||||
}
|
||||
|
||||
type OrderRefundReq struct {
|
||||
OrderNo string `json:"order_no"`
|
||||
DeliveryMethod int64 `json:"delivery_method"`
|
||||
DeliveryAddres DeliveryAddres `json:"delivery_addres"`
|
||||
}
|
||||
type DeliveryAddres struct {
|
||||
Address string `json:"address"`
|
||||
Name string `json:"name"`
|
||||
Mobile string `json:"mobile"`
|
||||
}
|
||||
|
||||
type OrderDetail struct {
|
||||
OrderProduct []OrderProduct `json:"order_product"`
|
||||
OrderInfo OrderInfo `json:"order_info"`
|
||||
OrderAmount OrderAmount `json:"order_amount"`
|
||||
DeliveryAddres DeliveryAddres `json:"delivery_addres"`
|
||||
}
|
||||
|
||||
type ProductLogoResource struct {
|
||||
ResourceID string `json:"resource_id"`
|
||||
ResourceType string `json:"resource_type"`
|
||||
ResourceURL string `json:"resource_url"`
|
||||
Metadata map[string]interface{} `json:"metadata"`
|
||||
}
|
||||
|
||||
type TemplateInfo struct {
|
||||
TemplateJSON string `json:"template_json"`
|
||||
TemplateTag string `json:"template_tag"`
|
||||
}
|
||||
type ModelInfo struct {
|
||||
ModelJSON string `json:"model_json"`
|
||||
}
|
||||
type FittingInfo struct {
|
||||
FittingJSON string `json:"fitting_json"`
|
||||
}
|
||||
type SizeInfo struct {
|
||||
Inch string `json:"inch"`
|
||||
Cm string `json:"cm"`
|
||||
}
|
||||
type UserDiyInformation struct {
|
||||
Phone string `json:"phone"`
|
||||
Address string `json:"address"`
|
||||
Website string `json:"website"`
|
||||
Qrcode string `json:"qrcode"`
|
||||
Slogan string `json:"slogan"`
|
||||
}
|
||||
type Snapshot struct {
|
||||
Logo string `json:"logo"`
|
||||
CombineImage string `json:"combine_image"`
|
||||
RenderImage string `json:"render_image"`
|
||||
TemplateInfo TemplateInfo `json:"template_info"`
|
||||
ModelInfo ModelInfo `json:"model_info"`
|
||||
FittingInfo FittingInfo `json:"fitting_info"`
|
||||
SizeInfo SizeInfo `json:"size_info"`
|
||||
UserDiyInformation UserDiyInformation `json:"user_diy_information"`
|
||||
}
|
||||
type ShoppingCartSnapshot struct {
|
||||
ID int64 `json:"id"`
|
||||
UserID int64 `json:"user_id"`
|
||||
ProductID int64 `json:"product_id"`
|
||||
TemplateID int64 `json:"template_id"`
|
||||
ModelID int64 `json:"model_id"`
|
||||
SizeID int64 `json:"size_id"`
|
||||
FittingID int64 `json:"fitting_id"`
|
||||
PurchaseQuantity int64 `json:"purchase_quantity"`
|
||||
Snapshot Snapshot `json:"snapshot"`
|
||||
IsHighlyCustomized int64 `json:"is_highly_customized"`
|
||||
Ctime string `json:"ctime"`
|
||||
Utime string `json:"utime"`
|
||||
}
|
||||
type OrderProduct struct {
|
||||
ProductID string `json:"product_id"`
|
||||
ProductName string `json:"product_name"`
|
||||
ProductPrice string `json:"product_price"`
|
||||
ProductLogo string `json:"product_logo"`
|
||||
ProductLogoResource ProductLogoResource `json:"product_logo_resource"`
|
||||
ProductSnapshot map[string]interface{} `json:"product_snapshot"`
|
||||
Number int64 `json:"number"`
|
||||
Amount string `json:"amount"`
|
||||
Unit string `json:"unit"`
|
||||
ExpectedDeliveryTime string `json:"expected_delivery_time"`
|
||||
ShoppingCartSnapshot ShoppingCartSnapshot `json:"shopping_cart_snapshot"`
|
||||
}
|
||||
|
||||
type OrderStatus struct {
|
||||
StatusCode int64 `json:"status_code"`
|
||||
StatusTitle string `json:"status_title"`
|
||||
ExpectedTime string `json:"expected_time"`
|
||||
Ctime string `json:"ctime"`
|
||||
Utime string `json:"utime"`
|
||||
Metadata map[string]interface{} `json:"metadata"`
|
||||
Children []*OrderStatus `json:"children"`
|
||||
}
|
||||
type OrderInfo struct {
|
||||
OrderNo string `json:"order_no"`
|
||||
DeliveryMethod int64 `json:"delivery_method"`
|
||||
Ctime string `json:"ctime"`
|
||||
Utime string `json:"utime"`
|
||||
Status OrderStatus `json:"status"`
|
||||
StatusLink []OrderStatus `json:"status_link"`
|
||||
Metadata map[string]interface{} `json:"metadata"`
|
||||
}
|
||||
type Subtotal struct {
|
||||
Currency string `json:"currency"`
|
||||
Current string `json:"current"`
|
||||
Initiate string `json:"initiate"`
|
||||
Change string `json:"change"`
|
||||
ChangeRemark string `json:"change_remark"`
|
||||
Metadata map[string]interface{} `json:"metadata"`
|
||||
}
|
||||
type ShippingFee struct {
|
||||
Currency string `json:"currency"`
|
||||
Current string `json:"current"`
|
||||
Initiate string `json:"initiate"`
|
||||
Change string `json:"change"`
|
||||
ChangeRemark string `json:"change_remark"`
|
||||
Metadata map[string]interface{} `json:"metadata"`
|
||||
}
|
||||
type Tax struct {
|
||||
Currency string `json:"currency"`
|
||||
Current string `json:"current"`
|
||||
Initiate string `json:"initiate"`
|
||||
Change string `json:"change"`
|
||||
ChangeRemark string `json:"change_remark"`
|
||||
Metadata map[string]interface{} `json:"metadata"`
|
||||
}
|
||||
type Discount struct {
|
||||
Currency string `json:"currency"`
|
||||
Current string `json:"current"`
|
||||
Initiate string `json:"initiate"`
|
||||
Change string `json:"change"`
|
||||
ChangeRemark string `json:"change_remark"`
|
||||
Metadata map[string]interface{} `json:"metadata"`
|
||||
}
|
||||
type Total struct {
|
||||
Currency string `json:"currency"`
|
||||
Current string `json:"current"`
|
||||
Initiate string `json:"initiate"`
|
||||
Change string `json:"change"`
|
||||
ChangeRemark string `json:"change_remark"`
|
||||
Metadata map[string]interface{} `json:"metadata"`
|
||||
}
|
||||
type PayStatus struct {
|
||||
StatusCode int64 `json:"status_code"`
|
||||
StatusTitle string `json:"status_title"`
|
||||
Metadata map[string]interface{} `json:"metadata"`
|
||||
}
|
||||
|
||||
type PayAmount struct {
|
||||
Currency string `json:"currency"`
|
||||
Current string `json:"current"`
|
||||
Initiate string `json:"initiate"`
|
||||
Change string `json:"change"`
|
||||
ChangeRemark string `json:"change_remark"`
|
||||
Metadata map[string]interface{} `json:"metadata"`
|
||||
}
|
||||
type Deposit struct {
|
||||
TradeNo string `json:"trade_no"`
|
||||
Status Status `json:"status"`
|
||||
StatusLink []PayStatus `json:"status_link"`
|
||||
PayTime string `json:"pay_time"`
|
||||
PayAmount PayAmount `json:"pay_amount"`
|
||||
PayMethod string `json:"pay_method"`
|
||||
Metadata map[string]interface{} `json:"metadata"`
|
||||
}
|
||||
type RemainingBalance struct {
|
||||
TradeNo string `json:"trade_no"`
|
||||
Status PayStatus `json:"status"`
|
||||
StatusLink []PayStatus `json:"status_link"`
|
||||
PayTime string `json:"pay_time"`
|
||||
PayAmount PayAmount `json:"pay_amount"`
|
||||
PayMethod string `json:"pay_method"`
|
||||
Metadata map[string]interface{} `json:"metadata"`
|
||||
}
|
||||
type OrderAmount struct {
|
||||
Subtotal Subtotal `json:"subtotal"`
|
||||
ShippingFee ShippingFee `json:"shipping_fee"`
|
||||
Tax Tax `json:"tax"`
|
||||
Discount Discount `json:"discount"`
|
||||
Total Total `json:"total"`
|
||||
Deposit Deposit `json:"deposit"`
|
||||
RemainingBalance RemainingBalance `json:"remaining_balance"`
|
||||
}
|
||||
type DeliveryAddres struct {
|
||||
Address string `json:"address"`
|
||||
Name string `json:"name"`
|
||||
Mobile string `json:"mobile"`
|
||||
}
|
Loading…
Reference in New Issue
Block a user