修改
This commit is contained in:
parent
d6dd566524
commit
7ecadf2721
40
go.mod
40
go.mod
@ -2,29 +2,22 @@ module fonchain-fiee
|
||||
|
||||
go 1.18
|
||||
|
||||
replace (
|
||||
//github.com/fonchain_enterprise/utils/aes => ./docs/utils/aes
|
||||
//github.com/fonchain_enterprise/utils/chain => ./docs/utils/chain
|
||||
//github.com/fonchain_enterprise/utils/jwt => ./docs/utils/jwt
|
||||
//github.com/fonchain_enterprise/utils/logger => ./docs/utils/logger
|
||||
//github.com/fonchain_enterprise/utils/rand => ./docs/utils/rand
|
||||
//github.com/fonchain_enterprise/utils/aes => ./docs/utils/aes
|
||||
//github.com/fonchain_enterprise/utils/chain => ./docs/utils/chain
|
||||
//github.com/fonchain_enterprise/utils/jwt => ./docs/utils/jwt
|
||||
//github.com/fonchain_enterprise/utils/logger => ./docs/utils/logger
|
||||
//github.com/fonchain_enterprise/utils/rand => ./docs/utils/rand
|
||||
|
||||
//github.com/fonchain/electronic-contract => ../../electronic-contract
|
||||
//github.com/fonchain_enterprise/utils/aes => ../utils/aes
|
||||
//github.com/fonchain_enterprise/utils/baidu => ../utils/baidu
|
||||
//github.com/fonchain_enterprise/utils/bankQuery => ../utils/bankQuery
|
||||
//github.com/fonchain_enterprise/utils/chain => ../utils/chain
|
||||
//github.com/fonchain_enterprise/utils/feie => ../utils/feie
|
||||
//github.com/fonchain_enterprise/utils/ipAddrQuery => ../utils/ipAddrQuery
|
||||
//github.com/fonchain_enterprise/utils/jwt => ../utils/jwt
|
||||
//github.com/fonchain_enterprise/utils/logger => ../utils/logger
|
||||
github.com/fonchain_enterprise/utils/objstorage => ../utils/objstorage
|
||||
//github.com/fonchain_enterprise/utils/ocr => ../utils/ocr
|
||||
//github.com/fonchain_enterprise/utils/pay => ../utils/pay
|
||||
//github.com/fonchain_enterprise/utils/rand => ../utils/rand
|
||||
//github.com/fonchain_enterprise/utils/utils => ../utils/utils
|
||||
|
||||
)
|
||||
//github.com/fonchain/electronic-contract => ../../electronic-contract
|
||||
//github.com/fonchain_enterprise/utils/aes => ../utils/aes
|
||||
//github.com/fonchain_enterprise/utils/baidu => ../utils/baidu
|
||||
//github.com/fonchain_enterprise/utils/bankQuery => ../utils/bankQuery
|
||||
//github.com/fonchain_enterprise/utils/chain => ../utils/chain
|
||||
//github.com/fonchain_enterprise/utils/feie => ../utils/feie
|
||||
//github.com/fonchain_enterprise/utils/ipAddrQuery => ../utils/ipAddrQuery
|
||||
//github.com/fonchain_enterprise/utils/jwt => ../utils/jwt
|
||||
//github.com/fonchain_enterprise/utils/logger => ../utils/logger
|
||||
replace github.com/fonchain_enterprise/utils/objstorage => ../../tyfon-新/utils/objstorage
|
||||
|
||||
require (
|
||||
dubbo.apache.org/dubbo-go/v3 v3.0.2
|
||||
@ -120,6 +113,7 @@ require (
|
||||
github.com/gin-contrib/pprof v1.4.0
|
||||
github.com/go-redis/redis v6.15.9+incompatible
|
||||
github.com/rwcarlsen/goexif v0.0.0-20190401172101-9e8deecbddbd
|
||||
github.com/signintech/gopdf v0.29.2
|
||||
github.com/skip2/go-qrcode v0.0.0-20200617195104-da1b6568686e
|
||||
github.com/spf13/viper v1.7.1
|
||||
github.com/u2takey/ffmpeg-go v0.5.0
|
||||
@ -173,7 +167,6 @@ require (
|
||||
github.com/pierrec/lz4 v2.5.2+incompatible // indirect
|
||||
github.com/polarismesh/polaris-go v1.1.0 // indirect
|
||||
github.com/shirou/gopsutil/v3 v3.21.6 // indirect
|
||||
github.com/signintech/gopdf v0.29.2 // indirect
|
||||
github.com/sirupsen/logrus v1.9.0 // indirect
|
||||
github.com/smartystreets/assertions v1.1.1 // indirect
|
||||
github.com/spaolacci/murmur3 v1.1.0 // indirect
|
||||
@ -182,7 +175,6 @@ require (
|
||||
github.com/spf13/jwalterweatherman v1.0.0 // indirect
|
||||
github.com/spf13/pflag v1.0.5 // indirect
|
||||
github.com/subosito/gotenv v1.2.0 // indirect
|
||||
github.com/tealeg/xlsx v1.0.5 // indirect
|
||||
github.com/tklauser/go-sysconf v0.3.6 // indirect
|
||||
github.com/tklauser/numcpus v0.2.2 // indirect
|
||||
github.com/twitchyliquid64/golang-asm v0.15.1 // indirect
|
||||
|
2
go.sum
2
go.sum
@ -826,8 +826,6 @@ github.com/stretchr/testify v1.8.3 h1:RP3t2pwF7cMEbC1dqtB6poj3niw/9gnV4Cjg5oW5gt
|
||||
github.com/stretchr/testify v1.8.3/go.mod h1:sz/lmYIOXD/1dqDmKjjqLyZ2RngseejIcXlSw2iwfAo=
|
||||
github.com/subosito/gotenv v1.2.0 h1:Slr1R9HxAlEKefgq5jn9U+DnETlIUa6HfgEzj0g5d7s=
|
||||
github.com/subosito/gotenv v1.2.0/go.mod h1:N0PQaV/YGNqwC0u51sEeR/aUtSLEXKX9iv69rRypqCw=
|
||||
github.com/tealeg/xlsx v1.0.5 h1:+f8oFmvY8Gw1iUXzPk+kz+4GpbDZPK1FhPiQRd+ypgE=
|
||||
github.com/tealeg/xlsx v1.0.5/go.mod h1:btRS8dz54TDnvKNosuAqxrM1QgN1udgk9O34bDCnORM=
|
||||
github.com/tebeka/strftime v0.1.3/go.mod h1:7wJm3dZlpr4l/oVK0t1HYIc4rMzQ2XJlOMIUJUJH6XQ=
|
||||
github.com/tevid/gohamcrest v1.1.1 h1:ou+xSqlIw1xfGTg1uq1nif/htZ2S3EzRqLm2BP+tYU0=
|
||||
github.com/tevid/gohamcrest v1.1.1/go.mod h1:3UvtWlqm8j5JbwYZh80D/PVBt0mJ1eJiYgZMibh0H/k=
|
||||
|
@ -7,6 +7,7 @@ import (
|
||||
"fonchain-fiee/pkg/model/login"
|
||||
"fonchain-fiee/pkg/service"
|
||||
"fonchain-fiee/pkg/service/bundle/common"
|
||||
"fonchain-fiee/pkg/service/bundle/logic"
|
||||
bundleModel "fonchain-fiee/pkg/service/bundle/model"
|
||||
"github.com/gin-gonic/gin"
|
||||
"github.com/gin-gonic/gin/binding"
|
||||
@ -53,7 +54,13 @@ func CreateBundleOrderSignature(c *gin.Context) {
|
||||
req.AmountType = bundleDetail.Bundle.PriceType
|
||||
|
||||
// 当前 未将 签名 写入合同中
|
||||
req.SignContract = bundleDetail.Bundle.Contract
|
||||
signContract, signContractErr := logic.SignContract(req.CustomerName, bundleDetail.Bundle.Contract, req.Signature)
|
||||
if signContractErr != nil {
|
||||
service.Error(c, signContractErr)
|
||||
return
|
||||
}
|
||||
|
||||
req.SignContract = signContract
|
||||
|
||||
req.SignedTime = common.GetBeijingTime()
|
||||
|
||||
|
@ -4,6 +4,7 @@ package common
|
||||
const (
|
||||
MissBundleUUID = "缺少套餐UUID"
|
||||
MissOrderSignature = "缺少客户签名信息"
|
||||
ErrorInsertSignature = "插入签名失败"
|
||||
)
|
||||
|
||||
// 订单
|
||||
@ -20,3 +21,8 @@ const (
|
||||
const (
|
||||
ErrorQueryStripeInfo = "查询支付信息失败"
|
||||
)
|
||||
|
||||
const (
|
||||
ErrorDownloadFile = "下载文件失败"
|
||||
ErrorUploadFile = "上传文件失败"
|
||||
)
|
||||
|
@ -4,15 +4,46 @@ import (
|
||||
"bytes"
|
||||
"errors"
|
||||
"fmt"
|
||||
"fonchain-fiee/pkg/service/bundle/common"
|
||||
"fonchain-fiee/pkg/service/upload"
|
||||
"github.com/signintech/gopdf"
|
||||
"go.uber.org/zap"
|
||||
"image"
|
||||
"io"
|
||||
"log"
|
||||
"net/http"
|
||||
"os"
|
||||
"time"
|
||||
)
|
||||
|
||||
// 把用户签字内容 填充到 合同模版里面
|
||||
func insertSignature(templatePath string, outputPath string, signImgPath string) error {
|
||||
func SignContract(customerName string, contract string, signImgPath string) (outputUrl string, err error) {
|
||||
filePath := customerName + "_" + time.Now().String() + ".pdf"
|
||||
downloadFileErr := DownloadFile(filePath, contract)
|
||||
if downloadFileErr != nil {
|
||||
zap.L().Error("download file error: ", zap.Error(downloadFileErr))
|
||||
//service.Error(c, errors.New(common.ErrorDownloadFile))
|
||||
return outputUrl, errors.New(common.ErrorDownloadFile)
|
||||
}
|
||||
|
||||
signFile := customerName + "signed" + "_" + time.Now().String() + ".pdf"
|
||||
|
||||
signErr := InsertSignature(filePath, signFile, signImgPath)
|
||||
if signErr != nil {
|
||||
zap.L().Error("insert signature error: ", zap.Error(signErr))
|
||||
return outputUrl, errors.New(common.ErrorInsertSignature)
|
||||
}
|
||||
|
||||
os.Remove(filePath)
|
||||
|
||||
outputUrl, ossErr := upload.PutBos(signFile, upload.PdfType, true)
|
||||
if ossErr != nil {
|
||||
return "", errors.New(common.ErrorUploadFile)
|
||||
}
|
||||
return outputUrl, nil
|
||||
}
|
||||
|
||||
// InsertSignature 把用户签字内容 填充到 合同模版里面
|
||||
func InsertSignature(templatePath string, outputPath string, signImgPath string) error {
|
||||
pdf := gopdf.GoPdf{}
|
||||
pdf.Start(gopdf.Config{PageSize: *gopdf.PageSizeA4})
|
||||
|
||||
@ -79,3 +110,20 @@ func insertSignature(templatePath string, outputPath string, signImgPath string)
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func DownloadFile(filepath string, url string) error {
|
||||
resp, err := http.Get(url)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
defer resp.Body.Close()
|
||||
|
||||
out, err := os.Create(filepath)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
defer out.Close()
|
||||
|
||||
_, err = io.Copy(out, resp.Body)
|
||||
return err
|
||||
}
|
||||
|
@ -36,6 +36,7 @@ const (
|
||||
VideoType = "video"
|
||||
ImageType = "image"
|
||||
PngType = "png"
|
||||
PdfType = "pdf"
|
||||
ArtworkFilePath = "artwork"
|
||||
ArtworkChunkBasePath = "./runtime/tmp/artworks"
|
||||
)
|
||||
|
Loading…
Reference in New Issue
Block a user