<?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.phy.ebuy.dao.EbuyMapper">

    <!--验证登录-->
    <select id="verifyLogin" parameterType="map" resultType="map" >
        select * from ebuy_user where (user_name = #{userName}  and pass_word = #{passWord})
        or (mobile = #{userName} and pass_word = #{passWord})
    </select>

    <!--注册提交-->
    <insert id="registerSub" parameterType="map">
        INSERT INTO ebuy_user
        VALUES
            (
            ( SELECT RIGHT ( RAND( ), 16 ) ),
            #{userName},
            #{passWord},
            '',
            '',
            '',
            #{mobile},
            '',
            '00',
            now( ),
            '',
            '00',
            '0',
            ( SELECT RIGHT ( RAND( ), 16 ) )
            );
    </insert>

    <!--获取所有订单-->
    <select id="allOrderTable" resultType="map" parameterType="String">
    SELECT
	o.creat_time creat_time,
	o.order_id order_id,
	o.businesses_id businesses_id,
	b.business_name businesses_name,
	c.commodity_photo commodity_photo,
	c.commodity_name commodity_name,
	o.commodity_attribute commodity_attribute,
	c.commodity_price commodity_price,
	o.commodity_amount commodity_amount,
	o.order_status order_status
FROM
	ebuy_order o
	INNER JOIN ebuy_businesses b ON o.businesses_id = b.business_id
	INNER JOIN ebuy_commodity c ON o.commodity_id = c.commodity_id
        where 1 = 1
        <if test="orderStatus != null and orderStatus != ''">
          and  order_status=#{orderStatus}
        </if>
    </select>

    <!--查询字典表-->
    <select id="queryDictionary" resultType="map">
        SELECT
	*
FROM
	ebuy_dictionaries
WHERE
	id IN
        <foreach collection="array" open="(" separator="," close=")" item="id">
        #{id}
    </foreach>
    </select>

    <!--获取商品分类-->
    <select id="typeDown" resultType="string" parameterType="string">
        SELECT
	type_down_details
FROM
	ebuy_dictionaries
WHERE
	type_down = #{typeDown}
    </select>
</mapper>