doum
13 小时以前 fbdbb67c9de7a99398b5776435abb69352a11845
经销商管理
已添加1个文件
已修改6个文件
180 ■■■■ 文件已修改
admin/src/api/business/workbench.js 7 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
admin/src/views/index.vue 27 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
server/dmmall_admin/src/main/java/com/doumee/api/business/WorkbenchController.java 1 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
server/dmmall_service/src/main/java/com/doumee/dao/business/model/GoodsorderDetail.java 3 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
server/dmmall_service/src/main/java/com/doumee/dao/system/vo/BusinessDataCountVO.java 6 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
server/dmmall_service/src/main/java/com/doumee/dao/system/vo/CountDataVO.java 2 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
server/dmmall_service/src/main/java/com/doumee/service/business/impl/WorkbenchServiceImpl.java 134 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
admin/src/api/business/workbench.js
¶Ô±ÈÐÂÎļþ
@@ -0,0 +1,7 @@
import request from '../../utils/request'
export function allList (data) {
  return request.post('/business/workbench/businessData', data, {
    trim: true
  })
}
admin/src/views/index.vue
@@ -145,9 +145,9 @@
  },
  data () {
    return {
      tabs2: [{ index: 0, name: '按销量' }, { index: 1, name: '按销售额' } ],
      tabs2: [{ index: 0, name: '按销量' }, { index: 1, name: '按销售额'}],
      tabs1: [{ index: 0, name: '按订单量' }, { index: 1, name: '按销售额' }, { index: 2, name: '按会员数' }],
      tabs: [{ index: 0, name: '今日' }, { index: 1, name: '近7日' }, { index: 2, name: '近30日' }, { index: 3, name: '近1å¹´' }],
      tabs: [{ index: 0, name: '今日' }, { index: 1, name: '近7日' }, { index: 2, name: '近30日' }, { index: 3, name: '近12月' }],
      tabName: '今日',
      tabIndex: 0,
      tabIndex1: 0,
@@ -156,6 +156,9 @@
        topYear:null,
        topMonth:null,
        topYear2:null,
      },
      topData:{
      },
      countData: {
        totalPrice: 1000,
@@ -170,6 +173,14 @@
      myChart0: null,
      myChart1: null
    }
  },
  created () {
    this.config({
      module: '工作台数据统计',
      api: '/business/workbench',
      'field.id': 'id',
      'field.main': 'id'
    })
  },
  mounted () {
    this.initCountData()
@@ -228,18 +239,6 @@
          data: this.orderCorderCount
        }]
      })
    },
    changeCount (page) {
      if (page == 7) {
        this.orderCorderCount = [10, 10, 20, 10, 40, 10, 30]
        this.opinionData = ['3.20', '3.21', '3.22', '3.23', '3.24', '3.25', '3.26']
      } else {
        this.orderCorderCount = [11, 10, 20, 10, 40, 10, 30, 20, 10, 20, 10, 40, 10, 30, 10, 10, 20, 10, 40, 10, 30, 10, 10, 20, 10, 40, 10, 30, 20, 40]
        this.opinionData = ['3.01', '3.02', '3.03', '3.04', '3.05', '3.06', '3.07', '3.08', '3.09', '3.10', '3.11', '3.12', '3.13', '3.14', '3.15', '3.16', '3.17', '3.18', '3.19', '3.20', '3.21', '3.22', '3.23', '3.24', '3.25', '3.26', '3.27', '3.28', '3.28', '3.30']
      }
      // this.orderCorderCount.push(1)
      // this.opinionData.push(1)
      this.renderOrderChange()
    }
  }
}
server/dmmall_admin/src/main/java/com/doumee/api/business/WorkbenchController.java
@@ -30,7 +30,6 @@
    @PreventRepeat
    @ApiOperation("新建")
    @PostMapping("/businessData")
    @RequiresPermissions("business:fund:create")
    public ApiResponse<BusinessDataCountVO> create(@RequestBody CountDataDTO param) {
        return ApiResponse.success(workbenchService.businessData(param));
    }
server/dmmall_service/src/main/java/com/doumee/dao/business/model/GoodsorderDetail.java
@@ -55,6 +55,9 @@
    @ApiModelProperty(value = "订单编码(关联goodsorder表)", example = "1")
    @ExcelColumn(name="订单编码(关联goodsorder表)")
    private Integer orderId;
    @ApiModelProperty(value = "商品编码(gooods表)", example = "1")
    @ExcelColumn(name="商品编码(gooods表)")
    private Integer goodsId;
    @ApiModelProperty(value = "SKU列表图")
    @ExcelColumn(name="SKU列表图")
server/dmmall_service/src/main/java/com/doumee/dao/system/vo/BusinessDataCountVO.java
@@ -14,7 +14,7 @@
    @ApiModelProperty(value = "统计数量(订单数、销量、消耗积分量)")
    private Long num;
    @ApiModelProperty(value = "统计数量2 (会员数)")
    private Long num2;
    private Long num1;
    @ApiModelProperty(value = "销售额,优惠金额")
    private BigDecimal price;
    @ApiModelProperty(value = "销售额,促成交易金额金额")
@@ -25,4 +25,8 @@
    private List<CountDataVO> dataList;
    @ApiModelProperty(value = "统计列表数据2")
    private List<CountDataVO> dataList2;
    @ApiModelProperty(value = "统计列表数据分类2")
    private List<String>  cateList;
    @ApiModelProperty(value = "统计列表数据3")
    private List<BigDecimal[]> numList;
}
server/dmmall_service/src/main/java/com/doumee/dao/system/vo/CountDataVO.java
@@ -24,4 +24,6 @@
    private BigDecimal price1;
    @ApiModelProperty(value = "统计维度名称")
    private String name;
    @ApiModelProperty(value = "统计维度时间名称")
    private String dateStr;
}
server/dmmall_service/src/main/java/com/doumee/service/business/impl/WorkbenchServiceImpl.java
@@ -35,6 +35,7 @@
import org.apache.commons.collections4.MapUtils;
import org.apache.commons.lang3.StringUtils;
import org.apache.shiro.SecurityUtils;
import org.checkerframework.checker.units.qual.C;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.ApplicationEventPublisher;
@@ -57,33 +58,148 @@
public class WorkbenchServiceImpl implements WorkbenchService {
    @Autowired
    private GoodsorderMapper goodsorderMapper;
    @Autowired
    private GoodsorderDetailMapper goodsorderDetailMapper;
    @Override
    public BusinessDataCountVO businessData(CountDataDTO param) {
        BusinessDataCountVO data = new BusinessDataCountVO();
        int dataType = param.getDateType();//0今日 1近七日 2近30日 3近1å¹´
        int days = 1;
        String name = "HOUR(CREATE_DATE)";
        List<String> dateList = new ArrayList<>();
        Date date = Utils.Date.getEnd(new Date());//今日 23:59:59
        Date startDate = DateUtil.addDaysToDate(date,-1);
        switch (dataType) {
            case 1: {
                days = 7;
                name = "DATE_FORMAT(t.CREATE_DATE, '%Y-%m-%d')";
                for(int i=1;i<=7;i++){
                    dateList.add(DateUtil.getPlusTime2(DateUtil.addDaysToDate(date,7-i)));
                }
                startDate = DateUtil.addDaysToDate(date,7);
                break;
            } case 2: {
                days =30;
                name = "DATE_FORMAT(GoodsCREATE_DATE, '%Y-%m-%d')";
                for(int i=1;i<=30;i++){
                    dateList.add(DateUtil.getPlusTime2(DateUtil.addDaysToDate(date,30-i)));
                }
                startDate = DateUtil.addDaysToDate(date,30);
                break;
            } case 3: {
                days = 365;
                startDate = DateUtil.increaseMonth(date,-12);
                name = "DATE_FORMAT(GoodsCREATE_DATE, '%Y-%m')";
                for(int i=1;i<=12;i++){
                    dateList.add(DateUtil.getPlusTime2(DateUtil.increaseMonth(date,12-i)));
                }
                break;
            } default:{
                for(int i=0;i<=23;i++){
                    dateList.add(i+"");
                }
                break;
            }
        }
        Date startDate = DateUtil.addDaysToDate(Utils.Date.getStart(new Date()),-days);
        CountDataVO r=   goodsorderMapper.selectJoinOne(CountDataVO.class,new MPJLambdaWrapper<Goodsorder>()
        //订单销量
        CountDataVO r =  goodsorderMapper.selectJoinOne(CountDataVO.class,new MPJLambdaWrapper<Goodsorder>()
                        .select("(select count(t.id) )",CountDataVO::getNum)
                        .select("(select sum(t.totalPrice) )",CountDataVO::getPrice)
                .ge(Goodsorder::getCreateDate,startDate)
                .in(Goodsorder::getStatus,Constants.OrderStatus.DONE.getKey(),Constants.OrderStatus.DONE.getKey())
                );
                .eq(Goodsorder::getIsdeleted,Constants.ZERO)
                .in(Goodsorder::getStatus,Constants.OrderStatus.DONE.getKey(),Constants.OrderStatus.REFUND.getKey()) );
        if (r != null) {
            data.setNum(Constants.formatLongNum(r.getNum()));//订单量
            data.setPrice(Constants.formatBigdecimal(r.getPrice()));//订单金额
        }
        //退款统计
        CountDataVO r1 =  goodsorderMapper.selectJoinOne(CountDataVO.class,new MPJLambdaWrapper<Goodsorder>()
                        .select("(select count(t.id) )",CountDataVO::getNum)
                        .select("(select sum(t.reundMoney) )",CountDataVO::getPrice)
                .ge(Goodsorder::getRefundTime,startDate)
                .eq(Goodsorder::getIsdeleted,Constants.ZERO)
                .in(Goodsorder::getStatus,Constants.OrderStatus.REFUND.getKey())  );
        if (r1 != null) {
            data.setNum1(Constants.formatLongNum(r1.getNum()));//退款单量
            data.setPrice1(Constants.formatBigdecimal(r1.getPrice()));//退款金额
        }
        //统计订单销量和销售额集合
        List<CountDataVO> list1 =  goodsorderMapper.selectJoinList(CountDataVO.class,new MPJLambdaWrapper<Goodsorder>()
                .select("(select "+name+")",CountDataVO::getDateStr)
                .select("(select count(t.id) )",CountDataVO::getNum)
                .select("(select sum(t.totalPrice) )",CountDataVO::getPrice)
                .ge(Goodsorder::getRefundTime,startDate)
                .eq(Goodsorder::getIsdeleted,Constants.ZERO)
                .in(Goodsorder::getStatus,Constants.OrderStatus.DONE.getKey(),Constants.OrderStatus.REFUND.getKey())
                .groupBy(name) );
        List<CountDataVO> datalist1 = new ArrayList<>();
        for(String str : dateList){
            CountDataVO tmp = new CountDataVO();
            tmp.setDateStr(str);
            tmp.setNum(0l);
            tmp.setPrice(new BigDecimal(0));
            if(list1!=null){
                for(CountDataVO p : list1){
                    if(StringUtils.equals(p.getDateStr(),str)){
                        tmp.setNum(Constants.formatLongNum(p.getNum()));
                        tmp.setPrice(Constants.formatBigdecimal(p.getPrice()));
                    }
                }
            }
            datalist1.add(tmp);
        }
        data.setDataList(datalist1 );
        //统计各类商品数据集合
        List<CountDataVO> list2 =  goodsorderDetailMapper.selectJoinList(CountDataVO.class,new MPJLambdaWrapper<GoodsorderDetail>()
                .select("(select "+name+")",CountDataVO::getDateStr)
                .selectAs(Labels::getName,CountDataVO::getName)
                .select("(select sum(t.totalPrice) )",CountDataVO::getPrice)
                 .leftJoin(Goods.class,Goods::getId,GoodsorderDetail::getGoodsId)
                 .leftJoin(Labels.class,Labels::getId,Goods::getCategoryId)
                 .leftJoin(Goodsorder.class,Goodsorder::getId,GoodsorderDetail::getOrderId)
                .ge(Goodsorder::getRefundTime,startDate)
                .eq(Goodsorder::getIsdeleted,Constants.ZERO)
                .in(Goodsorder::getStatus,Constants.OrderStatus.DONE.getKey(),Constants.OrderStatus.REFUND.getKey())
                .groupBy(name +",t2.category_id"));
        List<BigDecimal[]> datalist2 = new ArrayList<>();
        List<String> cateList = getCateListFromDataList(list2);
        if(list2!=null &&list2.size()>0 && cateList!=null && cateList.size()>0){
            BigDecimal[] temp = new BigDecimal[dateList.size()];
            for(String cate : cateList){
                for(int i=0;i<dateList.size();i++){
                    temp[i] = new BigDecimal(0);
                    for(CountDataVO model : list2){
                        if(StringUtils.equals(model.getDateStr(),dateList.get(i)) && StringUtils.equals(model.getName(),cate)){
                            temp[i] = temp[i].add(Constants.formatBigdecimal(model.getPrice()));
                        }
                    }
                }
                datalist2.add(temp);
            }
        }
        data.setCateList(cateList);
        data.setNumList(datalist2 );
        return data;
    }
    private List<String> getCateListFromDataList(List<CountDataVO> list2) {
        List<String> list = new ArrayList<>();
        for(CountDataVO model :list2){
            boolean isnew = true;
            for(String str :list){
                if(StringUtils.equals(str,model.getName())){
                    isnew = false;
                }
            }
            if(isnew ){
                list.add(model.getName());
            }
        }
        return list;
    }
}