123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391 |
- <?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.znyun.commons.dao.OrdersProductDao">
- <select id="getOrdersRemind" resultType="Integer">
- SELECT count(*)
- FROM zny_orders_product o
- WHERE o.product_id IN (SELECT id FROM zny_product p WHERE p.user_id = #{userId}) AND o.is_remind = 0
- </select>
- <update id="updateOrdersIsRemind">
- UPDATE zny_orders
- SET is_remind = 1
- WHERE product_id IN (SELECT id FROM zny_product p WHERE user_id = #{userId})
- </update>
- <select id="getUserOrdersList" resultType="com.znyun.commons.response.OrdersProductResponse">
- SELECT
- o.id as ordersId,
- o.orders_no,
- o.state,
- o.service_mode,
- o.province,
- o.city,
- o.district,
- o.address,
- o.update_time,
- o.create_time,
- o.rate,
- o.shop_rate,
- o.zhi_rate,
- o.zhi_user_id,
- o.fei_user_id,
- o.fei_rate,
- o.ping_rate,
- o.order_number,
- o.pay_money,
- o.code,
- o.traffic_money,
- o.pay_type,
- p.id AS productId,
- p.name AS productName,
- p.image AS productImage,
- p.describes,
- p.category_def,
- p.unit,
- p.details_address AS productAddress,
- s.business_name as shopName,
- s.business_short_name as shopShortName,
- u.uid AS productUserId,
- u.user_name AS productUserName,
- u.avatar AS productUserAvatar,
- (SELECT count(*) FROM zny_comment_reply c WHERE c.orders_id = o.id AND c.user_id = #{userId}) AS commentCount
- FROM zny_orders_product o
- LEFT JOIN zny_product p ON o.product_id = p.id
- LEFT JOIN zny_user_shop s ON s.id = o.shop_id
- LEFT JOIN zny_user u ON u.uid = p.user_id
- WHERE o.orders_type = 1 AND o.is_del = 0 AND o.order_user_id = #{userId}
- <if test="status != null">
- AND o.state = #{status}
- </if>
- order BY o.create_time DESC
- </select>
- <select id="getWorkerTakeOrdersList" resultType="com.znyun.commons.response.OrdersProductResponse">
- SELECT
- o.id AS ordersId,
- o.orders_no,
- o.state,
- o.service_mode,
- o.province,
- o.city,
- o.district,
- o.address,
- o.update_time,
- o.create_time,
- o.rate,
- o.shop_rate,
- o.zhi_rate,
- o.zhi_user_id,
- o.fei_user_id,
- o.fei_rate,
- o.ping_rate,
- o.order_number,
- o.pay_money,
- o.code,
- o.traffic_money,
- o.pay_type,
- p.id AS productId,
- p.name AS productName,
- p.image AS productImage,
- p.describes,
- p.category_def,
- p.unit,
- u.uid AS productUserId,
- u.user_name AS productUserName,
- u.avatar AS productUserAvatar
- FROM zny_orders_product o
- LEFT JOIN zny_product p ON o.product_id = p.id
- LEFT JOIN zny_user u ON u.uid = p.user_id
- WHERE o.orders_type = 1 AND o.is_del = 0
- <if test="userId != null">
- AND o.worker_user_id = #{userId}
- </if>
- <if test="status != null">
- AND o.state = #{status}
- </if>
- order BY o.create_time DESC
- </select>
- <select id="getTeamOrdersList" resultType="Map">
- SELECT
- o.id AS ordersId,
- o.state,
- o.service_mode,
- o.create_time AS createTime,
- o.pay_money AS payMoney,
- o.order_user_id AS ordersUserId,
- o.code,
- o.order_number AS orderNumber,
- o.remarks,
- o.orders_no AS ordersNo,
- o.zhi_rate AS zhiRate,
- o.fei_rate AS feiRate,
- o.shop_rate AS shopRate,
- o.rate AS rate,
- p.id AS productId,
- p.unit,
- p.old_price AS oldPrice,
- u.user_name AS orderUserName,
- u.avatar AS orderUserAvatar,
- c.name AS categoryName,
- c.category_img
- FROM zny_orders_product o
- LEFT JOIN zny_product p ON p.id = o.product_id
- LEFT JOIN zny_user u ON u.uid = o.order_user_id
- LEFT JOIN zny_category c ON c.name LIKE p.category_def
- WHERE o.orders_type = 1
- <if test="status != null and status != 0">
- AND o.state = #{status}
- </if>
- <if test="type == 1">
- AND o.zhi_user_id = #{userId}
- </if>
- <if test="type == 2">
- AND o.fei_user_id = #{userId}
- </if>
- ORDER BY o.create_time DESC
- </select>
- <select id="getOrdersAllList" resultType="com.znyun.commons.response.OrdersProductResponse">
- SELECT
- o.id AS ordersId,
- o.orders_no,
- o.state,
- o.service_mode,
- o.province,
- o.city,
- o.district,
- o.address,
- o.address_user_name,
- o.address_phone,
- o.rate,
- o.shop_rate,
- o.zhi_rate,
- o.zhi_user_id,
- o.fei_rate,
- o.fei_user_id,
- o.ping_rate,
- o.order_number,
- o.pay_money,
- o.price_money,
- o.less_money,
- o.refund_content,
- o.orders_type,
- o.remarks,
- o.start_time,
- o.`code`,
- o.update_time,
- o.create_time,
- o.traffic_money,
- o.pay_type,
- p.id AS productId,
- p.name AS productName,
- p.image AS productImage,
- p.category_def,
- p.unit,
- p.member_price,
- u.uid AS productUserId,
- u.user_name AS productUserName,
- u.avatar AS productUserAvatar,
- u2.uid AS orderUserId,
- u2.user_name AS orderUserName,
- u2.avatar AS orderUserAvatar,
- u3.uid AS shareUserId,
- u3.user_name AS shareUserName,
- u3.avatar as shareUserAvatar,
- u4.uid AS workerUserId,
- u4.user_name AS workerUserName,
- u4.avatar AS workerUserAvatar,
- u5.user_name AS zhiUserName,
- u6.user_name AS feiUserName,
- cu.id AS couponUserId,
- cu.money AS couponMoney,
- s.business_name as shopName,
- s.business_short_name as shopShortName
- FROM zny_orders_product o
- LEFT JOIN zny_product p ON o.product_id = p.id
- LEFT JOIN zny_user u ON u.uid = p.user_id
- LEFT JOIN zny_user u2 ON u2.uid = o.order_user_id
- LEFT JOIN zny_user u3 ON u3.invitation_code = o.inviter_code
- LEFT JOIN zny_user u4 ON u4.uid = o.worker_user_id
- LEFT JOIN zny_user u5 ON u5.uid = o.zhi_user_id
- LEFT JOIN zny_user u6 ON u6.uid = o.fei_user_id
- LEFT JOIN zny_coupon_user cu ON cu.id = o.coupon_user_id
- LEFT JOIN zny_user_shop s ON s.id = o.shop_id
- WHERE o.orders_type = 1 AND o.is_del = 0
- <if test="shopId != null">
- AND o.shop_id = #{shopId}
- </if>
- <if test="orderUserId != null">
- AND o.order_user_id = #{orderUserId}
- </if>
- <if test="workerUserId != null">
- AND o.worker_user_id = #{workerUserId}
- </if>
- <if test="serviceMode != null">
- AND o.service_mode = #{serviceMode}
- </if>
- <if test="status != null">
- AND o.state = #{status}
- </if>
- <if test="orderUserName != null and orderUserName != ''">
- AND u2.user_name LIKE concat('%',#{orderUserName},'%')
- </if>
- <if test="shareUserName != null and shareUserName != ''">
- AND u3.user_name LIKE concat('%',#{shareUserName},'%')
- </if>
- <if test="workerUserName != null and workerUserName != ''">
- AND u4.user_name LIKE concat('%',#{workerUserName},'%')
- </if>
- <if test="ordersNo != null and ordersNo != ''">
- AND o.orders_no LIKE concat('%',#{ordersNo},'%')
- </if>
- <if test="startTime != null and startTime != ''">
- AND date_format(o.create_time,'%Y-%m-%d') >= date_format(#{startTime},'%Y-%m-%d')
- </if>
- <if test="endTime != null and endTime != ''">
- AND date_format(o.create_time,'%Y-%m-%d') <= date_format(#{endTime},'%Y-%m-%d')
- </if>
- ORDER BY o.create_time DESC
- </select>
- <select id="getUnDispatchOrdersList" resultType="com.znyun.commons.response.OrdersProductResponse">
- SELECT
- o.id as ordersId,
- o.*,
- p.id AS productId,
- p.name AS productName,
- p.image AS productImage,
- p.describes,
- p.category_def,
- p.unit,
- p.details_address AS productAddress,
- s.business_name as shopName,
- s.business_short_name as shopShortName
- FROM zny_orders_product o
- LEFT JOIN zny_product p ON o.product_id = p.id
- LEFT JOIN zny_user_shop s ON s.id = o.shop_id
- WHERE o.orders_type = 1 AND o.is_del = 0 AND o.shop_id = #{shopId}
- AND o.state = 1 and o.worker_user_id is null
- order BY o.create_time DESC
- </select>
- <select id="sumUserOrdersMoney" resultType="BigDecimal">
- SELECT ifnull(sum(money),0.00) FROM zny_user_money_details
- WHERE `type` = 1 AND (title LIKE '%订单完成%' OR title LIKE '%接单完成%') AND user_id = #{userId}
- <if test="startTime != null and startTime!=''">
- AND date_format(create_time,'%Y-%m-%d') >= date_format(#{startTime},'%Y-%m-%d')
- </if>
- <if test="endTime != null and endTime != ''">
- AND date_format(create_time,'%Y-%m-%d') <= date_format(#{endTime},'%Y-%m-%d')
- </if>
- </select>
- <select id="sumUserOrdersCount" resultType="Integer">
- SELECT count(*) FROM zny_orders_product
- WHERE worker_user_id = #{userId} AND state IN (1,2,3)
- <if test="startTime != null and startTime != ''">
- AND date_format(create_time,'%Y-%m-%d')>=date_format(#{startTime},'%Y-%m-%d')
- </if>
- <if test="endTime != null and endTime != '' ">
- AND date_format(create_time,'%Y-%m-%d') <= date_format(#{endTime},'%Y-%m-%d')
- </if>
- </select>
- <select id="avgUserOrdersScore" resultType="Float">
- SELECT
- IFNULL(AVG(c.score), 0)
- FROM zny_comment_reply c
- LEFT JOIN zny_orders_product o ON c.orders_id = o.id
- WHERE c.orders_id IS NOT NULL AND o.worker_user_id = #{userId}
- </select>
- <select id="sumUserOrdersStateCount" resultType="Integer">
- SELECT count(*) FROM zny_orders_product
- WHERE worker_user_id = #{userId} AND state = #{status}
- <if test="startTime != null and startTime != ''">
- AND date_format(create_time,'%Y-%m-%d') >= date_format(#{startTime},'%Y-%m-%d')
- </if>
- <if test="endTime != null and endTime != ''">
- AND date_format(create_time,'%Y-%m-%d') <= date_format(#{endTime},'%Y-%m-%d')
- </if>
- </select>
- <select id="sumUserOrdersRefundMoney" resultType="BigDecimal">
- SELECT ifnull(sum(o.refund_price), 0.00) FROM zny_orders_product o
- WHERE o.worker_user_id = #{userId} AND o.refund_status = 2
- <if test="startTime!=null and startTime!=''">
- AND date_format(o.create_time,'%Y-%m-%d')>=date_format(#{startTime},'%Y-%m-%d')
- </if>
- <if test="endTime!=null and endTime!=''">
- AND date_format(o.create_time,'%Y-%m-%d')<=date_format(#{endTime},'%Y-%m-%d')
- </if>
- </select>
- <select id="queryOrdersCount" resultType="Integer">
- SELECT count(*) FROM zny_orders_product WHERE state = 2
- <if test="type == 1">
- AND date_format(update_time,'%Y-%m-%d')=date_format(#{time},'%Y-%m-%d')
- </if>
- <if test="type == 2">
- AND date_format(update_time,'%Y-%m')=date_format(#{time},'%Y-%m')
- </if>
- <if test="type == 3">
- AND date_format(update_time,'%Y')=date_format(#{time},'%Y')
- </if>
- </select>
- <select id="sumTeamUserOrdersMoney" resultType="Double">
- SELECT
- <if test="type == 1">
- ifnull(sum(zhi_rate), 0.00)
- </if>
- <if test="type == 2">
- ifnull(sum(fei_rate), 0.00)
- </if>
- FROM zny_orders_product WHERE state = 2
- <if test="type == 1">
- AND zhi_user_id = #{userId}
- </if>
- <if test="type == 2">
- AND fei_user_id = #{userId}
- </if>
- </select>
- <select id="listOrderGroupByDate" resultType="Map">
- SELECT
- count(o.id) AS 'count',
- sum(o.pay_money) AS payMoney,
- LEFT(o.create_time, #{dateLen}) AS payTime
- FROM zny_orders_product o
- WHERE 1= 1 AND (o.state = 1 OR o.state = 2)
- <if test="startTime != null and startTime != ''">
- AND date_format(o.create_time,'%Y-%m-%d') >= date_format(#{startTime},'%Y-%m-%d')
- </if>
- <if test="endTime != null and endTime != ''">
- AND date_format(o.create_time,'%Y-%m-%d') <= date_format(#{endTime},'%Y-%m-%d')
- </if>
- GROUP BY payTime
- ORDER BY payTime ASC
- </select>
- </mapper>
|