提交 dcc8a50d authored 作者: huyufan's avatar huyufan

资金相关

上级 04b9dc0f
...@@ -69,7 +69,7 @@ public enum PerformanceResultEnum implements ResultEnum { ...@@ -69,7 +69,7 @@ public enum PerformanceResultEnum implements ResultEnum {
SETTLEMENT_ORDER_STATUS_CHANGED(1401, "结算单状态已变更,请重新刷新页面"), SETTLEMENT_ORDER_STATUS_CHANGED(1401, "结算单状态已变更,请重新刷新页面"),
SETTLEMENT_NO_FOUND(1401, "结算单不存在"), SETTLEMENT_NO_FOUND(1401, "结算单不存在"),
MONEY_NO_SAME(1501, "货主提现金额和平台支付金额不一致"),
; ;
private final int code; private final int code;
......
...@@ -17,7 +17,7 @@ public class PageOwnerAccountListParam extends PageParam { ...@@ -17,7 +17,7 @@ public class PageOwnerAccountListParam extends PageParam {
private String ownerUserNo; private String ownerUserNo;
@ApiModelProperty(value = "联系电话") @ApiModelProperty(value = "联系电话")
private Integer mobile; private String mobile;
@ApiModelProperty(value = "账户类型 1:保证金 2:预付运费") @ApiModelProperty(value = "账户类型 1:保证金 2:预付运费")
private Integer accountType; private Integer accountType;
......
...@@ -15,9 +15,9 @@ public class FrozenAccountParam { ...@@ -15,9 +15,9 @@ public class FrozenAccountParam {
private Long userNo; private Long userNo;
//保证金
private BigDecimal frozenBalance;
//预付运费 //预付运费
private BigDecimal frozenBalance;
//保证金
private BigDecimal ensureBalance; private BigDecimal ensureBalance;
private Integer orderId; private Integer orderId;
private String orderNo; private String orderNo;
......
...@@ -40,6 +40,9 @@ public interface OwnerAccountMapper extends BaseMapper<OwnerAccount> { ...@@ -40,6 +40,9 @@ public interface OwnerAccountMapper extends BaseMapper<OwnerAccount> {
) )
Integer subAccount(@Param("account") OwnerAccount account, @Param("now")String now); Integer subAccount(@Param("account") OwnerAccount account, @Param("now")String now);
@SelectProvider(type = OwnerAccountSqlProvider.class, method = "updateOwnerAccountForConfirm") @Update("update owner_account set frozen_balance = frozen_balance - #{account.frozenBalance}," +
"modified_time=#{now}"
+"where id = #{account.id} and modified_time = #{account.modifiedTime}"
)
Integer updateOwnerAccountForConfirm(OwnerAccount account); Integer updateOwnerAccountForConfirm(OwnerAccount account);
} }
\ No newline at end of file
...@@ -328,7 +328,7 @@ public class OwnerAccountServiceImpl implements OwnerAccountService { ...@@ -328,7 +328,7 @@ public class OwnerAccountServiceImpl implements OwnerAccountService {
BigDecimal caseOutBalance = ownerCaseOut.getCaseOutBalance(); BigDecimal caseOutBalance = ownerCaseOut.getCaseOutBalance();
BigDecimal platformPayBalance = ownerCaseOut.getPlatformPayBalance(); BigDecimal platformPayBalance = ownerCaseOut.getPlatformPayBalance();
if (platformPayBalance.compareTo(caseOutBalance) != 0) { if (platformPayBalance.compareTo(caseOutBalance) != 0) {
throw new ServiceSystemException(PerformanceResultEnum.HTTP_ERROR, "货主提现金额和平台支付金额不一致"); throw new ServiceSystemException(PerformanceResultEnum.MONEY_NO_SAME);
} }
//给对应账户减少金额 //给对应账户减少金额
...@@ -627,26 +627,26 @@ public class OwnerAccountServiceImpl implements OwnerAccountService { ...@@ -627,26 +627,26 @@ public class OwnerAccountServiceImpl implements OwnerAccountService {
entity.setId(ownerAccount.getId()); entity.setId(ownerAccount.getId());
entity.setModifiedTime(ownerAccount.getModifiedTime()); entity.setModifiedTime(ownerAccount.getModifiedTime());
if (ownerAccount.getAccountType().equals(OwnerAccountEnum.AccountTypeStatus.MARGIN_ACCOUNT.getCode())) { if (ownerAccount.getAccountType().equals(OwnerAccountEnum.AccountTypeStatus.MARGIN_ACCOUNT.getCode())) {
if (ownerAccount.getUsableBalance().compareTo(frozenBalance) < 0) { if (ownerAccount.getUsableBalance().compareTo(ensureBalance) < 0) {
throw new ServiceSystemException(PerformanceResultEnum.HTTP_ERROR, "当前货主保证金账户可用余额不够冻结"); throw new ServiceSystemException(PerformanceResultEnum.HTTP_ERROR, "当前货主保证金账户可用余额不够冻结");
} }
//冻结金额 //冻结金额
entity.setFrozenBalance(frozenBalance); entity.setFrozenBalance(ensureBalance);
//可用余额 //可用余额
entity.setUsableBalance(frozenBalance); entity.setUsableBalance(ensureBalance);
//账户余额 //账户余额
entity.setAccountBalance(frozenBalance); entity.setAccountBalance(ensureBalance);
//updateList.add(entity); //updateList.add(entity);
flag += ownerAccountDao.updateAccountCAS(entity, now, false); flag += ownerAccountDao.updateAccountCAS(entity, now, false);
} else { } else {
if (ownerAccount.getUsableBalance().compareTo(ensureBalance) < 0) { if (ownerAccount.getUsableBalance().compareTo(frozenBalance) < 0) {
throw new ServiceSystemException(PerformanceResultEnum.HTTP_ERROR, "当前货主预付运费账户可用余额不够冻结"); throw new ServiceSystemException(PerformanceResultEnum.HTTP_ERROR, "当前货主预付运费账户可用余额不够冻结");
} }
//冻结金额 //冻结金额
entity.setFrozenBalance(ensureBalance); entity.setFrozenBalance(frozenBalance);
//可用余额 //可用余额
entity.setUsableBalance(ensureBalance); entity.setUsableBalance(frozenBalance);
//账户余额 //账户余额
entity.setAccountBalance(frozenBalance); entity.setAccountBalance(frozenBalance);
//updateList.add(entity); //updateList.add(entity);
......
...@@ -64,13 +64,4 @@ public class OwnerAccountSqlProvider { ...@@ -64,13 +64,4 @@ public class OwnerAccountSqlProvider {
return sqlList.toString(); return sqlList.toString();
} }
public String updateOwnerAccountForConfirm(OwnerAccount account) {
StringBuffer sqlList = new StringBuffer();
sqlList.append("update owner_account set frozen_balance = frozen_balance -" +
account.getFrozenBalance()
+ "where id = " + account.getId() + "and modified_time = '" + DateUtils.formatDateTime(account.getModifiedTime(), "yyyy-MM-dd HH:mm:ss").get()+"'"
);
return sqlList.toString();
}
} }
...@@ -11,16 +11,20 @@ import com.clx.performance.constant.RabbitKeyConstants; ...@@ -11,16 +11,20 @@ import com.clx.performance.constant.RabbitKeyConstants;
import com.clx.performance.constant.RedisConstants; import com.clx.performance.constant.RedisConstants;
import com.clx.performance.dao.OrderGoodsDao; import com.clx.performance.dao.OrderGoodsDao;
import com.clx.performance.dao.OwnerAccountDao; import com.clx.performance.dao.OwnerAccountDao;
import com.clx.performance.dao.OwnerCaseOutDao;
import com.clx.performance.enums.OrderGoodsStatusEnum; import com.clx.performance.enums.OrderGoodsStatusEnum;
import com.clx.performance.enums.OrderGoodsTruckBindEnum; import com.clx.performance.enums.OrderGoodsTruckBindEnum;
import com.clx.performance.enums.PerformanceResultEnum;
import com.clx.performance.feign.PerformanceFeign; import com.clx.performance.feign.PerformanceFeign;
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.model.OwnerCaseOut;
import com.clx.performance.param.pc.OwnerCaseOutParam; import com.clx.performance.param.pc.OwnerCaseOutParam;
import com.clx.performance.param.pc.owner.FrozenAccountParam; import com.clx.performance.param.pc.owner.FrozenAccountParam;
import com.clx.performance.service.OwnerAccountService; import com.clx.performance.service.OwnerAccountService;
import com.msl.common.base.Optional; import com.msl.common.base.Optional;
import com.msl.common.exception.ServiceSystemException;
import com.msl.common.result.Result; import com.msl.common.result.Result;
import org.junit.Test; import org.junit.Test;
import org.junit.runner.RunWith; import org.junit.runner.RunWith;
...@@ -69,8 +73,17 @@ public class JobTest { ...@@ -69,8 +73,17 @@ public class JobTest {
@Autowired @Autowired
private PerformanceFeign performanceFeign; private PerformanceFeign performanceFeign;
@Autowired
private OwnerCaseOutDao ownerCaseOutDao;
@Test @Test
public void test1() { public void test1() {
Optional<OwnerCaseOut> optional = ownerCaseOutDao.getEntityByKey(19);
OwnerCaseOut ownerCaseOut = optional.get();
BigDecimal caseOutBalance = ownerCaseOut.getCaseOutBalance();
BigDecimal platformPayBalance = ownerCaseOut.getPlatformPayBalance();
if (platformPayBalance.compareTo(caseOutBalance) != 0) {
throw new ServiceSystemException(PerformanceResultEnum.MONEY_NO_SAME);
}
} }
} }
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论