<?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="vip.xiaonuo.purchase.mapper.PurchasePriceMapper">

    <select id="getZhuYaoYuanCaiLiao" resultType="vip.xiaonuo.purchase.param.PurchaseYuanCaiLiaoParam">
    SELECT ROUND(IFNULL(AVG(price), 0), 2) "羊毛粗脂"  , DATE_FORMAT(create_time, '%Y-%m')
    ymonth  FROM `purchase_price`  ${ew.customSqlSegment}
    </select>
    <select id="getGongYingShang" resultType="vip.xiaonuo.purchase.param.GongYingShangParam">
SELECT ROUND(IFNULL(SUM(purchase_money ) , 0) /10000 , 2)    money
 ,supplier gongYingName
  FROM `purchase_order`
  ${ew.customSqlSegment}
   ORDER BY (ROUND(IFNULL(SUM(purchase_money ) , 0) , 2))  DESC
    </select>
    <select id="getWuLiaoShaiXuan" resultType="java.lang.String">
        SELECT
    material_name-- 明确计数的别名
FROM
    `warehouse_stock_detail`
HAVING
    SUM(material_number) > 0
    </select>
    <select id="getKuCunWuLiao" resultType="vip.xiaonuo.purchase.param.DongShiKuCunWuliaoVoParam">
SELECT   ROUND(IFNULL(SUM(material_number), 0) , 2)   kuCunNum  , DATE_FORMAT(create_time, '%Y-%m') ymonth ,
 ROUND(IFNULL( (SELECT SUM(kuncun_wuliao_money)
     FROM `warehouse_kucun_money`
      ${ew.customSqlSegment} and  DATE_FORMAT(date_time, '%Y-%m') = DATE_FORMAT(mb.create_time, '%Y-%m') ), 0)/10000, 2) AS kuCunMoney
FROM `warehouse_stock_detail` mb  ${ew.customSqlSegment}   group by ymonth
</select>
</mapper>
