| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304 |
- <?xml version="1.0" encoding="UTF-8" ?>
- <!DOCTYPE mapper
- PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
- "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
- <mapper namespace="com.ruoyi.system.mapper.PosOrderMapper">
- <resultMap type="PosOrder" id="PosOrderResult">
- <result property="id" column="id" />
- <result property="ddId" column="dd_id" />
- <result property="shId" column="sh_id" />
- <result property="mdId" column="md_id" />
- <result property="cretim" column="cretim" />
- <result property="shdzId" column="shdz_id" />
- <result property="userId" column="user_id" />
- <result property="amount" column="amount" />
- <result property="remarks" column="remarks" />
- <result property="food" column="food" />
- <result property="state" column="state" />
- <result property="type" column="type" />
- <result property="delryTime" column="delry_time" />
- <result property="yhId" column="yh_id" />
- <result property="jvli" column="jvli" />
- <result property="freight" column="freight" />
- <result property="diningStatus" column="dining_status" />
- <result property="qsId" column="qs_id" />
- <result property="payUrl" column="pay_url" />
- <result property="collectPayment" column="collect_payment" />
- <result property="activity" column="activity" />
- <result property="kefuState" column="kefu_state" />
- <result property="kefuContent" column="kefu_content" />
- <result property="kefuRepeat" column="kefu_repeat" />
- <result property="repeatDdId" column="repeat_dd_id" />
- <result property="shAddress" column="sh_address" />
- <result property="mdActivity" column="md_activity" />
- <result property="yhName" column="yh_name" />
- <result property="mdYhId" column="md_yh_id" />
- <result property="mdYhName" column="md_yh_name" />
- <result property="mdDiscountAmount" column="md_discount_amount" />
- <result property="salesName" column="sales_name" />
- <result property="mdSalesName" column="md_sales_name" />
- <result property="salesReduction" column="sales_reduction" />
- <result property="mdSalesReduction" column="md_sales_reduction" />
- <result property="points" column="points" />
- <result property="pointsReduction" column="points_reduction" />
- <result property="sdTime" column="sd_time" />
- <result property="payType" column="pay_type" />
- <result property="parentDdId" column="parent_dd_id" />
- </resultMap>
- <sql id="selectPosOrderVo">
- select id, dd_id, sh_id, md_id, cretim, shdz_id, user_id,sh_address, amount, remarks, state, type, delry_time,food,yh_id,yh_name,md_yh_id,md_yh_name,md_discount_amount,jvli,freight,dining_status,qs_id,pay_url,collect_payment,activity,md_activity,kefu_state,kefu_content,kefu_repeat,repeat_dd_id,sales_name,md_sales_name,sales_reduction,md_sales_reduction,points,points_reduction,sd_time,pay_type,parent_dd_id from pos_order
- </sql>
- <select id="selectPosOrderList" parameterType="PosOrder" resultMap="PosOrderResult">
- <include refid="selectPosOrderVo"/>
- <where>
- <if test="ddId != null "> and dd_id = #{ddId}</if>
- <if test="shId != null "> and sh_id = #{shId}</if>
- <if test="mdId != null "> and md_id = #{mdId}</if>
- <if test="cretim != null "> and cretim = #{cretim}</if>
- <if test="shdzId != null "> and shdz_id = #{shdzId}</if>
- <if test="userId != null "> and user_id = #{userId}</if>
- <if test="amount != null "> and amount = #{amount}</if>
- <if test="state != null "> and state = #{state}</if>
- <if test="type != null "> and type = #{type}</if>
- <if test="delryTime != null and delryTime != ''"> and delry_time = #{delryTime}</if>
- <if test="cretimStart != null and cretimStart != ''"> and cretim > date_format(#{cretimStart},'%y-%m-%d')</if>
- <if test="cretimEnd != null and cretimEnd != ''"> and cretim < DATE_FORMAT(DATE_ADD(date_format(#{cretimEnd},'%y-%m-%d'),INTERVAL 1 DAY),'%Y-%m-%d')</if>
- <if test="collectPayment != null and collectPayment != ''"> and collect_payment = #{collectPayment}</if>
- <if test="mdActivity != null"> and md_activity = #{mdActivity}</if>
- <if test="yhName != null and yhName != ''"> and yh_name = #{yhName}</if>
- <if test="mdYhId != null"> and md_yh_id = #{mdYhId}</if>
- <if test="mdYhName != null and mdYhName != ''"> and md_yh_name = #{mdYhName}</if>
- <if test="mdDiscountAmount != null"> and md_discount_amount = #{mdDiscountAmount}</if>
- <if test="salesName != null and salesName != ''"> and sales_name = #{salesName}</if>
- <if test="mdSalesName != null and mdSalesName != ''"> and md_sales_name = #{mdSalesName}</if>
- <if test="salesReduction != null"> and sales_reduction = #{salesReduction}</if>
- <if test="mdSalesReduction != null"> and md_sales_reduction = #{mdSalesReduction}</if>
- <if test="points != null"> and points = #{points}</if>
- <if test="pointsReduction != null"> and points_reduction = #{pointsReduction}</if>
- <if test="sdTime != null"> and sd_time = #{sdTime}</if>
- <if test="payType != null"> and pay_type =#{payType}</if>
- <if test="parentDdId != null and parentDdId != ''"> and parent_dd_id = #{parentDdId}</if>
- and not (state=0 and collect_payment=0)
- </where>
- order by id desc
- </select>
- <select id="selectPosOrderShList" parameterType="PosOrder" resultMap="PosOrderResult">
- <include refid="selectPosOrderVo"/>
- <where>
- <if test="ddId != null "> and dd_id = #{ddId}</if>
- <if test="shId != null "> and sh_id = #{shId}</if>
- <if test="mdId != null "> and md_id = #{mdId}</if>
- <if test="cretim != null "> and cretim = #{cretim}</if>
- <if test="shdzId != null "> and shdz_id = #{shdzId}</if>
- <if test="userId != null "> and user_id = #{userId}</if>
- <if test="amount != null "> and amount = #{amount}</if>
- <if test="state != null "> and state > #{state} and state < 10</if>
- <if test="type != null "> and type = #{type}</if>
- <if test="delryTime != null and delryTime != ''"> and delry_time = #{delryTime}</if>
- <if test="cretimStart != null and cretimStart != ''"> and cretim > date_format(#{cretimStart},'%y-%m-%d')</if>
- <if test="cretimEnd != null and cretimEnd != ''"> and cretim < DATE_FORMAT(DATE_ADD(date_format(#{cretimEnd},'%y-%m-%d'),INTERVAL 1 DAY),'%Y-%m-%d')</if>
- <if test="collectPayment != null and collectPayment != ''"> and collect_payment = #{collectPayment}</if>
- <if test="mdActivity != null"> and md_activity = #{mdActivity}</if>
- <if test="yhName != null and yhName != ''"> and yh_name = #{yhName}</if>
- <if test="mdYhId != null"> and md_yh_id = #{mdYhId}</if>
- <if test="mdYhName != null and mdYhName != ''"> and md_yh_name = #{mdYhName}</if>
- <if test="mdDiscountAmount != null"> and md_discount_amount = #{mdDiscountAmount}</if>
- <if test="salesName != null and salesName != ''"> and sales_name = #{salesName}</if>
- <if test="mdSalesName != null and mdSalesName != ''"> and md_sales_name = #{mdSalesName}</if>
- <if test="salesReduction != null"> and sales_reduction = #{salesReduction}</if>
- <if test="mdSalesReduction != null"> and md_sales_reduction = #{mdSalesReduction}</if>
- <if test="points != null"> and points = #{points}</if>
- <if test="pointsReduction != null"> and points_reduction = #{pointsReduction}</if>
- <if test="sdTime != null"> and sd_time =#{sdTime}</if>
- <if test="payType != null"> and pay_type =#{payType}</if>
- <if test="parentDdId != null and parentDdId != ''"> and parent_dd_id = #{parentDdId}</if>
- </where>
- order by kefu_state desc,cretim desc
- </select>
- <select id="selectPosOrderById" parameterType="Long" resultMap="PosOrderResult">
- <include refid="selectPosOrderVo"/>
- where id = #{id}
- </select>
- <insert id="insertPosOrder" parameterType="PosOrder" useGeneratedKeys="true" keyProperty="id">
- insert into pos_order
- <trim prefix="(" suffix=")" suffixOverrides=",">
- <if test="ddId != null">dd_id,</if>
- <if test="shId != null">sh_id,</if>
- <if test="mdId != null">md_id,</if>
- <if test="cretim != null">cretim,</if>
- <if test="shdzId != null">shdz_id,</if>
- <if test="userId != null">user_id,</if>
- <if test="amount != null">amount,</if>
- <if test="remarks != null">remarks,</if>
- <if test="state != null">state,</if>
- <if test="type != null">type,</if>
- <if test="delryTime != null and delryTime != ''">delry_time,</if>
- <if test="collectPayment != null and collectPayment != ''">collect_payment,</if>
- <if test="mdActivity != null">md_activity,</if>
- <if test="yhName != null and yhName != ''">yh_name,</if>
- <if test="mdYhId != null">md_yh_id,</if>
- <if test="mdYhName != null and mdYhName != ''">md_yh_name,</if>
- <if test="mdDiscountAmount != null">md_discount_amount,</if>
- <if test="salesName != null and salesName != ''">sales_name,</if>
- <if test="mdSalesName != null and mdSalesName != ''">md_sales_name,</if>
- <if test="salesReduction != null">sales_reduction,</if>
- <if test="mdSalesReduction != null">md_sales_reduction,</if>
- <if test="points != null">points,</if>
- <if test="pointsReduction != null">points_reduction,</if>
- <if test="sdTime != null">sd_time,</if>
- <if test="payType != null">pay_type,</if>
- <if test="parentDdId != null and parentDdId != ''">parent_dd_id,</if>
- </trim>
- <trim prefix="values (" suffix=")" suffixOverrides=",">
- <if test="ddId != null">#{ddId},</if>
- <if test="shId != null">#{shId},</if>
- <if test="mdId != null">#{mdId},</if>
- <if test="cretim != null">#{cretim},</if>
- <if test="shdzId != null">#{shdzId},</if>
- <if test="userId != null">#{userId},</if>
- <if test="amount != null">#{amount},</if>
- <if test="remarks != null">#{remarks},</if>
- <if test="state != null">#{state},</if>
- <if test="type != null">#{type},</if>
- <if test="delryTime != null and delryTime != ''">#{delryTime},</if>
- <if test="collectPayment != null and collectPayment != ''">#{collectPayment},</if>
- <if test="mdActivity != null">#{mdActivity},</if>
- <if test="yhName != null and yhName != ''">#{yhName},</if>
- <if test="mdYhId != null">#{mdYhId},</if>
- <if test="mdYhName != null and mdYhName != ''">#{mdYhName},</if>
- <if test="mdDiscountAmount != null">#{mdDiscountAmount},</if>
- <if test="salesName != null and salesName != ''">#{salesName},</if>
- <if test="mdSalesName != null and mdSalesName != ''">#{mdSalesName},</if>
- <if test="salesReduction != null">#{salesReduction},</if>
- <if test="mdSalesReduction != null">#{mdSalesReduction},</if>
- <if test="points != null">#{points},</if>
- <if test="pointsReduction != null">#{pointsReduction},</if>
- <if test="sdTime != null">#{sdTime},</if>
- <if test="payType != null">#{payType},</if>
- <if test="parentDdId != null and parentDdId != ''">#{parentDdId},</if>
- </trim>
- </insert>
- <update id="updatePosOrder" parameterType="PosOrder">
- update pos_order
- <trim prefix="SET" suffixOverrides=",">
- <if test="ddId != null">dd_id = #{ddId},</if>
- <if test="shId != null">sh_id = #{shId},</if>
- <if test="mdId != null">md_id = #{mdId},</if>
- <if test="cretim != null">cretim = #{cretim},</if>
- <if test="shdzId != null">shdz_id = #{shdzId},</if>
- <if test="userId != null">user_id = #{userId},</if>
- <if test="amount != null">amount = #{amount},</if>
- <if test="remarks != null">remarks = #{remarks},</if>
- <if test="state != null">state = #{state},</if>
- <if test="type != null">type = #{type},</if>
- <if test="kefuState != null">kefu_state = #{kefuState},</if>
- <if test="kefuContent != null">kefu_content = #{kefuContent},</if>
- <if test="delryTime != null and delryTime != ''">delry_time = #{delryTime},</if>
- <if test="collectPayment != null and collectPayment != ''">collect_payment = #{collectPayment},</if>
- <if test="mdActivity != null">md_activity = #{mdActivity},</if>
- <if test="yhName != null and yhName != ''">yh_name = #{yhName},</if>
- <if test="mdYhId != null">md_yh_id = #{mdYhId},</if>
- <if test="mdYhName != null and mdYhName != ''">md_yh_name = #{mdYhName},</if>
- <if test="mdDiscountAmount != null">md_discount_amount = #{mdDiscountAmount},</if>
- <if test="salesName != null and salesName != ''">sales_name = #{salesName},</if>
- <if test="mdSalesName != null and mdSalesName != ''">md_sales_name = #{mdSalesName},</if>
- <if test="salesReduction != null">sales_reduction = #{salesReduction},</if>
- <if test="mdSalesReduction != null">md_sales_reduction = #{mdSalesReduction},</if>
- <if test="points != null">points = #{points},</if>
- <if test="pointsReduction != null">points_reduction = #{pointsReduction},</if>
- <if test="sdTime != null">sd_time = #{sdTime},</if>
- <if test="payType != null">pay_type = #{payType},</if>
- <if test="parentDdId != null and parentDdId != ''">parent_dd_id = #{parentDdId},</if>
- </trim>
- where id = #{id}
- </update>
- <delete id="deletePosOrderById" parameterType="Long">
- delete from pos_order where id = #{id}
- </delete>
- <delete id="deletePosOrderByIds" parameterType="String">
- delete from pos_order where id in
- <foreach item="id" collection="array" open="(" separator="," close=")">
- #{id}
- </foreach>
- </delete>
- <select id="countOrderByNowYear" resultType="int">
- SELECT COUNT(*)
- FROM pos_order
- <where>
- <if test="nowYearFirstDay != null">
- cretim >= #{nowYearFirstDay}
- </if>
- </where>
- </select>
- <select id="countOrderSuccessByNowYear" resultType="int">
- SELECT COUNT(*)
- FROM pos_order
- <where>
- <if test="nowYearFirstDay != null">
- cretim >= #{nowYearFirstDay}
- </if>
- AND state in (5, 11)
- </where>
- </select>
- <select id="countOrderFailByNowYear" resultType="int">
- SELECT COUNT(*)
- FROM pos_order
- <where>
- <if test="nowYearFirstDay != null">
- cretim >= #{nowYearFirstDay}
- </if>
- AND state = 10
- </where>
- </select>
- <select id="totalTurnoverByNowYear" resultType="Double">
- SELECT sum(amount)
- FROM pos_order
- <where>
- <if test="nowYearFirstDay != null">
- cretim >= #{nowYearFirstDay}
- </if>
- AND state in (5, 11)
- </where>
- </select>
- <select id="getOrderCountByDate" resultType="int">
- SELECT IFNULL(COUNT(*),0) as amount FROM pos_order
- <where>
- <if test="startDate != null and startDate != '' and endDate != null and endDate != ''">
- and cretim between #{startDate} and #{endDate}
- </if>
- <if test="startDate != null and startDate != '' and (endDate == null or endDate == '')">
- and cretim >= #{startDate}
- </if>
- <if test="(startDate == null or startDate == '') and (endDate != null and endDate != '')">
- and cretim <= #{endDate}
- </if>
- </where>
- </select>
- <select id="getOrderSumByDate" resultType="int">
- SELECT IFNULL(SUM(amount),0) as amount FROM pos_order
- <where>
- <if test="startDate != null and startDate != '' and endDate != null and endDate != ''">
- and cretim between #{startDate} and #{endDate}
- </if>
- <if test="startDate != null and startDate != '' and (endDate == null or endDate == '')">
- and cretim >= #{startDate}
- </if>
- <if test="(startDate == null or startDate == '') and (endDate != null and endDate != '')">
- and cretim <= #{endDate}
- </if>
- </where>
- </select>
- </mapper>
|