Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Q
qk_backend
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
quanku
qk_backend
Commits
7511f116
Commit
7511f116
authored
Apr 16, 2024
by
shiyu
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
发送模板消息
parent
605b6f55
Changes
9
Hide whitespace changes
Inline
Side-by-side
Showing
9 changed files
with
160 additions
and
60 deletions
+160
-60
ch-core/src/main/java/com/wwdz/ch/core/notify/AliSmsSender.java
...e/src/main/java/com/wwdz/ch/core/notify/AliSmsSender.java
+3
-4
ch-wx-api/src/main/java/com/wwdz/ch/wx/api/WxAppletApi.java
ch-wx-api/src/main/java/com/wwdz/ch/wx/api/WxAppletApi.java
+4
-2
ch-wx-api/src/main/java/com/wwdz/ch/wx/entity/FollowFansMsg.java
...pi/src/main/java/com/wwdz/ch/wx/entity/FollowFansMsg.java
+34
-0
ch-wx-api/src/main/java/com/wwdz/ch/wx/impl/FollowFansRecordServiceImpl.java
...java/com/wwdz/ch/wx/impl/FollowFansRecordServiceImpl.java
+34
-14
ch-wx-api/src/main/java/com/wwdz/ch/wx/impl/distribution/AuctionRecordServiceImpl.java
...wdz/ch/wx/impl/distribution/AuctionRecordServiceImpl.java
+12
-10
ch-wx-api/src/main/java/com/wwdz/ch/wx/impl/distribution/DistributionOrderServiceImpl.java
...ch/wx/impl/distribution/DistributionOrderServiceImpl.java
+16
-13
ch-wx-api/src/main/java/com/wwdz/ch/wx/impl/distribution/SendMsgServiceImpl.java
.../com/wwdz/ch/wx/impl/distribution/SendMsgServiceImpl.java
+45
-4
ch-wx-api/src/main/java/com/wwdz/ch/wx/job/AutoSendMsgJob.java
...-api/src/main/java/com/wwdz/ch/wx/job/AutoSendMsgJob.java
+10
-8
ch-wx-api/src/main/java/com/wwdz/ch/wx/service/distribution/SendMsgService.java
...a/com/wwdz/ch/wx/service/distribution/SendMsgService.java
+2
-5
No files found.
ch-core/src/main/java/com/wwdz/ch/core/notify/AliSmsSender.java
View file @
7511f116
...
...
@@ -7,7 +7,6 @@ import com.wwdz.ch.db.domain.User;
import
com.xxdxxs.utils.JsonUtils
;
import
com.xxdxxs.utils.StringUtils
;
import
lombok.extern.slf4j.Slf4j
;
import
okhttp3.Cache
;
import
org.slf4j.Logger
;
import
org.slf4j.LoggerFactory
;
import
org.springframework.beans.factory.annotation.Autowired
;
...
...
@@ -92,7 +91,7 @@ public class AliSmsSender implements SmsSender {
}
public
Result
send
AuctionWithTemplate
(
long
userId
,
String
msg
)
{
public
Result
send
Sms
(
long
userId
,
String
msg
)
{
try
{
User
user
=
cacheUtil
.
getAppletUsers
(
userId
);
if
(
user
==
null
)
{
...
...
@@ -107,7 +106,7 @@ public class AliSmsSender implements SmsSender {
Map
<
String
,
Object
>
map
=
new
HashMap
<>();
map
.
put
(
"msg"
,
msg
);
logger
.
info
(
"
拍卖
通知发送内容 : {} "
,
msg
);
logger
.
info
(
"
短信
通知发送内容 : {} "
,
msg
);
com
.
aliyun
.
dysmsapi20170525
.
Client
client
=
createClient
();
com
.
aliyun
.
dysmsapi20170525
.
models
.
SendSmsRequest
sendSmsRequest
=
new
com
.
aliyun
.
dysmsapi20170525
.
models
.
SendSmsRequest
()
.
setPhoneNumbers
(
phone
)
...
...
@@ -115,7 +114,7 @@ public class AliSmsSender implements SmsSender {
.
setTemplateParam
(
JsonUtils
.
fromMap
(
map
))
.
setSignName
(
"换藏小程序"
);
SendSmsResponse
sendSmsResponse
=
client
.
sendSmsWithOptions
(
sendSmsRequest
,
new
com
.
aliyun
.
teautil
.
models
.
RuntimeOptions
());
logger
.
info
(
"
拍卖
通知发送结果 : {} "
,
JsonUtils
.
from
(
sendSmsResponse
));
logger
.
info
(
"
短信
通知发送结果 : {} "
,
JsonUtils
.
from
(
sendSmsResponse
));
if
(
"OK"
.
equals
(
sendSmsResponse
.
getBody
().
code
))
{
return
Result
.
success
();
}
...
...
ch-wx-api/src/main/java/com/wwdz/ch/wx/api/WxAppletApi.java
View file @
7511f116
...
...
@@ -61,12 +61,12 @@ public class WxAppletApi {
public
String
getUrlLink
(
String
query
)
{
public
String
getUrlLink
(
String
redirectUrl
,
String
query
)
{
String
urlLink
=
""
;
try
{
String
accessToken
=
wxLoginManager
.
getAccessToken
();
String
url
=
String
.
format
(
URL_LINK
,
accessToken
);
StringBuffer
stringBuffer
=
new
StringBuffer
(
AUCTION_MSG_URL
);
StringBuffer
stringBuffer
=
new
StringBuffer
(
redirectUrl
);
OkHttpUtil
okHttpUtil
=
OkHttpUtil
.
builder
().
url
(
url
);
Map
<
String
,
Object
>
map
=
new
HashMap
<>();
map
.
put
(
"path"
,
stringBuffer
.
toString
());
...
...
@@ -91,4 +91,6 @@ public class WxAppletApi {
}
ch-wx-api/src/main/java/com/wwdz/ch/wx/entity/FollowFansMsg.java
0 → 100644
View file @
7511f116
package
com.wwdz.ch.wx.entity
;
import
com.xxdxxs.entity.Entity
;
import
lombok.Data
;
import
java.util.Date
;
@Data
public
class
FollowFansMsg
implements
Entity
{
private
String
openId
;
private
String
templetId
;
/**
* 被关注人名称
*/
private
String
followerName
;
/**
* 粉丝名称
*/
private
String
fansName
;
/**
* 时间
*/
private
Date
createTime
;
/**
* 消息内容
*/
private
String
content
;
}
ch-wx-api/src/main/java/com/wwdz/ch/wx/impl/FollowFansRecordServiceImpl.java
View file @
7511f116
package
com.wwdz.ch.wx.impl
;
import
com.alibaba.dubbo.config.annotation.Reference
;
import
com.github.pagehelper.PageInfo
;
import
com.wwdz.ch.core.consts.FollowFansEnum
;
import
com.wwdz.ch.core.consts.MessageEnum
;
import
com.wwdz.ch.core.consts.ResultCode
;
import
com.wwdz.ch.core.notify.AliSmsSender
;
import
com.wwdz.ch.core.type.PageSearchResult
;
import
com.wwdz.ch.core.type.Result
;
import
com.wwdz.ch.core.util.CacheUtil
;
...
...
@@ -16,31 +15,22 @@ import com.wwdz.ch.db.dao.distribution.DistributionOrderDao;
import
com.wwdz.ch.db.dao.distribution.SupplierItemDao
;
import
com.wwdz.ch.db.domain.FollowFansRecord
;
import
com.wwdz.ch.db.domain.distribution.DistributionOrder
;
import
com.wwdz.ch.db.domain.distribution.DistributorShareRecord
;
import
com.wwdz.ch.db.domain.distribution.SupplierItem
;
import
com.wwdz.ch.db.dto.request.FollowFansRecordRequestDto
;
import
com.wwdz.ch.db.dto.request.distribution.DistributionOrderRequestDto
;
import
com.wwdz.ch.wx.
entity.MessageContentText
;
import
com.wwdz.ch.wx.entity.
request.MessageRequestDto
;
import
com.wwdz.ch.wx.
api.WxAppletApi
;
import
com.wwdz.ch.wx.entity.
FollowFansMsg
;
import
com.wwdz.ch.wx.entity.vo.FollowFansRecordVo
;
import
com.wwdz.ch.wx.entity.vo.distribution.DistributionOrderVo
;
import
com.wwdz.ch.wx.entity.vo.distribution.DistributorShareRecordVo
;
import
com.wwdz.ch.wx.service.FollowFansRecordService
;
import
com.wwdz.ch.wx.service.MessageService
;
import
com.wwdz.mall.common.vo.response.CloudServerResponse
;
import
com.wwdz.mall.contentcenter.api.CommunityAttributeReadService
;
import
com.wwdz.mall.contentcenter.domain.result.attribute.CommunityUserAttributeDO
;
import
com.xxdxxs.utils.DateUtils
;
import
com.wwdz.ch.wx.service.distribution.SendMsgService
;
import
com.xxdxxs.utils.EntityMapper
;
import
com.xxdxxs.utils.JsonUtils
;
import
org.slf4j.Logger
;
import
org.slf4j.LoggerFactory
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.stereotype.Service
;
import
org.springframework.transaction.annotation.Transactional
;
import
org.springframework.transaction.interceptor.TransactionAspectSupport
;
import
java.time.LocalDateTime
;
import
java.util.*
;
import
java.util.stream.Collectors
;
...
...
@@ -50,6 +40,8 @@ public class FollowFansRecordServiceImpl implements FollowFansRecordService {
private
static
final
Logger
logger
=
LoggerFactory
.
getLogger
(
FollowFansRecordServiceImpl
.
class
);
private
static
final
String
TEMPLET_URL
=
"/pages/followAndFansList/index"
;
@Autowired
FollowFansRecordDao
followFansRecordDao
;
...
...
@@ -68,6 +60,15 @@ public class FollowFansRecordServiceImpl implements FollowFansRecordService {
@Autowired
SupplierItemDao
supplierItemDao
;
@Autowired
SendMsgService
sendMsgService
;
@Autowired
AliSmsSender
aliSmsSender
;
@Autowired
WxAppletApi
wxAppletApi
;
@Override
public
Result
follow
(
FollowFansRecordRequestDto
dto
)
{
try
{
...
...
@@ -89,6 +90,25 @@ public class FollowFansRecordServiceImpl implements FollowFansRecordService {
Map
<
String
,
Object
>
map
=
new
HashMap
<>();
map
.
put
(
"recordId"
,
id
);
String
fansName
=
cacheUtil
.
appletUserInfoCache
.
get
(
dto
.
getFansId
()).
get
().
getNickname
();
//发送消息通知对应的分销商有用户出价
String
openId
=
sendMsgService
.
getOpenIdByUserId
(
dto
.
getFollowerId
());
if
(
com
.
xxdxxs
.
utils
.
StringUtils
.
hasLength
(
openId
))
{
FollowFansMsg
followFansMsg
=
new
FollowFansMsg
();
followFansMsg
.
setFansName
(
fansName
+
"关注了你"
);
followFansMsg
.
setOpenId
(
openId
);
followFansMsg
.
setContent
(
"由"
+
cacheUtil
.
appletUserInfoCache
.
get
(
dto
.
getIntroducerId
()).
get
().
getNickname
()
+
"介绍"
);
Result
result
=
sendMsgService
.
followNoticeMsg
(
followFansMsg
);
if
(!
result
.
getSuccess
())
{
String
url
=
wxAppletApi
.
getUrlLink
(
TEMPLET_URL
,
"tabType=1"
);
String
msg
=
"您新增了一个粉丝"
+
fansName
+
", 请前往"
+
url
+
"查看"
;
aliSmsSender
.
sendSms
(
dto
.
getFollowerId
(),
msg
);
}
}
else
{
String
url
=
wxAppletApi
.
getUrlLink
(
TEMPLET_URL
,
"tabType=1"
);
String
msg
=
"您新增了一个粉丝"
+
fansName
+
", 请前往"
+
url
+
"查看"
;
aliSmsSender
.
sendSms
(
dto
.
getFollowerId
(),
msg
);
}
/* String messageKey = StringUtil.formatMessageKey(dto.getFansId(), MessageEnum.TypeEnum.FOLLOW.getCode(), dto.getFollowerId());
if (redisUtils.hasKey(messageKey)) {
return Result.success(map);
...
...
ch-wx-api/src/main/java/com/wwdz/ch/wx/impl/distribution/AuctionRecordServiceImpl.java
View file @
7511f116
...
...
@@ -13,8 +13,6 @@ import com.wwdz.ch.core.util.PriceUtil;
import
com.wwdz.ch.db.dao.OfficialAccountSubscribeRecordDao
;
import
com.wwdz.ch.db.dao.UserDao
;
import
com.wwdz.ch.db.dao.distribution.*
;
import
com.wwdz.ch.db.domain.OfficialAccountSubscribeRecord
;
import
com.wwdz.ch.db.domain.User
;
import
com.wwdz.ch.db.domain.distribution.*
;
import
com.wwdz.ch.db.dto.request.distribution.AuctionRecordRequestDto
;
import
com.wwdz.ch.wx.api.WxAppletApi
;
...
...
@@ -30,6 +28,7 @@ import org.redisson.api.RedissonClient;
import
org.slf4j.Logger
;
import
org.slf4j.LoggerFactory
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.beans.factory.annotation.Value
;
import
org.springframework.stereotype.Service
;
import
org.springframework.transaction.annotation.Transactional
;
import
org.springframework.transaction.interceptor.TransactionAspectSupport
;
...
...
@@ -47,6 +46,9 @@ public class AuctionRecordServiceImpl implements AuctionRecordService {
private
static
final
Logger
logger
=
LoggerFactory
.
getLogger
(
AuctionRecordServiceImpl
.
class
);
@Value
(
"${dts.wx.auction-msg-url}"
)
private
String
AUCTION_MSG_URL
;
@Autowired
AuctionConfigDao
auctionConfigDao
;
...
...
@@ -133,16 +135,16 @@ public class AuctionRecordServiceImpl implements AuctionRecordService {
auctionOfferNoticeMsg
.
setOpenId
(
openId
);
Result
result
=
sendMsgService
.
sendAuctionOfferOutMsg
(
auctionOfferNoticeMsg
);
if
(!
result
.
getSuccess
())
{
String
url
=
wxAppletApi
.
getUrlLink
(
"itemId="
+
itemId
+
"&shareRecordId="
);
String
url
=
wxAppletApi
.
getUrlLink
(
AUCTION_MSG_URL
,
"itemId="
+
itemId
+
"&shareRecordId="
);
String
msg
=
"您出价过的拍品"
+
supplierItem
.
getName
()
+
"的价格被其他人超越了, 当前价是"
+
PriceUtil
.
convertPriceFenToYuan
(
price
)
+
"元,竞拍截止时间是"
+
DateUtils
.
toString
(
endTime
)
+
", 请前往"
+
url
+
"查看"
;
aliSmsSender
.
send
AuctionWithTemplate
(
auctionRecord
.
getUserId
(),
msg
);
aliSmsSender
.
send
Sms
(
auctionRecord
.
getUserId
(),
msg
);
}
}
else
{
String
url
=
wxAppletApi
.
getUrlLink
(
"itemId="
+
itemId
+
"&shareRecordId="
);
String
url
=
wxAppletApi
.
getUrlLink
(
AUCTION_MSG_URL
,
"itemId="
+
itemId
+
"&shareRecordId="
);
String
msg
=
"您出价过的拍品"
+
supplierItem
.
getName
()
+
"的价格被其他人超越了, 当前价是"
+
PriceUtil
.
convertPriceFenToYuan
(
price
)
+
"元,竞拍截止时间是"
+
DateUtils
.
toString
(
endTime
)
+
", 请前往"
+
url
+
"查看"
;
aliSmsSender
.
send
AuctionWithTemplate
(
auctionRecord
.
getUserId
(),
msg
);
aliSmsSender
.
send
Sms
(
auctionRecord
.
getUserId
(),
msg
);
}
}
//插入最新出价记录
...
...
@@ -176,16 +178,16 @@ public class AuctionRecordServiceImpl implements AuctionRecordService {
auctionOfferNoticeMsg
.
setCurrentPrice
(
PriceUtil
.
convertPriceFenToYuan
(
price
));
Result
result
=
sendMsgService
.
offerNoticeToDistributorMsg
(
auctionOfferNoticeMsg
);
if
(!
result
.
getSuccess
())
{
String
url
=
wxAppletApi
.
getUrlLink
(
"itemId="
+
itemId
+
"&shareRecordId="
);
String
url
=
wxAppletApi
.
getUrlLink
(
AUCTION_MSG_URL
,
"itemId="
+
itemId
+
"&shareRecordId="
);
String
msg
=
"您分销的拍品"
+
supplierItem
.
getName
()
+
"有人成出价"
+
PriceUtil
.
convertPriceFenToYuan
(
price
)
+
"元,请前往"
+
url
+
"查看"
;
aliSmsSender
.
send
AuctionWithTemplate
(
distributorShareRecord
.
getDistributorId
(),
msg
);
aliSmsSender
.
send
Sms
(
distributorShareRecord
.
getDistributorId
(),
msg
);
}
}
else
{
String
url
=
wxAppletApi
.
getUrlLink
(
"itemId="
+
itemId
+
"&shareRecordId="
);
String
url
=
wxAppletApi
.
getUrlLink
(
AUCTION_MSG_URL
,
"itemId="
+
itemId
+
"&shareRecordId="
);
String
msg
=
"您分销的拍品"
+
supplierItem
.
getName
()
+
"有人成出价"
+
PriceUtil
.
convertPriceFenToYuan
(
price
)
+
"元,请前往"
+
url
+
"查看"
;
aliSmsSender
.
send
AuctionWithTemplate
(
distributorShareRecord
.
getDistributorId
(),
msg
);
aliSmsSender
.
send
Sms
(
distributorShareRecord
.
getDistributorId
(),
msg
);
}
return
Result
.
success
();
}
else
{
...
...
ch-wx-api/src/main/java/com/wwdz/ch/wx/impl/distribution/DistributionOrderServiceImpl.java
View file @
7511f116
...
...
@@ -16,7 +16,6 @@ import com.wwdz.ch.core.util.*;
import
com.wwdz.ch.db.dao.FollowFansRecordDao
;
import
com.wwdz.ch.db.dao.distribution.*
;
import
com.wwdz.ch.db.domain.FollowFansRecord
;
import
com.wwdz.ch.db.domain.User
;
import
com.wwdz.ch.db.domain.distribution.*
;
import
com.wwdz.ch.db.dto.request.FollowFansRecordRequestDto
;
import
com.wwdz.ch.db.dto.request.distribution.DistributionOrderRequestDto
;
...
...
@@ -36,6 +35,7 @@ import org.redisson.api.RedissonClient;
import
org.slf4j.Logger
;
import
org.slf4j.LoggerFactory
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.beans.factory.annotation.Value
;
import
org.springframework.stereotype.Service
;
import
org.springframework.transaction.annotation.Transactional
;
import
org.springframework.transaction.interceptor.TransactionAspectSupport
;
...
...
@@ -62,6 +62,9 @@ public class DistributionOrderServiceImpl implements DistributionOrderService {
private
static
final
String
CREATE_ORDER_KEY_PRE
=
"AUCTION:CREATE:"
;
@Value
(
"${dts.wx.auction-msg-url}"
)
private
String
AUCTION_MSG_URL
;
@Autowired
DistributionOrderDao
distributionOrderDao
;
...
...
@@ -292,16 +295,16 @@ public class DistributionOrderServiceImpl implements DistributionOrderService {
auctionOfferNoticeMsg
.
setProfit
(
PriceUtil
.
convertDoubleToString
(
Math
.
floor
(
averageProfit
)));
Result
result
=
sendMsgService
.
auctionSuccessForDistributorsMsg
(
auctionOfferNoticeMsg
);
if
(!
result
.
getSuccess
())
{
String
url
=
wxAppletApi
.
getUrlLink
(
"itemId="
+
supplierItem
.
getId
()
+
"&shareRecordId="
);
String
url
=
wxAppletApi
.
getUrlLink
(
AUCTION_MSG_URL
,
"itemId="
+
supplierItem
.
getId
()
+
"&shareRecordId="
);
String
msg
=
"您分销的拍品"
+
supplierItem
.
getName
()
+
"已成拍,成交价是"
+
PriceUtil
.
convertPriceFenToYuan
(
distributionOrder
.
getAmount
())
+
"元,您预计获得利润"
+
PriceUtil
.
convertDoubleToString
(
Math
.
floor
(
averageProfit
))
+
"元。请前往"
+
url
+
"查看"
;
aliSmsSender
.
send
AuctionWithTemplate
(
record
.
getDistributorId
(),
msg
);
aliSmsSender
.
send
Sms
(
record
.
getDistributorId
(),
msg
);
}
}
else
{
String
url
=
wxAppletApi
.
getUrlLink
(
"itemId="
+
supplierItem
.
getId
()
+
"&shareRecordId="
);
String
url
=
wxAppletApi
.
getUrlLink
(
AUCTION_MSG_URL
,
"itemId="
+
supplierItem
.
getId
()
+
"&shareRecordId="
);
String
msg
=
"您分销的拍品"
+
supplierItem
.
getName
()
+
"已成拍,成交价是"
+
PriceUtil
.
convertPriceFenToYuan
(
distributionOrder
.
getAmount
())
+
"元,您预计获得利润"
+
PriceUtil
.
convertDoubleToString
(
Math
.
floor
(
averageProfit
))
+
"元。请前往"
+
url
+
"查看"
;
aliSmsSender
.
send
AuctionWithTemplate
(
record
.
getDistributorId
(),
msg
);
aliSmsSender
.
send
Sms
(
record
.
getDistributorId
(),
msg
);
}
}
//把该拍卖配置信息改为已处理
...
...
@@ -320,16 +323,16 @@ public class DistributionOrderServiceImpl implements DistributionOrderService {
auctionOfferNoticeMsg
.
setPayEndTime
(
payEndTime
);
Result
result
=
sendMsgService
.
auctionSuccessMsg
(
auctionOfferNoticeMsg
);
if
(!
result
.
getSuccess
())
{
String
url
=
wxAppletApi
.
getUrlLink
(
"itemId="
+
supplierItem
.
getId
()
+
"&shareRecordId="
);
String
url
=
wxAppletApi
.
getUrlLink
(
AUCTION_MSG_URL
,
"itemId="
+
supplierItem
.
getId
()
+
"&shareRecordId="
);
String
msg
=
"您已中拍"
+
supplierItem
.
getName
()
+
",成交价是"
+
PriceUtil
.
convertPriceFenToYuan
(
distributionOrder
.
getAmount
())
+
"元,请在"
+
DateUtils
.
toString
(
payEndTime
)
+
"前完成付款,请前往"
+
url
+
"查看"
;
aliSmsSender
.
send
AuctionWithTemplate
(
auctionRecord
.
getUserId
(),
msg
);
aliSmsSender
.
send
Sms
(
auctionRecord
.
getUserId
(),
msg
);
}
}
else
{
String
url
=
wxAppletApi
.
getUrlLink
(
"itemId="
+
supplierItem
.
getId
()
+
"&shareRecordId="
);
String
url
=
wxAppletApi
.
getUrlLink
(
AUCTION_MSG_URL
,
"itemId="
+
supplierItem
.
getId
()
+
"&shareRecordId="
);
String
msg
=
"您已中拍"
+
supplierItem
.
getName
()
+
",成交价是"
+
PriceUtil
.
convertPriceFenToYuan
(
distributionOrder
.
getAmount
())
+
"元,请在"
+
DateUtils
.
toString
(
payEndTime
)
+
"前完成付款,请前往"
+
url
+
"查看"
;
aliSmsSender
.
send
AuctionWithTemplate
(
auctionRecord
.
getUserId
(),
msg
);
aliSmsSender
.
send
Sms
(
auctionRecord
.
getUserId
(),
msg
);
}
//给中拍用户对应分销商发消息
String
lastOpenId
=
sendMsgService
.
getOpenIdByUserId
(
distributionOrder
.
getSellerId
());
...
...
@@ -344,16 +347,16 @@ public class DistributionOrderServiceImpl implements DistributionOrderService {
auctionOfferNoticeMsg
.
setProfit
(
PriceUtil
.
convertDoubleToString
(
Math
.
floor
(
profit
)));
Result
result
=
sendMsgService
.
auctionSuccessForDistributorsMsg
(
auctionOfferNoticeMsg
);
if
(!
result
.
getSuccess
())
{
String
url
=
wxAppletApi
.
getUrlLink
(
"itemId="
+
supplierItem
.
getId
()
+
"&shareRecordId="
);
String
url
=
wxAppletApi
.
getUrlLink
(
AUCTION_MSG_URL
,
"itemId="
+
supplierItem
.
getId
()
+
"&shareRecordId="
);
String
msg
=
"您分销的拍品"
+
supplierItem
.
getName
()
+
"已成拍,成交价是"
+
PriceUtil
.
convertPriceFenToYuan
(
distributionOrder
.
getAmount
())
+
"元,您预计获得利润"
+
PriceUtil
.
convertDoubleToString
(
Math
.
floor
(
profit
))
+
"元。请前往"
+
url
+
"查看"
;
aliSmsSender
.
send
AuctionWithTemplate
(
distributionOrder
.
getSellerId
(),
msg
);
aliSmsSender
.
send
Sms
(
distributionOrder
.
getSellerId
(),
msg
);
}
}
else
{
String
url
=
wxAppletApi
.
getUrlLink
(
"itemId="
+
supplierItem
.
getId
()
+
"&shareRecordId="
);
String
url
=
wxAppletApi
.
getUrlLink
(
AUCTION_MSG_URL
,
"itemId="
+
supplierItem
.
getId
()
+
"&shareRecordId="
);
String
msg
=
"您分销的拍品"
+
supplierItem
.
getName
()
+
"已成拍,成交价是"
+
PriceUtil
.
convertPriceFenToYuan
(
distributionOrder
.
getAmount
())
+
"元,您预计获得利润"
+
PriceUtil
.
convertDoubleToString
(
Math
.
floor
(
profit
))
+
"元。请前往"
+
url
+
"查看"
;
aliSmsSender
.
send
AuctionWithTemplate
(
distributionOrder
.
getSellerId
(),
msg
);
aliSmsSender
.
send
Sms
(
distributionOrder
.
getSellerId
(),
msg
);
}
return
Result
.
success
(
map
);
...
...
ch-wx-api/src/main/java/com/wwdz/ch/wx/impl/distribution/SendMsgServiceImpl.java
View file @
7511f116
...
...
@@ -8,10 +8,7 @@ import com.wwdz.ch.db.dao.OfficialAccountSubscribeRecordDao;
import
com.wwdz.ch.db.dao.UserDao
;
import
com.wwdz.ch.db.domain.OfficialAccountSubscribeRecord
;
import
com.wwdz.ch.db.domain.User
;
import
com.wwdz.ch.wx.entity.AuctionOfferNoticeMsg
;
import
com.wwdz.ch.wx.entity.DeliveryNoticeMsg
;
import
com.wwdz.ch.wx.entity.PayNoticeMsg
;
import
com.wwdz.ch.wx.entity.SignedNoticeMsg
;
import
com.wwdz.ch.wx.entity.*
;
import
com.wwdz.ch.wx.service.distribution.SendMsgService
;
import
com.xxdxxs.utils.DateUtils
;
import
com.xxdxxs.utils.JsonUtils
;
...
...
@@ -662,4 +659,48 @@ public class SendMsgServiceImpl implements SendMsgService {
logger
.
info
(
"============= 发送竞拍开始通知成功 ==========="
);
return
true
;
}
@Override
public
Result
followNoticeMsg
(
FollowFansMsg
followFansMsg
)
{
try
{
String
openId
=
followFansMsg
.
getOpenId
();
String
token
=
officialAccountApi
.
getAccessToken
();
String
url
=
SEND_MSG_URL
+
"?access_token="
+
token
;
OkHttpUtil
okHttpUtil
=
OkHttpUtil
.
builder
().
url
(
url
);
Map
<
String
,
Object
>
map
=
new
HashMap
<>();
map
.
put
(
"touser"
,
openId
);
map
.
put
(
"template_id"
,
"WW7Um5y1xuvtKF9DnBufHWuqBMnDT1FoRhjC_L2Z8V8"
);
Map
<
String
,
Object
>
miniprogramMap
=
new
HashMap
<>();
miniprogramMap
.
put
(
"appid"
,
APPLET_APPID
);
StringBuffer
stringBuffer
=
new
StringBuffer
(
"/pages/followAndFansList/index"
);
stringBuffer
.
append
(
"?tabType=1"
);
miniprogramMap
.
put
(
"pagepath"
,
stringBuffer
.
toString
());
map
.
put
(
"miniprogram"
,
miniprogramMap
);
Map
<
String
,
Object
>
paramMap
=
new
LinkedHashMap
<>();
paramMap
.
put
(
"thing2"
,
new
HashMap
()
{{
put
(
"value"
,
followFansMsg
.
getFansName
());
}});
paramMap
.
put
(
"thing1"
,
new
HashMap
()
{{
put
(
"value"
,
followFansMsg
.
getContent
());
}});
map
.
put
(
"data"
,
paramMap
);
logger
.
info
(
"============ 发送关注通知模板消息内容 : {}"
,
JsonUtils
.
fromMap
(
map
));
okHttpUtil
.
addParams
(
map
);
okHttpUtil
.
post
(
true
);
String
responseStr
=
okHttpUtil
.
async
();
logger
.
info
(
"openid : {}, 发送关注通知模板消息 response :{}"
,
openId
,
responseStr
);
String
errorCode
=
JsonUtils
.
getValueByPath
(
responseStr
,
"errcode"
);
String
errmsg
=
JsonUtils
.
getValueByPath
(
responseStr
,
"errmsg"
);
if
(!
"0"
.
equals
(
errorCode
))
{
logger
.
error
(
"openid : {}, 发送关注通知模板消息, errorCode : {}, errmsg : {} "
,
openId
,
errorCode
,
errmsg
);
return
Result
.
failed
();
}
logger
.
info
(
"=============发送关注通知模板消息 成功 ==========="
);
return
Result
.
success
();
}
catch
(
Exception
e
)
{
logger
.
error
(
"发送竞拍成功模板消息 error :{}"
,
e
);
}
return
Result
.
failed
();
}
}
ch-wx-api/src/main/java/com/wwdz/ch/wx/job/AutoSendMsgJob.java
View file @
7511f116
...
...
@@ -13,18 +13,17 @@ import com.wwdz.ch.db.domain.distribution.AuctionConfig;
import
com.wwdz.ch.db.domain.distribution.AuctionRecord
;
import
com.wwdz.ch.db.domain.distribution.DistributionOrder
;
import
com.wwdz.ch.db.domain.distribution.SupplierItem
;
import
com.wwdz.ch.db.dto.request.distribution.DistributionOrderRequestDto
;
import
com.wwdz.ch.wx.api.WxAppletApi
;
import
com.wwdz.ch.wx.entity.AuctionOfferNoticeMsg
;
import
com.wwdz.ch.wx.service.distribution.DistributionOrderService
;
import
com.wwdz.ch.wx.service.distribution.SendMsgService
;
import
com.xxdxxs.utils.DateUtils
;
import
com.xxdxxs.utils.StringUtils
;
import
org.redisson.api.RLock
;
import
org.redisson.api.RedissonClient
;
import
org.slf4j.Logger
;
import
org.slf4j.LoggerFactory
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.beans.factory.annotation.Value
;
import
org.springframework.scheduling.annotation.Scheduled
;
import
org.springframework.stereotype.Component
;
import
org.springframework.util.CollectionUtils
;
...
...
@@ -85,6 +84,9 @@ public class AutoSendMsgJob {
@Autowired
WxAppletApi
wxAppletApi
;
@Value
(
"${dts.wx.auction-msg-url}"
)
private
String
AUCTION_MSG_URL
;
/**
* 隔5分钟运行一次
*/
...
...
@@ -134,9 +136,9 @@ public class AutoSendMsgJob {
aliSmsSender.sendAuctionWithTemplate(userId, msg);
logger.info("================商品id:{}, 将在1小时内结束,提醒短信发送成功 ==============", supplierItem.getId());
}*/
String
url
=
wxAppletApi
.
getUrlLink
(
"itemId="
+
itemId
+
"&shareRecordId="
);
String
url
=
wxAppletApi
.
getUrlLink
(
AUCTION_MSG_URL
,
"itemId="
+
itemId
+
"&shareRecordId="
);
String
msg
=
"您出过价的拍品"
+
supplierItem
.
getName
()
+
",将在1小时内结束,请前往"
+
url
+
"查看"
;
aliSmsSender
.
send
AuctionWithTemplate
(
userId
,
msg
);
aliSmsSender
.
send
Sms
(
userId
,
msg
);
logger
.
info
(
"================商品id:{}, 将在1小时内结束,提醒短信发送成功 =============="
,
supplierItem
.
getId
());
redisUtils
.
set
(
abortEndKey
,
itemId
,
3600
);
}
...
...
@@ -199,17 +201,17 @@ public class AutoSendMsgJob {
auctionOfferNoticeMsg
.
setPayEndTime
(
payEndTime
);
Result
result
=
sendMsgService
.
prePayMsg
(
auctionOfferNoticeMsg
);
if
(!
result
.
getSuccess
())
{
String
url
=
wxAppletApi
.
getUrlLink
(
"itemId="
+
supplierItem
.
getId
()
+
"&shareRecordId="
);
String
url
=
wxAppletApi
.
getUrlLink
(
AUCTION_MSG_URL
,
"itemId="
+
supplierItem
.
getId
()
+
"&shareRecordId="
);
//发短信
String
msg
=
"您已中拍"
+
supplierItem
.
getName
()
+
",成交价是"
+
PriceUtil
.
convertPriceFenToYuan
(
distributionOrder
.
getAmount
())
+
"元,请在"
+
DateUtils
.
toString
(
payEndTime
)
+
"前完成付款,请前往"
+
url
+
"查看"
;
aliSmsSender
.
send
AuctionWithTemplate
(
userId
,
msg
);
aliSmsSender
.
send
Sms
(
userId
,
msg
);
}
}
else
{
String
url
=
wxAppletApi
.
getUrlLink
(
"itemId="
+
supplierItem
.
getId
()
+
"&shareRecordId="
);
String
url
=
wxAppletApi
.
getUrlLink
(
AUCTION_MSG_URL
,
"itemId="
+
supplierItem
.
getId
()
+
"&shareRecordId="
);
String
msg
=
"您已中拍"
+
supplierItem
.
getName
()
+
",成交价是"
+
PriceUtil
.
convertPriceFenToYuan
(
distributionOrder
.
getAmount
())
+
"元,请在"
+
DateUtils
.
toString
(
payEndTime
)
+
"前完成付款,请前往"
+
url
+
"查看"
;
aliSmsSender
.
send
AuctionWithTemplate
(
userId
,
msg
);
aliSmsSender
.
send
Sms
(
userId
,
msg
);
logger
.
info
(
"================订单号:{}, 催付款短信通知发送成功 =============="
,
distributionOrder
.
getDistributionOrderId
());
}
redisUtils
.
set
(
key
,
distributionOrder
.
getDistributionOrderId
(),
3600
*
24
);
...
...
ch-wx-api/src/main/java/com/wwdz/ch/wx/service/distribution/SendMsgService.java
View file @
7511f116
...
...
@@ -2,10 +2,7 @@ package com.wwdz.ch.wx.service.distribution;
import
com.wwdz.ch.core.entity.AbstractSubscribeMsg
;
import
com.wwdz.ch.core.type.Result
;
import
com.wwdz.ch.wx.entity.AuctionOfferNoticeMsg
;
import
com.wwdz.ch.wx.entity.DeliveryNoticeMsg
;
import
com.wwdz.ch.wx.entity.PayNoticeMsg
;
import
com.wwdz.ch.wx.entity.SignedNoticeMsg
;
import
com.wwdz.ch.wx.entity.*
;
public
interface
SendMsgService
{
...
...
@@ -74,7 +71,7 @@ public interface SendMsgService {
* 通知被关注者
* @return
*/
Result
followNoticeMsg
();
Result
followNoticeMsg
(
FollowFansMsg
followFansMsg
);
String
getOpenIdByUserId
(
long
userId
);
...
...
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