Authored by caoyan

物权转移

package com.yohoufo.dal.product;
import org.apache.ibatis.annotations.Param;
import com.yohoufo.dal.product.model.TransferRecordsHistory;
/**
*/
public interface TransferRecordsHistoryMapper {
int insert(TransferRecordsHistory transferRecordsHistory);
TransferRecordsHistory selectByToUid(@Param("tagId") String tagId, @Param("nfcUid") String nfcUid, @Param("toUid") Integer toUid);
}
... ...
package com.yohoufo.dal.product.model;
import com.alibaba.fastjson.JSONObject;
public class TransferRecordsHistory {
private Integer id;
private String tagId;
private String nfcUid;
private Integer operateTime;
private String fromUid;
private String toUid;
private Integer status;
public Integer getId() {
return id;
}
public void setId(Integer id) {
this.id = id;
}
public String getTagId() {
return tagId;
}
public void setTagId(String tagId) {
this.tagId = tagId;
}
public String getNfcUid() {
return nfcUid;
}
public void setNfcUid(String nfcUid) {
this.nfcUid = nfcUid;
}
public String getFromUid() {
return fromUid;
}
public void setFromUid(String fromUid) {
this.fromUid = fromUid;
}
public String getToUid() {
return toUid;
}
public void setToUid(String toUid) {
this.toUid = toUid;
}
public Integer getOperateTime() {
return operateTime;
}
public void setOperateTime(Integer operateTime) {
this.operateTime = operateTime;
}
public Integer getStatus() {
return status;
}
public void setStatus(Integer status) {
this.status = status;
}
@Override
public String toString() {
return JSONObject.toJSONString(this);
}
}
\ No newline at end of file
... ...
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd" >
<mapper namespace="com.yohoufo.dal.product.TransferRecordsHistoryMapper">
<resultMap id="BaseResultMap" type="com.yohoufo.dal.product.model.TransferRecordsHistory">
<result column="id" property="id" jdbcType="INTEGER" />
<result column="tag_id" property="tagId" jdbcType="VARCHAR" />
<result column="nfc_uid" property="nfcUid" jdbcType="VARCHAR" />
<result column="from_uid" property="fromUid" jdbcType="VARCHAR" />
<result column="to_uid" property="toUid" jdbcType="VARCHAR" />
<result column="operate_time" property="operateTime" jdbcType="INTEGER" />
<result column="status" property="status" jdbcType="INTEGER" />
</resultMap>
<sql id="Base_Column_List">
id,tag_id,nfc_uid,from_uid,to_uid,operate_time, status
</sql>
<insert id="insert" parameterType="com.yohoufo.dal.product.model.TransferRecordsHistory">
insert into transfer_records_history (tag_id, nfc_uid, from_uid, to_uid, operate_time, status)
values (#{tagId}, #{nfcUid}, #{fromUid}, #{toUid}, #{operateTime}, #{status})
</insert>
<select id="selectByToUid" resultMap="BaseResultMap">
select <include refid="Base_Column_List"></include>
from transfer_records_history
where tag_id=#{tagId}
<if test="nfcUid != null and nfcUid != '' ">
and nfc_uid=#{nfcUid}
</if>
<if test="toUid != null and toUid != 0">
and to_uid=#{toUid}
</if>
order by operate_time desc
limit 1
</select>
</mapper>
\ No newline at end of file
... ...
... ... @@ -85,4 +85,53 @@ public class ProductIdentifyController {
return new ApiResponse.ApiResponseBuilder().code(402).message("查询失败,请稍后重试").build();
}
}
@ApiOperation(name = "ufo.product.applyToBeOwner", desc="申请成为物权所有人")
@ApiParam(name="tagId",required = true,desc="NFC标签id",type=Integer.class)
@ApiParam(name="nfcUid",required = false,desc="NFC芯片id",type=Integer.class)
@ApiParam(name="uid",required = true,desc="有货uid",type=Integer.class)
@ApiResp(dataClazz=ProductIdentifyResp.class, desc="申请成为物权所有人")
@ApiRespCode(code=200,desc="操作成功")
@ApiRespCode(code=402,desc="操作失败")
@IgnoreSignature
@RequestMapping(params = "method=ufo.product.applyToBeOwner")
public ApiResponse applyToBeOwner(@RequestParam(value = "tagId", required = true) String tagId,
@RequestParam(value = "nfcUid",required = false) String nfcUid,
@RequestParam(value = "uid", required = true) Integer uid) throws GatewayException {
try{
int result = identifyService.applyToBeOwner(tagId, nfcUid, uid);
return new ApiResponse.ApiResponseBuilder().code(200).data(result).build();
}catch (Exception e){
logger.warn("applyToBeOwner error! tagId={}, nfcUid={}, uid={}, e is {}", tagId, nfcUid, uid, e);
if( e instanceof GatewayException){
throw e;
}
return new ApiResponse.ApiResponseBuilder().code(402).message("申请失败,请稍后重试").build();
}
}
// @ApiOperation(name = "ufo.product.confirmTransferOwner", desc="确认物权转移")
// @ApiParam(name="tagId",required = true,desc="NFC标签id",type=Integer.class)
// @ApiParam(name="nfcUid",required = false,desc="NFC芯片id",type=Integer.class)
// @ApiParam(name="uid",required = true,desc="有货uid",type=Integer.class)
// @ApiResp(dataClazz=ProductIdentifyResp.class, desc="申请成为物权所有人")
// @ApiRespCode(code=200,desc="操作成功")
// @ApiRespCode(code=402,desc="操作失败")
// @IgnoreSignature
// @RequestMapping(params = "method=ufo.product.confirmTransferOwner")
// public ApiResponse confirmTransferOwner(@RequestParam(value = "tagId", required = true) String tagId,
// @RequestParam(value = "nfcUid",required = false) String nfcUid,
// @RequestParam(value = "from_uid", required = true) Integer fromUid,
// @RequestParam(value = "to_uid", required = true) Integer toUid) throws GatewayException {
// try{
// int result = identifyService.applyToBeOwner(tagId, nfcUid, uid);
// return new ApiResponse.ApiResponseBuilder().code(200).data(result).build();
// }catch (Exception e){
// logger.warn("applyToBeOwner error! tagId={}, nfcUid={}, uid={}, e is {}", tagId, nfcUid, uid, e);
// if( e instanceof GatewayException){
// throw e;
// }
// return new ApiResponse.ApiResponseBuilder().code(402).message("申请失败,请稍后重试").build();
// }
// }
}
\ No newline at end of file
... ...
... ... @@ -8,11 +8,12 @@ import com.yohoufo.product.response.ProductIdentifyResp;
public interface ProductIdentifyService {
ProductIdentifyResp queryIdentifyInfo(String tagId, String nfcUid) throws GatewayException;
IdentifyShareInfoResp getShareIdentifyInfo( String tagId, String nfcUid) throws GatewayException;
ProductIdentifyResp queryNewIdentifyInfo(String tagId, String nfcUid, Integer uid) throws GatewayException;
int applyToBeOwner(String tagId, String nfcUid, Integer uid) throws GatewayException;
}
... ...
... ... @@ -35,6 +35,7 @@ import com.yohobuy.ufo.model.order.constants.QNliveConstants;
import com.yohoufo.common.cache.CacheClient;
import com.yohoufo.common.exception.GatewayException;
import com.yohoufo.common.helper.ImageUrlAssist;
import com.yohoufo.common.utils.DateUtil;
import com.yohoufo.common.utils.MobileHelper;
import com.yohoufo.dal.order.BuyerOrderGoodsMapper;
import com.yohoufo.dal.order.BuyerOrderMapper;
... ... @@ -51,11 +52,13 @@ import com.yohoufo.dal.order.model.SellerOrderGoods;
import com.yohoufo.dal.product.IdentifyRecordsMapper;
import com.yohoufo.dal.product.IdentifyRelationMapper;
import com.yohoufo.dal.product.ProductChainMapper;
import com.yohoufo.dal.product.TransferRecordsHistoryMapper;
import com.yohoufo.dal.product.TransferRecordsMapper;
import com.yohoufo.dal.product.model.IdentifyRecord;
import com.yohoufo.dal.product.model.IdentifyRelation;
import com.yohoufo.dal.product.model.ProductChain;
import com.yohoufo.dal.product.model.TransferRecords;
import com.yohoufo.dal.product.model.TransferRecordsHistory;
import com.yohoufo.product.response.IdentifyShareInfoResp;
import com.yohoufo.product.response.IdentifyTrackResp;
import com.yohoufo.product.response.ProductIdentifyResp;
... ... @@ -105,12 +108,23 @@ public class ProductIdentifyServiceImpl implements ProductIdentifyService{
@Autowired
private OrderOperateRecordMapper orderOperateRecordMapper;
@Autowired
private TransferRecordsHistoryMapper transferRecordsHistoryMapper;
@Value("${uic.url:http://uic.yohoops.org/uic}")
private String uicUrl;
public static final String DEFAULT_HEAD_IMG = "http://img11.static.yhbimg.com/yhb-img01/2016/07/05/13/017ec560b82c132ab2fdb22f7cf6f42b83.png?imageView/{mode}/w/{width}/h/{height}";
public static final Integer OPERATE_TYPE_APPLYING = 0;//申请中
public static final Integer OPERATE_TYPE_PASS = 1;//同意
public static final Integer OPERATE_TYPE_REJECT = 2;//拒绝
public static final Integer OPERATE_TYPE_TIMEOUT = 3;//确认超时
/**
* 鉴定结果查询接口
* @param tagId
... ... @@ -293,6 +307,37 @@ public class ProductIdentifyServiceImpl implements ProductIdentifyService{
return result;
}
@Override
public int applyToBeOwner(String tagId, String nfcUid, Integer uid) throws GatewayException {
IdentifyRecord identifyRecord = queryIdentifyRecord(tagId, nfcUid);
if(identifyRecord == null){
throw new GatewayException(402, "鉴定信息不存在");
}
if(identifyRecord.getOwner() == uid.intValue()) {
throw new GatewayException(402, "已经是物权所有人");
}
TransferRecordsHistory history = transferRecordsHistoryMapper.selectByToUid(tagId, nfcUid, uid);
if(null != history) {
throw new GatewayException(402, "已经在申请中");
}
//将申请记录插入数据库
TransferRecordsHistory insertItem = new TransferRecordsHistory();
insertItem.setTagId(tagId);
insertItem.setNfcUid(nfcUid);
insertItem.setFromUid(String.valueOf(identifyRecord.getOwner()));
insertItem.setToUid(String.valueOf(uid));
insertItem.setOperateTime(DateUtil.getCurrentTimeSecond());
insertItem.setStatus(OPERATE_TYPE_APPLYING);
int result = transferRecordsHistoryMapper.insert(insertItem);
//向物权所有人发送站内信
return result;
}
private void rebuildResult(ProductIdentifyResp result, String tagId, String nfcUid, Integer uid) {
boolean isOwner = queryIsOwner(tagId, nfcUid, uid);
result.setOwner(isOwner);
... ...
... ... @@ -36,6 +36,7 @@ datasources:
- com.yohoufo.dal.product.PriceTrendHalfYearMapper
- com.yohoufo.dal.product.PriceTrendDayMapper
- com.yohoufo.dal.product.TransferRecordsMapper
- com.yohoufo.dal.product.TransferRecordsHistoryMapper
ufo_order:
servers:
... ...
... ... @@ -36,6 +36,7 @@ datasources:
- com.yohoufo.dal.product.PriceTrendHalfYearMapper
- com.yohoufo.dal.product.PriceTrendDayMapper
- com.yohoufo.dal.product.TransferRecordsMapper
- com.yohoufo.dal.product.TransferRecordsHistoryMapper
ufo_order:
servers:
... ...