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
90111eb5
Commit
90111eb5
authored
May 27, 2020
by
liudong1993
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'master' of
http://gitlab.oytour.com/Kui2/mall.oytour.com
parents
df5b4a86
47b327de
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
449 additions
and
233 deletions
+449
-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
+19
-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 @
90111eb5
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 @
90111eb5
...
@@ -14,13 +14,6 @@ namespace Mall.Common.Pay.WeChatPat
...
@@ -14,13 +14,6 @@ namespace Mall.Common.Pay.WeChatPat
/// </summary>
/// </summary>
public
class
RequestHandler
public
class
RequestHandler
{
{
private
IHttpContextAccessor
_accessor
;
public
RequestHandler
(
IHttpContextAccessor
accessor
)
{
_accessor
=
accessor
;
}
/// <summary>
/// <summary>
/// 请求的参数
/// 请求的参数
/// </summary>
/// </summary>
...
@@ -171,6 +164,35 @@ namespace Mall.Common.Pay.WeChatPat
...
@@ -171,6 +164,35 @@ namespace Mall.Common.Pay.WeChatPat
var
sign
=
Plugin
.
SecurityHelper
.
MD5EncryptWeChat
(
sb
.
ToString
(),
GetCharset
()).
ToUpper
();
var
sign
=
Plugin
.
SecurityHelper
.
MD5EncryptWeChat
(
sb
.
ToString
(),
GetCharset
()).
ToUpper
();
return
sign
;
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>
/// <summary>
/// 创建sha1签名
/// 创建sha1签名
/// </summary>
/// </summary>
...
@@ -269,18 +291,37 @@ namespace Mall.Common.Pay.WeChatPat
...
@@ -269,18 +291,37 @@ namespace Mall.Common.Pay.WeChatPat
/// 获取编号
/// 获取编号
/// </summary>
/// </summary>
/// <returns></returns>
/// <returns></returns>
protected
virtual
string
GetCharset
()
protected
virtual
string
GetCharset
(
IHttpContextAccessor
accessor
)
{
{
//return "UTF-8";
//return "UTF-8";
try
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
)
catch
(
Exception
)
{
{
return
"UTF-8"
;
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 @
90111eb5
...
@@ -3,6 +3,7 @@ using System;
...
@@ -3,6 +3,7 @@ using System;
using
System.Collections.Generic
;
using
System.Collections.Generic
;
using
System.Text
;
using
System.Text
;
using
Mall.Model.Entity.Product
;
using
Mall.Model.Entity.Product
;
using
Mall.Common.Enum.Goods
;
namespace
Mall.Model.Extend.Product
namespace
Mall.Model.Extend.Product
{
{
...
@@ -108,6 +109,21 @@ namespace Mall.Model.Extend.Product
...
@@ -108,6 +109,21 @@ namespace Mall.Model.Extend.Product
/// </summary>
/// </summary>
public
int
?
User_Coupon_Id
{
get
;
set
;
}
public
int
?
User_Coupon_Id
{
get
;
set
;
}
/// <summary>
/// 支付方式
/// </summary>
public
OrderPayTypeEnum
?
OrderPayType
{
get
;
set
;
}
/// <summary>
/// 唯一识别码
/// </summary>
public
string
OpenId
{
get
;
set
;
}
#
region
订单导入
#
region
订单导入
/// <summary>
/// <summary>
...
@@ -156,12 +172,14 @@ namespace Mall.Model.Extend.Product
...
@@ -156,12 +172,14 @@ namespace Mall.Model.Extend.Product
public
string
DName
{
get
;
set
;
}
public
string
DName
{
get
;
set
;
}
#
endregion
#
endregion
>>>>>>>
61
e2df8d6e7f6e7b0ef4482885c6e6b79d1870e7
}
}
/// <summary>
/// <summary>
/// 订单优惠金额
/// 订单优惠金额
/// </summary>
/// </summary>
public
class
RB_Goods_CouponModel
{
public
class
RB_Goods_CouponModel
{
/// <summary>
/// <summary>
/// 商品id
/// 商品id
/// </summary>
/// </summary>
...
...
Mall.Module.User/MiniProgramModule.cs
View file @
90111eb5
...
@@ -561,6 +561,7 @@ namespace Mall.Module.User
...
@@ -561,6 +561,7 @@ namespace Mall.Module.User
{
nameof
(
RB_MiniProgram_Extend
.
WeChatApiSecret
),
extModel
.
WeChatApiSecret
},
{
nameof
(
RB_MiniProgram_Extend
.
WeChatApiSecret
),
extModel
.
WeChatApiSecret
},
{
nameof
(
RB_MiniProgram_Extend
.
WeChatPayCertificate
),
extModel
.
WeChatPayCertificate
},
{
nameof
(
RB_MiniProgram_Extend
.
WeChatPayCertificate
),
extModel
.
WeChatPayCertificate
},
{
nameof
(
RB_MiniProgram_Extend
.
WeChatPayPrivateKey
),
extModel
.
WeChatPayPrivateKey
},
{
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
));
flag
=
programRepository
.
Update
(
fileds
,
new
WhereHelper
(
nameof
(
RB_MiniProgram_Extend
.
MallBaseId
),
extModel
.
MallBaseId
));
}
}
...
...
Mall.WebApi/App_Code/PayUtil.cs
View file @
90111eb5
This diff is collapsed.
Click to expand it.
Mall.WebApi/Controllers/AppletWeChat/WeChatNotifyController.cs
View file @
90111eb5
...
@@ -9,78 +9,16 @@ using Mall.Common.Plugin;
...
@@ -9,78 +9,16 @@ using Mall.Common.Plugin;
using
Mall.WebApi.Filter
;
using
Mall.WebApi.Filter
;
using
Microsoft.AspNetCore.Cors
;
using
Microsoft.AspNetCore.Cors
;
using
Microsoft.AspNetCore.Mvc
;
using
Microsoft.AspNetCore.Mvc
;
using
Newtonsoft.Json.Linq
;
namespace
Mall.WebApi.Controllers.AppletWeChat
namespace
Mall.WebApi.Controllers.AppletWeChat
{
{
[
Route
(
"api/[controller]/[action]"
)]
[
ApiExceptionFilter
]
public
class
WeChatNotifyController
:
Controller
[
ApiController
]
[
EnableCors
(
"AllowCors"
)]
public
class
WeChatNotifyController
:
BaseController
{
{
private
static
object
_lock
=
new
object
();
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>
/// <summary>
...
@@ -157,5 +95,16 @@ namespace Mall.WebApi.Controllers.AppletWeChat
...
@@ -157,5 +95,16 @@ namespace Mall.WebApi.Controllers.AppletWeChat
//告诉微信我们处理失败,请继续调用我们的接口。好像是会重试8次。
//告诉微信我们处理失败,请继续调用我们的接口。好像是会重试8次。
}
}
}
}
}
}
\ No newline at end of file
Mall.WebApi/Controllers/AppletWeChat/WeChatPayController.cs
0 → 100644
View file @
90111eb5
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