feat:新增api
This commit is contained in:
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"
|
"time"
|
||||||
)
|
)
|
||||||
|
|
||||||
// fs_order
|
// fs_order 订单表
|
||||||
type FsOrder struct {
|
type FsOrder struct {
|
||||||
Id int64 `gorm:"primary_key;default:0;auto_increment;" json:"id"` //
|
Id int64 `gorm:"primary_key;default:0;auto_increment;" json:"id"` // 订单ID
|
||||||
Sn *string `gorm:"unique_key;default:'';" json:"sn"` // 订单编号 FS211224OL2XDKNP
|
|
||||||
UserId *int64 `gorm:"index;default:0;" json:"user_id"` // 用户ID
|
UserId *int64 `gorm:"index;default:0;" json:"user_id"` // 用户ID
|
||||||
SellerUserId *int64 `gorm:"default:0;" json:"seller_user_id"` // 销售员ID 0:自主下单
|
DeliveryMethod *int64 `gorm:"index;default:0;" json:"delivery_method"` // 物流类型
|
||||||
TotalAmount *int64 `gorm:"default:0;" json:"total_amount"` // 总价
|
OrderNo *string `gorm:"index;default:'';" json:"order_no"` //
|
||||||
PayedAmount *int64 `gorm:"default:0;" json:"payed_amount"` // 已支付金额
|
OrderSource *string `gorm:"default:'';" json:"order_source"` //
|
||||||
PayMethod *int64 `gorm:"default:0;" json:"pay_method"` // 支付方式 1paypal 2strip
|
Status *int64 `gorm:"index;default:0;" json:"status"` // 订单状态
|
||||||
Ctime *int64 `gorm:"default:0;" json:"ctime"` // 添加时间
|
Metadata *[]byte `gorm:"default:'';" json:"metadata"` //
|
||||||
Utime *int64 `gorm:"default:0;" json:"utime"` // 更新时间
|
Ctime *time.Time `gorm:"default:'0000-00-00 00:00:00';" json:"ctime"` //
|
||||||
Ptime *int64 `gorm:"default:0;" json:"ptime"` // 最后一次 支付时间(可能多次支付)
|
Utime *time.Time `gorm:"default:'0000-00-00 00:00:00';" json:"utime"` //
|
||||||
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 FsOrderModel struct {
|
type FsOrderModel struct {
|
||||||
db *gorm.DB
|
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"` // 购买数量
|
PurchaseQuantity *int64 `gorm:"default:0;" json:"purchase_quantity"` // 购买数量
|
||||||
Snapshot *string `gorm:"default:'';" json:"snapshot"` //
|
Snapshot *string `gorm:"default:'';" json:"snapshot"` //
|
||||||
IsHighlyCustomized *int64 `gorm:"default:0;" json:"is_highly_customized"` // 是否高度定制 0非 1是(针对客人高度定制只能后台增加如购物车)
|
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"` //
|
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"` //
|
Utime *time.Time `gorm:"default:'0000-00-00 00:00:00';" json:"utime"` //
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -7,7 +7,6 @@ type AllModelsGen struct {
|
|||||||
CasbinRule *CasbinRuleModel // casbin_rule
|
CasbinRule *CasbinRuleModel // casbin_rule
|
||||||
FsAddress *FsAddressModel // fs_address 用户地址表
|
FsAddress *FsAddressModel // fs_address 用户地址表
|
||||||
FsAdminApi *FsAdminApiModel // fs_admin_api 后台--接口表
|
FsAdminApi *FsAdminApiModel // fs_admin_api 后台--接口表
|
||||||
FsAdminAuthRole *FsAdminAuthRoleModel // fs_admin_auth_role 后台--角色表
|
|
||||||
FsAdminDepartment *FsAdminDepartmentModel // fs_admin_department 后台--部门表
|
FsAdminDepartment *FsAdminDepartmentModel // fs_admin_department 后台--部门表
|
||||||
FsAdminMenu *FsAdminMenuModel // fs_admin_menu 后台--菜单表
|
FsAdminMenu *FsAdminMenuModel // fs_admin_menu 后台--菜单表
|
||||||
FsAdminRole *FsAdminRoleModel // fs_admin_role 后台--角色表
|
FsAdminRole *FsAdminRoleModel // fs_admin_role 后台--角色表
|
||||||
@@ -23,15 +22,15 @@ type AllModelsGen struct {
|
|||||||
FsCardGroup *FsCardGroupModel // fs_card_group 卡号分组表
|
FsCardGroup *FsCardGroupModel // fs_card_group 卡号分组表
|
||||||
FsCart *FsCartModel // fs_cart 购物车
|
FsCart *FsCartModel // fs_cart 购物车
|
||||||
FsChangeCode *FsChangeCodeModel // fs_change_code 忘记密码code表
|
FsChangeCode *FsChangeCodeModel // fs_change_code 忘记密码code表
|
||||||
FsCloud *FsCloudModel // fs_cloud 云仓表
|
FsCloudDeliverEveryTmpOld *FsCloudDeliverEveryTmpOldModel // fs_cloud_deliver_every_tmp_old
|
||||||
FsCloudDeliverEveryTmp *FsCloudDeliverEveryTmpModel // fs_cloud_deliver_every_tmp
|
FsCloudDeliverTmpOld *FsCloudDeliverTmpOldModel // fs_cloud_deliver_tmp_old
|
||||||
FsCloudDeliverTmp *FsCloudDeliverTmpModel // fs_cloud_deliver_tmp
|
FsCloudOld *FsCloudOldModel // fs_cloud_old 云仓表
|
||||||
FsCloudPickUp *FsCloudPickUpModel // fs_cloud_pick_up 云仓提货单
|
FsCloudPickUpDetailOld *FsCloudPickUpDetailOldModel // fs_cloud_pick_up_detail_old 云仓提货单-详情
|
||||||
FsCloudPickUpDetail *FsCloudPickUpDetailModel // fs_cloud_pick_up_detail 云仓提货单-详情
|
FsCloudPickUpOld *FsCloudPickUpOldModel // fs_cloud_pick_up_old 云仓提货单
|
||||||
FsCloudReceive *FsCloudReceiveModel // fs_cloud_receive 云仓接收工厂总单
|
FsCloudReceiveEveryOld *FsCloudReceiveEveryOldModel // fs_cloud_receive_every_old
|
||||||
FsCloudReceiveEvery *FsCloudReceiveEveryModel // fs_cloud_receive_every
|
FsCloudReceiveOld *FsCloudReceiveOldModel // fs_cloud_receive_old 云仓接收工厂总单
|
||||||
FsCloudRenderLog *FsCloudRenderLogModel // fs_cloud_render_log 云渲染日志表
|
FsCloudRenderLogOld *FsCloudRenderLogOldModel // fs_cloud_render_log_old 云渲染日志表
|
||||||
FsCloudUserApplyBack *FsCloudUserApplyBackModel // fs_cloud_user_apply_back 该表废弃
|
FsCloudUserApplyBackOld *FsCloudUserApplyBackOldModel // fs_cloud_user_apply_back_old 该表废弃
|
||||||
FsContact *FsContactModel // fs_contact 该表暂未使用
|
FsContact *FsContactModel // fs_contact 该表暂未使用
|
||||||
FsContactService *FsContactServiceModel // fs_contact_service
|
FsContactService *FsContactServiceModel // fs_contact_service
|
||||||
FsCoupon *FsCouponModel // fs_coupon 代金券(暂未使用)
|
FsCoupon *FsCouponModel // fs_coupon 代金券(暂未使用)
|
||||||
@@ -55,11 +54,14 @@ type AllModelsGen struct {
|
|||||||
FsMenu *FsMenuModel // fs_menu 后台菜单
|
FsMenu *FsMenuModel // fs_menu 后台菜单
|
||||||
FsMerchantCategory *FsMerchantCategoryModel // fs_merchant_category 商户类型表
|
FsMerchantCategory *FsMerchantCategoryModel // fs_merchant_category 商户类型表
|
||||||
FsMigration *FsMigrationModel // fs_migration 版本库
|
FsMigration *FsMigrationModel // fs_migration 版本库
|
||||||
FsOrder *FsOrderModel // fs_order
|
FsOrder *FsOrderModel // fs_order 订单表
|
||||||
FsOrderAffiliate *FsOrderAffiliateModel // fs_order_affiliate 订单附属表-流程控制时间等
|
FsOrderAffiliateOld *FsOrderAffiliateOldModel // fs_order_affiliate_old 订单附属表-流程控制时间等
|
||||||
FsOrderDetail *FsOrderDetailModel // fs_order_detail 订单详细表
|
FsOrderDetailOld *FsOrderDetailOldModel // fs_order_detail_old 订单详细表
|
||||||
FsOrderDetailTemplate *FsOrderDetailTemplateModel // fs_order_detail_template 订单模板详细表
|
FsOrderDetailTemplateOld *FsOrderDetailTemplateOldModel // fs_order_detail_template_old 订单模板详细表
|
||||||
FsOrderRemark *FsOrderRemarkModel // fs_order_remark 订单备注表
|
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 支付记录
|
FsPay *FsPayModel // fs_pay 支付记录
|
||||||
FsPayEvent *FsPayEventModel // fs_pay_event 支付回调事件日志
|
FsPayEvent *FsPayEventModel // fs_pay_event 支付回调事件日志
|
||||||
FsProduct *FsProductModel // fs_product 产品表
|
FsProduct *FsProductModel // fs_product 产品表
|
||||||
@@ -114,7 +116,6 @@ func NewAllModels(gdb *gorm.DB) *AllModelsGen {
|
|||||||
CasbinRule: NewCasbinRuleModel(gdb),
|
CasbinRule: NewCasbinRuleModel(gdb),
|
||||||
FsAddress: NewFsAddressModel(gdb),
|
FsAddress: NewFsAddressModel(gdb),
|
||||||
FsAdminApi: NewFsAdminApiModel(gdb),
|
FsAdminApi: NewFsAdminApiModel(gdb),
|
||||||
FsAdminAuthRole: NewFsAdminAuthRoleModel(gdb),
|
|
||||||
FsAdminDepartment: NewFsAdminDepartmentModel(gdb),
|
FsAdminDepartment: NewFsAdminDepartmentModel(gdb),
|
||||||
FsAdminMenu: NewFsAdminMenuModel(gdb),
|
FsAdminMenu: NewFsAdminMenuModel(gdb),
|
||||||
FsAdminRole: NewFsAdminRoleModel(gdb),
|
FsAdminRole: NewFsAdminRoleModel(gdb),
|
||||||
@@ -130,15 +131,15 @@ func NewAllModels(gdb *gorm.DB) *AllModelsGen {
|
|||||||
FsCardGroup: NewFsCardGroupModel(gdb),
|
FsCardGroup: NewFsCardGroupModel(gdb),
|
||||||
FsCart: NewFsCartModel(gdb),
|
FsCart: NewFsCartModel(gdb),
|
||||||
FsChangeCode: NewFsChangeCodeModel(gdb),
|
FsChangeCode: NewFsChangeCodeModel(gdb),
|
||||||
FsCloud: NewFsCloudModel(gdb),
|
FsCloudDeliverEveryTmpOld: NewFsCloudDeliverEveryTmpOldModel(gdb),
|
||||||
FsCloudDeliverEveryTmp: NewFsCloudDeliverEveryTmpModel(gdb),
|
FsCloudDeliverTmpOld: NewFsCloudDeliverTmpOldModel(gdb),
|
||||||
FsCloudDeliverTmp: NewFsCloudDeliverTmpModel(gdb),
|
FsCloudOld: NewFsCloudOldModel(gdb),
|
||||||
FsCloudPickUp: NewFsCloudPickUpModel(gdb),
|
FsCloudPickUpDetailOld: NewFsCloudPickUpDetailOldModel(gdb),
|
||||||
FsCloudPickUpDetail: NewFsCloudPickUpDetailModel(gdb),
|
FsCloudPickUpOld: NewFsCloudPickUpOldModel(gdb),
|
||||||
FsCloudReceive: NewFsCloudReceiveModel(gdb),
|
FsCloudReceiveEveryOld: NewFsCloudReceiveEveryOldModel(gdb),
|
||||||
FsCloudReceiveEvery: NewFsCloudReceiveEveryModel(gdb),
|
FsCloudReceiveOld: NewFsCloudReceiveOldModel(gdb),
|
||||||
FsCloudRenderLog: NewFsCloudRenderLogModel(gdb),
|
FsCloudRenderLogOld: NewFsCloudRenderLogOldModel(gdb),
|
||||||
FsCloudUserApplyBack: NewFsCloudUserApplyBackModel(gdb),
|
FsCloudUserApplyBackOld: NewFsCloudUserApplyBackOldModel(gdb),
|
||||||
FsContact: NewFsContactModel(gdb),
|
FsContact: NewFsContactModel(gdb),
|
||||||
FsContactService: NewFsContactServiceModel(gdb),
|
FsContactService: NewFsContactServiceModel(gdb),
|
||||||
FsCoupon: NewFsCouponModel(gdb),
|
FsCoupon: NewFsCouponModel(gdb),
|
||||||
@@ -163,10 +164,13 @@ func NewAllModels(gdb *gorm.DB) *AllModelsGen {
|
|||||||
FsMerchantCategory: NewFsMerchantCategoryModel(gdb),
|
FsMerchantCategory: NewFsMerchantCategoryModel(gdb),
|
||||||
FsMigration: NewFsMigrationModel(gdb),
|
FsMigration: NewFsMigrationModel(gdb),
|
||||||
FsOrder: NewFsOrderModel(gdb),
|
FsOrder: NewFsOrderModel(gdb),
|
||||||
FsOrderAffiliate: NewFsOrderAffiliateModel(gdb),
|
FsOrderAffiliateOld: NewFsOrderAffiliateOldModel(gdb),
|
||||||
FsOrderDetail: NewFsOrderDetailModel(gdb),
|
FsOrderDetailOld: NewFsOrderDetailOldModel(gdb),
|
||||||
FsOrderDetailTemplate: NewFsOrderDetailTemplateModel(gdb),
|
FsOrderDetailTemplateOld: NewFsOrderDetailTemplateOldModel(gdb),
|
||||||
FsOrderRemark: NewFsOrderRemarkModel(gdb),
|
FsOrderOld: NewFsOrderOldModel(gdb),
|
||||||
|
FsOrderRemarkOld: NewFsOrderRemarkOldModel(gdb),
|
||||||
|
FsOrderTrade: NewFsOrderTradeModel(gdb),
|
||||||
|
FsOrderTradeEvent: NewFsOrderTradeEventModel(gdb),
|
||||||
FsPay: NewFsPayModel(gdb),
|
FsPay: NewFsPayModel(gdb),
|
||||||
FsPayEvent: NewFsPayEventModel(gdb),
|
FsPayEvent: NewFsPayEventModel(gdb),
|
||||||
FsProduct: NewFsProductModel(gdb),
|
FsProduct: NewFsProductModel(gdb),
|
||||||
|
|||||||
@@ -1,10 +1,8 @@
|
|||||||
package logic
|
package logic
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"fusenapi/model/gmodel"
|
|
||||||
"fusenapi/utils/auth"
|
"fusenapi/utils/auth"
|
||||||
"fusenapi/utils/basic"
|
"fusenapi/utils/basic"
|
||||||
"fusenapi/utils/collect"
|
|
||||||
|
|
||||||
"context"
|
"context"
|
||||||
|
|
||||||
@@ -12,7 +10,6 @@ import (
|
|||||||
"fusenapi/server/home-user-auth/internal/types"
|
"fusenapi/server/home-user-auth/internal/types"
|
||||||
|
|
||||||
"github.com/zeromicro/go-zero/core/logx"
|
"github.com/zeromicro/go-zero/core/logx"
|
||||||
"gorm.io/gorm"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
type UserContactServiceLogic struct {
|
type UserContactServiceLogic struct {
|
||||||
@@ -33,36 +30,36 @@ func (l *UserContactServiceLogic) UserContactService(req *types.RequestContactSe
|
|||||||
// 返回值必须调用Set重新返回, resp可以空指针调用 resp.SetStatus(basic.CodeOK, data)
|
// 返回值必须调用Set重新返回, resp可以空指针调用 resp.SetStatus(basic.CodeOK, data)
|
||||||
// userinfo 传入值时, 一定不为null
|
// userinfo 传入值时, 一定不为null
|
||||||
|
|
||||||
if !userinfo.IsUser() {
|
// if !userinfo.IsUser() {
|
||||||
return resp.SetStatus(basic.CodeUnAuth)
|
// return resp.SetStatus(basic.CodeUnAuth)
|
||||||
}
|
// }
|
||||||
|
|
||||||
cs := gmodel.FsContactService{
|
// cs := gmodel.FsContactService{
|
||||||
UserId: &userinfo.UserId,
|
// UserId: &userinfo.UserId,
|
||||||
}
|
// }
|
||||||
collect.LoadJsonTag(&cs, &req)
|
// collect.LoadJsonTag(&cs, &req)
|
||||||
|
|
||||||
switch req.Type {
|
// switch req.Type {
|
||||||
case "order":
|
// case "order":
|
||||||
_, err := l.svcCtx.AllModels.FsOrder.FindOneAndCreateServiceContact(l.ctx, userinfo.UserId, req.RelationID, &cs)
|
// _, err := l.svcCtx.AllModels.FsOrder.FindOneAndCreateServiceContact(l.ctx, userinfo.UserId, req.RelationID, &cs)
|
||||||
if err != nil {
|
// if err != nil {
|
||||||
if err == gorm.ErrRecordNotFound {
|
// if err == gorm.ErrRecordNotFound {
|
||||||
return resp.SetStatus(basic.CodeOrderNotFoundErr)
|
// return resp.SetStatus(basic.CodeOrderNotFoundErr)
|
||||||
}
|
// }
|
||||||
return resp.SetStatus(basic.CodeDbSqlErr)
|
// return resp.SetStatus(basic.CodeDbSqlErr)
|
||||||
}
|
// }
|
||||||
case "cloud":
|
// case "cloud":
|
||||||
_, err := l.svcCtx.AllModels.FsCloudPickUp.GetCloudPickUpByIDAndUserID(l.ctx, userinfo.UserId, req.RelationID, &cs)
|
// _, err := l.svcCtx.AllModels.FsCloudPickUp.GetCloudPickUpByIDAndUserID(l.ctx, userinfo.UserId, req.RelationID, &cs)
|
||||||
if err != nil {
|
// if err != nil {
|
||||||
if err == gorm.ErrRecordNotFound {
|
// if err == gorm.ErrRecordNotFound {
|
||||||
return resp.SetStatus(basic.CodeCloudOrderNotFoundErr)
|
// return resp.SetStatus(basic.CodeCloudOrderNotFoundErr)
|
||||||
}
|
// }
|
||||||
return resp.SetStatus(basic.CodeDbSqlErr)
|
// return resp.SetStatus(basic.CodeDbSqlErr)
|
||||||
}
|
// }
|
||||||
return
|
// return
|
||||||
default:
|
// default:
|
||||||
return resp.SetStatusWithMessage(basic.CodeRequestParamsErr, "type is unknown")
|
// 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
|
package logic
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"errors"
|
|
||||||
"fusenapi/constants"
|
|
||||||
"fusenapi/model/gmodel"
|
|
||||||
"fusenapi/utils/auth"
|
"fusenapi/utils/auth"
|
||||||
"fusenapi/utils/basic"
|
"fusenapi/utils/basic"
|
||||||
"time"
|
|
||||||
|
|
||||||
"context"
|
"context"
|
||||||
|
|
||||||
"fusenapi/server/home-user-auth/internal/svc"
|
"fusenapi/server/home-user-auth/internal/svc"
|
||||||
"fusenapi/server/home-user-auth/internal/types"
|
"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"
|
"github.com/zeromicro/go-zero/core/logx"
|
||||||
"gorm.io/gorm"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
type UserOderDeleteLogic struct {
|
type UserOderDeleteLogic struct {
|
||||||
@@ -38,109 +30,109 @@ func (l *UserOderDeleteLogic) UserOderDelete(req *types.RequestOrderId, userinfo
|
|||||||
// 返回值必须调用Set重新返回, resp可以空指针调用 resp.SetStatus(basic.CodeOK, data)
|
// 返回值必须调用Set重新返回, resp可以空指针调用 resp.SetStatus(basic.CodeOK, data)
|
||||||
// userinfo 传入值时, 一定不为null
|
// userinfo 传入值时, 一定不为null
|
||||||
|
|
||||||
if !userinfo.IsUser() {
|
// if !userinfo.IsUser() {
|
||||||
return resp.SetStatus(basic.CodeUnAuth) // 如果不是用户信息, 返回未授权错误
|
// return resp.SetStatus(basic.CodeUnAuth) // 如果不是用户信息, 返回未授权错误
|
||||||
}
|
// }
|
||||||
|
|
||||||
//订单id
|
// //订单id
|
||||||
orderId := req.OrderId
|
// orderId := req.OrderId
|
||||||
if orderId < 1 {
|
// if orderId < 1 {
|
||||||
return resp.SetStatus(basic.CodeRequestParamsErr)
|
// return resp.SetStatus(basic.CodeRequestParamsErr)
|
||||||
}
|
// }
|
||||||
|
|
||||||
m := l.svcCtx.AllModels.FsOrder
|
// m := l.svcCtx.AllModels.FsOrder
|
||||||
order, err := m.FindOne(l.ctx, userinfo.UserId, orderId)
|
// order, err := m.FindOne(l.ctx, userinfo.UserId, orderId)
|
||||||
if err != nil {
|
// if err != nil {
|
||||||
if errors.Is(err, gorm.ErrRecordNotFound) {
|
// if errors.Is(err, gorm.ErrRecordNotFound) {
|
||||||
return resp.SetStatus(basic.CodeOrderNotFoundErr)
|
// return resp.SetStatus(basic.CodeOrderNotFoundErr)
|
||||||
}
|
// }
|
||||||
logx.Error(err)
|
// logx.Error(err)
|
||||||
return resp.SetStatus(basic.CodeDbSqlErr)
|
// return resp.SetStatus(basic.CodeDbSqlErr)
|
||||||
}
|
// }
|
||||||
|
|
||||||
if auth.CheckValueRange[constants.Order](
|
// if auth.CheckValueRange[constants.Order](
|
||||||
constants.Order(*order.Status),
|
// constants.Order(*order.Status),
|
||||||
constants.STATUS_NEW_NOT_PAY,
|
// constants.STATUS_NEW_NOT_PAY,
|
||||||
constants.STATUS_NEW_PAY_COMPLETED,
|
// constants.STATUS_NEW_PAY_COMPLETED,
|
||||||
constants.STATUS_NEW_PART_PAY,
|
// constants.STATUS_NEW_PART_PAY,
|
||||||
) {
|
// ) {
|
||||||
return resp.SetStatus(basic.CodeOrderNotCancelledErr)
|
// return resp.SetStatus(basic.CodeOrderNotCancelledErr)
|
||||||
}
|
// }
|
||||||
|
|
||||||
if *order.IsPayCompleted == 1 &&
|
// if *order.IsPayCompleted == 1 &&
|
||||||
time.Now().After(time.Unix(*order.Ctime, 0).Add(48*time.Hour)) {
|
// time.Now().After(time.Unix(*order.Ctime, 0).Add(48*time.Hour)) {
|
||||||
return resp.SetStatus(basic.CodeOrderNotCancelledErr)
|
// return resp.SetStatus(basic.CodeOrderNotCancelledErr)
|
||||||
}
|
// }
|
||||||
|
|
||||||
uOrder := &gmodel.FsOrder{
|
// uOrder := &gmodel.FsOrder{
|
||||||
Id: orderId,
|
// Id: orderId,
|
||||||
}
|
// }
|
||||||
|
|
||||||
var (
|
// var (
|
||||||
isCancel int64 = 1
|
// isCancel int64 = 1
|
||||||
ustatus int64 = int64(constants.STATUS_NEW_CANCEL)
|
// ustatus int64 = int64(constants.STATUS_NEW_CANCEL)
|
||||||
)
|
// )
|
||||||
// 修改取消状态和取消原因
|
// // 修改取消状态和取消原因
|
||||||
uOrder.Status = &ustatus
|
// uOrder.Status = &ustatus
|
||||||
uOrder.IsCancel = &isCancel
|
// uOrder.IsCancel = &isCancel
|
||||||
uOrder.RefundReasonId = &req.RefundReasonId
|
// uOrder.RefundReasonId = &req.RefundReasonId
|
||||||
uOrder.RefundReason = &req.RefundReason
|
// uOrder.RefundReason = &req.RefundReason
|
||||||
|
|
||||||
err = m.Update(l.ctx, uOrder)
|
// err = m.Update(l.ctx, uOrder)
|
||||||
if err != nil {
|
// if err != nil {
|
||||||
logx.Error(err)
|
// logx.Error(err)
|
||||||
return resp.SetStatus(basic.CodeDbUpdateErr)
|
// return resp.SetStatus(basic.CodeDbUpdateErr)
|
||||||
}
|
// }
|
||||||
|
|
||||||
var (
|
// var (
|
||||||
IsRefund int64 = 0
|
// IsRefund int64 = 0
|
||||||
CreatedAt = time.Now().UTC().Unix()
|
// CreatedAt = time.Now().UTC().Unix()
|
||||||
)
|
// )
|
||||||
|
|
||||||
refund := &gmodel.FsRefundReason{
|
// refund := &gmodel.FsRefundReason{
|
||||||
IsRefund: &IsRefund,
|
// IsRefund: &IsRefund,
|
||||||
RefundReasonId: &req.RefundReasonId,
|
// RefundReasonId: &req.RefundReasonId,
|
||||||
RefundReason: &req.RefundReason,
|
// RefundReason: &req.RefundReason,
|
||||||
OrderId: &order.Id,
|
// OrderId: &order.Id,
|
||||||
CreatedAt: &CreatedAt,
|
// CreatedAt: &CreatedAt,
|
||||||
}
|
// }
|
||||||
|
|
||||||
mFsRefundReason := gmodel.NewFsRefundReasonModel(l.svcCtx.MysqlConn)
|
// mFsRefundReason := gmodel.NewFsRefundReasonModel(l.svcCtx.MysqlConn)
|
||||||
err = mFsRefundReason.Create(l.ctx, refund)
|
// err = mFsRefundReason.Create(l.ctx, refund)
|
||||||
if err != nil {
|
// if err != nil {
|
||||||
logx.Error(err)
|
// logx.Error(err)
|
||||||
return resp.SetStatus(basic.CodeDbSqlErr)
|
// return resp.SetStatus(basic.CodeDbSqlErr)
|
||||||
}
|
// }
|
||||||
|
|
||||||
// 退款
|
// // 退款
|
||||||
// 调用第三方接口发起退款
|
// // 调用第三方接口发起退款
|
||||||
|
|
||||||
config := &stripe.BackendConfig{
|
// config := &stripe.BackendConfig{
|
||||||
MaxNetworkRetries: stripe.Int64(0), // Zero retries
|
// MaxNetworkRetries: stripe.Int64(0), // Zero retries
|
||||||
}
|
// }
|
||||||
|
|
||||||
sc := &client.API{}
|
// sc := &client.API{}
|
||||||
sc.Init(l.svcCtx.Config.Stripe.SK, &stripe.Backends{
|
// sc.Init(l.svcCtx.Config.Stripe.SK, &stripe.Backends{
|
||||||
API: stripe.GetBackendWithConfig(stripe.APIBackend, config),
|
// API: stripe.GetBackendWithConfig(stripe.APIBackend, config),
|
||||||
Uploads: stripe.GetBackendWithConfig(stripe.UploadsBackend, config),
|
// Uploads: stripe.GetBackendWithConfig(stripe.UploadsBackend, config),
|
||||||
})
|
// })
|
||||||
// ['order_number' => $order->sn, 'is_refund' => 0, 'pay_status' => 1]
|
// // ['order_number' => $order->sn, 'is_refund' => 0, 'pay_status' => 1]
|
||||||
payM := l.svcCtx.AllModels.FsPay
|
// payM := l.svcCtx.AllModels.FsPay
|
||||||
|
|
||||||
// 查询支付信息
|
// // 查询支付信息
|
||||||
pays, err := payM.GetOrderPayList(l.ctx, *order.Sn, 1, 0)
|
// pays, err := payM.GetOrderPayList(l.ctx, *order.Sn, 1, 0)
|
||||||
for _, pay := range pays {
|
// for _, pay := range pays {
|
||||||
sc.Refunds.New(&stripe.RefundParams{
|
// sc.Refunds.New(&stripe.RefundParams{
|
||||||
PaymentIntent: pay.TradeNo,
|
// PaymentIntent: pay.TradeNo,
|
||||||
})
|
// })
|
||||||
}
|
// }
|
||||||
if err != nil {
|
// if err != nil {
|
||||||
if errors.Is(err, gorm.ErrRecordNotFound) {
|
// if errors.Is(err, gorm.ErrRecordNotFound) {
|
||||||
return resp.SetStatus(basic.CodeApiErr)
|
// return resp.SetStatus(basic.CodeApiErr)
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
|
|
||||||
return resp.SetStatus(basic.CodePayCancelOk, uOrder)
|
return resp.SetStatus(basic.CodePayCancelOk)
|
||||||
|
|
||||||
// return ResponseError(500, "Cancellation failure")
|
// return ResponseError(500, "Cancellation failure")
|
||||||
|
|
||||||
|
|||||||
@@ -1,13 +1,8 @@
|
|||||||
package logic
|
package logic
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"errors"
|
|
||||||
"fusenapi/constants"
|
|
||||||
"fusenapi/model/gmodel"
|
|
||||||
"fusenapi/utils/auth"
|
"fusenapi/utils/auth"
|
||||||
"fusenapi/utils/basic"
|
"fusenapi/utils/basic"
|
||||||
"fusenapi/utils/handlers"
|
|
||||||
"time"
|
|
||||||
|
|
||||||
"context"
|
"context"
|
||||||
|
|
||||||
@@ -15,7 +10,6 @@ import (
|
|||||||
"fusenapi/server/home-user-auth/internal/types"
|
"fusenapi/server/home-user-auth/internal/types"
|
||||||
|
|
||||||
"github.com/zeromicro/go-zero/core/logx"
|
"github.com/zeromicro/go-zero/core/logx"
|
||||||
"gorm.io/gorm"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
type UserOrderCancelLogic struct {
|
type UserOrderCancelLogic struct {
|
||||||
@@ -36,93 +30,93 @@ func (l *UserOrderCancelLogic) UserOrderCancel(req *types.UserOrderCancelReq, us
|
|||||||
// 返回值必须调用Set重新返回, resp可以空指针调用 resp.SetStatus(basic.CodeOK, data)
|
// 返回值必须调用Set重新返回, resp可以空指针调用 resp.SetStatus(basic.CodeOK, data)
|
||||||
// userinfo 传入值时, 一定不为null
|
// userinfo 传入值时, 一定不为null
|
||||||
|
|
||||||
if userinfo == nil || userinfo.UserId == 0 {
|
// if userinfo == nil || userinfo.UserId == 0 {
|
||||||
return resp.SetStatusWithMessage(basic.CodeDbRecordNotFoundErr, "order not found")
|
// return resp.SetStatusWithMessage(basic.CodeDbRecordNotFoundErr, "order not found")
|
||||||
}
|
// }
|
||||||
|
|
||||||
//查询订单信息
|
// //查询订单信息
|
||||||
orderModel := gmodel.NewFsOrderModel(l.svcCtx.MysqlConn)
|
// orderModel := gmodel.NewFsOrderModel(l.svcCtx.MysqlConn)
|
||||||
orderInfo, err := orderModel.FindOne(l.ctx, userinfo.UserId, req.ID)
|
// orderInfo, err := orderModel.FindOne(l.ctx, userinfo.UserId, req.ID)
|
||||||
if err != nil {
|
// if err != nil {
|
||||||
if errors.Is(err, gorm.ErrRecordNotFound) {
|
// if errors.Is(err, gorm.ErrRecordNotFound) {
|
||||||
return resp.SetStatusWithMessage(basic.CodeDbRecordNotFoundErr, "the order is not exists")
|
// return resp.SetStatusWithMessage(basic.CodeDbRecordNotFoundErr, "the order is not exists")
|
||||||
}
|
// }
|
||||||
logx.Error(err)
|
// logx.Error(err)
|
||||||
return resp.SetStatus(basic.CodeServiceErr, "failed to get order info")
|
// return resp.SetStatus(basic.CodeServiceErr, "failed to get order info")
|
||||||
}
|
// }
|
||||||
|
|
||||||
// 判断订单状态
|
// // 判断订单状态
|
||||||
var notCancelStatusMap = make(map[int64]struct{}, 3)
|
// var notCancelStatusMap = make(map[int64]struct{}, 3)
|
||||||
notCancelStatusMap[int64(constants.STATUS_NEW_NOT_PAY)] = struct{}{}
|
// notCancelStatusMap[int64(constants.STATUS_NEW_NOT_PAY)] = struct{}{}
|
||||||
notCancelStatusMap[int64(constants.STATUS_NEW_PART_PAY)] = struct{}{}
|
// notCancelStatusMap[int64(constants.STATUS_NEW_PART_PAY)] = struct{}{}
|
||||||
notCancelStatusMap[int64(constants.STATUS_NEW_PAY_COMPLETED)] = struct{}{}
|
// notCancelStatusMap[int64(constants.STATUS_NEW_PAY_COMPLETED)] = struct{}{}
|
||||||
_, ok := notCancelStatusMap[int64(*orderInfo.Status)]
|
// _, ok := notCancelStatusMap[int64(*orderInfo.Status)]
|
||||||
if !ok {
|
// if !ok {
|
||||||
return resp.SetStatusWithMessage(basic.CodeOrderNotCancelledErr, "the order status not cancle")
|
// return resp.SetStatusWithMessage(basic.CodeOrderNotCancelledErr, "the order status not cancle")
|
||||||
}
|
// }
|
||||||
|
|
||||||
var cancelTime int64 = time.Now().UTC().Unix() - (*orderInfo.Ctime + int64(constants.CANCLE_ORDER_EXPIRE))
|
// var cancelTime int64 = time.Now().UTC().Unix() - (*orderInfo.Ctime + int64(constants.CANCLE_ORDER_EXPIRE))
|
||||||
// 第一次支付成功后48小时后不能进行取消操作
|
// // 第一次支付成功后48小时后不能进行取消操作
|
||||||
if *orderInfo.IsPayCompleted == 1 && cancelTime > 0 {
|
// if *orderInfo.IsPayCompleted == 1 && cancelTime > 0 {
|
||||||
return resp.SetStatusWithMessage(basic.CodeOrderNotCancelledErr, "The current order cannot be cancelled")
|
// return resp.SetStatusWithMessage(basic.CodeOrderNotCancelledErr, "The current order cannot be cancelled")
|
||||||
}
|
// }
|
||||||
|
|
||||||
// 修改订单--取消状态和取消原因
|
// // 修改订单--取消状态和取消原因
|
||||||
*orderInfo.Status = int64(constants.STATUS_NEW_CANCEL)
|
// *orderInfo.Status = int64(constants.STATUS_NEW_CANCEL)
|
||||||
*orderInfo.IsCancel = 1
|
// *orderInfo.IsCancel = 1
|
||||||
orderInfo.RefundReasonId = &req.RefundReasonId
|
// orderInfo.RefundReasonId = &req.RefundReasonId
|
||||||
orderInfo.RefundReason = &req.RefundReason
|
// orderInfo.RefundReason = &req.RefundReason
|
||||||
|
|
||||||
var nowTime = time.Now().UTC().Unix()
|
// var nowTime = time.Now().UTC().Unix()
|
||||||
var payList []handlers.PayInfo
|
// var payList []handlers.PayInfo
|
||||||
// 事务处理
|
// // 事务处理
|
||||||
ctx := l.ctx
|
// ctx := l.ctx
|
||||||
err = l.svcCtx.MysqlConn.Transaction(func(tx *gorm.DB) error {
|
// err = l.svcCtx.MysqlConn.Transaction(func(tx *gorm.DB) error {
|
||||||
// 修改订单信息
|
// // 修改订单信息
|
||||||
orderModelTS := gmodel.NewFsOrderModel(tx)
|
// orderModelTS := gmodel.NewFsOrderModel(tx)
|
||||||
err = orderModelTS.RBUpdate(ctx, orderInfo)
|
// err = orderModelTS.RBUpdate(ctx, orderInfo)
|
||||||
if err != nil {
|
// if err != nil {
|
||||||
return err
|
// return err
|
||||||
}
|
// }
|
||||||
// 新增退款记录
|
// // 新增退款记录
|
||||||
var isRefund int64 = 0
|
// var isRefund int64 = 0
|
||||||
refundReasonModelTS := gmodel.NewFsRefundReasonModel(tx)
|
// refundReasonModelTS := gmodel.NewFsRefundReasonModel(tx)
|
||||||
refundReasonModelTS.RBCreateOrUpdate(ctx, &gmodel.FsRefundReason{
|
// refundReasonModelTS.RBCreateOrUpdate(ctx, &gmodel.FsRefundReason{
|
||||||
IsRefund: &isRefund,
|
// IsRefund: &isRefund,
|
||||||
RefundReasonId: &req.RefundReasonId,
|
// RefundReasonId: &req.RefundReasonId,
|
||||||
RefundReason: &req.RefundReason,
|
// RefundReason: &req.RefundReason,
|
||||||
OrderId: &orderInfo.Id,
|
// OrderId: &orderInfo.Id,
|
||||||
CreatedAt: &nowTime,
|
// CreatedAt: &nowTime,
|
||||||
})
|
// })
|
||||||
// 退款申请
|
// // 退款申请
|
||||||
// 退款申请--查询支付信息
|
// // 退款申请--查询支付信息
|
||||||
fsPayModelTS := gmodel.NewFsPayModel(tx)
|
// fsPayModelTS := gmodel.NewFsPayModel(tx)
|
||||||
rbFsPay := fsPayModelTS.RowSelectBuilder(nil).Where("order_number = ?", orderInfo.Sn).Where("pay_status =?", constants.PAYSTATUS_SUCCESS).Where("is_refund =?", 0)
|
// 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, "")
|
// payInfoList, err := fsPayModelTS.FindAll(ctx, rbFsPay, nil, "")
|
||||||
if err != nil {
|
// if err != nil {
|
||||||
return err
|
// return err
|
||||||
}
|
// }
|
||||||
for _, payInfo := range payInfoList {
|
// for _, payInfo := range payInfoList {
|
||||||
var key string
|
// var key string
|
||||||
if *payInfo.PaymentMethod == int64(constants.PAYMETHOD_STRIPE) {
|
// if *payInfo.PaymentMethod == int64(constants.PAYMETHOD_STRIPE) {
|
||||||
key = l.svcCtx.Config.PayConfig.Stripe.Key
|
// key = l.svcCtx.Config.PayConfig.Stripe.Key
|
||||||
}
|
// }
|
||||||
payList = append(payList, handlers.PayInfo{
|
// payList = append(payList, handlers.PayInfo{
|
||||||
TradeNo: *payInfo.TradeNo,
|
// TradeNo: *payInfo.TradeNo,
|
||||||
PaymentMethod: *payInfo.PaymentMethod,
|
// PaymentMethod: *payInfo.PaymentMethod,
|
||||||
Key: key,
|
// Key: key,
|
||||||
})
|
// })
|
||||||
}
|
// }
|
||||||
return nil
|
// return nil
|
||||||
})
|
// })
|
||||||
// 退款申请--调取第三方接口发起退款
|
// // 退款申请--调取第三方接口发起退款
|
||||||
handlers.PayRefundHandler(&handlers.PayRefundHandlerReq{
|
// handlers.PayRefundHandler(&handlers.PayRefundHandlerReq{
|
||||||
PayInfoList: payList,
|
// PayInfoList: payList,
|
||||||
})
|
// })
|
||||||
if err != nil {
|
// if err != nil {
|
||||||
logx.Error(err)
|
// logx.Error(err)
|
||||||
return resp.SetStatusWithMessage(basic.CodeOrderCancelledNotOk, "the order cancle failed")
|
// return resp.SetStatusWithMessage(basic.CodeOrderCancelledNotOk, "the order cancle failed")
|
||||||
}
|
// }
|
||||||
|
|
||||||
return resp.SetStatus(basic.CodeOK)
|
return resp.SetStatus(basic.CodeOK)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,9 +1,6 @@
|
|||||||
package logic
|
package logic
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"errors"
|
|
||||||
"fusenapi/constants"
|
|
||||||
"fusenapi/model/gmodel"
|
|
||||||
"fusenapi/utils/auth"
|
"fusenapi/utils/auth"
|
||||||
"fusenapi/utils/basic"
|
"fusenapi/utils/basic"
|
||||||
|
|
||||||
@@ -13,7 +10,6 @@ import (
|
|||||||
"fusenapi/server/home-user-auth/internal/types"
|
"fusenapi/server/home-user-auth/internal/types"
|
||||||
|
|
||||||
"github.com/zeromicro/go-zero/core/logx"
|
"github.com/zeromicro/go-zero/core/logx"
|
||||||
"gorm.io/gorm"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
type UserOrderDeleteLogic struct {
|
type UserOrderDeleteLogic struct {
|
||||||
@@ -43,36 +39,36 @@ func (l *UserOrderDeleteLogic) UserOrderDelete(req *types.UserOrderDeleteReq, us
|
|||||||
// 返回值必须调用Set重新返回, resp可以空指针调用 resp.SetStatus(basic.CodeOK, data)
|
// 返回值必须调用Set重新返回, resp可以空指针调用 resp.SetStatus(basic.CodeOK, data)
|
||||||
// userinfo 传入值时, 一定不为null
|
// userinfo 传入值时, 一定不为null
|
||||||
|
|
||||||
if userinfo == nil || userinfo.UserId == 0 {
|
// if userinfo == nil || userinfo.UserId == 0 {
|
||||||
return resp.SetStatusWithMessage(basic.CodeDbRecordNotFoundErr, "order not found")
|
// return resp.SetStatusWithMessage(basic.CodeDbRecordNotFoundErr, "order not found")
|
||||||
}
|
// }
|
||||||
|
|
||||||
orderModel := gmodel.NewFsOrderModel(l.svcCtx.MysqlConn)
|
// orderModel := gmodel.NewFsOrderModel(l.svcCtx.MysqlConn)
|
||||||
orderInfo, err := orderModel.FindOne(l.ctx, userinfo.UserId, req.ID)
|
// orderInfo, err := orderModel.FindOne(l.ctx, userinfo.UserId, req.ID)
|
||||||
|
|
||||||
if err != nil {
|
// if err != nil {
|
||||||
if errors.Is(err, gorm.ErrRecordNotFound) {
|
// if errors.Is(err, gorm.ErrRecordNotFound) {
|
||||||
return resp.SetStatusWithMessage(basic.CodeDbRecordNotFoundErr, "order not found")
|
// return resp.SetStatusWithMessage(basic.CodeDbRecordNotFoundErr, "order not found")
|
||||||
}
|
// }
|
||||||
logx.Error(err)
|
// logx.Error(err)
|
||||||
return resp.SetStatusWithMessage(basic.CodeServiceErr, "failed to get order info")
|
// return resp.SetStatusWithMessage(basic.CodeServiceErr, "failed to get order info")
|
||||||
}
|
// }
|
||||||
|
|
||||||
updateStatusMap := make(map[constants.Order]struct{}, 4)
|
// updateStatusMap := make(map[constants.Order]struct{}, 4)
|
||||||
updateStatusMap[constants.STATUS_NEW_COMPLETED] = struct{}{}
|
// updateStatusMap[constants.STATUS_NEW_COMPLETED] = struct{}{}
|
||||||
updateStatusMap[constants.STATUS_NEW_CANCEL] = struct{}{}
|
// updateStatusMap[constants.STATUS_NEW_CANCEL] = struct{}{}
|
||||||
updateStatusMap[constants.STATUS_NEW_REFUNDED] = struct{}{}
|
// updateStatusMap[constants.STATUS_NEW_REFUNDED] = struct{}{}
|
||||||
updateStatusMap[constants.STATUS_NEW_CLOSE] = struct{}{}
|
// updateStatusMap[constants.STATUS_NEW_CLOSE] = struct{}{}
|
||||||
if _, ok := updateStatusMap[constants.Order(*orderInfo.Status)]; !ok {
|
// if _, ok := updateStatusMap[constants.Order(*orderInfo.Status)]; !ok {
|
||||||
return resp.SetStatusWithMessage(basic.CodeDbRecordNotFoundErr, "order not found")
|
// return resp.SetStatusWithMessage(basic.CodeDbRecordNotFoundErr, "order not found")
|
||||||
}
|
// }
|
||||||
*orderInfo.Status = int64(constants.STATUS_NEW_DELETE)
|
// *orderInfo.Status = int64(constants.STATUS_NEW_DELETE)
|
||||||
*orderInfo.IsDeleted = 1
|
// *orderInfo.IsDeleted = 1
|
||||||
err = orderModel.Update(l.ctx, orderInfo)
|
// err = orderModel.Update(l.ctx, orderInfo)
|
||||||
if err != nil {
|
// if err != nil {
|
||||||
logx.Error(err)
|
// logx.Error(err)
|
||||||
return resp.SetStatusWithMessage(basic.CodeServiceErr, "fail to delete")
|
// return resp.SetStatusWithMessage(basic.CodeServiceErr, "fail to delete")
|
||||||
}
|
// }
|
||||||
|
|
||||||
return resp.SetStatus(basic.CodeOK)
|
return resp.SetStatus(basic.CodeOK)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,20 +1,8 @@
|
|||||||
package logic
|
package logic
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"errors"
|
|
||||||
"fmt"
|
|
||||||
"fusenapi/constants"
|
|
||||||
"fusenapi/model/gmodel"
|
|
||||||
"fusenapi/utils/auth"
|
"fusenapi/utils/auth"
|
||||||
"fusenapi/utils/basic"
|
"fusenapi/utils/basic"
|
||||||
"fusenapi/utils/configs"
|
|
||||||
"fusenapi/utils/image"
|
|
||||||
"strings"
|
|
||||||
|
|
||||||
"fusenapi/utils/format"
|
|
||||||
"fusenapi/utils/order"
|
|
||||||
"math"
|
|
||||||
"time"
|
|
||||||
|
|
||||||
"context"
|
"context"
|
||||||
|
|
||||||
@@ -22,7 +10,6 @@ import (
|
|||||||
"fusenapi/server/home-user-auth/internal/types"
|
"fusenapi/server/home-user-auth/internal/types"
|
||||||
|
|
||||||
"github.com/zeromicro/go-zero/core/logx"
|
"github.com/zeromicro/go-zero/core/logx"
|
||||||
"gorm.io/gorm"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
type UserOrderListLogic struct {
|
type UserOrderListLogic struct {
|
||||||
@@ -43,263 +30,264 @@ func (l *UserOrderListLogic) UserOrderList(req *types.UserOrderListReq, userinfo
|
|||||||
// 返回值必须调用Set重新返回, resp可以空指针调用 resp.SetStatus(basic.CodeOK, data)
|
// 返回值必须调用Set重新返回, resp可以空指针调用 resp.SetStatus(basic.CodeOK, data)
|
||||||
// userinfo 传入值时, 一定不为null
|
// userinfo 传入值时, 一定不为null
|
||||||
|
|
||||||
size := req.Size
|
// size := req.Size
|
||||||
|
|
||||||
if size > 0 {
|
// if size > 0 {
|
||||||
size = int64(image.GetCurrentSize(uint32(size)))
|
// size = int64(image.GetCurrentSize(uint32(size)))
|
||||||
}
|
// }
|
||||||
|
|
||||||
orderDetailModel := gmodel.NewFsOrderDetailModel(l.svcCtx.MysqlConn)
|
// orderDetailModel := gmodel.NewFsOrderDetailModel(l.svcCtx.MysqlConn)
|
||||||
orderDetailTemplateModel := gmodel.NewFsOrderDetailTemplateModel(l.svcCtx.MysqlConn)
|
// orderDetailTemplateModel := gmodel.NewFsOrderDetailTemplateModel(l.svcCtx.MysqlConn)
|
||||||
fsProductDesignModel := gmodel.NewFsProductDesignModel(l.svcCtx.MysqlConn)
|
// fsProductDesignModel := gmodel.NewFsProductDesignModel(l.svcCtx.MysqlConn)
|
||||||
orderModel := gmodel.NewFsOrderModel(l.svcCtx.MysqlConn)
|
// orderModel := gmodel.NewFsOrderModel(l.svcCtx.MysqlConn)
|
||||||
rowBuilder := orderModel.RowSelectBuilder(nil)
|
// rowBuilder := orderModel.RowSelectBuilder(nil)
|
||||||
if userinfo == nil || userinfo.UserId == 0 {
|
// if userinfo == nil || userinfo.UserId == 0 {
|
||||||
return resp.SetStatusWithMessage(basic.CodeDbRecordNotFoundErr, "order not found")
|
// return resp.SetStatusWithMessage(basic.CodeDbRecordNotFoundErr, "order not found")
|
||||||
}
|
// }
|
||||||
|
|
||||||
// 查询条件
|
// // 查询条件
|
||||||
var page = req.Page
|
// var page = req.Page
|
||||||
var pageSize = req.PageSize
|
// var pageSize = req.PageSize
|
||||||
var listRes []*gmodel.FsOrderRel
|
// var listRes []*gmodel.FsOrderRel
|
||||||
rowBuilder = rowBuilder.Where("user_id =?", userinfo.UserId).Where("status <> ?", constants.STATUS_NEW_NOT_PAY).Where("status <>?", constants.STATUS_NEW_DELETE)
|
// rowBuilder = rowBuilder.Where("user_id =?", userinfo.UserId).Where("status <> ?", constants.STATUS_NEW_NOT_PAY).Where("status <>?", constants.STATUS_NEW_DELETE)
|
||||||
|
|
||||||
// 根据时间来查询不同范围的订单
|
// // 根据时间来查询不同范围的订单
|
||||||
switch req.Time {
|
// switch req.Time {
|
||||||
case 1:
|
// case 1:
|
||||||
rowBuilder = rowBuilder.Where("ctime >?", time.Now().UTC().AddDate(0, -1, 0).Unix())
|
// rowBuilder = rowBuilder.Where("ctime >?", time.Now().UTC().AddDate(0, -1, 0).Unix())
|
||||||
case 2:
|
// case 2:
|
||||||
rowBuilder = rowBuilder.Where("ctime >?", time.Now().UTC().AddDate(0, -3, 0).Unix())
|
// rowBuilder = rowBuilder.Where("ctime >?", time.Now().UTC().AddDate(0, -3, 0).Unix())
|
||||||
case 3:
|
// case 3:
|
||||||
rowBuilder = rowBuilder.Where("ctime >?", time.Now().UTC().AddDate(0, -6, 0).Unix())
|
// rowBuilder = rowBuilder.Where("ctime >?", time.Now().UTC().AddDate(0, -6, 0).Unix())
|
||||||
case 4:
|
// case 4:
|
||||||
rowBuilder = rowBuilder.Where("ctime >?", time.Now().UTC().AddDate(-1, 0, 0).Unix())
|
// rowBuilder = rowBuilder.Where("ctime >?", time.Now().UTC().AddDate(-1, 0, 0).Unix())
|
||||||
default:
|
// default:
|
||||||
}
|
// }
|
||||||
|
|
||||||
//按照订单状态查询不同的订单
|
// //按照订单状态查询不同的订单
|
||||||
if req.Status != -1 {
|
// if req.Status != -1 {
|
||||||
switch req.Status {
|
// switch req.Status {
|
||||||
case 1:
|
// case 1:
|
||||||
rowBuilder = rowBuilder.Where("status in ?", [3]constants.Order{constants.STATUS_NEW_PART_PAY, constants.STATUS_NEW_PAY_COMPLETED, constants.STATUS_NEW_SURE})
|
// rowBuilder = rowBuilder.Where("status in ?", [3]constants.Order{constants.STATUS_NEW_PART_PAY, constants.STATUS_NEW_PAY_COMPLETED, constants.STATUS_NEW_SURE})
|
||||||
case 2:
|
// case 2:
|
||||||
rowBuilder = rowBuilder.Where("status in ?", [2]constants.Order{constants.STATUS_NEW_PRODUTING, constants.STATUS_NEW_PRODUT_COMPLETED})
|
// rowBuilder = rowBuilder.Where("status in ?", [2]constants.Order{constants.STATUS_NEW_PRODUTING, constants.STATUS_NEW_PRODUT_COMPLETED})
|
||||||
case 3:
|
// case 3:
|
||||||
rowBuilder = rowBuilder.Where("status in ?", [2]constants.Order{constants.STATUS_NEW_DELIVER, constants.STATUS_NEW_UPS})
|
// rowBuilder = rowBuilder.Where("status in ?", [2]constants.Order{constants.STATUS_NEW_DELIVER, constants.STATUS_NEW_UPS})
|
||||||
case 4:
|
// case 4:
|
||||||
rowBuilder = rowBuilder.Where("status =?", constants.STATUS_NEW_ARRIVAL)
|
// rowBuilder = rowBuilder.Where("status =?", constants.STATUS_NEW_ARRIVAL)
|
||||||
case 5:
|
// case 5:
|
||||||
rowBuilder = rowBuilder.Where("status =?", constants.STATUS_NEW_COMPLETED).Where("delivery_method =?", constants.DELIVERY_METHOD_ADDRESS)
|
// rowBuilder = rowBuilder.Where("status =?", constants.STATUS_NEW_COMPLETED).Where("delivery_method =?", constants.DELIVERY_METHOD_ADDRESS)
|
||||||
case 7:
|
// case 7:
|
||||||
rowBuilder = rowBuilder.Where("status in ?", [3]constants.Order{constants.STATUS_NEW_CANCEL, constants.STATUS_NEW_REFUNDED, constants.STATUS_NEW_REFUNDING})
|
// rowBuilder = rowBuilder.Where("status in ?", [3]constants.Order{constants.STATUS_NEW_CANCEL, constants.STATUS_NEW_REFUNDED, constants.STATUS_NEW_REFUNDING})
|
||||||
case 8:
|
// case 8:
|
||||||
rowBuilder = rowBuilder.Where("status =?", constants.STATUS_NEW_COMPLETED).Where("delivery_method =?", constants.DELIVERY_METHOD_CLOUD)
|
// rowBuilder = rowBuilder.Where("status =?", constants.STATUS_NEW_COMPLETED).Where("delivery_method =?", constants.DELIVERY_METHOD_CLOUD)
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
|
|
||||||
// 查询总数
|
// // 查询总数
|
||||||
total, err := orderModel.FindCount(l.ctx, rowBuilder, nil)
|
// total, err := orderModel.FindCount(l.ctx, rowBuilder, nil)
|
||||||
if err != nil {
|
// if err != nil {
|
||||||
if errors.Is(err, gorm.ErrRecordNotFound) {
|
// if errors.Is(err, gorm.ErrRecordNotFound) {
|
||||||
return resp.SetStatusWithMessage(basic.CodeDbRecordNotFoundErr, "order not found")
|
// return resp.SetStatusWithMessage(basic.CodeDbRecordNotFoundErr, "order not found")
|
||||||
}
|
// }
|
||||||
logx.Error(err)
|
// logx.Error(err)
|
||||||
return resp.SetStatusWithMessage(basic.CodeServiceErr, "failed to get order info")
|
// return resp.SetStatusWithMessage(basic.CodeServiceErr, "failed to get order info")
|
||||||
}
|
// }
|
||||||
|
|
||||||
// 查询数据
|
// // 查询数据
|
||||||
if total > 0 {
|
// if total > 0 {
|
||||||
rowBuilder = rowBuilder.Preload("FsOrderAffiliateInfo").Preload("FsOrderDetails", func(dbPreload *gorm.DB) *gorm.DB {
|
// 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(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(orderDetailTemplateModel.TableName()).Preload("FsProductDesignInfo", func(dbPreload *gorm.DB) *gorm.DB {
|
||||||
return dbPreload.Table(fsProductDesignModel.TableName()).Preload("OptionData").Preload("TemplateData")
|
// return dbPreload.Table(fsProductDesignModel.TableName()).Preload("OptionData").Preload("TemplateData")
|
||||||
}).Preload("FsProductSizeInfo")
|
// }).Preload("FsProductSizeInfo")
|
||||||
}).Preload("FsProductInfo")
|
// }).Preload("FsProductInfo")
|
||||||
})
|
// })
|
||||||
listRes, err = orderModel.FindPageListByPage(l.ctx, rowBuilder, &page, &pageSize, nil, "")
|
// listRes, err = orderModel.FindPageListByPage(l.ctx, rowBuilder, &page, &pageSize, nil, "")
|
||||||
}
|
// }
|
||||||
|
|
||||||
if err != nil {
|
// if err != nil {
|
||||||
if errors.Is(err, gorm.ErrRecordNotFound) {
|
// if errors.Is(err, gorm.ErrRecordNotFound) {
|
||||||
return resp.SetStatusWithMessage(basic.CodeDbRecordNotFoundErr, "order not found")
|
// return resp.SetStatusWithMessage(basic.CodeDbRecordNotFoundErr, "order not found")
|
||||||
}
|
// }
|
||||||
logx.Error(err)
|
// logx.Error(err)
|
||||||
return resp.SetStatusWithMessage(basic.CodeServiceErr, "failed to get order info")
|
// return resp.SetStatusWithMessage(basic.CodeServiceErr, "failed to get order info")
|
||||||
}
|
// }
|
||||||
listResLen := len(listRes)
|
// listResLen := len(listRes)
|
||||||
|
|
||||||
var respList []types.Items
|
// var respList []types.Items
|
||||||
if listResLen > 0 {
|
// if listResLen > 0 {
|
||||||
// 获取订单时间配置
|
// // 获取订单时间配置
|
||||||
orderTimeConfig, err := configs.GetOrderTimeConfig(l.ctx, l.svcCtx.MysqlConn)
|
// orderTimeConfig, err := configs.GetOrderTimeConfig(l.ctx, l.svcCtx.MysqlConn)
|
||||||
if err != nil {
|
// if err != nil {
|
||||||
return resp.SetStatusWithMessage(basic.CodeServiceErr, "failed to get config time info")
|
// return resp.SetStatusWithMessage(basic.CodeServiceErr, "failed to get config time info")
|
||||||
}
|
// }
|
||||||
|
|
||||||
// 数据处理
|
// // 数据处理
|
||||||
for _, item := range listRes {
|
// for _, item := range listRes {
|
||||||
var pbData types.Items
|
// var pbData types.Items
|
||||||
pbData.ID = item.Id
|
// pbData.ID = item.Id
|
||||||
pbData.Sn = *item.Sn
|
// pbData.Sn = *item.Sn
|
||||||
pbData.UserID = *item.UserId
|
// pbData.UserID = *item.UserId
|
||||||
pbData.TotalAmount = *item.TotalAmount
|
// pbData.TotalAmount = *item.TotalAmount
|
||||||
pbData.Ctime = format.TimeIntToFormat(*item.Ctime)
|
// pbData.Ctime = format.TimeIntToFormat(*item.Ctime)
|
||||||
pbData.Status = *item.Status
|
// pbData.Status = *item.Status
|
||||||
pbData.DeliveryMethod = *item.DeliveryMethod
|
// pbData.DeliveryMethod = *item.DeliveryMethod
|
||||||
pbData.TsTime = format.TimeToFormat(*item.TsTime)
|
// pbData.TsTime = format.TimeToFormat(*item.TsTime)
|
||||||
pbData.IsPayCompleted = *item.IsPayCompleted
|
// pbData.IsPayCompleted = *item.IsPayCompleted
|
||||||
pbData.DeliverSn = *item.DeliverSn
|
// pbData.DeliverSn = *item.DeliverSn
|
||||||
|
|
||||||
var pcsBox int64
|
// var pcsBox int64
|
||||||
var pcs int64
|
// var pcs int64
|
||||||
var productList []types.Product
|
// var productList []types.Product
|
||||||
|
|
||||||
var surplusAt int64
|
// var surplusAt int64
|
||||||
|
|
||||||
//如果是部分支付状态,那么取消订单倒计时2天
|
// //如果是部分支付状态,那么取消订单倒计时2天
|
||||||
if *item.Status == int64(constants.STATUS_NEW_PART_PAY) {
|
// if *item.Status == int64(constants.STATUS_NEW_PART_PAY) {
|
||||||
surplusAt = (*item.Ctime + int64(constants.CANCLE_ORDER_EXPIRE)) - time.Now().UTC().Unix()
|
// surplusAt = (*item.Ctime + int64(constants.CANCLE_ORDER_EXPIRE)) - time.Now().UTC().Unix()
|
||||||
if surplusAt < 0 {
|
// if surplusAt < 0 {
|
||||||
surplusAt = 0
|
// surplusAt = 0
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
|
|
||||||
fsOrderAffiliateInfo := item.FsOrderAffiliateInfo
|
// fsOrderAffiliateInfo := item.FsOrderAffiliateInfo
|
||||||
|
|
||||||
var sureTime int64
|
// var sureTime int64
|
||||||
var productTime int64
|
// var productTime int64
|
||||||
var ProductEndtime int64
|
// var ProductEndtime int64
|
||||||
var deliverTime int64
|
// var deliverTime int64
|
||||||
var upsDeliverTime int64
|
// var upsDeliverTime int64
|
||||||
var upsTime int64
|
// var upsTime int64
|
||||||
var arrivalTime int64
|
// var arrivalTime int64
|
||||||
var recevieTime int64
|
// var recevieTime int64
|
||||||
if fsOrderAffiliateInfo.Id > 0 {
|
// if fsOrderAffiliateInfo.Id > 0 {
|
||||||
sureTime = *fsOrderAffiliateInfo.SureTime
|
// sureTime = *fsOrderAffiliateInfo.SureTime
|
||||||
productTime = *fsOrderAffiliateInfo.ProductTime
|
// productTime = *fsOrderAffiliateInfo.ProductTime
|
||||||
ProductEndtime = *fsOrderAffiliateInfo.ProductEndtime
|
// ProductEndtime = *fsOrderAffiliateInfo.ProductEndtime
|
||||||
deliverTime = *fsOrderAffiliateInfo.DeliverTime
|
// deliverTime = *fsOrderAffiliateInfo.DeliverTime
|
||||||
upsDeliverTime = *fsOrderAffiliateInfo.UpsDeliverTime
|
// upsDeliverTime = *fsOrderAffiliateInfo.UpsDeliverTime
|
||||||
upsTime = *fsOrderAffiliateInfo.UpsTime
|
// upsTime = *fsOrderAffiliateInfo.UpsTime
|
||||||
arrivalTime = *fsOrderAffiliateInfo.ArrivalTime
|
// arrivalTime = *fsOrderAffiliateInfo.ArrivalTime
|
||||||
recevieTime = *fsOrderAffiliateInfo.RecevieTime
|
// recevieTime = *fsOrderAffiliateInfo.RecevieTime
|
||||||
}
|
// }
|
||||||
|
|
||||||
var getOrderStatusAndLogisticsReq = order.GetOrderStatusAndLogisticsReq{
|
// var getOrderStatusAndLogisticsReq = order.GetOrderStatusAndLogisticsReq{
|
||||||
OrderStatus: constants.Order(*item.Status),
|
// OrderStatus: constants.Order(*item.Status),
|
||||||
DeliveryMethod: constants.DeliveryMethod(*item.DeliveryMethod),
|
// DeliveryMethod: constants.DeliveryMethod(*item.DeliveryMethod),
|
||||||
IsPayCompleted: *item.IsAllProductCompleted,
|
// IsPayCompleted: *item.IsAllProductCompleted,
|
||||||
OrderCtime: *item.Ctime,
|
// OrderCtime: *item.Ctime,
|
||||||
|
|
||||||
SureTime: sureTime,
|
// SureTime: sureTime,
|
||||||
ProductTime: productTime,
|
// ProductTime: productTime,
|
||||||
ProductEndtime: ProductEndtime,
|
// ProductEndtime: ProductEndtime,
|
||||||
DeliverTime: deliverTime,
|
// DeliverTime: deliverTime,
|
||||||
UpsDeliverTime: upsDeliverTime,
|
// UpsDeliverTime: upsDeliverTime,
|
||||||
UpsTime: upsTime,
|
// UpsTime: upsTime,
|
||||||
ArrivalTime: arrivalTime,
|
// ArrivalTime: arrivalTime,
|
||||||
RecevieTime: recevieTime,
|
// RecevieTime: recevieTime,
|
||||||
|
|
||||||
WebSetTimeInfo: orderTimeConfig,
|
// WebSetTimeInfo: orderTimeConfig,
|
||||||
}
|
// }
|
||||||
|
|
||||||
statusAndLogisticsRes := order.GetOrderStatusAndLogistics(getOrderStatusAndLogisticsReq)
|
// statusAndLogisticsRes := order.GetOrderStatusAndLogistics(getOrderStatusAndLogisticsReq)
|
||||||
|
|
||||||
// 流程控制
|
// // 流程控制
|
||||||
var statusTime []types.StatusTime
|
// var statusTime []types.StatusTime
|
||||||
for _, itemTimes := range statusAndLogisticsRes.Times {
|
// for _, itemTimes := range statusAndLogisticsRes.Times {
|
||||||
statusTime = append(statusTime, types.StatusTime{
|
// statusTime = append(statusTime, types.StatusTime{
|
||||||
Key: itemTimes.Key,
|
// Key: itemTimes.Key,
|
||||||
Time: itemTimes.Time,
|
// Time: itemTimes.Time,
|
||||||
})
|
// })
|
||||||
}
|
// }
|
||||||
pbData.StatusTimes = statusTime
|
// pbData.StatusTimes = statusTime
|
||||||
pbData.LogisticsStatus = int64(statusAndLogisticsRes.LogisticsStatus)
|
// pbData.LogisticsStatus = int64(statusAndLogisticsRes.LogisticsStatus)
|
||||||
pbData.Status = int64(statusAndLogisticsRes.OrderStatus)
|
// pbData.Status = int64(statusAndLogisticsRes.OrderStatus)
|
||||||
|
|
||||||
var isStopMax int64
|
// var isStopMax int64
|
||||||
if len(item.FsOrderDetails) > 0 {
|
// if len(item.FsOrderDetails) > 0 {
|
||||||
for _, fsOrderDetailItem := range item.FsOrderDetails {
|
// for _, fsOrderDetailItem := range item.FsOrderDetails {
|
||||||
|
|
||||||
fsOrderDetailBuyNum := *fsOrderDetailItem.FsOrderDetail.BuyNum
|
// fsOrderDetailBuyNum := *fsOrderDetailItem.FsOrderDetail.BuyNum
|
||||||
fsOrderDetailEachBoxNum := *fsOrderDetailItem.FsOrderDetailTemplateInfo.EachBoxNum
|
// fsOrderDetailEachBoxNum := *fsOrderDetailItem.FsOrderDetailTemplateInfo.EachBoxNum
|
||||||
pcs = pcs + fsOrderDetailBuyNum
|
// pcs = pcs + fsOrderDetailBuyNum
|
||||||
pcsBoxNum := fsOrderDetailBuyNum / fsOrderDetailEachBoxNum
|
// pcsBoxNum := fsOrderDetailBuyNum / fsOrderDetailEachBoxNum
|
||||||
var csBoxNumF int64
|
// var csBoxNumF int64
|
||||||
if (fsOrderDetailBuyNum % fsOrderDetailEachBoxNum) > 0 {
|
// if (fsOrderDetailBuyNum % fsOrderDetailEachBoxNum) > 0 {
|
||||||
csBoxNumF = 1
|
// csBoxNumF = 1
|
||||||
}
|
// }
|
||||||
pcsBox = pcsBox + pcsBoxNum + csBoxNumF
|
// pcsBox = pcsBox + pcsBoxNum + csBoxNumF
|
||||||
|
|
||||||
productCover := *fsOrderDetailItem.Cover
|
// productCover := *fsOrderDetailItem.Cover
|
||||||
// 尺寸
|
// // 尺寸
|
||||||
if size >= 200 {
|
// if size >= 200 {
|
||||||
coverArr := strings.Split(*fsOrderDetailItem.Cover, ".")
|
// coverArr := strings.Split(*fsOrderDetailItem.Cover, ".")
|
||||||
if len(coverArr) < 2 {
|
// if len(coverArr) < 2 {
|
||||||
return resp.SetStatusWithMessage(basic.CodeServiceErr, "cover split slice item count is less than 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])
|
// productCover = fmt.Sprintf("%s_%d.%s", coverArr[0], req.Size, coverArr[1])
|
||||||
}
|
// }
|
||||||
|
|
||||||
// 判断stop
|
// // 判断stop
|
||||||
var isStop int64
|
// var isStop int64
|
||||||
if fsOrderDetailItem.FsOrderDetailTemplateInfo.FsProductDesignInfo.OptionData.Id != 0 {
|
// if fsOrderDetailItem.FsOrderDetailTemplateInfo.FsProductDesignInfo.OptionData.Id != 0 {
|
||||||
// 尺寸或者模板下架
|
// // 尺寸或者模板下架
|
||||||
if fsOrderDetailItem.FsOrderDetailTemplateInfo.FsProductDesignInfo.Id != 0 {
|
// if fsOrderDetailItem.FsOrderDetailTemplateInfo.FsProductDesignInfo.Id != 0 {
|
||||||
isStop = 1
|
// isStop = 1
|
||||||
} else {
|
// } else {
|
||||||
isStop = 3
|
// isStop = 3
|
||||||
}
|
// }
|
||||||
} else {
|
// } else {
|
||||||
if fsOrderDetailItem.FsOrderDetailTemplateInfo.FsProductDesignInfo.Id != 0 {
|
// if fsOrderDetailItem.FsOrderDetailTemplateInfo.FsProductDesignInfo.Id != 0 {
|
||||||
isStop = 1
|
// isStop = 1
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
|
|
||||||
// 判断产品是否下架
|
// // 判断产品是否下架
|
||||||
if *fsOrderDetailItem.FsProductInfo.IsShelf == 0 || *fsOrderDetailItem.FsProductInfo.IsDel == 1 {
|
// if *fsOrderDetailItem.FsProductInfo.IsShelf == 0 || *fsOrderDetailItem.FsProductInfo.IsDel == 1 {
|
||||||
isStop = 2
|
// isStop = 2
|
||||||
}
|
// }
|
||||||
if isStop > isStopMax {
|
// if isStop > isStopMax {
|
||||||
isStopMax = isStop
|
// isStopMax = isStop
|
||||||
}
|
// }
|
||||||
|
|
||||||
productList = append(productList, types.Product{
|
// productList = append(productList, types.Product{
|
||||||
Cover: productCover,
|
// Cover: productCover,
|
||||||
Fitting: *fsOrderDetailItem.OptionalTitle,
|
// Fitting: *fsOrderDetailItem.OptionalTitle,
|
||||||
OptionPrice: *fsOrderDetailItem.OptionPrice,
|
// OptionPrice: *fsOrderDetailItem.OptionPrice,
|
||||||
OrderDetailTemplateId: *fsOrderDetailItem.OrderDetailTemplateId,
|
// OrderDetailTemplateId: *fsOrderDetailItem.OrderDetailTemplateId,
|
||||||
OrderId: *fsOrderDetailItem.OrderId,
|
// OrderId: *fsOrderDetailItem.OrderId,
|
||||||
Pcs: fsOrderDetailBuyNum,
|
// Pcs: fsOrderDetailBuyNum,
|
||||||
PcsBox: pcsBox,
|
// PcsBox: pcsBox,
|
||||||
Price: *fsOrderDetailItem.FsOrderDetail.Amount,
|
// Price: *fsOrderDetailItem.FsOrderDetail.Amount,
|
||||||
ProductId: *fsOrderDetailItem.OptionPrice,
|
// ProductId: *fsOrderDetailItem.OptionPrice,
|
||||||
Title: *fsOrderDetailItem.FsProductInfo.Title,
|
// Title: *fsOrderDetailItem.FsProductInfo.Title,
|
||||||
Size: *fsOrderDetailItem.FsOrderDetailTemplateInfo.FsProductSizeInfo.Capacity,
|
// Size: *fsOrderDetailItem.FsOrderDetailTemplateInfo.FsProductSizeInfo.Capacity,
|
||||||
IsStop: isStop,
|
// IsStop: isStop,
|
||||||
})
|
// })
|
||||||
}
|
// }
|
||||||
pbData.ProductList = productList
|
// pbData.ProductList = productList
|
||||||
}
|
// }
|
||||||
|
|
||||||
pbData.IsStop = isStopMax
|
// pbData.IsStop = isStopMax
|
||||||
pbData.PcsBox = pcsBox
|
// pbData.PcsBox = pcsBox
|
||||||
pbData.Pcs = pcs
|
// pbData.Pcs = pcs
|
||||||
pbData.SurplusAt = surplusAt
|
// pbData.SurplusAt = surplusAt
|
||||||
pbData.Deposit = *item.TotalAmount / 2
|
// pbData.Deposit = *item.TotalAmount / 2
|
||||||
pbData.Remaining = pbData.Deposit
|
// pbData.Remaining = pbData.Deposit
|
||||||
respList = append(respList, pbData)
|
// respList = append(respList, pbData)
|
||||||
}
|
// }
|
||||||
|
|
||||||
}
|
// }
|
||||||
|
|
||||||
return resp.SetStatusWithMessage(basic.CodeOK, "success", types.UserOrderListRsp{
|
// return resp.SetStatusWithMessage(basic.CodeOK, "success", types.UserOrderListRsp{
|
||||||
Items: respList,
|
// Items: respList,
|
||||||
Meta: types.Meta{
|
// Meta: types.Meta{
|
||||||
TotalCount: total,
|
// TotalCount: total,
|
||||||
PageCount: int64(math.Ceil(float64(total) / float64(pageSize))),
|
// PageCount: int64(math.Ceil(float64(total) / float64(pageSize))),
|
||||||
CurrentPage: int(page),
|
// CurrentPage: int(page),
|
||||||
PerPage: int(pageSize),
|
// PerPage: int(pageSize),
|
||||||
},
|
// },
|
||||||
})
|
// })
|
||||||
|
return resp.SetStatusWithMessage(basic.CodeOK, "success")
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,13 +1,8 @@
|
|||||||
package logic
|
package logic
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"errors"
|
|
||||||
"fusenapi/constants"
|
|
||||||
"fusenapi/model/gmodel"
|
|
||||||
"fusenapi/utils/auth"
|
"fusenapi/utils/auth"
|
||||||
"fusenapi/utils/basic"
|
"fusenapi/utils/basic"
|
||||||
"fusenapi/utils/pay"
|
|
||||||
"time"
|
|
||||||
|
|
||||||
"context"
|
"context"
|
||||||
|
|
||||||
@@ -15,7 +10,6 @@ import (
|
|||||||
"fusenapi/server/pay/internal/types"
|
"fusenapi/server/pay/internal/types"
|
||||||
|
|
||||||
"github.com/zeromicro/go-zero/core/logx"
|
"github.com/zeromicro/go-zero/core/logx"
|
||||||
"gorm.io/gorm"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
type OrderPaymentIntentLogic struct {
|
type OrderPaymentIntentLogic struct {
|
||||||
@@ -45,143 +39,143 @@ func (l *OrderPaymentIntentLogic) OrderPaymentIntent(req *types.OrderPaymentInte
|
|||||||
// 返回值必须调用Set重新返回, resp可以空指针调用 resp.SetStatus(basic.CodeOK, data)
|
// 返回值必须调用Set重新返回, resp可以空指针调用 resp.SetStatus(basic.CodeOK, data)
|
||||||
// userinfo 传入值时, 一定不为null
|
// userinfo 传入值时, 一定不为null
|
||||||
|
|
||||||
if userinfo == nil || userinfo.UserId == 0 {
|
// if userinfo == nil || userinfo.UserId == 0 {
|
||||||
return resp.SetStatusWithMessage(basic.CodeDbRecordNotFoundErr, "order not found")
|
// return resp.SetStatusWithMessage(basic.CodeDbRecordNotFoundErr, "order not found")
|
||||||
}
|
// }
|
||||||
|
|
||||||
// 查询订单数据
|
// // 查询订单数据
|
||||||
orderModel := gmodel.NewFsOrderModel(l.svcCtx.MysqlConn)
|
// orderModel := gmodel.NewFsOrderModel(l.svcCtx.MysqlConn)
|
||||||
orderInfo, err := orderModel.FindOneBySn(l.ctx, userinfo.UserId, req.Sn)
|
// orderInfo, err := orderModel.FindOneBySn(l.ctx, userinfo.UserId, req.Sn)
|
||||||
|
|
||||||
if err != nil {
|
// if err != nil {
|
||||||
if errors.Is(err, gorm.ErrRecordNotFound) {
|
// if errors.Is(err, gorm.ErrRecordNotFound) {
|
||||||
return resp.SetStatusWithMessage(basic.CodeDbRecordNotFoundErr, "order not found")
|
// return resp.SetStatusWithMessage(basic.CodeDbRecordNotFoundErr, "order not found")
|
||||||
}
|
// }
|
||||||
logx.Error(err)
|
// logx.Error(err)
|
||||||
return resp.SetStatusWithMessage(basic.CodeServiceErr, "failed to get order info")
|
// return resp.SetStatusWithMessage(basic.CodeServiceErr, "failed to get order info")
|
||||||
}
|
// }
|
||||||
|
|
||||||
// 校验订单状态
|
// // 校验订单状态
|
||||||
if *orderInfo.IsCancel == 1 {
|
// if *orderInfo.IsCancel == 1 {
|
||||||
return resp.SetStatusWithMessage(basic.CodeServiceErr, "order cancelled")
|
// return resp.SetStatusWithMessage(basic.CodeServiceErr, "order cancelled")
|
||||||
}
|
// }
|
||||||
|
|
||||||
// 校验地址信息
|
// // 校验地址信息
|
||||||
addressModel := gmodel.NewFsAddressModel(l.svcCtx.MysqlConn)
|
// addressModel := gmodel.NewFsAddressModel(l.svcCtx.MysqlConn)
|
||||||
_, err = addressModel.GetOne(l.ctx, req.AddressId, userinfo.UserId)
|
// _, err = addressModel.GetOne(l.ctx, req.AddressId, userinfo.UserId)
|
||||||
|
|
||||||
if err != nil {
|
// if err != nil {
|
||||||
if errors.Is(err, gorm.ErrRecordNotFound) {
|
// if errors.Is(err, gorm.ErrRecordNotFound) {
|
||||||
return resp.SetStatusWithMessage(basic.CodeDbRecordNotFoundErr, "address not found")
|
// return resp.SetStatusWithMessage(basic.CodeDbRecordNotFoundErr, "address not found")
|
||||||
}
|
// }
|
||||||
logx.Error(err)
|
// logx.Error(err)
|
||||||
return resp.SetStatusWithMessage(basic.CodeServiceErr, "failed to get address info")
|
// return resp.SetStatusWithMessage(basic.CodeServiceErr, "failed to get address info")
|
||||||
}
|
// }
|
||||||
|
|
||||||
// 校验订单支付信息
|
// // 校验订单支付信息
|
||||||
if *orderInfo.IsPayCompleted == 1 {
|
// if *orderInfo.IsPayCompleted == 1 {
|
||||||
return resp.SetStatusWithMessage(basic.CodeServiceErr, "order is pay completed")
|
// return resp.SetStatusWithMessage(basic.CodeServiceErr, "order is pay completed")
|
||||||
}
|
// }
|
||||||
|
|
||||||
// 判断订单状态以及该支付金额
|
// // 判断订单状态以及该支付金额
|
||||||
var nowAt int64 = time.Now().UTC().Unix()
|
// var nowAt int64 = time.Now().UTC().Unix()
|
||||||
var payAmount int64
|
// var payAmount int64
|
||||||
if *orderInfo.Status == int64(constants.STATUS_NEW_NOT_PAY) {
|
// if *orderInfo.Status == int64(constants.STATUS_NEW_NOT_PAY) {
|
||||||
payAmount = *orderInfo.TotalAmount / 2
|
// payAmount = *orderInfo.TotalAmount / 2
|
||||||
*orderInfo.DeliveryMethod = req.DeliveryMethod
|
// *orderInfo.DeliveryMethod = req.DeliveryMethod
|
||||||
*orderInfo.AddressId = req.AddressId
|
// *orderInfo.AddressId = req.AddressId
|
||||||
*orderInfo.PayMethod = req.PayMethod
|
// *orderInfo.PayMethod = req.PayMethod
|
||||||
} else {
|
// } else {
|
||||||
payAmount = *orderInfo.TotalAmount - *orderInfo.TotalAmount/2
|
// payAmount = *orderInfo.TotalAmount - *orderInfo.TotalAmount/2
|
||||||
}
|
// }
|
||||||
|
|
||||||
payConfig := &pay.Config{}
|
// payConfig := &pay.Config{}
|
||||||
var generatePrepaymentReq = &pay.GeneratePrepaymentReq{
|
// var generatePrepaymentReq = &pay.GeneratePrepaymentReq{
|
||||||
OrderSn: req.Sn,
|
// OrderSn: req.Sn,
|
||||||
ProductName: "支付标题",
|
// ProductName: "支付标题",
|
||||||
Amount: payAmount,
|
// Amount: payAmount,
|
||||||
Currency: "eur",
|
// Currency: "eur",
|
||||||
Quantity: 1,
|
// Quantity: 1,
|
||||||
ProductDescription: "支付描述",
|
// ProductDescription: "支付描述",
|
||||||
}
|
// }
|
||||||
|
|
||||||
var resData types.OrderPaymentIntentRes
|
// var resData types.OrderPaymentIntentRes
|
||||||
// 事务处理
|
// // 事务处理
|
||||||
ctx := l.ctx
|
// ctx := l.ctx
|
||||||
err = l.svcCtx.MysqlConn.Transaction(func(connGorm *gorm.DB) error {
|
// err = l.svcCtx.MysqlConn.Transaction(func(connGorm *gorm.DB) error {
|
||||||
// 支付记录--处理 //支付记录改为一条订单多条,分首款尾款
|
// // 支付记录--处理 //支付记录改为一条订单多条,分首款尾款
|
||||||
var payStatus int64 = 0
|
// var payStatus int64 = 0
|
||||||
var orderSource int64 = 1
|
// var orderSource int64 = 1
|
||||||
var payStage int64
|
// var payStage int64
|
||||||
var fspay *gmodel.FsPay
|
// var fspay *gmodel.FsPay
|
||||||
newFsPayModel := gmodel.NewFsPayModel(connGorm)
|
// newFsPayModel := gmodel.NewFsPayModel(connGorm)
|
||||||
if *orderInfo.Status == int64(constants.STATUS_NEW_NOT_PAY) {
|
// if *orderInfo.Status == int64(constants.STATUS_NEW_NOT_PAY) {
|
||||||
fspay, err = newFsPayModel.RBGetListByOrderNumberStage(ctx, *orderInfo.Sn, 1)
|
// fspay, err = newFsPayModel.RBGetListByOrderNumberStage(ctx, *orderInfo.Sn, 1)
|
||||||
if err != nil {
|
// if err != nil {
|
||||||
if !errors.Is(err, gorm.ErrRecordNotFound) {
|
// if !errors.Is(err, gorm.ErrRecordNotFound) {
|
||||||
return err
|
// return err
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
payStage = 1
|
// payStage = 1
|
||||||
} else {
|
// } else {
|
||||||
fspay, err = newFsPayModel.RBGetListByOrderNumberStage(ctx, *orderInfo.Sn, 2)
|
// fspay, err = newFsPayModel.RBGetListByOrderNumberStage(ctx, *orderInfo.Sn, 2)
|
||||||
if err != nil {
|
// if err != nil {
|
||||||
if !errors.Is(err, gorm.ErrRecordNotFound) {
|
// if !errors.Is(err, gorm.ErrRecordNotFound) {
|
||||||
return err
|
// return err
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
payStage = 2
|
// payStage = 2
|
||||||
}
|
// }
|
||||||
|
|
||||||
// 支付预付--生成
|
// // 支付预付--生成
|
||||||
if constants.PayMethod(req.PayMethod) == constants.PAYMETHOD_STRIPE {
|
// if constants.PayMethod(req.PayMethod) == constants.PAYMETHOD_STRIPE {
|
||||||
payConfig.Stripe.Key = l.svcCtx.Config.PayConfig.Stripe.Key
|
// payConfig.Stripe.Key = l.svcCtx.Config.PayConfig.Stripe.Key
|
||||||
generatePrepaymentReq.SuccessURL = l.svcCtx.Config.PayConfig.Stripe.SuccessURL
|
// generatePrepaymentReq.SuccessURL = l.svcCtx.Config.PayConfig.Stripe.SuccessURL
|
||||||
generatePrepaymentReq.CancelURL = l.svcCtx.Config.PayConfig.Stripe.CancelURL
|
// generatePrepaymentReq.CancelURL = l.svcCtx.Config.PayConfig.Stripe.CancelURL
|
||||||
}
|
// }
|
||||||
payDriver := pay.NewPayDriver(req.PayMethod, payConfig)
|
// payDriver := pay.NewPayDriver(req.PayMethod, payConfig)
|
||||||
prepaymentRes, err := payDriver.GeneratePrepayment(generatePrepaymentReq)
|
// prepaymentRes, err := payDriver.GeneratePrepayment(generatePrepaymentReq)
|
||||||
if err != nil {
|
// if err != nil {
|
||||||
return err
|
// return err
|
||||||
}
|
// }
|
||||||
|
|
||||||
// 订单信息--修改
|
// // 订单信息--修改
|
||||||
err = gmodel.NewFsOrderModel(connGorm).RBUpdate(ctx, orderInfo)
|
// err = gmodel.NewFsOrderModel(connGorm).RBUpdate(ctx, orderInfo)
|
||||||
if err != nil {
|
// if err != nil {
|
||||||
return err
|
// return err
|
||||||
}
|
// }
|
||||||
|
|
||||||
if fspay == nil {
|
// if fspay == nil {
|
||||||
fspay = &gmodel.FsPay{
|
// fspay = &gmodel.FsPay{
|
||||||
UserId: orderInfo.UserId,
|
// UserId: orderInfo.UserId,
|
||||||
OrderNumber: orderInfo.Sn,
|
// OrderNumber: orderInfo.Sn,
|
||||||
CreatedAt: &nowAt,
|
// CreatedAt: &nowAt,
|
||||||
}
|
// }
|
||||||
} else {
|
// } else {
|
||||||
fspay.UpdatedAt = &nowAt
|
// fspay.UpdatedAt = &nowAt
|
||||||
}
|
// }
|
||||||
fspay.PayAmount = &payAmount
|
// fspay.PayAmount = &payAmount
|
||||||
fspay.PayStage = &payStage
|
// fspay.PayStage = &payStage
|
||||||
//fspay.TradeNo = &prepaymentRes.TradeNo
|
// //fspay.TradeNo = &prepaymentRes.TradeNo
|
||||||
fspay.PaymentMethod = &req.PayMethod
|
// fspay.PaymentMethod = &req.PayMethod
|
||||||
fspay.OrderSource = &orderSource
|
// fspay.OrderSource = &orderSource
|
||||||
fspay.PayStatus = &payStatus
|
// fspay.PayStatus = &payStatus
|
||||||
|
|
||||||
_, err = newFsPayModel.RBCreateOrUpdate(ctx, fspay)
|
// _, err = newFsPayModel.RBCreateOrUpdate(ctx, fspay)
|
||||||
if err != nil {
|
// if err != nil {
|
||||||
return err
|
// return err
|
||||||
}
|
// }
|
||||||
|
|
||||||
resData.RedirectUrl = prepaymentRes.URL
|
// resData.RedirectUrl = prepaymentRes.URL
|
||||||
resData.ClientSecret = prepaymentRes.ClientSecret
|
// resData.ClientSecret = prepaymentRes.ClientSecret
|
||||||
|
|
||||||
return nil
|
// return nil
|
||||||
})
|
// })
|
||||||
|
|
||||||
if err != nil {
|
// if err != nil {
|
||||||
logx.Error(err)
|
// logx.Error(err)
|
||||||
return resp.SetStatusWithMessage(basic.CodeServiceErr, "failed to make payment")
|
// return resp.SetStatusWithMessage(basic.CodeServiceErr, "failed to make payment")
|
||||||
}
|
// }
|
||||||
|
|
||||||
return resp.SetStatusWithMessage(basic.CodeOK, "success", resData)
|
return resp.SetStatusWithMessage(basic.CodeOK, "success")
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,13 +1,9 @@
|
|||||||
package logic
|
package logic
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"encoding/json"
|
|
||||||
"errors"
|
|
||||||
"fusenapi/constants"
|
|
||||||
"fusenapi/model/gmodel"
|
"fusenapi/model/gmodel"
|
||||||
"fusenapi/utils/auth"
|
"fusenapi/utils/auth"
|
||||||
"fusenapi/utils/basic"
|
"fusenapi/utils/basic"
|
||||||
"time"
|
|
||||||
|
|
||||||
"context"
|
"context"
|
||||||
|
|
||||||
@@ -15,9 +11,7 @@ import (
|
|||||||
"fusenapi/server/pay/internal/types"
|
"fusenapi/server/pay/internal/types"
|
||||||
|
|
||||||
"github.com/stripe/stripe-go/v74"
|
"github.com/stripe/stripe-go/v74"
|
||||||
"github.com/stripe/stripe-go/v74/webhook"
|
|
||||||
"github.com/zeromicro/go-zero/core/logx"
|
"github.com/zeromicro/go-zero/core/logx"
|
||||||
"gorm.io/gorm"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
type StripeWebhookLogic struct {
|
type StripeWebhookLogic struct {
|
||||||
@@ -48,97 +42,97 @@ func (l *StripeWebhookLogic) StripeWebhook(req *types.StripeWebhookReq, userinfo
|
|||||||
// 返回值必须调用Set重新返回, resp可以空指针调用 resp.SetStatus(basic.CodeOK, data)
|
// 返回值必须调用Set重新返回, resp可以空指针调用 resp.SetStatus(basic.CodeOK, data)
|
||||||
// userinfo 传入值时, 一定不为null
|
// userinfo 传入值时, 一定不为null
|
||||||
|
|
||||||
stripe.Key = l.svcCtx.Config.PayConfig.Stripe.Key
|
// stripe.Key = l.svcCtx.Config.PayConfig.Stripe.Key
|
||||||
event := stripe.Event{}
|
// event := stripe.Event{}
|
||||||
|
|
||||||
if err := json.Unmarshal(req.Payload, &event); err != nil {
|
// 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 {
|
|
||||||
// logx.Error(err)
|
// 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":
|
// endpointSecret := l.svcCtx.Config.PayConfig.Stripe.EndpointSecret
|
||||||
// checkout checkout.session.completed 处理逻辑
|
// signatureHeader := req.StripeSignature
|
||||||
// var session stripe.CheckoutSession
|
// event, err := webhook.ConstructEvent(req.Payload, signatureHeader, endpointSecret)
|
||||||
// err := json.Unmarshal(event.Data.Raw, &session)
|
|
||||||
// if err != nil {
|
// if err != nil {
|
||||||
// logx.Error(err)
|
// 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")
|
// return resp.SetStatusWithMessage(basic.CodeAesCbcDecryptionErr, "pay notify Unmarshal fail event.Type payment_intent.succeeded")
|
||||||
// }
|
// }
|
||||||
// fmt.Println("checkout.session.completed")
|
// err = l.HandlePaymentIntentSucceeded(&paymentIntent)
|
||||||
// err = l.handlePaymentSessionCompleted(session.ID, session.PaymentIntent.ID)
|
|
||||||
// if err != nil {
|
// 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
|
// // ... handle other event types
|
||||||
default:
|
// default:
|
||||||
logx.Error("Unhandled event")
|
// logx.Error("Unhandled event")
|
||||||
return resp.SetStatusWithMessage(basic.CodeAesCbcDecryptionErr, "pay notify Unmarshal fail event.Type Unhandled")
|
// return resp.SetStatusWithMessage(basic.CodeAesCbcDecryptionErr, "pay notify Unmarshal fail event.Type Unhandled")
|
||||||
}
|
// }
|
||||||
|
|
||||||
return resp.SetStatus(basic.CodeOK)
|
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) {
|
func (l *StripeWebhookLogic) HandleChargeRefunded(chargeRefunded *stripe.Charge) (err error) {
|
||||||
// 退款成功
|
// // 退款成功
|
||||||
if chargeRefunded.Status == "succeeded" {
|
// if chargeRefunded.Status == "succeeded" {
|
||||||
ctx := l.ctx
|
// ctx := l.ctx
|
||||||
err = l.svcCtx.MysqlConn.Transaction(func(connGorm *gorm.DB) error {
|
// err = l.svcCtx.MysqlConn.Transaction(func(connGorm *gorm.DB) error {
|
||||||
// 查询支付记录
|
// // 查询支付记录
|
||||||
payModelT := gmodel.NewFsPayModel(connGorm)
|
// payModelT := gmodel.NewFsPayModel(connGorm)
|
||||||
payModelTRSB := payModelT.BuilderTrans(nil)
|
// payModelTRSB := payModelT.BuilderTrans(nil)
|
||||||
payModelTRSB1 := payModelTRSB.Where("trade_no = ?", chargeRefunded.PaymentIntent.ID).Where("pay_status = ?", constants.PAYSTATUS_SUCCESS).Where("is_refund = ?", 0)
|
// 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)
|
// payInfo, err := payModelT.FindOneByQuery(ctx, payModelTRSB1, nil)
|
||||||
if err != nil {
|
// if err != nil {
|
||||||
return err
|
// return err
|
||||||
}
|
// }
|
||||||
// 更新支付记录
|
// // 更新支付记录
|
||||||
*payInfo.IsRefund = 1
|
// *payInfo.IsRefund = 1
|
||||||
_, err = payModelT.RBCreateOrUpdate(ctx, payInfo)
|
// _, err = payModelT.RBCreateOrUpdate(ctx, payInfo)
|
||||||
if err != nil {
|
// if err != nil {
|
||||||
return err
|
// return err
|
||||||
}
|
// }
|
||||||
// 获取是否还有未退款的数据
|
// // 获取是否还有未退款的数据
|
||||||
payModelTRSB2 := payModelTRSB.Where("order_number = ?", payInfo.OrderNumber).Where("pay_status = ?", constants.PAYSTATUS_SUCCESS).Where("is_refund = ?", 0)
|
// 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)
|
// count, err := payModelT.FindCount(l.ctx, payModelTRSB2, nil)
|
||||||
if count == 0 {
|
// if count == 0 {
|
||||||
// 退款完成更新订单状态
|
// // 退款完成更新订单状态
|
||||||
orderModelT := gmodel.NewFsOrderModel(connGorm)
|
// orderModelT := gmodel.NewFsOrderModel(connGorm)
|
||||||
orderModelTRSB := orderModelT.BuilderTrans(nil).Where("sn =?", payInfo.OrderNumber)
|
// orderModelTRSB := orderModelT.BuilderTrans(nil).Where("sn =?", payInfo.OrderNumber)
|
||||||
orderInfoRel, err := orderModelT.FindOneByQuery(ctx, orderModelTRSB, nil)
|
// orderInfoRel, err := orderModelT.FindOneByQuery(ctx, orderModelTRSB, nil)
|
||||||
if err != nil {
|
// if err != nil {
|
||||||
return err
|
// return err
|
||||||
}
|
// }
|
||||||
var isRefunded int64 = 1
|
// var isRefunded int64 = 1
|
||||||
var isRefunding int64 = 1
|
// var isRefunding int64 = 1
|
||||||
var orderStatus int64 = int64(constants.STATUS_NEW_REFUNDED)
|
// var orderStatus int64 = int64(constants.STATUS_NEW_REFUNDED)
|
||||||
var orderInfo = &gmodel.FsOrder{}
|
// var orderInfo = &gmodel.FsOrder{}
|
||||||
orderInfo.Id = orderInfoRel.Id
|
// orderInfo.Id = orderInfoRel.Id
|
||||||
orderInfo.IsRefunded = &isRefunded
|
// orderInfo.IsRefunded = &isRefunded
|
||||||
orderInfo.IsRefunding = &isRefunding
|
// orderInfo.IsRefunding = &isRefunding
|
||||||
orderInfo.Status = &orderStatus
|
// orderInfo.Status = &orderStatus
|
||||||
orderModelT.Update(ctx, orderInfo)
|
// orderModelT.Update(ctx, orderInfo)
|
||||||
|
|
||||||
// 记录退款原因
|
// // 记录退款原因
|
||||||
refundReasonModelT := gmodel.NewFsRefundReasonModel(connGorm)
|
// refundReasonModelT := gmodel.NewFsRefundReasonModel(connGorm)
|
||||||
refundReasonModelTRSB := refundReasonModelT.BuilderTrans(nil)
|
// refundReasonModelTRSB := refundReasonModelT.BuilderTrans(nil)
|
||||||
refundReasonModelTRSB1 := refundReasonModelTRSB.Where("order_id =?", orderInfoRel.Id)
|
// refundReasonModelTRSB1 := refundReasonModelTRSB.Where("order_id =?", orderInfoRel.Id)
|
||||||
refundReasonInfo, err := refundReasonModelT.FindOneByQuery(ctx, refundReasonModelTRSB1, nil)
|
// refundReasonInfo, err := refundReasonModelT.FindOneByQuery(ctx, refundReasonModelTRSB1, nil)
|
||||||
if err != nil {
|
// if err != nil {
|
||||||
return err
|
// return err
|
||||||
}
|
// }
|
||||||
*refundReasonInfo.IsRefund = 1
|
// *refundReasonInfo.IsRefund = 1
|
||||||
_, err = refundReasonModelT.RBCreateOrUpdate(ctx, refundReasonInfo)
|
// _, err = refundReasonModelT.RBCreateOrUpdate(ctx, refundReasonInfo)
|
||||||
if err != nil {
|
// if err != nil {
|
||||||
return err
|
// return err
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
return err
|
// 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 {
|
func (l *StripeWebhookLogic) HandlePaymentIntentSucceeded(paymentIntent *stripe.PaymentIntent) error {
|
||||||
orderSn, ok := paymentIntent.Metadata["order_sn"]
|
// orderSn, ok := paymentIntent.Metadata["order_sn"]
|
||||||
if !ok || orderSn == "" {
|
// if !ok || orderSn == "" {
|
||||||
return errors.New("order_sn not found")
|
// return errors.New("order_sn not found")
|
||||||
}
|
// }
|
||||||
|
|
||||||
// 查询支付记录
|
// // 查询支付记录
|
||||||
payModel := gmodel.NewFsPayModel(l.svcCtx.MysqlConn)
|
// payModel := gmodel.NewFsPayModel(l.svcCtx.MysqlConn)
|
||||||
rsbPay := payModel.RowSelectBuilder(nil)
|
// rsbPay := payModel.RowSelectBuilder(nil)
|
||||||
rsbPay = rsbPay.Where("order_number = ?", orderSn).Where("pay_status = ?", constants.PAYSTATUS_UNSUCCESS)
|
// rsbPay = rsbPay.Where("order_number = ?", orderSn).Where("pay_status = ?", constants.PAYSTATUS_UNSUCCESS)
|
||||||
payInfo, err := payModel.FindOneByQuery(l.ctx, rsbPay, nil)
|
// payInfo, err := payModel.FindOneByQuery(l.ctx, rsbPay, nil)
|
||||||
if err != nil {
|
// if err != nil {
|
||||||
return err
|
// return err
|
||||||
}
|
// }
|
||||||
|
|
||||||
//订单信息
|
// //订单信息
|
||||||
orderDetailTemplateModel := gmodel.NewFsOrderDetailTemplateModel(l.svcCtx.MysqlConn)
|
// orderDetailTemplateModel := gmodel.NewFsOrderDetailTemplateModel(l.svcCtx.MysqlConn)
|
||||||
orderModel := gmodel.NewFsOrderModel(l.svcCtx.MysqlConn)
|
// orderModel := gmodel.NewFsOrderModel(l.svcCtx.MysqlConn)
|
||||||
fsOrderDetailModel := gmodel.NewFsOrderDetailModel(l.svcCtx.MysqlConn)
|
// fsOrderDetailModel := gmodel.NewFsOrderDetailModel(l.svcCtx.MysqlConn)
|
||||||
fsProductDesignModel := gmodel.NewFsProductDesignModel(l.svcCtx.MysqlConn)
|
// fsProductDesignModel := gmodel.NewFsProductDesignModel(l.svcCtx.MysqlConn)
|
||||||
|
|
||||||
rsbOrder := orderModel.RowSelectBuilder(nil)
|
// rsbOrder := orderModel.RowSelectBuilder(nil)
|
||||||
rsbOrder = rsbOrder.Where("sn =?", orderSn).Preload("FsOrderDetails")
|
// rsbOrder = rsbOrder.Where("sn =?", orderSn).Preload("FsOrderDetails")
|
||||||
rsbOrder = rsbOrder.Preload("FsOrderDetails", func(dbPreload *gorm.DB) *gorm.DB {
|
// 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(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(orderDetailTemplateModel.TableName()).Preload("FsProductDesignInfo", func(dbPreload *gorm.DB) *gorm.DB {
|
||||||
return dbPreload.Table(fsProductDesignModel.TableName())
|
// return dbPreload.Table(fsProductDesignModel.TableName())
|
||||||
})
|
// })
|
||||||
})
|
// })
|
||||||
})
|
// })
|
||||||
fsOrderRelInfo, err := orderModel.FindOneByQuery(l.ctx, rsbOrder, nil)
|
// fsOrderRelInfo, err := orderModel.FindOneByQuery(l.ctx, rsbOrder, nil)
|
||||||
if err != nil {
|
// if err != nil {
|
||||||
return err
|
// return err
|
||||||
}
|
// }
|
||||||
|
|
||||||
var designIds []int64
|
// var designIds []int64
|
||||||
var cartIds []int64
|
// var cartIds []int64
|
||||||
if len(fsOrderRelInfo.FsOrderDetails) > 0 {
|
// if len(fsOrderRelInfo.FsOrderDetails) > 0 {
|
||||||
for _, fsOrderDetail := range fsOrderRelInfo.FsOrderDetails {
|
// for _, fsOrderDetail := range fsOrderRelInfo.FsOrderDetails {
|
||||||
if fsOrderDetail.FsOrderDetailTemplateInfo.FsProductDesignInfo.Id != 0 {
|
// if fsOrderDetail.FsOrderDetailTemplateInfo.FsProductDesignInfo.Id != 0 {
|
||||||
designIds = append(designIds, fsOrderDetail.FsOrderDetailTemplateInfo.FsProductDesignInfo.Id)
|
// designIds = append(designIds, fsOrderDetail.FsOrderDetailTemplateInfo.FsProductDesignInfo.Id)
|
||||||
}
|
// }
|
||||||
cartIds = append(cartIds, *fsOrderDetail.CartId)
|
// cartIds = append(cartIds, *fsOrderDetail.CartId)
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
|
|
||||||
var nowTime int64 = time.Now().UTC().Unix()
|
// var nowTime int64 = time.Now().UTC().Unix()
|
||||||
|
|
||||||
// 支付成功
|
// // 支付成功
|
||||||
if paymentIntent.Status == "succeeded" {
|
// if paymentIntent.Status == "succeeded" {
|
||||||
var card string
|
// var card string
|
||||||
var brand string
|
// var brand string
|
||||||
if paymentIntent.LatestCharge.PaymentMethodDetails != nil {
|
// if paymentIntent.LatestCharge.PaymentMethodDetails != nil {
|
||||||
if paymentIntent.LatestCharge.PaymentMethodDetails.Card != nil {
|
// if paymentIntent.LatestCharge.PaymentMethodDetails.Card != nil {
|
||||||
if paymentIntent.LatestCharge.PaymentMethodDetails.Card.Last4 != "" {
|
// if paymentIntent.LatestCharge.PaymentMethodDetails.Card.Last4 != "" {
|
||||||
card = paymentIntent.LatestCharge.PaymentMethodDetails.Card.Last4
|
// card = paymentIntent.LatestCharge.PaymentMethodDetails.Card.Last4
|
||||||
}
|
// }
|
||||||
if paymentIntent.LatestCharge.PaymentMethodDetails.Card.Brand != "" {
|
// if paymentIntent.LatestCharge.PaymentMethodDetails.Card.Brand != "" {
|
||||||
brand = string(paymentIntent.LatestCharge.PaymentMethodDetails.Card.Brand)
|
// brand = string(paymentIntent.LatestCharge.PaymentMethodDetails.Card.Brand)
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
|
|
||||||
ctx := l.ctx
|
// ctx := l.ctx
|
||||||
err = l.svcCtx.MysqlConn.Transaction(func(connGorm *gorm.DB) error {
|
// err = l.svcCtx.MysqlConn.Transaction(func(connGorm *gorm.DB) error {
|
||||||
// 更新支付信息
|
// // 更新支付信息
|
||||||
payModelT := gmodel.NewFsPayModel(connGorm)
|
// payModelT := gmodel.NewFsPayModel(connGorm)
|
||||||
*payInfo.PayStatus = 1
|
// *payInfo.PayStatus = 1
|
||||||
*payInfo.PayTime = nowTime
|
// *payInfo.PayTime = nowTime
|
||||||
*payInfo.CardNo = card
|
// *payInfo.CardNo = card
|
||||||
*payInfo.Brand = brand
|
// *payInfo.Brand = brand
|
||||||
*payInfo.TradeNo = paymentIntent.ID
|
// *payInfo.TradeNo = paymentIntent.ID
|
||||||
_, err = payModelT.RBCreateOrUpdate(ctx, payInfo)
|
// _, err = payModelT.RBCreateOrUpdate(ctx, payInfo)
|
||||||
if err != nil {
|
// if err != nil {
|
||||||
return err
|
// return err
|
||||||
}
|
// }
|
||||||
|
|
||||||
// 更新设计数据
|
// // 更新设计数据
|
||||||
productDesignModelT := gmodel.NewFsProductDesignModel(connGorm)
|
// productDesignModelT := gmodel.NewFsProductDesignModel(connGorm)
|
||||||
productDesignModelTRSB := productDesignModelT.BuilderTrans(ctx, nil)
|
// productDesignModelTRSB := productDesignModelT.BuilderTrans(ctx, nil)
|
||||||
var isPay int64 = 1
|
// var isPay int64 = 1
|
||||||
err = productDesignModelT.RBUpdateByIds(productDesignModelTRSB, designIds, &gmodel.FsProductDesign{IsPay: &isPay})
|
// err = productDesignModelT.RBUpdateByIds(productDesignModelTRSB, designIds, &gmodel.FsProductDesign{IsPay: &isPay})
|
||||||
if err != nil {
|
// if err != nil {
|
||||||
return err
|
// return err
|
||||||
}
|
// }
|
||||||
|
|
||||||
var orderInfo = &gmodel.FsOrder{}
|
// var orderInfo = &gmodel.FsOrder{}
|
||||||
var orderStatus int64
|
// var orderStatus int64
|
||||||
var orderIsPartPay int64
|
// var orderIsPartPay int64
|
||||||
var orderPayedAmount int64
|
// var orderPayedAmount int64
|
||||||
var orderIsPayCompleted int64
|
// var orderIsPayCompleted int64
|
||||||
// 支付记录是首款
|
// // 支付记录是首款
|
||||||
if *payInfo.PayStage == int64(constants.PAYSTAGE_DEPOSIT) {
|
// if *payInfo.PayStage == int64(constants.PAYSTAGE_DEPOSIT) {
|
||||||
orderStatus = int64(constants.STATUS_NEW_PART_PAY)
|
// orderStatus = int64(constants.STATUS_NEW_PART_PAY)
|
||||||
orderIsPartPay = 1
|
// orderIsPartPay = 1
|
||||||
orderInfo.IsPartPay = &orderIsPartPay
|
// orderInfo.IsPartPay = &orderIsPartPay
|
||||||
orderPayedAmount = paymentIntent.Amount
|
// orderPayedAmount = paymentIntent.Amount
|
||||||
|
|
||||||
// 删除购物车
|
// // 删除购物车
|
||||||
cartModelT := gmodel.NewFsCartModel(connGorm)
|
// cartModelT := gmodel.NewFsCartModel(connGorm)
|
||||||
cartModelTRSB := cartModelT.BuilderTrans(ctx, nil)
|
// cartModelTRSB := cartModelT.BuilderTrans(ctx, nil)
|
||||||
err = cartModelT.RBDeleteCartsByIds(cartModelTRSB, cartIds)
|
// err = cartModelT.RBDeleteCartsByIds(cartModelTRSB, cartIds)
|
||||||
if err != nil {
|
// if err != nil {
|
||||||
return err
|
// return err
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
|
|
||||||
// 支付记录是尾款
|
// // 支付记录是尾款
|
||||||
if *payInfo.PayStage == int64(constants.PAYSTAGE_REMAINING) {
|
// if *payInfo.PayStage == int64(constants.PAYSTAGE_REMAINING) {
|
||||||
if *fsOrderRelInfo.Status < int64(constants.STATUS_NEW_PAY_COMPLETED) {
|
// if *fsOrderRelInfo.Status < int64(constants.STATUS_NEW_PAY_COMPLETED) {
|
||||||
orderStatus = int64(constants.STATUS_NEW_PAY_COMPLETED)
|
// orderStatus = int64(constants.STATUS_NEW_PAY_COMPLETED)
|
||||||
}
|
// }
|
||||||
orderIsPayCompleted = 1
|
// orderIsPayCompleted = 1
|
||||||
orderInfo.IsPayCompleted = &orderIsPayCompleted
|
// orderInfo.IsPayCompleted = &orderIsPayCompleted
|
||||||
orderPayedAmount = *fsOrderRelInfo.PayedAmount + paymentIntent.Amount
|
// orderPayedAmount = *fsOrderRelInfo.PayedAmount + paymentIntent.Amount
|
||||||
}
|
// }
|
||||||
|
|
||||||
// 更新订单信息
|
// // 更新订单信息
|
||||||
orderInfo.Id = fsOrderRelInfo.Id
|
// orderInfo.Id = fsOrderRelInfo.Id
|
||||||
orderInfo.Status = &orderStatus
|
// orderInfo.Status = &orderStatus
|
||||||
orderInfo.Ptime = &nowTime
|
// orderInfo.Ptime = &nowTime
|
||||||
orderInfo.PayedAmount = &orderPayedAmount
|
// orderInfo.PayedAmount = &orderPayedAmount
|
||||||
orderModelT := gmodel.NewFsOrderModel(connGorm)
|
// orderModelT := gmodel.NewFsOrderModel(connGorm)
|
||||||
err = orderModelT.RBUpdate(ctx, orderInfo)
|
// err = orderModelT.RBUpdate(ctx, orderInfo)
|
||||||
if err != nil {
|
// if err != nil {
|
||||||
return err
|
// return err
|
||||||
}
|
// }
|
||||||
return err
|
// return err
|
||||||
})
|
// })
|
||||||
if err != nil {
|
// if err != nil {
|
||||||
return err
|
// return err
|
||||||
}
|
// }
|
||||||
|
|
||||||
//千人千面的处理
|
// //千人千面的处理
|
||||||
// $renderServer = (new RenderService());
|
// // $renderServer = (new RenderService());
|
||||||
// $renderServer->thousandsFacesV2($order->id);
|
// // $renderServer->thousandsFacesV2($order->id);
|
||||||
// //清除用户最新的设计
|
// // //清除用户最新的设计
|
||||||
// $cache = \Yii::$app->cache;
|
// // $cache = \Yii::$app->cache;
|
||||||
// $cache->delete(CacheConfigHelper::LAST_DESIGN . $order->user_id);
|
// // $cache->delete(CacheConfigHelper::LAST_DESIGN . $order->user_id);
|
||||||
// //缓存最新订单编号
|
// // //缓存最新订单编号
|
||||||
// $cache->set(CacheConfigHelper::USER_ORDERNO . $order->user_id, $order->sn);
|
// // $cache->set(CacheConfigHelper::USER_ORDERNO . $order->user_id, $order->sn);
|
||||||
|
|
||||||
// //查询用户邮箱信息
|
// // //查询用户邮箱信息
|
||||||
// $user = \api\models\User::find()->where(['id' => $order->user_id])->one();
|
// // $user = \api\models\User::find()->where(['id' => $order->user_id])->one();
|
||||||
// $redisData = [
|
// // $redisData = [
|
||||||
// 'key' => 'receipt_download',
|
// // 'key' => 'receipt_download',
|
||||||
// 'param' => [
|
// // 'param' => [
|
||||||
// 'email' => $user->email,
|
// // 'email' => $user->email,
|
||||||
// 'order_id' => $order->id,
|
// // 'order_id' => $order->id,
|
||||||
// 'pay_id' => $pay->id,
|
// // 'pay_id' => $pay->id,
|
||||||
// 'type' => 1,//付款成功为1
|
// // 'type' => 1,//付款成功为1
|
||||||
// ]
|
// // ]
|
||||||
// ];
|
// // ];
|
||||||
// Email::timely($redisData);
|
// // Email::timely($redisData);
|
||||||
}
|
// }
|
||||||
|
|
||||||
// 订单记录
|
// 订单记录
|
||||||
return nil
|
return nil
|
||||||
|
|||||||
@@ -2,11 +2,10 @@ package logic
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
"encoding/json"
|
|
||||||
"errors"
|
"errors"
|
||||||
"fusenapi/constants"
|
|
||||||
"fusenapi/utils/auth"
|
"fusenapi/utils/auth"
|
||||||
"fusenapi/utils/basic"
|
"fusenapi/utils/basic"
|
||||||
|
|
||||||
"gorm.io/gorm"
|
"gorm.io/gorm"
|
||||||
|
|
||||||
"fusenapi/server/product/internal/svc"
|
"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")
|
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))
|
// orderInfo, err := l.svcCtx.AllModels.FsOrder.FindLastSuccessOneOrder(l.ctx, user.Id, int64(constants.STATUS_NEW_NOT_PAY))
|
||||||
if err != nil {
|
// if err != nil {
|
||||||
if errors.Is(err, gorm.ErrRecordNotFound) {
|
// if errors.Is(err, gorm.ErrRecordNotFound) {
|
||||||
return resp.SetStatusWithMessage(basic.CodeDbRecordNotFoundErr, "none of order is found")
|
// return resp.SetStatusWithMessage(basic.CodeDbRecordNotFoundErr, "none of order is found")
|
||||||
}
|
// }
|
||||||
logx.Error(err)
|
// logx.Error(err)
|
||||||
return resp.SetStatusAddMessage(basic.CodeDbSqlErr, "failed to get your last order")
|
// return resp.SetStatusAddMessage(basic.CodeDbSqlErr, "failed to get your last order")
|
||||||
}
|
// }
|
||||||
//获取该订单相关设计信息
|
//获取该订单相关设计信息
|
||||||
orderDetail, err := l.svcCtx.AllModels.FsOrderDetail.GetOneOrderDetailByOrderId(l.ctx, orderInfo.Id)
|
// orderDetail, err := l.svcCtx.AllModels.FsOrderDetail.GetOneOrderDetailByOrderId(l.ctx, orderInfo.Id)
|
||||||
if err != nil {
|
// if err != nil {
|
||||||
if errors.Is(err, gorm.ErrRecordNotFound) {
|
// if errors.Is(err, gorm.ErrRecordNotFound) {
|
||||||
return resp.SetStatusWithMessage(basic.CodeDbRecordNotFoundErr, "order detail is not found")
|
// return resp.SetStatusWithMessage(basic.CodeDbRecordNotFoundErr, "order detail is not found")
|
||||||
}
|
// }
|
||||||
logx.Error(err)
|
// logx.Error(err)
|
||||||
return resp.SetStatusAddMessage(basic.CodeDbSqlErr, "failed to get order detail")
|
// return resp.SetStatusAddMessage(basic.CodeDbSqlErr, "failed to get order detail")
|
||||||
}
|
// }
|
||||||
//获取设计模板详情,便于获得design_id
|
// //获取设计模板详情,便于获得design_id
|
||||||
orderDetailTemplate, err := l.svcCtx.AllModels.FsOrderDetailTemplate.FindOne(l.ctx, *orderDetail.OrderDetailTemplateId)
|
// orderDetailTemplate, err := l.svcCtx.AllModels.FsOrderDetailTemplate.FindOne(l.ctx, *orderDetail.OrderDetailTemplateId)
|
||||||
if err != nil {
|
// if err != nil {
|
||||||
if errors.Is(err, gorm.ErrRecordNotFound) {
|
// if errors.Is(err, gorm.ErrRecordNotFound) {
|
||||||
return resp.SetStatusWithMessage(basic.CodeDbRecordNotFoundErr, "order detail template is not found")
|
// return resp.SetStatusWithMessage(basic.CodeDbRecordNotFoundErr, "order detail template is not found")
|
||||||
}
|
// }
|
||||||
logx.Error(err)
|
// logx.Error(err)
|
||||||
return resp.SetStatusWithMessage(basic.CodeDbSqlErr, "failed to get order detail template")
|
// return resp.SetStatusWithMessage(basic.CodeDbSqlErr, "failed to get order detail template")
|
||||||
}
|
// }
|
||||||
//最后一次设计不存在,则不返回该设计相关数据
|
//最后一次设计不存在,则不返回该设计相关数据
|
||||||
if *orderDetailTemplate.DesignId <= 0 {
|
// if *orderDetailTemplate.DesignId <= 0 {
|
||||||
return resp.SetStatusWithMessage(basic.CodeOK, "success:last design id is not set")
|
// 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)
|
// productDesign, err := l.svcCtx.AllModels.FsProductDesign.FindOne(l.ctx, *orderDetailTemplate.DesignId, user.Id)
|
||||||
if err != nil {
|
// if err != nil {
|
||||||
if errors.Is(err, gorm.ErrRecordNotFound) {
|
// if errors.Is(err, gorm.ErrRecordNotFound) {
|
||||||
return resp.SetStatusWithMessage(basic.CodeDbRecordNotFoundErr, "product design is not found")
|
// return resp.SetStatusWithMessage(basic.CodeDbRecordNotFoundErr, "product design is not found")
|
||||||
}
|
// }
|
||||||
logx.Error(err)
|
// logx.Error(err)
|
||||||
return resp.SetStatusWithMessage(basic.CodeDbSqlErr, "failed to get product design")
|
// return resp.SetStatusWithMessage(basic.CodeDbSqlErr, "failed to get product design")
|
||||||
}
|
// }
|
||||||
var info interface{}
|
// var info interface{}
|
||||||
if productDesign.Info != nil && *productDesign.Info != "" {
|
// if productDesign.Info != nil && *productDesign.Info != "" {
|
||||||
if err := json.Unmarshal([]byte(*productDesign.Info), &info); err != nil {
|
// if err := json.Unmarshal([]byte(*productDesign.Info), &info); err != nil {
|
||||||
logx.Error(err)
|
// logx.Error(err)
|
||||||
return nil
|
// return nil
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
var logoColor interface{}
|
// var logoColor interface{}
|
||||||
if productDesign.LogoColor != nil && *productDesign.LogoColor != "" {
|
// if productDesign.LogoColor != nil && *productDesign.LogoColor != "" {
|
||||||
if err := json.Unmarshal([]byte(*productDesign.LogoColor), &logoColor); err != nil {
|
// if err := json.Unmarshal([]byte(*productDesign.LogoColor), &logoColor); err != nil {
|
||||||
logx.Error(err)
|
// logx.Error(err)
|
||||||
return nil
|
// return nil
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
return resp.SetStatusWithMessage(basic.CodeOK, "success", types.GetLastProductDesignRsp{
|
return resp.SetStatusWithMessage(basic.CodeOK, "success", types.GetLastProductDesignRsp{
|
||||||
Id: productDesign.Id,
|
Id: 1,
|
||||||
OptionalId: *productDesign.OptionalId,
|
OptionalId: 1,
|
||||||
SizeId: *productDesign.SizeId,
|
SizeId: 1,
|
||||||
LogoColor: logoColor,
|
LogoColor: 1,
|
||||||
Info: info,
|
Info: nil,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -8,10 +8,11 @@ import (
|
|||||||
"fusenapi/utils/basic"
|
"fusenapi/utils/basic"
|
||||||
"fusenapi/utils/format"
|
"fusenapi/utils/format"
|
||||||
"fusenapi/utils/step_price"
|
"fusenapi/utils/step_price"
|
||||||
"gorm.io/gorm"
|
|
||||||
"sort"
|
"sort"
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
|
"gorm.io/gorm"
|
||||||
|
|
||||||
"context"
|
"context"
|
||||||
|
|
||||||
"fusenapi/server/product/internal/svc"
|
"fusenapi/server/product/internal/svc"
|
||||||
|
|||||||
@@ -14,10 +14,11 @@ import (
|
|||||||
"fusenapi/utils/format"
|
"fusenapi/utils/format"
|
||||||
"fusenapi/utils/image"
|
"fusenapi/utils/image"
|
||||||
"fusenapi/utils/step_price"
|
"fusenapi/utils/step_price"
|
||||||
"gorm.io/gorm"
|
|
||||||
"strconv"
|
"strconv"
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
|
"gorm.io/gorm"
|
||||||
|
|
||||||
"fusenapi/server/product/internal/svc"
|
"fusenapi/server/product/internal/svc"
|
||||||
"fusenapi/server/product/internal/types"
|
"fusenapi/server/product/internal/types"
|
||||||
|
|
||||||
@@ -460,66 +461,66 @@ func (l *GetProductInfoLogic) getRenderDesign(clientNo string) interface{} {
|
|||||||
// 获取用户最新设计
|
// 获取用户最新设计
|
||||||
func (l *GetProductInfoLogic) getLastDesign(userInfo gmodel.FsUser) 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))
|
// orderInfo, err := l.svcCtx.AllModels.FsOrder.FindLastSuccessOneOrder(l.ctx, userInfo.Id, int64(constants.STATUS_NEW_NOT_PAY))
|
||||||
if err != nil {
|
// if err != nil {
|
||||||
if errors.Is(err, gorm.ErrRecordNotFound) {
|
// if errors.Is(err, gorm.ErrRecordNotFound) {
|
||||||
return nil
|
// return nil
|
||||||
}
|
// }
|
||||||
logx.Error(err)
|
// logx.Error(err)
|
||||||
return nil
|
// return nil
|
||||||
}
|
// }
|
||||||
//获取该订单相关设计信息
|
//获取该订单相关设计信息
|
||||||
orderDetail, err := l.svcCtx.AllModels.FsOrderDetail.GetOneOrderDetailByOrderId(l.ctx, orderInfo.Id)
|
// orderDetail, err := l.svcCtx.AllModels.FsOrderDetail.GetOneOrderDetailByOrderId(l.ctx, orderInfo.Id)
|
||||||
if err != nil {
|
// if err != nil {
|
||||||
if errors.Is(err, gorm.ErrRecordNotFound) {
|
// if errors.Is(err, gorm.ErrRecordNotFound) {
|
||||||
return nil
|
// return nil
|
||||||
}
|
// }
|
||||||
logx.Error(err)
|
// logx.Error(err)
|
||||||
return nil
|
// return nil
|
||||||
}
|
// }
|
||||||
//获取设计模板详情,便于获得design_id
|
// //获取设计模板详情,便于获得design_id
|
||||||
orderDetailTemplate, err := l.svcCtx.AllModels.FsOrderDetailTemplate.FindOne(l.ctx, *orderDetail.OrderDetailTemplateId)
|
// orderDetailTemplate, err := l.svcCtx.AllModels.FsOrderDetailTemplate.FindOne(l.ctx, *orderDetail.OrderDetailTemplateId)
|
||||||
if err != nil {
|
// if err != nil {
|
||||||
if errors.Is(err, gorm.ErrRecordNotFound) {
|
// if errors.Is(err, gorm.ErrRecordNotFound) {
|
||||||
return nil
|
// return nil
|
||||||
}
|
// }
|
||||||
logx.Error(err)
|
// logx.Error(err)
|
||||||
return nil
|
// return nil
|
||||||
}
|
// }
|
||||||
//若没打开了个性化渲染按钮或者最后一次设计不存在,则不返回该设计相关数据
|
//若没打开了个性化渲染按钮或者最后一次设计不存在,则不返回该设计相关数据
|
||||||
if *userInfo.IsOpenRender != 1 || *orderDetailTemplate.DesignId <= 0 {
|
// if *userInfo.IsOpenRender != 1 || *orderDetailTemplate.DesignId <= 0 {
|
||||||
return nil
|
// return nil
|
||||||
}
|
// }
|
||||||
//获取设计数据
|
// //获取设计数据
|
||||||
productDesign, err := l.svcCtx.AllModels.FsProductDesign.FindOne(l.ctx, *orderDetailTemplate.DesignId, userInfo.Id)
|
// productDesign, err := l.svcCtx.AllModels.FsProductDesign.FindOne(l.ctx, *orderDetailTemplate.DesignId, userInfo.Id)
|
||||||
if err != nil {
|
// if err != nil {
|
||||||
if errors.Is(err, gorm.ErrRecordNotFound) {
|
// if errors.Is(err, gorm.ErrRecordNotFound) {
|
||||||
return nil
|
// return nil
|
||||||
}
|
// }
|
||||||
logx.Error(err)
|
// logx.Error(err)
|
||||||
return nil
|
// return nil
|
||||||
}
|
// }
|
||||||
var info interface{}
|
// var info interface{}
|
||||||
if productDesign.Info != nil && *productDesign.Info != "" {
|
// if productDesign.Info != nil && *productDesign.Info != "" {
|
||||||
if err := json.Unmarshal([]byte(*productDesign.Info), &info); err != nil {
|
// if err := json.Unmarshal([]byte(*productDesign.Info), &info); err != nil {
|
||||||
logx.Error(err)
|
// logx.Error(err)
|
||||||
return nil
|
// return nil
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
var logoColor interface{}
|
// var logoColor interface{}
|
||||||
if productDesign.LogoColor != nil && *productDesign.LogoColor != "" {
|
// if productDesign.LogoColor != nil && *productDesign.LogoColor != "" {
|
||||||
if err := json.Unmarshal([]byte(*productDesign.LogoColor), &logoColor); err != nil {
|
// if err := json.Unmarshal([]byte(*productDesign.LogoColor), &logoColor); err != nil {
|
||||||
logx.Error(err)
|
// logx.Error(err)
|
||||||
return nil
|
// return nil
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
return map[string]interface{}{
|
return map[string]interface{}{
|
||||||
"id": productDesign.Id,
|
"id": 1,
|
||||||
"info": info,
|
"info": 1,
|
||||||
"logo_color": logoColor,
|
"logo_color": 1,
|
||||||
"material_id": *productDesign.MaterialId,
|
"material_id": 1,
|
||||||
"optional_id": *productDesign.OptionalId,
|
"optional_id": 1,
|
||||||
"size_id": *productDesign.SizeId,
|
"size_id": 1,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -2,14 +2,14 @@ package logic
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"errors"
|
"errors"
|
||||||
"fusenapi/constants"
|
|
||||||
"fusenapi/model/gmodel"
|
"fusenapi/model/gmodel"
|
||||||
"fusenapi/utils/auth"
|
"fusenapi/utils/auth"
|
||||||
"fusenapi/utils/basic"
|
"fusenapi/utils/basic"
|
||||||
"fusenapi/utils/color_list"
|
"fusenapi/utils/color_list"
|
||||||
"gorm.io/gorm"
|
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
|
"gorm.io/gorm"
|
||||||
|
|
||||||
"context"
|
"context"
|
||||||
|
|
||||||
"fusenapi/server/product/internal/svc"
|
"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) {
|
func (l *GetRenderSettingByPidLogic) checkLastDesignExists(userId int64) (bool, error) {
|
||||||
//查询用户最近下单成功的数据
|
//查询用户最近下单成功的数据
|
||||||
orderInfo, err := l.svcCtx.AllModels.FsOrder.FindLastSuccessOneOrder(l.ctx, userId, int64(constants.STATUS_NEW_NOT_PAY))
|
// orderInfo, err := l.svcCtx.AllModels.FsOrder.FindLastSuccessOneOrder(l.ctx, userId, int64(constants.STATUS_NEW_NOT_PAY))
|
||||||
if err != nil {
|
// if err != nil {
|
||||||
if errors.Is(err, gorm.ErrRecordNotFound) {
|
// if errors.Is(err, gorm.ErrRecordNotFound) {
|
||||||
return false, nil
|
// return false, nil
|
||||||
}
|
// }
|
||||||
return false, err
|
// return false, err
|
||||||
}
|
// }
|
||||||
//获取该订单相关设计信息
|
//获取该订单相关设计信息
|
||||||
orderDetail, err := l.svcCtx.AllModels.FsOrderDetail.GetOneOrderDetailByOrderId(l.ctx, orderInfo.Id)
|
// orderDetail, err := l.svcCtx.AllModels.FsOrderDetail.GetOneOrderDetailByOrderId(l.ctx, orderInfo.Id)
|
||||||
if err != nil {
|
// if err != nil {
|
||||||
if errors.Is(err, gorm.ErrRecordNotFound) {
|
// 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, 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"`
|
Data []byte `fsfile:"data"`
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// 统一分页
|
// 统一分页
|
||||||
type Meta struct {
|
type Meta struct {
|
||||||
TotalCount int64 `json:"totalCount"`
|
TotalCount int64 `json:"totalCount"`
|
||||||
@@ -41,3 +40,185 @@ type Meta struct {
|
|||||||
CurrentPage int `json:"currentPage"`
|
CurrentPage int `json:"currentPage"`
|
||||||
PerPage int `json:"perPage"`
|
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"`
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user