Commit 3ac44295 authored by maliang's avatar maliang

上传bug修复

parent 312a5298
......@@ -23,6 +23,13 @@ public class CopyrightBookController {
return copyrightBookService.selectSettlement(request.getCopyrightIds(),request.getPage(),request.getLimit());
}
@PostMapping("/settlementBookMonth")
@ApiOperation(value = "获取月结算数据")
@ResponseBody
public String getSettlementBookMonthData(@RequestBody PageTableRequest request) {
return copyrightBookService.selectBookSettlement(request.getCopyrightIds(),request.getStartTime(),request.getEndTime(),request.getBookId(),request.getBookName(),request.getPage(),request.getLimit());
}
@PostMapping("/getAllCopyright")
@ApiOperation(value = "版权方数据")
@ResponseBody
......
......@@ -25,7 +25,9 @@ public interface CopyrightDao {
@Select("SELECT a.copyright_id as copyrightId,a.copyright_name as copyrightName FROM bi_report.book_banquanweihu a group by a.copyright_id,a.copyright_name")
List<BaseSettlement> selectCopyrightAll();
List<BaseSettlement> selectBookDetail(@Param("copyrightIdList") List<BaseSettlement> copyrightIdList,@Param("bookId") Long bookId,@Param("bookName") String bookName,@Param("startTime") String startTime,@Param("endTime") String endTime);
List<BaseSettlement> selectBookDetail(@Param("copyrightIdList") List<BaseSettlement> copyrightIdList,@Param("bookId") Long bookId,@Param("bookName") String bookName,@Param("startTime") String startTime,@Param("endTime") String endTime,@Param("page") Integer page,@Param("limit")Integer limit);
Integer selectBookDetailCount(@Param("copyrightIdList") List<BaseSettlement> copyrightIdList,@Param("bookId") Long bookId,@Param("bookName") String bookName,@Param("startTime") String startTime,@Param("endTime") String endTime);
@Update("update bi_report.report_book_settlement_month set jiesuan_status=#{status},jiesuan_status_name=#{statusName} where report_date=#{reportDate} and copyright_id=#{copyrightId}")
int updateSettlementStatus(@Param("copyrightId") Integer copyrightId,@Param("reportDate") String reportDate,@Param("status") Integer status,@Param("statusName") String statusName);
......
......@@ -27,6 +27,24 @@ public class PageTableRequest implements Serializable {
private String advertId;
private AdvertiserData advertiserData;
private BaseSettlement baseSettlement;
private Long bookId;
private String bookName;
public Long getBookId() {
return bookId;
}
public void setBookId(Long bookId) {
this.bookId = bookId;
}
public String getBookName() {
return bookName;
}
public void setBookName(String bookName) {
this.bookName = bookName;
}
public Integer getCopyrightIds() {
return copyrightIds;
......
package com.boot.security.server.service;
import com.boot.security.server.model.BaseSettlement;
public interface CopyrightBookService {
String selectSettlement(Integer copyrightId,Integer page,Integer limit);
String selectBookSettlement(Integer copyrightId,String startTime,String endTime,Long bookId,String bookName,Integer page,Integer limit);
String getAllCopyright();
String selectBookInfo(Integer copyrightId,Integer page,Integer limit);
}
......@@ -121,6 +121,116 @@ public class CopyrightBookServiceImpl implements CopyrightBookService {
return PageTableHandler.getJSONObject(baseSettlements,count);
}
@Override
public String selectBookSettlement(Integer copyrightId,String startTime,String endTime,Long bookId,String bookName,Integer page,Integer limit) {
List<BaseSettlement> baseSettlementList =new ArrayList<>();
if(copyrightId==null||copyrightId==0){
baseSettlementList = copyrightDao.selectCopyrightById(UserUtil.getLoginUser().getId());
}else {
BaseSettlement baseSettlement = new BaseSettlement();
baseSettlement.setCopyrightId(copyrightId);
baseSettlementList.add(baseSettlement);
}
List<BaseSettlement> baseSettlements = copyrightDao.selectBookDetail(baseSettlementList,bookId,bookName,startTime,endTime,page-1,limit);
DecimalFormat df = new DecimalFormat("#.00");
for (BaseSettlement baseSettlement : baseSettlements) {
if(baseSettlement.getTotalAmount()==null){
baseSettlement.setTotalAmount(0d);
}
if(baseSettlement.getTotalAdvertAmount()==null){
baseSettlement.setTotalAdvertAmount(0d);
}
Double totalAmount = baseSettlement.getTotalAmount();
Double count=0.0;
if(totalAmount<=2000.0){
count=totalAmount;
}else if(totalAmount>=2001.0&&totalAmount<=5000.0){
Double a1=totalAmount-2000.0;
count=2000.0+a1*0.5;
}else if(totalAmount>=5001.0&&totalAmount<=10000.0){
Double a1=totalAmount-5000.0;
count=2000.0+3000*0.5+a1*0.2;
}else if(totalAmount>=10001.0&&totalAmount<=30000.0){
Double a1=totalAmount-10000.0;
count=2000.0+3000*0.5+5000*0.2+a1*0.2;
}else if(totalAmount>=30001.0&&totalAmount<=50000.0){
Double a1=totalAmount-30000.0;
count=2000.0+3000*0.5+5000*0.2+20000*0.2+a1*0.15;
}else if(totalAmount>=50001.0&&totalAmount<=100000.0){
Double a1=totalAmount-50000.0;
count=2000.0+3000*0.5+5000*0.2+20000*0.2*2+a1*0.15;
}else if(totalAmount>=100001.0&&totalAmount<=300000.0){
Double a1=totalAmount-100000.0;
count=2000.0+3000*0.5+5000*0.2+20000*0.2*2+50000*0.15+a1*0.1;
}else if(totalAmount>=300001.0&&totalAmount<=500000.0){
Double a1=totalAmount-300000.0;
count=2000.0+3000*0.5+5000*0.2+20000*0.2*2+50000*0.15+200000*0.1+a1*0.05;
}else if(totalAmount>=500001.0&&totalAmount<=1000000.0){
Double a1=totalAmount-500000.0;
count=2000.0+3000*0.5+5000*0.2+20000*0.2*2+50000*0.15+200000*0.1*2+a1*0.02;
}else if(totalAmount>=1000001.0&&totalAmount<=3000000.0){
Double a1=totalAmount-1000000.0;
count=2000.0+3000*0.5+5000*0.2+20000*0.2*2+50000*0.15+200000*0.1*2+500000*0.02+a1*0.02;
}else if(totalAmount>=3000001.0&&totalAmount<=5000000.0){
Double a1=totalAmount-3000000.0;
count=2000.0+3000*0.5+5000*0.2+20000*0.2*2+50000*0.15+200000*0.1*2+500000*0.02+2000000*0.02+a1*0.02;
}
count=Double.valueOf(df.format(count));
baseSettlement.setTotalAmount(count);
baseSettlement.setSettlementAmount(Double.valueOf(df.format(count*0.5)));
count=0.0;
Double totalAdvertAmount = baseSettlement.getTotalAdvertAmount();
if(totalAdvertAmount<=2000.0){
count=totalAdvertAmount;
}else if(totalAdvertAmount>=2001.0&&totalAdvertAmount<=5000.0){
Double a1=totalAdvertAmount-2000.0;
count=2000.0+a1*0.5;
}else if(totalAdvertAmount>=5001.0&&totalAdvertAmount<=10000.0){
Double a1=totalAdvertAmount-5000.0;
count=2000.0+3000*0.5+a1*0.2;
}else if(totalAdvertAmount>=10001.0&&totalAdvertAmount<=30000.0){
Double a1=totalAdvertAmount-10000.0;
count=2000.0+3000*0.5+5000*0.2+a1*0.2;
}else if(totalAdvertAmount>=30001.0&&totalAdvertAmount<=50000.0){
Double a1=totalAdvertAmount-30000.0;
count=2000.0+3000*0.5+5000*0.2+20000*0.2+a1*0.15;
}else if(totalAdvertAmount>=50001.0&&totalAdvertAmount<=100000.0){
Double a1=totalAdvertAmount-50000.0;
count=2000.0+3000*0.5+5000*0.2+20000*0.2*2+a1*0.15;
}else if(totalAdvertAmount>=100001.0&&totalAdvertAmount<=300000.0){
Double a1=totalAdvertAmount-100000.0;
count=2000.0+3000*0.5+5000*0.2+20000*0.2*2+50000*0.15+a1*0.1;
}else if(totalAdvertAmount>=300001.0&&totalAdvertAmount<=500000.0){
Double a1=totalAdvertAmount-300000.0;
count=2000.0+3000*0.5+5000*0.2+20000*0.2*2+50000*0.15+200000*0.1+a1*0.05;
}else if(totalAdvertAmount>=500001.0&&totalAdvertAmount<=1000000.0){
Double a1=totalAdvertAmount-500000.0;
count=2000.0+3000*0.5+5000*0.2+20000*0.2*2+50000*0.15+200000*0.1*2+a1*0.02;
}else if(totalAdvertAmount>=1000001.0&&totalAdvertAmount<=3000000.0){
Double a1=totalAdvertAmount-1000000.0;
count=2000.0+3000*0.5+5000*0.2+20000*0.2*2+50000*0.15+200000*0.1*2+500000*0.02+a1*0.02;
}else if(totalAdvertAmount>=3000001.0&&totalAdvertAmount<=5000000.0){
Double a1=totalAdvertAmount-3000000.0;
count=2000.0+3000*0.5+5000*0.2+20000*0.2*2+50000*0.15+200000*0.1*2+500000*0.02+2000000*0.02+a1*0.02;
}
count=Double.valueOf(df.format(count));
Integer id = baseSettlement.getCopyrightId();
if(id==3219||id==3230||id==3254||id==3253){
count=Double.valueOf(df.format(baseSettlement.getTotalAmount()+count));
baseSettlement.setTotalAmount(count);
baseSettlement.setSettlementAmount(Double.valueOf(df.format(count*0.5)));
baseSettlement.setTotalAdvertAmount(0d);
baseSettlement.setSettlementAdAmount(0d);
}else {
baseSettlement.setTotalAdvertAmount(count);
baseSettlement.setSettlementAdAmount(Double.valueOf(df.format(count*0.5)));
}
baseSettlement.setCountSettlement(Double.valueOf(df.format(baseSettlement.getSettlementAmount()+baseSettlement.getSettlementAdAmount())));
}
Integer count = copyrightDao.selectBookDetailCount(baseSettlementList,bookId,bookName,startTime,endTime);
return PageTableHandler.getJSONObject(baseSettlements,count);
}
@Override
public String getAllCopyright() {
List<BaseSettlement> baseSettlements = copyrightDao.selectCopyrightById(UserUtil.getLoginUser().getId());
......
......@@ -87,38 +87,33 @@
</insert>
<select id="selectBookDetail" resultType="com.boot.security.server.model.BaseSettlement" parameterType="java.util.List">
select reportDate,copyright_id copyrightId,copyright_name copyrightName,book_id bookId,book_name bookName,authors,sum(total_amount) totalAmount,sum(total_ad_amount) totalAdvertAmount
from
(SELECT
DATE_FORMAT(a.report_date,'%Y-%m') reportDate,a.copyright_id,a.copyright_name,a.book_id,a.book_name,a.authors,a.total_amount
,ifnull(b.total_ad_amount,0) total_ad_amount
FROM report_book_settlement a
left join report_book_advert b
on a.report_date=b.report_date and a.book_id=b.book_id and a.batch_id=b.batch_id and a.batch_name=b.batch_name
select report_date reportDate,copyright_id copyrightId,copyright_name copyrightName,book_id bookId,book_name bookName,authors,total_amount totalAmount,total_ad_amount totalAdvertAmount
from bi_report.report_books_settlement_month a
WHERE
<![CDATA[
DATE_FORMAT(a.report_date,'%Y-%m') >= #{startTime} and DATE_FORMAT(a.report_date,'%Y-%m') <= #{endTime}
a.report_date>= #{startTime} and a.report_date <= #{endTime}
]]>
<if test="bookId != null and bookId!='' ">
and a.book_id = #{bookId}
and b.book_id = #{bookId}
</if>
<if test=" bookName != null and bookName !='' ">
and a.book_name like #{bookName}
and b.book_name like #{bookName}
</if>
<if test="copyrightId != null">
and a.copyright_id =#{copyrightId}
<if test="copyrightIdList != null">
and a.copyright_id in
<foreach collection="copyrightIdList" item="item" index="index" separator="," open="(" close=")">
#{item.copyrightId}
</foreach>
</if>
UNION
limit #{page},#{limit};
</select>
SELECT
DATE_FORMAT(a.report_date,'%Y-%m') reportDate,b.copyright_id,b.copyright_name,b.book_id,b.book_name,b.authors,IFNULL(a.total_amount,0) total_amount,IFNULL(b.total_ad_amount,0) total_ad_amount
FROM report_book_settlement a
RIGHT JOIN report_book_advert b
ON a.report_date=b.report_date AND a.book_id=b.book_id AND a.batch_id=b.batch_id AND a.batch_name=b.batch_name
WHERE b.jiesuan_ad_amount>0
<select id="selectBookDetailCount" resultType="Integer" parameterType="java.util.List">
select count(*)
from bi_report.report_books_settlement_month a
WHERE
<![CDATA[
and
DATE_FORMAT(b.report_date,'%Y-%m') >= #{startTime} and DATE_FORMAT(b.report_date,'%Y-%m') <= #{endTime}
a.report_date>= #{startTime} and a.report_date <= #{endTime}
]]>
<if test="bookId != null and bookId!='' ">
and b.book_id = #{bookId}
......@@ -126,10 +121,12 @@
<if test=" bookName != null and bookName !='' ">
and b.book_name like #{bookName}
</if>
<if test="copyrightId != null">
and a.copyright_id =#{copyrightId}
</if>) t
group BY t.reportDate,t.copyright_id,t.copyright_name,t.book_id,t.book_name,t.authors
<if test="copyrightIdList != null">
and a.copyright_id in
<foreach collection="copyrightIdList" item="item" index="index" separator="," open="(" close=")">
#{item.copyrightId}
</foreach>
</if>
</select>
</mapper>
\ No newline at end of file
......@@ -92,7 +92,7 @@
,method:'post'
,contentType:'application/json'
,where:{startTime:startTime,endTime:endTime}
,url: '/copyrightBookController/settlementMonth'
,url: '/copyrightBookController/settlementBookMonth'
,page: true
,toolbar:'true'
,defaultToolbar: ['exports']
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment