Procházet zdrojové kódy

#MOD 订单详情页统计

谭斌 před 2 roky
rodič
revize
9a3f394544

+ 32 - 5
device-api-service/src/main/java/com/xy/service/DeviceInfoServiceImpl.java

@@ -4,6 +4,7 @@ import cn.hutool.core.bean.BeanUtil;
 import cn.hutool.core.collection.CollUtil;
 import cn.hutool.core.collection.ListUtil;
 import cn.hutool.core.date.DatePattern;
+import cn.hutool.core.date.DateTime;
 import cn.hutool.core.date.DateUtil;
 import cn.hutool.core.text.StrBuilder;
 import cn.hutool.core.util.BooleanUtil;
@@ -26,7 +27,6 @@ import com.xy.error.CommRuntimeException;
 import com.xy.mapper.DeviceInfoMapper;
 import com.xy.mapper.entity.DeviceInfoQueryPage;
 import com.xy.util.ExcelUtils;
-import com.xy.util.FileUtils;
 import com.xy.utils.*;
 import com.xy.utils.enums.DeviceActiveStateEnum;
 import com.xy.utils.enums.DeviceNetSateType;
@@ -87,9 +87,10 @@ public class DeviceInfoServiceImpl extends ServiceImpl<DeviceInfoMapper, DeviceI
 
     private final GoodsService goodsService;
 
+    private final OrderRefundService refundService;
+
     private final String keyPrefix = "device:history:";
 
-    private final FileUtils fileUtils;
 
     @Override
     @ApiOperation("对象查询")
@@ -765,8 +766,27 @@ public class DeviceInfoServiceImpl extends ServiceImpl<DeviceInfoMapper, DeviceI
         DeviceInfoDto.DeviceDataCountVO vo = new DeviceInfoDto.DeviceDataCountVO();
         //当天
         DeviceDataDto.Vo dayData = deviceDataService.getByDay(deviceId, mercId, DateUtil.format(new Date(), DatePattern.PURE_DATE_PATTERN));
+
+        //今日退款成功订单金额
+        OrderRefundDto.CountByDateVO countByDateVO = R.feignCheckData(
+                refundService.countByDate(new OrderRefundDto.CountByDateDTO()
+                        .setDate(DateTime.now())
+                        .setMercId(mercId).setDeviceId(deviceId)));
+        Integer hisRefundMoney = countByDateVO.getHisRefundMoney();
+        Integer todayRefundMoney = countByDateVO.getTodayRefundMoney();
+        //今日销售额 (扣除今日的订单的退款金额)
+        dayData.setSalesMoney(dayData.getSalesMoney() - todayRefundMoney);
+        dayData.setRefundMoney(hisRefundMoney + todayRefundMoney);
+
         //当月
         DeviceDataDto.Vo monthData = deviceDataService.getByMonth(deviceId, mercId, DateUtil.format(new Date(), DatePattern.SIMPLE_MONTH_PATTERN));
+        OrderRefundDto.CountByMonthVO countByMonthVO = R.feignCheckData(refundService.countByMonth(new OrderRefundDto.CountByMonthDTO().setCurMonthDate(DateTime.now()).setMercId(mercId).setDeviceId(deviceId)));
+        Integer hisMonthRefundMoney = countByMonthVO.getHisMonthRefundMoney();
+        Integer monthRefundMoney = countByMonthVO.getMonthRefundMoney();
+        monthData.setRefundMoney(hisMonthRefundMoney + monthRefundMoney);
+        monthData.setSalesMoney(monthData.getSalesMoney() - monthRefundMoney);
+
+
         vo.setDayBusinessData(copy(DeviceInfoDto.BusinessData.class, dayData));
         vo.setMonthBusinessData(copy(DeviceInfoDto.BusinessData.class, monthData));
         return vo;
@@ -977,8 +997,7 @@ public class DeviceInfoServiceImpl extends ServiceImpl<DeviceInfoMapper, DeviceI
     private DeviceInfoDto.DeviceDataCountVO dataCount5(DeviceInfoDto.DeviceDataCountDTO dto) {
         Long deviceId = dto.getDeviceId();
         DeviceInfoDto.DeviceDataCountVO vo = new DeviceInfoDto.DeviceDataCountVO();
-        DeviceStatus deviceStatus = deviceStatusService.getById(dto.getDeviceId());
-        DeviceInfoDto.GoodsData goodsData = copy(DeviceInfoDto.GoodsData.class, deviceStatus);
+        DeviceInfoDto.GoodsData goodsData = new DeviceInfoDto.GoodsData();
         //在售商品种类
         //根据设备ID查商品id
         GoodsDeviceDto.SelectList selectList = new GoodsDeviceDto.SelectList();
@@ -986,7 +1005,15 @@ public class DeviceInfoServiceImpl extends ServiceImpl<DeviceInfoMapper, DeviceI
         selectList.setMercId(dto.getMercId());
         R<List<GoodsDeviceDto.Vo>> r = R.feignCheck(goodsDeviceService.list(selectList));
         List<GoodsDeviceDto.Vo> goodsDeviceList = r.getData();
-        goodsData.setCategoryNum(CollUtil.isNotEmpty(goodsDeviceList) ? goodsDeviceList.size() : 0);
+        Integer stock = 0;
+        Integer afterFillStock = 0;
+        if (CollUtil.isNotEmpty(goodsDeviceList)) {
+            stock = goodsDeviceList.stream().mapToInt(GoodsDeviceDto.Vo::getStock).sum();
+            afterFillStock = goodsDeviceList.stream().mapToInt(GoodsDeviceDto.Vo::getFillCount).sum();
+        }
+        goodsData.setAfterFillStock(afterFillStock);
+        goodsData.setStock(stock);
+        goodsData.setCategoryNum(CollUtil.isNotEmpty(goodsDeviceList) ? goodsDeviceList.size() : new Integer(0));
         vo.setGoodsData(goodsData);
         return vo;
     }

+ 0 - 0
device-api-service-merc-mini/src/main/java/com/xy/dto/MercMiniDeviceDto.java → device-api/src/main/java/com/xy/dto/MercMiniDeviceDto.java