| | |
| | | package com.ruoyi.system.service.impl; |
| | | |
| | | import cn.hutool.crypto.SecureUtil; |
| | | import cn.hutool.http.HttpRequest; |
| | | import cn.hutool.http.HttpResponse; |
| | | import cn.hutool.http.HttpUtil; |
| | | import com.alibaba.fastjson2.JSON; |
| | | import com.alibaba.fastjson2.JSONArray; |
| | | import com.alibaba.fastjson2.JSONObject; |
| | | import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
| | | import com.baomidou.mybatisplus.core.metadata.IPage; |
| | | import com.baomidou.mybatisplus.extension.plugins.pagination.Page; |
| | | import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; |
| | | import com.ruoyi.common.core.domain.R; |
| | | import com.ruoyi.common.core.redis.RedisCache; |
| | | import com.ruoyi.common.exception.ServiceException; |
| | | import com.ruoyi.common.utils.wx.PaymentUtil; |
| | | import com.ruoyi.common.utils.wx.RefundCallbackResult; |
| | | import com.ruoyi.common.utils.wx.RefundResult; |
| | | import com.ruoyi.system.domain.*; |
| | | import com.ruoyi.system.mapper.*; |
| | | import com.ruoyi.system.pojo.dto.AddAgreementDTO; |
| | | import com.ruoyi.system.pojo.dto.FinanceFlowsDTO; |
| | | import com.ruoyi.system.pojo.dto.OrderPageDTO; |
| | | import com.ruoyi.system.pojo.model.DailyStatistics; |
| | | import com.ruoyi.system.pojo.model.DrawSheet; |
| | | import com.ruoyi.system.pojo.vo.*; |
| | | import com.ruoyi.system.service.AgreementService; |
| | | import com.ruoyi.system.service.OrderService; |
| | | import com.ruoyi.system.wx.RefundCallbackResult; |
| | | import com.ruoyi.system.wx.WechatPayService; |
| | | import lombok.extern.slf4j.Slf4j; |
| | | import org.springframework.beans.BeanUtils; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.security.provisioning.UserDetailsManager; |
| | | import org.springframework.stereotype.Service; |
| | | import org.springframework.transaction.annotation.Transactional; |
| | | |
| | |
| | | import java.time.LocalDate; |
| | | import java.time.LocalDateTime; |
| | | import java.time.format.DateTimeFormatter; |
| | | import java.util.ArrayList; |
| | | import java.util.List; |
| | | import java.util.Optional; |
| | | import java.util.*; |
| | | import java.util.concurrent.TimeUnit; |
| | | |
| | | @Slf4j |
| | | @Service |
| | |
| | | private ScheduleMapper scheduleMapper; |
| | | @Resource |
| | | private CompanyMapper companyMapper; |
| | | |
| | | @Autowired |
| | | private SystemConfigMapper systemConfigMapper; |
| | | private AppUserMapper appUserMapper; |
| | | |
| | | @Resource |
| | | private RedisCache redisCache; |
| | | @Resource |
| | | private QichachaMapper qichachaMapper; |
| | | |
| | | |
| | | @Override |
| | | public IPage<OrderPageVO> getOrderPage(OrderPageDTO dto) { |
| | |
| | | List<PermitVO> permitVOs = new ArrayList<>(); |
| | | LocalDateTime now = LocalDateTime.now(); |
| | | for (Permit permit : permits) { |
| | | DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss"); |
| | | LocalDateTime expireTime = LocalDateTime.parse(permit.getExpireTime(), formatter); |
| | | DateTimeFormatter dateFormatter = DateTimeFormatter.ofPattern("yyyy-MM-dd"); |
| | | LocalDate expireDate = LocalDate.parse(permit.getExpireTime(), dateFormatter); |
| | | |
| | | // 如果需要转为 LocalDateTime(添加默认时间) |
| | | LocalDateTime expireTime = expireDate.atTime(23,59,59); // 默认00:00:00 |
| | | if (now.isAfter(expireTime)) { |
| | | //过滤 未过期的 |
| | | PermitVO permitVO = new PermitVO(); |
| | |
| | | } |
| | | vo.setOpeningBankVOList(openingBankVOs); |
| | | |
| | | if (vo.getStatus() != 4 && vo.getStatus() != 5) { |
| | | if (vo.getStatus() != 4 && vo.getStatus() != 5&& vo.getStatus() != 6) { |
| | | return vo; |
| | | } |
| | | |
| | |
| | | |
| | | @Override |
| | | public BusinessVO business(String id) { |
| | | //先查询数据库中的 |
| | | Company company = companyMapper.selectById(id); |
| | | if (null == company || company.getIsDelete() != 0) { |
| | | throw new ServiceException("公司不存在"); |
| | |
| | | BusinessVO vo = new BusinessVO(); |
| | | BeanUtils.copyProperties(company, vo); |
| | | vo.setPlace(company.getCity()+company.getProvince()+company.getArea()); |
| | | |
| | | //todo 再查企业工商信息 覆盖掉之前的 |
| | | |
| | | |
| | | return vo; |
| | | } |
| | | |
| | | @Override |
| | | public ErrorVO error(String id) { |
| | | return null; |
| | | public R error(String id) { |
| | | ErrorVO errorVO = new ErrorVO(); |
| | | Company company = companyMapper.selectById(id); |
| | | if (null == company || company.getIsDelete() != 0) { |
| | | throw new ServiceException("公司不存在"); |
| | | } |
| | | JSONObject result = getQiChaChaCompanyExceptionCheck(company.getCompanyName()); |
| | | if("200".equals(result.get("Status"))){ |
| | | //查询成功 |
| | | JSONObject data = (JSONObject) result.get("Result"); |
| | | Integer verifyResult = (Integer) data.get("VerifyResult"); |
| | | errorVO.setVerifyResult(verifyResult); |
| | | if (verifyResult==1){ |
| | | //该企业有异常数据 |
| | | JSONArray list = (JSONArray) data.get("Data"); |
| | | errorVO.setData(list); |
| | | } |
| | | return R.ok(errorVO); |
| | | }else { |
| | | //查询失败 |
| | | return R.fail(result.get("Message")); |
| | | } |
| | | |
| | | } |
| | | |
| | | |
| | | /** |
| | | * 经营异常核查 |
| | | * @param companyName |
| | | * @return |
| | | * VerifyResult int 数据是否存在(1-存在,0-不存在) |
| | | * Data List<Object> 数据信息 |
| | | * Data:[{ |
| | | * AddReason 列入经营异常名录原因 |
| | | * AddDate 列入日期 |
| | | * RomoveReason 移出经营异常名录原因(保留字段) |
| | | * RemoveDate 移出日期(保留字段) |
| | | * DecisionOffice 作出决定机关 |
| | | * RemoveDecisionOffice 移出决定机关(保留字段) |
| | | * }] |
| | | * Status |
| | | * Message |
| | | * OrderNumber |
| | | */ |
| | | public JSONObject getQiChaChaBasicDetailsCompany(String companyName){ |
| | | Object cacheObject = redisCache.getCacheObject("qichacha_" +"basic_"+ companyName); |
| | | if(cacheObject != null){ |
| | | JSONObject jsonObject = JSONObject.parseObject(cacheObject.toString()); |
| | | return jsonObject; |
| | | } |
| | | String url = "https://api.qichacha.com/ECIV4/GetBasicDetailsByName?key=642987ca3faf4a7daeac70463ae22695&keyword="+companyName; |
| | | HttpRequest get = HttpUtil.createGet(url); |
| | | String timeStr = String.valueOf(System.currentTimeMillis() / 1000); |
| | | get.header("Token", SecureUtil.md5("642987ca3faf4a7daeac70463ae22695"+timeStr+"AC776F2957291EAE3B4161702E89A9F3").toUpperCase()); |
| | | get.header("Timespan", timeStr); |
| | | HttpResponse execute = get.execute(); |
| | | String body = execute.body(); |
| | | JSONObject jsonObject = JSONObject.parseObject(body); |
| | | if("200".equals(jsonObject.get("Status"))){ |
| | | //查询成功 |
| | | String string = jsonObject.toString(); |
| | | redisCache.setCacheObject("qichacha_"+"basic_"+companyName,string,24, TimeUnit.HOURS); |
| | | //统计调用次数 |
| | | Qichacha qichacha = new Qichacha(); |
| | | qichacha.setTime(LocalDateTime.now()); |
| | | qichacha.setType(1);//企业异常查询 |
| | | qichachaMapper.insert(qichacha); |
| | | |
| | | return jsonObject; |
| | | } |
| | | return jsonObject; |
| | | } |
| | | |
| | | /** |
| | | * 经营异常核查 |
| | | * @param companyName |
| | | * @return |
| | | * VerifyResult int 数据是否存在(1-存在,0-不存在) |
| | | * Data List<Object> 数据信息 |
| | | * Data:[{ |
| | | * AddReason 列入经营异常名录原因 |
| | | * AddDate 列入日期 |
| | | * RomoveReason 移出经营异常名录原因(保留字段) |
| | | * RemoveDate 移出日期(保留字段) |
| | | * DecisionOffice 作出决定机关 |
| | | * RemoveDecisionOffice 移出决定机关(保留字段) |
| | | * }] |
| | | * Status |
| | | * Message |
| | | * OrderNumber |
| | | */ |
| | | public JSONObject getQiChaChaCompanyExceptionCheck(String companyName){ |
| | | Object cacheObject = redisCache.getCacheObject("qichacha_" + companyName); |
| | | if(cacheObject != null){ |
| | | JSONObject jsonObject = JSONObject.parseObject(cacheObject.toString()); |
| | | return jsonObject; |
| | | } |
| | | String url = "https://api.qichacha.com/ExceptionCheck/GetList?key=642987ca3faf4a7daeac70463ae22695&searchKey="+companyName; |
| | | HttpRequest get = HttpUtil.createGet(url); |
| | | String timeStr = String.valueOf(System.currentTimeMillis() / 1000); |
| | | get.header("Token", SecureUtil.md5("642987ca3faf4a7daeac70463ae22695"+timeStr+"AC776F2957291EAE3B4161702E89A9F3").toUpperCase()); |
| | | get.header("Timespan", timeStr); |
| | | HttpResponse execute = get.execute(); |
| | | String body = execute.body(); |
| | | JSONObject jsonObject = JSONObject.parseObject(body); |
| | | if("200".equals(jsonObject.get("Status"))){ |
| | | //查询成功 |
| | | String string = jsonObject.toString(); |
| | | redisCache.setCacheObject("qichacha_"+companyName,string,24, TimeUnit.HOURS); |
| | | //统计调用次数 |
| | | Qichacha qichacha = new Qichacha(); |
| | | qichacha.setTime(LocalDateTime.now()); |
| | | qichacha.setType(2);//企业异常查询 |
| | | qichachaMapper.insert(qichacha); |
| | | |
| | | return jsonObject; |
| | | } |
| | | return jsonObject; |
| | | } |
| | | private JSONObject getReport(String sign){ |
| | | Object cacheObject = redisCache.getCacheObject("shuimu_" + sign); |
| | | if(cacheObject != null){ |
| | | JSONObject jsonObject = JSONObject.parseObject(cacheObject.toString()); |
| | | return jsonObject; |
| | | } |
| | | HttpRequest post = HttpUtil.createPost("https://shuimui.szsmjr.com/index/index/result"); |
| | | HashMap<String, String> stringStringHashMap = new HashMap<>(); |
| | | stringStringHashMap.put("Origin","https://shuimui.szsmjr.com"); |
| | | post.addHeaders(stringStringHashMap); |
| | | post.body("{\"sn\":\""+sign+"\"}"); |
| | | HttpResponse execute = post.execute(); |
| | | String body = execute.body(); |
| | | JSONObject jsonObject = JSONObject.parseObject(body); |
| | | if("1001".equals(jsonObject.get("code"))){ |
| | | //查询成功 |
| | | String string = jsonObject.toString(); |
| | | redisCache.setCacheObject("shuimu_"+sign,string,1, TimeUnit.MINUTES); |
| | | return jsonObject; |
| | | } |
| | | return jsonObject; |
| | | } |
| | | @Override |
| | | public R change(String id) { |
| | | // System.err.println(getReport("ZZD20250508017232394218445")); |
| | | ChangeVO changeVO = new ChangeVO(); |
| | | /* Company companyInfo = companyMapper.selectById(id); |
| | | if (null == companyInfo || companyInfo.getIsDelete() != 0) { |
| | | throw new ServiceException("公司不存在"); |
| | | }*/ |
| | | // JSONObject jsonObject=getReport(companyInfo.getLink().split("=")[1]); |
| | | JSONObject jsonObject=getReport("ZZD20250508017232394218445"); |
| | | if (!"1001".equals(jsonObject.getString("code"))){ |
| | | return R.fail(jsonObject.get("msg")); |
| | | } |
| | | JSONObject data1 = (JSONObject) jsonObject.get("data"); |
| | | JSONObject data2 = (JSONObject) data1.get("data"); |
| | | JSONObject company = (JSONObject) data2.get("company"); |
| | | // 银税互动 |
| | | JSONArray bankAndTaxInteractive = (JSONArray) company.get("bankAndTaxInteractive"); |
| | | changeVO.setBankAndTaxInteractive(bankAndTaxInteractive); |
| | | //股东明细 |
| | | JSONArray sharesRatioList = (JSONArray) company.get("sharesRatioList"); |
| | | changeVO.setSharesRatioList(sharesRatioList); |
| | | //法人/股东变更 |
| | | JSONArray legalPersonGdChange = (JSONArray) company.get("legalPersonGdChange"); |
| | | changeVO.setLegalPersonGdChange(legalPersonGdChange); |
| | | |
| | | return R.ok(changeVO); |
| | | } |
| | | |
| | | @Override |
| | | public ChangeVO change(String id) { |
| | | return null; |
| | | public R tax(String id) { |
| | | TaxVO taxVO = new TaxVO(); |
| | | /* Company companyInfo = companyMapper.selectById(id); |
| | | if (null == companyInfo || companyInfo.getIsDelete() != 0) { |
| | | throw new ServiceException("公司不存在"); |
| | | }*/ |
| | | // JSONObject jsonObject=getReport(companyInfo.getLink().split("=")[1]); |
| | | JSONObject jsonObject=getReport("ZZD20250508017232394218445"); |
| | | if (!"1001".equals(jsonObject.getString("code"))){ |
| | | return R.fail(jsonObject.get("msg")); |
| | | } |
| | | JSONObject data1 = (JSONObject) jsonObject.get("data"); |
| | | JSONObject data2 = (JSONObject) data1.get("data"); |
| | | JSONObject taxInfo = (JSONObject) data2.get("taxInfo"); |
| | | //税务处罚 |
| | | JSONObject enterprise = (JSONObject) data2.get("enterprise"); |
| | | taxVO.setEnterprise(enterprise); |
| | | //滞纳金情况 |
| | | JSONArray overdueFineDetailsList = (JSONArray) taxInfo.get("overdueFineDetailsList"); |
| | | taxVO.setOverdueFineDetailsList(overdueFineDetailsList); |
| | | |
| | | //近四年纳税信息完税表 |
| | | JSONArray taxPrev4yearsTaxInfoDict = (JSONArray) taxInfo.get("taxPrev4yearsTaxInfoDict"); |
| | | taxVO.setTaxPrev4yearsTaxInfoDict(taxPrev4yearsTaxInfoDict); |
| | | |
| | | //纳税信用等级 |
| | | String taxCreditRating = (String) taxInfo.get("taxCreditRating"); |
| | | taxVO.setTaxCreditRating(taxCreditRating); |
| | | |
| | | //纳税人种类 |
| | | String taxpayerType = (String) taxInfo.get("taxpayerType"); |
| | | taxVO.setTaxpayerType(taxpayerType); |
| | | |
| | | //近12月增税销售额 |
| | | JSONObject taxPrevMnMthsAllTaxDclrPrjInfoDict = (JSONObject) taxInfo.get("taxPrevMnMthsAllTaxDclrPrjInfoDict"); |
| | | |
| | | JSONObject taxPrev12mthsAllTaxDclrPrjInfoDict = (JSONObject) taxPrevMnMthsAllTaxDclrPrjInfoDict.get("taxPrev12mthsAllTaxDclrPrjInfoDict"); |
| | | taxVO.setVatTaxShouldsaleAmt12((BigDecimal) taxPrev12mthsAllTaxDclrPrjInfoDict.get("vatTaxShouldsaleAmt")); |
| | | //近24月增税销售额 |
| | | JSONObject taxPrev24mthsAllTaxDclrPrjInfoDict = (JSONObject) taxPrevMnMthsAllTaxDclrPrjInfoDict.get("taxPrev24mthsAllTaxDclrPrjInfoDict"); |
| | | |
| | | taxVO.setVatTaxShouldsaleAmt24( (BigDecimal) taxPrev24mthsAllTaxDclrPrjInfoDict.get("vatTaxShouldsaleAmt")); |
| | | JSONObject taxPrevMnMthsTaxInfoDict = (JSONObject) taxInfo.get("taxPrevMnMthsTaxInfoDict"); |
| | | |
| | | //近12月纳税总额(元) |
| | | JSONObject taxPrev12mthsTaxInfo = (JSONObject) taxPrevMnMthsTaxInfoDict.get("taxPrev12mthsTaxInfo"); |
| | | taxVO.setTaxAmt12( (BigDecimal) taxPrev12mthsTaxInfo.get("taxAmt")); |
| | | |
| | | //近24月纳税总额(元) |
| | | JSONObject taxPrev24mthsTaxInfo = (JSONObject) taxPrevMnMthsTaxInfoDict.get("taxPrev24mthsTaxInfo"); |
| | | taxVO.setTaxAmt24( (BigDecimal) taxPrev24mthsTaxInfo.get("taxAmt")); |
| | | |
| | | //近12月增税应纳额(元) |
| | | taxVO.setVatTaxShouldpay( (BigDecimal) taxPrev12mthsAllTaxDclrPrjInfoDict.get("vatTaxShouldpay")); |
| | | |
| | | //近12个月滞纳金金额(元) 次数 |
| | | JSONObject taxPrevMnMthsOverdueFineInfoDict = (JSONObject) taxInfo.get("taxPrevMnMthsOverdueFineInfoDict"); |
| | | JSONObject taxPrev12mthsOverdueFineInfo = (JSONObject) taxPrevMnMthsOverdueFineInfoDict.get("taxPrev12mthsOverdueFineInfo"); |
| | | taxVO.setOverdueFineInfoAmt12( (BigDecimal) taxPrev12mthsOverdueFineInfo.get("overdueFineInfoAmt")); |
| | | taxVO.setOverdueFineInfoCnt12( (Integer) taxPrev12mthsOverdueFineInfo.get("overdueFineInfoCnt")); |
| | | |
| | | |
| | | // 近3个月滞纳金金额(元) |
| | | JSONObject taxPrev3mthsOverdueFineInfo = (JSONObject) taxPrevMnMthsOverdueFineInfoDict.get("taxPrev3mthsOverdueFineInfo"); |
| | | taxVO.setOverdueFineInfoCnt3( (Integer) taxPrev3mthsOverdueFineInfo.get("overdueFineInfoCnt")); |
| | | |
| | | //近12月0申报月数(月数) |
| | | JSONObject taxPrevMnMthsAllTaxDclrInfoDict = (JSONObject) taxInfo.get("taxPrevMnMthsAllTaxDclrInfoDict"); |
| | | JSONObject taxPrev12mthsAllTaxDclrInfoDict = (JSONObject) taxPrevMnMthsAllTaxDclrInfoDict.get("taxPrev12mthsAllTaxDclrInfoDict"); |
| | | taxVO.setVatTax0dclrMonCnt( (Integer) taxPrev12mthsAllTaxDclrInfoDict.get("vatTax0dclrMonCnt")); |
| | | |
| | | return R.ok(taxVO); |
| | | } |
| | | |
| | | @Override |
| | | public TaxVO tax(String id) { |
| | | return null; |
| | | public R invoice(String id) { |
| | | InvoiceVO vo = new InvoiceVO(); |
| | | /* Company companyInfo = companyMapper.selectById(id); |
| | | if (null == companyInfo || companyInfo.getIsDelete() != 0) { |
| | | throw new ServiceException("公司不存在"); |
| | | }*/ |
| | | // JSONObject jsonObject=getReport(companyInfo.getLink().split("=")[1]); |
| | | JSONObject jsonObject=getReport("ZZD20250508017232394218445"); |
| | | if (!"1001".equals(jsonObject.getString("code"))){ |
| | | return R.fail(jsonObject.get("msg")); |
| | | } |
| | | JSONObject data1 = (JSONObject) jsonObject.get("data"); |
| | | JSONObject data2 = (JSONObject) data1.get("data"); |
| | | JSONObject invoiceInfo = (JSONObject) data2.get("invoiceInfo"); |
| | | //近45日是否有开票记录 |
| | | vo.setAnyPre45daysFpRcd((Boolean) invoiceInfo.get("anyPre45daysFpRcd")); |
| | | |
| | | //近一个月开票金额(元) |
| | | JSONArray f4yPer1mDownFpInfoList = (JSONArray) invoiceInfo.get("f4yPer1mDownFpInfoList"); |
| | | JSONObject f4yPer1mDownFpInfo1 = (JSONObject) f4yPer1mDownFpInfoList.get(1); |
| | | vo.setHjjeZc1( ObjectToBigDecimal(f4yPer1mDownFpInfo1.get("hjjeZc")) ); |
| | | |
| | | |
| | | JSONObject fpPrevMnMthsDownFpInfoList = (JSONObject) invoiceInfo.get("fpPrevMnMthsDownFpInfoList"); |
| | | JSONObject fpPrev3mthsDownFpInfoList = (JSONObject) fpPrevMnMthsDownFpInfoList.get("fpPrev3mthsDownFpInfoList"); |
| | | //近3个月开票环比增长率 |
| | | vo.setAvgMonJshjYxMomRate3( ObjectToBigDecimal(fpPrev3mthsDownFpInfoList.get("avgMonJshjYxMomRate")) ); |
| | | //近3个月开票金额(元) |
| | | vo.setHjjeZc3( ObjectToBigDecimal( fpPrev3mthsDownFpInfoList.get("hjjeZc") )); |
| | | |
| | | JSONObject fpPrev6mthsDownFpInfoList = (JSONObject) fpPrevMnMthsDownFpInfoList.get("fpPrev6mthsDownFpInfoList"); |
| | | //近6个月开票环比增长率 |
| | | vo.setAvgMonJshjYxMomRate6( ObjectToBigDecimal(fpPrev6mthsDownFpInfoList.get("avgMonJshjYxMomRate")) ); |
| | | //近6月开票金额(元) |
| | | vo.setHjjeZc6( ObjectToBigDecimal(fpPrev6mthsDownFpInfoList.get("hjjeZc")) ); |
| | | |
| | | |
| | | JSONObject fpPrev12mthsDownFpInfoList = (JSONObject) fpPrevMnMthsDownFpInfoList.get("fpPrev12mthsDownFpInfoList"); |
| | | //近12个月开票环比增长率 |
| | | vo.setAvgMonJshjYxMomRate12( ObjectToBigDecimal(fpPrev12mthsDownFpInfoList.get("avgMonJshjYxMomRate")) ); |
| | | //近12月开票金额(元) |
| | | vo.setHjjeZc12( ObjectToBigDecimal(fpPrev12mthsDownFpInfoList.get("hjjeZc")) ); |
| | | |
| | | //近24个月开票金额(元) |
| | | JSONObject fpPrev24mthsDownFpInfoList = (JSONObject) fpPrevMnMthsDownFpInfoList.get("fpPrev24mthsDownFpInfoList"); |
| | | vo.setHjjeZc24( ObjectToBigDecimal(fpPrev24mthsDownFpInfoList.get("hjjeZc") )); |
| | | |
| | | //近12个月下游客户统计 |
| | | vo.setDownCusCnt3( (Integer) fpPrev3mthsDownFpInfoList.get("downCusCnt")); |
| | | //近12个月下游客户统计 |
| | | vo.setDownCusCnt12( (Integer) fpPrev12mthsDownFpInfoList.get("downCusCnt")); |
| | | |
| | | //近12个月下游开票张数 |
| | | vo.setKpslQb( (Integer) fpPrev12mthsDownFpInfoList.get("kpslQb")); |
| | | |
| | | //近12月作废发票数量占比 |
| | | vo.setKpslFpRatio(ObjectToBigDecimal(fpPrev12mthsDownFpInfoList.get("kpslFpRatio"))); |
| | | |
| | | //近12月月均开票金额增长率 |
| | | vo.setAvgMonJshjYxYoyRate(ObjectToBigDecimal(fpPrev12mthsDownFpInfoList.get("avgMonJshjYxYoyRate")) ); |
| | | |
| | | //近12月红冲发票张数占比 |
| | | vo.setKpslHpRatio(ObjectToBigDecimal(fpPrev12mthsDownFpInfoList.get("kpslHpRatio"))); |
| | | |
| | | //近12个月红冲金额占比 |
| | | vo.setHjjeHpRatio(ObjectToBigDecimal(fpPrev12mthsDownFpInfoList.get("hjjeHpRatio")) ); |
| | | |
| | | //近12个月最大连续未开票间隔天数(销项) |
| | | vo.setNokpslYxMaxdayCnt((Integer) fpPrev12mthsDownFpInfoList.get("nokpslYxMaxdayCnt")); |
| | | |
| | | //近三年开票信息报表(元) |
| | | vo.setF4yPer1mDownFpInfoList(f4yPer1mDownFpInfoList); |
| | | |
| | | return R.ok(vo); |
| | | } |
| | | |
| | | @Override |
| | | public InvoiceVO invoice(String id) { |
| | | return null; |
| | | } |
| | | private BigDecimal ObjectToBigDecimal(Object o) { |
| | | // 处理不同类型的情况 |
| | | if ( o instanceof BigDecimal) { |
| | | return (BigDecimal) o; |
| | | } else if (o instanceof Number) { |
| | | // 将其他数字类型(如 Integer、Double)转换为 BigDecimal |
| | | return BigDecimal.valueOf(((Number) o).doubleValue()); |
| | | |
| | | } |
| | | return BigDecimal.ZERO; |
| | | } |
| | | @Transactional |
| | | @Override |
| | | public void delete(String id) { |
| | |
| | | //查看订单状态是否为待确认 |
| | | Order order = this.baseMapper.selectOne(new LambdaQueryWrapper<Order>() |
| | | .eq(Order::getCompanyId, company.getId()) |
| | | .eq(Order::getIsRefund,0) |
| | | .ne(Order::getStatus,-1));//取消的订单不要 |
| | | if (null == order) { |
| | | throw new ServiceException("订单不存在"); |
| | |
| | | |
| | | } |
| | | |
| | | @Transactional |
| | | @Override |
| | | public void cancel(String id) { |
| | | Company company = companyMapper.selectById(id); |
| | |
| | | if (!company.getStatus().equals(4)){// 4-锁定中 |
| | | throw new ServiceException("订单状态错误,不能操作"); |
| | | } |
| | | //查看订单 取消的不要 |
| | | //查看订单 |
| | | Order order = this.baseMapper.selectOne(new LambdaQueryWrapper<Order>() |
| | | .eq(Order::getCompanyId, company.getId()) |
| | | .ne(Order::getStatus,-1)); |
| | |
| | | throw new ServiceException("订单不存在"); |
| | | } |
| | | //检查状态 3已确认(未付款) 4办理中 5卖家已完成 |
| | | if (!order.getStatus().equals(3)||!order.getStatus().equals(4)||!order.getStatus().equals(5)) { |
| | | if (!order.getStatus().equals(3)&&!order.getStatus().equals(4)&&!order.getStatus().equals(5)) { |
| | | throw new ServiceException("订单状态错误,不能操作"); |
| | | } |
| | | if (company.getStatus().equals(3)){ |
| | | if (order.getStatus().equals(3)){ |
| | | //未付款 直接取消订单 |
| | | order.setStatus(-1); |
| | | this.baseMapper.updateById(order); |
| | | //将分佣次数加回 |
| | | User user = appUserMapper.selectById(order.getUserId()); |
| | | user.setInviteNum(user.getInviteNum()+1); |
| | | appUserMapper.updateById(user); |
| | | //商品状态修改 |
| | | company.setStatus(1); |
| | | order.setIsRefund(1); |
| | | order.setRefundTime(LocalDateTime.now()); |
| | | companyMapper.updateById(company); |
| | | }else{ |
| | | //退款 |
| | | order.setStatus(-1); |
| | | R r = refundPayMoney(order);//退款 |
| | | if (200 == r.getCode()) { |
| | | this.updateById(order); |
| | | //退款申请成功 |
| | | log.info("退款申请成功,订单id:{}",order.getId()); |
| | | } |
| | | } |
| | | } |
| | | |
| | | @Override |
| | | public R refundPayMoneyCallback(RefundCallbackResult refundCallbackResult) { |
| | | String code = refundCallbackResult.getR3_RefundOrderNo().substring(1); |
| | | log.info("退款回调:{}",code); |
| | | Order order = this.getOne(new LambdaQueryWrapper<Order>().eq(Order::getOrderNo, code)); |
| | | public R refundPayMoneyCallback(String xmlData ) { |
| | | RefundCallbackResult result = wechatPayService.processRefundCallback(xmlData); |
| | | if (!result.isSuccess()) { |
| | | System.out.println("会员退费错误:"+result.getMsg()); |
| | | return R.fail(result.getMsg()); |
| | | } |
| | | Order order = this.getOne(new LambdaQueryWrapper<Order>().eq(Order::getOrderNo, result.getOrderNo())); |
| | | if (null == order || order.getStatus() == -1) { |
| | | return R.ok(); |
| | | } |
| | | order.setStatus(-1); |
| | | order.setIsRefund(1); |
| | | order.setRefundTime(LocalDateTime.now()); |
| | | this.updateById(order); |
| | | //查找公司 |
| | | Company company = companyMapper.selectById(order.getCompanyId()); |
| | | |
| | | //取消订单 |
| | | order.setStatus(-1); |
| | | order.setIsRefund(1); |
| | | order.setRefundTime(LocalDateTime.now()); |
| | | this.baseMapper.updateById(order); |
| | | //将分佣次数加回 |
| | | User user = appUserMapper.selectById(order.getUserId()); |
| | | User inviter = appUserMapper.selectById(user.getInviteId()); |
| | | if (inviter!=null && inviter.getIsDelete()==0){ |
| | | inviter.setInviteNum(inviter.getInviteNum()+1); |
| | | appUserMapper.updateById(inviter); |
| | | } |
| | | |
| | | //商品状态修改 |
| | | company.setStatus(1); |
| | | companyMapper.updateById(company); |
| | | |
| | | return R.ok(); |
| | | } |
| | | /** |
| | | * 返回订单支付金额 |
| | | */ |
| | | @Autowired |
| | | private WechatPayService wechatPayService; |
| | | @Transactional |
| | | public R refundPayMoney(Order order) { |
| | | //开始退款 |
| | | BigDecimal paymentAmount = order.getPrice(); |
| | | if (BigDecimal.ZERO.compareTo(order.getPrice()) < 0) {//支付的金额是否大于0 |
| | | //微信退款 |
| | | RefundResult refund = PaymentUtil.refund(order.getOrderNo(), "R" + order.getOrderNo(), paymentAmount.doubleValue(), |
| | | "/system/order/refundPayMoneyCallback"); |
| | | if (!"100".equals(refund.getRa_Status())) { |
| | | return R.fail(refund.getRc_CodeMsg());//退款失败 |
| | | Map<String,String> map = wechatPayService.refund(order.getOrderNo(), order.getOrderNo(), order.getPrice().toString(), order.getPrice().toString(), "平台取消订单", "/system/order/refundPayMoneyCallback"); |
| | | |
| | | if (!"SUCCESS".equals(map.get("return_code"))) { |
| | | return R.fail(map.get("return_msg"));//退款失败 |
| | | } |
| | | } |
| | | //查找公司 |
| | | Company company = companyMapper.selectById(order.getCompanyId()); |
| | | |
| | | //取消订单 |
| | | order.setStatus(-1); |
| | | order.setIsRefund(1); |
| | | order.setRefundTime(LocalDateTime.now()); |
| | | this.baseMapper.updateById(order); |
| | | //将分佣次数加回 |
| | | User user = appUserMapper.selectById(order.getUserId()); |
| | | User inviter = appUserMapper.selectById(user.getInviteId()); |
| | | if (inviter!=null && inviter.getIsDelete()==0){ |
| | | inviter.setInviteNum(inviter.getInviteNum()+1); |
| | | appUserMapper.updateById(inviter); |
| | | } |
| | | |
| | | //商品状态修改 |
| | | company.setStatus(1); |
| | | companyMapper.updateById(company); |
| | | |
| | | return R.ok(); |
| | | } |
| | | |
| | |
| | | |
| | | } |
| | | |
| | | @Override |
| | | public FinanceFlowsTopVO financeTop(FinanceFlowsDTO dto) { |
| | | return this.baseMapper.financeTop(dto); |
| | | } |
| | | |
| | | @Override |
| | | public IPage<FinanceFlowsPageVO> flowsPage(FinanceFlowsDTO dto) { |
| | | IPage<FinanceFlowsPageVO> page = new Page<>(dto.getPageNum(), dto.getPageSize()); |
| | | Long total = this.baseMapper.countFlowsPage(dto); |
| | | //分页处理 |
| | | dto.setOffset((dto.getPageNum()-1)*dto.getPageSize()); |
| | | IPage<FinanceFlowsPageVO> financeFlowsPageVOIPage = this.baseMapper.flowsPage(page, dto); |
| | | financeFlowsPageVOIPage.setTotal(total); |
| | | return financeFlowsPageVOIPage; |
| | | } |
| | | |
| | | |
| | | |
| | | } |