|
- <?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.iformall.mapper.WxOrderMapper">
- <resultMap id="BaseResultMap" type="com.iformall.domain.po.WxOrder">
- <id column="id" jdbcType="BIGINT" property="id"/>
- <result column="order_number" jdbcType="BIGINT" property="orderNumber"/>
- <result column="tenant_id" jdbcType="VARCHAR" property="tenantId"/>
- <result column="parent_tenant_id" jdbcType="VARCHAR" property="parentTenantId" />
- <result column="c_user_id" jdbcType="BIGINT" property="cUserId"/>
- <result column="coupon_channel_id" jdbcType="BIGINT" property="couponChannelId"/>
- <result column="product_id" jdbcType="BIGINT" property="productId"/>
- <result column="type" jdbcType="TINYINT" property="type"/>
- <result column="pay_vendor" jdbcType="TINYINT" property="payVendor" />
- <result column="payment_type" jdbcType="INTEGER" property="paymentType"/>
- <result column="payment" jdbcType="INTEGER" property="payment"/>
- <result column="payment_time" jdbcType="TIMESTAMP" property="paymentTime"/>
- <result column="freight_price" jdbcType="INTEGER" property="freightPrice"/>
- <result column="order_status" jdbcType="INTEGER" property="orderStatus"/>
- <result column="create_date" jdbcType="TIMESTAMP" property="createDate"/>
- <result column="update_date" jdbcType="TIMESTAMP" property="updateDate"/>
- <result column="detail" jdbcType="VARCHAR" property="detail"/>
- <result column="press_end_date" jdbcType="TIMESTAMP" property="pressEndDate"/>
- <result column="press_current_num" jdbcType="INTEGER" property="pressCurrentNum"/>
- <result column="press_current_value" jdbcType="INTEGER" property="pressCurrentValue"/>
- <result column="order_group_id" jdbcType="BIGINT" property="orderGroupId"/>
- <result column="form_id" jdbcType="VARCHAR" property="formId"/>
- <result column="total_payment" jdbcType="INTEGER" property="totalPayment"/>
- <result column="compose_order_id" jdbcType="BIGINT" property="composeOrderId"/>
- <result column="coupon_number" jdbcType="INTEGER" property="couponNumber"/>
- <result column="compose_order_type" jdbcType="INTEGER" property="composeOrderType"/>
- <result column="shipping_type" jdbcType="INTEGER" property="shippingType"/>
- <result column="shipping_address" jdbcType="VARCHAR" property="shippingAddress"/>
- <result column="parent_order_id" jdbcType="BIGINT" property="parentOrderId"/>
- </resultMap>
-
- <sql id="allColumns">
- `id`,`order_number`,`tenant_id`,`parent_tenant_id`,`c_user_id`,`coupon_channel_id`,`product_id`,`type`,`pay_vendor`,`payment_type`,`payment`,`payment_time`,`freight_price`,`order_status`,`create_date`,`update_date`,`detail`,
- `press_end_date`,`press_current_num`,`press_current_value`,`order_group_id`,`form_id`,`total_payment`,`compose_order_id`,`coupon_number`,`compose_order_type`,`shipping_type`,`shipping_address`,`parent_order_id`
- </sql>
-
- <sql id="dynamicWhereConditions">
- where 1 = 1
-
- <if test=" null != id ">
- and `id` = #{id}
- </if>
-
- <if test=" null != orderNumber ">
- and `order_number` = #{orderNumber}
- </if>
-
- <if test=" null != tenantId and '' != tenantId">
- and `tenant_id` = #{tenantId}
- </if>
- <if test=" null != parentTenantId and '' != parentTenantId">
- and `parent_tenant_id` = #{parentTenantId}
- </if>
-
- <if test=" null != cUserId ">
- and `c_user_id` = #{cUserId}
- </if>
-
- <if test=" null != couponChannelId ">
- and `coupon_channel_id` = #{couponChannelId}
- </if>
-
- <if test=" null != productId ">
- and `product_id` = #{productId}
- </if>
-
- <if test=" null != type ">
- and `type` = #{type}
- </if>
- <if test=" null != payVendor ">
- and `pay_vendor` = #{payVendor}
- </if>
-
- <if test=" null != paymentType ">
- and `payment_type` = #{paymentType}
- </if>
-
- <if test=" null != payment ">
- and `payment` = #{payment}
- </if>
-
- <if test=" null != paymentTime ">
- and `payment_time` = #{paymentTime}
- </if>
-
- <if test=" null != orderStatus ">
- and `order_status` = #{orderStatus}
- </if>
-
- <if test=" null != createDate ">
- and `create_date` = #{createDate}
- </if>
-
- <if test=" null != updateDate ">
- and `update_date` = #{updateDate}
- </if>
-
- <if test=" null != detail ">
- and `detail` like concat('%', #{detail},'%')
- </if>
-
- <if test=" null != pressEndDate ">
- and `press_end_date` = #{pressEndDate}
- </if>
-
- <if test=" null != pressCurrentNum ">
- and `press_current_num` = #{pressCurrentNum}
- </if>
-
- <if test=" null != pressCurrentValue ">
- and `press_current_value` = #{pressCurrentValue}
- </if>
-
- <if test=" null != orderGroupId ">
- and `order_group_id` = #{orderGroupId}
- </if>
-
- <if test=" null != formId ">
- and `form_id` = #{formId}
- </if>
-
- <if test=" null != composeOrderId ">
- and `compose_order_id` = #{composeOrderId}
- </if>
-
- <if test=" null != composeOrderType ">
- and `compose_order_type` = #{composeOrderType}
- </if>
-
- <if test=" null != shippingType ">
- and `shipping_type` = #{shippingType}
- </if>
-
- <if test=" null != parentOrderId ">
- and `parent_order_id` = #{parentOrderId}
- </if>
-
- <if test=" null != statusS ">
- and `order_status` in
- <foreach collection="statusS" index="index" item="sItem" open="(" separator="," close=")">
- #{sItem}
- </foreach>
- </if>
-
- <if test=" null != ids ">
- and id in
- <foreach collection="ids" index="index" item="idItem" open="(" separator="," close=")">
- #{idItem}
- </foreach>
- </if>
- <if test=" null != sortColumns">order by ${sortColumns}</if>
- </sql>
-
- <select id="selectById" parameterType="java.util.HashMap" resultMap="BaseResultMap">
- select <include refid="allColumns"/> from wx_order where id =#{id} and tenant_id=#{tenantId}
- </select>
-
- <select id="findList" parameterType="com.iformall.domain.po.WxOrder" resultMap="BaseResultMap">
- select
- <include refid="allColumns"/>
- from wx_order
- <include refid="dynamicWhereConditions"/>
- </select>
-
- <select id="countList" parameterType="com.iformall.domain.po.WxOrder" resultType="java.lang.Integer">
- select count(1) from wx_order
- <include refid="dynamicWhereConditions"/>
- </select>
-
- <select id="countListProduct" parameterType="com.iformall.domain.po.WxOrder" resultType="java.lang.Integer">
- select COALESCE(sum(coupon_number),0) from wx_order
- <include refid="dynamicWhereConditions"/>
- </select>
-
- <select id="countCouponConditionType1" parameterType="com.iformall.domain.po.WxOrder" resultType="java.lang.Integer">
- select count(*) from wx_order o,wx_coupon c
- where o.product_id = c.id
- and c.conditions is not null
- /*and JSON_EXTRACT(c.conditions, '$.type') = 1*/
- <if test=" null != cUserId ">
- and o.c_user_id = #{cUserId}
- </if>
-
- <if test=" null != tenantId and '' != tenantId">
- and o.`tenant_id` = #{tenantId}
- </if>
- <if test=" null != parentTenantId and '' != parentTenantId">
- and o.`parent_tenant_id` = #{parentTenantId}
- </if>
-
- <if test=" null != type ">
- and o.type = #{type}
- </if>
- <if test=" null != payVendor ">
- and o.pay_vendor = #{payVendor}
- </if>
-
- <if test=" null != statusS ">
- and o.order_status in
- <foreach collection="statusS" index="index" item="sItem" open="(" separator="," close=")">
- #{sItem}
- </foreach>
- </if>
-
- </select>
-
-
- <select id="findListOfUnpaidOrderByDate" parameterType="map" resultMap="BaseResultMap">
- select
- <include refid="allColumns"/>
- from wx_order
- where order_status = '0' and press_end_date is null and tenant_id = #{tenantId}
- <if test="type != null">
- AND type = #{type,jdbcType=TINYINT}
- </if>
- <if test="payVendor != null">
- AND pay_vendor = #{payVendor,jdbcType=TINYINT}
- </if>
- <if test="startDate != null">
- AND unix_timestamp(`create_date`) > unix_timestamp(#{startDate,jdbcType=TIMESTAMP})
- </if>
- <if test="endDate != null">
- AND unix_timestamp(`create_date`) < unix_timestamp(#{endDate,jdbcType=TIMESTAMP})
- </if>
- </select>
-
- <select id="findListOfUnpaidPressOrderByDate" parameterType="map" resultMap="BaseResultMap">
- select
- <include refid="allColumns"/>
- from wx_order
- where press_end_date is not null and (order_status = 6 or order_status = 7) and tenant_id = #{tenantId}
- <if test="type != null">
- AND type = #{type,jdbcType=TINYINT}
- </if>
- <if test="payVendor != null">
- AND pay_vendor = #{payVendor,jdbcType=TINYINT}
- </if>
- <if test="startDate != null">
- AND unix_timestamp(`create_date`) > unix_timestamp(#{startDate,jdbcType=TIMESTAMP})
- </if>
- <if test="endDate != null">
- AND unix_timestamp(`press_end_date`) < unix_timestamp(#{endDate,jdbcType=TIMESTAMP})
- </if>
- </select>
-
- <select id="findListOfCompleteUnPaidPressOrderByDate" parameterType="map" resultMap="BaseResultMap">
- select
- <include refid="allColumns"/>
- from wx_order
- where press_end_date is not null and order_status = 7 and tenant_id = #{tenantId}
- <if test="type != null">
- AND type = #{type,jdbcType=TINYINT}
- </if>
- <if test="payVendor != null">
- AND pay_vendor = #{payVendor,jdbcType=TINYINT}
- </if>
- <if test="startDate != null">
- AND unix_timestamp(`create_date`) > unix_timestamp(#{startDate,jdbcType=TIMESTAMP})
- </if>
- <if test="endDate != null">
- AND unix_timestamp(`update_date`) < unix_timestamp(#{endDate,jdbcType=TIMESTAMP})
- </if>
- </select>
-
- <select id="findListOfUnpaidGroupOrderByDate" parameterType="map" resultMap="BaseResultMap">
- select
- <include refid="allColumns"/>
- from wx_order
- where order_status = 15 and press_end_date is null and tenant_id = #{tenantId}
- <if test="type != null">
- AND type = #{type,jdbcType=TINYINT}
- </if>
- <if test="payVendor != null">
- AND pay_vendor = #{payVendor,jdbcType=TINYINT}
- </if>
- <if test="startDate != null">
- AND unix_timestamp(`create_date`) > unix_timestamp(#{startDate,jdbcType=TIMESTAMP})
- </if>
- <if test="endDate != null">
- AND unix_timestamp(`create_date`) < unix_timestamp(#{endDate,jdbcType=TIMESTAMP})
- </if>
- </select>
-
-
- <sql id="allCUserOrderDetailColumns">
- o.id,o.order_number,o.tenant_id,o.parent_tenant_id,o.c_user_id,o.coupon_channel_id,o.product_id,o.payment_type,o.payment,o.payment_time,o.order_status,o.create_date,o.update_date,
- c.type,c.pay_vendor,c.cover_img,c.title,c.sub_title,c.sale_price,c.use_price,c.price,c.tail_price,c.orig_price,c.unit,c.detail,c.remark,c.valid_start_date,c.valid_end_date,c.pick_start_date,c.pick_end_date,c.gift_list,
- co.id as coupon_order_id,co.coupon_order_status,c.support_transfer,c.subsidy_num,o.compose_order_type,o.compose_order_id,o.parent_order_id,
- o.`coupon_number`,o.`freight_price`,o.`shipping_type`,o.`shipping_address`,co.`shipping_status`,co.`delivery_info`
- </sql>
-
- <update id="updateStatusByPressCouponId" parameterType="com.iformall.domain.po.WxOrder">
- update wx_order set order_status=#{orderStatus}
- where product_id=#{productId}
- and press_end_date is not null and order_status in (6,7)
- <if test=" null != tenantId and '' != tenantId">
- and `tenant_id` = #{tenantId}
- </if>
- <if test=" null != parentTenantId and '' != parentTenantId">
- and `parent_tenant_id` = #{parentTenantId}
- </if>
- </update>
-
- <update id="updateOrderGroupStatusByCouponId" parameterType="com.iformall.domain.po.WxOrder">
- update wx_order set order_status=#{orderStatus},update_date=#{updateDate}
- where product_id=#{productId} and order_status in(10,15)
- <if test=" null != tenantId and '' != tenantId">
- and `tenant_id` = #{tenantId}
- </if>
- <if test=" null != parentTenantId and '' != parentTenantId">
- and `parent_tenant_id` = #{parentTenantId}
- </if>
- </update>
-
- <update id="updateOrderGroupStatusByCouponChannelId" parameterType="com.iformall.domain.po.WxOrder">
- update wx_order set order_status=#{orderStatus},update_date=#{updateDate}
- where coupon_channel_id=#{couponChannelId} and order_status in(10,15)
- <if test=" null != tenantId and '' != tenantId">
- and `tenant_id` = #{tenantId}
- </if>
- <if test=" null != parentTenantId and '' != parentTenantId">
- and `parent_tenant_id` = #{parentTenantId}
- </if>
- </update>
-
-
- <resultMap id="CVoListMap" type="com.iformall.domain.vo.WxOrderCouponVo">
-
- <id column="id" jdbcType="BIGINT" property="id"/>
-
- <result column="level" jdbcType="INTEGER" property="level"/>
-
- <result column="order_number" jdbcType="BIGINT" property="orderNumber"/>
- <result column="tenant_id" jdbcType="VARCHAR" property="tenantId"/>
- <result column="parent_tenant_id" jdbcType="VARCHAR" property="parentTenantId" />
- <result column="c_user_id" jdbcType="BIGINT" property="cUserId"/>
- <result column="coupon_channel_id" jdbcType="BIGINT" property="couponChannelId"/>
- <result column="product_id" jdbcType="BIGINT" property="productId"/>
- <result column="payment_type" jdbcType="INTEGER" property="paymentType"/>
- <result column="payment" jdbcType="INTEGER" property="payment"/>
- <result column="payment_time" jdbcType="TIMESTAMP" property="paymentTime"/>
- <result column="freight_price" jdbcType="INTEGER" property="freightPrice"/>
- <result column="order_status" jdbcType="INTEGER" property="orderStatus"/>
- <result column="create_date" jdbcType="TIMESTAMP" property="createDate"/>
- <result column="update_date" jdbcType="TIMESTAMP" property="updateDate"/>
-
- <result column="type" jdbcType="INTEGER" property="type"/>
- <result column="pay_vendor" jdbcType="INTEGER" property="payVendor"/>
- <result column="cover_img" jdbcType="VARCHAR" property="coverImg"/>
- <result column="title" jdbcType="VARCHAR" property="title"/>
- <result column="sub_title" jdbcType="VARCHAR" property="subTitle"/>
- <result column="sale_price" jdbcType="INTEGER" property="salePrice"/>
- <result column="use_price" jdbcType="INTEGER" property="usePrice"/>
- <result column="detail" jdbcType="VARCHAR" property="detail"/>
- <result column="price" jdbcType="INTEGER" property="price"/>
- <result column="tail_price" jdbcType="INTEGER" property="tailPrice"/>
- <result column="orig_price" jdbcType="INTEGER" property="origPrice"/>
- <result column="unit" jdbcType="INTEGER" property="unit"/>
- <result column="remark" jdbcType="VARCHAR" property="remark"/>
- <result column="valid_start_date" jdbcType="TIMESTAMP" property="validStartDate"/>
- <result column="valid_end_date" jdbcType="TIMESTAMP" property="validEndDate"/>
- <result column="subsidy_num" jdbcType="INTEGER" property="subsidyNum"></result>
-
- <result column="pick_start_date" jdbcType="TIMESTAMP" property="pickStartDate"/>
- <result column="pick_end_date" jdbcType="TIMESTAMP" property="pickEndDate"/>
-
- <result column="coupon_order_id" jdbcType="BIGINT" property="couponOrderId"/>
- <result column="coupon_order_status" jdbcType="INTEGER" property="couponOrderStatus"/>
- <result column="send_channel_type" jdbcType="INTEGER" property="sendChannelType" />
- <result column="support_transfer" jdbcType="INTEGER" property="supportTransfer"/>
-
- <result column="compose_order_type" jdbcType="INTEGER" property="composeOrderType" />
- <result column="compose_order_id" jdbcType="BIGINT" property="composeOrderId" />
- <result column="coupon_number" jdbcType="INTEGER" property="couponNumber"/>
- <result column="parent_order_id" jdbcType="BIGINT" property="parentOrderId" />
-
- <result column="shipping_type" jdbcType="INTEGER" property="shippingType"/>
- <result column="shipping_address" jdbcType="VARCHAR" property="shippingAddress"/>
- <result column="shipping_status" jdbcType="INTEGER" property="shippingStatus"/>
- <result column="delivery_info" jdbcType="VARCHAR" property="deliveryInfo"/>
-
- </resultMap>
-
- <resultMap id="CVoResultMap" type="com.iformall.domain.vo.WxOrderCouponVo">
-
- <id column="id" jdbcType="BIGINT" property="id"/>
- <result column="order_number" jdbcType="BIGINT" property="orderNumber"/>
- <result column="tenant_id" jdbcType="VARCHAR" property="tenantId"/>
- <result column="parent_tenant_id" jdbcType="VARCHAR" property="parentTenantId" />
- <result column="c_user_id" jdbcType="BIGINT" property="cUserId"/>
- <result column="coupon_channel_id" jdbcType="BIGINT" property="couponChannelId"/>
- <result column="product_id" jdbcType="BIGINT" property="productId"/>
- <result column="payment_type" jdbcType="INTEGER" property="paymentType"/>
- <result column="payment" jdbcType="INTEGER" property="payment"/>
- <result column="payment_time" jdbcType="TIMESTAMP" property="paymentTime"/>
- <result column="freight_price" jdbcType="INTEGER" property="freightPrice"/>
- <result column="order_status" jdbcType="INTEGER" property="orderStatus"/>
- <result column="create_date" jdbcType="TIMESTAMP" property="createDate"/>
- <result column="update_date" jdbcType="TIMESTAMP" property="updateDate"/>
-
- <result column="type" jdbcType="INTEGER" property="type"/>
- <result column="pay_vendor" jdbcType="INTEGER" property="payVendor"/>
- <result column="cover_img" jdbcType="VARCHAR" property="coverImg"/>
- <result column="title" jdbcType="VARCHAR" property="title"/>
- <result column="sub_title" jdbcType="VARCHAR" property="subTitle"/>
- <result column="sale_price" jdbcType="INTEGER" property="salePrice"/>
- <result column="use_price" jdbcType="INTEGER" property="usePrice"/>
- <result column="detail" jdbcType="VARCHAR" property="detail"/>
- <result column="price" jdbcType="INTEGER" property="price"/>
- <result column="tail_price" jdbcType="INTEGER" property="tailPrice"/>
- <result column="orig_price" jdbcType="INTEGER" property="origPrice"/>
- <result column="unit" jdbcType="INTEGER" property="unit"/>
- <result column="remark" jdbcType="VARCHAR" property="remark"/>
- <result column="valid_start_date" jdbcType="TIMESTAMP" property="validStartDate"/>
- <result column="valid_end_date" jdbcType="TIMESTAMP" property="validEndDate"/>
- <result column="gift_list" jdbcType="VARCHAR" property="giftList"></result>
- <result column="subsidy_num" jdbcType="INTEGER" property="subsidyNum"></result>
-
- <result column="pick_start_date" jdbcType="TIMESTAMP" property="pickStartDate"/>
- <result column="pick_end_date" jdbcType="TIMESTAMP" property="pickEndDate"/>
-
- <result column="coupon_order_id" jdbcType="BIGINT" property="couponOrderId"/>
- <result column="coupon_order_status" jdbcType="INTEGER" property="couponOrderStatus"/>
- <result column="send_channel_type" jdbcType="INTEGER" property="sendChannelType" />
- <result column="support_transfer" jdbcType="INTEGER" property="supportTransfer"/>
-
- <result column="compose_order_type" jdbcType="INTEGER" property="composeOrderType" />
- <result column="compose_order_id" jdbcType="BIGINT" property="composeOrderId" />
- <result column="coupon_number" jdbcType="INTEGER" property="couponNumber"/>
- <result column="parent_order_id" jdbcType="BIGINT" property="parentOrderId" />
-
- <result column="shipping_type" jdbcType="INTEGER" property="shippingType"/>
- <result column="shipping_address" jdbcType="VARCHAR" property="shippingAddress"/>
- <result column="shipping_status" jdbcType="INTEGER" property="shippingStatus"/>
- <result column="delivery_info" jdbcType="VARCHAR" property="deliveryInfo"/>
-
- <collection column="{productId=product_id,tenantId=tenant_id}" property="merchantVoList"
- ofType="com.iformall.domain.vo.WxMerchantVo"
- javaType="java.util.List"
- select="com.iformall.mapper.WxCouponMerchantMapper.findMerchantVoList" >
- </collection>
- </resultMap>
-
-
- <!-- <sql id="allCUserOrderListColumns">
- o.id,o.order_number,o.tenant_id,o.parent_tenant_id,o.c_user_id,o.coupon_channel_id,o.product_id,o.payment_type,o.payment,o.payment_time,o.`freight_price`,o.order_status,o.create_date,o.update_date,
- c.type,c.cover_img,c.title,c.sub_title,c.sale_price,c.use_price,c.price,c.unit,c.valid_start_date,c.valid_end_date,
- cal.channel_type as send_channel_type
- </sql> -->
-
- <sql id="allCUserOrderListColumns">
- o.id,o.order_number,o.tenant_id,o.parent_tenant_id,o.c_user_id,o.coupon_channel_id,o.product_id,o.payment_type,o.payment,o.payment_time,o.order_status,o.create_date,o.update_date,
- c.type,c.pay_vendor,c.cover_img,c.title,c.sub_title,c.sale_price,c.use_price,c.price,c.tail_price,c.orig_price,c.unit,c.valid_start_date,c.valid_end_date,c.pick_start_date,c.pick_end_date,
- o.compose_order_type,o.compose_order_id,
- o.`coupon_number`,o.`freight_price`,o.`shipping_type`,o.`shipping_address`,o.parent_order_id
- </sql>
-
- <select id="findListOfCUser" parameterType="com.iformall.domain.po.WxOrder" resultMap="CVoResultMap">
- select
- <include refid="allCUserOrderListColumns"/>
- from wx_coupon c,wx_order o
- left join wx_coupon_order co on co.order_id = o.id
- <!-- left join wx_coupon_action_log cal on cal.coupon_order_id = co.id -->
- where o.product_id = c.id and o.order_status in (0,1,2,3,4,5)
- <if test="cUserId != null">
- and o.c_user_id = #{cUserId}
- </if>
- <if test=" null != tenantId and '' != tenantId">
- and o.`tenant_id` = #{tenantId}
- </if>
- <if test=" null != parentTenantId and '' != parentTenantId">
- and o.`parent_tenant_id` = #{parentTenantId}
- </if>
- <if test=" null != composeOrderId ">
- and o.`compose_order_id` = #{composeOrderId}
- </if>
- <if test=" null != parentOrderId ">
- and o.`parent_order_id` = #{parentOrderId}
- </if>
- <if test="orderStatus != null">
- AND o.order_status = #{orderStatus}
- </if>
- <if test=" null != payVendor ">
- and o.pay_vendor = #{payVendor}
- </if>
- <if test=" null != sortColumns">order by ${sortColumns}</if>
- </select>
-
- <select id="listGoodsCAsPage" parameterType="com.iformall.domain.po.WxOrder" resultMap="CVoListMap">
- select * from(
-
- select 0 level,o.compose_order_type,o.compose_order_id,o.payment,o.order_status,o.create_date,
- o.id,o.order_number,o.tenant_id,o.parent_tenant_id,o.c_user_id,o.coupon_channel_id,o.product_id,o.payment_type,o.payment_time,o.update_date,
- c.type,c.pay_vendor,c.cover_img,c.title,c.sub_title,c.sale_price,c.use_price,c.price,c.tail_price,c.orig_price,c.unit,c.valid_start_date,c.valid_end_date,c.pick_start_date,c.pick_end_date,
- o.`coupon_number`,o.`freight_price`,o.`shipping_type`,o.`shipping_address`
- from wx_coupon c,wx_order o
- where o.product_id = c.id and o.order_status in (0,2)
- and o.compose_order_type = 0
- and o.compose_order_id = 0
- and o.parent_order_id = 0
- <if test="cUserId != null">
- and o.c_user_id = #{cUserId}
- </if>
- <if test=" null != tenantId and '' != tenantId">
- and o.`tenant_id` = #{tenantId}
- </if>
- <if test=" null != parentTenantId and '' != parentTenantId">
- and o.`parent_tenant_id` = #{parentTenantId}
- </if>
- <if test="orderStatus != null">
- AND o.order_status = #{orderStatus}
- </if>
- <if test=" null != payVendor ">
- and o.pay_vendor = #{payVendor}
- </if>
-
- union all
-
- select 0 level, o.compose_order_type,o.compose_order_id,o.payment,o.order_status,o.create_date,
- o.id,o.order_number,o.tenant_id,o.parent_tenant_id,o.c_user_id,o.coupon_channel_id,o.product_id,o.payment_type,o.payment_time,o.update_date,
- c.type,c.pay_vendor,c.cover_img,c.title,c.sub_title,c.sale_price,c.use_price,c.price,c.tail_price,c.orig_price,c.unit,c.valid_start_date,c.valid_end_date,c.pick_start_date,c.pick_end_date,
- o.`coupon_number`,o.`freight_price`,o.`shipping_type`,o.`shipping_address`
- from wx_coupon c,wx_order o
- where o.product_id = c.id and o.order_status in (1,3,4,5)
- and o.compose_order_type in (0,1,2,3)
- and o.parent_order_id = 0
- <if test="cUserId != null">
- and o.c_user_id = #{cUserId}
- </if>
- <if test=" null != tenantId and '' != tenantId">
- and o.`tenant_id` = #{tenantId}
- </if>
- <if test=" null != parentTenantId and '' != parentTenantId">
- and o.`parent_tenant_id` = #{parentTenantId}
- </if>
- <if test="orderStatus != null">
- AND o.order_status = #{orderStatus}
- </if>
- <if test=" null != payVendor ">
- and o.pay_vendor = #{payVendor}
- </if>
-
- union all
-
- select 1 level,o.compose_order_type,o.compose_order_id,sum(o.payment) payment,o.order_status,min(create_date) create_date,
- null ,null ,null ,null ,null ,null ,null ,null ,null ,null ,
- null ,null ,null ,null ,null ,null ,null ,null ,null ,null ,null ,null ,null ,null ,null ,
- null ,null ,null ,null
- from wx_order o
- where o.order_status in (0,2)
- and o.compose_order_type in (1,2,3)
- and o.compose_order_id > 0
- and o.parent_order_id = 0
- <if test="cUserId != null">
- and o.c_user_id = #{cUserId}
- </if>
- <if test=" null != tenantId and '' != tenantId">
- and o.`tenant_id` = #{tenantId}
- </if>
- <if test=" null != parentTenantId and '' != parentTenantId">
- and o.`parent_tenant_id` = #{parentTenantId}
- </if>
- <if test="orderStatus != null">
- AND o.order_status = #{orderStatus}
- </if>
- <if test=" null != payVendor ">
- and o.pay_vendor = #{payVendor}
- </if>
- group by o.compose_order_type,o.compose_order_id
-
- ) a
- order by a.create_date desc
- </select>
-
- <select id="selectDetailOfCUser" parameterType="com.iformall.domain.po.WxOrder" resultMap="CVoResultMap">
- select
- <include refid="allCUserOrderDetailColumns"/>
- FROM wx_order o
- left join wx_coupon c ON o.product_id = c.id
- left join wx_coupon_order co on o.id = co.order_id
- where o.product_id = c.id
- <if test="cUserId != null">
- and o.c_user_id = #{cUserId}
- </if>
- <if test=" null != tenantId and '' != tenantId">
- and o.`tenant_id` = #{tenantId}
- </if>
- <if test=" null != parentTenantId and '' != parentTenantId">
- and o.`parent_tenant_id` = #{parentTenantId}
- </if>
-
- <if test=" null != composeOrderId ">
- and o.`compose_order_id` = #{composeOrderId}
- </if>
-
- <if test=" null != parentOrderId ">
- and o.`parent_order_id` = #{parentOrderId}
- </if>
- <if test="id != null">
- and o.id = #{id}
- </if>
-
- </select>
-
-
- <select id="dayMicroPayAmountList" parameterType="map" resultType="map">
- select count(*) as count, IFNULL(sum(o.payment), 0) as total_price
- from wx_order o
- inner join wx_merchant_b_user bu on bu.id = product_id
- inner join wx_merchant m on m.id = bu.merchant_id
- where o.`type` = 1 and o.`order_status` = 1
- <if test=" null != tenantId and '' != tenantId">
- and o.`tenant_id` = #{tenantId}
- </if>
- <if test=" null != parentTenantId and '' != parentTenantId">
- and o.`parent_tenant_id` = #{parentTenantId}
- </if>
-
- <if test=" null != payVendor ">
- and o.pay_vendor = #{payVendor}
- </if>
-
- <if test=" null != merchantId ">
- and bu.`merchant_id` = #{merchantId}
- </if>
-
- <if test=" null != cUserId ">
- and o.`c_user_id` = #{cUserId}
- </if>
-
- <if test=" null != bUserId ">
- and bu.`id` = #{bUserId}
- </if>
-
- <if test=" null != couponChannelId ">
- and o.`coupon_channel_id` = #{couponChannelId}
- </if>
-
- <if test=" null != productId ">
- and o.`product_id` = #{productId}
- </if>
-
- <if test="startDate != null">
- AND o.create_date > #{startDate,jdbcType=TIMESTAMP}
- </if>
-
- <if test="endDate != null">
- AND o.create_date < #{endDate,jdbcType=TIMESTAMP}
- </if>
- </select>
-
- <resultMap id="PayVoResultMap" type="com.iformall.domain.vo.WxOrderPayVo">
- <id column="id" jdbcType="BIGINT" property="id"/>
- <result column="order_number" jdbcType="BIGINT" property="orderNumber"/>
- <result column="tenant_id" jdbcType="VARCHAR" property="tenantId"/>
- <result column="parent_tenant_id" jdbcType="VARCHAR" property="parentTenantId" />
- <result column="c_user_id" jdbcType="BIGINT" property="cUserId"/>
- <result column="coupon_channel_id" jdbcType="BIGINT" property="couponChannelId"/>
- <result column="product_id" jdbcType="BIGINT" property="productId"/>
- <result column="type" jdbcType="TINYINT" property="type"/>
- <result column="pay_vendor" jdbcType="TINYINT" property="payVendor"/>
- <result column="payment_type" jdbcType="INTEGER" property="paymentType"/>
- <result column="payment" jdbcType="INTEGER" property="payment"/>
- <result column="payment_time" jdbcType="TIMESTAMP" property="paymentTime"/>
- <result column="freight_price" jdbcType="INTEGER" property="freightPrice"/>
- <result column="order_status" jdbcType="INTEGER" property="orderStatus"/>
- <result column="create_date" jdbcType="TIMESTAMP" property="createDate"/>
- <result column="update_date" jdbcType="TIMESTAMP" property="updateDate"/>
- <result column="detail" jdbcType="VARCHAR" property="detail"/>
-
- <result column="merchant_name" jdbcType="VARCHAR" property="merchantName" />
- <result column="name" jdbcType="VARCHAR" property="bUserName" />
- <result column="bphone" jdbcType="VARCHAR" property="bUserPhone" />
- <result column="phone" jdbcType="VARCHAR" property="cUserPhone" />
- <result column="nick_name" jdbcType="VARCHAR" property="nickName" />
- <result column="c_user_name" jdbcType="VARCHAR" property="cUserName" />
-
- </resultMap>
-
- <sql id="allPayOrderColumns">
- o.`id`,o.`order_number`,o.`tenant_id`,o.`parent_tenant_id`,o.`c_user_id`,o.`coupon_channel_id`,o.`product_id`,o.`type`,o.`pay_vendor`,
- o.`payment_type`,o.`payment`,o.`payment_time`,o.`freight_price`,o.`order_status`,o.`create_date`,o.`update_date`,o.`detail`,
- m.name as merchant_name, bu.name, bu.phone as bphone,
- cubi.phone, cubi.nick_name, cubi.name c_user_name
- </sql>
-
- <select id="findListOfMicroPayOrderByDate" parameterType="map" resultMap="PayVoResultMap">
- select
- <include refid="allPayOrderColumns"/>
- from wx_order o
- inner join wx_merchant_b_user bu on bu.id = o.product_id
- inner join wx_merchant m on m.id = bu.merchant_id
- LEFT JOIN wx_c_user_basic_info cubi on cubi.id = o.c_user_id
- where o.order_status = '1' and o.`type` = 1
- <if test=" null != tenantId and '' != tenantId">
- and o.`tenant_id` = #{tenantId}
- </if>
- <if test=" null != parentTenantId and '' != parentTenantId">
- and o.`parent_tenant_id` = #{parentTenantId}
- </if>
- <if test=" null != payVendor ">
- and o.pay_vendor = #{payVendor}
- </if>
- <if test=" null != merchantId ">
- and bu.`merchant_id` = #{merchantId}
- </if>
- <if test=" null != bUserId ">
- and bu.`id` = #{bUserId}
- </if>
- <if test="startDate != null">
- AND o.create_date > #{startDate,jdbcType=TIMESTAMP}
- </if>
- <if test="endDate != null">
- AND o.create_date < #{endDate,jdbcType=TIMESTAMP}
- </if>
- order by o.create_date desc
- </select>
-
- <resultMap id="PayExpVoResultMap" type="com.iformall.domain.vo.WxOrderPayExpVo">
- <id column="id" jdbcType="BIGINT" property="id"/>
- <result column="order_number" jdbcType="BIGINT" property="orderNumber"/>
- <result column="tenant_id" jdbcType="VARCHAR" property="tenantId"/>
- <result column="c_user_id" jdbcType="BIGINT" property="cUserId"/>
- <result column="coupon_channel_id" jdbcType="BIGINT" property="couponChannelId"/>
- <result column="product_id" jdbcType="BIGINT" property="productId"/>
- <result column="type" jdbcType="TINYINT" property="type"/>
- <result column="pay_vendor" jdbcType="TINYINT" property="payVendor"/>
- <result column="payment_type" jdbcType="INTEGER" property="paymentType"/>
- <result column="payment" jdbcType="INTEGER" property="payment"/>
- <result column="payment_time" jdbcType="TIMESTAMP" property="paymentTime"/>
- <result column="freight_price" jdbcType="INTEGER" property="freightPrice"/>
- <result column="order_status" jdbcType="INTEGER" property="orderStatus"/>
- <result column="create_date" jdbcType="TIMESTAMP" property="createDate"/>
- <result column="update_date" jdbcType="TIMESTAMP" property="updateDate"/>
- <result column="detail" jdbcType="VARCHAR" property="detail"/>
-
- <result column="merchant_name" jdbcType="VARCHAR" property="merchantName" />
- <result column="name" jdbcType="VARCHAR" property="bUserName" />
- <result column="bphone" jdbcType="VARCHAR" property="bUserPhone" />
- <result column="phone" jdbcType="VARCHAR" property="cUserPhone" />
- <result column="nick_name" jdbcType="VARCHAR" property="nickName" />
- <result column="c_user_name" jdbcType="VARCHAR" property="cUserName" />
-
- <result column="pay_order_id" jdbcType="BIGINT" property="payOrderId"/>
- <result column="transaction_id" jdbcType="VARCHAR" property="transactionId"/>
- </resultMap>
-
- <sql id="allExpPayOrderColumns">
- o.`id`,o.`order_number`,o.`tenant_id`,o.`c_user_id`,o.`coupon_channel_id`,o.`product_id`,o.`type`,o.`pay_vendor`,
- o.`payment_type`,o.`payment`,o.`payment_time`,o.`freight_price`,o.`order_status`,o.`create_date`,o.`update_date`,o.`detail`,
- m.name as merchant_name, bu.name, bu.phone as bphone,
- cubi.phone, cubi.nick_name, cubi.name c_user_name,
- po.id as pay_order_id, po.transaction_id
- </sql>
-
- <select id="findListOfExpMicroPayOrderByDate" parameterType="map" resultMap="PayExpVoResultMap">
- select
- <include refid="allExpPayOrderColumns"/>
- from wx_order o
- inner join wx_merchant_b_user bu on bu.id = o.product_id
- inner join wx_merchant m on m.id = bu.merchant_id
- left join wx_pay_order po on po.order_id = o.id
- LEFT JOIN wx_c_user_basic_info cubi on cubi.id = o.c_user_id
- where o.order_status = '0' and o.`type` = 1
- <if test=" null != tenantId and '' != tenantId">
- and o.`tenant_id` = #{tenantId}
- </if>
- <if test=" null != parentTenantId and '' != parentTenantId">
- and o.`parent_tenant_id` = #{parentTenantId}
- </if>
- <if test=" null != payVendor ">
- and o.pay_vendor = #{payVendor}
- </if>
- <if test=" null != merchantId ">
- and bu.`merchant_id` = #{merchantId}
- </if>
- <if test=" null != bUserId ">
- and bu.`id` = #{bUserId}
- </if>
- <if test="startDate != null">
- AND o.create_date > #{startDate,jdbcType=TIMESTAMP}
- </if>
- <if test="endDate != null">
- AND o.create_date < #{endDate,jdbcType=TIMESTAMP}
- </if>
- order by o.create_date desc
- </select>
-
- <select id="queryForSceneRepotyHistory" resultType="com.iformall.domain.vo.MarkingSceneDataVo" parameterType="hashmap">
- select DATE_FORMAT(o.create_date,'%Y-%m-%d') xTime, count(o.id) triggerCount
- from (<foreach collection="tenantEntitys" item="tenantEntity" index="index" separator="union all">
- SELECT * from wx_order${tenantEntity.shardTableSuffix}
- </foreach>) o
- where o.`type` = #{type}
- <if test=" null != payVendor ">
- and o.pay_vendor = #{payVendor}
- </if>
- <if test=" null != tenantId and '' != tenantId">
- and o.`tenant_id` = #{tenantId}
- </if>
- <if test=" null != parentTenantId and '' != parentTenantId">
- and o.`parent_tenant_id` = #{parentTenantId}
- </if>
- <if test=" null != startTime and null != endTime">
- and o.`create_date` BETWEEN #{startTime} and #{endTime}
- </if>
- group by xTime
- </select>
-
- <select id="listOrderReportByDate" resultType="com.iformall.domain.vo.WxOrderReportVo" parameterType="hashmap">
- select DATE_FORMAT(o.create_date,'%Y-%m-%d') xTime,
- count(o.id) count,
- IFNULL (SUM(o.payment),0) amount
- from (
- <foreach collection="tenantEntitys" item="tenantEntity" index="index" separator="union all">
- SELECT * from wx_order${tenantEntity.shardTableSuffix}
- </foreach>
- ) o
- where 1=1
- <if test=" null != tenantId and '' != tenantId">
- and o.`tenant_id` = #{tenantId}
- </if>
- <if test=" null != parentTenantId and '' != parentTenantId">
- and o.`parent_tenant_id` = #{parentTenantId}
- </if>
- <if test=" null != type">
- and o.`type` = #{type}
- </if>
- <if test=" null != payVendor ">
- and o.pay_vendor = #{payVendor}
- </if>
- <if test=" null != orderStatus">
- and o.`order_status` = #{orderStatus}
- </if>
- <if test=" null != startTime and null != endTime">
- and o.`create_date` BETWEEN #{startTime} and #{endTime}
- </if>
- group by xTime
- </select>
-
- <select id="listMicroPayOrderReportByDateAndMerchant" resultType="com.iformall.domain.vo.WxOrderReportVo" parameterType="hashmap">
- select DATE_FORMAT(o.create_date,'%Y-%m-%d') xTime, count(o.id) count, IFNULL (SUM(o.payment),0) amount
- from wx_order o
- inner join wx_merchant_b_user bu on bu.id = o.product_id
- inner join wx_merchant m on m.id = bu.merchant_id
- where m.`id` = #{merchantId} and o.tenant_id = #{tenantId} and o.`type` = 1 and o.`order_status` = 1
- <if test=" null != payVendor ">
- and o.pay_vendor = #{payVendor}
- </if>
- <if test=" null != startTime and null != endTime">
- and o.`create_date` BETWEEN #{startTime} and #{endTime}
- </if>
- group by xTime
- </select>
-
-
- <resultMap id="WxMerchantMicroPayVo" type="com.iformall.domain.vo.WxMerchantMicroPayVo">
- <id column="id" jdbcType="BIGINT" property="id" />
- <result column="tenant_id" jdbcType="VARCHAR" property="tenantId" />
- <result column="trade_amt" jdbcType="DECIMAL" property="tradeAmt" />
- <result column="report_date" jdbcType="VARCHAR" property="reportDate" />
- <result column="merchant_phone" jdbcType="VARCHAR" property="merchantPhone" />
- <result column="merchant_name" jdbcType="VARCHAR" property="merchantName" />
- </resultMap>
-
- <sql id="WxMerchantMicroPayColumnsVo">
- wm.id as id,
- wm.tenant_id as tenant_id,
- wm.parent_tenant_id as parent_tenant_id,
- wm.name as merchant_name,
- wm.link_phone as merchant_phone,
- mo.xTime as report_date,
- (case when mo.amount > 0 then mo.amount else 0 end) trade_amt
- </sql>
-
- <select id="findListOfMerchantMicroPayOrderByDate" parameterType="com.iformall.domain.dto.WxOrderReportDto" resultMap="WxMerchantMicroPayVo">
- select
- <include refid="WxMerchantMicroPayColumnsVo"/>
- from wx_merchant wm
- left join
- (select m.id as mid, IFNULL(sum(o.payment),0) amount,DATE_FORMAT(o.create_date,'%Y-%m-%d') xTime
- from wx_merchant m,
- (<foreach collection="tenantEntitys" item="tenantEntity" index="index" separator="union all">
- SELECT * from wx_order${tenantEntity.shardTableSuffix}
- </foreach>) o, wx_merchant_b_user bu
- where bu.id = o.product_id
- and m.status = 1
- and m.id = bu.merchant_id
- and o.order_status = '1'
- and o.type = 1
- <if test=" null != payVendor ">
- and o.pay_vendor = #{payVendor}
- </if>
- <if test="wxOrderReportDto.startTime != null">
- AND o.create_date > #{wxOrderReportDto.startTime}
- </if>
- <if test="wxOrderReportDto.endTime != null">
- AND o.create_date < #{wxOrderReportDto.endTime}
- </if>
- group by m.id,xTime) mo on mo.mid = wm.id
- where wm.status = 1
- <if test=" null != wxOrderReportDto.merchantName">
- <if test=" '' != wxOrderReportDto.merchantName">
- and wm.name like concat('%', #{wxOrderReportDto.merchantName},'%')
- </if>
- </if>
- <if test=" null != wxOrderReportDto.sortColumns"> order by ${wxOrderReportDto.sortColumns} </if>
- <if test=" null == wxOrderReportDto.sortColumns"> order by wm.create_date desc </if>
-
- </select>
-
- <resultMap id="orderMap" type="com.iformall.domain.po.WxOrder">
- <id column="id" jdbcType="BIGINT" property="id"/>
- <result column="order_number" jdbcType="BIGINT" property="orderNumber"/>
- <result column="tenant_id" jdbcType="VARCHAR" property="tenantId"/>
- <result column="parent_tenant_id" jdbcType="VARCHAR" property="parentTenantId" />
- <result column="c_user_id" jdbcType="BIGINT" property="cUserId"/>
- <result column="coupon_channel_id" jdbcType="BIGINT" property="couponChannelId"/>
- <result column="product_id" jdbcType="BIGINT" property="productId"/>
- <result column="type" jdbcType="TINYINT" property="type"/>
- <result column="pay_vendor" jdbcType="TINYINT" property="payVendor"/>
- <result column="payment_type" jdbcType="INTEGER" property="paymentType"/>
- <result column="payment" jdbcType="INTEGER" property="payment"/>
- <result column="payment_time" jdbcType="TIMESTAMP" property="paymentTime"/>
- <result column="freight_price" jdbcType="INTEGER" property="freightPrice"/>
- <result column="order_status" jdbcType="INTEGER" property="orderStatus"/>
- <result column="create_date" jdbcType="TIMESTAMP" property="createDate"/>
- <result column="update_date" jdbcType="TIMESTAMP" property="updateDate"/>
- <result column="detail" jdbcType="VARCHAR" property="detail"/>
- <result column="merchant_name" jdbcType="VARCHAR" property="merchantName"/>
- <result column="c_user_name" jdbcType="VARCHAR" property="cUserName"/>
- <result column="phone" jdbcType="VARCHAR" property="phone"/>
- <result column="title" jdbcType="VARCHAR" property="title"/>
- <result column="attribute" jdbcType="INTEGER" property="attribute"/>
- <result column="pay" jdbcType="INTEGER" property="pay"/>
-
- </resultMap>
-
- <select id="findListOrder" resultMap="orderMap" parameterType="com.iformall.domain.vo.WxOrderQueryVo">
-
- select o.*,case o.order_status when 0 then 0 when 2 then 0 else o.payment end pay from (
- select o.id,o.order_number,o.tenant_id,o.parent_tenant_id,o.product_id,o.payment,o.order_status,
- c.title,cubi.`name` c_user_name,cubi.phone,o.create_date,1 attribute from wx_order o
- left join wx_c_user_basic_info cubi on o.c_user_id=cubi.id
- left join wx_coupon c on o.product_id=c.id
- where c.type=100
- <if test=" null != tenantId and '' != tenantId">
- and o.`tenant_id` = #{tenantId}
- </if>
- <if test=" null != parentTenantId and '' != parentTenantId">
- and o.`parent_tenant_id` = #{parentTenantId}
- </if>
- union all
- select o.id,o.order_number,o.tenant_id,o.parent_tenant_id,o.product_id,o.payment,o.order_status,
- c.title,cubi.`name` c_user_name,cubi.phone,o.create_date,2 attribute from wx_order o
- left join wx_c_user_basic_info cubi on o.c_user_id=cubi.id
- left join wx_coupon c on o.product_id=c.id
- where c.type in (1,2,3,4,5,6,10,50,51) and o.order_status in(0,1,2,3,4,5)
- <if test=" null != tenantId and '' != tenantId">
- and o.`tenant_id` = #{tenantId}
- </if>
- <if test=" null != parentTenantId and '' != parentTenantId">
- and o.`parent_tenant_id` = #{parentTenantId}
- </if>
- <!-- and ifnull(press_current_num,0)=0 and ifnull(order_group_id,0)=0 -->
- union all
- select o.id,o.order_number,o.tenant_id,o.parent_tenant_id,o.product_id,o.payment,o.order_status,
- c.title,cubi.`name` c_user_name,cubi.phone,o.create_date,6 attribute from wx_order o
- left join wx_c_user_basic_info cubi on o.c_user_id=cubi.id
- left join wx_coupon c on o.product_id=c.id
- where c.type = 11 and o.order_status in(0,1,2,3,4,5)
- <if test=" null != tenantId and '' != tenantId">
- and o.`tenant_id` = #{tenantId}
- </if>
- <if test=" null != parentTenantId and '' != parentTenantId">
- and o.`parent_tenant_id` = #{parentTenantId}
- </if>
- union all
- select o.id,o.order_number,o.tenant_id,o.parent_tenant_id,o.product_id,o.payment,o.order_status,
- c.title,cubi.`name` c_user_name,cubi.phone,o.create_date,7 attribute from wx_order o
- left join wx_c_user_basic_info cubi on o.c_user_id=cubi.id
- left join wx_coupon c on o.product_id=c.id
- where c.type = 12 and o.order_status in(0,1,2,3,4,5)
- <if test=" null != tenantId and '' != tenantId">
- and o.`tenant_id` = #{tenantId}
- </if>
- <if test=" null != parentTenantId and '' != parentTenantId">
- and o.`parent_tenant_id` = #{parentTenantId}
- </if>
- union all
- select o.id,o.order_number,o.tenant_id,o.parent_tenant_id,o.product_id,o.payment,
- case o.order_status when 6 then 0 when 7 then 0
- when 8 then 2 when 9 then 2 else o.order_status end order_status,
- c.title,cubi.`name` c_user_name,cubi.phone,o.create_date,3 attribute from wx_order o
- left join wx_c_user_basic_info cubi on o.c_user_id=cubi.id
- left join wx_coupon c on o.product_id=c.id
- where c.type=8 and o.press_current_num>0
- <if test=" null != tenantId and '' != tenantId">
- and o.`tenant_id` = #{tenantId}
- </if>
- <if test=" null != parentTenantId and '' != parentTenantId">
- and o.`parent_tenant_id` = #{parentTenantId}
- </if>
- union all
- select o.id,o.order_number,o.tenant_id,o.parent_tenant_id,o.product_id,o.payment,
- case o.order_status when 10 then 1 when 11 then 1
- when 12 then 4 when 13 then 4 when 14 then 4 when 15 then 0 when 16 then 2
- else o.order_status end order_status,
- c.title,cubi.`name` c_user_name,cubi.phone,o.create_date,4 attribute from wx_order o
- left join wx_c_user_basic_info cubi on o.c_user_id=cubi.id
- left join wx_coupon c on o.product_id=c.id
- where c.type=9 and o.order_group_id>0
- <if test=" null != tenantId and '' != tenantId">
- and o.`tenant_id` = #{tenantId}
- </if>
- <if test=" null != parentTenantId and '' != parentTenantId">
- and o.`parent_tenant_id` = #{parentTenantId}
- </if>
- ) o
- <where>
- <if test=" null != tenantId and '' != tenantId">
- and o.`tenant_id` = #{tenantId}
- </if>
- <if test=" null != parentTenantId and '' != parentTenantId">
- and o.`parent_tenant_id` = #{parentTenantId}
- </if>
- <if test="title!=null and title!=''">
- and o.`title` like concat('%',#{title},'%')
- </if>
- <if test="payment!=null and (payment== '' or payment == 0)">
- and o.`payment` = 0
- </if>
- <if test="payment!=null and payment > 0">
- and o.`payment` > 0
- </if>
-
- <if test="startdate!=null and enddate!=null">
- and o.create_date between #{startdate} and #{enddate}
- </if>
- <if test="orderStatus!=null">
- and o.order_status = #{orderStatus}
- </if>
- <if test="attribute!=null">
- and o.attribute = #{attribute}
- </if>
- <if test="orderNumber!=null">
- and o.order_number like concat('%',#{orderNumber},'%')
- </if>
- </where>
-
- <if test=" null != sortColumns"> order by ${sortColumns} </if>
- <if test=" null == sortColumns">order by o.create_date desc, o.id desc</if>
-
- </select>
-
-
- <select id="queryOrderForMerchantCount" resultType="Long" parameterType="hashmap">
- select count(*) merchantCount from (
- select distinct merchant_id from (
- select o.*, m.`name` merchantName from (
- select o.*,cm.merchant_id from wx_order o
- left join wx_coupon_merchant cm on o.product_id=cm.product_id
- where o.type = 0 and o.order_status in (1,4)) o
- left join wx_merchant m on o.merchant_id=m.id
- union all
- select o.*,m.`name` merchantName from (
- select o.*,mbu.merchant_id from wx_order o
- left join wx_merchant_b_user mbu on o.product_id=mbu.id
- where o.type in (1,2) and o.order_status in (1,4)) o
- left join wx_merchant m on o.merchant_id=m.id
- ) o
- <where>
- <if test=" null != tenantId and '' != tenantId">
- and o.`tenant_id` = #{tenantId}
- </if>
- <if test=" null != parentTenantId and '' != parentTenantId">
- and o.`parent_tenant_id` = #{parentTenantId}
- </if>
- <if test="startdate!=null and enddate!=null">
- and o.create_date between #{startdate} and #{enddate}
- </if>
- </where>
- ) o
- </select>
-
- <select id="queryOrderForSum" resultType="Long" parameterType="hashmap">
- select ifnull(sum(o.payment),0) payment from (
- select o.* from wx_order o
- where o.type in (0,1,2) and o.order_status = #{order_status}
- ) o
- <where>
- <if test=" null != tenantId and '' != tenantId">
- and o.`tenant_id` = #{tenantId}
- </if>
- <if test=" null != parentTenantId and '' != parentTenantId">
- and o.`parent_tenant_id` = #{parentTenantId}
- </if>
- <if test="startdate!=null and enddate!=null">
- and o.create_date between #{startdate} and #{enddate}
- </if>
- </where>
- </select>
-
- <select id="queryOrderForCount" resultType="Long" parameterType="hashmap">
- select count(*) from (
- select o.* from wx_order o
- where o.type in (0,1,2) and o.order_status = #{order_status}
- ) o
- <where>
- <if test=" null != tenantId and '' != tenantId">
- and o.`tenant_id` = #{tenantId}
- </if>
- <if test=" null != parentTenantId and '' != parentTenantId">
- and o.`parent_tenant_id` = #{parentTenantId}
- </if>
- <if test="startdate!=null and enddate!=null">
- and o.create_date between #{startdate} and #{enddate}
- </if>
- </where>
- </select>
-
- <resultMap id="PressVoResultMap" type="com.iformall.domain.vo.WxOrderCouponPressVo">
-
- <id column="id" jdbcType="BIGINT" property="id"/>
- <result column="order_number" jdbcType="BIGINT" property="orderNumber"/>
- <result column="tenant_id" jdbcType="VARCHAR" property="tenantId"/>
- <result column="parent_tenant_id" jdbcType="VARCHAR" property="parentTenantId" />
- <result column="c_user_id" jdbcType="BIGINT" property="cUserId"/>
- <result column="coupon_channel_id" jdbcType="BIGINT" property="couponChannelId"/>
- <result column="product_id" jdbcType="BIGINT" property="productId"/>
- <result column="type" jdbcType="INTEGER" property="type"/>
- <result column="payment_type" jdbcType="INTEGER" property="paymentType"/>
- <result column="payment" jdbcType="INTEGER" property="payment"/>
- <result column="payment_time" jdbcType="TIMESTAMP" property="paymentTime"/>
- <result column="freight_price" jdbcType="INTEGER" property="freightPrice"/>
- <result column="order_status" jdbcType="INTEGER" property="orderStatus"/>
- <result column="create_date" jdbcType="TIMESTAMP" property="createDate"/>
- <result column="update_date" jdbcType="TIMESTAMP" property="updateDate"/>
- <result column="press_end_date" jdbcType="TIMESTAMP" property="pressEndDate"/>
- <result column="press_current_num" jdbcType="INTEGER" property="pressCurrentNum"/>
- <result column="press_current_value" jdbcType="INTEGER" property="pressCurrentValue"/>
-
- <result column="coupon_type" jdbcType="INTEGER" property="couponType"/>
- <result column="cover_img" jdbcType="VARCHAR" property="coverImg"/>
- <result column="title" jdbcType="VARCHAR" property="title"/>
- <result column="sub_title" jdbcType="VARCHAR" property="subTitle"/>
- <result column="sale_price" jdbcType="INTEGER" property="salePrice"/>
- <result column="use_price" jdbcType="INTEGER" property="usePrice"/>
- <result column="detail" jdbcType="VARCHAR" property="detail"/>
- <result column="price" jdbcType="INTEGER" property="price"/>
- <result column="unit" jdbcType="INTEGER" property="unit"/>
- <result column="remark" jdbcType="VARCHAR" property="remark"/>
- <result column="press_limit_num" jdbcType="INTEGER" property="pressLimitNum"/>
-
- <result column="coupon_order_id" jdbcType="BIGINT" property="couponOrderId"/>
- <result column="coupon_order_status" jdbcType="INTEGER" property="couponOrderStatus"/>
-
- <result column="compose_order_type" jdbcType="INTEGER" property="composeOrderType"/>
-
- <result column="shipping_type" jdbcType="INTEGER" property="shippingType"/>
- <result column="shipping_address" jdbcType="VARCHAR" property="shippingAddress"/>
- </resultMap>
-
- <resultMap id="PressVoDetailResultMap" type="com.iformall.domain.vo.WxOrderCouponPressVo">
-
- <id column="id" jdbcType="BIGINT" property="id"/>
- <result column="order_number" jdbcType="BIGINT" property="orderNumber"/>
- <result column="tenant_id" jdbcType="VARCHAR" property="tenantId"/>
- <result column="parent_tenant_id" jdbcType="VARCHAR" property="parentTenantId" />
- <result column="c_user_id" jdbcType="BIGINT" property="cUserId"/>
- <result column="coupon_channel_id" jdbcType="BIGINT" property="couponChannelId"/>
- <result column="product_id" jdbcType="BIGINT" property="productId"/>
- <result column="type" jdbcType="INTEGER" property="type"/>
- <result column="payment_type" jdbcType="INTEGER" property="paymentType"/>
- <result column="payment" jdbcType="INTEGER" property="payment"/>
- <result column="payment_time" jdbcType="TIMESTAMP" property="paymentTime"/>
- <result column="freight_price" jdbcType="INTEGER" property="freightPrice"/>
- <result column="order_status" jdbcType="INTEGER" property="orderStatus"/>
- <result column="create_date" jdbcType="TIMESTAMP" property="createDate"/>
- <result column="update_date" jdbcType="TIMESTAMP" property="updateDate"/>
- <result column="press_end_date" jdbcType="TIMESTAMP" property="pressEndDate"/>
- <result column="press_current_num" jdbcType="INTEGER" property="pressCurrentNum"/>
- <result column="press_current_value" jdbcType="INTEGER" property="pressCurrentValue"/>
-
- <result column="coupon_type" jdbcType="INTEGER" property="couponType"/>
- <result column="cover_img" jdbcType="VARCHAR" property="coverImg"/>
- <result column="title" jdbcType="VARCHAR" property="title"/>
- <result column="sub_title" jdbcType="VARCHAR" property="subTitle"/>
- <result column="sale_price" jdbcType="INTEGER" property="salePrice"/>
- <result column="use_price" jdbcType="INTEGER" property="usePrice"/>
- <result column="detail" jdbcType="VARCHAR" property="detail"/>
- <result column="price" jdbcType="INTEGER" property="price"/>
- <result column="unit" jdbcType="INTEGER" property="unit"/>
- <result column="remark" jdbcType="VARCHAR" property="remark"/>
- <result column="press_limit_num" jdbcType="INTEGER" property="pressLimitNum"/>
-
- <result column="coupon_order_id" jdbcType="BIGINT" property="couponOrderId"/>
- <result column="coupon_order_status" jdbcType="INTEGER" property="couponOrderStatus"/>
-
- <!-- <collection column="{orderId=order_number,tenantId=tenant_id}" property="orderPressList"
- ofType="com.iformall.domain.vo.WxOrderPressVo"
- javaType="java.util.List"
- select="com.iformall.mapper.WxOrderPressMapper.findPressList" >
- </collection> -->
- </resultMap>
-
- <sql id="allOrderPressListColumns">
- o.id,o.order_number,o.tenant_id,o.parent_tenant_id,o.c_user_id,o.coupon_channel_id,o.product_id,o.payment_type,o.payment,o.payment_time,o.`freight_price`,o.order_status,
- o.create_date,o.update_date,o.press_end_date,o.press_current_num,o.press_current_value,
- c.cover_img,c.title,c.sub_title,c.sale_price,c.use_price,c.price,c.unit,c.press_limit_num,
- o.compose_order_type,o.`shipping_type`,o.`shipping_address`
- </sql>
-
- <sql id="allOrderPressDetailColumns">
- o.id,o.order_number,o.tenant_id,o.parent_tenant_id,o.c_user_id,o.coupon_channel_id,o.product_id,o.payment_type,o.payment,o.payment_time,o.`freight_price`,o.order_status,
- o.create_date,o.update_date,o.press_end_date,o.press_current_num,o.press_current_value,
- c.type as coupon_type,c.cover_img,c.title,c.sub_title,c.sale_price,c.use_price,c.price,c.unit,c.detail,c.remark,c.press_limit_num,
- co.id as coupon_order_id,co.coupon_order_status
- </sql>
-
- <select id="findListOfPress" parameterType="com.iformall.domain.po.WxOrder" resultMap="PressVoResultMap">
- select
- <include refid="allOrderPressListColumns"/>
- from wx_coupon c,wx_order o
- left join wx_coupon_order co on co.order_id = o.id
- where o.product_id = c.id and c.type = 8 and o.order_status in (6,7,8,9)
- <if test="cUserId != null">
- and o.c_user_id = #{cUserId}
- </if>
- <if test=" null != tenantId and '' != tenantId">
- and o.`tenant_id` = #{tenantId}
- </if>
- <if test=" null != parentTenantId and '' != parentTenantId">
- and o.`parent_tenant_id` = #{parentTenantId}
- </if>
- <if test="orderStatus != null">
- AND o.order_status = #{orderStatus}
- </if>
- <if test=" null != sortColumns">order by ${sortColumns}</if>
- </select>
-
- <select id="selectDetailOfPress" parameterType="com.iformall.domain.po.WxOrder" resultMap="PressVoDetailResultMap">
- select
- <include refid="allOrderPressDetailColumns"/>
- FROM wx_order o
- left join wx_coupon c ON o.product_id = c.id
- left join wx_coupon_order co on o.id = co.order_id
- where o.product_id = c.id
- <if test="cUserId != null">
- and o.c_user_id = #{cUserId}
- </if>
- <if test=" null != tenantId and '' != tenantId">
- and o.`tenant_id` = #{tenantId}
- </if>
- <if test=" null != parentTenantId and '' != parentTenantId">
- and o.`parent_tenant_id` = #{parentTenantId}
- </if>
- <if test="id != null">
- and o.id = #{id}
- </if>
-
- </select>
-
- <update id="updateStatusByOrderGroupId" parameterType="com.iformall.domain.po.WxOrder">
- update wx_order set order_status=#{orderStatus}
- where order_group_id=#{orderGroupId} and order_status=10
- <if test=" null != tenantId and '' != tenantId">
- and `tenant_id` = #{tenantId}
- </if>
- <if test=" null != parentTenantId and '' != parentTenantId">
- and `parent_tenant_id` = #{parentTenantId}
- </if>
- </update>
-
- <update id="updateOrderStatusForGroup" parameterType="java.util.HashMap">
- update wx_order set order_status=12 where `type`=0 and tenant_id = #{tenantId} and order_status in(10,15) and now()>press_end_date
- </update>
-
- <update id="updateCUserId" parameterType="com.iformall.domain.po.WxOrder">
- update wx_order set c_user_id= #{cUserId} where tenant_id = #{tenantId}
- <if test=" null != id ">
- and id = #{id}
- </if>
- <if test=" null != ids ">
- and id in
- <foreach collection="ids" index="index" item="idItem" open="(" separator="," close=")">
- #{idItem}
- </foreach>
- </if>
- </update>
-
- </mapper>
|