2024-02-04 朱宝民 优化交易明细接口,合并交易统计接口
| | |
| | | import com.dy.pipIrrGlobal.pojoSe.SeCardOperate; |
| | | import com.dy.pipIrrGlobal.voSe.*; |
| | | import org.apache.ibatis.annotations.Mapper; |
| | | import org.apache.ibatis.annotations.Param; |
| | | |
| | | import java.util.List; |
| | | import java.util.Map; |
| | |
| | | */ |
| | | /*List<VoTransaction> getTransactions(Map<?, ?> params);*/ |
| | | List<VoTradeDetails> getTransactions(Map<?, ?> params); |
| | | |
| | | /** |
| | | * 根据指定条件获取交易统计记录数 |
| | | * @param params |
| | | * @return |
| | | */ |
| | | Long getTransactionStatisticsRecordCount(Map<?, ?> params); |
| | | |
| | | /** |
| | | * 根据指定条件获取交易统计记录 |
| | | * @param params |
| | | * @return |
| | | */ |
| | | List<VoTransactionStatistics> getTransactionStatistics(Map<?, ?> params); |
| | | |
| | | /** |
| | | * 根基指定条件获取笔数合计、实收金额合计、赠送金额合计 |
| | | * @param params |
| | | * @return |
| | | */ |
| | | Map getTransactionStatisticsSums(Map<?, ?> params); |
| | | |
| | | /** |
| | | * 获取指定日期、指定支付方式实收金额合计 |
| | | * @param tradeDate |
| | | * @param paymentId |
| | | * @return |
| | | */ |
| | | //Float getPaymentSums(Map<?, ?> params); |
| | | Float getPaymentSums(@Param("tradeDate") String tradeDate, @Param("paymentId") Long paymentId); |
| | | |
| | | /** |
| | | * 根据指定条件获取开卡记录数 |
| | |
| | | * @param params |
| | | * @return |
| | | */ |
| | | Long getToAuditRecordCount(Map<?, ?> params); |
| | | //Long getToAuditRecordCount(Map<?, ?> params); |
| | | |
| | | /** |
| | | * 财务对账审核页,收银员+日期分组,排除交易类型分组 |
| | | * 开卡系统交易统计,收银员+日期+类型分组 |
| | | * @param params |
| | | * @return |
| | | */ |
| | | List<VoTransactionStatistics> getToAudit(Map<?, ?> params); |
| | | List<VoTransactionStatistics> getSummaries(Map<?, ?> params); |
| | | |
| | | /** |
| | | * 获取指定日期、指定收银员、指定支付方式实收金额合计 |
| | |
| | | * @return |
| | | */ |
| | | Float getPaymentSums(@Param("tradeDate") String tradeDate, @Param("cashierId") Long cashierId, @Param("paymentId") Long paymentId); |
| | | |
| | | /** |
| | | * 根基指定日期、指定收银员获取笔数合计、实收金额合计、赠送金额合计 |
| | | * @param params |
| | | * @return |
| | | */ |
| | | Map getTransactionStatisticsSums(Map<?, ?> params); |
| | | |
| | | /** |
| | | * 根据收银员ID及日期获取财务对账_交易明细记录数 |
| | |
| | | private Double gift; |
| | | |
| | | /** |
| | | * 总额 |
| | | * 返还金额 |
| | | */ |
| | | @Schema(description = "总额", requiredMode = Schema.RequiredMode.NOT_REQUIRED) |
| | | @NotNull(message = "总额不能为空") |
| | | private Double totalAmount; |
| | | @Schema(description = "返还金额", requiredMode = Schema.RequiredMode.NOT_REQUIRED) |
| | | @NotNull(message = "返还金额不能为空") |
| | | private Double refundAmount; |
| | | |
| | | /** |
| | | * 交易日期 |
| | |
| | | @Schema(title = "赠送金额") |
| | | private Float gift; |
| | | |
| | | @Schema(title = "总额") |
| | | private Float totalAmount; |
| | | @Schema(title = "返还金额") |
| | | private Float refundAmount; |
| | | |
| | | @Schema(title = "交易日期") |
| | | private String operateDate; |
| | |
| | | @Schema(title = "赠送金额") |
| | | private Float gift; |
| | | |
| | | @Schema(title = "返还金额") |
| | | private Float refundAmount; |
| | | |
| | | @Schema(title = "收银员ID") |
| | | private String cashierId; |
| | | } |
| | |
| | | </if> |
| | | </select> |
| | | |
| | | |
| | | <!--根据指定条件获取交易统计记录数--> |
| | | <select id="getTransactionStatisticsRecordCount" parameterType="java.util.Map" resultType="java.lang.Long"> |
| | | SELECT |
| | | COUNT(*) AS recordCount |
| | | FROM v_transactionstatistics |
| | | <where> |
| | | <if test = "operateTimeStart != null and operateTimeStop != null"> |
| | | AND tradeDate BETWEEN #{operateTimeStart} AND #{operateTimeStop} |
| | | </if> |
| | | </where> |
| | | </select> |
| | | |
| | | <!--根据指定条件获取交易统计记录--> |
| | | <select id="getTransactionStatistics" resultType="com.dy.pipIrrGlobal.voSe.VoTransactionStatistics"> |
| | | SELECT * FROM v_transactionstatistics |
| | | <where> |
| | | <if test = "operateTimeStart != null and operateTimeStop != null"> |
| | | AND tradeDate BETWEEN #{operateTimeStart} AND #{operateTimeStop} |
| | | </if> |
| | | </where> |
| | | ORDER BY tradeDate |
| | | <if test="pageCurr != null and pageSize != null"> |
| | | LIMIT ${pageCurr}, ${pageSize} |
| | | </if> |
| | | </select> |
| | | |
| | | <!--根基指定条件获取笔数合计、实收金额合计、赠送金额合计--> |
| | | <select id="getTransactionStatisticsSums" resultType="java.util.Map"> |
| | | SELECT |
| | | SUM(count) AS totalCount, |
| | | SUM(received) AS totalReceived, |
| | | SUM(gift) AS totalGift |
| | | FROM v_transactionstatistics |
| | | <where> |
| | | <if test = "operateTimeStart != null and operateTimeStop != null"> |
| | | AND tradeDate BETWEEN #{operateTimeStart} AND #{operateTimeStop} |
| | | </if> |
| | | </where> |
| | | </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> |
| | | </where> |
| | | GROUP BY ope.payment_id, Date(ope.operate_dt) |
| | | </select> |
| | | |
| | | <!--根据指定条件获取开卡记录数量--> |
| | | <select id="getActiveCardRecordCount" parameterType="java.util.Map" resultType="java.lang.Long"> |
| | | select |
| | |
| | | <result column="cashier_name" jdbcType="VARCHAR" property="cashierName" /> |
| | | <result column="trade_amount" jdbcType="FLOAT" property="tradeAmount" /> |
| | | <result column="gift" jdbcType="FLOAT" property="gift" /> |
| | | <result column="total_amount" jdbcType="FLOAT" property="totalAmount" /> |
| | | <result column="refund_amount" jdbcType="FLOAT" property="refundAmount" /> |
| | | <result column="operate_date" jdbcType="TIMESTAMP" property="operateDate" /> |
| | | <result column="audit_status" jdbcType="TINYINT" property="auditStatus" /> |
| | | </resultMap> |
| | | <sql id="Base_Column_List"> |
| | | <!--@mbg.generated--> |
| | | id, cashier_id, cashier_name, trade_amount, gift, total_amount, operate_date, audit_status |
| | | id, cashier_id, cashier_name, trade_amount, gift, refund_amount, operate_date, audit_status |
| | | </sql> |
| | | <select id="selectByPrimaryKey" parameterType="java.lang.Long" resultMap="BaseResultMap"> |
| | | <!--@mbg.generated--> |
| | |
| | | <insert id="insert" parameterType="com.dy.pipIrrGlobal.pojoSe.SeGeneral"> |
| | | <!--@mbg.generated--> |
| | | insert into se_general (id, cashier_id, cashier_name, |
| | | trade_amount, gift, total_amount, |
| | | trade_amount, gift, refund_amount, |
| | | operate_date, audit_status) |
| | | values (#{id,jdbcType=BIGINT}, #{cashierId,jdbcType=BIGINT}, #{cashierName,jdbcType=VARCHAR}, |
| | | #{tradeAmount,jdbcType=FLOAT}, #{gift,jdbcType=FLOAT}, #{totalAmount,jdbcType=FLOAT}, |
| | | #{tradeAmount,jdbcType=FLOAT}, #{gift,jdbcType=FLOAT}, #{refundAmount,jdbcType=FLOAT}, |
| | | #{operateDate,jdbcType=TIMESTAMP}, #{auditStatus,jdbcType=TINYINT}) |
| | | </insert> |
| | | <insert id="insertSelective" parameterType="com.dy.pipIrrGlobal.pojoSe.SeGeneral"> |
| | |
| | | <if test="gift != null"> |
| | | gift, |
| | | </if> |
| | | <if test="totalAmount != null"> |
| | | total_amount, |
| | | <if test="refundAmount != null"> |
| | | refund_amount, |
| | | </if> |
| | | <if test="operateDate != null"> |
| | | operate_date, |
| | |
| | | <if test="gift != null"> |
| | | #{gift,jdbcType=FLOAT}, |
| | | </if> |
| | | <if test="totalAmount != null"> |
| | | #{totalAmount,jdbcType=FLOAT}, |
| | | <if test="refundAmount != null"> |
| | | #{refundAmount,jdbcType=FLOAT}, |
| | | </if> |
| | | <if test="operateDate != null"> |
| | | #{operateDate,jdbcType=TIMESTAMP}, |
| | |
| | | <if test="gift != null"> |
| | | gift = #{gift,jdbcType=FLOAT}, |
| | | </if> |
| | | <if test="totalAmount != null"> |
| | | total_amount = #{totalAmount,jdbcType=FLOAT}, |
| | | <if test="refundAmount != null"> |
| | | refund_amount = #{refundAmount,jdbcType=FLOAT}, |
| | | </if> |
| | | <if test="operateDate != null"> |
| | | operate_date = #{operateDate,jdbcType=TIMESTAMP}, |
| | |
| | | cashier_name = #{cashierName,jdbcType=VARCHAR}, |
| | | trade_amount = #{tradeAmount,jdbcType=FLOAT}, |
| | | gift = #{gift,jdbcType=FLOAT}, |
| | | total_amount = #{totalAmount,jdbcType=FLOAT}, |
| | | refund_amount = #{refundAmount,jdbcType=FLOAT}, |
| | | operate_date = #{operateDate,jdbcType=TIMESTAMP}, |
| | | audit_status = #{auditStatus,jdbcType=TINYINT} |
| | | where id = #{id,jdbcType=BIGINT} |
| | |
| | | <!--根据交易日期获取总账记录列表(待生成的) --> |
| | | <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, |
| | | IFNULL((SUM(ope.trade_amount) + SUM(ope.gift)),0) AS totalAmount, |
| | | Date(ope.operate_dt) AS operateDate, |
| | | 1 AS auditStatus |
| | | us.id AS cashierId, |
| | | us.`name` AS cashierName, |
| | | (IFNULL(SUM(ope.trade_amount),0) + IFNULL(SUM(ope.card_cost),0)) AS tradeAmount, |
| | | IFNULL(SUM(ope.gift),0) AS gift, |
| | | IFNULL(SUM(ope.refund_amount),0) AS refundAmount, |
| | | Date(ope.operate_dt) AS operateDate, |
| | | 1 AS auditStatus |
| | | FROM se_card_operate ope |
| | | INNER JOIN ba_user us ON ope.operator = us.id |
| | | INNER JOIN ba_user us ON ope.operator = us.id |
| | | WHERE Date(ope.operate_dt) = #{operateDate} |
| | | GROUP BY ope.operator, Date(ope.operate_dt) |
| | | |
| | | UNION ALL |
| | | |
| | | SELECT |
| | | 1000000 AS cashierId, |
| | | '微信' AS cashierName, |
| | | IFNULL(SUM(amount), 0) AS tradeAmount, |
| | | 0 AS gift, |
| | | IFNULL(SUM(amount), 0) AS totalAmount, |
| | | Date(recharge_time) AS operateDate, |
| | | 1 AS auditStatus |
| | | 1000000 AS cashierId, |
| | | '微信' AS cashierName, |
| | | IFNULL(SUM(amount), 0) AS tradeAmount, |
| | | 0 AS gift, |
| | | 0 AS refundAmount, |
| | | Date(recharge_time) AS operateDate, |
| | | 1 AS auditStatus |
| | | FROM se_wallet_recharge |
| | | WHERE Date(recharge_time) = #{operateDate} |
| | | GROUP BY Date(recharge_time) |
| | |
| | | UNION ALL |
| | | |
| | | SELECT |
| | | 1000000 AS cashierId, |
| | | '微信' AS cashierName, |
| | | IFNULL(-SUM(refund_amount), 0) AS tradeAmount, |
| | | 0 AS gift, |
| | | IFNULL(-SUM(refund_amount), 0) AS totalAmount, |
| | | Date(audit_time) AS operateDate, |
| | | 1 AS auditStatus |
| | | 1000000 AS cashierId, |
| | | '微信' AS cashierName, |
| | | IFNULL(-SUM(refund_amount), 0) AS tradeAmount, |
| | | 0 AS gift, |
| | | 0 AS refundAmount, |
| | | Date(audit_time) AS operateDate, |
| | | 1 AS auditStatus |
| | | FROM se_refund |
| | | WHERE Date(audit_time) = #{operateDate} |
| | | GROUP BY Date(audit_time) |
| | |
| | | cashier_name AS cashierName, |
| | | trade_amount AS tradeAmount, |
| | | gift, |
| | | total_amount AS totalAmount, |
| | | refund_amount AS refundAmount, |
| | | Date(operate_date) AS operateDate, |
| | | (CASE |
| | | WHEN audit_status = 1 THEN "未审核" |
| | |
| | | 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_trade_summary |
| | | <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_trade_summary |
| | | <where> |
| | | <if test = "cashierId != null and cashierId > 0"> |
| | | AND cashierId = ${cashierId} |
| | | </if> |
| | | <!-- <select id="getToAuditRecordCount" parameterType="java.util.Map" resultType="java.lang.Long">--> |
| | | <!-- SELECT--> |
| | | <!-- COUNT(*) AS recordCount--> |
| | | <!-- FROM v_trade_summary--> |
| | | <!-- <where>--> |
| | | <!-- <if test = "cashierId != null and cashierId > 0">--> |
| | | <!-- AND cashierId = ${cashierId}--> |
| | | <!-- </if>--> |
| | | |
| | | <if test = "tradeDate != null"> |
| | | AND tradeDate = #{tradeDate} |
| | | </if> |
| | | </where> |
| | | </select> |
| | | <!-- <if test = "tradeDate != null">--> |
| | | <!-- AND tradeDate = #{tradeDate}--> |
| | | <!-- </if>--> |
| | | <!-- </where>--> |
| | | <!-- </select>--> |
| | | |
| | | <!--财务对账审核页,收银员+日期+类型分组,排除交易类型分组--> |
| | | <select id="getToAudit" resultType="com.dy.pipIrrGlobal.voSe.VoTransactionStatistics"> |
| | | <!--开卡系统交易统计,收银员+日期+类型分组--> |
| | | <select id="getSummaries" resultType="com.dy.pipIrrGlobal.voSe.VoTransactionStatistics"> |
| | | SELECT * FROM v_trade_summary |
| | | <where> |
| | | <if test = "cashierId != null and cashierId > 0"> |
| | | AND cashierId = ${cashierId} |
| | | </if> |
| | | |
| | | <if test = "tradeDate != null"> |
| | | AND tradeDate = #{tradeDate} |
| | | <if test = "timeStart != null and timeStop != null"> |
| | | AND Date(tradeDate) BETWEEN #{timeStart} AND #{timeStop} |
| | | </if> |
| | | </where> |
| | | ORDER BY tradeDate |
| | |
| | | </if> |
| | | |
| | | <if test = "tradeDate != null"> |
| | | AND tradeDate = #{tradeDate} |
| | | AND Date(tradeTime) = #{tradeDate} |
| | | </if> |
| | | </where> |
| | | </select> |
| | |
| | | AND cashierId = ${cashierId} |
| | | </if> |
| | | |
| | | <if test = "tradeTime != null"> |
| | | AND tradeTime = #{tradeTime} |
| | | <if test = "tradeDate != null"> |
| | | AND Date(tradeTime) = #{tradeDate} |
| | | </if> |
| | | </where> |
| | | ORDER BY tradeTime |
| | |
| | | |
| | | |
| | | /** |
| | | * 获取交易汇总记录 |
| | | * @param vo |
| | | * @return |
| | | */ |
| | | @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 = "getStatistics") |
| | | @SsoAop() |
| | | public BaseResponse<Map> getStatistics(QoTransactionStatistics vo){ |
| | | try { |
| | | Map res = cardOperateSv.getTransactionStatistics(vo); |
| | | return BaseResponseUtils.buildSuccess(res); |
| | | } catch (Exception e) { |
| | | log.error("查询交易汇总记录异常", e); |
| | | return BaseResponseUtils.buildException(e.getMessage()) ; |
| | | } |
| | | } |
| | | |
| | | |
| | | /** |
| | | * 根据指定条件获取开卡记录 |
| | | * @param vo |
| | | * @return |
| | |
| | | import org.springframework.stereotype.Service; |
| | | |
| | | import java.text.DecimalFormat; |
| | | import java.text.ParseException; |
| | | import java.text.SimpleDateFormat; |
| | | import java.util.*; |
| | | |
| | | /** |
| | |
| | | map_result.put("waterCost", df.format(totalWaterCost)); |
| | | map_result.put("cardCost", df.format(totalCardCost)); |
| | | map_result.put("records", map_record); |
| | | |
| | | return map_result; |
| | | } |
| | | |
| | | /** |
| | | * 获取交易统计记录 |
| | | * 1.交易统计记录 |
| | | * 2.笔数合计、实收金额合计、赠送金额合计 |
| | | * 3.每一天、各种支付方式实收金额合计 |
| | | * @param vo |
| | | * @return |
| | | */ |
| | | public Map getTransactionStatistics(QoTransactionStatistics vo) throws ParseException { |
| | | /** |
| | | * 遍历查询日期,取出每天三种支付方式(现金、扫码、转账)实收金额 |
| | | * 每天一个对象 |
| | | * 对象组成JSONArray添加到返回对象中 |
| | | */ |
| | | SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd"); |
| | | Date startDate = dateFormat.parse(vo.getOperateTimeStart()); |
| | | Date stopDate = dateFormat.parse(vo.getOperateTimeStop()); |
| | | Calendar calendar = Calendar.getInstance(); |
| | | calendar.setTime(startDate); |
| | | |
| | | JSONArray array_paymentSums = new JSONArray(); |
| | | while (calendar.getTime().before(stopDate) || calendar.getTime().equals(stopDate)) { |
| | | String tradeDate = dateFormat.format(calendar.getTime()) ; |
| | | Float receivedCash = Optional.ofNullable(seCardOperateMapper.getPaymentSums(tradeDate ,1L)).orElse(0f); |
| | | Float receivedQRCode = Optional.ofNullable(seCardOperateMapper.getPaymentSums(tradeDate,2L)).orElse(0f); |
| | | Float receivedTransfer = Optional.ofNullable(seCardOperateMapper.getPaymentSums(tradeDate, 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); |
| | | calendar.add(Calendar.DAY_OF_MONTH, 1); |
| | | } |
| | | |
| | | |
| | | // 补齐查询时间 |
| | | String operateTimeStart = vo.operateTimeStart; |
| | | String operateTimeStop = vo.operateTimeStop; |
| | | if(operateTimeStart != null) { |
| | | operateTimeStart = operateTimeStart + " 00:00:00"; |
| | | vo.setOperateTimeStart(operateTimeStart); |
| | | } |
| | | if(operateTimeStop != null) { |
| | | operateTimeStop = operateTimeStop + " 23:59:59"; |
| | | vo.setOperateTimeStop(operateTimeStop); |
| | | } |
| | | |
| | | // 生成查询参数 |
| | | Map<String, Object> params = (Map<String, Object>) PojoUtils.generalize(vo) ; |
| | | |
| | | //获取笔数合计、实收金额合计、赠送金额合计 |
| | | Integer totalCount = 0; |
| | | Float totalReceived = 0f; |
| | | Float totalGift = 0f; |
| | | Map map_sum = Optional.ofNullable(seCardOperateMapper.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 = seCardOperateMapper.getTransactionStatisticsRecordCount(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 = seCardOperateMapper.getTransactionStatistics(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; |
| | | } |
| | |
| | | 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.QoSummary; |
| | | import com.dy.pipIrrSell.general.qo.QoToAudit; |
| | | import com.dy.pipIrrSell.result.SellResultCode; |
| | | import io.swagger.v3.oas.annotations.Operation; |
| | |
| | | try { |
| | | add_general(); |
| | | QueryResultVo<List<VoGeneral>> res = generalSv.getGenerals(vo); |
| | | return BaseResponseUtils.buildSuccess(res); |
| | | if(res.itemTotal > 0) { |
| | | return BaseResponseUtils.buildSuccess(res); |
| | | }else { |
| | | return BaseResponseUtils.buildFail(SellResultCode.No_GENERALS.getMessage()); |
| | | } |
| | | } catch (Exception e) { |
| | | log.error("查询交易记录异常", e); |
| | | return BaseResponseUtils.buildException(e.getMessage()) ; |
| | |
| | | return BaseResponseUtils.buildSuccess() ; |
| | | } |
| | | |
| | | |
| | | /** |
| | | * 获得待审核交易汇总记录 |
| | | * 开卡系统交易汇总查询与对账系统交易汇总查询共用接口 |
| | | * 开卡系统参数:收银员ID、查询起止日期 |
| | | * 对账系统参数:收银员ID、交易日期 |
| | | * @param vo |
| | | * @return |
| | | */ |
| | | @Operation(summary = "获得待审核交易汇总记录", description = "返回待审核交易汇总记录") |
| | | @Operation(summary = "获得开卡系统交易统计记录", description = "返回开卡系统交易统计记录") |
| | | @ApiResponses(value = { |
| | | @ApiResponse( |
| | | responseCode = ResultCodeMsg.RsCode.SUCCESS_CODE, |
| | |
| | | schema = @Schema(implementation = BaClient.class))} |
| | | ) |
| | | }) |
| | | @GetMapping(path = "getToAudit") |
| | | @GetMapping(path = "getSummaries") |
| | | @SsoAop() |
| | | public BaseResponse<Map> getToAudit(QoToAudit vo){ |
| | | public BaseResponse<Map> getSummaries(QoSummary vo){ |
| | | try { |
| | | Map res = generalSv.getToAudit(vo); |
| | | return BaseResponseUtils.buildSuccess(res); |
| | | Map res = generalSv.getSummaries(vo); |
| | | if(res.size() > 0) { |
| | | return BaseResponseUtils.buildSuccess(res); |
| | | }else { |
| | | return BaseResponseUtils.buildFail(SellResultCode.No_TRADE_SUMMARIES.getMessage()); |
| | | } |
| | | } catch (Exception e) { |
| | | log.error("查询交易汇总记录异常", e); |
| | | return BaseResponseUtils.buildException(e.getMessage()) ; |
| | |
| | | import com.dy.pipIrrGlobal.voSe.VoTradeDetails; |
| | | import com.dy.pipIrrGlobal.voSe.VoTransactionStatistics; |
| | | import com.dy.pipIrrSell.general.qo.QoGeneral; |
| | | import com.dy.pipIrrSell.general.qo.QoSummary; |
| | | import com.dy.pipIrrSell.general.qo.QoToAudit; |
| | | import lombok.extern.slf4j.Slf4j; |
| | | import org.apache.dubbo.common.utils.PojoUtils; |
| | |
| | | import org.springframework.stereotype.Service; |
| | | |
| | | import java.text.DecimalFormat; |
| | | import java.text.ParseException; |
| | | import java.text.SimpleDateFormat; |
| | | import java.util.*; |
| | | |
| | | /** |
| | |
| | | return seAuditsMapper.insert(po); |
| | | } |
| | | |
| | | |
| | | /** |
| | | * 财务对账审核页,收银员+日期分组,排除交易类型分组 |
| | | * 开卡系统交易汇总查询与对账系统交易汇总查询共用服务实现类 |
| | | * @param vo |
| | | * @return |
| | | * @throws ParseException |
| | | */ |
| | | public Map getToAudit(QoToAudit vo) { |
| | | public Map getSummaries(QoSummary vo) throws ParseException { |
| | | DecimalFormat df = new DecimalFormat("0.00"); |
| | | SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd"); |
| | | |
| | | // 接收传入参数:操作日期、收银员ID |
| | | // 接收传入参数:交易起止日期、收银员ID |
| | | JSONArray array_paymentSums = new JSONArray(); |
| | | String tradeDate = vo.getTradeTime(); |
| | | Date timeStart = dateFormat.parse(vo.getTimeStart()); |
| | | Date timeStop = dateFormat.parse(vo.getTimeStop()); |
| | | 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); |
| | | Calendar calendar = Calendar.getInstance(); |
| | | calendar.setTime(timeStart); |
| | | 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); |
| | | |
| | | // 分级计算指定日期微信收退款合计,再计算实收金额 |
| | | Double rechargeWeChat = Optional.ofNullable(seWalletRechargeMapper.getRechargeSum(tradeDate)).orElse(0.0); |
| | | Double refundWeChat = Optional.ofNullable(seRefundMapper.getRefundSum(tradeDate)).orElse(0.0); |
| | | Double receiveWeChat = rechargeWeChat - refundWeChat; |
| | | JSONObject job = new JSONObject(); |
| | | job.put("tradeDate", tradeDate); |
| | | job.put("receivedCash", receivedCash); |
| | | job.put("receivedQRCode", receivedQRCode); |
| | | job.put("receivedTransfer", receivedTransfer); |
| | | array_paymentSums.add(job); |
| | | |
| | | // 四种支付方式实收金额合计写入返回对象(写入前格式化) |
| | | JSONObject job = new JSONObject(); |
| | | job.put("tradeDate", tradeDate); |
| | | job.put("receivedCash", df.format(receivedCash)); |
| | | job.put("receivedQRCode", df.format(receivedQRCode)); |
| | | job.put("receivedTransfer", df.format(receivedTransfer)); |
| | | job.put("receiveWeChat", df.format(receiveWeChat)); |
| | | 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; |
| | | |
| | | // 微信实收金额写入返回对象(写入前格式化) |
| | | JSONObject job = new JSONObject(); |
| | | job.put("receiveWeChat", df.format(receiveWeChat)); |
| | | array_paymentSums.add(job); |
| | | } |
| | | calendar.add(Calendar.DAY_OF_MONTH, 1); |
| | | } |
| | | |
| | | // 生成查询参数 |
| | | Map<String, Object> params = (Map<String, Object>) PojoUtils.generalize(vo) ; |
| | | |
| | | //获取笔数合计、实收金额合计、赠送金额合计 |
| | | // 获取符合条件的记录数(代码全部注释掉了,没删) |
| | | //Long itemTotal = seGeneralMapper.getToAuditRecordCount(params); |
| | | |
| | | /** |
| | | * 根据收银员编号、交易日期查询汇总记录 |
| | | * 遍历汇总记录查询结果,计算笔数合计、实收金额合计、赠送金额合计、返还金额合计 |
| | | */ |
| | | 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; |
| | | 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()); |
| | | 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); |
| | | } |
| | | |
| | | // 获取符合条件的记录数 |
| | | Long itemTotal = seGeneralMapper.getToAuditRecordCount(params); |
| | | |
| | | 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("itemTotal", itemTotal); |
| | | 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("totalRefund", totalRefund); |
| | | |
| | | map_result.put("records", map_record); |
| | | map_result.put("paymentSums", array_paymentSums); |
| | | |
New file |
| | |
| | | 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-02-04 17:15 |
| | | * @LastEditTime 2024-02-04 17:15 |
| | | * @Description |
| | | */ |
| | | |
| | | @Data |
| | | @EqualsAndHashCode(callSuper = false) |
| | | @ToString(callSuper = true) |
| | | @NoArgsConstructor |
| | | @AllArgsConstructor |
| | | @Builder |
| | | @Schema(name = "交易汇总查询条件") |
| | | public class QoSummary extends QueryConditionVo { |
| | | @Schema(description = "查询起始日期") |
| | | public String timeStart; |
| | | |
| | | @Schema(description = "查询截止日期") |
| | | public String timeStop; |
| | | |
| | | @Schema(description = "收银员ID") |
| | | public Long cashierId; |
| | | } |
| | |
| | | @Builder |
| | | @Schema(name = "待审核交易汇总查询条件") |
| | | public class QoToAudit extends QueryConditionVo { |
| | | @Schema(description = "交易时间") |
| | | public String tradeTime; |
| | | @Schema(description = "交易日期") |
| | | public String tradeDate; |
| | | |
| | | @Schema(description = "收银员ID") |
| | | public Long cashierId; |
| | |
| | | /** |
| | | * 财务对账 |
| | | */ |
| | | No_GENERALS(100001, "没有符合条件的总账记录"), |
| | | No_TRADE_SUMMARIES(100001, "没有符合条件的交易汇总记录"), |
| | | No_TRADE_DETAILS(100001, "没有符合条件的交易明细"); |
| | | |
| | | private final Integer code; |