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
e7a50b46
Commit
e7a50b46
authored
May 19, 2020
by
吴春
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
提交抖音小程序根据手机号码获取验证码
parent
838b654d
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
162 additions
and
133 deletions
+162
-133
ByteDanceController.cs
Mall.WebApi/Controllers/ByteDance/ByteDanceController.cs
+161
-132
AppletCouponController.cs
...Api/Controllers/MarketingCenter/AppletCouponController.cs
+1
-1
No files found.
Mall.WebApi/Controllers/ByteDance/ByteDanceController.cs
View file @
e7a50b46
...
@@ -3,6 +3,7 @@ using System.Collections.Generic;
...
@@ -3,6 +3,7 @@ using System.Collections.Generic;
using
System.IO
;
using
System.IO
;
using
System.Linq
;
using
System.Linq
;
using
System.Net
;
using
System.Net
;
using
System.Text
;
using
System.Threading.Tasks
;
using
System.Threading.Tasks
;
using
Google.Protobuf.WellKnownTypes
;
using
Google.Protobuf.WellKnownTypes
;
using
Mall.Common.API
;
using
Mall.Common.API
;
...
@@ -59,143 +60,147 @@ namespace Mall.WebApi.Controllers.ByteDance
...
@@ -59,143 +60,147 @@ namespace Mall.WebApi.Controllers.ByteDance
}
}
/// <summary>
///
//
<summary>
/// 向客户抖音小程序发送消息
///
//
向客户抖音小程序发送消息
/// </summary>
///
//
</summary>
/// <param name="content"></param>
///
//
<param name="content"></param>
/// <param name="model"></param>
///
//
<param name="model"></param>
/// <param name="ID"></param>
///
//
<param name="ID"></param>
/// <param name="guestModel"></param>
///
//
<param name="guestModel"></param>
public
void
SendMsg
(
string
content
,
ByteDanceCustomer
model
,
int
ID
,
RB_Member_User
userModel
)
//
public void SendMsg(string content, ByteDanceCustomer model, int ID, RB_Member_User userModel)
{
//
{
//谁来接受微信消息通知
//
//谁来接受微信消息通知
string
tempOpenId
=
model
.
Openid
;
//
string tempOpenId = model.Openid;
//要使用的form_id
//
//要使用的form_id
string
formId
=
""
;
//
string formId = "";
var
list
=
CacheManager
.
ByteDance
.
ByteDanceRedis
.
GetByteDanceList
(
model
.
UserID
,
formId
);
//
var list = CacheManager.ByteDance.ByteDanceRedis.GetByteDanceList(model.UserID, formId);
if
(
list
!=
null
&&
list
.
Any
())
//
if (list != null && list.Any())
{
//
{
formId
=
list
.
OrderBy
(
x
=>
x
.
FormCreateDate
).
FirstOrDefault
().
FormId
;
//
formId = list.OrderBy(x => x.FormCreateDate).FirstOrDefault().FormId;
string
WeChatSendTemplate
=
Common
.
Config
.
ByteDanceSendTemplate
;
//
string WeChatSendTemplate = Common.Config.ByteDanceSendTemplate;
var
tempData
=
new
//
var tempData = new
{
//
{
keyword1
=
new
//
keyword1 = new
{
//
{
value
=
"旅客意见调查表"
,
//
value = "旅客意见调查表",
},
//
},
keyword2
=
new
//
keyword2 = new
{
//
{
value
=
userModel
.
AliasName
,
//
value = userModel.AliasName,
},
//
},
keyword3
=
new
//
keyword3 = new
{
//
{
value
=
content
,
//
value = content,
},
//
},
};
//
};
//拼接字符串
//
//拼接字符串
var
msgData
=
new
//
var msgData = new
{
//
{
access_token
=
""
,
//
access_token = "",
touser
=
tempOpenId
,
//openId,推送给谁,给那个用户
//
touser = tempOpenId,//openId,推送给谁,给那个用户
template_id
=
WeChatSendTemplate
,
//模板消息ID,在微信小程序后台的模板消息里有.。这个是*****成功通知。的id
//
template_id = WeChatSendTemplate,//模板消息ID,在微信小程序后台的模板消息里有.。这个是*****成功通知。的id
// topcolor = "#173177",
//
// topcolor = "#173177",
page
=
""
,
//点击消息卡片之后打开的小程序页面地址,空则无跳转。
//
page = "",//点击消息卡片之后打开的小程序页面地址,空则无跳转。
form_id
=
formId
,
//要从服务器数据库里取最近7天时间最长的一条没有使用的来,用完了要设置这个formId被用过了。
//
form_id = formId,//要从服务器数据库里取最近7天时间最长的一条没有使用的来,用完了要设置这个formId被用过了。
data
=
tempData
//
data = tempData
};
//
};
string
postData
=
JsonHelper
.
Serialize
(
msgData
);
// string postData = JsonHelper.Serialize(msgData);
string
tempUrl
=
"https://developer.toutiao.com/api/apps/game/template/send"
;
// string tempUrl = "https://developer.toutiao.com/api/apps/game/template/send";
string
resulr
=
WebRequestPostOrGet
(
tempUrl
,
postData
);
// string resulr = WebRequestPostOrGet(tempUrl, postData);
CacheManager
.
ByteDance
.
ByteDanceRedis
.
RemoveCacheKey
(
model
.
UserID
.
ToString
(),
formId
,
model
);
// CacheManager.ByteDance.ByteDanceRedis.RemoveCacheKey(model.UserID.ToString(), formId, model);
}
// }
}
//}
///// <summary>
///// 发送消息
///// </summary>
///// <param name="sUrl"></param>
///// <param name="sParam"></param>
///// <returns></returns>
//public static string WebRequestPostOrGet(string sUrl, string sParam)
//{
// byte[] bt = System.Text.Encoding.UTF8.GetBytes(sParam);
// Uri uriurl = new Uri(sUrl);
// HttpWebRequest req = (HttpWebRequest)HttpWebRequest.Create(uriurl);//HttpWebRequest req = (HttpWebRequest)HttpWebRequest.Create(url + (url.IndexOf("?") > -1 ? "" : "?") + param);
// req.Method = "Post";
// req.Timeout = 120 * 1000;
// req.ContentType = "application/x-www-form-urlencoded;";
// req.ContentLength = bt.Length;
// using (Stream reqStream = req.GetRequestStream())//using 使用可以释放using段内的内存
// {
// reqStream.Write(bt, 0, bt.Length);
// reqStream.Flush();
// }
// try
// {
// using (WebResponse res = req.GetResponse())
// {
// Stream resStream = res.GetResponseStream();
// StreamReader resStreamReader = new StreamReader(resStream, System.Text.Encoding.UTF8);
// string resLine;
// System.Text.StringBuilder resStringBuilder = new System.Text.StringBuilder();
// while ((resLine = resStreamReader.ReadLine()) != null)
// {
// resStringBuilder.Append(resLine + System.Environment.NewLine);
// }
// resStream.Close();
// resStreamReader.Close();
// return resStringBuilder.ToString();
// }
// }
// catch (Exception ex)
// {
// return ex.Message;//url错误时候回报错
// }
//}
/// <summary>
/// <summary>
///
发送消息
///
输入手机号码获取抖音小程序短信验证码
/// </summary>
/// </summary>
/// <param name="sUrl"></param>
/// <param name="sParam"></param>
/// <returns></returns>
/// <returns></returns>
public
static
string
WebRequestPostOrGet
(
string
sUrl
,
string
sParam
)
[
HttpPost
]
{
public
ApiResult
GetMobileCode
()
byte
[]
bt
=
System
.
Text
.
Encoding
.
UTF8
.
GetBytes
(
sParam
);
Uri
uriurl
=
new
Uri
(
sUrl
);
HttpWebRequest
req
=
(
HttpWebRequest
)
HttpWebRequest
.
Create
(
uriurl
);
//HttpWebRequest req = (HttpWebRequest)HttpWebRequest.Create(url + (url.IndexOf("?") > -1 ? "" : "?") + param);
req
.
Method
=
"Post"
;
req
.
Timeout
=
120
*
1000
;
req
.
ContentType
=
"application/x-www-form-urlencoded;"
;
req
.
ContentLength
=
bt
.
Length
;
using
(
Stream
reqStream
=
req
.
GetRequestStream
())
//using 使用可以释放using段内的内存
{
reqStream
.
Write
(
bt
,
0
,
bt
.
Length
);
reqStream
.
Flush
();
}
try
{
using
(
WebResponse
res
=
req
.
GetResponse
())
{
{
Stream
resStream
=
res
.
GetResponseStream
()
;
var
parms
=
RequestParm
;
StreamReader
resStreamReader
=
new
StreamReader
(
resStream
,
System
.
Text
.
Encoding
.
UTF8
);
JObject
parmsJob
=
JObject
.
Parse
(
RequestParm
.
msg
.
ToString
()
);
string
resLine
;
string
mobile
=
parmsJob
.
GetStringValue
(
"mobile"
)
;
System
.
Text
.
StringBuilder
resStringBuilder
=
new
System
.
Text
.
StringBuilder
(
);
string
info
=
ExecuteInCmd
(
$"bytecli -l
{
mobile
}
"
);
while
((
resLine
=
resStreamReader
.
ReadLine
())
!=
null
)
if
(
info
.
IndexOf
(
"获取验证码成功"
)
>
-
1
)
{
{
resStringBuilder
.
Append
(
resLine
+
System
.
Environment
.
NewLine
);
return
ApiResult
.
Success
(
"获取验证码成功,请查看手机,输入验证码"
,
info
);
}
resStream
.
Close
();
resStreamReader
.
Close
();
return
resStringBuilder
.
ToString
();
}
}
}
else
catch
(
Exception
ex
)
{
{
return
ex
.
Message
;
//url错误时候回报错
return
ApiResult
.
Failed
(
"获取验证失败"
);
}
}
}
}
public
ApiResult
GetTest
()
{
string
info
=
ExecuteInCmd
(
"ipconfig"
);
// ProcessCore.ExecuteOutCmd("-I http://www.baidu.com", @"C:\curl.exe");
return
ApiResult
.
Success
(
""
,
info
);
}
/// <summary>
/// <summary>
///
执行外部命令
///
输入手机号码获取抖音小程序短信验证码
/// </summary>
/// </summary>
/// <param name="argument">命令参数</param>
/// <returns></returns>
/// <param name="application">命令程序路径</param>
[
HttpPost
]
/// <returns>执行结果</returns>
public
ApiResult
GetLogin
()
public
static
string
ExecuteOutCmd
(
string
argument
,
string
applocaltion
)
{
{
using
(
var
process
=
new
System
.
Diagnostics
.
Process
())
var
parms
=
RequestParm
;
JObject
parmsJob
=
JObject
.
Parse
(
RequestParm
.
msg
.
ToString
());
string
mobile
=
parmsJob
.
GetStringValue
(
"mobile"
);
string
code
=
parmsJob
.
GetStringValue
(
"code"
);
string
info
=
ExecuteInCmd
(
$"bytecli -l
{
mobile
}
@
{
code
}
"
);
if
(
info
.
IndexOf
(
"获取验证码成功"
)
>
-
1
)
{
{
process
.
StartInfo
.
Arguments
=
argument
;
return
ApiResult
.
Success
(
"获取验证码成功,请查看手机,输入验证码"
,
info
);
process
.
StartInfo
.
FileName
=
applocaltion
;
}
process
.
StartInfo
.
UseShellExecute
=
false
;
else
process
.
StartInfo
.
RedirectStandardInput
=
true
;
{
process
.
StartInfo
.
RedirectStandardOutput
=
true
;
return
ApiResult
.
Failed
(
"获取验证失败"
);
process
.
StartInfo
.
RedirectStandardError
=
true
;
process
.
StartInfo
.
CreateNoWindow
=
true
;
process
.
Start
();
process
.
StandardInput
.
AutoFlush
=
true
;
process
.
StandardInput
.
WriteLine
(
"exit"
);
//获取cmd窗口的输出信息
string
output
=
process
.
StandardOutput
.
ReadToEnd
();
process
.
WaitForExit
();
process
.
Close
();
return
output
;
}
}
}
}
...
@@ -207,27 +212,51 @@ namespace Mall.WebApi.Controllers.ByteDance
...
@@ -207,27 +212,51 @@ namespace Mall.WebApi.Controllers.ByteDance
/// <returns>执行结果</returns>
/// <returns>执行结果</returns>
public
static
string
ExecuteInCmd
(
string
cmdline
)
public
static
string
ExecuteInCmd
(
string
cmdline
)
{
{
using
(
var
process
=
new
System
.
Diagnostics
.
Process
())
//创建ProcessInfo对象
{
System
.
Diagnostics
.
ProcessStartInfo
psi
=
new
System
.
Diagnostics
.
ProcessStartInfo
(
"cmd.exe"
);
process
.
StartInfo
.
FileName
=
"cmd.exe"
;
psi
.
UseShellExecute
=
false
;
process
.
StartInfo
.
UseShellExecute
=
false
;
psi
.
RedirectStandardOutput
=
true
;
process
.
StartInfo
.
RedirectStandardInput
=
true
;
psi
.
RedirectStandardInput
=
true
;
process
.
StartInfo
.
RedirectStandardOutput
=
true
;
psi
.
RedirectStandardError
=
true
;
process
.
StartInfo
.
RedirectStandardError
=
true
;
psi
.
WorkingDirectory
=
"D:\\Tool\\bytedance\\bytedanceide\\resources\\app.asar.unpacked"
;
process
.
StartInfo
.
CreateNoWindow
=
true
;
psi
.
StandardOutputEncoding
=
Encoding
.
UTF8
;
// psi.StandardInputEncoding = Encoding.UTF8;
// Start the process
System
.
Diagnostics
.
Process
proc
=
System
.
Diagnostics
.
Process
.
Start
(
psi
);
process
.
Start
();
proc
.
StandardInput
.
AutoFlush
=
true
;
process
.
StandardInput
.
AutoFlush
=
true
;
proc
.
StandardInput
.
WriteLine
(
cmdline
+
"&exit"
);
process
.
StandardInput
.
WriteLine
(
cmdline
+
"&exit"
);
//获取cmd窗口的输出信息
//获取cmd窗口的输出信息
string
output
=
process
.
StandardOutput
.
ReadToEnd
();
string
output
=
proc
.
StandardOutput
.
ReadToEnd
();
process
.
WaitForExit
();
proc
.
WaitForExit
();
process
.
Close
();
proc
.
Close
();
return
output
;
return
output
;
}
//////using (var process = new System.Diagnostics.Process())
//////{
////// process.StartInfo.FileName = "cmd.exe cd 'D:\\Tool\\bytedance\\bytedanceide\\resources\\app.asar.unpacked\\bytecli.bat'";//后面的 \"D:\\ServKit\"替换为你需要的路径即可。
////// // process.StartInfo.FileName = "cmd.exe";
////// process.StartInfo.UseShellExecute = false;
////// process.StartInfo.RedirectStandardInput = true;
////// process.StartInfo.RedirectStandardOutput = true;
////// process.StartInfo.RedirectStandardError = true;
////// process.StartInfo.CreateNoWindow = true;
////// process.StartInfo.StandardOutputEncoding = Encoding.UTF8;
////// process.Start();
////// process.StandardInput.AutoFlush = true;
////// process.StandardInput.WriteLine(cmdline + "&exit");
////// //获取cmd窗口的输出信息
////// string output = process.StandardOutput.ReadToEnd();
////// process.WaitForExit();
////// process.Close();
////// return output;
//////}
}
}
}
}
...
...
Mall.WebApi/Controllers/MarketingCenter/AppletCouponController.cs
View file @
e7a50b46
...
@@ -25,7 +25,7 @@ namespace Mall.WebApi.Controllers.MarketingCenter
...
@@ -25,7 +25,7 @@ namespace Mall.WebApi.Controllers.MarketingCenter
/// <summary>
/// <summary>
///
设置购物车数量
///
获取用户未使用的优惠券
/// </summary>
/// </summary>
/// <returns></returns>
/// <returns></returns>
[
HttpPost
]
[
HttpPost
]
...
...
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