Commit 1e773134 authored by shiyu's avatar shiyu

扣除和释放保证金,按照记录状态修改,防止多次出价记录被一起修改

parent 0532fa31
...@@ -23,6 +23,15 @@ public interface EarnestRecordDao { ...@@ -23,6 +23,15 @@ public interface EarnestRecordDao {
*/ */
boolean update(EarnestRecord earnestRecord); boolean update(EarnestRecord earnestRecord);
/**
* 释放或扣除保证金
*
* @param dto
* @return
*/
boolean updateState(EarnestRecordRequestDto dto);
/** /**
* 查询保证金明细 * 查询保证金明细
* @param dto * @param dto
......
...@@ -66,4 +66,10 @@ public class EarnestRecordRequestDto extends BaseRequestDto implements Entity { ...@@ -66,4 +66,10 @@ public class EarnestRecordRequestDto extends BaseRequestDto implements Entity {
* 状态 * 状态
*/ */
private Integer state; private Integer state;
/**
* 要查询的状态
* 用于扣除保证金,指定状态的记录修改
*/
private Integer searchState;
} }
...@@ -32,6 +32,20 @@ public class EarnestRecordDaoImpl implements EarnestRecordDao { ...@@ -32,6 +32,20 @@ public class EarnestRecordDaoImpl implements EarnestRecordDao {
return earnestRecordMapper.updateByExampleSelective(earnestRecord, example) > 0; return earnestRecordMapper.updateByExampleSelective(earnestRecord, example) > 0;
} }
@Override
public boolean updateState(EarnestRecordRequestDto dto) {
EarnestRecordExample example = new EarnestRecordExample();
EarnestRecordExample.Criteria criteria = example.createCriteria();
criteria.andUserIdEqualTo(dto.getUserId());
criteria.andItemIdEqualTo(dto.getItemId());
criteria.andTypeEqualTo(dto.getType());
criteria.andStateEqualTo(dto.getSearchState());
EarnestRecord earnestRecord = new EarnestRecord();
earnestRecord.setState(dto.getState());
return earnestRecordMapper.updateByExampleSelective(earnestRecord, example) > 0;
}
@Override @Override
public List<EarnestRecord> findList(EarnestRecordRequestDto dto) { public List<EarnestRecord> findList(EarnestRecordRequestDto dto) {
EarnestRecordExample example = new EarnestRecordExample(); EarnestRecordExample example = new EarnestRecordExample();
......
...@@ -206,12 +206,13 @@ public class AuctionEarnestServiceImpl implements AuctionEarnestService { ...@@ -206,12 +206,13 @@ public class AuctionEarnestServiceImpl implements AuctionEarnestService {
long occupyAmount = earnestAmount.longValue(); long occupyAmount = earnestAmount.longValue();
//把上一次的占用记录状态更改为已释放 //把上一次的占用记录状态更改为已释放
EarnestRecord newEarnestRecord = new EarnestRecord(); EarnestRecordRequestDto newEarnestRecord = new EarnestRecordRequestDto();
newEarnestRecord.setUserId(dto.getUserId()); newEarnestRecord.setUserId(dto.getUserId());
newEarnestRecord.setItemId(dto.getItemId()); newEarnestRecord.setItemId(dto.getItemId());
newEarnestRecord.setType(EarnestEnum.TypeEnum.OCCUPY.getCode()); newEarnestRecord.setType(EarnestEnum.TypeEnum.OCCUPY.getCode());
newEarnestRecord.setSearchState(EarnestEnum.StateEnum.VALID.getCode());
newEarnestRecord.setState(EarnestEnum.StateEnum.RELEASE.getCode()); newEarnestRecord.setState(EarnestEnum.StateEnum.RELEASE.getCode());
earnestRecordDao.update(newEarnestRecord); earnestRecordDao.updateState(newEarnestRecord);
EarnestRecord earnestRecord = new EarnestRecord(); EarnestRecord earnestRecord = new EarnestRecord();
earnestRecord.setUserId(dto.getUserId()); earnestRecord.setUserId(dto.getUserId());
...@@ -263,12 +264,13 @@ public class AuctionEarnestServiceImpl implements AuctionEarnestService { ...@@ -263,12 +264,13 @@ public class AuctionEarnestServiceImpl implements AuctionEarnestService {
long occupyAmount = earnestAmount.longValue(); long occupyAmount = earnestAmount.longValue();
//把上一次的占用记录状态更改为已扣除 //把上一次的占用记录状态更改为已扣除
EarnestRecord newEarnestRecord = new EarnestRecord(); EarnestRecordRequestDto newEarnestRecord = new EarnestRecordRequestDto();
newEarnestRecord.setUserId(dto.getUserId()); newEarnestRecord.setUserId(dto.getUserId());
newEarnestRecord.setItemId(dto.getItemId()); newEarnestRecord.setItemId(dto.getItemId());
newEarnestRecord.setType(EarnestEnum.TypeEnum.OCCUPY.getCode()); newEarnestRecord.setType(EarnestEnum.TypeEnum.OCCUPY.getCode());
newEarnestRecord.setSearchState(EarnestEnum.StateEnum.VALID.getCode());
newEarnestRecord.setState(EarnestEnum.StateEnum.DEDUCT.getCode()); newEarnestRecord.setState(EarnestEnum.StateEnum.DEDUCT.getCode());
earnestRecordDao.update(newEarnestRecord); earnestRecordDao.updateState(newEarnestRecord);
//保证金扣除记录 //保证金扣除记录
EarnestRecord earnestRecord = new EarnestRecord(); EarnestRecord earnestRecord = new EarnestRecord();
......
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