Commit 18f2f52a authored by shiyu's avatar shiyu

钱包保证金明细

parent 7f0036ee
package com.wwdz.ch.core.entity; package com.wwdz.ch.core.entity;
import com.wwdz.ch.core.consts.CommConsts;
import com.wwdz.ch.core.util.PriceUtil; import com.wwdz.ch.core.util.PriceUtil;
import com.wwdz.ch.db.domain.openShop.UserAccount; import com.wwdz.ch.db.domain.openShop.UserAccount;
import com.xxdxxs.entity.Entity; import com.xxdxxs.entity.Entity;
...@@ -66,6 +67,16 @@ public class UserAccountVo implements Entity{ ...@@ -66,6 +67,16 @@ public class UserAccountVo implements Entity{
*/ */
private String giftEarnestAmount; private String giftEarnestAmount;
/**
* 可出价额度
*/
private String usableOfferAmount;
/**
* 占用的出价额度
*/
private String occupyEarnestAmount;
/** /**
* 创建时间 * 创建时间
*/ */
...@@ -89,6 +100,7 @@ public class UserAccountVo implements Entity{ ...@@ -89,6 +100,7 @@ public class UserAccountVo implements Entity{
userAccountVo.setEarnestAmount(PriceUtil.convertPriceFenToYuan(userAccount.getEarnestAmount())); userAccountVo.setEarnestAmount(PriceUtil.convertPriceFenToYuan(userAccount.getEarnestAmount()));
userAccountVo.setEarnestUsableAmount(PriceUtil.convertPriceFenToYuan(userAccount.getEarnestUsableAmount())); userAccountVo.setEarnestUsableAmount(PriceUtil.convertPriceFenToYuan(userAccount.getEarnestUsableAmount()));
userAccountVo.setGiftEarnestAmount(PriceUtil.convertPriceFenToYuan(userAccount.getGiftEarnestAmount())); userAccountVo.setGiftEarnestAmount(PriceUtil.convertPriceFenToYuan(userAccount.getGiftEarnestAmount()));
userAccountVo.setUsableOfferAmount(PriceUtil.convertPriceFenToYuan(userAccount.getEarnestUsableAmount() * CommConsts.EARNEST_TRANSFORM_AUCTION_REBATE));
return userAccountVo; return userAccountVo;
} }
} }
package com.wwdz.ch.wx.impl; package com.wwdz.ch.wx.impl;
import com.wwdz.ch.core.consts.CommConsts; import com.wwdz.ch.core.consts.CommConsts;
import com.wwdz.ch.core.consts.EarnestEnum;
import com.wwdz.ch.core.entity.UserAccountVo; import com.wwdz.ch.core.entity.UserAccountVo;
import com.wwdz.ch.core.type.Result; import com.wwdz.ch.core.type.Result;
import com.wwdz.ch.core.util.PriceUtil;
import com.wwdz.ch.db.dao.openShop.EarnestRecordDao;
import com.wwdz.ch.db.dao.openShop.UserAccountDao; import com.wwdz.ch.db.dao.openShop.UserAccountDao;
import com.wwdz.ch.db.domain.openShop.UserAccount; import com.wwdz.ch.db.domain.openShop.UserAccount;
import com.wwdz.ch.db.dto.request.openShop.EarnestRecordRequestDto;
import com.wwdz.ch.wx.service.UserAccountService; import com.wwdz.ch.wx.service.UserAccountService;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
...@@ -21,6 +25,9 @@ public class UserAccountServiceImpl implements UserAccountService { ...@@ -21,6 +25,9 @@ public class UserAccountServiceImpl implements UserAccountService {
@Autowired @Autowired
UserAccountDao userAccountDao; UserAccountDao userAccountDao;
@Autowired
EarnestRecordDao earnestRecordDao;
@Override @Override
public Result initAccount(long userId) { public Result initAccount(long userId) {
try { try {
...@@ -54,6 +61,13 @@ public class UserAccountServiceImpl implements UserAccountService { ...@@ -54,6 +61,13 @@ public class UserAccountServiceImpl implements UserAccountService {
initAccount(userId); initAccount(userId);
UserAccount userAccount = userAccountDao.findByUserId(userId); UserAccount userAccount = userAccountDao.findByUserId(userId);
UserAccountVo userAccountVo = UserAccountVo.convert(userAccount); UserAccountVo userAccountVo = UserAccountVo.convert(userAccount);
//查询被占用的保证金额度
EarnestRecordRequestDto earnestRecordRequestDto = new EarnestRecordRequestDto();
earnestRecordRequestDto.setUserId(userId);
earnestRecordRequestDto.setType(EarnestEnum.TypeEnum.OCCUPY.getCode());
earnestRecordRequestDto.setState(EarnestEnum.StateEnum.VALID.getCode());
long occupyAmount = earnestRecordDao.sumForOccupy(earnestRecordRequestDto);
userAccountVo.setOccupyEarnestAmount(PriceUtil.convertPriceFenToYuan(occupyAmount * 20));
return Result.success(userAccountVo); return Result.success(userAccountVo);
} catch (Exception e) { } catch (Exception e) {
logger.info("查询用户账户失败 error: {}", e); logger.info("查询用户账户失败 error: {}", e);
......
...@@ -278,17 +278,21 @@ public class AuctionEarnestServiceImpl implements AuctionEarnestService { ...@@ -278,17 +278,21 @@ public class AuctionEarnestServiceImpl implements AuctionEarnestService {
long oldEarnestAmount = userAccount.getEarnestAmount(); long oldEarnestAmount = userAccount.getEarnestAmount();
long earnestUsableAmount = userAccount.getEarnestUsableAmount(); long earnestUsableAmount = userAccount.getEarnestUsableAmount();
long giftEarnestAmount = userAccount.getGiftEarnestAmount(); long giftEarnestAmount = userAccount.getGiftEarnestAmount();
//可用的保证金金额
newUserAccount.setEarnestUsableAmount(earnestUsableAmount - occupyAmount);
if (occupyAmount <= giftEarnestAmount) { if (occupyAmount <= giftEarnestAmount) {
newUserAccount.setEarnestUsableAmount(earnestUsableAmount - occupyAmount); //赠送的保证金足够扣除,就只扣除赠送的部分额度
newUserAccount.setGiftEarnestAmount(giftEarnestAmount - occupyAmount); newUserAccount.setGiftEarnestAmount(giftEarnestAmount - occupyAmount);
} else if (occupyAmount > giftEarnestAmount) { } else if (occupyAmount > giftEarnestAmount) {
//赠送的保证金不够扣除,就扣除用户自己的缴纳的保证金
newUserAccount.setGiftEarnestAmount(0L);
long differAmount = occupyAmount - giftEarnestAmount;
newUserAccount.setEarnestAmount(oldEarnestAmount - differAmount);
} }
userAccountDao.update(newUserAccount); userAccountDao.update(newUserAccount);
return Result.success();
}catch (Exception e) { }catch (Exception e) {
logger.error("释放保证金失败 error : {}", e); logger.error("扣除保证金失败 error : {}", e);
TransactionAspectSupport.currentTransactionStatus().setRollbackOnly(); TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
} finally { } finally {
if (lock != null && lock.isHeldByCurrentThread()) { if (lock != null && lock.isHeldByCurrentThread()) {
......
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