金币系统后端
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

81 lines
10 KiB

  1. package com.example.demo.mapper;
  2. import com.example.demo.domain.entity.Admin;
  3. import com.example.demo.domain.entity.Detail;
  4. import com.example.demo.domain.entity.Product;
  5. import com.example.demo.domain.entity.User;
  6. import com.example.demo.domain.vo.DetailVo;
  7. import org.apache.ibatis.annotations.*;
  8. import java.util.List;
  9. @Mapper
  10. public interface ConsumeMapper {
  11. //通过id查询user全部信息
  12. @Select({
  13. "select * from user where user_id=#{userId}"
  14. })
  15. User getByUserId(Integer userId);
  16. //通过id查询admin全部信息
  17. @Select({
  18. "select * from admin where admin_id=#{adminId}"
  19. })
  20. Admin getByadminId(@Param("adminId") Integer adminId);
  21. //新增消费记录
  22. @Insert({
  23. "insert into detail",
  24. "(jwcode,activity_id,recharge_way,product_id,consume_platform,consume_type,refund_type,refund_goods,contact_id,remark,recharge_coin,fre
  25. "values",
  26. "(#{jwcode},#{activityId},#{rechargeWay},#{productId},'金币系统','购买商品',#{refundType},#{refundGoods},#{contactId},#{remark},#{rechargeCoin},#{freeCoin},#{taskCoin},#{adminId},#{updateType},1,now(),1,orderCode)"
  27. })
  28. // 获取自增主键
  29. @Options(useGeneratedKeys = true,keyColumn = "detail_id",keyProperty = "detailId")
  30. int insert(Detail detail);
  31. //userName
  32. //模糊分页查询,查询消费明细
  33. @Select({
  34. "<script>",
  35. "select detail.*,admin.name as adminName ,admin.area as area ,user.name as userName,product.name as productName from detail ",
  36. "inner join admin on detail.admin_id=admin.admin_id ",
  37. "inner join user on detail.jwcode= user.jwcode ",
  38. "inner join product on detail.product_id= product.product_id ",
  39. "<where>",
  40. "`detail_flag`=1 AND update_type = '消费'",
  41. "<if test='jwcode!=null'>and detail.jwcode =#{jwcode}</if>",
  42. "<if test='productName!=null'>and product.name like concat('%',#{productName},'%')</if>",
  43. "<if test='consumePlatform!=null'>and detail.consume_platform like concat('%',#{consumePlatform},'%')</if>",
  44. "<if test='consumeType!=null'>and detail.consume_type like concat('%',#{consumeType},'%')</if>",
  45. "<if test='startDate != null and endDate != null'>AND detail.create_time BETWEEN #{startDate} AND #{endDate}</if>",
  46. "</where>",
  47. "ORDER BY detail.create_time DESC",
  48. "</script>"
  49. })
  50. List<DetailVo> select(DetailVo detailVo);
  51. //查询消费信息
  52. @Select({
  53. "select * ,product.name as productName from detail " ,
  54. "inner join product on detail.product_id= product.product_id ",
  55. "where `detail_flag`=1 AND update_type = '消费' and jwcode=#{jwcode} AND refund_flag=1"
  56. })
  57. List<Detail> getDeatil(Integer jwcode);
  58. //查询消费信息
  59. @Select({
  60. "select * from product",
  61. " where product_flag=1 and name=#{name}",
  62. "GROUP BY name"
  63. })
  64. List<Product> getProduct(String name);
  65. }