Toggle navigation
Toggle navigation
This project
Loading...
Sign in
ufo
/
yohoufo-fore
·
Commits
Go to a project
GitLab
Go to group
Project
Activity
Files
Commits
Pipelines
0
Builds
0
Graphs
Milestones
Issues
0
Merge Requests
0
Members
Labels
Wiki
Forks
Network
Create a new issue
Download as
Plain Diff
Browse Files
Authored by
caoyan
6 years ago
Commit
0b6704caeafc4b684fcf0e90b6b625dc93a0a8fa
2 parents
898a6c97
acda199c
Merge branch 'dev_物权转移' into test6.8.6
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
73 additions
and
7 deletions
common/src/main/java/com/yohoufo/common/cache/CacheEnum.java
dal/src/main/java/com/yohoufo/dal/user/IInBoxAttrDao.java
dal/src/main/resources/META-INF/mybatis/users/InBoxAttrMapper.xml
product/src/main/java/com/yohoufo/product/controller/ProductIdentifyController.java
product/src/main/java/com/yohoufo/product/service/ProductIdentifyService.java
product/src/main/java/com/yohoufo/product/service/impl/ProductIdentifyServiceImpl.java
common/src/main/java/com/yohoufo/common/cache/CacheEnum.java
View file @
0b6704c
...
...
@@ -25,6 +25,20 @@ public enum CacheEnum {
*/
PRODUCT_CATEGORY_SEARCH
(
"yh:ufo:resources:product_category_search"
,
1
*
60
,
"resources.cachetime.product_category_search"
),
/**
* 消息盒子-某类型下未读消息总数,缓存5分钟
*/
USERS_INBOX_TYPE_UNREADCOUNT
(
"yh:users:inbox_type_unreadcount"
,
5
*
60
,
"users.cachetime.inbox_type_unreadcount"
),
/**
* 消息盒子-消息,缓存5分钟
*/
USERS_INBOX_LIST
(
"yh:users:inbox_list"
,
5
*
60
,
"users.cachetime.inbox_list"
),
/**
* 消息盒子-消息总数,缓存5分钟
*/
USERS_INBOX_LIST_TOTAL
(
"yh:users:inbox_list_total"
,
5
*
60
,
"users.cachetime.inbox_list_total"
),
/*
* end
*/
;
...
...
dal/src/main/java/com/yohoufo/dal/user/IInBoxAttrDao.java
View file @
0b6704c
...
...
@@ -14,4 +14,6 @@ public interface IInBoxAttrDao {
void
insert
(
InBoxAttr
inboxAttr
);
List
<
InBoxAttr
>
selectInboxAttrList
(
@Param
(
"uid"
)
Integer
uid
,
@Param
(
"inboxIdList"
)
List
<
Integer
>
inboxIdList
);
int
updateJsonContent
(
@Param
(
"uid"
)
Integer
uid
,
@Param
(
"inboxId"
)
Integer
inboxId
,
@Param
(
"jsonContent"
)
String
jsonContent
);
}
...
...
dal/src/main/resources/META-INF/mybatis/users/InBoxAttrMapper.xml
View file @
0b6704c
...
...
@@ -29,4 +29,9 @@
</foreach>
</if>
</select>
<update
id=
"updateJsonContent"
>
update inbox_attr set json_content=#{jsonContent}
where inbox_id=#{inboxId} and uid=#{uid}
</update>
</mapper>
\ No newline at end of file
...
...
product/src/main/java/com/yohoufo/product/controller/ProductIdentifyController.java
View file @
0b6704c
...
...
@@ -125,9 +125,10 @@ public class ProductIdentifyController {
@RequestParam
(
value
=
"nfcUid"
,
required
=
false
)
String
nfcUid
,
@RequestParam
(
value
=
"from_uid"
,
required
=
true
)
Integer
fromUid
,
@RequestParam
(
value
=
"to_uid"
,
required
=
true
)
Integer
toUid
,
@RequestParam
(
value
=
"status"
,
required
=
true
)
Integer
status
)
throws
GatewayException
{
@RequestParam
(
value
=
"status"
,
required
=
true
)
Integer
status
,
@RequestParam
(
value
=
"inbox_id"
,
required
=
true
)
Integer
inboxId
)
throws
GatewayException
{
try
{
int
result
=
identifyService
.
confirmOwner
(
tagId
,
nfcUid
,
fromUid
,
toUid
,
status
);
int
result
=
identifyService
.
confirmOwner
(
tagId
,
nfcUid
,
fromUid
,
toUid
,
status
,
inboxId
);
return
new
ApiResponse
.
ApiResponseBuilder
().
code
(
200
).
data
(
result
).
build
();
}
catch
(
Exception
e
){
logger
.
warn
(
"confirmTransferOwner error! tagId={}, nfcUid={}, fromUid={}, toUid is{}, e is {}"
,
tagId
,
nfcUid
,
fromUid
,
toUid
,
e
);
...
...
product/src/main/java/com/yohoufo/product/service/ProductIdentifyService.java
View file @
0b6704c
...
...
@@ -17,7 +17,7 @@ public interface ProductIdentifyService {
int
applyToBeOwner
(
String
tagId
,
String
nfcUid
,
Integer
uid
)
throws
GatewayException
;
int
confirmOwner
(
String
tagId
,
String
nfcUid
,
Integer
fromUid
,
Integer
toUid
,
Integer
status
)
throws
GatewayException
;
int
confirmOwner
(
String
tagId
,
String
nfcUid
,
Integer
fromUid
,
Integer
toUid
,
Integer
status
,
Integer
inboxId
)
throws
GatewayException
;
IdentifyRecord
queryIdentifyRecord
(
String
tagId
,
String
nfcUid
);
...
...
product/src/main/java/com/yohoufo/product/service/impl/ProductIdentifyServiceImpl.java
View file @
0b6704c
...
...
@@ -12,6 +12,7 @@ import java.util.stream.Collectors;
import
javax.annotation.Resource
;
import
org.apache.commons.collections.CollectionUtils
;
import
org.apache.commons.collections.MapUtils
;
import
org.apache.commons.lang3.StringUtils
;
import
org.elasticsearch.common.collect.Lists
;
...
...
@@ -21,6 +22,7 @@ import org.springframework.beans.factory.annotation.Autowired;
import
org.springframework.beans.factory.annotation.Value
;
import
org.springframework.stereotype.Service
;
import
com.alibaba.fastjson.JSON
;
import
com.alibaba.fastjson.JSONObject
;
import
com.yoho.core.config.ConfigReader
;
import
com.yoho.core.rabbitmq.YhProducer
;
...
...
@@ -35,8 +37,10 @@ import com.yoho.service.model.uic.request.UserInfoBO;
import
com.yohobuy.ufo.model.order.common.OperateTypeEnum
;
import
com.yohobuy.ufo.model.order.constants.QNliveConstants
;
import
com.yohoufo.common.cache.CacheClient
;
import
com.yohoufo.common.cache.CacheEnum
;
import
com.yohoufo.common.exception.GatewayException
;
import
com.yohoufo.common.helper.ImageUrlAssist
;
import
com.yohoufo.common.redis.NoSyncGracefulRedisTemplate
;
import
com.yohoufo.common.utils.DateUtil
;
import
com.yohoufo.common.utils.MobileHelper
;
import
com.yohoufo.dal.order.BuyerOrderGoodsMapper
;
...
...
@@ -63,6 +67,8 @@ import com.yohoufo.dal.product.model.Product;
import
com.yohoufo.dal.product.model.ProductChain
;
import
com.yohoufo.dal.product.model.TransferRecords
;
import
com.yohoufo.dal.product.model.TransferRecordsHistory
;
import
com.yohoufo.dal.user.IInBoxAttrDao
;
import
com.yohoufo.dal.user.model.InBoxAttr
;
import
com.yohoufo.product.mq.TopicConstants
;
import
com.yohoufo.product.response.IdentifyShareInfoResp
;
import
com.yohoufo.product.response.IdentifyTrackResp
;
...
...
@@ -127,6 +133,9 @@ public class ProductIdentifyServiceImpl implements ProductIdentifyService{
@Autowired
private
ProductMapper
productMapper
;
@Autowired
private
IInBoxAttrDao
inBoxAttrDao
;
@Resource
(
name
=
"yhProducer"
)
private
YhProducer
yhProducer
;
...
...
@@ -136,6 +145,9 @@ public class ProductIdentifyServiceImpl implements ProductIdentifyService{
@Value
(
"${uic.url}"
)
private
String
uicServerIpAndPort
;
@Resource
(
name
=
"NoSyncGracefulRedisTemplate"
)
private
NoSyncGracefulRedisTemplate
redisTemplate
;
@Value
(
"${ufo.nfc.syncBlockChain.url}"
)
private
String
syncBlockChain_url
;
...
...
@@ -389,14 +401,13 @@ public class ProductIdentifyServiceImpl implements ProductIdentifyService{
messageFacade
.
applyToBeOwner
(
insertItem
.
getFromUid
(),
String
.
valueOf
(
uid
),
tagId
,
nfcUid
,
orderCode
);
//发送定时mq
// yhProducer.send(TopicConstants.MQ_TOPIC_CONFIRM_OWNER_DELAY, insertItem, null, 3*24*60);//3天
yhProducer
.
send
(
TopicConstants
.
MQ_TOPIC_CONFIRM_OWNER_DELAY
,
insertItem
,
null
,
5
);
yhProducer
.
send
(
TopicConstants
.
MQ_TOPIC_CONFIRM_OWNER_DELAY
,
insertItem
,
null
,
3
*
24
*
60
);
//3天
return
result
;
}
@Override
public
int
confirmOwner
(
String
tagId
,
String
nfcUid
,
Integer
fromUid
,
Integer
toUid
,
Integer
status
)
throws
GatewayException
{
public
int
confirmOwner
(
String
tagId
,
String
nfcUid
,
Integer
fromUid
,
Integer
toUid
,
Integer
status
,
Integer
inboxId
)
throws
GatewayException
{
if
(
null
==
status
||
!(
status
.
equals
(
OPERATE_TYPE_PASS
)
||
status
.
equals
(
OPERATE_TYPE_REJECT
))){
throw
new
GatewayException
(
402
,
"参数status错误"
);
}
...
...
@@ -425,6 +436,7 @@ public class ProductIdentifyServiceImpl implements ProductIdentifyService{
int
result
=
transferRecordsHistoryMapper
.
insert
(
histroy
);
if
(
status
.
equals
(
OPERATE_TYPE_REJECT
))
{
setFinalTimeToEnd
(
inboxId
,
fromUid
);
//“不同意”则拒绝物权占有,短信通知申请⼈人“您发起商品xxxxxx的物权转 移申请,当前物权所有⼈人拒绝转移申请,您可以重新发起物权申请”
messageFacade
.
ownerReject
(
String
.
valueOf
(
toUid
),
queryIdentifyRecord
(
tagId
,
nfcUid
).
getOrderCode
());
return
result
;
...
...
@@ -441,6 +453,8 @@ public class ProductIdentifyServiceImpl implements ProductIdentifyService{
//更新identify_record
result
=
identifyRecordsMapper
.
updateOwner
(
tagId
,
nfcUid
,
toUid
);
setFinalTimeToEnd
(
inboxId
,
fromUid
);
//区块链
syncBlockChain
(
tagId
,
nfcUid
,
toUid
);
...
...
@@ -450,6 +464,36 @@ public class ProductIdentifyServiceImpl implements ProductIdentifyService{
return
result
;
}
private
void
setFinalTimeToEnd
(
Integer
inboxId
,
Integer
uid
)
{
if
(
null
==
inboxId
)
{
return
;
}
List
<
InBoxAttr
>
attrList
=
inBoxAttrDao
.
selectInboxAttrList
(
uid
,
Lists
.
newArrayList
(
inboxId
));
if
(
CollectionUtils
.
isEmpty
(
attrList
))
{
return
;
}
InBoxAttr
attr
=
attrList
.
get
(
0
);
String
jsonContent
=
attr
.
getJsonContent
();
JSONObject
jo
=
JSON
.
parseObject
(
jsonContent
);
jo
.
replace
(
"finalTime"
,
0
);
inBoxAttrDao
.
updateJsonContent
(
uid
,
inboxId
,
jo
.
toJSONString
());
//清缓存
deleteIboxsByRedis
(
uid
,
2
);
}
private
void
deleteIboxsByRedis
(
int
uid
,
int
type
){
logger
.
info
(
"deleteIboxsByRedis params uid is {} type is {}"
,
uid
,
type
);
RedisKeyBuilder
inboxKey
=
CacheEnum
.
USERS_INBOX_LIST
.
generateKey
(
uid
);
redisTemplate
.
delete
(
inboxKey
);
RedisKeyBuilder
key
=
CacheEnum
.
USERS_INBOX_TYPE_UNREADCOUNT
.
generateKey
(
uid
,
type
);
redisTemplate
.
delete
(
key
);
RedisKeyBuilder
inboxTotalKey
=
CacheEnum
.
USERS_INBOX_LIST_TOTAL
.
generateKey
(
uid
,
"N"
);
redisTemplate
.
delete
(
inboxTotalKey
);
RedisKeyBuilder
inboxTypeTotalKey
=
CacheEnum
.
USERS_INBOX_LIST_TOTAL
.
generateKey
(
uid
,
type
);
redisTemplate
.
delete
(
inboxTypeTotalKey
);
}
private
void
syncBlockChain
(
String
tagId
,
String
nfcUid
,
Integer
toUid
){
IdentifyRecord
record
=
queryIdentifyRecord
(
tagId
,
nfcUid
);
//商品信息
...
...
@@ -475,7 +519,7 @@ public class ProductIdentifyServiceImpl implements ProductIdentifyService{
//根据uid去uic获取用户手机号,并进行模糊处理。吃掉异常,防止超时影响正常逻辑
try
{
Map
<
String
,
Integer
>
request
=
Collections
.
singletonMap
(
"uid"
,
toUid
);
JSONObject
jsonObject
=
serviceCaller
.
get
(
"uic.getProfileAction"
,
"http://"
+
uicServerIpAndPort
+
UIC_PROFILE_URL
,
request
,
JSONObject
.
class
,
null
).
get
(
1
);
JSONObject
jsonObject
=
serviceCaller
.
get
(
"uic.getProfileAction"
,
uicServerIpAndPort
+
UIC_PROFILE_URL
,
request
,
JSONObject
.
class
,
null
).
get
(
1
);
if
(
null
!=
jsonObject
.
getJSONObject
(
"data"
)
&&
null
!=
jsonObject
.
getJSONObject
(
"data"
).
getString
(
"mobile_phone"
))
{
String
mobile
=
jsonObject
.
getJSONObject
(
"data"
).
getString
(
"mobile_phone"
);;
...
...
Please
register
or
login
to post a comment