liurunyu
5 天以前 f1c648e7ac1b4c437e7f0c9a69130cb443ca46fd
Merge branch 'master' of http://8.140.179.55:20000/r/pipIrr-SV
3个文件已修改
3个文件已添加
255 ■■■■■ 已修改文件
pipIrr-platform/pipIrr-global/src/main/resources/mapper/SeGeneralMapper.xml 6 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
pipIrr-platform/pipIrr-web/pipIrr-web-terminal/src/main/java/com/dy/pipIrrTerminal/card/CardCtrl.java 7 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
pipIrr-platform/pipIrr-web/pipIrr-web-terminal/src/main/java/com/dy/pipIrrTerminal/card/dto/DtoRecharge.java 1 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
pipIrr-platform/pipIrr-web/pipIrr-web-terminal/src/main/java/com/dy/pipIrrTerminal/general/GeneralCtrl.java 53 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
pipIrr-platform/pipIrr-web/pipIrr-web-terminal/src/main/java/com/dy/pipIrrTerminal/general/GeneralSv.java 148 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
pipIrr-platform/pipIrr-web/pipIrr-web-terminal/src/main/java/com/dy/pipIrrTerminal/general/qo/QoSummary.java 40 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
pipIrr-platform/pipIrr-global/src/main/resources/mapper/SeGeneralMapper.xml
@@ -293,8 +293,8 @@
            WHEN ope.operate_type = 2 THEN '充值'
            WHEN ope.operate_type = 3 THEN '销卡'
            WHEN ope.operate_type = 4 THEN '补卡'
            WHEN ope.operate_type = 5 THEN '返还'
            WHEN ope.operate_type = 10 THEN '反写'
            WHEN ope.operate_type = 5 THEN '补扣'
<!--            WHEN ope.operate_type = 6 THEN '返还'-->
        END AS operateType,
        Date(ope.operate_dt) AS tradeDate,
        COUNT(*) AS count,
@@ -305,7 +305,7 @@
    FROM se_card_operate ope
        INNER JOIN ba_user us ON us.id = ope.operator
    <where>
      AND ope.operate_type IN(1,2,3,4,5,10)
      AND ope.operate_type IN(1,2,3,4,5)
      AND ope.operate_valid = 2
      <if test = "cashierId != null and cashierId > 0">
        AND us.id = #{cashierId}
pipIrr-platform/pipIrr-web/pipIrr-web-terminal/src/main/java/com/dy/pipIrrTerminal/card/CardCtrl.java
@@ -54,7 +54,10 @@
            return BaseResponseUtils
                    .buildErrorMsg(Objects.requireNonNull(bindingResult.getFieldError()).getDefaultMessage());
        }
        // 检查卡片地址是否已存在
        if (cardSv.isCardAddrExists(po.getCardAddr())) {
            return BaseResponseUtils.buildErrorMsg("该卡片地址已存在,请使用其他卡");
        }
        Map map_result = cardSv.activeOrReissueTermCard(po);
        if (map_result.get("success").equals(false)) {
            return BaseResponseUtils.buildErrorMsg(map_result.get("msg").toString());
@@ -379,7 +382,7 @@
        // 检查卡片地址是否已存在
        if (cardSv.isCardAddrExists(dto.getCardAddr())) {
            return BaseResponseUtils.buildErrorMsg("该卡片地址已存在,请使用其他地址");
            return BaseResponseUtils.buildErrorMsg("该卡片地址已存在,请使用其他卡");
        }
        Map<String, Object> result = cardSv.createManagementCard(dto);
pipIrr-platform/pipIrr-web/pipIrr-web-terminal/src/main/java/com/dy/pipIrrTerminal/card/dto/DtoRecharge.java
@@ -52,6 +52,7 @@
    /**
     * 付款方式编号
     */
    @NotNull(message = "付款方式不能为空")
    private Long paymentId;
    /**
pipIrr-platform/pipIrr-web/pipIrr-web-terminal/src/main/java/com/dy/pipIrrTerminal/general/GeneralCtrl.java
New file
@@ -0,0 +1,53 @@
package com.dy.pipIrrTerminal.general;
import com.dy.common.aop.SsoAop;
import com.dy.common.webUtil.BaseResponse;
import com.dy.common.webUtil.BaseResponseUtils;
import com.dy.pipIrrTerminal.general.qo.QoSummary;
import io.swagger.v3.oas.annotations.tags.Tag;
import jakarta.validation.Valid;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.validation.BindingResult;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import java.util.Map;
import java.util.Objects;
/**
 * @author ZhuBaoMin
 * @date 2025-06-25 11:25
 * @LastEditTime 2025-06-25 11:25
 * @Description
 */
@Slf4j
@RestController
@RequestMapping(path="general")
@RequiredArgsConstructor
public class GeneralCtrl {
    private final GeneralSv generalSv;
    /**
     * 充值机用获取交易统计记录
     * @param vo
     * @param bindingResult
     * @return
     */
    @GetMapping(path = "getSummaries")
    @SsoAop()
    public BaseResponse<Map> getSummaries(@Valid QoSummary vo, BindingResult bindingResult){
        if(bindingResult != null && bindingResult.hasErrors()){
            return BaseResponseUtils.buildErrorMsg(Objects.requireNonNull(bindingResult.getFieldError()).getDefaultMessage());
        }
        try {
            Map res = generalSv.getSummaries(vo);
            return BaseResponseUtils.buildSuccess(res);
        } catch (Exception e) {
            log.error("查询交易汇总记录异常", e);
            return BaseResponseUtils.buildException(e.getMessage()) ;
        }
    }
}
pipIrr-platform/pipIrr-web/pipIrr-web-terminal/src/main/java/com/dy/pipIrrTerminal/general/GeneralSv.java
New file
@@ -0,0 +1,148 @@
package com.dy.pipIrrTerminal.general;
import com.alibaba.fastjson2.JSON;
import com.alibaba.fastjson2.JSONArray;
import com.alibaba.fastjson2.JSONObject;
import com.dy.pipIrrGlobal.daoSe.SeGeneralMapper;
import com.dy.pipIrrGlobal.daoSe.SePaymentMethodMapper;
import com.dy.pipIrrGlobal.pojoSe.SePaymentMethod;
import com.dy.pipIrrGlobal.voSe.VoTransactionStatistics;
import com.dy.pipIrrTerminal.general.qo.QoSummary;
import lombok.extern.slf4j.Slf4j;
import org.apache.dubbo.common.utils.PojoUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.text.DecimalFormat;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.*;
/**
 * @author ZhuBaoMin
 * @date 2025-06-25 11:22
 * @LastEditTime 2025-06-25 11:22
 * @Description
 */
@Slf4j
@Service
public class GeneralSv {
    @Autowired
    private SeGeneralMapper seGeneralMapper;
    @Autowired
    private SePaymentMethodMapper sePaymentMethodMapper;
    /**
     * 充值机用获取交易统计记录
     * @param vo
     * @return
     * @throws ParseException
     */
    public Map getSummaries(QoSummary vo) throws ParseException {
        SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd");
        Integer pageSize = vo.getPageSize();
        Integer pageCurr = vo.getPageCurr();
        // 起始索引位置
        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();
        Date timeStart = dateFormat.parse(vo.getTimeStart());
        Date timeStop = dateFormat.parse(vo.getTimeStop());
        Long cashierId = vo.cashierId;
        Calendar calendar = Calendar.getInstance();
        calendar.setTime(timeStart);
        while (calendar.getTime().before(timeStop) || calendar.getTime().equals(timeStop)) {
            String tradeDate = dateFormat.format(calendar.getTime()) ;
            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("receivedPos", receivedPos);
            job.put("receivedTransfer", receivedTransfer);
            array_paymentSums.add(job);
            calendar.add(Calendar.DAY_OF_MONTH, 1);
        }
        // 生成查询参数
        Map<String, Object> params = (Map<String, Object>) PojoUtils.generalize(vo) ;
        /**
         * 根据收银员编号、交易日期查询汇总记录
         * 遍历汇总记录查询结果,计算笔数合计、实收金额合计、赠送金额合计、返还金额合计
         */
        List<VoTransactionStatistics> list = Optional.ofNullable(seGeneralMapper.getSummaries(params)).orElse(new ArrayList<>());
        if(list.size() == 0) {
            return new HashMap();
        }
        Integer totalCount = 0;
        Float totalReceived = 0f;
        Float totalGift = 0f;
        Float totalRefund = 0f;
        JSONArray array= JSONArray.parseArray(JSON.toJSONString(list));
        for(int i = 0; i < array.size(); i++) {
            JSONObject job_summary = array.getJSONObject(i);
            totalCount = totalCount +  Optional.ofNullable(job_summary.getInteger("count")).orElse(0);
            totalReceived = totalReceived + Optional.ofNullable(job_summary.getFloat("received")).orElse(0f);
            totalGift = totalGift + Optional.ofNullable(job_summary.getFloat("gift")).orElse(0f);
            totalRefund = totalRefund + Optional.ofNullable(job_summary.getFloat("refundAmount")).orElse(0f);
        }
        Map map_result = new HashMap();
        map_result.put("totalCount", totalCount);
        map_result.put("totalReceived", totalReceived);
        map_result.put("totalGift", totalGift);
        map_result.put("totalRefund", totalRefund);
        // 分页格式组装记录列表
        Map map_record = new HashMap();
        map_record.put("itemTotal", list.size());
        map_record.put("pageCurr", pageCurr);
        map_record.put("pageSize", pageSize);
        map_record.put("pageTotal", (int)Math.ceil((double)list.size() / pageSize));
        JSONArray array_record = (JSONArray) JSON.toJSON(list);
        JSONArray array_record_page = (JSONArray)JSON.toJSON(array_record.subList(startIndex, Math.min(startIndex + pageSize, array_record.size())));
        map_record.put("list", array_record_page);
        // 分页格式组装支付方式列表
        Map map_paymentSums = new HashMap();
        map_paymentSums.put("itemTotal", array_paymentSums.size());
        map_paymentSums.put("pageCurr", pageCurr);
        map_paymentSums.put("pageSize", pageSize);
        map_paymentSums.put("pageTotal", (int)Math.ceil((double)array_paymentSums.size() / pageSize));
        JSONArray array_paymentSums_page = (JSONArray) JSON.toJSON(array_paymentSums.subList(startIndex, Math.min(startIndex + pageSize, array_paymentSums.size())));
        map_paymentSums.put("list", array_paymentSums_page);
        map_result.put("records", map_record);
        map_result.put("paymentSums", map_paymentSums);
        return map_result;
    }
}
pipIrr-platform/pipIrr-web/pipIrr-web-terminal/src/main/java/com/dy/pipIrrTerminal/general/qo/QoSummary.java
New file
@@ -0,0 +1,40 @@
package com.dy.pipIrrTerminal.general.qo;
import com.dy.common.webUtil.QueryConditionVo;
import io.swagger.v3.oas.annotations.media.Schema;
import jakarta.validation.constraints.NotBlank;
import jakarta.validation.constraints.NotNull;
import lombok.*;
/**
 * @author ZhuBaoMin
 * @date 2025-06-25 13:53
 * @LastEditTime 2025-06-25 13:53
 * @Description 充值机用交易汇总查询对象
 */
@Data
@EqualsAndHashCode(callSuper = false)
@ToString(callSuper = true)
@NoArgsConstructor
@AllArgsConstructor
@Builder
public class QoSummary extends QueryConditionVo {
    /**
     * 查询起始日期
     */
    @NotBlank(message = "查询起始日期不能为空")
    public String timeStart;
    /**
     * 查询截止日期
     */
    @NotBlank(message = "查询截止日期不能为空")
    public String timeStop;
    /**
     * 收银员ID
     */
    @NotNull(message = "收银员不能为空")
    public Long cashierId;
}