|  |  |  | 
|---|
|  |  |  | import com.dy.pipIrrGlobal.daoSe.*; | 
|---|
|  |  |  | import com.dy.pipIrrGlobal.pojoSe.SeAudits; | 
|---|
|  |  |  | import com.dy.pipIrrGlobal.pojoSe.SeGeneral; | 
|---|
|  |  |  | import com.dy.pipIrrGlobal.pojoSe.SePaymentMethod; | 
|---|
|  |  |  | import com.dy.pipIrrGlobal.voSe.VoGeneral; | 
|---|
|  |  |  | import com.dy.pipIrrGlobal.voSe.VoTradeDetails; | 
|---|
|  |  |  | import com.dy.pipIrrGlobal.voSe.VoTransactionStatistics; | 
|---|
|  |  |  | 
|---|
|  |  |  | @Autowired | 
|---|
|  |  |  | private SeRefundMapper seRefundMapper; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | @Autowired | 
|---|
|  |  |  | private SePaymentMethodMapper sePaymentMethodMapper; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | /** | 
|---|
|  |  |  | * 获取未生成总账的交易日期列表(当天的交易记录不生成总账) | 
|---|
|  |  |  | * @return | 
|---|
|  |  |  | 
|---|
|  |  |  | rsVo.pageSize = queryVo.pageSize ; | 
|---|
|  |  |  | rsVo.pageCurr = queryVo.pageCurr ; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | rsVo.calculateAndSet(itemTotal, params); | 
|---|
|  |  |  | rsVo.obj = seGeneralMapper.getGenerals(params); | 
|---|
|  |  |  | return rsVo ; | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | /** | 
|---|
|  |  |  | * 导出指定条件的总账记录 | 
|---|
|  |  |  | * @param queryVo | 
|---|
|  |  |  | * @return | 
|---|
|  |  |  | */ | 
|---|
|  |  |  | public QueryResultVo<List<VoGeneral>> exportGenerals(QoGeneral queryVo) { | 
|---|
|  |  |  | Map<String, Object> params = (Map<String, Object>) PojoUtils.generalize(queryVo); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | Long itemTotal = seGeneralMapper.getRecordCount(params); | 
|---|
|  |  |  | QueryResultVo<List<VoGeneral>> rsVo = new QueryResultVo<>() ; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | rsVo.calculateAndSet(itemTotal, params); | 
|---|
|  |  |  | params.remove("start"); | 
|---|
|  |  |  | params.remove("count"); | 
|---|
|  |  |  | rsVo.obj = seGeneralMapper.getGenerals(params); | 
|---|
|  |  |  | return rsVo ; | 
|---|
|  |  |  | } | 
|---|
|  |  |  | 
|---|
|  |  |  | // 起始索引位置 | 
|---|
|  |  |  | Integer startIndex = (pageCurr - 1) * pageSize; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | // 获取各支付方式ID | 
|---|
|  |  |  | Long paymentId_cash = 0L; | 
|---|
|  |  |  | Long paymentId_pos = 0L; | 
|---|
|  |  |  | Long paymentId_transfer = 0L; | 
|---|
|  |  |  | List<SePaymentMethod> list_payment = sePaymentMethodMapper.getPaymentMethods(); | 
|---|
|  |  |  | for (int i = 0; i < list_payment.size(); i++) { | 
|---|
|  |  |  | SePaymentMethod paymentMethod = list_payment.get(i); | 
|---|
|  |  |  | if(paymentMethod.getName().equals("现金")) { | 
|---|
|  |  |  | paymentId_cash = paymentMethod.getId(); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | if(paymentMethod.getName().equals("POS机")) { | 
|---|
|  |  |  | paymentId_pos = paymentMethod.getId(); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | if(paymentMethod.getName().equals("银行转账")) { | 
|---|
|  |  |  | paymentId_transfer = paymentMethod.getId(); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | // 接收传入参数:交易起止日期、收银员ID | 
|---|
|  |  |  | JSONArray array_paymentSums = new JSONArray(); | 
|---|
|  |  |  | 
|---|
|  |  |  | while (calendar.getTime().before(timeStop) || calendar.getTime().equals(timeStop)) { | 
|---|
|  |  |  | String tradeDate = dateFormat.format(calendar.getTime()) ; | 
|---|
|  |  |  | if(cashierId != 1000000L) { | 
|---|
|  |  |  | Float receivedCash = Optional.ofNullable(seGeneralMapper.getPaymentSums(tradeDate, cashierId, 1L)).orElse(0f); | 
|---|
|  |  |  | Float receivedQRCode = Optional.ofNullable(seGeneralMapper.getPaymentSums(tradeDate, cashierId,2L)).orElse(0f); | 
|---|
|  |  |  | Float receivedTransfer = Optional.ofNullable(seGeneralMapper.getPaymentSums(tradeDate, cashierId, 3L)).orElse(0f); | 
|---|
|  |  |  | Float receivedCash = Optional.ofNullable(seGeneralMapper.getPaymentSums(tradeDate, cashierId, paymentId_cash)).orElse(0f); | 
|---|
|  |  |  | Float receivedPos = Optional.ofNullable(seGeneralMapper.getPaymentSums(tradeDate, cashierId,paymentId_pos)).orElse(0f); | 
|---|
|  |  |  | Float receivedTransfer = Optional.ofNullable(seGeneralMapper.getPaymentSums(tradeDate, cashierId, paymentId_transfer)).orElse(0f); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | JSONObject job = new JSONObject(); | 
|---|
|  |  |  | job.put("tradeDate", tradeDate); | 
|---|
|  |  |  | job.put("receivedCash", receivedCash); | 
|---|
|  |  |  | job.put("receivedQRCode", receivedQRCode); | 
|---|
|  |  |  | job.put("receivedPos", receivedPos); | 
|---|
|  |  |  | job.put("receivedTransfer", receivedTransfer); | 
|---|
|  |  |  | array_paymentSums.add(job); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | }else { | 
|---|
|  |  |  | // 分级计算指定日期微信收退款合计,再计算实收金额 | 
|---|
|  |  |  | // 此处应用时再优化 | 
|---|
|  |  |  | Double rechargeWeChat = Optional.ofNullable(seWalletRechargeMapper.getRechargeSum(tradeDate)).orElse(0.0); | 
|---|
|  |  |  | Double refundWeChat = Optional.ofNullable(seRefundMapper.getRefundSum(tradeDate)).orElse(0.0); | 
|---|
|  |  |  | Double receiveWeChat = rechargeWeChat - refundWeChat; | 
|---|
|  |  |  | 
|---|
|  |  |  | return map_result; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | /** | 
|---|
|  |  |  | * 导出交易明细记录 | 
|---|
|  |  |  | * @param queryVo | 
|---|
|  |  |  | * @return | 
|---|
|  |  |  | */ | 
|---|
|  |  |  | public Map exportTradeDetails(QoToAudit queryVo) { | 
|---|
|  |  |  | DecimalFormat df = new DecimalFormat("0.00"); | 
|---|
|  |  |  | Map<String, Object> params = (Map<String, Object>) PojoUtils.generalize(queryVo); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | Long itemTotal = seGeneralMapper.getTradeDetailsRecordCount(params); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | QueryResultVo<List<VoTradeDetails>> rsVo = new QueryResultVo<>() ; | 
|---|
|  |  |  | rsVo.pageSize = queryVo.pageSize ; | 
|---|
|  |  |  | rsVo.pageCurr = queryVo.pageCurr ; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | rsVo.calculateAndSet(itemTotal, params); | 
|---|
|  |  |  | params.remove("start"); | 
|---|
|  |  |  | params.remove("count"); | 
|---|
|  |  |  | List<VoTradeDetails> list = Optional.ofNullable(seGeneralMapper.getTradeDetails(params)).orElse(new ArrayList<>()); | 
|---|
|  |  |  | if(list.size() == 0) { | 
|---|
|  |  |  | return new HashMap(); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | // 遍历交易明细记录,汇总交易金额 | 
|---|
|  |  |  | Double totalTradeAmount = 0.0; | 
|---|
|  |  |  | JSONArray array= JSONArray.parseArray(JSON.toJSONString(list)); | 
|---|
|  |  |  | for(int i = 0; i < array.size(); i++) { | 
|---|
|  |  |  | JSONObject job = array.getJSONObject(i); | 
|---|
|  |  |  | Double tradeAmount = Optional.ofNullable(job.getDouble("tradeAmount")).orElse(0.0); | 
|---|
|  |  |  | totalTradeAmount = totalTradeAmount + tradeAmount; | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | Map map_record = new HashMap(); | 
|---|
|  |  |  | map_record.put("itemTotal", rsVo.itemTotal); | 
|---|
|  |  |  | map_record.put("pageCurr", rsVo.pageCurr); | 
|---|
|  |  |  | map_record.put("pageSize", rsVo.pageSize); | 
|---|
|  |  |  | map_record.put("pageTotal", rsVo.pageTotal); | 
|---|
|  |  |  | map_record.put("list", list); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | Map map_result = new HashMap(); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | map_result.put("totalTradeAmount", df.format(totalTradeAmount)); | 
|---|
|  |  |  | map_result.put("records", map_record); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | return map_result; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|