| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256 |
- <?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.fs.his.mapper.FsExternalOrderMapper">
-
- <resultMap type="FsExternalOrder" id="FsExternalOrderResult">
- <result property="orderId" column="order_id" />
- <result property="orderCode" column="order_code" />
- <result property="source" column="source" />
- <result property="userId" column="user_id" />
- <result property="userName" column="user_name" />
- <result property="userPhone" column="user_phone" />
- <result property="userAddress" column="user_address" />
- <result property="totalNum" column="total_num" />
- <result property="totalPrice" column="total_price" />
- <result property="payPrice" column="pay_price" />
- <result property="freightPrice" column="freight_price" />
- <result property="isPay" column="is_pay" />
- <result property="payTime" column="pay_time" />
- <result property="payType" column="pay_type" />
- <result property="status" column="status" />
- <result property="deliveryCode" column="delivery_code" />
- <result property="deliveryName" column="delivery_name" />
- <result property="deliverySn" column="delivery_sn" />
- <result property="deliveryTime" column="delivery_time" />
- <result property="shippingType" column="shipping_type" />
- <result property="companyId" column="company_id" />
- <result property="companyUserId" column="company_user_id" />
- <result property="remark" column="remark" />
- <result property="externalCreateTime" column="external_create_time" />
- <result property="isSync" column="is_sync" />
- <result property="syncMsg" column="sync_msg" />
- <result property="createTime" column="create_time" />
- <result property="updateTime" column="update_time" />
- <result property="extendOrderId" column="extend_order_id" />
- <result property="storeId" column="store_id" />
- </resultMap>
- <sql id="selectFsExternalOrderVo">
- select order_id, order_code, source, user_id, user_name, user_phone, user_address, total_num, total_price, pay_price, freight_price, is_pay, pay_time, pay_type, status, delivery_code, delivery_name, delivery_sn, delivery_time, shipping_type, company_id, company_user_id, remark, external_create_time, is_sync, sync_msg, create_time, update_time, extend_order_id,store_id from fs_external_order
- </sql>
- <select id="selectFsExternalOrderList" parameterType="FsExternalOrder" resultMap="FsExternalOrderResult">
- <include refid="selectFsExternalOrderVo"/>
- <where>
- <if test="orderCode != null and orderCode != ''"> and order_code = #{orderCode}</if>
- <if test="source != null and source != ''"> and source = #{source}</if>
- <if test="userId != null "> and user_id = #{userId}</if>
- <if test="userName != null and userName != ''"> and user_name like concat('%', #{userName}, '%')</if>
- <if test="userPhone != null and userPhone != ''"> and user_phone = #{userPhone}</if>
- <if test="isPay != null "> and is_pay = #{isPay}</if>
- <if test="status != null "> and status = #{status}</if>
- <if test="companyId != null "> and company_id = #{companyId}</if>
- <if test="isSync != null "> and is_sync = #{isSync}</if>
- </where>
- order by create_time desc
- </select>
-
- <select id="selectFsExternalOrderByOrderId" parameterType="Long" resultMap="FsExternalOrderResult">
- <include refid="selectFsExternalOrderVo"/>
- where order_id = #{orderId}
- </select>
- <select id="selectFsExternalOrderByOrderCode" parameterType="String" resultMap="FsExternalOrderResult">
- <include refid="selectFsExternalOrderVo"/>
- where order_code = #{orderCode}
- </select>
- <insert id="insertFsExternalOrder" parameterType="FsExternalOrder" useGeneratedKeys="true" keyProperty="orderId">
- insert into fs_external_order
- <trim prefix="(" suffix=")" suffixOverrides=",">
- <if test="orderCode != null and orderCode != ''">order_code,</if>
- <if test="source != null and source != ''">source,</if>
- <if test="userId != null">user_id,</if>
- <if test="userName != null and userName != ''">user_name,</if>
- <if test="userPhone != null and userPhone != ''">user_phone,</if>
- <if test="userAddress != null and userAddress != ''">user_address,</if>
- <if test="totalNum != null">total_num,</if>
- <if test="totalPrice != null">total_price,</if>
- <if test="payPrice != null">pay_price,</if>
- <if test="freightPrice != null">freight_price,</if>
- <if test="isPay != null">is_pay,</if>
- <if test="payTime != null">pay_time,</if>
- <if test="payType != null">pay_type,</if>
- <if test="status != null">status,</if>
- <if test="deliveryCode != null and deliveryCode != ''">delivery_code,</if>
- <if test="deliveryName != null and deliveryName != ''">delivery_name,</if>
- <if test="deliverySn != null and deliverySn != ''">delivery_sn,</if>
- <if test="deliveryTime != null">delivery_time,</if>
- <if test="shippingType != null">shipping_type,</if>
- <if test="companyId != null">company_id,</if>
- <if test="companyUserId != null">company_user_id,</if>
- <if test="remark != null and remark != ''">remark,</if>
- <if test="externalCreateTime != null">external_create_time,</if>
- <if test="isSync != null">is_sync,</if>
- <if test="syncMsg != null and syncMsg != ''">sync_msg,</if>
- <if test="extendOrderId !=null and extendOrderId !=''">extend_order_id,</if>
- <if test="storeId != null">store_id,</if>
- create_time
- </trim>
- <trim prefix="values (" suffix=")" suffixOverrides=",">
- <if test="orderCode != null and orderCode != ''">#{orderCode},</if>
- <if test="source != null and source != ''">#{source},</if>
- <if test="userId != null">#{userId},</if>
- <if test="userName != null and userName != ''">#{userName},</if>
- <if test="userPhone != null and userPhone != ''">#{userPhone},</if>
- <if test="userAddress != null and userAddress != ''">#{userAddress},</if>
- <if test="totalNum != null">#{totalNum},</if>
- <if test="totalPrice != null">#{totalPrice},</if>
- <if test="payPrice != null">#{payPrice},</if>
- <if test="freightPrice != null">#{freightPrice},</if>
- <if test="isPay != null">#{isPay},</if>
- <if test="payTime != null">#{payTime},</if>
- <if test="payType != null">#{payType},</if>
- <if test="status != null">#{status},</if>
- <if test="deliveryCode != null and deliveryCode != ''">#{deliveryCode},</if>
- <if test="deliveryName != null and deliveryName != ''">#{deliveryName},</if>
- <if test="deliverySn != null and deliverySn != ''">#{deliverySn},</if>
- <if test="deliveryTime != null">#{deliveryTime},</if>
- <if test="shippingType != null">#{shippingType},</if>
- <if test="companyId != null">#{companyId},</if>
- <if test="companyUserId != null">#{companyUserId},</if>
- <if test="remark != null and remark != ''">#{remark},</if>
- <if test="externalCreateTime != null">#{externalCreateTime},</if>
- <if test="isSync != null">#{isSync},</if>
- <if test="syncMsg != null and syncMsg != ''">#{syncMsg},</if>
- <if test="extendOrderId !=null and extendOrderId !=''">#{extendOrderId},</if>
- <if test="storeId != null">#{storeId},</if>
- sysdate()
- </trim>
- </insert>
- <update id="updateFsExternalOrder" parameterType="FsExternalOrder">
- update fs_external_order
- <trim prefix="SET" suffixOverrides=",">
- <if test="orderCode != null and orderCode != ''">order_code = #{orderCode},</if>
- <if test="source != null and source != ''">source = #{source},</if>
- <if test="userId != null">user_id = #{userId},</if>
- <if test="userName != null and userName != ''">user_name = #{userName},</if>
- <if test="userPhone != null and userPhone != ''">user_phone = #{userPhone},</if>
- <if test="userAddress != null and userAddress != ''">user_address = #{userAddress},</if>
- <if test="totalNum != null">total_num = #{totalNum},</if>
- <if test="totalPrice != null">total_price = #{totalPrice},</if>
- <if test="payPrice != null">pay_price = #{payPrice},</if>
- <if test="freightPrice != null">freight_price = #{freightPrice},</if>
- <if test="isPay != null">is_pay = #{isPay},</if>
- <if test="payTime != null">pay_time = #{payTime},</if>
- <if test="payType != null">pay_type = #{payType},</if>
- <if test="status != null">status = #{status},</if>
- <if test="deliveryCode != null and deliveryCode != ''">delivery_code = #{deliveryCode},</if>
- <if test="deliveryName != null and deliveryName != ''">delivery_name = #{deliveryName},</if>
- <if test="deliverySn != null and deliverySn != ''">delivery_sn = #{deliverySn},</if>
- <if test="deliveryTime != null">delivery_time = #{deliveryTime},</if>
- <if test="shippingType != null">shipping_type = #{shippingType},</if>
- <if test="companyId != null">company_id = #{companyId},</if>
- <if test="companyUserId != null">company_user_id = #{companyUserId},</if>
- <if test="remark != null and remark != ''">remark = #{remark},</if>
- <if test="externalCreateTime != null">external_create_time = #{externalCreateTime},</if>
- <if test="isSync != null">is_sync = #{isSync},</if>
- <if test="syncMsg != null and syncMsg != ''">sync_msg = #{syncMsg},</if>
- <if test="extendOrderId !=null and extendOrderId !=''">extend_order_id = #{extendOrderId},</if>
- <if test="storeId != null">store_id = #{storeId},</if>
- update_time = sysdate()
- </trim>
- where order_id = #{orderId}
- </update>
- <delete id="deleteFsExternalOrderByOrderId" parameterType="Long">
- delete from fs_external_order where order_id = #{orderId}
- </delete>
- <delete id="deleteFsExternalOrderByOrderIds" parameterType="String">
- delete from fs_external_order where order_id in
- <foreach item="orderId" collection="array" open="(" separator="," close=")">
- #{orderId}
- </foreach>
- </delete>
- <select id="selectExternalOrderListVO" parameterType="FsExternalOrder" resultType="com.fs.his.domain.vo.FsExternalOrderListVO">
- SELECT
- o.order_id,
- o.order_code,
- c.company_name AS companyName,
- cu.user_name AS companyUserName,
- o.user_name AS userName,
- o.user_phone AS userPhone,
- GROUP_CONCAT(oi.product_name SEPARATOR ',') AS productNames,
- SUM(oi.price) AS receivablePrice,
- o.pay_price AS payPrice,
- o.pay_type AS payType,
- o.external_create_time AS externalCreateTime,
- o.status,
- CASE o.status
- WHEN 1 THEN '待审核'
- WHEN 2 THEN '待发货'
- WHEN 3 THEN '待收货'
- WHEN 4 THEN '已完成'
- WHEN -3 THEN '已取消'
- ELSE '未知'
- END AS statusDesc,
- IF(fa.id IS NOT NULL AND fa.audit_status = 0, true, false) AS isApplyAudit
- FROM fs_external_order o
- LEFT JOIN company c ON o.company_id = c.company_id
- LEFT JOIN company_user cu ON o.company_user_id = cu.user_id
- LEFT JOIN fs_external_order_item oi ON o.order_id = oi.order_id
- LEFT JOIN fs_store_order_finance_audit fa ON fa.order_id = o.order_id AND fa.order_type = 0 AND fa.audit_status = 0
- <where>
- <if test="orderCode != null and orderCode != ''"> AND o.order_code = #{orderCode}</if>
- <if test="userId != null"> AND o.user_id = #{userId}</if>
- <if test="userName != null and userName != ''"> AND o.user_name LIKE CONCAT('%', #{userName}, '%')</if>
- <if test="userPhone != null and userPhone != ''"> AND o.user_phone = #{userPhone}</if>
- <if test="isPay != null"> AND o.is_pay = #{isPay}</if>
- <if test="status != null"> AND o.status = #{status}</if>
- <if test="companyId != null"> AND o.company_id = #{companyId}</if>
- <if test="companyUserId != null"> AND o.company_user_id = #{companyUserId}</if>
- <if test="isSync != null"> AND o.is_sync = #{isSync}</if>
- ${params.dataScope}
- </where>
- GROUP BY o.order_id
- ORDER BY o.create_time DESC
- </select>
- <select id="selectExternalOrderDetailVO" parameterType="Long" resultType="com.fs.his.vo.FsExternalOrderDetailVO">
- SELECT
- o.order_id AS orderId,
- o.order_code AS orderCode,
- o.source,
- o.user_id AS userId,
- o.user_name AS userName,
- o.user_phone AS userPhone,
- o.user_address AS userAddress,
- o.total_num AS totalNum,
- o.total_price AS totalPrice,
- o.pay_price AS payPrice,
- o.freight_price AS freightPrice,
- o.is_pay AS isPay,
- o.pay_time AS payTime,
- o.pay_type AS payType,
- o.status,
- o.delivery_code AS deliveryCode,
- o.delivery_name AS deliveryName,
- o.delivery_sn AS deliverySn,
- o.delivery_time AS deliveryTime,
- o.shipping_type AS shippingType,
- o.remark,
- o.external_create_time AS externalCreateTime,
- o.create_time AS createTime,
- c.company_name AS companyName,
- cu.nick_name AS companyUserName
- FROM fs_external_order o
- LEFT JOIN company c ON o.company_id = c.company_id
- LEFT JOIN company_user cu ON o.company_user_id = cu.user_id
- WHERE o.order_id = #{orderId}
- </select>
- </mapper>
|