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
15785911
Commit
15785911
authored
May 27, 2020
by
吴春
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
提交代码
parent
e9b95178
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
447 additions
and
233 deletions
+447
-233
OrderPayTypeEnum.cs
Mall.Common/Enum/Goods/OrderPayTypeEnum.cs
+22
-0
RequestHandler.cs
Mall.Common/Pay/WeChatPat/RequestHandler.cs
+50
-9
RB_Goods_Order_Extend.cs
Mall.Model/Extend/Product/RB_Goods_Order_Extend.cs
+17
-1
MiniProgramModule.cs
Mall.Module.User/MiniProgramModule.cs
+1
-0
PayUtil.cs
Mall.WebApi/App_Code/PayUtil.cs
+97
-158
WeChatNotifyController.cs
...WebApi/Controllers/AppletWeChat/WeChatNotifyController.cs
+14
-65
WeChatPayController.cs
Mall.WebApi/Controllers/AppletWeChat/WeChatPayController.cs
+246
-0
No files found.
Mall.Common/Enum/Goods/OrderPayTypeEnum.cs
0 → 100644
View file @
15785911
using
Mall.Common.Plugin
;
using
System
;
using
System.Collections.Generic
;
using
System.Text
;
namespace
Mall.Common.Enum.Goods
{
public
enum
OrderPayTypeEnum
{
/// <summary>
/// 微信
/// </summary>
[
EnumField
(
"微信"
)]
WeChatPay
=
1
,
/// <summary>
/// 支付宝
/// </summary>
[
EnumField
(
"支付宝"
)]
Alipay
=
2
}
}
Mall.Common/Pay/WeChatPat/RequestHandler.cs
View file @
15785911
...
...
@@ -14,13 +14,6 @@ namespace Mall.Common.Pay.WeChatPat
/// </summary>
public
class
RequestHandler
{
private
IHttpContextAccessor
_accessor
;
public
RequestHandler
(
IHttpContextAccessor
accessor
)
{
_accessor
=
accessor
;
}
/// <summary>
/// 请求的参数
/// </summary>
...
...
@@ -171,6 +164,35 @@ namespace Mall.Common.Pay.WeChatPat
var
sign
=
Plugin
.
SecurityHelper
.
MD5EncryptWeChat
(
sb
.
ToString
(),
GetCharset
()).
ToUpper
();
return
sign
;
}
/// <summary>
/// 创建package签名,按参数名称a-z排序,遇到空值的参数不参加签名。
/// </summary>
/// <returns></returns>
public
string
CreateMd5Sign
(
IHttpContextAccessor
accessor
)
{
var
sb
=
new
StringBuilder
();
var
akeys
=
new
ArrayList
(
Parameters
.
Keys
);
akeys
.
Sort
();
foreach
(
string
k
in
akeys
)
{
var
v
=
(
string
)
Parameters
[
k
];
if
(
null
!=
v
&&
String
.
Compare
(
""
,
v
,
StringComparison
.
Ordinal
)
!=
0
&&
String
.
Compare
(
"sign"
,
k
,
StringComparison
.
Ordinal
)
!=
0
&&
String
.
Compare
(
"key"
,
k
,
StringComparison
.
Ordinal
)
!=
0
)
{
sb
.
Append
(
k
+
"="
+
v
+
"&"
);
}
}
sb
.
Append
(
"key="
+
GetKey
());
var
sign
=
Plugin
.
SecurityHelper
.
MD5EncryptWeChat
(
sb
.
ToString
(),
GetCharset
(
accessor
)).
ToUpper
();
return
sign
;
}
/// <summary>
/// 创建sha1签名
/// </summary>
...
...
@@ -269,18 +291,37 @@ namespace Mall.Common.Pay.WeChatPat
/// 获取编号
/// </summary>
/// <returns></returns>
protected
virtual
string
GetCharset
()
protected
virtual
string
GetCharset
(
IHttpContextAccessor
accessor
)
{
//return "UTF-8";
try
{
return
HttpHelper
.
GetRequestEncoding
(
_
accessor
.
HttpContext
.
Request
).
BodyName
;
// HttpContext.Current.Request.ContentEncoding.BodyName;
return
HttpHelper
.
GetRequestEncoding
(
accessor
.
HttpContext
.
Request
).
BodyName
;
// HttpContext.Current.Request.ContentEncoding.BodyName;
}
catch
(
Exception
)
{
return
"UTF-8"
;
}
}
/// <summary>
/// 获取编号
/// </summary>
/// <returns></returns>
protected
virtual
string
GetCharset
()
{
return
"UTF-8"
;
//try
//{
// return HttpHelper.GetRequestEncoding(accessor.HttpContext.Request).BodyName; // HttpContext.Current.Request.ContentEncoding.BodyName;
//}
//catch (Exception)
//{
// return "UTF-8";
//}
}
}
}
Mall.Model/Extend/Product/RB_Goods_Order_Extend.cs
View file @
15785911
...
...
@@ -3,6 +3,7 @@ using System;
using
System.Collections.Generic
;
using
System.Text
;
using
Mall.Model.Entity.Product
;
using
Mall.Common.Enum.Goods
;
namespace
Mall.Model.Extend.Product
{
...
...
@@ -107,12 +108,27 @@ namespace Mall.Model.Extend.Product
/// 使用优惠卷id
/// </summary>
public
int
?
User_Coupon_Id
{
get
;
set
;
}
/// <summary>
/// 支付方式
/// </summary>
public
OrderPayTypeEnum
?
OrderPayType
{
get
;
set
;
}
/// <summary>
/// 唯一识别码
/// </summary>
public
string
OpenId
{
get
;
set
;
}
}
/// <summary>
/// 订单优惠金额
/// </summary>
public
class
RB_Goods_CouponModel
{
public
class
RB_Goods_CouponModel
{
/// <summary>
/// 商品id
/// </summary>
...
...
Mall.Module.User/MiniProgramModule.cs
View file @
15785911
...
...
@@ -550,6 +550,7 @@ namespace Mall.Module.User
{
nameof
(
RB_MiniProgram_Extend
.
WeChatApiSecret
),
extModel
.
WeChatApiSecret
},
{
nameof
(
RB_MiniProgram_Extend
.
WeChatPayCertificate
),
extModel
.
WeChatPayCertificate
},
{
nameof
(
RB_MiniProgram_Extend
.
WeChatPayPrivateKey
),
extModel
.
WeChatPayPrivateKey
},
{
nameof
(
RB_MiniProgram_Extend
.
WeChatPayCertificateUrl
),
extModel
.
WeChatPayCertificateUrl
},
};
flag
=
programRepository
.
Update
(
fileds
,
new
WhereHelper
(
nameof
(
RB_MiniProgram_Extend
.
MallBaseId
),
extModel
.
MallBaseId
));
}
...
...
Mall.WebApi/App_Code/PayUtil.cs
View file @
15785911
This diff is collapsed.
Click to expand it.
Mall.WebApi/Controllers/AppletWeChat/WeChatNotifyController.cs
View file @
15785911
...
...
@@ -9,78 +9,16 @@ using Mall.Common.Plugin;
using
Mall.WebApi.Filter
;
using
Microsoft.AspNetCore.Cors
;
using
Microsoft.AspNetCore.Mvc
;
using
Newtonsoft.Json.Linq
;
namespace
Mall.WebApi.Controllers.AppletWeChat
{
[
Route
(
"api/[controller]/[action]"
)]
[
ApiExceptionFilter
]
[
ApiController
]
[
EnableCors
(
"AllowCors"
)]
public
class
WeChatNotifyController
:
BaseController
public
class
WeChatNotifyController
:
Controller
{
private
static
object
_lock
=
new
object
();
/// <summary>
/// 微信支付方法
/// </summary>
/// <param name="sOrderNo"></param>
/// <param name="sCurOpenID"></param>
/// <returns></returns>
[
HttpGet
]
[
HttpPost
]
public
ApiResult
DoPay
(
string
sOrderNo
,
string
sCurOpenID
=
""
)
{
if
(
string
.
IsNullOrWhiteSpace
(
sCurOpenID
))
{
return
ApiResult
.
Failed
(
"OpenId不能为空!"
);
}
string
result
=
""
;
//判断订单信息
//var model = new REBORN.Module.SellModule.CounponOrderModule().GetEntity(Convert.ToInt32(sOrderNo));
//if (model == null)
//{
// return ApiResult.Failed("订单信息不存在!");
//}
//if (model.OrderState == 2)
//{
// return ApiResult.Failed("订单已支付");
//}
//if (model.OrderState == 3)
//{
// return ApiResult.Failed("订单已取消");
//}
var
payParam
=
new
Common
.
Pay
.
WeChatPat
.
PayParam
()
{
TotalFee
=
1
,
// Convert.ToInt32(model.PreferPrice * 100),//总价,单位:分。2500即25元
OpenId
=
sCurOpenID
,
//支付用户的OpenId
OrderNumber
=
(
System
.
DateTime
.
Now
.
ToString
(
"yyyyMMddHHmmssfff"
))
+
sOrderNo
,
ProductName
=
"测试商品名称"
,
//model.ProductName,
IsRecharge
=
false
};
try
{
LogHelper
.
Write
(
null
,
"DoPay-H5:"
+
payParam
);
App_Code
.
PayUtil
PayUtil
=
new
App_Code
.
PayUtil
();
result
=
PayUtil
.
CreateJSAPIPayJson
(
payParam
);
return
ApiResult
.
Success
(
""
,
result
);
}
catch
(
Exception
ex
)
{
if
(
ex
.
Message
.
Contains
(
"timed out"
))
{
App_Code
.
PayUtil
PayUtil
=
new
App_Code
.
PayUtil
();
var
json
=
PayUtil
.
CreateJSAPIPayJson
(
payParam
);
return
ApiResult
.
Success
(
""
,
json
);
}
}
return
ApiResult
.
Success
();
}
/// <summary>
...
...
@@ -157,5 +95,16 @@ namespace Mall.WebApi.Controllers.AppletWeChat
//告诉微信我们处理失败,请继续调用我们的接口。好像是会重试8次。
}
}
}
\ No newline at end of file
Mall.WebApi/Controllers/AppletWeChat/WeChatPayController.cs
0 → 100644
View file @
15785911
This diff is collapsed.
Click to expand it.
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