PineappleMapper.xml 15.7 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">
        <!-- 订单实体 -->
        <resultMap id="orders" type="com.sibu.orderHelper.integral.pineapple.model.Orders">
            <result property="id" column="id" />
            <result property="sellerId" column="seller_id" />
            <result property="sellerName" column="seller_name" />
            <result property="orderId" column="order_id" />
            <result property="orderSn" column="order_sn" />
            <result property="orderProductId" column="order_product_id" />
            <result property="productId" column="product_id" />
            <result property="productName" column="product_name" />
            <result property="memberId" column="member_id" />
            <result property="memberName" column="member_name" />
            <result property="provinceId" column="province_id" />
            <result property="cityId" column="city_id" />
            <result property="areaId" column="area_id" />
            <result property="addressAll" column="address_all" />
            <result property="addressInfo" column="address_info" />
            <result property="zipCode" column="zip_code" />
            <result property="changeName" column="change_name" />
            <result property="phone" column="phone" />
            <result property="logisticsId" column="logistics_id" />
            <result property="logisticsName" column="logistics_name" />
            <result property="logisticsMark" column="logistics_mark" />
            <result property="logisticsNumber" column="logistics_number" />
            <result property="number" column="number" />
            <result property="question" column="question" />
            <result property="image" column="image" />
            <result property="name" column="name" />
            <result property="state" column="state" />
            <result property="optId" column="opt_id" />
            <result property="optName" column="opt_name" />
            <result property="remark" column="remark" />
            <result property="createTime" column="create_time" />
            <result property="updateTime" column="update_time" />
            <result property="province" column="regionName1" />
            <result property="city" column="regionName2" />
            <result property="area" column="regionName3" />
        </resultMap>

        <!-- 根据订单号查询订单信息  只查询不是主订单的订单 -->
        <select id="getOrders" parameterType="java.util.Map"  resultMap="orders">
            select * from orders  where  order_sn = #{orderSn} AND seller_id = #{sellerId} AND  is_parent = 0
        </select>

        <!-- 修改订单备注 -->
        <update id="updateOdersRemark">
            UPDATE orders SET remark = #{remark} WHERE order_sn = #{orderSn} AND seller_id = #{sellerId}
        </update>

        <!-- 订单发货-->
        <!-- 验证订单号是否已存在-->
        <select id="checkLogisticsNumber" parameterType="java.util.Map" resultType="java.lang.Integer">
            select count(*) from orders  where  order_sn = #{orderSn} AND seller_id = #{sellerId} and logistics_number like concat(concat('%',#{logisticsNumber},'%'))
        </select>

        <!--更改订单状态、电话、地址、发货时间、收货人姓名,快递单号 -->
        <update id="updateOrdersState">
          UPDATE orders SET
          <set>
              <if test="name !=null and name !=''">
                  name = #{name},
              </if>
              <if test="addressInfo !=null and addressInfo !=''">
                  address_info = #{addressInfo},
              </if>
              <if test="logisticsNumber !=null and logisticsNumber !=''">
                  logistics_number = #{logisticsNumber},
              </if>
              <if test="mobile !=null and mobile !=''">
                  mobile = #{mobile},
              </if>
              <if test="addressAll !=null and addressAll !=''">
                  address_all = #{addressAll},
              </if>
              <if test="orderState !=null and orderState !=''">
                  order_state = #{orderState},
              </if>
              <if test="provinceId !=null and provinceId !=''">
                  province_id = #{provinceId},
              </if>
              <if test="areaId !=null and areaId !=''">
                  area_id = #{areaId},
              </if>
              <if test="cityId !=null and cityId !=''">
                  city_id = #{cityId},
              </if>
              <if test="deliverTime !=null and deliverTime !=''">
                  deliver_time = now(),
              </if>
              <if test="logisticsName !=null and logisticsName !=''">
                  logistics_name = #{logisticsName},
              </if>
              <if test="logisticsId !=null and logisticsId !=''">
                  logistics_id = #{logisticsId},
              </if>
          </set>
            WHERE order_sn = #{orderSn} AND seller_id = #{sellerId}
        </update>

        <!-- 商品下载实体-->
        <resultMap id="downloadProductBean" type="com.sibu.orderHelper.integral.model.DownloadProductBean">
            <result column="id" property="PlatProductID"/>
            <result column="name" property="name"/>
            <result column="outerID" property="OuterID"/>
            <result column="price" property="price"/>
            <result column="num" property="num"/>
            <result column="pictureurl" property="pictureurl"/>
        </resultMap>

        <!-- 商品下载 -->
        <select id="downloadProductListByMap" parameterType="java.util.Map"  resultMap="downloadProductBean">
            SELECT p.id,p.product_code AS outerID,p.name1 AS  productName,p.product_stock AS num,p.master_img AS pictureurl,
            p.mall_pc_price AS price
            FROM product p  WHERE p.seller_id = #{sellerId}
            <if test="productId !=null and productId !=''">
                AND (p.id = #{productId} or p.product_code = #{productId}
            </if>
            <if test="state !=null and state !='' and state != -1">
                AND p.state = #{state}
            </if>
            <if test="state !=null and state !='' and state == -1">
                AND p.state IN ('6','7')
            </if>
            <if test="productName !=null and productName !=''">
                AND p.state = #{productName}
            </if>
            ORDER BY p.im_product_id DESC
            limit ${PageIndex}, ${PageSize}
        </select>

        <!-- 商品sku实体 -->
        <resultMap id="downloadSku" type="com.sibu.orderHelper.integral.model.DownloadProductSkuBean">
            <result column="skuId" property="SkuID"/>
            <result column="skuOuterID" property="skuOuterID"/>
            <result column="skuprice" property="skuprice"/>
            <result column="skuQuantity" property="skuQuantity"/>
            <result column="skuname" property="skuname"/>
            <result column="skupictureurl" property="skupictureurl"/>
        </resultMap>

        <!-- 获取商品sku -->
        <select id="downloadSkuByProductId" resultType="java.lang.String"  resultMap="downloadSku">
            select g.sku AS skuId,g.sku AS skuOuterID,g.mall_pc_price AS skuprice,g.product_stock AS skuQuantity,
            g.norm_name AS skuname ,g.images AS skupictureurl  FROM product_goods g WHERE g.product_id = #{productId}
        </select>

        <!-- 更新SKU库存-->
        <update id="updateSkuStock" parameterType="java.util.Map">
            UPDATE product_goods SET product_stock = #{stock} WHERE sku = #{skuId} and product_id = #{productId}
        </update>

        <!-- 更新产品库存-->
        <update id="updateProductStock" parameterType="java.util.Map">
            UPDATE product SET product_stock = #{productStock} WHERE id = #{productId}
        </update>


        <!-- 下载订单实体-->
       <!-- <resultMap id="orderResponse" type="com.sibu.orderHelper.integral.pineapple.response.OrderResponse">
            <result property="platOrderNo" column="order_sn" />
            <result property="tradeStatus" column="order_state" />
            <result property="tradeStatusDescription" column="remark" />
            <result property="tradeTime" column="create_time" />
            <result property="province" column="regionName1" />
            <result property="city" column="regionName2" />
            <result property="area" column="regionName3" />
            <result property="address" column="address_info" />
            <result property="mobile" column="mobile" />
            <result property="zip" column="zip_code" />
            <result property="postFee" column="money_logistics" />
            <result property="totalMoney" column="money_order" />
            <result property="favourableMoney" column="couponMoney" />
            <result property="goodsFee" column="money_product" />
            <result property="payTime" column="pay_time" />
            <result property="nick" column="member_name" />
        </resultMap>-->


        <!-- 主订单下载-->
        <select id="getOrdersList" parameterType="java.util.Map"  resultMap="orders">
            select o.order_sn,o.order_state,o.remark,o.create_time,p.regionName AS regionName1,
            c.regionName AS regionName2,a.regionName AS regionName3,
            o.address_info,o.mobile,o.zip_code,o.zip_code,o.money_logistics,o.money_product-o.money_order-o.money_logistics AS couponMoney
            o.money_order,o.money_product,o.pay_time,o.member_name FROM orders  o
            LEFT JOIN regions p ON p.id = o.province_id
            LEFT JOIN regions c ON c.id = o.city_id
            LEFT JOIN regions a ON a.id = o.area_id
            WHERE o.is_parent = 0
            AND seller_id = #{sellerId} AND order_sn = #{orderSn}
            <if test="startTime !=null and startTime ! =''">
                AND create_time >= #{startTime}
            </if>
            <if test="endTime !=null and endTime ! =''">
                <![CDATA[
					and  create_time <= #{endTime}
					]]>
            </if>
            ORDER BY o.id DESC
            limit ${PageIndex}, ${PageSize}
        </select>

        <!-- 子订单实体-->
        <resultMap id="ordersProduct" type="com.sibu.orderHelper.integral.pineapple.model.OrdersProduct">
            <result property="id" column="id" />
            <result property="ordersId" column="orders_id" />
            <result property="ordersSn" column="orders_sn" />
            <result property="ordersPsn" column="orders_psn" />
            <result property="sellerId" column="seller_id" />
            <result property="sellerName" column="seller_name" />
            <result property="productCateId" column="product_cate_id" />
            <result property="productId" column="product_id" />
            <result property="productGoodsId" column="product_goods_id" />
            <result property="specInfo" column="spec_info" />
            <result property="productName" column="product_name" />
            <result property="productSku" column="product_sku" />
            <result property="packageGroupsId" column="package_groups_id" />
            <result property="mallGroupsId" column="mall_groups_id" />
            <result property="giftId" column="gift_id" />
            <result property="isGift" column="is_gift" />
            <result property="moneyPrice" column="money_price" />
            <result property="number" column="number" />
            <result property="moneyAmount" column="money_amount" />
            <result property="moneyActSingle" column="money_act_single" />
            <result property="actSingleId" column="act_single_id" />
            <result property="actGroupId" column="act_group_id" />
            <result property="actFlashSaleId" column="act_flash_sale_id" />
            <result property="actFlashSaleProductId" column="act_flash_sale_product_id" />
            <result property="actBiddingId" column="act_bidding_id" />
            <result property="actIntegralId" column="act_integral_id" />
            <result property="actIntegralNum" column="act_integral_num" />
            <result property="actIntegralMoney" column="act_integral_money" />
            <result property="systemRemark" column="system_remark" />
            <result property="backNumber" column="back_number" />
            <result property="exchangeNumber" column="exchange_number" />
            <result property="createTime" column="create_time" />
            <result property="updateTime" column="update_time" />
            <result property="isEvaluate" column="is_evaluate" />
        </resultMap>

    <!-- 下载子订单实体-->
   <!-- <resultMap id="ordersProduct" type="com.sibu.orderHelper.integral.pineapple.response.OrderGoodResponse">
        <result property="productId" column="" />
        <result property="subOrderNo" column="" />
        <result property="tradeGoodsNo" column="" />
        <result property="tradeGoodsName" column="" />
        <result property="tradeGoodsSpec" column="" />
        <result property="goodsCount" column="" />
        <result property="price" column="" />
        <result property="discountMoney" column="" />
        <result property="status" column="" />
    </resultMap>-->


        <!-- 查询子订单-->
        <select id="getOrdersProductList" resultType="java.util.Map" resultMap="ordersProduct">
            SELECT product_sku,id,product_name,spec_info,number,money_price,money_act_single FROM orders_product
            WHERE orders_sn = #{ordersSn}
        </select>

    <!-- 地址实体类-->
    <resultMap id="regionsResult" type="com.sibu.orderHelper.integral.pineapple.model.Regions">
        <result property="id" column="id" />
        <result property="parentId" column="parentId" />
        <result property="regionName" column="regionName" />
        <result property="parentPath" column="parentPath" />
        <result property="firstLetter" column="firstLetter" />
        <result property="regionType" column="regionType" />
        <result property="agencyId" column="agencyId" />
        <result property="shippingId" column="shippingId" />
        <result property="visible" column="visible" />
        <result property="rowId" column="rowId" />
    </resultMap>

    <!-- 根据条件查询省市级信息-->
    <select id="getRegionsByMap" parameterType="java.util.Map" resultMap="regionsResult">
      SELECT * FROM regions WHERE regionName LIKE concat('%',#{name},'%') AND regionType = #{regionType}
    </select>

    <!-- 根据id查询省市级信息-->
    <select id="getRegionsById" parameterType="java.lang.Integer" resultMap="regionsResult">
        select
        *
        from `regions`
        where `id` = #{id}
    </select>

    <!-- 物流公司实体-->
    <resultMap id="courierCompanyResult" type="com.sibu.orderHelper.integral.pineapple.model.CourierCompany">
        <result property="id" column="id" />
        <result property="createTime" column="create_time" />
        <result property="state" column="state" />
        <result property="companyMark" column="company_mark" />
        <result property="companyName" column="company_name" />
        <result property="seq" column="seq" />
        <result property="sellerId" column="seller_id" />
        <result property="companyType" column="company_type" />
        <result property="imagePath" column="image_path" />
        <result property="content" column="content" />
    </resultMap>

    <!-- 根据条件查询物流公司-->
    <select id="getCourierCompanyByName" parameterType="java.util.Map" resultMap="courierCompanyResult">
        select
        *
        from `courier_company`
        where  company_name LIKE concat('%',#{name},'%') AND seller_id =#{sellerId}
    </select>
</mapper>