会员超额退款使用
This commit is contained in:
parent
974ca671c1
commit
1df88281b0
|
|
@ -28,6 +28,7 @@ import org.apache.dubbo.config.annotation.DubboService;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
import org.springframework.transaction.annotation.Transactional;
|
import org.springframework.transaction.annotation.Transactional;
|
||||||
|
|
||||||
|
import java.math.BigDecimal;
|
||||||
import java.math.RoundingMode;
|
import java.math.RoundingMode;
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -103,7 +104,12 @@ public class ShopUserServiceImpl extends ServiceImpl<ShopUserMapper, ShopUser> i
|
||||||
ShopUserFlow userFlow = new ShopUserFlow();
|
ShopUserFlow userFlow = new ShopUserFlow();
|
||||||
int flag;
|
int flag;
|
||||||
if (shopUserEditDTO.getType() == 0) {
|
if (shopUserEditDTO.getType() == 0) {
|
||||||
flag = mapper.decrAccount(shopId, shopUserEditDTO.getId(), DateUtil.date().toLocalDateTime(), shopUserEditDTO.getMoney());
|
if(shopUserEditDTO.getMoney().compareTo(userInfo.getAmount()) > 0){
|
||||||
|
//如果超额退款 则退为0
|
||||||
|
flag = mapper.decrAccount(shopId, shopUserEditDTO.getId(), DateUtil.date().toLocalDateTime(), userInfo.getAmount());
|
||||||
|
}else {
|
||||||
|
flag = mapper.decrAccount(shopId, shopUserEditDTO.getId(), DateUtil.date().toLocalDateTime(), shopUserEditDTO.getMoney());
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
flag = mapper.incrAccount(shopId, shopUserEditDTO.getId(), DateUtil.date().toLocalDateTime(), shopUserEditDTO.getMoney());
|
flag = mapper.incrAccount(shopId, shopUserEditDTO.getId(), DateUtil.date().toLocalDateTime(), shopUserEditDTO.getMoney());
|
||||||
}
|
}
|
||||||
|
|
@ -115,6 +121,9 @@ public class ShopUserServiceImpl extends ServiceImpl<ShopUserMapper, ShopUser> i
|
||||||
userFlow.setShopId(userInfo.getShopId());
|
userFlow.setShopId(userInfo.getShopId());
|
||||||
userFlow.setAmount(shopUserEditDTO.getType() == 0 ? shopUserEditDTO.getMoney().negate() : shopUserEditDTO.getMoney());
|
userFlow.setAmount(shopUserEditDTO.getType() == 0 ? shopUserEditDTO.getMoney().negate() : shopUserEditDTO.getMoney());
|
||||||
userFlow.setBalance(shopUserEditDTO.getType() == 0 ? userInfo.getAmount().subtract(shopUserEditDTO.getMoney()) : userInfo.getAmount().add(shopUserEditDTO.getMoney()));
|
userFlow.setBalance(shopUserEditDTO.getType() == 0 ? userInfo.getAmount().subtract(shopUserEditDTO.getMoney()) : userInfo.getAmount().add(shopUserEditDTO.getMoney()));
|
||||||
|
if (userFlow.getBalance().compareTo(BigDecimal.ZERO) < 0) {
|
||||||
|
userFlow.setBalance(BigDecimal.ZERO);
|
||||||
|
}
|
||||||
userFlow.setBizCode(shopUserEditDTO.getBizEnum().getCode());
|
userFlow.setBizCode(shopUserEditDTO.getBizEnum().getCode());
|
||||||
userFlow.setRemark(shopUserEditDTO.getRemark());
|
userFlow.setRemark(shopUserEditDTO.getRemark());
|
||||||
userFlow.setRelationId(shopUserEditDTO.getRelationId());
|
userFlow.setRelationId(shopUserEditDTO.getRelationId());
|
||||||
|
|
@ -233,7 +242,6 @@ public class ShopUserServiceImpl extends ServiceImpl<ShopUserMapper, ShopUser> i
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean join(Long shopId, Long userId, ShopUserAddDTO shopUserAddDTO) {
|
public boolean join(Long shopId, Long userId, ShopUserAddDTO shopUserAddDTO) {
|
||||||
UserInfo userInfo = userInfoService.getById(userId);
|
UserInfo userInfo = userInfoService.getById(userId);
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue