package com.example.demo.mapper;
import com.example.demo.domain.entity.Admin;
import com.example.demo.domain.entity.Detail;
import com.example.demo.domain.entity.Product;
import com.example.demo.domain.entity.User;
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})"
})
// 获取自增主键
@Options(useGeneratedKeys = true,keyColumn = "detail_id",keyProperty = "detailId")
int insert(Detail detail);
//userName
//模糊分页查询,查询消费明细
@Select({
""
})
List 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 getDeatil(Integer jwcode);
//查询消费信息
@Select({
"select * from product",
" where product_flag=1 and name=#{name}",
"GROUP BY name"
})
List getProduct(String name);
}