|
@@ -19,19 +19,20 @@ import cn.hutool.core.util.StrUtil;
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
|
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
|
+import io.swagger.v3.oas.annotations.media.Schema;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
|
+import vip.xiaonuo.biz.modular.bizservicecustomer.entity.BizServiceCustomerFlow;
|
|
|
+import vip.xiaonuo.biz.modular.bizservicecustomer.param.*;
|
|
|
+import vip.xiaonuo.biz.modular.bizsupplier.entity.BizSupplierAccount;
|
|
|
import vip.xiaonuo.common.enums.CommonSortOrderEnum;
|
|
|
import vip.xiaonuo.common.exception.CommonException;
|
|
|
import vip.xiaonuo.common.page.CommonPageRequest;
|
|
|
import vip.xiaonuo.biz.modular.bizservicecustomer.entity.BizServiceCustomerAccount;
|
|
|
import vip.xiaonuo.biz.modular.bizservicecustomer.mapper.BizServiceCustomerAccountMapper;
|
|
|
-import vip.xiaonuo.biz.modular.bizservicecustomer.param.BizServiceCustomerAccountAddParam;
|
|
|
-import vip.xiaonuo.biz.modular.bizservicecustomer.param.BizServiceCustomerAccountEditParam;
|
|
|
-import vip.xiaonuo.biz.modular.bizservicecustomer.param.BizServiceCustomerAccountIdParam;
|
|
|
-import vip.xiaonuo.biz.modular.bizservicecustomer.param.BizServiceCustomerAccountPageParam;
|
|
|
import vip.xiaonuo.biz.modular.bizservicecustomer.service.BizServiceCustomerAccountService;
|
|
|
|
|
|
+import java.math.BigDecimal;
|
|
|
import java.util.List;
|
|
|
|
|
|
/**
|
|
@@ -46,12 +47,15 @@ public class BizServiceCustomerAccountServiceImpl extends ServiceImpl<BizService
|
|
|
@Override
|
|
|
public Page<BizServiceCustomerAccount> page(BizServiceCustomerAccountPageParam bizServiceCustomerAccountPageParam) {
|
|
|
QueryWrapper<BizServiceCustomerAccount> queryWrapper = new QueryWrapper<BizServiceCustomerAccount>().checkSqlInjection();
|
|
|
+ if(ObjectUtil.isNotEmpty(bizServiceCustomerAccountPageParam.getServiceCustomerId())){
|
|
|
+ queryWrapper.lambda().like(BizServiceCustomerAccount::getServiceCustomerId, bizServiceCustomerAccountPageParam.getServiceCustomerId());
|
|
|
+ }
|
|
|
if(ObjectUtil.isAllNotEmpty(bizServiceCustomerAccountPageParam.getSortField(), bizServiceCustomerAccountPageParam.getSortOrder())) {
|
|
|
CommonSortOrderEnum.validate(bizServiceCustomerAccountPageParam.getSortOrder());
|
|
|
queryWrapper.orderBy(true, bizServiceCustomerAccountPageParam.getSortOrder().equals(CommonSortOrderEnum.ASC.getValue()),
|
|
|
StrUtil.toUnderlineCase(bizServiceCustomerAccountPageParam.getSortField()));
|
|
|
} else {
|
|
|
- queryWrapper.lambda().orderByAsc(BizServiceCustomerAccount::getId);
|
|
|
+ queryWrapper.lambda().orderByDesc(BizServiceCustomerAccount::getCreateTime);
|
|
|
}
|
|
|
return this.page(CommonPageRequest.defaultPage(), queryWrapper);
|
|
|
}
|
|
@@ -91,4 +95,39 @@ public class BizServiceCustomerAccountServiceImpl extends ServiceImpl<BizService
|
|
|
}
|
|
|
return bizServiceCustomerAccount;
|
|
|
}
|
|
|
+
|
|
|
+ @Transactional(rollbackFor = Exception.class)
|
|
|
+ @Override
|
|
|
+ public void lock(BizServiceCustomerAccountLockParam bizServiceCustomerFlowLockParam){
|
|
|
+ BizServiceCustomerAccount bizServiceCustomerAccount = this.queryEntity(bizServiceCustomerFlowLockParam.getId());
|
|
|
+ BigDecimal lockAmount = bizServiceCustomerFlowLockParam.getLockAmount();
|
|
|
+ /** 锁定金额(占用金额) */
|
|
|
+ BigDecimal lockAmountOld = bizServiceCustomerAccount.getLockAmount();
|
|
|
+ /** 可用余额(账户余额) */
|
|
|
+ BigDecimal accountAmount = bizServiceCustomerAccount.getAccountAmount();
|
|
|
+
|
|
|
+ // 添加锁定金额
|
|
|
+ bizServiceCustomerAccount.setLockAmount(lockAmountOld.add(lockAmount));
|
|
|
+ // 余额扣减
|
|
|
+ bizServiceCustomerAccount.setAccountAmount(accountAmount.subtract(lockAmount));
|
|
|
+ this.updateById(bizServiceCustomerAccount);
|
|
|
+ }
|
|
|
+
|
|
|
+ @Transactional(rollbackFor = Exception.class)
|
|
|
+ @Override
|
|
|
+ public void unlock(BizServiceCustomerAccountLockParam bizServiceCustomerFlowLockParam){
|
|
|
+ BizServiceCustomerAccount bizServiceCustomerAccount = this.queryEntity(bizServiceCustomerFlowLockParam.getId());
|
|
|
+ BigDecimal lockAmount = bizServiceCustomerFlowLockParam.getLockAmount();
|
|
|
+ /** 锁定金额(占用金额) */
|
|
|
+ BigDecimal lockAmountOld = bizServiceCustomerAccount.getLockAmount();
|
|
|
+ /** 可用余额(账户余额) */
|
|
|
+ BigDecimal accountAmount = bizServiceCustomerAccount.getAccountAmount();
|
|
|
+
|
|
|
+ // 取消锁定金额
|
|
|
+ bizServiceCustomerAccount.setLockAmount(lockAmountOld.subtract(lockAmount));
|
|
|
+ // 余额恢复
|
|
|
+ bizServiceCustomerAccount.setAccountAmount(accountAmount.add(lockAmount));
|
|
|
+ this.updateById(bizServiceCustomerAccount);
|
|
|
+ }
|
|
|
+
|
|
|
}
|