Authored by caoyan

物权转移

... ... @@ -42,5 +42,9 @@
<groupId>com.yoho.core</groupId>
<artifactId>yoho-core-rabbitmq</artifactId>
</dependency>
<dependency>
<groupId>com.yoho.service.model</groupId>
<artifactId>message-service-model</artifactId>
</dependency>
</dependencies>
</project>
\ No newline at end of file
... ...
package com.yohoufo.product.service;
import com.yoho.core.rest.client.ServiceCaller;
import com.yoho.service.model.msgcenter.sms.McSmsByMobileBO;
import com.yoho.service.model.sms.response.CommonRspBO;
import org.apache.commons.collections.CollectionUtils;
import org.apache.commons.lang3.StringUtils;
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 java.util.List;
/**
* Created by chenchao on 2018/10/19.
*/
@Service
public class SendMessageService {
private static Logger log = LoggerFactory.getLogger(SendMessageService.class);
@Autowired
private ServiceCaller serviceCaller;
@Value("${yoho.message.controller.url}")
private String messageUrl;
public void smsSendByMobile(String content, List<String> mobileList) {
log.info("smsSendByMobile start, content {}, mobileList {}", content, mobileList);
if(StringUtils.isEmpty(content) || CollectionUtils.isEmpty(mobileList)) {
log.warn("smsSendByMobile fail! content is null or mobileList is empty");
return;
}
McSmsByMobileBO[] boArray = new McSmsByMobileBO[mobileList.size()];
for(int i=0; i<mobileList.size(); i++) {
McSmsByMobileBO smsBo = new McSmsByMobileBO();
smsBo.setMobile(mobileList.get(i));
smsBo.setContent(content);
//"smsProviderCode" : "3"
smsBo.setSmsProviderCode("3");
smsBo.setIsNoDisturb(0);//是否免打扰, 1-是 0-否
boArray[i] = smsBo;
}
String url = messageUrl + "/mcSMS/smsSendByMobile";
log.info("sendMessage url is {}", url);
serviceCaller.post("message.sendMessage", url, boArray, CommonRspBO.class, null);
}
}
... ...
... ... @@ -67,6 +67,7 @@ import com.yohoufo.product.response.IdentifyShareInfoResp;
import com.yohoufo.product.response.IdentifyTrackResp;
import com.yohoufo.product.response.ProductIdentifyResp;
import com.yohoufo.product.service.ProductIdentifyService;
import com.yohoufo.product.service.SendMessageService;
@Service
... ... @@ -116,6 +117,9 @@ public class ProductIdentifyServiceImpl implements ProductIdentifyService{
@Autowired
private TransferRecordsHistoryMapper transferRecordsHistoryMapper;
@Autowired
private SendMessageService sendMessageService;
@Resource(name = "yhProducer")
private YhProducer yhProducer;
... ... @@ -339,10 +343,9 @@ public class ProductIdentifyServiceImpl implements ProductIdentifyService{
throw new GatewayException(402, "已经是物权所有人");
}
TransferRecordsHistory history = transferRecordsHistoryMapper.selectByToUid(tagId, nfcUid, uid);
if(null != history && (history.getStatus().equals(OPERATE_TYPE_APPLYING)
|| history.getStatus().equals(OPERATE_TYPE_PASS) || history.getStatus().equals(OPERATE_TYPE_REJECT))) {
throw new GatewayException(402, "当前不可再申请");
TransferRecordsHistory history = transferRecordsHistoryMapper.selectByToUid(tagId, nfcUid, null);
if(null != history && (history.getStatus().equals(OPERATE_TYPE_APPLYING))) {
throw new GatewayException(402, "当前不可申请");
}
//将申请记录插入数据库
... ... @@ -355,6 +358,16 @@ public class ProductIdentifyServiceImpl implements ProductIdentifyService{
insertItem.setStatus(OPERATE_TYPE_APPLYING);
int result = transferRecordsHistoryMapper.insert(insertItem);
//根据鉴定记录 获取订单号
Long orderCode = identifyRecord.getOrderCode();
//获取订单详细信息
BuyerOrder buyerOrder = buyerOrderMapper.selectOnlyByOrderCode(orderCode);
if(buyerOrder == null){
throw new GatewayException(403, "订单不存在");
}
//向物权所有人发短信“用户189******59向您发起商品xxxxxx的物权转移申请,您可以 打开有货APP站内信查看并确认”
sendSmsToOwner(insertItem.getFromUid(), String.valueOf(uid), orderCode);
//向物权所有人发送站内信
//发送定时mq
... ... @@ -409,6 +422,23 @@ public class ProductIdentifyServiceImpl implements ProductIdentifyService{
return identifyRecordsMapper.updateOwner(tagId, nfcUid, toUid);
}
private void sendSmsToOwner(String fromUid, String uid, Long orderCode) {
List<String> uidList = Lists.newArrayList(fromUid, uid);
Map<Integer, ProfileInfoRsp> profileMap = queryIcoAndMobile(uidList);
String fromMobile = profileMap.get(Integer.parseInt(fromUid)).getMobile();
String toMobileMask = MobileHelper.coverMobile2(profileMap.get(Integer.parseInt(uid)).getMobile());
//商品信息
BuyerOrderGoods buyerOrderGoods = buyerOrderGoodsMapper.selectOnlyByOrderCode(orderCode);
Integer skup = buyerOrderGoods.getSkup();
//skup获取 productInfo
SellerOrderGoods sellerOrderGoods = sellerOrderGoodsMapper.selectByPrimaryKey(skup);
StringBuilder content = new StringBuilder();
content.append("用户").append(toMobileMask).append("向您发起商品").append(sellerOrderGoods.getProductName());
content.append("的物权转移申请,您可以打开有货APP站内信查看并确认");
sendMessageService.smsSendByMobile(content.toString(), Lists.newArrayList(fromMobile));
}
private void rebuildResult(ProductIdentifyResp result, String tagId, String nfcUid, Integer uid) {
boolean isOwner = queryIsOwner(tagId, nfcUid, uid);
result.setIfOwner(isOwner);
... ...