| | |
| | | import com.dy.common.webUtil.BaseResponseUtils; |
| | | import com.dy.common.webUtil.QueryResultVo; |
| | | import com.dy.pipIrrGlobal.daoBa.BaSettingsMapper; |
| | | import com.dy.pipIrrGlobal.daoSe.SeCardOperateMapper; |
| | | import com.dy.pipIrrGlobal.daoSe.SeClientCardMapper; |
| | | import com.dy.pipIrrGlobal.daoSe.SeClientMapper; |
| | | import com.dy.pipIrrGlobal.daoSe.SeGeneralMapper; |
| | | import com.dy.pipIrrGlobal.pojoSe.SeCardOperate; |
| | | import com.dy.pipIrrGlobal.pojoSe.SeClientCard; |
| | | import com.dy.pipIrrGlobal.daoRm.RmOpenCloseValveHistoryMapper; |
| | | import com.dy.pipIrrGlobal.daoSe.*; |
| | | import com.dy.pipIrrGlobal.pojoSe.*; |
| | | import com.dy.pipIrrGlobal.voRm.VoExpend; |
| | | import com.dy.pipIrrGlobal.voSe.*; |
| | | import com.dy.pipIrrSell.cardOperate.dto.DtoRecharge; |
| | | import com.dy.pipIrrSell.cardOperate.enums.OperateTypeENUM; |
| | |
| | | import lombok.extern.slf4j.Slf4j; |
| | | import org.apache.dubbo.common.utils.PojoUtils; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.beans.factory.annotation.Value; |
| | | import org.springframework.stereotype.Service; |
| | | |
| | | import java.text.DecimalFormat; |
| | |
| | | @Autowired |
| | | private BaSettingsMapper baSettingsMapper; |
| | | |
| | | @Autowired |
| | | private SeManagerCardMapper seManagerCardMapper; |
| | | |
| | | @Autowired |
| | | private SePaymentMethodMapper sePaymentMethodMapper; |
| | | |
| | | @Autowired |
| | | private SeRechargeHistoryMapper seRechargeHistoryMapper; |
| | | |
| | | @Autowired |
| | | private RmOpenCloseValveHistoryMapper rmOpenCloseValveHistoryMapper; |
| | | |
| | | @Value("${project.projectNo}") |
| | | private Integer projectNo; |
| | | |
| | | /** |
| | | * 添加开卡记录 |
| | |
| | | public Long getAreaCodeById(Long clientId) { |
| | | return seClientMapper.getAreaCodeById(clientId); |
| | | } |
| | | |
| | | /** |
| | | * 根据行政区划串模块查询水卡编号,开卡使用 |
| | | * @param areaCode |
| | | * @return |
| | | */ |
| | | String getCardNumOfMax(String areaCode) { |
| | | public String getCardNumOfMax(String areaCode) { |
| | | return seClientCardMapper.getCardNumOfMax(areaCode); |
| | | } |
| | | |
| | | /** |
| | | * 根据行政区划串模糊查询管理卡编号,创建管理卡使用 |
| | | * @param areaCode |
| | | * @return |
| | | */ |
| | | public String getManagerCardNumOfMax(String areaCode) { |
| | | return seManagerCardMapper.getManagerCardNumOfMax(areaCode); |
| | | } |
| | | |
| | | /** |
| | | * 创建管理卡 |
| | | * @param po |
| | | * @return |
| | | */ |
| | | public Long addManagerCard(SeManagerCard po) { |
| | | seManagerCardMapper.insert(po); |
| | | return po.getId(); |
| | | } |
| | | |
| | | /** |
| | |
| | | |
| | | /** |
| | | * 添加充值记录 |
| | | * 修改农户信息、添加充值记录 |
| | | * 修改农户信息、添加水卡操作记录、添加充值记录 |
| | | * @param po |
| | | * @return |
| | | */ |
| | |
| | | Long operator = po.getOperator(); |
| | | Date rechargeTime = new Date(); |
| | | |
| | | // 如果传入的是10位的水卡编号,升为17位水卡编号 |
| | | String cardNumS = String.valueOf(cardNum).trim(); |
| | | if(cardNumS.length() == 10) { |
| | | cardNumS = "100000" + cardNumS.substring(0,6) + "0" + cardNumS.substring(6); |
| | | } |
| | | cardNum = Long.valueOf(cardNumS); |
| | | |
| | | // 验证水卡状态是否支持当前操作 |
| | | String stateName = Optional.ofNullable(clientCardSv.getCardStateByCardNum(cardNum)).orElse(""); |
| | | if(stateName.length() == 0 || !stateName.equals("正常")) { |
| | |
| | | * 补卡时间 |
| | | * 最后操作类型-2 |
| | | */ |
| | | |
| | | // 根据支付方式ID获取支付方式名称 |
| | | SePaymentMethod sePaymentMethod = sePaymentMethodMapper.selectByPrimaryKey(paymentId); |
| | | String paymentName = sePaymentMethod.getName(); |
| | | |
| | | SeClientCard seClientCard = new SeClientCard(); |
| | | seClientCard.setId(cardId); |
| | | seClientCard.setMoney(afterRecharge); |
| | | seClientCard.setRechargedt(rechargeTime); |
| | | //if(paymentName != null && paymentName.equals("换卡")) { |
| | | // seClientCard.setLastoper(LastOperateENUM.CHANGE_RECHARGE.getCode ()); |
| | | //}else { |
| | | // seClientCard.setLastoper(LastOperateENUM.RECHARGE.getCode ()); |
| | | //} |
| | | seClientCard.setLastoper(LastOperateENUM.RECHARGE.getCode ()); |
| | | Integer rec_updateClientCard = Optional.ofNullable(clientCardSv.UpdateClientCard(seClientCard)).orElse(0); |
| | | if(rec_updateClientCard == 0) { |
| | |
| | | } |
| | | |
| | | /** |
| | | * 添加充值记录 |
| | | * 添加水卡充值操作记录 |
| | | */ |
| | | SeCardOperate seCardOperate = new SeCardOperate(); |
| | | seCardOperate.setCardId(cardId); |
| | |
| | | seCardOperate.setMoney(money); |
| | | seCardOperate.setTradeAmount(amount); |
| | | seCardOperate.setGift(gift); |
| | | //if(paymentName != null && paymentName.equals("换卡")) { |
| | | // seCardOperate.setOperateType(OperateTypeENUM.CHANGE_RECHARGE.getCode()); |
| | | //}else { |
| | | // seCardOperate.setOperateType(OperateTypeENUM.RECHARGE.getCode()); |
| | | //} |
| | | seCardOperate.setOperateType(OperateTypeENUM.RECHARGE.getCode()); |
| | | seCardOperate.setPaymentId(paymentId); |
| | | seCardOperate.setPrice(price); |
| | |
| | | seCardOperateMapper.insert(seCardOperate); |
| | | Long rec = Optional.ofNullable(seCardOperate.getId()).orElse(0L); |
| | | if(rec == 0) { |
| | | return BaseResponseUtils.buildErrorMsg(SellResultCode.REPLACE_FAIL_WRITE_RECHARGE_ERROR.getMessage()); |
| | | return BaseResponseUtils.buildErrorMsg(SellResultCode.RECHARGE_FAIL_WRITE_RECHARGE_ERROR.getMessage()); |
| | | } |
| | | |
| | | return BaseResponseUtils.buildSuccess(true) ; |
| | | /** |
| | | * 添加充值历史记录 |
| | | */ |
| | | SeRechargeHistory seRechargeHistory = new SeRechargeHistory(); |
| | | seRechargeHistory.setCardid(cardId); |
| | | seRechargeHistory.setClientid(clientId); |
| | | seRechargeHistory.setMoney(money); |
| | | seRechargeHistory.setAmount(amount); |
| | | seRechargeHistory.setGift(gift); |
| | | seRechargeHistory.setAfterrecharge(afterRecharge); |
| | | seRechargeHistory.setPaymentid(paymentId); |
| | | seRechargeHistory.setPrice(price); |
| | | seRechargeHistory.setRemarks(remarks); |
| | | seRechargeHistory.setOperator(operator); |
| | | seRechargeHistory.setOperatedt(rechargeTime); |
| | | seRechargeHistoryMapper.insert(seRechargeHistory); |
| | | Long rec_seRechargeHistory = Optional.ofNullable(seRechargeHistory.getId()).orElse(0L); |
| | | if(rec_seRechargeHistory == 0) { |
| | | return BaseResponseUtils.buildErrorMsg(SellResultCode.RECHARGE_FAIL_WRITE_RECHARGE_HISTORY_ERROR.getMessage()); |
| | | } |
| | | |
| | | Map map_response = new HashMap(); |
| | | map_response.put("projectNo", String.format("%02x", projectNo)); |
| | | map_response.put("orderNumber", rec); |
| | | map_response.put("cardNum", cardNum); |
| | | return BaseResponseUtils.buildSuccess(map_response) ; |
| | | } |
| | | |
| | | /** |
| | |
| | | } |
| | | |
| | | /** |
| | | * 获取充值记录,管理平台充值列表使用,APP未使用 |
| | | * @param queryVo |
| | | * @return |
| | | */ |
| | | public QueryResultVo<List<VoRechargeNew>> getRechargesNew(QoRecharge queryVo) { |
| | | Map<String, Object> params = (Map<String, Object>) PojoUtils.generalize(queryVo); |
| | | |
| | | Long itemTotal = seCardOperateMapper.getRechargesCountNew(params); |
| | | |
| | | QueryResultVo<List<VoRechargeNew>> rsVo = new QueryResultVo<>() ; |
| | | rsVo.pageSize = queryVo.pageSize ; |
| | | rsVo.pageCurr = queryVo.pageCurr ; |
| | | |
| | | rsVo.calculateAndSet(itemTotal, params); |
| | | rsVo.obj = seCardOperateMapper.getRechargesNew(params); |
| | | return rsVo ; |
| | | } |
| | | |
| | | /** |
| | | * 获取返还记录,管理平台充值列表使用 |
| | | * @param queryVo |
| | | * @return |
| | | */ |
| | | public QueryResultVo<List<VoRefund>> getRefunds(QoRecharge queryVo) { |
| | | Map<String, Object> params = (Map<String, Object>) PojoUtils.generalize(queryVo); |
| | | |
| | | Long itemTotal = seCardOperateMapper.getRefundsCount(params); |
| | | |
| | | QueryResultVo<List<VoRefund>> rsVo = new QueryResultVo<>() ; |
| | | rsVo.pageSize = queryVo.pageSize ; |
| | | rsVo.pageCurr = queryVo.pageCurr ; |
| | | |
| | | rsVo.calculateAndSet(itemTotal, params); |
| | | rsVo.obj = seCardOperateMapper.getRefunds(params); |
| | | return rsVo ; |
| | | } |
| | | |
| | | /** |
| | | * 获取水卡消费记录,管理平台使用 |
| | | * @param queryVo |
| | | * @return |
| | | */ |
| | | public QueryResultVo<List<VoExpend>> getExpends(QoRecharge queryVo) { |
| | | Map<String, Object> params = (Map<String, Object>) PojoUtils.generalize(queryVo); |
| | | |
| | | Long itemTotal = rmOpenCloseValveHistoryMapper.getExpendsCount(params); |
| | | |
| | | QueryResultVo<List<VoExpend>> rsVo = new QueryResultVo<>() ; |
| | | rsVo.pageSize = queryVo.pageSize ; |
| | | rsVo.pageCurr = queryVo.pageCurr ; |
| | | |
| | | rsVo.calculateAndSet(itemTotal, params); |
| | | rsVo.obj = rmOpenCloseValveHistoryMapper.getExpends(params); |
| | | return rsVo ; |
| | | } |
| | | |
| | | /** |
| | | * 根据指定条件获取交易记录 |
| | | * @param vo |
| | | * @return |
| | |
| | | // 获取符合条件的记录数 |
| | | Long itemTotal = Optional.ofNullable(seCardOperateMapper.getTransactionRecordCount(params)).orElse(0L); |
| | | |
| | | List<VoTradeDetails> list = seCardOperateMapper.getTransactions(params); |
| | | QueryResultVo<List<VoTradeDetails>> rsVo = new QueryResultVo<>() ; |
| | | rsVo.pageSize = vo.pageSize ; |
| | | rsVo.pageCurr = vo.pageCurr ; |
| | | rsVo.calculateAndSet(itemTotal, params); |
| | | |
| | | rsVo.obj = seCardOperateMapper.getTransactions(params); |
| | | List<VoTradeDetails> list = rsVo.obj; |
| | | if(list.size() == 0) { |
| | | return new HashMap(); |
| | | } |
| | |
| | | // 遍历交易明细记录,汇总购水金额、购卡金额 |
| | | Double totalWaterCost = 0.0; |
| | | Double totalCardCost = 0.0; |
| | | Double totalGift = 0.0; |
| | | Double totalRefund = 0.0; |
| | | |
| | | JSONArray array= JSONArray.parseArray(JSON.toJSONString(list)); |
| | | for(int i = 0; i < array.size(); i++) { |
| | | JSONObject job = array.getJSONObject(i); |
| | | Double waterCost = Optional.ofNullable(job.getDouble("waterCost")).orElse(0.0); |
| | | Double cardCost = Optional.ofNullable(job.getDouble("cardCost")).orElse(0.0); |
| | | Double gift = Optional.ofNullable(job.getDouble("gift")).orElse(0.0); |
| | | Double refundAmount = Optional.ofNullable(job.getDouble("refundAmount")).orElse(0.0); |
| | | |
| | | totalWaterCost = totalWaterCost + waterCost; |
| | | totalCardCost = totalCardCost + cardCost; |
| | | totalGift = totalGift + gift; |
| | | totalRefund = totalRefund + refundAmount; |
| | | } |
| | | |
| | | Map map_record = new HashMap(); |
| | | map_record.put("itemTotal", itemTotal); |
| | | map_record.put("list", list); |
| | | map_record.put("list", rsVo); |
| | | |
| | | Map map_result = new HashMap(); |
| | | map_result.put("waterCost", df.format(totalWaterCost)); |
| | | map_result.put("cardCost", df.format(totalCardCost)); |
| | | map_result.put("gift", df.format(totalGift)); |
| | | map_result.put("refund", df.format(totalRefund)); |
| | | |
| | | map_result.put("records", map_record); |
| | | |
| | | return map_result; |
| | |
| | | } |
| | | |
| | | /** |
| | | * 根据指定条件获取IC卡注销记录 |
| | | * 根据指定条件获取通用操作记录 |
| | | * @param queryVo |
| | | * @return |
| | | */ |
| | |
| | | * @return |
| | | */ |
| | | public Map getReceipts(QoReceipt queryVo) { |
| | | if (queryVo.getTimeStart() != null && queryVo.getTimeStart() != ""){ |
| | | queryVo.setTimeStart(queryVo.getTimeStart() + " 00:00:00"); |
| | | } |
| | | if (queryVo.getTimeStop() != null && queryVo.getTimeStop() != ""){ |
| | | queryVo.setTimeStop(queryVo.getTimeStop() + " 23:59:59"); |
| | | } |
| | | |
| | | Map<String, Object> params = (Map<String, Object>) PojoUtils.generalize(queryVo); |
| | | |
| | | DecimalFormat df = new DecimalFormat("#.00"); |
| | |
| | | public Double getTradeAmountByCardNo(Long cardNum) { |
| | | return seCardOperateMapper.getTradeAmountByCardNo(cardNum); |
| | | } |
| | | |
| | | /** |
| | | * 根据水卡地址判断该卡是否可以开卡 |
| | | * @param cardAddr |
| | | * @return |
| | | */ |
| | | public Boolean canActiveCard(String cardAddr) { |
| | | |
| | | // 指定水卡地址的水卡数量 |
| | | Long cardCount = Optional.ofNullable(seClientCardMapper.getCountByCardAddr(cardAddr)).orElse(0L); |
| | | if(cardCount == 0) { |
| | | return true; |
| | | } |
| | | |
| | | // 指定水卡地址且正常状态或挂失状态的水卡数量 |
| | | cardCount = Optional.ofNullable(seClientCardMapper.getCountByCardAddrAndState(cardAddr)).orElse(0L); |
| | | if(cardCount == 0) { |
| | | return true; |
| | | } |
| | | |
| | | return false; |
| | | } |
| | | } |