pipIrr-platform/pipIrr-global/src/main/java/com/dy/pipIrrGlobal/daoSe/SeGeneralMapper.java
@@ -3,6 +3,7 @@ import com.baomidou.mybatisplus.core.mapper.BaseMapper; import com.dy.pipIrrGlobal.pojoSe.SeGeneral; import com.dy.pipIrrGlobal.voSe.VoGeneral; import com.dy.pipIrrGlobal.voSe.VoTransactionStatistics; import org.apache.ibatis.annotations.Mapper; import org.apache.ibatis.annotations.Param; @@ -12,7 +13,7 @@ /** * @author ZhuBaoMin * @date 2024-01-24 18:57 * @LastEditTime 2024-01-24 18:57 * @LastEditTime 2024-01-25 15:55 * @Description */ @@ -56,4 +57,33 @@ * @return */ List<VoGeneral> getGenerals(Map<?, ?> params); /** * 财务对账审核页,收银员+日期分组,排除交易类型分组,记录数 * @param params * @return */ Long getToAuditRecordCount(Map<?, ?> params); /** * 财务对账审核页,收银员+日期分组,排除交易类型分组 * @param params * @return */ List<VoTransactionStatistics> getToAudit(Map<?, ?> params); /** * 获取指定日期、指定收银员、指定支付方式实收金额合计 * @param tradeDate * @param paymentId * @return */ Float getPaymentSums(@Param("tradeDate") String tradeDate, @Param("cashierId") Long cashierId, @Param("paymentId") Long paymentId); /** * 根基指定日期、指定收银员获取笔数合计、实收金额合计、赠送金额合计 * @param params * @return */ Map getTransactionStatisticsSums(Map<?, ?> params); } pipIrr-platform/pipIrr-global/src/main/java/com/dy/pipIrrGlobal/pojoSe/SeGeneral.java
@@ -41,6 +41,13 @@ private Long id; /** * 收银员ID */ @Schema(description = "收银员ID", requiredMode = Schema.RequiredMode.NOT_REQUIRED) @NotNull(message = "收银员ID不能为空") private Long cashierId; /** * 收银员姓名 */ @Schema(description = "收银员姓名", requiredMode = Schema.RequiredMode.NOT_REQUIRED) pipIrr-platform/pipIrr-global/src/main/java/com/dy/pipIrrGlobal/voSe/VoGeneral.java
@@ -17,7 +17,10 @@ private static final long serialVersionUID = 202401241706001L; @Schema(title = "总账ID") private Long generalId; private String generalId; @Schema(title = "收银员ID") private String cashierId; @Schema(title = "收银员姓名") private String cashierName; pipIrr-platform/pipIrr-global/src/main/resources/mapper/SeCardOperateMapper.xml
@@ -361,6 +361,10 @@ <if test = "operateTimeStart != null and operateTimeStop != null"> AND ope.operate_dt BETWEEN #{operateTimeStart} AND #{operateTimeStop} </if> <if test = "cashierId != null and cashierId > 0"> AND user.id = ${cashierId} </if> </where> ORDER BY ope.operate_dt <if test="pageCurr != null and pageSize != null"> pipIrr-platform/pipIrr-global/src/main/resources/mapper/SeGeneralMapper.xml
@@ -5,6 +5,7 @@ <!--@mbg.generated--> <!--@Table se_general--> <id column="id" jdbcType="BIGINT" property="id" /> <result column="cashier_id" jdbcType="BIGINT" property="cashierId" /> <result column="cashier_name" jdbcType="VARCHAR" property="cashierName" /> <result column="trade_amount" jdbcType="FLOAT" property="tradeAmount" /> <result column="gift" jdbcType="FLOAT" property="gift" /> @@ -14,7 +15,7 @@ </resultMap> <sql id="Base_Column_List"> <!--@mbg.generated--> id, cashier_name, trade_amount, gift, total_amount, operate_date, audit_status id, cashier_id, cashier_name, trade_amount, gift, total_amount, operate_date, audit_status </sql> <select id="selectByPrimaryKey" parameterType="java.lang.Long" resultMap="BaseResultMap"> <!--@mbg.generated--> @@ -30,12 +31,12 @@ </delete> <insert id="insert" parameterType="com.dy.pipIrrGlobal.pojoSe.SeGeneral"> <!--@mbg.generated--> insert into se_general (id, cashier_name, trade_amount, gift, total_amount, operate_date, audit_status) values (#{id,jdbcType=BIGINT}, #{cashierName,jdbcType=VARCHAR}, #{tradeAmount,jdbcType=FLOAT}, #{gift,jdbcType=FLOAT}, #{totalAmount,jdbcType=FLOAT}, #{operateDate,jdbcType=TIMESTAMP}, #{auditStatus,jdbcType=TINYINT}) insert into se_general (id, cashier_id, cashier_name, trade_amount, gift, total_amount, operate_date, audit_status) values (#{id,jdbcType=BIGINT}, #{cashierId,jdbcType=BIGINT}, #{cashierName,jdbcType=VARCHAR}, #{tradeAmount,jdbcType=FLOAT}, #{gift,jdbcType=FLOAT}, #{totalAmount,jdbcType=FLOAT}, #{operateDate,jdbcType=TIMESTAMP}, #{auditStatus,jdbcType=TINYINT}) </insert> <insert id="insertSelective" parameterType="com.dy.pipIrrGlobal.pojoSe.SeGeneral"> <!--@mbg.generated--> @@ -43,6 +44,9 @@ <trim prefix="(" suffix=")" suffixOverrides=","> <if test="id != null"> id, </if> <if test="cashierId != null"> cashier_id, </if> <if test="cashierName != null"> cashier_name, @@ -66,6 +70,9 @@ <trim prefix="values (" suffix=")" suffixOverrides=","> <if test="id != null"> #{id,jdbcType=BIGINT}, </if> <if test="cashierId != null"> #{cashierId,jdbcType=BIGINT}, </if> <if test="cashierName != null"> #{cashierName,jdbcType=VARCHAR}, @@ -91,6 +98,9 @@ <!--@mbg.generated--> update se_general <set> <if test="cashierId != null"> cashier_id = #{cashierId,jdbcType=BIGINT}, </if> <if test="cashierName != null"> cashier_name = #{cashierName,jdbcType=VARCHAR}, </if> @@ -115,7 +125,8 @@ <update id="updateByPrimaryKey" parameterType="com.dy.pipIrrGlobal.pojoSe.SeGeneral"> <!--@mbg.generated--> update se_general set cashier_name = #{cashierName,jdbcType=VARCHAR}, set cashier_id = #{cashierId,jdbcType=BIGINT}, cashier_name = #{cashierName,jdbcType=VARCHAR}, trade_amount = #{tradeAmount,jdbcType=FLOAT}, gift = #{gift,jdbcType=FLOAT}, total_amount = #{totalAmount,jdbcType=FLOAT}, @@ -135,6 +146,7 @@ <!--根据交易日期获取总账记录列表(待生成的) --> <select id="getGeneralByOperateDate" resultType="com.dy.pipIrrGlobal.pojoSe.SeGeneral"> SELECT us.id AS cashierId, us.`name` AS cashierName, IFNULL(SUM(ope.trade_amount),0) AS tradeAmount, IFNULL(SUM(ope.gift),0) AS gift, @@ -170,7 +182,8 @@ <!--根据指定条件获取总账记录--> <select id="getGenerals" resultType="com.dy.pipIrrGlobal.voSe.VoGeneral"> SELECT id AS generalId, CAST(id AS char) AS generalId, CAST(cashier_id AS char) AS cashierId, cashier_name AS cashierName, trade_amount AS tradeAmount, gift, @@ -201,4 +214,76 @@ </if> </select> <!--获取指定日期、指定收银员、指定支付方式实收金额合计--> <select id="getPaymentSums" resultType="java.lang.Float"> SELECT SUM(ope.trade_amount) AS tradeAmount FROM se_card_operate ope <where> <if test = "tradeDate != null and tradeDate !=''"> AND Date(ope.operate_dt) = #{tradeDate} </if> <if test = "paymentId != null and paymentId >0"> AND ope.payment_id = ${paymentId} </if> <if test = "cashierId != null and cashierId >0"> AND ope.operator = ${cashierId} </if> </where> GROUP BY ope.payment_id, Date(ope.operate_dt) </select> <!--根基指定日期、指定收银员获取笔数合计、实收金额合计、赠送金额合计--> <select id="getTransactionStatisticsSums" resultType="java.util.Map"> SELECT SUM(count) AS totalCount, SUM(received) AS totalReceived, SUM(gift) AS totalGift FROM v_transactionstatistics2 <where> <if test = "tradeDate != null and tradeDate !=''"> AND tradeDate = #{tradeDate} </if> <if test = "cashierId != null and cashierId >0"> AND cashierId = ${cashierId} </if> </where> </select> <!-- 财务对账审核页,收银员+日期分组,排除交易类型分组,记录数--> <select id="getToAuditRecordCount" parameterType="java.util.Map" resultType="java.lang.Long"> SELECT COUNT(*) AS recordCount FROM v_transactionstatistics2 <where> <if test = "cashierId != null and cashierId > 0"> AND cashierId = ${cashierId} </if> <if test = "tradeDate != null"> AND tradeDate = #{tradeDate} </if> </where> </select> <!--财务对账审核页,收银员+日期分组,排除交易类型分组--> <select id="getToAudit" resultType="com.dy.pipIrrGlobal.voSe.VoTransactionStatistics"> SELECT * FROM v_transactionstatistics2 <where> <if test = "cashierId != null and cashierId > 0"> AND cashierId = ${cashierId} </if> <if test = "tradeDate != null"> AND tradeDate = #{tradeDate} </if> </where> ORDER BY tradeDate <if test="pageCurr != null and pageSize != null"> LIMIT ${pageCurr}, ${pageSize} </if> </select> </mapper> pipIrr-platform/pipIrr-web/pipIrr-web-sell/src/main/java/com/dy/pipIrrSell/cardOperate/qo/QoTransaction.java
@@ -30,4 +30,7 @@ @Schema(description = "交易查询截止时间") public String operateTimeStop; @Schema(description = "收银员ID") public Long cashierId; } pipIrr-platform/pipIrr-web/pipIrr-web-sell/src/main/java/com/dy/pipIrrSell/general/GeneralCtrl.java
@@ -11,6 +11,7 @@ import com.dy.pipIrrGlobal.voSe.VoGeneral; import com.dy.pipIrrSell.general.dto.DtoGeneral; import com.dy.pipIrrSell.general.qo.QoGeneral; import com.dy.pipIrrSell.general.qo.QoToAudit; import com.dy.pipIrrSell.result.SellResultCode; import io.swagger.v3.oas.annotations.Operation; import io.swagger.v3.oas.annotations.media.Content; @@ -164,4 +165,25 @@ return BaseResponseUtils.buildSuccess() ; } @Operation(summary = "获得待审核交易汇总记录", description = "返回待审核交易汇总记录") @ApiResponses(value = { @ApiResponse( responseCode = ResultCodeMsg.RsCode.SUCCESS_CODE, description = "返回一页农户数据(BaseResponse.content:QueryResultVo[{}])", content = {@Content(mediaType = MediaType.APPLICATION_JSON_VALUE, schema = @Schema(implementation = BaClient.class))} ) }) @GetMapping(path = "getToAudit") @SsoAop() public BaseResponse<Map> getToAudit(QoToAudit vo){ try { Map res = generalSv.getToAudit(vo); return BaseResponseUtils.buildSuccess(res); } catch (Exception e) { log.error("查询交易汇总记录异常", e); return BaseResponseUtils.buildException(e.getMessage()) ; } } } pipIrr-platform/pipIrr-web/pipIrr-web-sell/src/main/java/com/dy/pipIrrSell/general/GeneralSv.java
@@ -1,19 +1,23 @@ package com.dy.pipIrrSell.general; import com.alibaba.fastjson2.JSONArray; import com.alibaba.fastjson2.JSONObject; import com.dy.common.webUtil.QueryResultVo; import com.dy.pipIrrGlobal.daoSe.SeAuditsMapper; import com.dy.pipIrrGlobal.daoSe.SeCardOperateMapper; import com.dy.pipIrrGlobal.daoSe.SeGeneralMapper; import com.dy.pipIrrGlobal.pojoSe.SeAudits; import com.dy.pipIrrGlobal.pojoSe.SeGeneral; import com.dy.pipIrrGlobal.voSe.VoGeneral; import com.dy.pipIrrGlobal.voSe.VoTransactionStatistics; import com.dy.pipIrrSell.general.qo.QoGeneral; import com.dy.pipIrrSell.general.qo.QoToAudit; 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.util.List; import java.util.Map; import java.util.*; /** * @author ZhuBaoMin @@ -30,6 +34,9 @@ @Autowired private SeAuditsMapper seAuditsMapper; @Autowired private SeCardOperateMapper seCardOperateMapper; /** * 获取未生成总账的交易日期列表(当天的交易记录不生成总账) @@ -112,4 +119,71 @@ public Integer addAudits(SeAudits po) { return seAuditsMapper.insert(po); } /** * 财务对账审核页,收银员+日期分组,排除交易类型分组 * @param vo * @return */ public Map getToAudit(QoToAudit vo) { /** * 取出指定日期三种支付方式(现金、扫码、转账)实收金额 */ JSONArray array_paymentSums = new JSONArray(); String tradeDate = vo.getTradeDate(); Long cashierId = vo.cashierId; 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); JSONObject job = new JSONObject(); job.put("tradeDate", tradeDate); job.put("receivedCash", receivedCash); job.put("receivedQRCode", receivedQRCode); job.put("receivedTransfer", receivedTransfer); array_paymentSums.add(job); // 生成查询参数 Map<String, Object> params = (Map<String, Object>) PojoUtils.generalize(vo) ; //获取笔数合计、实收金额合计、赠送金额合计 Integer totalCount = 0; Float totalReceived = 0f; Float totalGift = 0f; Map map_sum = Optional.ofNullable(seGeneralMapper.getTransactionStatisticsSums(params)).orElse(new HashMap()); if(map_sum.size() > 0) { totalCount = Integer.parseInt(map_sum.get("totalCount").toString()); totalReceived = Float.parseFloat(map_sum.get("totalReceived").toString()); totalGift = Float.parseFloat(map_sum.get("totalGift").toString()); } // 获取符合条件的记录数 Long itemTotal = seGeneralMapper.getToAuditRecordCount(params); Integer pageSize = vo.getPageSize(); // 计算总页数 Integer pageTotal ; pageTotal = (int)Math.ceil((itemTotal==null?0.0D:itemTotal.doubleValue())/pageSize); // 根据当前页码及每页数量计算偏移量 Integer pageCurr = (Integer.parseInt(params.get("pageCurr").toString()) - 1) * Integer.parseInt(params.get("pageSize").toString()); params.put("pageCurr", pageCurr); List<VoTransactionStatistics> list = seGeneralMapper.getToAudit(params); Map map_record = new HashMap(); map_record.put("itemTotal", itemTotal); map_record.put("pageCurr", vo.pageCurr); map_record.put("pageSize", pageSize); map_record.put("pageTotal", pageTotal); map_record.put("list", list); Map map_result = new HashMap(); map_result.put("totalCount", totalCount); map_result.put("totalReceived", totalReceived); map_result.put("totalGift", totalGift); map_result.put("records", map_record); map_result.put("paymentSums", array_paymentSums); return map_result; } } pipIrr-platform/pipIrr-web/pipIrr-web-sell/src/main/java/com/dy/pipIrrSell/general/qo/QoToAudit.java
New file @@ -0,0 +1,27 @@ package com.dy.pipIrrSell.general.qo; import com.dy.common.webUtil.QueryConditionVo; import io.swagger.v3.oas.annotations.media.Schema; import lombok.*; /** * @author ZhuBaoMin * @date 2024-01-25 20:13 * @LastEditTime 2024-01-25 20:13 * @Description */ @Data @EqualsAndHashCode(callSuper = false) @ToString(callSuper = true) @NoArgsConstructor @AllArgsConstructor @Builder @Schema(name = "待审核交易汇总查询条件") public class QoToAudit extends QueryConditionVo { @Schema(description = "交易时间") public String tradeDate; @Schema(description = "收银员ID") public Long cashierId; }