ERPDoingOrderMapper.xml 6.0 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.web.dao.ERPDoingOrderDao">
	
	
	<!-- 根据未发货状状获取前500条订单信息 -->
	<select id="getOrderList" parameterType="map" resultMap="oneIMOrderDetailColumn">
		select * from
	 <foreach collection="tableNames" open="(" close=")" separator=" UNION ALL " item="orderTable">
		select do.order_id,do.order_code,do.main_order_code,do.order_status,do.order_from,
        do.contact,do.phone,do.province,do.city,do.area,do.address,do.pay_dt,
        do.buyer_remark,do.freight,do.create_dt,do1.order1_id,do1.product_id,do.buyer_phone,do.total_money,do.deduction_vb,
		 do.user_coupon_id,do.user_coupon_money,do.platform_type,
        do1.purchase_quantity,do1.price,do.pay_type,do.transaction_id,do1.integral,
        p.product_type,p.is_group,do1.erp_code,do1.discount_price,do1.discount_line_price
        from ${orderTable[0]} do left join ${orderTable[1]} do1 on do.order_id=do1.order_id 
        left join sibu_integralmall_base.im_product p on do1.product_id = p.im_product_id
        where do.platform_type=0 and do.order_status=#{orderStatus} and do.delete_flag = 1 and do.erp_import IN (0,101) and do.buyer_phone not like '13800138%'
	  </foreach> 
		as temp 
	</select>
	
	
		<!-- 根据未发货状状获取前500条订单信息 -->
	<select id="getOrderListOld" parameterType="map" resultMap="oneIMOrderDetailColumn">
		select * from
	 <foreach collection="tableNames" open="(" close="" separator=" UNION ALL " item="orderTable">
		select doo.order_id,doo.order_code,doo.main_order_code,doo.order_from,
        doo.contact,doo.phone,doo.province,doo.city,doo.area,doo.address,doo.pay_dt,
        doo.buyer_remark,doo.freight,doo.create_dt,doo.buyer_phone,
        doo.pay_type,doo.transaction_id
        from ${orderTable[0]} doo
        where doo.order_status=3 and doo.delete_flag = 1  and doo.buyer_phone not like '13800138%'
	  </foreach> 
		limit 0, ${size} )	as o
		left join 
	 <foreach collection="tableNames" open="(" close=")" separator=" UNION ALL " item="orderTable">
		select do1.product_id, do1.purchase_quantity,do1.price,do1.integral,do1.order_id,
        p.product_type,p.erp_code
        from ${orderTable[1]} do1 
        left join sibu_integralmall_base.im_product p on do1.product_id = p.im_product_id 
	  </foreach> 
	  as s 
	  on o.order_id=s.order_id 
	</select>
	
	
	<!-- 更新订单的erp导入状态 -->
	<update id="updateOrderStatus" parameterType="map" >
		UPDATE ${tableName} SET erp_import =1 ,erp_import_dt=#{importDt} where order_code=#{orderCode} and erp_import=101
	</update>
	
	<!-- 更新订单的发货信息 -->
	<update id="updateOrderShipMessage" parameterType="map">
		UPDATE ${tableName} SET order_status =#{orderStatus} 
		<if test="expressName!=null and expressName!=''">
			,express_name=#{expressName} 
		</if>
		<if test="expressCode!=null and expressCode!=''">
			,express_code=#{expressCode} 
		</if>
		<if test="shipDt!=null and shipDt!=''">
			,ship_dt=#{shipDt}
		</if>
		where order_code=#{orderCode} and order_status = 3 limit 1
	</update>

	<!--订单已发货【若订单状态为已发货,匹配【起始快递单号】是否存在,若存在,则不返写;若不存在,则返写快递信息(快递单号)到【起始快递单号】】-->
	<update id="updateOrderExpressCodeByShip" parameterType="java.util.Map">
		UPDATE ${tableName} SET order_status =#{orderStatus}
		<if test="type == 1">
			<if test="expressCode!=null and expressCode!=''">
				,express_code=#{expressCode}
			</if>
		</if>
		<if test="type == 2">
			<if test="expressCode != null and expressCode != ''">
				,express_code2=#{expressCode}
			</if>
		</if>
		where order_code=#{orderCode} and order_status = #{orderStatus} limit 1
	</update>
	<update id="lockErpImport" parameterType="java.util.Map">
		UPDATE ${tableName} SET erp_import=101
		where order_code=#{orderCode} and erp_import in (0,101)  and order_status = 3 limit 1
	</update>
	<resultMap type="IMDoingOrderBean" id="oneIMOrderDetailColumn">
		<result column="order_id" property="orderId" />
		<result column="order_code" property="orderCode" />
		<result column="main_order_code" property="mainOrderCode" />
		<result column="order_status" property="orderStatus"/>
		<result column="order_from" property="orderFrom" />
		<result column="contact" property="contact" />
		<result column="phone" property="phone" />
		<result column="province" property="province" />
		<result column="city" property="city" />
		<result column="area" property="area" />
		<result column="address" property="address" />
		<result column="buyer_remark" property="buyerRemark" />
		<result column="freight" property="freight" />
		<result column="create_dt" property="createDt"/>
		<result column="pay_dt" property="payDt"/>
		<result column="pay_type" property="payType"></result>
		<result column="transaction_id" property="transactionId"></result>
		<result column="buyer_phone" property="buyerPhone"></result>
		<result column="user_coupon_id" property="userCouponId" />
		<result column="user_coupon_money" property="userCouponMoney" />
		<result column="total_money" property="totalMoney" />
		<result column="deduction_vb" property="deductionVb" />
		<result column="platform_type" property="platformType"/>
		<collection property="order1s" column="order_id" ofType="IMDoingOrder1Bean">
			<result column="order1_id" property="order1Id"/>
			<result column="product_id" property="productId" />
			<result column="purchase_quantity" property="purchaseQuantity" />
			<result column="price" property="price" />
			<result column="integral" property="integral" />
			<result column="discount_price" property="discountPrice" />
			<result column="discount_line_price" property="discountLinePrice" />
			<association property="product" javaType="IMAPIProductBean">
				<result column="erp_code" property="erpCode" />
				<result column="product_type" property="productType" />
				<result column="is_group" property="isGroup" />
			</association>
		</collection>
	</resultMap>
	
	
</mapper>