|  |  | 
 |  |  |     <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 | 
 |  |  |       DISTINCT Date(ope.operate_dt) AS operateDate | 
 |  |  |     FROM se_card_operate ope | 
 |  |  |     WHERE Date(ope.operate_dt) NOT IN(SELECT operate_date FROM se_general) AND Date(ope.operate_dt) != CURDATE() | 
 |  |  |     WHERE Date(ope.operate_dt) NOT IN(SELECT operate_date FROM se_general) | 
 |  |  | <!--      取消当天限制--> | 
 |  |  | <!--      AND Date(ope.operate_dt) != CURDATE()--> | 
 |  |  |   </select> | 
 |  |  |  | 
 |  |  |   <!--根据交易日期获取总账记录列表(待生成的)  --> | 
 |  |  | 
 |  |  |     SELECT | 
 |  |  |         us.id AS cashierId, | 
 |  |  |         us.`name` AS cashierName, | 
 |  |  |         IFNULL(SUM(ope.trade_amount),0) AS tradeAmount, | 
 |  |  |         (IFNULL(SUM(ope.trade_amount),0) + IFNULL(SUM(ope.card_cost),0)) AS tradeAmount, | 
 |  |  |         IFNULL(SUM(ope.gift),0) AS gift, | 
 |  |  |         IFNULL((SUM(ope.trade_amount) + SUM(ope.gift)),0) AS totalAmount, | 
 |  |  |         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 | 
 |  |  |     WHERE Date(ope.operate_dt) = #{operateDate} | 
 |  |  |     WHERE Date(ope.operate_dt) = #{operateDate} AND ope.operate_valid = 2 | 
 |  |  |     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, | 
 |  |  |         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, | 
 |  |  |         0 AS refundAmount, | 
 |  |  |         Date(audit_time) AS operateDate, | 
 |  |  |         1 AS auditStatus | 
 |  |  |     FROM se_refund | 
 |  |  |     WHERE Date(audit_time) = #{operateDate} | 
 |  |  |     GROUP BY Date(audit_time) | 
 |  |  |   </select> | 
 |  |  |  | 
 |  |  |   <!--根据指定条件获取总账记录数--> | 
 |  |  | 
 |  |  |       </if> | 
 |  |  |  | 
 |  |  |       <if test = "auditStatus != null and auditStatus > 0"> | 
 |  |  |         AND audit_status = ${auditStatus} | 
 |  |  |         AND audit_status = #{auditStatus} | 
 |  |  |       </if> | 
 |  |  |  | 
 |  |  |       <if test = "operateDateStart != null and operateDateStop != null"> | 
 |  |  | 
 |  |  |   <!--根据指定条件获取总账记录--> | 
 |  |  |   <select id="getGenerals" resultType="com.dy.pipIrrGlobal.voSe.VoGeneral"> | 
 |  |  |     SELECT | 
 |  |  |         CAST(id AS  char) AS generalId, | 
 |  |  |         CAST(cashier_id AS char) AS cashierId, | 
 |  |  |         id AS generalId, | 
 |  |  |         cashier_id AS cashierId, | 
 |  |  |         cashier_name AS cashierName, | 
 |  |  |         trade_amount AS tradeAmount, | 
 |  |  |         gift, | 
 |  |  |         total_amount AS totalAmount, | 
 |  |  |         refund_amount AS refundAmount, | 
 |  |  |         (trade_amount + gift - refund_amount) AS totalAmount, | 
 |  |  |         Date(operate_date) AS operateDate, | 
 |  |  |         (CASE | 
 |  |  |           WHEN audit_status = 1 THEN "未审核" | 
 |  |  |           WHEN audit_status = 2 THEN "同意" | 
 |  |  |           WHEN audit_status = 3 THEN "驳回" | 
 |  |  |           WHEN audit_status = 1 THEN '未审核' | 
 |  |  |           WHEN audit_status = 2 THEN '同意' | 
 |  |  |           WHEN audit_status = 3 THEN '驳回' | 
 |  |  |         END) AS auditStatus | 
 |  |  |     FROM se_general | 
 |  |  |     <where> | 
 |  |  | 
 |  |  |       </if> | 
 |  |  |  | 
 |  |  |       <if test = "auditStatus != null and auditStatus > 0"> | 
 |  |  |         AND audit_status = ${auditStatus} | 
 |  |  |         AND audit_status = #{auditStatus} | 
 |  |  |       </if> | 
 |  |  |  | 
 |  |  |       <if test = "operateDateStart != null and operateDateStop != null"> | 
 |  |  | 
 |  |  |       </if> | 
 |  |  |     </where> | 
 |  |  |     ORDER BY Date(operate_date) DESC | 
 |  |  |     <if test="pageCurr != null and pageSize != null"> | 
 |  |  |       LIMIT ${pageCurr}, ${pageSize} | 
 |  |  |     </if> | 
 |  |  |     <trim prefix="limit " > | 
 |  |  |       <if test="start != null and count != null"> | 
 |  |  |         #{start,javaType=Integer,jdbcType=INTEGER}, #{count,javaType=Integer,jdbcType=INTEGER} | 
 |  |  |       </if> | 
 |  |  |     </trim> | 
 |  |  |   </select> | 
 |  |  |  | 
 |  |  |   <!--获取指定日期、指定收银员、指定支付方式实收金额合计--> | 
 |  |  |   <select id="getPaymentSums" resultType="java.lang.Float"> | 
 |  |  |     SELECT | 
 |  |  |     SUM(ope.trade_amount) AS tradeAmount | 
 |  |  |         (SUM(ope.trade_amount) + SUM(ope.card_cost)) AS tradeAmount | 
 |  |  |     FROM se_card_operate ope | 
 |  |  |     <where> | 
 |  |  |       AND ope.operate_valid = 2 | 
 |  |  |       <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} | 
 |  |  |         AND ope.payment_id = #{paymentId} | 
 |  |  |       </if> | 
 |  |  |  | 
 |  |  |       <if test = "cashierId != null and cashierId >0"> | 
 |  |  |         AND ope.operator = ${cashierId} | 
 |  |  |         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> | 
 |  |  | <!--    GROUP BY ope.payment_id,  Date(ope.operate_dt)--> | 
 |  |  |   </select> | 
 |  |  |  | 
 |  |  |   <!--  财务对账审核页,收银员+日期分组,排除交易类型分组,记录数--> | 
 |  |  |   <select id="getToAuditRecordCount" parameterType="java.util.Map" resultType="java.lang.Long"> | 
 |  |  | <!--  <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>--> | 
 |  |  |  | 
 |  |  |   <!--开卡系统交易统计,收银员+日期+类型分组--> | 
 |  |  |   <select id="getSummaries" resultType="com.dy.pipIrrGlobal.voSe.VoTransactionStatistics"> | 
 |  |  |     SELECT | 
 |  |  |     COUNT(*) AS recordCount | 
 |  |  |     FROM v_transactionstatistics2 | 
 |  |  |         CASE | 
 |  |  |             WHEN ope.operate_type = 1 THEN '开卡' | 
 |  |  |             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 = 6 THEN '返还'--> | 
 |  |  |         END AS operateType, | 
 |  |  |         Date(ope.operate_dt) AS tradeDate, | 
 |  |  |         COUNT(*) AS count, | 
 |  |  |         (IFNULL(SUM(ope.trade_amount), 0) + IFNULL(SUM(ope.card_cost), 0)) AS received, | 
 |  |  |         IFNULL(SUM(ope.gift), 0) AS gift, | 
 |  |  |         IFNULL(sum(ope.refund_amount),0) AS refundAmount, | 
 |  |  |         us.id AS cashierId | 
 |  |  |     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) | 
 |  |  |       AND ope.operate_valid = 2 | 
 |  |  |       <if test = "cashierId != null and cashierId > 0"> | 
 |  |  |         AND cashierId = ${cashierId} | 
 |  |  |         AND us.id = #{cashierId} | 
 |  |  |       </if> | 
 |  |  |  | 
 |  |  |       <if test = "tradeDate != null"> | 
 |  |  |         AND tradeDate = #{tradeDate} | 
 |  |  |       <if test = "timeStart != null and timeStop != null"> | 
 |  |  |         AND Date(ope.operate_dt) BETWEEN #{timeStart} AND #{timeStop} | 
 |  |  |       </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> | 
 |  |  |     GROUP BY ope.operate_type,  Date(ope.operate_dt), us.id | 
 |  |  |     ORDER BY tradeDate | 
 |  |  |     <if test="pageCurr != null and pageSize != null"> | 
 |  |  |       LIMIT ${pageCurr}, ${pageSize} | 
 |  |  |     </if> | 
 |  |  |  | 
 |  |  | <!--    SELECT * FROM v_trade_summary--> | 
 |  |  | <!--    <where>--> | 
 |  |  | <!--      <if test = "cashierId != null and cashierId > 0">--> | 
 |  |  | <!--        AND cashierId = #{cashierId}--> | 
 |  |  | <!--      </if>--> | 
 |  |  |  | 
 |  |  | <!--      <if test = "timeStart != null and timeStop != null">--> | 
 |  |  | <!--        AND Date(tradeDate) BETWEEN #{timeStart} AND #{timeStop}--> | 
 |  |  | <!--      </if>--> | 
 |  |  | <!--    </where>--> | 
 |  |  | <!--    ORDER BY tradeDate--> | 
 |  |  |   </select> | 
 |  |  |  | 
 |  |  |   <!--  根据收银员ID及日期获取财务对账_交易明细记录数--> | 
 |  |  |   <select id="getTradeDetailsRecordCount" parameterType="java.util.Map" resultType="java.lang.Long"> | 
 |  |  |     SELECT | 
 |  |  |         COUNT(*) AS recordCount | 
 |  |  |     FROM v_trade_details | 
 |  |  |     <where> | 
 |  |  |       <if test = "cashierId != null and cashierId > 0"> | 
 |  |  |         AND cashierId = #{cashierId} | 
 |  |  |       </if> | 
 |  |  |  | 
 |  |  |       <if test = "tradeDate != null"> | 
 |  |  |         AND Date(tradeTime) = #{tradeDate} | 
 |  |  |       </if> | 
 |  |  |     </where> | 
 |  |  |   </select> | 
 |  |  |  | 
 |  |  |   <!--根据收银员ID及日期获取财务对账_交易明细记录--> | 
 |  |  |   <select id="getTradeDetails" resultType="com.dy.pipIrrGlobal.voSe.VoTradeDetails"> | 
 |  |  |     SELECT * FROM v_trade_details | 
 |  |  |     <where> | 
 |  |  |       <if test = "cashierId != null and cashierId > 0"> | 
 |  |  |         AND cashierId = #{cashierId} | 
 |  |  |       </if> | 
 |  |  |  | 
 |  |  |       <if test = "tradeDate != null"> | 
 |  |  |         AND Date(tradeTime) = #{tradeDate} | 
 |  |  |       </if> | 
 |  |  |     </where> | 
 |  |  |     ORDER BY tradeTime | 
 |  |  |     <trim prefix="limit " > | 
 |  |  |       <if test="start != null and count != null"> | 
 |  |  |         #{start,javaType=Integer,jdbcType=INTEGER}, #{count,javaType=Integer,jdbcType=INTEGER} | 
 |  |  |       </if> | 
 |  |  |     </trim> | 
 |  |  |   </select> | 
 |  |  |   <!-- 删除今天的总账--> | 
 |  |  |   <delete id="deleteTodayGeneral"> | 
 |  |  |     DELETE FROM se_general | 
 |  |  |     WHERE operate_date = DATE(NOW()) | 
 |  |  |   </delete> | 
 |  |  | </mapper> |