| | |
| | | import com.mzl.flower.constant.LockConstants; |
| | | import com.mzl.flower.dto.request.wallet.QueryWalletAmountDTO; |
| | | import com.mzl.flower.dto.response.supplier.SupplierDTO; |
| | | import com.mzl.flower.entity.supplier.Supplier; |
| | | import com.mzl.flower.entity.wallet.WalletDO; |
| | | import com.mzl.flower.enums.TrueOrFalseEnum; |
| | | import com.mzl.flower.mapper.wallet.WalletMapper; |
| | |
| | | import org.redisson.api.RedissonClient; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.stereotype.Service; |
| | | import org.springframework.util.StringUtils; |
| | | |
| | | import java.math.BigDecimal; |
| | | import java.text.SimpleDateFormat; |
| | |
| | | |
| | | @Override |
| | | public WalletDO getOrCreateBySupplierId(Long supplierId) { |
| | | |
| | | |
| | | WalletDO walletDO=getBySupplierId(supplierId); |
| | | if(null==walletDO){ |
| | | RLock lock = redissonClient.getLock(String.format(LockConstants.WALLET_SUPPLIER_ID_KEY, supplierId)); |
| | |
| | | try { |
| | | walletDO=getBySupplierId(supplierId); |
| | | if(null!=walletDO) return walletDO; |
| | | |
| | | final Supplier supplier = supplierService.getSupplierById(supplierId); |
| | | |
| | | // 创建一个钱包 |
| | | walletDO =new WalletDO(); |
| | | walletDO.setUserId(SecurityUtils.getUserId()); |
| | | walletDO.setUserId(supplier.getUserId()); |
| | | walletDO.setSupplierId(supplierId); |
| | | walletDO.setTotalAmount(BigDecimal.ZERO); |
| | | walletDO.setWithdrawableAmount(BigDecimal.ZERO); |
| | |
| | | |
| | | @Override |
| | | public BigDecimal getWaittingSettlementAmount(WalletDO walletDO) { |
| | | |
| | | if(null!=walletDO && !StringUtils.isEmpty(walletDO.getSupplierId()) && StringUtils.isEmpty(walletDO.getUserId())){ |
| | | final Supplier supplier = supplierService.getSupplierById(walletDO.getSupplierId()); |
| | | walletDO.setUserId(supplier.getUserId()); |
| | | } |
| | | return baseMapper.getWaittingSettlementAmount(walletDO); |
| | | } |
| | | |