Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
jinli gu
Litemall
Commits
78127aed
Commit
78127aed
authored
Aug 15, 2018
by
Menethil
Browse files
物流信息改为随订单详情返回,移除物流订单API
parent
786e8e8c
Changes
5
Hide whitespace changes
Inline
Side-by-side
litemall-core/src/main/java/org/linlinjava/litemall/core/express/ExpressService.java
View file @
78127aed
package
org.linlinjava.litemall.core.express
;
package
org.linlinjava.litemall.core.express
;
import
com.fasterxml.jackson.databind.ObjectMapper
;
import
org.linlinjava.litemall.core.express.config.ExpressProperties
;
import
org.linlinjava.litemall.core.express.config.ExpressProperties
;
import
org.linlinjava.litemall.core.express.dao.ExpressInfo
;
import
org.linlinjava.litemall.core.util.HttpUtil
;
import
org.linlinjava.litemall.core.util.HttpUtil
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.stereotype.Service
;
import
org.springframework.util.Base64Utils
;
import
org.springframework.util.Base64Utils
;
import
java.net.URLEncoder
;
import
java.net.URLEncoder
;
...
@@ -33,24 +33,45 @@ public class ExpressService {
...
@@ -33,24 +33,45 @@ public class ExpressService {
/**
/**
* 获取物流供应商名
* 获取物流供应商名
*
*
* @param vendo
o
Code
* @param vendo
r
Code
* @return
* @return
*/
*/
public
String
getVendorName
(
String
vendo
o
Code
)
{
public
String
getVendorName
(
String
vendo
r
Code
)
{
for
(
Map
<
String
,
String
>
item
:
properties
.
getVendors
())
{
for
(
Map
<
String
,
String
>
item
:
properties
.
getVendors
())
{
if
(
item
.
get
(
"code"
).
equals
(
vendo
o
Code
))
if
(
item
.
get
(
"code"
).
equals
(
vendo
r
Code
))
return
item
.
get
(
"name"
);
return
item
.
get
(
"name"
);
}
}
return
null
;
return
null
;
}
}
/**
* 获取物流信息
*
* @param expCode
* @param expNo
* @return
*/
public
ExpressInfo
getExpressInfo
(
String
expCode
,
String
expNo
)
{
try
{
String
result
=
getOrderTracesByJson
(
expCode
,
expNo
);
ObjectMapper
objMap
=
new
ObjectMapper
();
ExpressInfo
ei
=
objMap
.
readValue
(
result
,
ExpressInfo
.
class
);
ei
.
setShipperName
(
getVendorName
(
expCode
));
return
ei
;
}
catch
(
Exception
e
)
{
e
.
printStackTrace
();
}
return
null
;
}
/**
/**
* Json方式 查询订单物流轨迹
* Json方式 查询订单物流轨迹
*
*
* @throws Exception
* @throws Exception
*/
*/
p
ublic
String
getOrderTracesByJson
(
String
expCode
,
String
expNo
)
throws
Exception
{
p
rivate
String
getOrderTracesByJson
(
String
expCode
,
String
expNo
)
throws
Exception
{
if
(!
properties
.
isEnable
()){
if
(!
properties
.
isEnable
())
{
return
null
;
return
null
;
}
}
...
@@ -101,7 +122,7 @@ public class ExpressService {
...
@@ -101,7 +122,7 @@ public class ExpressService {
* @param charset 编码方式
* @param charset 编码方式
* @return DataSign签名
* @return DataSign签名
*/
*/
private
String
encrypt
(
String
content
,
String
keyValue
,
String
charset
)
{
private
String
encrypt
(
String
content
,
String
keyValue
,
String
charset
)
{
if
(
keyValue
!=
null
)
{
if
(
keyValue
!=
null
)
{
content
=
content
+
keyValue
;
content
=
content
+
keyValue
;
}
}
...
...
litemall-core/src/main/java/org/linlinjava/litemall/core/express/dao/ExpressInfo.java
View file @
78127aed
...
@@ -28,6 +28,8 @@ public class ExpressInfo {
...
@@ -28,6 +28,8 @@ public class ExpressInfo {
@JsonProperty
(
"Success"
)
@JsonProperty
(
"Success"
)
private
boolean
Success
;
private
boolean
Success
;
private
String
ShipperName
;
public
void
setLogisticCode
(
String
LogisticCode
)
{
public
void
setLogisticCode
(
String
LogisticCode
)
{
this
.
LogisticCode
=
LogisticCode
;
this
.
LogisticCode
=
LogisticCode
;
}
}
...
@@ -76,4 +78,11 @@ public class ExpressInfo {
...
@@ -76,4 +78,11 @@ public class ExpressInfo {
return
Success
;
return
Success
;
}
}
public
String
getShipperName
()
{
return
ShipperName
;
}
public
void
setShipperName
(
String
shipperName
)
{
ShipperName
=
shipperName
;
}
}
}
\ No newline at end of file
litemall-wx-api/src/main/java/org/linlinjava/litemall/wx/web/WxExpressController.java
deleted
100644 → 0
View file @
786e8e8c
package
org.linlinjava.litemall.wx.web
;
import
com.fasterxml.jackson.databind.ObjectMapper
;
import
org.linlinjava.litemall.core.express.ExpressService
;
import
org.linlinjava.litemall.core.express.dao.ExpressInfo
;
import
org.linlinjava.litemall.core.util.JacksonUtil
;
import
org.linlinjava.litemall.core.util.ResponseUtil
;
import
org.linlinjava.litemall.wx.annotation.LoginUser
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.validation.annotation.Validated
;
import
org.springframework.web.bind.annotation.PostMapping
;
import
org.springframework.web.bind.annotation.RequestBody
;
import
org.springframework.web.bind.annotation.RequestMapping
;
import
org.springframework.web.bind.annotation.RestController
;
import
java.util.HashMap
;
import
java.util.Map
;
/**
* 物流信息查询接口
*/
@RestController
@RequestMapping
(
"/wx/express"
)
@Validated
public
class
WxExpressController
{
@Autowired
private
ExpressService
expressService
;
@PostMapping
(
"query"
)
public
Object
query
(
@LoginUser
Integer
userId
,
@RequestBody
String
body
)
{
if
(
userId
==
null
)
{
return
ResponseUtil
.
unlogin
();
}
String
expCode
=
JacksonUtil
.
parseString
(
body
,
"expCode"
);
String
expNo
=
JacksonUtil
.
parseString
(
body
,
"expNo"
);
try
{
String
result
=
expressService
.
getOrderTracesByJson
(
expCode
,
expNo
);
ObjectMapper
objMap
=
new
ObjectMapper
();
ExpressInfo
ei
=
objMap
.
readValue
(
result
,
ExpressInfo
.
class
);
Map
<
String
,
Object
>
data
=
new
HashMap
<>();
data
.
put
(
"expCode"
,
ei
.
getLogisticCode
());
data
.
put
(
"expNo"
,
ei
.
getShipperCode
());
data
.
put
(
"expName"
,
expressService
.
getVendorName
(
expCode
));
data
.
put
(
"Traces"
,
ei
.
getTraces
());
return
ResponseUtil
.
ok
(
data
);
}
catch
(
Exception
e
)
{
e
.
printStackTrace
();
}
return
ResponseUtil
.
badArgument
();
}
}
litemall-wx-api/src/main/java/org/linlinjava/litemall/wx/web/WxOrderController.java
View file @
78127aed
...
@@ -9,6 +9,8 @@ import com.github.binarywang.wxpay.service.WxPayService;
...
@@ -9,6 +9,8 @@ import com.github.binarywang.wxpay.service.WxPayService;
import
org.apache.commons.io.IOUtils
;
import
org.apache.commons.io.IOUtils
;
import
org.apache.commons.logging.Log
;
import
org.apache.commons.logging.Log
;
import
org.apache.commons.logging.LogFactory
;
import
org.apache.commons.logging.LogFactory
;
import
org.linlinjava.litemall.core.express.ExpressService
;
import
org.linlinjava.litemall.core.express.dao.ExpressInfo
;
import
org.linlinjava.litemall.core.notify.NotifyService
;
import
org.linlinjava.litemall.core.notify.NotifyService
;
import
org.linlinjava.litemall.core.notify.NotifyType
;
import
org.linlinjava.litemall.core.notify.NotifyType
;
import
org.linlinjava.litemall.core.qcode.QCodeService
;
import
org.linlinjava.litemall.core.qcode.QCodeService
;
...
@@ -28,6 +30,7 @@ import org.springframework.transaction.TransactionDefinition;
...
@@ -28,6 +30,7 @@ import org.springframework.transaction.TransactionDefinition;
import
org.springframework.transaction.TransactionStatus
;
import
org.springframework.transaction.TransactionStatus
;
import
org.springframework.transaction.support.DefaultTransactionDefinition
;
import
org.springframework.transaction.support.DefaultTransactionDefinition
;
import
org.springframework.util.Assert
;
import
org.springframework.util.Assert
;
import
org.springframework.util.StringUtils
;
import
org.springframework.validation.annotation.Validated
;
import
org.springframework.validation.annotation.Validated
;
import
org.springframework.web.bind.annotation.*
;
import
org.springframework.web.bind.annotation.*
;
...
@@ -95,6 +98,8 @@ public class WxOrderController {
...
@@ -95,6 +98,8 @@ public class WxOrderController {
private
LitemallGrouponService
grouponService
;
private
LitemallGrouponService
grouponService
;
@Autowired
@Autowired
private
QCodeService
qCodeService
;
private
QCodeService
qCodeService
;
@Autowired
private
ExpressService
expressService
;
public
WxOrderController
()
{
public
WxOrderController
()
{
}
}
...
@@ -251,6 +256,14 @@ public class WxOrderController {
...
@@ -251,6 +256,14 @@ public class WxOrderController {
Map
<
String
,
Object
>
result
=
new
HashMap
<>();
Map
<
String
,
Object
>
result
=
new
HashMap
<>();
result
.
put
(
"orderInfo"
,
orderVo
);
result
.
put
(
"orderInfo"
,
orderVo
);
result
.
put
(
"orderGoods"
,
orderGoodsVoList
);
result
.
put
(
"orderGoods"
,
orderGoodsVoList
);
// 订单状态为已发货且物流信息不为空
//"YTO", "800669400640887922"
if
(
order
.
getOrderStatus
().
equals
(
OrderUtil
.
STATUS_SHIP
))
{
ExpressInfo
ei
=
expressService
.
getExpressInfo
(
order
.
getShipChannel
(),
order
.
getShipSn
());
result
.
put
(
"expressInfo"
,
ei
);
}
return
ResponseUtil
.
ok
(
result
);
return
ResponseUtil
.
ok
(
result
);
}
}
...
...
litemall-wx-api/src/test/java/org/linlinjava/litemall/wx/ExpressTest.java
View file @
78127aed
package
org.linlinjava.litemall.wx
;
package
org.linlinjava.litemall.wx
;
import
com.fasterxml.jackson.databind.ObjectMapper
;
import
org.junit.Test
;
import
org.junit.Test
;
import
org.junit.runner.RunWith
;
import
org.junit.runner.RunWith
;
import
org.linlinjava.litemall.core.express.ExpressService
;
import
org.linlinjava.litemall.core.express.ExpressService
;
...
@@ -17,15 +16,12 @@ public class ExpressTest {
...
@@ -17,15 +16,12 @@ public class ExpressTest {
@Test
@Test
public
void
test
()
{
public
void
test
()
{
ExpressService
expressService
=
new
ExpressService
();
ExpressService
expressService
=
new
ExpressService
();
String
result
=
null
;
ExpressInfo
ei
=
null
;
try
{
try
{
result
=
expressService
.
getOrderTracesByJson
(
"YTO"
,
"800669400640887922"
);
ei
=
expressService
.
getExpressInfo
(
"YTO"
,
"800669400640887922"
);
ObjectMapper
objMap
=
new
ObjectMapper
();
ExpressInfo
ei
=
objMap
.
readValue
(
result
,
ExpressInfo
.
class
);
ei
.
getTraces
();
}
catch
(
Exception
e
)
{
}
catch
(
Exception
e
)
{
e
.
printStackTrace
();
e
.
printStackTrace
();
}
}
System
.
out
.
print
(
result
);
System
.
out
.
print
(
ei
);
}
}
}
}
Write
Preview
Supports
Markdown
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