Commit 526121a2 authored by shiyu's avatar shiyu

保证金

parent 96940a93
...@@ -150,6 +150,11 @@ public interface CommConsts { ...@@ -150,6 +150,11 @@ public interface CommConsts {
*/ */
public final static String AUCTION_EARNEST_ORDER_PREFIX = "AE"; public final static String AUCTION_EARNEST_ORDER_PREFIX = "AE";
/**
* 保证金换成出价额度比例为1:20,换成百分比为5%
*/
public final static String EARNEST_REBATE = "0.05";
/** /**
* 平台收货地址 * 平台收货地址
......
...@@ -48,6 +48,11 @@ public class PriceUtil { ...@@ -48,6 +48,11 @@ public class PriceUtil {
} }
public static Long convertToLong(BigDecimal number){
return number.multiply(new BigDecimal(100)).longValue();
}
public static Long convertPriceUnit(Long price){ public static Long convertPriceUnit(Long price){
BigDecimal bigDecimal = new BigDecimal(price); BigDecimal bigDecimal = new BigDecimal(price);
bigDecimal = bigDecimal.multiply(new BigDecimal(100)); bigDecimal = bigDecimal.multiply(new BigDecimal(100));
......
...@@ -4,8 +4,6 @@ import java.io.Serializable; ...@@ -4,8 +4,6 @@ import java.io.Serializable;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Arrays; import java.util.Arrays;
import java.util.Date; import java.util.Date;
import com.xxdxxs.entity.Entity;
import lombok.Data; import lombok.Data;
/** /**
...@@ -13,7 +11,7 @@ import lombok.Data; ...@@ -13,7 +11,7 @@ import lombok.Data;
* @date 2024/11/06 * @date 2024/11/06
*/ */
@Data @Data
public class UserAccount implements Entity { public class UserAccount implements Serializable {
private Long id; private Long id;
/** /**
...@@ -52,10 +50,15 @@ public class UserAccount implements Entity { ...@@ -52,10 +50,15 @@ public class UserAccount implements Entity {
private Long earnestAmount; private Long earnestAmount;
/** /**
* 保证金可用额度 * 保证金可用金额
*/ */
private Long earnestUsableAmount; private Long earnestUsableAmount;
/**
* 赠送的保证金金额
*/
private Long giftEarnestAmount;
/** /**
* 创建时间 * 创建时间
*/ */
...@@ -83,6 +86,7 @@ public class UserAccount implements Entity { ...@@ -83,6 +86,7 @@ public class UserAccount implements Entity {
sb.append(", introduceWaitEntryAmount=").append(introduceWaitEntryAmount); sb.append(", introduceWaitEntryAmount=").append(introduceWaitEntryAmount);
sb.append(", earnestAmount=").append(earnestAmount); sb.append(", earnestAmount=").append(earnestAmount);
sb.append(", earnestUsableAmount=").append(earnestUsableAmount); sb.append(", earnestUsableAmount=").append(earnestUsableAmount);
sb.append(", giftEarnestAmount=").append(giftEarnestAmount);
sb.append(", createTime=").append(createTime); sb.append(", createTime=").append(createTime);
sb.append(", updateTime=").append(updateTime); sb.append(", updateTime=").append(updateTime);
sb.append(", serialVersionUID=").append(serialVersionUID); sb.append(", serialVersionUID=").append(serialVersionUID);
...@@ -111,6 +115,7 @@ public class UserAccount implements Entity { ...@@ -111,6 +115,7 @@ public class UserAccount implements Entity {
&& (this.getIntroduceWaitEntryAmount() == null ? other.getIntroduceWaitEntryAmount() == null : this.getIntroduceWaitEntryAmount().equals(other.getIntroduceWaitEntryAmount())) && (this.getIntroduceWaitEntryAmount() == null ? other.getIntroduceWaitEntryAmount() == null : this.getIntroduceWaitEntryAmount().equals(other.getIntroduceWaitEntryAmount()))
&& (this.getEarnestAmount() == null ? other.getEarnestAmount() == null : this.getEarnestAmount().equals(other.getEarnestAmount())) && (this.getEarnestAmount() == null ? other.getEarnestAmount() == null : this.getEarnestAmount().equals(other.getEarnestAmount()))
&& (this.getEarnestUsableAmount() == null ? other.getEarnestUsableAmount() == null : this.getEarnestUsableAmount().equals(other.getEarnestUsableAmount())) && (this.getEarnestUsableAmount() == null ? other.getEarnestUsableAmount() == null : this.getEarnestUsableAmount().equals(other.getEarnestUsableAmount()))
&& (this.getGiftEarnestAmount() == null ? other.getGiftEarnestAmount() == null : this.getGiftEarnestAmount().equals(other.getGiftEarnestAmount()))
&& (this.getCreateTime() == null ? other.getCreateTime() == null : this.getCreateTime().equals(other.getCreateTime())) && (this.getCreateTime() == null ? other.getCreateTime() == null : this.getCreateTime().equals(other.getCreateTime()))
&& (this.getUpdateTime() == null ? other.getUpdateTime() == null : this.getUpdateTime().equals(other.getUpdateTime())); && (this.getUpdateTime() == null ? other.getUpdateTime() == null : this.getUpdateTime().equals(other.getUpdateTime()));
} }
...@@ -128,6 +133,7 @@ public class UserAccount implements Entity { ...@@ -128,6 +133,7 @@ public class UserAccount implements Entity {
result = prime * result + ((getIntroduceWaitEntryAmount() == null) ? 0 : getIntroduceWaitEntryAmount().hashCode()); result = prime * result + ((getIntroduceWaitEntryAmount() == null) ? 0 : getIntroduceWaitEntryAmount().hashCode());
result = prime * result + ((getEarnestAmount() == null) ? 0 : getEarnestAmount().hashCode()); result = prime * result + ((getEarnestAmount() == null) ? 0 : getEarnestAmount().hashCode());
result = prime * result + ((getEarnestUsableAmount() == null) ? 0 : getEarnestUsableAmount().hashCode()); result = prime * result + ((getEarnestUsableAmount() == null) ? 0 : getEarnestUsableAmount().hashCode());
result = prime * result + ((getGiftEarnestAmount() == null) ? 0 : getGiftEarnestAmount().hashCode());
result = prime * result + ((getCreateTime() == null) ? 0 : getCreateTime().hashCode()); result = prime * result + ((getCreateTime() == null) ? 0 : getCreateTime().hashCode());
result = prime * result + ((getUpdateTime() == null) ? 0 : getUpdateTime().hashCode()); result = prime * result + ((getUpdateTime() == null) ? 0 : getUpdateTime().hashCode());
return result; return result;
...@@ -150,6 +156,7 @@ public class UserAccount implements Entity { ...@@ -150,6 +156,7 @@ public class UserAccount implements Entity {
introduceWaitEntryAmount("introduce_wait_entry_amount", "introduceWaitEntryAmount", "BIGINT", false), introduceWaitEntryAmount("introduce_wait_entry_amount", "introduceWaitEntryAmount", "BIGINT", false),
earnestAmount("earnest_amount", "earnestAmount", "BIGINT", false), earnestAmount("earnest_amount", "earnestAmount", "BIGINT", false),
earnestUsableAmount("earnest_usable_amount", "earnestUsableAmount", "BIGINT", false), earnestUsableAmount("earnest_usable_amount", "earnestUsableAmount", "BIGINT", false),
giftEarnestAmount("gift_earnest_amount", "giftEarnestAmount", "BIGINT", false),
createTime("create_time", "createTime", "TIMESTAMP", false), createTime("create_time", "createTime", "TIMESTAMP", false),
updateTime("update_time", "updateTime", "TIMESTAMP", false); updateTime("update_time", "updateTime", "TIMESTAMP", false);
......
...@@ -1336,6 +1336,138 @@ public class UserAccountExample { ...@@ -1336,6 +1336,138 @@ public class UserAccountExample {
return (Criteria) this; return (Criteria) this;
} }
public Criteria andGiftEarnestAmountIsNull() {
addCriterion("gift_earnest_amount is null");
return (Criteria) this;
}
public Criteria andGiftEarnestAmountIsNotNull() {
addCriterion("gift_earnest_amount is not null");
return (Criteria) this;
}
public Criteria andGiftEarnestAmountEqualTo(Long value) {
addCriterion("gift_earnest_amount =", value, "giftEarnestAmount");
return (Criteria) this;
}
/**
* This method was generated by MyBatis Generator.
* This method corresponds to the database table user_account
*
* @mbg.generated
* @project https://github.com/itfsw/mybatis-generator-plugin
*/
public Criteria andGiftEarnestAmountEqualToColumn(UserAccount.Column column) {
addCriterion(new StringBuilder("gift_earnest_amount = ").append(column.getEscapedColumnName()).toString());
return (Criteria) this;
}
public Criteria andGiftEarnestAmountNotEqualTo(Long value) {
addCriterion("gift_earnest_amount <>", value, "giftEarnestAmount");
return (Criteria) this;
}
/**
* This method was generated by MyBatis Generator.
* This method corresponds to the database table user_account
*
* @mbg.generated
* @project https://github.com/itfsw/mybatis-generator-plugin
*/
public Criteria andGiftEarnestAmountNotEqualToColumn(UserAccount.Column column) {
addCriterion(new StringBuilder("gift_earnest_amount <> ").append(column.getEscapedColumnName()).toString());
return (Criteria) this;
}
public Criteria andGiftEarnestAmountGreaterThan(Long value) {
addCriterion("gift_earnest_amount >", value, "giftEarnestAmount");
return (Criteria) this;
}
/**
* This method was generated by MyBatis Generator.
* This method corresponds to the database table user_account
*
* @mbg.generated
* @project https://github.com/itfsw/mybatis-generator-plugin
*/
public Criteria andGiftEarnestAmountGreaterThanColumn(UserAccount.Column column) {
addCriterion(new StringBuilder("gift_earnest_amount > ").append(column.getEscapedColumnName()).toString());
return (Criteria) this;
}
public Criteria andGiftEarnestAmountGreaterThanOrEqualTo(Long value) {
addCriterion("gift_earnest_amount >=", value, "giftEarnestAmount");
return (Criteria) this;
}
/**
* This method was generated by MyBatis Generator.
* This method corresponds to the database table user_account
*
* @mbg.generated
* @project https://github.com/itfsw/mybatis-generator-plugin
*/
public Criteria andGiftEarnestAmountGreaterThanOrEqualToColumn(UserAccount.Column column) {
addCriterion(new StringBuilder("gift_earnest_amount >= ").append(column.getEscapedColumnName()).toString());
return (Criteria) this;
}
public Criteria andGiftEarnestAmountLessThan(Long value) {
addCriterion("gift_earnest_amount <", value, "giftEarnestAmount");
return (Criteria) this;
}
/**
* This method was generated by MyBatis Generator.
* This method corresponds to the database table user_account
*
* @mbg.generated
* @project https://github.com/itfsw/mybatis-generator-plugin
*/
public Criteria andGiftEarnestAmountLessThanColumn(UserAccount.Column column) {
addCriterion(new StringBuilder("gift_earnest_amount < ").append(column.getEscapedColumnName()).toString());
return (Criteria) this;
}
public Criteria andGiftEarnestAmountLessThanOrEqualTo(Long value) {
addCriterion("gift_earnest_amount <=", value, "giftEarnestAmount");
return (Criteria) this;
}
/**
* This method was generated by MyBatis Generator.
* This method corresponds to the database table user_account
*
* @mbg.generated
* @project https://github.com/itfsw/mybatis-generator-plugin
*/
public Criteria andGiftEarnestAmountLessThanOrEqualToColumn(UserAccount.Column column) {
addCriterion(new StringBuilder("gift_earnest_amount <= ").append(column.getEscapedColumnName()).toString());
return (Criteria) this;
}
public Criteria andGiftEarnestAmountIn(List<Long> values) {
addCriterion("gift_earnest_amount in", values, "giftEarnestAmount");
return (Criteria) this;
}
public Criteria andGiftEarnestAmountNotIn(List<Long> values) {
addCriterion("gift_earnest_amount not in", values, "giftEarnestAmount");
return (Criteria) this;
}
public Criteria andGiftEarnestAmountBetween(Long value1, Long value2) {
addCriterion("gift_earnest_amount between", value1, value2, "giftEarnestAmount");
return (Criteria) this;
}
public Criteria andGiftEarnestAmountNotBetween(Long value1, Long value2) {
addCriterion("gift_earnest_amount not between", value1, value2, "giftEarnestAmount");
return (Criteria) this;
}
public Criteria andCreateTimeIsNull() { public Criteria andCreateTimeIsNull() {
addCriterion("create_time is null"); addCriterion("create_time is null");
return (Criteria) this; return (Criteria) this;
......
...@@ -30,6 +30,11 @@ public class EarnestRecordRequestDto extends BaseRequestDto implements Entity { ...@@ -30,6 +30,11 @@ public class EarnestRecordRequestDto extends BaseRequestDto implements Entity {
*/ */
private String amount; private String amount;
/**
* 拍卖出价金额
*/
private Long auctionPrice;
/** /**
* -1扣除1新增 * -1扣除1新增
*/ */
......
...@@ -3,10 +3,8 @@ package com.wwdz.ch.db.mapper.openShop; ...@@ -3,10 +3,8 @@ package com.wwdz.ch.db.mapper.openShop;
import com.wwdz.ch.db.domain.openShop.UserAccount; import com.wwdz.ch.db.domain.openShop.UserAccount;
import com.wwdz.ch.db.domain.openShop.UserAccountExample; import com.wwdz.ch.db.domain.openShop.UserAccountExample;
import java.util.List; import java.util.List;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param; import org.apache.ibatis.annotations.Param;
@Mapper
public interface UserAccountMapper { public interface UserAccountMapper {
long countByExample(UserAccountExample example); long countByExample(UserAccountExample example);
......
...@@ -160,6 +160,9 @@ public class AuctionRecordServiceImpl implements AuctionRecordService { ...@@ -160,6 +160,9 @@ public class AuctionRecordServiceImpl implements AuctionRecordService {
} }
//把上次的最高价记录改为落后 //把上次的最高价记录改为落后
auctionRecordDao.updateNotLeadById(auctionRecord.getId()); auctionRecordDao.updateNotLeadById(auctionRecord.getId());
//把上次出价的用户保证金释放
//发送模板消息,提示用户出价被超越 //发送模板消息,提示用户出价被超越
String openId = sendMsgService.getOpenIdByUserId(auctionRecord.getUserId()); String openId = sendMsgService.getOpenIdByUserId(auctionRecord.getUserId());
if (com.xxdxxs.utils.StringUtils.hasLength(openId)) { if (com.xxdxxs.utils.StringUtils.hasLength(openId)) {
...@@ -201,6 +204,8 @@ public class AuctionRecordServiceImpl implements AuctionRecordService { ...@@ -201,6 +204,8 @@ public class AuctionRecordServiceImpl implements AuctionRecordService {
//更新专场配置中商品的当前价 //更新专场配置中商品的当前价
specialPerformanceConfigDao.updatePrice(itemId, price); specialPerformanceConfigDao.updatePrice(itemId, price);
//把当前领先的用户的保证金额度占用
//如果当前时间是拍卖截止时间的最后五分钟内,则再延长五分钟 //如果当前时间是拍卖截止时间的最后五分钟内,则再延长五分钟
Instant instant = endTime.toInstant().minus(Duration.ofMinutes(5)); Instant instant = endTime.toInstant().minus(Duration.ofMinutes(5));
Date time = Date.from(instant); Date time = Date.from(instant);
......
...@@ -10,6 +10,8 @@ import com.wwdz.ch.db.dao.openShop.EarnestOrderDao; ...@@ -10,6 +10,8 @@ import com.wwdz.ch.db.dao.openShop.EarnestOrderDao;
import com.wwdz.ch.db.dao.openShop.EarnestRecordDao; 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.EarnestOrder; import com.wwdz.ch.db.domain.openShop.EarnestOrder;
import com.wwdz.ch.db.domain.openShop.EarnestRecord;
import com.wwdz.ch.db.domain.openShop.UserAccount;
import com.wwdz.ch.db.dto.request.distribution.DistributionOrderRequestDto; import com.wwdz.ch.db.dto.request.distribution.DistributionOrderRequestDto;
import com.wwdz.ch.db.dto.request.openShop.EarnestOrderRequestDto; import com.wwdz.ch.db.dto.request.openShop.EarnestOrderRequestDto;
import com.wwdz.ch.db.dto.request.openShop.EarnestRecordRequestDto; import com.wwdz.ch.db.dto.request.openShop.EarnestRecordRequestDto;
...@@ -18,6 +20,10 @@ import org.slf4j.Logger; ...@@ -18,6 +20,10 @@ import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.transaction.interceptor.TransactionAspectSupport;
import java.math.BigDecimal;
import java.util.Date; import java.util.Date;
@Service @Service
...@@ -81,18 +87,46 @@ public class AuctionEarnestServiceImpl implements AuctionEarnestService { ...@@ -81,18 +87,46 @@ public class AuctionEarnestServiceImpl implements AuctionEarnestService {
} }
@Transactional
@Override @Override
public Result occupyEarnest(EarnestRecordRequestDto dto) { public Result occupyEarnest(EarnestRecordRequestDto dto) {
try { try {
EarnestRecord earnestRecord = new EarnestRecord();
long auctionPrice = dto.getAuctionPrice();
BigDecimal earnestAmount = new BigDecimal(String.valueOf(auctionPrice)).multiply(new BigDecimal(CommConsts.EARNEST_REBATE));
//换算成对应占用的保证金
long occupyAmount = earnestAmount.longValue();
earnestRecord.setAmount(earnestAmount.longValue());
earnestRecord.setItemId(dto.getItemId());
earnestRecord.setSpecialPerformanceId(dto.getSpecialPerformanceId());
earnestRecord.setEntryType(EarnestEnum.EntryEnum.DEDUCT.getCode());
earnestRecord.setCreateTime(new Date());
earnestRecord.setUpdateTime(new Date());
earnestRecord.setType(EarnestEnum.TypeEnum.OCCUPY.getCode());
earnestRecord.setState(EarnestEnum.StateEnum.VALID.getCode());
earnestRecordDao.insert(earnestRecord);
//用户账户,更新保证金额度
UserAccount userAccount = new UserAccount();
userAccount.setUserId(dto.getUserId());
return Result.success(); return Result.success();
} catch (Exception e) { } catch (Exception e) {
logger.error("占用保证金失败 error : {}", e); logger.error("占用保证金失败 error : {}", e);
TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
} }
return Result.failed(); return Result.failed();
} }
@Transactional
@Override @Override
public Result releaseEarnest(EarnestRecordRequestDto dto) { public Result releaseEarnest(EarnestRecordRequestDto dto) {
return null; try {
} catch (Exception e) {
logger.error("释放保证金失败 error : {}", e);
TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
}
return Result.failed();
} }
} }
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