mirror of
https://gitee.com/dromara/hmily.git
synced 2024-12-05 04:39:09 +08:00
发布1.1.0-release
This commit is contained in:
parent
262870c190
commit
8e90784e08
@ -23,7 +23,7 @@
|
||||
<parent>
|
||||
<artifactId>happylifeplat-tcc</artifactId>
|
||||
<groupId>com.happylifeplat.tcc</groupId>
|
||||
<version>1.0.0-RELEASE</version>
|
||||
<version>1.1.0-RELEASE</version>
|
||||
</parent>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
|
@ -23,7 +23,7 @@
|
||||
<parent>
|
||||
<artifactId>happylifeplat-tcc</artifactId>
|
||||
<groupId>com.happylifeplat.tcc</groupId>
|
||||
<version>1.0.0-RELEASE</version>
|
||||
<version>1.1.0-RELEASE</version>
|
||||
</parent>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
|
@ -5,7 +5,7 @@
|
||||
<parent>
|
||||
<artifactId>happylifeplat-tcc</artifactId>
|
||||
<groupId>com.happylifeplat.tcc</groupId>
|
||||
<version>1.0.0-RELEASE</version>
|
||||
<version>1.1.0-RELEASE</version>
|
||||
</parent>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
|
@ -5,7 +5,7 @@
|
||||
<parent>
|
||||
<artifactId>happylifeplat-tcc</artifactId>
|
||||
<groupId>com.happylifeplat.tcc</groupId>
|
||||
<version>1.0.0-RELEASE</version>
|
||||
<version>1.1.0-RELEASE</version>
|
||||
</parent>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
|
@ -23,7 +23,7 @@
|
||||
<parent>
|
||||
<artifactId>happylifeplat-tcc-demo-dubbo</artifactId>
|
||||
<groupId>com.happylifeplat.tcc</groupId>
|
||||
<version>1.0.0-RELEASE</version>
|
||||
<version>1.1.0-RELEASE</version>
|
||||
</parent>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
|
@ -23,7 +23,7 @@
|
||||
<parent>
|
||||
<artifactId>happylifeplat-tcc-demo-dubbo</artifactId>
|
||||
<groupId>com.happylifeplat.tcc</groupId>
|
||||
<version>1.0.0-RELEASE</version>
|
||||
<version>1.1.0-RELEASE</version>
|
||||
</parent>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<artifactId>happylifeplat-tcc-demo-dubbo-account</artifactId>
|
||||
|
@ -35,9 +35,34 @@ public interface AccountMapper {
|
||||
*/
|
||||
@Update("update account set balance =#{balance}," +
|
||||
" freeze_amount= #{freezeAmount} ,update_time = #{updateTime}" +
|
||||
" where user_id =#{userId} and balance > 0")
|
||||
" where user_id =#{userId} and balance > 0 and freeze_amount = 0 ")
|
||||
int update(AccountDO accountDO);
|
||||
|
||||
|
||||
/**
|
||||
* 确认扣减账户余额
|
||||
*
|
||||
* @param accountDO 实体类
|
||||
* @return rows
|
||||
*/
|
||||
@Update("update account set " +
|
||||
" freeze_amount= #{freezeAmount} ,update_time = #{updateTime}" +
|
||||
" where user_id =#{userId} and freeze_amount >0 ")
|
||||
int confirm(AccountDO accountDO);
|
||||
|
||||
|
||||
/**
|
||||
* 取消扣减账户余额
|
||||
*
|
||||
* @param accountDO 实体类
|
||||
* @return rows
|
||||
*/
|
||||
@Update("update account set balance =#{balance}," +
|
||||
" freeze_amount= #{freezeAmount} ,update_time = #{updateTime}" +
|
||||
" where user_id =#{userId} and freeze_amount >0")
|
||||
int cancel(AccountDO accountDO);
|
||||
|
||||
|
||||
/**
|
||||
* 根据userId获取用户账户信息
|
||||
*
|
||||
|
@ -78,7 +78,10 @@ public class AccountServiceImpl implements AccountService {
|
||||
final AccountDO accountDO = accountMapper.findByUserId(accountDTO.getUserId());
|
||||
accountDO.setFreezeAmount(accountDO.getFreezeAmount().subtract(accountDTO.getAmount()));
|
||||
accountDO.setUpdateTime(new Date());
|
||||
accountMapper.update(accountDO);
|
||||
final int rows = accountMapper.confirm(accountDO);
|
||||
if(rows!=1){
|
||||
throw new TccRuntimeException("确认扣减账户异常!");
|
||||
}
|
||||
return Boolean.TRUE;
|
||||
}
|
||||
|
||||
@ -90,7 +93,10 @@ public class AccountServiceImpl implements AccountService {
|
||||
accountDO.setBalance(accountDO.getBalance().add(accountDTO.getAmount()));
|
||||
accountDO.setFreezeAmount(accountDO.getFreezeAmount().subtract(accountDTO.getAmount()));
|
||||
accountDO.setUpdateTime(new Date());
|
||||
accountMapper.update(accountDO);
|
||||
final int rows = accountMapper.cancel(accountDO);
|
||||
if(rows!=1){
|
||||
throw new TccRuntimeException("取消扣减账户异常!");
|
||||
}
|
||||
return Boolean.TRUE;
|
||||
}
|
||||
}
|
||||
|
@ -23,7 +23,7 @@
|
||||
<parent>
|
||||
<artifactId>happylifeplat-tcc-demo-dubbo</artifactId>
|
||||
<groupId>com.happylifeplat.tcc</groupId>
|
||||
<version>1.0.0-RELEASE</version>
|
||||
<version>1.1.0-RELEASE</version>
|
||||
</parent>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
|
@ -23,7 +23,7 @@
|
||||
<parent>
|
||||
<artifactId>happylifeplat-tcc-demo-dubbo</artifactId>
|
||||
<groupId>com.happylifeplat.tcc</groupId>
|
||||
<version>1.0.0-RELEASE</version>
|
||||
<version>1.1.0-RELEASE</version>
|
||||
</parent>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
|
@ -28,6 +28,7 @@ import org.apache.ibatis.annotations.Update;
|
||||
public interface InventoryMapper {
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* 库存扣减
|
||||
*
|
||||
@ -36,9 +37,33 @@ public interface InventoryMapper {
|
||||
*/
|
||||
@Update("update inventory set total_inventory =#{totalInventory}," +
|
||||
" lock_inventory= #{lockInventory} " +
|
||||
" where product_id =#{productId} and total_inventory >0 and lock_inventory >=0 ")
|
||||
" where product_id =#{productId} and total_inventory >0 and lock_inventory =0 ")
|
||||
int decrease(Inventory inventory);
|
||||
|
||||
|
||||
/**
|
||||
* 库存扣减confirm
|
||||
*
|
||||
* @param inventory 实体对象
|
||||
* @return rows
|
||||
*/
|
||||
@Update("update inventory set " +
|
||||
" lock_inventory= #{lockInventory} " +
|
||||
" where product_id =#{productId} and lock_inventory >0 ")
|
||||
int confirm(Inventory inventory);
|
||||
|
||||
|
||||
/**
|
||||
* 库存扣减 cancel
|
||||
*
|
||||
* @param inventory 实体对象
|
||||
* @return rows
|
||||
*/
|
||||
@Update("update inventory set total_inventory =#{totalInventory}," +
|
||||
" lock_inventory= #{lockInventory} " +
|
||||
" where product_id =#{productId} and lock_inventory >0 ")
|
||||
int cancel(Inventory inventory);
|
||||
|
||||
/**
|
||||
* 根据商品id找到库存信息
|
||||
*
|
||||
|
@ -182,7 +182,14 @@ public class InventoryServiceImpl implements InventoryService {
|
||||
|
||||
entity.setLockInventory(entity.getLockInventory() - inventoryDTO.getCount());
|
||||
|
||||
inventoryMapper.decrease(entity);
|
||||
|
||||
final int rows = inventoryMapper.confirm(entity);
|
||||
|
||||
|
||||
if (rows != 1) {
|
||||
throw new TccRuntimeException("确认库存操作失败!");
|
||||
}
|
||||
|
||||
return true;
|
||||
|
||||
}
|
||||
@ -198,7 +205,12 @@ public class InventoryServiceImpl implements InventoryService {
|
||||
|
||||
entity.setLockInventory(entity.getLockInventory() - inventoryDTO.getCount());
|
||||
|
||||
inventoryMapper.decrease(entity);
|
||||
int rows= inventoryMapper.cancel(entity);
|
||||
|
||||
|
||||
if (rows != 1) {
|
||||
throw new TccRuntimeException("取消库存操作失败!");
|
||||
}
|
||||
|
||||
return true;
|
||||
|
||||
|
@ -23,7 +23,7 @@
|
||||
<parent>
|
||||
<artifactId>happylifeplat-tcc-demo-dubbo</artifactId>
|
||||
<groupId>com.happylifeplat.tcc</groupId>
|
||||
<version>1.0.0-RELEASE</version>
|
||||
<version>1.1.0-RELEASE</version>
|
||||
</parent>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
|
@ -23,7 +23,7 @@
|
||||
<parent>
|
||||
<artifactId>happylifeplat-tcc-demo</artifactId>
|
||||
<groupId>com.happylifeplat.tcc</groupId>
|
||||
<version>1.0.0-RELEASE</version>
|
||||
<version>1.1.0-RELEASE</version>
|
||||
</parent>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
|
@ -23,7 +23,7 @@
|
||||
<parent>
|
||||
<artifactId>happylifeplat-tcc-demo-springcloud</artifactId>
|
||||
<groupId>com.happylifeplat.tcc</groupId>
|
||||
<version>1.0.0-RELEASE</version>
|
||||
<version>1.1.0-RELEASE</version>
|
||||
</parent>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
|
@ -23,7 +23,7 @@
|
||||
<parent>
|
||||
<artifactId>happylifeplat-tcc-demo-springcloud</artifactId>
|
||||
<groupId>com.happylifeplat.tcc</groupId>
|
||||
<version>1.0.0-RELEASE</version>
|
||||
<version>1.1.0-RELEASE</version>
|
||||
</parent>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
|
@ -23,7 +23,7 @@
|
||||
<parent>
|
||||
<artifactId>happylifeplat-tcc-demo-springcloud</artifactId>
|
||||
<groupId>com.happylifeplat.tcc</groupId>
|
||||
<version>1.0.0-RELEASE</version>
|
||||
<version>1.1.0-RELEASE</version>
|
||||
</parent>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
|
@ -23,7 +23,7 @@
|
||||
<parent>
|
||||
<artifactId>happylifeplat-tcc-demo-springcloud</artifactId>
|
||||
<groupId>com.happylifeplat.tcc</groupId>
|
||||
<version>1.0.0-RELEASE</version>
|
||||
<version>1.1.0-RELEASE</version>
|
||||
</parent>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
|
@ -23,7 +23,7 @@
|
||||
<parent>
|
||||
<artifactId>happylifeplat-tcc-demo</artifactId>
|
||||
<groupId>com.happylifeplat.tcc</groupId>
|
||||
<version>1.0.0-RELEASE</version>
|
||||
<version>1.1.0-RELEASE</version>
|
||||
</parent>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
|
@ -5,7 +5,7 @@
|
||||
<parent>
|
||||
<artifactId>happylifeplat-tcc</artifactId>
|
||||
<groupId>com.happylifeplat.tcc</groupId>
|
||||
<version>1.0.0-RELEASE</version>
|
||||
<version>1.1.0-RELEASE</version>
|
||||
</parent>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
|
@ -5,7 +5,7 @@
|
||||
<parent>
|
||||
<artifactId>happylifeplat-tcc</artifactId>
|
||||
<groupId>com.happylifeplat.tcc</groupId>
|
||||
<version>1.0.0-RELEASE</version>
|
||||
<version>1.1.0-RELEASE</version>
|
||||
</parent>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
|
@ -5,7 +5,7 @@
|
||||
<parent>
|
||||
<artifactId>happylifeplat-tcc</artifactId>
|
||||
<groupId>com.happylifeplat.tcc</groupId>
|
||||
<version>1.0.0-RELEASE</version>
|
||||
<version>1.1.0-RELEASE</version>
|
||||
</parent>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<packaging>jar</packaging>
|
||||
|
Loading…
Reference in New Issue
Block a user