ljl 5 months ago
parent ed5dbeb4d5
commit f6c6e87841

@ -4,6 +4,7 @@ import (
"encoding/json"
"fmt"
"github.com/gin-gonic/gin"
"github.com/tidwall/gjson"
"insure/global"
"insure/model"
"insure/service"
@ -28,16 +29,18 @@ func Create(c *gin.Context) {
if body != nil {
fmt.Printf("body:%s\n", body)
}
var param suixing.CommonParam
err := c.ShouldBindJSON(&param)
var param suixing.CreateParam
err := json.Unmarshal(body, &param)
if err != nil {
result["code"] = 201
result["msg"] = "参数异常"
result["msg"] = "参数异常:" + err.Error()
c.JSON(200, result)
return
}
fmt.Println(param)
if !suixing.SuixingApi.Verify(param) {
dataStr := gjson.Get(string(body), "data")
if !suixing.SuixingApi.Verify(param.CommonParam, dataStr.String()) {
result["code"] = 301
result["msg"] = "验签失败"
c.JSON(200, result)
@ -53,7 +56,7 @@ func Create(c *gin.Context) {
}
data["order_sn"] = order.OrderSn
data["url"] = global.Config.Server.Domain + "/pages/order?token" + order.Token
data["url"] = global.Config.Server.Domain + "/tender?token=" + order.Token
result["data"] = data
c.JSON(200, result)
return

@ -1,10 +1,12 @@
package main
import (
"encoding/json"
"flag"
"fmt"
"github.com/gin-gonic/gin"
"github.com/jung-kurt/gofpdf"
"github.com/tidwall/gjson"
"insure/global"
"insure/initialize"
"insure/router"
@ -17,6 +19,7 @@ func main() {
//runServer()
//gen3()
runServerInWindows()
//jsonum1()
}
func initial() {
@ -44,6 +47,33 @@ func initial() {
}
}*/
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"`
Sign string `json:"sign" form:"sign"`
Data string `json:"data" form:"data"`
}
func jsonum() {
var param map[string]interface{}
str := "{\"requestid\":\"2c5db07a2ace41dea1ddf894f2bae1fe\",\"appid\":\"zijin\",\"timestamp\":\"1719193514\",\"version\":\"1.0.0\",\"sign\":\"3ffff2e00610b3bc46d818c0b2fbd7ce7236b839\",\"data\":{\"user\":{\"unitname\":\"湖南弘湘建设工程管理有限公司\",\"insurances_start\":\"\",\"username\":\"投标企业4\",\"server_amount\":\"200.000\",\"bank_name\":\"中国建设银行\",\"userid\":\"5987c1944b0931216ce8526f\",\"beiandiqu_code\":\"x00004\",\"unitid\":\"5993a8144b09311cacb51e12\",\"bank_card_num\":\"6217001820001592123\",\"buinessNo\":[],\"mobile\":\"15605914788\",\"bank_user_name\":\"湖南弘湘建设工程管理有限公司\",\"fileList\":[],\"guarantee_type\":\"0\",\"rate\":\"\",\"policy_period_type\":\"\",\"unit_qual\":\"\",\"insurances_end\":\"\"},\"project\":{\"amount\":\"300000.00\",\"bulid_price\":\"3424257\",\"plan_date\":\"108日历天\",\"district\":\"350100\",\"city\":\"350100\",\"valid_period\":\"23\",\"name\":\"住建-测试项目\",\"province\":\"350000\",\"bulid_place\":\"23412\",\"tender_notice_url\":\"http://192.168.118.171:7702/views/pages/entp-view.html?type=tp&tpId=66027a207109b83d96aa86eb&flag=false&foId=66027a207109b83d96aa86eb\",\"createtime\":\"2024-03-26 15:41:37\",\"tender_project_type\":\"A99\",\"bzj_etime\":\"2027-06-18 11:12:03\",\"bd_name\":\"标段1\",\"start_date\":\"2027-06-15 11:12:03\",\"bzj_stime\":\"2024-06-18 11:12:03\",\"tender_file_url\":\"https://filetest.enjoy5191.com:15064/File/GetQiniuContent?appId=test_ebid_szj&key=%E4%BD%8F%E5%BB%BA-%E5%8D%8E%E5%AE%89%E4%BF%9D%E9%99%A9%E4%BF%9D%E6%B6%B5%E6%B5%81%E7%A8%8B%E9%AA%8C%E8%AF%81-RNM20240326_%E6%8B%9B%E6%A0%87%E6%96%87%E4%BB%B6_20240326154137.zip\",\"tender_file_url_md5\":\"d72fa88274c9449252a172afe832124e\",\"bdid\":\"42370bf371e74bb984aef56718520a81\",\"premium\":\"300.00000\",\"project_approval_no\":\"234234\",\"tpid\":\"345\"},\"applicant\":{\"applicant_name\":\"湖南弘湘建设工程管理有限公司\",\"city\":\"福州\",\"license_files\":[\"https://filetest.enjoy5191.com:15064/file/getcontent/6115d42094ce671bd8ff8e4f.png\"],\"province\":\"福建\",\"com_tel_num\":\"18888888866\",\"address\":\"高新科技园创业大厦25楼随行软件有限公司星网锐捷66\",\"legal_name\":\"法定代表人姓名166\",\"credit_vld\":\"2023-09-01\",\"credit_code\":\"91350206M00019WY2P\",\"com_tel_area\":\"\",\"legal_num\":\"62040320240328205X\",\"email\":\"743203624@qq.com\",\"bzj_way\":\"BAOXIAN_BAOHAN\",\"contact_mobile\":\"15605914788\",\"district\":\"闽候\",\"contact_name\":\"李一一\"},\"assured\":{\"assured_name\":\"345\",\"agency\":\"345\",\"district\":\"\",\"city\":\"-\",\"province\":\"\",\"com_tel_num\":\"1323423423\",\"address\":\"12312\",\"credit_vld\":\"\",\"credit_code\":\"123123123\",\"com_tel_area\":\"\",\"tender_bank_account\":\"-\",\"tender_bank_openbank\":\"-\",\"contact_mobile\":\"1323423423\",\"contact_name\":\"23234\",\"tender_account_name\":\"-\"}}}"
err := json.Unmarshal([]byte(str), &param)
if err != nil {
fmt.Println(err.Error())
}
s, err := json.Marshal(param)
fmt.Println(string(s))
}
func jsonum1() {
//var param map[string]interface{}
str := "{\"requestid\":\"2c5db07a2ace41dea1ddf894f2bae1fe\",\"appid\":\"zijin\",\"timestamp\":\"1719193514\",\"version\":\"1.0.0\",\"sign\":\"3ffff2e00610b3bc46d818c0b2fbd7ce7236b839\",\"data\":{\"user\":{\"unitname\":\"湖南弘湘建设工程管理有限公司\",\"insurances_start\":\"\",\"username\":\"投标企业4\",\"server_amount\":\"200.000\",\"bank_name\":\"中国建设银行\",\"userid\":\"5987c1944b0931216ce8526f\",\"beiandiqu_code\":\"x00004\",\"unitid\":\"5993a8144b09311cacb51e12\",\"bank_card_num\":\"6217001820001592123\",\"buinessNo\":[],\"mobile\":\"15605914788\",\"bank_user_name\":\"湖南弘湘建设工程管理有限公司\",\"fileList\":[],\"guarantee_type\":\"0\",\"rate\":\"\",\"policy_period_type\":\"\",\"unit_qual\":\"\",\"insurances_end\":\"\"},\"project\":{\"amount\":\"300000.00\",\"bulid_price\":\"3424257\",\"plan_date\":\"108日历天\",\"district\":\"350100\",\"city\":\"350100\",\"valid_period\":\"23\",\"name\":\"住建-测试项目\",\"province\":\"350000\",\"bulid_place\":\"23412\",\"tender_notice_url\":\"http://192.168.118.171:7702/views/pages/entp-view.html?type=tp&tpId=66027a207109b83d96aa86eb&flag=false&foId=66027a207109b83d96aa86eb\",\"createtime\":\"2024-03-26 15:41:37\",\"tender_project_type\":\"A99\",\"bzj_etime\":\"2027-06-18 11:12:03\",\"bd_name\":\"标段1\",\"start_date\":\"2027-06-15 11:12:03\",\"bzj_stime\":\"2024-06-18 11:12:03\",\"tender_file_url\":\"https://filetest.enjoy5191.com:15064/File/GetQiniuContent?appId=test_ebid_szj&key=%E4%BD%8F%E5%BB%BA-%E5%8D%8E%E5%AE%89%E4%BF%9D%E9%99%A9%E4%BF%9D%E6%B6%B5%E6%B5%81%E7%A8%8B%E9%AA%8C%E8%AF%81-RNM20240326_%E6%8B%9B%E6%A0%87%E6%96%87%E4%BB%B6_20240326154137.zip\",\"tender_file_url_md5\":\"d72fa88274c9449252a172afe832124e\",\"bdid\":\"42370bf371e74bb984aef56718520a81\",\"premium\":\"300.00000\",\"project_approval_no\":\"234234\",\"tpid\":\"345\"},\"applicant\":{\"applicant_name\":\"湖南弘湘建设工程管理有限公司\",\"city\":\"福州\",\"license_files\":[\"https://filetest.enjoy5191.com:15064/file/getcontent/6115d42094ce671bd8ff8e4f.png\"],\"province\":\"福建\",\"com_tel_num\":\"18888888866\",\"address\":\"高新科技园创业大厦25楼随行软件有限公司星网锐捷66\",\"legal_name\":\"法定代表人姓名166\",\"credit_vld\":\"2023-09-01\",\"credit_code\":\"91350206M00019WY2P\",\"com_tel_area\":\"\",\"legal_num\":\"62040320240328205X\",\"email\":\"743203624@qq.com\",\"bzj_way\":\"BAOXIAN_BAOHAN\",\"contact_mobile\":\"15605914788\",\"district\":\"闽候\",\"contact_name\":\"李一一\"},\"assured\":{\"assured_name\":\"345\",\"agency\":\"345\",\"district\":\"\",\"city\":\"-\",\"province\":\"\",\"com_tel_num\":\"1323423423\",\"address\":\"12312\",\"credit_vld\":\"\",\"credit_code\":\"123123123\",\"com_tel_area\":\"\",\"tender_bank_account\":\"-\",\"tender_bank_openbank\":\"-\",\"contact_mobile\":\"1323423423\",\"contact_name\":\"23234\",\"tender_account_name\":\"-\"}}}"
val := gjson.Get(str, "data")
fmt.Println(val.String())
}
func runServerInWindows() {
r := gin.Default()
router.Initial(r)

@ -25,5 +25,7 @@ zking:
app-secret: ""
suixing:
base-url: "https://test-open.zking.com"
app-id: "2024060132098212"
app-secret: "N1xsd0sPxoWxUYb6"
# app-id: "2024060132098212"
# app-secret: "N1xsd0sPxoWxUYb6"
app-id: "zijin"
app-secret: "25CCFF96DC3E106F33E0D8C0B61126B0"

@ -43,6 +43,9 @@ require (
github.com/pelletier/go-toml/v2 v2.2.2 // indirect
github.com/richardlehane/mscfb v1.0.4 // indirect
github.com/richardlehane/msoleps v1.0.3 // indirect
github.com/tidwall/gjson v1.17.1 // indirect
github.com/tidwall/match v1.1.1 // indirect
github.com/tidwall/pretty v1.2.1 // indirect
github.com/twitchyliquid64/golang-asm v0.15.1 // indirect
github.com/ugorji/go/codec v1.2.12 // indirect
github.com/xuri/efp v0.0.0-20231025114914-d1ff6096ae53 // indirect

@ -125,6 +125,13 @@ github.com/stretchr/testify v1.8.1/go.mod h1:w2LPCIKwWwSfY2zedu0+kehJoqGctiVI29o
github.com/stretchr/testify v1.8.4/go.mod h1:sz/lmYIOXD/1dqDmKjjqLyZ2RngseejIcXlSw2iwfAo=
github.com/stretchr/testify v1.9.0 h1:HtqpIVDClZ4nwg75+f6Lvsy/wHu+3BoSGCbBAcpTsTg=
github.com/stretchr/testify v1.9.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY=
github.com/tidwall/gjson v1.17.1 h1:wlYEnwqAHgzmhNUFfw7Xalt2JzQvsMx2Se4PcoFCT/U=
github.com/tidwall/gjson v1.17.1/go.mod h1:/wbyibRr2FHMks5tjHJ5F8dMZh3AcwJEMf5vlfC0lxk=
github.com/tidwall/match v1.1.1 h1:+Ho715JplO36QYgwN9PGYNhgZvoUSc9X2c80KVTi+GA=
github.com/tidwall/match v1.1.1/go.mod h1:eRSPERbgtNPcGhD8UCthc6PmLEQXEWd3PRB5JTxsfmM=
github.com/tidwall/pretty v1.2.0/go.mod h1:ITEVvHYasfjBbM0u2Pg8T2nJnzm8xPwvNhhsoaGGjNU=
github.com/tidwall/pretty v1.2.1 h1:qjsOFOWWQl+N3RsoF5/ssm1pHmJJwhjlSbZ51I6wMl4=
github.com/tidwall/pretty v1.2.1/go.mod h1:ITEVvHYasfjBbM0u2Pg8T2nJnzm8xPwvNhhsoaGGjNU=
github.com/tjfoc/gmsm v1.4.1 h1:aMe1GlZb+0bLjn+cKTPEvvn9oUEBlJitaZiiBwsbgho=
github.com/tjfoc/gmsm v1.4.1/go.mod h1:j4INPkHWMrhJb38G+J6W4Tw0AbuN8Thu3PbdVYhVcTE=
github.com/twitchyliquid64/golang-asm v0.15.1 h1:SU5vSMR7hnwNxj24w34ZyCi/FmDZTkS4MhqMhdFk5YI=

BIN
insure

Binary file not shown.

@ -24,32 +24,26 @@ var OrderService = orderService{}
type orderService struct {
}
func (s *orderService) CreateOrder(param suixing.CommonParam) (*model.Order, error) {
func (s *orderService) CreateOrder(param suixing.CreateParam) (*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)
user, err := s.saveUser(orderSn, param.Data.User)
if err != nil {
return nil, err
}
project, err := s.saveProject(orderSn, orderParam.Project)
project, err := s.saveProject(orderSn, param.Data.Project)
if err != nil {
return nil, err
}
applicant, err := s.saveApplicant(orderSn, orderParam.Applicant)
applicant, err := s.saveApplicant(orderSn, param.Data.Applicant)
if err != nil {
return nil, err
}
assured, err := s.saveAssured(orderSn, orderParam.Assured)
assured, err := s.saveAssured(orderSn, param.Data.Assured)
if err != nil {
return nil, err
}
@ -319,7 +313,7 @@ func (s *orderService) PostToZking(orderSn string) (*zking.Result, error) {
Agency: order.Assured.Agency,
}
createData := suixing.Order{
createData := suixing.CreateData{
User: user,
Project: project,
Applicant: applicant,

@ -18,7 +18,7 @@ type suixingApi struct {
}
func (api *suixingApi) CreateOrderCallback(param CommonParam) (*Result, error) {
err := api.Sign(&param)
err := api.Sign(&param, "")
if err != nil {
return nil, err
}
@ -34,23 +34,25 @@ func (api *suixingApi) CreateOrderCallback(param CommonParam) (*Result, error) {
return &result, nil
}
func (api *suixingApi) Sign(param *CommonParam) error {
func (api *suixingApi) Sign(param *CommonParam, data string) error {
//vals, err := utils.StructToURLValues(param)
fmt.Println("data: " + data)
data = "{\"user\":{\"unitname\":\"湖南弘湘建设工程管理有限公司\",\"insurances_start\":\"\",\"username\":\"投标企业4\",\"server_amount\":\"200.000\",\"bank_name\":\"中国建设银行\",\"userid\":\"5987c1944b0931216ce8526f\",\"beiandiqu_code\":\"x00004\",\"unitid\":\"5993a8144b09311cacb51e12\",\"bank_card_num\":\"6217001820001592123\",\"buinessNo\":[],\"mobile\":\"15605914788\",\"bank_user_name\":\"湖南弘湘建设工程管理有限公司\",\"fileList\":[],\"guarantee_type\":\"0\",\"rate\":\"\",\"policy_period_type\":\"\",\"unit_qual\":\"\",\"insurances_end\":\"\"},\"project\":{\"amount\":\"300000.00\",\"bulid_price\":\"3424257\",\"plan_date\":\"108日历天\",\"district\":\"350100\",\"city\":\"350100\",\"valid_period\":\"23\",\"name\":\"住建-测试项目\",\"province\":\"350000\",\"bulid_place\":\"23412\",\"tender_notice_url\":\"http://192.168.118.171:7702/views/pages/entp-view.html?type=tp&tpId=66027a207109b83d96aa86eb&flag=false&foId=66027a207109b83d96aa86eb\",\"createtime\":\"2024-03-26 15:41:37\",\"tender_project_type\":\"A99\",\"bzj_etime\":\"2027-06-18 11:12:03\",\"bd_name\":\"标段1\",\"start_date\":\"2027-06-15 11:12:03\",\"bzj_stime\":\"2024-06-18 11:12:03\",\"tender_file_url\":\"https://filetest.enjoy5191.com:15064/File/GetQiniuContent?appId=test_ebid_szj&key=%E4%BD%8F%E5%BB%BA-%E5%8D%8E%E5%AE%89%E4%BF%9D%E9%99%A9%E4%BF%9D%E6%B6%B5%E6%B5%81%E7%A8%8B%E9%AA%8C%E8%AF%81-RNM20240326_%E6%8B%9B%E6%A0%87%E6%96%87%E4%BB%B6_20240326154137.zip\",\"tender_file_url_md5\":\"d72fa88274c9449252a172afe832124e\",\"bdid\":\"42370bf371e74bb984aef56718520a81\",\"premium\":\"300.00000\",\"project_approval_no\":\"234234\",\"tpid\":\"345\"},\"applicant\":{\"applicant_name\":\"湖南弘湘建设工程管理有限公司\",\"city\":\"福州\",\"license_files\":[\"https://filetest.enjoy5191.com:15064/file/getcontent/6115d42094ce671bd8ff8e4f.png\"],\"province\":\"福建\",\"com_tel_num\":\"18888888866\",\"address\":\"高新科技园创业大厦25楼随行软件有限公司星网锐捷66\",\"legal_name\":\"法定代表人姓名166\",\"credit_vld\":\"2023-09-01\",\"credit_code\":\"91350206M00019WY2P\",\"com_tel_area\":\"\",\"legal_num\":\"62040320240328205X\",\"email\":\"743203624@qq.com\",\"bzj_way\":\"BAOXIAN_BAOHAN\",\"contact_mobile\":\"15605914788\",\"district\":\"闽候\",\"contact_name\":\"李一一\"},\"assured\":{\"assured_name\":\"345\",\"agency\":\"345\",\"district\":\"\",\"city\":\"-\",\"province\":\"\",\"com_tel_num\":\"1323423423\",\"address\":\"12312\",\"credit_vld\":\"\",\"credit_code\":\"123123123\",\"com_tel_area\":\"\",\"tender_bank_account\":\"-\",\"tender_bank_openbank\":\"-\",\"contact_mobile\":\"1323423423\",\"contact_name\":\"23234\",\"tender_account_name\":\"-\"}}"
vals := url.Values{}
vals.Set("appid", global.Config.Suixing.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("data", utils.Md5(data))
vals.Set("appsecret", global.Config.Suixing.AppSecret)
fmt.Println(vals.Encode())
param.Sign = utils.Sha1(vals.Encode())
return nil
}
func (api *suixingApi) Verify(param CommonParam) bool {
func (api *suixingApi) Verify(param CommonParam, data string) bool {
postSign := param.Sign
err := api.Sign(&param)
err := api.Sign(&param, data)
if err != nil {
fmt.Println("sign error")
return false

@ -5,6 +5,5 @@ type CommonParam struct {
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"`
}

@ -1,6 +1,6 @@
package suixing
type Order struct {
type CreateData struct {
User User `json:"user" form:"user"`
Project Project `json:"project" form:"project"`
Applicant Applicant `json:"applicant" form:"applicant"`

@ -0,0 +1,6 @@
package suixing
type CreateParam struct {
CommonParam
Data CreateData `json:"data" form:"data"`
}
Loading…
Cancel
Save