PineappleMapper.xml 23.0 KB
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442
<?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="getOrdersByMap" 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>


    <!--退货表实体-->
    <resultMap id="memberProductBackResult" type="com.sibu.orderHelper.integral.pineapple.model.MemberProductBack">
        <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="contactPhone" column="contact_phone" />
        <result property="contactName" column="contact_name" />
        <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="question" column="question" />
        <result property="image" column="image" />
        <result property="stateReturn" column="state_return" />
        <result property="stateMoney" column="state_money" />
        <result property="number" column="number" />
        <result property="backMoney" column="back_money" />
        <result property="backIntegral" column="back_integral" />
        <result property="backIntegralMoney" column="back_integral_money" />
        <result property="backCouponUserId" column="back_coupon_user_id" />
        <result property="backMoneyTime" column="back_money_time" />
        <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" />
    </resultMap>

    <!--根据订单号查询换货信息-->
    <select id="getMemberProductBackByOrderSn" parameterType="java.lang.String" resultMap="memberProductBackResult">
      SELECT * FROM member_product_back WHERE order_sn = #{orderSn} AND state_return  IN ('1','2','3','4') ORDER  BY create_time
    </select>

    <!--换货实体类-->
    <resultMap id="memberProductExchangeResult" type="com.sibu.orderHelper.integral.pineapple.model.MemberProductExchange">
        <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="provinceId2" column="province_id2" />
        <result property="cityId2" column="city_id2" />
        <result property="areaId2" column="area_id2" />
        <result property="addressAll2" column="address_all2" />
        <result property="addressInfo2" column="address_info2" />
        <result property="zipCode2" column="zip_code2" />
        <result property="changeName2" column="change_name2" />
        <result property="phone2" column="phone2" />
        <result property="logisticsId2" column="logistics_id2" />
        <result property="logisticsName2" column="logistics_name2" />
        <result property="logisticsMark2" column="logistics_mark2" />
        <result property="logisticsNumber2" column="logistics_number2" />
        <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" />
    </resultMap>

    <!--根据订单号查询换货信息-->
    <select id="getMemberProductExchangeByOrderSn" parameterType="java.lang.String" resultMap="memberProductExchangeResult">
        SELECT * FROM member_product_exchange  WHERE order_sn = #{orderSn} AND state IN ('1','2','3','4')  ORDER  BY create_time
    </select>

    <!-- 投诉表实体-->
    <resultMap id="sellerComplaintResult" type="com.sibu.orderHelper.integral.pineapple.model.SellerComplaint">
        <result property="id" column="id" />
        <result property="userId" column="user_id" />
        <result property="userName" column="user_name" />
        <result property="orderId" column="order_id" />
        <result property="orderProductId" column="order_product_id" />
        <result property="productBackId" column="product_back_id" />
        <result property="productExchangeId" column="product_exchange_id" />
        <result property="content" column="content" />
        <result property="image" column="image" />
        <result property="complaintTime" column="complaint_time" />
        <result property="sellerId" column="seller_id" />
        <result property="sellerComplaintTime" column="seller_complaint_time" />
        <result property="sellerCompContent" column="seller_comp_content" />
        <result property="sellerCompImage" column="seller_comp_image" />
        <result property="state" column="state" />
        <result property="optId" column="opt_id" />
        <result property="optContent" column="opt_content" />
        <result property="userContent" column="user_content" />
        <result property="createTime" column="create_time" />
        <result property="optTime" column="opt_time" />
    </resultMap>

    <!-- 根据条件查询投诉表-->
    <select id="getSellerComplaintById" parameterType="java.lang.Integer" resultMap="sellerComplaintResult">
        SELECT * FROM seller_complaint WHERE order_id = #{orderId} AND state IN (1,3,4) ORDER  BY create_time
    </select>
</mapper>