
7 changed files with 266 additions and 3 deletions
@ -0,0 +1,110 @@ |
|||
package com.yxt.supervise.report.biz.salesstatisticsday; |
|||
|
|||
|
|||
import com.baomidou.mybatisplus.annotation.TableName; |
|||
import com.fasterxml.jackson.annotation.JsonFormat; |
|||
import com.yxt.common.core.domain.EntityWithId; |
|||
|
|||
import java.util.Date; |
|||
|
|||
@TableName("report_sales_statistics_day") |
|||
public class ReportSalesStatisticsDay extends EntityWithId { |
|||
public ReportSalesStatisticsDay() { |
|||
} |
|||
|
|||
public ReportSalesStatisticsDay(String orderDate) { |
|||
this.orderDate = orderDate; |
|||
} |
|||
|
|||
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8") |
|||
private Date createTime = new Date(); // 记录创建时间
|
|||
private String remarks; // 备注说明
|
|||
private String orderDate; // 单据日期
|
|||
private double zydAmount = 0; // 直营店金额
|
|||
private double pifaAmount = 0; // 批发金额
|
|||
private double jmdAmount = 0; // 加盟店金额
|
|||
private double countAmount = 0; // 合计金额
|
|||
private int uploadRk = 0; // 是否上传了入库数据,0:无,1:有
|
|||
private int uploadPf = 0; // 是否上传了批发数据,0:无,1:有
|
|||
private int uploadXs = 0; // 是否上传了销售数据,0:无,1:有
|
|||
|
|||
public Date getCreateTime() { |
|||
return createTime; |
|||
} |
|||
|
|||
public void setCreateTime(Date createTime) { |
|||
this.createTime = createTime; |
|||
} |
|||
|
|||
public String getRemarks() { |
|||
return remarks; |
|||
} |
|||
|
|||
public void setRemarks(String remarks) { |
|||
this.remarks = remarks; |
|||
} |
|||
|
|||
public String getOrderDate() { |
|||
return orderDate; |
|||
} |
|||
|
|||
public void setOrderDate(String orderDate) { |
|||
this.orderDate = orderDate; |
|||
} |
|||
|
|||
public double getZydAmount() { |
|||
return zydAmount; |
|||
} |
|||
|
|||
public void setZydAmount(double zydAmount) { |
|||
this.zydAmount = zydAmount; |
|||
} |
|||
|
|||
public double getPifaAmount() { |
|||
return pifaAmount; |
|||
} |
|||
|
|||
public void setPifaAmount(double pifaAmount) { |
|||
this.pifaAmount = pifaAmount; |
|||
} |
|||
|
|||
public double getJmdAmount() { |
|||
return jmdAmount; |
|||
} |
|||
|
|||
public void setJmdAmount(double jmdAmount) { |
|||
this.jmdAmount = jmdAmount; |
|||
} |
|||
|
|||
public double getCountAmount() { |
|||
return countAmount; |
|||
} |
|||
|
|||
public void setCountAmount(double countAmount) { |
|||
this.countAmount = countAmount; |
|||
} |
|||
|
|||
public int getUploadRk() { |
|||
return uploadRk; |
|||
} |
|||
|
|||
public void setUploadRk(int uploadRk) { |
|||
this.uploadRk = uploadRk; |
|||
} |
|||
|
|||
public int getUploadPf() { |
|||
return uploadPf; |
|||
} |
|||
|
|||
public void setUploadPf(int uploadPf) { |
|||
this.uploadPf = uploadPf; |
|||
} |
|||
|
|||
public int getUploadXs() { |
|||
return uploadXs; |
|||
} |
|||
|
|||
public void setUploadXs(int uploadXs) { |
|||
this.uploadXs = uploadXs; |
|||
} |
|||
} |
@ -0,0 +1,28 @@ |
|||
package com.yxt.supervise.report.biz.salesstatisticsday; |
|||
|
|||
import com.baomidou.mybatisplus.core.mapper.BaseMapper; |
|||
import org.apache.ibatis.annotations.Mapper; |
|||
import org.apache.ibatis.annotations.Param; |
|||
import org.apache.ibatis.annotations.Select; |
|||
|
|||
@Mapper |
|||
public interface ReportSalesStatisticsDayMapper extends BaseMapper<ReportSalesStatisticsDay> { |
|||
|
|||
@Select("select " + |
|||
"CONVERT(IFNULL(sum(colq16),0),DECIMAL(12,2)) as amount " + |
|||
"from gd_instorage_gd gi left join store_index si on gi.colb1=si.code " + |
|||
"where gi.orderDate=#{orderDate} and (si.`type` ='连锁外加盟(销配结算)' OR si.`type` ='连锁外加盟(销配结算)' )") |
|||
double sumSaleAmountJmd(@Param("orderDate") String day); |
|||
|
|||
@Select("select " + |
|||
" CONVERT(IFNULL(sum(saleNum*salePrice),0),DECIMAL(12,2)) as amount " + |
|||
"from gd_sales_gd gs " + |
|||
"where gs.dataDate=#{orderDate} ") |
|||
double sumSaleAmountZyd(@Param("orderDate") String day); |
|||
|
|||
@Select("select " + |
|||
" CONVERT(IFNULL(sum(saleNum*salePrice),0),DECIMAL(12,2)) as amount " + |
|||
"from gd_wholesale_gd gwg " + |
|||
"where gwg.dataDate=#{orderDate} ") |
|||
double sumSaleAmountPf(@Param("orderDate") String day); |
|||
} |
@ -0,0 +1,50 @@ |
|||
package com.yxt.supervise.report.biz.salesstatisticsday; |
|||
|
|||
import cn.hutool.core.date.DateTime; |
|||
import cn.hutool.core.date.DateUtil; |
|||
import cn.hutool.core.util.StrUtil; |
|||
import com.yxt.common.core.result.ResultBean; |
|||
import org.springframework.beans.factory.annotation.Autowired; |
|||
import org.springframework.web.bind.annotation.GetMapping; |
|||
import org.springframework.web.bind.annotation.RequestMapping; |
|||
import org.springframework.web.bind.annotation.RequestParam; |
|||
import org.springframework.web.bind.annotation.RestController; |
|||
|
|||
import java.util.Date; |
|||
import java.util.List; |
|||
|
|||
@RestController("com.yxt.supervise.report.biz.salesstatisticsday.ReportSalesStatisticsDayRest") |
|||
@RequestMapping("/sales/statistics/day") |
|||
public class ReportSalesStatisticsDayRest { |
|||
|
|||
@Autowired |
|||
private ReportSalesStatisticsDayService reportSalesStatisticsDayService; |
|||
|
|||
@GetMapping("/countForDay") |
|||
public ResultBean<ReportSalesStatisticsDay> countForDay(@RequestParam("day") String day) { |
|||
ResultBean rb = ResultBean.fireFail(); |
|||
if (StrUtil.isBlank(day)) |
|||
return rb.setMsg("必须指定日期"); |
|||
try { |
|||
DateTime parse = DateUtil.parse(day, "yyyy-MM-dd"); |
|||
if (parse.isAfterOrEquals(new Date())) { |
|||
return rb.setMsg("只能统计之前日期"); |
|||
} |
|||
} catch (Exception e) { |
|||
e.printStackTrace(); |
|||
return rb.setMsg("日期格式不正确"); |
|||
} |
|||
|
|||
ReportSalesStatisticsDay reportSalesStatisticsDay = reportSalesStatisticsDayService.countForDay(day); |
|||
return rb.success().setData(reportSalesStatisticsDay); |
|||
} |
|||
|
|||
|
|||
@GetMapping("/listOneMonth") |
|||
public ResultBean<List<ReportSalesStatisticsDay>> listOneMonth() { |
|||
ResultBean rb = ResultBean.fireFail(); |
|||
List<ReportSalesStatisticsDay> list = reportSalesStatisticsDayService.ReportSalesStatisticsDay(null); |
|||
return rb.success().setData(list); |
|||
} |
|||
|
|||
} |
@ -0,0 +1,50 @@ |
|||
package com.yxt.supervise.report.biz.salesstatisticsday; |
|||
|
|||
import cn.hutool.core.date.DateUtil; |
|||
import cn.hutool.core.util.StrUtil; |
|||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
|||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; |
|||
import com.yxt.common.core.result.ResultBean; |
|||
import org.springframework.stereotype.Service; |
|||
|
|||
import java.util.Date; |
|||
import java.util.List; |
|||
|
|||
@Service |
|||
public class ReportSalesStatisticsDayService extends ServiceImpl<ReportSalesStatisticsDayMapper, ReportSalesStatisticsDay> { |
|||
|
|||
public ReportSalesStatisticsDay countForDay(String day) { |
|||
|
|||
ReportSalesStatisticsDay rssd = fetchByDay(day); |
|||
if (rssd == null) |
|||
rssd = new ReportSalesStatisticsDay(day); |
|||
|
|||
double jmd = baseMapper.sumSaleAmountJmd(day); |
|||
rssd.setJmdAmount(jmd); |
|||
double zyd = baseMapper.sumSaleAmountZyd(day); |
|||
rssd.setZydAmount(zyd); |
|||
double pf = baseMapper.sumSaleAmountPf(day); |
|||
rssd.setPifaAmount(pf); |
|||
rssd.setCountAmount(jmd + zyd + pf); |
|||
|
|||
this.saveOrUpdate(rssd); |
|||
return rssd; |
|||
|
|||
} |
|||
|
|||
public ReportSalesStatisticsDay fetchByDay(String day) { |
|||
QueryWrapper<ReportSalesStatisticsDay> qw = new QueryWrapper<>(); |
|||
qw.eq("orderDate", day); |
|||
return baseMapper.selectOne(qw); |
|||
} |
|||
|
|||
public List<ReportSalesStatisticsDay> ReportSalesStatisticsDay(String endDay) { |
|||
if (StrUtil.isBlank(endDay)) |
|||
endDay = DateUtil.format(new Date(), "yyyy-MM-dd"); |
|||
QueryWrapper<ReportSalesStatisticsDay> qw = new QueryWrapper<>(); |
|||
qw.lt("orderDate", endDay); |
|||
qw.orderByDesc("orderDate"); |
|||
qw.last("limit 30"); |
|||
return baseMapper.selectList(qw); |
|||
} |
|||
} |
Loading…
Reference in new issue