zhubaomin
2024-09-09 97675aaafec74cc653d2dff70636241ba0de367d
pipIrr-platform/pipIrr-web/pipIrr-web-sell/src/main/java/com/dy/pipIrrSell/cardOperate/CardOperateSv.java
@@ -21,6 +21,7 @@
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;
@@ -57,6 +58,8 @@
    @Autowired
    private SeManagerCardMapper seManagerCardMapper;
    @Value("${project.projectNo}")
    private Integer projectNo;
    /**
     * 添加开卡记录
@@ -225,7 +228,8 @@
        }
        Map map_response = new HashMap();
        map_response.put("projectNo", String.format("%02x", Integer.parseInt(getProjectNo())));
//        map_response.put("projectNo", String.format("%02x", Integer.parseInt(getProjectNo())));
        map_response.put("projectNo", String.format("%02x", projectNo));
        map_response.put("orderNumber", rec);
        map_response.put("cardNum", cardNum);
        return BaseResponseUtils.buildSuccess(map_response) ;
@@ -287,6 +291,11 @@
        // 获取符合条件的记录数
        Long itemTotal = Optional.ofNullable(seCardOperateMapper.getTransactionRecordCount(params)).orElse(0L);
        QueryResultVo rsVo = new QueryResultVo<>() ;
        rsVo.pageSize = vo.pageSize ;
        rsVo.pageCurr = vo.pageCurr ;
        rsVo.calculateAndSet(itemTotal, params);
        List<VoTradeDetails> list = seCardOperateMapper.getTransactions(params);
        if(list.size() == 0) {
            return new HashMap();
@@ -295,13 +304,21 @@
        // 遍历交易明细记录,汇总购水金额、购卡金额
        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();
@@ -311,6 +328,10 @@
        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;
@@ -381,7 +402,7 @@
    }
    /**
     * 根据指定条件获取IC卡注销记录
     * 根据指定条件获取通用操作记录
     * @param queryVo
     * @return
     */
@@ -487,4 +508,26 @@
    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;
    }
}