|
|
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({ "<script>", "select detail_y.*,admin.name as adminName ,admin.area as area ,user.name as userName,product.name as productName from detail ", "inner join `admin` on detail.admin_id=admin.admin_id ", "inner join `user` on detail.jwcode= user.jwcode ", "inner join product on detail.product_id= product.product_id ", "<where>", // "`detail_flag`=1 AND update_type = '1'",
"update_type=1", "<if test='jwcode!=null'>and detail.jwcode =#{jwcode}</if>", "<if test='productName!=null'>and product.name like concat('%',#{productName},'%')</if>", "<if test='consumePlatform!=null'>and detail.consume_platform like concat('%',#{consumePlatform},'%')</if>", "<if test='consumeType!=null'>and detail.consume_type like concat('%',#{consumeType},'%')</if>", "<if test='startDate != null and endDate != null'>AND detail.create_time BETWEEN #{startDate} AND #{endDate}</if>", "</where>", // "ORDER BY detail.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);
}
|