|
|
|
@ -14,9 +14,9 @@ public class CurrencyOwnershipLockRepository {
|
|
|
|
public boolean tryLock(String currencyId, String ownerType, String ownerId,
|
|
|
|
public boolean tryLock(String currencyId, String ownerType, String ownerId,
|
|
|
|
String businessType, String businessId) {
|
|
|
|
String businessType, String businessId) {
|
|
|
|
return jdbc.update("UPDATE central_bank_currency_ownership " +
|
|
|
|
return jdbc.update("UPDATE central_bank_currency_ownership " +
|
|
|
|
"SET status='LOCKED',lock_business_type=?,lock_business_id=?,updated_at=CURRENT_TIMESTAMP " +
|
|
|
|
"SET status=?,lock_business_type=?,lock_business_id=?,updated_at=CURRENT_TIMESTAMP " +
|
|
|
|
"WHERE currency_id=? AND owner_type=? AND owner_id=? AND status='AVAILABLE'",
|
|
|
|
"WHERE currency_id=? AND owner_type=? AND owner_id=? AND status='AVAILABLE'",
|
|
|
|
businessType, businessId, currencyId, ownerType, ownerId) == 1;
|
|
|
|
lockStatus(businessType), businessType, businessId, currencyId, ownerType, ownerId) == 1;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public boolean transferLocked(String currencyId, String ownerType, String ownerId,
|
|
|
|
public boolean transferLocked(String currencyId, String ownerType, String ownerId,
|
|
|
|
@ -24,18 +24,24 @@ public class CurrencyOwnershipLockRepository {
|
|
|
|
String newOwnerType, String newOwnerId, String transactionId) {
|
|
|
|
String newOwnerType, String newOwnerId, String transactionId) {
|
|
|
|
return jdbc.update("UPDATE central_bank_currency_ownership SET owner_type=?,owner_id=?,status='AVAILABLE'," +
|
|
|
|
return jdbc.update("UPDATE central_bank_currency_ownership SET owner_type=?,owner_id=?,status='AVAILABLE'," +
|
|
|
|
"lock_business_type=NULL,lock_business_id=NULL,last_transaction_id=?,updated_at=CURRENT_TIMESTAMP " +
|
|
|
|
"lock_business_type=NULL,lock_business_id=NULL,last_transaction_id=?,updated_at=CURRENT_TIMESTAMP " +
|
|
|
|
"WHERE currency_id=? AND owner_type=? AND owner_id=? AND status='LOCKED' " +
|
|
|
|
"WHERE currency_id=? AND owner_type=? AND owner_id=? AND status=? " +
|
|
|
|
"AND lock_business_type=? AND lock_business_id=?",
|
|
|
|
"AND lock_business_type=? AND lock_business_id=?",
|
|
|
|
newOwnerType, newOwnerId, transactionId, currencyId, ownerType, ownerId,
|
|
|
|
newOwnerType, newOwnerId, transactionId, currencyId, ownerType, ownerId,
|
|
|
|
businessType, businessId) == 1;
|
|
|
|
lockStatus(businessType), businessType, businessId) == 1;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public boolean release(String currencyId, String ownerType, String ownerId,
|
|
|
|
public boolean release(String currencyId, String ownerType, String ownerId,
|
|
|
|
String businessType, String businessId) {
|
|
|
|
String businessType, String businessId) {
|
|
|
|
return jdbc.update("UPDATE central_bank_currency_ownership SET status='AVAILABLE'," +
|
|
|
|
return jdbc.update("UPDATE central_bank_currency_ownership SET status='AVAILABLE'," +
|
|
|
|
"lock_business_type=NULL,lock_business_id=NULL,updated_at=CURRENT_TIMESTAMP " +
|
|
|
|
"lock_business_type=NULL,lock_business_id=NULL,updated_at=CURRENT_TIMESTAMP " +
|
|
|
|
"WHERE currency_id=? AND owner_type=? AND owner_id=? AND status='LOCKED' " +
|
|
|
|
"WHERE currency_id=? AND owner_type=? AND owner_id=? AND status=? " +
|
|
|
|
"AND lock_business_type=? AND lock_business_id=?",
|
|
|
|
"AND lock_business_type=? AND lock_business_id=?",
|
|
|
|
currencyId, ownerType, ownerId, businessType, businessId) == 1;
|
|
|
|
currencyId, ownerType, ownerId, lockStatus(businessType), businessType, businessId) == 1;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private String lockStatus(String businessType) {
|
|
|
|
|
|
|
|
if ("EXCHANGE".equals(businessType)) return "EXCHANGE_LOCKED";
|
|
|
|
|
|
|
|
if ("PAYMENT".equals(businessType)) return "PAYMENT_LOCKED";
|
|
|
|
|
|
|
|
throw new IllegalArgumentException("不支持的币串锁业务类型:" + businessType);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|