package com.hfkj.dao;

import com.hfkj.model.OpenStoreModel;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.List;
import java.util.Map;

/**
 * mapper扩展类
 */
public interface BsStoreMapperExt {

    @Select(" <script>" +
            " select" +
            " count(1) tradeSum," +
            " case when sum(trade_amount) is not null then sum(trade_amount) else 0 end tradePrice " +
            " from bs_trade_order " +
            " where 1 = 1" +
            " <if test='param.storeId != null'> and store_id in (${param.storeId}) </if> " +
            " <if test='param.payTimeS != null'> <![CDATA[ and pay_time >= #{param.payTimeS} ]]> </if> " +
            " <if test='param.payTimeE != null'> <![CDATA[ and pay_time <= #{param.payTimeE} ]]> </if> " +
            " <if test='param.status != null'> and `status` in (${param.status}) </if> " +
            " </script>")
    Map<String, Object> countStoreTrade(@Param("param") Map<String, Object> param);

    @Select(" <script>" +
            " select" +
            " address," +
            " longitude," +
            " latitude," +
            " door_head_img as doorHeadImg, " +
            " bs.name as storeName , " +
            "  parent_id as parentId , " +
            "  child_id  as childId, " +
            "  parent_name as parentName , " +
            "  child_name as childName, " +
            "  bs.status as storeStatus , " +
            "  bs.create_time as storeCreateTime " +
            "  from bs_store bs join bs_store_industry bi on bs.id = bi.store_id " +
            " where bs.status = 2" +
            " <if test='param.childId != null'> and child_id in (${param.childId}) </if> " +
            " <if test='param.name != null'> and name like '%${param.name}%' </if> " +
            " </script>")
    List<OpenStoreModel> getStoreList(@Param("param") Map<String, Object> param);
}
