Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Contribute to GitLab
Sign in
Toggle navigation
O
oms
Project
Project
Details
Activity
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
曲欣亮
oms
Commits
998c35d4
Commit
998c35d4
authored
Dec 13, 2019
by
Quxl
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
x
parent
9623b8d4
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
841 additions
and
1 deletion
+841
-1
QiyeWxService.java
src/main/java/com/egolm/oms/service/QiyeWxService.java
+89
-0
OrderServiceImpl.java
...ain/java/com/egolm/oms/service/impl/OrderServiceImpl.java
+46
-1
QiyeWxServiceImpl.java
...in/java/com/egolm/oms/service/impl/QiyeWxServiceImpl.java
+98
-0
HttpUtil.java
src/main/java/com/egolm/oms/util/HttpUtil.java
+608
-0
No files found.
src/main/java/com/egolm/oms/service/QiyeWxService.java
0 → 100644
View file @
998c35d4
package
com
.
egolm
.
oms
.
service
;
import
java.util.ArrayList
;
import
java.util.HashMap
;
import
java.util.List
;
import
java.util.Map
;
public
interface
QiyeWxService
{
long
DevTime
=
1000
*
60
*
15
;
String
PrefixRedisTokenKey
=
"AccessTokenRedis_"
;
String
UrlGetToken
=
"/gettoken?corpid={0}&corpsecret={1}"
;
String
UrlSendMsg
=
"/message/send?access_token={0}"
;
String
getTokenString
();
void
refreshToken
();
void
sendMessage
(
WxMessage
wxMessage
);
public
static
class
WxMessage
{
final
String
touser
;
final
String
msgtype
=
"miniprogram_notice"
;
MiniprogramNotice
miniprogram_notice
;
public
WxMessage
(
String
touser
)
{
this
.
touser
=
touser
;
}
public
String
getTouser
()
{
return
touser
;
}
public
String
getMsgtype
()
{
return
msgtype
;
}
public
MiniprogramNotice
getMiniprogram_notice
()
{
return
miniprogram_notice
;
}
public
void
setMiniprogram_notice
(
MiniprogramNotice
miniprogram_notice
)
{
this
.
miniprogram_notice
=
miniprogram_notice
;
}
public
static
class
MiniprogramNotice
{
String
appid
;
String
page
;
String
title
;
String
description
;
final
Boolean
emphasis_first_item
=
true
;
List
<
Map
<
String
,
?>>
content_item
=
new
ArrayList
<
Map
<
String
,
?>>();
public
String
getAppid
()
{
return
appid
;
}
public
void
setAppid
(
String
appid
)
{
this
.
appid
=
appid
;
}
public
String
getPage
()
{
return
page
;
}
public
void
setPage
(
String
page
)
{
this
.
page
=
page
;
}
public
String
getTitle
()
{
return
title
;
}
public
void
setTitle
(
String
title
)
{
this
.
title
=
title
;
}
public
String
getDescription
()
{
return
description
;
}
public
void
setDescription
(
String
description
)
{
this
.
description
=
description
;
}
public
Boolean
getEmphasis_first_item
()
{
return
emphasis_first_item
;
}
public
List
<
Map
<
String
,
?>>
getContent_item
()
{
return
content_item
;
}
public
void
setContent_item
(
List
<
Map
<
String
,
?>>
content_item
)
{
this
.
content_item
=
content_item
;
}
public
void
setContent_item
(
Map
<?,
?>
contentMap
)
{
for
(
Object
key
:
contentMap
.
keySet
())
{
Object
vlaue
=
contentMap
.
get
(
key
);
Map
<
String
,
Object
>
map
=
new
HashMap
<
String
,
Object
>();
map
.
put
(
"key"
,
key
);
map
.
put
(
"value"
,
vlaue
);
content_item
.
add
(
map
);
}
}
}
}
}
src/main/java/com/egolm/oms/service/impl/OrderServiceImpl.java
View file @
998c35d4
...
...
@@ -4,6 +4,7 @@ import java.math.BigDecimal;
import
java.util.ArrayList
;
import
java.util.Date
;
import
java.util.HashMap
;
import
java.util.LinkedHashMap
;
import
java.util.List
;
import
java.util.Map
;
import
java.util.stream.Collectors
;
...
...
@@ -28,12 +29,18 @@ import com.egolm.oms.config.XException;
import
com.egolm.oms.model.TSalesOrder
;
import
com.egolm.oms.model.TSalesOrderDtl
;
import
com.egolm.oms.service.OrderService
;
import
com.egolm.oms.service.QiyeWxService
;
import
com.egolm.oms.service.QiyeWxService.WxMessage
;
import
com.egolm.oms.service.QiyeWxService.WxMessage.MiniprogramNotice
;
import
com.egolm.oms.util.I18NUtils
;
@Service
public
class
OrderServiceImpl
implements
OrderService
{
@Autowired
private
JdbcTemplate
jdbcTemplate
;
@Autowired
private
QiyeWxService
wxService
;
/**
* 订单检查
...
...
@@ -258,7 +265,7 @@ public class OrderServiceImpl implements OrderService {
Dialect
dialect
=
jdbcTemplate
.
getDialect
();
Sql
sqlDesc
=
dialect
.
argsInsert
(
"tSalesOrderPay"
,
map
);
String
sql
=
"if not exists (select * from tSalesOrderPay where sTransTraceNO = '"
+
sTransTraceNO
+
"') "
+
sqlDesc
.
getSql
();
jdbcTemplate
.
update
(
sql
,
sqlDesc
.
getArgs
());
int
count
=
jdbcTemplate
.
update
(
sql
,
sqlDesc
.
getArgs
());
jdbcTemplate
.
update
(
"update tSalesOrder set nOrderStatus = nOrderStatus|32 where sSalesOrderID = ?"
,
sSalesOrderID
);
try
{
jdbcTemplate
.
executeMutil
(
"exec Up_Ego_SplitOrderPrd '"
+
sSalesOrderID
+
"'"
);
...
...
@@ -268,6 +275,44 @@ public class OrderServiceImpl implements OrderService {
}
throw
e
;
}
if
(
count
>
0
)
{
TSalesOrder
order
=
jdbcTemplate
.
queryForBean
(
"select * from tSalesOrder where sSalesOrderID = ?"
,
TSalesOrder
.
class
,
sSalesOrderID
);
String
salesmanNo
=
order
.
getsSalesmanNO
();
String
shopNo
=
order
.
getsShopNO
();
BigDecimal
totalAmount
=
order
.
getnTotalSaleAmount
();
BigDecimal
totalSaleQty
=
order
.
getnTotalSaleQty
();
String
payType
=
order
.
getsSalesOrderPayType
();
Map
<
String
,
Object
>
salesman
=
null
;
try
{
salesman
=
jdbcTemplate
.
queryForMap
(
"select * from tSalesman where sSalesmanNO = ?"
,
salesmanNo
);
}
catch
(
EmptyResultDataAccessException
e
)
{
e
.
printStackTrace
();
}
if
(
salesman
!=
null
)
{
Map
<
String
,
Object
>
shop
=
jdbcTemplate
.
queryForMap
(
"select * from tShop where sShopNO = ?"
,
shopNo
);
String
custNo
=
(
String
)
shop
.
get
(
"sCustNO"
);
String
shopMemo
=
(
String
)
shop
.
get
(
"sMemo"
);
Map
<
String
,
Object
>
cust
=
jdbcTemplate
.
queryForMap
(
"select * from tCustomer where sCustNO = ?"
,
custNo
);;
String
custName
=
(
String
)
cust
.
get
(
"sCustName"
);
String
sCompanyAccountID
=
(
String
)
salesman
.
get
(
"sCompanyAccountID"
);
WxMessage
wxMessage
=
new
WxMessage
(
sCompanyAccountID
);
MiniprogramNotice
notice
=
new
MiniprogramNotice
();
wxMessage
.
setMiniprogram_notice
(
notice
);
notice
.
setDescription
(
"当前时间"
);
notice
.
setTitle
(
"认证审核通知"
);
notice
.
setPage
(
"pages/ordermanage/detail/detail?SalesmanNO="
+
salesmanNo
+
"&isShare=1&id="
+
sSalesOrderID
+
"&isActive=0"
);
Map
<
Object
,
Object
>
params
=
new
LinkedHashMap
<
Object
,
Object
>();
params
.
put
(
"订单状态"
,
"待审核"
);
params
.
put
(
"客户"
,
custName
);
params
.
put
(
"订单金额"
,
totalAmount
);
params
.
put
(
"商品数量"
,
totalSaleQty
);
params
.
put
(
"支付方式"
,
payType
);
params
.
put
(
"订单时间"
,
DateUtil
.
format
(
new
Date
()));
params
.
put
(
"备注"
,
StringUtil
.
isBlank
(
shopMemo
)
?
" "
:
shopMemo
);
notice
.
setContent_item
(
params
);
wxService
.
sendMessage
(
wxMessage
);
}
}
}
@Override
...
...
src/main/java/com/egolm/oms/service/impl/QiyeWxServiceImpl.java
0 → 100644
View file @
998c35d4
package
com
.
egolm
.
oms
.
service
.
impl
;
import
java.text.MessageFormat
;
import
java.util.Date
;
import
java.util.HashMap
;
import
java.util.Map
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.beans.factory.annotation.Value
;
import
org.springframework.data.redis.core.RedisTemplate
;
import
org.springframework.stereotype.Service
;
import
com.alibaba.fastjson.JSON
;
import
com.alibaba.fastjson.JSONObject
;
import
com.egolm.common.DateUtil
;
import
com.egolm.common.StringUtil
;
import
com.egolm.oms.service.QiyeWxService
;
import
com.egolm.oms.util.HttpUtil
;
import
com.egolm.oms.util.HttpUtil.HttpReqObject
;
import
com.egolm.oms.util.HttpUtil.HttpRespObject
;
import
com.egolm.oms.util.HttpUtil.JsonReqObject
;
import
com.egolm.oms.util.HttpUtil.SSLVersion
;
@Service
public
class
QiyeWxServiceImpl
implements
QiyeWxService
{
@Value
(
"${qiyewx.corpid}"
)
private
String
corpid
;
@Value
(
"${qiyewx.corpsecret}"
)
private
String
corpsecret
;
@Value
(
"${qiyewx.baseUrl}"
)
private
String
baseUrl
;
@Value
(
"${qiyewx.msg.redirect.appid}"
)
private
String
redirectAppid
;
@Autowired
private
RedisTemplate
<
String
,
String
>
redis
;
@Override
public
String
getTokenString
()
{
String
redisCacheKey
=
PrefixRedisTokenKey
+
corpid
;
Long
systemTime
=
System
.
currentTimeMillis
();
String
tokenObjectString
=
redis
.
opsForValue
().
get
(
redisCacheKey
);
if
(
StringUtil
.
isNotBlank
(
tokenObjectString
))
{
JSONObject
tokenObject
=
JSON
.
parseObject
(
tokenObjectString
);
Integer
errcode
=
tokenObject
.
getInteger
(
"errcode"
);
if
(
errcode
==
0
)
{
Long
expires_in
=
tokenObject
.
getLong
(
"expires_in"
);
String
loadTimeString
=
tokenObject
.
getString
(
"loadTime"
);
if
(
expires_in
!=
null
&&
StringUtil
.
isNotBlank
(
loadTimeString
))
{
Date
loadTime
=
DateUtil
.
parse
(
loadTimeString
,
"yyyy-MM-dd HH:mm:ss"
);
Long
expireTime
=
loadTime
.
getTime
()
+
(
expires_in
*
1000L
);
if
((
expireTime
-
DevTime
)
>
systemTime
)
{
String
access_token
=
tokenObject
.
getString
(
"access_token"
);
if
(
StringUtil
.
isNotBlank
(
access_token
))
{
return
access_token
;
}
}
}
}
}
String
requestUrl
=
baseUrl
+
MessageFormat
.
format
(
UrlGetToken
,
corpid
,
corpsecret
);
HttpRespObject
resp
=
HttpUtil
.
newInstance
().
setSSLVersion
(
SSLVersion
.
SSLv3
).
get
(
new
HttpReqObject
(
requestUrl
,
null
,
null
));
if
(
resp
.
getHttpCode
()
==
200
)
{
String
text
=
resp
.
getResponseBody
();
JSONObject
tokenObject
=
JSON
.
parseObject
(
text
);
Integer
code
=
tokenObject
.
getInteger
(
"errcode"
);
if
(
code
==
0
)
{
tokenObject
.
put
(
"loadTime"
,
DateUtil
.
format
(
new
Date
(),
"yyyy-MM-dd HH:mm:ss"
));
redis
.
opsForValue
().
set
(
redisCacheKey
,
tokenObject
.
toJSONString
());
return
tokenObject
.
getString
(
"access_token"
);
}
}
return
null
;
}
@Override
public
void
refreshToken
()
{
String
redisCacheKey
=
PrefixRedisTokenKey
+
corpid
;
redis
.
delete
(
redisCacheKey
);
}
@Override
public
void
sendMessage
(
WxMessage
wxMessage
)
{
String
tokenString
=
this
.
getTokenString
();
String
requestUrl
=
baseUrl
+
MessageFormat
.
format
(
UrlSendMsg
,
tokenString
);
Map
<
String
,
String
>
headers
=
new
HashMap
<
String
,
String
>();
headers
.
put
(
"content-type"
,
"application/x-www-form-urlencoded"
);
wxMessage
.
getMiniprogram_notice
().
setAppid
(
redirectAppid
);
HttpUtil
.
newInstance
().
setSSLVersion
(
SSLVersion
.
SSLv3
).
postJson
(
new
JsonReqObject
(
requestUrl
,
wxMessage
,
headers
));
}
}
src/main/java/com/egolm/oms/util/HttpUtil.java
0 → 100644
View file @
998c35d4
This diff is collapsed.
Click to expand it.
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