FengChaoYu 9 ماه پیش
والد
کامیت
21029f2d5c

+ 4 - 0
mall-server-api/src/main/java/com/gree/mall/manager/bean/settle/repair/DailyReduceCostVO.java

@@ -17,6 +17,10 @@ public class DailyReduceCostVO {
     @ZfireField(hide = true)
     private String id;
 
+    @ZfireField(hide = true)
+    @ApiModelProperty(value = "导入批次号")
+    private String importBatchNo;
+
     @ApiModelProperty(value = "所属商户")
     private String companyWechatName;
 

+ 42 - 61
mall-server-api/src/main/java/com/gree/mall/manager/controller/settle/repair/BankAccountController.java

@@ -10,6 +10,8 @@ import com.gree.mall.manager.helper.ResponseHelper;
 import com.gree.mall.manager.logic.settle.repair.DailyTransferLogic;
 import com.gree.mall.manager.logic.settle.repair.RepairSettleAccountLogic;
 import com.gree.mall.manager.plus.entity.SettleDailyBankAccount;
+import com.gree.mall.manager.plus.entity.SettleDailyBankCardBalance;
+import com.gree.mall.manager.plus.entity.SettleDailyBankTransferRecord;
 import com.gree.mall.manager.zfire.bean.ZfireParamBean;
 import com.gree.mall.manager.zfire.util.FieldUtils;
 import io.swagger.annotations.Api;
@@ -113,57 +115,53 @@ public class BankAccountController {
         repairSettleAccountLogic.delete(id);
         return ResponseHelper.success();
     }
-//
-//    @GetMapping("/transfer/list")
-//    @ApiOperation(value = "转帐记录列表")
-//    public ResponseHelper<IPage<DailyBankTransferRecord>> transferList(
-//            @ApiParam(required = false, value = "服务人员编号") @RequestParam(required = false) String workerNumber,
-//            @ApiParam(required = false, value = "批次号") @RequestParam(required = false) String batchNo,
-//            @ApiParam(value = "开始日期", required = false) @RequestParam(required = false) String startTime,
-//            @ApiParam(value = "结束日期", required = false) @RequestParam(required = false) String endTime,
-//            @ApiParam(required = true, value = "页号") @RequestParam(required = true) Integer pageNo,
-//            @ApiParam(required = true, value = "页大小") @RequestParam(required = true) Integer pageSize,
-//            HttpServletRequest request
-//    ) {
-//        IPage<DailyBankTransferRecord> list = repairSettleAccountLogic.transferList(workerNumber, startTime, endTime, batchNo, pageNo, pageSize);
-//        return ResponseHelper.success(list);
-//    }
-//
-//
-//    @GetMapping("/company/account/list")
-//    @ApiOperation(value = "公司卡号余额列表")
-//    public ResponseHelper<IPage<DailyBankCardBalance>> companyAccountList(
-//            @ApiParam(required = true, value = "页号") @RequestParam(required = true) Integer pageNo,
-//            @ApiParam(required = true, value = "页大小") @RequestParam(required = true) Integer pageSize
-//    ) {
-//        IPage<DailyBankCardBalance> list = repairSettleAccountLogic.companyAccountList(pageNo, pageSize);
-//        return ResponseHelper.success(list);
-//    }
-//
-//
+
+    @PostMapping("/transfer/list")
+    @ApiOperation(value = "转帐记录列表")
+    public ResponseHelper<IPage<SettleDailyBankTransferRecord>> transferList(
+            @ApiParam(value = "服务人员编号") @RequestParam(required = false) String workerNumber,
+            @ApiParam(value = "批次号") @RequestParam(required = false) String batchNo,
+            @ApiParam(value = "开始日期") @RequestParam(required = false) String startTime,
+            @ApiParam(value = "结束日期") @RequestParam(required = false) String endTime,
+            @ApiParam(required = true, value = "页号") @RequestParam Integer pageNo,
+            @ApiParam(required = true, value = "页大小") @RequestParam Integer pageSize,
+            HttpServletRequest request
+    ) {
+        IPage<SettleDailyBankTransferRecord> list = repairSettleAccountLogic.transferList(workerNumber, startTime, endTime, batchNo, pageNo, pageSize);
+        return ResponseHelper.success(list);
+    }
+
+    @PostMapping("/company/account/list")
+    @ApiOperation(value = "公司卡号余额列表")
+    public ResponseHelper<IPage<SettleDailyBankCardBalance>> companyAccountList(
+            @ApiParam(required = true, value = "页号") @RequestParam Integer pageNo,
+            @ApiParam(required = true, value = "页大小") @RequestParam Integer pageSize
+    ) {
+        IPage<SettleDailyBankCardBalance> list = repairSettleAccountLogic.companyAccountList(pageNo, pageSize);
+        return ResponseHelper.success(list);
+    }
+
     @PostMapping("/send/msg")
     @ApiOperation(value = "查询余额/(发放工资)发送验证码")
     public ResponseHelper sendMsg(
             @ApiParam(required = true, value = "手机号") @RequestParam String mobile,
             @ApiParam(value = "类型 发放:issue , 余额:balance") @RequestParam(required = false) String type
     ) throws Exception {
-        repairSettleAccountLogic.sendMsg(mobile,type);
+        repairSettleAccountLogic.sendMsg(mobile, type);
         return ResponseHelper.success();
     }
-//
-//
-//
-//    @GetMapping("/company/account/balance")
-//    @ApiOperation(value = "查询公司卡余额")
-//    public ResponseHelper<DailyBankCardBalance> selBankCardBalance(
-//            @ApiParam(required = true, value = "id") @RequestParam(required = true) Integer id,
-//            @ApiParam(required = true, value = "手机号") @RequestParam(required = true) String mobile,
-//            @ApiParam(required = true, value = "验证码") @RequestParam(required = true) String code
-//    ) throws Exception {
-//        DailyBankCardBalance  bean =  repairSettleAccountLogic.selBankCardBalance(id,mobile,code);
-//        return ResponseHelper.success(bean);
-//    }
-//
+
+    @PostMapping("/company/account/balance")
+    @ApiOperation(value = "查询公司卡余额")
+    public ResponseHelper<SettleDailyBankCardBalance> selBankCardBalance(
+            @ApiParam(required = true, value = "id") @RequestParam Integer id,
+            @ApiParam(required = true, value = "手机号") @RequestParam String mobile,
+            @ApiParam(required = true, value = "验证码") @RequestParam String code
+    ) throws Exception {
+        SettleDailyBankCardBalance bean = repairSettleAccountLogic.selBankCardBalance(id, mobile, code);
+        return ResponseHelper.success(bean);
+    }
+
     @PostMapping("/template/import")
     @ApiOperation("导入银行账户")
     public ResponseHelper importData(MultipartFile file) throws Exception {
@@ -173,26 +171,9 @@ public class BankAccountController {
 
     @PostMapping("/excute")
     @ApiOperation("查询转账结果")
-    public ResponseHelper excute(){
+    public ResponseHelper excute() {
         dailyTransferLogic.excute();
         return ResponseHelper.success();
     }
-//
-//    @GetMapping("/template/export")
-//    @ApiOperation("银行账号信息-导出")
-//    public void exportRepairLevel(
-//            @ApiParam(required = false, value = "服务人员编号") @RequestParam(required = false) String workerNumber,
-//            @ApiParam(required = false, value = "服务人员名称") @RequestParam(required = false) String workerName,
-//            @ApiParam(required = false, value = "所属网点编号") @RequestParam(required = false) String websitNumber,
-//            @ApiParam(required = false, value = "身份证") @RequestParam(required = false) String idcard,
-//            @ApiParam(required = false, value = "手机号") @RequestParam(required = false) String mobile,
-//            HttpServletRequest request,
-//            HttpServletResponse response
-//    ) throws Exception {
-//        IPage<DailyBankAccountBean> list = repairSettleAccountLogic.list(workerNumber, workerName, websitNumber, idcard, mobile, 1, -1);
-//        ExcelData excelData = repairSettleAccountLogic.exportData(list.getRecords());
-//        ExcelUtils.exportExcel(request,response,"银行账号信息.xlsx",excelData);
-//    }
-
 
 }

+ 81 - 10
mall-server-api/src/main/java/com/gree/mall/manager/logic/settle/repair/RepairSettleAccountLogic.java

@@ -2,10 +2,12 @@ package com.gree.mall.manager.logic.settle.repair;
 
 import cn.hutool.core.collection.CollectionUtil;
 import cn.hutool.core.lang.Validator;
+import com.alibaba.fastjson.JSONObject;
 import com.baomidou.mybatisplus.core.metadata.IPage;
 import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
 import com.gree.mall.manager.bean.admin.AdminUserCom;
 import com.gree.mall.manager.bean.settle.repair.DailyBankAccountVO;
+import com.gree.mall.manager.bean.settle.repair.cmc.BankCardInfoBean;
 import com.gree.mall.manager.commonmapper.CommonMapper;
 import com.gree.mall.manager.constant.Constant;
 import com.gree.mall.manager.enums.ExamineStatusEnum;
@@ -13,15 +15,11 @@ import com.gree.mall.manager.enums.UserTypeEnum;
 import com.gree.mall.manager.exception.RemoteServiceException;
 import com.gree.mall.manager.logic.common.CommonLogic;
 import com.gree.mall.manager.logic.common.SMSLogic;
-import com.gree.mall.manager.plus.entity.AdminWebsit;
-import com.gree.mall.manager.plus.entity.SettleDailyBankAccount;
-import com.gree.mall.manager.plus.entity.User;
-import com.gree.mall.manager.plus.entity.WebsitUser;
-import com.gree.mall.manager.plus.service.AdminWebsitService;
-import com.gree.mall.manager.plus.service.SettleDailyBankAccountService;
-import com.gree.mall.manager.plus.service.UserService;
-import com.gree.mall.manager.plus.service.WebsitUserService;
+import com.gree.mall.manager.logic.settle.repair.cmc.CmcBankLogic;
+import com.gree.mall.manager.plus.entity.*;
+import com.gree.mall.manager.plus.service.*;
 import com.gree.mall.manager.utils.CommonUtils;
+import com.gree.mall.manager.utils.RedisUtil;
 import com.gree.mall.manager.utils.excel.ExcelUtils;
 import com.gree.mall.manager.zfire.bean.ZfireParamBean;
 import com.gree.mall.manager.zfire.util.FieldUtils;
@@ -30,9 +28,12 @@ import lombok.extern.slf4j.Slf4j;
 import org.apache.commons.lang3.StringUtils;
 import org.springframework.beans.BeanUtils;
 import org.springframework.stereotype.Service;
+import org.springframework.transaction.annotation.Transactional;
 import org.springframework.web.multipart.MultipartFile;
 
+import java.math.BigDecimal;
 import java.util.ArrayList;
+import java.util.Date;
 import java.util.List;
 import java.util.Map;
 import java.util.function.Function;
@@ -49,6 +50,10 @@ public class RepairSettleAccountLogic {
     private final WebsitUserService websitUserService;
     private final AdminWebsitService adminWebsitService;
     private final SMSLogic smsLogic;
+    private final SettleDailyBankTransferRecordService settleDailyBankTransferRecordService;
+    private final SettleDailyBankCardBalanceService settleDailyBankCardBalanceService;
+    private final RedisUtil redisUtil;
+    private final CmcBankLogic cmcBankLogic;
 
     public IPage<DailyBankAccountVO> page(ZfireParamBean zfireParamBean) {
         AdminUserCom adminUser = commonLogic.getAdminUser();
@@ -256,15 +261,81 @@ public class RepairSettleAccountLogic {
             settleDailyBankAccountService.saveBatch(importList);
     }
 
-    public void sendMsg(String mobile, String type) throws Exception  {
+    public void sendMsg(String mobile, String type) throws Exception {
         if (!Validator.isMobile(mobile)) {
             throw new RemoteServiceException("手机号格式不正确。");
         }
         // 向手机号发送验证码
         String sendType = Constant.RedisPrefix.BALANCE_SEL_MOBILE_SMS;
-        if(type != null && type.equals("issue")){
+        if (type != null && type.equals("issue")) {
             sendType = Constant.RedisPrefix.ISSUE_SAL_MOBILE_SMS;
         }
         smsLogic.sendSms(sendType, mobile, "BALANCE_SEL", Constant.SMS_EXPIRE);
     }
+
+    public IPage<SettleDailyBankTransferRecord> transferList(String workerNumber, String startTime, String endTime, String batchNo, Integer pageNo, Integer pageSize) {
+        AdminUserCom adminUser = commonLogic.getAdminUser();
+
+        return settleDailyBankTransferRecordService.lambdaQuery()
+                .in(CollectionUtil.isNotEmpty(adminUser.getCompanyWechatIds()), SettleDailyBankTransferRecord::getCompanyWechatId, adminUser.getCompanyWechatIds())
+                .between(StringUtils.isNotEmpty(startTime) && StringUtils.isNotEmpty(endTime), SettleDailyBankTransferRecord::getCreateTime, startTime, endTime)
+                .eq(StringUtils.isNotEmpty(batchNo), SettleDailyBankTransferRecord::getIssueBatchNo, batchNo)
+                // .eq(StringUtils.isNotEmpty(workerNumber),DailyBankTransferRecord::workerNumber)
+                .orderByDesc(SettleDailyBankTransferRecord::getCreateTime)
+                .page(new Page<>(pageNo, pageSize));
+    }
+
+    public IPage<SettleDailyBankCardBalance> companyAccountList(Integer pageNo, Integer pageSize) {
+        AdminUserCom adminUser = commonLogic.getAdminUser();
+        return settleDailyBankCardBalanceService.lambdaQuery()
+                .in(CollectionUtil.isNotEmpty(adminUser.getCompanyWechatIds()), SettleDailyBankCardBalance::getCompanyWechatId, adminUser.getCompanyWechatIds())
+                .orderByDesc(SettleDailyBankCardBalance::getCreateTime)
+                .page(new Page<>(pageNo, pageSize));
+    }
+
+    /**
+     * 查询银行卡余额
+     */
+    @Transactional
+    public SettleDailyBankCardBalance selBankCardBalance(Integer id ,String mobile,String code) throws Exception {
+        AdminUserCom adminUser = commonLogic.getAdminUser();
+
+        if (adminUser.getType() == 2) {
+            throw new RemoteServiceException("平台账号禁止操作");
+        }
+
+        Object validMessageCode = redisUtil.get(Constant.RedisPrefix.BALANCE_SEL_MOBILE_SMS + mobile);
+        if(validMessageCode == null || code == null){
+            throw new RemoteServiceException("请先发送验证码");
+        }
+        if (!code.equals(validMessageCode.toString())){
+            throw new RemoteServiceException("短信验证码输入错误");
+        }
+
+        SettleDailyBankCardBalance bankCardBalance = settleDailyBankCardBalanceService.getById(id);
+        if(bankCardBalance == null){
+            throw new RemoteServiceException("公司信息不存在");
+        }
+        List<BankCardInfoBean> list = new ArrayList<>();
+        BankCardInfoBean bankCardInfoBean = new BankCardInfoBean();
+        bankCardInfoBean.setAuthType("1");
+        bankCardInfoBean.setBankAccount(bankCardBalance.getBankCardId());
+        bankCardInfoBean.setBankOrgCode(bankCardBalance.getOpenBankOrgId());
+        list.add(bankCardInfoBean);
+        Map<String,Object> response = cmcBankLogic.getAccountBalance(list,bankCardBalance.getSummaryNumber());
+        JSONObject head = JSONObject.parseObject(response.get("head").toString());
+
+        if(head != null && head.get("resultcode").equals("SUC0000")){
+            Map<String,Map<String,Object>> body = (Map<String, Map<String, Object>>) response.get("body");
+            List<Map<String,Object>> ntqadinfz = (List<Map<String,Object>>) body.get("ntqadinfz");
+            bankCardBalance.setBalanceAmount(new BigDecimal(ntqadinfz.get(0).get("avlblv").toString()));
+            bankCardBalance.setUpdateTime(new Date());
+            bankCardBalance.updateById();
+        }else {
+            throw new RemoteServiceException("查询失败" + response.get("errtxt"));
+        }
+
+        return bankCardBalance;
+    }
+
 }