| | |
| | | import com.doumee.core.utils.DateUtil; |
| | | import com.doumee.core.utils.Utils; |
| | | import com.doumee.core.wx.WxMiniConfig; |
| | | import com.doumee.core.wx.WxPayProperties; |
| | | import com.doumee.dao.business.WxBillDetailMapper; |
| | | import com.doumee.dao.business.WxBillMapper; |
| | | import com.doumee.dao.business.model.Goodsorder; |
| | | import com.doumee.dao.business.model.WxBill; |
| | | import com.doumee.dao.business.model.WxBillDetail; |
| | | import com.doumee.service.business.WxBillService; |
| | |
| | | import com.github.binarywang.wxpay.bean.result.WxPayBillResult; |
| | | import com.github.binarywang.wxpay.exception.WxPayException; |
| | | import org.apache.commons.lang3.StringUtils; |
| | | import org.checkerframework.checker.units.qual.C; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.stereotype.Service; |
| | | import org.springframework.transaction.annotation.Transactional; |
| | |
| | | } |
| | | @Override |
| | | @Transactional(rollbackFor = {BusinessException.class,Exception.class}) |
| | | public void getWxBill() { |
| | | public void getWxBill(String billDate) { |
| | | // 获取交易账单数据 |
| | | WxPayDownloadBillRequest request = new WxPayDownloadBillRequest(); |
| | | String billDate = DateUtil.beforeDateToStr(1); |
| | | // String billDate = DateUtil.beforeDateToStr(1); |
| | | Date ydate = DateUtil.addDaysToDate(new Date(), -1); |
| | | request.setBillDate(billDate); |
| | | request.setBillType("SUCCESS"); |
| | | WxPayBillResult response = null; |
| | |
| | | } |
| | | wxBillMapper.delete(new UpdateWrapper<WxBill>().lambda().eq( WxBill::getId, bill.getId())); |
| | | wxBillDetailMapper.delete(new UpdateWrapper<WxBillDetail>().lambda().eq( WxBillDetail::getPid, bill.getId())); |
| | | |
| | | // getTotalAndIncome(bill,ydate);//统计结算金额和自行车收入 |
| | | //总结算金额(收款金额-收款手续费-退款金额-退款手续费(负数)) |
| | | bill.setTotal(bill.getSumSuccessFee().subtract(bill.getSumCmmsAmt()).subtract(bill.getSumRefundFee()).subtract(bill.getSumRefundCmmsAmt())); |
| | | // //自行车收入(收款金额-收款手续费-退款金额-退款手续费(负数)) |
| | | // bill.setBikeFee(bill.getSumSuccessFee().subtract(bill.getSumRefundFee())); |
| | | wxBillMapper.insert(bill); |
| | | if(detailList.size()>0){ |
| | | wxBillDetailMapper.insertBatch(detailList); |
| | | } |
| | | } |
| | | private void getTotalAndIncome(WxBill bill,Date date) { |
| | | QueryWrapper<Goodsorder> queryWrapper = new QueryWrapper<>(); |
| | | queryWrapper.apply("to_char(create_date, 'yyyy-MM-dd') = {0}", date); |
| | | queryWrapper.lambda().eq(Goodsorder::getIsdeleted, Constants.ZERO); |
| | | queryWrapper.lambda().eq(Goodsorder::getStatus, Constants.goodsorderStatus.over);//已結算 |
| | | queryWrapper.select("sum(money) as totalMoney","sum(close_money) as totalCloseMoney"); |
| | | } |
| | | |
| | | private List<WxBillDetail> getDetialModelByInfo(WxBill bill, List<WxPayBillInfo> billInfoList) { |
| | |
| | | detail.setRateRemark(info.getFeeRemark());//费率备注 |
| | | detail.setRefundSuccessDate(DateUtil.getDateFromString2(info.getRefundSuccessTime()));//成功退款时间 |
| | | detail.setRefundApplyDate(DateUtil.getDateFromString2(info.getRefundTime())); //申请退款时间 |
| | | |
| | | //计算自行车收入,匹配来自自行车小程序的所有支付成功和退款成功的金额,作为自行车收入(累计收款金额-累计退款成功金额) |
| | | if(StringUtils.equals(detail.getAppid(), WxMiniConfig.wxPayService.getConfig().getAppId())){ |
| | | //自行车收入累计收款金额 |
| | | bill.setBikeFee(bill.getBikeFee().add(detail.getSettlementTotalFee())); |
| | | if(StringUtils.equals(detail.getRefundSuccessStatus(),"SUCCESS")){ |
| | | //如果退款成功,扣除退款金额 |
| | | bill.setBikeFee(bill.getBikeFee().subtract(detail.getApplyRefundFee())); |
| | | } |
| | | } |
| | | detailList.add(detail); |
| | | } |
| | | } |