| | |
| | | @PostMapping(value = "/profitDetails") |
| | | public AjaxResult<ProfitDetailsVO> profitDetails(@RequestBody ProfitDetailsQuery query) { |
| | | Long objectId = tokenService.getLoginUser().getObjectId(); |
| | | Integer roleType = tokenService.getLoginUser().getRoleType(); |
| | | query.setShopId(objectId); |
| | | if(StringUtils.isEmpty(query.getStartTime()) && StringUtils.isEmpty(query.getEndTime())){ |
| | | if(Objects.nonNull(query.getTimeType())){ |
| | |
| | | query.setEndTime(DateUtils.localDateTimeToDate(endTime)); |
| | | } |
| | | } |
| | | return AjaxResult.success(orderMealService.profitDetails(query)); |
| | | ProfitDetailsVO profitDetailsVO; |
| | | if(roleType.equals(2)){ |
| | | profitDetailsVO = orderMealService.profitDetails(query); |
| | | }else { |
| | | profitDetailsVO = orderSaleService.profitDetails(query); |
| | | } |
| | | return AjaxResult.success(profitDetailsVO); |
| | | } |
| | | |
| | | @ApiOperation( value = "盈利明细导出") |
| | | @PostMapping(value = "/profitDetailsExport") |
| | | public void profitDetailsExport(@RequestBody ProfitDetailsQuery query) { |
| | | Long objectId = tokenService.getLoginUser().getObjectId(); |
| | | Integer roleType = tokenService.getLoginUser().getRoleType(); |
| | | query.setShopId(objectId); |
| | | if(StringUtils.isEmpty(query.getStartTime()) && StringUtils.isEmpty(query.getEndTime())){ |
| | | |
| | |
| | | query.setEndTime(DateUtils.localDateTimeToDate(endTime)); |
| | | } |
| | | } |
| | | List<GoodsProfitVO> list = orderMealService.profitDetailsExport(query); |
| | | List<GoodsProfitVO> list; |
| | | if(roleType.equals(2)){ |
| | | list = orderMealService.profitDetailsExport(query); |
| | | }else { |
| | | list = orderSaleService.profitDetailsExport(query); |
| | | } |
| | | Workbook workbook = ExcelExportUtil.exportExcel(new ExportParams(), GoodsProfitVO.class, list); |
| | | HttpServletResponse response = WebUtils.response(); |
| | | response.setContentType("application/vnd.ms-excel"); |
| | |
| | | Integer roleType = tokenService.getLoginUser().getRoleType(); |
| | | Long objectId = tokenService.getLoginUser().getObjectId(); |
| | | query.setShopId(objectId); |
| | | if(StringUtils.isEmpty(query.getStartTime()) && StringUtils.isEmpty(query.getEndTime())){ |
| | | |
| | | if(Objects.isNull(query.getTimeType())){ |
| | | query.setTimeType(3); |
| | | } |
| | |
| | | } |
| | | query.setStartTime(DateUtils.localDateTimeToDate(startTime)); |
| | | query.setEndTime(DateUtils.localDateTimeToDate(endTime)); |
| | | } |
| | | List<OrderTrendsVO> orderTrendsVOS; |
| | | if(roleType == 2){ |
| | | orderTrendsVOS = orderMealService.orderingTrends(query); |
| | |
| | | List<PersonnelStatisticsVO> personnelStatisticsVOS = orderMealService.personnelStatistics(query); |
| | | personnelStatisticsAndSumVO.setPersonnelStatisticsVOS(personnelStatisticsVOS); |
| | | if(!CollectionUtils.isEmpty(personnelStatisticsVOS)){ |
| | | personnelStatisticsAndSumVO.setPersonCountSum(personnelStatisticsVOS.stream().filter(e->e.getPersonCount() != null).mapToInt(PersonnelStatisticsVO::getPersonCount).sum()); |
| | | int sum = personnelStatisticsVOS.stream().filter(e -> e.getPersonCount() != null).mapToInt(PersonnelStatisticsVO::getPersonCount).sum(); |
| | | personnelStatisticsAndSumVO.setPersonCountSum(sum); |
| | | // 计算列表中平均金额乘以人数的总和 |
| | | personnelStatisticsAndSumVO.setTotalMoney(personnelStatisticsVOS.stream().filter(e->e.getPersonCount() != null).mapToDouble(personnelStatisticsVO -> personnelStatisticsVO.getAvgAmount().doubleValue() * personnelStatisticsVO.getPersonCount()).sum()); |
| | | personnelStatisticsAndSumVO.setTotalMoney(personnelStatisticsVOS.stream().filter(e->e.getPersonCount() != null).mapToDouble(personnelStatisticsVO -> (personnelStatisticsVO.getAvgAmount().doubleValue() * personnelStatisticsVO.getPersonCount()) / sum).sum()); |
| | | } |
| | | return AjaxResult.success(personnelStatisticsAndSumVO); |
| | | } |
| | |
| | | import com.baomidou.mybatisplus.core.toolkit.Wrappers; |
| | | import com.ruoyi.common.basic.PageInfo; |
| | | import com.ruoyi.common.core.domain.AjaxResult; |
| | | import com.ruoyi.common.utils.CodeGenerateUtils; |
| | | import com.ruoyi.common.utils.bean.BeanUtils; |
| | | import com.ruoyi.framework.web.service.TokenService; |
| | | import com.ruoyi.system.domain.TGoods; |
| | | import com.ruoyi.system.domain.TGoodsType; |
| | | import com.ruoyi.system.domain.*; |
| | | import com.ruoyi.system.query.TGoodsQuery; |
| | | import com.ruoyi.system.service.TGoodsService; |
| | | import com.ruoyi.system.service.TGoodsTypeService; |
| | | import com.ruoyi.system.service.*; |
| | | import com.ruoyi.system.vo.TGoodsVO; |
| | | import io.swagger.annotations.Api; |
| | | import io.swagger.annotations.ApiOperation; |
| | |
| | | private final TGoodsService goodsService; |
| | | private final TGoodsTypeService goodsTypeService; |
| | | private final TokenService tokenService; |
| | | private final TOrderStockGoodsService orderStockGoodsService; |
| | | private final TOrderSaleGoodsService orderSaleGoodsService; |
| | | private final TOrderMealGoodsService orderMealGoodsService; |
| | | |
| | | @Autowired |
| | | public TGoodsController(TGoodsService goodsService, TGoodsTypeService goodsTypeService, TokenService tokenService) { |
| | | public TGoodsController(TGoodsService goodsService, TGoodsTypeService goodsTypeService, TokenService tokenService, TOrderStockGoodsService orderStockGoodsService, TOrderSaleGoodsService orderSaleGoodsService, TOrderMealGoodsService orderMealGoodsService) { |
| | | this.goodsService = goodsService; |
| | | this.goodsTypeService = goodsTypeService; |
| | | this.tokenService = tokenService; |
| | | this.orderStockGoodsService = orderStockGoodsService; |
| | | this.orderSaleGoodsService = orderSaleGoodsService; |
| | | this.orderMealGoodsService = orderMealGoodsService; |
| | | } |
| | | |
| | | /** |
| | |
| | | @PostMapping(value = "/add") |
| | | public AjaxResult<Boolean> add(@RequestBody TGoods dto) { |
| | | dto.setShopId(tokenService.getLoginUser().getObjectId()); |
| | | dto.setGoodsNum(CodeGenerateUtils.generateVolumeSn()); |
| | | return AjaxResult.success(goodsService.save(dto)); |
| | | } |
| | | |
| | |
| | | @ApiOperation( value = "修改商品管理") |
| | | @PostMapping(value = "/update") |
| | | public AjaxResult<Boolean> update(@RequestBody TGoods dto) { |
| | | // 判断是否修改了名称 |
| | | TGoods goods = goodsService.getById(dto.getId()); |
| | | if(!goods.getGoodsName().equals(dto.getGoodsName())){ |
| | | List<TOrderStockGoods> orderStockGoods = orderStockGoodsService.list(Wrappers.lambdaQuery(TOrderStockGoods.class) |
| | | .eq(TOrderStockGoods::getGoodsNum, goods.getGoodsNum())); |
| | | orderStockGoods.stream().forEach(tOrderStockGoods -> tOrderStockGoods.setGoodsNum(dto.getGoodsNum())); |
| | | orderStockGoodsService.updateBatchById(orderStockGoods); |
| | | |
| | | List<TOrderMealGoods> orderMealGoods = orderMealGoodsService.list(Wrappers.lambdaQuery(TOrderMealGoods.class) |
| | | .eq(TOrderMealGoods::getGoodsNum, goods.getGoodsNum())); |
| | | orderMealGoods.stream().forEach(tOrderMealGoods -> tOrderMealGoods.setGoodsNum(dto.getGoodsNum())); |
| | | orderMealGoodsService.updateBatchById(orderMealGoods); |
| | | |
| | | List<TOrderSaleGoods> list = orderSaleGoodsService.list(Wrappers.lambdaQuery(TOrderSaleGoods.class) |
| | | .eq(TOrderSaleGoods::getGoodsNum, goods.getGoodsNum())); |
| | | list.stream().forEach(tOrderSaleGoods -> tOrderSaleGoods.setGoodsNum(dto.getGoodsNum())); |
| | | orderSaleGoodsService.updateBatchById(list); |
| | | } |
| | | return AjaxResult.success(goodsService.updateById(dto)); |
| | | } |
| | | |
| | |
| | | */ |
| | | @ApiOperation( value = "查询销售金额统计") |
| | | @PostMapping(value = "/amountSum") |
| | | public AjaxResult<AmountSumVO> amountSum(@RequestBody TOrderMealQuery query) { |
| | | public AjaxResult<AmountSumVO> amountSum(@RequestBody TOrderSaleQuery query) { |
| | | query.setShopId(tokenService.getLoginUser().getObjectId()); |
| | | orderSaleService.amountSum(query); |
| | | return AjaxResult.success(orderSaleService.amountSum(query)); |
| | | } |
| | | |
| | |
| | | List<TOrderSaleGoods> list = orderSaleGoodsService.list(Wrappers.lambdaQuery(TOrderSaleGoods.class) |
| | | .eq(TOrderSaleGoods::getOrderId, orderSale.getId())); |
| | | orderSaleVO.setOrderSaleGoods(list); |
| | | BigDecimal sum = BigDecimal.ZERO; |
| | | Integer count = 0; |
| | | for (TOrderSaleGoods tOrderSaleGoods : list) { |
| | | sum = sum.add(tOrderSaleGoods.getThisSalePrice().multiply(new BigDecimal(tOrderSaleGoods.getGoodsCount()))); |
| | | count = count + tOrderSaleGoods.getGoodsCount(); |
| | | } |
| | | orderSaleVO.setGoodsAmount(sum); |
| | | orderSaleVO.setGoodsCount(count); |
| | | return AjaxResult.success(orderSaleVO); |
| | | } |
| | | |
| | |
| | | RoleInfoVO roleInfoVo = new RoleInfoVO(); |
| | | roleInfoVo.setRoleId(role.getRoleId()); |
| | | roleInfoVo.setRoleName(role.getRoleName()); |
| | | roleInfoVo.setRemark(role.getRemark()); |
| | | |
| | | // 获取当前角色的菜单列表 |
| | | List<SysMenu> menus = menuService.selectListByRoleId(roleId); |
| | |
| | | List<Long> menusId = menus.stream().map(SysMenu::getMenuId).collect(Collectors.toList()); |
| | | |
| | | // 获取当前的权限菜单(有层级) |
| | | List<SysMenu> levelMenus = roleService.getMenuLevelList(menusId); |
| | | // List<SysMenu> levelMenus = roleService.getMenuLevelList(menusId); |
| | | |
| | | roleInfoVo.setMenus(menusId); |
| | | return AjaxResult.success(roleInfoVo); |
| | |
| | | public static LocalDate stringToLocalDate(String time) { |
| | | return LocalDate.parse(time, DateTimeFormatter.ofPattern("yyyy-MM-dd")); |
| | | } |
| | | /** |
| | | * 字符串转为localdate |
| | | * |
| | | * @param time localdate |
| | | * @return 字符串 |
| | | */ |
| | | public static LocalDateTime stringToLocalDateTime(String time) { |
| | | return LocalDateTime.parse(time, DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss")); |
| | | } |
| | | |
| | | /** |
| | | * LocalDateTime转Date |
| | |
| | | import com.ruoyi.system.domain.TGoods; |
| | | import com.ruoyi.system.query.TGoodsQuery; |
| | | import com.ruoyi.system.vo.TGoodsVO; |
| | | import org.apache.ibatis.annotations.Mapper; |
| | | import org.apache.ibatis.annotations.Param; |
| | | |
| | | import java.util.List; |
| | |
| | | * @author xiaochen |
| | | * @since 2024-08-14 |
| | | */ |
| | | @Mapper |
| | | public interface TGoodsMapper extends BaseMapper<TGoods> { |
| | | |
| | | /** |
| | |
| | | * @param query |
| | | * @return |
| | | */ |
| | | AmountSumVO amountSum(@Param("query") TOrderMealQuery query); |
| | | AmountSumVO amountSum(@Param("query") TOrderSaleQuery query); |
| | | |
| | | /** |
| | | * 查询销售销售量统计 |
| | |
| | | * @return |
| | | */ |
| | | List<TDataGeneratorVO> saleGeneratorListExport(@Param("query")TDataGeneratorQuery query); |
| | | |
| | | /** |
| | | * 销售利润详情列表 |
| | | * @param query |
| | | * @param pageInfo |
| | | * @return |
| | | */ |
| | | List<GoodsProfitVO> profitDetails(@Param("query")ProfitDetailsQuery query, @Param("pageInfo")PageInfo<GoodsProfitVO> pageInfo); |
| | | |
| | | /** |
| | | * 查询利润详情统计 |
| | | * @param query |
| | | * @return |
| | | */ |
| | | Map<String, Double> profitDetailsStatistics(@Param("query")ProfitDetailsQuery query); |
| | | |
| | | /** |
| | | * 导出 |
| | | * @param query |
| | | * @return |
| | | */ |
| | | List<GoodsProfitVO> profitDetailsExport(@Param("query")ProfitDetailsQuery query); |
| | | |
| | | } |
| | |
| | | package com.ruoyi.system.mapper; |
| | | |
| | | import com.baomidou.mybatisplus.core.mapper.BaseMapper; |
| | | import com.ruoyi.system.domain.TOrderSaleGoods; |
| | | import com.ruoyi.system.domain.TOrderStockGoods; |
| | | import com.ruoyi.system.query.TDataGeneratorStockQuery; |
| | | import org.apache.ibatis.annotations.Param; |
| | | |
| | | import java.util.List; |
| | | import java.util.Map; |
| | | |
| | | /** |
| | |
| | | */ |
| | | public interface TOrderStockGoodsMapper extends BaseMapper<TOrderStockGoods> { |
| | | |
| | | /** |
| | | * 根据时间获取商品列表 |
| | | * @param orderTime |
| | | * @param shopId |
| | | * @return |
| | | */ |
| | | List<TOrderStockGoods> getListByTimeAndShopId(@Param("orderTime") String orderTime, @Param("shopId")Long shopId); |
| | | } |
| | |
| | | * @param query |
| | | * @return |
| | | */ |
| | | AmountSumVO amountSum(TOrderMealQuery query); |
| | | AmountSumVO amountSum(TOrderSaleQuery query); |
| | | |
| | | /** |
| | | * 查询销售销售量统计 |
| | |
| | | * @return |
| | | */ |
| | | List<TDataGeneratorVO> saleGeneratorListExport(TDataGeneratorQuery query); |
| | | |
| | | /** |
| | | * 盈利明细详情 |
| | | * @param query |
| | | * @return |
| | | */ |
| | | ProfitDetailsVO profitDetails(ProfitDetailsQuery query); |
| | | |
| | | /** |
| | | * 明细导出 |
| | | * @param query |
| | | * @return |
| | | */ |
| | | List<GoodsProfitVO> profitDetailsExport(ProfitDetailsQuery query); |
| | | } |
| | |
| | | package com.ruoyi.system.service; |
| | | |
| | | import com.baomidou.mybatisplus.extension.service.IService; |
| | | import com.ruoyi.system.domain.TOrderSaleGoods; |
| | | import com.ruoyi.system.domain.TOrderStockGoods; |
| | | import com.ruoyi.system.query.TDataGeneratorStockQuery; |
| | | |
| | | import java.time.LocalDate; |
| | | import java.util.List; |
| | | import java.util.Map; |
| | | |
| | | /** |
| | |
| | | */ |
| | | public interface TOrderStockGoodsService extends IService<TOrderStockGoods> { |
| | | |
| | | /** |
| | | * 查询下单时间和店铺的id |
| | | * @param orderTime |
| | | * @param shopId |
| | | * @return |
| | | */ |
| | | List<TOrderStockGoods> getListByTimeAndShopId(String orderTime, Long shopId); |
| | | |
| | | } |
| | |
| | | e.setGeneratorId(dataGenerator.getId()); |
| | | e.setOrderNum(OrderNumConstants.SALE + CodeGenerateUtils.generateVolumeSn()); |
| | | e.setIsCover(0); |
| | | e.setStatus(2); |
| | | }); |
| | | List<TOrderSaleGoods> orderSaleGoods = orderSales.stream().map(TOrderSale::getOrderSaleGoods).flatMap(Collection::stream).collect(Collectors.toList()); |
| | | |
| | | TOrderStock orderStockLast = orderStockService.getOne(Wrappers.lambdaQuery(TOrderStock.class) |
| | | .eq(TOrderStock::getShopId, dto.getShopId()) |
| | | .orderByDesc(TOrderStock::getStockTime) |
| | | .last("LIMIT 1")); |
| | | // 生成进货数据 |
| | | List<TOrderStock> stockList = new ArrayList<>(); |
| | | stockDataSets.stream().sorted(Comparator.comparing(TStockDataSet::getStockDate)); |
| | |
| | | stockList.add(orderStock); |
| | | |
| | | }else if(i==0 && Objects.nonNull(stockDataSet)){ |
| | | if(Objects.nonNull(orderStockLast)){ |
| | | // 查询商品进价 |
| | | List<TOrderStockGoods> orderStockGoodsList = orderStockGoodsService.list(Wrappers.lambdaQuery(TOrderStockGoods.class).eq(TOrderStockGoods::getOrderId, orderStockLast.getId())); |
| | | // 第一次 第一次的进货时间为上一次的结束时间 开始时间为上一次的开始时间 |
| | | LocalDate startTime1 = stockDataSet.getStockDate(); |
| | | List<TOrderSale> collect = orderSales.stream().filter(e -> e.getOrderTime().compareTo(startTime) < 0).collect(Collectors.toList()); |
| | |
| | | // 删除上一次的数据生成 新生成一条数据 |
| | | TOrderStock orderStock = new TOrderStock(); |
| | | orderStock.setStockNum(OrderNumConstants.STOCK + CodeGenerateUtils.generateVolumeSn()); |
| | | orderStock.setStockTime(startTime); |
| | | orderStock.setStockTime(orderStockLast.getStockTime()); |
| | | orderStock.setIsCover(0); |
| | | orderStock.setGeneratorId(dataGenerator.getId()); |
| | | orderStock.setGeneratorId(orderStockLast.getGeneratorId()); |
| | | orderStock.setShopId(dto.getShopId()); |
| | | |
| | | Map<String, List<TOrderSaleGoods>> goodsList = list.stream().collect(Collectors.groupingBy(TOrderSaleGoods::getGoodsName)); |
| | |
| | | tOrderStockGoods.setGoodsNum(v.get(0).getGoodsNum()); |
| | | tOrderStockGoods.setCostPrice(v.get(0).getGoodsCostPrice()); |
| | | tOrderStockGoods.setSalePrice(v.get(0).getGoodsSalePrice()); |
| | | // tOrderStockGoods.setThisCostPrice(v.get(0).getThisSalePrice()); |
| | | TOrderStockGoods orderStockGoods1 = orderStockGoodsList.stream().filter(e -> e.getGoodsName().equals(k)).findFirst().orElse(null); |
| | | if(Objects.nonNull(orderStockGoods1)){ |
| | | tOrderStockGoods.setThisCostPrice(orderStockGoods1.getThisCostPrice()); |
| | | } |
| | | tOrderStockGoods.setGoodsPicture(v.get(0).getGoodsPicture()); |
| | | tOrderStockGoods.setGoodsId(v.get(0).getGoodsId()); |
| | | int sum = v.stream().mapToInt(TOrderSaleGoods::getGoodsCount).sum(); |
| | |
| | | }); |
| | | orderStock.setOrderStockGoods(orderStockGoods); |
| | | stockList.add(orderStock); |
| | | } |
| | | |
| | | // 处理第一次到下一次的数据 |
| | | TStockDataSet end = stockDataSets.get(i + 1); |
| | |
| | | return; |
| | | } |
| | | // 删除上一次的数据生成 |
| | | TOrderStock orderStock = orderStockService.getOne(Wrappers.lambdaQuery(TOrderStock.class) |
| | | .eq(TOrderStock::getShopId, dto.getShopId()) |
| | | .orderByDesc(TOrderStock::getStockTime) |
| | | .last("LIMIT 1")); |
| | | if(Objects.nonNull(orderStock)){ |
| | | orderStockService.removeById(orderStock); |
| | | if(Objects.nonNull(orderStockLast)){ |
| | | orderStockService.removeById(orderStockLast); |
| | | } |
| | | orderSaleService.saveBatch(orderSales); |
| | | for (TOrderSale orderSale : orderSales) { |
| | |
| | | import java.math.BigDecimal; |
| | | import java.time.LocalDate; |
| | | import java.time.LocalDateTime; |
| | | import java.time.temporal.ChronoUnit; |
| | | import java.util.*; |
| | | import java.util.stream.Collectors; |
| | | |
| | |
| | | orderMeal.setMealType(dto.getMealType()); |
| | | orderMeal.setMealPerson(dto.getMealPerson()); |
| | | orderMeal.setMealTime(dto.getMealTime()); |
| | | orderMeal.setOrderMoney(dto.getOrderMoney()); |
| | | |
| | | // 查询菜品分类 |
| | | List<TGoodsType> list1 = goodsTypeService.list(); |
| | |
| | | List<Long> goodsIds = dto.getMealOrderGoodsDTOS().stream().map(MealOrderGoodsDTO::getGoodsId).collect(Collectors.toList()); |
| | | List<TGoods> list = goodsService.list(Wrappers.lambdaQuery(TGoods.class) |
| | | .in(TGoods::getId, goodsIds)); |
| | | // 查询已存在的菜品 |
| | | List<TOrderMealGoods> list2 = orderMealGoodsService.list(Wrappers.lambdaQuery(TOrderMealGoods.class) |
| | | .in(TOrderMealGoods::getOrderId, dto.getId())); |
| | | dto.getMealOrderGoodsDTOS().forEach(item -> { |
| | | if(CollectionUtils.isEmpty(list2)){ |
| | | list.stream().filter(item1 -> item1.getId().equals(item.getGoodsId())).findFirst().ifPresent(item1 -> { |
| | | TOrderMealGoods orderMealGood = new TOrderMealGoods(); |
| | | orderMealGood.setGoodsName(item1.getGoodsName()); |
| | |
| | | orderMealGood.setTypeName(list1.stream().filter(item2 -> item2.getId().equals(item1.getTypeId())).findFirst().get().getTypeName()); |
| | | orderMealGoods.add(orderMealGood); |
| | | }); |
| | | }else { |
| | | list2.stream().filter(item1 -> item1.getGoodsId().equals(item.getGoodsId())).findFirst().ifPresent(item1 -> { |
| | | item1.setGoodsCount(item1.getGoodsCount()+item.getGoodsCount()); |
| | | orderMealGoods.add(item1); |
| | | }); |
| | | } |
| | | }); |
| | | BigDecimal orderMoney = BigDecimal.ZERO; |
| | | // 添加菜品 |
| | |
| | | orderMealGood.setOrderId(dto.getId()); |
| | | orderMoney = orderMoney.add(orderMealGood.getGoodsSalePrice().multiply(new BigDecimal(orderMealGood.getGoodsCount()))); |
| | | } |
| | | orderMealGoodsService.saveBatch(orderMealGoods); |
| | | orderMealGoodsService.saveOrUpdateBatch(orderMealGoods); |
| | | orderMeal.setOrderMoney(orderMoney); |
| | | this.updateById(orderMeal); |
| | | // 添加备注 |
| | |
| | | List<TOrderMeal> list = this.list(Wrappers.lambdaQuery(TOrderMeal.class) |
| | | .eq(TOrderMeal::getShopId, query.getShopId()) |
| | | .ge(TOrderMeal::getMealTime, query.getStartTime()) |
| | | .le(TOrderMeal::getMealTime, query.getEndTime())); |
| | | .le(TOrderMeal::getMealTime, query.getEndTime()) |
| | | .eq(TOrderMeal::getStatus,2)); |
| | | List<Long> ids = list.stream().map(TOrderMeal::getId).collect(Collectors.toList()); |
| | | if(!CollectionUtils.isEmpty(ids)){ |
| | | BigDecimal costTotal = orderMealGoodsService.costTotal(ids); |
| | |
| | | |
| | | @Override |
| | | public List<OrderTrendsVO> orderingTrends(TDataStatisticsQuery query) { |
| | | return this.baseMapper.orderingTrends(query); |
| | | List<OrderTrendsVO> orderTrendsVOS = this.baseMapper.orderingTrends(query); |
| | | LocalDate localDate = LocalDate.now(); |
| | | for (int i = 0; i < 7; i++) { |
| | | if(i == 0){ |
| | | LocalDate finalLocalDate = localDate; |
| | | OrderTrendsVO orderTrendsVO = orderTrendsVOS.stream().filter(e -> DateUtils.stringToLocalDate(e.getDayTime()).compareTo(finalLocalDate) == 0).findFirst().orElse(null); |
| | | if(Objects.isNull(orderTrendsVO)){ |
| | | orderTrendsVO = new OrderTrendsVO(); |
| | | orderTrendsVO.setDayTime(DateUtils.localDateToString(localDate)); |
| | | orderTrendsVO.setOrderCount(0); |
| | | orderTrendsVOS.add(orderTrendsVO); |
| | | } |
| | | }else { |
| | | localDate = localDate.minusDays(1); |
| | | LocalDate finalLocalDate1 = localDate; |
| | | OrderTrendsVO orderTrendsVO = orderTrendsVOS.stream().filter(e -> DateUtils.stringToLocalDate(e.getDayTime()).compareTo(finalLocalDate1) == 0).findFirst().orElse(null); |
| | | if(Objects.isNull(orderTrendsVO)){ |
| | | orderTrendsVO = new OrderTrendsVO(); |
| | | orderTrendsVO.setDayTime(DateUtils.localDateToString(finalLocalDate1)); |
| | | orderTrendsVO.setOrderCount(0); |
| | | orderTrendsVOS.add(orderTrendsVO); |
| | | } |
| | | } |
| | | } |
| | | return orderTrendsVOS.stream().sorted(Comparator.comparing(OrderTrendsVO::getDayTime)).collect(Collectors.toList()); |
| | | } |
| | | |
| | | @Override |
| | |
| | | import com.ruoyi.common.constant.OrderNumConstants; |
| | | import com.ruoyi.common.utils.CodeGenerateUtils; |
| | | import com.ruoyi.common.utils.DateUtils; |
| | | import com.ruoyi.common.utils.StringUtils; |
| | | import com.ruoyi.system.domain.*; |
| | | import com.ruoyi.system.dto.CheckoutDTO; |
| | | import com.ruoyi.system.dto.TOrderSaleDTO; |
| | | import com.ruoyi.system.mapper.TOrderSaleGoodsMapper; |
| | | import com.ruoyi.system.mapper.TOrderSaleMapper; |
| | | import com.ruoyi.system.query.*; |
| | | import com.ruoyi.system.service.TGoodsService; |
| | | import com.ruoyi.system.service.TGoodsTypeService; |
| | | import com.ruoyi.system.service.TOrderSaleGoodsService; |
| | | import com.ruoyi.system.service.TOrderSaleService; |
| | | import com.ruoyi.system.service.*; |
| | | import com.ruoyi.system.vo.*; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.stereotype.Service; |
| | |
| | | @Autowired |
| | | private TOrderSaleGoodsService orderSaleGoodsService; |
| | | @Autowired |
| | | private TOrderStockGoodsService orderStockGoodsService; |
| | | @Autowired |
| | | private TOrderSaleGoodsMapper orderSaleGoodsMapper; |
| | | @Autowired |
| | | private TGoodsTypeService goodsTypeService; |
| | | @Autowired |
| | | private TGoodsService goodsService; |
| | | @Override |
| | | public void add(TOrderSaleDTO dto) { |
| | | // 查询菜品分类 |
| | | List<TGoodsType> list1 = goodsTypeService.list(); |
| | | // List<TGoodsType> list1 = goodsTypeService.list(); |
| | | // 销售单号 |
| | | dto.setOrderNum(OrderNumConstants.SALE + CodeGenerateUtils.generateVolumeSn()); |
| | | List<TOrderSaleGoods> orderSaleGoods = dto.getOrderSaleGoods(); |
| | | BigDecimal sum = orderSaleGoods.stream().map(TOrderSaleGoods::getGoodsSalePrice).reduce(BigDecimal::add).get(); |
| | | BigDecimal sum = BigDecimal.ZERO; |
| | | for (TOrderSaleGoods orderSaleGood : orderSaleGoods) { |
| | | sum = sum.add(orderSaleGood.getThisSalePrice().multiply(new BigDecimal(orderSaleGood.getGoodsCount()))); |
| | | } |
| | | dto.setOrderMoney(sum); |
| | | this.save(dto); |
| | | |
| | | // 查询进货数据 |
| | | List<TOrderStockGoods> orderStockGoodsList = orderStockGoodsService.getListByTimeAndShopId(DateUtils.localDateToString(dto.getOrderTime()), dto.getShopId()); |
| | | |
| | | // 添加商品 |
| | | orderSaleGoods.forEach(orderSaleGoods1 -> { |
| | | orderSaleGoods1.setOrderId(dto.getId()); |
| | | orderSaleGoods1.setId(null); |
| | | TOrderStockGoods orderStockGoods = orderStockGoodsList.stream().filter(m -> m.getGoodsNum().equals(orderSaleGoods1.getGoodsNum())).findFirst().orElse(null); |
| | | if(Objects.nonNull(orderStockGoods)){ |
| | | orderSaleGoods1.setGoodsCostPrice(orderStockGoods.getThisCostPrice()); |
| | | }else { |
| | | orderSaleGoods1.setGoodsCostPrice(BigDecimal.ZERO); |
| | | } |
| | | }); |
| | | orderSaleGoodsService.saveBatch(orderSaleGoods); |
| | | } |
| | | |
| | | @Override |
| | | public PageInfo<TOrderSaleVO> pageList(TOrderSaleQuery query) { |
| | | if(Objects.nonNull(query.getStartTime()) && Objects.nonNull(query.getEndTime())){ |
| | | if(Objects.isNull(query.getStartTime()) && Objects.isNull(query.getEndTime())){ |
| | | if(Objects.nonNull(query.getTimeType())){ |
| | | LocalDateTime startTime = null; |
| | | LocalDateTime endTime = null; |
| | |
| | | List<TOrderSaleGoods> collect = list1.stream().filter(m -> m.getOrderId().equals(e.getId())).collect(Collectors.toList()); |
| | | if(!CollectionUtils.isEmpty(collect)){ |
| | | BigDecimal goodsAmount = BigDecimal.ZERO; |
| | | Integer count = 0; |
| | | for (TOrderSaleGoods tOrderSaleGoods : collect) { |
| | | goodsAmount = goodsAmount.add(tOrderSaleGoods.getThisSalePrice().multiply(new BigDecimal(tOrderSaleGoods.getGoodsCount()))); |
| | | count = count+tOrderSaleGoods.getGoodsCount(); |
| | | } |
| | | e.setGoodsAmount(goodsAmount); |
| | | e.setGoodsCount(count); |
| | | e.setOrderSaleGoods(collect); |
| | | } |
| | | }); |
| | |
| | | } |
| | | |
| | | @Override |
| | | public AmountSumVO amountSum(TOrderMealQuery query) { |
| | | return this.baseMapper.amountSum(query); |
| | | public AmountSumVO amountSum(TOrderSaleQuery query) { |
| | | AmountSumVO amountSumVO = this.baseMapper.amountSum(query); |
| | | if(amountSumVO.getObligation().compareTo(BigDecimal.ZERO) < 0){ |
| | | amountSumVO.setObligation(BigDecimal.ZERO); |
| | | } |
| | | return amountSumVO; |
| | | } |
| | | |
| | | @Override |
| | |
| | | .add(salesVolumeVO.getMoneyPay()).add(salesVolumeVO.getAliPay())); |
| | | // 查询成本 |
| | | List<TOrderSale> list = this.list(Wrappers.lambdaQuery(TOrderSale.class) |
| | | .eq(TOrderSale::getShopId, query.getShopId())); |
| | | .eq(TOrderSale::getShopId, query.getShopId()) |
| | | .ge(TOrderSale::getOrderTime, query.getStartTime()) |
| | | .le(TOrderSale::getOrderTime, query.getEndTime()) |
| | | .eq(TOrderSale::getStatus,2)); |
| | | List<Long> ids = list.stream().map(TOrderSale::getId).collect(Collectors.toList()); |
| | | if(!CollectionUtils.isEmpty(ids)){ |
| | | BigDecimal costTotal = orderSaleGoodsService.costTotal(ids); |
| | |
| | | |
| | | @Override |
| | | public List<TOrderSaleVO> exportOrderSale(TOrderMealQuery query) { |
| | | if(StringUtils.isEmpty(query.getStartTime()) && StringUtils.isEmpty(query.getEndTime())){ |
| | | if(Objects.nonNull(query.getTimeType())){ |
| | | LocalDateTime startTime = null; |
| | | LocalDateTime endTime = null; |
| | |
| | | query.setStartTime(DateUtils.localDateTimeToDate(startTime)); |
| | | query.setEndTime(DateUtils.localDateTimeToDate(endTime)); |
| | | } |
| | | } |
| | | List<TOrderSaleVO> list = this.baseMapper.exportOrderSale(query); |
| | | List<Long> ids = list.stream().map(TOrderSaleVO::getId).collect(Collectors.toList()); |
| | | List<TOrderSaleGoods> list1 = orderSaleGoodsService.list(Wrappers.lambdaQuery(TOrderSaleGoods.class) |
| | |
| | | |
| | | @Override |
| | | public Map<String, Double> getDataGeneratorSaleDetail(TDataGeneratorSaleQuery query) { |
| | | if(Objects.nonNull(query.getStartTime()) && Objects.nonNull(query.getEndTime())){ |
| | | if(Objects.isNull(query.getStartTime()) && Objects.isNull(query.getEndTime())){ |
| | | if(Objects.nonNull(query.getTimeType())){ |
| | | LocalDateTime startTime = null; |
| | | LocalDateTime endTime = null; |
| | |
| | | } |
| | | return list; |
| | | } |
| | | |
| | | @Override |
| | | public ProfitDetailsVO profitDetails(ProfitDetailsQuery query) { |
| | | ProfitDetailsVO profitDetailsVO = new ProfitDetailsVO(); |
| | | // 查询商品盈利明细 |
| | | PageInfo<GoodsProfitVO> pageInfo = new PageInfo<>(query.getPageNum(),query.getPageSize()); |
| | | List<GoodsProfitVO> list = this.baseMapper.profitDetails(query,pageInfo); |
| | | pageInfo.setRecords(list); |
| | | profitDetailsVO.setGoodsProfitVOS(pageInfo); |
| | | |
| | | // 统计商品金额 |
| | | Map<String,Double> map = this.baseMapper.profitDetailsStatistics(query); |
| | | profitDetailsVO.setTotalProfits(new BigDecimal(map.get("totalProfits").toString())); |
| | | profitDetailsVO.setTotalCosts(new BigDecimal(map.get("totalCosts").toString())); |
| | | profitDetailsVO.setTotalSales(new BigDecimal(map.get("totalSales").toString())); |
| | | return profitDetailsVO; |
| | | } |
| | | |
| | | @Override |
| | | public List<GoodsProfitVO> profitDetailsExport(ProfitDetailsQuery query) { |
| | | return this.baseMapper.profitDetailsExport(query); |
| | | } |
| | | } |
| | |
| | | package com.ruoyi.system.service.impl; |
| | | |
| | | import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; |
| | | import com.ruoyi.system.domain.TOrderSaleGoods; |
| | | import com.ruoyi.system.domain.TOrderStockGoods; |
| | | import com.ruoyi.system.mapper.TOrderStockGoodsMapper; |
| | | import com.ruoyi.system.query.TDataGeneratorStockQuery; |
| | | import com.ruoyi.system.service.TOrderStockGoodsService; |
| | | import org.springframework.stereotype.Service; |
| | | |
| | | import java.util.List; |
| | | import java.util.Map; |
| | | |
| | | /** |
| | |
| | | @Service |
| | | public class TOrderStockGoodsServiceImpl extends ServiceImpl<TOrderStockGoodsMapper, TOrderStockGoods> implements TOrderStockGoodsService { |
| | | |
| | | @Override |
| | | public List<TOrderStockGoods> getListByTimeAndShopId(String orderTime, Long shopId) { |
| | | return this.baseMapper.getListByTimeAndShopId(orderTime,shopId); |
| | | } |
| | | } |
| | |
| | | import com.ruoyi.system.domain.*; |
| | | import com.ruoyi.system.dto.TOrderSaleDTO; |
| | | import com.ruoyi.system.dto.TOrderStockDTO; |
| | | import com.ruoyi.system.mapper.TDataGeneratorMapper; |
| | | import com.ruoyi.system.mapper.TOrderSaleGoodsMapper; |
| | | import com.ruoyi.system.mapper.TOrderSaleMapper; |
| | | import com.ruoyi.system.mapper.TOrderStockMapper; |
| | | import com.ruoyi.system.mapper.*; |
| | | import com.ruoyi.system.query.TDataGeneratorQuery; |
| | | import com.ruoyi.system.query.TDataGeneratorStockQuery; |
| | | import com.ruoyi.system.query.TOrderStockQuery; |
| | |
| | | private TStockDataSetService stockDataSetService; |
| | | @Autowired |
| | | private TDataGeneratorMapper dataGeneratorMapper; |
| | | @Autowired |
| | | private TGoodsService goodsService; |
| | | @Override |
| | | public void add(TOrderStockDTO dto) { |
| | | // 进货单号 |
| | |
| | | dto.setIsCover(0); |
| | | } |
| | | this.save(dto); |
| | | List<TGoods> goods = goodsService.list(Wrappers.lambdaQuery(TGoods.class)); |
| | | List<TGoods> goodsUpdateList = new ArrayList<>(); |
| | | // 添加商品 |
| | | orderStockGoods.forEach(orderSaleGoods1 -> { |
| | | orderSaleGoods1.setId(null); |
| | | orderSaleGoods1.setOrderId(dto.getId()); |
| | | for (TGoods good : goods) { |
| | | if(good.getGoodsNum().equals(orderSaleGoods1.getGoodsNum())){ |
| | | good.setInventory(orderSaleGoods1.getStockCount()+good.getInventory()); |
| | | goodsUpdateList.add(good); |
| | | }else { |
| | | break; |
| | | } |
| | | } |
| | | }); |
| | | goodsService.updateBatchById(goodsUpdateList); |
| | | tOrderStockGoodsService.saveBatch(orderStockGoods); |
| | | } |
| | | |
| | |
| | | |
| | | @Override |
| | | public PageInfo<TOrderStockVO> pageList(TOrderStockQuery query) { |
| | | if(Objects.nonNull(query.getStartTime()) && Objects.nonNull(query.getEndTime())){ |
| | | if(Objects.isNull(query.getStartTime()) && Objects.isNull(query.getEndTime())){ |
| | | // 判断时间 |
| | | if(Objects.nonNull(query.getTimeType())){ |
| | | LocalDateTime startTime = null; |
| | |
| | | List<TOrderStockGoods> collect = orderStockGoods.stream().filter(orderSaleGoods -> orderSaleGoods.getOrderId().equals(orderStockVO.getId())).collect(Collectors.toList()); |
| | | if(!CollectionUtils.isEmpty(collect)){ |
| | | orderStockVO.setOrderStockGoods(collect); |
| | | orderStockVO.setOrderStockCount(collect.size()); |
| | | orderStockVO.setTotalPrice(collect.stream().map(TOrderStockGoods::getCostPrice).reduce(BigDecimal::add).get()); |
| | | int sum = collect.stream().mapToInt(TOrderStockGoods::getStockCount).sum(); |
| | | orderStockVO.setOrderStockCount(sum); |
| | | BigDecimal money = BigDecimal.ZERO; |
| | | for (TOrderStockGoods tOrderStockGoods : collect) { |
| | | money = money.add(tOrderStockGoods.getThisCostPrice().multiply(new BigDecimal(tOrderStockGoods.getStockCount()))); |
| | | } |
| | | orderStockVO.setTotalPrice(money); |
| | | } |
| | | }); |
| | | } |
| | |
| | | private Long roleId; |
| | | |
| | | private String roleName; |
| | | private String remark; |
| | | |
| | | @ApiModelProperty("菜单id") |
| | | private List<Long> menus; |
| | |
| | | |
| | | @ApiModelProperty(value = "货品总价") |
| | | private BigDecimal goodsAmount; |
| | | @ApiModelProperty(value = "货品数量") |
| | | private Integer goodsCount; |
| | | @ApiModelProperty(value = "菜品集合") |
| | | private List<TOrderSaleGoods> orderSaleGoods; |
| | | |
| | |
| | | </foreach> |
| | | </if> |
| | | AND tom.isCover = 1 |
| | | AND tom.status = 2 |
| | | </where> |
| | | GROUP BY tomg.typeName |
| | | </select> |
| | |
| | | </if> |
| | | AND disabled = ${@com.ruoyi.common.enums.DisabledEnum@NO.getCode()} |
| | | AND isCover = 1 |
| | | AND status = 2 |
| | | </where> |
| | | </select> |
| | | <select id="exportOrderMeal" resultType="com.ruoyi.system.vo.TOrderMealVO"> |
| | |
| | | </if> |
| | | AND disabled = ${@com.ruoyi.common.enums.DisabledEnum@NO.getCode()} |
| | | AND isCover = 1 |
| | | AND status = 2 |
| | | </where> |
| | | </select> |
| | | <select id="personnelStatistics" resultType="com.ruoyi.system.vo.PersonnelStatisticsVO"> |
| | |
| | | </if> |
| | | AND tom.disabled = ${@com.ruoyi.common.enums.DisabledEnum@NO.getCode()} |
| | | AND tom.isCover = 1 |
| | | AND tom.status = 2 |
| | | </where> |
| | | </select> |
| | | <select id="pageListGenerator" resultType="com.ruoyi.system.vo.TOrderMealVO"> |
| | |
| | | </if> |
| | | AND tom.disabled = ${@com.ruoyi.common.enums.DisabledEnum@NO.getCode()} |
| | | </where> |
| | | ORDER BY tom.createTime DESC |
| | | ORDER BY tom.mealTime DESC |
| | | </select> |
| | | <select id="getDataGeneratorMealDetail" resultType="java.util.Map"> |
| | | SELECT |
| | |
| | | LEFT JOIN t_order_meal tom ON tom.id = tomg.orderId |
| | | <where> |
| | | <if test="query.startTime != null and query.startTime != '' and query.endTime != null and query.endTime != ''"> |
| | | AND (tom.createTime BETWEEN #{query.startTime} AND #{query.endTime}) |
| | | AND (tom.mealTime BETWEEN #{query.startTime} AND #{query.endTime}) |
| | | </if> |
| | | <if test="query.goodsName != null and query.goodsName != ''"> |
| | | AND tomg.goodsName like concat('%', #{query.goodsName}, '%') |
| | |
| | | </if> |
| | | AND tom.disabled = ${@com.ruoyi.common.enums.DisabledEnum@NO.getCode()} |
| | | AND tom.isCover = 1 |
| | | AND tom.status = 2 |
| | | </where> |
| | | GROUP BY tomg.goodsName |
| | | </select> |
| | |
| | | </if> |
| | | AND tom.disabled = ${@com.ruoyi.common.enums.DisabledEnum@NO.getCode()} |
| | | AND tom.isCover = 1 |
| | | AND tom.status = 2 |
| | | </where> |
| | | GROUP BY tomg.goodsName) a |
| | | </select> |
| | |
| | | LEFT JOIN t_order_meal tom ON tom.id = tomg.orderId |
| | | <where> |
| | | <if test="query.startTime != null and query.startTime != '' and query.endTime != null and query.endTime != ''"> |
| | | AND (tom.createTime BETWEEN #{query.startTime} AND #{query.endTime}) |
| | | AND (tom.mealTime BETWEEN #{query.startTime} AND #{query.endTime}) |
| | | </if> |
| | | <if test="query.goodsName != null and query.goodsName != ''"> |
| | | AND tomg.goodsName like concat('%', #{query.goodsName}, '%') |
| | |
| | | AND tom.shopId = #{query.shopId} |
| | | </if> |
| | | AND tom.disabled = ${@com.ruoyi.common.enums.DisabledEnum@NO.getCode()} |
| | | AND tom.isCover = 1 |
| | | AND tom.status = 2 |
| | | </where> |
| | | GROUP BY tomg.goodsName |
| | | </select> |
| | |
| | | </where> |
| | | </select> |
| | | <select id="salesRanking" resultType="com.ruoyi.system.vo.SalesRankingVO"> |
| | | SELECT tgt.typeName,SUM(tosg.goodsSalePrice*tosg.goodsCount) AS salesVolume |
| | | SELECT tgt.typeName,SUM(tosg.thisSalePrice*tosg.goodsCount) AS salesVolume |
| | | FROM t_order_sale_goods tosg |
| | | LEFT JOIN t_order_sale tos on tosg.orderId=tos.id |
| | | LEFT JOIN t_goods_type tgt ON tosg.typeId = tgt.id |
| | |
| | | </foreach> |
| | | </if> |
| | | AND tos.isCover = 1 |
| | | AND tos.status = 2 |
| | | </where> |
| | | GROUP BY tgt.typeName |
| | | </select> |
| | |
| | | <select id="amountSum" resultType="com.ruoyi.system.vo.AmountSumVO"> |
| | | select |
| | | COUNT(id) AS orderCount, |
| | | SUM(orderMoney) AS saleAmount, |
| | | SUM(payMoney) AS payAmount, |
| | | SUM(orderMoney - payMoney) AS obligation |
| | | IFNULL(SUM(orderMoney),0) AS saleAmount, |
| | | IFNULL(SUM(payMoney),0) AS payAmount, |
| | | IFNULL(SUM(orderMoney - IFNULL(payMoney,0)),0) AS obligation |
| | | from t_order_sale |
| | | <where> |
| | | <if test="query.orderNum != null and query.orderNum != ''"> |
| | |
| | | </if> |
| | | AND disabled = ${@com.ruoyi.common.enums.DisabledEnum@NO.getCode()} |
| | | AND isCover = 1 |
| | | AND status = 2 |
| | | </where> |
| | | </select> |
| | | <select id="exportOrderSale" resultType="com.ruoyi.system.vo.TOrderSaleVO"> |
| | | select id, orderTime, remark, createTime, updateTime, disabled, createBy, updateBy, orderNum, status,orderMoney,payMoney,shopId |
| | | select id, orderTime, remark, createTime, updateTime, disabled, createBy, updateBy, orderNum, status,orderMoney,payMoney,shopId,payType |
| | | from t_order_sale |
| | | <where> |
| | | <if test="query.orderNum != null and query.orderNum != ''"> |
| | |
| | | AND shopId = #{query.shopId} |
| | | </if> |
| | | <if test="query.startTime != null and query.startTime != '' and query.endTime != null and query.endTime != ''"> |
| | | AND (createTime BETWEEN #{query.startTime} AND #{query.endTime}) |
| | | AND (orderTime BETWEEN #{query.startTime} AND #{query.endTime}) |
| | | </if> |
| | | AND disabled = ${@com.ruoyi.common.enums.DisabledEnum@NO.getCode()} |
| | | AND isCover = 1 |
| | | AND status = 2 |
| | | </where> |
| | | </select> |
| | | <select id="getDataGeneratorSaleDetail" resultType="java.util.Map"> |
| | |
| | | and tdg.orderType = 2 |
| | | </where> |
| | | </select> |
| | | <select id="profitDetails" resultType="com.ruoyi.system.vo.GoodsProfitVO"> |
| | | SELECT |
| | | tomg.goodsName, |
| | | (select typeName from t_goods_type where id = tomg.typeId) AS typeName, |
| | | IFNULL(SUM( tomg.goodsCount ),0) AS totalSalesCount, |
| | | IFNULL(SUM( tomg.goodsCount * tomg.thisSalePrice ),0) AS goodsSaleAmount, |
| | | IFNULL(SUM( tomg.goodsCount * tomg.goodsCostPrice ),0) AS goodsCostAmount, |
| | | IFNULL(SUM(tomg.goodsCount *(tomg.thisSalePrice - tomg.goodsCostPrice)),0) AS goodsProfitAmount |
| | | FROM t_order_sale_goods tomg |
| | | LEFT JOIN t_order_sale tom ON tom.id = tomg.orderId |
| | | <where> |
| | | <if test="query.startTime != null and query.startTime != '' and query.endTime != null and query.endTime != ''"> |
| | | AND (tom.orderTime BETWEEN #{query.startTime} AND #{query.endTime}) |
| | | </if> |
| | | <if test="query.goodsName != null and query.goodsName != ''"> |
| | | AND tomg.goodsName like concat('%', #{query.goodsName}, '%') |
| | | </if> |
| | | <if test="query.typeId != null and query.typeId != ''"> |
| | | AND tomg.typeId = #{query.typeId} |
| | | </if> |
| | | <if test="query.shopId != null"> |
| | | AND tom.shopId = #{query.shopId} |
| | | </if> |
| | | AND tom.disabled = ${@com.ruoyi.common.enums.DisabledEnum@NO.getCode()} |
| | | AND tom.isCover = 1 |
| | | AND tom.status = 2 |
| | | </where> |
| | | GROUP BY tomg.goodsName |
| | | </select> |
| | | <select id="profitDetailsStatistics" resultType="java.util.Map"> |
| | | SELECT |
| | | IFNULL(SUM(a.goodsSaleAmount),0) AS totalSales, |
| | | IFNULL(SUM(a.goodsCostAmount),0) AS totalCosts, |
| | | IFNULL(SUM(a.goodsProfitAmount),0) AS totalProfits |
| | | FROM ( |
| | | SELECT |
| | | tomg.goodsName, |
| | | IFNULL(SUM( tomg.goodsCount ),0) AS totalSalesCount, |
| | | IFNULL(SUM( tomg.goodsCount * tomg.thisSalePrice ),0) AS goodsSaleAmount, |
| | | IFNULL(SUM( tomg.goodsCount * tomg.goodsCostPrice ),0) AS goodsCostAmount, |
| | | IFNULL(SUM(tomg.goodsCount * (tomg.thisSalePrice - tomg.goodsCostPrice)),0) AS goodsProfitAmount |
| | | FROM t_order_sale_goods tomg |
| | | LEFT JOIN t_order_sale tom ON tom.id = tomg.orderId |
| | | <where> |
| | | <if test="query.startTime != null and query.startTime != '' and query.endTime != null and query.endTime != ''"> |
| | | AND (tom.orderTime BETWEEN #{query.startTime} AND #{query.endTime}) |
| | | </if> |
| | | <if test="query.goodsName != null and query.goodsName != ''"> |
| | | AND tomg.goodsName like concat('%', #{query.goodsName}, '%') |
| | | </if> |
| | | <if test="query.typeId != null and query.typeId != ''"> |
| | | AND tomg.typeId = #{query.typeId} |
| | | </if> |
| | | <if test="query.shopId != null"> |
| | | AND tom.shopId = #{query.shopId} |
| | | </if> |
| | | AND tom.disabled = ${@com.ruoyi.common.enums.DisabledEnum@NO.getCode()} |
| | | AND tom.isCover = 1 |
| | | AND tom.status = 2 |
| | | </where> |
| | | GROUP BY tomg.goodsName) a |
| | | </select> |
| | | <select id="profitDetailsExport" resultType="com.ruoyi.system.vo.GoodsProfitVO"> |
| | | SELECT |
| | | tomg.goodsName, |
| | | (select typeName from t_goods_type where id = tomg.typeId) AS typeName, |
| | | IFNULL(SUM( tomg.goodsCount ),0) AS totalSalesCount, |
| | | IFNULL(SUM( tomg.goodsCount * tomg.thisSalePrice ),0) AS goodsSaleAmount, |
| | | IFNULL(SUM( tomg.goodsCount * tomg.goodsCostPrice ),0) AS goodsCostAmount, |
| | | IFNULL(SUM(tomg.goodsCount *(tomg.thisSalePrice - tomg.goodsCostPrice)),0) AS goodsProfitAmount |
| | | FROM t_order_sale_goods tomg |
| | | LEFT JOIN t_order_sale tom ON tom.id = tomg.orderId |
| | | <where> |
| | | <if test="query.startTime != null and query.startTime != '' and query.endTime != null and query.endTime != ''"> |
| | | AND (tom.orderTime BETWEEN #{query.startTime} AND #{query.endTime}) |
| | | </if> |
| | | <if test="query.goodsName != null and query.goodsName != ''"> |
| | | AND tomg.goodsName like concat('%', #{query.goodsName}, '%') |
| | | </if> |
| | | <if test="query.typeId != null and query.typeId != ''"> |
| | | AND tomg.typeId = #{query.typeId} |
| | | </if> |
| | | <if test="query.shopId != null"> |
| | | AND tom.shopId = #{query.shopId} |
| | | </if> |
| | | AND tom.disabled = ${@com.ruoyi.common.enums.DisabledEnum@NO.getCode()} |
| | | AND tom.isCover = 1 |
| | | AND tom.status = 2 |
| | | </where> |
| | | GROUP BY tomg.goodsName |
| | | </select> |
| | | |
| | | </mapper> |
| | |
| | | <sql id="Base_Column_List"> |
| | | id, orderId, goodsNum, goodsName, costPrice, salePrice, goodsPicture, stockCount,thisCostPrice,goodsId |
| | | </sql> |
| | | <select id="getListByTimeAndShopId" resultType="com.ruoyi.system.domain.TOrderStockGoods"> |
| | | select t.id, t.orderId, t.goodsNum, t.goodsName, t.costPrice, t.salePrice, t.goodsPicture, t.stockCount,t.thisCostPrice,t.goodsId |
| | | from t_order_stock_goods t |
| | | where t.orderId in (select id from t_order_stock where DATE_FORMAT(orderTime, '%Y-%m-%d')) = #{orderTime} and shopId = #{shopId}) |
| | | </select> |
| | | |
| | | </mapper> |