Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
N
Njzj.Biz.Bocoms.Openapis.V4.5
Project
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
陶然
Njzj.Biz.Bocoms.Openapis.V4.5
Commits
1bc98960
Commit
1bc98960
authored
Aug 03, 2023
by
陶然
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
优化
parent
7d84f33a
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
226 additions
and
42 deletions
+226
-42
Extension.cs
Extension.cs
+2
-2
Njzj.Biz.Bocoms.Openapis.V4.5.csproj
Njzj.Biz.Bocoms.Openapis.V4.5.csproj
+5
-8
WriteOffResultResponseV2.cs
Sdk/response/WriteOffResultResponseV2.cs
+135
-23
ApiUtils.cs
Sdk/utils/ApiUtils.cs
+81
-7
RestfulTest.cs
Transforms/RestfulTest.cs
+0
-0
packages.config
packages.config
+3
-2
No files found.
Extension.cs
View file @
1bc98960
...
...
@@ -27,13 +27,13 @@ namespace Com.Bocom.OpenApi
client
.
IgnoreSslHostnameVerifier
();
var
bizKvid
=
settlement
.
Kvid
.
ToString
();
var
bizId
=
settlement
.
BizId
;
var
request
=
new
AddContractOrderRequestV2
();
request
.
SetServiceUrl
(
Configs
.
APIGW_URL_ADDRESS
+
Configs
.
AddContractOrderRequestV2
);
var
bizContent
=
new
AddContractOrderRequestV2
.
AddContractOrderRequestV2Biz
();
bizContent
.
org_id
=
Configs
.
ORG_ID
;
bizContent
.
bat_id
=
biz
Kvi
d
;
bizContent
.
bat_id
=
biz
I
d
;
bizContent
.
cont_order_list
=
new
List
<
ContOrder
>();
var
contorder
=
new
ContOrder
();
contorder
.
cont_id
=
bizKvid
;
...
...
Njzj.Biz.Bocoms.Openapis.V4.5.csproj
View file @
1bc98960
...
...
@@ -35,17 +35,14 @@
<SpecificVersion>
False
</SpecificVersion>
<HintPath>
Sdk\Dll\BouncyCastle.Crypto.dll
</HintPath>
</Reference>
<Reference
Include=
"Kivii.Common.V4.5, Version=5.6.2023.4000, Culture=neutral, processorArchitecture=MSIL"
>
<HintPath>
..\..\k5-njzj\packages\Kivii.Common.5.6.2023.4000\lib\net45\Kivii.Common.V4.5.dll
</HintPath>
<Private>
False
</Private>
<Reference
Include=
"Kivii.Common.V4.5, Version=5.6.2023.6000, Culture=neutral, processorArchitecture=MSIL"
>
<HintPath>
..\local-njzj\packages\Kivii.Common.5.6.2023.6000\lib\net45\Kivii.Common.V4.5.dll
</HintPath>
</Reference>
<Reference
Include=
"Kivii.Core.V4.5, Version=5.6.2023.4140, Culture=neutral, processorArchitecture=MSIL"
>
<HintPath>
..\..\k5-njzj\packages\Kivii.Core.5.6.2023.4140\lib\net45\Kivii.Core.V4.5.dll
</HintPath>
<Private>
False
</Private>
<Reference
Include=
"Kivii.Core.V4.5, Version=5.6.2023.6000, Culture=neutral, processorArchitecture=MSIL"
>
<HintPath>
..\local-njzj\packages\Kivii.Core.5.6.2023.6000\lib\net45\Kivii.Core.V4.5.dll
</HintPath>
</Reference>
<Reference
Include=
"Kivii.Linq.V4.5, Version=5.6.2023.4200, Culture=neutral, processorArchitecture=MSIL"
>
<HintPath>
..\..\k5-njzj\packages\Kivii.Linq.5.6.2023.4200\lib\net45\Kivii.Linq.V4.5.dll
</HintPath>
<Private>
False
</Private>
<HintPath>
..\local-njzj\packages\Kivii.Linq.5.6.2023.4200\lib\net45\Kivii.Linq.V4.5.dll
</HintPath>
</Reference>
<Reference
Include=
"System"
/>
<Reference
Include=
"System.Core"
/>
...
...
Sdk/response/WriteOffResultResponseV2.cs
View file @
1bc98960
...
...
@@ -600,9 +600,30 @@ namespace Com.Bocom.OpenApi
}
}
public
class
WriteOffBizContentObj
{
public
string
biz_content
{
get
;
set
;
}
public
string
msg_id
{
get
;
set
;
}
public
string
timestamp
{
get
;
set
;
}
public
string
encrypt_key
{
get
;
set
;
}
}
[
Alias
(
"BCOM_WriteOffResultNotifys"
)]
public
class
WriteOffResultNotify
:
EntityWithMetadata
{
public
string
BillId
{
get
;
set
;
}
[
DefaultEmptyGuid
]
public
Guid
BizKvid
{
get
;
set
;
}
[
ApiMember
(
Description
=
"业务流水号"
)]
[
StringLength
(
200
)]
public
string
BizId
{
get
;
set
;
}
[
ApiMember
(
Description
=
"业务类型"
)]
[
StringLength
(
100
)]
public
string
BizType
{
get
;
set
;
}
public
WriteOffBizContent
biz_content
{
get
;
set
;
}
[
StringLength
(
2000
)]
public
string
encrypt_key
{
get
;
set
;
}
...
...
@@ -618,50 +639,141 @@ namespace Com.Bocom.OpenApi
public
class
WriteOffBizContent
{
public
string
transcode
{
get
;
set
;
}
/// <summary>
///
/// appid@http://notify.com
/// </summary>
public
string
communication_url
{
get
;
set
;
}
/// <summary>
/// 机构编号
/// </summary>
public
string
org_id
{
get
;
set
;
}
/// <summary>
/// 账单编号
/// </summary>
public
string
bill_id
{
get
;
set
;
}
/// <summary>
/// 应付款人
/// </summary>
public
string
term_trans_time
{
get
;
set
;
}
public
string
ori_payer
{
get
;
set
;
}
/// <summary>
///
///
实际应付金额
/// </summary>
public
string
requester_type
{
get
;
set
;
}
public
string
ori_act_amt
{
get
;
set
;
}
/// <summary>
///
///
此次账单核销总金额
/// </summary>
public
string
trace_no
{
get
;
set
;
}
public
string
bill_write_off_amt
{
get
;
set
;
}
/// <summary>
///
///
合同号
/// </summary>
public
string
version
{
get
;
set
;
}
public
string
cont_id
{
get
;
set
;
}
/// <summary>
///
///
费项名称
/// </summary>
public
string
mer_ptc_id
{
get
;
set
;
}
public
string
ori_itm_nme
{
get
;
set
;
}
/// <summary>
///
///
账期
/// </summary>
public
string
mobile_no
{
get
;
set
;
}
public
string
payment_period
{
get
;
set
;
}
/// <summary>
///
///
账单已核销金额
/// </summary>
public
string
cert_type
{
get
;
set
;
}
public
string
write_off_amt
{
get
;
set
;
}
/// <summary>
///
///
账单核销状态 01-未核销; 02-部分核销; 03-全额核销; 04-失效
/// </summary>
public
string
cert_no
{
get
;
set
;
}
public
string
bill_wo_state
{
get
;
set
;
}
/// <summary>
///
///
核销编号
/// </summary>
public
string
cus_name
{
get
;
set
;
}
public
string
write_off_no
{
get
;
set
;
}
/// <summary>
///
///
核销日期
/// </summary>
public
string
reserved
{
get
;
set
;
}
public
string
write_off_dte
{
get
;
set
;
}
/// <summary>
///
///
核销状态 01-已核销;02-核销待确认
/// </summary>
public
string
communication_url
{
get
;
set
;
}
public
string
write_off_state
{
get
;
set
;
}
/// <summary>
/// 备注
/// </summary>
public
string
remark
{
get
;
set
;
}
/// <summary>
/// 流水列表
/// </summary>
public
List
<
PayDetail
>
pay_detail_list
{
get
;
set
;
}
}
public
class
PayDetail
{
/// <summary>
/// 会计传票号
/// </summary>
public
string
vch_no
{
get
;
set
;
}
/// <summary>
/// 对方户名
/// </summary>
public
string
opp_ac_nme
{
get
;
set
;
}
/// <summary>
/// 交易金额
/// </summary>
public
string
txn_amt
{
get
;
set
;
}
/// <summary>
/// 交易时间
/// </summary>
public
string
tr_time
{
get
;
set
;
}
/// <summary>
/// 交易渠道
/// </summary>
public
string
chnl
{
get
;
set
;
}
/// <summary>
/// 流水核销金额
/// </summary>
public
string
jnl_write_off_amt
{
get
;
set
;
}
/// <summary>
/// 流水已核销金额
/// </summary>
public
string
write_off_amt
{
get
;
set
;
}
/// <summary>
/// 流水核销状态 01-未核销; 02-部分核销; 03-全额核销; 04-失效
/// </summary>
public
string
jnl_wo_state
{
get
;
set
;
}
/// <summary>
/// 备注
/// </summary>
public
string
remark
{
get
;
set
;
}
}
}
Sdk/utils/ApiUtils.cs
View file @
1bc98960
...
...
@@ -4,6 +4,8 @@ using System.IO;
using
System.Runtime.Serialization.Json
;
using
Com.Bocom.OpenApi.Security.Sign
;
using
System.Collections.Generic
;
using
System.Linq
;
using
Org.BouncyCastle.Asn1.Crmf
;
namespace
Com.Bocom.OpenApi
{
...
...
@@ -46,7 +48,7 @@ namespace Com.Bocom.OpenApi
using
(
MemoryStream
ms
=
new
MemoryStream
(
Encoding
.
GetEncoding
(
charset
).
GetBytes
(
bizContentStr
)))
{
DataContractJsonSerializer
deseralizer
=
new
DataContractJsonSerializer
(
T
);
response
=
(
BocomResponse
)
deseralizer
.
ReadObject
(
ms
)
as
BocomResponse
;
response
=
(
BocomResponse
)
deseralizer
.
ReadObject
(
ms
)
as
BocomResponse
;
}
return
response
;
...
...
@@ -59,13 +61,13 @@ namespace Com.Bocom.OpenApi
}
}
public
static
Object
ParseCommunicationJsonWithBocomSign
(
string
respStr
,
string
charset
,
string
MY_PRIVATE_KEY
,
string
APIGW_PUBLIC_KEY
)
public
static
WriteOffResultNotify
ParseCommunicationJsonWithBocomSign
(
string
respStr
,
string
charset
,
string
MY_PRIVATE_KEY
,
string
APIGW_PUBLIC_KEY
)
{
string
bizContentStr
;
string
sign
;
try
{
//
int indexOfRootStart = respStr.IndexOf(BocomConstants.BIZ_CONTENT) + BocomConstants.BIZ_CONTENT.Length + 2;
int
indexOfRootStart
=
respStr
.
IndexOf
(
BocomConstants
.
BIZ_CONTENT
)
+
BocomConstants
.
BIZ_CONTENT
.
Length
+
2
;
int
indexOfRootEnd
=
respStr
.
LastIndexOf
(
","
);
int
indexOfSignStart
=
respStr
.
LastIndexOf
(
BocomConstants
.
SIGN
+
"\""
)
+
BocomConstants
.
SIGN
.
Length
+
3
;
int
indexOfSignEnd
=
respStr
.
LastIndexOf
(
"\""
);
...
...
@@ -90,16 +92,87 @@ namespace Com.Bocom.OpenApi
var
reqBizContentEncrypt
=
jsonDic
[
"biz_content"
];
var
encryptKey
=
BocomEncrypt
.
AsymmetricalDecrypt
(
encryptKeyEncrypt
,
BocomConstants
.
ENCRYPT_TYPE_RSA_AND_AES
,
MY_PRIVATE_KEY
,
charset
);
var
reqBizContent
=
BocomEncrypt
.
SymmetricalDecrypt
(
reqBizContentEncrypt
,
BocomConstants
.
ENCRYPT_TYPE_RSA_AND_AES
,
encryptKey
,
charset
);
jsonDic
[
"encrypt_key"
]
=
encryptKey
;
jsonDic
[
"biz_content"
]
=
reqBizContent
;
//var rtns=Kivii.Text.JsonSerializer.SerializeToString(jsonDic);
return
jsonDic
;
var
rtns
=
new
WriteOffResultNotify
();
rtns
.
encrypt_key
=
encryptKey
;
rtns
.
msg_id
=
jsonDic
[
"msg_id"
];
rtns
.
timestamp
=
jsonDic
[
"timestamp"
];
rtns
.
sign
=
sign
;
rtns
.
biz_content
=
Kivii
.
Text
.
JsonSerializer
.
DeserializeFromString
<
WriteOffBizContent
>(
reqBizContent
);
rtns
[
"encrypt_key"
]
=
encryptKey
;
rtns
[
"biz_content"
]
=
reqBizContent
;
rtns
[
"msg_id"
]
=
jsonDic
[
"msg_id"
];
rtns
[
"timestamp"
]
=
jsonDic
[
"timestamp"
];
rtns
[
"sign"
]
=
sign
;
return
rtns
;
}
catch
(
Exception
e
)
{
throw
new
Exception
(
"Bocom decrypt not success."
,
e
);
}
}
public
static
WriteOffResultNotify
ParseCommunicationJsonWithBocomSign
(
Dictionary
<
string
,
string
>
respStr
,
string
charset
,
string
MY_PRIVATE_KEY
,
string
APIGW_PUBLIC_KEY
)
{
string
biz_content
=
respStr
[
"biz_content"
];
string
msg_id
=
respStr
[
"msg_id"
];
string
timestamp
=
respStr
[
"timestamp"
];
string
encrypt_key
=
respStr
[
"encrypt_key"
];
string
sign
=
respStr
[
"sign"
];
var
notify
=
new
WriteOffBizContentObj
();
notify
.
biz_content
=
biz_content
;
notify
.
msg_id
=
msg_id
;
notify
.
timestamp
=
timestamp
;
notify
.
encrypt_key
=
encrypt_key
;
var
biz_contentStr
=
Kivii
.
Text
.
JsonSerializer
.
SerializeToString
(
notify
);
biz_contentStr
=
biz_contentStr
.
Replace
(
"{"
,
""
);
biz_contentStr
=
biz_contentStr
.
Replace
(
"}"
,
""
);
Boolean
passed
=
BocomSignature
.
Verify
(
BocomConstants
.
ENCRYPT_TYPE_RSA_AND_AES
,
biz_contentStr
,
APIGW_PUBLIC_KEY
,
charset
,
sign
);
if
(!
passed
)
{
throw
new
Exception
(
"Bocom sign verify not passed."
);
}
try
{
//var jsonDic = Kivii.Text.JsonSerializer.DeserializeFromString<Dictionary<string, string>>(respStr);
var
encryptKeyEncrypt
=
encrypt_key
;
var
reqBizContentEncrypt
=
biz_content
;
var
encryptKey
=
BocomEncrypt
.
AsymmetricalDecrypt
(
encryptKeyEncrypt
,
BocomConstants
.
ENCRYPT_TYPE_RSA_AND_AES
,
MY_PRIVATE_KEY
,
charset
);
var
reqBizContent
=
BocomEncrypt
.
SymmetricalDecrypt
(
reqBizContentEncrypt
,
BocomConstants
.
ENCRYPT_TYPE_RSA_AND_AES
,
encryptKey
,
charset
);
var
rtns
=
new
WriteOffResultNotify
();
rtns
.
encrypt_key
=
encryptKey
;
rtns
.
msg_id
=
msg_id
;
rtns
.
timestamp
=
timestamp
;
rtns
.
sign
=
sign
;
rtns
.
biz_content
=
Kivii
.
Text
.
JsonSerializer
.
DeserializeFromString
<
WriteOffBizContent
>(
reqBizContent
);
rtns
[
"encrypt_key"
]
=
encryptKey
;
rtns
[
"biz_content"
]
=
reqBizContent
;
rtns
[
"msg_id"
]
=
msg_id
;
rtns
[
"timestamp"
]
=
timestamp
;
rtns
[
"sign"
]
=
sign
;
return
rtns
;
}
catch
(
Exception
e
)
{
throw
new
Exception
(
"Bocom decrypt not success."
,
e
);
}
}
public
static
object
SignRspBizContent
(
string
rspBizContent
,
string
encrypt_key
,
string
mY_PRIVATE_KEY
)
{
var
rspContent
=
BocomEncrypt
.
SymmetricalEncrypt
(
rspBizContent
,
BocomConstants
.
ENCRYPT_TYPE_RSA_AND_AES
,
encrypt_key
,
"UTF-8"
);
string
signContent
;
try
{
signContent
=
BocomSignature
.
Sign
(
BocomConstants
.
ENCRYPT_TYPE_RSA_AND_AES
,
rspContent
,
mY_PRIVATE_KEY
,
"UTF-8"
);
}
catch
(
Exception
ex
)
{
throw
new
BocomApiException
(
$"Bocom sign not success.
{
ex
.
Message
}
"
);
}
string
newBody
=
"{\"rsp_biz_content\":\""
+
rspContent
+
"\",\"sign\":\""
+
signContent
+
"\"}"
;
return
newBody
;
}
}
}
}
\ No newline at end of file
Transforms/RestfulTest.cs
View file @
1bc98960
This diff is collapsed.
Click to expand it.
packages.config
View file @
1bc98960
<?
xml
version
=
"1.0"
encoding
=
"utf-8"
?>
<
packages
>
<
package
id
=
"Kivii.Common"
version
=
"5.6.2023.
4
000"
targetFramework
=
"net45"
/>
<
package
id
=
"Kivii.Core"
version
=
"5.6.2023.
414
0"
targetFramework
=
"net45"
/>
<
package
id
=
"Kivii.Common"
version
=
"5.6.2023.
6
000"
targetFramework
=
"net45"
/>
<
package
id
=
"Kivii.Core"
version
=
"5.6.2023.
600
0"
targetFramework
=
"net45"
/>
<
package
id
=
"Kivii.Linq"
version
=
"5.6.2023.4200"
targetFramework
=
"net45"
/>
</
packages
>
\ No newline at end of file
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment