|
|
package com.example.demo.mapper;
import com.example.demo.domain.entity.*; import com.example.demo.domain.vo.ConsumeDetail; import org.apache.ibatis.annotations.*;
import java.util.List;
@Mapper public interface ConsumeMapper {
//通过id查询user全部信息
@Select({ "select * from user where user_id=#{userId}" }) User getByUserId(Integer userId);
//通过id查询admin全部信息
@Select({ "select * from admin where admin_id=#{adminId}" }) Admin getByadminId(@Param("adminId") Integer adminId); //新增消费记录
@Insert({ // "insert into detail",
// "(jwcode,activity_id,recharge_way,product_id,consume_platform,consume_type,refund_type,refund_goods,contact_id,remark,recharge_coin,free_coin,task_coin,admin_id,update_type,detail_flag,create_time,refund_flag,order_code)",
// "values",
// "(#{jwcode},#{activityId},#{rechargeWay},#{productId},'金币系统','购买商品',#{refundType},#{refundGoods},#{contactId},#{remark},#{rechargeCoin},#{freeCoin},#{taskCoin},#{adminId},#{updateType},1,now(),1,#{orderCode})"
"insert into detail_y", "(jwcode,order_code,activity_id,recharge_way,product_id,consume_platform,consume_type,refund_type,refund_goods," + "contact_id,remark,recharge_coin,free_coin,task_coin,admin_id,update_type,detail_flag,create_time,first_recharge,`name`,username,area)", "values ", "(#{jwcode},#{orderCode},#{activityId},#{rechargeWay},#{productId},'金币系统','购买商品',#{refundType}" + ",#{refundGoods},#{contactId},#{remark},#{rechargeCoin}" + ",#{freeCoin},#{taskCoin},#{adminId},#{updateType},1,now(),#{firstRecharge},#{name},#{username},#{area})" }) // 获取自增主键
@Options(useGeneratedKeys = true,keyColumn = "detaily_id",keyProperty = "detailyId") int insert(DetailY detailY);
//userName
//模糊分页查询,查询消费明细
@Select({ "<script>", "select detail_y.*,admin.name as adminName,user.area as uarea,user.name as name,product.name as productName from detail_y ", "left join `admin` on detail_y.admin_id=admin.admin_id ", "left join `user` on detail_y.jwcode= user.jwcode ", "left join product on detail_y.product_id= product.product_id ", "<where>", // "`detail_flag`=1 AND update_type = '1'",
"update_type=1", "<if test='jwcode!=null'>and detail_y.jwcode =#{jwcode}</if>", "<if test='productName!=null'>and product.name = #{productName}</if>", "<if test='consumePlatform!=null'>and detail_y.consume_platform=#{consumePlatform}</if>", "<if test='consumeType!=null'>and detail_y.consume_type= #{consumeType}</if>", "<if test='startDate != null and endDate != null'>AND detail_y.create_time BETWEEN #{startDate} AND #{endDate}</if>", "</where>", "ORDER BY detail_y.create_time DESC", "</script>" }) List<ConsumeDetail> select(ConsumeDetail consumeDetail);
//查询消费信息
@Select({ "select * ,product.name as productName from detail " , "inner join product on detail.product_id= product.product_id ", "where `detail_flag`=1 AND update_type = '1' and jwcode=#{jwcode} AND refund_flag=1" }) List<Detail> getDeatil(Integer jwcode);
//查询消费信息
@Select({ "select * from product", " where product_flag=1 and name=#{name}", "GROUP BY name" }) List<Product> getProduct(String name);
}
|