PineappleMapper.xml 17.8 KB
<?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.sibu.orderHelper.integral.dao.PineappleDao">

    <!--检测退款订单-->
    <select id="countCheckRefundStatusResponse"  parameterType="java.util.Map" resultType="java.lang.Integer">
        SELECT COUNT(*) FROM im_order_refund WHERE order_code = #{orderCode} AND refund_status IN ('1','2','3','5','7')
    </select>

    <select id="getIMDoingOrderBean" parameterType="java.util.Map" resultMap="iMDoingOrderBean">
        select order_code,order_status from ${doingOrderTable}  WHERE  order_code = #{orderCode}
    </select>


    <resultMap id="iMDoingOrderBean" type="com.sibu.orderHelper.integral.model.IMDoingOrderBean">
        <result column="order_code" property="orderCode"/>
        <result column="order_status" property="orderStatus"/>
    </resultMap>

    <select id="childrenrefundStatusBySuccess" parameterType="java.lang.String" resultMap="checkRefundStatusBean">
        SELECT r.refund_code,r1.name,r.refund_status FROM im_refund_order_item r1
        LEFT JOIN im_order_refund r ON r1.refund_id = r.refund_id
        WHERE r.refund_status = 7 AND r.order_code = #{orderCode}
    </select>

    <resultMap id="checkRefundStatusBean" type="com.sibu.orderHelper.integral.model.CheckRefundStatusBean">
        <result column="refund_code" property="refundno"/>
        <result column="name" property="ProductName"/>
        <result column="refund_status" property="refundStatus"/>
    </resultMap>

    <select id="childrenrefundStatusByCourse" parameterType="java.lang.String" resultMap="checkRefundStatusBean">
        SELECT r.refund_code,r1.name,r.refund_status FROM im_refund_order_item r1
        LEFT JOIN im_order_refund r ON r1.refund_id = r.refund_id
        WHERE r.refund_status IN ('1','2','3','5') AND r.order_code = #{orderCode}
    </select>




    <!-- 退货退款单下载 -->
    <resultMap id="getRefundBeanResultMap" type="com.sibu.orderHelper.integral.model.GetRefundBean">
        <result column="refund_code" property="refundno"/>
        <result column="order_code" property="platorderno"/>
        <result column="order1_id" property="subplatorderno"/>
        <result column="refund_money" property="refundamount"/>
        <result column="apply_date" property="createtime"/>
        <result column="refund_status_last_update_dt" property="updatetime"/>
        <result column="refund_reason" property="reason"/>
        <result column="name" property="productname"/>
        <result column="refund_goods_deliver_name" property="logisticname"/>
        <result column="refund_goods_waybill" property="logisticno"/>
        <result column="status" property="goodsstatus"/>
        <result column="refund_remark" property="refundstatusdesc"/>
        <result column="refund_status" property="refundstatus"/>
        <result column="spec_detail" property="sku"/>
        <result column="im_product_id" property="outerid"/>
    </resultMap>


    <select id="pageGetRefundBean" parameterType="java.util.Map"  resultMap="getRefundBeanResultMap">
        SELECT r.refund_code,r.order_code,r1.order1_id,r.refund_money,r.apply_date,r.refund_status_last_update_dt,r.refund_status,p.im_product_id,
        r.refund_remark,'JH_98' status,p.details,r.refund_reason,r.refund_reason,r1.name,r.refund_goods_deliver_name,r.refund_goods_waybill,r1.spec_detail
        FROM im_order_refund r
        LEFT JOIN im_refund_order_item r1 ON r.refund_id = r1.refund_id
        LEFT JOIN im_product p ON p.im_product_id = r1.product_id
        WHERE  1 = 1 and r.order_from = 1 and r.refund_status IN ('1','2','3','5','7')
        <if test="supplierId!=null and  supplierId !=''">
            AND  r.supplier_id = #{supplierId}
        </if>
        <if test="beginTime != null and beginTime !=''">
            and r.apply_date >= #{beginTime}
        </if>
        <if test="endTime != null and endTime != ''">
            <![CDATA[
		   and r.apply_date <= #{endTime}
		  ]]>
        </if>
        ORDER  by r.apply_date DESC
        limit ${pageNow}, ${PageSize}
    </select>


    <!-- 获取订单详情(不包含产品) -->
    <select id="getOneIMOrderById" parameterType="map" resultMap="pineappleOderDetailBean">
        select ifnull(do.total_money,0) money,do.supplier_name,do.buyer_username,do.prerefund_original_order_status,do1.purchase_quantity
        from ${doingOrderTable1} do1  LEFT JOIN ${doingOrderTable} do on do1.order_id = do.order_id
        where do1.order1_id=#{orderId1}
    </select>
    <resultMap type="com.sibu.orderHelper.integral.model.PineappleOderDetailBean" id="pineappleOderDetailBean">
        <result column="money" property="totalMoney" />
        <result column="supplier_name" property="supplierName" />
        <result column="buyer_username" property="buyerUsername" />
        <result column="prerefund_original_order_status" property="orderStatus" />
        <result column="purchase_quantity" property="num" />
    </resultMap>





    <resultMap type="com.sibu.orderHelper.integral.model.IMProductBean" id="listAPIIMProduct">
        <result column="im_product_id" property="imProductId" />
        <result column="name" property="name" />
        <result column="short_name" property="shortName" />
        <result column="stock_num" property="stockNum" />
        <result column="details" property="details" />
        <result column="exchange_integral" property="exchangeIntegral" />
        <result column="xws_exchange_integral" property="xwsExchangeIntegral" />
        <result column="sibukg_exchange_integral" property="sibukgExchangeIntegral" />
        <result column="onther1_exchange_integral" property="onther1ExchangeIntegral" />
        <result column="onther2_exchange_integral" property="onther2ExchangeIntegral" />
        <result column="onther3_exchange_integral" property="onther3ExchangeIntegral" />
        <result column="thumb_img" property="thumbImg" />
        <result column="bannel_img1" property="bannelImg1" />
        <result column="bannel_img2" property="bannelImg2" />
        <result column="bannel_img3" property="bannelImg3" />
        <result column="bannel_img4" property="bannelImg4" />
        <result column="bannel_img5" property="bannelImg5" />
        <result column="limit_exchange_number" property="limitExchangeNumber"/>
        <result column="is_new" property="isNew" />
        <result column="is_hot" property="isHot" />
        <result column="is_reco" property="isReco" />
        <result column="cost" property="cost" />
        <result column="attention" property="attention" />
        <result column="total_comment_score" property="totalCommentScore" />
        <result column="total_comment_number" property="totalCommentNumber" />
        <result column="member_price" property="memberPrice" />
        <result column="retail_price" property="retailPrice" />
        <result column="market_price" property="marketPrice" />
        <result column="product_type" property="productType" />
        <result column="is_show" property="isShow"/>
        <result column="is_open_spec" property="isOpenSpec"/>
        <result column="spec" property="spec"/>
        <result column="mini_purchase_number" property="miniPurchaseNumber"/>
        <result column="format_str" property="formatStr"/>
        <result column="erp_code" property="erpCode"/>
        <result column="is_group" property="isGroup"/>
        <result column="share_status" property="shareStatus"/>
        <result column="share_percentage" property="sharePercentage"/>
        <result column="im_category_id" property="imCategoryId"/>
        <result column="delete_flag" property="deleteFlag"/>
    </resultMap>




    <!--  产品下载 -->
    <resultMap id="downloadProductBean" type="com.sibu.orderHelper.integral.model.DownloadProductBean">
        <result column="im_product_id" property="PlatProductID"/>
        <result column="name" property="name"/>
        <result column="OuterID" property="OuterID"/>
        <result column="price" property="price"/>
        <result column="stock_num" property="num"/>
        <result column="bannel_img1" property="pictureurl"/>
    </resultMap>

    <select id="getProductListByMap" parameterType="java.util.Map" resultMap="downloadProductBean">
    SELECT p.im_product_id,p.name,p.im_product_id AS  OuterID,IFNULL(p.retail_price,0) price,p.stock_num,p.bannel_img1
    FROM im_product p,im_product_supplier i
    WHERE p.im_product_id = i.product_id and i.supplier_id= #{supplierId}
    <if test="isShow !=null and isShow !='' and isShow != -1">
        and p.is_show = #{isShow}
    </if>
    <if test="productId !=null and productId !=''">
        AND p.im_product_id =#{productId}
    </if>
    <if test="productName !=null and productName !=''">
       AND p.name =#{productName}
    </if>
    ORDER BY p.im_product_id DESC
        limit ${PageIndex}, ${PageSize}
    </select>

    <resultMap id="downloadProductSkuBeanList" type="com.sibu.orderHelper.integral.model.DownloadProductSkuBean">
        <result column="sku_id" property="SkuID"/>
        <result column="sku_id" property="skuOuterID"/>
        <result column="market_price" property="skuprice"/>
        <result column="stock_num" property="skuQuantity"/>
    </resultMap>
    <select id="getDownloadProductSkuBeanList" parameterType="java.lang.String" resultMap="downloadProductSkuBeanList">
            SELECT sku_id,stock_num,market_price FROM sku WHERE  im_product_id = #{productId}
    </select>

    <resultMap id="sku" type="com.sibu.orderHelper.integral.model.DownloadProductSkuBean">
        <result column="name" property="skuname"/>
    </resultMap>

    <select id="getDownloadSkuBean" parameterType="java.lang.String" resultMap="sku">
        SELECT concat(concat(n.attr_name,':'),v.attr_value) name FROM attr_ref a
        LEFT JOIN attr_value v ON a.attr_value_id = v.value_id
        LEFT JOIN attr_name n on v.attr_id = n.attr_id WHERE a.sku_id = #{skuId} AND n.attr_name IS NOT NULL
    </select>



    <!-- 同步库存 -->
    <resultMap id="rs_SkuBean" type="com.sibu.orderHelper.integral.model.SkuBean">
        <result property="skuId" column="sku_id" />
        <result property="imProductId" column="im_product_id"/>
        <result property="erpCode" column="erp_code" />
        <result property="stockNum" column="stock_num" />
        <result property="exchangeIntegral" column="exchange_integral"/>
        <result property="retailPrice" column="retail_price" />
        <result property="marketPrice" column="market_price" />
        <result property="createDate" column="create_date" />
        <result property="updateDate" column="update_date" />
        <result property="isShow" column="is_show" />
    </resultMap>

    <resultMap id="skuApiResponse" type="com.sibu.orderHelper.integral.reponse.SkuApiResponse">
        <result property="skuId" column="sku_id" javaType="java.lang.String" jdbcType="VARCHAR"/>
        <result property="erpCode" column="erp_code" javaType="java.lang.String" jdbcType="VARCHAR"/>
        <result property="stockNum" column="stock_num" javaType="java.lang.Integer" jdbcType="INTEGER"/>
        <result property="exchangeIntegral" column="exchange_integral" javaType="java.lang.Integer" jdbcType="INTEGER"/>
        <result property="memberPrice" column="member_price"/>
        <result property="retailPrice" column="retail_price"/>
        <result property="marketPrice" column="market_price"/>
        <collection property="values" ofType="com.sibu.orderHelper.integral.reponse.SkuValueResponse" column="sku_Id">
            <result property="attrValueId" column="attr_value_id" javaType="java.lang.Long" jdbcType="BIGINT"/>
            <result property="attrId" column="attr_id" javaType="java.lang.Long" jdbcType="BIGINT"/>
            <result property="attrName" column="attr_name" javaType="java.lang.String" jdbcType="VARCHAR"/>
            <result property="valueName" column="attr_value" javaType="java.lang.String" jdbcType="VARCHAR"/>
            <result property="sortIndex" column="sort_index" javaType="java.lang.Integer" jdbcType="TINYINT"/>
        </collection>
    </resultMap>

    <!--根据产品ID与SKUID 查询SKU -->
    <select id="getSkuBeanByMap" parameterType="java.util.Map" resultMap="rs_SkuBean">
        SELECT * FROM sku where
		 sku_id = #{skuId} AND  im_product_id = #{productId} and is_show =1
    </select>

    <!-- 查询product sku返回 -->
    <select id="getSkuBeanListByMap"  parameterType="java.lang.String" resultMap="skuApiResponse">
        SELECT s.sku_id,s.erp_code,s.stock_num,s.exchange_integral,s.retail_price,s.market_price,s.member_price,
        s.is_show,ref.attr_value_id,n.attr_id,n.attr_name,v.attr_value ,n.sort_index FROM sku s
        LEFT JOIN attr_ref ref ON s.sku_id =ref.sku_id
        LEFT JOIN attr_value v ON v.value_id =ref.attr_value_id
        LEFT JOIN attr_name n ON n.attr_id =v.attr_id
        WHERE s.im_product_id =#{productId}
    </select>



    <!-- 更新SKU-->
    <update id="updateSku" parameterType="com.sibu.orderHelper.integral.model.SkuBean">
        update sku SET stock_num = #{stockNum} WHERE  sku_id = #{skuId}
    </update>


    <!-- 根据条件查询产品 -->
    <sql id="Base_Product_Column">
        imp.im_product_id,
        imp.name,
        imp.short_name,
        imp.stock_num,
        imp.exchange_integral,
        imp.xws_exchange_integral,
        imp.sibukg_exchange_integral,
        imp.onther1_exchange_integral,
        imp.onther2_exchange_integral,
        imp.onther3_exchange_integral,
        imp.limit_exchange_number,
        imp.thumb_img,
        imp.is_new,
        imp.is_hot,
        imp.is_reco,
        imp.cost,
        imp.attention,
        imp.is_show,
        imp.product_type,
        imp.member_price,
        imp.retail_price,
        imp.market_price,
        imp.is_open_spec,
        imp.spec,
        imp.mini_purchase_number,
        imp.format_str,
        imp.share_status,
        imp.share_percentage
    </sql>


    <select id="getIMProductBeanByMap" parameterType="java.util.Map" resultMap="listAPIIMProduct">
        SELECT
        <include refid="Base_Product_Column" />
        FROM
        im_product imp,im_product_supplier s
        WHERE imp.im_product_id = s.product_id
        AND imp.im_product_id = #{productId}
        AND  s.supplier_id = #{supplierId}
    </select>

    <update id="updateProductInventory" parameterType="com.sibu.orderHelper.integral.model.IMProductInventory">
        update im_product_inventory set stock_num=#{stockNum} where im_product_id=#{imProductId}
    </update>

    <update id="updateProduct" parameterType="java.util.Map">
        update im_product set stock_num = #{stockNum}  WHERE  im_product_id = #{productId}
    </update>


    <select id="getApiProductDetailById" resultMap="listAPIIMProduct" parameterType="String" useCache="true" statementType="PREPARED">
        select imp.im_product_id,
        imp.name,
        imp.short_name,
        imp.stock_num,
        imp.details,
        imp.exchange_integral,
        imp.xws_exchange_integral,
        imp.sibukg_exchange_integral,
        imp.onther1_exchange_integral,
        imp.onther2_exchange_integral,
        imp.onther3_exchange_integral,
        imp.limit_exchange_number,
        imp.thumb_img,
        imp.bannel_img1,
        imp.bannel_img2,
        imp.bannel_img3,
        imp.bannel_img4,
        imp.bannel_img5,
        imp.is_new,
        imp.is_hot,
        imp.is_reco,
        imp.is_show,
        imp.product_type,
        imp.member_price,
        imp.retail_price,
        imp.market_price,
        imp.is_open_spec,
        imp.spec,
        imp.mini_purchase_number,
        imp.format_str,
        imp.erp_code,
        imp.is_group,
        imp.share_status,
        imp.share_percentage,
        ipi.attention,
        ipi.total_comment_score,
        ipi.total_comment_number,
        ipi.cost,
        imp.delete_flag
        FROM im_product imp left join im_product_inventory ipi on imp.im_product_id = ipi.im_product_id
        WHERE
        imp.im_product_id = #{productId}
    </select>

    <!-- 订单发货-->
    <select id="getOrderByMap" parameterType="java.util.Map" resultType="java.lang.Integer">
        SELECT COUNT(*) FROM ${doingOrderTable} WHERE express_code  like concat(#{expressCode},'%') AND   order_code = #{orderCode}
        AND  supplier_id = #{supplierId}
    </select>

    <update id="updateBusinessSend" parameterType="java.util.Map">
        UPDATE ${doingOrderTable}
        <set>
            <if test="buyerUsername !=null and buyerUsername !='' ">
                buyer_username =#{buyerUsername},
            </if>
            <if test="expressCode !=null and expressCode !='' ">
                express_code = concat(IFNULL(concat(express_code,','),''),#{expressCode}),
            </if>
            <if test="buyerPhone !=null and buyerPhone !=''">
                buyer_phone = #{buyerPhone}
            </if>
            <if test="address!=null and address!='' ">
                address =#{address},
            </if>
            <if test="expressName !=null and expressName !='' ">
                express_name =#{expressName},
            </if>
            <if test="province !=null and province !='' ">
                province =#{province},
            </if>
            <if test="city !=null and city !='' ">
                city =#{city},
            </if>
            <if test="area !=null and area !='' ">
                area =#{area},
            </if>
            <if test="buyerUsername !=null and buyerUsername !='' ">
                buyer_username =#{buyerUsername},
            </if>
           erp_import = 1,erp_import_dt = now(),
            order_status = 4
        </set>
        WHERE order_code = #{orderCode}
        AND supplier_id = #{supplierId}
    </update>



    <!-- 修改订单备注 -->
    <update id="updateSelle" parameterType="java.util.Map">
        UPDATE  ${doingOrderTable} SET  seller_remark = #{sellerRemark} WHERE order_code = #{orderCode}
        AND  supplier_id = #{supplierId}
    </update>
</mapper>