Commit 0a94f7d1 by xieshixiang

Merge remote-tracking branch 'origin/dev' into dev

# Conflicts:
#	domain/src/main/java/com/hikcreate/edl/pub/web/mobile/domain/impl/BindServiceImpl.java
parents cac4c594 d1a62fc8
......@@ -68,7 +68,7 @@ public class BindInfoControlller extends BaseController {
@PostMapping("unbind")
@BodyDecryptAnnotation
public Response unbindInfo(@RequestBody @Validated UnBindReq req) {
return service.unbindInfo(req) ? ResponseGenerator.success() : ResponseGenerator.fail("解绑失败");
return service.unbindInfo(req) ;
}
/**
......
......@@ -35,7 +35,7 @@ public interface IBindService extends IService<ParkBindInfo> {
* @param req
* @return
*/
boolean unbindInfo( UnBindReq req );
Response unbindInfo( UnBindReq req );
/**
* 查询用户绑定信息
......
......@@ -37,7 +37,10 @@ import com.hikcreate.edl.pub.web.mobile.infra.model.param.response.ViolationInfo
import com.hikcreate.edl.pub.web.mobile.infra.model.param.response.YearCheckInfoRes;
import lombok.extern.slf4j.Slf4j;
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;
import javax.annotation.Resource;
import java.util.ArrayList;
......@@ -70,6 +73,13 @@ public class BindServiceImpl extends ServiceImpl<BindInfoMapper, ParkBindInfo> i
@Autowired
UnqIdUtil unqIdUtil;
/**
* 解除绑定时间限制
* 单位:小时
*/
@Value("${biz.unbind.time:-720}")
Integer unBindTime;
@Override
public Response bind(ParkBindInfo info) {
......@@ -144,22 +154,25 @@ public class BindServiceImpl extends ServiceImpl<BindInfoMapper, ParkBindInfo> i
* @return
*/
@Override
public boolean unbindInfo(UnBindReq req) {
@Transactional(rollbackFor = Exception.class)
public Response unbindInfo(UnBindReq req) {
/**
* 解绑规则:30天内,同一客户解绑次数总计不能超过10次
*/
QueryWrapper<ParkBindInfo> queryWrapper = new QueryWrapper<>();
queryWrapper.eq("user_id", req.getUnqId());
queryWrapper.lt("unbind_time", DateUtil.offsetDay(new Date(), -30));
queryWrapper.eq("user_id", req.getUserId());
queryWrapper.ge("unbind_time", DateUtil.offsetHour(new Date(), unBindTime));
queryWrapper.eq("status", "0");
Integer integer = mapper.selectCount(queryWrapper);
if (integer >= 10) {
return false;
return ResponseGenerator.fail(StatusCode.BUSINESS_ERROR, "同一用户30天内只能解绑10次");
}
return bindCache.unBind(req.getUnqId(), req.getUserId());
if( !bindCache.unBind(req.getUnqId(), req.getUserId()) ) {
//手动回滚
TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
return ResponseGenerator.fail(StatusCode.SYSTEM_ERROR, "解绑失败");
}
return ResponseGenerator.success();
}
/**
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment