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
9b1afdf7
Commit
9b1afdf7
authored
Jun 18, 2020
by
liudong1993
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
订单导入
parent
bea77fbc
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
487 additions
and
29 deletions
+487
-29
MySqlHelper.cs
Test/DBHelper/MySqlHelper.cs
+28
-0
OrderCommissionHelper.cs
Test/Helper/OrderCommissionHelper.cs
+185
-0
OrderHelper.cs
Test/Helper/OrderHelper.cs
+193
-18
OrderCommissionInfo.cs
Test/Model/OrderCommissionInfo.cs
+50
-0
OrderInfo.cs
Test/Model/OrderInfo.cs
+27
-9
Test.csproj
Test/Test.csproj
+4
-2
No files found.
Test/DBHelper/MySqlHelper.cs
View file @
9b1afdf7
...
...
@@ -84,5 +84,33 @@ namespace Test.DBHelper
cmd
.
Parameters
.
Add
(
parm
);
}
}
/// <summary>
/// 执行SQL语句或者存储过程 ,返回参数dataset
/// </summary>
/// <param name="connection">要执行SQL语句的连接</param>
/// <param name="commandText">SQL语句或者存储过程名</param>
/// <param name="commandParameters">SQL语句或者存储过程参数</param>
/// <param name="commandType">SQL语句类型</param>
/// <param name="commandTimeout">超时时间</param>
/// <returns>执行结果集</returns>
public
static
DataSet
ExecuteDataset
(
string
connectionString
,
CommandType
commandType
,
string
commandText
,
params
MySqlParameter
[]
commandParameters
)
{
MySqlCommand
cmd
=
new
MySqlCommand
();
bool
mustCloseConnection
=
false
;
using
(
MySqlConnection
connection
=
new
MySqlConnection
(
connectionString
))
{
PrepareCommand
(
cmd
,
connection
,
null
,
commandType
,
commandText
,
commandParameters
);
using
(
MySqlDataAdapter
da
=
new
MySqlDataAdapter
(
cmd
))
{
DataSet
ds
=
new
DataSet
();
da
.
Fill
(
ds
);
cmd
.
Parameters
.
Clear
();
if
(
mustCloseConnection
)
connection
.
Close
();
return
ds
;
}
}
}
}
}
Test/Helper/OrderCommissionHelper.cs
0 → 100644
View file @
9b1afdf7
using
Newtonsoft.Json.Linq
;
using
Test.Model
;
using
System
;
using
System.Collections.Generic
;
using
System.IO
;
using
System.Net
;
using
System.Text
;
using
System.Threading
;
using
System.Text.RegularExpressions
;
using
Test.DBHelper
;
using
System.Linq
;
using
System.Data
;
using
Newtonsoft.Json
;
namespace
Test.Helper
{
/// <summary>
/// 订单返佣帮助类
/// </summary>
public
class
OrderCommissionHelper
{
/// <summary>
/// 获取数据
/// </summary>
/// <param name="cookie"></param>
public
static
void
GetOrderCommissionData
()
{
string
cookie
=
""
;
int
pageIndex
=
1
;
int
pageCount
=
7
;
while
(
pageIndex
<=
pageCount
)
{
string
dt
=
DateTime
.
Now
.
ToString
(
"yyyy-MM-dd HH:mm:ss"
);
var
tempImgList
=
GetOrderCommissionList
(
cookie
,
pageIndex
,
out
pageCount
);
Console
.
WriteLine
(
pageIndex
+
"/"
+
pageCount
+
" Edd"
);
if
(
tempImgList
!=
null
&&
tempImgList
.
Any
())
{
foreach
(
var
subItem
in
tempImgList
)
{
try
{
if
(
subItem
.
id
>
0
)
{
//根据订单号 或者订单id
int
OrderId
=
0
;
int
OrderDetailId
=
0
;
if
(
subItem
.
detail
.
Any
())
{
OrderDetailId
=
subItem
.
detail
?.
FirstOrDefault
()?.
order_detail_id
??
0
;
}
bool
IsSelfBuying
=
false
;
if
(
subItem
.
user_id
==
subItem
.
first_parent_id
)
{
IsSelfBuying
=
true
;
}
if
(
subItem
.
first_parent_id
>
0
)
{
string
sqlOrder
=
$@"
insert into rb_goods_ordercommission_drcs ( OrderId, OrderDetailId,UserId,Grade,Commission,IsGoodsDistribution,CommissionState,Type,Remark,TenantId,MallBaseId,CreateDate,UpdateDate)
VALUES (
{
OrderId
}
,
{
OrderDetailId
}
,
{
subItem
.
first_parent_id
}
,
{(
IsSelfBuying
?
0
:
1
)}
,
{
subItem
.
first_price
}
,2,
{(
subItem
.
is_confirm
==
1
?
2
:
1
)}
,1,'赞羊返佣导入',1,1,'
{
dt
}
','
{
dt
}
');
"
;
var
sqlOrderResult
=
MySqlHelper
.
ExecuteNonQuery
(
MySqlHelper
.
defaultConnection
,
System
.
Data
.
CommandType
.
Text
,
sqlOrder
,
null
);
}
if
(
subItem
.
second_parent_id
>
0
)
{
string
sqlOrder
=
$@"
insert into rb_goods_ordercommission_drcs ( OrderId, OrderDetailId,UserId,Grade,Commission,IsGoodsDistribution,CommissionState,Type,Remark,TenantId,MallBaseId,CreateDate,UpdateDate)
VALUES (
{
OrderId
}
,
{
OrderDetailId
}
,
{
subItem
.
second_parent_id
}
,
{(
IsSelfBuying
?
1
:
2
)}
,
{
subItem
.
second_price
}
,2,
{(
subItem
.
is_confirm
==
1
?
2
:
1
)}
,1,'赞羊返佣导入',1,1,'
{
dt
}
','
{
dt
}
');
"
;
var
sqlOrderResult
=
MySqlHelper
.
ExecuteNonQuery
(
MySqlHelper
.
defaultConnection
,
System
.
Data
.
CommandType
.
Text
,
sqlOrder
,
null
);
}
if
(
subItem
.
third_parent_id
>
0
)
{
string
sqlOrder
=
$@"
insert into rb_goods_ordercommission_drcs ( OrderId, OrderDetailId,UserId,Grade,Commission,IsGoodsDistribution,CommissionState,Type,Remark,TenantId,MallBaseId,CreateDate,UpdateDate)
VALUES (
{
OrderId
}
,
{
OrderDetailId
}
,
{
subItem
.
third_parent_id
}
,
{(
IsSelfBuying
?
2
:
3
)}
,
{
subItem
.
third_price
}
,2,
{(
subItem
.
is_confirm
==
1
?
2
:
1
)}
,1,'赞羊返佣导入',1,1,'
{
dt
}
','
{
dt
}
');
"
;
var
sqlOrderResult
=
MySqlHelper
.
ExecuteNonQuery
(
MySqlHelper
.
defaultConnection
,
System
.
Data
.
CommandType
.
Text
,
sqlOrder
,
null
);
}
}
}
catch
(
Exception
ex
)
{
Console
.
WriteLine
(
"失败OrderNO:"
+
subItem
.
order_no
+
" Msg:"
+
ex
.
Message
);
}
}
}
pageIndex
++;
var
ranDomNum
=
new
Random
().
Next
(
3
,
7
);
Thread
.
Sleep
(
1000
*
ranDomNum
);
}
}
/// <summary>
/// 获取订单列表
/// </summary>
/// <param name="cookie"></param>
/// <param name="pageIndex"></param>
/// <param name="pageCount"></param>
/// <returns></returns>
static
List
<
OrderCommissionInfo
>
GetOrderCommissionList
(
string
cookie
,
int
pageIndex
,
out
int
pageCount
)
{
pageCount
=
2
;
List
<
OrderCommissionInfo
>
list
=
new
List
<
OrderCommissionInfo
>();
string
newImaApi
=
"http://wx.weibaoge.cn/web/index.php?r=mall%2Fshare%2Forder&keyword=&keyword_1=order_no&date_start=&date_end=&platform=&status=all&plugin=all&send_type=-1&parent_id=0&page="
+
pageIndex
;
cookie
=
"search={'keyword':'','status':' - 1','sort_prop':'','sort_type':'','cats':[],'date_start':null,'date_end':null,'type':''}; _identity=c964edefdd891bb281844324071fea4e2c1e7d2b21aef031ed81730f4e753d06a%3A2%3A%7Bi%3A0%3Bs%3A9%3A%22_identity%22%3Bi%3A1%3Bs%3A48%3A%22%5B19740%2C%22Cktp5k6Wf3lVS_yjQI_uTgEEE6_ANe-5%22%2C86400%5D%22%3B%7D; HJ_SESSION_ID=tv09q5jnte4v44ca14bnvdi28s; _csrf=9a1b84c62ffd209719019cca9730bf48f33854d3acc2f31982a5ef51ceda400ca%3A2%3A%7Bi%3A0%3Bs%3A5%3A%22_csrf%22%3Bi%3A1%3Bs%3A32%3A%22QwYL8fmmakdUX981YM7R26-Y5YoMnXxU%22%3B%7D"
;
string
jsonData
=
HttpGet
(
newImaApi
,
cookie
);
if
(
jsonData
!=
null
&&
!
string
.
IsNullOrEmpty
(
jsonData
))
{
JObject
obj
=
JObject
.
Parse
(
jsonData
);
JObject
dataObj
=
JObject
.
Parse
(
obj
[
"data"
].
ToString
());
list
=
Newtonsoft
.
Json
.
JsonConvert
.
DeserializeObject
<
List
<
OrderCommissionInfo
>>(
dataObj
[
"list"
].
ToString
());
var
pageObj
=
JObject
.
Parse
(
dataObj
[
"pagination"
].
ToString
());
Int32
.
TryParse
(
pageObj
[
"page_count"
].
ToString
(),
out
pageCount
);
}
return
list
;
}
/// <summary>
/// Get获取数据
/// </summary>
/// <param name="url">url地址</param>
/// <param name="encode">编码方式</param>
/// <param name="Source">来源</param>
/// <returns></returns>
static
string
HttpGet
(
string
url
,
string
cookie
)
{
HttpWebRequest
myRequest
=
(
HttpWebRequest
)
WebRequest
.
Create
(
url
);
myRequest
.
Headers
.
Add
(
"Cookie"
,
cookie
);
myRequest
.
Headers
.
Add
(
"X-Requested-With"
,
"XMLHttpRequest"
);
myRequest
.
Method
=
"GET"
;
HttpWebResponse
myResponse
=
(
HttpWebResponse
)
myRequest
.
GetResponse
();
StreamReader
reader
=
new
StreamReader
(
myResponse
.
GetResponseStream
(),
Encoding
.
UTF8
);
string
content
=
reader
.
ReadToEnd
();
reader
.
Close
();
return
content
;
}
/// <summary>
/// Get获取数据
/// </summary>
/// <param name="url">url地址</param>
/// <param name="encode">编码方式</param>
/// <param name="Source">来源</param>
/// <returns></returns>
public
static
string
HttpGet
(
string
url
,
Encoding
encode
,
string
Source
,
string
cookie
=
""
)
{
HttpWebRequest
myRequest
=
(
HttpWebRequest
)
WebRequest
.
Create
(
url
);
if
(!
string
.
IsNullOrEmpty
(
Source
))
{
myRequest
.
Referer
=
Source
;
}
if
(!
string
.
IsNullOrEmpty
(
cookie
))
{
myRequest
.
Headers
.
Add
(
"cookie"
,
cookie
);
}
myRequest
.
Method
=
"GET"
;
HttpWebResponse
myResponse
=
null
;
try
{
myResponse
=
(
HttpWebResponse
)
myRequest
.
GetResponse
();
StreamReader
reader
=
new
StreamReader
(
myResponse
.
GetResponseStream
(),
encode
);
string
content
=
reader
.
ReadToEnd
();
return
content
;
}
//异常请求
catch
(
WebException
e
)
{
myResponse
=
(
HttpWebResponse
)
e
.
Response
;
using
(
Stream
errData
=
myResponse
.
GetResponseStream
())
{
using
(
StreamReader
reader
=
new
StreamReader
(
errData
))
{
string
text
=
reader
.
ReadToEnd
();
return
text
;
}
}
}
}
}
}
Test/Helper/OrderHelper.cs
View file @
9b1afdf7
This diff is collapsed.
Click to expand it.
Test/Model/OrderCommissionInfo.cs
0 → 100644
View file @
9b1afdf7
using
System
;
using
System.Collections.Generic
;
using
System.Linq
;
using
System.Text
;
using
System.Threading.Tasks
;
namespace
Test.Model
{
/// <summary>
/// 订单返佣信息
/// </summary>
public
class
OrderCommissionInfo
{
/// <summary>
/// 主键编号
/// </summary>
public
int
id
{
get
;
set
;
}
/// <summary>
/// 用户id
/// </summary>
public
int
user_id
{
get
;
set
;
}
/// <summary>
/// 订单号
/// </summary>
public
string
order_no
{
get
;
set
;
}
public
decimal
first_price
{
get
;
set
;
}
public
decimal
second_price
{
get
;
set
;
}
public
decimal
third_price
{
get
;
set
;
}
public
int
first_parent_id
{
get
;
set
;
}
public
int
second_parent_id
{
get
;
set
;
}
public
int
third_parent_id
{
get
;
set
;
}
public
int
is_confirm
{
get
;
set
;
}
public
List
<
DetailCommiossion
>
detail
{
get
;
set
;
}
}
public
class
DetailCommiossion
{
public
int
id
{
get
;
set
;
}
public
int
order_detail_id
{
get
;
set
;
}
}
}
Test/Model/OrderInfo.cs
View file @
9b1afdf7
...
...
@@ -63,16 +63,18 @@ namespace Test.Model
public
string
remark
{
get
;
set
;
}
public
string
seller_remark
{
get
;
set
;
}
public
int
is_pay
{
get
;
set
;
}
public
string
pay_time
{
get
;
set
;
}
public
int
is_send
{
get
;
set
;
}
public
string
send_time
{
get
;
set
;
}
public
int
is_confirm
{
get
;
set
;
}
public
string
confirm_time
{
get
;
set
;
}
public
DateTime
pay
_time
{
get
;
set
;
}
public
string
comment
_time
{
get
;
set
;
}
public
DateTime
send
_time
{
get
;
set
;
}
public
string
cancel
_time
{
get
;
set
;
}
public
DateTime
confirm_time
{
get
;
set
;
}
public
DateTime
comment_time
{
get
;
set
;
}
public
DateTime
created_at
{
get
;
set
;
}
public
string
created_at
{
get
;
set
;
}
/// <summary>
/// 取消状态 =1 表示取消
/// </summary>
...
...
@@ -82,7 +84,15 @@ namespace Test.Model
/// </summary>
public
int
is_recycle
{
get
;
set
;
}
public
int
is_delete
{
get
;
set
;
}
public
List
<
OrderDetailInfo
>
detail
{
get
;
set
;
}
public
List
<
DetailExpress
>
detailExpress
{
get
;
set
;
}
public
string
PName
{
get
;
set
;
}
public
string
CName
{
get
;
set
;
}
public
string
DName
{
get
;
set
;
}
}
public
class
OrderDetailInfo
{
...
...
@@ -100,7 +110,7 @@ namespace Test.Model
public
decimal
member_discount_price
{
get
;
set
;
}
public
DateTime
created_at
{
get
;
set
;
}
public
string
created_at
{
get
;
set
;
}
public
string
goods_no
{
get
;
set
;
}
...
...
@@ -134,6 +144,8 @@ namespace Test.Model
public
int
id
{
get
;
set
;
}
public
int
goods_id
{
get
;
set
;
}
public
string
sign_id
{
get
;
set
;
}
public
string
name
{
get
;
set
;
}
public
string
cover_pic
{
get
;
set
;
}
public
string
no
{
get
;
set
;
}
public
int
weight
{
get
;
set
;
}
public
int
number
{
get
;
set
;
}
...
...
@@ -150,6 +162,12 @@ namespace Test.Model
/// </summary>
public
string
express_content
{
get
;
set
;
}
public
int
is_delete
{
get
;
set
;
}
public
DateTime
created_at
{
get
;
set
;
}
public
string
created_at
{
get
;
set
;
}
}
public
class
ExpressInfo
{
public
int
id
{
get
;
set
;
}
public
string
name
{
get
;
set
;
}
public
string
code
{
get
;
set
;
}
}
}
Test/Test.csproj
View file @
9b1afdf7
...
...
@@ -67,11 +67,13 @@
</ItemGroup>
<ItemGroup>
<Compile
Include=
"DBHelper\MySqlHelper.cs"
/>
<Compile
Include=
"Helper\OrderCommissionHelper.cs"
/>
<Compile
Include=
"Helper\OrderHelper.cs"
/>
<Compile
Include=
"Helper\UserHelper.cs"
/>
<Compile
Include=
"Helper\MallHelper.cs"
/>
<Compile
Include=
"Model\OrderCommissionInfo.cs"
/>
<Compile
Include=
"Model\OrderInfo.cs"
/>
<Compile
Include=
"Model\UserImage.cs"
/>
<Compile
Include=
"Model\Category.cs"
/>
<Compile
Include=
"Model\Destination.cs"
/>
<Compile
Include=
"Program.cs"
/>
<Compile
Include=
"Properties\AssemblyInfo.cs"
/>
</ItemGroup>
...
...
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