金币系统后端
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.

130 lines
6.6 KiB

package com.example.demo.mapper;
import com.example.demo.domain.entity.DetailY;
import com.example.demo.domain.entity.UserDetailExport;
import com.example.demo.domain.vo.DetailYgold;
import com.example.demo.domain.vo.DetailExport;
import org.apache.ibatis.annotations.*;
import java.util.List;
@Mapper
public interface DetailYMapper {
@Insert({
// "insert into detail_y",
// "(jwcode,order_code,activity_id,recharge_way,product_id,consume_platform,consume_type,refund_type,refund_goods,name,username,area" +
// "contact_id,remark,recharge_coin,free_coin,task_coin,admin_id,update_type,detail_flag,create_time,first_recharge)",
// "values ",
// "(#{jwcode},#{orderCode},#{activityId},#{rechargeWay},#{productId},#{consumePlatform},#{consumeType},#{refundType}" +
// ",#{refundGoods},#{name},#{username},#{area},#{contactId},#{remark},#{rechargeCoin}" +
// ",#{freeCoin},#{taskCoin},#{adminId},#{updateType},1,now(),#{firstRecharge})"
"insert into detail_y \n" +
"(jwcode, order_code, activity_id, recharge_way, product_id, consume_platform, consume_type, refund_type, refund_goods, name, username, area, contact_id, remark, recharge_coin, free_coin, task_coin, admin_id, update_type, detail_flag, create_time, first_recharge,product_name)\n" +
"values \n" +
"(#{jwcode}, #{orderCode}, #{activityId}, #{rechargeWay}, #{productId}, #{consumePlatform}, #{consumeType}, #{refundType}, #{refundGoods},'小洪', #{username}, #{area}, #{contactId}, #{remark}, #{rechargeCoin}, #{freeCoin}, #{taskCoin}, #{adminId}, #{updateType}, 1, #{createTime}, #{firstRecharge},#{productName})"
})
@Options(useGeneratedKeys = true,keyColumn = "detaily_id",keyProperty = "detailyId")
int add(DetailY detaily);
@Select({
"SELECT * from detail_y where detaily_id =#{detailyId}"
})
DetailY selectByDetailyId(Integer detaily_id);
@Select({
"<script>",
"SELECT ",
"`user`.name,`user`.area,user_gold.buy_jb,user_gold.core_jb,user_gold.free_12,user_gold.free_6,",
"user_gold.jwcode,",
"SUM(CASE WHEN detail_y.update_type = 0 THEN detail_y.recharge_coin ELSE 0 END) AS Rcoin,",
"SUM(CASE WHEN detail_y.update_type = 1 THEN detail_y.recharge_coin + detail_y.free_coin + detail_y.task_coin ELSE 0 END) AS Scoin",
"FROM ",
"detail_y",
"LEFT JOIN ",
"user_gold ON detail_y.jwcode = user_gold.jwcode",
"LEFT JOIN",
"`user` ON detail_y.jwcode = `user`.jwcode",
"<where>",
"<if test='jwcode!=null and jwcode.length>0'>and detail_y.jwcode=#{jwcode}</if>",
"<if test='area!=null and area.length>0'>AND `user`.area=#{area}</if>",
"</where>",
"GROUP BY",
"user_gold.jwcode",
"ORDER BY ",
"Rcoin DESC",
"</script>"
})
List<DetailYgold> selectgold(DetailYgold detailYgold);
@Select({
"<script>",
"select username,name,detail_y.jwcode,area,detail_y.update_type,detail_y.create_time,detail_y.consume_platform,detail_y.free_coin,detail_y.recharge_coin,detail_y.task_coin from detail_y",
// "select * from detail_y",
// "select detail_y.*,admin.name,admin.area,user.name as uname,audit.status from detail",
// "left join `admin` on `detail_y`.admin_id = `admin`.admin_id",
// "left join `user` on `detail_y`.jwcode = `user`.jwcode",
// "left join audit on `detail_y`.detail_id=audit.detail_id",
"<where>",
// "(status is null or status='1')",
"<if test='jwcode!=null and jwcode.length>0'>and detail_y.jwcode=#{jwcode}</if>",
"<if test='updateType!=null'>and update_type=#{updateType}</if>",
"<if test='startDate != null and endDate != null'>AND detail_y.create_time BETWEEN #{startDate} AND #{endDate}</if>",
"<if test='consumePlatform!=null and consumePlatform.length>0'>and consume_platform=#{consumePlatform}</if>",
"<if test='area!=null and area.length>0'>and area=#{area}</if>",
"</where>",
"ORDER BY detaily_id desc",
"</script>"
})
List<DetailY> select(DetailY detailY);
@Select({
"<script>",
"SELECT",
" SUM(`recharge_coin`) AS 'sumR',",
" SUM(`task_coin`) AS 'sumT',",
" SUM(`free_coin`) AS 'sumF'",
"FROM",
"`detail_y`",
"<where>",
"<if test='jwcode!=null and jwcode.length>0'>AND jwcode=#{jwcode}</if>",
"<if test='updateType!=null'>AND update_type=#{updateType}</if>",
"<if test='startDate != null and endDate != null'>AND create_time BETWEEN #{startDate} AND #{endDate}</if>",
"<if test='area!=null and area.length>0'>AND area=#{area}</if>",
"</where>",
"</script>"
})
DetailY getCount(DetailY detailY);
//导出数据的SQL
@Select({
"<script>",
"SELECT d.detaily_id,u.name,d.jwcode,u.area,d.consume_platform,d.update_type,d.recharge_coin,d.task_coin," +
"d.free_coin,d.create_admin,d.create_time",
"FROM detail_y d",
"LEFT JOIN user u on d.jwcode = u.jwcode ",
"ORDER BY detaily_id LIMIT #{offset}, #{pageSize}",
"</script>"
})
List<UserDetailExport> searchExport(@Param("offset") int offset, @Param("pageSize") int pageSize);
@Select("SELECT COUNT(*) FROM detail_y")
int getTotalCount();
@Select({
"<script>",
"SELECT d.detaily_id,u.name,d.jwcode,u.area,d.consume_platform,d.update_type,d.recharge_coin,d.task_coin," +
"d.free_coin,d.create_admin,d.create_time",
"FROM detail_y d",
"LEFT JOIN user u on d.jwcode = u.jwcode ",
"<where>",
"<if test='updateType!=null'>AND d.update_type=#{updateType}</if>",
"<if test='jwcode!=null'>AND d.jwcode=#{jwcode}</if>",
"<if test='area != null '>AND u.area=#{area}</if>",
"<if test='startDate != null and endDate != null'>AND create_time BETWEEN #{startDate} AND #{endDate}</if>",
"</where>",
"ORDER BY detaily_id desc",
"</script>"
})
List<UserDetailExport> searchAll(DetailExport detailExport);
}