Bläddra i källkod

服务账户流水

shasha 1 månad sedan
förälder
incheckning
97baa9052c
10 ändrade filer med 186 tillägg och 26 borttagningar
  1. 33 4
      snowy-plugin/snowy-plugin-biz/src/main/java/vip/xiaonuo/biz/modular/bizservicecustomer/controller/BizServiceCustomerAccountController.java
  2. 15 0
      snowy-plugin/snowy-plugin-biz/src/main/java/vip/xiaonuo/biz/modular/bizservicecustomer/controller/BizServiceCustomerFlowController.java
  3. 3 3
      snowy-plugin/snowy-plugin-biz/src/main/java/vip/xiaonuo/biz/modular/bizservicecustomer/entity/BizServiceCustomerFlow.java
  4. 4 0
      snowy-plugin/snowy-plugin-biz/src/main/java/vip/xiaonuo/biz/modular/bizservicecustomer/param/BizServiceCustomerAccountPageParam.java
  5. 8 0
      snowy-plugin/snowy-plugin-biz/src/main/java/vip/xiaonuo/biz/modular/bizservicecustomer/param/BizServiceCustomerFlowPageParam.java
  6. 18 4
      snowy-plugin/snowy-plugin-biz/src/main/java/vip/xiaonuo/biz/modular/bizservicecustomer/service/BizServiceCustomerAccountService.java
  7. 14 5
      snowy-plugin/snowy-plugin-biz/src/main/java/vip/xiaonuo/biz/modular/bizservicecustomer/service/BizServiceCustomerFlowService.java
  8. 44 5
      snowy-plugin/snowy-plugin-biz/src/main/java/vip/xiaonuo/biz/modular/bizservicecustomer/service/impl/BizServiceCustomerAccountServiceImpl.java
  9. 45 4
      snowy-plugin/snowy-plugin-biz/src/main/java/vip/xiaonuo/biz/modular/bizservicecustomer/service/impl/BizServiceCustomerFlowServiceImpl.java
  10. 2 1
      snowy-plugin/snowy-plugin-biz/src/main/java/vip/xiaonuo/biz/modular/bizservicecustomer/service/impl/BizServiceCustomerServiceImpl.java

+ 33 - 4
snowy-plugin/snowy-plugin-biz/src/main/java/vip/xiaonuo/biz/modular/bizservicecustomer/controller/BizServiceCustomerAccountController.java

@@ -21,13 +21,10 @@ import org.springframework.web.bind.annotation.GetMapping;
 import org.springframework.web.bind.annotation.PostMapping;
 import org.springframework.web.bind.annotation.RequestBody;
 import org.springframework.web.bind.annotation.RestController;
+import vip.xiaonuo.biz.modular.bizservicecustomer.param.*;
 import vip.xiaonuo.common.annotation.CommonLog;
 import vip.xiaonuo.common.pojo.CommonResult;
 import vip.xiaonuo.biz.modular.bizservicecustomer.entity.BizServiceCustomerAccount;
-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 jakarta.annotation.Resource;
@@ -118,4 +115,36 @@ public class BizServiceCustomerAccountController {
     public CommonResult<BizServiceCustomerAccount> detail(@Valid BizServiceCustomerAccountIdParam bizServiceCustomerAccountIdParam) {
         return CommonResult.data(bizServiceCustomerAccountService.detail(bizServiceCustomerAccountIdParam));
     }
+
+
+    /**
+     * 服务客户资金锁定
+     *
+     * @author sandy
+     * @date  2025/06/03 17:40
+     */
+    @Operation(summary = "服务客户资金锁定")
+    @CommonLog("服务客户资金锁定")
+    @SaCheckPermission("/biz/bizservicecustomeraccount/lock")
+    @PostMapping("/biz/bizservicecustomeraccount/lock")
+    public CommonResult<String> lock(@RequestBody @Valid BizServiceCustomerAccountLockParam bizServiceCustomerFlowLockParam) {
+        bizServiceCustomerAccountService.lock(bizServiceCustomerFlowLockParam);
+        return CommonResult.ok();
+    }
+
+    /**
+     * 服务客户资金解锁
+     *
+     * @author sandy
+     * @date  2025/06/03 17:40
+     */
+    @Operation(summary = "服务客户资金解锁")
+    @CommonLog("服务客户资金解锁")
+    @SaCheckPermission("/biz/bizservicecustomeraccount/unlock")
+    @PostMapping("/biz/bizservicecustomeraccount/unlock")
+    public CommonResult<String> unlock(@RequestBody @Valid BizServiceCustomerAccountLockParam bizServiceCustomerFlowLockParam) {
+        bizServiceCustomerAccountService.unlock(bizServiceCustomerFlowLockParam);
+        return CommonResult.ok();
+    }
+
 }

+ 15 - 0
snowy-plugin/snowy-plugin-biz/src/main/java/vip/xiaonuo/biz/modular/bizservicecustomer/controller/BizServiceCustomerFlowController.java

@@ -130,4 +130,19 @@ public class BizServiceCustomerFlowController {
     public CommonResult<BizServiceCustomerFlow> detail(@Valid BizServiceCustomerFlowIdParam bizServiceCustomerFlowIdParam) {
         return CommonResult.data(bizServiceCustomerFlowService.detail(bizServiceCustomerFlowIdParam));
     }
+
+    /**
+     * 服务客户资金锁定金额确定扣费
+     *
+     * @author sandy
+     * @date  2025/06/03 17:40
+     */
+    @Operation(summary = "服务客户资金锁定金额确定扣费")
+    @CommonLog("服务客户资金锁定金额确定扣费")
+    @SaCheckPermission("/biz/bizservicecustomerflow/lockConsume")
+    @PostMapping("/biz/bizservicecustomerflow/lockConsume")
+    public CommonResult<String> lockConsume(@RequestBody @Valid BizServiceCustomerAccountLockParam bizServiceCustomerFlowLockParam) {
+        bizServiceCustomerFlowService.lockConsume(bizServiceCustomerFlowLockParam);
+        return CommonResult.ok();
+    }
 }

+ 3 - 3
snowy-plugin/snowy-plugin-biz/src/main/java/vip/xiaonuo/biz/modular/bizservicecustomer/entity/BizServiceCustomerFlow.java

@@ -60,9 +60,9 @@ public class BizServiceCustomerFlow extends CommonEntity {
     @Schema(description = "操作后账户余额(充值或消费后账户余额)")
     private BigDecimal operateAmountAfter;
 
-    /** 操作状态   0正常    1取消 */
-    @Schema(description = "操作类型")
-    private String operateStatus;
+    /** 数据状态   0正常    1取消 */
+    @Schema(description = "数据状态")
+    private String dataStatus;
 
     /** 取消说明 */
     @Schema(description = "取消说明")

+ 4 - 0
snowy-plugin/snowy-plugin-biz/src/main/java/vip/xiaonuo/biz/modular/bizservicecustomer/param/BizServiceCustomerAccountPageParam.java

@@ -46,4 +46,8 @@ public class BizServiceCustomerAccountPageParam {
     @Schema(description = "关键词")
     private String searchKey;
 
+    /** 服务客户id */
+    @Schema(description = "服务客户id")
+    private String serviceCustomerId;
+
 }

+ 8 - 0
snowy-plugin/snowy-plugin-biz/src/main/java/vip/xiaonuo/biz/modular/bizservicecustomer/param/BizServiceCustomerFlowPageParam.java

@@ -46,4 +46,12 @@ public class BizServiceCustomerFlowPageParam {
     @Schema(description = "关键词")
     private String searchKey;
 
+    /** 服务客户id */
+    @Schema(description = "服务客户id")
+    private String serviceCustomerId;
+
+    /** 服务客户账户id */
+    @Schema(description = "服务客户账户id")
+    private String scAccountId;
+
 }

+ 18 - 4
snowy-plugin/snowy-plugin-biz/src/main/java/vip/xiaonuo/biz/modular/bizservicecustomer/service/BizServiceCustomerAccountService.java

@@ -15,10 +15,7 @@ package vip.xiaonuo.biz.modular.bizservicecustomer.service;
 import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
 import com.baomidou.mybatisplus.extension.service.IService;
 import vip.xiaonuo.biz.modular.bizservicecustomer.entity.BizServiceCustomerAccount;
-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.param.*;
 
 import java.util.List;
 
@@ -77,4 +74,21 @@ public interface BizServiceCustomerAccountService extends IService<BizServiceCus
      * @date  2025/05/29 14:39
      **/
     BizServiceCustomerAccount queryEntity(String id);
+
+    /**
+     * 服务客户资金锁定
+     *
+     * @author sandy
+     * @date  2025/06/04 09:13
+     */
+    void lock(BizServiceCustomerAccountLockParam bizServiceCustomerFlowLockParam);
+
+    /**
+     * 服务客户资金解锁
+     *
+     * @author sandy
+     * @date  2025/06/04 09:13
+     */
+    void unlock(BizServiceCustomerAccountLockParam bizServiceCustomerFlowLockParam);
+
 }

+ 14 - 5
snowy-plugin/snowy-plugin-biz/src/main/java/vip/xiaonuo/biz/modular/bizservicecustomer/service/BizServiceCustomerFlowService.java

@@ -38,16 +38,16 @@ public interface BizServiceCustomerFlowService extends IService<BizServiceCustom
     /**
      * 添加服务客户资金流水
      *
-     * @author fanzherong
-     * @date  2025/05/29 14:40
+     * @author sandy
+     * @date  2025/06/03 17:13
      */
     void add(BizServiceCustomerFlowAddParam bizServiceCustomerFlowAddParam);
 
     /**
-     * 添加服务客户资金流水
+     * 取消服务客户资金流水
      *
-     * @author fanzherong
-     * @date  2025/05/29 14:40
+     * @author sandy
+     * @date  2025/06/03 15:13
      */
     void cancel(BizServiceCustomerFlowCancelParam bizServiceCustomerFlowCancelParam);
 
@@ -82,4 +82,13 @@ public interface BizServiceCustomerFlowService extends IService<BizServiceCustom
      * @date  2025/05/29 14:40
      **/
     BizServiceCustomerFlow queryEntity(String id);
+
+    /**
+     * 锁定金额确定扣费服务客户资金流水
+     *
+     * @author sandy
+     * @date  2025/06/04 09:13
+     */
+    void lockConsume(BizServiceCustomerAccountLockParam bizServiceCustomerFlowLockParam);
+
 }

+ 44 - 5
snowy-plugin/snowy-plugin-biz/src/main/java/vip/xiaonuo/biz/modular/bizservicecustomer/service/impl/BizServiceCustomerAccountServiceImpl.java

@@ -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);
+    }
+
 }

+ 45 - 4
snowy-plugin/snowy-plugin-biz/src/main/java/vip/xiaonuo/biz/modular/bizservicecustomer/service/impl/BizServiceCustomerFlowServiceImpl.java

@@ -26,7 +26,7 @@ import org.springframework.transaction.annotation.Transactional;
 import vip.xiaonuo.biz.modular.bizservicecustomer.entity.BizServiceCustomerAccount;
 import vip.xiaonuo.biz.modular.bizservicecustomer.param.*;
 import vip.xiaonuo.biz.modular.bizservicecustomer.service.BizServiceCustomerAccountService;
-import vip.xiaonuo.biz.modular.goods.service.BizGoodsService;
+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;
@@ -49,16 +49,21 @@ public class BizServiceCustomerFlowServiceImpl extends ServiceImpl<BizServiceCus
     @Resource
     private BizServiceCustomerAccountService accountService;
 
-
     @Override
     public Page<BizServiceCustomerFlow> page(BizServiceCustomerFlowPageParam bizServiceCustomerFlowPageParam) {
         QueryWrapper<BizServiceCustomerFlow> queryWrapper = new QueryWrapper<BizServiceCustomerFlow>().checkSqlInjection();
+        if(ObjectUtil.isNotEmpty(bizServiceCustomerFlowPageParam.getServiceCustomerId())){
+            queryWrapper.lambda().like(BizServiceCustomerFlow::getServiceCustomerId, bizServiceCustomerFlowPageParam.getServiceCustomerId());
+        }
+        if(ObjectUtil.isNotEmpty(bizServiceCustomerFlowPageParam.getScAccountId())){
+            queryWrapper.lambda().like(BizServiceCustomerFlow::getScAccountId, bizServiceCustomerFlowPageParam.getScAccountId());
+        }
         if(ObjectUtil.isAllNotEmpty(bizServiceCustomerFlowPageParam.getSortField(), bizServiceCustomerFlowPageParam.getSortOrder())) {
             CommonSortOrderEnum.validate(bizServiceCustomerFlowPageParam.getSortOrder());
             queryWrapper.orderBy(true, bizServiceCustomerFlowPageParam.getSortOrder().equals(CommonSortOrderEnum.ASC.getValue()),
                     StrUtil.toUnderlineCase(bizServiceCustomerFlowPageParam.getSortField()));
         } else {
-            queryWrapper.lambda().orderByAsc(BizServiceCustomerFlow::getId);
+            queryWrapper.lambda().orderByDesc(BizServiceCustomerFlow::getCreateTime);
         }
         return this.page(CommonPageRequest.defaultPage(), queryWrapper);
     }
@@ -141,7 +146,7 @@ public class BizServiceCustomerFlowServiceImpl extends ServiceImpl<BizServiceCus
         accountService.updateById(account);
 
         // 更新流水数据为取消状态
-        bizServiceCustomerFlow.setOperateStatus("1");
+        bizServiceCustomerFlow.setDataStatus("1");
         bizServiceCustomerFlow.setOperateExplain(bizServiceCustomerFlowCancelParam.getOperateExplain());
         this.updateById(bizServiceCustomerFlow);
     }
@@ -174,4 +179,40 @@ public class BizServiceCustomerFlowServiceImpl extends ServiceImpl<BizServiceCus
         }
         return bizServiceCustomerFlow;
     }
+
+    @Transactional(rollbackFor = Exception.class)
+    @Override
+    public void lockConsume(BizServiceCustomerAccountLockParam bizServiceCustomerFlowLockParam){
+        BizServiceCustomerAccount bizServiceCustomerAccount = accountService.queryEntity(bizServiceCustomerFlowLockParam.getId());
+        BigDecimal lockAmount = bizServiceCustomerFlowLockParam.getLockAmount();
+        /** 锁定金额(占用金额) */
+        BigDecimal lockAmountOld = bizServiceCustomerAccount.getLockAmount();
+        /** 消费总金额 */
+        BigDecimal consumptionAmount = bizServiceCustomerAccount.getConsumptionAmount();
+        /** 可用余额(账户余额) */
+        BigDecimal accountAmount = bizServiceCustomerAccount.getAccountAmount();
+
+        //释放锁定金额
+        bizServiceCustomerAccount.setLockAmount(lockAmountOld.subtract(lockAmount));
+        // 增加消费金额
+        bizServiceCustomerAccount.setConsumptionAmount(consumptionAmount.add(lockAmount));
+        accountService.updateById(bizServiceCustomerAccount);
+
+        //添加消费扣款流水记录
+        BizServiceCustomerFlow bizServiceCustomerFlow = new BizServiceCustomerFlow();
+        /** 服务客户id */
+        bizServiceCustomerFlow.setServiceCustomerId(bizServiceCustomerAccount.getServiceCustomerId());
+        /** 服务客户账户id */
+        bizServiceCustomerFlow.setScAccountId(bizServiceCustomerAccount.getId());
+        /** 操作类型  1:充值   2:消费 */
+        bizServiceCustomerFlow.setOperateType("2");
+        /** 操作前账户余额(充值或消费前账户余额) */
+        bizServiceCustomerFlow.setOperateAmountBegin(accountAmount.subtract(lockAmount));
+        /** 操作金额(充值或消费金额) */
+        bizServiceCustomerFlow.setOperateAmount(lockAmount);
+        /** 操作后账户余额(充值或消费后账户余额) */
+        bizServiceCustomerFlow.setOperateAmountAfter(accountAmount);
+
+        this.save(bizServiceCustomerFlow);
+    }
 }

+ 2 - 1
snowy-plugin/snowy-plugin-biz/src/main/java/vip/xiaonuo/biz/modular/bizservicecustomer/service/impl/BizServiceCustomerServiceImpl.java

@@ -22,6 +22,7 @@ import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
 import org.springframework.stereotype.Service;
 import org.springframework.transaction.annotation.Transactional;
+import vip.xiaonuo.biz.modular.bizservicecustomer.entity.BizServiceCustomerFlow;
 import vip.xiaonuo.common.enums.CommonSortOrderEnum;
 import vip.xiaonuo.common.exception.CommonException;
 import vip.xiaonuo.common.page.CommonPageRequest;
@@ -52,7 +53,7 @@ public class BizServiceCustomerServiceImpl extends ServiceImpl<BizServiceCustome
             queryWrapper.orderBy(true, bizServiceCustomerPageParam.getSortOrder().equals(CommonSortOrderEnum.ASC.getValue()),
                     StrUtil.toUnderlineCase(bizServiceCustomerPageParam.getSortField()));
         } else {
-            queryWrapper.lambda().orderByAsc(BizServiceCustomer::getId);
+            queryWrapper.lambda().orderByDesc(BizServiceCustomer::getCreateTime);
         }
         return this.page(CommonPageRequest.defaultPage(), queryWrapper);
     }