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
c4458f13
Commit
c4458f13
authored
Nov 03, 2020
by
liudong1993
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
快递查询 + 购买佣金抵扣
parent
72f39c74
Hide whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
416 additions
and
16 deletions
+416
-16
AliyunApiSearchDemo.cs
Mall.Common/Plugin/AliyunApiSearchDemo.cs
+72
-0
KdApiSearchDemo.cs
Mall.Common/Plugin/KdApiSearchDemo.cs
+5
-5
RB_Express_Config.cs
Mall.Model/Entity/BaseSetUp/RB_Express_Config.cs
+75
-0
MallBaseModule.cs
Mall.Module.BaseSetUp/MallBaseModule.cs
+78
-0
OrderModule.cs
Mall.Module.Product/OrderModule.cs
+25
-2
RB_Express_ConfigRepository.cs
Mall.Repository/BaseSetUp/RB_Express_ConfigRepository.cs
+46
-0
MallBaseController.cs
Mall.WebApi/Controllers/MallBase/MallBaseController.cs
+74
-0
AppletOrderController.cs
Mall.WebApi/Controllers/Product/AppletOrderController.cs
+41
-9
No files found.
Mall.Common/Plugin/AliyunApiSearchDemo.cs
0 → 100644
View file @
c4458f13
using
System
;
using
System.Collections.Generic
;
using
System.Linq
;
using
System.Text
;
using
System.Web
;
using
System.Net
;
using
System.IO
;
using
System.Net.Security
;
using
System.Security.Cryptography.X509Certificates
;
namespace
Mall.Common.Plugin
{
public
class
AliyunApiSearchDemo
{
//private const String host = "https://wdexpress.market.alicloudapi.com";
//private const String path = "/gxali";
private
const
String
method
=
"GET"
;
//private const String appcode = "82a534b5a9d04bbca2358715436b48ff";//开通服务后 买家中心-查看AppCode
public
static
string
GetExpressInfo
(
string
ExpressNo
,
string
ExpressType
,
string
AppCode
,
string
ReqUrl
)
{
String
querys
=
@
$"n=
{
ExpressNo
}
&t=
{
ExpressType
}
"
;
String
bodys
=
""
;
String
url
=
ReqUrl
;
HttpWebRequest
httpRequest
=
null
;
HttpWebResponse
httpResponse
=
null
;
if
(
0
<
querys
.
Length
)
{
url
=
url
+
"?"
+
querys
;
}
if
(
ReqUrl
.
Contains
(
"https://"
))
{
ServicePointManager
.
ServerCertificateValidationCallback
=
new
RemoteCertificateValidationCallback
(
CheckValidationResult
);
httpRequest
=
(
HttpWebRequest
)
WebRequest
.
CreateDefault
(
new
Uri
(
url
));
}
else
{
httpRequest
=
(
HttpWebRequest
)
WebRequest
.
Create
(
url
);
}
httpRequest
.
Method
=
method
;
httpRequest
.
Headers
.
Add
(
"Authorization"
,
"APPCODE "
+
AppCode
);
if
(
0
<
bodys
.
Length
)
{
byte
[]
data
=
Encoding
.
UTF8
.
GetBytes
(
bodys
);
using
(
Stream
stream
=
httpRequest
.
GetRequestStream
())
{
stream
.
Write
(
data
,
0
,
data
.
Length
);
}
}
try
{
httpResponse
=
(
HttpWebResponse
)
httpRequest
.
GetResponse
();
}
catch
(
WebException
ex
)
{
httpResponse
=
(
HttpWebResponse
)
ex
.
Response
;
}
Stream
st
=
httpResponse
.
GetResponseStream
();
StreamReader
reader
=
new
StreamReader
(
st
,
Encoding
.
GetEncoding
(
"utf-8"
));
return
reader
.
ReadToEnd
();
}
public
static
bool
CheckValidationResult
(
object
sender
,
X509Certificate
certificate
,
X509Chain
chain
,
SslPolicyErrors
errors
)
{
return
true
;
}
}
}
Mall.Common/Plugin/KdApiSearchDemo.cs
View file @
c4458f13
...
...
@@ -11,11 +11,11 @@ namespace Mall.Common.Plugin
public
class
KdApiSearchDemo
{
//电商ID
private
string
EBusinessID
=
"1644004"
;
//
private string EBusinessID = "1644004";
//电商加密私钥,快递鸟提供,注意保管,不要泄漏
private
string
AppKey
=
"1cff9561-518d-42b3-b4a0-889faeda6111"
;
//
private string AppKey = "1cff9561-518d-42b3-b4a0-889faeda6111";
//请求url
private
string
ReqURL
=
"http://api.kdniao.com/Ebusiness/EbusinessOrderHandle.aspx"
;
//
private string ReqURL = "http://api.kdniao.com/Ebusiness/EbusinessOrderHandle.aspx";
/// <summary>
/// Json方式 查询订单物流轨迹
...
...
@@ -24,9 +24,9 @@ namespace Mall.Common.Plugin
/// <param name="LogisticCode"></param>
/// <param name="OrderCode"></param>
/// <returns></returns>
public
string
getOrderTracesByJson
(
string
ShipperCode
,
string
LogisticCode
,
string
OrderCode
=
""
)
public
string
getOrderTracesByJson
(
string
ShipperCode
,
string
LogisticCode
,
string
EBusinessID
,
string
AppKey
,
string
ReqURL
)
{
string
requestData
=
"{'OrderCode':'
"
+
OrderCode
+
"
','ShipperCode':'"
+
ShipperCode
+
"','LogisticCode':'"
+
LogisticCode
+
"'}"
;
string
requestData
=
"{'OrderCode':'','ShipperCode':'"
+
ShipperCode
+
"','LogisticCode':'"
+
LogisticCode
+
"'}"
;
Dictionary
<
string
,
string
>
param
=
new
Dictionary
<
string
,
string
>();
param
.
Add
(
"RequestData"
,
HttpUtility
.
UrlEncode
(
requestData
,
Encoding
.
UTF8
));
...
...
Mall.Model/Entity/BaseSetUp/RB_Express_Config.cs
0 → 100644
View file @
c4458f13
using
VT.FW.DB
;
using
Mall.Common.Enum.MallBase
;
using
System
;
using
System.Collections.Generic
;
using
System.Text
;
namespace
Mall.Model.Entity.BaseSetUp
{
/// <summary>
/// 快递配置
/// </summary>
[
Serializable
]
[
DB
(
ConnectionName
=
"DefaultConnection"
)]
public
class
RB_Express_Config
{
public
int
Id
{
get
;
set
;
}
/// <summary>
/// 别名
/// </summary>
public
string
Name
{
get
;
set
;
}
/// <summary>
/// 快递类型1-阿里,2-快递鸟
/// </summary>
public
int
?
Type
{
get
;
set
;
}
/// <summary>
/// appid
/// </summary>
public
string
AppID
{
get
;
set
;
}
/// <summary>
/// key
/// </summary>
public
string
AppKey
{
get
;
set
;
}
/// <summary>
/// 秘钥
/// </summary>
public
string
AppSecret
{
get
;
set
;
}
/// <summary>
/// code
/// </summary>
public
string
AppCode
{
get
;
set
;
}
/// <summary>
/// 请求
/// </summary>
public
string
RquUrl
{
get
;
set
;
}
/// <summary>
/// 商户id
/// </summary>
public
int
TenantId
{
get
;
set
;
}
/// <summary>
/// 小程序id
/// </summary>
public
int
MallBaseId
{
get
;
set
;
}
/// <summary>
/// 1-是 2否
/// </summary>
public
int
?
IsDefault
{
get
;
set
;
}
public
int
?
Status
{
get
;
set
;
}
public
DateTime
CreateDate
{
get
;
set
;
}
public
DateTime
UpdateDate
{
get
;
set
;
}
}
}
Mall.Module.BaseSetUp/MallBaseModule.cs
View file @
c4458f13
...
...
@@ -31,6 +31,10 @@ namespace Mall.Module.BaseSetUp
private
readonly
RB_FreeShippingRepository
freeShippingRepository
=
new
RB_FreeShippingRepository
();
private
readonly
RB_MicroShop_BasicsRepository
microShopBasicsRepository
=
new
RB_MicroShop_BasicsRepository
();
/// <summary>
/// 快递配置
/// </summary>
private
readonly
RB_Express_ConfigRepository
express_ConfigRepository
=
new
RB_Express_ConfigRepository
();
...
...
@@ -956,6 +960,80 @@ namespace Mall.Module.BaseSetUp
}
#
endregion
#
region
快递配置
/// <summary>
/// 获取列表
/// </summary>
/// <param name="query"></param>
/// <returns></returns>
public
List
<
RB_Express_Config
>
GetExpressConfigList
(
RB_Express_Config
query
)
{
return
express_ConfigRepository
.
GetListRepository
(
query
);
}
/// <summary>
/// 新增修改快递配置
/// </summary>
/// <param name="query"></param>
/// <returns></returns>
public
bool
SetExpressConfig
(
RB_Express_Config
query
)
{
if
(
query
.
IsDefault
==
1
)
{
//所有的先默认为非默认
Dictionary
<
string
,
object
>
keyValues
=
new
Dictionary
<
string
,
object
>()
{
{
nameof
(
RB_Express_Config
.
IsDefault
),
2
}
};
List
<
WhereHelper
>
wheres
=
new
List
<
WhereHelper
>()
{
new
WhereHelper
(){
FiledName
=
nameof
(
RB_Express_Config
.
TenantId
),
FiledValue
=
query
.
TenantId
,
OperatorEnum
=
OperatorEnum
.
Equal
},
new
WhereHelper
(){
FiledName
=
nameof
(
RB_Express_Config
.
MallBaseId
),
FiledValue
=
query
.
MallBaseId
,
OperatorEnum
=
OperatorEnum
.
Equal
}
};
express_ConfigRepository
.
Update
(
keyValues
,
wheres
);
}
if
(
query
.
Id
>
0
)
{
//所有的先默认为非默认
Dictionary
<
string
,
object
>
keyValues
=
new
Dictionary
<
string
,
object
>()
{
{
nameof
(
RB_Express_Config
.
Name
),
query
.
Name
},
{
nameof
(
RB_Express_Config
.
IsDefault
),
query
.
IsDefault
},
{
nameof
(
RB_Express_Config
.
AppID
),
query
.
AppID
},
{
nameof
(
RB_Express_Config
.
AppKey
),
query
.
AppKey
},
{
nameof
(
RB_Express_Config
.
AppSecret
),
query
.
AppSecret
},
{
nameof
(
RB_Express_Config
.
AppCode
),
query
.
AppCode
},
{
nameof
(
RB_Express_Config
.
RquUrl
),
query
.
RquUrl
},
{
nameof
(
RB_Express_Config
.
UpdateDate
),
DateTime
.
Now
}
};
List
<
WhereHelper
>
wheres
=
new
List
<
WhereHelper
>()
{
new
WhereHelper
(){
FiledName
=
nameof
(
RB_Express_Config
.
TenantId
),
FiledValue
=
query
.
TenantId
,
OperatorEnum
=
OperatorEnum
.
Equal
},
new
WhereHelper
(){
FiledName
=
nameof
(
RB_Express_Config
.
MallBaseId
),
FiledValue
=
query
.
MallBaseId
,
OperatorEnum
=
OperatorEnum
.
Equal
}
};
return
express_ConfigRepository
.
Update
(
keyValues
,
wheres
);
}
else
{
return
express_ConfigRepository
.
Insert
(
query
)
>
0
;
}
}
#
endregion
#
region
分类包邮规则
/// <summary>
...
...
Mall.Module.Product/OrderModule.cs
View file @
c4458f13
...
...
@@ -308,6 +308,10 @@ namespace Mall.Module.Product
/// 车辆颜色
/// </summary>
private
RB_GuideCar_CarColorRepository
guideCar_CarColorRepository
=
new
RB_GuideCar_CarColorRepository
();
/// <summary>
/// 快递配置
/// </summary>
private
RB_Express_ConfigRepository
express_ConfigRepository
=
new
RB_Express_ConfigRepository
();
/// <summary>
/// 教育订单对应的老师
...
...
@@ -14406,9 +14410,28 @@ namespace Mall.Module.Product
/// <param name="expressCode"></param>
/// <param name="expressNumber"></param>
/// <returns></returns>
public
string
GetOrderExpressInfo
(
string
expressCode
,
string
expressNumber
)
public
string
GetOrderExpressInfo
(
string
expressCode
,
string
expressNumber
,
string
EBusinessID
,
string
AppKey
,
string
ReqURL
)
{
return
new
KdApiSearchDemo
().
getOrderTracesByJson
(
expressCode
,
expressNumber
);
return
new
KdApiSearchDemo
().
getOrderTracesByJson
(
expressCode
,
expressNumber
,
EBusinessID
,
AppKey
,
ReqURL
);
}
/// <summary>
/// 查询物流信息
/// </summary>
/// <param name="expressCode"></param>
/// <param name="expressNumber"></param>
/// <returns></returns>
public
string
GetOrderExpressInfoForAliyun
(
string
expressNumber
,
string
expressCode
,
string
AppCode
,
string
ReqUrl
)
{
return
AliyunApiSearchDemo
.
GetExpressInfo
(
expressNumber
,
expressCode
,
AppCode
,
ReqUrl
);
}
/// <summary>
/// 获取快递配置
/// </summary>
/// <returns></returns>
public
Model
.
Entity
.
BaseSetUp
.
RB_Express_Config
GetExpressConfig
(
int
tenantId
,
int
mallBaseId
)
{
return
express_ConfigRepository
.
GetListRepository
(
new
Model
.
Entity
.
BaseSetUp
.
RB_Express_Config
()
{
TenantId
=
tenantId
,
MallBaseId
=
mallBaseId
,
IsDefault
=
1
}).
FirstOrDefault
();
}
#
endregion
...
...
Mall.Repository/BaseSetUp/RB_Express_ConfigRepository.cs
0 → 100644
View file @
c4458f13
using
Mall.Model.Entity.BaseSetUp
;
using
System
;
using
System.Collections.Generic
;
using
System.Linq
;
using
System.Text
;
namespace
Mall.Repository.BaseSetUp
{
/// <summary>
/// 快递配置仓储层
/// </summary>
public
class
RB_Express_ConfigRepository
:
BaseRepository
<
RB_Express_Config
>
{
/// <summary>
/// 获取上传存储信息
/// </summary>
/// <param name="query">查询条件</param>
/// <returns></returns>
public
List
<
RB_Express_Config
>
GetListRepository
(
RB_Express_Config
query
)
{
StringBuilder
builder
=
new
StringBuilder
();
builder
.
Append
(
$" SELECT * FROM RB_Express_Config WHERE
{
nameof
(
RB_Express_Config
.
Status
)}
=0"
);
if
(
query
!=
null
)
{
if
(
query
.
TenantId
>
0
)
{
builder
.
Append
(
$" AND
{
nameof
(
RB_Express_Config
.
TenantId
)}
=
{
query
.
TenantId
}
"
);
}
if
(
query
.
MallBaseId
>
0
)
{
builder
.
Append
(
$" AND
{
nameof
(
RB_Express_Config
.
MallBaseId
)}
=
{
query
.
MallBaseId
}
"
);
}
if
(
query
.
Type
>
0
)
{
builder
.
Append
(
$" AND
{
nameof
(
RB_Express_Config
.
Type
)}
=
{
query
.
Type
}
"
);
}
if
(
query
.
IsDefault
>
0
)
{
builder
.
Append
(
$" AND
{
nameof
(
RB_Express_Config
.
IsDefault
)}
=
{
query
.
IsDefault
}
"
);
}
}
return
Get
<
RB_Express_Config
>(
builder
.
ToString
()).
ToList
();
}
}
}
Mall.WebApi/Controllers/MallBase/MallBaseController.cs
View file @
c4458f13
...
...
@@ -1254,5 +1254,79 @@ namespace Mall.WebApi.Controllers.MallBase
return
ApiResult
.
Success
(
"获取成功"
,
microShopBasics
);
}
#
endregion
#
region
快递配置
/// <summary>
/// 获取快递配置列表
/// </summary>
/// <returns></returns>
public
ApiResult
GetExpressConfigList
()
{
var
parms
=
RequestParm
;
var
query
=
new
RB_Express_Config
();
query
.
TenantId
=
parms
.
TenantId
;
query
.
MallBaseId
=
parms
.
MallBaseId
;
var
list
=
mallBaseModule
.
GetExpressConfigList
(
query
);
return
ApiResult
.
Success
(
"获取成功"
,
list
.
Select
(
x
=>
new
{
x
.
Id
,
x
.
Name
,
x
.
AppCode
,
x
.
AppID
,
x
.
AppKey
,
x
.
AppSecret
,
x
.
IsDefault
,
x
.
RquUrl
,
x
.
Type
}));
}
/// <summary>
/// 新增/修改快递配置
/// </summary>
/// <returns></returns>
public
ApiResult
SetExpressConfig
()
{
var
parms
=
RequestParm
;
var
query
=
JsonConvert
.
DeserializeObject
<
RB_Express_Config
>(
RequestParm
.
msg
.
ToString
());
query
.
TenantId
=
parms
.
TenantId
;
query
.
MallBaseId
=
parms
.
MallBaseId
;
if
(
query
.
Type
==
1
)
{
if
(
string
.
IsNullOrEmpty
(
query
.
AppCode
))
{
return
ApiResult
.
ParamIsNull
(
"请传递appcode"
);
}
}
else
if
(
query
.
Type
==
2
)
{
if
(
string
.
IsNullOrEmpty
(
query
.
AppID
))
{
return
ApiResult
.
ParamIsNull
(
"请传递appid"
);
}
}
if
(
string
.
IsNullOrEmpty
(
query
.
Name
))
{
return
ApiResult
.
ParamIsNull
(
"请输入别名"
);
}
if
(
string
.
IsNullOrEmpty
(
query
.
RquUrl
))
{
return
ApiResult
.
ParamIsNull
(
"请传递请求地址"
);
}
query
.
CreateDate
=
DateTime
.
Now
;
query
.
Status
=
0
;
bool
flag
=
mallBaseModule
.
SetExpressConfig
(
query
);
if
(
flag
)
{
return
ApiResult
.
Success
();
}
else
{
return
ApiResult
.
Failed
();
}
}
#
endregion
}
}
\ No newline at end of file
Mall.WebApi/Controllers/Product/AppletOrderController.cs
View file @
c4458f13
...
...
@@ -1526,20 +1526,52 @@ namespace Mall.WebApi.Controllers.MallBase
return
ApiResult
.
Failed
(
"快递不存在"
);
}
var
jsonStr
=
orderModule
.
GetOrderExpressInfo
(
model
.
ExpressCode
,
ExpressNumber
);
JObject
Rparms
=
JObject
.
Parse
(
jsonStr
);
if
(
Rparms
.
GetStringValue
(
"Success"
).
ToLower
()
==
"true"
)
//获取快递配置
var
configModel
=
orderModule
.
GetExpressConfig
(
userInfo
.
TenantId
,
userInfo
.
MallBaseId
);
if
(
configModel
==
null
)
{
return
ApiResult
.
Failed
(
"未配置快递参数,无法查询"
);
}
if
(
configModel
.
Type
==
1
)
{
List
<
Model
.
Query
.
ExpressTraces
>
list
=
JsonConvert
.
DeserializeObject
<
List
<
Model
.
Query
.
ExpressTraces
>>(
Rparms
.
GetStringValue
(
"Traces"
));
if
(
list
.
Any
())
string
alimsg
=
orderModule
.
GetOrderExpressInfoForAliyun
(
ExpressNumber
,
model
.
ExpressCode
,
configModel
.
AppCode
,
configModel
.
RquUrl
);
LogHelper
.
Write
(
alimsg
);
JObject
Rparms
=
JObject
.
Parse
(
alimsg
);
if
(
Rparms
.
GetStringValue
(
"Success"
).
ToLower
()
==
"true"
)
{
List
<
Model
.
Query
.
ExpressTraces
>
list
=
JsonConvert
.
DeserializeObject
<
List
<
Model
.
Query
.
ExpressTraces
>>(
Rparms
.
GetStringValue
(
"Traces"
));
if
(
list
.
Any
())
{
list
=
list
.
OrderByDescending
(
x
=>
x
.
AcceptTime
).
ToList
();
}
return
ApiResult
.
Success
(
""
,
list
);
}
else
{
list
=
list
.
OrderByDescending
(
x
=>
x
.
AcceptTime
).
ToList
(
);
return
ApiResult
.
Failed
(
"未能查询到该快递信息"
);
}
return
ApiResult
.
Success
(
""
,
list
);
}
else
else
if
(
configModel
.
Type
==
2
)
{
return
ApiResult
.
Failed
(
"未能查询到该快递信息"
);
var
jsonStr
=
orderModule
.
GetOrderExpressInfo
(
model
.
ExpressCode
,
ExpressNumber
,
configModel
.
AppID
,
configModel
.
AppKey
,
configModel
.
RquUrl
);
LogHelper
.
Write
(
jsonStr
);
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"
));
if
(
list
.
Any
())
{
list
=
list
.
OrderByDescending
(
x
=>
x
.
AcceptTime
).
ToList
();
}
return
ApiResult
.
Success
(
""
,
list
);
}
else
{
return
ApiResult
.
Failed
(
"未能查询到该快递信息"
);
}
}
else
{
return
ApiResult
.
Failed
(
"未查询到快递配置"
);
}
}
catch
(
Exception
ex
)
...
...
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