| | |
| | | import java.security.NoSuchAlgorithmException; |
| | | import java.util.*; |
| | | import java.util.concurrent.TimeUnit; |
| | | import java.util.stream.Collectors; |
| | | |
| | | /** |
| | | * 收款确认 |
| | |
| | | public R add(PaymentConfirmAddDTO addDTO) { |
| | | if (StrUtil.isNotBlank(addDTO.getContractNo())) { |
| | | Contract contract = contractService.getOne(Wrappers.<Contract>lambdaQuery().eq(Contract::getContractNo, addDTO.getContractNo())); |
| | | if (ObjUtil.isNull(contract)) { |
| | | return R.failed("合同查询失败,请检查合同编号"); |
| | | } |
| | | BusinessCustomer customer = businessCustomerService.getOne(Wrappers.<BusinessCustomer>lambdaQuery() |
| | | .eq(StrUtil.isNotBlank(addDTO.getBusGuestName()), BusinessCustomer::getCompanyName, addDTO.getBusGuestName()) |
| | | .eq(StrUtil.isNotBlank(addDTO.getBusGuestName()), BusinessCustomer::getRegisterName, addDTO.getBusGuestName()) |
| | | .eq(StrUtil.isNotBlank(addDTO.getBusGuestId()), BusinessCustomer::getId, addDTO.getBusGuestId())); |
| | | if (ObjUtil.isNull(customer)) { |
| | | return R.failed("客商查询失败,请检查客商"); |
| | |
| | | entity.setScheduleName(lastConfirm.getScheduleName()); |
| | | } |
| | | entity.setBusGuestId(customer.getId()); |
| | | entity.setBusGuestName(customer.getCompanyName()); |
| | | entity.setBusGuestName(customer.getRegisterName()); |
| | | entity.setBusinessType("客户付款"); |
| | | if (newtotal.compareTo(new BigDecimal("0")) > 0) { |
| | | entity.setTransationAmount(addDTO.getTransationAmount()); |
| | |
| | | entity.setContractNo(addDTO.getContractNo()); |
| | | |
| | | entity.setBusGuestId(customer.getId()); |
| | | entity.setBusGuestName(customer.getCompanyName()); |
| | | entity.setBusinessType(""); |
| | | entity.setBusGuestName(customer.getRegisterName()); |
| | | entity.setBusinessType("退款"); |
| | | entity.setTransationAmount(addDTO.getTransationAmount()); |
| | | BigDecimal newtotal = addDTO.getTransationAmount().multiply(new BigDecimal("-1")).add(lastConfirm.getTotalAmount()); |
| | | if (newtotal.compareTo(new BigDecimal("0")) > 0) { |
| | |
| | | return R.failed("为查询到未付款合同"); |
| | | } |
| | | BusinessCustomer customer = businessCustomerService.getOne(Wrappers.<BusinessCustomer>lambdaQuery() |
| | | .eq(StrUtil.isNotBlank(addDTO.getBusGuestName()), BusinessCustomer::getCompanyName, addDTO.getBusGuestName()) |
| | | .eq(StrUtil.isNotBlank(addDTO.getBusGuestName()), BusinessCustomer::getRegisterName, addDTO.getBusGuestName()) |
| | | .eq(ObjUtil.isNotNull(addDTO.getBusGuestId()), BusinessCustomer::getId, addDTO.getBusGuestId()) |
| | | .last("limit 1")); |
| | | if (ObjUtil.isNull(customer)) { |
| | |
| | | //新增付款单 |
| | | PaymentSlip slip = new PaymentSlip(); |
| | | slip.setBusGuestId(customer.getId()); |
| | | slip.setBusGuestName(customer.getCompanyName()); |
| | | slip.setBusGuestName(customer.getRegisterName()); |
| | | slip.setPayeeCompId(SecurityUtils.getUser().getCompId()); |
| | | slip.setPaymentTime(addDTO.getConfirmTime()); |
| | | slip.setPaymentAmount(addDTO.getTransationAmount()); |
| | |
| | | entity.setScheduleName(lastConfirm.getScheduleName()); |
| | | } |
| | | entity.setBusGuestId(customer.getId()); |
| | | entity.setBusGuestName(customer.getCompanyName()); |
| | | entity.setBusGuestName(customer.getRegisterName()); |
| | | entity.setBusinessType("客户付款"); |
| | | if (transtionRemainAmount.compareTo(new BigDecimal("0")) > 0) { |
| | | entity.setConfirmTime(payDate); |
| | |
| | | String result = HttpUtil.post(url + "/yonbip/EFI/collection/list?access_token=" + finalAccessToken, params.toJSONString()); |
| | | log.info("SK_CX Response:{}", result); |
| | | //保存请求记录 |
| | | saveBipRequestRecord(params, result); |
| | | saveBipRequestRecord(params,"<XSJZ_SK_CX_001>-收款单查询接口", result); |
| | | JSONObject resultJson = JSONObject.parseObject(result); |
| | | if (resultJson.containsKey("code") && resultJson.getString("code").equals("200")) { |
| | | handleAndSave(bipCode, resultJson); |
| | |
| | | return params; |
| | | } |
| | | |
| | | private void getAccessToken(String accessToken) { |
| | | @Override |
| | | public String getAccessToken(String accessToken) { |
| | | long timestamp = System.currentTimeMillis(); |
| | | Map<String, Object> paramMap = new HashMap<>(); |
| | | paramMap.put("appKey", appKey); |
| | |
| | | JSONObject tokenJson = JSONObject.parseObject(getTokenResult); |
| | | if (!tokenJson.containsKey("code") || !tokenJson.getString("code").equals("200")) { |
| | | log.error("Get access_token ERROR"); |
| | | return; |
| | | return ""; |
| | | } |
| | | if (ObjUtil.isNull(tokenJson.get("data")) || ObjUtil.isNull(JSONObject.parseObject(tokenJson.getString("data")))) { |
| | | log.error("access_token value exception"); |
| | | return; |
| | | return ""; |
| | | } |
| | | accessToken = JSONObject.parseObject(tokenJson.getString("data")).getString("access_token"); |
| | | log.info("access_token value:", accessToken); |
| | | redisTemplate.opsForValue().set("BIP_TOKEN", accessToken, tokenJson.getIntValue("expire") - 10, TimeUnit.SECONDS); |
| | | return accessToken; |
| | | } |
| | | |
| | | private void saveBipRequestRecord(JSONObject params, String result) { |
| | | @Override |
| | | public void saveBipRequestRecord(JSONObject params, String methodName, String result) { |
| | | BipRequestRecord record = new BipRequestRecord(); |
| | | record.setInterfaceName("<XSJZ_SK_CX_001>-收款单查询接口"); |
| | | record.setInterfaceName(methodName); |
| | | record.setRequestParams(params.toJSONString()); |
| | | record.setResponseParams(result); |
| | | record.setResponseCode(JSONObject.parseObject(result).getString("code")); |
| | |
| | | return; |
| | | } |
| | | BusinessCustomer customer = businessCustomerService.getOne(Wrappers.<BusinessCustomer>lambdaQuery() |
| | | .eq(StrUtil.isNotBlank(record.getString("bodyItemCustomerName")), BusinessCustomer::getCompanyName, record.getString("bodyItemCustomerName")) |
| | | .eq(StrUtil.isNotBlank(record.getString("bodyItemCustomerName")), BusinessCustomer::getRegisterName, record.getString("bodyItemCustomerName")) |
| | | ); |
| | | if (ObjUtil.isNull(customer)) { |
| | | log.error("付款单id:{},客商查询失败,请检查客商", record.getString("id")); |
| | |
| | | entity.setScheduleName(lastConfirm.getScheduleName()); |
| | | } |
| | | entity.setBusGuestId(customer.getId()); |
| | | entity.setBusGuestName(customer.getCompanyName()); |
| | | entity.setBusGuestName(customer.getRegisterName()); |
| | | entity.setBusinessType("客户付款"); |
| | | entity.setIsBip(1); |
| | | entity.setPaymentCode(record.getString("code")); |
| | |
| | | private Boolean savePaymentSlip(BusinessCustomer customer, JSONObject record,SysDept dept) { |
| | | PaymentSlip slip = new PaymentSlip(); |
| | | slip.setBusGuestId(customer.getId()); |
| | | slip.setBusGuestName(customer.getCompanyName()); |
| | | slip.setBusGuestName(customer.getRegisterName()); |
| | | slip.setPayee(dept.getName()); |
| | | slip.setPayeeCompId(dept.getDeptId()); |
| | | slip.setPaymentTime(ObjUtil.isNotNull(record.get("billDate"))? |
| | |
| | | } |
| | | |
| | | entity.setBusGuestId(customer.getId()); |
| | | entity.setBusGuestName(customer.getCompanyName()); |
| | | entity.setBusGuestName(customer.getRegisterName()); |
| | | entity.setBusinessType("客户付款"); |
| | | if (ObjUtil.isNotNull(record)){ |
| | | entity.setIsBip(1); |
| | |
| | | } |
| | | baseMapper.insert(entity); |
| | | } |
| | | |
| | | @Override |
| | | public R queryAllBusinessType() { |
| | | return R.ok(baseMapper.selectList(Wrappers.<PaymentConfirm>lambdaQuery().select(PaymentConfirm::getBusinessType).isNotNull(PaymentConfirm::getBusinessType) |
| | | .groupBy(PaymentConfirm::getBusinessType)).stream().map(PaymentConfirm::getBusinessType).collect(Collectors.toList())); |
| | | } |
| | | } |