提交 320eebc9 authored 作者: huyufan's avatar huyufan

冻结资金相关

上级 1d21085f
...@@ -9,6 +9,7 @@ import com.clx.performance.param.pc.PageOwnerAccountListParam; ...@@ -9,6 +9,7 @@ import com.clx.performance.param.pc.PageOwnerAccountListParam;
import com.clx.performance.struct.OwnerAccountStruct; import com.clx.performance.struct.OwnerAccountStruct;
import com.clx.performance.vo.pc.OwnerAccountVO; import com.clx.performance.vo.pc.OwnerAccountVO;
import com.msl.common.dao.impl.BaseDaoImpl; import com.msl.common.dao.impl.BaseDaoImpl;
import com.msl.common.utils.DateUtils;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Repository; import org.springframework.stereotype.Repository;
...@@ -45,10 +46,11 @@ public class OwnerAccountDaoImpl extends BaseDaoImpl<OwnerAccountMapper, OwnerAc ...@@ -45,10 +46,11 @@ public class OwnerAccountDaoImpl extends BaseDaoImpl<OwnerAccountMapper, OwnerAc
@Override @Override
public Integer updateAccountCAS(OwnerAccount account, LocalDateTime now, boolean flag) { public Integer updateAccountCAS(OwnerAccount account, LocalDateTime now, boolean flag) {
String nowStr = DateUtils.formatDateTime(now,"yyyy-MM-dd HH:mm:ss").get();
if (flag) { if (flag) {
return baseMapper.addAccount(account, now); return baseMapper.addAccount(account, nowStr);
} else { } else {
return baseMapper.subAccount(account, now); return baseMapper.subAccount(account, nowStr);
} }
} }
......
...@@ -7,8 +7,11 @@ import com.clx.performance.model.OwnerAccount; ...@@ -7,8 +7,11 @@ import com.clx.performance.model.OwnerAccount;
import com.clx.performance.param.pc.PageOwnerAccountListParam; import com.clx.performance.param.pc.PageOwnerAccountListParam;
import com.clx.performance.sqlProvider.OwnerAccountSqlProvider; import com.clx.performance.sqlProvider.OwnerAccountSqlProvider;
import com.clx.performance.vo.pc.OwnerAccountVO; import com.clx.performance.vo.pc.OwnerAccountVO;
import com.msl.common.utils.DateUtils;
import org.apache.ibatis.annotations.Mapper; import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.SelectProvider; import org.apache.ibatis.annotations.SelectProvider;
import org.apache.ibatis.annotations.Update;
import java.time.LocalDateTime; import java.time.LocalDateTime;
import java.util.List; import java.util.List;
...@@ -22,11 +25,20 @@ public interface OwnerAccountMapper extends BaseMapper<OwnerAccount> { ...@@ -22,11 +25,20 @@ public interface OwnerAccountMapper extends BaseMapper<OwnerAccount> {
@SelectProvider(type = OwnerAccountSqlProvider.class, method = "pageList") @SelectProvider(type = OwnerAccountSqlProvider.class, method = "pageList")
IPage<OwnerAccountVO> pageList(Page<OwnerAccountVO> page, PageOwnerAccountListParam param); IPage<OwnerAccountVO> pageList(Page<OwnerAccountVO> page, PageOwnerAccountListParam param);
@SelectProvider(type = OwnerAccountSqlProvider.class, method = "addAccount") // @SelectProvider(type = OwnerAccountSqlProvider.class, method = "addAccount")
Integer addAccount(OwnerAccount account, LocalDateTime now); @Update("update owner_account set usable_balance = usable_balance + #{account.usableBalance}"
+",account_balance = account_balance + #{account.accountBalance}"
+",modified_time= #{now}"
+"where id = #{account.id} and modified_time = #{account.modifiedTime}"
)
Integer addAccount(@Param("account") OwnerAccount account, @Param("now")String now);
@SelectProvider(type = OwnerAccountSqlProvider.class, method = "subAccount") @Update("update owner_account set usable_balance = usable_balance - #{account.usableBalance}," +
Integer subAccount(OwnerAccount account, LocalDateTime now); "frozen_balance = frozen_balance + #{account.frozenBalance},account_balance = account_balance - #{account.accountBalance}," +
"modified_time=#{now}"
+"where id = #{account.id} and modified_time = #{account.modifiedTime}"
)
Integer subAccount(@Param("account") OwnerAccount account, @Param("now")String now);
@SelectProvider(type = OwnerAccountSqlProvider.class, method = "updateOwnerAccountForConfirm") @SelectProvider(type = OwnerAccountSqlProvider.class, method = "updateOwnerAccountForConfirm")
Integer updateOwnerAccountForConfirm(OwnerAccount account); Integer updateOwnerAccountForConfirm(OwnerAccount account);
......
...@@ -38,7 +38,7 @@ public class OwnerAccountSqlProvider { ...@@ -38,7 +38,7 @@ public class OwnerAccountSqlProvider {
return sql; return sql;
} }
public String addAccount(OwnerAccount account, LocalDateTime now) { public String addAccount(@Param("account") OwnerAccount account, @Param("now")LocalDateTime now) {
StringBuffer sqlList = new StringBuffer(); StringBuffer sqlList = new StringBuffer();
sqlList.append("update owner_account set usable_balance = usable_balance +" + sqlList.append("update owner_account set usable_balance = usable_balance +" +
...@@ -51,7 +51,7 @@ public class OwnerAccountSqlProvider { ...@@ -51,7 +51,7 @@ public class OwnerAccountSqlProvider {
return sqlList.toString(); return sqlList.toString();
} }
public String subAccount(OwnerAccount account, LocalDateTime now) { public String subAccount(@Param("account") OwnerAccount account, @Param("now")LocalDateTime now) {
StringBuffer sqlList = new StringBuffer(); StringBuffer sqlList = new StringBuffer();
sqlList.append("update owner_account set usable_balance = usable_balance -" + sqlList.append("update owner_account set usable_balance = usable_balance -" +
......
...@@ -16,6 +16,8 @@ import com.clx.performance.enums.OrderGoodsTruckBindEnum; ...@@ -16,6 +16,8 @@ import com.clx.performance.enums.OrderGoodsTruckBindEnum;
import com.clx.performance.mapper.OrderGoodsMapper; import com.clx.performance.mapper.OrderGoodsMapper;
import com.clx.performance.model.OrderGoods; import com.clx.performance.model.OrderGoods;
import com.clx.performance.model.OwnerAccount; import com.clx.performance.model.OwnerAccount;
import com.clx.performance.param.pc.OwnerCaseOutParam;
import com.clx.performance.service.OwnerAccountService;
import com.msl.common.base.Optional; import com.msl.common.base.Optional;
import org.junit.Test; import org.junit.Test;
import org.junit.runner.RunWith; import org.junit.runner.RunWith;
...@@ -58,12 +60,15 @@ public class JobTest { ...@@ -58,12 +60,15 @@ public class JobTest {
@Autowired @Autowired
private OwnerAccountDao ownerAccountDao; private OwnerAccountDao ownerAccountDao;
@Autowired
private OwnerAccountService ownerAccountService;
@Test @Test
public void test1() { public void test1() {
OwnerAccount account = new OwnerAccount(); OwnerCaseOutParam param = new OwnerCaseOutParam();
account.setId(7); param.setOwnerUserNo(1021181283626946629L);
account.setModifiedTime(LocalDateTime.now()); param.setCaseOutBalance(new BigDecimal("1"));
Integer i = ownerAccountDao.updateAccountCAS(account, LocalDateTime.now(), false); param.setAccountType(1);
System.out.println(i); ownerAccountService.accountCaseOut(param);
} }
} }
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论