分账
This commit is contained in:
@@ -102,7 +102,7 @@ public class ShopInfoServiceImpl extends ServiceImpl<ShopInfoMapper, ShopInfo> i
|
||||
if (shopInfo.getExpireTime() != null && (DateUtil.date().toLocalDateTime().isAfter(shopInfo.getExpireTime()))) {
|
||||
throw new CzgException("店铺已过期,请联系商家");
|
||||
}
|
||||
if (SystemConstants.OneZero.ZERO == shopInfo.getOnSale() || shopInfo.getStatus() !=SystemConstants.OneZero.ONE) {
|
||||
if (SystemConstants.OneZero.ZERO == shopInfo.getOnSale() || shopInfo.getStatus() != SystemConstants.OneZero.ONE) {
|
||||
throw new CzgException("店铺已停业,请联系商家");
|
||||
}
|
||||
|
||||
@@ -460,8 +460,8 @@ public class ShopInfoServiceImpl extends ServiceImpl<ShopInfoMapper, ShopInfo> i
|
||||
@Override
|
||||
public BigDecimal updateAmount(Long id, BigDecimal amount) {
|
||||
ShopInfo shopInfo = getShopInfo(id);
|
||||
if (shopInfo.getAmount() == null) {
|
||||
shopInfo.setAmount(BigDecimal.ZERO);
|
||||
if (shopInfo.getAmount() == null || shopInfo.getAmount().compareTo(BigDecimal.ZERO) <= 0) {
|
||||
throw new CzgException("更新失败");
|
||||
}
|
||||
boolean flag = mapper.updateAmount(id, amount);
|
||||
if (!flag) {
|
||||
|
||||
@@ -674,12 +674,19 @@ public class MkDistributionUserServiceImpl extends ServiceImpl<MkDistributionUse
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public void refund(Long orderId, String orderNo) {
|
||||
long count = distributionFlowService.count(new QueryWrapper().eq(MkDistributionFlow::getOrderNo, orderNo).eq(MkDistributionFlow::getStatus, TableValueConstant.DistributionFlow.Status.PENDING.getCode()));
|
||||
if (count >= 1) {
|
||||
boolean exists = distributionFlowService.exists(new QueryWrapper()
|
||||
.eq(MkDistributionFlow::getOrderNo, orderNo)
|
||||
.eq(MkDistributionFlow::getStatus, TableValueConstant.DistributionFlow.Status.REFUND.getCode()));
|
||||
if (exists) {
|
||||
log.warn("此分销已经退款");
|
||||
return;
|
||||
}
|
||||
distributionFlowService.list(new QueryWrapper().eq(MkDistributionFlow::getOrderNo, orderNo).ne(MkDistributionFlow::getStatus, TableValueConstant.DistributionFlow.Status.REFUND.getCode())).forEach(item -> {
|
||||
|
||||
List<MkDistributionFlow> list = distributionFlowService.list(new QueryWrapper()
|
||||
.eq(MkDistributionFlow::getOrderNo, orderNo)
|
||||
.ne(MkDistributionFlow::getStatus, TableValueConstant.DistributionFlow.Status.REFUND.getCode()));
|
||||
|
||||
list.forEach(item -> {
|
||||
MkDistributionFlow refundFlow = BeanUtil.copyProperties(item, MkDistributionFlow.class);
|
||||
refundFlow.setStatus(TableValueConstant.DistributionFlow.Status.REFUND.getCode());
|
||||
refundFlow.setSourceId(item.getId());
|
||||
@@ -688,7 +695,7 @@ public class MkDistributionUserServiceImpl extends ServiceImpl<MkDistributionUse
|
||||
refundFlow.setUpdateTime(DateUtil.date().toLocalDateTime());
|
||||
if (TableValueConstant.DistributionFlow.Status.PENDING.getCode().equals(item.getStatus())) {
|
||||
item.setStatus(TableValueConstant.DistributionFlow.Status.SUCCESS.getCode());
|
||||
updateIncome(item.getRewardAmount().negate(), BigDecimal.ZERO, BigDecimal.ZERO, item.getDistributionUserId(), item.getUserId(), item.getShopUserId(), item.getShopId(), item.getLevel());
|
||||
// updateIncome(item.getRewardAmount().negate(), BigDecimal.ZERO, BigDecimal.ZERO, item.getDistributionUserId(), item.getUserId(), item.getShopUserId(), item.getShopId(), item.getLevel());
|
||||
distributionFlowService.updateById(item);
|
||||
} else {
|
||||
// 执行扣款
|
||||
@@ -737,14 +744,6 @@ public class MkDistributionUserServiceImpl extends ServiceImpl<MkDistributionUse
|
||||
}
|
||||
}
|
||||
|
||||
static void main() {
|
||||
BigDecimal amount = new BigDecimal("0.18");
|
||||
BigDecimal fee = amount.multiply(BigDecimal.valueOf(0.08)).setScale(2, RoundingMode.UP);
|
||||
BigDecimal finalAmount = amount.subtract(fee);
|
||||
System.out.println(finalAmount);
|
||||
System.out.println(fee);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Boolean withdraw(long userId, MkDistributionWithdrawFlowDTO withdrawFlowDTO) {
|
||||
UserInfo userInfo = userInfoService.getById(userId);
|
||||
|
||||
Reference in New Issue
Block a user