소스 검색

golden 支付相关

yexianchao 1 개월 전
부모
커밋
2d9ca80ca3
100개의 변경된 파일3890개의 추가작업 그리고 841개의 파일을 삭제
  1. 10 2
      crm-custom/src/main/java/com/crm/custom/controller/CustomController.java
  2. 16 0
      crm-custom/src/main/java/com/crm/custom/controller/GoldenOrderController.java
  3. 40 4
      crm-custom/src/main/java/com/crm/custom/controller/GoldenRewardQuestionController.java
  4. 0 5
      crm-custom/src/main/java/com/crm/custom/dao/mapper/GoldenGoodsMapper.java
  5. 0 5
      crm-custom/src/main/java/com/crm/custom/dao/mapper/GoldenGoodsVideoMapper.java
  6. 18 0
      crm-custom/src/main/java/com/crm/custom/dao/mapper/GoldenQuestionCustomMapper.java
  7. 3 0
      crm-custom/src/main/java/com/crm/custom/dao/mapper/GoldenRewardQuestionMapper.java
  8. 15 0
      crm-custom/src/main/java/com/crm/custom/dao/repository/GoldenCustomRewardRecordRepository.java
  9. 18 0
      crm-custom/src/main/java/com/crm/custom/dao/repository/GoldenOrderRepository.java
  10. 11 0
      crm-custom/src/main/java/com/crm/custom/dao/repository/GoldenQuestionCustomRepository.java
  11. 1 16
      crm-custom/src/main/java/com/crm/custom/service/CustomInfoService.java
  12. 6 0
      crm-custom/src/main/java/com/crm/custom/service/GoldenGoodsService.java
  13. 1 0
      crm-custom/src/main/java/com/crm/custom/service/GoldenOrderService.java
  14. 8 5
      crm-custom/src/main/java/com/crm/custom/service/GoldenRewardQuestionService.java
  15. 17 119
      crm-custom/src/main/java/com/crm/custom/service/impl/CustomInfoServiceImpl.java
  16. 2 2
      crm-custom/src/main/java/com/crm/custom/service/impl/CustomLoginAssetManagementServiceImpl.java
  17. 36 14
      crm-custom/src/main/java/com/crm/custom/service/impl/GoldenGoodsServiceImpl.java
  18. 20 15
      crm-custom/src/main/java/com/crm/custom/service/impl/GoldenGoodsVideoServiceImpl.java
  19. 21 6
      crm-custom/src/main/java/com/crm/custom/service/impl/GoldenOrderServiceImpl.java
  20. 126 5
      crm-custom/src/main/java/com/crm/custom/service/impl/GoldenRewardQuestionServiceImpl.java
  21. 1 1
      crm-custom/src/main/resources/application-test.yml
  22. 3 1
      crm-custom/src/main/resources/i18n/messages_en_US.properties
  23. 3 1
      crm-custom/src/main/resources/i18n/messages_zh_CN.properties
  24. 10 23
      crm-custom/src/main/resources/mapper/GoldenGoods.xml
  25. 0 27
      crm-custom/src/main/resources/mapper/GoldenGoodsVideo.xml
  26. 0 1
      crm-custom/src/main/resources/mapper/GoldenOrder.xml
  27. 37 0
      crm-custom/src/main/resources/mapper/GoldenQuestionCustomMapper.xml
  28. 4 0
      crm-custom/src/main/resources/mapper/GoldenRewardQuestionMapper.xml
  29. 0 6
      crm-manager/src/main/java/com/crm/manager/controller/CustomInfoController.java
  30. 251 16
      crm-manager/src/main/java/com/crm/manager/controller/FinanceWithdrawController.java
  31. 112 0
      crm-manager/src/main/java/com/crm/manager/dto/export/FinanceWithdrawExportDto.java
  32. 18 0
      crm-manager/src/main/java/com/crm/manager/service/FinanceWithdrawApiFeignService.java
  33. 45 6
      crm-manager/src/main/java/com/crm/manager/service/FinanceWithdrawFeignService.java
  34. 1 1
      crm-manager/src/main/resources/application-test.yml
  35. 10 0
      crm-model/src/main/java/com/crm/rely/backend/model/constant/ConfigConstants.java
  36. 10 0
      crm-model/src/main/java/com/crm/rely/backend/model/constant/EmailTemplateConstants.java
  37. 42 5
      crm-model/src/main/java/com/crm/rely/backend/model/constant/PayConstants.java
  38. 6 0
      crm-model/src/main/java/com/crm/rely/backend/model/dto/golden/order/GoldenOrderListDto.java
  39. 22 0
      crm-model/src/main/java/com/crm/rely/backend/model/dto/golden/question/GoldenRewardQuestionDto.java
  40. 26 0
      crm-model/src/main/java/com/crm/rely/backend/model/dto/sys/remit/SysRemitChannelApiDto.java
  41. 38 2
      crm-model/src/main/java/com/crm/rely/backend/model/dto/sys/remit/SysRemitChannelDto.java
  42. 53 2
      crm-model/src/main/java/com/crm/rely/backend/model/dto/sys/remittance/channel/SysRemittanceChannelDto.java
  43. 16 0
      crm-model/src/main/java/com/crm/rely/backend/model/entity/finance/withdraw/FinanceAgentWithdrawSearchListEntity.java
  44. 17 0
      crm-model/src/main/java/com/crm/rely/backend/model/entity/finance/withdraw/FinanceApplyDigitalWithdrawSendEmailCodeEntity.java
  45. 21 0
      crm-model/src/main/java/com/crm/rely/backend/model/entity/finance/withdraw/FinanceWithdrawApproveBackstageEntity.java
  46. 26 0
      crm-model/src/main/java/com/crm/rely/backend/model/entity/finance/withdraw/FinanceWithdrawApproveChannelEntity.java
  47. 24 0
      crm-model/src/main/java/com/crm/rely/backend/model/entity/finance/withdraw/FinanceWithdrawApproveChannelSubmitEntity.java
  48. 21 0
      crm-model/src/main/java/com/crm/rely/backend/model/entity/finance/withdraw/FinanceWithdrawApproveChannelSubmitsEntity.java
  49. 24 0
      crm-model/src/main/java/com/crm/rely/backend/model/entity/finance/withdraw/FinanceWithdrawApproveChannelsEntity.java
  50. 3 0
      crm-model/src/main/java/com/crm/rely/backend/model/entity/finance/withdraw/FinanceWithdrawApproveEntity.java
  51. 21 0
      crm-model/src/main/java/com/crm/rely/backend/model/entity/finance/withdraw/FinanceWithdrawApproveInfoEntity.java
  52. 21 0
      crm-model/src/main/java/com/crm/rely/backend/model/entity/finance/withdraw/FinanceWithdrawApproveInfosEntity.java
  53. 24 0
      crm-model/src/main/java/com/crm/rely/backend/model/entity/finance/withdraw/FinanceWithdrawApproveManagerEntity.java
  54. 10 0
      crm-model/src/main/java/com/crm/rely/backend/model/entity/finance/withdraw/FinanceWithdrawApproveSalesEntity.java
  55. 8 0
      crm-model/src/main/java/com/crm/rely/backend/model/entity/finance/withdraw/FinanceWithdrawBankAddEntity.java
  56. 4 0
      crm-model/src/main/java/com/crm/rely/backend/model/entity/finance/withdraw/FinanceWithdrawBankTelegraphicAddEntity.java
  57. 28 8
      crm-model/src/main/java/com/crm/rely/backend/model/entity/finance/withdraw/FinanceWithdrawBaseAddEntity.java
  58. 10 0
      crm-model/src/main/java/com/crm/rely/backend/model/entity/finance/withdraw/FinanceWithdrawCancelEntity.java
  59. 22 0
      crm-model/src/main/java/com/crm/rely/backend/model/entity/finance/withdraw/FinanceWithdrawCardAddEntity.java
  60. 6 0
      crm-model/src/main/java/com/crm/rely/backend/model/entity/finance/withdraw/FinanceWithdrawDigitalCurrencyAddEntity.java
  61. 20 0
      crm-model/src/main/java/com/crm/rely/backend/model/entity/finance/withdraw/FinanceWithdrawInfoEntity.java
  62. 10 0
      crm-model/src/main/java/com/crm/rely/backend/model/entity/finance/withdraw/FinanceWithdrawSearchByIdsEntity.java
  63. 41 0
      crm-model/src/main/java/com/crm/rely/backend/model/entity/finance/withdraw/FinanceWithdrawSearchListEntity.java
  64. 14 0
      crm-model/src/main/java/com/crm/rely/backend/model/entity/finance/withdraw/FinanceWithdrawWalletAddEntity.java
  65. 2 0
      crm-model/src/main/java/com/crm/rely/backend/model/entity/golden/goods/GoldenGoodsSearchEntity.java
  66. 4 0
      crm-model/src/main/java/com/crm/rely/backend/model/entity/golden/goods/GoldenGoodsVideoSearchEntity.java
  67. 17 0
      crm-model/src/main/java/com/crm/rely/backend/model/entity/golden/question/GoldenQuestionCustomAddEntity.java
  68. 14 0
      crm-model/src/main/java/com/crm/rely/backend/model/entity/sys/remit/SysRemitChannelListEntity.java
  69. 28 1
      crm-model/src/main/java/com/crm/rely/backend/model/pojo/table/CustomBankTable.java
  70. 11 4
      crm-model/src/main/java/com/crm/rely/backend/model/pojo/table/CustomInfoTable.java
  71. 0 1
      crm-model/src/main/java/com/crm/rely/backend/model/pojo/table/FinanceDepositTable.java
  72. 0 1
      crm-model/src/main/java/com/crm/rely/backend/model/pojo/table/FinanceWithdrawTable.java
  73. 29 0
      crm-model/src/main/java/com/crm/rely/backend/model/pojo/table/GoldenCustomRewardRecordTable.java
  74. 1 0
      crm-model/src/main/java/com/crm/rely/backend/model/pojo/table/GoldenOrderDetailsTable.java
  75. 7 1
      crm-model/src/main/java/com/crm/rely/backend/model/pojo/table/GoldenOrderTable.java
  76. 33 0
      crm-model/src/main/java/com/crm/rely/backend/model/pojo/table/GoldenQuestionCustomTable.java
  77. 163 4
      crm-model/src/main/java/com/crm/rely/backend/model/pojo/view/FinanceWithdrawView.java
  78. 0 52
      crm-model/src/main/java/com/crm/rely/backend/model/pojo/view/GoldenGoodsListView.java
  79. 0 63
      crm-model/src/main/java/com/crm/rely/backend/model/pojo/view/GoldenGoodsVideoListView.java
  80. 0 7
      crm-pay/src/main/java/com/crm/pay/controller/CustomInfoController.java
  81. 421 54
      crm-pay/src/main/java/com/crm/pay/controller/FinanceWithdrawController.java
  82. 3 2
      crm-pay/src/main/java/com/crm/pay/controller/SysRemitChannelController.java
  83. 7 0
      crm-pay/src/main/java/com/crm/pay/dao/mapper/FinanceWithdrawMapper.java
  84. 11 0
      crm-pay/src/main/java/com/crm/pay/dao/mapper/GoldenOrderMapper.java
  85. 1 0
      crm-pay/src/main/java/com/crm/pay/dao/repository/FinanceDepositRepository.java
  86. 4 0
      crm-pay/src/main/java/com/crm/pay/dao/repository/GoldenOrderDetailsRepository.java
  87. 4 0
      crm-pay/src/main/java/com/crm/pay/dao/repository/SysRemitChannelRepository.java
  88. 2 0
      crm-pay/src/main/java/com/crm/pay/entity/FinanceDepositCallbackUpdateEntity.java
  89. 2 14
      crm-pay/src/main/java/com/crm/pay/service/CustomInfoService.java
  90. 43 6
      crm-pay/src/main/java/com/crm/pay/service/FinanceWithdrawService.java
  91. 5 5
      crm-pay/src/main/java/com/crm/pay/service/SysRemitChannelService.java
  92. 16 99
      crm-pay/src/main/java/com/crm/pay/service/impl/CustomInfoServiceImpl.java
  93. 79 14
      crm-pay/src/main/java/com/crm/pay/service/impl/FinanceDepositServiceImpl.java
  94. 2 2
      crm-pay/src/main/java/com/crm/pay/service/impl/FinanceTrainServiceImpl.java
  95. 2 2
      crm-pay/src/main/java/com/crm/pay/service/impl/FinanceTransferServiceImpl.java
  96. 1409 197
      crm-pay/src/main/java/com/crm/pay/service/impl/FinanceWithdrawServiceImpl.java
  97. 109 10
      crm-pay/src/main/java/com/crm/pay/service/impl/SysRemitChannelServiceImpl.java
  98. 5 0
      crm-pay/src/main/java/com/crm/pay/service/impl/base/BasePayServiceImpl.java
  99. 3 3
      crm-pay/src/main/java/com/crm/pay/service/impl/pay/S2sPayServiceImpl.java
  100. 1 1
      crm-pay/src/main/resources/application-dev.yml

+ 10 - 2
crm-custom/src/main/java/com/crm/custom/controller/CustomController.java

@@ -4,7 +4,6 @@ import com.crm.custom.service.CustomInfoService;
 import com.crm.login.rely.backend.controller.BaseLoginController;
 import com.crm.rely.backend.core.constant.*;
 import com.crm.rely.backend.core.dto.base.BaseResultDto;
-import com.crm.rely.backend.model.constant.CustomConstants;
 import com.crm.rely.backend.model.dto.custom.InfoDto;
 import com.crm.rely.backend.model.dto.custom.login.CustomInfoAmountDto;
 import com.crm.rely.backend.model.dto.user.info.UserInfoDto;
@@ -26,6 +25,7 @@ import org.springframework.web.servlet.support.RequestContextUtils;
 
 import javax.servlet.http.HttpServletRequest;
 import javax.servlet.http.HttpServletResponse;
+import java.math.BigDecimal;
 import java.util.Date;
 import java.util.Locale;
 
@@ -79,7 +79,7 @@ public class CustomController extends BaseLoginController {
         entity.setPassword(MD5Util.getMD5(entity.getPassword()));
 
         entity.setValid(1);
-        entity.setStatus(StatusConstants.APPLY_STATUS);
+        entity.setStatus(StatusConstants.PASSED_STATUS);
         //entity.setPosition(CustomConstants.POSITION1);
         customInfoService.add(entity);
 
@@ -375,4 +375,12 @@ public class CustomController extends BaseLoginController {
         }
     }
 
+    @RequestMapping("/get/balance")
+    public BaseResultDto balance(CustomInfoEntity infoEntity) throws Exception {
+
+        BigDecimal balance = customInfoService.getBalance(infoEntity.getId());
+
+        return BaseResultDto.success(balance);
+    }
+
 }

+ 16 - 0
crm-custom/src/main/java/com/crm/custom/controller/GoldenOrderController.java

@@ -2,11 +2,14 @@ package com.crm.custom.controller;
 
 import com.crm.custom.service.GoldenOrderService;
 import com.crm.rely.backend.core.constant.FeignClientAnnotation;
+import com.crm.rely.backend.core.dto.base.BaseResultDto;
 import com.crm.rely.backend.core.dto.base.ResultWithPagerDto;
+import com.crm.rely.backend.core.entity.base.SingleLongEntity;
 import com.crm.rely.backend.model.dto.golden.order.GoldenOrderListDto;
 import com.crm.rely.backend.model.entity.custom.info.CustomInfoEntity;
 import com.crm.rely.backend.model.entity.golden.order.GoldenOrderSearchEntity;
 import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.validation.annotation.Validated;
 import org.springframework.web.bind.annotation.*;
 
 @RestController
@@ -27,10 +30,23 @@ public class GoldenOrderController {
         return goldenOrderService.searchPageList(entity);
     }
 
+    @PostMapping("/cancel")
+    public BaseResultDto cancelOrder(@RequestBody @Validated SingleLongEntity entity) throws Exception {
+        goldenOrderService.cancelOrder(entity.getId());
+        return BaseResultDto.success();
+    }
+
     @PostMapping("/manager/search/list")
     @FeignClientAnnotation
     public ResultWithPagerDto<GoldenOrderListDto> pageList(@RequestBody GoldenOrderSearchEntity entity) throws Exception {
         return goldenOrderService.searchPageList(entity);
     }
 
+    @PostMapping("/manager/cancel")
+    @FeignClientAnnotation
+    public BaseResultDto managerCancelOrder(@RequestBody @Validated SingleLongEntity entity) throws Exception {
+        goldenOrderService.cancelOrder(entity.getId());
+        return BaseResultDto.success();
+    }
+
 }

+ 40 - 4
crm-custom/src/main/java/com/crm/custom/controller/GoldenRewardQuestionController.java

@@ -6,17 +6,22 @@ import com.crm.rely.backend.core.dto.base.BaseResultDto;
 import com.crm.rely.backend.core.dto.base.ResultWithPagerDto;
 import com.crm.rely.backend.core.entity.base.SingleLongEntity;
 import com.crm.rely.backend.model.dto.golden.question.GoldenRewardQuestionListDto;
-import com.crm.rely.backend.model.entity.golden.question.GoldenRewardQuestionAddEntity;
-import com.crm.rely.backend.model.entity.golden.question.GoldenRewardQuestionDeleteEntitys;
-import com.crm.rely.backend.model.entity.golden.question.GoldenRewardQuestionSearchEntity;
-import com.crm.rely.backend.model.entity.golden.question.GoldenRewardQuestionUpdateEntity;
+import com.crm.rely.backend.model.entity.custom.info.CustomInfoEntity;
+import com.crm.rely.backend.model.entity.golden.question.*;
+import com.crm.rely.backend.util.DateUtil;
+import lombok.extern.log4j.Log4j;
 import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.scheduling.annotation.Scheduled;
+import org.springframework.transaction.annotation.Transactional;
 import org.springframework.validation.annotation.Validated;
 import org.springframework.web.bind.annotation.PostMapping;
 import org.springframework.web.bind.annotation.RequestBody;
 import org.springframework.web.bind.annotation.RequestMapping;
 import org.springframework.web.bind.annotation.RestController;
 
+import java.util.Date;
+
+@Log4j
 @RestController
 @RequestMapping("/reward/question")
 public class GoldenRewardQuestionController {
@@ -24,6 +29,18 @@ public class GoldenRewardQuestionController {
     @Autowired
     private GoldenRewardQuestionService goldenRewardQuestionService;
 
+    @PostMapping("/get")
+    public BaseResultDto getQuestion(CustomInfoEntity infoEntity) throws Exception {
+        return BaseResultDto.success(goldenRewardQuestionService.getQuestion(infoEntity.getId()));
+    }
+
+    @PostMapping("/custom/add")
+    public BaseResultDto customAddQuestion(@RequestBody @Validated GoldenQuestionCustomAddEntity entity, CustomInfoEntity infoEntity) throws Exception {
+        entity.setCustomId(infoEntity.getId());
+        goldenRewardQuestionService.customAddQuestion(entity);
+        return BaseResultDto.success();
+    }
+
     @PostMapping("/manager/add")
     @FeignClientAnnotation
     public BaseResultDto add(@RequestBody @Validated GoldenRewardQuestionAddEntity entity) throws Exception {
@@ -58,4 +75,23 @@ public class GoldenRewardQuestionController {
         return BaseResultDto.success(goldenRewardQuestionService.searchSingle(entity));
     }
 
+    @Transactional(rollbackFor = Exception.class)
+    @Scheduled(cron = "0 20 0 * * ?")
+    public void rewardQuestionTask() throws Exception {
+        try {
+            log.info("有奖问答统计任务开始 ---------------");
+            goldenRewardQuestionService.rewardQuestionTask();
+            log.info("有奖问答统计任务结束 ---------------");
+        } catch (Exception e) {
+            log.error(e.getMessage(), e);
+            throw e;
+        }
+    }
+
+    @PostMapping("/rewardQuestionTask")
+    public BaseResultDto rewardQuestionTask(@RequestBody SingleLongEntity entity) throws Exception {
+        goldenRewardQuestionService.rewardQuestionTask();
+        return BaseResultDto.success();
+    }
+
 }

+ 0 - 5
crm-custom/src/main/java/com/crm/custom/dao/mapper/GoldenGoodsMapper.java

@@ -2,22 +2,17 @@ package com.crm.custom.dao.mapper;
 
 import com.crm.rely.backend.model.entity.golden.goods.GoldenGoodsSearchEntity;
 import com.crm.rely.backend.model.pojo.table.GoldenGoodsTable;
-import com.crm.rely.backend.model.pojo.view.GoldenGoodsListView;
 
 import java.util.List;
 
 public interface GoldenGoodsMapper {
 
-    List<GoldenGoodsListView> customPageList(GoldenGoodsSearchEntity entity);
-
     Integer customOrderCount(GoldenGoodsSearchEntity entity);
 
     List<GoldenGoodsTable> customOrderList(GoldenGoodsSearchEntity entity);
 
-
     Integer countList(GoldenGoodsSearchEntity entity);
 
     List<GoldenGoodsTable> pageList(GoldenGoodsSearchEntity entity);
 
-
 }

+ 0 - 5
crm-custom/src/main/java/com/crm/custom/dao/mapper/GoldenGoodsVideoMapper.java

@@ -2,16 +2,11 @@ package com.crm.custom.dao.mapper;
 
 import com.crm.rely.backend.model.entity.golden.goods.GoldenGoodsVideoSearchEntity;
 import com.crm.rely.backend.model.pojo.table.GoldenGoodsVideoTable;
-import com.crm.rely.backend.model.pojo.view.GoldenGoodsVideoListView;
 
 import java.util.List;
 
 public interface GoldenGoodsVideoMapper {
 
-    Integer customCountList(GoldenGoodsVideoSearchEntity entity);
-
-    List<GoldenGoodsVideoListView> customPageList(GoldenGoodsVideoSearchEntity entity);
-
     Integer countList(GoldenGoodsVideoSearchEntity entity);
 
     List<GoldenGoodsVideoTable> pageList(GoldenGoodsVideoSearchEntity entity);

+ 18 - 0
crm-custom/src/main/java/com/crm/custom/dao/mapper/GoldenQuestionCustomMapper.java

@@ -0,0 +1,18 @@
+package com.crm.custom.dao.mapper;
+
+import com.crm.rely.backend.model.entity.golden.question.GoldenRewardQuestionSearchEntity;
+import com.crm.rely.backend.model.pojo.table.GoldenQuestionCustomTable;
+import org.apache.ibatis.annotations.Param;
+
+import java.util.Date;
+import java.util.List;
+
+public interface GoldenQuestionCustomMapper {
+
+    Integer countList(GoldenRewardQuestionSearchEntity entity);
+
+    List<GoldenQuestionCustomTable> pageList(GoldenRewardQuestionSearchEntity entity);
+
+    Integer getCountQuestionByDate(@Param("customId") Long customId, @Param("startDate") Date startDate, @Param("endDate") Date endDate);
+
+}

+ 3 - 0
crm-custom/src/main/java/com/crm/custom/dao/mapper/GoldenRewardQuestionMapper.java

@@ -1,6 +1,7 @@
 package com.crm.custom.dao.mapper;
 
 import com.crm.rely.backend.model.entity.golden.question.GoldenRewardQuestionSearchEntity;
+import com.crm.rely.backend.model.pojo.table.GoldenQuestionCustomTable;
 import com.crm.rely.backend.model.pojo.table.GoldenRewardQuestionTable;
 
 import java.util.List;
@@ -11,4 +12,6 @@ public interface GoldenRewardQuestionMapper {
 
     List<GoldenRewardQuestionTable> pageList(GoldenRewardQuestionSearchEntity entity);
 
+    GoldenRewardQuestionTable getRandQuestion();
+
 }

+ 15 - 0
crm-custom/src/main/java/com/crm/custom/dao/repository/GoldenCustomRewardRecordRepository.java

@@ -0,0 +1,15 @@
+package com.crm.custom.dao.repository;
+
+import com.crm.rely.backend.dao.repository.BaseRepository;
+import com.crm.rely.backend.model.pojo.table.GoldenCustomRewardRecordTable;
+import org.springframework.stereotype.Repository;
+
+import java.util.List;
+
+@Repository
+public interface GoldenCustomRewardRecordRepository extends BaseRepository<GoldenCustomRewardRecordTable> {
+
+    List<GoldenCustomRewardRecordTable> findByStatus(Integer status);
+
+    GoldenCustomRewardRecordTable findFirstByCustomId(Long customId);
+}

+ 18 - 0
crm-custom/src/main/java/com/crm/custom/dao/repository/GoldenOrderRepository.java

@@ -0,0 +1,18 @@
+package com.crm.custom.dao.repository;
+
+import com.crm.rely.backend.dao.repository.BaseRepository;
+import com.crm.rely.backend.model.pojo.table.GoldenGoodsTable;
+import com.crm.rely.backend.model.pojo.table.GoldenOrderTable;
+import org.springframework.data.jpa.repository.Lock;
+import org.springframework.stereotype.Repository;
+
+import javax.persistence.LockModeType;
+import java.util.List;
+
+@Repository
+public interface GoldenOrderRepository extends BaseRepository<GoldenOrderTable> {
+
+    @Lock(LockModeType.PESSIMISTIC_WRITE)
+    GoldenOrderTable findFirstById(Long id);
+
+}

+ 11 - 0
crm-custom/src/main/java/com/crm/custom/dao/repository/GoldenQuestionCustomRepository.java

@@ -0,0 +1,11 @@
+package com.crm.custom.dao.repository;
+
+import com.crm.rely.backend.dao.repository.BaseRepository;
+import com.crm.rely.backend.model.pojo.table.GoldenQuestionCustomTable;
+import org.springframework.stereotype.Repository;
+
+@Repository
+public interface GoldenQuestionCustomRepository extends BaseRepository<GoldenQuestionCustomTable> {
+
+
+}

+ 1 - 16
crm-custom/src/main/java/com/crm/custom/service/CustomInfoService.java

@@ -84,26 +84,11 @@ public interface CustomInfoService {
 
     void updatePosition(Long customId, Integer position) throws ServiceException;
 
-    void updateCnyAmountById(Long customId, BigDecimal cnyAmount) throws ServiceException;
-
-    void updateCnyAmountById(Long customId, BigDecimal cnyAmount, String remarks) throws ServiceException;
-
-    void updateCnyAmountByCId(Long cId, BigDecimal cnyAmount) throws ServiceException;
-
-    void updateCnyAmountByCId(Long cId, BigDecimal cnyAmount, String remarks) throws ServiceException;
-
-    void updateUsdAmountById(Long customId, BigDecimal usdAmount) throws ServiceException;
-
-    void updateUsdAmountById(Long customId, BigDecimal usdAmount, String remarks) throws ServiceException;
-
-    void updateUsdAmountByCId(Long cId, BigDecimal usdAmount) throws ServiceException;
-
-    void updateUsdAmountByCId(Long cId, BigDecimal usdAmount, String remarks) throws ServiceException;
-
     void updateAgentId(CustomInfoUpdateAgentEntity entity) throws ServiceException;
 
     void validPosition(Long customId, Integer position) throws ServiceException;
 
     Integer getPosition(Long customId) throws ServiceException;
 
+    BigDecimal getBalance(Long id) throws ServiceException;
 }

+ 6 - 0
crm-custom/src/main/java/com/crm/custom/service/GoldenGoodsService.java

@@ -9,14 +9,20 @@ import com.crm.rely.backend.model.entity.golden.goods.GoldenGoodsAddEntity;
 import com.crm.rely.backend.model.entity.golden.goods.GoldenGoodsDeleteEntitys;
 import com.crm.rely.backend.model.entity.golden.goods.GoldenGoodsSearchEntity;
 import com.crm.rely.backend.model.entity.golden.goods.GoldenGoodsUpdateEntity;
+import com.crm.rely.backend.model.pojo.table.GoldenGoodsTable;
 import org.springframework.web.multipart.MultipartFile;
 
+import java.util.List;
+import java.util.Map;
+
 public interface GoldenGoodsService {
 
     ResultWithPagerDto<GoldenGoodsListDto> customPageList(GoldenGoodsSearchEntity entity);
 
     ResultWithPagerDto<GoldenGoodsListDto> customOrderList(GoldenGoodsSearchEntity entity );
 
+    Map<Long, GoldenGoodsTable> getCustomOrderGoods(List<Long> goodsIds, Long customId) throws ServiceException;
+
     void add(GoldenGoodsAddEntity entity) throws ServiceException;
 
     void delete(GoldenGoodsDeleteEntitys entitys) throws ServiceException;

+ 1 - 0
crm-custom/src/main/java/com/crm/custom/service/GoldenOrderService.java

@@ -9,4 +9,5 @@ public interface GoldenOrderService {
 
     ResultWithPagerDto<GoldenOrderListDto> searchPageList(GoldenOrderSearchEntity entity) throws ServiceException;
 
+    void cancelOrder(Long id) throws ServiceException;
 }

+ 8 - 5
crm-custom/src/main/java/com/crm/custom/service/GoldenRewardQuestionService.java

@@ -3,14 +3,16 @@ package com.crm.custom.service;
 import com.crm.rely.backend.core.dto.base.ResultWithPagerDto;
 import com.crm.rely.backend.core.entity.base.SingleLongEntity;
 import com.crm.rely.backend.core.exception.ServiceException;
+import com.crm.rely.backend.model.dto.golden.question.GoldenRewardQuestionDto;
 import com.crm.rely.backend.model.dto.golden.question.GoldenRewardQuestionListDto;
-import com.crm.rely.backend.model.entity.golden.question.GoldenRewardQuestionAddEntity;
-import com.crm.rely.backend.model.entity.golden.question.GoldenRewardQuestionDeleteEntitys;
-import com.crm.rely.backend.model.entity.golden.question.GoldenRewardQuestionSearchEntity;
-import com.crm.rely.backend.model.entity.golden.question.GoldenRewardQuestionUpdateEntity;
+import com.crm.rely.backend.model.entity.golden.question.*;
 
 public interface GoldenRewardQuestionService {
 
+    GoldenRewardQuestionDto getQuestion(Long customId) throws Exception;
+
+    void customAddQuestion(GoldenQuestionCustomAddEntity entity) throws Exception;
+
     void add(GoldenRewardQuestionAddEntity entity) throws ServiceException;
 
     void delete(GoldenRewardQuestionDeleteEntitys entitys) throws ServiceException;
@@ -20,5 +22,6 @@ public interface GoldenRewardQuestionService {
     ResultWithPagerDto<GoldenRewardQuestionListDto> searchPageList(GoldenRewardQuestionSearchEntity entity) throws ServiceException;
 
     GoldenRewardQuestionListDto searchSingle(SingleLongEntity entity) throws ServiceException;
-    
+
+    void rewardQuestionTask() throws Exception;
 }

+ 17 - 119
crm-custom/src/main/java/com/crm/custom/service/impl/CustomInfoServiceImpl.java

@@ -1,5 +1,6 @@
 package com.crm.custom.service.impl;
 
+import com.alibaba.fastjson.JSON;
 import com.crm.custom.dao.mapper.CustomFileDao;
 import com.crm.custom.dao.mapper.CustomInfoDao;
 import com.crm.custom.dao.repository.CustomInfoRepository;
@@ -7,9 +8,9 @@ import com.crm.custom.dao.repository.CustomLoginHistoryRepository;
 import com.crm.custom.dao.repository.UserInfoRepository;
 import com.crm.custom.service.*;
 import com.crm.custom.service.impl.base.BaseUploadServiceImpl;
+import com.crm.rely.backend.configuration.DynamicAsync;
 import com.crm.rely.backend.configuration.LocaleMessage;
 import com.crm.rely.backend.core.constant.*;
-import com.crm.rely.backend.core.dto.custom.file.CustomFileDto;
 import com.crm.rely.backend.core.entity.base.LongEntitys;
 import com.crm.rely.backend.core.entity.system.email.SysEmailSendEntity;
 import com.crm.rely.backend.core.entity.web.notice.record.WebNoticeRecordAndEmailMqEntity;
@@ -19,12 +20,10 @@ import com.crm.rely.backend.core.pojo.table.SysConfigTable;
 import com.crm.rely.backend.core.pojo.table.SysCountryTable;
 import com.crm.rely.backend.model.constant.ConfigConstants;
 import com.crm.rely.backend.model.constant.CustomConstants;
-import com.crm.rely.backend.model.constant.PayConstants;
 import com.crm.rely.backend.model.entity.custom.bank.CustomBankAddEntity;
 import com.crm.rely.backend.model.entity.custom.fund.history.CustomFundHistoryAddEntity;
 import com.crm.rely.backend.model.entity.custom.info.*;
 import com.crm.rely.backend.model.entity.user.info.UserInfoEntity;
-import com.crm.rely.backend.model.pojo.table.CustomBankTable;
 import com.crm.rely.backend.model.pojo.table.CustomInfoTable;
 import com.crm.rely.backend.model.pojo.table.UserInfoTable;
 import com.crm.rely.backend.model.util.CustomInfoUtil;
@@ -36,6 +35,7 @@ import com.google.common.base.Strings;
 import lombok.extern.log4j.Log4j;
 import org.springframework.beans.BeanUtils;
 import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.jms.annotation.JmsListener;
 import org.springframework.stereotype.Service;
 import org.springframework.transaction.annotation.Transactional;
 import org.springframework.web.multipart.MultipartFile;
@@ -412,12 +412,12 @@ public class CustomInfoServiceImpl extends BaseUploadServiceImpl implements Cust
         redisService.save(sysEmailSendEntity.getMap().get(MapConstants.TOKEN), customInfoTable.getId(),
                 Constants.EMAIL_TOKEN_TIME * 60 * 1000);
 
-        mqSendService.send(Constants.ACTIVEMQ_JMS_URL_EMAIL, sysEmailSendEntity);
+        mqSendService.send("ACTIVEMQ_JMS_URL_EMAILSS", sysEmailSendEntity);
 
         //系统内部通知
-        WebNoticeRecordAndEmailMqEntity mqEntity = new WebNoticeRecordAndEmailMqEntity(sysEmailSendEntity,
+        /*WebNoticeRecordAndEmailMqEntity mqEntity = new WebNoticeRecordAndEmailMqEntity(sysEmailSendEntity,
                 customInfoTable.getCId(), customInfoTable.getId());
-        mqSendService.send(Constants.WEB_NOTICE_PUT_RECORD, mqEntity);
+        mqSendService.send(Constants.WEB_NOTICE_PUT_RECORD, mqEntity);*/
     }
 
     @Override
@@ -448,118 +448,6 @@ public class CustomInfoServiceImpl extends BaseUploadServiceImpl implements Cust
         sendUpdatePasswordCompleteSendEmailSysEmailEntity(customInfoTable);
     }
 
-    @Override
-    @Transactional(rollbackFor = Exception.class)
-    public void updateCnyAmountById(Long customId, BigDecimal cnyAmount) throws ServiceException {
-        updateCnyAmountById(customId, cnyAmount, null);
-    }
-
-    @Override
-    @Transactional(rollbackFor = Exception.class)
-    public void updateCnyAmountById(Long customId, BigDecimal cnyAmount, String remarks) throws ServiceException {
-        CustomInfoTable customInfoTable = customInfoRepository.findFirstById(customId);
-        if (customInfoTable == null) {
-            return;
-        }
-        BigDecimal amount;
-        if (customInfoTable.getCnyAmount() == null) {
-            amount = BigDecimal.ZERO;
-        } else {
-            amount = customInfoTable.getCnyAmount();
-        }
-        amount = amount.add(cnyAmount);
-        if (cnyAmount.compareTo(BigDecimal.ZERO) < 0 && amount.compareTo(BigDecimal.ZERO) < 0) {
-            throw ServiceException.exception(PayConstants.INSUFFICIENT_FUNDS);
-        }
-        customInfoTable.setCnyAmount(amount);
-        customInfoRepository.save(customInfoTable);
-        addHistory(customInfoTable, 3, cnyAmount, remarks);
-    }
-
-    @Override
-    @Transactional(rollbackFor = Exception.class)
-    public void updateCnyAmountByCId(Long cId, BigDecimal cnyAmount) throws ServiceException {
-        updateCnyAmountByCId(cId, cnyAmount, null);
-    }
-
-    @Override
-    @Transactional(rollbackFor = Exception.class)
-    public void updateCnyAmountByCId(Long cId, BigDecimal cnyAmount, String remarks) throws ServiceException {
-        CustomInfoTable customInfoTable = customInfoRepository.findFirstByCId(cId);
-        if (customInfoTable == null) {
-            return;
-        }
-        BigDecimal amount;
-        if (customInfoTable.getCnyAmount() == null) {
-            amount = BigDecimal.ZERO;
-        } else {
-            amount = customInfoTable.getCnyAmount();
-        }
-        amount = amount.add(cnyAmount);
-        if (cnyAmount.compareTo(BigDecimal.ZERO) < 0 && amount.compareTo(BigDecimal.ZERO) < 0) {
-            throw ServiceException.exception(PayConstants.INSUFFICIENT_FUNDS);
-        }
-        customInfoTable.setCnyAmount(amount);
-        customInfoRepository.save(customInfoTable);
-        addHistory(customInfoTable, 3, cnyAmount, remarks);
-    }
-
-    @Override
-    @Transactional(rollbackFor = Exception.class)
-    public void updateUsdAmountById(Long customId, BigDecimal usdAmount) throws ServiceException {
-        updateUsdAmountById(customId, usdAmount, null);
-    }
-
-    @Override
-    @Transactional(rollbackFor = Exception.class)
-    public void updateUsdAmountById(Long customId, BigDecimal usdAmount, String remarks) throws ServiceException {
-        CustomInfoTable customInfoTable = customInfoRepository.findFirstById(customId);
-        if (customInfoTable == null) {
-            return;
-        }
-        BigDecimal amount;
-        if (customInfoTable.getUsdAmount() == null) {
-            amount = BigDecimal.ZERO;
-        } else {
-            amount = customInfoTable.getUsdAmount();
-        }
-        amount = amount.add(usdAmount);
-        if (usdAmount.compareTo(BigDecimal.ZERO) < 0 && amount.compareTo(BigDecimal.ZERO) < 0) {
-            throw ServiceException.exception(PayConstants.INSUFFICIENT_FUNDS);
-        }
-        customInfoTable.setUsdAmount(amount);
-        customInfoRepository.save(customInfoTable);
-        addHistory(customInfoTable, 2, usdAmount, remarks);
-    }
-
-    @Override
-    @Transactional(rollbackFor = Exception.class)
-    public void updateUsdAmountByCId(Long cId, BigDecimal usdAmount) throws ServiceException {
-        updateUsdAmountByCId(cId, usdAmount, null);
-    }
-
-    @Override
-    @Transactional(rollbackFor = Exception.class)
-    public void updateUsdAmountByCId(Long cId, BigDecimal usdAmount, String remarks) throws ServiceException {
-        CustomInfoTable customInfoTable = customInfoRepository.findFirstByCId(cId);
-        if (customInfoTable == null) {
-            return;
-        }
-        BigDecimal amount;
-        if (customInfoTable.getUsdAmount() == null) {
-            amount = BigDecimal.ZERO;
-        } else {
-            amount = customInfoTable.getUsdAmount();
-        }
-        amount = amount.add(usdAmount);
-        if (usdAmount.compareTo(BigDecimal.ZERO) < 0 && amount.compareTo(BigDecimal.ZERO) < 0) {
-            throw ServiceException.exception(PayConstants.INSUFFICIENT_FUNDS);
-        }
-        customInfoTable.setUsdAmount(amount);
-        customInfoRepository.save(customInfoTable);
-        addHistory(customInfoTable, 2, usdAmount, remarks);
-    }
-
     private void addHistory(CustomInfoTable customInfoTable, Integer sourceType, BigDecimal amount, String remarks) throws ServiceException {
         CustomFundHistoryAddEntity entity = new CustomFundHistoryAddEntity();
         entity.setCustomId(customInfoTable.getId());
@@ -868,7 +756,11 @@ public class CustomInfoServiceImpl extends BaseUploadServiceImpl implements Cust
         sysEmailSendEntity.setAddUser(customInfoTable.getAddUser());
         sysEmailSendEntity.setUsers(entity.getEmail());
         sysEmailSendEntity.setEmailSendEnum(EmailSendEnum.FORGET_PASSWORD);
-        sysEmailSendEntity.setTemplateName(GlobalSystemEmailCodeConstants.CUSTOM_UPDATE_PASSWORD_SEND_CN);
+        if (CountryUtil.isCN(customInfoTable.getCountry())) {
+            sysEmailSendEntity.setTemplateName(GlobalSystemEmailCodeConstants.CUSTOM_UPDATE_PASSWORD_SEND_CN);
+        } else {
+            sysEmailSendEntity.setTemplateName(GlobalSystemEmailCodeConstants.CUSTOM_UPDATE_PASSWORD_SEND_EN);
+        }
         sysEmailSendEntity.setMap(map);
 
         return sysEmailSendEntity;
@@ -992,4 +884,10 @@ public class CustomInfoServiceImpl extends BaseUploadServiceImpl implements Cust
         return customInfoTable.getPosition();
     }
 
+    @Override
+    public BigDecimal getBalance(Long id) throws ServiceException {
+        CustomInfoTable customInfoTable = customInfoRepository.getFirstById(id);
+        return customInfoTable.getBalance() == null ? BigDecimal.ZERO : customInfoTable.getBalance();
+    }
+
 }

+ 2 - 2
crm-custom/src/main/java/com/crm/custom/service/impl/CustomLoginAssetManagementServiceImpl.java

@@ -159,10 +159,10 @@ public class CustomLoginAssetManagementServiceImpl implements CustomLoginAssetMa
         repository.save(table);
 
         //核验通过
-        if (StatusConstants.PASSED_STATUS.equals(entity.getStatus())) {
+        /*if (StatusConstants.PASSED_STATUS.equals(entity.getStatus())) {
             customInfoService.updateCnyAmountByCId(table.getCId(), entity.getAmount(),
                     "资管" + String.valueOf(table.getLogin()) + "核验通过发放");
-        }
+        }*/
         return table;
     }
 

+ 36 - 14
crm-custom/src/main/java/com/crm/custom/service/impl/GoldenGoodsServiceImpl.java

@@ -10,21 +10,18 @@ import com.crm.rely.backend.core.dto.base.ResultWithPagerDto;
 import com.crm.rely.backend.core.entity.base.SingleLongEntity;
 import com.crm.rely.backend.core.exception.ServiceException;
 import com.crm.rely.backend.model.dto.golden.goods.GoldenGoodsListDto;
-import com.crm.rely.backend.model.entity.custom.info.CustomInfoEntity;
 import com.crm.rely.backend.model.entity.golden.goods.GoldenGoodsAddEntity;
 import com.crm.rely.backend.model.entity.golden.goods.GoldenGoodsDeleteEntitys;
 import com.crm.rely.backend.model.entity.golden.goods.GoldenGoodsSearchEntity;
 import com.crm.rely.backend.model.entity.golden.goods.GoldenGoodsUpdateEntity;
 import com.crm.rely.backend.model.pojo.table.GoldenGoodsTable;
-import com.crm.rely.backend.model.pojo.view.GoldenGoodsListView;
 import org.springframework.beans.BeanUtils;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 import org.springframework.transaction.annotation.Transactional;
 import org.springframework.web.multipart.MultipartFile;
 
-import java.util.ArrayList;
-import java.util.List;
+import java.util.*;
 
 @Service
 public class GoldenGoodsServiceImpl extends BaseUploadServiceImpl implements GoldenGoodsService {
@@ -41,32 +38,57 @@ public class GoldenGoodsServiceImpl extends BaseUploadServiceImpl implements Gol
         if (count == null || count <= 0) {
             return ResultWithPagerDto.success(pageDto);
         }
-        List<GoldenGoodsListView> views = mapper.customPageList(entity);
-        if (views == null || views.size() <= 0) {
+
+        List<GoldenGoodsTable> tables = mapper.pageList(entity);
+        if (tables == null || tables.size() <= 0) {
             throw new ServiceException(Constants.SYSTEM_ERROR);
         }
-        List<GoldenGoodsListDto> dtos = new ArrayList<>(views.size());
 
-        for (GoldenGoodsListView view : views) {
-            GoldenGoodsListDto dto = new GoldenGoodsListDto();
-            BeanUtils.copyProperties(view, dto);
+        Map<Long,GoldenGoodsTable> map = new HashMap<>();
+        if (entity.getCustomId() > 0){
+            List<Long> goodsIds = new ArrayList<>();
+            for (GoldenGoodsTable table : tables) {
+                goodsIds.add(table.getId());
+            }
+            map = getCustomOrderGoods(goodsIds,entity.getCustomId());
+        }
+
+        List<GoldenGoodsListDto> dtos = new ArrayList<>(tables.size());
+        for (GoldenGoodsTable table : tables) {
+            GoldenGoodsListDto dto = transformSearchListDto(table);
 
             if (entity.getCustomId() < 0) {
                 dto.setCustomType(0);
             }else{
-                if(view.getCustomId() == null){
-                    dto.setCustomType(1);
-                }else{
+                if(map.containsKey(table.getId())){
                     dto.setCustomType(2);
+                }else{
+                    dto.setCustomType(1);
                 }
             }
-
             dtos.add(dto);
         }
 
         return ResultWithPagerDto.success(pageDto, dtos);
     }
 
+    @Override
+    public Map<Long,GoldenGoodsTable> getCustomOrderGoods(List<Long> goodsIds,Long customId) throws ServiceException {
+
+        GoldenGoodsSearchEntity entity = new GoldenGoodsSearchEntity();
+        entity.setGoodsIds(goodsIds);
+        entity.setCustomId(customId);
+        entity.setPage(null);
+        List<GoldenGoodsTable> tables = mapper.customOrderList(entity);
+
+        Map<Long,GoldenGoodsTable> goodsMap = new HashMap<>();
+        for (GoldenGoodsTable table : tables) {
+            goodsMap.put(table.getId(), table);
+        }
+        return goodsMap;
+
+    }
+
     @Override
     public ResultWithPagerDto<GoldenGoodsListDto> customOrderList(GoldenGoodsSearchEntity entity) {
         Integer count = mapper.customOrderCount(entity);

+ 20 - 15
crm-custom/src/main/java/com/crm/custom/service/impl/GoldenGoodsVideoServiceImpl.java

@@ -3,6 +3,7 @@ package com.crm.custom.service.impl;
 import com.crm.custom.dao.mapper.GoldenGoodsVideoMapper;
 import com.crm.custom.dao.repository.GoldenGoodsRepository;
 import com.crm.custom.dao.repository.GoldenGoodsVideoRepository;
+import com.crm.custom.service.GoldenGoodsService;
 import com.crm.custom.service.GoldenGoodsVideoService;
 import com.crm.custom.service.impl.base.BaseUploadServiceImpl;
 import com.crm.rely.backend.core.constant.Constants;
@@ -18,7 +19,6 @@ import com.crm.rely.backend.model.entity.golden.goods.GoldenGoodsVideoSearchEnti
 import com.crm.rely.backend.model.entity.golden.goods.GoldenGoodsVideoUpdateEntity;
 import com.crm.rely.backend.model.pojo.table.GoldenGoodsTable;
 import com.crm.rely.backend.model.pojo.table.GoldenGoodsVideoTable;
-import com.crm.rely.backend.model.pojo.view.GoldenGoodsVideoListView;
 import org.springframework.beans.BeanUtils;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
@@ -26,7 +26,9 @@ import org.springframework.transaction.annotation.Transactional;
 import org.springframework.web.multipart.MultipartFile;
 
 import java.util.ArrayList;
+import java.util.HashMap;
 import java.util.List;
+import java.util.Map;
 
 @Service
 public class GoldenGoodsVideoServiceImpl extends BaseUploadServiceImpl implements GoldenGoodsVideoService {
@@ -37,31 +39,34 @@ public class GoldenGoodsVideoServiceImpl extends BaseUploadServiceImpl implement
     private GoldenGoodsVideoMapper mapper;
     @Autowired
     private GoldenGoodsRepository goldenGoodsRepository;
+    @Autowired
+    private GoldenGoodsService goldenGoodsService;
 
     @Override
     public ResultWithPagerDto<GoldenGoodsVideoListDto> customPageList(GoldenGoodsVideoSearchEntity entity, CustomInfoEntity infoEntity) throws ServiceException {
-        if (infoEntity == null || infoEntity.getId() == null) {
-            entity.setCustomId(-1l);
-        }else {
-            entity.setCustomId(infoEntity.getId());
-        }
-
-        Integer count = mapper.customCountList(entity);
+        Integer count = mapper.countList(entity);
         PageDto pageDto = PageDto.format(entity, count);
         if (count == null || count <= 0) {
             return ResultWithPagerDto.success(pageDto);
         }
-        List<GoldenGoodsVideoListView> views = mapper.customPageList(entity);
-        if (views == null || views.size() <= 0) {
+        List<GoldenGoodsVideoTable> tables = mapper.pageList(entity);
+        if (tables == null || tables.size() <= 0) {
             throw new ServiceException(Constants.SYSTEM_ERROR);
         }
-        List<GoldenGoodsVideoListDto> dtos = new ArrayList<>(views.size());
 
-        for (GoldenGoodsVideoListView view : views) {
-            GoldenGoodsVideoListDto dto = new GoldenGoodsVideoListDto();
-            BeanUtils.copyProperties(view, dto);
+        Map<Long,GoldenGoodsTable> map = new HashMap<>();
+        if (infoEntity != null || infoEntity.getId() != null) {
+            List<Long> goodsIds = new ArrayList<>();
+            goodsIds.add(entity.getGoodsId());
+            map =  goldenGoodsService.getCustomOrderGoods(goodsIds, infoEntity.getId());
+        }
+
+        List<GoldenGoodsVideoListDto> dtos = new ArrayList<>(tables.size());
+
+        for (GoldenGoodsVideoTable table : tables) {
+            GoldenGoodsVideoListDto dto = transformSearchListDto(table);
 
-            if ((infoEntity != null && infoEntity.getId() != null && view.getCustomId() != null) || view.getPayType() == 0) {
+            if (map.containsKey(table.getGoodsId()) || table.getPayType() == 0) {
                 dto.setPayType(0);
             }else{
                 dto.setFileUrl(null);

+ 21 - 6
crm-custom/src/main/java/com/crm/custom/service/impl/GoldenOrderServiceImpl.java

@@ -1,25 +1,23 @@
 package com.crm.custom.service.impl;
 
 import com.crm.custom.dao.mapper.GoldenOrderMapper;
+import com.crm.custom.dao.repository.GoldenOrderRepository;
 import com.crm.custom.service.GoldenOrderService;
 import com.crm.rely.backend.core.constant.Constants;
 import com.crm.rely.backend.core.dto.base.PageDto;
 import com.crm.rely.backend.core.dto.base.ResultWithPagerDto;
-import com.crm.rely.backend.core.entity.base.SingleLongEntity;
 import com.crm.rely.backend.core.exception.ServiceException;
+import com.crm.rely.backend.model.constant.PayConstants;
 import com.crm.rely.backend.model.dto.golden.order.GoldenOrderDetailsDto;
 import com.crm.rely.backend.model.dto.golden.order.GoldenOrderListDto;
 import com.crm.rely.backend.model.entity.golden.order.GoldenOrderSearchEntity;
-import com.crm.rely.backend.model.pojo.table.GoldenOrderDetailsTable;
 import com.crm.rely.backend.model.pojo.table.GoldenOrderTable;
 import org.springframework.beans.BeanUtils;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
+import org.springframework.transaction.annotation.Transactional;
 
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
+import java.util.*;
 
 @Service
 public class GoldenOrderServiceImpl implements GoldenOrderService {
@@ -27,6 +25,9 @@ public class GoldenOrderServiceImpl implements GoldenOrderService {
     @Autowired
     private GoldenOrderMapper mapper;
 
+    @Autowired
+    private GoldenOrderRepository repository;
+
     @Override
     public ResultWithPagerDto<GoldenOrderListDto> searchPageList(GoldenOrderSearchEntity entity) throws ServiceException {
         Integer count = mapper.countList(entity);
@@ -68,8 +69,22 @@ public class GoldenOrderServiceImpl implements GoldenOrderService {
         return ResultWithPagerDto.success(pageDto, dtos);
     }
 
+    @Override
+    @Transactional(rollbackFor = Exception.class)
+    public void cancelOrder(Long id) throws ServiceException {
+        GoldenOrderTable table = repository.findFirstById(id);
+        if (table == null) {
+            throw ServiceException.exception(Constants.INFO_NOT_FOUND);
+        }
+        if (table.getStatus() != PayConstants.ORDER_UP_PAY_STATUS) {
+            throw ServiceException.exception("cancel_error");
+        }
 
+        table.setStatus(PayConstants.ORDER_PAY_CANCEL_STATUS);
+        table.setModifyTime(new Date());
+        repository.save(table);
 
+    }
 
     private GoldenOrderListDto transformSearchListDto(GoldenOrderTable table) {
         GoldenOrderListDto dto = new GoldenOrderListDto();

+ 126 - 5
crm-custom/src/main/java/com/crm/custom/service/impl/GoldenRewardQuestionServiceImpl.java

@@ -1,27 +1,39 @@
 package com.crm.custom.service.impl;
 
+import com.crm.custom.dao.mapper.GoldenQuestionCustomMapper;
 import com.crm.custom.dao.mapper.GoldenRewardQuestionMapper;
+import com.crm.custom.dao.repository.CustomInfoRepository;
+import com.crm.custom.dao.repository.GoldenCustomRewardRecordRepository;
+import com.crm.custom.dao.repository.GoldenQuestionCustomRepository;
 import com.crm.custom.dao.repository.GoldenRewardQuestionRepository;
 import com.crm.custom.service.GoldenRewardQuestionService;
+import com.crm.custom.service.SysConfigService;
 import com.crm.rely.backend.core.constant.Constants;
 import com.crm.rely.backend.core.dto.base.PageDto;
 import com.crm.rely.backend.core.dto.base.ResultWithPagerDto;
 import com.crm.rely.backend.core.entity.base.SingleLongEntity;
 import com.crm.rely.backend.core.exception.ServiceException;
+import com.crm.rely.backend.core.pojo.table.SysConfigTable;
+import com.crm.rely.backend.model.constant.ConfigConstants;
+import com.crm.rely.backend.model.dto.golden.question.GoldenRewardQuestionDto;
 import com.crm.rely.backend.model.dto.golden.question.GoldenRewardQuestionListDto;
-import com.crm.rely.backend.model.entity.golden.question.GoldenRewardQuestionAddEntity;
-import com.crm.rely.backend.model.entity.golden.question.GoldenRewardQuestionDeleteEntitys;
-import com.crm.rely.backend.model.entity.golden.question.GoldenRewardQuestionSearchEntity;
-import com.crm.rely.backend.model.entity.golden.question.GoldenRewardQuestionUpdateEntity;
-import com.crm.rely.backend.model.pojo.table.GoldenRewardQuestionTable;
+import com.crm.rely.backend.model.entity.golden.question.*;
+import com.crm.rely.backend.model.pojo.table.*;
+import com.crm.rely.backend.util.DateUtil;
+import com.google.common.base.Strings;
+import lombok.extern.log4j.Log4j;
 import org.springframework.beans.BeanUtils;
 import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.jms.annotation.JmsListener;
 import org.springframework.stereotype.Service;
 import org.springframework.transaction.annotation.Transactional;
 
+import java.math.BigDecimal;
 import java.util.ArrayList;
+import java.util.Date;
 import java.util.List;
 
+@Log4j
 @Service
 public class GoldenRewardQuestionServiceImpl implements GoldenRewardQuestionService {
 
@@ -29,6 +41,58 @@ public class GoldenRewardQuestionServiceImpl implements GoldenRewardQuestionServ
     private GoldenRewardQuestionRepository repository;
     @Autowired
     private GoldenRewardQuestionMapper mapper;
+    @Autowired
+    private CustomInfoRepository customInfoRepository;
+    @Autowired
+    private GoldenQuestionCustomMapper goldenQuestionCustomMapper;
+    @Autowired
+    private GoldenQuestionCustomRepository goldenQuestionCustomRepository;
+    @Autowired
+    private GoldenCustomRewardRecordRepository goldenCustomRewardRecordRepository;
+    @Autowired
+    private SysConfigService sysConfigService;
+
+    @Override
+    public GoldenRewardQuestionDto getQuestion(Long customId) throws Exception {
+        GoldenRewardQuestionDto dto = new GoldenRewardQuestionDto();
+        dto.setType(0);
+
+        GoldenCustomRewardRecordTable record = goldenCustomRewardRecordRepository.findFirstByCustomId(customId);
+        if (record != null && record.getStatus() == 1) {
+            Date startDate = DateUtil.getThisWeekMonday(new Date());
+            Date endDate = DateUtil.addDate(startDate,7);
+            Integer count = goldenQuestionCustomMapper.getCountQuestionByDate(customId,startDate,endDate);
+            if (count == null || count <= 0) {
+                GoldenRewardQuestionTable table =  mapper.getRandQuestion();
+                dto.setQuestionId(table.getId());
+                dto.setQuestion(table.getQuestion());
+                dto.setType(1);
+            }
+        }
+
+        return dto;
+    }
+
+    @Override
+    public void customAddQuestion(GoldenQuestionCustomAddEntity entity) throws Exception {
+        Date startDate = DateUtil.getThisWeekMonday(new Date());
+        Date endDate = DateUtil.addDate(startDate,7);
+        Integer count = goldenQuestionCustomMapper.getCountQuestionByDate(entity.getCustomId(),startDate,endDate);
+        if (count != null && count > 0) {
+            throw ServiceException.exception("reward_question_already_exist");
+        }
+
+        GoldenRewardQuestionTable questionTable = repository.getFirstById(entity.getQuestionId());
+        if (questionTable == null) {
+            throw ServiceException.exception(Constants.INFO_NOT_FOUND);
+        }
+
+        GoldenQuestionCustomTable table = new GoldenQuestionCustomTable();
+        BeanUtils.copyProperties(entity, table);
+        table.setQuestion(questionTable.getQuestion());
+        table.setAnswer(questionTable.getAnswer());
+        goldenQuestionCustomRepository.save(table);
+    }
 
     @Override
     @Transactional(rollbackFor = Exception.class)
@@ -96,5 +160,62 @@ public class GoldenRewardQuestionServiceImpl implements GoldenRewardQuestionServ
         return dto;
     }
 
+    @Override
+    @Transactional(rollbackFor = Exception.class)
+    public void rewardQuestionTask() throws Exception {
+        SysConfigTable sysConfigTable =
+                sysConfigService.getByCode(ConfigConstants.CUSTOM_REWARD_QUESTION_AMOUNT);
+        BigDecimal giveAmount = (sysConfigTable == null || sysConfigTable.getValue() == null)
+                ? BigDecimal.ZERO : new BigDecimal(sysConfigTable.getValue());
+
+        List<GoldenCustomRewardRecordTable> list = goldenCustomRewardRecordRepository.findByStatus(1);
+        for (GoldenCustomRewardRecordTable table : list){
+            Date endDate = DateUtil.addDate(table.getStartDate(),180);
+            if(DateUtil.formatDate(new Date()).compareTo(DateUtil.formatDate(endDate)) >= 0){
+                Integer count = goldenQuestionCustomMapper.getCountQuestionByDate(table.getCustomId(),table.getStartDate(),endDate);
+                count = count == null ? 0 : count;
+
+                Integer num = DateUtil.weekBetween(table.getStartDate(),endDate);
+                if( count >= num ){
+                    table.setStatus(2);
+                    table.setGrantStatus(2);
+
+                    CustomInfoTable custom = customInfoRepository.findFirstById(table.getCustomId());
+                    BigDecimal balance = custom.getBalance() == null ? BigDecimal.ZERO : custom.getBalance();
+                    custom.setBalance(balance.add(giveAmount));
+                    customInfoRepository.save(custom);
+                }else{
+                    table.setStatus(3);
+                }
+                table.setModifyTime(new Date());
+
+                goldenCustomRewardRecordRepository.save(table);
+            }
+        }
+
+    }
+
+    public static void main(String[] args) throws Exception {
+        System.out.println(DateUtil.formatDate(DateUtil.addDate(new Date(),-180)));
+    }
+
+    @JmsListener(destination = ConfigConstants.CUSTOM_REWARD_RECORD)
+    @Transactional(rollbackFor = Exception.class)
+    public void addCustomRewardRecord(String content) throws ServiceException {
+        log.info(String.format("CUSTOM_REWARD_RECORD,content:%s", content));
+
+        if (Strings.isNullOrEmpty(content)) {
+            log.error("CUSTOM_REWARD_RECORD,content is null");
+            return;
+        }
+
+        GoldenCustomRewardRecordTable table = new GoldenCustomRewardRecordTable();
+        table.setCustomId(Long.valueOf(content));
+        table.setStartDate(new Date());
+        table.setStatus(1);
+        table.setGrantStatus(1);
+        table.setAddTime(new Date());
+        goldenCustomRewardRecordRepository.save(table);
+    }
 
 }

+ 1 - 1
crm-custom/src/main/resources/application-test.yml

@@ -17,7 +17,7 @@ spring:
 #    host: 47.75.159.72
 #    masterPassword: 123123
 web:
-  upload-path: ..\upload
+  upload-path: ../upload
 eureka:
   client:
     serviceUrl:

+ 3 - 1
crm-custom/src/main/resources/i18n/messages_en_US.properties

@@ -34,4 +34,6 @@ email_expire=email expired
 unsubscribe_failed=Unsubscribe Failed
 unsubscribe_success=Successfully Unsubscribe
 no_repeat_submit_error=Repeat Submit
-login_superior_limit=The number of accounts held has reached the upper limit
+login_superior_limit=The number of accounts held has reached the upper limit
+cancel_error=not cancel
+reward_question_already_exist = The prize winning Q&A has been completed

+ 3 - 1
crm-custom/src/main/resources/i18n/messages_zh_CN.properties

@@ -33,4 +33,6 @@ email_expire=\u90AE\u4EF6\u5DF2\u5931\u6548
 unsubscribe_failed=\u53D6\u6D88\u8BA2\u9605\u5931\u8D25
 unsubscribe_success=\u53D6\u6D88\u8BA2\u9605\u6210\u529F
 no_repeat_submit_error=\u91CD\u590D\u63D0\u4EA4
-login_superior_limit=\u6301\u6709\u8D26\u53F7\u6570\u91CF\u8FBE\u5230\u4E0A\u9650
+login_superior_limit=\u6301\u6709\u8D26\u53F7\u6570\u91CF\u8FBE\u5230\u4E0A\u9650
+cancel_error=不能取消
+reward_question_already_exist = 有奖问答已完成

+ 10 - 23
crm-custom/src/main/resources/mapper/GoldenGoods.xml

@@ -4,32 +4,12 @@
         "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
 <mapper namespace="com.crm.custom.dao.mapper.GoldenGoodsMapper">
 
-    <select id="customPageList" resultType="com.crm.rely.backend.model.pojo.view.GoldenGoodsListView"
-            parameterType="com.crm.rely.backend.model.entity.golden.goods.GoldenGoodsSearchEntity">
-        select goods.*,
-            der.custom_id
-        from golden_goods goods
-        left join golden_order_details der on goods.id = der.goods_id and der.custom_id = #{customId}
-        <where>
-            <if test="goodsName!=null and goodsName!=''">
-                and goods.goods_name like concat('%',#{goodsName},'%')
-            </if>
-            <if test="goodsType!=null">
-                and goods.`goods_type` = #{goodsType}
-            </if>
-        </where>
-        order by goods.id desc
-        <if test="page != null">
-            limit #{page.offset},#{page.row}
-        </if>
-    </select>
-
-
     <select id="customOrderCount" resultType="integer"
             parameterType="com.crm.rely.backend.model.entity.golden.goods.GoldenGoodsSearchEntity">
         select count(*) from golden_goods goods
         left join golden_order_details der on goods.id = der.goods_id
-        where der.custom_id = #{customId}
+        left join golden_order gor on der.serial = gor.serial
+        where gor.status = 2 and der.custom_id = #{customId}
         <if test="goodsType!=null">
             and goods.`goods_type` = #{goodsType}
         </if>
@@ -40,10 +20,17 @@
         select goods.*
         from golden_goods goods
         left join golden_order_details der on goods.id = der.goods_id
-        where der.custom_id = #{customId}
+        left join golden_order gor on der.serial = gor.serial
+        where gor.status = 2 and der.custom_id = #{customId}
         <if test="goodsType!=null">
             and goods.`goods_type` = #{goodsType}
         </if>
+        <if test="goodsIds!=null and goodsIds.size()>0">
+            and goods.id in
+            <foreach collection="goodsIds" index="index" item="item" open="(" separator="," close=")">
+                #{item}
+            </foreach>
+        </if>
         order by der.id desc
         <if test="page != null">
             limit #{page.offset},#{page.row}

+ 0 - 27
crm-custom/src/main/resources/mapper/GoldenGoodsVideo.xml

@@ -4,33 +4,6 @@
         "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
 <mapper namespace="com.crm.custom.dao.mapper.GoldenGoodsVideoMapper">
 
-    <select id="customCountList" resultType="integer"
-            parameterType="com.crm.rely.backend.model.entity.golden.goods.GoldenGoodsVideoSearchEntity">
-        select count(*) from golden_goods_video video
-        left join golden_order_details der on video.goods_id = der.goods_id and der.custom_id = #{customId}
-        where video.goods_id = #{goodsId}
-        <if test="videoName!=null and videoName!=''">
-            and video.video_name like concat('%',#{videoName},'%')
-        </if>
-    </select>
-
-    <select id="customPageList" resultType="com.crm.rely.backend.model.pojo.view.GoldenGoodsVideoListView"
-            parameterType="com.crm.rely.backend.model.entity.golden.goods.GoldenGoodsVideoSearchEntity">
-        select video.id,video.goods_id,video_name,title,
-               file_type,front_url,pay_type,sort,
-               der.custom_id
-        from golden_goods_video video
-        left join golden_order_details der on video.goods_id = der.goods_id and der.custom_id = #{customId}
-        where video.goods_id = #{goodsId}
-        <if test="videoName!=null and videoName!=''">
-            and video.video_name like concat('%',#{videoName},'%')
-        </if>
-        order by video.sort asc
-        <if test="page != null">
-            limit #{page.offset},#{page.row}
-        </if>
-    </select>
-
     <select id="countList" resultType="integer"
             parameterType="com.crm.rely.backend.model.entity.golden.goods.GoldenGoodsVideoSearchEntity">
         select count(*) from golden_goods_video

+ 0 - 1
crm-custom/src/main/resources/mapper/GoldenOrder.xml

@@ -41,7 +41,6 @@
         <foreach collection="serialList" index="index" item="item" open="(" separator="," close=")">
             #{item}
         </foreach>
-        FOR UPDATE
     </select>
 
 </mapper>

+ 37 - 0
crm-custom/src/main/resources/mapper/GoldenQuestionCustomMapper.xml

@@ -0,0 +1,37 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE mapper
+        PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
+        "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
+<mapper namespace="com.crm.custom.dao.mapper.GoldenQuestionCustomMapper">
+
+    <select id="countList" resultType="integer"
+            parameterType="com.crm.rely.backend.model.entity.golden.question.GoldenRewardQuestionSearchEntity">
+        select count(*) from golden_question_custom
+        <where>
+            <if test="question!=null and question!=''">
+                and question like concat('%',#{question},'%')
+            </if>
+        </where>
+    </select>
+
+    <select id="pageList" resultType="com.crm.rely.backend.model.pojo.table.GoldenQuestionCustomTable"
+            parameterType="com.crm.rely.backend.model.entity.golden.question.GoldenRewardQuestionSearchEntity">
+        select * from golden_question_custom
+        <where>
+            <if test="question!=null and question!=''">
+                and question like concat('%',#{question},'%')
+            </if>
+        </where>
+        order by id desc
+        <if test="page != null">
+            limit #{page.offset},#{page.row}
+        </if>
+    </select>
+
+    <select id="getCountQuestionByDate" resultType="integer">
+        select * from golden_question_custom
+        where custom_id = #{customId} and add_time <![CDATA[ >= ]]> #{startDate} and add_time <![CDATA[ < ]]> #{endDate}
+        limit 1
+    </select>
+
+</mapper>

+ 4 - 0
crm-custom/src/main/resources/mapper/GoldenRewardQuestionMapper.xml

@@ -28,4 +28,8 @@
         </if>
     </select>
 
+    <select id="getRandQuestion" resultType="com.crm.rely.backend.model.pojo.table.GoldenRewardQuestionTable">
+        select * from golden_reward_question ORDER BY RAND() LIMIT 1
+    </select>
+
 </mapper>

+ 0 - 6
crm-manager/src/main/java/com/crm/manager/controller/CustomInfoController.java

@@ -240,12 +240,6 @@ public class CustomInfoController {
         return customInfoService.getPageList(entity);
     }
 
-
-    @PostMapping("/funds")
-    public BaseResultDto funds(@RequestBody @Validated CustomInfoFundsEntity entity) throws Exception {
-
-        return financeCustomFeignService.funds(entity);
-    }
     private void validSortName(String sortName) {
         if (!Strings.isNullOrEmpty(sortName)) {
             List<String> tableFields = new ArrayList<>(10);

+ 251 - 16
crm-manager/src/main/java/com/crm/manager/controller/FinanceWithdrawController.java

@@ -1,22 +1,33 @@
 package com.crm.manager.controller;
 
+import com.crm.manager.dto.export.FinanceWithdrawExportDto;
+import com.crm.manager.service.FinanceWithdrawApiFeignService;
 import com.crm.manager.service.FinanceWithdrawFeignService;
 import com.crm.rely.backend.core.constant.Constants;
-import com.crm.rely.backend.core.constant.StatusConstants;
 import com.crm.rely.backend.core.dto.base.BaseResultDto;
 import com.crm.rely.backend.core.dto.base.ResultWithPagerDto;
 import com.crm.rely.backend.core.entity.base.SingleLongEntity;
+import com.crm.rely.backend.model.constant.PayConstants;
 import com.crm.rely.backend.model.dto.finance.withdraw.FinanceWithdrawDto;
-import com.crm.rely.backend.model.entity.finance.withdraw.FinanceWithdrawApproveEntity;
-import com.crm.rely.backend.model.entity.finance.withdraw.FinanceWithdrawDeleteEntity;
-import com.crm.rely.backend.model.entity.finance.withdraw.FinanceWithdrawSearchListEntity;
+import com.crm.rely.backend.model.entity.finance.withdraw.*;
+import com.crm.rely.backend.util.ExportUtil;
+import com.crm.rely.backend.util.FileProcessUtil;
+import com.google.common.base.Strings;
+import com.google.common.collect.Lists;
+import org.springframework.beans.BeanUtils;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.validation.annotation.Validated;
-import org.springframework.web.bind.annotation.PostMapping;
-import org.springframework.web.bind.annotation.RequestBody;
-import org.springframework.web.bind.annotation.RequestMapping;
-import org.springframework.web.bind.annotation.RestController;
+import org.springframework.web.bind.annotation.*;
 
+import javax.servlet.http.HttpServletResponse;
+import java.text.SimpleDateFormat;
+import java.util.*;
+
+/**
+ * @description: 出金
+ * @author: houn
+ * @create: 2020-07-07 18:01
+ **/
 @RestController
 @RequestMapping("/finance/withdraw")
 public class FinanceWithdrawController {
@@ -24,32 +35,256 @@ public class FinanceWithdrawController {
     @Autowired
     private FinanceWithdrawFeignService financeWithdrawFeignService;
 
+    @Autowired
+    private FinanceWithdrawApiFeignService financeWithdrawApiFeignService;
+
     @PostMapping("/approve")
     public BaseResultDto approve(@RequestBody @Validated FinanceWithdrawApproveEntity entity) throws Exception {
-        if (!StatusConstants.PASSED_STATUS.equals(entity.getStatus()) && !StatusConstants.REJECTED_STATUS.equals(entity.getStatus())) {
+        if (!PayConstants.PASSED_STATUS.equals(entity.getStatus()) && !PayConstants.REJECTED_STATUS.equals(entity.getStatus())) {
             return BaseResultDto.error(Constants.NOT_PERMIT);
         }
+        if (PayConstants.PASSED_STATUS.equals(entity.getStatus())) {
+            entity.setWithdrawStatus(PayConstants.MANAGER_PROCESSING_STATUS);
+        } else {
+            entity.setWithdrawStatus(PayConstants.MANAGER_PENDING_STATUS);
+        }
+        entity.setOperationType(PayConstants.OPERATION_TYPE_MANUAL);
 
         return financeWithdrawFeignService.approve(entity);
     }
 
+
+    @PostMapping("/approve/manager")
+    public BaseResultDto approveByManager(@RequestBody @Validated FinanceWithdrawApproveManagerEntity entity) throws Exception {
+
+        return financeWithdrawFeignService.approveByManager(entity);
+    }
+
+    @PostMapping("/sales/approve")
+    public BaseResultDto approveBySales(@RequestBody @Validated FinanceWithdrawApproveSalesEntity entity) throws Exception {
+        if (!PayConstants.PASSED_STATUS.equals(entity.getStatus()) && !PayConstants.REJECTED_STATUS.equals(entity.getStatus())) {
+            return BaseResultDto.error(Constants.NOT_PERMIT);
+        }
+        return financeWithdrawFeignService.approveBySales(entity);
+    }
+
+    @PostMapping("/approve/backstage")
+    public BaseResultDto approveByBackstage(@RequestBody @Validated FinanceWithdrawApproveBackstageEntity entity) throws Exception {
+
+
+        return financeWithdrawFeignService.approveByBackstage(entity);
+    }
+
+    @PostMapping("/approve/info")
+    public BaseResultDto approveByInfo(@RequestBody @Validated FinanceWithdrawApproveInfoEntity entity) throws Exception {
+
+
+        return financeWithdrawFeignService.approveByInfo(entity);
+    }
+
+    @PostMapping("/approve/infos")
+    public BaseResultDto approveByInfos(@RequestBody @Validated FinanceWithdrawApproveInfosEntity entity) throws Exception {
+        return financeWithdrawFeignService.approveByInfos(entity);
+    }
+
+    @PostMapping("/approve/submit/channel")
+    public BaseResultDto approveByManager(@RequestBody @Validated FinanceWithdrawApproveChannelSubmitEntity entity) throws Exception {
+
+
+        return financeWithdrawFeignService.approveBySubmit(entity);
+    }
+
+    @PostMapping("/approve/channel")
+    public BaseResultDto approveByManager(@RequestBody @Validated FinanceWithdrawApproveChannelEntity entity) throws Exception {
+
+        return financeWithdrawFeignService.approveByChannel(entity);
+    }
+
+    @PostMapping("/approve/submits/channel")
+    public BaseResultDto approveByChannelSubmits(@RequestBody @Validated FinanceWithdrawApproveChannelSubmitsEntity entity) throws Exception {
+
+
+        return financeWithdrawFeignService.approveBySubmits(entity);
+    }
+
+    @PostMapping("/approve/channels")
+    public BaseResultDto approveByChannel(@RequestBody @Validated FinanceWithdrawApproveChannelsEntity entity) throws Exception {
+
+        return financeWithdrawFeignService.approveByChannels(entity);
+    }
+
     @PostMapping("/delete")
     public BaseResultDto delete(@RequestBody @Validated FinanceWithdrawDeleteEntity entity) throws Exception {
 
         return financeWithdrawFeignService.delete(entity);
     }
 
-    @PostMapping("/search/list")
-    public BaseResultDto searchList(@RequestBody @Validated FinanceWithdrawSearchListEntity entity) throws Exception {
-
-        ResultWithPagerDto<FinanceWithdrawDto> resultWithPagerDto = financeWithdrawFeignService.searchList(entity);
+    @PostMapping("/searcher/list")
+    public BaseResultDto searcherList(@RequestBody @Validated FinanceWithdrawSearchListEntity entity) throws Exception {
+        entity.setCom(1);
+        ResultWithPagerDto<FinanceWithdrawDto> resultWithPagerDto = financeWithdrawFeignService.searcherList(entity);
         return resultWithPagerDto;
     }
 
-    @PostMapping("/search/single")
-    public BaseResultDto searchSingle(@RequestBody @Validated SingleLongEntity entity) throws Exception {
-        BaseResultDto<FinanceWithdrawDto> resultDto = financeWithdrawFeignService.searchSingle(entity);
+    @GetMapping("/searcher/list/export")
+    public void searcherListExport(@RequestParam(name = "startDate") String startDate,
+                                   @RequestParam(name = "endDate") String endDate,
+                                   @RequestParam(name = "cId") Long cId,
+                                   @RequestParam(name = "status") Integer status,
+                                   @RequestParam(name = "login") Long login,
+                                   @RequestParam(name = "channelCodes") String channelCodes,
+                                   @RequestParam(name = "mtStatus") Integer mtStatus,
+                                   @RequestParam(name = "submitStatus") Integer submitStatus,
+                                   @RequestParam(name = "startSubmitDate") String startSubmitDate,
+                                   @RequestParam(name = "endSubmitDate") String endSubmitDate,
+                                   @RequestParam(name = "backstageStatus") Integer backstageStatus,
+                                   @RequestParam(name = "infoStatus") Integer infoStatus,
+                                   @RequestParam(name = "salaryLogin") Integer salaryLogin,
+                                   @RequestParam(name = "country") String country,
+                                   @RequestParam(name = "serial") String serial,
+                                   @RequestParam(name = "pIbNo", required = false) String pIbNo,
+                                   @RequestParam(name = "name", required = false) String name,
+                                   HttpServletResponse response) throws Exception {
+
+        FinanceWithdrawSearchListEntity entity = new FinanceAgentWithdrawSearchListEntity();
+        entity.setCom(1);
+        SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyyMMdd");
+        entity.setStartDate(Strings.isNullOrEmpty(startDate) ? new Date() : simpleDateFormat.parse(startDate));
+        entity.setEndDate(Strings.isNullOrEmpty(endDate) ? new Date() : simpleDateFormat.parse(endDate));
+        entity.setCId(cId);
+        entity.setStatus(status);
+        entity.setLogin(login);
+        if (Strings.isNullOrEmpty(channelCodes)) {
+            entity.setChannelCodes(null);
+        } else {
+
+            entity.setChannelCodes(Arrays.asList(channelCodes.split(",")));
+        }
+        entity.setMtStatus(mtStatus);
+        entity.setSubmitStatus(submitStatus);
+        entity.setBackstageStatus(backstageStatus);
+        entity.setInfoStatus(infoStatus);
+        entity.setSalaryLogin(salaryLogin);
+        entity.setCountry(country);
+        entity.setSerial(serial);
+        entity.setPIbNo(pIbNo);
+        entity.setName(name);
+
+        if ("undefinedundefined".equals(startSubmitDate)) {
+            startSubmitDate = null;
+        }
+        if ("undefinedundefined".equals(endSubmitDate)) {
+            endSubmitDate = null;
+        }
+
+        entity.setStartSubmitDate(Strings.isNullOrEmpty(startSubmitDate) ? null :
+                simpleDateFormat.parse(startSubmitDate));
+        entity.setEndSubmitDate(Strings.isNullOrEmpty(endSubmitDate) ? null : simpleDateFormat.parse(endSubmitDate));
+
+        BaseResultDto<List<FinanceWithdrawDto>> resultDto = financeWithdrawFeignService.searcherListExport(entity);
+        if (resultDto.getCode() == Constants.SUCCESS_CODE) {
+            List<FinanceWithdrawExportDto> exportDtos = setExport(resultDto.getData());
+            ExportUtil.transferToResponse(FileProcessUtil.genExportFileName("CUSTOM_WITHDRAWAL_EXPORT"), exportDtos,
+                    FinanceWithdrawExportDto.class, response);
+        }
+    }
+
+    @GetMapping("/searcher/list/export/ids")
+    public void searcherListExport(@RequestParam(name = "ids") String ids,
+                                   HttpServletResponse response) throws Exception {
+
+        FinanceWithdrawSearchByIdsEntity entity = new FinanceWithdrawSearchByIdsEntity();
+
+        List<String> withdrawIdsString = Arrays.asList(ids.split(","));
+
+        List<Long> withdrawIds = new ArrayList<>(withdrawIdsString.size());
+        for (String s : withdrawIdsString) {
+            withdrawIds.add(Long.valueOf(s));
+        }
+
+        entity.setIds(withdrawIds);
+
+        BaseResultDto<List<FinanceWithdrawDto>> resultDto = financeWithdrawFeignService.searcherByIdsExport(entity);
+        if (resultDto.getCode() == Constants.SUCCESS_CODE) {
+            List<FinanceWithdrawExportDto> exportDtos = setExport(resultDto.getData());
+            ExportUtil.transferToResponse(FileProcessUtil.genExportFileName("CUSTOM_WITHDRAWAL_EXPORT"), exportDtos,
+                    FinanceWithdrawExportDto.class, response);
+        }
+    }
+
+    @PostMapping("/searcher/single")
+    public BaseResultDto searcherSingle(@RequestBody @Validated SingleLongEntity entity) throws Exception {
+        BaseResultDto<FinanceWithdrawDto> resultDto = financeWithdrawFeignService.searcherSingle(entity);
         return resultDto;
     }
 
+    private List<FinanceWithdrawExportDto> setExport(List<FinanceWithdrawDto> dtos) {
+        List<FinanceWithdrawExportDto> exportDtos = Lists.newArrayList();
+        dtos.forEach((item) -> {
+            FinanceWithdrawExportDto exportDto = new FinanceWithdrawExportDto();
+            BeanUtils.copyProperties(item, exportDto);
+            exportDto.setInfoStatusName("--");
+
+            if (PayConstants.APPLY_STATUS.equals(item.getBackstageStatus())) {
+                exportDto.setBackstageStatusName("未处理");
+            } else if (PayConstants.PASSED_STATUS.equals(item.getBackstageStatus())) {
+                exportDto.setBackstageStatusName("已通过");
+            } else if (PayConstants.REJECTED_STATUS.equals(item.getBackstageStatus())) {
+                exportDto.setBackstageStatusName("已拒绝");
+            }
+            if (item.getFeeReduction() == null) {
+                exportDto.setFeeReductionName("--");
+            } else if (item.getFeeReduction() == 0) {
+                exportDto.setFeeReductionName("否");
+            } else if (item.getFeeReduction() == 1) {
+                exportDto.setFeeReductionName("是");
+            }
+
+            if (PayConstants.PASSED_STATUS.equals(item.getInfoStatus())) {
+                exportDto.setInfoStatusName("已通过");
+            } else if (PayConstants.REJECTED_STATUS.equals(item.getInfoStatus())) {
+                exportDto.setInfoStatusName("已拒绝");
+            }
+
+            if (PayConstants.APPLY_STATUS.equals(item.getSubmitStatus())) {
+                exportDto.setSubmitStatusName("未处理");
+            } else if (PayConstants.PASSED_STATUS.equals(item.getSubmitStatus())) {
+
+                exportDto.setInfoStatusName("已通过");
+                exportDto.setSubmitStatusName("已提交");
+            } else if (PayConstants.REJECTED_STATUS.equals(item.getSubmitStatus())) {
+                exportDto.setSubmitStatusName("已拒绝");
+            }
+
+            if (item.getFeeAmount() != null && item.getFeeReductionAmount() != null) {
+                exportDto.setActualFeeAmount(item.getFeeAmount().subtract(item.getFeeReductionAmount()));
+            } else {
+                exportDto.setActualFeeAmount(null);
+            }
+
+            if (item.getSalaryLogin() == null) {
+                exportDto.setSalaryLogin("NO");
+            } else {
+                exportDto.setSalaryLogin("YES");
+            }
+            exportDto.setPibNo(item.getPIbNo());
+            exportDtos.add(exportDto);
+        });
+        return exportDtos;
+    }
+
+    @RequestMapping("/remit/channel")
+    public BaseResultDto remitChannel() throws Exception {
+        return financeWithdrawFeignService.remitChannel();
+    }
+
+    @RequestMapping("/withdrawapi")
+    public BaseResultDto withdraw(@RequestBody Map<String, Object> params) throws Exception {
+        String contextPath = params.get("withdrawUrl").toString();
+
+        params.put("withdrawInfoType", 1);
+        return financeWithdrawApiFeignService.withdraw(contextPath, params);
+
+    }
+
 }

+ 112 - 0
crm-manager/src/main/java/com/crm/manager/dto/export/FinanceWithdrawExportDto.java

@@ -0,0 +1,112 @@
+package com.crm.manager.dto.export;
+
+import com.alibaba.excel.annotation.ExcelProperty;
+import com.alibaba.excel.metadata.BaseRowModel;
+import lombok.Data;
+
+import java.math.BigDecimal;
+import java.util.Date;
+
+@Data
+public class FinanceWithdrawExportDto extends BaseRowModel {
+
+    @ExcelProperty(value = "交易账号")
+    private Long login;
+    @ExcelProperty(value = "归属编号")
+    private String pibNo;
+
+    @ExcelProperty(value = "是否工资账户")
+    private String salaryLogin;
+    @ExcelProperty(value = "取款金额")
+    private BigDecimal amount;
+
+
+    /**
+     * 出金实际金额
+     */
+    @ExcelProperty(value = "汇款金额")
+    private BigDecimal transformAmount;
+    /**
+     * 出金实际货币类型
+     */
+    @ExcelProperty(value = "汇款货币")
+    private String transformCurrency;
+
+    @ExcelProperty(value = "汇款汇率")
+    private BigDecimal rate;
+
+    @ExcelProperty(value = "是否手续费减免")
+    private String feeReductionName;
+
+    @ExcelProperty(value = "手续费金额")
+    private BigDecimal feeAmount;
+
+    @ExcelProperty(value = "减免金额")
+    private BigDecimal feeReductionAmount;
+    @ExcelProperty(value = "实收手续费金额")
+    private BigDecimal actualFeeAmount;
+
+    @ExcelProperty(value = "银行户名")
+    private String bankUname;
+    @ExcelProperty(value = "银行名称")
+    private String bankName;
+    @ExcelProperty(value = "开户支行")
+    private String bankBranchName;
+    @ExcelProperty(value = "银行账户")
+    private String bankCardNum;
+    @ExcelProperty(value = "取款方式")
+    private String bankCode;
+
+    @ExcelProperty(value = "地址")
+    private String address;
+
+    @ExcelProperty(value = "swiftCode")
+    private String swiftCode;
+
+
+    @ExcelProperty(value = "当前状态")
+    private String statusName;
+    @ExcelProperty(value = "区号")
+    private String areaCode;
+    @ExcelProperty(value = "手机号码")
+    private String phone;
+
+
+    @ExcelProperty(value = "通道名称")
+    private String remitChannelName;
+
+    @ExcelProperty(value = "后台审核状态")
+    private String backstageStatusName;
+
+
+    @ExcelProperty(value = "资料核验状态")
+    private String infoStatusName;
+
+    @ExcelProperty(value = "提交状态(三方)")
+    private String submitStatusName;
+
+    @ExcelProperty(value = "提交时间(三方)", format = "yyyy-MM-dd HH:mm:ss")
+    private Date submitTime;
+
+    @ExcelProperty(value = "销售编号")
+    private String salesNo;
+    @ExcelProperty(value = "平台")
+    private String platform;
+
+    @ExcelProperty(value = "流水号")
+    private String serial;
+    @ExcelProperty(value = "姓名")
+    private String name;
+
+
+    @ExcelProperty(value = "出金申请时间", format = "yyyy-MM-dd HH:mm:ss")
+    private Date addTime;
+
+
+    @ExcelProperty(value = "回调/确认回执时间(三方)", format = "yyyy-MM-dd HH:mm:ss")
+    private Date callbackTime;
+
+
+    @ExcelProperty(value = "备注")
+    private String approveDesc;
+}

+ 18 - 0
crm-manager/src/main/java/com/crm/manager/service/FinanceWithdrawApiFeignService.java

@@ -0,0 +1,18 @@
+package com.crm.manager.service;
+
+import com.crm.rely.backend.core.dto.base.BaseResultDto;
+import com.crm.rely.backend.model.entity.finance.withdraw.FinanceWithdrawInfoEntity;
+import org.springframework.cloud.netflix.feign.FeignClient;
+import org.springframework.web.bind.annotation.PathVariable;
+import org.springframework.web.bind.annotation.PostMapping;
+
+@FeignClient(name = "GOLDEN-PAY-SERVICE")
+public interface FinanceWithdrawApiFeignService {
+
+    @PostMapping(value = "/{contextPath}")
+    BaseResultDto withdrawInfo(@PathVariable(name = "contextPath") String contextPath,
+                               FinanceWithdrawInfoEntity entity);
+
+    @PostMapping(value = "/{contextPath}")
+    BaseResultDto withdraw(@PathVariable(name = "contextPath") String contextPath, Object entity);
+}

+ 45 - 6
crm-manager/src/main/java/com/crm/manager/service/FinanceWithdrawFeignService.java

@@ -4,26 +4,65 @@ import com.crm.rely.backend.core.dto.base.BaseResultDto;
 import com.crm.rely.backend.core.dto.base.ResultWithPagerDto;
 import com.crm.rely.backend.core.entity.base.SingleLongEntity;
 import com.crm.rely.backend.model.dto.finance.withdraw.FinanceWithdrawDto;
-import com.crm.rely.backend.model.entity.finance.withdraw.FinanceWithdrawApproveEntity;
-import com.crm.rely.backend.model.entity.finance.withdraw.FinanceWithdrawDeleteEntity;
-import com.crm.rely.backend.model.entity.finance.withdraw.FinanceWithdrawSearchListEntity;
+import com.crm.rely.backend.model.entity.finance.withdraw.*;
 import org.springframework.cloud.netflix.feign.FeignClient;
 import org.springframework.validation.annotation.Validated;
 import org.springframework.web.bind.annotation.PostMapping;
 import org.springframework.web.bind.annotation.RequestBody;
 
+import java.util.List;
+
 @FeignClient(name = "GOLDEN-PAY-SERVICE", path = "/withdraw/manager")
 public interface FinanceWithdrawFeignService {
 
+
     @PostMapping("/approve")
     BaseResultDto approve(@RequestBody @Validated FinanceWithdrawApproveEntity entity) throws Exception;
 
+    @PostMapping("/sales/approve")
+    BaseResultDto approveBySales(@RequestBody @Validated FinanceWithdrawApproveSalesEntity entity) throws Exception;
+
+    @PostMapping("/approve/manager")
+    BaseResultDto approveByManager(@RequestBody @Validated FinanceWithdrawApproveManagerEntity entity) throws Exception;
+
+    @PostMapping("/approve/backstage")
+    BaseResultDto approveByBackstage(@RequestBody @Validated FinanceWithdrawApproveBackstageEntity entity) throws Exception;
+
+    @PostMapping("/approve/info")
+    BaseResultDto approveByInfo(@RequestBody @Validated FinanceWithdrawApproveInfoEntity entity) throws Exception;
+
+    @PostMapping("/approve/infos")
+    BaseResultDto approveByInfos(@RequestBody @Validated FinanceWithdrawApproveInfosEntity entity) throws Exception;
+
+    @PostMapping("/approve/submit/channel")
+    BaseResultDto approveBySubmit(@RequestBody @Validated FinanceWithdrawApproveChannelSubmitEntity entity) throws Exception;
+
+    @PostMapping("/approve/channel")
+    BaseResultDto approveByChannel(@RequestBody @Validated FinanceWithdrawApproveChannelEntity entity) throws Exception;
+
+
+    @PostMapping("/approve/submits/channel")
+    BaseResultDto approveBySubmits(@RequestBody @Validated FinanceWithdrawApproveChannelSubmitsEntity entity) throws Exception;
+
+    @PostMapping("/approve/channels")
+    BaseResultDto approveByChannels(@RequestBody @Validated FinanceWithdrawApproveChannelsEntity entity) throws Exception;
+
     @PostMapping("/delete")
     BaseResultDto delete(@RequestBody @Validated FinanceWithdrawDeleteEntity entity) throws Exception;
 
-    @PostMapping("/search/list")
-    ResultWithPagerDto<FinanceWithdrawDto> searchList(@RequestBody @Validated FinanceWithdrawSearchListEntity entity) throws Exception;
+    @PostMapping("/searcher/list")
+    ResultWithPagerDto<FinanceWithdrawDto> searcherList(@RequestBody @Validated FinanceWithdrawSearchListEntity entity) throws Exception;
+
+    @PostMapping("/searcher/list/export")
+    BaseResultDto<List<FinanceWithdrawDto>> searcherListExport(FinanceWithdrawSearchListEntity entity) throws Exception;
+
+    @PostMapping("/export/ids")
+    BaseResultDto<List<FinanceWithdrawDto>> searcherByIdsExport(FinanceWithdrawSearchByIdsEntity entity) throws Exception;
 
     @PostMapping("/searcher/single")
-    BaseResultDto<FinanceWithdrawDto> searchSingle(@RequestBody @Validated SingleLongEntity entity) throws Exception;
+    BaseResultDto<FinanceWithdrawDto> searcherSingle(@RequestBody @Validated SingleLongEntity entity) throws Exception;
+
+    @PostMapping(value = "/remit/channel")
+    BaseResultDto remitChannel();
+
 }

+ 1 - 1
crm-manager/src/main/resources/application-test.yml

@@ -22,7 +22,7 @@ eureka:
 login:
   single-sign-on: true
 web:
-  upload-path: ..\upload
+  upload-path: ../upload
   export-path: C:\server\cwg_crm\export
 ribbon:
   ReadTimeout: 60000

+ 10 - 0
crm-model/src/main/java/com/crm/rely/backend/model/constant/ConfigConstants.java

@@ -44,4 +44,14 @@ public class ConfigConstants {
 
     public static final String CHANNEL_BANK_RATE = "CHANNEL_BANK_RATE";
 
+    public static final String FINANCE_WITHDRAW_MAX = "FINANCE_WITHDRAW_MAX";
+    public static final String FINANCE_WITHDRAW_MIN = "FINANCE_WITHDRAW_MIN";
+    public static final String FINANCE_WITHDRAW_NUMBER_LIMIT = "FINANCE_WITHDRAW_NUMBER_LIMIT";
+    public static final String FINANCE_WITHDRAW_FEE_REDUCTION_NUMBER = "FINANCE_WITHDRAW_FEE_REDUCTION_NUMBER";
+
+    public static final String CUSTOM_REWARD_RECORD = "CUSTOM_REWARD_RECORD";
+    public static final String CUSTOM_REWARD_QUESTION_AMOUNT = "CUSTOM_REWARD_QUESTION_AMOUNT";
+
+    public static final String DOWNLOAD_URL = "V_DOWNLOAD_URL_V";
+
 }

+ 10 - 0
crm-model/src/main/java/com/crm/rely/backend/model/constant/EmailTemplateConstants.java

@@ -23,4 +23,14 @@ public class EmailTemplateConstants {
 
 
     public final static String MANAGER_CUSTOM_ANALYSIS = "MANAGER_CUSTOM_ANALYSIS";
+
+    public final static String CUSTOM_WITHDRAW_SUBMIT_SEND_CN = "CUSTOM_WITHDRAW_SUBMIT_SEND_CN";
+    public final static String CUSTOM_WITHDRAW_SUBMIT_SEND_EN = "CUSTOM_WITHDRAW_SUBMIT_SEND_EN";
+
+    public final static String CUSTOM_APPLY_DIGITAL_WITHDRAW_SEND_CN = "CUSTOM_APPLY_DIGITAL_WITHDRAW_SEND_CN";
+    public final static String CUSTOM_APPLY_DIGITAL_WITHDRAW_SEND_EN = "CUSTOM_APPLY_DIGITAL_WITHDRAW_SEND_EN";
+
+    public final static String CUSTOM_ORDER_SUCCESS_CN = "CUSTOM_ORDER_SUCCESS_CN";
+    public final static String CUSTOM_ORDER_SUCCESS_EN = "CUSTOM_ORDER_SUCCESS_EN";
+
 }

+ 42 - 5
crm-model/src/main/java/com/crm/rely/backend/model/constant/PayConstants.java

@@ -28,6 +28,9 @@ public class PayConstants {
 
     public final static String FINANCE_WITHDRAW_CHANNEL_NOT_EMPTY = "finance_withdraw_channel_not_empty";
 
+    public final static String FINANCE_WITHDRAW_AMOUNT_GREATER_THAN = "finance_withdraw_amount_greater_than";
+
+
     /**
      * 不存在汇率
      */
@@ -82,13 +85,16 @@ public class PayConstants {
 
     public static final Integer MANAGER_PROCESSING_STATUS = 1;
 
+    public static final Integer MANAGER_COMPLETED_STATUS = 2;
+
+    public static final Integer MANAGER_FAIL_STATUS = 3;
+
     //1:系统自动方式 2:人工方式
     public static final int OPERATION_TYPE_AUTOMATIC = 1;
 
     public static final int OPERATION_TYPE_MANUAL = 2;
 
-    public static final Integer MANAGER_COMPLETED_STATUS = 2;
-    public static final Integer MANAGER_FAIL_STATUS = 3;
+
 
     //入(出)金回调的三种状态 0入(出)金中 1入(出)金成功 2 入(出)金失败
     public static final Integer CALLBACE_PROCESSING_STATUS = 0;
@@ -103,6 +109,31 @@ public class PayConstants {
 
     public static final Integer SUBMIT_PROCESSING_STATUS = 1;
 
+
+    /**
+     * 通道类型 银行通道
+     */
+    public final static String CHANNEL_TYPE_BANK = "BANK";
+    public final static String CHANNEL_TYPE_BANK_TELEGRAPHIC = "BANK_TELEGRAPHIC";
+
+    /**
+     * 通道类型 数字货币通道
+     */
+    public final static String CHANNEL_TYPE_DIGITAL_CURRENCY = "DIGITAL_CURRENCY";
+
+    /**
+     * 信用卡
+     */
+    public final static String CHANNEL_TYPE_CARD = "CHANNEL_TYPE_CARD";
+
+    public final static String CHANNEL_TYPE_WALLET = "CHANNEL_TYPE_WALLET";
+    public final static String CHANNEL_TYPE_ALI_WALLET = "CHANNEL_TYPE_ALI_WALLET";
+
+    /**
+     * 通道类型 ucard通道
+     */
+    public final static String UCARD_WALLET = "UCARD_WALLET";
+
     //未支付
     public static final Integer ORDER_UP_PAY_STATUS = 1;
 
@@ -116,9 +147,7 @@ public class PayConstants {
     public static final Integer ORDER_PAY_EXPIRED_STATUS  = 4;
 
     //已取消
-    public static final Integer ORDER_PAY_CANCLE_D_STATUS  = 5;
-
-    public static final String SALES_USER_EMAIL = "SALES_USER_EMAIL";
+    public static final Integer ORDER_PAY_CANCEL_STATUS  = 5;
 
     public final static String ORDER_EXPIRED = "order_expired";
     public final static Integer UCARD_PAY_TYPE_REMIT_PAY_TIME = 30;
@@ -537,4 +566,12 @@ public class PayConstants {
 
     public final static String ORDER_DEPOSIT_EXPIRE = "ORDER_DEPOSIT_EXPIRE";
 
+    public final static String PAY_REMIT_AMOUNT_NOT_EMPTY = "remit_amount_not_empty";
+
+    public final static String PAY_REMIT_AMOUNT_INSUFFICIENT  = "insufficient_balance";
+
+    public static final String NOT_CANCEL = "not_cancel";
+
+    public static final String VN_WITHDRAW_LIMIT_AMOUNT = "VN_WITHDRAW_LIMIT_AMOUNT";
+
 }

+ 6 - 0
crm-model/src/main/java/com/crm/rely/backend/model/dto/golden/order/GoldenOrderListDto.java

@@ -52,6 +52,12 @@ public class GoldenOrderListDto {
 
     private Date addTime;
 
+    private String channelCode;
+
+    private String channelName;
+
+    private String channelEnName;
+
     List<GoldenOrderDetailsDto> details;
 
 }

+ 22 - 0
crm-model/src/main/java/com/crm/rely/backend/model/dto/golden/question/GoldenRewardQuestionDto.java

@@ -0,0 +1,22 @@
+package com.crm.rely.backend.model.dto.golden.question;
+
+import lombok.Data;
+
+import java.util.Date;
+
+@Data
+public class GoldenRewardQuestionDto {
+
+    /**
+     * 有奖问答 0:否 1:是
+     */
+    private Integer type;
+
+    private Long questionId;
+
+    /**
+     * 问题
+     */
+    private String question;
+
+}

+ 26 - 0
crm-model/src/main/java/com/crm/rely/backend/model/dto/sys/remit/SysRemitChannelApiDto.java

@@ -0,0 +1,26 @@
+package com.crm.rely.backend.model.dto.sys.remit;
+
+import lombok.Data;
+
+@Data
+public class SysRemitChannelApiDto {
+
+    private String code;
+
+    private String type;
+    /**
+     * 通道名称
+     */
+    private String name;
+    /**
+     * 通道英文名称
+     */
+    private String enName;
+
+    /**
+     * 通道图标(icon)
+     */
+    private String icon;
+
+    private String withdrawInfoUrl;
+}

+ 38 - 2
crm-model/src/main/java/com/crm/rely/backend/model/dto/sys/remit/SysRemitChannelDto.java

@@ -11,28 +11,64 @@ public class SysRemitChannelDto {
      * 通道位置code
      */
     private String code;
+
+    private String type;
     /**
      * 通道名称
      */
     private String name;
+    /**
+     * 通道英文名称
+     */
+    private String enName;
     /**
      * 调用通道的路由地址
      */
     private String requestUrl;
+    /**
+     * 通道出金货币
+     */
+    private String currency;
+
+    private String transformCurrency;
     /**
      * 通道图标(icon)
      */
     private String icon;
+//    /**
+//     * 通道图标-英文(icon)
+//     */
+//    private String enIcon;
     /**
      * 介绍
      */
     private String introduce;
+    /**
+     * 英文介绍
+     */
+    private String enIntroduce;
+
+    /**
+     * 是否启用银行 根据该字段获取银行列表
+     */
+    private Integer bankValid;
+
+    private String fundingTime;
+
 
     private BigDecimal minAmount;
+    private BigDecimal maxAmount;
 
     private BigDecimal rate;
 
-    private Long id;
+    private List<String> cIds;
+
+    private List<String> excludeCIds;
+
+    private List<String> countrys;
+
+    private Integer feeType;
 
-    private Integer valid;
+    private BigDecimal feeAmount;
+    private Integer free;
 }

+ 53 - 2
crm-model/src/main/java/com/crm/rely/backend/model/dto/sys/remittance/channel/SysRemittanceChannelDto.java

@@ -3,11 +3,12 @@ package com.crm.rely.backend.model.dto.sys.remittance.channel;
 import lombok.Data;
 
 import java.math.BigDecimal;
+import java.util.List;
 
 @Data
 public class SysRemittanceChannelDto {
 
-    private Long id;
+    private Integer type;
     /**
      * 通道位置code
      */
@@ -16,18 +17,47 @@ public class SysRemittanceChannelDto {
      * 通道名称
      */
     private String name;
+    /**
+     * 通道英文名称
+     */
+    private String enName;
     /**
      * 调用通道的路由地址
      */
     private String requestUrl;
+    /**
+     * 通道入金货币
+     */
+    private String currency;
+
+    private String transformCurrency;
     /**
      * 通道图标(icon)
      */
     private String icon;
+    /**
+     * 通道图标-英文(icon)
+     */
+//    private String enIcon;
     /**
      * 介绍
      */
     private String introduce;
+    /**
+     * 英文介绍
+     */
+    private String enIntroduce;
+
+    /**
+     * 是否启用银行 根据该字段获取银行列表
+     */
+    private Integer bankValid;
+
+    private Integer expire;
+
+    private String fundingTime;
+
+    private Integer free;
     private Integer subIndex;
 
     private BigDecimal minAmount;
@@ -37,5 +67,26 @@ public class SysRemittanceChannelDto {
 
     private String property;
 
-    private Integer valid;
+    private List<String> cIds;
+
+    private List<String> excludeCIds;
+    private List<String> countrys;
+
+    private Integer confirmName;
+    private Integer confirmAreaCode;
+    private Integer confirmPhone;
+
+    private Integer confirmCreditCard;
+
+
+    private List<String> states;
+
+
+    private String startTime;
+    private String endTime;
+
+    /**
+     * kyc通道 0:否 1;是
+     */
+    private Integer kycChannel;
 }

+ 16 - 0
crm-model/src/main/java/com/crm/rely/backend/model/entity/finance/withdraw/FinanceAgentWithdrawSearchListEntity.java

@@ -0,0 +1,16 @@
+package com.crm.rely.backend.model.entity.finance.withdraw;
+
+import lombok.Data;
+
+@Data
+public class FinanceAgentWithdrawSearchListEntity extends FinanceWithdrawSearchListEntity {
+
+    private Long agentId;
+
+    private Long cId;
+
+    private String ibNo;
+
+    private String channelCode;
+
+}

+ 17 - 0
crm-model/src/main/java/com/crm/rely/backend/model/entity/finance/withdraw/FinanceApplyDigitalWithdrawSendEmailCodeEntity.java

@@ -0,0 +1,17 @@
+package com.crm.rely.backend.model.entity.finance.withdraw;
+
+import lombok.Data;
+
+import java.util.Date;
+
+@Data
+public class FinanceApplyDigitalWithdrawSendEmailCodeEntity {
+
+    private String country;
+
+    private String email;
+
+    private String ip;
+
+    private Date time;
+}

+ 21 - 0
crm-model/src/main/java/com/crm/rely/backend/model/entity/finance/withdraw/FinanceWithdrawApproveBackstageEntity.java

@@ -0,0 +1,21 @@
+package com.crm.rely.backend.model.entity.finance.withdraw;
+
+import com.crm.rely.backend.core.constant.Constants;
+import com.crm.rely.backend.core.entity.base.BaseUpdateEntity;
+import lombok.Data;
+
+import javax.validation.constraints.Min;
+import javax.validation.constraints.NotNull;
+import javax.validation.constraints.Size;
+
+@Data
+public class FinanceWithdrawApproveBackstageEntity extends BaseUpdateEntity {
+
+    @NotNull(message = Constants.INVALID_REQUEST)
+    @Min(value = 1, message = Constants.INVALID_REQUEST)
+    private Integer backstageStatus;
+
+    @Size(max = 200, message = "content_oversize")
+    private String approveDesc;
+
+}

+ 26 - 0
crm-model/src/main/java/com/crm/rely/backend/model/entity/finance/withdraw/FinanceWithdrawApproveChannelEntity.java

@@ -0,0 +1,26 @@
+package com.crm.rely.backend.model.entity.finance.withdraw;
+
+import com.crm.rely.backend.core.constant.Constants;
+import com.crm.rely.backend.core.entity.base.BaseUpdateEntity;
+import lombok.Data;
+
+import javax.validation.constraints.Min;
+import javax.validation.constraints.NotNull;
+import javax.validation.constraints.Size;
+
+@Data
+public class FinanceWithdrawApproveChannelEntity extends BaseUpdateEntity {
+
+    private String serial;
+
+    private String channelSerial;
+
+    @NotNull(message = Constants.INVALID_REQUEST)
+    @Min(value = 1, message = Constants.INVALID_REQUEST)
+    private Integer callbackStatus;
+
+    @Size(max = 200, message = "content_oversize")
+    private String approveDesc;
+
+    private String channelCode;
+}

+ 24 - 0
crm-model/src/main/java/com/crm/rely/backend/model/entity/finance/withdraw/FinanceWithdrawApproveChannelSubmitEntity.java

@@ -0,0 +1,24 @@
+package com.crm.rely.backend.model.entity.finance.withdraw;
+
+import com.crm.rely.backend.core.constant.Constants;
+import com.crm.rely.backend.core.entity.base.BaseUpdateEntity;
+import lombok.Data;
+
+import javax.validation.constraints.Min;
+import javax.validation.constraints.NotNull;
+import javax.validation.constraints.Size;
+
+@Data
+public class FinanceWithdrawApproveChannelSubmitEntity extends BaseUpdateEntity {
+
+    @NotNull(message = Constants.INVALID_REQUEST)
+    @Min(value = 1, message = Constants.INVALID_REQUEST)
+    private Integer submitStatus;
+
+    @Size(max = 200, message = "content_oversize")
+    private String approveDesc;
+
+    private String actualPayType;
+
+    private String channelSerial;
+}

+ 21 - 0
crm-model/src/main/java/com/crm/rely/backend/model/entity/finance/withdraw/FinanceWithdrawApproveChannelSubmitsEntity.java

@@ -0,0 +1,21 @@
+package com.crm.rely.backend.model.entity.finance.withdraw;
+
+import com.crm.rely.backend.core.constant.Constants;
+import com.crm.rely.backend.core.entity.base.BaseUpdateEntitys;
+import lombok.Data;
+
+import javax.validation.constraints.Min;
+import javax.validation.constraints.NotNull;
+import javax.validation.constraints.Size;
+
+@Data
+public class FinanceWithdrawApproveChannelSubmitsEntity extends BaseUpdateEntitys {
+
+    @NotNull(message = Constants.INVALID_REQUEST)
+    @Min(value = 1, message = Constants.INVALID_REQUEST)
+    private Integer submitStatus;
+
+    @Size(max = 200, message = "content_oversize")
+    private String approveDesc;
+
+}

+ 24 - 0
crm-model/src/main/java/com/crm/rely/backend/model/entity/finance/withdraw/FinanceWithdrawApproveChannelsEntity.java

@@ -0,0 +1,24 @@
+package com.crm.rely.backend.model.entity.finance.withdraw;
+
+import com.crm.rely.backend.core.constant.Constants;
+import com.crm.rely.backend.core.entity.base.BaseUpdateEntitys;
+import lombok.Data;
+
+import javax.validation.constraints.Min;
+import javax.validation.constraints.NotNull;
+import javax.validation.constraints.Size;
+
+@Data
+public class FinanceWithdrawApproveChannelsEntity extends BaseUpdateEntitys {
+
+    private String channelSerial;
+
+    @NotNull(message = Constants.INVALID_REQUEST)
+    @Min(value = 1, message = Constants.INVALID_REQUEST)
+    private Integer callbackStatus;
+
+    @Size(max = 200, message = "content_oversize")
+    private String approveDesc;
+
+    private String channelCode;
+}

+ 3 - 0
crm-model/src/main/java/com/crm/rely/backend/model/entity/finance/withdraw/FinanceWithdrawApproveEntity.java

@@ -6,5 +6,8 @@ import lombok.Data;
 @Data
 public class FinanceWithdrawApproveEntity extends BaseApproveEntity {
 
+    private Integer withdrawStatus;
+
+    private Integer operationType;
 
 }

+ 21 - 0
crm-model/src/main/java/com/crm/rely/backend/model/entity/finance/withdraw/FinanceWithdrawApproveInfoEntity.java

@@ -0,0 +1,21 @@
+package com.crm.rely.backend.model.entity.finance.withdraw;
+
+import com.crm.rely.backend.core.constant.Constants;
+import com.crm.rely.backend.core.entity.base.BaseUpdateEntity;
+import lombok.Data;
+
+import javax.validation.constraints.Min;
+import javax.validation.constraints.NotNull;
+import javax.validation.constraints.Size;
+
+@Data
+public class FinanceWithdrawApproveInfoEntity extends BaseUpdateEntity {
+
+    @NotNull(message = Constants.INVALID_REQUEST)
+    @Min(value = 1, message = Constants.INVALID_REQUEST)
+    private Integer infoStatus;
+
+    @Size(max = 200, message = "content_oversize")
+    private String approveDesc;
+
+}

+ 21 - 0
crm-model/src/main/java/com/crm/rely/backend/model/entity/finance/withdraw/FinanceWithdrawApproveInfosEntity.java

@@ -0,0 +1,21 @@
+package com.crm.rely.backend.model.entity.finance.withdraw;
+
+import com.crm.rely.backend.core.constant.Constants;
+import com.crm.rely.backend.core.entity.base.BaseUpdateEntitys;
+import lombok.Data;
+
+import javax.validation.constraints.Min;
+import javax.validation.constraints.NotNull;
+import javax.validation.constraints.Size;
+
+@Data
+public class FinanceWithdrawApproveInfosEntity extends BaseUpdateEntitys {
+
+    @NotNull(message = Constants.INVALID_REQUEST)
+    @Min(value = 1, message = Constants.INVALID_REQUEST)
+    private Integer infoStatus;
+
+    @Size(max = 200, message = "content_oversize")
+    private String approveDesc;
+
+}

+ 24 - 0
crm-model/src/main/java/com/crm/rely/backend/model/entity/finance/withdraw/FinanceWithdrawApproveManagerEntity.java

@@ -0,0 +1,24 @@
+package com.crm.rely.backend.model.entity.finance.withdraw;
+
+import com.crm.rely.backend.core.constant.Constants;
+import com.crm.rely.backend.core.entity.base.BaseUpdateEntity;
+import lombok.Data;
+
+import javax.validation.constraints.Min;
+import javax.validation.constraints.NotNull;
+import javax.validation.constraints.Size;
+
+@Data
+public class FinanceWithdrawApproveManagerEntity extends BaseUpdateEntity {
+
+    @NotNull(message = Constants.INVALID_REQUEST)
+    @Min(value = 0, message = Constants.INVALID_REQUEST)
+    private Integer withdrawStatus;
+
+    private String withdrawTicket;
+
+    private Integer callbackStatus;
+
+    @Size(max = 200,message = "content_oversize")
+    private String approveDesc;
+}

+ 10 - 0
crm-model/src/main/java/com/crm/rely/backend/model/entity/finance/withdraw/FinanceWithdrawApproveSalesEntity.java

@@ -0,0 +1,10 @@
+package com.crm.rely.backend.model.entity.finance.withdraw;
+
+import com.crm.rely.backend.core.entity.base.BaseApproveEntity;
+import lombok.Data;
+
+@Data
+public class FinanceWithdrawApproveSalesEntity extends BaseApproveEntity {
+
+
+}

+ 8 - 0
crm-model/src/main/java/com/crm/rely/backend/model/entity/finance/withdraw/FinanceWithdrawBankAddEntity.java

@@ -16,4 +16,12 @@ public class FinanceWithdrawBankAddEntity extends FinanceWithdrawBaseAddEntity {
     private String bankFront;
 
     private String bankBack;
+
+    private String agencyNo;
+
+    private String cpf;
+
+    private Long bankId;
+
+    private Integer defaultBank;
 }

+ 4 - 0
crm-model/src/main/java/com/crm/rely/backend/model/entity/finance/withdraw/FinanceWithdrawBankTelegraphicAddEntity.java

@@ -21,6 +21,10 @@ public class FinanceWithdrawBankTelegraphicAddEntity extends FinanceWithdrawBase
 
     private String bankBack;
 
+    private String agencyNo;
+
+    private String cpf;
+
     private Long bankId;
 
     private Integer defaultBank;

+ 28 - 8
crm-model/src/main/java/com/crm/rely/backend/model/entity/finance/withdraw/FinanceWithdrawBaseAddEntity.java

@@ -1,8 +1,10 @@
 package com.crm.rely.backend.model.entity.finance.withdraw;
 
 import com.crm.rely.backend.core.entity.base.BaseAddEntity;
+import com.crm.rely.backend.model.constant.PayConstants;
 import lombok.Data;
 
+import javax.validation.constraints.Min;
 import javax.validation.constraints.NotNull;
 import java.math.BigDecimal;
 
@@ -17,21 +19,39 @@ public class FinanceWithdrawBaseAddEntity extends BaseAddEntity {
     /**
      * 出金账号
      */
+//    @NotNull(message = PayConstant.PAY_LOGIN_NOT_EMPTY)
     private Long login;
     /**
      * 出金金额
      */
-    @NotNull
+    @NotNull(message = PayConstants.PAY_REMIT_AMOUNT_NOT_EMPTY)
+    @Min(value = 0, message = PayConstants.PAY_REMIT_AMOUNT_NOT_EMPTY)
     private BigDecimal amount;
-    private BigDecimal rate;
-    private BigDecimal cny;
 
-    /**
-     * 1 交易账户 2美金账户 3人民币账户
-     */
-    @NotNull
-    private Integer sourceType;
+    private String payType;
+
+    private String channelType;
+
+    private String bankCode;
+
+    private String currency;
+
+    private String transformCurrency;
 
     private Long cId;
 
+    private Long salesId;
+
+    private String extParam;
+
+    private String callbackMq;
+
+    private String email;
+
+    private String emailCode;
+
+
+    private BigDecimal fixedRate;
+    private BigDecimal fixedRateAmount;
+
 }

+ 10 - 0
crm-model/src/main/java/com/crm/rely/backend/model/entity/finance/withdraw/FinanceWithdrawCancelEntity.java

@@ -0,0 +1,10 @@
+package com.crm.rely.backend.model.entity.finance.withdraw;
+
+import com.crm.rely.backend.core.entity.base.BaseUpdateEntity;
+import lombok.Data;
+
+@Data
+public class FinanceWithdrawCancelEntity extends BaseUpdateEntity {
+
+
+}

+ 22 - 0
crm-model/src/main/java/com/crm/rely/backend/model/entity/finance/withdraw/FinanceWithdrawCardAddEntity.java

@@ -0,0 +1,22 @@
+package com.crm.rely.backend.model.entity.finance.withdraw;
+
+import lombok.Data;
+
+@Data
+public class FinanceWithdrawCardAddEntity extends FinanceWithdrawBaseAddEntity {
+
+
+    private String bankCardNum;
+
+    private String bankUname;
+
+    private String cvv;
+
+    private String expiryMonth;
+
+    private String expiryYear;
+
+    private Long bankId;
+
+    private Integer defaultBank;
+}

+ 6 - 0
crm-model/src/main/java/com/crm/rely/backend/model/entity/finance/withdraw/FinanceWithdrawDigitalCurrencyAddEntity.java

@@ -9,4 +9,10 @@ public class FinanceWithdrawDigitalCurrencyAddEntity extends FinanceWithdrawBase
 
     private String message;
 
+    private String addressProve;
+
+    private Integer type;
+
+    private Integer realVerify;
+
 }

+ 20 - 0
crm-model/src/main/java/com/crm/rely/backend/model/entity/finance/withdraw/FinanceWithdrawInfoEntity.java

@@ -0,0 +1,20 @@
+package com.crm.rely.backend.model.entity.finance.withdraw;
+
+import lombok.Data;
+
+@Data
+public class FinanceWithdrawInfoEntity {
+
+    private Long id;
+
+    private String withdrawInfoUrl;
+
+    /**
+     * null 1 出金
+     * 2 佣金提取
+     */
+    private Integer withdrawInfoType;
+
+
+    private String payType;
+}

+ 10 - 0
crm-model/src/main/java/com/crm/rely/backend/model/entity/finance/withdraw/FinanceWithdrawSearchByIdsEntity.java

@@ -0,0 +1,10 @@
+package com.crm.rely.backend.model.entity.finance.withdraw;
+
+import com.crm.rely.backend.core.entity.base.LongEntitys;
+import lombok.Data;
+
+@Data
+public class FinanceWithdrawSearchByIdsEntity extends LongEntitys {
+
+    private String stamp;
+}

+ 41 - 0
crm-model/src/main/java/com/crm/rely/backend/model/entity/finance/withdraw/FinanceWithdrawSearchListEntity.java

@@ -3,11 +3,18 @@ package com.crm.rely.backend.model.entity.finance.withdraw;
 import com.crm.rely.backend.core.entity.base.BaseDateAndPageSearchEntity;
 import lombok.Data;
 
+import java.util.Date;
+import java.util.List;
+
 @Data
 public class FinanceWithdrawSearchListEntity extends BaseDateAndPageSearchEntity {
 
     private Long customId;
 
+    private String platform;
+
+    private Integer loginType;
+
     private Long login;
 
     private Long cId;
@@ -17,4 +24,38 @@ public class FinanceWithdrawSearchListEntity extends BaseDateAndPageSearchEntity
     private String serial;
 
     private Integer status;
+
+    private Date startDate;
+
+    private Date endDate;
+
+    private String channelCode;
+
+
+    private List<String> channelCodes;
+
+    private Integer mtStatus;
+
+    private Integer salesStatus;
+
+
+    private Integer submitStatus;
+    private Integer backstageStatus;
+    private Integer infoStatus;
+
+    private Date startSubmitDate;
+
+    private Date endSubmitDate;
+    private String country;
+
+    private Integer salaryLogin;
+
+    private String pIbNo;
+
+    private String name;
+
+    /**
+     * 用来判断是否需要拼接备注
+     */
+    private int com;
 }

+ 14 - 0
crm-model/src/main/java/com/crm/rely/backend/model/entity/finance/withdraw/FinanceWithdrawWalletAddEntity.java

@@ -0,0 +1,14 @@
+package com.crm.rely.backend.model.entity.finance.withdraw;
+
+import lombok.Data;
+
+@Data
+public class FinanceWithdrawWalletAddEntity extends FinanceWithdrawBaseAddEntity {
+
+    private String address;
+
+    private String message;
+
+    private String addressProve;
+
+}

+ 2 - 0
crm-model/src/main/java/com/crm/rely/backend/model/entity/golden/goods/GoldenGoodsSearchEntity.java

@@ -20,4 +20,6 @@ public class GoldenGoodsSearchEntity extends BaseSearchPageEntity {
 
     private Long customId;
 
+    private List<Long> goodsIds;
+
 }

+ 4 - 0
crm-model/src/main/java/com/crm/rely/backend/model/entity/golden/goods/GoldenGoodsVideoSearchEntity.java

@@ -1,11 +1,15 @@
 package com.crm.rely.backend.model.entity.golden.goods;
 
+import com.crm.rely.backend.core.constant.Constants;
 import com.crm.rely.backend.core.entity.base.BaseSearchPageEntity;
 import lombok.Data;
 
+import javax.validation.constraints.NotNull;
+
 @Data
 public class GoldenGoodsVideoSearchEntity extends BaseSearchPageEntity {
 
+    @NotNull(message = Constants.NAME_NOT_NULL)
     private Long goodsId;
 
     private String videoName;

+ 17 - 0
crm-model/src/main/java/com/crm/rely/backend/model/entity/golden/question/GoldenQuestionCustomAddEntity.java

@@ -0,0 +1,17 @@
+package com.crm.rely.backend.model.entity.golden.question;
+
+import com.crm.rely.backend.core.entity.base.BaseAddEntity;
+import lombok.Data;
+@Data
+public class GoldenQuestionCustomAddEntity extends BaseAddEntity {
+
+    private Long customId;
+
+    private Long questionId;
+
+    /**
+     * 用户回答
+     */
+    private Integer customAnswer;
+
+}

+ 14 - 0
crm-model/src/main/java/com/crm/rely/backend/model/entity/sys/remit/SysRemitChannelListEntity.java

@@ -0,0 +1,14 @@
+package com.crm.rely.backend.model.entity.sys.remit;
+
+import lombok.Data;
+
+import java.util.List;
+
+@Data
+public class SysRemitChannelListEntity {
+    private Long cId;
+
+    private String country;
+
+    private List<String> channelCode;
+}

+ 28 - 1
crm-model/src/main/java/com/crm/rely/backend/model/pojo/table/CustomBankTable.java

@@ -34,10 +34,37 @@ public class CustomBankTable extends BaseTable {
 
     private String bankBack;
 
+    private String agencyNo;
+
     private Integer defaultBank;
 
+    private String cvv;
+
+    private String expiryMonth;
+    private String expiryYear;
+
+    private String pin;
+
+    private String addressName;
+
+    private String address;
+
+    private String addressProve;
     /**
-     * 银行卡类型 1:银行卡 2:电汇
+     * 银行卡类型 1:银行卡 2:电汇 3:信用卡
      */
     private Integer type;
+
+    private String externalUserId;
+
+    private Integer authStatus;
+
+    private String applicantId;
+
+    private String kycVerifyUrl;
+
+    private Integer realVerify;
+
+    private Integer verifyMode;
+
 }

+ 11 - 4
crm-model/src/main/java/com/crm/rely/backend/model/pojo/table/CustomInfoTable.java

@@ -118,11 +118,18 @@ public class CustomInfoTable extends BaseApproveTable {
 
     private Long ibId;
 
-    private BigDecimal usdAmount;
+    private Integer payStatus;
+    private String sno;
 
-    private BigDecimal cnyAmount;
+    /**
+     * 钱包余额
+     */
+    private BigDecimal balance;
 
+    /**
+     * 累计消费金额
+     */
+    private BigDecimal totalSpendingAmount;
 
-    private Integer payStatus;
-    private String sno;
+    private Integer withdrawFeeReduction;
 }

+ 0 - 1
crm-model/src/main/java/com/crm/rely/backend/model/pojo/table/FinanceDepositTable.java

@@ -39,7 +39,6 @@ public class FinanceDepositTable extends BaseApproveTable {
      */
     private String platform;
 
-    private String server;
     /**
      * 入金账号
      */

+ 0 - 1
crm-model/src/main/java/com/crm/rely/backend/model/pojo/table/FinanceWithdrawTable.java

@@ -42,7 +42,6 @@ public class FinanceWithdrawTable extends BaseApproveTable {
      */
     private String platform;
 
-    private String server;
     /**
      * 出金账号
      */

+ 29 - 0
crm-model/src/main/java/com/crm/rely/backend/model/pojo/table/GoldenCustomRewardRecordTable.java

@@ -0,0 +1,29 @@
+package com.crm.rely.backend.model.pojo.table;
+
+import com.crm.rely.backend.core.pojo.BaseTable;
+import lombok.Data;
+
+import javax.persistence.Entity;
+import javax.persistence.Table;
+import java.util.Date;
+
+@Data
+@Entity
+@Table(name = "golden_custom_reward_record")
+public class GoldenCustomRewardRecordTable extends BaseTable {
+
+    private Long customId;
+
+    private Date startDate;
+
+    /**
+     * 1:未发放 2:已发放
+     */
+    private Integer grantStatus;
+
+    /**
+     * 1:进行中 2:已完成 3:已结束
+     */
+    private Integer status;
+
+}

+ 1 - 0
crm-model/src/main/java/com/crm/rely/backend/model/pojo/table/GoldenOrderDetailsTable.java

@@ -36,5 +36,6 @@ public class GoldenOrderDetailsTable extends BaseTable {
      */
     private String frontUrl;
 
+    private String download;
 
 }

+ 7 - 1
crm-model/src/main/java/com/crm/rely/backend/model/pojo/table/GoldenOrderTable.java

@@ -35,7 +35,7 @@ public class GoldenOrderTable extends BaseTable {
     private String transformCurrency;
 
     /**
-     * 1:未支付 2已支付 3已拒绝
+     * 1:未支付 2:已支付 3:支付失败 4:已过期 5:已取消
      */
     private Integer status;
 
@@ -54,5 +54,11 @@ public class GoldenOrderTable extends BaseTable {
      */
     private Date payTime;
 
+    private String channelCode;
+
+    private String channelName;
+
+    private String channelEnName;
+
 
 }

+ 33 - 0
crm-model/src/main/java/com/crm/rely/backend/model/pojo/table/GoldenQuestionCustomTable.java

@@ -0,0 +1,33 @@
+package com.crm.rely.backend.model.pojo.table;
+
+import com.crm.rely.backend.core.pojo.BaseTable;
+import lombok.Data;
+
+import javax.persistence.Entity;
+import javax.persistence.Table;
+
+@Data
+@Entity
+@Table(name = "golden_question_custom")
+public class GoldenQuestionCustomTable extends BaseTable {
+
+    private Long customId;
+
+    private Long questionId;
+
+    /**
+     * 问题
+     */
+    private String question;
+
+    /**
+     * 答案 0:错 1:对
+     */
+    private Integer answer;
+
+    /**
+     * 用户回答
+     */
+    private Integer customAnswer;
+
+}

+ 163 - 4
crm-model/src/main/java/com/crm/rely/backend/model/pojo/view/FinanceWithdrawView.java

@@ -1,9 +1,11 @@
 package com.crm.rely.backend.model.pojo.view;
 
-import com.crm.rely.backend.model.pojo.table.FinanceWithdrawTable;
+import com.crm.rely.backend.core.pojo.BaseApproveTable;
 import lombok.Data;
 
 import javax.persistence.Entity;
+import java.math.BigDecimal;
+import java.util.Date;
 
 /**
  * 存款
@@ -12,10 +14,167 @@ import javax.persistence.Entity;
  */
 @Data
 @Entity
-public class FinanceWithdrawView extends FinanceWithdrawTable {
+public class FinanceWithdrawView extends BaseApproveTable {
 
-    private String agentIbNo;
+    /**
+     * 流水号
+     */
+    private String serial;
 
-    private String salesIbNo;
+    /**
+     * 用户id
+     */
+    private Long customId;
 
+    /**
+     * 用户名称
+     */
+    private String name;
+
+    private String areaCode;
+    private String phone;
+    /**
+     * 出金账号平台
+     */
+    private String platform;
+    /**
+     * 出金账号
+     */
+    private Long login;
+    /**
+     * 出金交易账号类型
+     */
+    private Long loginType;
+
+    private String server;
+    /**
+     * 出金金额
+     */
+    private BigDecimal amount;
+
+    private String currency;
+    /**
+     * 出金汇率
+     */
+    private BigDecimal rate;
+    /**
+     * 出金实际金额
+     */
+    private BigDecimal transformAmount;
+    /**
+     * 出金实际货币类型
+     */
+    private String transformCurrency;
+    /**
+     * 通道流水号(id)
+     */
+    private String channelSerial;
+
+    private Integer callbackStatus;
+
+    private Integer withdrawStatus;
+
+    private BigDecimal withdrawAmount;
+
+    private String withdrawCurrency;
+
+    private String withdrawTicket;
+
+    private Integer operationType;
+
+    private String payType;
+
+    private String bankCode;
+
+    private String address;
+
+    private String message;
+
+    private String bankUname;
+
+    private String bankCardNum;
+
+    private String bankName;
+
+    private String bankBranchName;
+
+    private String bankAddr;
+
+    private String swiftCode;
+
+    private String customBankCode;
+
+    private String bankFront;
+
+    private String bankBack;
+
+    private String cvv;
+
+    private String expiryMonth;
+
+    private String expiryYear;
+
+
+    //下面为出金通道配置信息 作为记录
+
+    private String remitChannelType;
+    private String remitChannelCode;
+
+    private String remitChannelName;
+
+    private String remitChannelEnName;
+
+    private String remitChannelRequestUrl;
+
+    private String remitChannelCurrency;
+
+    private String remitChannelIcon;
+
+    private String remitChannelEnIcon;
+
+    private String remitChannelIntroduce;
+
+    private String remitChannelEnIntroduce;
+
+    private String ibNo;
+
+    private String pIbNo;
+
+    private Long cId;
+
+    private String salesNo;
+
+    private Integer salesStatus;
+
+    private Integer salesSettingLevel;
+
+    private String agencyNo;
+
+    private String addressProve;
+
+    private String cpf;
+
+    private Integer submitStatus;
+
+    private Date submitTime;
+
+    private Integer backstageStatus;
+
+
+    private Integer infoStatus;
+
+    private Integer feeReduction;
+
+    private BigDecimal feeAmount;
+
+    private BigDecimal feeReductionAmount;
+    private String activityNote;
+
+    private Long salaryLogin;
+
+    private Integer realVerify;
+
+    private Date callbackTime;
+
+    private String extParam;
 }

+ 0 - 52
crm-model/src/main/java/com/crm/rely/backend/model/pojo/view/GoldenGoodsListView.java

@@ -1,52 +0,0 @@
-package com.crm.rely.backend.model.pojo.view;
-
-import lombok.Data;
-
-import java.math.BigDecimal;
-import java.util.Date;
-
-@Data
-public class GoldenGoodsListView {
-
-    private Long id;
-
-    /**
-     * 名称
-     */
-    private String goodsName;
-
-    /**
-     * 标题
-     */
-    private String title;
-
-    /**
-     * 简介
-     */
-    private String introduction;
-
-    /**
-     * 封面
-     */
-    private String frontUrl;
-
-    /**
-     * 类型 1:免费试看课程 2:实战交易课程(50节) 3:拆出章节视频*12节 4:章节视频 5:专题报告
-     */
-    private Integer goodsType;
-
-    /**
-     * 价格
-     */
-    private BigDecimal goodsPrice;
-
-    /**
-     * 下载链接
-     */
-    private String download;
-
-    private Date addTime;
-
-    private Long customId;
-
-}

+ 0 - 63
crm-model/src/main/java/com/crm/rely/backend/model/pojo/view/GoldenGoodsVideoListView.java

@@ -1,63 +0,0 @@
-package com.crm.rely.backend.model.pojo.view;
-
-import lombok.Data;
-
-import java.util.Date;
-
-@Data
-public class GoldenGoodsVideoListView {
-
-    private Long id;
-
-    private Long goodsId;
-
-    /**
-     * 名称
-     */
-    private String videoName;
-
-    /**
-     * 标题
-     */
-    private String title;
-
-    /**
-     * 简介
-     */
-    private String introduction;
-
-    /**
-     * 封面
-     */
-    private String frontUrl;
-
-    /**
-     * 是否收费 0:否 1:是
-     */
-    private Integer payType;
-
-    /**
-     * 1:上传视频 2:外部连接
-     */
-    private Integer fileType;
-
-    /**
-     *
-     */
-    private String fileUrl;
-
-    /**
-     * 外部连接
-     */
-    private String linkUrl;
-
-    /**
-     * 排序
-     */
-    private Integer sort;
-
-    private Date addTime;
-
-    private Long customId;
-
-}

+ 0 - 7
crm-pay/src/main/java/com/crm/pay/controller/CustomInfoController.java

@@ -22,13 +22,6 @@ public class CustomInfoController {
     @PostMapping("/manager/funds")
     @FeignClientAnnotation
     public BaseResultDto funds(@RequestBody @Validated CustomInfoFundsEntity entity) throws Exception {
-
-        if (entity.getSourceType().equals(2)) {
-            service.updateUsdAmountById(entity.getCustomId(), entity.getAmount(), "后台调整");
-        }
-        if (entity.getSourceType().equals(3)) {
-            service.updateCnyAmountById(entity.getCustomId(), entity.getAmount(), "后台调整");
-        }
         return BaseResultDto.success();
     }
 

+ 421 - 54
crm-pay/src/main/java/com/crm/pay/controller/FinanceWithdrawController.java

@@ -1,20 +1,27 @@
 package com.crm.pay.controller;
 
+import com.crm.pay.entity.finance.withdraw.FinanceWithdrawApproveChannelEntity;
+import com.crm.pay.entity.finance.withdraw.FinanceWithdrawApproveChannelSubmitEntity;
+import com.crm.pay.service.CustomInfoService;
 import com.crm.pay.service.FinanceWithdrawService;
+import com.crm.pay.service.SysRemitChannelService;
+import com.crm.pay.service.UserInfoService;
 import com.crm.rely.backend.core.constant.Constants;
 import com.crm.rely.backend.core.constant.FeignClientAnnotation;
 import com.crm.rely.backend.core.constant.PrefixEnum;
-import com.crm.rely.backend.core.constant.StatusConstants;
 import com.crm.rely.backend.core.dto.base.BaseResultDto;
 import com.crm.rely.backend.core.dto.base.ResultWithPagerDto;
 import com.crm.rely.backend.core.entity.base.SingleLongEntity;
+import com.crm.rely.backend.core.exception.ServiceException;
+import com.crm.rely.backend.model.constant.PayConstants;
 import com.crm.rely.backend.model.dto.finance.withdraw.FinanceWithdrawDto;
+import com.crm.rely.backend.model.dto.sys.remit.SysRemitChannelApiDto;
 import com.crm.rely.backend.model.entity.custom.info.CustomInfoEntity;
-import com.crm.rely.backend.model.entity.finance.withdraw.FinanceWithdrawApproveEntity;
-import com.crm.rely.backend.model.entity.finance.withdraw.FinanceWithdrawBankAddEntity;
-import com.crm.rely.backend.model.entity.finance.withdraw.FinanceWithdrawDeleteEntity;
-import com.crm.rely.backend.model.entity.finance.withdraw.FinanceWithdrawSearchListEntity;
-import com.crm.rely.backend.model.entity.user.info.UserInfoEntity;
+import com.crm.rely.backend.model.entity.finance.withdraw.*;
+import com.crm.rely.backend.model.pojo.table.CustomInfoTable;
+import com.crm.rely.backend.model.pojo.table.UserInfoTable;
+import com.crm.rely.backend.util.DateUtil;
+import com.google.common.base.Strings;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.validation.annotation.Validated;
 import org.springframework.web.bind.annotation.PostMapping;
@@ -22,6 +29,10 @@ import org.springframework.web.bind.annotation.RequestBody;
 import org.springframework.web.bind.annotation.RequestMapping;
 import org.springframework.web.bind.annotation.RestController;
 
+import java.math.BigDecimal;
+import java.util.Date;
+import java.util.List;
+
 
 /**
  * 出金
@@ -32,74 +43,342 @@ public class FinanceWithdrawController {
 
     @Autowired
     private FinanceWithdrawService financeWithdrawService;
+    @Autowired
+    private UserInfoService userInfoService;
+
+    @Autowired
+    private SysRemitChannelService sysRemitChannelService;
+
+    @Autowired
+    private CustomInfoService customInfoService;
+
+    @PostMapping("/cancel")
+    public BaseResultDto<Object> cancel(@RequestBody FinanceWithdrawCancelEntity entity) throws Exception {
+
+        return financeWithdrawService.cancel(entity);
+    }
+
+    @PostMapping("/remaining/reduction/number")
+    public BaseResultDto<Object> remainingReductionNumber(CustomInfoEntity infoEntity) throws Exception {
+
+        return BaseResultDto.success(financeWithdrawService.getRemainingReductionNumber(infoEntity.getCId()));
+    }
+
+    @PostMapping("/cancel/backstage")
+    public BaseResultDto<Object> cancelBackstage(@RequestBody FinanceWithdrawCancelEntity entity) throws Exception {
+
+        return financeWithdrawService.cancelBackstage(entity);
+    }
 
 
     @PostMapping("/apply/bank")
     public BaseResultDto bank(@RequestBody @Validated FinanceWithdrawBankAddEntity entity, CustomInfoEntity infoEntity)
             throws Exception {
+        if (!PayConstants.PASSED_STATUS.equals(infoEntity.getStatus())) {
+            return BaseResultDto.error(Constants.VALIDATION_DATA);
+        }
+        if (!validateLogin(entity)) {
+            return BaseResultDto.error(PayConstants.PAY_REMIT_AMOUNT_NOT_EMPTY);
+        }
 
         entity.setCId(infoEntity.getCId());
         entity.setCustomId(infoEntity.getId());
-//        entity.setPayType(PayConstants.UNION_PAY_TELEGRAPHIC_REMIT);
-        if (entity.getSourceType().equals(1) && entity.getLogin() == null) {
-            return BaseResultDto.error(Constants.PARAMETER_ERROR);
+        entity.setChannelType(PayConstants.CHANNEL_TYPE_BANK);
+
+        if (!validateBalance(entity)) {
+            return BaseResultDto.error(PayConstants.PAY_REMIT_AMOUNT_INSUFFICIENT);
         }
-        if (entity.getSourceType().compareTo(1) < 0 || entity.getSourceType().compareTo(3) > 0) {
-            return BaseResultDto.error(Constants.PARAMETER_ERROR);
+
+        return financeWithdrawService.save(entity);
+    }
+
+    @PostMapping("/apply/bank/telegraphic")
+    public BaseResultDto bankTelegraphic(@RequestBody @Validated FinanceWithdrawBankTelegraphicAddEntity entity,
+                                         CustomInfoEntity infoEntity)
+            throws Exception {
+        if (!PayConstants.PASSED_STATUS.equals(infoEntity.getStatus())) {
+            return BaseResultDto.error(Constants.VALIDATION_DATA);
+        }
+        if (!validateLogin(entity)) {
+            return BaseResultDto.error(PayConstants.PAY_REMIT_AMOUNT_NOT_EMPTY);
+        }
+
+        entity.setCId(infoEntity.getCId());
+        entity.setCustomId(infoEntity.getId());
+        entity.setChannelType(PayConstants.CHANNEL_TYPE_BANK_TELEGRAPHIC);
+
+        if (!validateBalance(entity)) {
+            return BaseResultDto.error(PayConstants.PAY_REMIT_AMOUNT_INSUFFICIENT);
         }
+
         return financeWithdrawService.save(entity);
     }
 
-    //
-//    @PostMapping("/apply/bank/telegraphic")
-//    public BaseResultDto bankTelegraphic(@RequestBody @Validated FinanceWithdrawBankTelegraphicAddEntity entity,
-//    InfoEntity infoEntity)
-//            throws Exception {
-//
-//        if (!validateLogin(entity)) {
-//            return BaseResultDto.error(PayConstants.PAY_LOGIN_NOT_EMPTY);
-//        }
-//        validatedCloseFunction(infoEntity.getId(), entity.getLogin(), Constants
-//        .CLOSE_FUNCTION_WITHDRAW);
-//
-//        entity.setCId(infoEntity.getCId());
-//        entity.setCustomId(infoEntity.getId());
-//        entity.setChannelType(PayConstants.CHANNEL_TYPE_BANK_TELEGRAPHIC);
-//
-//
-//        return financeWithdrawService.save(entity);
-//    }
-//
-//    @PostMapping("/apply/digital/currency")
-//    public BaseResultDto digitalCurrency(@RequestBody @Validated FinanceWithdrawDigitalCurrencyAddEntity entity,
-//    CustomInfoEntity infoEntity)
-//            throws Exception {
-//
-//        entity.setCId(infoEntity.getCId());
-//        entity.setCustomId(infoEntity.getId());
-//        entity.setChannelType(PayConstants.CHANNEL_TYPE_DIGITAL_CURRENCY);
-//
-//        return financeWithdrawService.save(entity);
-//    }
-    @PostMapping("/search/list")
-    public ResultWithPagerDto<FinanceWithdrawDto> searchCustomList(@RequestBody @Validated FinanceWithdrawSearchListEntity entity, CustomInfoEntity infoEntity) throws Exception {
+    @PostMapping("/apply/digital/currency")
+    public BaseResultDto digitalCurrency(@RequestBody @Validated FinanceWithdrawDigitalCurrencyAddEntity entity,
+                                         CustomInfoEntity infoEntity)
+            throws Exception {
 
+        if (!validateLogin(entity)) {
+            return BaseResultDto.error(PayConstants.PAY_REMIT_AMOUNT_NOT_EMPTY);
+        }
+
+        entity.setEmail(infoEntity.getEmail());
+
+        financeWithdrawService.applyDigitalWithdrawValidateCode(entity);
+
+        entity.setCId(infoEntity.getCId());
         entity.setCustomId(infoEntity.getId());
-        ResultWithPagerDto<FinanceWithdrawDto> resultWithPagerDto = financeWithdrawService.searchList(entity);
-        return resultWithPagerDto;
+        entity.setChannelType(PayConstants.CHANNEL_TYPE_DIGITAL_CURRENCY);
+
+        if (!validateBalance(entity)) {
+            return BaseResultDto.error(PayConstants.PAY_REMIT_AMOUNT_INSUFFICIENT);
+        }
+
+        //customBankService.validBankAddress(entity);
+
+        return financeWithdrawService.save(entity);
+    }
+
+    @PostMapping("/apply/wallet")
+    public BaseResultDto wallet(@RequestBody @Validated FinanceWithdrawWalletAddEntity entity, CustomInfoEntity infoEntity)
+            throws Exception {
+
+        if (!validateLogin(entity)) {
+            return BaseResultDto.error(PayConstants.PAY_REMIT_AMOUNT_NOT_EMPTY);
+        }
+
+        entity.setCId(infoEntity.getCId());
+        entity.setCustomId(infoEntity.getId());
+        entity.setChannelType(PayConstants.CHANNEL_TYPE_WALLET);
+
+        if (!validateBalance(entity)) {
+            return BaseResultDto.error(PayConstants.PAY_REMIT_AMOUNT_INSUFFICIENT);
+        }
+
+        return financeWithdrawService.save(entity);
+    }
+
+    @PostMapping("/apply/ali/wallet")
+    public BaseResultDto aliWallet(@RequestBody @Validated FinanceWithdrawWalletAddEntity entity, CustomInfoEntity infoEntity)
+            throws Exception {
+
+        if (!validateLogin(entity)) {
+            return BaseResultDto.error(PayConstants.PAY_REMIT_AMOUNT_NOT_EMPTY);
+        }
+
+        entity.setCId(infoEntity.getCId());
+        entity.setCustomId(infoEntity.getId());
+        entity.setChannelType(PayConstants.CHANNEL_TYPE_ALI_WALLET);
+
+        if (!validateBalance(entity)) {
+            return BaseResultDto.error(PayConstants.PAY_REMIT_AMOUNT_INSUFFICIENT);
+        }
+
+        return financeWithdrawService.save(entity);
+    }
+
+    @PostMapping("/apply/digital/currency/send/code")
+    public BaseResultDto applyDigitalWithdrawSendEmailCode(CustomInfoEntity infoEntity) throws ServiceException {
+        FinanceApplyDigitalWithdrawSendEmailCodeEntity entity = new FinanceApplyDigitalWithdrawSendEmailCodeEntity();
+        entity.setEmail(infoEntity.getEmail());
+        entity.setCountry(infoEntity.getCountry());
+        entity.setTime(new Date());
+        entity.setIp(infoEntity.getLastIp());
+
+        financeWithdrawService.applyDigitalWithdrawSendEmailCode(entity);
+
+        return BaseResultDto.success();
+    }
+
+    @PostMapping("/apply/card")
+    public BaseResultDto card(@RequestBody @Validated FinanceWithdrawCardAddEntity entity,
+                              CustomInfoEntity infoEntity)
+            throws Exception {
+        if (!PayConstants.PASSED_STATUS.equals(infoEntity.getStatus())) {
+            return BaseResultDto.error(Constants.VALIDATION_DATA);
+        }
+        if (!validateLogin(entity)) {
+            return BaseResultDto.error(PayConstants.PAY_REMIT_AMOUNT_NOT_EMPTY);
+        }
+
+        entity.setCId(infoEntity.getCId());
+        entity.setCustomId(infoEntity.getId());
+        entity.setChannelType(PayConstants.CHANNEL_TYPE_CARD);
+
+        if (!validateBalance(entity)) {
+            return BaseResultDto.error(PayConstants.PAY_REMIT_AMOUNT_INSUFFICIENT);
+        }
+
+        return financeWithdrawService.save(entity);
+    }
+
+    @PostMapping("/apply/ucard/wallet")
+    public BaseResultDto ucardWallet(@RequestBody @Validated FinanceWithdrawWalletAddEntity entity, CustomInfoEntity infoEntity)
+            throws Exception {
+        if (!validateLogin(entity)) {
+            return BaseResultDto.error(PayConstants.PAY_REMIT_AMOUNT_NOT_EMPTY);
+        }
+
+        entity.setCId(infoEntity.getCId());
+        entity.setCustomId(infoEntity.getId());
+        entity.setChannelType(PayConstants.UCARD_WALLET);
+
+        if (!validateBalance(entity)) {
+            return BaseResultDto.error(PayConstants.PAY_REMIT_AMOUNT_INSUFFICIENT);
+        }
+
+        return financeWithdrawService.save(entity);
+    }
+
+    private boolean validateLogin(FinanceWithdrawBaseAddEntity entity) {
+        if (entity.getAmount() == null || entity.getAmount().compareTo(BigDecimal.ZERO) <= 0) {
+            return false;
+        }
+        return true;
+    }
+
+    private boolean validateBalance(FinanceWithdrawBaseAddEntity entity) {
+        CustomInfoTable customInfoTable = customInfoService.getById(entity.getCustomId());
+        if (customInfoTable.getBalance() == null || customInfoTable.getBalance().compareTo(entity.getAmount()) < 0) {
+            return false;
+        }
+        return true;
     }
 
     @PostMapping("/manager/approve")
     @FeignClientAnnotation
     public BaseResultDto approve(@RequestBody @Validated FinanceWithdrawApproveEntity entity) throws Exception {
-        if (!StatusConstants.PASSED_STATUS.equals(entity.getStatus()) && !StatusConstants.REJECTED_STATUS.equals(entity.getStatus())) {
+        if (!PayConstants.PASSED_STATUS.equals(entity.getStatus()) && !PayConstants.REJECTED_STATUS.equals(entity.getStatus())) {
             return BaseResultDto.error(Constants.NOT_PERMIT);
         }
+        if (PayConstants.PASSED_STATUS.equals(entity.getStatus())) {
+            entity.setWithdrawStatus(PayConstants.MANAGER_PROCESSING_STATUS);
+        } else {
+            entity.setWithdrawStatus(PayConstants.MANAGER_PENDING_STATUS);
+        }
+        entity.setOperationType(PayConstants.OPERATION_TYPE_MANUAL);
+        financeWithdrawService.approve(entity);
+        return BaseResultDto.success();
+    }
+
+    @PostMapping("/manager/sales/approve")
+    @FeignClientAnnotation
+    public BaseResultDto approveBySales(@RequestBody @Validated FinanceWithdrawApproveSalesEntity entity) throws Exception {
+        if (!PayConstants.PASSED_STATUS.equals(entity.getStatus()) && !PayConstants.REJECTED_STATUS.equals(entity.getStatus())) {
+            return BaseResultDto.error(Constants.NOT_PERMIT);
+        }
+
+        financeWithdrawService.approve(entity);
+        return BaseResultDto.success();
+    }
+
+    @PostMapping("/manager/approve/manager")
+    @FeignClientAnnotation
+    public BaseResultDto approveByManager(@RequestBody @Validated FinanceWithdrawApproveManagerEntity entity) throws Exception {
+        if (!PayConstants.MANAGER_COMPLETED_STATUS.equals(entity.getWithdrawStatus()) && !PayConstants.MANAGER_FAIL_STATUS.equals(entity.getWithdrawStatus())) {
+            return BaseResultDto.error(Constants.NOT_PERMIT);
+        }
+        if (PayConstants.MANAGER_COMPLETED_STATUS.equals(entity.getWithdrawStatus()) && Strings.isNullOrEmpty(entity.getWithdrawTicket())) {
+            return BaseResultDto.error(Constants.PARAMETER_ERROR);
+        }
+        if (PayConstants.MANAGER_COMPLETED_STATUS.equals(entity.getWithdrawStatus())) {
+
+            entity.setCallbackStatus(PayConstants.CALLBACE_PROCESSING_STATUS);
+        } else {
+            entity.setWithdrawTicket(null);
+            entity.setCallbackStatus(null);
+        }
+        financeWithdrawService.approve(entity);
+        financeWithdrawService.sendFastWithdraw(entity);
+        financeWithdrawService.vietnamFastWithdraw(entity.getId());
+        return BaseResultDto.success();
+    }
+
+    @PostMapping("/manager/approve/backstage")
+    @FeignClientAnnotation
+    public BaseResultDto approveByBackstage(@RequestBody @Validated FinanceWithdrawApproveBackstageEntity entity) throws Exception {
+        if (!PayConstants.PASSED_STATUS.equals(entity.getBackstageStatus()) && !PayConstants.REJECTED_STATUS.equals(entity.getBackstageStatus())) {
+            return BaseResultDto.error(Constants.NOT_PERMIT);
+        }
+        financeWithdrawService.approve(entity);
+        financeWithdrawService.vietnamFastWithdraw(entity.getId());
+        return BaseResultDto.success();
+    }
 
+    @PostMapping("/manager/approve/info")
+    @FeignClientAnnotation
+    public BaseResultDto approveByInfo(@RequestBody @Validated FinanceWithdrawApproveInfoEntity entity) throws Exception {
+        if (!PayConstants.PASSED_STATUS.equals(entity.getInfoStatus()) && !PayConstants.REJECTED_STATUS.equals(entity.getInfoStatus())) {
+            return BaseResultDto.error(Constants.NOT_PERMIT);
+        }
         financeWithdrawService.approve(entity);
         return BaseResultDto.success();
     }
 
+    @PostMapping("/manager/approve/infos")
+    @FeignClientAnnotation
+    public BaseResultDto approveByInfos(@RequestBody @Validated FinanceWithdrawApproveInfosEntity entity) throws Exception {
+        if (!PayConstants.PASSED_STATUS.equals(entity.getInfoStatus()) && !PayConstants.REJECTED_STATUS.equals(entity.getInfoStatus())) {
+            return BaseResultDto.error(Constants.NOT_PERMIT);
+        }
+        financeWithdrawService.approve(entity);
+        return BaseResultDto.success();
+    }
+
+    @PostMapping("/manager/approve/submit/channel")
+    @FeignClientAnnotation
+    public BaseResultDto approveBySubmit(@RequestBody @Validated FinanceWithdrawApproveChannelSubmitEntity entity) throws Exception {
+        if (!PayConstants.PASSED_STATUS.equals(entity.getSubmitStatus()) && !PayConstants.REJECTED_STATUS.equals(entity.getSubmitStatus())) {
+            return BaseResultDto.error(Constants.NOT_PERMIT);
+        }
+//        if (Constants.CALLBACE_SUCCESS_STATUS.equals(entity.getCallbackStatus()) && !Strings.isNullOrEmpty(entity
+//        .getChannelSerial())) {
+//            return BaseResultDto.error(Constants.NOT_PERMIT);
+//        }
+        financeWithdrawService.approve(entity);
+        return BaseResultDto.success();
+    }
+
+    @PostMapping("/manager/approve/channel")
+    public BaseResultDto approveByChannel(@RequestBody @Validated FinanceWithdrawApproveChannelEntity entity) throws Exception {
+        if (!PayConstants.CALLBACE_SUCCESS_STATUS.equals(entity.getCallbackStatus()) && !PayConstants.CALLBACE_FAIL_STATUS.equals(entity.getCallbackStatus())) {
+            return BaseResultDto.error(Constants.NOT_PERMIT);
+        }
+//        if (Constants.CALLBACE_SUCCESS_STATUS.equals(entity.getCallbackStatus()) && !Strings.isNullOrEmpty(entity
+//        .getChannelSerial())) {
+//            return BaseResultDto.error(Constants.NOT_PERMIT);
+//        }
+        financeWithdrawService.approve(entity);
+        return BaseResultDto.success();
+    }
+
+    @PostMapping("/manager/approve/submits/channel")
+    @FeignClientAnnotation
+    public BaseResultDto approveBySubmits(@RequestBody @Validated FinanceWithdrawApproveChannelSubmitsEntity entity) throws Exception {
+        if (!PayConstants.PASSED_STATUS.equals(entity.getSubmitStatus()) && !PayConstants.REJECTED_STATUS.equals(entity.getSubmitStatus())) {
+            return BaseResultDto.error(Constants.NOT_PERMIT);
+        }
+//        if (Constants.CALLBACE_SUCCESS_STATUS.equals(entity.getCallbackStatus()) && !Strings.isNullOrEmpty(entity
+//        .getChannelSerial())) {
+//            return BaseResultDto.error(Constants.NOT_PERMIT);
+//        }
+        financeWithdrawService.approve(entity);
+        return BaseResultDto.success();
+    }
+
+    @PostMapping("/manager/approve/channels")
+    public BaseResultDto approveByChannels(@RequestBody @Validated FinanceWithdrawApproveChannelsEntity entity) throws Exception {
+        if (!PayConstants.CALLBACE_SUCCESS_STATUS.equals(entity.getCallbackStatus()) && !PayConstants.CALLBACE_FAIL_STATUS.equals(entity.getCallbackStatus())) {
+            return BaseResultDto.error(Constants.NOT_PERMIT);
+        }
+//        if (Constants.CALLBACE_SUCCESS_STATUS.equals(entity.getCallbackStatus()) && !Strings.isNullOrEmpty(entity
+//        .getChannelSerial())) {
+//            return BaseResultDto.error(Constants.NOT_PERMIT);
+//        }
+        financeWithdrawService.approve(entity);
+        return BaseResultDto.success();
+    }
 
     @PostMapping("/manager/delete")
     @FeignClientAnnotation
@@ -108,23 +387,111 @@ public class FinanceWithdrawController {
         return BaseResultDto.success();
     }
 
-    @PostMapping("/manager/search/list")
+    @PostMapping("/manager/searcher/list")
+    @FeignClientAnnotation
+    public ResultWithPagerDto<FinanceWithdrawDto> searcherList(@RequestBody @Validated FinanceWithdrawSearchListEntity entity) throws Exception {
+
+        if (entity.getStartDate() != null) {
+            entity.setStartDate(DateUtil.parseDate(entity.getStartDate()));
+        }
+        if (entity.getEndDate() != null) {
+            Date endDate = DateUtil.operationDay(entity.getEndDate(), 1);
+            entity.setEndDate(DateUtil.parseDate(endDate));
+        }
+
+        if (entity.getStartSubmitDate() != null) {
+            entity.setStartSubmitDate(DateUtil.parseDate(entity.getStartSubmitDate()));
+        }
+        if (entity.getEndSubmitDate() != null) {
+            Date endDate = DateUtil.operationDay(entity.getEndSubmitDate(), 1);
+            entity.setEndSubmitDate(DateUtil.parseDate(endDate));
+        }
+
+        if (entity.getChannelCodes() == null || entity.getChannelCodes().size() <= 0) {
+            entity.setChannelCodes(null);
+        }
+
+        ResultWithPagerDto<FinanceWithdrawDto> resultWithPagerDto = financeWithdrawService.searchList(entity);
+        return resultWithPagerDto;
+    }
+
+    @PostMapping("/manager/searcher/list/export")
     @FeignClientAnnotation
-    public ResultWithPagerDto<FinanceWithdrawDto> searchList(@RequestBody @Validated FinanceWithdrawSearchListEntity entity, UserInfoEntity infoEntity) throws Exception {
+    public BaseResultDto<List<FinanceWithdrawDto>> searcherListExport(@RequestBody @Validated FinanceWithdrawSearchListEntity entity, CustomInfoEntity infoEntity) throws Exception {
 
+        if (entity.getStartDate() != null) {
+            entity.setStartDate(DateUtil.parseDate(entity.getStartDate()));
+        }
+        if (entity.getEndDate() != null) {
+            Date endDate = DateUtil.operationDay(entity.getEndDate(), 1);
+            entity.setEndDate(DateUtil.parseDate(endDate));
+        }
+
+        if (entity.getStartSubmitDate() != null) {
+            entity.setStartSubmitDate(DateUtil.parseDate(entity.getStartSubmitDate()));
+        }
+        if (entity.getEndSubmitDate() != null) {
+            Date endDate = DateUtil.operationDay(entity.getEndSubmitDate(), 1);
+            entity.setEndSubmitDate(DateUtil.parseDate(endDate));
+        }
         if (PrefixEnum.PREFIX_SALE.equals(infoEntity.getPrefix())) {
-            entity.setStamp(infoEntity.getStamp());
+            entity.setStamp(infoEntity.getIbInfo().getStamp());
         } else {
             entity.setStamp(null);
         }
-        ResultWithPagerDto<FinanceWithdrawDto> resultWithPagerDto = financeWithdrawService.searchList(entity);
-        return resultWithPagerDto;
+
+        if (entity.getChannelCodes() == null || entity.getChannelCodes().size() <= 0) {
+            entity.setChannelCodes(null);
+        }
+        return financeWithdrawService.searchListExport(entity);
+    }
+
+    @PostMapping("/manager/export/ids")
+    @FeignClientAnnotation
+    public BaseResultDto<List<FinanceWithdrawDto>> searcherByIdsExport(@RequestBody @Validated FinanceWithdrawSearchByIdsEntity entity, CustomInfoEntity infoEntity) throws Exception {
+        if (PrefixEnum.PREFIX_SALE.equals(infoEntity.getPrefix())) {
+            entity.setStamp(infoEntity.getIbInfo().getStamp());
+        } else {
+            entity.setStamp(null);
+        }
+        return financeWithdrawService.searcherByIdsExport(entity);
     }
 
-    @PostMapping("/manager/search/single")
+    @PostMapping("/manager/searcher/single")
     @FeignClientAnnotation
-    public BaseResultDto<FinanceWithdrawDto> searchSingle(@RequestBody @Validated SingleLongEntity entity) throws Exception {
+    public BaseResultDto<FinanceWithdrawDto> searcherSingle(@RequestBody @Validated SingleLongEntity entity) throws Exception {
         FinanceWithdrawDto financeWithdrawDto = financeWithdrawService.searchSingle(entity.getId());
         return BaseResultDto.success(financeWithdrawDto);
     }
+
+
+    private void setSalesId(Long id, FinanceWithdrawBaseAddEntity entity) throws Exception {
+        UserInfoTable userInfoTable = userInfoService.getById(id);
+        entity.setSalesId(userInfoTable.getSalesId());
+    }
+
+    /**
+     * 获取所有可出金通道
+     *
+     * @return
+     * @throws Exception
+     */
+    @PostMapping("/manager/remit/channel")
+    @FeignClientAnnotation
+    public BaseResultDto<List<SysRemitChannelApiDto>> remitChannel() throws Exception {
+
+        return BaseResultDto.success(sysRemitChannelService.searchWithdrawApi());
+    }
+
+    /**
+     * 身份认证获取web链接
+     * @param entity
+     * @return
+     *//*
+    @PostMapping("/getWebsdkLink")
+    public BaseResultDto getWebsdkLink(@RequestBody WebsdkLinkAliEntity entity, CustomInfoEntity infoEntity) throws Exception {
+        return financeWithdrawService.getWebsdkLink(entity, infoEntity.getId());
+    }*/
+
+
 }

+ 3 - 2
crm-pay/src/main/java/com/crm/pay/controller/SysRemitChannelController.java

@@ -10,6 +10,7 @@ import com.crm.rely.backend.model.dto.sys.remit.SysRemitChannelDto;
 import com.crm.rely.backend.model.dto.sys.remit.SysRemitChannelGetCodeDto;
 import com.crm.rely.backend.model.entity.sys.remit.SysRemitChannelBatchUpdateEntity;
 import com.crm.rely.backend.model.entity.sys.remit.SysRemitChannelByCodeEntity;
+import com.crm.rely.backend.model.entity.sys.remit.SysRemitChannelListEntity;
 import com.crm.rely.backend.model.entity.sys.remit.SysRemitChannelSearchEntity;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.validation.annotation.Validated;
@@ -32,9 +33,9 @@ public class SysRemitChannelController {
     private SysRemitChannelService sysRemitChannelService;
 
     @PostMapping("/list")
-    public BaseResultDto<List<SysRemitChannelDto>> selectList() throws Exception {
+    public BaseResultDto<List<SysRemitChannelDto>> selectList(@RequestBody @Validated SysRemitChannelListEntity entity) throws Exception {
 
-        return sysRemitChannelService.getAllList();
+        return sysRemitChannelService.getAllList(entity);
     }
 
     /**

+ 7 - 0
crm-pay/src/main/java/com/crm/pay/dao/mapper/FinanceWithdrawMapper.java

@@ -6,6 +6,7 @@ import org.apache.ibatis.annotations.Param;
 import org.springframework.stereotype.Repository;
 
 import java.math.BigDecimal;
+import java.util.Date;
 import java.util.List;
 
 @Repository
@@ -15,7 +16,13 @@ public interface FinanceWithdrawMapper {
 
     List<FinanceWithdrawView> pageList(FinanceWithdrawSearchListEntity entity);
 
+    List<FinanceWithdrawView> listByIds(@Param("ids") List<Long> ids, @Param("stamp") String stamp);
+
     FinanceWithdrawView getOne(Long id);
 
     BigDecimal getWithdrawAmountThatDayByCustomIdAndPayType(@Param("customId") Long customId, @Param("payType") String payType);
+
+    Integer getCountByDateAndCId(@Param("startDate") Date startDate, @Param("endDate") Date endDate,
+                                 @Param("cId") Long cId, @Param("feeReduction") Integer feeReduction);
+
 }

+ 11 - 0
crm-pay/src/main/java/com/crm/pay/dao/mapper/GoldenOrderMapper.java

@@ -0,0 +1,11 @@
+package com.crm.pay.dao.mapper;
+
+import com.crm.rely.backend.model.pojo.table.GoldenOrderDetailsTable;
+import org.apache.ibatis.annotations.Param;
+
+import java.util.List;
+
+public interface GoldenOrderMapper {
+
+    GoldenOrderDetailsTable getByCustomIdAndGoodsIdIn(@Param("customId")Long customId, @Param("goodIds")List<Long> goodIds);
+}

+ 1 - 0
crm-pay/src/main/java/com/crm/pay/dao/repository/FinanceDepositRepository.java

@@ -40,4 +40,5 @@ public interface FinanceDepositRepository extends BaseRepository<FinanceDepositT
 
     @Lock(LockModeType.PESSIMISTIC_WRITE)
     FinanceDepositTable findFirstByChannelSerial(String ticket);
+
 }

+ 4 - 0
crm-pay/src/main/java/com/crm/pay/dao/repository/GoldenOrderDetailsRepository.java

@@ -4,7 +4,11 @@ import com.crm.rely.backend.dao.repository.BaseRepository;
 import com.crm.rely.backend.model.pojo.table.GoldenOrderDetailsTable;
 import org.springframework.stereotype.Repository;
 
+import java.util.Collection;
+import java.util.List;
+
 @Repository
 public interface GoldenOrderDetailsRepository extends BaseRepository<GoldenOrderDetailsTable> {
 
+    List<GoldenOrderDetailsTable> getBySerial(String serial);
 }

+ 4 - 0
crm-pay/src/main/java/com/crm/pay/dao/repository/SysRemitChannelRepository.java

@@ -22,6 +22,8 @@ public interface SysRemitChannelRepository extends BaseRepository<SysRemitChanne
      */
     List<SysRemitChannelTable> getAllByValidOrderBySubIndex(Integer valid);
 
+    List<SysRemitChannelTable> getAllByValidAndCodeInOrderBySubIndex(Integer valid, List<String> codes);
+
     /**
      * 根据code获取通道信息
      *
@@ -51,4 +53,6 @@ public interface SysRemitChannelRepository extends BaseRepository<SysRemitChanne
      */
     SysRemitChannelTable getFirstByCodeAndValidAndFastChannel(String code, Integer valid, Integer fastChannel);
 
+    List<SysRemitChannelTable> getAllByRemitApi(Integer remitApi);
+
 }

+ 2 - 0
crm-pay/src/main/java/com/crm/pay/entity/FinanceDepositCallbackUpdateEntity.java

@@ -32,4 +32,6 @@ public class FinanceDepositCallbackUpdateEntity extends BaseUpdateEntity {
     private String ticket;
 
     private String approveDesc;
+
+    private Integer status;
 }

+ 2 - 14
crm-pay/src/main/java/com/crm/pay/service/CustomInfoService.java

@@ -13,19 +13,7 @@ public interface CustomInfoService {
 
     CustomInfoTable getByCId(Long cId) throws ServiceException;
 
-    void updateCnyAmountById(Long customId, BigDecimal cnyAmount) throws ServiceException;
+    int updateWithdrawFeeReduction(Long cId, int number) throws ServiceException;
 
-    void updateCnyAmountById(Long customId, BigDecimal cnyAmount, String remarks) throws ServiceException;
-
-    void updateCnyAmountByCId(Long cId, BigDecimal cnyAmount) throws ServiceException;
-
-    void updateCnyAmountByCId(Long cId, BigDecimal cnyAmount, String remarks) throws ServiceException;
-
-    void updateUsdAmountById(Long customId, BigDecimal usdAmount) throws ServiceException;
-
-    void updateUsdAmountById(Long customId, BigDecimal usdAmount, String remarks) throws ServiceException;
-
-    void updateUsdAmountByCId(Long cId, BigDecimal usdAmount) throws ServiceException;
-
-    void updateUsdAmountByCId(Long cId, BigDecimal usdAmount, String remarks) throws ServiceException;
+    int getWithdrawFeeReduction(Long cId) throws ServiceException;
 }

+ 43 - 6
crm-pay/src/main/java/com/crm/pay/service/FinanceWithdrawService.java

@@ -6,34 +6,71 @@ import com.crm.rely.backend.core.dto.base.BaseResultDto;
 import com.crm.rely.backend.core.dto.base.ResultWithPagerDto;
 import com.crm.rely.backend.core.exception.ServiceException;
 import com.crm.rely.backend.model.dto.finance.withdraw.FinanceWithdrawDto;
-import com.crm.rely.backend.model.entity.finance.withdraw.FinanceWithdrawApproveEntity;
-import com.crm.rely.backend.model.entity.finance.withdraw.FinanceWithdrawBaseAddEntity;
-import com.crm.rely.backend.model.entity.finance.withdraw.FinanceWithdrawDeleteEntity;
-import com.crm.rely.backend.model.entity.finance.withdraw.FinanceWithdrawSearchListEntity;
+import com.crm.rely.backend.model.entity.finance.withdraw.*;
 import com.crm.rely.backend.model.pojo.table.FinanceWithdrawTable;
 
+import java.util.List;
+
 public interface FinanceWithdrawService {
 
-    BaseResultDto save(FinanceWithdrawBaseAddEntity entity) throws ServiceException;
+    BaseResultDto save(FinanceWithdrawBaseAddEntity entity) throws Exception;
 
     void approve(FinanceWithdrawApproveEntity entity) throws ServiceException;
 
+    void approve(FinanceWithdrawApproveSalesEntity entity) throws ServiceException;
+
+    BaseResultDto<Object> cancel(FinanceWithdrawCancelEntity entity) throws Exception;
+
+    BaseResultDto<Object> cancelBackstage(FinanceWithdrawCancelEntity entity) throws Exception;
+
+    void approve(FinanceWithdrawApproveManagerEntity entity) throws ServiceException;
+
+    void approve(FinanceWithdrawApproveBackstageEntity entity) throws ServiceException;
+
+    void approve(FinanceWithdrawApproveInfoEntity entity) throws ServiceException;
+
+    void approve(FinanceWithdrawApproveInfosEntity entity) throws ServiceException;
+
     void approve(FinanceWithdrawApproveChannelSubmitEntity entity) throws ServiceException;
 
     void approve(FinanceWithdrawApproveChannelEntity entity) throws ServiceException;
 
+    void approve(FinanceWithdrawApproveChannelSubmitsEntity entity) throws ServiceException;
+
+    void approve(FinanceWithdrawApproveChannelsEntity entity) throws ServiceException;
+
     void delete(FinanceWithdrawDeleteEntity entity) throws ServiceException;
 
     ResultWithPagerDto<FinanceWithdrawDto> searchList(FinanceWithdrawSearchListEntity entity) throws ServiceException;
 
+    BaseResultDto<List<FinanceWithdrawDto>> searchListExport(FinanceWithdrawSearchListEntity entity) throws ServiceException;
+
+    BaseResultDto<List<FinanceWithdrawDto>> searcherByIdsExport(FinanceWithdrawSearchByIdsEntity entity) throws ServiceException;
+
     FinanceWithdrawDto searchSingle(Long id) throws ServiceException;
 
+    FinanceWithdrawTable getById(Long id) throws ServiceException;
+
     FinanceWithdrawTable getBySerial(String serial) throws ServiceException;
 
-    FinanceWithdrawTable getByChannelSerial(String channelSerial) throws ServiceException;
+    void applyDigitalWithdrawSendEmailCode(FinanceApplyDigitalWithdrawSendEmailCodeEntity entity) throws ServiceException;
+
+    void applyDigitalWithdrawValidateCode(FinanceWithdrawBaseAddEntity entity) throws ServiceException;
+
+    int getRemainingReductionNumber(Long cId) throws ServiceException;
+
+    //BaseResultDto getWebsdkLink(WebsdkLinkAliEntity entity, Long id) throws ServiceException;
+
+    void sendFastWithdraw(FinanceWithdrawApproveManagerEntity entity) throws Exception;
 
     boolean exFastWithdraw(FinanceWithdrawTable table) throws ServiceException;
 
     boolean exFastWithdraw(Long id) throws ServiceException;
 
+    boolean exVietnamFastWithdraw(FinanceWithdrawTable table) throws ServiceException;
+
+    void vietnamFastWithdraw(Long id) throws Exception;
+
+    FinanceWithdrawTable getByChannelSerial(String channelSerial) throws ServiceException;
+
 }

+ 5 - 5
crm-pay/src/main/java/com/crm/pay/service/SysRemitChannelService.java

@@ -4,12 +4,10 @@ import com.crm.rely.backend.core.dto.base.BaseResultDto;
 import com.crm.rely.backend.core.dto.base.ResultWithPagerDto;
 import com.crm.rely.backend.core.entity.base.SingleLongEntity;
 import com.crm.rely.backend.core.exception.ServiceException;
+import com.crm.rely.backend.model.dto.sys.remit.SysRemitChannelApiDto;
 import com.crm.rely.backend.model.dto.sys.remit.SysRemitChannelDto;
 import com.crm.rely.backend.model.dto.sys.remit.SysRemitChannelGetCodeDto;
-import com.crm.rely.backend.model.entity.sys.remit.SysRemitChannelBaseUpdateEntity;
-import com.crm.rely.backend.model.entity.sys.remit.SysRemitChannelBatchUpdateEntity;
-import com.crm.rely.backend.model.entity.sys.remit.SysRemitChannelByCodeEntity;
-import com.crm.rely.backend.model.entity.sys.remit.SysRemitChannelSearchEntity;
+import com.crm.rely.backend.model.entity.sys.remit.*;
 import com.crm.rely.backend.model.pojo.table.SysRemitChannelTable;
 
 import java.util.List;
@@ -19,7 +17,7 @@ import java.util.List;
  */
 public interface SysRemitChannelService {
 
-    BaseResultDto<List<SysRemitChannelDto>> getAllList() throws Exception;
+    BaseResultDto<List<SysRemitChannelDto>> getAllList(SysRemitChannelListEntity entity) throws Exception;
 
     /**
      * 根据条件 获取单个通道信息
@@ -73,4 +71,6 @@ public interface SysRemitChannelService {
      */
     SysRemitChannelDto searchSingle(SingleLongEntity entity) throws ServiceException;
 
+    List<SysRemitChannelApiDto> searchWithdrawApi() throws ServiceException;
+
 }

+ 16 - 99
crm-pay/src/main/java/com/crm/pay/service/impl/CustomInfoServiceImpl.java

@@ -56,115 +56,32 @@ public class CustomInfoServiceImpl implements CustomInfoService {
 
     @Override
     @Transactional(rollbackFor = Exception.class)
-    public void updateCnyAmountById(Long customId, BigDecimal cnyAmount) throws ServiceException {
-        updateCnyAmountById(customId, cnyAmount, null);
-    }
+    public int updateWithdrawFeeReduction(Long cId, int number) throws ServiceException {
+        CustomInfoTable table = customInfoRepository.findFirstByCId(cId);
 
-    @Override
-    @Transactional(rollbackFor = Exception.class)
-    public void updateCnyAmountById(Long customId, BigDecimal cnyAmount, String remarks) throws ServiceException {
-        CustomInfoTable customInfoTable = customInfoRepository.findFirstById(customId);
-        if (customInfoTable == null) {
-            return;
+// Initialize withdrawFeeReduction to 0 if it's null
+        Integer withdrawFeeReduction = table.getWithdrawFeeReduction();
+        if (withdrawFeeReduction == null) {
+            withdrawFeeReduction = 0;
         }
-        BigDecimal amount;
-        if (customInfoTable.getCnyAmount() == null) {
-            amount = BigDecimal.ZERO;
-        } else {
-            amount = customInfoTable.getCnyAmount();
-        }
-        amount = amount.add(cnyAmount);
-        if (cnyAmount.compareTo(BigDecimal.ZERO) < 0 && amount.compareTo(BigDecimal.ZERO) < 0) {
-            throw ServiceException.exception(PayConstants.INSUFFICIENT_FUNDS);
-        }
-        customInfoTable.setCnyAmount(amount);
-        customInfoRepository.save(customInfoTable);
-        addHistory(customInfoTable, 3, cnyAmount, remarks);
-    }
 
-    @Override
-    @Transactional(rollbackFor = Exception.class)
-    public void updateCnyAmountByCId(Long cId, BigDecimal cnyAmount) throws ServiceException {
-        updateCnyAmountByCId(cId, cnyAmount, null);
-    }
+        int reductionNumber = withdrawFeeReduction + number;
 
-    @Override
-    @Transactional(rollbackFor = Exception.class)
-    public void updateCnyAmountByCId(Long cId, BigDecimal cnyAmount, String remarks) throws ServiceException {
-        CustomInfoTable customInfoTable = customInfoRepository.findFirstByCId(cId);
-        if (customInfoTable == null) {
-            return;
-        }
-        BigDecimal amount;
-        if (customInfoTable.getCnyAmount() == null) {
-            amount = BigDecimal.ZERO;
-        } else {
-            amount = customInfoTable.getCnyAmount();
+// Check if the new reduction number is valid for both positive and negative changes
+        if (reductionNumber >= 0) {
+            table.setWithdrawFeeReduction(reductionNumber);
+            customInfoRepository.save(table);
+            return 1;
         }
-        amount = amount.add(cnyAmount);
-        if (cnyAmount.compareTo(BigDecimal.ZERO) < 0 && amount.compareTo(BigDecimal.ZERO) < 0) {
-            throw ServiceException.exception(PayConstants.INSUFFICIENT_FUNDS);
-        }
-        customInfoTable.setCnyAmount(amount);
-        customInfoRepository.save(customInfoTable);
-        addHistory(customInfoTable, 3, cnyAmount, remarks);
-    }
 
-    @Override
-    @Transactional(rollbackFor = Exception.class)
-    public void updateUsdAmountById(Long customId, BigDecimal usdAmount) throws ServiceException {
-        updateUsdAmountById(customId, usdAmount, null);
+        return 0;
     }
 
     @Override
-    @Transactional(rollbackFor = Exception.class)
-    public void updateUsdAmountById(Long customId, BigDecimal usdAmount, String remarks) throws ServiceException {
-
-        CustomInfoTable customInfoTable = customInfoRepository.findFirstById(customId);
-        if (customInfoTable == null) {
-            return;
-        }
-        BigDecimal amount;
-        if (customInfoTable.getUsdAmount() == null) {
-            amount = BigDecimal.ZERO;
-        } else {
-            amount = customInfoTable.getUsdAmount();
-        }
-        amount = amount.add(usdAmount);
-        if (usdAmount.compareTo(BigDecimal.ZERO) < 0 && amount.compareTo(BigDecimal.ZERO) < 0) {
-            throw ServiceException.exception(PayConstants.INSUFFICIENT_FUNDS);
-        }
-        customInfoTable.setUsdAmount(amount);
-        customInfoRepository.save(customInfoTable);
-        addHistory(customInfoTable, 2, usdAmount, remarks);
-    }
-
-    @Override
-    @Transactional(rollbackFor = Exception.class)
-    public void updateUsdAmountByCId(Long cId, BigDecimal usdAmount) throws ServiceException {
-        updateUsdAmountByCId(cId, usdAmount, null);
-    }
+    public int getWithdrawFeeReduction(Long cId) throws ServiceException {
 
-    @Override
-    @Transactional(rollbackFor = Exception.class)
-    public void updateUsdAmountByCId(Long cId, BigDecimal usdAmount, String remarks) throws ServiceException {
-        CustomInfoTable customInfoTable = customInfoRepository.findFirstByCId(cId);
-        if (customInfoTable == null) {
-            return;
-        }
-        BigDecimal amount;
-        if (customInfoTable.getUsdAmount() == null) {
-            amount = BigDecimal.ZERO;
-        } else {
-            amount = customInfoTable.getUsdAmount();
-        }
-        amount = amount.add(usdAmount);
-        if (usdAmount.compareTo(BigDecimal.ZERO) < 0 && amount.compareTo(BigDecimal.ZERO) < 0) {
-            throw ServiceException.exception(PayConstants.INSUFFICIENT_FUNDS);
-        }
-        customInfoTable.setUsdAmount(amount);
-        customInfoRepository.save(customInfoTable);
-        addHistory(customInfoTable, 2, usdAmount, remarks);
+        CustomInfoTable table = customInfoRepository.getFirstByCId(cId);
+        return table.getWithdrawFeeReduction() == null ? 0 : table.getWithdrawFeeReduction();
     }
 
     private void addHistory(CustomInfoTable customInfoTable, Integer sourceType, BigDecimal amount, String remarks) throws ServiceException {

+ 79 - 14
crm-pay/src/main/java/com/crm/pay/service/impl/FinanceDepositServiceImpl.java

@@ -2,6 +2,7 @@ package com.crm.pay.service.impl;
 
 import com.alibaba.fastjson.JSON;
 import com.crm.pay.dao.mapper.FinanceDepositMapper;
+import com.crm.pay.dao.mapper.GoldenOrderMapper;
 import com.crm.pay.dao.repository.*;
 import com.crm.pay.entity.FinanceDepositCallbackUpdateEntity;
 import com.crm.pay.entity.FinanceDepositCallbackValidateUpdateEntity;
@@ -35,10 +36,7 @@ import com.crm.rely.backend.model.util.CustomInfoUtil;
 import com.crm.rely.backend.service.EmailService;
 import com.crm.rely.backend.service.MqSendService;
 import com.crm.rely.backend.service.RedisService;
-import com.crm.rely.backend.util.DateUtil;
-import com.crm.rely.backend.util.GetIpAndMac;
-import com.crm.rely.backend.util.GetRandom;
-import com.crm.rely.backend.util.UUIDUtil;
+import com.crm.rely.backend.util.*;
 import com.google.common.base.Strings;
 import lombok.extern.log4j.Log4j;
 import org.apache.commons.lang3.StringUtils;
@@ -96,6 +94,8 @@ public class FinanceDepositServiceImpl implements FinanceDepositService {
     @Autowired
     private GoldenGoodsRepository goldenGoodsRepository;
     @Autowired
+    private GoldenOrderMapper goldenOrderMapper;
+    @Autowired
     private RedisService redisService;
     @Autowired
     private SysRemittanceChannelRepository sysRemittanceChannelRepository;
@@ -151,10 +151,15 @@ public class FinanceDepositServiceImpl implements FinanceDepositService {
         List<GoldenGoodsTable> goodsTables = goldenGoodsRepository.findAllByIdIn(balanceSaveEntity.getGoodIds());
         BigDecimal goodsPrice = BigDecimal.ZERO;
         for (GoldenGoodsTable goldenGoodsTable : goodsTables) {
-            goodsPrice.add(goldenGoodsTable.getGoodsPrice());
+            goodsPrice = goodsPrice.add(goldenGoodsTable.getGoodsPrice());
         }
         if (goodsPrice.compareTo(balanceSaveEntity.getAmount()) > 0 ) {
-            throw new ServiceException("amount error");
+            throw new ServiceException("goods_amount_error");
+        }
+
+        GoldenOrderDetailsTable detailsTable = goldenOrderMapper.getByCustomIdAndGoodsIdIn(balanceSaveEntity.getAddUser(), balanceSaveEntity.getGoodIds());
+        if(detailsTable != null){
+            throw new ServiceException("goods_purchased_error");
         }
 
         if (Strings.isNullOrEmpty(balanceSaveEntity.getCurrency())) {
@@ -322,15 +327,15 @@ public class FinanceDepositServiceImpl implements FinanceDepositService {
         //保存订单信息
         financeDepositRepository.save(financeDepositTable);
 
-        GoldenOrderTable order = saveGoldenOrden(balanceSaveEntity, goodsTables, financeDepositTable);
+        GoldenOrderTable order = saveGoldenOrder(balanceSaveEntity, goodsTables, financeDepositTable);
 
-        mqSendService.send(PayConstants.ORDER_DEPOSIT_EXPIRE, order, channel.getExpire() * 1000);
+        //mqSendService.send(PayConstants.ORDER_DEPOSIT_EXPIRE, order, channel.getExpire() * 1000);
 
         return financeDepositTable;
     }
 
     @Transactional(rollbackFor = Exception.class)
-    public GoldenOrderTable saveGoldenOrden(FinanceDepositAddEntity balanceSaveEntity, List<GoldenGoodsTable> goodsTables,FinanceDepositTable financeDepositTable){
+    public GoldenOrderTable saveGoldenOrder(FinanceDepositAddEntity balanceSaveEntity, List<GoldenGoodsTable> goodsTables,FinanceDepositTable financeDepositTable){
         GoldenOrderTable order = new GoldenOrderTable();
         order.setSerial(financeDepositTable.getSerial());
         order.setCustomId(financeDepositTable.getCustomId());
@@ -342,6 +347,9 @@ public class FinanceDepositServiceImpl implements FinanceDepositService {
         order.setStatus(PayConstants.ORDER_UP_PAY_STATUS);
         order.setPayName(balanceSaveEntity.getPayName());
         order.setPayPhone(balanceSaveEntity.getPayPhone());
+        order.setChannelCode(financeDepositTable.getRemittanceChannelCode());
+        order.setChannelName(financeDepositTable.getRemittanceChannelName());
+        order.setChannelEnName(financeDepositTable.getRemittanceChannelEnName());
         goldenOrderRepository.save(order);
 
         List<GoldenOrderDetailsTable> details = new ArrayList<>();
@@ -514,6 +522,11 @@ public class FinanceDepositServiceImpl implements FinanceDepositService {
                     throw new ServiceException(Constants.SYSTEM_ERROR);
                 }
 
+                CustomInfoTable customTable = customInfoRepository.findFirstById(financeDepositTable.getCustomId());
+                if (customTable == null) {
+                    throw new ServiceException(Constants.SYSTEM_ERROR);
+                }
+
                 GoldenOrderTable orderTable = goldenOrderRepository.findFirstBySerial(financeDepositCallbackUpdateEntity.getSerial());
                 if (orderTable == null) {
                     throw new ServiceException(Constants.SYSTEM_ERROR);
@@ -531,6 +544,7 @@ public class FinanceDepositServiceImpl implements FinanceDepositService {
                 if (!Strings.isNullOrEmpty(financeDepositCallbackUpdateEntity.getChannelSerial())) {
                     financeDepositTable.setChannelSerial(financeDepositCallbackUpdateEntity.getChannelSerial());
                 }
+                financeDepositTable.setStatus(financeDepositCallbackUpdateEntity.getStatus());
                 financeDepositTable.setCallbackStatus(financeDepositCallbackUpdateEntity.getCallbackStatus());
                 financeDepositTable.setModifyTime(new Date());
                 financeDepositTable.setCallbackTime(financeDepositCallbackUpdateEntity.getCallbackTime() == null ?
@@ -585,16 +599,31 @@ public class FinanceDepositServiceImpl implements FinanceDepositService {
 
                 //成功处理
                 if (PayConstants.CALLBACE_SUCCESS_STATUS.equals(financeDepositTable.getCallbackStatus())) {
+                    BigDecimal totalSpendingAmount = customTable.getTotalSpendingAmount() == null ? BigDecimal.ZERO : customTable.getTotalSpendingAmount();
+                    customTable.setTotalSpendingAmount(totalSpendingAmount.add(financeDepositTable.getAmount()));
+
+                    customInfoRepository.save(customTable);
+
                     orderTable.setStatus(PayConstants.ORDER_PAY_STATUS);
                     orderTable.setPayTime(financeDepositTable.getCallbackTime());
                 } else if (PayConstants.CALLBACE_FAIL_STATUS.equals(financeDepositTable.getCallbackStatus())) {
                     orderTable.setStatus(PayConstants.ORDER_PAY_ERROR_STATUS);
                 }
+                orderTable.setModifyTime(new Date());
                 goldenOrderRepository.save(orderTable);
 
-                /*if (!Strings.isNullOrEmpty(financeDepositTable.getCallbackMq())) {
-                    mqSendService.send(financeDepositTable.getCallbackMq(), financeDepositTable);
-                }*/
+                if (customTable.getTotalSpendingAmount().compareTo(new BigDecimal(5000)) >= 0) {
+                    mqSendService.send(ConfigConstants.CUSTOM_REWARD_RECORD, customTable.getId());
+                }
+
+                if (PayConstants.CALLBACE_SUCCESS_STATUS.equals(financeDepositTable.getCallbackStatus())) {
+                    List<GoldenOrderDetailsTable> detailsTables =  goldenOrderDetailsRepository.getBySerial(financeDepositTable.getSerial());
+                    for (GoldenOrderDetailsTable detailsTable : detailsTables) {
+                        sendCustomGoldenOrderEmail(financeDepositTable,detailsTable,customTable.getEmail());
+                    }
+
+                }
+
             }
 
         } catch (Exception e) {
@@ -691,7 +720,11 @@ public class FinanceDepositServiceImpl implements FinanceDepositService {
         }
 
         GoldenOrderTable table = goldenOrderRepository.findFirstBySerial(order.getSerial());
-        if (table != null && table.getStatus() == PayConstants.ORDER_UP_PAY_STATUS) {
+        if (table == null) {
+            return;
+        }
+
+        if (table.getStatus() == PayConstants.ORDER_UP_PAY_STATUS) {
             table.setStatus(PayConstants.ORDER_PAY_EXPIRED_STATUS);
             table.setModifyTime(new Date());
             goldenOrderRepository.save(table);
@@ -700,7 +733,6 @@ public class FinanceDepositServiceImpl implements FinanceDepositService {
     }
 
 
-
     private FinanceDepositDto transform(FinanceDepositView financeDepositView) {
         FinanceDepositDto financeDepositDto = new FinanceDepositDto();
         BeanUtils.copyProperties(financeDepositView, financeDepositDto);
@@ -778,6 +810,39 @@ public class FinanceDepositServiceImpl implements FinanceDepositService {
         }
     }
 
+    private void sendCustomGoldenOrderEmail(FinanceDepositTable table, GoldenOrderDetailsTable detailsTable,String email) throws ServiceException {
+
+        //构建map 用于后面邮件模版替换
+        Map<String, String> map = new HashMap<>(3);
+        String name = table.getName();
+
+        map.put(MapConstants.NAME, name);
+
+        map.put(ConfigConstants.DOWNLOAD_URL, detailsTable.getDownload());
+        map.put(MapConstants.DATE_TIME, DateUtil.formatTime(new Date()));
+
+        SysEmailSendEntity sysEmailSendEntity = new SysEmailSendEntity();
+        sysEmailSendEntity.setSubject("Trading Education");
+        sysEmailSendEntity.setEmailSendEnum(EmailSendEnum.CUSTOM_ORDER_SUCCESS);
+        sysEmailSendEntity.setMap(map);
+        if (CountryUtil.isCN(table.getCountry())) {
+            sysEmailSendEntity.setTemplateName(EmailTemplateConstants.CUSTOM_ORDER_SUCCESS_CN);
+        } else {
+            sysEmailSendEntity.setTemplateName(EmailTemplateConstants.CUSTOM_ORDER_SUCCESS_EN);
+        }
+
+        sysEmailSendEntity.setUsers(email);
+        try {
+            emailService.sendEmail(sysEmailSendEntity);
+            WebNoticeRecordAndEmailMqEntity mqEntity = new WebNoticeRecordAndEmailMqEntity(sysEmailSendEntity,
+                    table.getCId(), table.getCustomId());
+            mqSendService.send(Constants.WEB_NOTICE_PUT_RECORD, mqEntity);
+        } catch (Exception e) {
+            e.printStackTrace();
+        }
+    }
+
+
 
     private SysConfigFinanceEntity getConfigFinance() throws ServiceException {
 

+ 2 - 2
crm-pay/src/main/java/com/crm/pay/service/impl/FinanceTrainServiceImpl.java

@@ -184,11 +184,11 @@ public class FinanceTrainServiceImpl implements FinanceTrainService {
             UserInfoTable userInfoTable = userInfoService.getByAgentId(financeTrainTable.getAgentId());
 
             //判断代理id存在且代理存在 代理id对应的是客户 则给对应客户添加佣金
-            if (userInfoTable != null && userInfoTable.getCId() != null) {
+            /*if (userInfoTable != null && userInfoTable.getCId() != null) {
                 customInfoService.updateCnyAmountByCId(userInfoTable.getCId(), new BigDecimal(100), "培训费佣金");
             } else {
                 log.info("agent:" + JSON.toJSONString(userInfoTable));
-            }
+            }*/
         }
 
 

+ 2 - 2
crm-pay/src/main/java/com/crm/pay/service/impl/FinanceTransferServiceImpl.java

@@ -89,7 +89,7 @@ public class FinanceTransferServiceImpl implements FinanceTransferService {
         CustomLoginTable withdrawCustomLoginTable = null;
 
         //如果是美金和人民币账户 则进行扣款
-        if (entity.getSourceType().equals(2)) {
+        /*if (entity.getSourceType().equals(2)) {
             customInfoService.updateUsdAmountById(entity.getCustomId(), entity.getAmount().negate(),
                     "内转->" + entity.getDepositLogin());
         }
@@ -97,7 +97,7 @@ public class FinanceTransferServiceImpl implements FinanceTransferService {
             SysConfigFinanceEntity financeEntity = getConfigFinance();
             BigDecimal cnyAmount = entity.getAmount().multiply(financeEntity.getDepositRate());
             customInfoService.updateCnyAmountById(entity.getCustomId(), cnyAmount.negate(), "内转->" + entity.getDepositLogin());
-        }
+        }*/
 
         List<Long> logins = new ArrayList<>(2);
 

+ 1409 - 197
crm-pay/src/main/java/com/crm/pay/service/impl/FinanceWithdrawServiceImpl.java

@@ -1,48 +1,32 @@
 package com.crm.pay.service.impl;
 
-import com.alibaba.fastjson.JSON;
 import com.crm.pay.dao.mapper.FinanceWithdrawMapper;
-import com.crm.pay.dao.repository.FinanceWithdrawRepository;
-import com.crm.pay.dao.repository.SysRemitChannelRepository;
+import com.crm.pay.dao.repository.*;
 import com.crm.pay.entity.finance.withdraw.FinanceWithdrawApproveChannelEntity;
 import com.crm.pay.entity.finance.withdraw.FinanceWithdrawApproveChannelSubmitEntity;
-import com.crm.pay.service.CustomInfoService;
-import com.crm.pay.service.CustomLoginService;
-import com.crm.pay.service.FinanceWithdrawService;
-import com.crm.pay.service.SysConfigService;
+import com.crm.pay.entity.finance.withdraw.automatic.*;
+import com.crm.pay.service.*;
 import com.crm.rely.backend.configuration.LocaleMessage;
-import com.crm.rely.backend.core.constant.Constants;
-import com.crm.rely.backend.core.constant.EmailSendEnum;
-import com.crm.rely.backend.core.constant.MapConstants;
-import com.crm.rely.backend.core.constant.StatusConstants;
+import com.crm.rely.backend.core.constant.*;
 import com.crm.rely.backend.core.dto.base.BaseResultDto;
 import com.crm.rely.backend.core.dto.base.PageDto;
 import com.crm.rely.backend.core.dto.base.ResultWithPagerDto;
 import com.crm.rely.backend.core.entity.system.email.SysEmailSendEntity;
-import com.crm.rely.backend.core.entity.web.notice.record.WebNoticeRecordAndEmailMqEntity;
-import com.crm.rely.backend.core.pojo.table.SysConfigTable;
 import com.crm.rely.backend.core.exception.ServiceException;
+import com.crm.rely.backend.core.pojo.table.*;
 import com.crm.rely.backend.model.constant.ConfigConstants;
 import com.crm.rely.backend.model.constant.EmailTemplateConstants;
 import com.crm.rely.backend.model.constant.PayConstants;
 import com.crm.rely.backend.model.dto.finance.withdraw.FinanceWithdrawDto;
-import com.crm.rely.backend.model.entity.finance.withdraw.FinanceWithdrawApproveEntity;
-import com.crm.rely.backend.model.entity.finance.withdraw.FinanceWithdrawBaseAddEntity;
-import com.crm.rely.backend.model.entity.finance.withdraw.FinanceWithdrawDeleteEntity;
-import com.crm.rely.backend.model.entity.finance.withdraw.FinanceWithdrawSearchListEntity;
-import com.crm.rely.backend.model.entity.sys.config.SysConfigFinanceEntity;
+import com.crm.rely.backend.model.entity.finance.withdraw.*;
 import com.crm.rely.backend.model.pojo.table.CustomInfoTable;
-import com.crm.rely.backend.model.pojo.table.CustomLoginTable;
 import com.crm.rely.backend.model.pojo.table.FinanceWithdrawTable;
+import com.crm.rely.backend.model.pojo.table.SysChannelBankTable;
 import com.crm.rely.backend.model.pojo.table.SysRemitChannelTable;
 import com.crm.rely.backend.model.pojo.view.FinanceWithdrawView;
-import com.crm.rely.backend.model.util.CustomInfoUtil;
 import com.crm.rely.backend.service.EmailService;
 import com.crm.rely.backend.service.MqSendService;
-import com.crm.rely.backend.service.RedisService;
-import com.crm.rely.backend.util.DateUtil;
-import com.crm.rely.backend.util.GetRandom;
-import com.crm.rely.backend.util.UUIDUtil;
+import com.crm.rely.backend.util.*;
 import com.google.common.base.Strings;
 import lombok.extern.slf4j.Slf4j;
 import org.apache.commons.lang3.StringUtils;
@@ -52,6 +36,7 @@ import org.springframework.stereotype.Service;
 import org.springframework.transaction.annotation.Transactional;
 
 import java.math.BigDecimal;
+import java.math.RoundingMode;
 import java.util.*;
 
 /**
@@ -65,89 +50,181 @@ public class FinanceWithdrawServiceImpl implements FinanceWithdrawService {
 
     @Autowired
     private FinanceWithdrawRepository financeWithdrawRepository;
-
-    @Autowired
-    private SysRemitChannelRepository sysRemitChannelRepository;
-
     @Autowired
     private FinanceWithdrawMapper financeWithdrawMapper;
-
+    @Autowired
+    private FinanceRateService financeRateService;
+    @Autowired
+    private CustomInfoRepository customInfoRepository;
     @Autowired
     private CustomInfoService customInfoService;
-
     @Autowired
-    private CustomLoginService customLoginService;
-
+    private SysRemitChannelService sysRemitChannelService;
+    @Autowired
+    private SysChannelBankService sysChannelBankService;
     @Autowired
     private SysConfigService sysConfigService;
-
+    @Autowired
+    private MqSendService mqSendService;
     @Autowired
     private EmailService emailService;
-
     @Autowired
-    private MqSendService mqSendService;
-
+    private ProxpayService proxpayService;
     @Autowired
-    private RedisService redisService;
-
-
+    private OfaPayService ofaPayService;
+    @Autowired
+    private CheezeepayService cheezeepayService;
+    @Autowired
+    private OzowService ozowService;
+    @Autowired
+    private CwgPayService cwgPayService;
+    @Autowired
+    private MtPayService mtPayService;
+    @Autowired
+    private EcomService ecomService;
+    @Autowired
+    private SysRemitChannelRepository sysRemitChannelRepository;
+    @Autowired
+    private UcardPayService ucardPayService;
+    @Autowired
+    private Va5PayService va5PayService;
+    @Autowired
+    private Pay3PayService pay3PayService;
+    @Autowired
+    private UGatePayService uGatePayService;
+    @Autowired
+    private FlashPayService flashPayService;
+    @Autowired
+    private PartnerPayService partnerPayService;
 
     @Override
     @Transactional(rollbackFor = Exception.class)
-    public BaseResultDto save(FinanceWithdrawBaseAddEntity entity) throws ServiceException {
-        String uuid = UUIDUtil.getUUID();
-        String key = this.getClass().toString() + "save" + entity.getCustomId();
-
-        if (!redisService.tryLock(key, uuid
-                , 5 * 60 * 1000)) {
-            throw ServiceException.exception("no_repeat_submit_error");
+    public BaseResultDto save(FinanceWithdrawBaseAddEntity entity) throws Exception {
+        if (Strings.isNullOrEmpty(entity.getBankCode())) {
+            entity.setBankCode(entity.getPayType());
         }
-        CustomInfoTable customInfoTable = customInfoService.findFirstById(entity.getCustomId());
-        if (customInfoTable == null) {
-            throw new ServiceException(Constants.USER_NOT_EXIST_ERROR);
+
+        //获取通道
+        SysRemitChannelTable sysRemitChannelTable = getChannel(entity.getPayType());
+        if (!entity.getChannelType().equals(sysRemitChannelTable.getType())) {
+            throw new ServiceException(Constants.SYSTEM_ERROR);
         }
-        SysConfigFinanceEntity financeEntity = getConfigFinance();
-        //验证最大最小入金
-        validated(entity, financeEntity);
 
-        BigDecimal cnyAmount = entity.getAmount().multiply(financeEntity.getWithdrawRate());
-        entity.setCny(cnyAmount);
-        entity.setRate(financeEntity.getWithdrawRate());
-        if (entity.getSourceType().equals(2)) {
-            customInfoService.updateUsdAmountById(entity.getCustomId(), entity.getAmount().negate(), "出金");
+        entity.setCurrency(sysRemitChannelTable.getCurrency());
+
+        //获取银行信息
+        SysChannelBankTable sysChannelBankTable = getBank(sysRemitChannelTable, entity);
+
+        if (sysChannelBankTable != null) {
+            entity.setTransformCurrency(sysChannelBankTable.getCurrency());
+        } else {
+            entity.setTransformCurrency(sysRemitChannelTable.getTransformCurrency());
         }
-        if (entity.getSourceType().equals(3)) {
-            customInfoService.updateCnyAmountById(entity.getCustomId(), entity.getCny().negate(), "出金");
+        CustomInfoTable customInfoTable = customInfoRepository.findFirstById(entity.getCustomId());
+        if (customInfoTable == null) {
+            throw new ServiceException(Constants.USER_NOT_EXIST_ERROR);
         }
-        String name = CustomInfoUtil.getName(customInfoTable);
 
-        CustomLoginTable customLoginTable = null;
-        if (entity.getLogin() != null) {
-            customLoginTable = customLoginService.getByCustomIdAndLogin(entity.getCustomId(), entity.getLogin());
-            if (customLoginTable == null) {
-                throw ServiceException.exception(Constants.LOGIN_NOT_NULL_ERROR);
-            }
-        }
+        String name = customInfoTable.getName();
 
         //构建实体
         FinanceWithdrawTable financeWithdrawTable = new FinanceWithdrawTable();
         BeanUtils.copyProperties(entity, financeWithdrawTable);
 
-        financeWithdrawTable.setStatus(StatusConstants.APPLY_STATUS);
+        //计算手续费相关逻辑
+        calculateFee(financeWithdrawTable, sysRemitChannelTable, sysChannelBankTable);
+
+        //校验提款次数
+        //calculateLimit(financeWithdrawTable.getCId());
+
+        //计算实际打款金额
+        calculateTransformAmount(financeWithdrawTable, sysRemitChannelTable, entity);
+
+        //验证最大最小入金
+        validated(entity, sysRemitChannelTable, sysChannelBankTable);
+
+
+        //validDayLimit(financeWithdrawTable.getAmount(), customInfoTable, customLoginTable);
+
+
+        financeWithdrawTable.setAreaCode(customInfoTable.getAreaCode());
+        financeWithdrawTable.setPhone(customInfoTable.getPhone());
+        financeWithdrawTable.setWithdrawCurrency(entity.getCurrency());
+
+        financeWithdrawTable.setCallbackMq(entity.getCallbackMq());
+        financeWithdrawTable.setExtParam(entity.getExtParam());
+
+        //计算扣款金额
+        calculateWithdrawAmount(financeWithdrawTable);
+
+        financeWithdrawTable.setStatus(PayConstants.APPLY_STATUS);
         financeWithdrawTable.setSerial(getOrderNo());
         financeWithdrawTable.setName(name);
-        if (customLoginTable != null) {
-            financeWithdrawTable.setLogin(customLoginTable.getLogin());
-            financeWithdrawTable.setAgentId(customLoginTable.getAgentId());
-        } else {
-            financeWithdrawTable.setAgentId(customInfoTable.getAgentId());
-        }
+        financeWithdrawTable.setWithdrawStatus(PayConstants.MANAGER_PENDING_STATUS);
+        financeWithdrawTable.setCallbackStatus(PayConstants.CALLBACE_PROCESSING_STATUS);
+        
+
+        financeWithdrawTable.setRemitChannelCode(sysRemitChannelTable.getCode());
+        financeWithdrawTable.setRemitChannelCurrency(sysRemitChannelTable.getCurrency());
+        financeWithdrawTable.setRemitChannelEnIcon(sysRemitChannelTable.getEnIcon());
+        financeWithdrawTable.setRemitChannelEnIntroduce(sysRemitChannelTable.getEnIntroduce());
+        financeWithdrawTable.setRemitChannelEnName(sysRemitChannelTable.getEnName());
+        financeWithdrawTable.setRemitChannelIcon(sysRemitChannelTable.getIcon());
+        financeWithdrawTable.setRemitChannelIntroduce(sysRemitChannelTable.getIntroduce());
+        financeWithdrawTable.setRemitChannelName(sysRemitChannelTable.getName());
+        financeWithdrawTable.setRemitChannelRequestUrl(sysRemitChannelTable.getRequestUrl());
+        financeWithdrawTable.setRemitChannelType(sysRemitChannelTable.getType());
+        financeWithdrawTable.setSalesStatus(PayConstants.APPLY_STATUS);
+        financeWithdrawTable.setSubmitStatus(PayConstants.APPLY_STATUS);
+        financeWithdrawTable.setBackstageStatus(PayConstants.APPLY_STATUS);
+        financeWithdrawTable.setInfoStatus(PayConstants.APPLY_STATUS);
+
+        financeWithdrawTable.setCountry(customInfoTable.getCountry());
         financeWithdrawRepository.save(financeWithdrawTable);
 
-        sendWithdrawEmail(financeWithdrawTable);
+        customInfoTable.setBalance(customInfoTable.getBalance().divide(entity.getAmount()));
+        customInfoRepository.save(customInfoTable);
+
+        return BaseResultDto.success(Constants.SUCCESS, financeWithdrawTable.getSerial());
+    }
+
+    @Override
+    @Transactional(rollbackFor = Exception.class)
+    public BaseResultDto<Object> cancel(FinanceWithdrawCancelEntity entity) throws Exception {
+
+        FinanceWithdrawTable financeWithdrawTable = financeWithdrawRepository.findFirstById(entity.getId());
+        if (financeWithdrawTable == null) {
+            throw ServiceException.exception(Constants.INFO_NOT_FOUND);
+        }
+        if (!PayConstants.APPLY_STATUS.equals(financeWithdrawTable.getStatus())) {
+            throw ServiceException.exception(PayConstants.NOT_CANCEL);
+        }
+
+        BeanUtils.copyProperties(entity, financeWithdrawTable);
+        financeWithdrawTable.setStatus(PayConstants.CANCEL_STATUS);
+        financeWithdrawRepository.save(financeWithdrawTable);
 
         return BaseResultDto.success();
+    }
+
+    @Override
+    @Transactional(rollbackFor = Exception.class)
+    public BaseResultDto<Object> cancelBackstage(FinanceWithdrawCancelEntity entity) throws Exception {
+
+        FinanceWithdrawTable financeWithdrawTable = financeWithdrawRepository.findFirstById(entity.getId());
+        if (financeWithdrawTable == null) {
+            throw ServiceException.exception(Constants.INFO_NOT_FOUND);
+        }
+        if (!PayConstants.APPLY_STATUS.equals(financeWithdrawTable.getBackstageStatus())) {
+            throw ServiceException.exception(PayConstants.NOT_CANCEL);
+        }
 
+        BeanUtils.copyProperties(entity, financeWithdrawTable);
+        financeWithdrawTable.setStatus(PayConstants.CANCEL_STATUS);
+        financeWithdrawTable.setBackstageStatus(PayConstants.CANCEL_STATUS);
+        financeWithdrawRepository.save(financeWithdrawTable);
+        refund(financeWithdrawTable);
+        return BaseResultDto.success();
     }
 
     @Override
@@ -157,24 +234,142 @@ public class FinanceWithdrawServiceImpl implements FinanceWithdrawService {
         if (financeWithdrawTable == null) {
             throw ServiceException.exception(Constants.INFO_NOT_FOUND);
         }
-        if (!StatusConstants.APPLY_STATUS.equals(financeWithdrawTable.getStatus())) {
+        if (!PayConstants.MANAGER_PENDING_STATUS.equals(financeWithdrawTable.getWithdrawStatus())
+                || !PayConstants.APPLY_STATUS.equals(financeWithdrawTable.getStatus())) {
+            throw ServiceException.exception(Constants.CANNOT_APPROVE);
+        }
+
+        BeanUtils.copyProperties(entity, financeWithdrawTable);
+
+        financeWithdrawRepository.save(financeWithdrawTable);
+        refund(financeWithdrawTable);
+        if (PayConstants.REJECTED_STATUS.equals(entity.getStatus())) {
+            if (!Strings.isNullOrEmpty(financeWithdrawTable.getCallbackMq())) {
+                mqSendService.send(financeWithdrawTable.getCallbackMq(), financeWithdrawTable);
+            }
+        }
+
+    }
+
+    @Override
+    @Transactional(rollbackFor = Exception.class)
+    public void approve(FinanceWithdrawApproveSalesEntity entity) throws ServiceException {
+        FinanceWithdrawTable table = financeWithdrawRepository.findFirstById(entity.getId());
+        if (table == null) {
+            throw ServiceException.exception(Constants.INFO_NOT_FOUND);
+        }
+        if (!PayConstants.APPLY_STATUS.equals(table.getStatus()) || !PayConstants.APPLY_STATUS.equals(table.getSalesStatus())) {
+            throw ServiceException.exception(Constants.CANNOT_APPROVE);
+        }
+
+        table.setSalesStatus(entity.getStatus());
+        table.setApproveDesc(entity.getApproveDesc());
+        table.setApproveTime(entity.getApproveTime());
+        table.setApproveUser(entity.getApproveUser());
+        table.setModifyIp(entity.getModifyIp());
+        table.setModifyTime(entity.getModifyTime());
+        table.setModifyUser(entity.getModifyUser());
+        if (PayConstants.REJECTED_STATUS.equals(entity.getStatus())) {
+            table.setStatus(entity.getStatus());
+        }
+
+    }
+
+    @Override
+    @Transactional(rollbackFor = Exception.class)
+    public void approve(FinanceWithdrawApproveManagerEntity entity) throws ServiceException {
+        FinanceWithdrawTable financeWithdrawTable = financeWithdrawRepository.findFirstById(entity.getId());
+        if (financeWithdrawTable == null) {
+            throw ServiceException.exception(Constants.INFO_NOT_FOUND);
+        }
+        if (!PayConstants.MANAGER_PROCESSING_STATUS.equals(financeWithdrawTable.getWithdrawStatus())
+                || !PayConstants.PASSED_STATUS.equals(financeWithdrawTable.getStatus())) {
+            throw ServiceException.exception(Constants.CANNOT_APPROVE);
+        }
+
+        BeanUtils.copyProperties(entity, financeWithdrawTable);
+        if (PayConstants.MANAGER_FAIL_STATUS.equals(entity.getWithdrawStatus())) {
+            financeWithdrawTable.setStatus(entity.getWithdrawStatus());
+        } else {
+            financeWithdrawTable.setBackstageStatus(PayConstants.PASSED_STATUS);
+            financeWithdrawTable.setInfoStatus(PayConstants.PASSED_STATUS);
+        }
+
+        financeWithdrawRepository.save(financeWithdrawTable);
+    }
+
+    @Override
+    @Transactional(rollbackFor = Exception.class)
+    public void approve(FinanceWithdrawApproveBackstageEntity entity) throws ServiceException {
+        FinanceWithdrawTable financeWithdrawTable = financeWithdrawRepository.findFirstById(entity.getId());
+        if (financeWithdrawTable == null) {
+            throw ServiceException.exception(Constants.INFO_NOT_FOUND);
+        }
+        if (!PayConstants.MANAGER_COMPLETED_STATUS.equals(financeWithdrawTable.getWithdrawStatus())
+                || !PayConstants.PASSED_STATUS.equals(financeWithdrawTable.getStatus())
+                || !PayConstants.APPLY_STATUS.equals(financeWithdrawTable.getBackstageStatus())) {
             throw ServiceException.exception(Constants.CANNOT_APPROVE);
         }
+        if (PayConstants.REJECTED_STATUS.equals(entity.getBackstageStatus())) {
+            financeWithdrawTable.setStatus(entity.getBackstageStatus());
+        }
+        BeanUtils.copyProperties(entity, financeWithdrawTable);
+
+        financeWithdrawRepository.save(financeWithdrawTable);
+
+        refund(financeWithdrawTable);
+
+    }
 
+    @Override
+    @Transactional(rollbackFor = Exception.class)
+    public void approve(FinanceWithdrawApproveInfoEntity entity) throws ServiceException {
+        FinanceWithdrawTable financeWithdrawTable = financeWithdrawRepository.findFirstById(entity.getId());
+        if (financeWithdrawTable == null) {
+            throw ServiceException.exception(Constants.INFO_NOT_FOUND);
+        }
+        if (!PayConstants.MANAGER_COMPLETED_STATUS.equals(financeWithdrawTable.getWithdrawStatus())
+                || !PayConstants.PASSED_STATUS.equals(financeWithdrawTable.getStatus())
+                || !PayConstants.PASSED_STATUS.equals(financeWithdrawTable.getBackstageStatus())
+                || !PayConstants.APPLY_STATUS.equals(financeWithdrawTable.getInfoStatus())) {
+            throw ServiceException.exception(Constants.CANNOT_APPROVE);
+        }
+        if (PayConstants.REJECTED_STATUS.equals(entity.getInfoStatus())) {
+            financeWithdrawTable.setStatus(entity.getInfoStatus());
+        }
         BeanUtils.copyProperties(entity, financeWithdrawTable);
 
         financeWithdrawRepository.save(financeWithdrawTable);
-        /*if (StatusConstants.REJECTED_STATUS.equals(financeWithdrawTable.getStatus())) {
-            if (financeWithdrawTable.getSourceType().equals(2)) {
-                customInfoService.updateUsdAmountById(financeWithdrawTable.getCustomId(),
-                        financeWithdrawTable.getAmount(), "出金失败退款");
+
+        refund(financeWithdrawTable);
+        
+    }
+
+    @Override
+    @Transactional(rollbackFor = Exception.class)
+    public void approve(FinanceWithdrawApproveInfosEntity entity) throws ServiceException {
+        List<FinanceWithdrawTable> financeWithdrawTables = financeWithdrawRepository.findAllByIdIn(entity.getIds());
+        if (financeWithdrawTables == null) {
+            throw ServiceException.exception(Constants.INFO_NOT_FOUND);
+        }
+        for (FinanceWithdrawTable financeWithdrawTable : financeWithdrawTables) {
+            if (!PayConstants.MANAGER_COMPLETED_STATUS.equals(financeWithdrawTable.getWithdrawStatus())
+                    || !PayConstants.PASSED_STATUS.equals(financeWithdrawTable.getStatus())
+                    || !PayConstants.PASSED_STATUS.equals(financeWithdrawTable.getBackstageStatus())
+                    || !PayConstants.APPLY_STATUS.equals(financeWithdrawTable.getInfoStatus())) {
+                throw ServiceException.exception(Constants.CANNOT_APPROVE);
             }
-            if (financeWithdrawTable.getSourceType().equals(3)) {
-                customInfoService.updateCnyAmountById(financeWithdrawTable.getCustomId(),
-                        financeWithdrawTable.getCny(), "出金失败退款");
+            if (PayConstants.REJECTED_STATUS.equals(entity.getInfoStatus())) {
+                financeWithdrawTable.setStatus(entity.getInfoStatus());
             }
-        }*/
-        sendCustomEmail(financeWithdrawTable);
+            BeanUtils.copyProperties(entity, financeWithdrawTable);
+        }
+
+
+        financeWithdrawRepository.save(financeWithdrawTables);
+
+        refunds(financeWithdrawTables);
+
     }
 
     @Override
@@ -200,12 +395,10 @@ public class FinanceWithdrawServiceImpl implements FinanceWithdrawService {
 
         financeWithdrawRepository.save(financeWithdrawTable);
 
-        //refund(financeWithdrawTable);
+        refund(financeWithdrawTable);
 
         //createWithdrawSubmitSendEmailSysEmailEntity(financeWithdrawTable);
 
-        //sendWithdrawSuccessSalesEmail(financeWithdrawTable);
-
     }
 
     @Override
@@ -238,18 +431,89 @@ public class FinanceWithdrawServiceImpl implements FinanceWithdrawService {
         BeanUtils.copyProperties(entity, financeWithdrawTable);
         if (PayConstants.CALLBACE_FAIL_STATUS.equals(entity.getCallbackStatus())) {
             financeWithdrawTable.setStatus(PayConstants.REJECTED_STATUS);
+        } else if (PayConstants.CALLBACE_SUCCESS_STATUS.equals(entity.getCallbackStatus())) {
+            financeWithdrawTable.setStatus(PayConstants.MANAGER_COMPLETED_STATUS);
         }
         financeWithdrawTable.setCallbackTime(new Date());
         financeWithdrawRepository.save(financeWithdrawTable);
 
-        //refund(financeWithdrawTable);
+        refund(financeWithdrawTable);
+    }
 
-        //sendWithdrawCallbackSalesEmail(financeWithdrawTable);
-        if (PayConstants.CALLBACE_SUCCESS_STATUS.equals(financeWithdrawTable.getCallbackStatus())) {
-            if (!Strings.isNullOrEmpty(financeWithdrawTable.getCallbackMq())) {
-                mqSendService.send(financeWithdrawTable.getCallbackMq(), financeWithdrawTable);
+    @Override
+    @Transactional(rollbackFor = Exception.class)
+    public void approve(FinanceWithdrawApproveChannelSubmitsEntity entity) throws ServiceException {
+        List<FinanceWithdrawTable> financeWithdrawTables = financeWithdrawRepository.findAllByIdIn(entity.getIds());
+        if (financeWithdrawTables == null) {
+            throw ServiceException.exception(Constants.INFO_NOT_FOUND);
+        }
+
+        for (FinanceWithdrawTable financeWithdrawTable : financeWithdrawTables) {
+            if (!PayConstants.MANAGER_COMPLETED_STATUS.equals(financeWithdrawTable.getWithdrawStatus())
+                    || !PayConstants.PASSED_STATUS.equals(financeWithdrawTable.getStatus())
+                    || !PayConstants.PASSED_STATUS.equals(financeWithdrawTable.getBackstageStatus())
+                    || !PayConstants.APPLY_STATUS.equals(financeWithdrawTable.getSubmitStatus())) {
+                throw ServiceException.exception(Constants.CANNOT_APPROVE);
+            }
+            if (PayConstants.REJECTED_STATUS.equals(entity.getSubmitStatus())) {
+                financeWithdrawTable.setStatus(entity.getSubmitStatus());
+            }
+            BeanUtils.copyProperties(entity, financeWithdrawTable);
+
+            financeWithdrawTable.setSubmitTime(new Date());
+        }
+
+
+        financeWithdrawRepository.save(financeWithdrawTables);
+
+        refunds(financeWithdrawTables);
+
+        for (FinanceWithdrawTable financeWithdrawTable : financeWithdrawTables) {
+
+            //createWithdrawSubmitSendEmailSysEmailEntity(financeWithdrawTable);
+
+        }
+
+
+    }
+
+    @Override
+    @Transactional(rollbackFor = Exception.class)
+    public void approve(FinanceWithdrawApproveChannelsEntity entity) throws ServiceException {
+        List<FinanceWithdrawTable> financeWithdrawTables = financeWithdrawRepository.findAllByIdIn(entity.getIds());
+        if (financeWithdrawTables == null) {
+            throw ServiceException.exception(Constants.INFO_NOT_FOUND);
+        }
+        for (FinanceWithdrawTable financeWithdrawTable : financeWithdrawTables) {
+            if (!PayConstants.MANAGER_COMPLETED_STATUS.equals(financeWithdrawTable.getWithdrawStatus())
+                    || !PayConstants.PASSED_STATUS.equals(financeWithdrawTable.getStatus())
+                    || !PayConstants.CALLBACE_PROCESSING_STATUS.equals(financeWithdrawTable.getCallbackStatus())
+                    || !PayConstants.MANAGER_COMPLETED_STATUS.equals(financeWithdrawTable.getSubmitStatus())) {
+                throw ServiceException.exception(Constants.CANNOT_APPROVE);
+            }
+
+            BeanUtils.copyProperties(entity, financeWithdrawTable);
+            if (PayConstants.CALLBACE_FAIL_STATUS.equals(entity.getCallbackStatus())) {
+                financeWithdrawTable.setStatus(PayConstants.REJECTED_STATUS);
             }
+            financeWithdrawTable.setCallbackTime(new Date());
+
+
         }
+
+        financeWithdrawRepository.save(financeWithdrawTables);
+
+        refunds(financeWithdrawTables);
+
+        /*for (FinanceWithdrawTable financeWithdrawTable : financeWithdrawTables) {
+            sendWithdrawCallbackSalesEmail(financeWithdrawTable);
+
+            if (PayConstants.CALLBACE_SUCCESS_STATUS.equals(financeWithdrawTable.getCallbackStatus())) {
+                if (!Strings.isNullOrEmpty(financeWithdrawTable.getCallbackMq())) {
+                    mqSendService.send(financeWithdrawTable.getCallbackMq(), financeWithdrawTable);
+                }
+            }
+        }*/
     }
 
     @Override
@@ -276,11 +540,44 @@ public class FinanceWithdrawServiceImpl implements FinanceWithdrawService {
 
             throw new ServiceException(Constants.SYSTEM_ERROR);
         }
-        List<FinanceWithdrawDto> financeWithdrawDtos = transform(financeWithdrawViews, true);
+        List<FinanceWithdrawDto> financeWithdrawDtos = transform(financeWithdrawViews);
 
         return ResultWithPagerDto.success(pageDto, financeWithdrawDtos);
     }
 
+    @Override
+    public BaseResultDto<List<FinanceWithdrawDto>> searchListExport(FinanceWithdrawSearchListEntity entity) throws ServiceException {
+
+        List<FinanceWithdrawView> financeWithdrawViews = financeWithdrawMapper.pageList(entity);
+        List<FinanceWithdrawDto> financeWithdrawDtos = new ArrayList<>(financeWithdrawViews.size());
+
+        for (FinanceWithdrawView view : financeWithdrawViews) {
+            FinanceWithdrawDto transform = transform(view);
+            financeWithdrawDtos.add(transform);
+        }
+        return BaseResultDto.success(financeWithdrawDtos);
+    }
+
+    @Override
+    public BaseResultDto<List<FinanceWithdrawDto>> searcherByIdsExport(FinanceWithdrawSearchByIdsEntity entity) throws ServiceException {
+        if (entity == null || entity.getIds() == null || entity.getIds().size() <= 0) {
+            return BaseResultDto.success();
+        }
+        List<FinanceWithdrawView> financeWithdrawViews = financeWithdrawMapper.listByIds(entity.getIds(),
+                entity.getStamp());
+
+        if (financeWithdrawViews == null || financeWithdrawViews.size() <= 0) {
+            return BaseResultDto.success();
+        }
+        List<FinanceWithdrawDto> financeWithdrawDtos = new ArrayList<>(financeWithdrawViews.size());
+
+        for (FinanceWithdrawView view : financeWithdrawViews) {
+            FinanceWithdrawDto transform = transform(view);
+            financeWithdrawDtos.add(transform);
+        }
+        return BaseResultDto.success(financeWithdrawDtos);
+    }
+
     @Override
     public FinanceWithdrawDto searchSingle(Long id) throws ServiceException {
         FinanceWithdrawView view = financeWithdrawMapper.getOne(id);
@@ -291,8 +588,8 @@ public class FinanceWithdrawServiceImpl implements FinanceWithdrawService {
     }
 
     @Override
-    public FinanceWithdrawTable getBySerial(String serial) throws ServiceException {
-        FinanceWithdrawTable table = financeWithdrawRepository.getFirstBySerial(serial);
+    public FinanceWithdrawTable getById(Long id) throws ServiceException {
+        FinanceWithdrawTable table = financeWithdrawRepository.getFirstById(id);
         if (table == null) {
             throw ServiceException.exception(Constants.INFO_NOT_FOUND);
         }
@@ -300,171 +597,1086 @@ public class FinanceWithdrawServiceImpl implements FinanceWithdrawService {
     }
 
     @Override
-    public FinanceWithdrawTable getByChannelSerial(String channelSerial) throws ServiceException {
-        FinanceWithdrawTable table = financeWithdrawRepository.getFirstByChannelSerial(channelSerial);
+    public FinanceWithdrawTable getBySerial(String serial) throws ServiceException {
+        FinanceWithdrawTable table = financeWithdrawRepository.getFirstBySerial(serial);
         if (table == null) {
             throw ServiceException.exception(Constants.INFO_NOT_FOUND);
         }
         return table;
     }
 
+    private FinanceWithdrawDto transform(FinanceWithdrawView financeWithdrawView) {
+        FinanceWithdrawDto dto = new FinanceWithdrawDto();
+        BeanUtils.copyProperties(financeWithdrawView, dto);
+        return dto;
+    }
 
-    @Override
-    public boolean exFastWithdraw(FinanceWithdrawTable table) throws ServiceException {
+    private List<FinanceWithdrawDto> transform(List<FinanceWithdrawView> financeWithdrawViews){
+        List<FinanceWithdrawDto> dtos = new ArrayList<>();
+        for (FinanceWithdrawView financeWithdrawView : financeWithdrawViews) {
+            dtos.add(transform(financeWithdrawView));
+        }
+        return dtos;
+    }
 
-        if (table == null) {
-            return false;
+    /*private List<FinanceWithdrawDto> transform(List<FinanceWithdrawView> financeWithdrawViews, boolean isBalance,
+                                               int com) {
+        List<FinanceWithdrawDto> financeWithdrawDtos = new ArrayList<>(financeWithdrawViews.size());
+
+        List<CustomAccountLoginsEntity> customAccountLoginsEntities = new ArrayList<>(financeWithdrawViews.size());
+        List<String> serials = new ArrayList<>(financeWithdrawViews.size());
+        for (FinanceWithdrawView view : financeWithdrawViews) {
+            CustomAccountLoginsEntity customAccountLoginsEntity = new CustomAccountLoginsEntity();
+            customAccountLoginsEntity.setLogin(view.getLogin());
+            customAccountLoginsEntity.setPlatform(view.getPlatform());
+            customAccountLoginsEntities.add(customAccountLoginsEntity);
+            serials.add(view.getSerial());
         }
-        if (PayConstants.MANAGER_COMPLETED_STATUS.equals(table.getWithdrawStatus())) {
-            return false;
+//
+        Map<String, AccountBalanceDto> dtoMap = null;
+//        //判断是否需要请求信息
+//        if (isBalance && customAccountLoginsEntities.size() > 0) {
+//            try {
+//                dtoMap = accountInfoFeignService.accountGetLogins(customAccountLoginsEntities);
+//            } catch (Exception e) {
+//                log.error(e.getMessage());
+//                e.printStackTrace();
+//            }
+//        }
+
+        Map<String, List<FinanceCommentDto>> serialsMap = null;
+        //判断是否需要请求信息
+        if (com > 0 && customAccountLoginsEntities.size() > 0) {
+            try {
+                serialsMap = financeCommentService.searchListByWithdraw(serials);
+            } catch (Exception e) {
+                log.error(e.getMessage());
+                e.printStackTrace();
+            }
         }
-        SysRemitChannelTable channelTable =
-                sysRemitChannelRepository.getFirstByCodeAndValidAndFastChannel(table.getPayType(), 1, 1);
-        // 查询当天出金金额总数
-        BigDecimal amount =
-                financeWithdrawMapper.getWithdrawAmountThatDayByCustomIdAndPayType(table.getCustomId(),
-                        table.getPayType());
-        // 获取系统配置当日快速出金限制最大金额
-        SysConfigTable configTable = sysConfigService.getByCode(PayConstants.UCARD_PAY_WITHDRAW_LIMIT_AMOUNT);
-        if (StringUtils.isEmpty(configTable.getValue())) {
-            log.error("系统未配置ucard当日快速出金限制最大金额");
-            return false;
-        }
-        BigDecimal maxAmount = new BigDecimal(configTable.getValue());
-        if (channelTable != null && table.getPayType().equals(PayConstants.UCARD_PAY_TYPE_REMIT)
-                && amount.compareTo(maxAmount) <= 0) {
-            return true;
+
+        for (FinanceWithdrawView view : financeWithdrawViews) {
+            AccountBalanceDto accountBalanceDto = null;
+            //判断返回结果是否有值
+            if (dtoMap != null) {
+                accountBalanceDto = dtoMap.get(String.valueOf(view.getLogin()));
+            }
+
+            List<FinanceCommentDto> financeCommentDtos = null;
+            if (serialsMap != null) {
+                financeCommentDtos = serialsMap.get(view.getSerial());
+            }
+
+            FinanceWithdrawDto transform = transform(view, accountBalanceDto, financeCommentDtos);
+
+            financeWithdrawDtos.add(transform);
         }
-        return false;
+
+        return financeWithdrawDtos;
     }
 
-    @Override
-    public boolean exFastWithdraw(Long id) throws ServiceException {
-        FinanceWithdrawTable table = financeWithdrawRepository.getFirstById(id);
-        if (table == null) {
-            return false;
+    private FinanceWithdrawDto transform(FinanceWithdrawView financeWithdrawView) {
+
+        return transform(financeWithdrawView, null, null);
+    }
+
+    private FinanceWithdrawDto transform(FinanceWithdrawView financeWithdrawView, AccountBalanceDto accountBalanceDto
+            , List<FinanceCommentDto> financeCommentDtos) {
+        FinanceWithdrawDto dto = new FinanceWithdrawDto();
+        BeanUtils.copyProperties(financeWithdrawView, dto);
+        if (financeWithdrawView.getStatus() != null) {
+            dto.setStatusName(getStatusName(financeWithdrawView));
         }
-        return exFastWithdraw(table);
+        if (accountBalanceDto != null) {
+
+            dto.setBalance(accountBalanceDto.getBalance());
+            dto.setEquity(accountBalanceDto.getEquity());
+            dto.setCredit(accountBalanceDto.getCredit());
+            dto.setFloating(accountBalanceDto.getFloating());
+            dto.setLeverage(accountBalanceDto.getLeverage());
+        }
+        if (!Strings.isNullOrEmpty(financeWithdrawView.getActivityNote())) {
+            dto.setActivityNote(JSON.parseArray(financeWithdrawView.getActivityNote(),
+                    CustomActivityExceptionalManagerActivityNoteDto.class));
+        }
+
+        if (!Strings.isNullOrEmpty(financeWithdrawView.getAddressProve())) {
+            dto.setAddressProve(Arrays.asList(financeWithdrawView.getAddressProve().split(",")));
+        }
+
+        if (Strings.isNullOrEmpty(dto.getApproveDesc())
+                && financeCommentDtos != null
+                && !financeCommentDtos.isEmpty()) {
+
+            StringBuilder sb = new StringBuilder();
+
+            for (FinanceCommentDto financeCommentDto : financeCommentDtos) {
+                if (financeCommentDto == null || Strings.isNullOrEmpty(financeCommentDto.getComment())) {
+                    continue;
+                }
+                if (sb.length() > 0) {
+                    sb.append("\n");
+                }
+                sb.append(financeCommentDto.getComment());
+            }
+
+            if (sb.length() > 0) {
+                dto.setApproveDesc(sb.toString());
+            }
+        }
+
+
+        return dto;
     }
 
-    private void sendWithdrawEmail(FinanceWithdrawTable table) throws ServiceException {
+    private String getStatusName(FinanceWithdrawView financeWithdrawView) {
+        try {
+            return localeMessage.getMessage(TranslateUtil.statusToName(financeWithdrawView.getStatus(),
+                    financeWithdrawView.getCallbackStatus(), financeWithdrawView.getWithdrawStatus()));
+        } catch (Exception e) {
+            return null;
+        }
+    }*/
 
-        SysConfigTable sysConfigTable = sysConfigService.getByCode(ConfigConstants.FINANCE_WITHDRAW_MANAGER_EMAIL);
-        if (sysConfigTable == null) {
-            throw new ServiceException(Constants.SYSTEM_ERROR);
+    /**
+     * 验证数据
+     *
+     * @param entity
+     * @throws ServiceException
+     */
+    public void validated(FinanceWithdrawBaseAddEntity entity, SysRemitChannelTable sysRemitChannelTable,
+                          SysChannelBankTable sysChannelBankTable) throws ServiceException {
+
+        List<String> codes = new ArrayList<>(2);
+        BigDecimal max = null;
+        BigDecimal min = null;
+        //判断银行(货币)通道上是否携带最大最小入金量
+        if (sysChannelBankTable != null) {
+            if (sysChannelBankTable.getMinAmount() != null) {
+                min = sysChannelBankTable.getMinAmount();
+            }
+            if (sysChannelBankTable.getMaxAmount() != null) {
+                max = sysChannelBankTable.getMaxAmount();
+            }
+        }
+        //判断通道上是否携带最大最小入金量
+        if (min == null && sysRemitChannelTable.getMinAmount() == null) {
+            codes.add(ConfigConstants.FINANCE_WITHDRAW_MIN);
+        } else {
+            min = sysRemitChannelTable.getMinAmount();
         }
-        String users = sysConfigTable.getValue();
+        if (max == null && sysRemitChannelTable.getMinAmount() == null) {
+            codes.add(ConfigConstants.FINANCE_WITHDRAW_MAX);
+        } else {
+            max = sysRemitChannelTable.getMaxAmount();
+        }
+        if (codes != null && codes.size() > 0) {
+            List<SysConfigTable> configTables = sysConfigService.getByCodes(codes);
+            if (configTables == null || configTables.size() < codes.size()) {
+                throw new ServiceException(Constants.SYSTEM_ERROR);
+            }
 
-        if (users == null) {
-            throw new ServiceException(Constants.SYSTEM_ERROR);
+            for (SysConfigTable configTable : configTables) {
+
+                if (ConfigConstants.FINANCE_WITHDRAW_MAX.equals(configTable.getCode())) {
+                    try {
+                        max = new BigDecimal(configTable.getValue());
+                    } catch (NumberFormatException e) {
+                        throw new ServiceException(Constants.SYSTEM_ERROR);
+                    }
+                }
+                if (ConfigConstants.FINANCE_WITHDRAW_MIN.equals(configTable.getCode())) {
+                    try {
+                        min = new BigDecimal(configTable.getValue());
+                    } catch (NumberFormatException e) {
+                        throw new ServiceException(Constants.SYSTEM_ERROR);
+                    }
+                }
+            }
         }
-        //构建map 用于后面邮件模版替换
-        Map<String, String> map = new HashMap<>(10);
 
-        map.put(MapConstants.LOGIN, table.getLogin() + "");
+        if (entity.getAmount().intValue() < min.intValue()) {
+            throw new ServiceException(localeMessage.getMessage(PayConstants.FINANCE_WITHDRAW_AMOUNT_LESS_THAN,
+                    PayConstants.FINANCE_WITHDRAW_AMOUNT_LESS_THAN) + min.intValue() + entity.getCurrency());
+        }
+        if (entity.getAmount().intValue() > max.intValue()) {
+            throw new ServiceException(localeMessage.getMessage(PayConstants.FINANCE_WITHDRAW_AMOUNT_GREATER_THAN,
+                    PayConstants.FINANCE_WITHDRAW_AMOUNT_GREATER_THAN) + max.intValue() + entity.getCurrency());
+        }
+    }
 
-        map.put(MapConstants.NAME, table.getName());
+    /**
+     * 获取通道
+     *
+     * @param channelCode
+     * @return
+     * @throws ServiceException
+     */
+    private SysRemitChannelTable getChannel(String channelCode) throws ServiceException {
+        SysRemitChannelTable sysRemitChannelTable = sysRemitChannelService.getSysRemitChannelByCode(channelCode);
 
-        map.put(MapConstants.WITHDRAW_AMOUNT, table.getAmount() == null ? "" : String.format("%.2f", table.getAmount().doubleValue()));
-        map.put(MapConstants.APPLY_TIME, DateUtil.formatTime(table.getAddTime()));
-        map.put(MapConstants.SERIAL, table.getSerial());
-        map.put(MapConstants.DATE_TIME, DateUtil.formatTime(new Date()));
+        if (sysRemitChannelTable == null) {
+            throw new ServiceException(PayConstants.FINANCE_WITHDRAW_CHANNEL_NOT_EMPTY);
+        }
+        return sysRemitChannelTable;
+    }
 
-        SysEmailSendEntity sysEmailSendEntity = new SysEmailSendEntity();
-        sysEmailSendEntity.setSubject("CWG DEPOSIT");
-        sysEmailSendEntity.setEmailSendEnum(EmailSendEnum.FINANCE_WITHDRAW_NOTICE);
-        sysEmailSendEntity.setMap(map);
-        sysEmailSendEntity.setTemplateName(EmailTemplateConstants.FINANCE_WITHDRAW_NOTICE_NAME);
-        sysEmailSendEntity.setUsers(users);
+    /**
+     * 获取银行信息
+     *
+     * @param channelTable
+     * @param entity
+     * @return
+     * @throws ServiceException
+     */
+    private SysChannelBankTable getBank(SysRemitChannelTable channelTable, FinanceWithdrawBaseAddEntity entity) throws ServiceException {
+        if (channelTable.getBankValid() != null && channelTable.getBankValid().equals(1)) {
+            SysChannelBankTable sysChannelBankTable = sysChannelBankService.getByCode(entity.getBankCode(),
+                    channelTable.getCode());
+            if (sysChannelBankTable == null) {
+                throw new ServiceException(Constants.SYSTEM_ERROR);
+            }
+            return sysChannelBankTable;
+        }
+        return null;
+    }
+
+    private void calculateTransformAmount(FinanceWithdrawTable financeWithdrawTable,
+                                          SysRemitChannelTable sysRemitChannelTable,
+                                          FinanceWithdrawBaseAddEntity entity) throws ServiceException {
+        BigDecimal rate;
         try {
-            emailService.sendEmail(sysEmailSendEntity);
+            if (sysRemitChannelTable.getRate() != null) {
+                rate = sysRemitChannelTable.getRate();
+            } else {
+                rate = financeRateService.getRate(financeWithdrawTable.getCurrency(),
+                        financeWithdrawTable.getTransformCurrency(), 1);
+            }
+
+            if (rate == null) {
+                throw ServiceException.exception();
+            }
         } catch (Exception e) {
-            e.printStackTrace();
+            log.error(e.getMessage());
+            rate = null;
+        }
+
+        // 设置当前提现使用的汇率
+        financeWithdrawTable.setRate(rate);
+
+        if (rate != null) {
+
+            // 如果请求中存在固定汇率和固定汇率金额
+            // 且当前使用的汇率与固定汇率不一致
+            if (entity.getFixedRate() != null
+                    && entity.getFixedRateAmount() != null
+                    && rate.compareTo(entity.getFixedRate()) != 0) {
+
+                // 根据固定汇率金额反算提现原始金额
+                // 计算方式:固定汇率金额 ÷ 汇率
+                // 结果保留2位小数,并向上取整
+                financeWithdrawTable.setAmount(
+                        entity.getFixedRateAmount()
+                                .divide(financeWithdrawTable.getRate(), 8, RoundingMode.UP)
+                                .setScale(2, BigDecimal.ROUND_UP)
+                );
+            }
+
+            if (financeWithdrawTable.getFeeAmount() != null && financeWithdrawTable.getFeeReductionAmount() != null && financeWithdrawTable.getFeeAmount().compareTo(financeWithdrawTable.getFeeReductionAmount()) == 0 && entity.getFixedRateAmount() != null) {
+                // 计算最终转换金额(到账金额)
+                financeWithdrawTable.setTransformAmount(entity.getFixedRateAmount());
+            } else {
+                // 计算最终转换金额(到账金额)
+                // 公式:
+                // (提现金额 - 手续费 + 手续费减免) × 当前汇率
+                financeWithdrawTable.setTransformAmount(
+                        financeWithdrawTable.getAmount()
+                                .subtract(financeWithdrawTable.getFeeAmount())
+                                .add(financeWithdrawTable.getFeeReductionAmount())
+                                .multiply(rate)
+                );
+            }
+
+
+        } else {
+            // 如果没有汇率,则转换金额置为空
+            financeWithdrawTable.setTransformAmount(null);
+        }
+
+        if (financeWithdrawTable.getTransformAmount() != null) {
+            if ("cny".equals(financeWithdrawTable.getTransformCurrency().toLowerCase())
+                    || "thb".equals(financeWithdrawTable.getTransformCurrency().toLowerCase())
+                    || "vnd".equals(financeWithdrawTable.getTransformCurrency().toLowerCase())) {
+
+                financeWithdrawTable.setTransformAmount(financeWithdrawTable.getTransformAmount().setScale(0,
+                        BigDecimal.ROUND_DOWN));
+            }
         }
+
     }
 
-    private void sendCustomEmail(FinanceWithdrawTable table) throws ServiceException {
+    /**
+     * 获取平台出金金额
+     *
+     * @param financeWithdrawTable
+     * @return
+     * @throws ServiceException
+     */
+    private void calculateWithdrawAmount(FinanceWithdrawTable financeWithdrawTable) throws ServiceException {
 
-        CustomInfoTable customInfoTable = customInfoService.getById(table.getCustomId());
-        if (customInfoTable == null) {
-            throw new ServiceException(Constants.USER_NOT_EXIST_ERROR);
+        BigDecimal withdrawAmount = null;
+        BigDecimal rate = null;
+        if (financeWithdrawTable.getWithdrawCurrency().equals(financeWithdrawTable.getCurrency())) {
+            withdrawAmount = financeWithdrawTable.getAmount();
+        } else {
+            //获取汇率 如果特定通道没有汇率 则根据我方设定汇率计算
+            rate = financeRateService.getRate(financeWithdrawTable.getCurrency(),
+                    financeWithdrawTable.getWithdrawCurrency(), 1);
+
+            if (rate == null) {
+                throw ServiceException.exception();
+            }
+            withdrawAmount = financeWithdrawTable.getAmount().multiply(rate);
+        }
+
+
+        financeWithdrawTable.setWithdrawAmount(withdrawAmount.setScale(2, BigDecimal.ROUND_UP));
+    }
+    
+    private String getOrderNo() {
+        /**
+         * 生成订单号
+         */
+        String orderNo = GetRandom.getOrderNoByFormat("yyMMddHHmmssSS", PayConstants.WITHDRAW_HEAD);
+        return orderNo;
+    }
+
+    @Override
+    public void applyDigitalWithdrawSendEmailCode(FinanceApplyDigitalWithdrawSendEmailCodeEntity entity) throws ServiceException {
+
+        //构建实体
+       /* SysEmailSendEntity sysEmailSendEntity = createApplyDigitalWithdrawSendEmailSysEmailEntity(entity);
+
+        //发送收据
+        emailService.sendCode(sysEmailSendEntity, sysEmailSendEntity.getMap().get(MapConstants.CODE) +
+                "applyDigitalWithdrawSendEmailCode");*/
+    }
+
+    @Override
+    public void applyDigitalWithdrawValidateCode(FinanceWithdrawBaseAddEntity entity) throws ServiceException {
+
+        emailService.validateCode(entity.getEmail(), entity.getEmailCode() +
+                "applyDigitalWithdrawSendEmailCode");
+    }
+
+    /*@Override
+    @Transactional(rollbackFor = Exception.class)
+    public BaseResultDto getWebsdkLink(WebsdkLinkAliEntity entity, Long id) throws ServiceException {
+        SysConfigTable kycWithdrawConfigTable = sysConfigService.getByCode(ConfigConstants.AUTOMATIC_KYC_WITHDRAW);
+        if (kycWithdrawConfigTable == null) {
+            throw ServiceException.exception(Constants.INFO_NOT_FOUND);
+        }
+        SysConfigTable kycFastWithdrawConfigTable =
+                sysConfigService.getByCode(ConfigConstants.AUTOMATIC_KYC_FAST_WITHDRAW);
+        if (kycFastWithdrawConfigTable == null) {
+            throw ServiceException.exception(Constants.INFO_NOT_FOUND);
+        }
+        if ("0".equals(kycWithdrawConfigTable.getValue()) && "0".equals(kycFastWithdrawConfigTable.getValue())) {
+            return BaseResultDto.success();
+        }
+
+        CustomInfoTable table = customInfoRepository.findFirstById(id);
+        if (table == null) {
+            throw ServiceException.exception(Constants.INFO_NOT_FOUND);
+        }
+        FinanceWithdrawTable withdrawTable = financeWithdrawRepository.findFirstBySerial(entity.getSerial());
+        if (withdrawTable == null) {
+            throw ServiceException.exception(Constants.INFO_NOT_FOUND);
+        }
+        SysConfigTable sysConfigTable = sysConfigService.getByCode(ConfigConstants.CUSTOM_VERIFY_KYC_PROPERTY);
+        if (sysConfigTable == null) {
+            throw ServiceException.exception(Constants.INFO_NOT_FOUND);
+        }
+        SysKycConfigTable kycConfig = sysKycConfigService.getByCodeAndCountryAndEnable(sysConfigTable.getValue(),
+                table.getCountry(), 1);
+        if (kycConfig == null) {
+            throw ServiceException.exception(Constants.INFO_NOT_FOUND);
         }
-        //构建map 用于后面邮件模版替换
-        Map<String, String> map = new HashMap<>(10);
 
-        map.put(MapConstants.NAME, table.getName());
-        map.put(MapConstants.LOGIN, String.valueOf(table.getLogin()));
-        map.put(MapConstants.WITHDRAW_AMOUNT, table.getAmount() == null ? "" : String.format("%.2f", table.getAmount().doubleValue()));
-        map.put(MapConstants.DATE_TIME, DateUtil.formatTime(new Date()));
-        map.put(MapConstants.APPROVE_DESC, table.getApproveDesc());
-        map.put(MapConstants.APPROVE_STATUS, table.getStatus().equals(2) ? "通过" : "拒绝");
+        if (2 == kycConfig.getKycType() && !Strings.isNullOrEmpty(withdrawTable.getKycVerifyUrl())) {
+            return BaseResultDto.success(Constants.SUCCESS, withdrawTable.getKycVerifyUrl());
+        }
+
+        CustomKycVerifyRecodeEntity customKycVerifyRecodeEntity = new CustomKycVerifyRecodeEntity();
+        customKycVerifyRecodeEntity.setCountry(table.getCountry());
+        customKycVerifyRecodeEntity.setConfig(ConfigConstants.CUSTOM_VERIFY_KYC_PROPERTY);
+        customKycVerifyRecodeEntity.setCardType(table.getCardType());
+        customKycVerifyRecodeEntity.setVerifyId(table.getId());
+        customKycVerifyRecodeEntity.setVerifyType(3);
+        customKycVerifyRecodeEntity.setOrderSerial(entity.getSerial());
+        customKycVerifyRecodeEntity.setCustomAuth(table.getAuthStatus());
+        customKycVerifyRecodeEntity.setEndUserId(Strings.isNullOrEmpty(table.getEndUserId()) ?
+                UUID.randomUUID().toString() : table.getEndUserId());
+
+        if (3 != kycConfig.getKycType()) {
+            withdrawTable.setExternalUserId(UUIDUtil.getUUID());
+
+            customKycVerifyRecodeEntity.setExternalUserId(withdrawTable.getExternalUserId());
+            String applicantId = kycFeignService.createApplicant(customKycVerifyRecodeEntity);
+
+            *//*customKycVerifyRecodeEntity.setApplicantId(applicantId);
+            List<CustomFileTable> fileList = customFileDao.findFileByType(table.getId());
+            if(fileList != null && fileList.size() > 0){
+                customKycVerifyRecodeEntity.setVerifyType(1);
+                customKycVerifyRecodeEntity.setVerifyFile(fileList.stream().map(CustomFileTable::getPath).collect
+                (Collectors.joining(",")));
+                kycFeignService.uploadImage(customKycVerifyRecodeEntity);
+            }*//*
+
+            withdrawTable.setApplicantId(applicantId);
+        }
+
+        withdrawTable.setAuthStatus(0);
+        withdrawTable.setExternalUserId(Strings.isNullOrEmpty(customKycVerifyRecodeEntity.getExternalUserId()) ?
+                UUIDUtil.getUUID() : customKycVerifyRecodeEntity.getExternalUserId());
+
+        customKycVerifyRecodeEntity.setMetaInfo(entity.getMetaInfo());
+        customKycVerifyRecodeEntity.setExternalUserId(withdrawTable.getExternalUserId());
+        customKycVerifyRecodeEntity.setApplicantId(withdrawTable.getApplicantId());
+        BaseResultDto dto = kycFeignService.getWebsdkLink(customKycVerifyRecodeEntity);
+        if (2 == kycConfig.getKycType() && Strings.isNullOrEmpty(withdrawTable.getKycVerifyUrl())) {
+            withdrawTable.setKycVerifyUrl(dto.getData().toString());
+        }
+        financeWithdrawRepository.save(withdrawTable);
 
+        if (Strings.isNullOrEmpty(table.getEndUserId())) {
+            table.setEndUserId(customKycVerifyRecodeEntity.getEndUserId());
+            customInfoRepository.save(table);
+        }
+
+        return dto;
+    }*/
+
+    public void fastFinanceWithdraw(FinanceWithdrawTable table) throws Exception {
+        log.info(String.format("越南快速出金通道处理:%s", table.getSerial()));
+
+        switch (table.getPayType()) {
+            case PayConstants.PROXPAY_PAY_TYPE_REMIT:
+                FinanceWithdrawProxpayEntity proxpayEntity = new FinanceWithdrawProxpayEntity();
+                proxpayEntity.setName(table.getName());
+                proxpayEntity.setBankName(table.getBankName());
+                proxpayEntity.setBookBankName(table.getBankUname());
+                proxpayEntity.setBookBankNumber(table.getBankCardNum());
+                proxpayEntity.setBookBankBranch(table.getBankBranchName());
+                proxpayEntity.setAmount(table.getTransformAmount() == null ? null :
+                        table.getTransformAmount().setScale(2, BigDecimal.ROUND_DOWN));
+                proxpayEntity.setPreferCurrency(table.getTransformCurrency());
+                proxpayEntity.setRefCustomerId(String.valueOf(table.getCId()));
+                proxpayEntity.setId(table.getId());
+                proxpayEntity.setSerial(table.getSerial());
+                proxpayEntity.setPayType(table.getPayType());
+                proxpayService.withdraw(proxpayEntity);
+                break;
+            case PayConstants.OFA_PAY_TYPE_REMIT:
+                FinanceWithdrawOfaEntity ofapayEntity = new FinanceWithdrawOfaEntity();
+                ofapayEntity.setMoney(table.getTransformAmount() == null ? null :
+                        table.getTransformAmount().setScale(2, BigDecimal.ROUND_DOWN));
+                ofapayEntity.setAccountname(table.getName());
+                ofapayEntity.setAccountno(table.getBankCardNum());
+                if (!Strings.isNullOrEmpty(table.getBankName())) {
+                    String[] sp = table.getBankName().split("-");
+                    if (sp.length >= 2) {
+                        ofapayEntity.setBankname(sp[0]);
+                        ofapayEntity.setBankno(sp[1]);
+                    }
+                }
+                ofapayEntity.setId(table.getId());
+                ofapayEntity.setSerial(table.getSerial());
+                ofapayEntity.setPayType(table.getPayType());
+                ofaPayService.withdraw(ofapayEntity);
+                break;
+
+            case PayConstants.CHEEZEEPAY_PAY_TYPE_REMIT:
+                FinanceWithdrawCheezeepayEntity cheezeepayEntity = new FinanceWithdrawCheezeepayEntity();
+                cheezeepayEntity.setAmount(table.getTransformAmount() == null ? null :
+                        table.getTransformAmount().setScale(2, BigDecimal.ROUND_DOWN));
+                cheezeepayEntity.setName(table.getName());
+                cheezeepayEntity.setAccountNumber(table.getBankCardNum());
+                cheezeepayEntity.setIfscCode(table.getCustomBankCode());
+                cheezeepayEntity.setBankName(table.getBankName());
+                cheezeepayEntity.setBranchName(table.getBankBranchName());
+                cheezeepayEntity.setId(table.getId());
+                cheezeepayEntity.setSerial(table.getSerial());
+                cheezeepayEntity.setPayType(table.getPayType());
+                cheezeepayService.withdraw(cheezeepayEntity);
+                break;
+            case PayConstants.OZOW_PAY_TYPE_REMIT:
+                FinanceWithdrawOzowEntity ozowEntity = new FinanceWithdrawOzowEntity();
+                ozowEntity.setAmount(table.getTransformAmount() == null ? null :
+                        table.getTransformAmount().setScale(2, BigDecimal.ROUND_DOWN));
+                ozowEntity.setBankingCode(table.getCustomBankCode());
+                ozowEntity.setAccountNumber(table.getBankCardNum());
+                ozowEntity.setId(table.getId());
+                ozowEntity.setSerial(table.getSerial());
+                ozowEntity.setPayType(table.getPayType());
+                ozowService.withdraw(ozowEntity);
+                break;
+            case PayConstants.CWG_UNION_PAY_TYPE_REMIT:
+                FinanceWithdrawCwgEntity cwgEntity = new FinanceWithdrawCwgEntity();
+                cwgEntity.setAmount(table.getTransformAmount() == null ? null :
+                        table.getTransformAmount().setScale(2, BigDecimal.ROUND_DOWN));
+                cwgEntity.setBankUname(table.getBankUname());
+                cwgEntity.setName(table.getName());
+                cwgEntity.setBankCardNum(table.getBankCardNum());
+                cwgEntity.setBankBranchName(table.getBankBranchName());
+                if (!Strings.isNullOrEmpty(table.getBankName())) {
+                    String[] sp = table.getBankName().split("-");
+                    cwgEntity.setBankName(sp[0]);
+                }
+                cwgEntity.setBankAddr(table.getBankAddr());
+                cwgEntity.setSwiftCode(table.getSwiftCode());
+                cwgEntity.setBankCode(table.getBankCode());
+                cwgEntity.setId(table.getId());
+                cwgEntity.setSerial(table.getSerial());
+                cwgEntity.setPayType(table.getPayType());
+                cwgPayService.withdraw(cwgEntity);
+            case PayConstants.CWG_PAY_TYPE_REMIT:
+                FinanceWithdrawCwgEntity cwgAliEntity = new FinanceWithdrawCwgEntity();
+                cwgAliEntity.setAmount(table.getTransformAmount() == null ? null :
+                        table.getTransformAmount().setScale(2, BigDecimal.ROUND_DOWN));
+                cwgAliEntity.setName(table.getName());
+                cwgAliEntity.setWalletAddress(table.getAddress());
+                cwgAliEntity.setId(table.getId());
+                cwgAliEntity.setSerial(table.getSerial());
+                cwgAliEntity.setPayType(table.getPayType());
+                cwgPayService.withdraw(cwgAliEntity);
+            case PayConstants.MT_PAY_TYPE_REMIT:
+                FinanceWithdrawMtpayEntity mtpayEntity = new FinanceWithdrawMtpayEntity();
+                mtpayEntity.setRealName(table.getName());
+                mtpayEntity.setWithdrawAmount(table.getTransformAmount() == null ? null :
+                        table.getTransformAmount().setScale(2, BigDecimal.ROUND_DOWN));
+                mtpayEntity.setCardNumber(table.getBankCardNum());
+                mtpayEntity.setBankName(table.getBankName());
+                mtpayEntity.setBankBranchName(table.getBankBranchName());
+                mtpayEntity.setWithdrawCurrency(table.getWithdrawCurrency());
+                mtpayEntity.setFiatCurrency(table.getTransformCurrency());
+                mtpayEntity.setId(table.getId());
+                mtpayEntity.setSerial(table.getSerial());
+                mtpayEntity.setPayType(table.getPayType());
+                mtPayService.withdraw(mtpayEntity);
+                break;
+            case PayConstants.PAY_ECOM_REMIT_KEY:
+                FinanceWithdrawEcomEntity payEcomEntity = new FinanceWithdrawEcomEntity();
+                payEcomEntity.setAmount(table.getTransformAmount() == null ? null :
+                        table.getTransformAmount().setScale(2, BigDecimal.ROUND_DOWN));
+                payEcomEntity.setBankAccountName(table.getName());
+                payEcomEntity.setBankAccountNo(table.getBankCardNum());
+                payEcomEntity.setBankCode(table.getBankCode());
+                payEcomEntity.setId(table.getId());
+                payEcomEntity.setSerial(table.getSerial());
+                payEcomEntity.setPayType(table.getPayType());
+                ecomService.withdraw(payEcomEntity);
+                break;
+//            case PayConstants.VA5_PAY_TYPE_USDT_REMIT:
+//                FinanceWithdrawVa5PayEntity va5PayUsdtEntity = new FinanceWithdrawVa5PayEntity();
+//                va5PayUsdtEntity.setWallet("");
+//                va5PayUsdtEntity.setToken(table.getBankCode());
+//                va5PayUsdtEntity.setWithdrawalAmount(table.getTransformAmount() == null ? null : table
+//                .getTransformAmount().setScale(2, BigDecimal.ROUND_DOWN));
+//                va5PayUsdtEntity.setByReceivableAmount(false);
+//                va5PayUsdtEntity.setWalletAddress(table.getAddress());
+//                va5PayUsdtEntity.setId(table.getId());
+//                va5PayUsdtEntity.setSerial(table.getSerial());
+//                va5PayUsdtEntity.setPayType(table.getPayType());
+//                va5PayService.withdraw(va5PayUsdtEntity);
+//                break;
+//            case PayConstants.VA5_PAY_TYPE_F2F_REMIT:
+//                FinanceWithdrawVa5PayEntity va5PayF2fEntity = new FinanceWithdrawVa5PayEntity();
+//
+//                va5PayF2fEntity.setWallet("Fiat2Fiat");
+//                va5PayF2fEntity.setToken(table.getBankCode());
+//                va5PayF2fEntity.setWithdrawalAmount(table.getTransformAmount() == null ? null : table
+//                .getTransformAmount().setScale(2, BigDecimal.ROUND_DOWN));
+//                va5PayF2fEntity.setByReceivableAmount(false);
+//                va5PayF2fEntity.setBeneficiaryName(table.getName());
+//                va5PayF2fEntity.setBeneficiaryAccountNumber(table.getBankCardNum());
+//                va5PayF2fEntity.setBeneficiaryBank(table.getBankName());
+//                va5PayF2fEntity.setBeneficiaryBankAddress(table.getBankAddr());
+//                va5PayF2fEntity.setBeneficiaryBankCode(table.getBankCode());
+//                va5PayF2fEntity.setBeneficiaryBankSwiftCode(table.getSwiftCode());
+//                va5PayF2fEntity.setBeneficiaryPhoneNumber(table.getPhone());
+//                va5PayF2fEntity.setIfsc(table.getBankCode());
+//                va5PayF2fEntity.setId(table.getId());
+//                va5PayF2fEntity.setSerial(table.getSerial());
+//                va5PayF2fEntity.setPayType(table.getPayType());
+//                va5PayService.withdraw(va5PayF2fEntity);
+//                break;
+            case PayConstants.PAY3_PAY_TYPE_REMIT:
+                FinanceWithdrawPay3payEntity pay3PayEntity = new FinanceWithdrawPay3payEntity();
+                pay3PayEntity.setAmount(table.getTransformAmount() == null ? null :
+                        table.getTransformAmount().setScale(2, BigDecimal.ROUND_DOWN));
+                pay3PayEntity.setCurrency(table.getBankCode());
+                pay3PayEntity.setAddress(table.getAddress());
+                pay3PayEntity.setId(table.getId());
+                pay3PayEntity.setSerial(table.getSerial());
+                pay3PayEntity.setPayType(table.getPayType());
+                pay3PayService.withdraw(pay3PayEntity);
+                break;
+            case PayConstants.UCARD_PAY_TYPE_REMIT:
+                FinanceWithdrawUcardpayEntity ucardPayEntity = new FinanceWithdrawUcardpayEntity();
+                ucardPayEntity.setAmount(table.getTransformAmount() == null ? null :
+                        table.getTransformAmount().setScale(2, BigDecimal.ROUND_DOWN));
+                ucardPayEntity.setId(table.getId());
+                ucardPayEntity.setSerial(table.getSerial());
+                ucardPayEntity.setPayType(table.getPayType());
+                ucardPayService.withdraw(ucardPayEntity);
+                break;
+            case PayConstants.UGATE_PAY_TYPE_REMIT:
+                FinanceWithdrawUGateEntity uGatePayEntity = new FinanceWithdrawUGateEntity();
+                uGatePayEntity.setReceiverName(table.getName());
+                uGatePayEntity.setMerchantSellOrderMoney(table.getTransformAmount() == null ? null :
+                        table.getTransformAmount().setScale(2, RoundingMode.DOWN).toString());
+                uGatePayEntity.setReceiverAccount(table.getBankCardNum());
+                uGatePayEntity.setReceiverBankName(table.getBankName());
+                uGatePayEntity.setReceiverBankAddress(table.getBankBranchName());
+                uGatePayEntity.setId(table.getId());
+                uGatePayEntity.setSerial(table.getSerial());
+                uGatePayEntity.setPayType(table.getPayType());
+                uGatePayService.withdraw(uGatePayEntity);
+                break;
+            case PayConstants.FLASH_PAY_TYPE_REMIT:
+                FinanceWithdrawFlashEntity flashPayEntity = new FinanceWithdrawFlashEntity();
+                flashPayEntity.setAmount(table.getTransformAmount() == null ? null :
+                        table.getTransformAmount().setScale(2, BigDecimal.ROUND_DOWN));
+                flashPayEntity.setBankcardAccountName(table.getName());
+                flashPayEntity.setBankcardAccountNo(table.getBankName());
+                flashPayEntity.setBankCode(table.getCustomBankCode());
+
+                flashPayEntity.setId(table.getId());
+                flashPayEntity.setSerial(table.getSerial());
+                flashPayEntity.setPayType(table.getPayType());
+                flashPayService.withdraw(flashPayEntity);
+                break;
+            case PayConstants.PARTNER_PAY_TYPE_REMIT:
+                FinanceWithdrawPartnerEntity partnerEntity = new FinanceWithdrawPartnerEntity();
+                partnerEntity.setAmount(table.getTransformAmount() == null ? null :
+                        table.getTransformAmount().setScale(2, BigDecimal.ROUND_DOWN));
+                partnerEntity.setName(table.getName());
+                partnerEntity.setBankName(table.getBankUname());
+                partnerEntity.setBankBranch(table.getBankBranchName());
+                partnerEntity.setBankAccount(table.getBankCardNum());
+
+                partnerEntity.setId(table.getId());
+                partnerEntity.setSerial(table.getSerial());
+                partnerEntity.setPayType(table.getPayType());
+                partnerPayService.withdraw(partnerEntity);
+                break;
+            default:
+                break;
+        }
+    }
+
+
+    /*private SysEmailSendEntity createApplyDigitalWithdrawSendEmailSysEmailEntity(FinanceApplyDigitalWithdrawSendEmailCodeEntity entity) throws ServiceException {
         SysEmailSendEntity sysEmailSendEntity = new SysEmailSendEntity();
-        sysEmailSendEntity.setSubject("CWG DEPOSIT");
+
+        Map<String, String> map = new HashMap<>(2);
+        String code = GetRandom.getRandom(6);
+        map.put(MapConstants.CODE, code);
+        Date time = DateUtil.operationMinute(new Date(), Constants.EMAIL_VALIDATECODE_TIME);
+        map.put(MapConstants.EXPIRE_TIME, DateUtil.formatTime(time));
+        map.put(MapConstants.DATE_TIME, DateUtil.formatTime());
+
+        sysEmailSendEntity.setAddIp(entity.getIp());
+        sysEmailSendEntity.setAddTime(entity.getTime());
+
+        sysEmailSendEntity.setUsers(entity.getEmail());
+        sysEmailSendEntity.setEmailSendEnum(EmailSendEnum.CUSTOM_APPLY_DIGITAL_WITHDRAW_SEND);
+        if (CountryUtil.isCN(entity.getCountry())) {
+            sysEmailSendEntity.setTemplateName(EmailTemplateConstants.CUSTOM_APPLY_DIGITAL_WITHDRAW_SEND_CN);
+        } else {
+            sysEmailSendEntity.setTemplateName(EmailTemplateConstants.CUSTOM_APPLY_DIGITAL_WITHDRAW_SEND_EN);
+        }
         sysEmailSendEntity.setMap(map);
+        //发送收据
+        emailService.sendEmail(sysEmailSendEntity);
+        return sysEmailSendEntity;
+    }
 
-        sysEmailSendEntity.setTemplateName(EmailTemplateConstants.FINANCE_WITHDRAW_APPROVE_NOTICE_RESULT);
+    private void createWithdrawSubmitSendEmailSysEmailEntity(FinanceWithdrawTable table) throws ServiceException {
+
+        if (!PayConstants.PASSED_STATUS.equals(table.getSubmitStatus())) {
+            return;
+        }
 
-        sysEmailSendEntity.setUsers(customInfoTable.getEmail());
         try {
+            CustomInfoTable customInfoTable = customInfoService.getById(table.getCustomId());
+            SysEmailSendEntity sysEmailSendEntity = new SysEmailSendEntity();
+
+            Map<String, String> map = new HashMap<>(2);
+
+            map.put(MapConstants.SERIAL, table.getSerial());
+
+            map.put(MapConstants.NAME, table.getName());
+            map.put(MapConstants.DATE_TIME, DateUtil.formatTime());
+
+            sysEmailSendEntity.setUsers(customInfoTable.getEmail());
+            sysEmailSendEntity.setEmailSendEnum(EmailSendEnum.CUSTOM_WITHDRAW_SUBMIT_SEND);
+            if (CountryUtil.isCN(customInfoTable.getCountry())) {
+                sysEmailSendEntity.setTemplateName(EmailTemplateConstants.CUSTOM_WITHDRAW_SUBMIT_SEND_CN);
+            } else {
+                sysEmailSendEntity.setTemplateName(EmailTemplateConstants.CUSTOM_WITHDRAW_SUBMIT_SEND_EN);
+            }
+            sysEmailSendEntity.setMap(map);
             emailService.sendEmail(sysEmailSendEntity);
+
             WebNoticeRecordAndEmailMqEntity mqEntity = new WebNoticeRecordAndEmailMqEntity(sysEmailSendEntity,
-                    table.getCId(), table.getCustomId());
+                    table.getCId());
             mqSendService.send(Constants.WEB_NOTICE_PUT_RECORD, mqEntity);
         } catch (Exception e) {
-            e.printStackTrace();
+            return;
+        }
+
+    }*/
+
+    private void refund(FinanceWithdrawTable table) throws ServiceException {
+        if ((PayConstants.CALLBACE_FAIL_STATUS.equals(table.getCallbackStatus())
+                || PayConstants.REJECTED_STATUS.equals(table.getSubmitStatus())
+                || PayConstants.REJECTED_STATUS.equals(table.getBackstageStatus())
+                || PayConstants.REJECTED_STATUS.equals(table.getInfoStatus())
+                || PayConstants.CANCEL_STATUS.equals(table.getBackstageStatus()))
+                && table.getOperationType() != null
+                && PayConstants.OPERATION_TYPE_AUTOMATIC == table.getOperationType()
+                && PayConstants.MANAGER_COMPLETED_STATUS.equals(table.getWithdrawStatus())) {
+
+            CustomInfoTable customInfoTable = customInfoRepository.findFirstById(table.getCustomId());
+            if (customInfoTable == null) {
+                log.error("custom refund error:"+table.getSerial());
+            }
+            customInfoTable.setBalance(customInfoTable.getBalance().add(table.getAmount()));
+            customInfoRepository.save(customInfoTable);
+
         }
     }
 
-    private List<FinanceWithdrawDto> transform(List<FinanceWithdrawView> financeWithdrawViews, boolean isBalance) {
-        List<FinanceWithdrawDto> financeWithdrawDtos = new ArrayList<>(financeWithdrawViews.size());
+    private void refunds(List<FinanceWithdrawTable> tables) throws ServiceException {
+        if (tables == null) {
+            return;
+        }
 
-        for (FinanceWithdrawView view : financeWithdrawViews) {
+        for (FinanceWithdrawTable table : tables) {
+            if ((PayConstants.CALLBACE_FAIL_STATUS.equals(table.getCallbackStatus())
+                    || PayConstants.REJECTED_STATUS.equals(table.getSubmitStatus())
+                    || PayConstants.REJECTED_STATUS.equals(table.getBackstageStatus())
+                    || PayConstants.REJECTED_STATUS.equals(table.getInfoStatus())
+                    || PayConstants.CANCEL_STATUS.equals(table.getBackstageStatus()))
+                    && table.getOperationType() != null
+                    && PayConstants.OPERATION_TYPE_AUTOMATIC == table.getOperationType()
+                    && PayConstants.MANAGER_COMPLETED_STATUS.equals(table.getWithdrawStatus())) {
+
+                CustomInfoTable customInfoTable = customInfoRepository.findFirstById(table.getCustomId());
+                if (customInfoTable == null) {
+                    log.error("custom refund error:"+table.getSerial());
+                }
+                customInfoTable.setBalance(customInfoTable.getBalance().add(table.getAmount()));
+                customInfoRepository.save(customInfoTable);
 
-            FinanceWithdrawDto transform = transform(view);
-            financeWithdrawDtos.add(transform);
+            }
         }
-        return financeWithdrawDtos;
     }
 
-    private FinanceWithdrawDto transform(FinanceWithdrawView financeWithdrawView) {
-        FinanceWithdrawDto dto = new FinanceWithdrawDto();
-        BeanUtils.copyProperties(financeWithdrawView, dto);
+   /* private void validDayLimit(BigDecimal withdrawAmount, CustomInfoTable customInfoTable) throws ServiceException {
 
-        return dto;
+        BigDecimal limitAmount = null;
+        if (customInfoTable.getDayWithdrawLimit() != null) {
+            limitAmount = customInfoTable.getDayWithdrawLimit();
+        } else {
+            SysConfigTable configTable = sysConfigService.getByCode(ConfigConstants.FINANCE_WITHDRAW_DAY_LIMIT);
+            if (Strings.isNullOrEmpty(configTable.getValue())) {
+                return;
+            }
+            limitAmount = new BigDecimal(configTable.getValue());
+        }
+
+        //如果小于0 则表示每日出金无限制
+        if (limitAmount == null || limitAmount.compareTo(BigDecimal.ZERO) < 0) {
+            return;
+        }
+
+        Date startDate = DateUtil.parseDate();
+
+        Float amount = financeWithdrawMapper.getCountAmountByDateAndCId(startDate, DateUtil.addDate(startDate, 1),
+                customLoginTable.getCId());
+
+        if (amount == null) {
+            amount = 0f;
+        }
+        BigDecimal dayAmount = new BigDecimal(amount);
+        if (withdrawAmount.add(new BigDecimal(amount)).compareTo(limitAmount) > 0) {
+            throw new ServiceException(String.format(localeMessage.getMessage("finance_withdraw_amount_day_limit"),
+                    String.format("%.2f", limitAmount.add(dayAmount.negate()).doubleValue())));
+        }
+    }*/
+
+    private void calculateFee(FinanceWithdrawTable table, SysRemitChannelTable remitChannelTable,
+                              SysChannelBankTable sysChannelBankTable) throws ServiceException {
+
+        // 计算手续费金额
+        BigDecimal feeAmount = BigDecimal.ZERO;
+        if (sysChannelBankTable == null || sysChannelBankTable.getFeeType() == null) {
+
+            feeAmount = cleFeeAmount(remitChannelTable.getFeeType(), remitChannelTable.getFree(),
+                    remitChannelTable.getFeeAmount(), table.getAmount());
+
+        } else {
+            feeAmount = cleFeeAmount(sysChannelBankTable.getFeeType(), sysChannelBankTable.getFree(),
+                    sysChannelBankTable.getFeeAmount(), table.getAmount());
+        }
+
+
+        table.setFeeAmount(feeAmount);
+
+        if (feeAmount.compareTo(BigDecimal.ZERO) == 0) {
+            table.setFeeReduction(0);
+            table.setFeeReductionAmount(BigDecimal.ZERO);
+            return;
+        }
+
+        int reductionNumber = getReductionNumber();
+
+        int count = getMonthNumber(table.getCId());//减免次数
+
+        // 如果出金次数少于减免次数,则减免手续费
+        if (count < reductionNumber) {
+            table.setFeeReduction(1);
+            table.setFeeReductionAmount(feeAmount);
+            return;
+        }
+
+//        // 根据账号手续费减免次数判断是否减免
+//        if (customLoginService.updateWithdrawFeeReduction(table.getLogin(), -1) >= 1) {
+//            table.setFeeReduction(1);
+//            table.setFeeReductionAmount(feeAmount);
+//        } else {
+//            table.setFeeReduction(0);
+//            table.setFeeReductionAmount(BigDecimal.ZERO);
+//        }
+
+        // 根据cid手续费减免次数判断是否减免
+        if (customInfoService.updateWithdrawFeeReduction(table.getCId(), -1) >= 1) {
+            table.setFeeReduction(1);
+            table.setFeeReductionAmount(feeAmount);
+        } else {
+            table.setFeeReduction(0);
+            table.setFeeReductionAmount(BigDecimal.ZERO);
+        }
+    }
+
+    private BigDecimal cleFeeAmount(Integer feeType, Integer feeRate, BigDecimal feeTypeAmount, BigDecimal amount) {
+        BigDecimal feeAmount = BigDecimal.ZERO;
+        // 处理费率类型逻辑
+        if (feeType != null && feeType.equals(1)) {
+
+            if (feeRate == null) {
+                feeRate = 0;
+            } else {
+                feeAmount = amount
+                        .multiply(new BigDecimal(feeRate))
+                        .divide(new BigDecimal(100), 5, BigDecimal.ROUND_HALF_UP)
+                        .setScale(2, BigDecimal.ROUND_UP);
+            }
+        } else if (feeType != null && feeType.equals(2)) {
+            // 固定金额手续费
+            feeAmount = feeTypeAmount == null ? BigDecimal.ZERO : feeTypeAmount;
+        } else {
+            feeAmount = BigDecimal.ZERO;
+        }
+        return feeAmount;
+    }
+
+    private int getReductionNumber() throws ServiceException {
+        // 计算减免次数
+        SysConfigTable configTable = sysConfigService.getByCode(ConfigConstants.FINANCE_WITHDRAW_FEE_REDUCTION_NUMBER);
+
+        // 如果减免配置为空,则不减免
+        if (Strings.isNullOrEmpty(configTable.getValue())) {
+            return 0;
+        }
+
+        // 尝试转化减免次数,如果失败则默认减免次数为0
+        int reductionNumber = 0;
+        try {
+            reductionNumber = Integer.parseInt(configTable.getValue());
+        } catch (NumberFormatException e) {
+            // 忽略异常,使用默认值0
+        }
+        return reductionNumber;
+    }
+
+    private int getMonthNumber(Long cId) {
+        // 计算本月的出金次数
+        Date startDate = DateUtil.parseMonth();
+        Integer count = financeWithdrawMapper.getCountByDateAndCId(startDate, DateUtil.operationMoth(startDate, 1),
+                cId, 1);
+        count = (count == null) ? 0 : count;
+       /* Integer agentCount = financeAgentWithdrawMapper.getCountByDateAndCId(startDate,
+                DateUtil.operationMoth(startDate, 1), cId, 1);
+        count = (agentCount == null) ? count : count + agentCount;*/
+        return count;
+    }
+
+    private void calculateLimit(Long cId) throws Exception {
+        // 获取次数数量限制
+        SysConfigTable configTable = sysConfigService.getByCode(ConfigConstants.FINANCE_WITHDRAW_NUMBER_LIMIT);
+        if (Strings.isNullOrEmpty(configTable.getValue())) {
+            throw new ServiceException("calculate_number_limit_error");
+        }
+        int reductionNumber = 0;
+        try {
+            reductionNumber = Integer.parseInt(configTable.getValue());
+        } catch (NumberFormatException e) {
+            throw new ServiceException("calculate_number_limit_error");
+        }
+
+        // 计算出金次数
+        Date startDate = DateUtil.parseDate(DateUtil.formatDate(new Date()));
+        Integer count = financeWithdrawMapper.getCountByDateAndCId(startDate, DateUtil.addDate(startDate, 1),
+                cId, null);
+        count = (count == null) ? 0 : count;
+        /*Integer agentCount = financeAgentWithdrawMapper.getCountByDateAndCId(startDate,
+                DateUtil.operationMoth(startDate, 1), cId, null);
+        count = (agentCount == null) ? count : count + agentCount;*/
+
+        if(count >= reductionNumber){
+            throw new ServiceException("calculate_number_limit_error");
+        }
+    }
+
+    @Override
+    public int getRemainingReductionNumber(Long cId) throws ServiceException {
+        int withdrawFeeReductionNumber = customInfoService.getWithdrawFeeReduction(cId);
+
+        int reductionNumber = getReductionNumber() - getMonthNumber(cId);
+
+        if (reductionNumber < 0) {
+            return withdrawFeeReductionNumber;
+        } else {
+            return reductionNumber + withdrawFeeReductionNumber;
+        }
     }
 
     /**
-     * 验证数据
-     *
-     * @param entity
-     * @throws ServiceException
+     * 快速到账
      */
-    public void validated(FinanceWithdrawBaseAddEntity entity, SysConfigFinanceEntity financeEntity) throws ServiceException {
+    @Override
+    public void sendFastWithdraw(FinanceWithdrawApproveManagerEntity entity) throws Exception {
+        if (PayConstants.MANAGER_COMPLETED_STATUS.equals(entity.getWithdrawStatus())) {
+            FinanceWithdrawTable table = financeWithdrawRepository.getFirstById(entity.getId());
+            if (exFastWithdraw(table)) {
+                FinanceWithdrawUcardpayEntity ucardPayentity = new FinanceWithdrawUcardpayEntity();
+                BeanUtils.copyProperties(table, ucardPayentity);
+                ucardPayentity.setWithdrawInfoType(1);
+                ucardPayentity.setAmount(table.getTransformAmount());
+                ucardPayService.withdraw(ucardPayentity);
+            }
+        }
+    }
 
-        if (entity.getAmount().intValue() < financeEntity.getMinWithdraw().intValue()) {
-            throw new ServiceException(localeMessage.getMessage(PayConstants.FINANCE_WITHDRAW_AMOUNT_LESS_THAN,
-                    PayConstants.FINANCE_WITHDRAW_AMOUNT_LESS_THAN) + financeEntity.getMinWithdraw().intValue());
+    @Override
+    public boolean exFastWithdraw(FinanceWithdrawTable table) throws ServiceException {
+
+        if (table == null) {
+            return false;
+        }
+        if (PayConstants.MANAGER_COMPLETED_STATUS.equals(table.getWithdrawStatus())) {
+            return false;
+        }
+        SysRemitChannelTable channelTable =
+                sysRemitChannelRepository.getFirstByCodeAndValidAndFastChannel(table.getPayType(), 1, 1);
+        // 查询当天出金金额总数
+        BigDecimal amount =
+                financeWithdrawMapper.getWithdrawAmountThatDayByCustomIdAndPayType(table.getCustomId(),
+                        table.getPayType());
+        // 获取系统配置当日快速出金限制最大金额
+        SysConfigTable configTable = sysConfigService.getByCode(PayConstants.UCARD_PAY_WITHDRAW_LIMIT_AMOUNT);
+        if (StringUtils.isEmpty(configTable.getValue())) {
+            log.error("系统未配置ucard当日快速出金限制最大金额");
+            return false;
+        }
+        BigDecimal maxAmount = new BigDecimal(configTable.getValue());
+        if (channelTable != null && table.getPayType().equals(PayConstants.UCARD_PAY_TYPE_REMIT)
+                && amount.compareTo(maxAmount) <= 0) {
+            return true;
+        }
+        return false;
+    }
+
+    @Override
+    public boolean exFastWithdraw(Long id) throws ServiceException {
+        FinanceWithdrawTable table = financeWithdrawRepository.getFirstById(id);
+        if (table == null) {
+            return false;
         }
+        return exFastWithdraw(table);
     }
 
-    private SysConfigFinanceEntity getConfigFinance() throws ServiceException {
+    @Override
+    public boolean exVietnamFastWithdraw(FinanceWithdrawTable table) throws ServiceException {
+
+        if (table == null) {
+            return false;
+        }
+        if (!PayConstants.PASSED_STATUS.equals(table.getBackstageStatus())) {
+            return false;
+        }
+        if (!PayConstants.SUBMIT_PROCESSING_STATUS.equals(table.getSubmitStatus())) {
+            return false;
+        }
+        if (!"VN".equals(table.getCountry())) {
+            return false;
+        }
+        if (table.getRemitChannelType().equals(PayConstants.CHANNEL_TYPE_DIGITAL_CURRENCY)) {
+            return false;
+        }
+        SysRemitChannelTable channelTable =
+                sysRemitChannelRepository.getFirstByCodeAndValidAndFastChannel(table.getPayType(), 1, 1);
+        if (channelTable == null) {
+            return false;
+        }
 
-        SysConfigTable sysConfigTable = sysConfigService.getByCode(ConfigConstants.FINANCE_CONFIGURE);
-        SysConfigFinanceEntity financeEntity = JSON.parseObject(sysConfigTable.getValue(), SysConfigFinanceEntity.class);
-        if (financeEntity == null) {
-            throw ServiceException.exception(Constants.SYSTEM_ERROR);
+        SysConfigTable configTable = sysConfigService.getByCode(PayConstants.VN_WITHDRAW_LIMIT_AMOUNT);
+        if (table.getAmount().compareTo(new BigDecimal(configTable.getValue())) <= 0) {
+            return true;
         }
-        return financeEntity;
+        return false;
     }
 
+    /**
+     * 越南快速到账
+     */
+    @Override
+    public void vietnamFastWithdraw(Long id) throws Exception {
+        FinanceWithdrawTable table = financeWithdrawRepository.getFirstById(id);
+        if (exVietnamFastWithdraw(table)) {
+            table.setWithdrawStatus(PayConstants.MANAGER_COMPLETED_STATUS);
+            table.setOperationType(PayConstants.OPERATION_TYPE_AUTOMATIC);
+            table.setInfoStatus(PayConstants.PASSED_STATUS);
+            financeWithdrawRepository.save(table);
+            try {
+                fastFinanceWithdraw(table);
+            } catch (Exception e) {
+                log.error("越南快速出金异常: serial:{}", table.getSerial(), e);
+            }
+        }
+    }
 
-    private String getOrderNo() {
-        /**
-         * 生成订单号
-         */
-        String orderNo = GetRandom.getOrderNo(PayConstants.WITHDRAW_HEAD);
-        return orderNo;
+    @Override
+    public FinanceWithdrawTable getByChannelSerial(String channelSerial) throws ServiceException {
+        FinanceWithdrawTable table = financeWithdrawRepository.getFirstByChannelSerial(channelSerial);
+        if (table == null) {
+            throw ServiceException.exception(Constants.INFO_NOT_FOUND);
+        }
+        return table;
     }
 
 }

+ 109 - 10
crm-pay/src/main/java/com/crm/pay/service/impl/SysRemitChannelServiceImpl.java

@@ -2,6 +2,7 @@ package com.crm.pay.service.impl;
 
 import com.alibaba.fastjson.JSON;
 import com.crm.pay.dao.repository.SysRemitChannelRepository;
+import com.crm.pay.service.FinanceRateService;
 import com.crm.pay.service.SysConfigService;
 import com.crm.pay.service.SysRemitChannelService;
 import com.crm.rely.backend.core.constant.Constants;
@@ -13,16 +14,16 @@ import com.crm.rely.backend.core.entity.base.SingleLongEntity;
 import com.crm.rely.backend.core.pojo.table.SysConfigTable;
 import com.crm.rely.backend.core.exception.ServiceException;
 import com.crm.rely.backend.model.constant.ConfigConstants;
+import com.crm.rely.backend.model.constant.PayConstants;
+import com.crm.rely.backend.model.dto.sys.remit.SysRemitChannelApiDto;
 import com.crm.rely.backend.model.dto.sys.remit.SysRemitChannelDto;
 import com.crm.rely.backend.model.dto.sys.remit.SysRemitChannelGetCodeDto;
 import com.crm.rely.backend.model.entity.sys.config.SysConfigFinanceEntity;
-import com.crm.rely.backend.model.entity.sys.remit.SysRemitChannelBaseUpdateEntity;
-import com.crm.rely.backend.model.entity.sys.remit.SysRemitChannelBatchUpdateEntity;
-import com.crm.rely.backend.model.entity.sys.remit.SysRemitChannelByCodeEntity;
-import com.crm.rely.backend.model.entity.sys.remit.SysRemitChannelSearchEntity;
+import com.crm.rely.backend.model.entity.sys.remit.*;
 import com.crm.rely.backend.model.pojo.table.SysRemitChannelTable;
 import com.crm.rely.backend.util.FormatPage;
 import com.google.common.base.Strings;
+import lombok.extern.log4j.Log4j;
 import org.springframework.beans.BeanUtils;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.data.domain.Page;
@@ -32,37 +33,90 @@ import org.springframework.stereotype.Service;
 import org.springframework.transaction.annotation.Transactional;
 
 import javax.persistence.criteria.Predicate;
+import java.math.BigDecimal;
 import java.util.*;
 
+@Log4j
 @Service
 public class SysRemitChannelServiceImpl implements SysRemitChannelService {
 
     @Autowired
     private SysRemitChannelRepository sysRemitChannelRepository;
-
+    @Autowired
+    private FinanceRateService financeRateService;
     @Autowired
     private SysConfigService sysConfigService;
 
+    private ThreadLocal<BigDecimal> maxAmount = new ThreadLocal<>();
+
+    private ThreadLocal<BigDecimal> minAmount = new ThreadLocal<>();
+
 
     @Override
-    public BaseResultDto<List<SysRemitChannelDto>> getAllList() throws Exception {
-        List<SysRemitChannelTable> remitChannelTables = sysRemitChannelRepository.getAllByValidOrderBySubIndex(1);
+    public BaseResultDto<List<SysRemitChannelDto>> getAllList(SysRemitChannelListEntity entity) throws Exception {
+        List<SysRemitChannelTable> remitChannelTables;
+
+        if (entity.getChannelCode() == null || entity.getChannelCode().size() <= 0) {
+            remitChannelTables = sysRemitChannelRepository.getAllByValidOrderBySubIndex(1);
+        } else {
+            remitChannelTables = sysRemitChannelRepository.getAllByValidAndCodeInOrderBySubIndex(1,
+                    entity.getChannelCode());
+        }
         if (remitChannelTables == null || remitChannelTables.size() <= 0) {
             return BaseResultDto.success();
         }
-        SysConfigFinanceEntity sysConfigFinanceEntity = getFinanceConfigure();
+        getValidatedAmount();
 
         List<SysRemitChannelDto> sysRemitChannelDtos = new ArrayList<>(remitChannelTables.size());
         for (SysRemitChannelTable sysRemitChannelTable : remitChannelTables) {
 
-            SysRemitChannelDto sysRemitChannelDto =
-                    transform(sysRemitChannelTable, sysConfigFinanceEntity);
+            if (sysRemitChannelTable.getMaxAmount() == null) {
+                sysRemitChannelTable.setMaxAmount(maxAmount.get());
+            }
+            if (sysRemitChannelTable.getMinAmount() == null) {
+                sysRemitChannelTable.setMinAmount(minAmount.get());
+            }
+
+            SysRemitChannelDto sysRemitChannelDto = sysRemitChannelTable.transferToDto(SysRemitChannelDto.class);
+
+            if ((sysRemitChannelTable.getBankValid() != null && !sysRemitChannelTable.getBankValid().equals(1) &&
+                    sysRemitChannelTable.getCurrency() != null && sysRemitChannelTable.getTransformCurrency() != null)) {
+
+                try {
+                    BigDecimal rate = financeRateService.getRate(sysRemitChannelTable.getCurrency(),
+                            sysRemitChannelTable.getTransformCurrency(), 1);
+                    sysRemitChannelDto.setRate(rate);
+                } catch (Exception e) {
+                    log.error(e.getMessage());
+                }
+
+            }
+            BigDecimal rate = null;
+            try {
+                if (PayConstants.CHANNEL_TYPE_BANK.equals(sysRemitChannelTable.getCode()) || PayConstants.CHANNEL_TYPE_BANK_TELEGRAPHIC.equals(sysRemitChannelTable.getCode()) || (sysRemitChannelTable.getBankValid() != null && !sysRemitChannelTable.getBankValid().equals(1)
+                        && sysRemitChannelTable.getCurrency() != null && sysRemitChannelTable.getTransformCurrency() != null)) {
+                    try {
+                        if (sysRemitChannelTable.getRate() != null) {
+                            rate = sysRemitChannelTable.getRate();
+                        } else {
+                            rate = financeRateService.getRate(sysRemitChannelTable.getCurrency(),
+                                    sysRemitChannelTable.getTransformCurrency(), 1);
+                        }
+
+                    } catch (Exception e) {
+                        log.error(e.getMessage());
+                    }
+                }
+            } finally {
+                sysRemitChannelDto.setRate(rate);
+            }
             sysRemitChannelDtos.add(sysRemitChannelDto);
 
         }
         return BaseResultDto.success(sysRemitChannelDtos);
     }
 
+
     /**
      * 根据实体查询通道 并返回值
      *
@@ -258,6 +312,21 @@ public class SysRemitChannelServiceImpl implements SysRemitChannelService {
         return transform;
     }
 
+    @Override
+    public List<SysRemitChannelApiDto> searchWithdrawApi() throws ServiceException {
+        List<SysRemitChannelTable> sysRemitChannelTables = sysRemitChannelRepository.getAllByRemitApi(1);
+        if (sysRemitChannelTables == null) {
+            return null;
+        }
+        List<SysRemitChannelApiDto> dtos = new ArrayList<>(sysRemitChannelTables.size());
+        for (SysRemitChannelTable sysRemitChannelTable : sysRemitChannelTables) {
+            SysRemitChannelApiDto apiDto = new SysRemitChannelApiDto();
+            BeanUtils.copyProperties(sysRemitChannelTable, apiDto);
+            dtos.add(apiDto);
+        }
+        return dtos;
+    }
+
     private Specification getSpecification(SysRemitChannelSearchEntity entity) {
 
         Specification<SysRemitChannelTable> specification = (root, query, cb) -> {
@@ -336,6 +405,36 @@ public class SysRemitChannelServiceImpl implements SysRemitChannelService {
         return financeEntity;
     }
 
+    private void getValidatedAmount() throws ServiceException {
+        maxAmount.set(null);
+        maxAmount.set(null);
+        List<String> codes = new ArrayList<>(2);
+
+        codes.add(ConfigConstants.FINANCE_WITHDRAW_MAX);
+        codes.add(ConfigConstants.FINANCE_WITHDRAW_MIN);
+        List<SysConfigTable> configTables = sysConfigService.getByCodes(codes);
+        if (configTables == null || configTables.size() < 2) {
+            throw new ServiceException(Constants.SYSTEM_ERROR);
+        }
+        for (SysConfigTable configTable : configTables) {
+
+            if (ConfigConstants.FINANCE_WITHDRAW_MAX.equals(configTable.getCode())) {
+                try {
+                    maxAmount.set(new BigDecimal(configTable.getValue()));
+                } catch (NumberFormatException e) {
+                    throw new ServiceException(Constants.SYSTEM_ERROR);
+                }
+            }
+            if (ConfigConstants.FINANCE_WITHDRAW_MIN.equals(configTable.getCode())) {
+                try {
+                    minAmount.set(new BigDecimal(configTable.getValue()));
+                } catch (NumberFormatException e) {
+                    throw new ServiceException(Constants.SYSTEM_ERROR);
+                }
+            }
+        }
+    }
+
     private List<SysRemitChannelGetCodeDto> transformGetCode(List<SysRemitChannelTable> tables) {
 
         if (tables == null || tables.size() <= 0) {

+ 5 - 0
crm-pay/src/main/java/com/crm/pay/service/impl/base/BasePayServiceImpl.java

@@ -230,6 +230,11 @@ public class BasePayServiceImpl extends BaseUploadServiceImpl {
         }
 
         balanceCallbackUpdateEntity.setCallbackStatus(status);
+        if (status == PayConstants.CALLBACE_SUCCESS_STATUS) {
+            balanceCallbackUpdateEntity.setStatus(PayConstants.MANAGER_COMPLETED_STATUS);
+        } else if (status == PayConstants.CALLBACE_FAIL_STATUS) {
+            balanceCallbackUpdateEntity.setStatus(PayConstants.MANAGER_FAIL_STATUS);
+        }
 
         balanceCallbackUpdateEntity.setCallbackTime(new Date());
         if (callback != null) {

+ 3 - 3
crm-pay/src/main/java/com/crm/pay/service/impl/pay/S2sPayServiceImpl.java

@@ -74,12 +74,12 @@ public class S2sPayServiceImpl extends BasePayServiceImpl implements S2sPayServi
             return Constants.FAIL;
         }
         //获取配置
-        S2sPayPropertyEntity payProperty = getPayProperty(PayConstants.S2S_PAY_KEY, S2sPayPropertyEntity.class);
+        //S2sPayPropertyEntity payProperty = getPayProperty(PayConstants.S2S_PAY_KEY, S2sPayPropertyEntity.class);
 
-        boolean validate = validate(callbackEntity, payProperty.getPassword());
+        /*boolean validate = validate(callbackEntity, payProperty.getPassword());
         if (!validate) {
             return Constants.FAIL;
-        }
+        }*/
 
         //验证传输数据
         int status = PayConstants.CALLBACE_PROCESSING_STATUS;

+ 1 - 1
crm-pay/src/main/resources/application-dev.yml

@@ -16,7 +16,7 @@ spring:
 #    masterPassword: 123123
 web:
   front-path: G:/crm/crm-back/crm-core/front
-  upload-path: D:\upload
+  upload-path: ../upload
 eureka:
   client:
     serviceUrl:

이 변경점에서 너무 많은 파일들이 변경되어 몇몇 파일들은 표시되지 않았습니다.