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
1350b679
Commit
1350b679
authored
May 22, 2020
by
liudong1993
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
物流实时查询+下单积分赠送
parent
bac80ab2
Hide whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
312 additions
and
7 deletions
+312
-7
KdApiSearchDemo.cs
Mall.Common/Plugin/KdApiSearchDemo.cs
+158
-0
RB_Goods_OrderDetail_Extend.cs
Mall.Model/Extend/Product/RB_Goods_OrderDetail_Extend.cs
+16
-1
ExpressTraces.cs
Mall.Model/Query/ExpressTraces.cs
+25
-0
OrderModule.cs
Mall.Module.Product/OrderModule.cs
+62
-2
RB_Member_GradeRepository.cs
Mall.Repository/User/RB_Member_GradeRepository.cs
+1
-1
AppletOrderController.cs
Mall.WebApi/Controllers/Product/AppletOrderController.cs
+46
-0
UserController.cs
Mall.WebApi/Controllers/User/UserController.cs
+2
-2
Startup.cs
Mall.WebApi/Startup.cs
+2
-1
No files found.
Mall.Common/Plugin/KdApiSearchDemo.cs
0 → 100644
View file @
1350b679
using
System
;
using
System.Collections.Generic
;
using
System.Linq
;
using
System.Text
;
using
System.Web
;
using
System.Net
;
using
System.IO
;
namespace
Mall.Common.Plugin
{
public
class
KdApiSearchDemo
{
//电商ID
private
string
EBusinessID
=
"1644004"
;
//电商加密私钥,快递鸟提供,注意保管,不要泄漏
private
string
AppKey
=
"1cff9561-518d-42b3-b4a0-889faeda6111"
;
//请求url
private
string
ReqURL
=
"http://api.kdniao.com/Ebusiness/EbusinessOrderHandle.aspx"
;
/// <summary>
/// Json方式 查询订单物流轨迹
/// </summary>
/// <param name="ShipperCode"></param>
/// <param name="LogisticCode"></param>
/// <param name="OrderCode"></param>
/// <returns></returns>
public
string
getOrderTracesByJson
(
string
ShipperCode
,
string
LogisticCode
,
string
OrderCode
=
""
)
{
string
requestData
=
"{'OrderCode':'"
+
OrderCode
+
"','ShipperCode':'"
+
ShipperCode
+
"','LogisticCode':'"
+
LogisticCode
+
"'}"
;
Dictionary
<
string
,
string
>
param
=
new
Dictionary
<
string
,
string
>();
param
.
Add
(
"RequestData"
,
HttpUtility
.
UrlEncode
(
requestData
,
Encoding
.
UTF8
));
param
.
Add
(
"EBusinessID"
,
EBusinessID
);
param
.
Add
(
"RequestType"
,
"1002"
);
string
dataSign
=
encrypt
(
requestData
,
AppKey
,
"UTF-8"
);
param
.
Add
(
"DataSign"
,
HttpUtility
.
UrlEncode
(
dataSign
,
Encoding
.
UTF8
));
param
.
Add
(
"DataType"
,
"2"
);
string
result
=
sendPost
(
ReqURL
,
param
);
//根据公司业务处理返回的信息......
return
result
;
}
/// <summary>
/// Post方式提交数据,返回网页的源代码
/// </summary>
/// <param name="url">发送请求的 URL</param>
/// <param name="param">请求的参数集合</param>
/// <returns>远程资源的响应结果</returns>
private
string
sendPost
(
string
url
,
Dictionary
<
string
,
string
>
param
)
{
string
result
=
""
;
StringBuilder
postData
=
new
StringBuilder
();
if
(
param
!=
null
&&
param
.
Count
>
0
)
{
foreach
(
var
p
in
param
)
{
if
(
postData
.
Length
>
0
)
{
postData
.
Append
(
"&"
);
}
postData
.
Append
(
p
.
Key
);
postData
.
Append
(
"="
);
postData
.
Append
(
p
.
Value
);
}
}
byte
[]
byteData
=
Encoding
.
GetEncoding
(
"UTF-8"
).
GetBytes
(
postData
.
ToString
());
try
{
HttpWebRequest
request
=
(
HttpWebRequest
)
WebRequest
.
Create
(
url
);
request
.
ContentType
=
"application/x-www-form-urlencoded"
;
request
.
Referer
=
url
;
request
.
Accept
=
"*/*"
;
request
.
Timeout
=
30
*
1000
;
request
.
UserAgent
=
"Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1; .NET CLR 2.0.50727; .NET CLR 3.0.04506.648; .NET CLR 3.0.4506.2152; .NET CLR 3.5.30729)"
;
request
.
Method
=
"POST"
;
request
.
ContentLength
=
byteData
.
Length
;
Stream
stream
=
request
.
GetRequestStream
();
stream
.
Write
(
byteData
,
0
,
byteData
.
Length
);
stream
.
Flush
();
stream
.
Close
();
HttpWebResponse
response
=
(
HttpWebResponse
)
request
.
GetResponse
();
Stream
backStream
=
response
.
GetResponseStream
();
StreamReader
sr
=
new
StreamReader
(
backStream
,
Encoding
.
GetEncoding
(
"UTF-8"
));
result
=
sr
.
ReadToEnd
();
sr
.
Close
();
backStream
.
Close
();
response
.
Close
();
request
.
Abort
();
}
catch
(
Exception
ex
)
{
result
=
ex
.
Message
;
}
return
result
;
}
///<summary>
///电商Sign签名
///</summary>
///<param name="content">内容</param>
///<param name="keyValue">Appkey</param>
///<param name="charset">URL编码 </param>
///<returns>DataSign签名</returns>
private
string
encrypt
(
String
content
,
String
keyValue
,
String
charset
)
{
if
(
keyValue
!=
null
)
{
return
base64
(
MD5
(
content
+
keyValue
,
charset
),
charset
);
}
return
base64
(
MD5
(
content
,
charset
),
charset
);
}
///<summary>
/// 字符串MD5加密
///</summary>
///<param name="str">要加密的字符串</param>
///<param name="charset">编码方式</param>
///<returns>密文</returns>
private
string
MD5
(
string
str
,
string
charset
)
{
byte
[]
buffer
=
System
.
Text
.
Encoding
.
GetEncoding
(
charset
).
GetBytes
(
str
);
try
{
System
.
Security
.
Cryptography
.
MD5CryptoServiceProvider
check
;
check
=
new
System
.
Security
.
Cryptography
.
MD5CryptoServiceProvider
();
byte
[]
somme
=
check
.
ComputeHash
(
buffer
);
string
ret
=
""
;
foreach
(
byte
a
in
somme
)
{
if
(
a
<
16
)
ret
+=
"0"
+
a
.
ToString
(
"X"
);
else
ret
+=
a
.
ToString
(
"X"
);
}
return
ret
.
ToLower
();
}
catch
{
throw
;
}
}
/// <summary>
/// base64编码
/// </summary>
/// <param name="str">内容</param>
/// <param name="charset">编码方式</param>
/// <returns></returns>
private
string
base64
(
String
str
,
String
charset
)
{
return
Convert
.
ToBase64String
(
System
.
Text
.
Encoding
.
GetEncoding
(
charset
).
GetBytes
(
str
));
}
}
}
Mall.Model/Extend/Product/RB_Goods_OrderDetail_Extend.cs
View file @
1350b679
...
...
@@ -64,7 +64,22 @@ namespace Mall.Model.Extend.Product
public
int
?
IsApplyForAfterSale
{
get
;
set
;
}
/// <summary>
/// 积分赠送
/// </summary>
public
int
?
IntegralPresent
{
get
;
set
;
}
/// <summary>
/// 赠送类型 2固定值 1百分比
/// </summary>
public
int
?
IntegralPresentType
{
get
;
set
;
}
}
}
Mall.Model/Query/ExpressTraces.cs
0 → 100644
View file @
1350b679
using
Mall.Common.AOP
;
using
System
;
using
System.Collections.Generic
;
using
System.Text
;
namespace
Mall.Model.Query
{
[
Serializable
]
[
DB
(
ConnectionName
=
"DefaultConnection"
)]
public
class
ExpressTraces
{
/// <summary>
/// 时间
/// </summary>
public
string
AcceptTime
{
get
;
set
;
}
/// <summary>
/// 描述
/// </summary>
public
string
AcceptStation
{
get
;
set
;
}
/// <summary>
/// 备注
/// </summary>
public
string
Remark
{
get
;
set
;
}
}
}
Mall.Module.Product/OrderModule.cs
View file @
1350b679
...
...
@@ -152,6 +152,10 @@ namespace Mall.Module.Product
/// 商品评论
/// </summary>
private
readonly
RB_Goods_CommentRepository
goods_CommentRepository
=
new
RB_Goods_CommentRepository
();
/// <summary>
/// 用户积分
/// </summary>
private
readonly
RB_Member_IntegralRepository
member_IntegralRepository
=
new
RB_Member_IntegralRepository
();
#
region
购物车
...
...
@@ -1108,7 +1112,10 @@ namespace Mall.Module.Product
if
(
umodel
==
null
)
{
return
ApiResult
.
Failed
(
"用户不存在"
);
}
}
if
(
umodel
.
Blacklist
==
1
)
{
return
ApiResult
.
Failed
(
"您在黑名单状态无法下单,请联系管理员核实"
);
}
List
<
int
>
disList
=
new
List
<
int
>();
disList
.
Add
(
demodel
.
Province
??
0
);
disList
.
Add
(
demodel
.
City
??
0
);
...
...
@@ -1334,6 +1341,8 @@ namespace Mall.Module.Product
item
.
SeparateDistribution
=
gmodel
.
SeparateDistribution
;
item
.
SeparateDistributionType
=
gmodel
.
SeparateDistributionType
;
item
.
SeparateDistributionMoneyType
=
gmodel
.
SeparateDistributionMoneyType
;
item
.
IntegralPresent
=
gmodel
.
IntegralPresent
;
item
.
IntegralPresentType
=
gmodel
.
IntegralPresentType
;
}
}
...
...
@@ -1498,7 +1507,7 @@ namespace Mall.Module.Product
goods_ShoppingCartRepository
.
Update
(
keyValues2
,
wheres2
);
}
}
//下线
if
(
umodel
.
DownlineCondition
==
Common
.
Enum
.
User
.
DistrbutorReferralsEnum
.
SCXD
&&
umodel
.
IsBeDownline
==
2
)
{
//首次下单成为下线
Dictionary
<
string
,
object
>
keyValues1
=
new
Dictionary
<
string
,
object
>()
{
...
...
@@ -1889,6 +1898,7 @@ namespace Mall.Module.Product
/// <param name="OrderId"></param>
private
void
InsertOrderDetail
(
RB_Goods_Order_Extend
demodel
,
System
.
Data
.
IDbTransaction
trans
,
int
OrderId
)
{
int
IntegralPresentTotal
=
0
;
foreach
(
var
item
in
demodel
.
DetailList
)
{
//插入订单明细表
...
...
@@ -1918,6 +1928,16 @@ namespace Mall.Module.Product
FreightMoney
=
item
.
FreightMoney
},
trans
);
item
.
Id
=
detailId
;
//积分
if
(
item
.
IntegralPresent
>
0
)
{
int
IntegralPresent
=
item
.
IntegralPresent
??
0
;
if
(
item
.
IntegralPresentType
==
1
)
{
IntegralPresent
=
Convert
.
ToInt32
(((
item
.
Final_Price
??
0
)
+
(
item
.
FreightMoney
??
0
))
*
(
item
.
IntegralPresent
??
0
)
/
100
);
}
if
(
IntegralPresent
>
0
)
{
IntegralPresentTotal
+=
IntegralPresent
;
}
}
//更新商品数量
Dictionary
<
string
,
object
>
keyValues
=
new
Dictionary
<
string
,
object
>()
{
{
nameof
(
RB_Goods
.
InventoryNum
),
item
.
InventoryNum
-(
item
.
Number
??
0
)}
...
...
@@ -1985,6 +2005,22 @@ namespace Mall.Module.Product
}));
}
}
if
(
IntegralPresentTotal
>
0
)
{
member_IntegralRepository
.
Insert
(
new
Model
.
Entity
.
User
.
RB_Member_Integral
()
{
Id
=
0
,
CreateDate
=
DateTime
.
Now
,
Description
=
"订单购买赠送积分"
,
Image
=
0
,
Integral
=
IntegralPresentTotal
,
MallBaseId
=
demodel
.
MallBaseId
,
PlatformType
=
demodel
.
OrderSource
,
Remarks
=
""
,
TenantId
=
demodel
.
TenantId
,
Type
=
Common
.
Enum
.
MarketingCenter
.
RecordTypeEnum
.
Income
,
UserId
=
demodel
.
UserId
});
}
}
/// <summary>
...
...
@@ -4339,5 +4375,29 @@ namespace Mall.Module.Product
return
""
;
}
#
endregion
#
region
查询物流
/// <summary>
/// 获取物流信息
/// </summary>
/// <param name="expressId"></param>
/// <returns></returns>
public
Model
.
Entity
.
BaseSetUp
.
RB_Logistics_Express
GerExpressModel
(
int
expressId
)
{
return
logistics_ExpressRepository
.
GetEntity
(
expressId
);
}
/// <summary>
/// 查询物料信息
/// </summary>
/// <param name="expressCode"></param>
/// <param name="expressNumber"></param>
/// <returns></returns>
public
string
GetOrderExpressInfo
(
string
expressCode
,
string
expressNumber
)
{
return
new
KdApiSearchDemo
().
getOrderTracesByJson
(
expressCode
,
expressNumber
);
}
#
endregion
}
}
Mall.Repository/User/RB_Member_GradeRepository.cs
View file @
1350b679
...
...
@@ -72,7 +72,7 @@ namespace Mall.Repository.User
{
where
+=
$@" and
{
nameof
(
RB_Member_Grade
.
Enabled
)}
=
{(
int
)
dmodel
.
Enabled
}
"
;
}
string
sql
=
$@"select * from RB_Member_Grade where
{
where
}
order by
Id de
sc"
;
string
sql
=
$@"select * from RB_Member_Grade where
{
where
}
order by
Grade a
sc"
;
return
Get
<
RB_Member_Grade_Extend
>(
sql
).
ToList
();
}
}
...
...
Mall.WebApi/Controllers/Product/AppletOrderController.cs
View file @
1350b679
...
...
@@ -753,5 +753,51 @@ namespace Mall.WebApi.Controllers.MallBase
}
#
endregion
#
region
查询物流
/// <summary>
/// 获取快递信息
/// </summary>
/// <returns></returns>
[
HttpPost
]
public
ApiResult
GetOrderExpressInfo
()
{
var
req
=
RequestParm
;
var
userInfo
=
AppletUserInfo
;
JObject
parms
=
JObject
.
Parse
(
req
.
msg
.
ToString
());
int
ExpressId
=
parms
.
GetInt
(
"ExpressId"
,
0
);
string
ExpressNumber
=
parms
.
GetStringValue
(
"ExpressNumber"
);
if
(
ExpressId
<=
0
)
{
return
ApiResult
.
ParamIsNull
();
}
if
(
string
.
IsNullOrEmpty
(
ExpressNumber
))
{
return
ApiResult
.
ParamIsNull
();
}
try
{
var
model
=
orderModule
.
GerExpressModel
(
ExpressId
);
if
(
model
==
null
)
{
return
ApiResult
.
Failed
(
"快递不存在"
);
}
var
jsonStr
=
orderModule
.
GetOrderExpressInfo
(
model
.
ExpressCode
,
ExpressNumber
);
JObject
Rparms
=
JObject
.
Parse
(
jsonStr
);
if
(
Rparms
.
GetStringValue
(
"Success"
).
ToLower
()
==
"true"
)
{
List
<
Model
.
Query
.
ExpressTraces
>
list
=
JsonConvert
.
DeserializeObject
<
List
<
Model
.
Query
.
ExpressTraces
>>(
Rparms
.
GetStringValue
(
"Traces"
));
return
ApiResult
.
Success
(
""
,
list
);
}
else
{
return
ApiResult
.
Failed
(
"未能查询到该快递信息"
);
}
}
catch
(
Exception
ex
)
{
LogHelper
.
Write
(
ex
,
"GetOrderExpressInfo"
);
return
ApiResult
.
Failed
(
"出错了,请联系管理员"
);
}
}
#
endregion
}
}
\ No newline at end of file
Mall.WebApi/Controllers/User/UserController.cs
View file @
1350b679
...
...
@@ -64,7 +64,7 @@ namespace Mall.WebApi.Controllers.User
x
.
Source
,
SourceName
=
x
.
Source
.
GetEnumName
(),
x
.
TenantId
,
CreateDate
=
x
.
CreateDate
.
HasValue
?
x
.
CreateDate
.
Value
.
ToString
(
"yyyy-MM-dd"
)
:
""
CreateDate
=
x
.
CreateDate
.
HasValue
?
x
.
CreateDate
.
Value
.
ToString
(
"yyyy-MM-dd
HH:mm:ss
"
)
:
""
});
return
ApiResult
.
Success
(
""
,
pagelist
);
}
...
...
@@ -367,7 +367,7 @@ namespace Mall.WebApi.Controllers.User
RB_Member_Grade_Extend
demodel
=
JsonConvert
.
DeserializeObject
<
RB_Member_Grade_Extend
>(
parms
.
msg
.
ToString
());
demodel
.
TenantId
=
Convert
.
ToInt32
(
parms
.
uid
);
demodel
.
MallBaseId
=
parms
.
MallBaseId
;
demodel
.
MallBaseId
=
parms
.
MallBaseId
;
var
list
=
userModule
.
GetMemberGradeList
(
demodel
);
return
ApiResult
.
Success
(
""
,
list
.
Select
(
x
=>
new
{
...
...
Mall.WebApi/Startup.cs
View file @
1350b679
...
...
@@ -43,7 +43,8 @@ namespace Mall.WebApi
List
<
string
>
corsArray
=
new
List
<
string
>()
{
"http://localhost:8081"
,
"http://localhost:8080"
"http://localhost:8080"
,
"http://localhost:8082"
};
services
.
AddCors
(
options
=>
options
.
AddPolicy
(
"AllowCors"
,
policy
=>
policy
.
AllowAnyHeader
().
AllowAnyMethod
().
AllowCredentials
().
WithOrigins
(
corsArray
.
ToArray
())));
}
...
...
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