fix:合图调整
This commit is contained in:
commit
f7c3ccd01d
16
.gitignore
vendored
16
.gitignore
vendored
|
@ -40,18 +40,6 @@ screenlog.*
|
|||
|
||||
proxyserver/proxyserver
|
||||
|
||||
server/backend/backend
|
||||
server/canteen/canteen
|
||||
server/data-transfer/data-transfer
|
||||
server/home-user-auth/home-user-auth
|
||||
server/inventory/inventory
|
||||
server/map-library/map-library
|
||||
server/orders/orders
|
||||
server/product/product
|
||||
server/product-model/product-model
|
||||
server/product-template/product-template
|
||||
server/shopping-cart-confirmation/shopping-cart-confirmation
|
||||
server/upload/upload
|
||||
server/webset/webset
|
||||
shared-state
|
||||
|
||||
shared-state
|
||||
*.zip
|
6
constants/min_purchase_box.go
Normal file
6
constants/min_purchase_box.go
Normal file
|
@ -0,0 +1,6 @@
|
|||
package constants
|
||||
|
||||
type Purchase int64
|
||||
|
||||
// 最低购买箱数
|
||||
const MIN_PURCHASE_QUANTITY Purchase = 3
|
88
constants/orders.go
Normal file
88
constants/orders.go
Normal file
|
@ -0,0 +1,88 @@
|
|||
package constants
|
||||
|
||||
// 货币
|
||||
type Currency string
|
||||
|
||||
const (
|
||||
Usd Currency = "usd"
|
||||
)
|
||||
|
||||
// 金额单位
|
||||
type AmountUnit interface{}
|
||||
|
||||
// 汇率单位
|
||||
type ExchangeRateUnit interface{}
|
||||
|
||||
// 交易方式
|
||||
type PayMethods string
|
||||
|
||||
const (
|
||||
Card PayMethods = "CARD"
|
||||
Visa PayMethods = "VISA"
|
||||
)
|
||||
|
||||
// 支付状态
|
||||
type PayStatusCode int64
|
||||
|
||||
const (
|
||||
PayStatusUnpaid PayStatusCode = 10 //10,未支付
|
||||
PayStatusPaid PayStatusCode = 20 //20,已支付
|
||||
PayStatusRefunded PayStatusCode = 30 //30,已退款
|
||||
)
|
||||
|
||||
// 订单状态
|
||||
type OrderStatusCode int64
|
||||
|
||||
const (
|
||||
ORDERSTATUSUNPAIDDEPOSIT OrderStatusCode = 0 // 0,未支付定金
|
||||
ORDERSTATUSDIRECTMAILORDERED OrderStatusCode = 10100 // 10100,直邮单--已下单
|
||||
ORDERSTATUSDIRECTMAILCANCEL OrderStatusCode = 10101 // 10101,直邮单--已取消
|
||||
ORDERSTATUSDIRECTMAILSTARTPRODUCTION OrderStatusCode = 10200 // 10200,直邮单--开始生产
|
||||
ORDERSTATUSDIRECTMAILCOMPLETEPRODUCTION OrderStatusCode = 10300 // 10300,直邮单--生产完成
|
||||
ORDERSTATUSDIRECTMAILSHIPPED OrderStatusCode = 10400 // 10400,直邮单--已发货
|
||||
ORDERSTATUSDIRECTMAILARRIVED OrderStatusCode = 10500 // 10500,直邮单--已到达
|
||||
ORDERSTATUSCLOUDSTOREORDERED OrderStatusCode = 20100 // 20100,云仓单--已下单
|
||||
ORDERSTATUSCLOUDSTORECANCEL OrderStatusCode = 20101 // 20101,云仓单--已取消
|
||||
ORDERSTATUSCLOUDSTORESTARTPRODUCTION OrderStatusCode = 20200 // 20200,云仓单--开始生产
|
||||
ORDERSTATUSCLOUDSTOREOMPLETEPRODUCTION OrderStatusCode = 20300 // 20300,云仓单--生产完成
|
||||
ORDERSTATUSCLOUDSTOREARRIVEDWAREHOUSE OrderStatusCode = 20400 // 20400,云仓单--直达仓库
|
||||
)
|
||||
|
||||
// 订单状态名称
|
||||
var OrderStatusMessage map[OrderStatusCode]string
|
||||
|
||||
// 支付状态名称
|
||||
var PayStatusMessage map[PayStatusCode]string
|
||||
|
||||
// 订单状态--用户可见
|
||||
var OrderStatusUser []OrderStatusCode
|
||||
|
||||
func init() {
|
||||
// 订单状态名称
|
||||
PayStatusMessage = make(map[PayStatusCode]string)
|
||||
PayStatusMessage[PayStatusUnpaid] = "Paid"
|
||||
PayStatusMessage[PayStatusPaid] = "Unpaid"
|
||||
PayStatusMessage[PayStatusRefunded] = "Refunded"
|
||||
|
||||
// 订单状态名称
|
||||
OrderStatusMessage = make(map[OrderStatusCode]string)
|
||||
OrderStatusMessage[ORDERSTATUSUNPAIDDEPOSIT] = "未支付定金"
|
||||
|
||||
OrderStatusMessage[ORDERSTATUSDIRECTMAILORDERED] = "直邮单--已下单"
|
||||
OrderStatusMessage[ORDERSTATUSDIRECTMAILSTARTPRODUCTION] = "直邮单--开始生产"
|
||||
OrderStatusMessage[ORDERSTATUSDIRECTMAILCOMPLETEPRODUCTION] = "直邮单--生产完成"
|
||||
OrderStatusMessage[ORDERSTATUSDIRECTMAILSHIPPED] = "直邮单--已发货"
|
||||
OrderStatusMessage[ORDERSTATUSDIRECTMAILARRIVED] = "直邮单--已到达"
|
||||
|
||||
OrderStatusMessage[ORDERSTATUSCLOUDSTOREORDERED] = "云仓单--已下单"
|
||||
OrderStatusMessage[ORDERSTATUSCLOUDSTORESTARTPRODUCTION] = "云仓单--开始生产"
|
||||
OrderStatusMessage[ORDERSTATUSCLOUDSTOREOMPLETEPRODUCTION] = "云仓单--生产完成"
|
||||
OrderStatusMessage[ORDERSTATUSCLOUDSTOREARRIVEDWAREHOUSE] = "云仓单--直达仓库"
|
||||
|
||||
// 订单状态--用户可见
|
||||
OrderStatusUser = []OrderStatusCode{
|
||||
ORDERSTATUSUNPAIDDEPOSIT,
|
||||
ORDERSTATUSDIRECTMAILORDERED, ORDERSTATUSDIRECTMAILSTARTPRODUCTION, ORDERSTATUSDIRECTMAILCOMPLETEPRODUCTION, ORDERSTATUSDIRECTMAILSHIPPED, ORDERSTATUSDIRECTMAILARRIVED,
|
||||
ORDERSTATUSCLOUDSTOREORDERED, ORDERSTATUSCLOUDSTORESTARTPRODUCTION, ORDERSTATUSCLOUDSTOREOMPLETEPRODUCTION, ORDERSTATUSCLOUDSTOREARRIVEDWAREHOUSE,
|
||||
}
|
||||
}
|
7
env.yaml
Normal file
7
env.yaml
Normal file
|
@ -0,0 +1,7 @@
|
|||
nacos:
|
||||
- server.fusen.3718.cn:8848
|
||||
- server.fusen.3718.cn:8849
|
||||
username: ...
|
||||
password: ...
|
||||
namespace: fs_server_api_dev
|
||||
group: FS-SERVER-API
|
25
fs_nacos_etc_pack.sh
Executable file
25
fs_nacos_etc_pack.sh
Executable file
|
@ -0,0 +1,25 @@
|
|||
#!/bin/bash
|
||||
|
||||
CURRENT_DIR=`pwd`
|
||||
SOURCE_DIR="server"
|
||||
TEMP_DIR="/tmp"
|
||||
DEST_DIR="FS-SERVER-API"
|
||||
ZIP_FILE="FS-SERVER-API.zip"
|
||||
|
||||
mkdir -p $TEMP_DIR/$DEST_DIR
|
||||
|
||||
# 查找并复制文件
|
||||
find "$SOURCE_DIR" -type d -name "etc" -exec sh -c 'cp "$0"/*.yaml "$1"' {} "$TEMP_DIR/$DEST_DIR" \;
|
||||
|
||||
cd $TEMP_DIR
|
||||
# 打包目标文件夹
|
||||
zip -r "$ZIP_FILE" "$DEST_DIR"
|
||||
|
||||
#返回当前目录
|
||||
cd $CURRENT_DIR
|
||||
|
||||
# 移动到当前目录
|
||||
mv "$TEMP_DIR/$ZIP_FILE" .
|
||||
|
||||
# 清理临时文件夹
|
||||
rm "$TEMP_DIR/$DEST_DIR" -rf
|
14
go.mod
14
go.mod
|
@ -14,6 +14,7 @@ require (
|
|||
github.com/gorilla/websocket v1.5.0
|
||||
github.com/hashicorp/raft v1.5.0
|
||||
github.com/lni/dragonboat/v4 v4.0.0-20230709075559-54497b9553be
|
||||
github.com/nacos-group/nacos-sdk-go/v2 v2.2.3
|
||||
github.com/nfnt/resize v0.0.0-20180221191011-83c6a9932646
|
||||
github.com/skip2/go-qrcode v0.0.0-20200617195104-da1b6568686e
|
||||
github.com/streadway/amqp v1.1.0
|
||||
|
@ -31,14 +32,17 @@ require (
|
|||
github.com/DataDog/zstd v1.4.5 // indirect
|
||||
github.com/HdrHistogram/hdrhistogram-go v1.1.2 // indirect
|
||||
github.com/VictoriaMetrics/metrics v1.18.1 // indirect
|
||||
github.com/aliyun/alibaba-cloud-sdk-go v1.61.1704 // indirect
|
||||
github.com/andybalholm/brotli v1.0.5 // indirect
|
||||
github.com/armon/go-metrics v0.4.1 // indirect
|
||||
github.com/buger/jsonparser v1.1.1 // indirect
|
||||
github.com/cockroachdb/errors v1.9.0 // indirect
|
||||
github.com/cockroachdb/logtags v0.0.0-20211118104740-dabe8e521a4f // indirect
|
||||
github.com/cockroachdb/pebble v0.0.0-20221207173255-0f086d933dac // indirect
|
||||
github.com/cockroachdb/redact v1.1.3 // indirect
|
||||
github.com/getsentry/sentry-go v0.12.0 // indirect
|
||||
github.com/gogo/protobuf v1.3.2 // indirect
|
||||
github.com/golang/mock v1.6.0 // indirect
|
||||
github.com/golang/snappy v0.0.4 // indirect
|
||||
github.com/google/btree v1.0.0 // indirect
|
||||
github.com/hashicorp/errwrap v1.1.0 // indirect
|
||||
|
@ -50,12 +54,15 @@ require (
|
|||
github.com/hashicorp/golang-lru v0.5.1 // indirect
|
||||
github.com/hashicorp/memberlist v0.3.1 // indirect
|
||||
github.com/jmespath/go-jmespath v0.4.0 // indirect
|
||||
github.com/json-iterator/go v1.1.12 // indirect
|
||||
github.com/klauspost/compress v1.15.15 // indirect
|
||||
github.com/kr/pretty v0.3.1 // indirect
|
||||
github.com/kr/text v0.2.0 // indirect
|
||||
github.com/lni/goutils v1.3.1-0.20220604063047-388d67b4dbc4 // indirect
|
||||
github.com/lni/vfs v0.2.1-0.20220616104132-8852fd867376 // indirect
|
||||
github.com/miekg/dns v1.1.26 // indirect
|
||||
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect
|
||||
github.com/modern-go/reflect2 v1.0.2 // indirect
|
||||
github.com/pierrec/lz4/v4 v4.1.17 // indirect
|
||||
github.com/pkg/errors v0.9.1 // indirect
|
||||
github.com/rogpeppe/go-internal v1.9.0 // indirect
|
||||
|
@ -64,11 +71,18 @@ require (
|
|||
github.com/valyala/fastrand v1.1.0 // indirect
|
||||
github.com/valyala/histogram v1.2.0 // indirect
|
||||
go.opentelemetry.io/otel/exporters/stdout/stdouttrace v1.14.0 // indirect
|
||||
go.uber.org/atomic v1.10.0 // indirect
|
||||
go.uber.org/multierr v1.9.0 // indirect
|
||||
go.uber.org/zap v1.24.0 // indirect
|
||||
golang.org/x/crypto v0.11.0 // indirect
|
||||
golang.org/x/exp v0.0.0-20230728194245-b0cb94b80691 // indirect
|
||||
golang.org/x/sync v0.2.0 // indirect
|
||||
golang.org/x/time v0.3.0 // indirect
|
||||
google.golang.org/appengine v1.6.7 // indirect
|
||||
google.golang.org/genproto/googleapis/api v0.0.0-20230530153820-e85fd2cbaebc // indirect
|
||||
google.golang.org/genproto/googleapis/rpc v0.0.0-20230530153820-e85fd2cbaebc // indirect
|
||||
gopkg.in/ini.v1 v1.66.2 // indirect
|
||||
gopkg.in/natefinch/lumberjack.v2 v2.0.0 // indirect
|
||||
)
|
||||
|
||||
require (
|
||||
|
|
32
go.sum
32
go.sum
|
@ -41,6 +41,7 @@ github.com/474420502/random v0.4.1 h1:HUUyLXRWMijVb7CJoEC16f0aFQOW25Lkr80Mut6PoK
|
|||
github.com/474420502/requests v1.42.0 h1:aUj0rWhfldbOOlGHDIcqT9zgXEoSlK4IBmRF3LxI1+Y=
|
||||
github.com/474420502/requests v1.42.0/go.mod h1:2SCVzim0ONFYG09g/GrM7RTeJIC6qTyZfnohsjnG5C8=
|
||||
github.com/AndreasBriese/bbloom v0.0.0-20190306092124-e2d15f34fcf9/go.mod h1:bOvUY6CB00SOBii9/FifXqc0awNKxLFCL/+pkDPuyl8=
|
||||
github.com/BurntSushi/toml v0.3.1 h1:WXkYYl6Yr3qBf1K79EBnL4mak0OimBfB0XUf9Vl28OQ=
|
||||
github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU=
|
||||
github.com/BurntSushi/xgb v0.0.0-20160522181843-27f122750802/go.mod h1:IVnqGOEym/WlBOVXweHU+Q+/VP0lqqI8lqeDx9IjBqo=
|
||||
github.com/CloudyKit/fastprinter v0.0.0-20170127035650-74b38d55f37a/go.mod h1:EFZQ978U7x8IRnstaskI3IysnWY5Ao3QgZUKOXlsAdw=
|
||||
|
@ -69,6 +70,8 @@ github.com/alecthomas/units v0.0.0-20151022065526-2efee857e7cf/go.mod h1:ybxpYRF
|
|||
github.com/alecthomas/units v0.0.0-20190717042225-c3de453c63f4/go.mod h1:ybxpYRFXyAe+OPACYpWeL0wqObRcbAqCMya13uyzqw0=
|
||||
github.com/alicebob/gopher-json v0.0.0-20200520072559-a9ecdc9d1d3a h1:HbKu58rmZpUGpz5+4FfNmIU+FmZg2P3Xaj2v2bfNWmk=
|
||||
github.com/alicebob/miniredis/v2 v2.30.4 h1:8S4/o1/KoUArAGbGwPxcwf0krlzceva2XVOSchFS7Eo=
|
||||
github.com/aliyun/alibaba-cloud-sdk-go v1.61.1704 h1:PpfENOj/vPfhhy9N2OFRjpue0hjM5XqAp2thFmkXXIk=
|
||||
github.com/aliyun/alibaba-cloud-sdk-go v1.61.1704/go.mod h1:RcDobYh8k5VP6TNybz9m++gL3ijVI5wueVr0EM10VsU=
|
||||
github.com/andybalholm/brotli v1.0.5 h1:8uQZIdzKmjc/iuPu7O2ioW48L81FgatrcpfFmiq/cCs=
|
||||
github.com/andybalholm/brotli v1.0.5/go.mod h1:fO7iG3H7G2nSZ7m0zPUDn85XEX2GTukHGRSepvi9Eig=
|
||||
github.com/antihax/optional v1.0.0/go.mod h1:uupD/76wgC+ih3iEmQUL+0Ugr19nfwCT1kdvxnR2qWY=
|
||||
|
@ -79,10 +82,13 @@ github.com/armon/go-metrics v0.4.1/go.mod h1:E6amYzXo6aW1tqzoZGT755KkbgrJsSdpwZ+
|
|||
github.com/aws/aws-sdk-go v1.44.295 h1:SGjU1+MqttXfRiWHD6WU0DRhaanJgAFY+xIhEaugV8Y=
|
||||
github.com/aws/aws-sdk-go v1.44.295/go.mod h1:aVsgQcEevwlmQ7qHE9I3h+dtQgpqhFB+i8Phjh7fkwI=
|
||||
github.com/aymerick/raymond v2.0.3-0.20180322193309-b565731e1464+incompatible/go.mod h1:osfaiScAUVup+UC9Nfq76eWqDhXlp+4UYaA8uhTBO6g=
|
||||
github.com/benbjohnson/clock v1.1.0 h1:Q92kusRqC1XV2MjkWETPvjJVqKetz1OzxZB7mHJLju8=
|
||||
github.com/beorn7/perks v0.0.0-20180321164747-3a771d992973/go.mod h1:Dwedo/Wpr24TaqPxmxbtue+5NUziq4I4S80YR8gNf3Q=
|
||||
github.com/beorn7/perks v1.0.0/go.mod h1:KWe93zE9D1o94FZ5RNwFwVgaQK1VOXiVxmqh+CedLV8=
|
||||
github.com/beorn7/perks v1.0.1 h1:VlbKKnNfV8bJzeqoa4cOKqO6bYr3WgKZxO8Z16+hsOM=
|
||||
github.com/beorn7/perks v1.0.1/go.mod h1:G2ZrVWU2WbWT9wwq4/hrbKbnv/1ERSJQ0ibhJ6rlkpw=
|
||||
github.com/buger/jsonparser v1.1.1 h1:2PnMjfWD7wBILjqQbt530v576A/cAbQvEW9gGIpYMUs=
|
||||
github.com/buger/jsonparser v1.1.1/go.mod h1:6RYKKt7H4d4+iWqouImQ9R2FZql3VbhNgx27UK13J/0=
|
||||
github.com/bwmarrin/snowflake v0.3.0 h1:xm67bEhkKh6ij1790JB83OujPR5CzNe8QuQqAgISZN0=
|
||||
github.com/bwmarrin/snowflake v0.3.0/go.mod h1:NdZxfVWX+oR6y2K0o6qAYv6gIOP9rjG0/E9WsDpxqwE=
|
||||
github.com/cenkalti/backoff/v4 v4.2.0 h1:HN5dHm3WBOgndBH6E8V0q2jIYIR3s9yglV8k/+MN3u4=
|
||||
|
@ -202,6 +208,7 @@ github.com/gogo/protobuf v1.3.1/go.mod h1:SlYgWuQ5SjCEi6WLHjHCa1yvBfUnHcTbrrZtXP
|
|||
github.com/gogo/protobuf v1.3.2 h1:Ov1cvc58UF3b5XjBnZv7+opcTcQFZebYjWzi34vdm4Q=
|
||||
github.com/gogo/protobuf v1.3.2/go.mod h1:P1XiOD3dCwIKUDQYPy72D8LYyHL2YPYrpS2s69NZV8Q=
|
||||
github.com/gogo/status v1.1.0/go.mod h1:BFv9nrluPLmrS0EmGVvLaPNmRosr9KapBYd5/hpY1WM=
|
||||
github.com/goji/httpauth v0.0.0-20160601135302-2da839ab0f4d/go.mod h1:nnjvkQ9ptGaCkuDUx6wNykzzlUixGxvkme+H/lnzb+A=
|
||||
github.com/golang-jwt/jwt v3.2.2+incompatible h1:IfV12K8xAKAnZqdXVzCZ+TOjboZ2keLg81eXfW3O+oY=
|
||||
github.com/golang-jwt/jwt v3.2.2+incompatible/go.mod h1:8pz2t5EyA70fFQQSrl6XZXzqecmYZeUEB8OUGHkxJ+I=
|
||||
github.com/golang-jwt/jwt/v4 v4.5.0 h1:7cYmW1XlMY7h7ii7UhUyChSgS5wUJEnm9uZVTGqOWzg=
|
||||
|
@ -220,6 +227,8 @@ github.com/golang/mock v1.4.0/go.mod h1:UOMv5ysSaYNkG+OFQykRIcU/QvvxJf3p21QfJ2Bt
|
|||
github.com/golang/mock v1.4.1/go.mod h1:UOMv5ysSaYNkG+OFQykRIcU/QvvxJf3p21QfJ2Bt3cw=
|
||||
github.com/golang/mock v1.4.3/go.mod h1:UOMv5ysSaYNkG+OFQykRIcU/QvvxJf3p21QfJ2Bt3cw=
|
||||
github.com/golang/mock v1.4.4/go.mod h1:l3mdAwkq5BuhzHwde/uurv3sEJeZMXNpwsxVWU71h+4=
|
||||
github.com/golang/mock v1.6.0 h1:ErTB+efbowRARo13NNdxyJji2egdxLGQhRaY+DUumQc=
|
||||
github.com/golang/mock v1.6.0/go.mod h1:p6yTPP+5HYm5mzsMV8JkE6ZKdX+/wYM6Hr+LicevLPs=
|
||||
github.com/golang/protobuf v1.2.0/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U=
|
||||
github.com/golang/protobuf v1.3.1/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U=
|
||||
github.com/golang/protobuf v1.3.2/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U=
|
||||
|
@ -330,12 +339,16 @@ github.com/jinzhu/inflection v1.0.0 h1:K317FqzuhWc8YvSVlFMCCUb36O/S9MCKRDI7QkRKD
|
|||
github.com/jinzhu/inflection v1.0.0/go.mod h1:h+uFLlag+Qp1Va5pdKtLDYj+kHp5pxUVkryuEj+Srlc=
|
||||
github.com/jinzhu/now v1.1.5 h1:/o9tlHleP7gOFmsnYNz3RGnqzefHA47wQpKrrdTIwXQ=
|
||||
github.com/jinzhu/now v1.1.5/go.mod h1:d3SSVoowX0Lcu0IBviAWJpolVfI5UJVZZ7cO71lE/z8=
|
||||
github.com/jmespath/go-jmespath v0.0.0-20180206201540-c2b33e8439af/go.mod h1:Nht3zPeWKUH0NzdCt2Blrr5ys8VGpn0CEB0cQHVjt7k=
|
||||
github.com/jmespath/go-jmespath v0.4.0 h1:BEgLn5cpjn8UN1mAw4NjwDrS35OdebyEtFe+9YPoQUg=
|
||||
github.com/jmespath/go-jmespath v0.4.0/go.mod h1:T8mJZnbsbmF+m6zOOFylbeCJqk5+pHWvzYPziyZiYoo=
|
||||
github.com/jmespath/go-jmespath/internal/testify v1.5.1 h1:shLQSRRSCCPj3f2gpwzGwWFoC7ycTf1rcQZHOlsJ6N8=
|
||||
github.com/jmespath/go-jmespath/internal/testify v1.5.1/go.mod h1:L3OGu8Wl2/fWfCI6z80xFu9LTZmf1ZRjMHUOPmWr69U=
|
||||
github.com/json-iterator/go v1.1.5/go.mod h1:+SdeFBvtyEkXs7REEP0seUULqWtbJapLOCVDaaPEHmU=
|
||||
github.com/json-iterator/go v1.1.6/go.mod h1:+SdeFBvtyEkXs7REEP0seUULqWtbJapLOCVDaaPEHmU=
|
||||
github.com/json-iterator/go v1.1.9/go.mod h1:KdQUCv79m/52Kvf8AW2vK1V8akMuk1QjK/uOdHXbAo4=
|
||||
github.com/json-iterator/go v1.1.12 h1:PV8peI4a0ysnczrg+LtxykD8LfKY9ML6u2jnxaEnrnM=
|
||||
github.com/json-iterator/go v1.1.12/go.mod h1:e30LSqwooZae/UwlEbR2852Gd8hjQvJoHmT4TnhNGBo=
|
||||
github.com/jstemmer/go-junit-report v0.0.0-20190106144839-af01ea7f8024/go.mod h1:6v2b51hI/fHJwM22ozAgKL4VKDeJcHhJFhtBdhmNjmU=
|
||||
github.com/jstemmer/go-junit-report v0.9.1/go.mod h1:Brl9GWCQeLvo8nXZwPNNblvFj/XSXhF0NWZEnDohbsk=
|
||||
github.com/jtolds/gls v4.20.0+incompatible/go.mod h1:QJZ7F/aHp+rZTRtaJ1ow/lLfFfVYBRgL+9YlvaHOwJU=
|
||||
|
@ -413,11 +426,16 @@ github.com/miekg/dns v1.1.26/go.mod h1:bPDLeHnStXmXAq1m/Ch/hvfNHr14JKNPMBo3VZKju
|
|||
github.com/mitchellh/go-homedir v1.1.0/go.mod h1:SfyaCUpYCn1Vlf4IUYiD9fPX4A5wJrkLzIz1N1q0pr0=
|
||||
github.com/mitchellh/mapstructure v1.1.2/go.mod h1:FVVH3fgwuzCH5S8UJGiWEs2h04kUh9fWfEaFds41c1Y=
|
||||
github.com/modern-go/concurrent v0.0.0-20180228061459-e0a39a4cb421/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q=
|
||||
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd h1:TRLaZ9cD/w8PVh93nsPXa1VrQ6jlwL5oN8l14QlcNfg=
|
||||
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q=
|
||||
github.com/modern-go/reflect2 v0.0.0-20180701023420-4b7aa43c6742/go.mod h1:bx2lNnkwVCuqBIxFjflWJWanXIb3RllmbCylyMrvgv0=
|
||||
github.com/modern-go/reflect2 v1.0.1/go.mod h1:bx2lNnkwVCuqBIxFjflWJWanXIb3RllmbCylyMrvgv0=
|
||||
github.com/modern-go/reflect2 v1.0.2 h1:xBagoLtFs94CBntxluKeaWgTMpvLxC4ur3nMaC9Gz0M=
|
||||
github.com/modern-go/reflect2 v1.0.2/go.mod h1:yWuevngMOJpCy52FWWMvUC8ws7m/LJsjYzDa0/r8luk=
|
||||
github.com/moul/http2curl v1.0.0/go.mod h1:8UbvGypXm98wA/IqH45anm5Y2Z6ep6O31QGOAZ3H0fQ=
|
||||
github.com/mwitkow/go-conntrack v0.0.0-20161129095857-cc309e4a2223/go.mod h1:qRWi+5nqEBWmkhHvq77mSJWrCKwh8bxhgT7d/eI7P4U=
|
||||
github.com/nacos-group/nacos-sdk-go/v2 v2.2.3 h1:sUQx4f1bXDeeOOEQZjGAitzxYApbYY9fVDbxVCaBW+I=
|
||||
github.com/nacos-group/nacos-sdk-go/v2 v2.2.3/go.mod h1:UL4U89WYdnyajgKJUMpuT1Rr6iNmbjrxOO40JRgtA00=
|
||||
github.com/nats-io/jwt v0.3.0/go.mod h1:fRYCDE99xlTsqUzISS1Bi75UBJ6ljOJQOAAu5VglpSg=
|
||||
github.com/nats-io/nats.go v1.8.1/go.mod h1:BrFz9vVn0fU3AcH9Vn4Kd7W0NpJ651tD5omQ3M8LwxM=
|
||||
github.com/nats-io/nats.go v1.9.1/go.mod h1:ZjDU1L/7fJ09jvUSRVBR2e7+RnLiiIQyqyzEE/Zbp4w=
|
||||
|
@ -598,9 +616,15 @@ go.opentelemetry.io/otel/trace v1.14.0/go.mod h1:8avnQLK+CG77yNLUae4ea2JDQ6iT+go
|
|||
go.opentelemetry.io/proto/otlp v0.7.0/go.mod h1:PqfVotwruBrMGOCsRd/89rSnXhoiJIqeYNgFYFoEGnI=
|
||||
go.opentelemetry.io/proto/otlp v0.19.0 h1:IVN6GR+mhC4s5yfcTbmzHYODqvWAp3ZedA2SJPI1Nnw=
|
||||
go.opentelemetry.io/proto/otlp v0.19.0/go.mod h1:H7XAot3MsfNsj7EXtrA2q5xSNQ10UqI405h3+duxN4U=
|
||||
go.uber.org/atomic v1.10.0 h1:9qC72Qh0+3MqyJbAn8YU5xVq1frD8bn3JtD2oXtafVQ=
|
||||
go.uber.org/atomic v1.10.0/go.mod h1:LUxbIzbOniOlMKjJjyPfpl4v+PKK2cNJn91OQbhoJI0=
|
||||
go.uber.org/automaxprocs v1.5.2 h1:2LxUOGiR3O6tw8ui5sZa2LAaHnsviZdVOUZw4fvbnME=
|
||||
go.uber.org/automaxprocs v1.5.2/go.mod h1:eRbA25aqJrxAbsLO0xy5jVwPt7FQnRgjW+efnwa1WM0=
|
||||
go.uber.org/goleak v1.2.1 h1:NBol2c7O1ZokfZ0LEU9K6Whx/KnwvepVetCUhtKja4A=
|
||||
go.uber.org/multierr v1.9.0 h1:7fIwc/ZtS0q++VgcfqFDxSBZVv/Xo49/SYnDFupUwlI=
|
||||
go.uber.org/multierr v1.9.0/go.mod h1:X2jQV1h+kxSjClGpnseKVIxpmcjrj7MNnI0bnlfKTVQ=
|
||||
go.uber.org/zap v1.24.0 h1:FiJd5l1UOLj0wCgbSE0rwwXHzEdAZS6hiiSnxJN/D60=
|
||||
go.uber.org/zap v1.24.0/go.mod h1:2kMP+WWQ8aoFoedH3T2sq6iJ2yDWpHbP0f6MQbS9Gkg=
|
||||
golang.org/x/crypto v0.0.0-20180904163835-0709b304e793/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4=
|
||||
golang.org/x/crypto v0.0.0-20181203042331-505ab145d0a9/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4=
|
||||
golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w=
|
||||
|
@ -721,6 +745,7 @@ golang.org/x/sync v0.0.0-20201020160332-67f06af15bc9/go.mod h1:RxMgew5VJxzue5/jJ
|
|||
golang.org/x/sync v0.0.0-20210220032951-036812b2e83c/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
|
||||
golang.org/x/sync v0.0.0-20220722155255-886fb9371eb4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
|
||||
golang.org/x/sync v0.2.0 h1:PUR+T4wwASmuSTYdKjYHI5TD22Wy5ogLU5qZCOLxBrI=
|
||||
golang.org/x/sync v0.2.0/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
|
||||
golang.org/x/sys v0.0.0-20180830151530-49385e6e1522/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
|
||||
golang.org/x/sys v0.0.0-20180905080454-ebe1bf3edb33/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
|
||||
golang.org/x/sys v0.0.0-20180909124046-d0be0721c37e/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
|
||||
|
@ -798,6 +823,8 @@ golang.org/x/time v0.0.0-20181108054448-85acf8d2951c/go.mod h1:tRJNPiyCQ0inRvYxb
|
|||
golang.org/x/time v0.0.0-20190308202827-9d24e82272b4/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ=
|
||||
golang.org/x/time v0.0.0-20191024005414-555d28b269f0/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ=
|
||||
golang.org/x/time v0.0.0-20201208040808-7e3f01d25324/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ=
|
||||
golang.org/x/time v0.3.0 h1:rg5rLMjNzMS1RkNLzCG38eapWhnYLFYXDXj2gOlr8j4=
|
||||
golang.org/x/time v0.3.0/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ=
|
||||
golang.org/x/tools v0.0.0-20180525024113-a5b4c53f6e8b/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
|
||||
golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
|
||||
golang.org/x/tools v0.0.0-20181030221726-6c7e314b6563/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
|
||||
|
@ -847,6 +874,7 @@ golang.org/x/tools v0.0.0-20200729194436-6467de6f59a7/go.mod h1:njjCfa9FT2d7l9Bc
|
|||
golang.org/x/tools v0.0.0-20200804011535-6c149bb5ef0d/go.mod h1:njjCfa9FT2d7l9Bc6FUM5FLjQPp3cFF28FI3qnDFljA=
|
||||
golang.org/x/tools v0.0.0-20200825202427-b303f430e36d/go.mod h1:njjCfa9FT2d7l9Bc6FUM5FLjQPp3cFF28FI3qnDFljA=
|
||||
golang.org/x/tools v0.0.0-20210106214847-113979e3529a/go.mod h1:emZCQorbCU4vsT4fOWvOPXz4eW1wZW4PmDk9uLelYpA=
|
||||
golang.org/x/tools v0.1.1/go.mod h1:o0xws9oXOQQZyjljx8fwUC0k7L1pTE6eaCbjGeHmOkk=
|
||||
golang.org/x/tools v0.1.3/go.mod h1:o0xws9oXOQQZyjljx8fwUC0k7L1pTE6eaCbjGeHmOkk=
|
||||
golang.org/x/tools v0.1.12/go.mod h1:hNGJHUnrk76NpqgfD5Aqm5Crs+Hm0VOH/i9J2+nxYbc=
|
||||
golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
|
||||
|
@ -969,7 +997,11 @@ gopkg.in/go-playground/assert.v1 v1.2.1/go.mod h1:9RXL0bg/zibRAgZUYszZSwO/z8Y/a8
|
|||
gopkg.in/go-playground/validator.v8 v8.18.2/go.mod h1:RX2a/7Ha8BgOhfk7j780h4/u/RRjR0eouCJSH80/M2Y=
|
||||
gopkg.in/h2non/gock.v1 v1.1.2 h1:jBbHXgGBK/AoPVfJh5x4r/WxIrElvbLel8TCZkkZJoY=
|
||||
gopkg.in/ini.v1 v1.51.1/go.mod h1:pNLf8WUiyNEtQjuu5G5vTm06TEv9tsIgeAvK8hOrP4k=
|
||||
gopkg.in/ini.v1 v1.66.2 h1:XfR1dOYubytKy4Shzc2LHrrGhU0lDCfDGG1yLPmpgsI=
|
||||
gopkg.in/ini.v1 v1.66.2/go.mod h1:pNLf8WUiyNEtQjuu5G5vTm06TEv9tsIgeAvK8hOrP4k=
|
||||
gopkg.in/mgo.v2 v2.0.0-20180705113604-9856a29383ce/go.mod h1:yeKp02qBN3iKW1OzL3MGk2IdtZzaj7SFntXj72NppTA=
|
||||
gopkg.in/natefinch/lumberjack.v2 v2.0.0 h1:1Lc07Kr7qY4U2YPouBjpCLxpiyxIVoxqXgkXLknAOE8=
|
||||
gopkg.in/natefinch/lumberjack.v2 v2.0.0/go.mod h1:l0ndWWf7gzL7RNwBG7wST/UCcT4T24xpD6X8LsfU/+k=
|
||||
gopkg.in/tomb.v1 v1.0.0-20141024135613-dd632973f1e7 h1:uRGJdciOHaEIrze2W8Q3AKkepLTh2hOroT7a+7czfdQ=
|
||||
gopkg.in/tomb.v1 v1.0.0-20141024135613-dd632973f1e7/go.mod h1:dt/ZhP58zS4L8KSrWDmTeBkI65Dw0HsyUHuEVlX15mw=
|
||||
gopkg.in/yaml.v2 v2.2.1/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
|
||||
|
|
|
@ -3,7 +3,7 @@ Host: {{.host}}
|
|||
Port: {{.port}}
|
||||
Timeout: 15000 #服务超时时间(毫秒)
|
||||
SourceMysql: fsreaderwriter:XErSYmLELKMnf3Dh@tcp(fusen.cdmigcvz3rle.us-east-2.rds.amazonaws.com:3306)/fusen
|
||||
SourceRabbitMq: amqp://rabbit001:rabbit001129@110.41.19.98:5672
|
||||
SourceRabbitMq: ""
|
||||
Auth:
|
||||
AccessSecret: fusen2023
|
||||
AccessExpire: 2592000
|
||||
|
|
|
@ -7,6 +7,7 @@ import (
|
|||
"time"
|
||||
|
||||
"fusenapi/utils/auth"
|
||||
"fusenapi/utils/fsconfig"
|
||||
|
||||
{{.importPackages}}
|
||||
)
|
||||
|
@ -16,8 +17,10 @@ var configFile = flag.String("f", "etc/{{.serviceName}}.yaml", "the config file"
|
|||
func main() {
|
||||
flag.Parse()
|
||||
|
||||
cfgContent := fsconfig.StartNacosConfig(configFile,nil)
|
||||
var c config.Config
|
||||
conf.MustLoad(*configFile, &c)
|
||||
conf.LoadConfigFromYamlBytes([]byte(cfgContent),&c)
|
||||
|
||||
c.Timeout = int64(time.Second * 15)
|
||||
server := rest.MustNewServer(c.RestConf, rest.WithCustomCors(auth.FsCors, func(w http.ResponseWriter) {
|
||||
}))
|
||||
|
|
|
@ -13,7 +13,7 @@ func main() {
|
|||
flag.Parse()
|
||||
|
||||
var c gateway.GatewayConf
|
||||
conf.MustLoad(*configFile, &c)
|
||||
|
||||
c.Timeout = int64(time.Second * 15)
|
||||
gw := gateway.MustNewServer(c)
|
||||
defer gw.Stop()
|
||||
|
|
|
@ -18,8 +18,10 @@ var configFile = flag.String("f", "etc/{{.serviceName}}.yaml", "the config file"
|
|||
func main() {
|
||||
flag.Parse()
|
||||
|
||||
cfgContent := fsconfig.StartNacosConfig(configFile,nil)
|
||||
var c config.Config
|
||||
conf.MustLoad(*configFile, &c)
|
||||
conf.LoadConfigFromYamlBytes([]byte(cfgContent),&c)
|
||||
|
||||
c.Timeout = int64(time.Second * 15)
|
||||
ctx := svc.NewServiceContext(c)
|
||||
|
||||
|
|
|
@ -7,6 +7,7 @@ import (
|
|||
"time"
|
||||
|
||||
"fusenapi/utils/auth"
|
||||
"fusenapi/utils/fsconfig"
|
||||
|
||||
{{.importPackages}}
|
||||
)
|
||||
|
@ -16,8 +17,10 @@ var configFile = flag.String("f", "etc/{{.serviceName}}.yaml", "the config file"
|
|||
func main() {
|
||||
flag.Parse()
|
||||
|
||||
cfgContent := fsconfig.StartNacosConfig(configFile,nil)
|
||||
var c config.Config
|
||||
conf.MustLoad(*configFile, &c)
|
||||
conf.LoadConfigFromYamlBytes([]byte(cfgContent),&c)
|
||||
|
||||
c.Timeout = int64(time.Second * 15)
|
||||
|
||||
server := rest.MustNewServer(c.RestConf, rest.WithCustomCors(auth.FsCors, func(w http.ResponseWriter) {
|
||||
|
|
|
@ -13,7 +13,7 @@ func main() {
|
|||
flag.Parse()
|
||||
|
||||
var c gateway.GatewayConf
|
||||
conf.MustLoad(*configFile, &c)
|
||||
|
||||
c.Timeout = int64(time.Second * 15)
|
||||
gw := gateway.MustNewServer(c)
|
||||
defer gw.Stop()
|
||||
|
|
|
@ -18,8 +18,10 @@ var configFile = flag.String("f", "etc/{{.serviceName}}.yaml", "the config file"
|
|||
func main() {
|
||||
flag.Parse()
|
||||
|
||||
cfgContent := fsconfig.StartNacosConfig(configFile,nil)
|
||||
var c config.Config
|
||||
conf.MustLoad(*configFile, &c)
|
||||
conf.LoadConfigFromYamlBytes([]byte(cfgContent),&c)
|
||||
|
||||
c.Timeout = int64(time.Second * 15)
|
||||
ctx := svc.NewServiceContext(c)
|
||||
|
||||
|
|
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_storage_gen.go
Normal file
25
model/gmodel/fs_cloud_storage_gen.go
Normal file
|
@ -0,0 +1,25 @@
|
|||
package gmodel
|
||||
|
||||
import (
|
||||
"gorm.io/gorm"
|
||||
)
|
||||
|
||||
// fs_cloud_storage 仓库的基本信息, 只做映射
|
||||
type FsCloudStorage struct {
|
||||
CloudStorageId *string `gorm:"unique_key;default:'';" json:"cloud_storage_id"` // 仓库id, 需要固定的命名规则, 能表达国外国内,区域等,简单明了
|
||||
Name *string `gorm:"default:'';" json:"name"` // 仓库的名字, 中文使用拼音,国外使用英文
|
||||
Address *string `gorm:"default:'';" json:"address"` // 仓库地址
|
||||
Contact *[]byte `gorm:"default:'';" json:"contact"` //
|
||||
Ownership *int64 `gorm:"default:0;" json:"ownership"` // 0为自有, 1为第三方, 后期可以自由定制
|
||||
Scope *[]byte `gorm:"default:'';" json:"scope"` //
|
||||
Capacity *[]byte `gorm:"default:'';" json:"capacity"` //
|
||||
Metadata *[]byte `gorm:"default:'';" json:"metadata"` //
|
||||
}
|
||||
type FsCloudStorageModel struct {
|
||||
db *gorm.DB
|
||||
name string
|
||||
}
|
||||
|
||||
func NewFsCloudStorageModel(db *gorm.DB) *FsCloudStorageModel {
|
||||
return &FsCloudStorageModel{db: db, name: "fs_cloud_storage"}
|
||||
}
|
2
model/gmodel/fs_cloud_storage_logic.go
Normal file
2
model/gmodel/fs_cloud_storage_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的属性做你想做的
|
|
@ -1,48 +1,23 @@
|
|||
package gmodel
|
||||
|
||||
import (
|
||||
"gorm.io/gorm"
|
||||
"time"
|
||||
|
||||
"gorm.io/gorm"
|
||||
)
|
||||
|
||||
// fs_order
|
||||
// fs_order 订单表
|
||||
type FsOrder struct {
|
||||
Id int64 `gorm:"primary_key;default:0;auto_increment;" json:"id"` //
|
||||
Sn *string `gorm:"unique_key;default:'';" json:"sn"` // 订单编号 FS211224OL2XDKNP
|
||||
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"` // 邮件发送时间
|
||||
Id int64 `gorm:"primary_key;default:0;auto_increment;" json:"id"` // 订单ID
|
||||
UserId *int64 `gorm:"index;default:0;" json:"user_id"` // 用户ID
|
||||
DeliveryMethod *int64 `gorm:"index;default:0;" json:"delivery_method"` // 物流类型
|
||||
OrderSn *string `gorm:"index;default:'';" json:"order_sn"` //
|
||||
OrderSource *string `gorm:"default:'';" json:"order_source"` //
|
||||
Status *int64 `gorm:"index;default:0;" json:"status"` // 订单状态
|
||||
Metadata *[]byte `gorm:"default:'';" json:"metadata"` //
|
||||
Ctime *time.Time `gorm:"default:'0000-00-00 00:00:00';" json:"ctime"` //
|
||||
Utime *time.Time `gorm:"default:'0000-00-00 00:00:00';" json:"utime"` //
|
||||
IsDel *int64 `gorm:"default:0;" json:"is_del"` // 是否删除:0=否,1=是
|
||||
}
|
||||
type FsOrderModel struct {
|
||||
db *gorm.DB
|
||||
|
|
260
model/gmodel/fs_order_logic.go
Executable file → Normal file
260
model/gmodel/fs_order_logic.go
Executable file → Normal file
|
@ -1,192 +1,128 @@
|
|||
package gmodel
|
||||
|
||||
import (
|
||||
"context"
|
||||
"fusenapi/constants"
|
||||
"reflect"
|
||||
"time"
|
||||
|
||||
"fusenapi/utils/handlers"
|
||||
|
||||
"gorm.io/gorm"
|
||||
)
|
||||
|
||||
func (o *FsOrderModel) FindOneBySn(ctx context.Context, userId int64, sn string) (resp *FsOrder, err error) {
|
||||
err = o.db.WithContext(ctx).Model(&FsOrder{}).Where(" `user_id` = ? and `sn` = ? ", userId, sn).Take(&resp).Error
|
||||
return resp, err
|
||||
// TODO: 使用model的属性做你想做的
|
||||
|
||||
type NewFsOrder struct {
|
||||
Id int64 `gorm:"primary_key;default:0;auto_increment;" json:"id"` // 订单ID
|
||||
UserId *int64 `gorm:"index;default:0;" json:"user_id"` // 用户ID
|
||||
DeliveryMethod *int64 `gorm:"index;default:0;" json:"delivery_method"` // 物流类型
|
||||
OrderSn *string `gorm:"index;default:'';" json:"order_sn"` //
|
||||
OrderSource *string `gorm:"default:'';" json:"order_source"` //
|
||||
Status *int64 `gorm:"index;default:0;" json:"status"` // 订单状态
|
||||
Metadata *OrderDetail `gorm:"metadata,type:json" 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"` //
|
||||
IsDel *int64 `gorm:"default:0;" json:"is_del"` // 是否删除:0=否,1=是
|
||||
}
|
||||
|
||||
func (o *FsOrderModel) FindOne(ctx context.Context, userId int64, OrderId int64) (order *FsOrder, err error) {
|
||||
err = o.db.WithContext(ctx).Model(&FsOrder{}).Where("`user_id` = ? and `id` = ?", userId, OrderId).Take(&order).Error
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return
|
||||
// 订单详情
|
||||
type OrderDetail struct {
|
||||
DeliveryAddress *OrderAddress `json:"delivery_address"` // 收货地址
|
||||
OrderAmount OrderAmount `json:"order_amount"` // 订单金额
|
||||
OrderInfo OrderInfo `json:"order_info"` // 订单信息
|
||||
OrderProduct []OrderProduct `json:"order_product"` // 订单商品
|
||||
}
|
||||
|
||||
func (o *FsOrderModel) Update(ctx context.Context, data *FsOrder) error {
|
||||
return o.db.WithContext(ctx).Model(&FsOrder{}).Where("`id` = ?", data.Id).Updates(&data).Error
|
||||
// 收货地址
|
||||
type OrderAddress struct {
|
||||
Address string `json:"address"` // 详细地址
|
||||
Mobile string `json:"mobile"` // 手机
|
||||
Name string `json:"name"` // 姓名
|
||||
}
|
||||
|
||||
func (o *FsOrderModel) RBUpdate(ctx context.Context, data *FsOrder) error {
|
||||
return o.db.WithContext(ctx).Where("`id` = ?", data.Id).Updates(&data).Error
|
||||
// 订单金额
|
||||
type OrderAmount struct {
|
||||
Deposit PayInfo `json:"deposit"` // 定金
|
||||
RemainingBalance PayInfo `json:"remaining_balance"` // 尾款
|
||||
Discount AmountInfo `json:"discount"` // 折扣
|
||||
ShippingFee AmountInfo `json:"shipping_fee"` // 邮费
|
||||
Tax AmountInfo `json:"tax"` // 税费
|
||||
Subtotal AmountInfo `json:"subtotal"` // 商品总金额
|
||||
Total AmountInfo `json:"total"` // 订单总金额
|
||||
}
|
||||
|
||||
func (o *FsOrderModel) Create(ctx context.Context, data *FsOrder) error {
|
||||
return o.db.WithContext(ctx).Model(&FsOrder{}).Create(&data).Error
|
||||
// 支付明细
|
||||
type PayInfo struct {
|
||||
Metadata map[string]interface{} `json:"metadata"` // 额外参数
|
||||
PayAmount AmountInfo `json:"pay_amount"` // 金额明细
|
||||
PayMethod string `json:"pay_method"` // 交易方式
|
||||
PayTime string `json:"pay_time"` // 支付时间
|
||||
Status PayStatus `json:"status"` // 当前状态
|
||||
StatusLink []PayStatus `json:"status_link"` // 状态链路
|
||||
TradeNo string `json:"trade_no"` // 支付交易号
|
||||
}
|
||||
|
||||
func (o *FsOrderModel) FindOneAndCreateServiceContact(ctx context.Context, userId int64, OrderId int64, cs *FsContactService) (order *FsOrder, err error) {
|
||||
err = o.db.WithContext(ctx).Transaction(func(tx *gorm.DB) error {
|
||||
err = tx.Model(&FsOrder{}).Select("id").Limit(1).Where("`user_id` = ? and `id` = ?", userId, OrderId).Take(&order).Error
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
ctime := time.Now().UTC().Unix()
|
||||
cs.Ctime = &ctime
|
||||
if constants.ConcactService(*cs.Type) == constants.TYPE_DEFAULT {
|
||||
*cs.RelationId = 0
|
||||
}
|
||||
|
||||
return tx.Model(&FsContactService{}).Create(cs).Error
|
||||
})
|
||||
return order, err
|
||||
// 金额明细
|
||||
type AmountInfo struct {
|
||||
Change AmountCurrency `json:"change,omitempty"` // 变动金额
|
||||
ChangeRemark string `json:"change_remark,omitempty"` // 变动备注
|
||||
Current AmountCurrency `json:"current"` // 当前金额
|
||||
Initiate AmountCurrency `json:"initiate"` // 初始金额
|
||||
Metadata map[string]interface{} `json:"metadata"` // 额外明细
|
||||
}
|
||||
|
||||
// 获取用户最近下单成功的订单
|
||||
func (o *FsOrderModel) FindLastSuccessOneOrder(ctx context.Context, userId int64, statusGt int64) (order *FsOrder, err error) {
|
||||
err = o.db.WithContext(ctx).Model(&FsOrder{}).Where("`user_id` = ? and `status` > ?", userId, statusGt).Order("id DESC").Take(&order).Error
|
||||
return order, err
|
||||
// 金额货币
|
||||
type AmountCurrency struct {
|
||||
ExchangeRate constants.ExchangeRateUnit `json:"exchange_rate"` // 换算汇率
|
||||
CurrentCurrency string `json:"current_currency"` // 当前货币
|
||||
CurrentAmount constants.AmountUnit `json:"current_amount"` // 当前金额
|
||||
OriginalCurrency string `json:"original_currency"` // 原始货币
|
||||
OriginalAmount constants.AmountUnit `json:"original_amount"` // 原始金额
|
||||
}
|
||||
|
||||
// 分页查询的订单
|
||||
func (o *FsOrderModel) FindPageListByPage(ctx context.Context, rowBuilder *gorm.DB, page *int64, pageSize *int64, filterMap map[string]string, orderBy string) ([]*FsOrderRel, error) {
|
||||
var resp []*FsOrderRel
|
||||
// 过滤
|
||||
if filterMap != nil {
|
||||
rowBuilder = rowBuilder.Scopes(handlers.FilterData(filterMap))
|
||||
}
|
||||
|
||||
// 排序
|
||||
if orderBy != "" {
|
||||
var fieldsMap = make(map[string]struct{})
|
||||
s := reflect.TypeOf(&FsOrder{}).Elem() //通过反射获取type定义
|
||||
for i := 0; i < s.NumField(); i++ {
|
||||
fieldsMap[s.Field(i).Tag.Get("json")] = struct{}{}
|
||||
}
|
||||
rowBuilder = rowBuilder.Scopes(handlers.OrderCheck(orderBy, fieldsMap))
|
||||
}
|
||||
|
||||
// 分页
|
||||
rowBuilder = rowBuilder.Scopes(handlers.Paginate(page, pageSize))
|
||||
|
||||
// 结果
|
||||
result := rowBuilder.Debug().WithContext(ctx).Find(&resp)
|
||||
if result.Error != nil {
|
||||
return nil, result.Error
|
||||
} else {
|
||||
return resp, nil
|
||||
}
|
||||
// 支付状态
|
||||
type PayStatus struct {
|
||||
Metadata map[string]interface{} `json:"metadata"` // 额外参数
|
||||
StatusCode int64 `json:"status_code"` // 状态编码
|
||||
StatusTitle string `json:"status_title"` // 状态名称
|
||||
}
|
||||
|
||||
type FsOrderRel struct {
|
||||
FsOrder
|
||||
FsOrderDetails []FsOrderDetails `gorm:"foreignKey:order_id;references:id"`
|
||||
FsOrderAffiliateInfo FsOrderAffiliate `gorm:"foreignKey:order_id;references:id"`
|
||||
// 订单信息
|
||||
type OrderInfo struct {
|
||||
Ctime string `json:"ctime"` // 创建日期
|
||||
DeliveryMethod int64 `json:"delivery_method"` // 物流类型
|
||||
Metadata map[string]interface{} `json:"metadata"` // 额外参数
|
||||
OrderSn string `json:"order_sn"` // 订单编号
|
||||
Status OrderStatus `json:"status"` // 当前状态
|
||||
StatusLink []OrderStatus `json:"status_link"` // 状态链路
|
||||
Utime string `json:"utime"` // 更新时间
|
||||
}
|
||||
|
||||
type FsOrderDetails struct {
|
||||
FsOrderDetail
|
||||
FsOrderDetailTemplateInfo FsOrderDetailTemplateInfo `gorm:"foreignKey:id;references:order_detail_template_id"`
|
||||
FsProductInfo FsProduct `gorm:"foreignKey:id;references:product_id"`
|
||||
// 订单状态--用户
|
||||
type OrderStatus struct {
|
||||
Children []*OrderStatus `json:"children"` // 子状态,管理人员的处理状态, 用户不可见
|
||||
Ctime string `json:"ctime"` // 创建时间
|
||||
ExpectedTime string `json:"expected_time"` // 预计时间
|
||||
Metadata map[string]interface{} `json:"metadata"` // 额外参数
|
||||
StatusCode constants.OrderStatusCode `json:"status_code"` // 状态编码
|
||||
StatusTitle string `json:"status_title"` // 状态名称
|
||||
Utime string `json:"utime"` // 更新时间
|
||||
}
|
||||
|
||||
type FsOrderDetailTemplateInfo struct {
|
||||
FsOrderDetailTemplate
|
||||
FsProductDesignInfo FsProductDesignInfo `gorm:"foreignKey:id;references:design_id"` //获取设计数据
|
||||
FsProductSizeInfo FsProductSize `gorm:"foreignKey:id;references:size_id"`
|
||||
// 订单商品
|
||||
type OrderProduct struct {
|
||||
Amount AmountInfo `json:"amount"` // 商品总价
|
||||
ExpectedDeliveryTime string `json:"expected_delivery_time"` // 预计到货时间
|
||||
Number int64 `json:"number"` // 商品数量
|
||||
ProductID int64 `json:"product_id"` // 商品ID
|
||||
ProductLogo string `json:"product_logo"` // 商品logo
|
||||
ProductLogoResource *Resource `json:"product_logo_resource"` // 商品封面--资源详情
|
||||
ProductName string `json:"product_name"` // 商品名称
|
||||
ProductPrice AmountInfo `json:"product_price"` // 商品单价
|
||||
ProductSnapshot map[string]interface{} `json:"product_snapshot"` // 商品快照
|
||||
ShoppingCartSnapshot *FsShoppingCart `json:"shopping_cart_snapshot"` // 购物车快照
|
||||
Unit string `json:"unit"` // 商品单位
|
||||
}
|
||||
|
||||
type FsProductDesignInfo struct {
|
||||
FsProductDesign
|
||||
OptionData FsProduct `gorm:"foreignKey:id;references:optional_id"` //获取配件信息
|
||||
TemplateData FsProductTemplateV2 `gorm:"foreignKey:id;references:template_id"` //获取模板信息
|
||||
}
|
||||
|
||||
func (m *FsOrderModel) RowSelectBuilder(selectData []string) *gorm.DB {
|
||||
var rowBuilder = m.db.Table(m.name)
|
||||
|
||||
if selectData != nil {
|
||||
rowBuilder = rowBuilder.Select(selectData)
|
||||
} else {
|
||||
rowBuilder = rowBuilder.Select("*")
|
||||
}
|
||||
return rowBuilder
|
||||
}
|
||||
|
||||
func (m *FsOrderModel) BuilderTrans(selectData []string) *gorm.DB {
|
||||
var rowBuilder = m.db
|
||||
|
||||
if selectData != nil {
|
||||
rowBuilder = rowBuilder.Select(selectData)
|
||||
} else {
|
||||
rowBuilder = rowBuilder.Select("*")
|
||||
}
|
||||
return rowBuilder
|
||||
}
|
||||
|
||||
func (m *FsOrderModel) FindCount(ctx context.Context, countBuilder *gorm.DB, filterMap map[string]string) (int64, error) {
|
||||
var count int64
|
||||
|
||||
// 过滤
|
||||
if filterMap != nil {
|
||||
countBuilder = countBuilder.Scopes(handlers.FilterData(filterMap))
|
||||
}
|
||||
|
||||
result := countBuilder.WithContext(ctx).Limit(1).Count(&count)
|
||||
if result.Error != nil {
|
||||
return 0, result.Error
|
||||
} else {
|
||||
return count, nil
|
||||
}
|
||||
}
|
||||
|
||||
func (m *FsOrderModel) FindOneByQuery(ctx context.Context, rowBuilder *gorm.DB, filterMap map[string]string) (*FsOrderRel, error) {
|
||||
var resp FsOrderRel
|
||||
|
||||
if filterMap != nil {
|
||||
rowBuilder = rowBuilder.Scopes(handlers.FilterData(filterMap))
|
||||
}
|
||||
|
||||
result := rowBuilder.WithContext(ctx).Limit(1).Find(&resp)
|
||||
if result.Error != nil {
|
||||
return nil, result.Error
|
||||
} else {
|
||||
return &resp, nil
|
||||
}
|
||||
}
|
||||
|
||||
// 事务
|
||||
func (m *FsOrderModel) Trans(ctx context.Context, fn func(ctx context.Context, connGorm *gorm.DB) error) error {
|
||||
tx := m.db.Table(m.name).WithContext(ctx).Begin()
|
||||
defer func() {
|
||||
if r := recover(); r != nil {
|
||||
tx.Rollback()
|
||||
}
|
||||
}()
|
||||
|
||||
if err := tx.Error; err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
if err := fn(ctx, tx); err != nil {
|
||||
tx.Rollback()
|
||||
return err
|
||||
}
|
||||
|
||||
return tx.Commit().Error
|
||||
}
|
||||
|
||||
func (m *FsOrderModel) TableName() string {
|
||||
return m.name
|
||||
// 资源详情
|
||||
type Resource struct {
|
||||
Metadata map[string]interface{} `json:"metadata"` // 资源额外
|
||||
ResourceID string `json:"resource_id"` // 资源ID
|
||||
ResourceType string `json:"resource_type"` // 资源类型
|
||||
ResourceURL string `json:"resource_url"` // 资源地址
|
||||
}
|
||||
|
|
192
model/gmodel/fs_order_logic_1.go
Executable file
192
model/gmodel/fs_order_logic_1.go
Executable file
|
@ -0,0 +1,192 @@
|
|||
package gmodel
|
||||
|
||||
import (
|
||||
"context"
|
||||
"fusenapi/constants"
|
||||
"reflect"
|
||||
"time"
|
||||
|
||||
"fusenapi/utils/handlers"
|
||||
|
||||
"gorm.io/gorm"
|
||||
)
|
||||
|
||||
func (o *FsOrderModel) FindOneBySn(ctx context.Context, userId int64, sn string) (resp *FsOrder, err error) {
|
||||
err = o.db.WithContext(ctx).Model(&FsOrder{}).Where(" `user_id` = ? and `sn` = ? ", userId, sn).Take(&resp).Error
|
||||
return resp, err
|
||||
}
|
||||
|
||||
func (o *FsOrderModel) FindOne(ctx context.Context, userId int64, OrderId int64) (order *FsOrder, err error) {
|
||||
err = o.db.WithContext(ctx).Model(&FsOrder{}).Where("`user_id` = ? and `id` = ?", userId, OrderId).Take(&order).Error
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
func (o *FsOrderModel) Update(ctx context.Context, data *FsOrder) error {
|
||||
return o.db.WithContext(ctx).Model(&FsOrder{}).Where("`id` = ?", data.Id).Updates(&data).Error
|
||||
}
|
||||
|
||||
func (o *FsOrderModel) RBUpdate(ctx context.Context, data *FsOrder) error {
|
||||
return o.db.WithContext(ctx).Where("`id` = ?", data.Id).Updates(&data).Error
|
||||
}
|
||||
|
||||
func (o *FsOrderModel) Create(ctx context.Context, data *FsOrder) error {
|
||||
return o.db.WithContext(ctx).Model(&FsOrder{}).Create(&data).Error
|
||||
}
|
||||
|
||||
func (o *FsOrderModel) FindOneAndCreateServiceContact(ctx context.Context, userId int64, OrderId int64, cs *FsContactService) (order *FsOrder, err error) {
|
||||
err = o.db.WithContext(ctx).Transaction(func(tx *gorm.DB) error {
|
||||
err = tx.Model(&FsOrder{}).Select("id").Limit(1).Where("`user_id` = ? and `id` = ?", userId, OrderId).Take(&order).Error
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
ctime := time.Now().UTC().Unix()
|
||||
cs.Ctime = &ctime
|
||||
if constants.ConcactService(*cs.Type) == constants.TYPE_DEFAULT {
|
||||
*cs.RelationId = 0
|
||||
}
|
||||
|
||||
return tx.Model(&FsContactService{}).Create(cs).Error
|
||||
})
|
||||
return order, err
|
||||
}
|
||||
|
||||
// 获取用户最近下单成功的订单
|
||||
func (o *FsOrderModel) FindLastSuccessOneOrder(ctx context.Context, userId int64, statusGt int64) (order *FsOrder, err error) {
|
||||
err = o.db.WithContext(ctx).Model(&FsOrder{}).Where("`user_id` = ? and `status` > ?", userId, statusGt).Order("id DESC").Take(&order).Error
|
||||
return order, err
|
||||
}
|
||||
|
||||
// 分页查询的订单
|
||||
func (o *FsOrderModel) FindPageListByPage(ctx context.Context, rowBuilder *gorm.DB, page *int64, pageSize *int64, filterMap map[string]string, orderBy string) ([]*FsOrderRel, error) {
|
||||
var resp []*FsOrderRel
|
||||
// 过滤
|
||||
if filterMap != nil {
|
||||
rowBuilder = rowBuilder.Scopes(handlers.FilterData(filterMap))
|
||||
}
|
||||
|
||||
// 排序
|
||||
if orderBy != "" {
|
||||
var fieldsMap = make(map[string]struct{})
|
||||
s := reflect.TypeOf(&FsOrder{}).Elem() //通过反射获取type定义
|
||||
for i := 0; i < s.NumField(); i++ {
|
||||
fieldsMap[s.Field(i).Tag.Get("json")] = struct{}{}
|
||||
}
|
||||
rowBuilder = rowBuilder.Scopes(handlers.OrderCheck(orderBy, fieldsMap))
|
||||
}
|
||||
|
||||
// 分页
|
||||
rowBuilder = rowBuilder.Scopes(handlers.Paginate(page, pageSize))
|
||||
|
||||
// 结果
|
||||
result := rowBuilder.Debug().WithContext(ctx).Find(&resp)
|
||||
if result.Error != nil {
|
||||
return nil, result.Error
|
||||
} else {
|
||||
return resp, nil
|
||||
}
|
||||
}
|
||||
|
||||
type FsOrderRel struct {
|
||||
FsOrder
|
||||
FsOrderDetails []FsOrderDetails `gorm:"foreignKey:order_id;references:id"`
|
||||
FsOrderAffiliateInfo FsOrderAffiliate `gorm:"foreignKey:order_id;references:id"`
|
||||
}
|
||||
|
||||
type FsOrderDetails struct {
|
||||
FsOrderDetail
|
||||
FsOrderDetailTemplateInfo FsOrderDetailTemplateInfo `gorm:"foreignKey:id;references:order_detail_template_id"`
|
||||
FsProductInfo FsProduct `gorm:"foreignKey:id;references:product_id"`
|
||||
}
|
||||
|
||||
type FsOrderDetailTemplateInfo struct {
|
||||
FsOrderDetailTemplate
|
||||
FsProductDesignInfo FsProductDesignInfo `gorm:"foreignKey:id;references:design_id"` //获取设计数据
|
||||
FsProductSizeInfo FsProductSize `gorm:"foreignKey:id;references:size_id"`
|
||||
}
|
||||
|
||||
type FsProductDesignInfo struct {
|
||||
FsProductDesign
|
||||
OptionData FsProduct `gorm:"foreignKey:id;references:optional_id"` //获取配件信息
|
||||
TemplateData FsProductTemplateV2 `gorm:"foreignKey:id;references:template_id"` //获取模板信息
|
||||
}
|
||||
|
||||
func (m *FsOrderModel) RowSelectBuilder(selectData []string) *gorm.DB {
|
||||
var rowBuilder = m.db.Table(m.name)
|
||||
|
||||
if selectData != nil {
|
||||
rowBuilder = rowBuilder.Select(selectData)
|
||||
} else {
|
||||
rowBuilder = rowBuilder.Select("*")
|
||||
}
|
||||
return rowBuilder
|
||||
}
|
||||
|
||||
func (m *FsOrderModel) BuilderTrans(selectData []string) *gorm.DB {
|
||||
var rowBuilder = m.db
|
||||
|
||||
if selectData != nil {
|
||||
rowBuilder = rowBuilder.Select(selectData)
|
||||
} else {
|
||||
rowBuilder = rowBuilder.Select("*")
|
||||
}
|
||||
return rowBuilder
|
||||
}
|
||||
|
||||
func (m *FsOrderModel) FindCount(ctx context.Context, countBuilder *gorm.DB, filterMap map[string]string) (int64, error) {
|
||||
var count int64
|
||||
|
||||
// 过滤
|
||||
if filterMap != nil {
|
||||
countBuilder = countBuilder.Scopes(handlers.FilterData(filterMap))
|
||||
}
|
||||
|
||||
result := countBuilder.WithContext(ctx).Limit(1).Count(&count)
|
||||
if result.Error != nil {
|
||||
return 0, result.Error
|
||||
} else {
|
||||
return count, nil
|
||||
}
|
||||
}
|
||||
|
||||
func (m *FsOrderModel) FindOneByQuery(ctx context.Context, rowBuilder *gorm.DB, filterMap map[string]string) (*FsOrderRel, error) {
|
||||
var resp FsOrderRel
|
||||
|
||||
if filterMap != nil {
|
||||
rowBuilder = rowBuilder.Scopes(handlers.FilterData(filterMap))
|
||||
}
|
||||
|
||||
result := rowBuilder.WithContext(ctx).Limit(1).Find(&resp)
|
||||
if result.Error != nil {
|
||||
return nil, result.Error
|
||||
} else {
|
||||
return &resp, nil
|
||||
}
|
||||
}
|
||||
|
||||
// 事务
|
||||
func (m *FsOrderModel) Trans(ctx context.Context, fn func(ctx context.Context, connGorm *gorm.DB) error) error {
|
||||
tx := m.db.Table(m.name).WithContext(ctx).Begin()
|
||||
defer func() {
|
||||
if r := recover(); r != nil {
|
||||
tx.Rollback()
|
||||
}
|
||||
}()
|
||||
|
||||
if err := tx.Error; err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
if err := fn(ctx, tx); err != nil {
|
||||
tx.Rollback()
|
||||
return err
|
||||
}
|
||||
|
||||
return tx.Commit().Error
|
||||
}
|
||||
|
||||
func (m *FsOrderModel) TableName() string {
|
||||
return m.name
|
||||
}
|
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的属性做你想做的
|
35
model/gmodel/fs_orders_trade_gen.go
Normal file
35
model/gmodel/fs_orders_trade_gen.go
Normal file
|
@ -0,0 +1,35 @@
|
|||
package gmodel
|
||||
|
||||
import (
|
||||
"gorm.io/gorm"
|
||||
"time"
|
||||
)
|
||||
|
||||
// fs_orders_trade 订单交易记录表
|
||||
type FsOrdersTrade 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"` //
|
||||
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"` //
|
||||
Country *string `gorm:"default:'';" json:"country"` //
|
||||
Currency *string `gorm:"default:'';" json:"currency"` //
|
||||
Metadata *[]byte `gorm:"default:'';" json:"metadata"` //
|
||||
}
|
||||
type FsOrdersTradeModel struct {
|
||||
db *gorm.DB
|
||||
name string
|
||||
}
|
||||
|
||||
func NewFsOrdersTradeModel(db *gorm.DB) *FsOrdersTradeModel {
|
||||
return &FsOrdersTradeModel{db: db, name: "fs_orders_trade"}
|
||||
}
|
2
model/gmodel/fs_orders_trade_logic.go
Normal file
2
model/gmodel/fs_orders_trade_logic.go
Normal file
|
@ -0,0 +1,2 @@
|
|||
package gmodel
|
||||
// TODO: 使用model的属性做你想做的
|
|
@ -2,6 +2,15 @@ package gmodel
|
|||
|
||||
import "context"
|
||||
|
||||
type RelaFsProduct struct {
|
||||
FsProduct
|
||||
CoverResource *FsResource `json:"cover_resource" gorm:"foreignkey:cover;references:resource_id"`
|
||||
}
|
||||
|
||||
func (m *FsProductModel) TableName() string {
|
||||
return m.name
|
||||
}
|
||||
|
||||
func (p *FsProductModel) FindOne(ctx context.Context, id int64, fields ...string) (resp *FsProduct, err error) {
|
||||
db := p.db.WithContext(ctx).Model(&FsProduct{}).Where("`id` = ? ", id)
|
||||
if len(fields) != 0 {
|
||||
|
@ -18,12 +27,15 @@ func (p *FsProductModel) FindOneBySn(ctx context.Context, sn string, fields ...s
|
|||
err = db.Take(&resp).Error
|
||||
return resp, err
|
||||
}
|
||||
func (p *FsProductModel) GetProductListByIds(ctx context.Context, productIds []int64, sort string) (resp []FsProduct, err error) {
|
||||
func (p *FsProductModel) GetProductListByIds(ctx context.Context, productIds []int64, sort string, fields ...string) (resp []FsProduct, err error) {
|
||||
if len(productIds) == 0 {
|
||||
return
|
||||
}
|
||||
db := p.db.Model(&FsProduct{}).WithContext(ctx).
|
||||
Where("`id` in (?) and `is_del` =? and `is_shelf` = ? and `status` =?", productIds, 0, 1, 1)
|
||||
if len(fields) > 0 {
|
||||
db = db.Select(fields[0])
|
||||
}
|
||||
switch sort {
|
||||
case "sort-asc":
|
||||
db = db.Order("`sort` ASC")
|
||||
|
|
|
@ -37,11 +37,15 @@ func (d *FsProductModel3dModel) GetAllByIdsWithoutStatus(ctx context.Context, id
|
|||
err = db.Find(&resp).Error
|
||||
return resp, err
|
||||
}
|
||||
func (d *FsProductModel3dModel) GetAllByIdsTag(ctx context.Context, ids []int64, tag int64) (resp []FsProductModel3d, err error) {
|
||||
func (d *FsProductModel3dModel) GetAllByIdsTag(ctx context.Context, ids []int64, tag int64, fields ...string) (resp []FsProductModel3d, err error) {
|
||||
if len(ids) == 0 {
|
||||
return
|
||||
}
|
||||
err = d.db.WithContext(ctx).Model(&FsProductModel3d{}).Where("`id` in (?) and `status` = ? and `tag` = ?", ids, 1, tag).Find(&resp).Error
|
||||
db := d.db.WithContext(ctx).Model(&FsProductModel3d{}).Where("`id` in (?) and `status` = ? and `tag` = ?", ids, 1, tag)
|
||||
if len(fields) > 0 {
|
||||
db = db.Select(fields[0])
|
||||
}
|
||||
err = db.Find(&resp).Error
|
||||
return resp, err
|
||||
}
|
||||
|
||||
|
|
|
@ -23,11 +23,11 @@ func (p *FsProductPriceModel) GetSimplePriceListByProductIds(ctx context.Context
|
|||
}
|
||||
return
|
||||
}
|
||||
func (p *FsProductPriceModel) GetPriceListBySizeIds(ctx context.Context, sizeIds []int64) (resp []FsProductPrice, err error) {
|
||||
if len(sizeIds) == 0 {
|
||||
func (p *FsProductPriceModel) GetPriceListByProductIdsSizeIds(ctx context.Context, productIds, sizeIds []int64) (resp []FsProductPrice, err error) {
|
||||
if len(sizeIds) == 0 || len(productIds) == 0 {
|
||||
return
|
||||
}
|
||||
err = p.db.WithContext(ctx).Model(&FsProductPrice{}).Where("`size_id` in (?) and `status` = ? ", sizeIds, 1).Find(&resp).Error
|
||||
err = p.db.WithContext(ctx).Model(&FsProductPrice{}).Where("`size_id` in (?) and `product_id` in (?) and `status` = ? ", sizeIds, productIds, 1).Find(&resp).Error
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
@ -71,6 +71,11 @@ func (p *FsProductPriceModel) GetPriceListByProductIds(ctx context.Context, prod
|
|||
}
|
||||
return
|
||||
}
|
||||
func (p *FsProductPriceModel) FindOneBySizeId(ctx context.Context, sizeId int64) (resp *FsProductPrice, err error) {
|
||||
err = p.db.WithContext(ctx).Model(&FsProductPrice{}).
|
||||
Where("`size_id` = ? and `status` = ?", sizeId, 1).Take(&resp).Error
|
||||
return resp, err
|
||||
}
|
||||
|
||||
// 产品价格
|
||||
type ProductPrice struct {
|
||||
|
|
|
@ -17,8 +17,6 @@ type FsShoppingCart struct {
|
|||
PurchaseQuantity *int64 `gorm:"default:0;" json:"purchase_quantity"` // 购买数量
|
||||
Snapshot *string `gorm:"default:'';" json:"snapshot"` //
|
||||
IsHighlyCustomized *int64 `gorm:"default:0;" json:"is_highly_customized"` // 是否高度定制 0非 1是(针对客人高度定制只能后台增加如购物车)
|
||||
Status *int64 `gorm:"default:0;" json:"status"` // 0未下单 1已下单
|
||||
IsEffective *int64 `gorm:"default:1;" json:"is_effective"` // 是否有效 0非 1是(针对对购物车下单,此前数据表更失效)
|
||||
Ctime *time.Time `gorm:"default:'0000-00-00 00:00:00';" json:"ctime"` //
|
||||
Utime *time.Time `gorm:"default:'0000-00-00 00:00:00';" json:"utime"` //
|
||||
}
|
||||
|
|
|
@ -1,2 +1,102 @@
|
|||
package gmodel
|
||||
// TODO: 使用model的属性做你想做的
|
||||
|
||||
import (
|
||||
"context"
|
||||
)
|
||||
|
||||
type RelaFsShoppingCart struct {
|
||||
FsShoppingCart
|
||||
ShoppingCartProduct *RelaFsProduct `json:"shopping_cart_product" gorm:"foreignkey:product_id;references:id"`
|
||||
ShoppingCartProductPriceList []*FsProductPrice `json:"shopping_cart_product_price_list" gorm:"foreignkey:product_id;references:product_id"`
|
||||
ShoppingCartProductModel3dList []*FsProductModel3d `json:"shopping_cart_product_model3d_list" gorm:"foreignkey:product_id;references:product_id"`
|
||||
}
|
||||
|
||||
// 获取单个
|
||||
func (s *FsShoppingCartModel) FindOne(ctx context.Context, id int64, fields ...string) (resp *FsShoppingCart, err error) {
|
||||
db := s.db.WithContext(ctx).Where("id = ?", id)
|
||||
if len(fields) > 0 {
|
||||
db = db.Select(fields[0])
|
||||
}
|
||||
err = db.Take(&resp).Error
|
||||
return resp, err
|
||||
}
|
||||
|
||||
// 获取用户购物车指定item
|
||||
func (s *FsShoppingCartModel) FineOneUserCart(ctx context.Context, id, userId int64, fields ...string) (resp *FsShoppingCart, err error) {
|
||||
db := s.db.WithContext(ctx).Where("user_id = ? and id = ?", userId, id)
|
||||
if len(fields) > 0 {
|
||||
db = db.Select(fields[0])
|
||||
}
|
||||
err = db.Take(&resp).Error
|
||||
return resp, err
|
||||
}
|
||||
|
||||
// 创建
|
||||
func (s *FsShoppingCartModel) Create(ctx context.Context, data *FsShoppingCart) error {
|
||||
return s.db.WithContext(ctx).Model(&FsShoppingCart{}).Create(&data).Error
|
||||
}
|
||||
|
||||
// 删除
|
||||
func (s *FsShoppingCartModel) Delete(ctx context.Context, id, userId int64) error {
|
||||
return s.db.WithContext(ctx).Model(&FsShoppingCart{}).Where("user_id = ? and id = ?", userId, id).Delete(&FsShoppingCart{}).Error
|
||||
}
|
||||
|
||||
// 更新
|
||||
func (s *FsShoppingCartModel) Update(ctx context.Context, id, userId int64, data *FsShoppingCart) error {
|
||||
return s.db.WithContext(ctx).Model(&FsShoppingCart{}).Where("user_id = ? and id = ?", userId, id).Updates(&data).Error
|
||||
}
|
||||
|
||||
// 获取用户购物车数量
|
||||
func (s *FsShoppingCartModel) CountUserCart(ctx context.Context, userId int64) (total int64, err error) {
|
||||
err = s.db.WithContext(ctx).Model(&FsShoppingCart{}).Where("user_id = ?", userId).Limit(1).Count(&total).Error
|
||||
return total, err
|
||||
}
|
||||
|
||||
// 获取多个
|
||||
func (s *FsShoppingCartModel) GetAllByIds(ctx context.Context, ids []int64, sort string, fields ...string) (resp []FsShoppingCart, err error) {
|
||||
if len(ids) == 0 {
|
||||
return
|
||||
}
|
||||
db := s.db.WithContext(ctx).Model(&FsShoppingCart{}).Where("id in (?)", ids)
|
||||
if len(fields) > 0 {
|
||||
db = db.Select(fields[0])
|
||||
}
|
||||
if sort != "" {
|
||||
db = db.Order(sort)
|
||||
}
|
||||
err = db.Find(&resp).Error
|
||||
return resp, err
|
||||
}
|
||||
|
||||
// 获取用户所有的购物车
|
||||
type GetAllCartsByParamReq struct {
|
||||
Ids []int64 //id集合
|
||||
UserId int64 //用户id
|
||||
Fields string //筛选的字段
|
||||
Sort string //排序
|
||||
Page int //当前页
|
||||
Limit int //每页数量
|
||||
}
|
||||
|
||||
func (s *FsShoppingCartModel) GetAllCartsByParam(ctx context.Context, req GetAllCartsByParamReq) (resp []FsShoppingCart, total int64, err error) {
|
||||
db := s.db.WithContext(ctx).Model(&FsShoppingCart{})
|
||||
if req.UserId > 0 {
|
||||
db = db.Where("user_id = ?", req.UserId)
|
||||
}
|
||||
if len(req.Ids) > 0 {
|
||||
db = db.Where("id in (?)", req.Ids)
|
||||
}
|
||||
if req.Fields != "" {
|
||||
db = db.Select(req.Fields)
|
||||
}
|
||||
if req.Sort != "" {
|
||||
db = db.Order(req.Sort)
|
||||
}
|
||||
//查询数量
|
||||
if err = db.Limit(1).Count(&total).Error; err != nil {
|
||||
return nil, 0, err
|
||||
}
|
||||
offset := (req.Page - 1) * req.Limit
|
||||
err = db.Offset(offset).Limit(req.Limit).Find(&resp).Error
|
||||
return resp, total, err
|
||||
}
|
||||
|
|
|
@ -7,7 +7,6 @@ type AllModelsGen struct {
|
|||
CasbinRule *CasbinRuleModel // casbin_rule
|
||||
FsAddress *FsAddressModel // fs_address 用户地址表
|
||||
FsAdminApi *FsAdminApiModel // fs_admin_api 后台--接口表
|
||||
FsAdminAuthRole *FsAdminAuthRoleModel // fs_admin_auth_role 后台--角色表
|
||||
FsAdminDepartment *FsAdminDepartmentModel // fs_admin_department 后台--部门表
|
||||
FsAdminMenu *FsAdminMenuModel // fs_admin_menu 后台--菜单表
|
||||
FsAdminRole *FsAdminRoleModel // fs_admin_role 后台--角色表
|
||||
|
@ -23,15 +22,16 @@ type AllModelsGen struct {
|
|||
FsCardGroup *FsCardGroupModel // fs_card_group 卡号分组表
|
||||
FsCart *FsCartModel // fs_cart 购物车
|
||||
FsChangeCode *FsChangeCodeModel // fs_change_code 忘记密码code表
|
||||
FsCloud *FsCloudModel // fs_cloud 云仓表
|
||||
FsCloudDeliverEveryTmp *FsCloudDeliverEveryTmpModel // fs_cloud_deliver_every_tmp
|
||||
FsCloudDeliverTmp *FsCloudDeliverTmpModel // fs_cloud_deliver_tmp
|
||||
FsCloudPickUp *FsCloudPickUpModel // fs_cloud_pick_up 云仓提货单
|
||||
FsCloudPickUpDetail *FsCloudPickUpDetailModel // fs_cloud_pick_up_detail 云仓提货单-详情
|
||||
FsCloudReceive *FsCloudReceiveModel // fs_cloud_receive 云仓接收工厂总单
|
||||
FsCloudReceiveEvery *FsCloudReceiveEveryModel // fs_cloud_receive_every
|
||||
FsCloudRenderLog *FsCloudRenderLogModel // fs_cloud_render_log 云渲染日志表
|
||||
FsCloudUserApplyBack *FsCloudUserApplyBackModel // fs_cloud_user_apply_back 该表废弃
|
||||
FsCloudDeliverEveryTmpOld *FsCloudDeliverEveryTmpOldModel // fs_cloud_deliver_every_tmp_old
|
||||
FsCloudDeliverTmpOld *FsCloudDeliverTmpOldModel // fs_cloud_deliver_tmp_old
|
||||
FsCloudOld *FsCloudOldModel // fs_cloud_old 云仓表
|
||||
FsCloudPickUpDetailOld *FsCloudPickUpDetailOldModel // fs_cloud_pick_up_detail_old 云仓提货单-详情
|
||||
FsCloudPickUpOld *FsCloudPickUpOldModel // fs_cloud_pick_up_old 云仓提货单
|
||||
FsCloudReceiveEveryOld *FsCloudReceiveEveryOldModel // fs_cloud_receive_every_old
|
||||
FsCloudReceiveOld *FsCloudReceiveOldModel // fs_cloud_receive_old 云仓接收工厂总单
|
||||
FsCloudRenderLogOld *FsCloudRenderLogOldModel // fs_cloud_render_log_old 云渲染日志表
|
||||
FsCloudStorage *FsCloudStorageModel // fs_cloud_storage 仓库的基本信息, 只做映射
|
||||
FsCloudUserApplyBackOld *FsCloudUserApplyBackOldModel // fs_cloud_user_apply_back_old 该表废弃
|
||||
FsContact *FsContactModel // fs_contact 该表暂未使用
|
||||
FsContactService *FsContactServiceModel // fs_contact_service
|
||||
FsCoupon *FsCouponModel // fs_coupon 代金券(暂未使用)
|
||||
|
@ -55,11 +55,14 @@ type AllModelsGen struct {
|
|||
FsMenu *FsMenuModel // fs_menu 后台菜单
|
||||
FsMerchantCategory *FsMerchantCategoryModel // fs_merchant_category 商户类型表
|
||||
FsMigration *FsMigrationModel // fs_migration 版本库
|
||||
FsOrder *FsOrderModel // fs_order
|
||||
FsOrderAffiliate *FsOrderAffiliateModel // fs_order_affiliate 订单附属表-流程控制时间等
|
||||
FsOrderDetail *FsOrderDetailModel // fs_order_detail 订单详细表
|
||||
FsOrderDetailTemplate *FsOrderDetailTemplateModel // fs_order_detail_template 订单模板详细表
|
||||
FsOrderRemark *FsOrderRemarkModel // fs_order_remark 订单备注表
|
||||
FsOrder *FsOrderModel // fs_order 订单表
|
||||
FsOrderAffiliateOld *FsOrderAffiliateOldModel // fs_order_affiliate_old 订单附属表-流程控制时间等
|
||||
FsOrderDetailOld *FsOrderDetailOldModel // fs_order_detail_old 订单详细表
|
||||
FsOrderDetailTemplateOld *FsOrderDetailTemplateOldModel // fs_order_detail_template_old 订单模板详细表
|
||||
FsOrderOld *FsOrderOldModel // fs_order_old
|
||||
FsOrderRemarkOld *FsOrderRemarkOldModel // fs_order_remark_old 订单备注表
|
||||
FsOrderTrade *FsOrderTradeModel // fs_order_trade 订单交易表
|
||||
FsOrderTradeEvent *FsOrderTradeEventModel // fs_order_trade_event 订单交易事件表
|
||||
FsPay *FsPayModel // fs_pay 支付记录
|
||||
FsPayEvent *FsPayEventModel // fs_pay_event 支付回调事件日志
|
||||
FsProduct *FsProductModel // fs_product 产品表
|
||||
|
@ -114,7 +117,6 @@ func NewAllModels(gdb *gorm.DB) *AllModelsGen {
|
|||
CasbinRule: NewCasbinRuleModel(gdb),
|
||||
FsAddress: NewFsAddressModel(gdb),
|
||||
FsAdminApi: NewFsAdminApiModel(gdb),
|
||||
FsAdminAuthRole: NewFsAdminAuthRoleModel(gdb),
|
||||
FsAdminDepartment: NewFsAdminDepartmentModel(gdb),
|
||||
FsAdminMenu: NewFsAdminMenuModel(gdb),
|
||||
FsAdminRole: NewFsAdminRoleModel(gdb),
|
||||
|
@ -130,15 +132,16 @@ func NewAllModels(gdb *gorm.DB) *AllModelsGen {
|
|||
FsCardGroup: NewFsCardGroupModel(gdb),
|
||||
FsCart: NewFsCartModel(gdb),
|
||||
FsChangeCode: NewFsChangeCodeModel(gdb),
|
||||
FsCloud: NewFsCloudModel(gdb),
|
||||
FsCloudDeliverEveryTmp: NewFsCloudDeliverEveryTmpModel(gdb),
|
||||
FsCloudDeliverTmp: NewFsCloudDeliverTmpModel(gdb),
|
||||
FsCloudPickUp: NewFsCloudPickUpModel(gdb),
|
||||
FsCloudPickUpDetail: NewFsCloudPickUpDetailModel(gdb),
|
||||
FsCloudReceive: NewFsCloudReceiveModel(gdb),
|
||||
FsCloudReceiveEvery: NewFsCloudReceiveEveryModel(gdb),
|
||||
FsCloudRenderLog: NewFsCloudRenderLogModel(gdb),
|
||||
FsCloudUserApplyBack: NewFsCloudUserApplyBackModel(gdb),
|
||||
FsCloudDeliverEveryTmpOld: NewFsCloudDeliverEveryTmpOldModel(gdb),
|
||||
FsCloudDeliverTmpOld: NewFsCloudDeliverTmpOldModel(gdb),
|
||||
FsCloudOld: NewFsCloudOldModel(gdb),
|
||||
FsCloudPickUpDetailOld: NewFsCloudPickUpDetailOldModel(gdb),
|
||||
FsCloudPickUpOld: NewFsCloudPickUpOldModel(gdb),
|
||||
FsCloudReceiveEveryOld: NewFsCloudReceiveEveryOldModel(gdb),
|
||||
FsCloudReceiveOld: NewFsCloudReceiveOldModel(gdb),
|
||||
FsCloudRenderLogOld: NewFsCloudRenderLogOldModel(gdb),
|
||||
FsCloudStorage: NewFsCloudStorageModel(gdb),
|
||||
FsCloudUserApplyBackOld: NewFsCloudUserApplyBackOldModel(gdb),
|
||||
FsContact: NewFsContactModel(gdb),
|
||||
FsContactService: NewFsContactServiceModel(gdb),
|
||||
FsCoupon: NewFsCouponModel(gdb),
|
||||
|
@ -163,10 +166,13 @@ func NewAllModels(gdb *gorm.DB) *AllModelsGen {
|
|||
FsMerchantCategory: NewFsMerchantCategoryModel(gdb),
|
||||
FsMigration: NewFsMigrationModel(gdb),
|
||||
FsOrder: NewFsOrderModel(gdb),
|
||||
FsOrderAffiliate: NewFsOrderAffiliateModel(gdb),
|
||||
FsOrderDetail: NewFsOrderDetailModel(gdb),
|
||||
FsOrderDetailTemplate: NewFsOrderDetailTemplateModel(gdb),
|
||||
FsOrderRemark: NewFsOrderRemarkModel(gdb),
|
||||
FsOrderAffiliateOld: NewFsOrderAffiliateOldModel(gdb),
|
||||
FsOrderDetailOld: NewFsOrderDetailOldModel(gdb),
|
||||
FsOrderDetailTemplateOld: NewFsOrderDetailTemplateOldModel(gdb),
|
||||
FsOrderOld: NewFsOrderOldModel(gdb),
|
||||
FsOrderRemarkOld: NewFsOrderRemarkOldModel(gdb),
|
||||
FsOrderTrade: NewFsOrderTradeModel(gdb),
|
||||
FsOrderTradeEvent: NewFsOrderTradeEventModel(gdb),
|
||||
FsPay: NewFsPayModel(gdb),
|
||||
FsPayEvent: NewFsPayEventModel(gdb),
|
||||
FsProduct: NewFsProductModel(gdb),
|
||||
|
|
|
@ -15,8 +15,10 @@ run_server() {
|
|||
# 导航到相应的目录
|
||||
cd server/$server_name
|
||||
|
||||
go build
|
||||
echo $server_name > .gitignore
|
||||
# 使用 screen 运行 go run <server_name>.go
|
||||
screen -dmS $server_name -L go run $server_name.go
|
||||
screen -dmS $server_name -L ./$server_name
|
||||
|
||||
# 返回到上一级目录
|
||||
cd - > /dev/null
|
||||
|
@ -38,7 +40,6 @@ for server_dir in "${server_dirs[@]}"; do
|
|||
run_server $server_dir
|
||||
done
|
||||
|
||||
|
||||
# 定义目录和screen名称
|
||||
dir_path="./proxyserver"
|
||||
screen_name="proxyserver"
|
||||
|
|
1
server/auth/.gitignore
vendored
Normal file
1
server/auth/.gitignore
vendored
Normal file
|
@ -0,0 +1 @@
|
|||
auth
|
|
@ -6,6 +6,7 @@ import (
|
|||
"net/http"
|
||||
|
||||
"fusenapi/utils/auth"
|
||||
"fusenapi/utils/fsconfig"
|
||||
|
||||
"fusenapi/server/auth/internal/config"
|
||||
"fusenapi/server/auth/internal/handler"
|
||||
|
@ -20,8 +21,10 @@ var configFile = flag.String("f", "etc/auth.yaml", "the config file")
|
|||
func main() {
|
||||
flag.Parse()
|
||||
|
||||
cfgContent := fsconfig.StartNacosConfig(*configFile, nil)
|
||||
var c config.Config
|
||||
conf.MustLoad(*configFile, &c)
|
||||
conf.LoadConfigFromYamlBytes([]byte(cfgContent), &c)
|
||||
|
||||
server := rest.MustNewServer(c.RestConf, rest.WithCustomCors(auth.FsCors, func(w http.ResponseWriter) {
|
||||
}))
|
||||
defer server.Stop()
|
||||
|
|
|
@ -143,7 +143,7 @@ func TestSql(t *testing.T) {
|
|||
}
|
||||
|
||||
conn := initalize.InitMysql("fsreaderwriter:XErSYmLELKMnf3Dh@tcp(fusen.cdmigcvz3rle.us-east-2.rds.amazonaws.com:3306)/fusen")
|
||||
log.Println(conn.Model(&gmodel.FsUser{}))
|
||||
log.Println()
|
||||
|
||||
log.Println(conn.NamingStrategy.TableName(reflect.TypeOf(gmodel.FsUser{}).Name()))
|
||||
updatesql := `UPDATE %s
|
||||
|
|
1
server/base/.gitignore
vendored
Normal file
1
server/base/.gitignore
vendored
Normal file
|
@ -0,0 +1 @@
|
|||
base
|
|
@ -6,6 +6,7 @@ import (
|
|||
"net/http"
|
||||
|
||||
"fusenapi/utils/auth"
|
||||
"fusenapi/utils/fsconfig"
|
||||
|
||||
"fusenapi/server/base/internal/config"
|
||||
"fusenapi/server/base/internal/handler"
|
||||
|
@ -20,8 +21,9 @@ var configFile = flag.String("f", "etc/base.yaml", "the config file")
|
|||
func main() {
|
||||
flag.Parse()
|
||||
|
||||
cfgContent := fsconfig.StartNacosConfig(*configFile, nil)
|
||||
var c config.Config
|
||||
conf.MustLoad(*configFile, &c)
|
||||
conf.LoadConfigFromYamlBytes([]byte(cfgContent), &c)
|
||||
|
||||
server := rest.MustNewServer(c.RestConf, rest.WithCustomCors(auth.FsCors, func(w http.ResponseWriter) {
|
||||
}))
|
||||
|
|
|
@ -10,4 +10,4 @@ Auth:
|
|||
AccessSecret: fusen2023
|
||||
AccessExpire: 2592000
|
||||
RefreshAfter: 1592000
|
||||
SourceRabbitMq: "amqp://rabbit001:rabbit001129@110.41.19.98:5672"
|
||||
SourceRabbitMq: ""
|
1
server/canteen/.gitignore
vendored
Normal file
1
server/canteen/.gitignore
vendored
Normal file
|
@ -0,0 +1 @@
|
|||
canteen
|
|
@ -9,6 +9,7 @@ import (
|
|||
"fusenapi/server/canteen/internal/handler"
|
||||
"fusenapi/server/canteen/internal/svc"
|
||||
"fusenapi/utils/auth"
|
||||
"fusenapi/utils/fsconfig"
|
||||
|
||||
"github.com/zeromicro/go-zero/core/conf"
|
||||
"github.com/zeromicro/go-zero/rest"
|
||||
|
@ -19,9 +20,9 @@ var configFile = flag.String("f", "etc/canteen.yaml", "the config file")
|
|||
func main() {
|
||||
flag.Parse()
|
||||
|
||||
cfgContent := fsconfig.StartNacosConfig(*configFile, nil)
|
||||
var c config.Config
|
||||
|
||||
conf.MustLoad(*configFile, &c)
|
||||
conf.LoadConfigFromYamlBytes([]byte(cfgContent), &c)
|
||||
|
||||
server := rest.MustNewServer(c.RestConf, rest.WithCustomCors(auth.FsCors, func(w http.ResponseWriter) {
|
||||
|
||||
|
|
|
@ -31,7 +31,7 @@ func NewGetCanteenDetailLogic(ctx context.Context, svcCtx *svc.ServiceContext) *
|
|||
// 获取餐厅详情
|
||||
func (l *GetCanteenDetailLogic) GetCanteenDetail(req *types.GetCanteenDetailReq, userinfo *auth.UserInfo) (resp *basic.Response) {
|
||||
if userinfo.GetIdType() != auth.IDTYPE_User {
|
||||
return resp.SetStatusWithMessage(basic.CodeServiceErr, "please login first")
|
||||
return resp.SetStatusWithMessage(basic.CodeServiceErr, "please sign in first")
|
||||
}
|
||||
//获取餐厅类型数据
|
||||
canteenTypeModel := gmodel.NewFsCanteenTypeModel(l.svcCtx.MysqlConn)
|
||||
|
|
|
@ -32,7 +32,7 @@ func NewSaveCanteenTypeProductLogic(ctx context.Context, svcCtx *svc.ServiceCont
|
|||
// 保存餐厅类型的关联产品
|
||||
func (l *SaveCanteenTypeProductLogic) SaveCanteenTypeProduct(req *types.SaveCanteenTypeProductReq, userinfo *auth.UserInfo) (resp *basic.Response) {
|
||||
if userinfo.GetIdType() != auth.IDTYPE_User {
|
||||
return resp.SetStatusWithMessage(basic.CodeServiceErr, "please login first")
|
||||
return resp.SetStatusWithMessage(basic.CodeServiceErr, "please sign in first")
|
||||
}
|
||||
if len(req.ProductList) == 0 {
|
||||
return resp.SetStatusWithMessage(basic.CodeRequestParamsErr, "product list can`t be empty")
|
||||
|
|
1
server/data-transfer/.gitignore
vendored
Normal file
1
server/data-transfer/.gitignore
vendored
Normal file
|
@ -0,0 +1 @@
|
|||
data-transfer
|
|
@ -9,7 +9,6 @@ import (
|
|||
"fusenapi/utils/auth"
|
||||
"net/http"
|
||||
|
||||
"github.com/zeromicro/go-zero/core/conf"
|
||||
"github.com/zeromicro/go-zero/rest"
|
||||
)
|
||||
|
||||
|
@ -19,7 +18,6 @@ func main() {
|
|||
flag.Parse()
|
||||
|
||||
var c config2.Config
|
||||
conf.MustLoad(*configFile, &c)
|
||||
|
||||
server := rest.MustNewServer(c.RestConf, rest.WithCustomCors(auth.FsCors, func(w http.ResponseWriter) {
|
||||
|
||||
|
|
|
@ -29,7 +29,7 @@ func NewGetQrCodeSetListLogic(ctx context.Context, svcCtx *svc.ServiceContext) *
|
|||
// 获取二维码配置列表
|
||||
func (l *GetQrCodeSetListLogic) GetQrCodeSetList(req *types.Request, userinfo *auth.UserInfo) (resp *basic.Response) {
|
||||
if userinfo.GetIdType() != auth.IDTYPE_User {
|
||||
return resp.SetStatusWithMessage(basic.CodeServiceErr, "please login first")
|
||||
return resp.SetStatusWithMessage(basic.CodeServiceErr, "please sign in first")
|
||||
}
|
||||
qrCodeModel := gmodel.NewFsQrcodeSetModel(l.svcCtx.MysqlConn)
|
||||
qrCodeList, err := qrCodeModel.GetAll(l.ctx)
|
||||
|
|
|
@ -29,7 +29,7 @@ func NewGetStandardLogoListLogic(ctx context.Context, svcCtx *svc2.ServiceContex
|
|||
// 获取标准logo列表
|
||||
func (l *GetStandardLogoListLogic) GetStandardLogoList(req *types.Request, userinfo *auth.UserInfo) (resp *basic.Response) {
|
||||
if userinfo.GetIdType() != auth.IDTYPE_User {
|
||||
return resp.SetStatusWithMessage(basic.CodeServiceErr, "please login first")
|
||||
return resp.SetStatusWithMessage(basic.CodeServiceErr, "please sign in first")
|
||||
}
|
||||
standardLogoModel := gmodel.NewFsStandardLogoModel(l.svcCtx.MysqlConn)
|
||||
logoList, err := standardLogoModel.GetAll(l.ctx)
|
||||
|
|
1
server/home-user-auth/.gitignore
vendored
Normal file
1
server/home-user-auth/.gitignore
vendored
Normal file
|
@ -0,0 +1 @@
|
|||
home-user-auth
|
|
@ -9,6 +9,7 @@ import (
|
|||
"fusenapi/server/home-user-auth/internal/handler"
|
||||
"fusenapi/server/home-user-auth/internal/svc"
|
||||
"fusenapi/utils/auth"
|
||||
"fusenapi/utils/fsconfig"
|
||||
|
||||
"github.com/zeromicro/go-zero/core/conf"
|
||||
"github.com/zeromicro/go-zero/rest"
|
||||
|
@ -19,9 +20,9 @@ var configFile = flag.String("f", "etc/home-user-auth.yaml", "the config file")
|
|||
func main() {
|
||||
flag.Parse()
|
||||
|
||||
cfgContent := fsconfig.StartNacosConfig(*configFile, nil)
|
||||
var c config.Config
|
||||
|
||||
conf.MustLoad(*configFile, &c)
|
||||
conf.LoadConfigFromYamlBytes([]byte(cfgContent), &c)
|
||||
|
||||
server := rest.MustNewServer(c.RestConf, rest.WithCustomCors(auth.FsCors, func(w http.ResponseWriter) {
|
||||
|
||||
|
|
|
@ -1,10 +1,8 @@
|
|||
package logic
|
||||
|
||||
import (
|
||||
"fusenapi/model/gmodel"
|
||||
"fusenapi/utils/auth"
|
||||
"fusenapi/utils/basic"
|
||||
"fusenapi/utils/collect"
|
||||
|
||||
"context"
|
||||
|
||||
|
@ -12,7 +10,6 @@ import (
|
|||
"fusenapi/server/home-user-auth/internal/types"
|
||||
|
||||
"github.com/zeromicro/go-zero/core/logx"
|
||||
"gorm.io/gorm"
|
||||
)
|
||||
|
||||
type UserContactServiceLogic struct {
|
||||
|
@ -33,36 +30,36 @@ func (l *UserContactServiceLogic) UserContactService(req *types.RequestContactSe
|
|||
// 返回值必须调用Set重新返回, resp可以空指针调用 resp.SetStatus(basic.CodeOK, data)
|
||||
// userinfo 传入值时, 一定不为null
|
||||
|
||||
if !userinfo.IsUser() {
|
||||
return resp.SetStatus(basic.CodeUnAuth)
|
||||
}
|
||||
// if !userinfo.IsUser() {
|
||||
// return resp.SetStatus(basic.CodeUnAuth)
|
||||
// }
|
||||
|
||||
cs := gmodel.FsContactService{
|
||||
UserId: &userinfo.UserId,
|
||||
}
|
||||
collect.LoadJsonTag(&cs, &req)
|
||||
// cs := gmodel.FsContactService{
|
||||
// UserId: &userinfo.UserId,
|
||||
// }
|
||||
// collect.LoadJsonTag(&cs, &req)
|
||||
|
||||
switch req.Type {
|
||||
case "order":
|
||||
_, err := l.svcCtx.AllModels.FsOrder.FindOneAndCreateServiceContact(l.ctx, userinfo.UserId, req.RelationID, &cs)
|
||||
if err != nil {
|
||||
if err == gorm.ErrRecordNotFound {
|
||||
return resp.SetStatus(basic.CodeOrderNotFoundErr)
|
||||
}
|
||||
return resp.SetStatus(basic.CodeDbSqlErr)
|
||||
}
|
||||
case "cloud":
|
||||
_, err := l.svcCtx.AllModels.FsCloudPickUp.GetCloudPickUpByIDAndUserID(l.ctx, userinfo.UserId, req.RelationID, &cs)
|
||||
if err != nil {
|
||||
if err == gorm.ErrRecordNotFound {
|
||||
return resp.SetStatus(basic.CodeCloudOrderNotFoundErr)
|
||||
}
|
||||
return resp.SetStatus(basic.CodeDbSqlErr)
|
||||
}
|
||||
return
|
||||
default:
|
||||
return resp.SetStatusWithMessage(basic.CodeRequestParamsErr, "type is unknown")
|
||||
}
|
||||
// switch req.Type {
|
||||
// case "order":
|
||||
// _, err := l.svcCtx.AllModels.FsOrder.FindOneAndCreateServiceContact(l.ctx, userinfo.UserId, req.RelationID, &cs)
|
||||
// if err != nil {
|
||||
// if err == gorm.ErrRecordNotFound {
|
||||
// return resp.SetStatus(basic.CodeOrderNotFoundErr)
|
||||
// }
|
||||
// return resp.SetStatus(basic.CodeDbSqlErr)
|
||||
// }
|
||||
// case "cloud":
|
||||
// _, err := l.svcCtx.AllModels.FsCloudPickUp.GetCloudPickUpByIDAndUserID(l.ctx, userinfo.UserId, req.RelationID, &cs)
|
||||
// if err != nil {
|
||||
// if err == gorm.ErrRecordNotFound {
|
||||
// return resp.SetStatus(basic.CodeCloudOrderNotFoundErr)
|
||||
// }
|
||||
// return resp.SetStatus(basic.CodeDbSqlErr)
|
||||
// }
|
||||
// return
|
||||
// default:
|
||||
// return resp.SetStatusWithMessage(basic.CodeRequestParamsErr, "type is unknown")
|
||||
// }
|
||||
|
||||
return resp.SetStatus(basic.CodeOK, cs)
|
||||
return resp.SetStatus(basic.CodeOK)
|
||||
}
|
||||
|
|
|
@ -1,23 +1,15 @@
|
|||
package logic
|
||||
|
||||
import (
|
||||
"errors"
|
||||
"fusenapi/constants"
|
||||
"fusenapi/model/gmodel"
|
||||
"fusenapi/utils/auth"
|
||||
"fusenapi/utils/basic"
|
||||
"time"
|
||||
|
||||
"context"
|
||||
|
||||
"fusenapi/server/home-user-auth/internal/svc"
|
||||
"fusenapi/server/home-user-auth/internal/types"
|
||||
|
||||
"github.com/stripe/stripe-go/v74"
|
||||
"github.com/stripe/stripe-go/v74/client"
|
||||
|
||||
"github.com/zeromicro/go-zero/core/logx"
|
||||
"gorm.io/gorm"
|
||||
)
|
||||
|
||||
type UserOderDeleteLogic struct {
|
||||
|
@ -38,109 +30,109 @@ func (l *UserOderDeleteLogic) UserOderDelete(req *types.RequestOrderId, userinfo
|
|||
// 返回值必须调用Set重新返回, resp可以空指针调用 resp.SetStatus(basic.CodeOK, data)
|
||||
// userinfo 传入值时, 一定不为null
|
||||
|
||||
if !userinfo.IsUser() {
|
||||
return resp.SetStatus(basic.CodeUnAuth) // 如果不是用户信息, 返回未授权错误
|
||||
}
|
||||
// if !userinfo.IsUser() {
|
||||
// return resp.SetStatus(basic.CodeUnAuth) // 如果不是用户信息, 返回未授权错误
|
||||
// }
|
||||
|
||||
//订单id
|
||||
orderId := req.OrderId
|
||||
if orderId < 1 {
|
||||
return resp.SetStatus(basic.CodeRequestParamsErr)
|
||||
}
|
||||
// //订单id
|
||||
// orderId := req.OrderId
|
||||
// if orderId < 1 {
|
||||
// return resp.SetStatus(basic.CodeRequestParamsErr)
|
||||
// }
|
||||
|
||||
m := l.svcCtx.AllModels.FsOrder
|
||||
order, err := m.FindOne(l.ctx, userinfo.UserId, orderId)
|
||||
if err != nil {
|
||||
if errors.Is(err, gorm.ErrRecordNotFound) {
|
||||
return resp.SetStatus(basic.CodeOrderNotFoundErr)
|
||||
}
|
||||
logx.Error(err)
|
||||
return resp.SetStatus(basic.CodeDbSqlErr)
|
||||
}
|
||||
// m := l.svcCtx.AllModels.FsOrder
|
||||
// order, err := m.FindOne(l.ctx, userinfo.UserId, orderId)
|
||||
// if err != nil {
|
||||
// if errors.Is(err, gorm.ErrRecordNotFound) {
|
||||
// return resp.SetStatus(basic.CodeOrderNotFoundErr)
|
||||
// }
|
||||
// logx.Error(err)
|
||||
// return resp.SetStatus(basic.CodeDbSqlErr)
|
||||
// }
|
||||
|
||||
if auth.CheckValueRange[constants.Order](
|
||||
constants.Order(*order.Status),
|
||||
constants.STATUS_NEW_NOT_PAY,
|
||||
constants.STATUS_NEW_PAY_COMPLETED,
|
||||
constants.STATUS_NEW_PART_PAY,
|
||||
) {
|
||||
return resp.SetStatus(basic.CodeOrderNotCancelledErr)
|
||||
}
|
||||
// if auth.CheckValueRange[constants.Order](
|
||||
// constants.Order(*order.Status),
|
||||
// constants.STATUS_NEW_NOT_PAY,
|
||||
// constants.STATUS_NEW_PAY_COMPLETED,
|
||||
// constants.STATUS_NEW_PART_PAY,
|
||||
// ) {
|
||||
// return resp.SetStatus(basic.CodeOrderNotCancelledErr)
|
||||
// }
|
||||
|
||||
if *order.IsPayCompleted == 1 &&
|
||||
time.Now().After(time.Unix(*order.Ctime, 0).Add(48*time.Hour)) {
|
||||
return resp.SetStatus(basic.CodeOrderNotCancelledErr)
|
||||
}
|
||||
// if *order.IsPayCompleted == 1 &&
|
||||
// time.Now().After(time.Unix(*order.Ctime, 0).Add(48*time.Hour)) {
|
||||
// return resp.SetStatus(basic.CodeOrderNotCancelledErr)
|
||||
// }
|
||||
|
||||
uOrder := &gmodel.FsOrder{
|
||||
Id: orderId,
|
||||
}
|
||||
// uOrder := &gmodel.FsOrder{
|
||||
// Id: orderId,
|
||||
// }
|
||||
|
||||
var (
|
||||
isCancel int64 = 1
|
||||
ustatus int64 = int64(constants.STATUS_NEW_CANCEL)
|
||||
)
|
||||
// 修改取消状态和取消原因
|
||||
uOrder.Status = &ustatus
|
||||
uOrder.IsCancel = &isCancel
|
||||
uOrder.RefundReasonId = &req.RefundReasonId
|
||||
uOrder.RefundReason = &req.RefundReason
|
||||
// var (
|
||||
// isCancel int64 = 1
|
||||
// ustatus int64 = int64(constants.STATUS_NEW_CANCEL)
|
||||
// )
|
||||
// // 修改取消状态和取消原因
|
||||
// uOrder.Status = &ustatus
|
||||
// uOrder.IsCancel = &isCancel
|
||||
// uOrder.RefundReasonId = &req.RefundReasonId
|
||||
// uOrder.RefundReason = &req.RefundReason
|
||||
|
||||
err = m.Update(l.ctx, uOrder)
|
||||
if err != nil {
|
||||
logx.Error(err)
|
||||
return resp.SetStatus(basic.CodeDbUpdateErr)
|
||||
}
|
||||
// err = m.Update(l.ctx, uOrder)
|
||||
// if err != nil {
|
||||
// logx.Error(err)
|
||||
// return resp.SetStatus(basic.CodeDbUpdateErr)
|
||||
// }
|
||||
|
||||
var (
|
||||
IsRefund int64 = 0
|
||||
CreatedAt = time.Now().UTC().Unix()
|
||||
)
|
||||
// var (
|
||||
// IsRefund int64 = 0
|
||||
// CreatedAt = time.Now().UTC().Unix()
|
||||
// )
|
||||
|
||||
refund := &gmodel.FsRefundReason{
|
||||
IsRefund: &IsRefund,
|
||||
RefundReasonId: &req.RefundReasonId,
|
||||
RefundReason: &req.RefundReason,
|
||||
OrderId: &order.Id,
|
||||
CreatedAt: &CreatedAt,
|
||||
}
|
||||
// refund := &gmodel.FsRefundReason{
|
||||
// IsRefund: &IsRefund,
|
||||
// RefundReasonId: &req.RefundReasonId,
|
||||
// RefundReason: &req.RefundReason,
|
||||
// OrderId: &order.Id,
|
||||
// CreatedAt: &CreatedAt,
|
||||
// }
|
||||
|
||||
mFsRefundReason := gmodel.NewFsRefundReasonModel(l.svcCtx.MysqlConn)
|
||||
err = mFsRefundReason.Create(l.ctx, refund)
|
||||
if err != nil {
|
||||
logx.Error(err)
|
||||
return resp.SetStatus(basic.CodeDbSqlErr)
|
||||
}
|
||||
// mFsRefundReason := gmodel.NewFsRefundReasonModel(l.svcCtx.MysqlConn)
|
||||
// err = mFsRefundReason.Create(l.ctx, refund)
|
||||
// if err != nil {
|
||||
// logx.Error(err)
|
||||
// return resp.SetStatus(basic.CodeDbSqlErr)
|
||||
// }
|
||||
|
||||
// 退款
|
||||
// 调用第三方接口发起退款
|
||||
// // 退款
|
||||
// // 调用第三方接口发起退款
|
||||
|
||||
config := &stripe.BackendConfig{
|
||||
MaxNetworkRetries: stripe.Int64(0), // Zero retries
|
||||
}
|
||||
// config := &stripe.BackendConfig{
|
||||
// MaxNetworkRetries: stripe.Int64(0), // Zero retries
|
||||
// }
|
||||
|
||||
sc := &client.API{}
|
||||
sc.Init(l.svcCtx.Config.Stripe.SK, &stripe.Backends{
|
||||
API: stripe.GetBackendWithConfig(stripe.APIBackend, config),
|
||||
Uploads: stripe.GetBackendWithConfig(stripe.UploadsBackend, config),
|
||||
})
|
||||
// ['order_number' => $order->sn, 'is_refund' => 0, 'pay_status' => 1]
|
||||
payM := l.svcCtx.AllModels.FsPay
|
||||
// sc := &client.API{}
|
||||
// sc.Init(l.svcCtx.Config.Stripe.SK, &stripe.Backends{
|
||||
// API: stripe.GetBackendWithConfig(stripe.APIBackend, config),
|
||||
// Uploads: stripe.GetBackendWithConfig(stripe.UploadsBackend, config),
|
||||
// })
|
||||
// // ['order_number' => $order->sn, 'is_refund' => 0, 'pay_status' => 1]
|
||||
// payM := l.svcCtx.AllModels.FsPay
|
||||
|
||||
// 查询支付信息
|
||||
pays, err := payM.GetOrderPayList(l.ctx, *order.Sn, 1, 0)
|
||||
for _, pay := range pays {
|
||||
sc.Refunds.New(&stripe.RefundParams{
|
||||
PaymentIntent: pay.TradeNo,
|
||||
})
|
||||
}
|
||||
if err != nil {
|
||||
if errors.Is(err, gorm.ErrRecordNotFound) {
|
||||
return resp.SetStatus(basic.CodeApiErr)
|
||||
}
|
||||
}
|
||||
// // 查询支付信息
|
||||
// pays, err := payM.GetOrderPayList(l.ctx, *order.Sn, 1, 0)
|
||||
// for _, pay := range pays {
|
||||
// sc.Refunds.New(&stripe.RefundParams{
|
||||
// PaymentIntent: pay.TradeNo,
|
||||
// })
|
||||
// }
|
||||
// if err != nil {
|
||||
// if errors.Is(err, gorm.ErrRecordNotFound) {
|
||||
// return resp.SetStatus(basic.CodeApiErr)
|
||||
// }
|
||||
// }
|
||||
|
||||
return resp.SetStatus(basic.CodePayCancelOk, uOrder)
|
||||
return resp.SetStatus(basic.CodePayCancelOk)
|
||||
|
||||
// return ResponseError(500, "Cancellation failure")
|
||||
|
||||
|
|
|
@ -1,13 +1,8 @@
|
|||
package logic
|
||||
|
||||
import (
|
||||
"errors"
|
||||
"fusenapi/constants"
|
||||
"fusenapi/model/gmodel"
|
||||
"fusenapi/utils/auth"
|
||||
"fusenapi/utils/basic"
|
||||
"fusenapi/utils/handlers"
|
||||
"time"
|
||||
|
||||
"context"
|
||||
|
||||
|
@ -15,7 +10,6 @@ import (
|
|||
"fusenapi/server/home-user-auth/internal/types"
|
||||
|
||||
"github.com/zeromicro/go-zero/core/logx"
|
||||
"gorm.io/gorm"
|
||||
)
|
||||
|
||||
type UserOrderCancelLogic struct {
|
||||
|
@ -36,93 +30,93 @@ func (l *UserOrderCancelLogic) UserOrderCancel(req *types.UserOrderCancelReq, us
|
|||
// 返回值必须调用Set重新返回, resp可以空指针调用 resp.SetStatus(basic.CodeOK, data)
|
||||
// userinfo 传入值时, 一定不为null
|
||||
|
||||
if userinfo == nil || userinfo.UserId == 0 {
|
||||
return resp.SetStatusWithMessage(basic.CodeDbRecordNotFoundErr, "order not found")
|
||||
}
|
||||
// if userinfo == nil || userinfo.UserId == 0 {
|
||||
// return resp.SetStatusWithMessage(basic.CodeDbRecordNotFoundErr, "order not found")
|
||||
// }
|
||||
|
||||
//查询订单信息
|
||||
orderModel := gmodel.NewFsOrderModel(l.svcCtx.MysqlConn)
|
||||
orderInfo, err := orderModel.FindOne(l.ctx, userinfo.UserId, req.ID)
|
||||
if err != nil {
|
||||
if errors.Is(err, gorm.ErrRecordNotFound) {
|
||||
return resp.SetStatusWithMessage(basic.CodeDbRecordNotFoundErr, "the order is not exists")
|
||||
}
|
||||
logx.Error(err)
|
||||
return resp.SetStatus(basic.CodeServiceErr, "failed to get order info")
|
||||
}
|
||||
// //查询订单信息
|
||||
// orderModel := gmodel.NewFsOrderModel(l.svcCtx.MysqlConn)
|
||||
// orderInfo, err := orderModel.FindOne(l.ctx, userinfo.UserId, req.ID)
|
||||
// if err != nil {
|
||||
// if errors.Is(err, gorm.ErrRecordNotFound) {
|
||||
// return resp.SetStatusWithMessage(basic.CodeDbRecordNotFoundErr, "the order is not exists")
|
||||
// }
|
||||
// logx.Error(err)
|
||||
// return resp.SetStatus(basic.CodeServiceErr, "failed to get order info")
|
||||
// }
|
||||
|
||||
// 判断订单状态
|
||||
var notCancelStatusMap = make(map[int64]struct{}, 3)
|
||||
notCancelStatusMap[int64(constants.STATUS_NEW_NOT_PAY)] = struct{}{}
|
||||
notCancelStatusMap[int64(constants.STATUS_NEW_PART_PAY)] = struct{}{}
|
||||
notCancelStatusMap[int64(constants.STATUS_NEW_PAY_COMPLETED)] = struct{}{}
|
||||
_, ok := notCancelStatusMap[int64(*orderInfo.Status)]
|
||||
if !ok {
|
||||
return resp.SetStatusWithMessage(basic.CodeOrderNotCancelledErr, "the order status not cancle")
|
||||
}
|
||||
// // 判断订单状态
|
||||
// var notCancelStatusMap = make(map[int64]struct{}, 3)
|
||||
// notCancelStatusMap[int64(constants.STATUS_NEW_NOT_PAY)] = struct{}{}
|
||||
// notCancelStatusMap[int64(constants.STATUS_NEW_PART_PAY)] = struct{}{}
|
||||
// notCancelStatusMap[int64(constants.STATUS_NEW_PAY_COMPLETED)] = struct{}{}
|
||||
// _, ok := notCancelStatusMap[int64(*orderInfo.Status)]
|
||||
// if !ok {
|
||||
// return resp.SetStatusWithMessage(basic.CodeOrderNotCancelledErr, "the order status not cancle")
|
||||
// }
|
||||
|
||||
var cancelTime int64 = time.Now().UTC().Unix() - (*orderInfo.Ctime + int64(constants.CANCLE_ORDER_EXPIRE))
|
||||
// 第一次支付成功后48小时后不能进行取消操作
|
||||
if *orderInfo.IsPayCompleted == 1 && cancelTime > 0 {
|
||||
return resp.SetStatusWithMessage(basic.CodeOrderNotCancelledErr, "The current order cannot be cancelled")
|
||||
}
|
||||
// var cancelTime int64 = time.Now().UTC().Unix() - (*orderInfo.Ctime + int64(constants.CANCLE_ORDER_EXPIRE))
|
||||
// // 第一次支付成功后48小时后不能进行取消操作
|
||||
// if *orderInfo.IsPayCompleted == 1 && cancelTime > 0 {
|
||||
// return resp.SetStatusWithMessage(basic.CodeOrderNotCancelledErr, "The current order cannot be cancelled")
|
||||
// }
|
||||
|
||||
// 修改订单--取消状态和取消原因
|
||||
*orderInfo.Status = int64(constants.STATUS_NEW_CANCEL)
|
||||
*orderInfo.IsCancel = 1
|
||||
orderInfo.RefundReasonId = &req.RefundReasonId
|
||||
orderInfo.RefundReason = &req.RefundReason
|
||||
// // 修改订单--取消状态和取消原因
|
||||
// *orderInfo.Status = int64(constants.STATUS_NEW_CANCEL)
|
||||
// *orderInfo.IsCancel = 1
|
||||
// orderInfo.RefundReasonId = &req.RefundReasonId
|
||||
// orderInfo.RefundReason = &req.RefundReason
|
||||
|
||||
var nowTime = time.Now().UTC().Unix()
|
||||
var payList []handlers.PayInfo
|
||||
// 事务处理
|
||||
ctx := l.ctx
|
||||
err = l.svcCtx.MysqlConn.Transaction(func(tx *gorm.DB) error {
|
||||
// 修改订单信息
|
||||
orderModelTS := gmodel.NewFsOrderModel(tx)
|
||||
err = orderModelTS.RBUpdate(ctx, orderInfo)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
// 新增退款记录
|
||||
var isRefund int64 = 0
|
||||
refundReasonModelTS := gmodel.NewFsRefundReasonModel(tx)
|
||||
refundReasonModelTS.RBCreateOrUpdate(ctx, &gmodel.FsRefundReason{
|
||||
IsRefund: &isRefund,
|
||||
RefundReasonId: &req.RefundReasonId,
|
||||
RefundReason: &req.RefundReason,
|
||||
OrderId: &orderInfo.Id,
|
||||
CreatedAt: &nowTime,
|
||||
})
|
||||
// 退款申请
|
||||
// 退款申请--查询支付信息
|
||||
fsPayModelTS := gmodel.NewFsPayModel(tx)
|
||||
rbFsPay := fsPayModelTS.RowSelectBuilder(nil).Where("order_number = ?", orderInfo.Sn).Where("pay_status =?", constants.PAYSTATUS_SUCCESS).Where("is_refund =?", 0)
|
||||
payInfoList, err := fsPayModelTS.FindAll(ctx, rbFsPay, nil, "")
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
for _, payInfo := range payInfoList {
|
||||
var key string
|
||||
if *payInfo.PaymentMethod == int64(constants.PAYMETHOD_STRIPE) {
|
||||
key = l.svcCtx.Config.PayConfig.Stripe.Key
|
||||
}
|
||||
payList = append(payList, handlers.PayInfo{
|
||||
TradeNo: *payInfo.TradeNo,
|
||||
PaymentMethod: *payInfo.PaymentMethod,
|
||||
Key: key,
|
||||
})
|
||||
}
|
||||
return nil
|
||||
})
|
||||
// 退款申请--调取第三方接口发起退款
|
||||
handlers.PayRefundHandler(&handlers.PayRefundHandlerReq{
|
||||
PayInfoList: payList,
|
||||
})
|
||||
if err != nil {
|
||||
logx.Error(err)
|
||||
return resp.SetStatusWithMessage(basic.CodeOrderCancelledNotOk, "the order cancle failed")
|
||||
}
|
||||
// var nowTime = time.Now().UTC().Unix()
|
||||
// var payList []handlers.PayInfo
|
||||
// // 事务处理
|
||||
// ctx := l.ctx
|
||||
// err = l.svcCtx.MysqlConn.Transaction(func(tx *gorm.DB) error {
|
||||
// // 修改订单信息
|
||||
// orderModelTS := gmodel.NewFsOrderModel(tx)
|
||||
// err = orderModelTS.RBUpdate(ctx, orderInfo)
|
||||
// if err != nil {
|
||||
// return err
|
||||
// }
|
||||
// // 新增退款记录
|
||||
// var isRefund int64 = 0
|
||||
// refundReasonModelTS := gmodel.NewFsRefundReasonModel(tx)
|
||||
// refundReasonModelTS.RBCreateOrUpdate(ctx, &gmodel.FsRefundReason{
|
||||
// IsRefund: &isRefund,
|
||||
// RefundReasonId: &req.RefundReasonId,
|
||||
// RefundReason: &req.RefundReason,
|
||||
// OrderId: &orderInfo.Id,
|
||||
// CreatedAt: &nowTime,
|
||||
// })
|
||||
// // 退款申请
|
||||
// // 退款申请--查询支付信息
|
||||
// fsPayModelTS := gmodel.NewFsPayModel(tx)
|
||||
// rbFsPay := fsPayModelTS.RowSelectBuilder(nil).Where("order_number = ?", orderInfo.Sn).Where("pay_status =?", constants.PAYSTATUS_SUCCESS).Where("is_refund =?", 0)
|
||||
// payInfoList, err := fsPayModelTS.FindAll(ctx, rbFsPay, nil, "")
|
||||
// if err != nil {
|
||||
// return err
|
||||
// }
|
||||
// for _, payInfo := range payInfoList {
|
||||
// var key string
|
||||
// if *payInfo.PaymentMethod == int64(constants.PAYMETHOD_STRIPE) {
|
||||
// key = l.svcCtx.Config.PayConfig.Stripe.Key
|
||||
// }
|
||||
// payList = append(payList, handlers.PayInfo{
|
||||
// TradeNo: *payInfo.TradeNo,
|
||||
// PaymentMethod: *payInfo.PaymentMethod,
|
||||
// Key: key,
|
||||
// })
|
||||
// }
|
||||
// return nil
|
||||
// })
|
||||
// // 退款申请--调取第三方接口发起退款
|
||||
// handlers.PayRefundHandler(&handlers.PayRefundHandlerReq{
|
||||
// PayInfoList: payList,
|
||||
// })
|
||||
// if err != nil {
|
||||
// logx.Error(err)
|
||||
// return resp.SetStatusWithMessage(basic.CodeOrderCancelledNotOk, "the order cancle failed")
|
||||
// }
|
||||
|
||||
return resp.SetStatus(basic.CodeOK)
|
||||
}
|
||||
|
|
|
@ -1,9 +1,6 @@
|
|||
package logic
|
||||
|
||||
import (
|
||||
"errors"
|
||||
"fusenapi/constants"
|
||||
"fusenapi/model/gmodel"
|
||||
"fusenapi/utils/auth"
|
||||
"fusenapi/utils/basic"
|
||||
|
||||
|
@ -13,7 +10,6 @@ import (
|
|||
"fusenapi/server/home-user-auth/internal/types"
|
||||
|
||||
"github.com/zeromicro/go-zero/core/logx"
|
||||
"gorm.io/gorm"
|
||||
)
|
||||
|
||||
type UserOrderDeleteLogic struct {
|
||||
|
@ -43,36 +39,36 @@ func (l *UserOrderDeleteLogic) UserOrderDelete(req *types.UserOrderDeleteReq, us
|
|||
// 返回值必须调用Set重新返回, resp可以空指针调用 resp.SetStatus(basic.CodeOK, data)
|
||||
// userinfo 传入值时, 一定不为null
|
||||
|
||||
if userinfo == nil || userinfo.UserId == 0 {
|
||||
return resp.SetStatusWithMessage(basic.CodeDbRecordNotFoundErr, "order not found")
|
||||
}
|
||||
// if userinfo == nil || userinfo.UserId == 0 {
|
||||
// return resp.SetStatusWithMessage(basic.CodeDbRecordNotFoundErr, "order not found")
|
||||
// }
|
||||
|
||||
orderModel := gmodel.NewFsOrderModel(l.svcCtx.MysqlConn)
|
||||
orderInfo, err := orderModel.FindOne(l.ctx, userinfo.UserId, req.ID)
|
||||
// orderModel := gmodel.NewFsOrderModel(l.svcCtx.MysqlConn)
|
||||
// orderInfo, err := orderModel.FindOne(l.ctx, userinfo.UserId, req.ID)
|
||||
|
||||
if err != nil {
|
||||
if errors.Is(err, gorm.ErrRecordNotFound) {
|
||||
return resp.SetStatusWithMessage(basic.CodeDbRecordNotFoundErr, "order not found")
|
||||
}
|
||||
logx.Error(err)
|
||||
return resp.SetStatusWithMessage(basic.CodeServiceErr, "failed to get order info")
|
||||
}
|
||||
// if err != nil {
|
||||
// if errors.Is(err, gorm.ErrRecordNotFound) {
|
||||
// return resp.SetStatusWithMessage(basic.CodeDbRecordNotFoundErr, "order not found")
|
||||
// }
|
||||
// logx.Error(err)
|
||||
// return resp.SetStatusWithMessage(basic.CodeServiceErr, "failed to get order info")
|
||||
// }
|
||||
|
||||
updateStatusMap := make(map[constants.Order]struct{}, 4)
|
||||
updateStatusMap[constants.STATUS_NEW_COMPLETED] = struct{}{}
|
||||
updateStatusMap[constants.STATUS_NEW_CANCEL] = struct{}{}
|
||||
updateStatusMap[constants.STATUS_NEW_REFUNDED] = struct{}{}
|
||||
updateStatusMap[constants.STATUS_NEW_CLOSE] = struct{}{}
|
||||
if _, ok := updateStatusMap[constants.Order(*orderInfo.Status)]; !ok {
|
||||
return resp.SetStatusWithMessage(basic.CodeDbRecordNotFoundErr, "order not found")
|
||||
}
|
||||
*orderInfo.Status = int64(constants.STATUS_NEW_DELETE)
|
||||
*orderInfo.IsDeleted = 1
|
||||
err = orderModel.Update(l.ctx, orderInfo)
|
||||
if err != nil {
|
||||
logx.Error(err)
|
||||
return resp.SetStatusWithMessage(basic.CodeServiceErr, "fail to delete")
|
||||
}
|
||||
// updateStatusMap := make(map[constants.Order]struct{}, 4)
|
||||
// updateStatusMap[constants.STATUS_NEW_COMPLETED] = struct{}{}
|
||||
// updateStatusMap[constants.STATUS_NEW_CANCEL] = struct{}{}
|
||||
// updateStatusMap[constants.STATUS_NEW_REFUNDED] = struct{}{}
|
||||
// updateStatusMap[constants.STATUS_NEW_CLOSE] = struct{}{}
|
||||
// if _, ok := updateStatusMap[constants.Order(*orderInfo.Status)]; !ok {
|
||||
// return resp.SetStatusWithMessage(basic.CodeDbRecordNotFoundErr, "order not found")
|
||||
// }
|
||||
// *orderInfo.Status = int64(constants.STATUS_NEW_DELETE)
|
||||
// *orderInfo.IsDeleted = 1
|
||||
// err = orderModel.Update(l.ctx, orderInfo)
|
||||
// if err != nil {
|
||||
// logx.Error(err)
|
||||
// return resp.SetStatusWithMessage(basic.CodeServiceErr, "fail to delete")
|
||||
// }
|
||||
|
||||
return resp.SetStatus(basic.CodeOK)
|
||||
}
|
||||
|
|
|
@ -1,20 +1,8 @@
|
|||
package logic
|
||||
|
||||
import (
|
||||
"errors"
|
||||
"fmt"
|
||||
"fusenapi/constants"
|
||||
"fusenapi/model/gmodel"
|
||||
"fusenapi/utils/auth"
|
||||
"fusenapi/utils/basic"
|
||||
"fusenapi/utils/configs"
|
||||
"fusenapi/utils/image"
|
||||
"strings"
|
||||
|
||||
"fusenapi/utils/format"
|
||||
"fusenapi/utils/order"
|
||||
"math"
|
||||
"time"
|
||||
|
||||
"context"
|
||||
|
||||
|
@ -22,7 +10,6 @@ import (
|
|||
"fusenapi/server/home-user-auth/internal/types"
|
||||
|
||||
"github.com/zeromicro/go-zero/core/logx"
|
||||
"gorm.io/gorm"
|
||||
)
|
||||
|
||||
type UserOrderListLogic struct {
|
||||
|
@ -43,263 +30,264 @@ func (l *UserOrderListLogic) UserOrderList(req *types.UserOrderListReq, userinfo
|
|||
// 返回值必须调用Set重新返回, resp可以空指针调用 resp.SetStatus(basic.CodeOK, data)
|
||||
// userinfo 传入值时, 一定不为null
|
||||
|
||||
size := req.Size
|
||||
// size := req.Size
|
||||
|
||||
if size > 0 {
|
||||
size = int64(image.GetCurrentSize(uint32(size)))
|
||||
}
|
||||
// if size > 0 {
|
||||
// size = int64(image.GetCurrentSize(uint32(size)))
|
||||
// }
|
||||
|
||||
orderDetailModel := gmodel.NewFsOrderDetailModel(l.svcCtx.MysqlConn)
|
||||
orderDetailTemplateModel := gmodel.NewFsOrderDetailTemplateModel(l.svcCtx.MysqlConn)
|
||||
fsProductDesignModel := gmodel.NewFsProductDesignModel(l.svcCtx.MysqlConn)
|
||||
orderModel := gmodel.NewFsOrderModel(l.svcCtx.MysqlConn)
|
||||
rowBuilder := orderModel.RowSelectBuilder(nil)
|
||||
if userinfo == nil || userinfo.UserId == 0 {
|
||||
return resp.SetStatusWithMessage(basic.CodeDbRecordNotFoundErr, "order not found")
|
||||
}
|
||||
// orderDetailModel := gmodel.NewFsOrderDetailModel(l.svcCtx.MysqlConn)
|
||||
// orderDetailTemplateModel := gmodel.NewFsOrderDetailTemplateModel(l.svcCtx.MysqlConn)
|
||||
// fsProductDesignModel := gmodel.NewFsProductDesignModel(l.svcCtx.MysqlConn)
|
||||
// orderModel := gmodel.NewFsOrderModel(l.svcCtx.MysqlConn)
|
||||
// rowBuilder := orderModel.RowSelectBuilder(nil)
|
||||
// if userinfo == nil || userinfo.UserId == 0 {
|
||||
// return resp.SetStatusWithMessage(basic.CodeDbRecordNotFoundErr, "order not found")
|
||||
// }
|
||||
|
||||
// 查询条件
|
||||
var page = req.Page
|
||||
var pageSize = req.PageSize
|
||||
var listRes []*gmodel.FsOrderRel
|
||||
rowBuilder = rowBuilder.Where("user_id =?", userinfo.UserId).Where("status <> ?", constants.STATUS_NEW_NOT_PAY).Where("status <>?", constants.STATUS_NEW_DELETE)
|
||||
// // 查询条件
|
||||
// var page = req.Page
|
||||
// var pageSize = req.PageSize
|
||||
// var listRes []*gmodel.FsOrderRel
|
||||
// rowBuilder = rowBuilder.Where("user_id =?", userinfo.UserId).Where("status <> ?", constants.STATUS_NEW_NOT_PAY).Where("status <>?", constants.STATUS_NEW_DELETE)
|
||||
|
||||
// 根据时间来查询不同范围的订单
|
||||
switch req.Time {
|
||||
case 1:
|
||||
rowBuilder = rowBuilder.Where("ctime >?", time.Now().UTC().AddDate(0, -1, 0).Unix())
|
||||
case 2:
|
||||
rowBuilder = rowBuilder.Where("ctime >?", time.Now().UTC().AddDate(0, -3, 0).Unix())
|
||||
case 3:
|
||||
rowBuilder = rowBuilder.Where("ctime >?", time.Now().UTC().AddDate(0, -6, 0).Unix())
|
||||
case 4:
|
||||
rowBuilder = rowBuilder.Where("ctime >?", time.Now().UTC().AddDate(-1, 0, 0).Unix())
|
||||
default:
|
||||
}
|
||||
// // 根据时间来查询不同范围的订单
|
||||
// switch req.Time {
|
||||
// case 1:
|
||||
// rowBuilder = rowBuilder.Where("ctime >?", time.Now().UTC().AddDate(0, -1, 0).Unix())
|
||||
// case 2:
|
||||
// rowBuilder = rowBuilder.Where("ctime >?", time.Now().UTC().AddDate(0, -3, 0).Unix())
|
||||
// case 3:
|
||||
// rowBuilder = rowBuilder.Where("ctime >?", time.Now().UTC().AddDate(0, -6, 0).Unix())
|
||||
// case 4:
|
||||
// rowBuilder = rowBuilder.Where("ctime >?", time.Now().UTC().AddDate(-1, 0, 0).Unix())
|
||||
// default:
|
||||
// }
|
||||
|
||||
//按照订单状态查询不同的订单
|
||||
if req.Status != -1 {
|
||||
switch req.Status {
|
||||
case 1:
|
||||
rowBuilder = rowBuilder.Where("status in ?", [3]constants.Order{constants.STATUS_NEW_PART_PAY, constants.STATUS_NEW_PAY_COMPLETED, constants.STATUS_NEW_SURE})
|
||||
case 2:
|
||||
rowBuilder = rowBuilder.Where("status in ?", [2]constants.Order{constants.STATUS_NEW_PRODUTING, constants.STATUS_NEW_PRODUT_COMPLETED})
|
||||
case 3:
|
||||
rowBuilder = rowBuilder.Where("status in ?", [2]constants.Order{constants.STATUS_NEW_DELIVER, constants.STATUS_NEW_UPS})
|
||||
case 4:
|
||||
rowBuilder = rowBuilder.Where("status =?", constants.STATUS_NEW_ARRIVAL)
|
||||
case 5:
|
||||
rowBuilder = rowBuilder.Where("status =?", constants.STATUS_NEW_COMPLETED).Where("delivery_method =?", constants.DELIVERY_METHOD_ADDRESS)
|
||||
case 7:
|
||||
rowBuilder = rowBuilder.Where("status in ?", [3]constants.Order{constants.STATUS_NEW_CANCEL, constants.STATUS_NEW_REFUNDED, constants.STATUS_NEW_REFUNDING})
|
||||
case 8:
|
||||
rowBuilder = rowBuilder.Where("status =?", constants.STATUS_NEW_COMPLETED).Where("delivery_method =?", constants.DELIVERY_METHOD_CLOUD)
|
||||
}
|
||||
}
|
||||
// //按照订单状态查询不同的订单
|
||||
// if req.Status != -1 {
|
||||
// switch req.Status {
|
||||
// case 1:
|
||||
// rowBuilder = rowBuilder.Where("status in ?", [3]constants.Order{constants.STATUS_NEW_PART_PAY, constants.STATUS_NEW_PAY_COMPLETED, constants.STATUS_NEW_SURE})
|
||||
// case 2:
|
||||
// rowBuilder = rowBuilder.Where("status in ?", [2]constants.Order{constants.STATUS_NEW_PRODUTING, constants.STATUS_NEW_PRODUT_COMPLETED})
|
||||
// case 3:
|
||||
// rowBuilder = rowBuilder.Where("status in ?", [2]constants.Order{constants.STATUS_NEW_DELIVER, constants.STATUS_NEW_UPS})
|
||||
// case 4:
|
||||
// rowBuilder = rowBuilder.Where("status =?", constants.STATUS_NEW_ARRIVAL)
|
||||
// case 5:
|
||||
// rowBuilder = rowBuilder.Where("status =?", constants.STATUS_NEW_COMPLETED).Where("delivery_method =?", constants.DELIVERY_METHOD_ADDRESS)
|
||||
// case 7:
|
||||
// rowBuilder = rowBuilder.Where("status in ?", [3]constants.Order{constants.STATUS_NEW_CANCEL, constants.STATUS_NEW_REFUNDED, constants.STATUS_NEW_REFUNDING})
|
||||
// case 8:
|
||||
// rowBuilder = rowBuilder.Where("status =?", constants.STATUS_NEW_COMPLETED).Where("delivery_method =?", constants.DELIVERY_METHOD_CLOUD)
|
||||
// }
|
||||
// }
|
||||
|
||||
// 查询总数
|
||||
total, err := orderModel.FindCount(l.ctx, rowBuilder, nil)
|
||||
if err != nil {
|
||||
if errors.Is(err, gorm.ErrRecordNotFound) {
|
||||
return resp.SetStatusWithMessage(basic.CodeDbRecordNotFoundErr, "order not found")
|
||||
}
|
||||
logx.Error(err)
|
||||
return resp.SetStatusWithMessage(basic.CodeServiceErr, "failed to get order info")
|
||||
}
|
||||
// // 查询总数
|
||||
// total, err := orderModel.FindCount(l.ctx, rowBuilder, nil)
|
||||
// if err != nil {
|
||||
// if errors.Is(err, gorm.ErrRecordNotFound) {
|
||||
// return resp.SetStatusWithMessage(basic.CodeDbRecordNotFoundErr, "order not found")
|
||||
// }
|
||||
// logx.Error(err)
|
||||
// return resp.SetStatusWithMessage(basic.CodeServiceErr, "failed to get order info")
|
||||
// }
|
||||
|
||||
// 查询数据
|
||||
if total > 0 {
|
||||
rowBuilder = rowBuilder.Preload("FsOrderAffiliateInfo").Preload("FsOrderDetails", func(dbPreload *gorm.DB) *gorm.DB {
|
||||
return dbPreload.Table(orderDetailModel.TableName()).Preload("FsOrderDetailTemplateInfo", func(dbPreload *gorm.DB) *gorm.DB {
|
||||
return dbPreload.Table(orderDetailTemplateModel.TableName()).Preload("FsProductDesignInfo", func(dbPreload *gorm.DB) *gorm.DB {
|
||||
return dbPreload.Table(fsProductDesignModel.TableName()).Preload("OptionData").Preload("TemplateData")
|
||||
}).Preload("FsProductSizeInfo")
|
||||
}).Preload("FsProductInfo")
|
||||
})
|
||||
listRes, err = orderModel.FindPageListByPage(l.ctx, rowBuilder, &page, &pageSize, nil, "")
|
||||
}
|
||||
// // 查询数据
|
||||
// if total > 0 {
|
||||
// rowBuilder = rowBuilder.Preload("FsOrderAffiliateInfo").Preload("FsOrderDetails", func(dbPreload *gorm.DB) *gorm.DB {
|
||||
// return dbPreload.Table(orderDetailModel.TableName()).Preload("FsOrderDetailTemplateInfo", func(dbPreload *gorm.DB) *gorm.DB {
|
||||
// return dbPreload.Table(orderDetailTemplateModel.TableName()).Preload("FsProductDesignInfo", func(dbPreload *gorm.DB) *gorm.DB {
|
||||
// return dbPreload.Table(fsProductDesignModel.TableName()).Preload("OptionData").Preload("TemplateData")
|
||||
// }).Preload("FsProductSizeInfo")
|
||||
// }).Preload("FsProductInfo")
|
||||
// })
|
||||
// listRes, err = orderModel.FindPageListByPage(l.ctx, rowBuilder, &page, &pageSize, nil, "")
|
||||
// }
|
||||
|
||||
if err != nil {
|
||||
if errors.Is(err, gorm.ErrRecordNotFound) {
|
||||
return resp.SetStatusWithMessage(basic.CodeDbRecordNotFoundErr, "order not found")
|
||||
}
|
||||
logx.Error(err)
|
||||
return resp.SetStatusWithMessage(basic.CodeServiceErr, "failed to get order info")
|
||||
}
|
||||
listResLen := len(listRes)
|
||||
// if err != nil {
|
||||
// if errors.Is(err, gorm.ErrRecordNotFound) {
|
||||
// return resp.SetStatusWithMessage(basic.CodeDbRecordNotFoundErr, "order not found")
|
||||
// }
|
||||
// logx.Error(err)
|
||||
// return resp.SetStatusWithMessage(basic.CodeServiceErr, "failed to get order info")
|
||||
// }
|
||||
// listResLen := len(listRes)
|
||||
|
||||
var respList []types.Items
|
||||
if listResLen > 0 {
|
||||
// 获取订单时间配置
|
||||
orderTimeConfig, err := configs.GetOrderTimeConfig(l.ctx, l.svcCtx.MysqlConn)
|
||||
if err != nil {
|
||||
return resp.SetStatusWithMessage(basic.CodeServiceErr, "failed to get config time info")
|
||||
}
|
||||
// var respList []types.Items
|
||||
// if listResLen > 0 {
|
||||
// // 获取订单时间配置
|
||||
// orderTimeConfig, err := configs.GetOrderTimeConfig(l.ctx, l.svcCtx.MysqlConn)
|
||||
// if err != nil {
|
||||
// return resp.SetStatusWithMessage(basic.CodeServiceErr, "failed to get config time info")
|
||||
// }
|
||||
|
||||
// 数据处理
|
||||
for _, item := range listRes {
|
||||
var pbData types.Items
|
||||
pbData.ID = item.Id
|
||||
pbData.Sn = *item.Sn
|
||||
pbData.UserID = *item.UserId
|
||||
pbData.TotalAmount = *item.TotalAmount
|
||||
pbData.Ctime = format.TimeIntToFormat(*item.Ctime)
|
||||
pbData.Status = *item.Status
|
||||
pbData.DeliveryMethod = *item.DeliveryMethod
|
||||
pbData.TsTime = format.TimeToFormat(*item.TsTime)
|
||||
pbData.IsPayCompleted = *item.IsPayCompleted
|
||||
pbData.DeliverSn = *item.DeliverSn
|
||||
// // 数据处理
|
||||
// for _, item := range listRes {
|
||||
// var pbData types.Items
|
||||
// pbData.ID = item.Id
|
||||
// pbData.Sn = *item.Sn
|
||||
// pbData.UserID = *item.UserId
|
||||
// pbData.TotalAmount = *item.TotalAmount
|
||||
// pbData.Ctime = format.TimeIntToFormat(*item.Ctime)
|
||||
// pbData.Status = *item.Status
|
||||
// pbData.DeliveryMethod = *item.DeliveryMethod
|
||||
// pbData.TsTime = format.TimeToFormat(*item.TsTime)
|
||||
// pbData.IsPayCompleted = *item.IsPayCompleted
|
||||
// pbData.DeliverSn = *item.DeliverSn
|
||||
|
||||
var pcsBox int64
|
||||
var pcs int64
|
||||
var productList []types.Product
|
||||
// var pcsBox int64
|
||||
// var pcs int64
|
||||
// var productList []types.Product
|
||||
|
||||
var surplusAt int64
|
||||
// var surplusAt int64
|
||||
|
||||
//如果是部分支付状态,那么取消订单倒计时2天
|
||||
if *item.Status == int64(constants.STATUS_NEW_PART_PAY) {
|
||||
surplusAt = (*item.Ctime + int64(constants.CANCLE_ORDER_EXPIRE)) - time.Now().UTC().Unix()
|
||||
if surplusAt < 0 {
|
||||
surplusAt = 0
|
||||
}
|
||||
}
|
||||
// //如果是部分支付状态,那么取消订单倒计时2天
|
||||
// if *item.Status == int64(constants.STATUS_NEW_PART_PAY) {
|
||||
// surplusAt = (*item.Ctime + int64(constants.CANCLE_ORDER_EXPIRE)) - time.Now().UTC().Unix()
|
||||
// if surplusAt < 0 {
|
||||
// surplusAt = 0
|
||||
// }
|
||||
// }
|
||||
|
||||
fsOrderAffiliateInfo := item.FsOrderAffiliateInfo
|
||||
// fsOrderAffiliateInfo := item.FsOrderAffiliateInfo
|
||||
|
||||
var sureTime int64
|
||||
var productTime int64
|
||||
var ProductEndtime int64
|
||||
var deliverTime int64
|
||||
var upsDeliverTime int64
|
||||
var upsTime int64
|
||||
var arrivalTime int64
|
||||
var recevieTime int64
|
||||
if fsOrderAffiliateInfo.Id > 0 {
|
||||
sureTime = *fsOrderAffiliateInfo.SureTime
|
||||
productTime = *fsOrderAffiliateInfo.ProductTime
|
||||
ProductEndtime = *fsOrderAffiliateInfo.ProductEndtime
|
||||
deliverTime = *fsOrderAffiliateInfo.DeliverTime
|
||||
upsDeliverTime = *fsOrderAffiliateInfo.UpsDeliverTime
|
||||
upsTime = *fsOrderAffiliateInfo.UpsTime
|
||||
arrivalTime = *fsOrderAffiliateInfo.ArrivalTime
|
||||
recevieTime = *fsOrderAffiliateInfo.RecevieTime
|
||||
}
|
||||
// var sureTime int64
|
||||
// var productTime int64
|
||||
// var ProductEndtime int64
|
||||
// var deliverTime int64
|
||||
// var upsDeliverTime int64
|
||||
// var upsTime int64
|
||||
// var arrivalTime int64
|
||||
// var recevieTime int64
|
||||
// if fsOrderAffiliateInfo.Id > 0 {
|
||||
// sureTime = *fsOrderAffiliateInfo.SureTime
|
||||
// productTime = *fsOrderAffiliateInfo.ProductTime
|
||||
// ProductEndtime = *fsOrderAffiliateInfo.ProductEndtime
|
||||
// deliverTime = *fsOrderAffiliateInfo.DeliverTime
|
||||
// upsDeliverTime = *fsOrderAffiliateInfo.UpsDeliverTime
|
||||
// upsTime = *fsOrderAffiliateInfo.UpsTime
|
||||
// arrivalTime = *fsOrderAffiliateInfo.ArrivalTime
|
||||
// recevieTime = *fsOrderAffiliateInfo.RecevieTime
|
||||
// }
|
||||
|
||||
var getOrderStatusAndLogisticsReq = order.GetOrderStatusAndLogisticsReq{
|
||||
OrderStatus: constants.Order(*item.Status),
|
||||
DeliveryMethod: constants.DeliveryMethod(*item.DeliveryMethod),
|
||||
IsPayCompleted: *item.IsAllProductCompleted,
|
||||
OrderCtime: *item.Ctime,
|
||||
// var getOrderStatusAndLogisticsReq = order.GetOrderStatusAndLogisticsReq{
|
||||
// OrderStatus: constants.Order(*item.Status),
|
||||
// DeliveryMethod: constants.DeliveryMethod(*item.DeliveryMethod),
|
||||
// IsPayCompleted: *item.IsAllProductCompleted,
|
||||
// OrderCtime: *item.Ctime,
|
||||
|
||||
SureTime: sureTime,
|
||||
ProductTime: productTime,
|
||||
ProductEndtime: ProductEndtime,
|
||||
DeliverTime: deliverTime,
|
||||
UpsDeliverTime: upsDeliverTime,
|
||||
UpsTime: upsTime,
|
||||
ArrivalTime: arrivalTime,
|
||||
RecevieTime: recevieTime,
|
||||
// SureTime: sureTime,
|
||||
// ProductTime: productTime,
|
||||
// ProductEndtime: ProductEndtime,
|
||||
// DeliverTime: deliverTime,
|
||||
// UpsDeliverTime: upsDeliverTime,
|
||||
// UpsTime: upsTime,
|
||||
// ArrivalTime: arrivalTime,
|
||||
// RecevieTime: recevieTime,
|
||||
|
||||
WebSetTimeInfo: orderTimeConfig,
|
||||
}
|
||||
// WebSetTimeInfo: orderTimeConfig,
|
||||
// }
|
||||
|
||||
statusAndLogisticsRes := order.GetOrderStatusAndLogistics(getOrderStatusAndLogisticsReq)
|
||||
// statusAndLogisticsRes := order.GetOrderStatusAndLogistics(getOrderStatusAndLogisticsReq)
|
||||
|
||||
// 流程控制
|
||||
var statusTime []types.StatusTime
|
||||
for _, itemTimes := range statusAndLogisticsRes.Times {
|
||||
statusTime = append(statusTime, types.StatusTime{
|
||||
Key: itemTimes.Key,
|
||||
Time: itemTimes.Time,
|
||||
})
|
||||
}
|
||||
pbData.StatusTimes = statusTime
|
||||
pbData.LogisticsStatus = int64(statusAndLogisticsRes.LogisticsStatus)
|
||||
pbData.Status = int64(statusAndLogisticsRes.OrderStatus)
|
||||
// // 流程控制
|
||||
// var statusTime []types.StatusTime
|
||||
// for _, itemTimes := range statusAndLogisticsRes.Times {
|
||||
// statusTime = append(statusTime, types.StatusTime{
|
||||
// Key: itemTimes.Key,
|
||||
// Time: itemTimes.Time,
|
||||
// })
|
||||
// }
|
||||
// pbData.StatusTimes = statusTime
|
||||
// pbData.LogisticsStatus = int64(statusAndLogisticsRes.LogisticsStatus)
|
||||
// pbData.Status = int64(statusAndLogisticsRes.OrderStatus)
|
||||
|
||||
var isStopMax int64
|
||||
if len(item.FsOrderDetails) > 0 {
|
||||
for _, fsOrderDetailItem := range item.FsOrderDetails {
|
||||
// var isStopMax int64
|
||||
// if len(item.FsOrderDetails) > 0 {
|
||||
// for _, fsOrderDetailItem := range item.FsOrderDetails {
|
||||
|
||||
fsOrderDetailBuyNum := *fsOrderDetailItem.FsOrderDetail.BuyNum
|
||||
fsOrderDetailEachBoxNum := *fsOrderDetailItem.FsOrderDetailTemplateInfo.EachBoxNum
|
||||
pcs = pcs + fsOrderDetailBuyNum
|
||||
pcsBoxNum := fsOrderDetailBuyNum / fsOrderDetailEachBoxNum
|
||||
var csBoxNumF int64
|
||||
if (fsOrderDetailBuyNum % fsOrderDetailEachBoxNum) > 0 {
|
||||
csBoxNumF = 1
|
||||
}
|
||||
pcsBox = pcsBox + pcsBoxNum + csBoxNumF
|
||||
// fsOrderDetailBuyNum := *fsOrderDetailItem.FsOrderDetail.BuyNum
|
||||
// fsOrderDetailEachBoxNum := *fsOrderDetailItem.FsOrderDetailTemplateInfo.EachBoxNum
|
||||
// pcs = pcs + fsOrderDetailBuyNum
|
||||
// pcsBoxNum := fsOrderDetailBuyNum / fsOrderDetailEachBoxNum
|
||||
// var csBoxNumF int64
|
||||
// if (fsOrderDetailBuyNum % fsOrderDetailEachBoxNum) > 0 {
|
||||
// csBoxNumF = 1
|
||||
// }
|
||||
// pcsBox = pcsBox + pcsBoxNum + csBoxNumF
|
||||
|
||||
productCover := *fsOrderDetailItem.Cover
|
||||
// 尺寸
|
||||
if size >= 200 {
|
||||
coverArr := strings.Split(*fsOrderDetailItem.Cover, ".")
|
||||
if len(coverArr) < 2 {
|
||||
return resp.SetStatusWithMessage(basic.CodeServiceErr, "cover split slice item count is less than 2")
|
||||
}
|
||||
productCover = fmt.Sprintf("%s_%d.%s", coverArr[0], req.Size, coverArr[1])
|
||||
}
|
||||
// productCover := *fsOrderDetailItem.Cover
|
||||
// // 尺寸
|
||||
// if size >= 200 {
|
||||
// coverArr := strings.Split(*fsOrderDetailItem.Cover, ".")
|
||||
// if len(coverArr) < 2 {
|
||||
// return resp.SetStatusWithMessage(basic.CodeServiceErr, "cover split slice item count is less than 2")
|
||||
// }
|
||||
// productCover = fmt.Sprintf("%s_%d.%s", coverArr[0], req.Size, coverArr[1])
|
||||
// }
|
||||
|
||||
// 判断stop
|
||||
var isStop int64
|
||||
if fsOrderDetailItem.FsOrderDetailTemplateInfo.FsProductDesignInfo.OptionData.Id != 0 {
|
||||
// 尺寸或者模板下架
|
||||
if fsOrderDetailItem.FsOrderDetailTemplateInfo.FsProductDesignInfo.Id != 0 {
|
||||
isStop = 1
|
||||
} else {
|
||||
isStop = 3
|
||||
}
|
||||
} else {
|
||||
if fsOrderDetailItem.FsOrderDetailTemplateInfo.FsProductDesignInfo.Id != 0 {
|
||||
isStop = 1
|
||||
}
|
||||
}
|
||||
// // 判断stop
|
||||
// var isStop int64
|
||||
// if fsOrderDetailItem.FsOrderDetailTemplateInfo.FsProductDesignInfo.OptionData.Id != 0 {
|
||||
// // 尺寸或者模板下架
|
||||
// if fsOrderDetailItem.FsOrderDetailTemplateInfo.FsProductDesignInfo.Id != 0 {
|
||||
// isStop = 1
|
||||
// } else {
|
||||
// isStop = 3
|
||||
// }
|
||||
// } else {
|
||||
// if fsOrderDetailItem.FsOrderDetailTemplateInfo.FsProductDesignInfo.Id != 0 {
|
||||
// isStop = 1
|
||||
// }
|
||||
// }
|
||||
|
||||
// 判断产品是否下架
|
||||
if *fsOrderDetailItem.FsProductInfo.IsShelf == 0 || *fsOrderDetailItem.FsProductInfo.IsDel == 1 {
|
||||
isStop = 2
|
||||
}
|
||||
if isStop > isStopMax {
|
||||
isStopMax = isStop
|
||||
}
|
||||
// // 判断产品是否下架
|
||||
// if *fsOrderDetailItem.FsProductInfo.IsShelf == 0 || *fsOrderDetailItem.FsProductInfo.IsDel == 1 {
|
||||
// isStop = 2
|
||||
// }
|
||||
// if isStop > isStopMax {
|
||||
// isStopMax = isStop
|
||||
// }
|
||||
|
||||
productList = append(productList, types.Product{
|
||||
Cover: productCover,
|
||||
Fitting: *fsOrderDetailItem.OptionalTitle,
|
||||
OptionPrice: *fsOrderDetailItem.OptionPrice,
|
||||
OrderDetailTemplateId: *fsOrderDetailItem.OrderDetailTemplateId,
|
||||
OrderId: *fsOrderDetailItem.OrderId,
|
||||
Pcs: fsOrderDetailBuyNum,
|
||||
PcsBox: pcsBox,
|
||||
Price: *fsOrderDetailItem.FsOrderDetail.Amount,
|
||||
ProductId: *fsOrderDetailItem.OptionPrice,
|
||||
Title: *fsOrderDetailItem.FsProductInfo.Title,
|
||||
Size: *fsOrderDetailItem.FsOrderDetailTemplateInfo.FsProductSizeInfo.Capacity,
|
||||
IsStop: isStop,
|
||||
})
|
||||
}
|
||||
pbData.ProductList = productList
|
||||
}
|
||||
// productList = append(productList, types.Product{
|
||||
// Cover: productCover,
|
||||
// Fitting: *fsOrderDetailItem.OptionalTitle,
|
||||
// OptionPrice: *fsOrderDetailItem.OptionPrice,
|
||||
// OrderDetailTemplateId: *fsOrderDetailItem.OrderDetailTemplateId,
|
||||
// OrderId: *fsOrderDetailItem.OrderId,
|
||||
// Pcs: fsOrderDetailBuyNum,
|
||||
// PcsBox: pcsBox,
|
||||
// Price: *fsOrderDetailItem.FsOrderDetail.Amount,
|
||||
// ProductId: *fsOrderDetailItem.OptionPrice,
|
||||
// Title: *fsOrderDetailItem.FsProductInfo.Title,
|
||||
// Size: *fsOrderDetailItem.FsOrderDetailTemplateInfo.FsProductSizeInfo.Capacity,
|
||||
// IsStop: isStop,
|
||||
// })
|
||||
// }
|
||||
// pbData.ProductList = productList
|
||||
// }
|
||||
|
||||
pbData.IsStop = isStopMax
|
||||
pbData.PcsBox = pcsBox
|
||||
pbData.Pcs = pcs
|
||||
pbData.SurplusAt = surplusAt
|
||||
pbData.Deposit = *item.TotalAmount / 2
|
||||
pbData.Remaining = pbData.Deposit
|
||||
respList = append(respList, pbData)
|
||||
}
|
||||
// pbData.IsStop = isStopMax
|
||||
// pbData.PcsBox = pcsBox
|
||||
// pbData.Pcs = pcs
|
||||
// pbData.SurplusAt = surplusAt
|
||||
// pbData.Deposit = *item.TotalAmount / 2
|
||||
// pbData.Remaining = pbData.Deposit
|
||||
// respList = append(respList, pbData)
|
||||
// }
|
||||
|
||||
}
|
||||
// }
|
||||
|
||||
return resp.SetStatusWithMessage(basic.CodeOK, "success", types.UserOrderListRsp{
|
||||
Items: respList,
|
||||
Meta: types.Meta{
|
||||
TotalCount: total,
|
||||
PageCount: int64(math.Ceil(float64(total) / float64(pageSize))),
|
||||
CurrentPage: int(page),
|
||||
PerPage: int(pageSize),
|
||||
},
|
||||
})
|
||||
// return resp.SetStatusWithMessage(basic.CodeOK, "success", types.UserOrderListRsp{
|
||||
// Items: respList,
|
||||
// Meta: types.Meta{
|
||||
// TotalCount: total,
|
||||
// PageCount: int64(math.Ceil(float64(total) / float64(pageSize))),
|
||||
// CurrentPage: int(page),
|
||||
// PerPage: int(pageSize),
|
||||
// },
|
||||
// })
|
||||
return resp.SetStatusWithMessage(basic.CodeOK, "success")
|
||||
}
|
||||
|
|
1
server/info/.gitignore
vendored
Normal file
1
server/info/.gitignore
vendored
Normal file
|
@ -0,0 +1 @@
|
|||
info
|
|
@ -4,7 +4,7 @@ Port: 9988
|
|||
Timeout: 15000 #服务超时时间(毫秒)
|
||||
ReplicaId: 200
|
||||
SourceMysql: fsreaderwriter:XErSYmLELKMnf3Dh@tcp(fusen.cdmigcvz3rle.us-east-2.rds.amazonaws.com:3306)/fusen
|
||||
SourceRabbitMq: amqp://rabbit001:rabbit001129@110.41.19.98:5672
|
||||
SourceRabbitMq:
|
||||
Log:
|
||||
Stat: false
|
||||
Auth:
|
||||
|
|
|
@ -7,6 +7,7 @@ import (
|
|||
"time"
|
||||
|
||||
"fusenapi/utils/auth"
|
||||
"fusenapi/utils/fsconfig"
|
||||
|
||||
"fusenapi/server/info/internal/config"
|
||||
"fusenapi/server/info/internal/handler"
|
||||
|
@ -21,8 +22,10 @@ var configFile = flag.String("f", "etc/info.yaml", "the config file")
|
|||
func main() {
|
||||
flag.Parse()
|
||||
|
||||
cfgContent := fsconfig.StartNacosConfig(*configFile, nil)
|
||||
var c config.Config
|
||||
conf.MustLoad(*configFile, &c)
|
||||
conf.LoadConfigFromYamlBytes([]byte(cfgContent), &c)
|
||||
|
||||
c.Timeout = int64(time.Second * 15)
|
||||
server := rest.MustNewServer(c.RestConf, rest.WithCustomCors(auth.FsCors, func(w http.ResponseWriter) {
|
||||
}))
|
||||
|
|
1
server/map-library/.gitignore
vendored
Normal file
1
server/map-library/.gitignore
vendored
Normal file
|
@ -0,0 +1 @@
|
|||
map-library
|
|
@ -30,7 +30,7 @@ func NewGetMapLibraryListLogic(ctx context.Context, svcCtx *svc.ServiceContext)
|
|||
|
||||
func (l *GetMapLibraryListLogic) GetMapLibraryList(req *types.Request, userinfo *auth.UserInfo) (resp *basic.Response) {
|
||||
if userinfo.GetIdType() != auth.IDTYPE_User {
|
||||
return resp.SetStatusWithMessage(basic.CodeServiceErr, "please login first")
|
||||
return resp.SetStatusWithMessage(basic.CodeServiceErr, "please sign in first")
|
||||
}
|
||||
mapLibraryModel := gmodel.NewFsMapLibraryModel(l.svcCtx.MysqlConn)
|
||||
mapLibraryList, err := mapLibraryModel.GetAllEnabledList(l.ctx)
|
||||
|
|
|
@ -46,7 +46,7 @@ func (l *SaveMapLibraryLogic) BeforeLogic(w http.ResponseWriter, r *http.Request
|
|||
|
||||
func (l *SaveMapLibraryLogic) SaveMapLibrary(req *types.Request, userinfo *auth.UserInfo) (resp *basic.Response) {
|
||||
if userinfo.GetIdType() != auth.IDTYPE_User {
|
||||
return resp.SetStatusWithMessage(basic.CodeServiceErr, "please login first")
|
||||
return resp.SetStatusWithMessage(basic.CodeServiceErr, "please sign in first")
|
||||
}
|
||||
|
||||
if len(l.bodyData) == 0 {
|
||||
|
|
|
@ -9,6 +9,7 @@ import (
|
|||
"fusenapi/server/map-library/internal/handler"
|
||||
"fusenapi/server/map-library/internal/svc"
|
||||
"fusenapi/utils/auth"
|
||||
"fusenapi/utils/fsconfig"
|
||||
|
||||
"github.com/zeromicro/go-zero/core/conf"
|
||||
"github.com/zeromicro/go-zero/rest"
|
||||
|
@ -19,8 +20,9 @@ var configFile = flag.String("f", "etc/map-library.yaml", "the config file")
|
|||
func main() {
|
||||
flag.Parse()
|
||||
|
||||
cfgContent := fsconfig.StartNacosConfig(*configFile, nil)
|
||||
var c config.Config
|
||||
conf.MustLoad(*configFile, &c)
|
||||
conf.LoadConfigFromYamlBytes([]byte(cfgContent), &c)
|
||||
|
||||
server := rest.MustNewServer(c.RestConf, rest.WithCustomCors(auth.FsCors, func(w http.ResponseWriter) {
|
||||
|
||||
|
|
1
server/pay/.gitignore
vendored
Normal file
1
server/pay/.gitignore
vendored
Normal file
|
@ -0,0 +1 @@
|
|||
pay
|
|
@ -1,13 +1,8 @@
|
|||
package logic
|
||||
|
||||
import (
|
||||
"errors"
|
||||
"fusenapi/constants"
|
||||
"fusenapi/model/gmodel"
|
||||
"fusenapi/utils/auth"
|
||||
"fusenapi/utils/basic"
|
||||
"fusenapi/utils/pay"
|
||||
"time"
|
||||
|
||||
"context"
|
||||
|
||||
|
@ -15,7 +10,6 @@ import (
|
|||
"fusenapi/server/pay/internal/types"
|
||||
|
||||
"github.com/zeromicro/go-zero/core/logx"
|
||||
"gorm.io/gorm"
|
||||
)
|
||||
|
||||
type OrderPaymentIntentLogic struct {
|
||||
|
@ -45,143 +39,143 @@ func (l *OrderPaymentIntentLogic) OrderPaymentIntent(req *types.OrderPaymentInte
|
|||
// 返回值必须调用Set重新返回, resp可以空指针调用 resp.SetStatus(basic.CodeOK, data)
|
||||
// userinfo 传入值时, 一定不为null
|
||||
|
||||
if userinfo == nil || userinfo.UserId == 0 {
|
||||
return resp.SetStatusWithMessage(basic.CodeDbRecordNotFoundErr, "order not found")
|
||||
}
|
||||
// if userinfo == nil || userinfo.UserId == 0 {
|
||||
// return resp.SetStatusWithMessage(basic.CodeDbRecordNotFoundErr, "order not found")
|
||||
// }
|
||||
|
||||
// 查询订单数据
|
||||
orderModel := gmodel.NewFsOrderModel(l.svcCtx.MysqlConn)
|
||||
orderInfo, err := orderModel.FindOneBySn(l.ctx, userinfo.UserId, req.Sn)
|
||||
// // 查询订单数据
|
||||
// orderModel := gmodel.NewFsOrderModel(l.svcCtx.MysqlConn)
|
||||
// orderInfo, err := orderModel.FindOneBySn(l.ctx, userinfo.UserId, req.Sn)
|
||||
|
||||
if err != nil {
|
||||
if errors.Is(err, gorm.ErrRecordNotFound) {
|
||||
return resp.SetStatusWithMessage(basic.CodeDbRecordNotFoundErr, "order not found")
|
||||
}
|
||||
logx.Error(err)
|
||||
return resp.SetStatusWithMessage(basic.CodeServiceErr, "failed to get order info")
|
||||
}
|
||||
// if err != nil {
|
||||
// if errors.Is(err, gorm.ErrRecordNotFound) {
|
||||
// return resp.SetStatusWithMessage(basic.CodeDbRecordNotFoundErr, "order not found")
|
||||
// }
|
||||
// logx.Error(err)
|
||||
// return resp.SetStatusWithMessage(basic.CodeServiceErr, "failed to get order info")
|
||||
// }
|
||||
|
||||
// 校验订单状态
|
||||
if *orderInfo.IsCancel == 1 {
|
||||
return resp.SetStatusWithMessage(basic.CodeServiceErr, "order cancelled")
|
||||
}
|
||||
// // 校验订单状态
|
||||
// if *orderInfo.IsCancel == 1 {
|
||||
// return resp.SetStatusWithMessage(basic.CodeServiceErr, "order cancelled")
|
||||
// }
|
||||
|
||||
// 校验地址信息
|
||||
addressModel := gmodel.NewFsAddressModel(l.svcCtx.MysqlConn)
|
||||
_, err = addressModel.GetOne(l.ctx, req.AddressId, userinfo.UserId)
|
||||
// // 校验地址信息
|
||||
// addressModel := gmodel.NewFsAddressModel(l.svcCtx.MysqlConn)
|
||||
// _, err = addressModel.GetOne(l.ctx, req.AddressId, userinfo.UserId)
|
||||
|
||||
if err != nil {
|
||||
if errors.Is(err, gorm.ErrRecordNotFound) {
|
||||
return resp.SetStatusWithMessage(basic.CodeDbRecordNotFoundErr, "address not found")
|
||||
}
|
||||
logx.Error(err)
|
||||
return resp.SetStatusWithMessage(basic.CodeServiceErr, "failed to get address info")
|
||||
}
|
||||
// if err != nil {
|
||||
// if errors.Is(err, gorm.ErrRecordNotFound) {
|
||||
// return resp.SetStatusWithMessage(basic.CodeDbRecordNotFoundErr, "address not found")
|
||||
// }
|
||||
// logx.Error(err)
|
||||
// return resp.SetStatusWithMessage(basic.CodeServiceErr, "failed to get address info")
|
||||
// }
|
||||
|
||||
// 校验订单支付信息
|
||||
if *orderInfo.IsPayCompleted == 1 {
|
||||
return resp.SetStatusWithMessage(basic.CodeServiceErr, "order is pay completed")
|
||||
}
|
||||
// // 校验订单支付信息
|
||||
// if *orderInfo.IsPayCompleted == 1 {
|
||||
// return resp.SetStatusWithMessage(basic.CodeServiceErr, "order is pay completed")
|
||||
// }
|
||||
|
||||
// 判断订单状态以及该支付金额
|
||||
var nowAt int64 = time.Now().UTC().Unix()
|
||||
var payAmount int64
|
||||
if *orderInfo.Status == int64(constants.STATUS_NEW_NOT_PAY) {
|
||||
payAmount = *orderInfo.TotalAmount / 2
|
||||
*orderInfo.DeliveryMethod = req.DeliveryMethod
|
||||
*orderInfo.AddressId = req.AddressId
|
||||
*orderInfo.PayMethod = req.PayMethod
|
||||
} else {
|
||||
payAmount = *orderInfo.TotalAmount - *orderInfo.TotalAmount/2
|
||||
}
|
||||
// // 判断订单状态以及该支付金额
|
||||
// var nowAt int64 = time.Now().UTC().Unix()
|
||||
// var payAmount int64
|
||||
// if *orderInfo.Status == int64(constants.STATUS_NEW_NOT_PAY) {
|
||||
// payAmount = *orderInfo.TotalAmount / 2
|
||||
// *orderInfo.DeliveryMethod = req.DeliveryMethod
|
||||
// *orderInfo.AddressId = req.AddressId
|
||||
// *orderInfo.PayMethod = req.PayMethod
|
||||
// } else {
|
||||
// payAmount = *orderInfo.TotalAmount - *orderInfo.TotalAmount/2
|
||||
// }
|
||||
|
||||
payConfig := &pay.Config{}
|
||||
var generatePrepaymentReq = &pay.GeneratePrepaymentReq{
|
||||
OrderSn: req.Sn,
|
||||
ProductName: "支付标题",
|
||||
Amount: payAmount,
|
||||
Currency: "eur",
|
||||
Quantity: 1,
|
||||
ProductDescription: "支付描述",
|
||||
}
|
||||
// payConfig := &pay.Config{}
|
||||
// var generatePrepaymentReq = &pay.GeneratePrepaymentReq{
|
||||
// OrderSn: req.Sn,
|
||||
// ProductName: "支付标题",
|
||||
// Amount: payAmount,
|
||||
// Currency: "eur",
|
||||
// Quantity: 1,
|
||||
// ProductDescription: "支付描述",
|
||||
// }
|
||||
|
||||
var resData types.OrderPaymentIntentRes
|
||||
// 事务处理
|
||||
ctx := l.ctx
|
||||
err = l.svcCtx.MysqlConn.Transaction(func(connGorm *gorm.DB) error {
|
||||
// 支付记录--处理 //支付记录改为一条订单多条,分首款尾款
|
||||
var payStatus int64 = 0
|
||||
var orderSource int64 = 1
|
||||
var payStage int64
|
||||
var fspay *gmodel.FsPay
|
||||
newFsPayModel := gmodel.NewFsPayModel(connGorm)
|
||||
if *orderInfo.Status == int64(constants.STATUS_NEW_NOT_PAY) {
|
||||
fspay, err = newFsPayModel.RBGetListByOrderNumberStage(ctx, *orderInfo.Sn, 1)
|
||||
if err != nil {
|
||||
if !errors.Is(err, gorm.ErrRecordNotFound) {
|
||||
return err
|
||||
}
|
||||
}
|
||||
payStage = 1
|
||||
} else {
|
||||
fspay, err = newFsPayModel.RBGetListByOrderNumberStage(ctx, *orderInfo.Sn, 2)
|
||||
if err != nil {
|
||||
if !errors.Is(err, gorm.ErrRecordNotFound) {
|
||||
return err
|
||||
}
|
||||
}
|
||||
payStage = 2
|
||||
}
|
||||
// var resData types.OrderPaymentIntentRes
|
||||
// // 事务处理
|
||||
// ctx := l.ctx
|
||||
// err = l.svcCtx.MysqlConn.Transaction(func(connGorm *gorm.DB) error {
|
||||
// // 支付记录--处理 //支付记录改为一条订单多条,分首款尾款
|
||||
// var payStatus int64 = 0
|
||||
// var orderSource int64 = 1
|
||||
// var payStage int64
|
||||
// var fspay *gmodel.FsPay
|
||||
// newFsPayModel := gmodel.NewFsPayModel(connGorm)
|
||||
// if *orderInfo.Status == int64(constants.STATUS_NEW_NOT_PAY) {
|
||||
// fspay, err = newFsPayModel.RBGetListByOrderNumberStage(ctx, *orderInfo.Sn, 1)
|
||||
// if err != nil {
|
||||
// if !errors.Is(err, gorm.ErrRecordNotFound) {
|
||||
// return err
|
||||
// }
|
||||
// }
|
||||
// payStage = 1
|
||||
// } else {
|
||||
// fspay, err = newFsPayModel.RBGetListByOrderNumberStage(ctx, *orderInfo.Sn, 2)
|
||||
// if err != nil {
|
||||
// if !errors.Is(err, gorm.ErrRecordNotFound) {
|
||||
// return err
|
||||
// }
|
||||
// }
|
||||
// payStage = 2
|
||||
// }
|
||||
|
||||
// 支付预付--生成
|
||||
if constants.PayMethod(req.PayMethod) == constants.PAYMETHOD_STRIPE {
|
||||
payConfig.Stripe.Key = l.svcCtx.Config.PayConfig.Stripe.Key
|
||||
generatePrepaymentReq.SuccessURL = l.svcCtx.Config.PayConfig.Stripe.SuccessURL
|
||||
generatePrepaymentReq.CancelURL = l.svcCtx.Config.PayConfig.Stripe.CancelURL
|
||||
}
|
||||
payDriver := pay.NewPayDriver(req.PayMethod, payConfig)
|
||||
prepaymentRes, err := payDriver.GeneratePrepayment(generatePrepaymentReq)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
// // 支付预付--生成
|
||||
// if constants.PayMethod(req.PayMethod) == constants.PAYMETHOD_STRIPE {
|
||||
// payConfig.Stripe.Key = l.svcCtx.Config.PayConfig.Stripe.Key
|
||||
// generatePrepaymentReq.SuccessURL = l.svcCtx.Config.PayConfig.Stripe.SuccessURL
|
||||
// generatePrepaymentReq.CancelURL = l.svcCtx.Config.PayConfig.Stripe.CancelURL
|
||||
// }
|
||||
// payDriver := pay.NewPayDriver(req.PayMethod, payConfig)
|
||||
// prepaymentRes, err := payDriver.GeneratePrepayment(generatePrepaymentReq)
|
||||
// if err != nil {
|
||||
// return err
|
||||
// }
|
||||
|
||||
// 订单信息--修改
|
||||
err = gmodel.NewFsOrderModel(connGorm).RBUpdate(ctx, orderInfo)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
// // 订单信息--修改
|
||||
// err = gmodel.NewFsOrderModel(connGorm).RBUpdate(ctx, orderInfo)
|
||||
// if err != nil {
|
||||
// return err
|
||||
// }
|
||||
|
||||
if fspay == nil {
|
||||
fspay = &gmodel.FsPay{
|
||||
UserId: orderInfo.UserId,
|
||||
OrderNumber: orderInfo.Sn,
|
||||
CreatedAt: &nowAt,
|
||||
}
|
||||
} else {
|
||||
fspay.UpdatedAt = &nowAt
|
||||
}
|
||||
fspay.PayAmount = &payAmount
|
||||
fspay.PayStage = &payStage
|
||||
//fspay.TradeNo = &prepaymentRes.TradeNo
|
||||
fspay.PaymentMethod = &req.PayMethod
|
||||
fspay.OrderSource = &orderSource
|
||||
fspay.PayStatus = &payStatus
|
||||
// if fspay == nil {
|
||||
// fspay = &gmodel.FsPay{
|
||||
// UserId: orderInfo.UserId,
|
||||
// OrderNumber: orderInfo.Sn,
|
||||
// CreatedAt: &nowAt,
|
||||
// }
|
||||
// } else {
|
||||
// fspay.UpdatedAt = &nowAt
|
||||
// }
|
||||
// fspay.PayAmount = &payAmount
|
||||
// fspay.PayStage = &payStage
|
||||
// //fspay.TradeNo = &prepaymentRes.TradeNo
|
||||
// fspay.PaymentMethod = &req.PayMethod
|
||||
// fspay.OrderSource = &orderSource
|
||||
// fspay.PayStatus = &payStatus
|
||||
|
||||
_, err = newFsPayModel.RBCreateOrUpdate(ctx, fspay)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
// _, err = newFsPayModel.RBCreateOrUpdate(ctx, fspay)
|
||||
// if err != nil {
|
||||
// return err
|
||||
// }
|
||||
|
||||
resData.RedirectUrl = prepaymentRes.URL
|
||||
resData.ClientSecret = prepaymentRes.ClientSecret
|
||||
// resData.RedirectUrl = prepaymentRes.URL
|
||||
// resData.ClientSecret = prepaymentRes.ClientSecret
|
||||
|
||||
return nil
|
||||
})
|
||||
// return nil
|
||||
// })
|
||||
|
||||
if err != nil {
|
||||
logx.Error(err)
|
||||
return resp.SetStatusWithMessage(basic.CodeServiceErr, "failed to make payment")
|
||||
}
|
||||
// if err != nil {
|
||||
// logx.Error(err)
|
||||
// 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
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"errors"
|
||||
"fusenapi/constants"
|
||||
"fusenapi/model/gmodel"
|
||||
"fusenapi/utils/auth"
|
||||
"fusenapi/utils/basic"
|
||||
"time"
|
||||
|
||||
"context"
|
||||
|
||||
|
@ -15,9 +11,7 @@ import (
|
|||
"fusenapi/server/pay/internal/types"
|
||||
|
||||
"github.com/stripe/stripe-go/v74"
|
||||
"github.com/stripe/stripe-go/v74/webhook"
|
||||
"github.com/zeromicro/go-zero/core/logx"
|
||||
"gorm.io/gorm"
|
||||
)
|
||||
|
||||
type StripeWebhookLogic struct {
|
||||
|
@ -48,97 +42,97 @@ func (l *StripeWebhookLogic) StripeWebhook(req *types.StripeWebhookReq, userinfo
|
|||
// 返回值必须调用Set重新返回, resp可以空指针调用 resp.SetStatus(basic.CodeOK, data)
|
||||
// userinfo 传入值时, 一定不为null
|
||||
|
||||
stripe.Key = l.svcCtx.Config.PayConfig.Stripe.Key
|
||||
event := stripe.Event{}
|
||||
// stripe.Key = l.svcCtx.Config.PayConfig.Stripe.Key
|
||||
// event := stripe.Event{}
|
||||
|
||||
if err := json.Unmarshal(req.Payload, &event); err != nil {
|
||||
logx.Error(err)
|
||||
return resp.SetStatusWithMessage(basic.CodeAesCbcDecryptionErr, "pay notify Unmarshal fail")
|
||||
}
|
||||
// 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")
|
||||
}
|
||||
// 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)
|
||||
// // 新增支付回调事件日志
|
||||
// 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")
|
||||
// }
|
||||
// // 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")
|
||||
}
|
||||
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")
|
||||
}
|
||||
// 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")
|
||||
// }
|
||||
// err = l.HandlePaymentIntentSucceeded(&paymentIntent)
|
||||
// if err != nil {
|
||||
// logx.Errorf("err:%+v,desc:%s", err, "pay notify handle payment_intent.succeeded")
|
||||
// return resp.SetStatusWithMessage(basic.CodePaybackNotOk, "pay notify handle payment_intent.succeeded")
|
||||
// }
|
||||
// case "payment_method.attached":
|
||||
// var paymentMethod stripe.PaymentMethod
|
||||
// err := json.Unmarshal(event.Data.Raw, &paymentMethod)
|
||||
// if err != nil {
|
||||
// logx.Error(err)
|
||||
// return resp.SetStatusWithMessage(basic.CodeAesCbcDecryptionErr, "pay notify Unmarshal fail event.Type payment_method.attached")
|
||||
// }
|
||||
// case "charge.refunded":
|
||||
// var chargeRefunded stripe.Charge
|
||||
// err := json.Unmarshal(event.Data.Raw, &chargeRefunded)
|
||||
// if err != nil {
|
||||
// logx.Errorf("err:%+v,desc:%s", err, "pay notify Unmarshal fail event.Type charge.refunded")
|
||||
// return resp.SetStatusWithMessage(basic.CodeAesCbcDecryptionErr, "pay notify Unmarshal fail event.Type charge.refunded")
|
||||
// }
|
||||
// err = l.HandleChargeRefunded(&chargeRefunded)
|
||||
// if err != nil {
|
||||
// logx.Errorf("err:%+v,desc:%s", err, "pay notify handle charge.refunded")
|
||||
// return resp.SetStatusWithMessage(basic.CodeAesCbcDecryptionErr, "pay notify handle charge.refunded")
|
||||
// }
|
||||
|
||||
// ... handle other event types
|
||||
default:
|
||||
logx.Error("Unhandled event")
|
||||
return resp.SetStatusWithMessage(basic.CodeAesCbcDecryptionErr, "pay notify Unmarshal fail event.Type Unhandled")
|
||||
}
|
||||
// // ... handle other event types
|
||||
// default:
|
||||
// logx.Error("Unhandled event")
|
||||
// return resp.SetStatusWithMessage(basic.CodeAesCbcDecryptionErr, "pay notify Unmarshal fail event.Type Unhandled")
|
||||
// }
|
||||
|
||||
return resp.SetStatus(basic.CodeOK)
|
||||
}
|
||||
|
@ -151,62 +145,62 @@ func (l *StripeWebhookLogic) HandlePayEventCreate(fsPayEvent *gmodel.FsPayEvent)
|
|||
|
||||
// 退款成功
|
||||
func (l *StripeWebhookLogic) HandleChargeRefunded(chargeRefunded *stripe.Charge) (err error) {
|
||||
// 退款成功
|
||||
if chargeRefunded.Status == "succeeded" {
|
||||
ctx := l.ctx
|
||||
err = l.svcCtx.MysqlConn.Transaction(func(connGorm *gorm.DB) error {
|
||||
// 查询支付记录
|
||||
payModelT := gmodel.NewFsPayModel(connGorm)
|
||||
payModelTRSB := payModelT.BuilderTrans(nil)
|
||||
payModelTRSB1 := payModelTRSB.Where("trade_no = ?", chargeRefunded.PaymentIntent.ID).Where("pay_status = ?", constants.PAYSTATUS_SUCCESS).Where("is_refund = ?", 0)
|
||||
payInfo, err := payModelT.FindOneByQuery(ctx, payModelTRSB1, nil)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
// 更新支付记录
|
||||
*payInfo.IsRefund = 1
|
||||
_, err = payModelT.RBCreateOrUpdate(ctx, payInfo)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
// 获取是否还有未退款的数据
|
||||
payModelTRSB2 := payModelTRSB.Where("order_number = ?", payInfo.OrderNumber).Where("pay_status = ?", constants.PAYSTATUS_SUCCESS).Where("is_refund = ?", 0)
|
||||
count, err := payModelT.FindCount(l.ctx, payModelTRSB2, nil)
|
||||
if count == 0 {
|
||||
// 退款完成更新订单状态
|
||||
orderModelT := gmodel.NewFsOrderModel(connGorm)
|
||||
orderModelTRSB := orderModelT.BuilderTrans(nil).Where("sn =?", payInfo.OrderNumber)
|
||||
orderInfoRel, err := orderModelT.FindOneByQuery(ctx, orderModelTRSB, nil)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
var isRefunded int64 = 1
|
||||
var isRefunding int64 = 1
|
||||
var orderStatus int64 = int64(constants.STATUS_NEW_REFUNDED)
|
||||
var orderInfo = &gmodel.FsOrder{}
|
||||
orderInfo.Id = orderInfoRel.Id
|
||||
orderInfo.IsRefunded = &isRefunded
|
||||
orderInfo.IsRefunding = &isRefunding
|
||||
orderInfo.Status = &orderStatus
|
||||
orderModelT.Update(ctx, orderInfo)
|
||||
// // 退款成功
|
||||
// if chargeRefunded.Status == "succeeded" {
|
||||
// ctx := l.ctx
|
||||
// err = l.svcCtx.MysqlConn.Transaction(func(connGorm *gorm.DB) error {
|
||||
// // 查询支付记录
|
||||
// payModelT := gmodel.NewFsPayModel(connGorm)
|
||||
// payModelTRSB := payModelT.BuilderTrans(nil)
|
||||
// payModelTRSB1 := payModelTRSB.Where("trade_no = ?", chargeRefunded.PaymentIntent.ID).Where("pay_status = ?", constants.PAYSTATUS_SUCCESS).Where("is_refund = ?", 0)
|
||||
// payInfo, err := payModelT.FindOneByQuery(ctx, payModelTRSB1, nil)
|
||||
// if err != nil {
|
||||
// return err
|
||||
// }
|
||||
// // 更新支付记录
|
||||
// *payInfo.IsRefund = 1
|
||||
// _, err = payModelT.RBCreateOrUpdate(ctx, payInfo)
|
||||
// if err != nil {
|
||||
// return err
|
||||
// }
|
||||
// // 获取是否还有未退款的数据
|
||||
// payModelTRSB2 := payModelTRSB.Where("order_number = ?", payInfo.OrderNumber).Where("pay_status = ?", constants.PAYSTATUS_SUCCESS).Where("is_refund = ?", 0)
|
||||
// count, err := payModelT.FindCount(l.ctx, payModelTRSB2, nil)
|
||||
// if count == 0 {
|
||||
// // 退款完成更新订单状态
|
||||
// orderModelT := gmodel.NewFsOrderModel(connGorm)
|
||||
// orderModelTRSB := orderModelT.BuilderTrans(nil).Where("sn =?", payInfo.OrderNumber)
|
||||
// orderInfoRel, err := orderModelT.FindOneByQuery(ctx, orderModelTRSB, nil)
|
||||
// if err != nil {
|
||||
// return err
|
||||
// }
|
||||
// var isRefunded int64 = 1
|
||||
// var isRefunding int64 = 1
|
||||
// var orderStatus int64 = int64(constants.STATUS_NEW_REFUNDED)
|
||||
// var orderInfo = &gmodel.FsOrder{}
|
||||
// orderInfo.Id = orderInfoRel.Id
|
||||
// orderInfo.IsRefunded = &isRefunded
|
||||
// orderInfo.IsRefunding = &isRefunding
|
||||
// orderInfo.Status = &orderStatus
|
||||
// orderModelT.Update(ctx, orderInfo)
|
||||
|
||||
// 记录退款原因
|
||||
refundReasonModelT := gmodel.NewFsRefundReasonModel(connGorm)
|
||||
refundReasonModelTRSB := refundReasonModelT.BuilderTrans(nil)
|
||||
refundReasonModelTRSB1 := refundReasonModelTRSB.Where("order_id =?", orderInfoRel.Id)
|
||||
refundReasonInfo, err := refundReasonModelT.FindOneByQuery(ctx, refundReasonModelTRSB1, nil)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
*refundReasonInfo.IsRefund = 1
|
||||
_, err = refundReasonModelT.RBCreateOrUpdate(ctx, refundReasonInfo)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
return err
|
||||
})
|
||||
}
|
||||
// // 记录退款原因
|
||||
// refundReasonModelT := gmodel.NewFsRefundReasonModel(connGorm)
|
||||
// refundReasonModelTRSB := refundReasonModelT.BuilderTrans(nil)
|
||||
// refundReasonModelTRSB1 := refundReasonModelTRSB.Where("order_id =?", orderInfoRel.Id)
|
||||
// refundReasonInfo, err := refundReasonModelT.FindOneByQuery(ctx, refundReasonModelTRSB1, nil)
|
||||
// if err != nil {
|
||||
// return err
|
||||
// }
|
||||
// *refundReasonInfo.IsRefund = 1
|
||||
// _, err = refundReasonModelT.RBCreateOrUpdate(ctx, refundReasonInfo)
|
||||
// if err != nil {
|
||||
// return err
|
||||
// }
|
||||
// }
|
||||
// return err
|
||||
// })
|
||||
// }
|
||||
return err
|
||||
}
|
||||
|
||||
|
@ -234,160 +228,160 @@ func (l *StripeWebhookLogic) HandleChargeRefunded(chargeRefunded *stripe.Charge)
|
|||
|
||||
// 付款成功
|
||||
func (l *StripeWebhookLogic) HandlePaymentIntentSucceeded(paymentIntent *stripe.PaymentIntent) error {
|
||||
orderSn, ok := paymentIntent.Metadata["order_sn"]
|
||||
if !ok || orderSn == "" {
|
||||
return errors.New("order_sn not found")
|
||||
}
|
||||
// orderSn, ok := paymentIntent.Metadata["order_sn"]
|
||||
// if !ok || orderSn == "" {
|
||||
// return errors.New("order_sn not found")
|
||||
// }
|
||||
|
||||
// 查询支付记录
|
||||
payModel := gmodel.NewFsPayModel(l.svcCtx.MysqlConn)
|
||||
rsbPay := payModel.RowSelectBuilder(nil)
|
||||
rsbPay = rsbPay.Where("order_number = ?", orderSn).Where("pay_status = ?", constants.PAYSTATUS_UNSUCCESS)
|
||||
payInfo, err := payModel.FindOneByQuery(l.ctx, rsbPay, nil)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
// // 查询支付记录
|
||||
// payModel := gmodel.NewFsPayModel(l.svcCtx.MysqlConn)
|
||||
// rsbPay := payModel.RowSelectBuilder(nil)
|
||||
// rsbPay = rsbPay.Where("order_number = ?", orderSn).Where("pay_status = ?", constants.PAYSTATUS_UNSUCCESS)
|
||||
// payInfo, err := payModel.FindOneByQuery(l.ctx, rsbPay, nil)
|
||||
// if err != nil {
|
||||
// return err
|
||||
// }
|
||||
|
||||
//订单信息
|
||||
orderDetailTemplateModel := gmodel.NewFsOrderDetailTemplateModel(l.svcCtx.MysqlConn)
|
||||
orderModel := gmodel.NewFsOrderModel(l.svcCtx.MysqlConn)
|
||||
fsOrderDetailModel := gmodel.NewFsOrderDetailModel(l.svcCtx.MysqlConn)
|
||||
fsProductDesignModel := gmodel.NewFsProductDesignModel(l.svcCtx.MysqlConn)
|
||||
// //订单信息
|
||||
// orderDetailTemplateModel := gmodel.NewFsOrderDetailTemplateModel(l.svcCtx.MysqlConn)
|
||||
// orderModel := gmodel.NewFsOrderModel(l.svcCtx.MysqlConn)
|
||||
// fsOrderDetailModel := gmodel.NewFsOrderDetailModel(l.svcCtx.MysqlConn)
|
||||
// fsProductDesignModel := gmodel.NewFsProductDesignModel(l.svcCtx.MysqlConn)
|
||||
|
||||
rsbOrder := orderModel.RowSelectBuilder(nil)
|
||||
rsbOrder = rsbOrder.Where("sn =?", orderSn).Preload("FsOrderDetails")
|
||||
rsbOrder = rsbOrder.Preload("FsOrderDetails", func(dbPreload *gorm.DB) *gorm.DB {
|
||||
return dbPreload.Table(fsOrderDetailModel.TableName()).Preload("FsOrderDetailTemplateInfo", func(dbPreload *gorm.DB) *gorm.DB {
|
||||
return dbPreload.Table(orderDetailTemplateModel.TableName()).Preload("FsProductDesignInfo", func(dbPreload *gorm.DB) *gorm.DB {
|
||||
return dbPreload.Table(fsProductDesignModel.TableName())
|
||||
})
|
||||
})
|
||||
})
|
||||
fsOrderRelInfo, err := orderModel.FindOneByQuery(l.ctx, rsbOrder, nil)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
// rsbOrder := orderModel.RowSelectBuilder(nil)
|
||||
// rsbOrder = rsbOrder.Where("sn =?", orderSn).Preload("FsOrderDetails")
|
||||
// rsbOrder = rsbOrder.Preload("FsOrderDetails", func(dbPreload *gorm.DB) *gorm.DB {
|
||||
// return dbPreload.Table(fsOrderDetailModel.TableName()).Preload("FsOrderDetailTemplateInfo", func(dbPreload *gorm.DB) *gorm.DB {
|
||||
// return dbPreload.Table(orderDetailTemplateModel.TableName()).Preload("FsProductDesignInfo", func(dbPreload *gorm.DB) *gorm.DB {
|
||||
// return dbPreload.Table(fsProductDesignModel.TableName())
|
||||
// })
|
||||
// })
|
||||
// })
|
||||
// fsOrderRelInfo, err := orderModel.FindOneByQuery(l.ctx, rsbOrder, nil)
|
||||
// if err != nil {
|
||||
// return err
|
||||
// }
|
||||
|
||||
var designIds []int64
|
||||
var cartIds []int64
|
||||
if len(fsOrderRelInfo.FsOrderDetails) > 0 {
|
||||
for _, fsOrderDetail := range fsOrderRelInfo.FsOrderDetails {
|
||||
if fsOrderDetail.FsOrderDetailTemplateInfo.FsProductDesignInfo.Id != 0 {
|
||||
designIds = append(designIds, fsOrderDetail.FsOrderDetailTemplateInfo.FsProductDesignInfo.Id)
|
||||
}
|
||||
cartIds = append(cartIds, *fsOrderDetail.CartId)
|
||||
}
|
||||
}
|
||||
// var designIds []int64
|
||||
// var cartIds []int64
|
||||
// if len(fsOrderRelInfo.FsOrderDetails) > 0 {
|
||||
// for _, fsOrderDetail := range fsOrderRelInfo.FsOrderDetails {
|
||||
// if fsOrderDetail.FsOrderDetailTemplateInfo.FsProductDesignInfo.Id != 0 {
|
||||
// designIds = append(designIds, fsOrderDetail.FsOrderDetailTemplateInfo.FsProductDesignInfo.Id)
|
||||
// }
|
||||
// cartIds = append(cartIds, *fsOrderDetail.CartId)
|
||||
// }
|
||||
// }
|
||||
|
||||
var nowTime int64 = time.Now().UTC().Unix()
|
||||
// var nowTime int64 = time.Now().UTC().Unix()
|
||||
|
||||
// 支付成功
|
||||
if paymentIntent.Status == "succeeded" {
|
||||
var card string
|
||||
var brand string
|
||||
if paymentIntent.LatestCharge.PaymentMethodDetails != nil {
|
||||
if paymentIntent.LatestCharge.PaymentMethodDetails.Card != nil {
|
||||
if paymentIntent.LatestCharge.PaymentMethodDetails.Card.Last4 != "" {
|
||||
card = paymentIntent.LatestCharge.PaymentMethodDetails.Card.Last4
|
||||
}
|
||||
if paymentIntent.LatestCharge.PaymentMethodDetails.Card.Brand != "" {
|
||||
brand = string(paymentIntent.LatestCharge.PaymentMethodDetails.Card.Brand)
|
||||
}
|
||||
}
|
||||
}
|
||||
// // 支付成功
|
||||
// if paymentIntent.Status == "succeeded" {
|
||||
// var card string
|
||||
// var brand string
|
||||
// if paymentIntent.LatestCharge.PaymentMethodDetails != nil {
|
||||
// if paymentIntent.LatestCharge.PaymentMethodDetails.Card != nil {
|
||||
// if paymentIntent.LatestCharge.PaymentMethodDetails.Card.Last4 != "" {
|
||||
// card = paymentIntent.LatestCharge.PaymentMethodDetails.Card.Last4
|
||||
// }
|
||||
// if paymentIntent.LatestCharge.PaymentMethodDetails.Card.Brand != "" {
|
||||
// brand = string(paymentIntent.LatestCharge.PaymentMethodDetails.Card.Brand)
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
|
||||
ctx := l.ctx
|
||||
err = l.svcCtx.MysqlConn.Transaction(func(connGorm *gorm.DB) error {
|
||||
// 更新支付信息
|
||||
payModelT := gmodel.NewFsPayModel(connGorm)
|
||||
*payInfo.PayStatus = 1
|
||||
*payInfo.PayTime = nowTime
|
||||
*payInfo.CardNo = card
|
||||
*payInfo.Brand = brand
|
||||
*payInfo.TradeNo = paymentIntent.ID
|
||||
_, err = payModelT.RBCreateOrUpdate(ctx, payInfo)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
// ctx := l.ctx
|
||||
// err = l.svcCtx.MysqlConn.Transaction(func(connGorm *gorm.DB) error {
|
||||
// // 更新支付信息
|
||||
// payModelT := gmodel.NewFsPayModel(connGorm)
|
||||
// *payInfo.PayStatus = 1
|
||||
// *payInfo.PayTime = nowTime
|
||||
// *payInfo.CardNo = card
|
||||
// *payInfo.Brand = brand
|
||||
// *payInfo.TradeNo = paymentIntent.ID
|
||||
// _, err = payModelT.RBCreateOrUpdate(ctx, payInfo)
|
||||
// if err != nil {
|
||||
// return err
|
||||
// }
|
||||
|
||||
// 更新设计数据
|
||||
productDesignModelT := gmodel.NewFsProductDesignModel(connGorm)
|
||||
productDesignModelTRSB := productDesignModelT.BuilderTrans(ctx, nil)
|
||||
var isPay int64 = 1
|
||||
err = productDesignModelT.RBUpdateByIds(productDesignModelTRSB, designIds, &gmodel.FsProductDesign{IsPay: &isPay})
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
// // 更新设计数据
|
||||
// productDesignModelT := gmodel.NewFsProductDesignModel(connGorm)
|
||||
// productDesignModelTRSB := productDesignModelT.BuilderTrans(ctx, nil)
|
||||
// var isPay int64 = 1
|
||||
// err = productDesignModelT.RBUpdateByIds(productDesignModelTRSB, designIds, &gmodel.FsProductDesign{IsPay: &isPay})
|
||||
// if err != nil {
|
||||
// return err
|
||||
// }
|
||||
|
||||
var orderInfo = &gmodel.FsOrder{}
|
||||
var orderStatus int64
|
||||
var orderIsPartPay int64
|
||||
var orderPayedAmount int64
|
||||
var orderIsPayCompleted int64
|
||||
// 支付记录是首款
|
||||
if *payInfo.PayStage == int64(constants.PAYSTAGE_DEPOSIT) {
|
||||
orderStatus = int64(constants.STATUS_NEW_PART_PAY)
|
||||
orderIsPartPay = 1
|
||||
orderInfo.IsPartPay = &orderIsPartPay
|
||||
orderPayedAmount = paymentIntent.Amount
|
||||
// var orderInfo = &gmodel.FsOrder{}
|
||||
// var orderStatus int64
|
||||
// var orderIsPartPay int64
|
||||
// var orderPayedAmount int64
|
||||
// var orderIsPayCompleted int64
|
||||
// // 支付记录是首款
|
||||
// if *payInfo.PayStage == int64(constants.PAYSTAGE_DEPOSIT) {
|
||||
// orderStatus = int64(constants.STATUS_NEW_PART_PAY)
|
||||
// orderIsPartPay = 1
|
||||
// orderInfo.IsPartPay = &orderIsPartPay
|
||||
// orderPayedAmount = paymentIntent.Amount
|
||||
|
||||
// 删除购物车
|
||||
cartModelT := gmodel.NewFsCartModel(connGorm)
|
||||
cartModelTRSB := cartModelT.BuilderTrans(ctx, nil)
|
||||
err = cartModelT.RBDeleteCartsByIds(cartModelTRSB, cartIds)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
// // 删除购物车
|
||||
// cartModelT := gmodel.NewFsCartModel(connGorm)
|
||||
// cartModelTRSB := cartModelT.BuilderTrans(ctx, nil)
|
||||
// err = cartModelT.RBDeleteCartsByIds(cartModelTRSB, cartIds)
|
||||
// if err != nil {
|
||||
// return err
|
||||
// }
|
||||
// }
|
||||
|
||||
// 支付记录是尾款
|
||||
if *payInfo.PayStage == int64(constants.PAYSTAGE_REMAINING) {
|
||||
if *fsOrderRelInfo.Status < int64(constants.STATUS_NEW_PAY_COMPLETED) {
|
||||
orderStatus = int64(constants.STATUS_NEW_PAY_COMPLETED)
|
||||
}
|
||||
orderIsPayCompleted = 1
|
||||
orderInfo.IsPayCompleted = &orderIsPayCompleted
|
||||
orderPayedAmount = *fsOrderRelInfo.PayedAmount + paymentIntent.Amount
|
||||
}
|
||||
// // 支付记录是尾款
|
||||
// if *payInfo.PayStage == int64(constants.PAYSTAGE_REMAINING) {
|
||||
// if *fsOrderRelInfo.Status < int64(constants.STATUS_NEW_PAY_COMPLETED) {
|
||||
// orderStatus = int64(constants.STATUS_NEW_PAY_COMPLETED)
|
||||
// }
|
||||
// orderIsPayCompleted = 1
|
||||
// orderInfo.IsPayCompleted = &orderIsPayCompleted
|
||||
// orderPayedAmount = *fsOrderRelInfo.PayedAmount + paymentIntent.Amount
|
||||
// }
|
||||
|
||||
// 更新订单信息
|
||||
orderInfo.Id = fsOrderRelInfo.Id
|
||||
orderInfo.Status = &orderStatus
|
||||
orderInfo.Ptime = &nowTime
|
||||
orderInfo.PayedAmount = &orderPayedAmount
|
||||
orderModelT := gmodel.NewFsOrderModel(connGorm)
|
||||
err = orderModelT.RBUpdate(ctx, orderInfo)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
return err
|
||||
})
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
// // 更新订单信息
|
||||
// orderInfo.Id = fsOrderRelInfo.Id
|
||||
// orderInfo.Status = &orderStatus
|
||||
// orderInfo.Ptime = &nowTime
|
||||
// orderInfo.PayedAmount = &orderPayedAmount
|
||||
// orderModelT := gmodel.NewFsOrderModel(connGorm)
|
||||
// err = orderModelT.RBUpdate(ctx, orderInfo)
|
||||
// if err != nil {
|
||||
// return err
|
||||
// }
|
||||
// return err
|
||||
// })
|
||||
// if err != nil {
|
||||
// return err
|
||||
// }
|
||||
|
||||
//千人千面的处理
|
||||
// $renderServer = (new RenderService());
|
||||
// $renderServer->thousandsFacesV2($order->id);
|
||||
// //清除用户最新的设计
|
||||
// $cache = \Yii::$app->cache;
|
||||
// $cache->delete(CacheConfigHelper::LAST_DESIGN . $order->user_id);
|
||||
// //缓存最新订单编号
|
||||
// $cache->set(CacheConfigHelper::USER_ORDERNO . $order->user_id, $order->sn);
|
||||
// //千人千面的处理
|
||||
// // $renderServer = (new RenderService());
|
||||
// // $renderServer->thousandsFacesV2($order->id);
|
||||
// // //清除用户最新的设计
|
||||
// // $cache = \Yii::$app->cache;
|
||||
// // $cache->delete(CacheConfigHelper::LAST_DESIGN . $order->user_id);
|
||||
// // //缓存最新订单编号
|
||||
// // $cache->set(CacheConfigHelper::USER_ORDERNO . $order->user_id, $order->sn);
|
||||
|
||||
// //查询用户邮箱信息
|
||||
// $user = \api\models\User::find()->where(['id' => $order->user_id])->one();
|
||||
// $redisData = [
|
||||
// 'key' => 'receipt_download',
|
||||
// 'param' => [
|
||||
// 'email' => $user->email,
|
||||
// 'order_id' => $order->id,
|
||||
// 'pay_id' => $pay->id,
|
||||
// 'type' => 1,//付款成功为1
|
||||
// ]
|
||||
// ];
|
||||
// Email::timely($redisData);
|
||||
}
|
||||
// // //查询用户邮箱信息
|
||||
// // $user = \api\models\User::find()->where(['id' => $order->user_id])->one();
|
||||
// // $redisData = [
|
||||
// // 'key' => 'receipt_download',
|
||||
// // 'param' => [
|
||||
// // 'email' => $user->email,
|
||||
// // 'order_id' => $order->id,
|
||||
// // 'pay_id' => $pay->id,
|
||||
// // 'type' => 1,//付款成功为1
|
||||
// // ]
|
||||
// // ];
|
||||
// // Email::timely($redisData);
|
||||
// }
|
||||
|
||||
// 订单记录
|
||||
return nil
|
||||
|
|
|
@ -6,6 +6,7 @@ import (
|
|||
"net/http"
|
||||
|
||||
"fusenapi/utils/auth"
|
||||
"fusenapi/utils/fsconfig"
|
||||
|
||||
"fusenapi/server/pay/internal/config"
|
||||
"fusenapi/server/pay/internal/handler"
|
||||
|
@ -20,8 +21,10 @@ var configFile = flag.String("f", "etc/pay.yaml", "the config file")
|
|||
func main() {
|
||||
flag.Parse()
|
||||
|
||||
cfgContent := fsconfig.StartNacosConfig(*configFile, nil)
|
||||
var c config.Config
|
||||
conf.MustLoad(*configFile, &c)
|
||||
conf.LoadConfigFromYamlBytes([]byte(cfgContent), &c)
|
||||
|
||||
server := rest.MustNewServer(c.RestConf, rest.WithCustomCors(auth.FsCors, func(w http.ResponseWriter) {
|
||||
}))
|
||||
defer server.Stop()
|
||||
|
|
1
server/product-model/.gitignore
vendored
Normal file
1
server/product-model/.gitignore
vendored
Normal file
|
@ -0,0 +1 @@
|
|||
product-model
|
|
@ -9,6 +9,7 @@ import (
|
|||
"fusenapi/server/product-model/internal/handler"
|
||||
"fusenapi/server/product-model/internal/svc"
|
||||
"fusenapi/utils/auth"
|
||||
"fusenapi/utils/fsconfig"
|
||||
|
||||
"github.com/zeromicro/go-zero/core/conf"
|
||||
"github.com/zeromicro/go-zero/rest"
|
||||
|
@ -19,8 +20,9 @@ var configFile = flag.String("f", "etc/product-model.yaml", "the config file")
|
|||
func main() {
|
||||
flag.Parse()
|
||||
|
||||
cfgContent := fsconfig.StartNacosConfig(*configFile, nil)
|
||||
var c config.Config
|
||||
conf.MustLoad(*configFile, &c)
|
||||
conf.LoadConfigFromYamlBytes([]byte(cfgContent), &c)
|
||||
|
||||
server := rest.MustNewServer(c.RestConf, rest.WithCustomCors(auth.FsCors, func(w http.ResponseWriter) {
|
||||
|
||||
|
|
1
server/product-template-tag/.gitignore
vendored
Normal file
1
server/product-template-tag/.gitignore
vendored
Normal file
|
@ -0,0 +1 @@
|
|||
product-template-tag
|
|
@ -36,6 +36,16 @@ func NewGetProductTemplateTagsLogic(ctx context.Context, svcCtx *svc.ServiceCont
|
|||
// func (l *GetProductTemplateTagsLogic) AfterLogic(w http.ResponseWriter, r *http.Request, resp *basic.Response) {
|
||||
// // httpx.OkJsonCtx(r.Context(), w, resp)
|
||||
// }
|
||||
type logoSelect struct {
|
||||
LogoSelected struct {
|
||||
LogoSelectedId int `json:"logo_selected_id"`
|
||||
TemplateTagSelected struct {
|
||||
TemplateTag string `json:"template_tag"`
|
||||
Color [][]string `json:"color"`
|
||||
SelectedIndex int `json:"selected_index"`
|
||||
} `json:"template_tag_selected"`
|
||||
} `json:"logo_selected"`
|
||||
}
|
||||
|
||||
func (l *GetProductTemplateTagsLogic) GetProductTemplateTags(req *types.GetProductTemplateTagsReq, userinfo *auth.UserInfo) (resp *basic.Response) {
|
||||
if req.Limit <= 0 || req.Limit > 100 {
|
||||
|
@ -55,31 +65,44 @@ func (l *GetProductTemplateTagsLogic) GetProductTemplateTags(req *types.GetProdu
|
|||
return
|
||||
}
|
||||
if logoInfo.Metadata == nil || *logoInfo.Metadata == "" {
|
||||
// 返回固定模板A1a
|
||||
productTemplateTags, err = l.svcCtx.AllModels.FsProductTemplateTags.GetListByTagNames(l.ctx, []string{"A1"}, req.Limit, 1, "`id` DESC")
|
||||
if err != nil {
|
||||
return resp.SetStatusWithMessage(basic.CodeDbSqlErr, "logo info`s metadata is not set")
|
||||
}
|
||||
//解析用户素材元数据
|
||||
var metaData map[string]interface{}
|
||||
if err = json.Unmarshal([]byte(*logoInfo.Metadata), &metaData); err != nil {
|
||||
logx.Error(err)
|
||||
return resp.SetStatusWithMessage(basic.CodeJsonErr, "failed to parse user metadata")
|
||||
}
|
||||
var mapTemplateTag map[string][][]string
|
||||
b, _ := json.Marshal(metaData["template_tag"])
|
||||
if err = json.Unmarshal(b, &mapTemplateTag); err != nil {
|
||||
logx.Error(err)
|
||||
return resp.SetStatusWithMessage(basic.CodeJsonErr, "invalid format of metadata`s template_tag")
|
||||
}
|
||||
//从用户元数据获取选中的颜色数据
|
||||
mapSelectColor := make(map[string]int) //key是模板标签val是选中的索引
|
||||
if logoInfo.UserInfoMetadata != nil && *logoInfo.UserInfoMetadata != "" {
|
||||
//解析用户信息元数据
|
||||
var logoSelectInfo logoSelect
|
||||
if err = json.Unmarshal([]byte(*logoInfo.UserInfoMetadata), &logoSelectInfo); err != nil {
|
||||
logx.Error(err)
|
||||
return resp.SetStatusWithMessage(basic.CodeDbSqlErr, "failed to get template tags")
|
||||
return resp.SetStatusWithMessage(basic.CodeJsonErr, "failed to parse user info metadata")
|
||||
}
|
||||
} else {
|
||||
//解析元数据
|
||||
var metaData map[string]interface{}
|
||||
if err = json.Unmarshal([]byte(*logoInfo.Metadata), &metaData); err != nil {
|
||||
logx.Error(err)
|
||||
return resp.SetStatusWithMessage(basic.CodeJsonErr, "failed to parse user metadata")
|
||||
}
|
||||
var templateTagNameList []string
|
||||
b, _ := json.Marshal(metaData["template_tagid"])
|
||||
if err = json.Unmarshal(b, &templateTagNameList); err != nil {
|
||||
logx.Error(err)
|
||||
return resp.SetStatusWithMessage(basic.CodeJsonErr, "invalid format of metadata`s template_tagid")
|
||||
}
|
||||
productTemplateTags, err = l.svcCtx.AllModels.FsProductTemplateTags.GetListByTagNames(l.ctx, templateTagNameList, req.Limit, 1, "id DESC")
|
||||
if err != nil {
|
||||
logx.Error(err)
|
||||
return resp.SetStatusWithMessage(basic.CodeDbSqlErr, "failed to get template tags")
|
||||
//设置选中
|
||||
key := logoSelectInfo.LogoSelected.TemplateTagSelected.TemplateTag
|
||||
if _, ok := mapTemplateTag[key]; ok {
|
||||
mapSelectColor[key] = logoSelectInfo.LogoSelected.TemplateTagSelected.SelectedIndex
|
||||
}
|
||||
}
|
||||
var templateTagNameList []string
|
||||
for templateTag, _ := range mapTemplateTag {
|
||||
templateTagNameList = append(templateTagNameList, templateTag)
|
||||
}
|
||||
productTemplateTags, err = l.svcCtx.AllModels.FsProductTemplateTags.GetListByTagNames(l.ctx, templateTagNameList, req.Limit, 1, "id DESC")
|
||||
if err != nil {
|
||||
logx.Error(err)
|
||||
return resp.SetStatusWithMessage(basic.CodeDbSqlErr, "failed to get template tags")
|
||||
}
|
||||
//资源id集合
|
||||
resourceIds := make([]string, 0, 5)
|
||||
for _, v := range productTemplateTags {
|
||||
|
@ -100,12 +123,27 @@ func (l *GetProductTemplateTagsLogic) GetProductTemplateTags(req *types.GetProdu
|
|||
mapResourceMetadata[*v.ResourceUrl] = metadata
|
||||
}
|
||||
list := make([]types.GetProductTemplateTagsRsp, 0, len(productTemplateTags))
|
||||
for _, v := range productTemplateTags {
|
||||
for _, templateInfo := range productTemplateTags {
|
||||
colors := make([]types.ColorsItem, 0, 10)
|
||||
SelectedColorIndex := 0
|
||||
isDefaultTemplateTag := false
|
||||
for _, colorsSet := range mapTemplateTag[*templateInfo.TemplateTag] {
|
||||
if selectIndex, ok := mapSelectColor[*templateInfo.TemplateTag]; ok {
|
||||
isDefaultTemplateTag = true
|
||||
SelectedColorIndex = selectIndex
|
||||
}
|
||||
colors = append(colors, types.ColorsItem{
|
||||
Color: colorsSet,
|
||||
})
|
||||
}
|
||||
list = append(list, types.GetProductTemplateTagsRsp{
|
||||
Id: v.Id,
|
||||
TemplateTag: *v.TemplateTag,
|
||||
Cover: *v.Cover,
|
||||
CoverMetadata: mapResourceMetadata[*v.Cover],
|
||||
Id: templateInfo.Id,
|
||||
TemplateTag: *templateInfo.TemplateTag,
|
||||
IsDefaultTemplateTag: isDefaultTemplateTag,
|
||||
Cover: *templateInfo.Cover,
|
||||
CoverMetadata: mapResourceMetadata[*templateInfo.Cover],
|
||||
Colors: colors,
|
||||
SelectedColorIndex: SelectedColorIndex,
|
||||
})
|
||||
}
|
||||
return resp.SetStatusWithMessage(basic.CodeOK, "success", list)
|
||||
|
|
|
@ -10,10 +10,17 @@ type GetProductTemplateTagsReq struct {
|
|||
}
|
||||
|
||||
type GetProductTemplateTagsRsp struct {
|
||||
Id int64 `json:"id"`
|
||||
TemplateTag string `json:"template_tag"`
|
||||
Cover string `json:"cover"`
|
||||
CoverMetadata interface{} `json:"cover_metadata"`
|
||||
Id int64 `json:"id"`
|
||||
TemplateTag string `json:"template_tag"`
|
||||
IsDefaultTemplateTag bool `json:"is_default_template_tag"`
|
||||
Cover string `json:"cover"`
|
||||
CoverMetadata interface{} `json:"cover_metadata"`
|
||||
Colors []ColorsItem `json:"colors"`
|
||||
SelectedColorIndex int `json:"selected_color_index"`
|
||||
}
|
||||
|
||||
type ColorsItem struct {
|
||||
Color []string `json:"color"`
|
||||
}
|
||||
|
||||
type Request struct {
|
||||
|
@ -39,10 +46,10 @@ type File struct {
|
|||
}
|
||||
|
||||
type Meta struct {
|
||||
TotalCount int64 `json:"totalCount"`
|
||||
PageCount int64 `json:"pageCount"`
|
||||
CurrentPage int `json:"currentPage"`
|
||||
PerPage int `json:"perPage"`
|
||||
TotalCount int64 `json:"total_count"`
|
||||
PageCount int64 `json:"page_count"`
|
||||
CurrentPage int `json:"current_page"`
|
||||
PerPage int `json:"per_page"`
|
||||
}
|
||||
|
||||
// Set 设置Response的Code和Message值
|
||||
|
|
|
@ -6,6 +6,7 @@ import (
|
|||
"net/http"
|
||||
|
||||
"fusenapi/utils/auth"
|
||||
"fusenapi/utils/fsconfig"
|
||||
|
||||
"fusenapi/server/product-template-tag/internal/config"
|
||||
"fusenapi/server/product-template-tag/internal/handler"
|
||||
|
@ -20,8 +21,10 @@ var configFile = flag.String("f", "etc/product-template-tag.yaml", "the config f
|
|||
func main() {
|
||||
flag.Parse()
|
||||
|
||||
cfgContent := fsconfig.StartNacosConfig(*configFile, nil)
|
||||
var c config.Config
|
||||
conf.MustLoad(*configFile, &c)
|
||||
conf.LoadConfigFromYamlBytes([]byte(cfgContent), &c)
|
||||
|
||||
server := rest.MustNewServer(c.RestConf, rest.WithCustomCors(auth.FsCors, func(w http.ResponseWriter) {
|
||||
}))
|
||||
defer server.Stop()
|
||||
|
|
1
server/product-template/.gitignore
vendored
Normal file
1
server/product-template/.gitignore
vendored
Normal file
|
@ -0,0 +1 @@
|
|||
product-template
|
|
@ -9,6 +9,7 @@ import (
|
|||
"fusenapi/server/product-template/internal/handler"
|
||||
"fusenapi/server/product-template/internal/svc"
|
||||
"fusenapi/utils/auth"
|
||||
"fusenapi/utils/fsconfig"
|
||||
|
||||
"github.com/zeromicro/go-zero/core/conf"
|
||||
"github.com/zeromicro/go-zero/rest"
|
||||
|
@ -19,8 +20,9 @@ var configFile = flag.String("f", "etc/product-template.yaml", "the config file"
|
|||
func main() {
|
||||
flag.Parse()
|
||||
|
||||
cfgContent := fsconfig.StartNacosConfig(*configFile, nil)
|
||||
var c config.Config
|
||||
conf.MustLoad(*configFile, &c)
|
||||
conf.LoadConfigFromYamlBytes([]byte(cfgContent), &c)
|
||||
|
||||
server := rest.MustNewServer(c.RestConf, rest.WithCustomCors(auth.FsCors, func(w http.ResponseWriter) {
|
||||
|
||||
|
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue
Block a user