elf 5 months ago
parent 3441b272ec
commit d4aa8eb337

@ -1,8 +1,12 @@
package h5
import (
"encoding/json"
"github.com/gin-gonic/gin"
"insure/errors"
"insure/e"
"insure/global"
"insure/service"
"insure/third_party/signer"
"insure/utils/result"
)
@ -11,5 +15,50 @@ func Index(c *gin.Context) (result.Data, error) {
}
func Error(c *gin.Context) (result.Data, error) {
return nil, errors.NewBusinessError("测试", "1122")
return nil, e.NewError("测试", "1122")
}
func GetOrder(c *gin.Context) (result.Data, error) {
token := c.DefaultQuery("token", "")
if token == "" {
return nil, e.NewError("缺少参数")
}
order, err := service.OrderService.GetOrderByToken(token)
if err != nil {
return nil, err
}
return result.Data{"order": order}, nil
}
func GetSignUrl(c *gin.Context) (result.Data, error) {
token := c.DefaultQuery("token", "")
if token == "" {
return nil, e.NewError("缺少参数")
}
order, err := service.OrderService.GetOrderByToken(token)
if err != nil {
return nil, err
}
params := map[string]interface{}{
"token": token,
}
paramsStr, err := json.Marshal(params)
if err != nil {
return nil, err
}
param := signer.SignParam{}
param.Url = order.Applicant.SignUrl
param.UploadUrl = global.Config.Server.Domain + "/suixing/upload-signed-file"
param.IsView = "0"
param.IsAutoClose = "0"
param.IsEdit = "1"
param.IsUploadPdf = "1"
param.Params = string(paramsStr)
signUrl, err := signer.SignerApi.GetSignUrl(param)
if err != nil {
return nil, err
}
return result.Data{"signUrl": signUrl}, nil
}

@ -0,0 +1,132 @@
package suixing
import (
"encoding/json"
"fmt"
"github.com/gin-gonic/gin"
"insure/global"
"insure/model"
"insure/service"
"insure/third_party/signer"
"insure/third_party/suixing"
"insure/utils"
"net/http"
"strconv"
"strings"
"time"
)
func Create(c *gin.Context) {
data := map[string]interface{}{}
result := map[string]interface{}{
"code": 200,
"msg": "成功",
"data": data,
}
var param suixing.CommonParam
err := c.ShouldBindJSON(&param)
if err != nil {
result["code"] = 201
result["msg"] = "参数异常"
c.JSON(200, result)
return
}
fmt.Println(param)
if !suixing.SuixingApi.Verify(param) {
result["code"] = 301
result["msg"] = "验签失败"
c.JSON(200, result)
return
}
order, err := service.OrderService.CreateOrder(param)
if err != nil {
result["code"] = 202
result["msg"] = err.Error()
c.JSON(200, result)
return
}
data["order_sn"] = order.OrderSn
data["url"] = global.Config.Server.Domain + "/pages/order?token" + order.Token
result["data"] = data
c.JSON(200, result)
return
}
func UploadSignedFile(c *gin.Context) {
data := map[string]interface{}{}
result := map[string]interface{}{
"code": 200,
"msg": "成功",
"data": data,
}
param := signer.UploadParam{}
err := c.ShouldBind(&param)
if err != nil {
result["code"] = 201
result["msg"] = "参数异常"
c.JSON(200, result)
return
}
fmt.Println(param)
params := map[string]interface{}{}
err = json.Unmarshal([]byte(param.Params), &params)
if err != nil {
result["code"] = 201
result["msg"] = "params解析异常"
c.JSON(200, result)
return
}
token := params["token"].(string)
order, err := service.OrderService.GetOrderByToken(token)
if err != nil {
result["code"] = 201
result["msg"] = err.Error()
c.JSON(200, result)
return
}
file, err := c.FormFile("pdf")
if err != nil {
result["code"] = 201
result["msg"] = "文件上传失败"
c.JSON(200, result)
return
}
reader, err := file.Open()
if err != nil {
result["code"] = 201
result["msg"] = "文件打开失败:" + err.Error()
c.JSON(200, result)
return
}
b := make([]byte, 512)
reader.Read(b)
contentType := http.DetectContentType(b)
if contentType != "application/pdf" && contentType != "application/zip" {
result["code"] = 201
result["msg"] = "文件格式错误:" + contentType
c.JSON(200, result)
return
}
fileNameItems := strings.Split(file.Filename, ".")
filePath := time.Now().Format("20060102") + "/" + utils.Md5(file.Filename+strconv.Itoa(int(time.Now().UnixMicro()))+utils.GenerateRandomString(10)) + "." + fileNameItems[len(fileNameItems)-1]
dest := "./static/uploads/" + filePath
err = c.SaveUploadedFile(file, dest)
if err != nil {
result["code"] = 201
result["msg"] = "文件保存失败:" + err.Error()
c.JSON(200, result)
return
}
signFileUrl := global.Config.Server.Domain + "/uploads/" + filePath
global.DB.Model(&model.Applicant{}).Where("order_sn", order.OrderSn).UpdateColumn("sign_url", signFileUrl)
service.OrderService.AddSignLog(order.OrderSn, param)
c.JSON(200, result)
return
}

@ -17,7 +17,7 @@ func main() {
func initial() {
var configFilePath string
flag.StringVar(&configFilePath, "config", "./config.yaml", "配置文件")
flag.StringVar(&configFilePath, "config", "./conf/config.yaml", "配置文件")
flag.Parse()
global.Config = initialize.InitConfig(configFilePath)
global.DB = initialize.InitDB(global.Config)

@ -1,6 +1,6 @@
server:
port: 9090
domain: "http://pay.hexidongkeji.top"
domain: "http://localhost:9090"
alipay:
app-id: "2021004129619376"
private-key: "MIIEvwIBADANBgkqhkiG9w0BAQEFAASCBKkwggSlAgEAAoIBAQChC/5Psy+biyzdT/CkCknQKax44Ol0i6kAWVkw4BYERevISFqOHpVmlztcnYGx3LIDOeReYQ0ghLLT+6oGrymXzPbIOE+PTUEpPfIRdB8P96mkcbuZ7MnMCsA1vXSjYezVIAu8vdzp4FL2H1p3+gwhuLGT5w9tOUZmNAkKI8xEQwXeFDWlQ5G9w5unigEGnlODqxcStrvL14pceqsA3bm9sEDuSqVAmBXbEZxZyWnYoRJj4kNMqYIXLXwsPzE8268B+0NT9plzv8mGBI2jkwBTXvc1TjnAIK6O0vRfAz82Jz6RhMwIIOrA65F1oO44bihd/4lH+FjrMy5nYeEuBZeZAgMBAAECggEBAJ/EPi7jHL+6em+z9o9GhaO1NB1XQ0MTqj1mZk1OgYkLtLWk0fFb9eso7QMcXqYMw6zfqebXcSZpft8+M5cd/q1R8SEAfC01/wbjJVqbUJWOpQU2r14swqVhpP2rTiMn6sQkXoCH+rkqiiMRR7buoUpy5/hKqcs5ntWVmcItcV/lZ/SOshXIY1Pff9WcJkNUQqtM8OizjSA1htc3XencsOroU6KKLnVdBcGYQJQtr7hBQshgGiaNKapv6n/qGV6J6V7uBuSfwZhNXo0GxbBqZHW3LCesipPkNAvYCu+DhpqVr+j44apGhZ56cIhqdYCrnPrMKysvYHnQ7sm3GhwnimECgYEA5WeTVLkRj7gmcWQQn7KobUxfdQXZguJdVYguTwbWENbZRTDxlv3aZvivAMDx9xDfEd58/xqm5mUathxG8M/HINJ9u32elhFLXLHPD5QzCqv4+X+dZmtnnqEHa5smSEpFL2vJ7v8FGnrAqXiZVye7uqcT7j/6hCZol+EZ1SPz6g8CgYEAs7emjtDwKyzyO1kRQfTB/smlS/hfIvknZZKQoYYRgiB60f2t6aDJOzjUMCIgClWpQztDzbKonKx1ykCmiSgtUJF9MVP4iz5cJKc0wdnjO20DxFJGMHl89ejlfrfmM5D1E0d2l7kpO6M/66mjNT7fGtAdorAw8OzKbZh/KCfsq9cCgYEApWEL95ILtP5eyHQI//f+L/1U+7oh2pdyDc1FBTe6bx1UOOtV3zJWltFE6Fgwl5qUFf+9QPNnysSsgwjTo5tGxMS6W8Xt4+XH3KVazrJaMaFUthln0YQwiU0xWkPZT1grlEoyo5c5iKNh7UrB0PEWBzOXzLRW15oQ4R0oUF3A48UCgYARV4Nm/JpwUCH/wBR+PNQLdgHRVuI3SbuXfZEfRQSjfebcJJKHnNBOOqmfC2v0E1gF+M4OJ1NF6w5iueJYEdxtjdx6yhONvDLABrJ8kj3vGhHm+9lyDAcW46Zhl/VKvI4pkhfLhD6KVrJwVyo8lRiKSdLSRBY06WSPNsvuYAvieQKBgQDk52HC2XLdui/wMnESIJ/+qwuKh/BAC7e/jEuZpQxRFVbE8L2m638f+tkXdHlMERqaROd2h31cPpvZzOyeJBvhUEmuQcBfq+G4YsRQIH0XDvx/nBO4m03nFOXyLkFx4X1fZs/0i3CO506WHdgkM5wd8nA6+9S4DdNAjHvoC4WQ3A=="
@ -10,7 +10,7 @@ database:
port: "3306"
username: "elf1990"
password: "XtN1YiaqP4BxC9MEe"
dbname: "gold-shop"
dbname: "insure"
redis:
host: "127.0.0.1"
port: "6379"
@ -19,3 +19,11 @@ redis:
jwt:
key: "I2js2oElEo82NmRru8v73Nwm"
issuer: "gold-shop"
zking:
base-url: "https://test-open.zking.com"
app-id: ""
app-secret: ""
suixing:
base-url: "https://test-open.zking.com"
app-id: ""
app-secret: ""

@ -1,43 +0,0 @@
server:
port: 9090
domain: "http://pay.hexidongkeji.top"
alipay:
app-id: "2021004129619376"
private-key: "MIIEvwIBADANBgkqhkiG9w0BAQEFAASCBKkwggSlAgEAAoIBAQChC/5Psy+biyzdT/CkCknQKax44Ol0i6kAWVkw4BYERevISFqOHpVmlztcnYGx3LIDOeReYQ0ghLLT+6oGrymXzPbIOE+PTUEpPfIRdB8P96mkcbuZ7MnMCsA1vXSjYezVIAu8vdzp4FL2H1p3+gwhuLGT5w9tOUZmNAkKI8xEQwXeFDWlQ5G9w5unigEGnlODqxcStrvL14pceqsA3bm9sEDuSqVAmBXbEZxZyWnYoRJj4kNMqYIXLXwsPzE8268B+0NT9plzv8mGBI2jkwBTXvc1TjnAIK6O0vRfAz82Jz6RhMwIIOrA65F1oO44bihd/4lH+FjrMy5nYeEuBZeZAgMBAAECggEBAJ/EPi7jHL+6em+z9o9GhaO1NB1XQ0MTqj1mZk1OgYkLtLWk0fFb9eso7QMcXqYMw6zfqebXcSZpft8+M5cd/q1R8SEAfC01/wbjJVqbUJWOpQU2r14swqVhpP2rTiMn6sQkXoCH+rkqiiMRR7buoUpy5/hKqcs5ntWVmcItcV/lZ/SOshXIY1Pff9WcJkNUQqtM8OizjSA1htc3XencsOroU6KKLnVdBcGYQJQtr7hBQshgGiaNKapv6n/qGV6J6V7uBuSfwZhNXo0GxbBqZHW3LCesipPkNAvYCu+DhpqVr+j44apGhZ56cIhqdYCrnPrMKysvYHnQ7sm3GhwnimECgYEA5WeTVLkRj7gmcWQQn7KobUxfdQXZguJdVYguTwbWENbZRTDxlv3aZvivAMDx9xDfEd58/xqm5mUathxG8M/HINJ9u32elhFLXLHPD5QzCqv4+X+dZmtnnqEHa5smSEpFL2vJ7v8FGnrAqXiZVye7uqcT7j/6hCZol+EZ1SPz6g8CgYEAs7emjtDwKyzyO1kRQfTB/smlS/hfIvknZZKQoYYRgiB60f2t6aDJOzjUMCIgClWpQztDzbKonKx1ykCmiSgtUJF9MVP4iz5cJKc0wdnjO20DxFJGMHl89ejlfrfmM5D1E0d2l7kpO6M/66mjNT7fGtAdorAw8OzKbZh/KCfsq9cCgYEApWEL95ILtP5eyHQI//f+L/1U+7oh2pdyDc1FBTe6bx1UOOtV3zJWltFE6Fgwl5qUFf+9QPNnysSsgwjTo5tGxMS6W8Xt4+XH3KVazrJaMaFUthln0YQwiU0xWkPZT1grlEoyo5c5iKNh7UrB0PEWBzOXzLRW15oQ4R0oUF3A48UCgYARV4Nm/JpwUCH/wBR+PNQLdgHRVuI3SbuXfZEfRQSjfebcJJKHnNBOOqmfC2v0E1gF+M4OJ1NF6w5iueJYEdxtjdx6yhONvDLABrJ8kj3vGhHm+9lyDAcW46Zhl/VKvI4pkhfLhD6KVrJwVyo8lRiKSdLSRBY06WSPNsvuYAvieQKBgQDk52HC2XLdui/wMnESIJ/+qwuKh/BAC7e/jEuZpQxRFVbE8L2m638f+tkXdHlMERqaROd2h31cPpvZzOyeJBvhUEmuQcBfq+G4YsRQIH0XDvx/nBO4m03nFOXyLkFx4X1fZs/0i3CO506WHdgkM5wd8nA6+9S4DdNAjHvoC4WQ3A=="
ali-public-key: "MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAhgLRPY+3aSGRvlcivmcPnSSL9v3BXSea3uDOZpIpzydHxQ16c/A2m6kVh9LxlJJngXldOkO2Q4VS32RufZntc9fkjiiuUxDBlFPKl5x72eiQVoBX4yM7j0gtBlwQFezsIPD0SRC/uxj75+MtjDUupAQLA4gB4zgSDmWWYAIGQlgXXAQExr5k7P1dXrXJMP9SpIYn3Uaug5ifqxanoiDCmMp/sMFasjlVBDIpLOZuKgBwcX3d2FmhRdWIWR5UVy3IbtWuqTJ8vqH8j6Y2jVFLxBA7+woYc0s7npZ0kTa0yGXFw/9LGinSGshGUCBjuAoi67cW6YvODjYFHuGqsrXZvwIDAQAB"
database:
host: "124.223.222.61"
port: "3306"
username: "elf1990"
password: "XtN1YiaqP4BxC9MEe"
dbname: "gold-shop"
redis:
host: "127.0.0.1"
port: "6379"
password: ""
db: 0
payment:
base-url: "http://api2.lfwin.com"
# api-key: "00014005"
# sign-key: "punr8ucu"
api-key: "24114801"
sign-key: "88819264"
wx-pay:
auth-redirect-uri: "http://mall.wrtcjt.com/pages/wx/callback"
sub-app-id: "wx939c26e4e09ce9ee"
sub-app-secret: "0d365a525ec9bf2c055d735ced98a6c1"
ali-pay:
sub-app-id: "wx939c26e4e09ce9ee"
sub-pri-pem-file: ""
tl-pay:
base-url: "https://vsp.allinpay.com"
app-id: "00307595"
cus-id: "6603910521126XB"
pri-pem-file: "./pri.pem"
# base-url: "https://syb-test.allinpay.com"
# app-id: "00000051"
# cus-id: "990581007426001"
# pri-pem-file: "./pri_test.pem"
jwt:
key: "I2js2oElEo82NmRru8v73Nwm"
issuer: "gold-shop"

@ -5,4 +5,6 @@ type Config struct {
Database Database
Jwt Jwt
Redis Redis
Suixing Suixing
Zking Zking
}

@ -0,0 +1,7 @@
package config
type Suixing struct {
BaseUrl string `yaml:"base-url"`
AppID string `yaml:"app-id"`
AppSecret string `yaml:"app-secret"`
}

@ -0,0 +1,7 @@
package config
type Zking struct {
BaseUrl string `yaml:"base-url"`
AppID string `yaml:"app-id"`
AppSecret string `yaml:"app-secret"`
}

@ -1,18 +1,18 @@
package errors
package e
import sysErr "errors"
type BusinessError struct {
type Error struct {
Code string
Message string
}
func (e *BusinessError) Error() string {
func (e *Error) Error() string {
return e.Message
}
func NewBusinessError(message ...string) *BusinessError {
err := &BusinessError{
func NewError(message ...string) *Error {
err := &Error{
"1000",
"业务错误",
}

@ -0,0 +1,122 @@
CREATE TABLE `order` (
`id` int NOT NULL AUTO_INCREMENT COMMENT '主键',
`request_id` varchar(20) NOT NULL DEFAULT '' COMMENT '请求ID',
`order_sn` varchar(20) NOT NULL DEFAULT '' COMMENT '订单编号',
`created_at` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
`updated_at` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '最后更新时间',
PRIMARY KEY (`id`) USING BTREE,
UNIQUE KEY `udx_ordersn` (`order_sn`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='订单表';
CREATE TABLE `user` (
`id` int NOT NULL AUTO_INCREMENT COMMENT '主键',
`order_sn` varchar(20) NOT NULL DEFAULT '' COMMENT '订单编号',
`user_id` varchar(50) NOT NULL DEFAULT '' COMMENT '投保人(当前登录用户)ID',
`mobile` varchar(50) NOT NULL DEFAULT '' COMMENT '投保人(当前登录用户)手机号',
`username` varchar(50) NOT NULL DEFAULT '' COMMENT '投保人(当前登录用户)用户名',
`unitid` varchar(50) NOT NULL DEFAULT '' COMMENT '投保人(当前登录用户)单位ID',
`unitname` varchar(50) NOT NULL DEFAULT '' COMMENT '投保人(当前登录用户)企业名称',
`beiandiqu_code` varchar(50) NOT NULL DEFAULT '' COMMENT '备案地区编码',
`bank_name` varchar(100) NOT NULL DEFAULT '' COMMENT '投保企业基本户开户行',
`bank_card_name` varchar(100) NOT NULL DEFAULT '' COMMENT '投保企业基本户银行卡号',
`bank_user_name` varchar(100) NOT NULL DEFAULT '' COMMENT '投保企业基本户名称',
`created_at` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
`updated_at` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '最后更新时间',
PRIMARY KEY (`id`) USING BTREE,
UNIQUE KEY `udx_ordersn` (`order_sn`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='用户表';
CREATE TABLE `projects` (
`id` int NOT NULL AUTO_INCREMENT COMMENT '主键',
`order_sn` varchar(20) NOT NULL DEFAULT '' COMMENT '订单编号',
`name` varchar(500) NOT NULL DEFAULT '' COMMENT '项目名称',
`tpid` varchar(50) NOT NULL DEFAULT '' COMMENT '招标项目编号',
`bdid` varchar(50) NOT NULL DEFAULT '' COMMENT '标段包编号',
`bd_name` varchar(50) NOT NULL DEFAULT '' COMMENT '标段包名称',
`start_date` datetime default null COMMENT '开标时间',
`amount` decimal(12,2) NOT NULL DEFAULT '0.00' COMMENT '保证金金额',
`province` varchar(50) NOT NULL DEFAULT '' COMMENT '省编码',
`city` varchar(50) NOT NULL DEFAULT '' COMMENT '市编码',
`district` varchar(50) NOT NULL DEFAULT '' COMMENT '区编码',
`bzj_etime` datetime default null COMMENT '保证金缴纳截止时间',
`create_time` datetime default null COMMENT '项目发布时间',
`plan_date` varchar(50) NOT NULL DEFAULT '' COMMENT '计划工期',
`build_price` varchar(50) NOT NULL DEFAULT '' COMMENT '项目预计造价',
`build_place` varchar(800) NOT NULL DEFAULT '' COMMENT '项目建设地点',
`tender_project_type` varchar(50) NOT NULL DEFAULT '' COMMENT '招标项目类别',
`valid_period` varchar(50) NOT NULL DEFAULT '' COMMENT '投标有效期',
`tender_notice_url` varchar(500) NOT NULL DEFAULT '' COMMENT '招标公告地址',
`tender_file_url` varchar(500) NOT NULL DEFAULT '' COMMENT '招标文件下载地址',
`tender_file_url_md5` varchar(32) NOT NULL DEFAULT '' COMMENT '招标文件md5值',
`project_approval_no` varchar(50) NOT NULL DEFAULT '' COMMENT '项目审批文号',
`created_at` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
`updated_at` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '最后更新时间',
PRIMARY KEY (`id`) USING BTREE,
UNIQUE KEY `udx_ordersn` (`order_sn`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='项目表';
CREATE TABLE `applicant` (
`id` int NOT NULL AUTO_INCREMENT COMMENT '主键',
`order_sn` varchar(20) NOT NULL DEFAULT '' COMMENT '订单编号',
`applicant_name` varchar(100) NOT NULL DEFAULT '' COMMENT '姓名或企业名称',
`credit_code` varchar(100) NOT NULL DEFAULT '' COMMENT '身份证号码或统一社会信用代码',
`credit_vld` date DEFAULT null COMMENT '证件有效期',
`contact_name` varchar(100) NOT NULL DEFAULT '' COMMENT '联系人',
`contact_mobile` varchar(50) default null COMMENT '联系手机',
`com_tel_area` varchar(50) default null COMMENT '公司联系电话区号',
`province` varchar(50) NOT NULL DEFAULT '' COMMENT '省编码',
`city` varchar(50) NOT NULL DEFAULT '' COMMENT '市编码',
`district` varchar(50) NOT NULL DEFAULT '' COMMENT '区编码',
`address` varchar(200) NOT NULL DEFAULT '' COMMENT '详细地址',
`email` varchar(50) NOT NULL DEFAULT '' COMMENT '邮箱',
`legal_name` datetime default null COMMENT '投保企业法人姓名',
`legal_num` varchar(50) NOT NULL DEFAULT '' COMMENT '投保企业法人证件号',
`com_tel_num` varchar(50) NOT NULL DEFAULT '' COMMENT '投保企业法人联系方式',
`license_files` varchar(1000) NOT NULL DEFAULT '' COMMENT '营业执照',
`sign_url` varchar(500) NOT NULL DEFAULT '' COMMENT '签章文件下载地址',
`created_at` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
`updated_at` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '最后更新时间',
PRIMARY KEY (`id`) USING BTREE,
UNIQUE KEY `udx_ordersn` (`order_sn`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='投标人';
CREATE TABLE `assured` (
`id` int NOT NULL AUTO_INCREMENT COMMENT '主键',
`order_sn` varchar(20) NOT NULL DEFAULT '' COMMENT '订单编号',
`assured_name` varchar(500) NOT NULL DEFAULT '' COMMENT '招标人名称',
`credit_code` varchar(100) NOT NULL DEFAULT '' COMMENT '身份证号码或统一社会信用代码',
`credit_vld` date DEFAULT null COMMENT '证件有效期',
`contact_name` varchar(100) NOT NULL DEFAULT '' COMMENT '联系人',
`contact_mobile` varchar(50) default null COMMENT '联系手机',
`com_tel_area` varchar(50) default null COMMENT '公司联系电话区号',
`province` varchar(50) NOT NULL DEFAULT '' COMMENT '省编码',
`city` varchar(50) NOT NULL DEFAULT '' COMMENT '市编码',
`district` varchar(50) NOT NULL DEFAULT '' COMMENT '区编码',
`address` varchar(200) NOT NULL DEFAULT '' COMMENT '详细地址',
`com_tel_num` varchar(50) NOT NULL DEFAULT '' COMMENT '招标企业法人联系方式',
`tender_bank_account` varchar(100) NOT NULL DEFAULT '' COMMENT '招标人银行账号',
`tender_bank_openbank` varchar(100) NOT NULL DEFAULT '' COMMENT '招标人银行开户行',
`tender_account_name` varchar(100) NOT NULL DEFAULT '' COMMENT '招标人银行账户名称',
`agency` varchar(100) NOT NULL DEFAULT '' COMMENT '招标代理机构名称',
`created_at` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
`updated_at` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '最后更新时间',
PRIMARY KEY (`id`) USING BTREE,
UNIQUE KEY `udx_ordersn` (`order_sn`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='招标人';
CREATE TABLE `sign_log` (
`id` int NOT NULL AUTO_INCREMENT COMMENT '主键',
`order_sn` varchar(20) NOT NULL DEFAULT '' COMMENT '订单编号',
`is_upload_pdf` tinyint(1) NOT NULL DEFAULT 0,
`file_info` varchar(500) NOT NULL DEFAULT '' COMMENT '文件信息',
`pc_info` varchar(500) NOT NULL DEFAULT '' COMMENT 'pc信息',
`ca_info` varchar(500) NOT NULL DEFAULT '' COMMENT '签章信息',
`sign_url` varchar(500) NOT NULL DEFAULT '' COMMENT '签章文件下载地址',
`params` varchar(500) NOT NULL DEFAULT '' COMMENT '参数',
`created_at` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
`updated_at` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '最后更新时间',
PRIMARY KEY (`id`) USING BTREE,
KEY `idx_ordersn` (`order_sn`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci COMMENT='签章日志';

@ -0,0 +1,47 @@
package model
import (
"encoding/json"
"time"
)
type Applicant struct {
ID int
OrderSn string
ApplicantName string
CreditVld string
CreditCode string
ContactName string
ContactMobile string
ComTelArea string
Province string
City string
District string
Address string
Email string
LegalName string
LegalNum string
ComTelNum string
LicenseFiles string
SignUrl string
Order *Order `gorm:"foreignKey:OrderSn;references:OrderSn"`
CreatedAt time.Time
UpdatedAt time.Time `json:"-"`
}
func (Applicant) TableName() string {
return "applicant"
}
func (a Applicant) MarshalJSON() ([]byte, error) {
type Alias Applicant
return json.Marshal(&struct {
CreatedAt string
UpdatedAt string
*Alias
}{
CreatedAt: a.CreatedAt.Format("2006-01-02 15:04:05"),
UpdatedAt: a.UpdatedAt.Format("2006-01-02 15:04:05"),
Alias: (*Alias)(&a),
})
}

@ -0,0 +1,46 @@
package model
import (
"encoding/json"
"time"
)
type Assured struct {
ID int
OrderSn string
AssuredName string
ComTelArea string
CreditCode string
CreditVld string
ContactName string
ContactMobile string
TenderBankAccount string
TenderBankOpenbank string
TenderAccountName string
Province string
City string
District string
Address string
ComTelNum string
Agency string
Order *Order `gorm:"foreignKey:OrderSn;references:OrderSn"`
CreatedAt time.Time
UpdatedAt time.Time `json:"-"`
}
func (Assured) TableName() string {
return "assured"
}
func (a Assured) MarshalJSON() ([]byte, error) {
type Alias Assured
return json.Marshal(&struct {
CreatedAt string
UpdatedAt string
*Alias
}{
CreatedAt: a.CreatedAt.Format("2006-01-02 15:04:05"),
UpdatedAt: a.UpdatedAt.Format("2006-01-02 15:04:05"),
Alias: (*Alias)(&a),
})
}

@ -0,0 +1,36 @@
package model
import (
"encoding/json"
"time"
)
type Order struct {
ID int
RequestID string
OrderSn string
Token string
User *User `gorm:"foreignKey:OrderSn;references:OrderSn"`
Project *Project `gorm:"foreignKey:OrderSn;references:OrderSn"`
Applicant *Applicant `gorm:"foreignKey:OrderSn;references:OrderSn"`
Assured *Assured `gorm:"foreignKey:OrderSn;references:OrderSn"`
CreatedAt time.Time
UpdatedAt time.Time `json:"-"`
}
func (Order) TableName() string {
return "order"
}
func (a Order) MarshalJSON() ([]byte, error) {
type Alias Order
return json.Marshal(&struct {
CreatedAt string
UpdatedAt string
*Alias
}{
CreatedAt: a.CreatedAt.Format("2006-01-02 15:04:05"),
UpdatedAt: a.UpdatedAt.Format("2006-01-02 15:04:05"),
Alias: (*Alias)(&a),
})
}

@ -0,0 +1,51 @@
package model
import (
"encoding/json"
"time"
)
type Project struct {
ID int
OrderSn string
Name string
TpID string
BdID string
BdName string
StartDate string
Amount string
Province string
City string
District string
BzjEtime string
CreateTime string
PlanDate string
BuildPrice string
BuildPlace string
TenderProjectType string
ValidPeriod string
TenderNoticeUrl string
TenderFileUrl string
TenderFileUrlMd5 string
ProjectApprovalNo string
Order *Order `gorm:"foreignKey:OrderSn;references:OrderSn"`
CreatedAt time.Time
UpdatedAt time.Time `json:"-"`
}
func (Project) TableName() string {
return "project"
}
func (a Project) MarshalJSON() ([]byte, error) {
type Alias Project
return json.Marshal(&struct {
CreatedAt string
UpdatedAt string
*Alias
}{
CreatedAt: a.CreatedAt.Format("2006-01-02 15:04:05"),
UpdatedAt: a.UpdatedAt.Format("2006-01-02 15:04:05"),
Alias: (*Alias)(&a),
})
}

@ -0,0 +1,36 @@
package model
import (
"encoding/json"
"time"
)
type SignLog struct {
ID int
OrderSn string
PcInfo string
CaInfo string
FileInfo string
SignUrl string
Params string
IsUploadPdf int
CreatedAt time.Time
UpdatedAt time.Time `json:"-"`
}
func (SignLog) TableName() string {
return "sign_log"
}
func (a SignLog) MarshalJSON() ([]byte, error) {
type Alias SignLog
return json.Marshal(&struct {
CreatedAt string
UpdatedAt string
*Alias
}{
CreatedAt: a.CreatedAt.Format("2006-01-02 15:04:05"),
UpdatedAt: a.UpdatedAt.Format("2006-01-02 15:04:05"),
Alias: (*Alias)(&a),
})
}

@ -5,27 +5,25 @@ import (
"time"
)
const UserStatusActive = 1
const UserStatusDisable = 2
type User struct {
ID int
Mobile string
Nickname string
UserType int `json:"-"`
MasterUserId int `json:"-"`
PasswordHash string `json:"-"`
PaymentPasswordHash string `json:"-"`
AlipayAccount string
Profit float64
Balance float64
Status int
CreatedAt time.Time
UpdatedAt time.Time `json:"-"`
ID int
OrderSn string
Mobile string
Username string
UserID string
UnitID string
UnitName string
BeiandiquCode string
BankName string
BankCardName string
BankUserName string
Order *Order `gorm:"foreignKey:OrderSn;references:OrderSn"`
CreatedAt time.Time
UpdatedAt time.Time `json:"-"`
}
func (User) TableName() string {
return "users"
return "user"
}
func (u User) MarshalJSON() ([]byte, error) {
@ -38,14 +36,3 @@ func (u User) MarshalJSON() ([]byte, error) {
Alias: (*Alias)(&u),
})
}
func (u User) GetStatusText() string {
statusText := ""
switch u.Status {
case UserStatusActive:
statusText = "正常"
case UserStatusDisable:
statusText = "禁用"
}
return statusText
}

@ -6,5 +6,7 @@ import (
func Initial(r *gin.Engine) {
h5RouteInit(r)
webRouteInit(r)
adminRouteInit(r)
suixingRouteInit(r)
}

@ -5,4 +5,7 @@ import (
)
func h5RouteInit(r *gin.Engine) {
r.StaticFile("/order", "./static/index.html")
r.Static("/assets", "./static/assets")
r.Static("/uploads", "./static/uploads")
}

@ -0,0 +1,12 @@
package router
import (
"github.com/gin-gonic/gin"
"insure/api/suixing"
)
func suixingRouteInit(r *gin.Engine) {
sxGroup := r.Group("/suixing")
sxGroup.Match([]string{"POST", "OPTIONS"}, "/gurantee/create", suixing.Create)
sxGroup.Match([]string{"POST", "OPTIONS"}, "/upload-signed-file", suixing.UploadSignedFile)
}

@ -0,0 +1,13 @@
package router
import (
"github.com/gin-gonic/gin"
"insure/api/h5"
"insure/utils/result"
)
func webRouteInit(r *gin.Engine) {
webGroup := r.Group("/web")
webGroup.Match([]string{"GET", "OPTIONS"}, "/get-order", result.Json(h5.GetOrder))
webGroup.Match([]string{"GET", "OPTIONS"}, "/get-sign-url", result.Json(h5.GetSignUrl))
}

@ -0,0 +1,209 @@
package service
import (
"encoding/json"
"errors"
"gorm.io/gorm"
"insure/e"
"insure/global"
"insure/model"
"insure/third_party/signer"
"insure/third_party/suixing"
"insure/utils"
"strconv"
"time"
)
var OrderService = orderService{}
type orderService struct {
}
func (s *orderService) CreateOrder(param suixing.CommonParam) (*model.Order, error) {
orderSn := utils.GenerateNo("order")
orderParam := &suixing.Order{}
err := json.Unmarshal([]byte(param.Data), &orderParam)
if err != nil {
return nil, err
}
order, err := s.saveOrder(orderSn, param.RequestID)
if err != nil {
return nil, err
}
user, err := s.saveUser(orderSn, orderParam.User)
if err != nil {
return nil, err
}
project, err := s.saveProject(orderSn, orderParam.Project)
if err != nil {
return nil, err
}
applicant, err := s.saveApplicant(orderSn, orderParam.Applicant)
if err != nil {
return nil, err
}
assured, err := s.saveAssured(orderSn, orderParam.Assured)
if err != nil {
return nil, err
}
order.User = user
order.Applicant = applicant
order.Project = project
order.Assured = assured
return order, nil
}
func (s *orderService) saveOrder(orderSn string, requestID string) (*model.Order, error) {
o := model.Order{}
o.Token = utils.Md5(orderSn + utils.GenerateRandomString(10) + strconv.Itoa(int(time.Now().UnixMicro())))
o.OrderSn = orderSn
o.RequestID = requestID
err := global.DB.Save(&o).Error
if err != nil {
return nil, err
}
return &o, nil
}
func (s *orderService) saveUser(orderSn string, user suixing.User) (*model.User, error) {
u := model.User{}
u.OrderSn = orderSn
u.UserID = user.UserID
u.Username = user.Username
u.Mobile = user.Mobile
u.UnitID = user.UnitID
u.UnitName = user.UnitName
u.BankUserName = user.BankUserName
u.BankName = user.BankName
u.BankCardName = user.BankCardName
u.BeiandiquCode = user.BeiandiquCode
err := global.DB.Save(&u).Error
if err != nil {
return nil, err
}
return &u, nil
}
func (s *orderService) saveProject(orderSn string, project suixing.Project) (*model.Project, error) {
p := model.Project{}
p.OrderSn = orderSn
p.Name = project.Name
p.TpID = project.TpID
p.BdID = project.BdID
p.BdName = project.BdName
p.StartDate = project.StartDate
p.Amount = project.Amount
p.Province = project.Province
p.City = project.City
p.District = project.District
p.BzjEtime = project.BzjEtime
p.CreateTime = project.CreateTime
p.PlanDate = project.PlanDate
p.BuildPrice = project.BuildPrice
p.BuildPlace = project.BuildPlace
p.TenderProjectType = project.TenderProjectType
p.ValidPeriod = project.ValidPeriod
p.TenderNoticeUrl = project.TenderNoticeUrl
p.TenderFileUrl = project.TenderFileUrl
p.TenderFileUrlMd5 = project.TenderFileUrlMd5
p.ProjectApprovalNo = project.ProjectApprovalNo
err := global.DB.Save(&p).Error
if err != nil {
return nil, err
}
return &p, nil
}
func (s *orderService) saveApplicant(orderSn string, applicant suixing.Applicant) (*model.Applicant, error) {
licenseFiles, err := json.Marshal(applicant.LicenseFiles)
if err != nil {
return nil, err
}
a := model.Applicant{}
a.OrderSn = orderSn
a.ApplicantName = applicant.ApplicantName
a.CreditVld = applicant.CreditVld
a.CreditCode = applicant.CreditCode
a.ContactName = applicant.ContactName
a.ContactMobile = applicant.ContactMobile
a.ComTelArea = applicant.ComTelArea
a.Province = applicant.Province
a.City = applicant.City
a.District = applicant.District
a.Address = applicant.Address
a.Email = applicant.Email
a.LegalName = applicant.LegalName
a.LegalNum = applicant.LegalNum
a.ComTelNum = applicant.ComTelNum
a.LicenseFiles = string(licenseFiles)
a.SignUrl = applicant.SignUrl
err = global.DB.Save(&a).Error
if err != nil {
return nil, err
}
return &a, nil
}
func (s *orderService) saveAssured(orderSn string, assured suixing.Assured) (*model.Assured, error) {
a := model.Assured{}
a.OrderSn = orderSn
a.AssuredName = assured.AssuredName
a.CreditVld = assured.CreditVld
a.CreditCode = assured.CreditCode
a.ContactName = assured.ContactName
a.ContactMobile = assured.ContactMobile
a.ComTelArea = assured.ComTelArea
a.Province = assured.Province
a.City = assured.City
a.District = assured.District
a.Address = assured.Address
a.TenderBankAccount = assured.TenderBankAccount
a.TenderBankOpenbank = assured.TenderBankOpenbank
a.TenderAccountName = assured.TenderAccountName
a.Agency = assured.Agency
a.ComTelNum = assured.ComTelNum
err := global.DB.Save(&a).Error
if err != nil {
return nil, err
}
return &a, nil
}
func (s *orderService) GetOrderByToken(token string) (*model.Order, error) {
order := model.Order{}
err := global.DB.Preload("User").Preload("Project").Preload("Applicant").Preload("Assured").Where("token", token).First(&order).Error
if err != nil {
if errors.Is(err, gorm.ErrRecordNotFound) {
return nil, e.NewError("记录不存在")
} else {
return nil, e.NewError("数据异常")
}
}
return &order, nil
}
func (s *orderService) AddSignLog(orderSn string, param signer.UploadParam) (*model.SignLog, error) {
var err error
isUploadPdf := 1
if param.IsUploadPdf != "" {
isUploadPdf, err = strconv.Atoi(param.IsUploadPdf)
if err != nil {
return nil, err
}
}
l := model.SignLog{}
l.OrderSn = orderSn
l.Params = param.Params
l.CaInfo = param.CaInfo
l.IsUploadPdf = isUploadPdf
l.FileInfo = param.FileInfo
l.PcInfo = param.PcInfo
err = global.DB.Save(&l).Error
if err != nil {
return nil, err
}
return &l, nil
}

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because it is too large Load Diff

@ -0,0 +1,177 @@
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<!-- import CSS -->
<link rel="stylesheet" href="/assets/css/element-ui.css">
</head>
<body>
<div id="app">
<el-container>
<el-header class="page-header">
<!-- <div class="page-logo">logo</div>-->
<div class="page-title">确认投标</div>
</el-header>
<el-main>
<el-row :gutter="10" style="margin-bottom: 10px">
<el-col :span="24">
<div class="warning-row">
<div class="warning-label">温馨提示</div>
<div class="warning-content">
<div class="warning-item">尊敬的投保企业,投保时还请注意</div>
<div class="warning-item">1. 检查企业信息及开票信息是否有误</div>
<div class="warning-item">2. 第一次申请保函的企业如发现金额不正确请取消订单后重新下单即可,感谢您的信任。</div>
</div>
</div>
</el-col>
</el-row>
<el-row :gutter="10" style="margin-bottom: 10px">
<el-col :span="24">
<el-descriptions title="投保人信息" :column="2">
<el-descriptions-item label="企业名称">kooriookami</el-descriptions-item>
<el-descriptions-item label="统一社会信用代码">18100000000</el-descriptions-item>
<el-descriptions-item label="联系人姓名">苏州市</el-descriptions-item>
<el-descriptions-item label="联系人手机号">苏州市</el-descriptions-item>
<el-descriptions-item label="开户行(基本户)">测试</el-descriptions-item>
<el-descriptions-item label="银行账号">江苏省苏州市吴中区吴中大道 1188 号</el-descriptions-item>
</el-descriptions>
</el-col>
</el-row>
<el-row :gutter="10" style="margin-bottom: 10px">
<el-col :span="24">
<el-descriptions title="项目信息" :column="2">
<el-descriptions-item label="企业名称">kooriookami</el-descriptions-item>
<el-descriptions-item label="统一社会信用代码">18100000000</el-descriptions-item>
<el-descriptions-item label="联系人姓名">苏州市</el-descriptions-item>
<el-descriptions-item label="联系人手机号">苏州市</el-descriptions-item>
<el-descriptions-item label="开户行(基本户)">测试</el-descriptions-item>
<el-descriptions-item label="银行账号">江苏省苏州市吴中区吴中大道 1188 号</el-descriptions-item>
</el-descriptions>
</el-col>
</el-row>
<el-row :gutter="10" style="margin-bottom: 10px">
<el-col :span="12">
<el-descriptions title="保函信息" :column="1">
<el-descriptions-item label="企业名称">kooriookami</el-descriptions-item>
<el-descriptions-item label="统一社会信用代码">18100000000</el-descriptions-item>
<el-descriptions-item label="联系人姓名">苏州市</el-descriptions-item>
<el-descriptions-item label="联系人手机号">苏州市</el-descriptions-item>
<el-descriptions-item label="开户行(基本户)">测试</el-descriptions-item>
<el-descriptions-item label="银行账号">江苏省苏州市吴中区吴中大道 1188 号</el-descriptions-item>
</el-descriptions>
</el-col>
<el-col :span="12">
<el-descriptions title="开票信息" :column="1">
<el-descriptions-item label="企业名称">kooriookami</el-descriptions-item>
<el-descriptions-item label="统一社会信用代码">18100000000</el-descriptions-item>
<el-descriptions-item label="联系人姓名">苏州市</el-descriptions-item>
<el-descriptions-item label="联系人手机号">苏州市</el-descriptions-item>
<el-descriptions-item label="开户行(基本户)">测试</el-descriptions-item>
<el-descriptions-item label="银行账号">江苏省苏州市吴中区吴中大道 1188 号</el-descriptions-item>
</el-descriptions>
</el-col>
</el-row>
<el-row :gutter="10" style="margin-bottom: 10px">
<el-col :span="24">
<div class="next-step-row">
<el-checkbox v-model="checked">确认并同意<el-link type="primary">《客户告知书》</el-link></el-checkbox>
<el-button type="primary">下一步</el-button>
</div>
</el-col>
</el-row>
</el-main>
</el-container>
</div>
</body>
<!-- import Vue before Element -->
<script src="/assets/js/vue.js"></script>
<!-- import JavaScript -->
<script src="/assets/js/element-ui.js"></script>
<script>
new Vue({
el: '#app',
data: function() {
return { visible: false }
}
})
</script>
<style>
body {
padding: 0px;
margin: 0px;
}
.page-header {
text-align: center;
border-bottom: 1px solid #ebeef5;
box-shadow: 0 2px 12px 0 rgba(0,0,0,.1);
}
/*.page-logo {
height: 100%;
width: 150px;
display: inline-block;
}*/
.page-title {
display: inline-block;
height: 100%;
line-height: 60px;
}
.el-descriptions {
border-radius: 4px;
border: 1px solid #ebeef5;
background-color: #fff;
overflow: hidden;
color: #303133;
transition: .3s;
padding: 20px 25px;
box-shadow: 0 2px 12px 0 rgba(0,0,0,.1);
}
.warning-row {
border-radius: 4px;
border: 1px solid #ebeef5;
background-color: #fff;
overflow: hidden;
color: #303133;
transition: .3s;
box-shadow: 0 2px 12px 0 rgba(0,0,0,.1);
text-align: left;
height: 80px;
line-height: 80px;
}
.warning-label {
display: inline-block;
background-color: #409EFF;
color: #FFFFFF;
padding: 0px 20px;
top: -21px;
position: relative;
}
.warning-content {
display: inline-block;
margin-left: 10px;
height: 100%;
}
.warning-content .warning-item {
font-size: 13px;
line-height: 15px;
margin-top: 8px;
}
.next-step-row {
border-radius: 4px;
border: 1px solid #ebeef5;
background-color: #fff;
overflow: hidden;
color: #303133;
transition: .3s;
box-shadow: 0 2px 12px 0 rgba(0,0,0,.1);
text-align: right;
height: 60px;
line-height: 60px;
}
.next-step-row button {
border-radius: 0px;
height: 60px;
width: 150px;
border: none;
}
</style>
</html>

@ -0,0 +1,74 @@
{
"appid": "suixing",
"requestid": "39824ec696e67b40",
"timestamp": "1603246438",
"version": "1.0.0",
"sign": "099516e9e101ea02a929d2df418faa292e1fc1e7",
"data":
}
{"user": {
"unitid": "5987bdcf4b0931216ce7b9ca",
"mobile": "18120846352",
"username": "福建随行福州地区",
"userid": "5b371dc94b0930115808cb4c",
"unitname": "福建随行福州地区",
"bank_name": "",
"bank_card_num": ""
},
"project": {
"amount": "100",
"bzj_etime": "2021-10-01 00:00:00",
"start_date": "2021-10-01 00:00:00",
"createtime": "2020-10-10 18:01:06",
"city": "440400",
"name": "斗门-电子保函-通用-1010",
"tpid": "",
"bzj_stime": "2020-10-10 15:23:33",
"bd_name": "",
"district": "440403",
"bdid": "",
"province": "440000"
},
"applicant": {
"contact_mobile": "18120846352",
"district": "350150",
"city": "350100",
"address": "福建福州",
"license_files": [
"http://filetest.enjoy5191.com:19004/file/getcontent/5f168ce7269e48321cdbbadf.PNG"
],
"contact_name": "牛先生",
"com_tel_area": "",
"email": "2638190133@qq.com",
"credit_code": "12313123",
"bzj_way": "GCDB_BAOHAN",
"applicant_name": "福建随行福州地区",
"credit_vld": "2022-10-31",
"com_tel_num": "0000-39845798",
"province": "350000"
},
"assured": {
"credit_vld": "",
"com_tel_area": "",
"contact_mobile": "181111111111",
"address": "招标人地址",
"city": "",
"assured_name": "招标人名称",
"com_tel_num": "",
"agency": "",
"district": "",
"contact_name": "招标人联系人",
"credit_code": "",
"province": ""
}
}
{
"appid": "suixing",
"requestid": "39824ec696e67b40",
"timestamp": "1603246438",
"version": "1.0.0",
"sign": "099516e9e101ea02a929d2df418faa292e1fc1e7",
"data": "{\"user\":{\"unitid\":\"5987bdcf4b0931216ce7b9ca\",\"mobile\":\"18120846352\",\"username\":\"福建随行福州地区\",\"userid\":\"5b371dc94b0930115808cb4c\",\"unitname\":\"福建随行福州地区\",\"bank_name\":\"\",\"bank_card_num\":\"\"},\"project\":{\"amount\":\"100\",\"bzj_etime\":\"2021-10-01 00:00:00\",\"start_date\":\"2021-10-01 00:00:00\",\"createtime\":\"2020-10-10 18:01:06\",\"city\":\"440400\",\"name\":\"斗门-电子保函-通用-1010\",\"tpid\":\"\",\"bzj_stime\":\"2020-10-10 15:23:33\",\"bd_name\":\"\",\"district\":\"440403\",\"bdid\":\"\",\"province\":\"440000\"},\"applicant\":{\"contact_mobile\":\"18120846352\",\"district\":\"350150\",\"city\":\"350100\",\"address\":\"福建福州\",\"license_files\":[\"http://filetest.enjoy5191.com:19004/file/getcontent/5f168ce7269e48321cdbbadf.PNG\"],\"contact_name\":\"牛先生\",\"com_tel_area\":\"\",\"email\":\"2638190133@qq.com\",\"credit_code\":\"12313123\",\"bzj_way\":\"GCDB_BAOHAN\",\"applicant_name\":\"福建随行福州地区\",\"credit_vld\":\"2022-10-31\",\"com_tel_num\":\"0000-39845798\",\"province\":\"350000\"},\"assured\":{\"credit_vld\":\"\",\"com_tel_area\":\"\",\"contact_mobile\":\"181111111111\",\"address\":\"招标人地址\",\"city\":\"\",\"assured_name\":\"招标人名称\",\"com_tel_num\":\"\",\"agency\":\"\",\"district\":\"\",\"contact_name\":\"招标人联系人\",\"credit_code\":\"\",\"province\":\"\"}}"
}

@ -1 +0,0 @@
package alipay

@ -0,0 +1,20 @@
package signer
import (
"encoding/base64"
"encoding/json"
)
var SignerApi signerApi = signerApi{}
type signerApi struct {
}
func (api *signerApi) GetSignUrl(param SignParam) (string, error) {
str, err := json.Marshal(param)
if err != nil {
return "", err
}
data := base64.StdEncoding.EncodeToString([]byte(str))
return "FJGGFWCAUU://" + data, nil
}

@ -0,0 +1,13 @@
package signer
type SignParam struct {
Url string `json:"url"`
UploadUrl string `json:"upload_url"`
Params string `json:"params"`
IsView string `json:"is_view"`
IsUploadPdf string `json:"is_upload_pdf"`
IsAutoClose string `json:"is_auto_close"`
IsEdit string `json:"is_edit"`
IsEditOld string `json:"is_edit_old"`
IsShowSeal string `json:"is_show_seal"`
}

@ -0,0 +1,9 @@
package signer
type UploadParam struct {
PcInfo string `json:"pc_info" form:"pc_info"`
CaInfo string `json:"ca_info" form:"ca_info"`
FileInfo string `json:"file_info" form:"file_info"`
IsUploadPdf string `json:"is_upload_pdf" form:"is_upload_pdf"`
Params string `json:"params" form:"params"`
}

@ -0,0 +1,99 @@
package suixing
import (
"encoding/json"
"fmt"
"insure/e"
"insure/global"
"insure/utils"
"io"
"net/http"
"net/url"
"strings"
)
var SuixingApi suixingApi = suixingApi{}
type suixingApi struct {
}
func (api *suixingApi) CreateOrderCallback(param CommonParam) (*Result, error) {
err := api.Sign(&param)
if err != nil {
return nil, err
}
res, err := api.post("", param)
if err != nil {
return nil, err
}
result := Result{}
err = json.Unmarshal(res, &result)
if err != nil {
return nil, err
}
return &result, nil
}
func (api *suixingApi) Sign(param *CommonParam) error {
//vals, err := utils.StructToURLValues(param)
vals := url.Values{}
vals.Set("appid", param.AppID)
vals.Set("requestid", param.RequestID)
vals.Set("timestamp", param.Timestamp)
vals.Set("version", param.Version)
vals.Set("data", utils.Md5(param.Data))
vals.Set("appsecret", "aaaaaa")
fmt.Println(vals.Encode())
param.Sign = utils.Sha1(vals.Encode())
return nil
}
func (api *suixingApi) Verify(param CommonParam) bool {
postSign := param.Sign
err := api.Sign(&param)
if err != nil {
fmt.Println("sign error")
return false
}
if postSign != param.Sign {
return false
}
return true
}
func (api *suixingApi) post(uri string, data interface{}) ([]byte, error) {
client := &http.Client{}
dataStr, err := json.Marshal(data)
if err != nil {
return nil, err
}
body := strings.NewReader(string(dataStr))
u := global.Config.Suixing.BaseUrl + uri
fmt.Println("url: " + u)
request, err := http.NewRequest("POST", u, body)
request.Header.Set("content-type", "application/json")
if err != nil {
return nil, e.NewError("请求错误")
}
response, err := client.Do(request)
defer func(Body io.ReadCloser) {
err := Body.Close()
if err != nil {
}
}(response.Body)
bodyBytes, err := io.ReadAll(response.Body)
fmt.Println("res: ", string(bodyBytes))
if err != nil {
return nil, e.NewError("返回内容错误")
}
return bodyBytes, nil
}

@ -0,0 +1,20 @@
package suixing
type CallbackData struct {
DataType string `json:"data_type" form:"data_type"`
OrderSn string `json:"ordersn" form:"ordersn"`
PolicyNo string `json:"policy_no" form:"policy_no"`
MinPremium string `json:"min_premium" form:"min_premium"`
Rate string `json:"rate" form:"rate"`
Status string `json:"status" form:"status"`
ServiceAmount string `json:"service_amount" form:"service_amount"`
GuranteeLink string `json:"gurantee_link" form:"gurantee_link"`
GuranteeLinkMd5 string `json:"gurantee_link_md5" form:"gurantee_link_md5"`
GuranteeOfdLink string `json:"gurantee_ofd_link" form:"gurantee_ofd_link"`
GuranteeOfdLinkMd5 string `json:"gurantee_ofd_link_md5" form:"gurantee_ofd_link_md5"`
InvoiceLink string `json:"invoice_link" form:"invoice_link"`
InvoiceLinkMd5 string `json:"invoice_link_md5" form:"invoice_link_md5"`
ConfirmReceiptLink string `json:"confirm_receipt_link" form:"confirm_receipt_link"`
ConfirmReceiptLinkMd5 string `json:"confirm_receipt_link_md5" form:"confirm_receipt_link_md5"`
Remark string `json:"remark" form:"remark"`
}

@ -0,0 +1,10 @@
package suixing
type CommonParam struct {
AppID string `json:"appid" form:"appid"`
RequestID string `json:"requestid" form:"requestid"`
Timestamp string `json:"timestamp" form:"timestamp"`
Version string `json:"version" form:"version"`
Data string `json:"data" form:"data"`
Sign string `json:"sign" form:"sign"`
}

@ -0,0 +1,80 @@
package suixing
type Order struct {
User User `json:"user" form:"user"`
Project Project `json:"project" form:"project"`
Applicant Applicant `json:"applicant" form:"applicant"`
Assured Assured `json:"assured" form:"assured"`
}
type User struct {
Mobile string `json:"mobile" form:"mobile"`
Username string `json:"username" form:"username"`
UserID string `json:"userid" form:"userid"`
UnitID string `json:"unitid" form:"unitid"`
UnitName string `json:"unitname" form:"unitname"`
BeiandiquCode string `json:"beiandiqu_code" form:"beiandiqu_code"`
BankName string `json:"bank_name" form:"bank_name"`
BankCardName string `json:"bank_card_name" form:"bank_card_name"`
BankUserName string `json:"bank_user_name" form:"bank_user_name"`
}
type Project struct {
Name string `json:"name" form:"name"`
TpID string `json:"tpid" form:"tpid"`
BdID string `json:"bdid" form:"bdid"`
BdName string `json:"bd_name" form:"bd_name"`
StartDate string `json:"start_date" form:"name"`
Amount string `json:"amount" form:"amount"`
Province string `json:"province" form:"province"`
City string `json:"city" form:"city"`
District string `json:"district" form:"district"`
BzjEtime string `json:"bzj_etime" form:"bzj_etime"`
CreateTime string `json:"createtime" form:"createtime"`
PlanDate string `json:"plan_date" form:"plan_date"`
BuildPrice string `json:"build_price" form:"build_price"`
BuildPlace string `json:"build_place" form:"build_place"`
TenderProjectType string `json:"tender_project_type" form:"tender_project_type"`
ValidPeriod string `json:"valid_period" form:"valid_period"`
TenderNoticeUrl string `json:"tender_notice_url" form:"tender_notice_url"`
TenderFileUrl string `json:"tender_file_url" form:"tender_file_url"`
TenderFileUrlMd5 string `json:"tender_file_url_md5" form:"tender_file_url_md5"`
ProjectApprovalNo string `json:"project_approval_no" form:"project_approval_no"`
}
type Applicant struct {
ApplicantName string `json:"applicant_name" form:"applicant_name"`
CreditCode string `json:"credit_code" form:"credit_code"`
CreditVld string `json:"credit_vld" form:"credit_vld"`
ContactName string `json:"contact_name" form:"contact_name"`
ContactMobile string `json:"contact_mobile" form:"contact_mobile"`
ComTelArea string `json:"com_tel_area" form:"com_tel_area"`
Province string `json:"province" form:"province"`
City string `json:"city" form:"city"`
District string `json:"district" form:"district"`
Address string `json:"address" form:"address"`
Email string `json:"email" form:"email"`
LegalName string `json:"legal_name" form:"legal_name"`
LegalNum string `json:"legal_num" form:"legal_num"`
ComTelNum string `json:"com_tel_num" form:"com_tel_num"`
LicenseFiles []string `json:"license_files" form:"license_files"`
SignUrl string `json:"sign_url" form:"sign_url"`
}
type Assured struct {
AssuredName string `json:"assured_name" form:"assured_name"`
ComTelArea string `json:"com_tel_area" form:"com_tel_area"`
CreditCode string `json:"credit_code" form:"credit_code"`
CreditVld string `json:"credit_vld" form:"credit_vld"`
ContactName string `json:"contact_name" form:"contact_name"`
ContactMobile string `json:"contact_mobile" form:"contact_mobile"`
TenderBankAccount string `json:"tender_bank_account" form:"tender_bank_account"`
TenderBankOpenbank string `json:"tender_bank_openbank" form:"tender_bank_openbank"`
TenderAccountName string `json:"tender_account_name" form:"tender_account_name"`
Province string `json:"province" form:"province"`
City string `json:"city" form:"city"`
District string `json:"district" form:"district"`
Address string `json:"address" form:"address"`
ComTelNum string `json:"com_tel_num" form:"com_tel_num"`
Agency string `json:"agency" form:"agency"`
}

@ -0,0 +1,9 @@
package suixing
type Result struct {
Code string `json:"code"`
Msg string `json:"msg"`
Data Data `json:"data"`
}
type Data map[string]interface{}

@ -0,0 +1,99 @@
package zking
import (
"encoding/json"
"fmt"
"insure/e"
"insure/global"
"insure/utils"
"io"
"net/http"
"net/url"
"strings"
)
var InsureApi insureApi = insureApi{}
type insureApi struct {
}
func (api *insureApi) SuixingCreate(param CommonParam) (*Result, error) {
err := api.Sign(&param)
if err != nil {
return nil, err
}
res, err := api.post("/api/v1/insurance/public/suiXing/claim", param)
if err != nil {
return nil, err
}
result := Result{}
err = json.Unmarshal(res, &result)
if err != nil {
return nil, err
}
return &result, nil
}
func (api *insureApi) Sign(param *CommonParam) error {
//vals, err := utils.StructToURLValues(param)
vals := url.Values{}
vals.Set("appid", param.AppID)
vals.Set("requestid", param.RequestID)
vals.Set("timestamp", param.Timestamp)
vals.Set("version", param.Version)
vals.Set("data", utils.Md5(param.Data))
vals.Set("appsecret", "aaaaaa")
fmt.Println(vals.Encode())
param.Sign = utils.Sha1(vals.Encode())
return nil
}
func (api *insureApi) Verify(param CommonParam) bool {
postSign := param.Sign
err := api.Sign(&param)
if err != nil {
fmt.Println("sign error")
return false
}
if postSign != param.Sign {
return false
}
return true
}
func (api *insureApi) post(uri string, data interface{}) ([]byte, error) {
client := &http.Client{}
dataStr, err := json.Marshal(data)
if err != nil {
return nil, err
}
body := strings.NewReader(string(dataStr))
u := global.Config.Zking.BaseUrl + uri
fmt.Println("url: " + u)
request, err := http.NewRequest("POST", u, body)
request.Header.Set("content-type", "application/json")
if err != nil {
return nil, e.NewError("请求错误")
}
response, err := client.Do(request)
defer func(Body io.ReadCloser) {
err := Body.Close()
if err != nil {
}
}(response.Body)
bodyBytes, err := io.ReadAll(response.Body)
fmt.Println("res: ", string(bodyBytes))
if err != nil {
return nil, e.NewError("返回内容错误")
}
return bodyBytes, nil
}

@ -0,0 +1,10 @@
package zking
type CommonParam struct {
AppID string `json:"appid" form:"appid"`
RequestID string `json:"requestid" form:"requestid"`
Timestamp string `json:"timestamp" form:"timestamp"`
Version string `json:"version" form:"version"`
Data string `json:"data" form:"data"`
Sign string `json:"sign" form:"sign"`
}

@ -0,0 +1,9 @@
package zking
type Result struct {
Code string `json:"code"`
Msg string `json:"msg"`
Data Data `json:"data"`
}
type Data map[string]interface{}

@ -5,6 +5,7 @@ import (
"crypto/md5"
"crypto/rand"
"crypto/rsa"
"crypto/sha1"
"crypto/x509"
"encoding/base64"
"encoding/hex"
@ -133,3 +134,9 @@ func ReadParsePrivateKey(filename string) (*rsa.PrivateKey, error) {
return nil, errors.New("私钥错误")
}
}
func Sha1(data string) string {
h := sha1.New()
h.Write([]byte(data))
return hex.EncodeToString(h.Sum(nil))
}

@ -3,7 +3,7 @@ package utils
import (
syserrors "errors"
"github.com/gin-gonic/gin"
"gold-shop/errors"
"insure/e"
)
type Result struct {
@ -37,11 +37,11 @@ func Handler(api func(c *gin.Context)) func(c *gin.Context) {
func buildErrorResult(err error) Result {
result := Result{}
switch err.(type) {
case *errors.BusinessError:
var businessError *errors.BusinessError
syserrors.As(err, &businessError)
result.Code = businessError.Code
result.Message = businessError.Message
case *e.Error:
var bizErr *e.Error
syserrors.As(err, &bizErr)
result.Code = bizErr.Code
result.Message = bizErr.Message
default:
result.Code = Error
result.Message = "系统异常"

@ -3,7 +3,7 @@ package result
import (
syserrors "errors"
"github.com/gin-gonic/gin"
"gold-shop/errors"
"insure/e"
)
type Result struct {
@ -37,11 +37,11 @@ func Normal(api func(c *gin.Context)) func(c *gin.Context) {
func buildErrorResult(err error) Result {
result := Result{}
switch err.(type) {
case *errors.BusinessError:
var businessError *errors.BusinessError
syserrors.As(err, &businessError)
result.Code = businessError.Code
result.Message = businessError.Message
case *e.Error:
var bizErr *e.Error
syserrors.As(err, &bizErr)
result.Code = bizErr.Code
result.Message = bizErr.Message
default:
result.Code = Error
result.Message = "系统异常"

@ -2,7 +2,7 @@ package utils
import (
"context"
"gold-shop/global"
"insure/global"
"math/rand"
"strconv"
"strings"

Loading…
Cancel
Save