ShareOrderMapper.xml 6.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.ShareOrderDao">
	<sql id="Base_DoingOrder_column">
		order_id,member_id,order_code,order_status,order_from,
		order_platform,contact,phone,province,city,
		area,address,zipcode,total_integral,total_money,freight,buyer_remark,
		erp_download,erp_import,create_dt,main_order_code,delete_flag,buyer_username,buyer_phone,express_name,
		user_coupon_id,user_coupon_money,deduction_vb,deduction_money,share_member_id,share_order_money
	</sql>
	<sql id="Base_DoingOrder1_column">
		order1_id,member_id,order_id,sort_index,product_id,
		purchase_quantity,shipped_quantity,integral,line_integral,price,line_price
	</sql>
	<insert id="addShareOrder" parameterType="com.sibu.orderHelper.integral.model.IMDoingOrderBean">
		insert into t_share_order (
		<include refid="Base_DoingOrder_column"/>
		) value(
		#{orderId},
		#{memberId},
		#{orderCode},
		#{orderStatus},
		#{orderFrom},
		#{orderPlatform},
		#{contact},
		#{phone},
		#{province},
		#{city},
		#{area},
		#{address},
		#{zipcode},
		#{totalIntegral},
		#{totalMoney},
		#{freight},
		#{buyerRemark},
		#{erpDownload},
		#{erpImport},
		NOW(),
		#{mainOrderCode},
		#{deleteFlag},
		#{buyerUsername},
		#{buyerPhone},
		#{expressName},
		#{userCouponId},
		#{userCouponMoney},
		#{deductionVb},
		#{deductionMoney},
		#{shareMemberId},
		#{shareOrderMoney}
		)
	</insert>
	<!-- 添加子订单 -->
	<insert id="addShareOrder1" parameterType="java.util.List">
		<![CDATA[
		    insert into t_share_order_product (
				order1_id,member_id,order_id,sort_index,product_id,
        		purchase_quantity,shipped_quantity,integral,line_integral,price,line_price,sku_id,erp_code,spec_detail,name,thumb_img,market_price,
        		discount_price,discount_line_price,deduction_product_vb,deduction_line_vb,product_share_percentage
			) values
		]]>
		<foreach collection="list" item="item" index="index" separator=",">
			(
			#{item.order1Id},
			#{item.memberId},
			#{item.orderId},
			#{item.sortIndex},
			#{item.productId},
			#{item.purchaseQuantity},
			#{item.shippedQuantity},
			#{item.integral},
			#{item.lineIntegral},
			#{item.price},
			#{item.linePrice},
			#{item.skuId},
			#{item.erpCode},
			#{item.specDetail},
			#{item.name},
			#{item.thumbImg},
			#{item.marketPrice},
			#{item.discountPrice},
			#{item.discountLinePrice},
			#{item.deductionProductVb},
			#{item.deductionLineVb},
			#{item.productSharePercentage}
			)
		</foreach>
	</insert>

	<!--更新分享收益的订单状态-->
	<update id="updateShareOrderStatus" parameterType="java.util.Map">
		update t_share_order set order_status=#{orderStatus}
		<if test="orderStatus == 5">
			,receive_dt=now()
		</if>
		where order_code = #{orderCode} limit 1
	</update>
	<!--更新分享收益的订单状态-->
	<update id="updateOrderStatus" parameterType="java.util.Map">
		update t_share_order set order_status=#{orderStatus} where order_code = #{orderCode} limit 1
	</update>

	<!-- 分页查询订单列表 -->
	<select id="listShareOrder" parameterType="map" resultMap="listIMOrderColumn">
		select doo.order_id,doo.member_id,doo.order_code,doo.order_status,doo.order_from,
		doo.order_platform,doo.contact,doo.phone,doo.total_integral,doo.total_money,doo.freight,doo.create_dt,doo.if_evaluate,doo.share_order_money,doo.receive_dt,
		do1.order1_id,do1.product_id,do1.purchase_quantity,do1.integral,do1.line_integral,do1.price,do1.line_price,do1.is_evaluate,do1.spec_detail,
		do1.name,do1.thumb_img,do1.market_price,do1.product_share_percentage
		from t_share_order_product do1,
		(
		select do.order_id,do.member_id,do.order_code,do.order_status,do.order_from,
		do.order_platform,do.contact,do.phone,do.total_integral,do.total_money-do.freight as total_money,do.freight,do.create_dt,do.if_evaluate,do.share_order_money,do.receive_dt from t_share_order do
		where do.share_member_id = #{memberId} AND do.delete_flag=1
		<if test="orderStatus == 3">
			AND do.order_status = 3
		</if>
		<if test="orderStatus == 1">
			AND do.order_status = 1
		</if>
		<if test="orderStatus == 5">
			AND do.order_status = 5
		</if>
		<if test="orderStatus == 100">
			AND do.order_status = 100
		</if>
		<if test="orderStatus == 8">
			AND do.order_status in (7, 8)
		</if>
		order by do.create_dt desc
		limit ${pageNow}, ${pageSize}
		) doo
		where doo.order_id=do1.order_id
		order by doo.create_dt desc
	</select>
	<select id="countShareOrder" parameterType="map" resultType="int">
		select count(1) from t_share_order where share_member_id = #{memberId} AND delete_flag=1
		<if test="orderStatus == 3">
			AND order_status = 3
		</if>
		<if test="orderStatus == 1">
			AND order_status = 1
		</if>
		<if test="orderStatus == 4">
			AND order_status = 4
		</if>
		<if test="orderStatus ==5">
			AND order_status = 5
		</if>
		<if test="orderStatus == 100">
			AND order_status =100
		</if>
		<if test="orderStatus == 8">
			AND order_status = 8
		</if>
	</select>

	<resultMap type="com.sibu.orderHelper.integral.reponse.DoingOrderListResponse" id="listIMOrderColumn">
		<id column="order_id" property="orderId" />
		<result column="member_id" property="memberId" />
		<result column="order_code" property="orderCode" />
		<result column="order_status" property="orderStatus" />
		<result column="order_from" property="orderFrom" />
		<result column="contact" property="contact" />
		<result column="phone" property="phone" />
		<result column="total_integral" property="totalIntegral" />
		<result column="total_money" property="totalMoney" />
		<result column="freight" property="freight" />
		<result column="create_dt" property="createDt" />
		<result column="if_evaluate" property="ifEvaluate" />
		<result column="receive_dt" property="receiveDt" />
		<result column="share_order_money" property="shareOrderMoney" />
		<collection property="order1s" column="order_id" ofType="com.sibu.orderHelper.integral.reponse.DoingOrder1DetailResponse">
			<id column="order1_id" property="order1Id" />
			<result column="product_id" property="productId" />
			<result column="purchase_quantity" property="purchaseQuantity" />
			<result column="shipped_quantity" property="shippedQuantity" />
			<result column="integral" property="integral" />
			<result column="line_integral" property="lineIntegral" />
			<result column="price" property="price" />
			<result column="line_price" property="linePrice" />
			<result column="is_evaluate" property="isEvaluate" />
			<result column="spec_detail" property="specDetail"/>
			<result column="name" property="name" />
			<result column="market_price" property="marketPrice" />
			<result column="thumb_img" property="thumbImg" />
			<result column="product_share_percentage" property="productSharePercentage" />
		</collection>
	</resultMap>
</mapper>