Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
M
mall.oytour.com
Project
Project
Details
Activity
Releases
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
黄奎
mall.oytour.com
Commits
1a955160
Commit
1a955160
authored
Jun 04, 2020
by
黄奎
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'master' of
http://gitlab.oytour.com/Kui2/mall.oytour.com
parents
d2d941ce
b26e508a
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
110 additions
and
8 deletions
+110
-8
PayUtil.cs
Mall.WebApi/App_Code/PayUtil.cs
+71
-3
PublishController.cs
Mall.WebApi/Controllers/AppletWeChat/PublishController.cs
+24
-1
WeChatPayController.cs
Mall.WebApi/Controllers/AppletWeChat/WeChatPayController.cs
+15
-4
No files found.
Mall.WebApi/App_Code/PayUtil.cs
View file @
1a955160
...
...
@@ -46,11 +46,10 @@ namespace Mall.WebApi.App_Code
/// <param name="CustomerId"></param>
/// <param name="openid"></param>
/// <returns></returns>
public
static
string
GetMinUnifiedOrder
(
string
sOrderNo
,
string
sProductName
,
decimal
dPrice
,
string
CustomerId
,
string
openid
,
RB_MiniProgram_Extend
model
,
IHttpContextAccessor
_accessor
,
string
IPAddress
)
public
static
string
GetMinUnifiedOrder
(
string
sOrderNo
,
string
sProductName
,
decimal
dPrice
,
string
CustomerId
,
string
openid
,
string
notify_url
,
RB_MiniProgram_Extend
model
,
IHttpContextAccessor
_accessor
,
string
IPAddress
)
{
var
req
=
new
Common
.
Pay
.
WeChatPat
.
RequestHandler
();
req
.
SetKey
(
model
.
WeChatApiSecret
);
//
req
.
SetParameter
(
"appid"
,
model
.
MiniAppId
);
//微信开放平台审核通过的应用APPID
req
.
SetParameter
(
"mch_id"
,
model
.
WeChatPayMerchants
);
//微信支付分配的商户号
req
.
SetParameter
(
"nonce_str"
,
GetNoncestr
());
//随机字符串,不长于32位
...
...
@@ -61,7 +60,7 @@ namespace Mall.WebApi.App_Code
req
.
SetParameter
(
"spbill_create_ip"
,
IPAddress
);
req
.
SetParameter
(
"time_start"
,
DateTime
.
Now
.
ToString
(
"yyyyMMddHHmmss"
));
req
.
SetParameter
(
"time_expire"
,
DateTime
.
Now
.
AddMinutes
(
10
).
ToString
(
"yyyyMMddHHmmss"
));
req
.
SetParameter
(
"notify_url"
,
Config
.
sTenpayNotify
);
req
.
SetParameter
(
"notify_url"
,
notify_url
);
req
.
SetParameter
(
"trade_type"
,
"JSAPI"
);
req
.
SetParameter
(
"openid"
,
openid
);
req
.
SetParameter
(
"sign"
,
req
.
CreateMd5Sign
(
_accessor
,
model
.
WeChatApiSecret
));
...
...
@@ -494,6 +493,75 @@ namespace Mall.WebApi.App_Code
/// <summary>
/// 当面支付
/// </summary>
/// <param name="sOrderNo"></param>
/// <param name="dPrice"></param>
/// <param name="CustomerId"></param>
/// <param name="model"></param>
/// <param name="_accessor"></param>
/// <returns></returns>
public
static
BaseResult
GetNativeOrder
(
string
sOrderNo
,
decimal
dPrice
,
string
ProductName
,
string
CustomerId
,
RB_MiniProgram_Extend
model
,
string
IPAddress
,
IHttpContextAccessor
_accessor
)
{
var
req
=
new
Common
.
Pay
.
WeChatPat
.
RequestHandler
();
req
.
SetKey
(
model
.
WeChatApiSecret
);
req
.
SetParameter
(
"appid"
,
model
.
MiniAppId
);
//微信开放平台审核通过的应用APPID
req
.
SetParameter
(
"mch_id"
,
model
.
WeChatPayMerchants
);
//微信支付分配的商户号
req
.
SetParameter
(
"nonce_str"
,
GetNoncestr
());
//随机字符串,不长于32位
req
.
SetParameter
(
"out_trade_no"
,
sOrderNo
);
//商户订单号,需保持唯一性(只能是字母或者数字,不能包含有其它字符)
req
.
SetParameter
(
"body"
,
ProductName
);
req
.
SetParameter
(
"total_fee"
,
(
dPrice
*
100
).
ToString
(
"f0"
));
req
.
SetParameter
(
"spbill_create_ip"
,
IPAddress
);
req
.
SetParameter
(
"notify_url"
,
Config
.
sTenpayNotify
);
//回调地址20200604 后面用的时候修改,现在只是把支付调通
req
.
SetParameter
(
"trade_type"
,
"NATIVE"
);
//
req
.
SetParameter
(
"sign"
,
req
.
CreateMd5Sign
(
_accessor
,
model
.
WeChatApiSecret
));
var
reqXml
=
req
.
ParseXml
();
var
result
=
Common
.
Pay
.
WeChatPat
.
HttpHelper
.
Post
(
new
HttpParam
()
{
Url
=
Mall
.
Common
.
Pay
.
WeChatPat
.
Model
.
ApiList
.
UnifiedOrderUrl
,
PostParam
=
reqXml
,
Encoding
=
Common
.
Pay
.
WeChatPat
.
HttpHelper
.
GetRequestEncoding
(
_accessor
.
HttpContext
.
Request
),
});
var
xe
=
XElement
.
Parse
(
result
,
LoadOptions
.
SetLineInfo
);
var
returnCode
=
xe
.
GetElement
(
"return_code"
)
==
null
?
""
:
xe
.
GetElement
(
"return_code"
).
Value
;
var
returnMsg
=
xe
.
GetElement
(
"return_msg"
)
==
null
?
""
:
xe
.
GetElement
(
"return_msg"
).
Value
;
if
(
returnCode
.
Equals
(
"SUCCESS"
)
&&
returnCode
.
Equals
(
"SUCCESS"
))
{
var
code_url
=
xe
.
GetElement
(
"code_url"
)
==
null
?
""
:
xe
.
GetElement
(
"code_url"
).
Value
;
//在外面回写订单
return
new
BaseResult
()
{
IsSuccess
=
true
,
Data
=
new
Dictionary
<
string
,
string
>
{
{
"code_url"
,
code_url
}
}
};
}
//在外面回写订单
return
new
BaseResult
()
{
IsSuccess
=
false
,
Message
=
returnMsg
+
returnCode
,
Data
=
new
Dictionary
<
string
,
string
>
{
{
"code_url"
,
""
}
}
};
}
/// <summary>
/// 获取随机字符串
/// </summary>
...
...
Mall.WebApi/Controllers/AppletWeChat/PublishController.cs
View file @
1a955160
...
...
@@ -128,7 +128,7 @@ namespace Mall.WebApi.Controllers.AppletWeChat
int
version
=
Convert
.
ToInt32
(
query
.
Version
.
Replace
(
"."
,
""
));
version
+=
1
;
query
.
Version
=
version
.
ToString
().
Substring
(
0
,
version
.
ToString
().
Length
-
2
)
+
"."
+
version
.
ToString
().
Substring
(
version
.
ToString
().
Length
-
2
,
1
)
+
"."
+
version
.
ToString
().
Substring
(
version
.
ToString
().
Length
-
1
,
1
);
query
.
Version
=
version
.
ToString
().
Substring
(
0
,
version
.
ToString
().
Length
-
2
)
+
"."
+
version
.
ToString
().
Substring
(
version
.
ToString
().
Length
-
2
,
1
)
+
"."
+
version
.
ToString
().
Substring
(
version
.
ToString
().
Length
-
1
,
1
);
string
URL
=
$"http://127.0.0.1:
{
developerKitsPort
}
/v2/upload?project=
{
Mall
.
Common
.
Plugin
.
StringHelper
.
UrlEncode
(
projectUrl
)}
&version=V
{
query
.
Version
}
&desc=微信开发者工具HTTP上传&appid=
{
model
.
MiniAppId
}
"
;
string
result
=
Mall
.
Common
.
Plugin
.
HttpHelper
.
HttpGet
(
URL
,
Encoding
.
UTF8
,
""
);
...
...
@@ -176,6 +176,29 @@ namespace Mall.WebApi.Controllers.AppletWeChat
/// <summary>
/// 当面付页面调转
/// </summary>
/// <param name="request"></param>
/// <returns></returns>
[
HttpPost
]
public
virtual
ApiResult
GetNativeOrder
()
{
var
parms
=
RequestParm
;
var
query
=
new
RB_MiniProgram_Extend
{
TenantId
=
UserInfo
.
TenantId
,
MallBaseId
=
parms
.
MallBaseId
};
var
appletWeChatModel
=
appletWeChatModule
.
GetTenantListModule
(
query
).
FirstOrDefault
();
string
imgBase64
=
appletWeChatModule
.
GetWeiXinShare
(
appletWeChatModel
,
""
);
//页面暂时还未确定,确定后填入20200604 Add By:W
return
ApiResult
.
Success
(
""
,
imgBase64
);
}
/// <summary>
/// 订阅消息推送
/// </summary>
...
...
Mall.WebApi/Controllers/AppletWeChat/WeChatPayController.cs
View file @
1a955160
...
...
@@ -53,7 +53,7 @@ namespace Mall.WebApi.Controllers.AppletWeChat
{
var
request
=
RequestParm
;
var
userInfo
=
AppletUserInfo
;
// new AppletUserInfo();
if
(
userInfo
==
null
)
if
(
userInfo
==
null
)
{
return
ApiResult
.
Failed
(
"请登录"
);
}
...
...
@@ -96,7 +96,7 @@ namespace Mall.WebApi.Controllers.AppletWeChat
switch
((
int
)
demodel
.
OrderPayType
)
{
case
1
:
//微信支付 _accessor.HttpContext.Connection.RemoteIpAddress.ToString()
sPayInfo
=
App_Code
.
PayUtil
.
GetMinUnifiedOrder
(
sOrderNo
,
demodel
.
GoodsName
,
model
.
Income
.
Value
,
model
.
UserId
.
ToString
(),
demodel
.
OpenId
,
miniProgram
,
_accessor
,
System
.
Net
.
Dns
.
GetHostEntry
(
System
.
Net
.
Dns
.
GetHostName
()).
AddressList
.
FirstOrDefault
(
address
=>
address
.
AddressFamily
==
System
.
Net
.
Sockets
.
AddressFamily
.
InterNetwork
)?.
ToString
());
sPayInfo
=
App_Code
.
PayUtil
.
GetMinUnifiedOrder
(
sOrderNo
,
demodel
.
GoodsName
,
model
.
Income
.
Value
,
model
.
UserId
.
ToString
(),
demodel
.
OpenId
,
Config
.
sTenpayNotify
,
miniProgram
,
_accessor
,
System
.
Net
.
Dns
.
GetHostEntry
(
System
.
Net
.
Dns
.
GetHostName
()).
AddressList
.
FirstOrDefault
(
address
=>
address
.
AddressFamily
==
System
.
Net
.
Sockets
.
AddressFamily
.
InterNetwork
)?.
ToString
());
break
;
default
:
break
;
...
...
@@ -130,8 +130,19 @@ namespace Mall.WebApi.Controllers.AppletWeChat
RB_MiniProgram_Extend
miniProgram
=
new
RB_MiniProgram_Extend
();
//2020年5月26号新增
miniProgram
=
new
RB_MiniProgram_Extend
{
MiniAppId
=
"wxacd9f8cc3480d29e"
,
WeChatApiSecret
=
"936110e2c2214340b9829a3608bde6b0"
,
WeChatPayMerchants
=
"1562277941"
};
// programModule.GetMiniProgramModule(new RB_MiniProgram_Extend { MallBaseId = 1, TenantId =1 });
string
RefundOrderNo
=
"20200529160443264111"
;
var
Robj
=
App_Code
.
PayUtil
.
GetTransfersOrder
(
RefundOrderNo
,
Convert
.
ToDecimal
(
"0.01"
),
"21233"
,
"ow_7I5XC1-RGwwk8QANBmWKYKmOc"
,
miniProgram
,
_accessor
);
;
var
Robj
=
App_Code
.
PayUtil
.
GetTransfersOrder
(
RefundOrderNo
,
Convert
.
ToDecimal
(
"0.01"
),
"21233"
,
"ow_7I5XC1-RGwwk8QANBmWKYKmOc"
,
miniProgram
,
_accessor
);
;
return
ApiResult
.
Success
(
""
,
Robj
);
}
public
ApiResult
TestNativeOrder
()
{
RB_MiniProgram_Extend
miniProgram
=
new
RB_MiniProgram_Extend
();
//2020年5月26号新增
miniProgram
=
new
RB_MiniProgram_Extend
{
MiniAppId
=
"wxacd9f8cc3480d29e"
,
WeChatApiSecret
=
"936110e2c2214340b9829a3608bde6b0"
,
WeChatPayMerchants
=
"1562277941"
};
// programModule.GetMiniProgramModule(new RB_MiniProgram_Extend { MallBaseId = 1, TenantId =1 });
string
RefundOrderNo
=
System
.
DateTime
.
Now
.
ToString
(
"yyyyMMddHHmmssfff"
);
var
Robj
=
App_Code
.
PayUtil
.
GetNativeOrder
(
RefundOrderNo
,
Convert
.
ToDecimal
(
"0.01"
),
"测试商品"
,
"21233"
,
miniProgram
,
System
.
Net
.
Dns
.
GetHostEntry
(
System
.
Net
.
Dns
.
GetHostName
()).
AddressList
.
FirstOrDefault
(
address
=>
address
.
AddressFamily
==
System
.
Net
.
Sockets
.
AddressFamily
.
InterNetwork
)?.
ToString
(),
_accessor
);
;
return
ApiResult
.
Success
(
""
,
Robj
);
}
}
...
...
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