| | |
| | | import org.springframework.stereotype.Service; |
| | | import org.springframework.transaction.annotation.Propagation; |
| | | import org.springframework.transaction.annotation.Transactional; |
| | | import org.springframework.util.CollectionUtils; |
| | | |
| | | import java.math.BigDecimal; |
| | | import java.math.RoundingMode; |
| | |
| | | @Autowired |
| | | private TGoodsTypeService goodsTypeService; |
| | | @Autowired |
| | | private TShopService shopService; |
| | | @Autowired |
| | | private RedisCache redisCache; |
| | | |
| | | @Transactional(rollbackFor = Exception.class,propagation = Propagation.REQUIRED) |
| | |
| | | TDataGenerator dataGenerator = new TDataGenerator(); |
| | | dataGenerator.setUserId(dto.getUserId()); |
| | | dataGenerator.setUserName(dto.getNickName()); |
| | | dataGenerator.setShopId(dataGenerator.getShopId()); |
| | | dataGenerator.setShopId(dto.getShopId()); |
| | | dataGenerator.setStartTime(dto.getStartTime()); |
| | | dataGenerator.setEndTime(dto.getEndTime()); |
| | | dataGenerator.setMinMoney(dto.getMinMoney()); |
| | |
| | | orderMeal.setOrderNum(OrderNumConstants.MEAL + CodeGenerateUtils.generateVolumeSn()); |
| | | orderMeal.setStatus(2); |
| | | List<TOrderMealGoods> orderMealGoods = new ArrayList<>(); |
| | | // 获取当前桌的菜品 |
| | | List<TFoundationConfigVO> foundationConfigVOS = foundationConfigs.stream().filter(e -> e.getMealCount().equals(random)).collect(Collectors.toList()); |
| | | // 每种菜品分类需要几个菜的生成 |
| | | foundationConfigVOS.forEach(e -> { |
| | | int random1 = getRandom(e.getMinCount(), e.getMaxCount()); |
| | | List<TGoods> typeGoods = goods.stream().filter(m -> e.getTypeId().equals(m.getTypeId())).collect(Collectors.toList()); |
| | |
| | | tOrderMealGoods.setGoodsPicture(typeGood.getGoodsPicture()); |
| | | tOrderMealGoods.setGoodsSalePrice(typeGood.getSalePrice()); |
| | | tOrderMealGoods.setGoodsCount(1); |
| | | tOrderMealGoods.setTypeId(typeGood.getTypeId()); |
| | | orderMealGoods.add(tOrderMealGoods); |
| | | } |
| | | } |
| | |
| | | PageInfo<TDataGeneratorVO> pageInfo = new PageInfo<>(query.getPageNum(), query.getPageSize()); |
| | | List<TDataGeneratorVO> list = this.baseMapper.pageList(query,pageInfo); |
| | | List<Long> ids = list.stream().map(TDataGeneratorVO::getId).collect(Collectors.toList()); |
| | | if(CollectionUtils.isEmpty(ids)){ |
| | | return new PageInfo<>(); |
| | | } |
| | | if(query.getOrderType() == 1){ |
| | | List<TOrderMeal> orderMeals = orderMealService.list(Wrappers.lambdaQuery(TOrderMeal.class) |
| | | .in(TOrderMeal::getGeneratorId, ids)); |
| | |
| | | TDataGenerator dataGenerator = this.getById(query.getGeneratorId()); |
| | | TDataGeneratorMealDetailVO data = new TDataGeneratorMealDetailVO(); |
| | | BeanUtils.copyProperties(dataGenerator,data); |
| | | // 查询店铺 |
| | | TShop shop = shopService.getById(dataGenerator.getShopId()); |
| | | if(Objects.nonNull(shop)){ |
| | | data.setShopName(shop.getShopName()); |
| | | } |
| | | // 查询订单 |
| | | PageInfo<TOrderMealVO> pageInfo = orderMealService.pageListGenerator(query); |
| | | data.setOrderMealList(pageInfo); |
| | | // 统计支付金额 |
| | | Map<String, BigDecimal> map = orderMealService.getDataGeneratorMealDetail(query); |
| | | BigDecimal money = map.get("moneyPay"); |
| | | BigDecimal card = map.get("cardPay"); |
| | | BigDecimal weiXin = map.get("weiXinPay"); |
| | | BigDecimal ali = map.get("aliPay"); |
| | | BigDecimal other = map.get("otherPay"); |
| | | Map<String, Double> map = orderMealService.getDataGeneratorMealDetail(query); |
| | | BigDecimal money = new BigDecimal(map.get("moneyPay")).setScale(2,BigDecimal.ROUND_HALF_UP); |
| | | BigDecimal card = new BigDecimal(map.get("cardPay")).setScale(2,BigDecimal.ROUND_HALF_UP); |
| | | BigDecimal weiXin = new BigDecimal(map.get("weiXinPay")).setScale(2,BigDecimal.ROUND_HALF_UP); |
| | | BigDecimal ali = new BigDecimal(map.get("aliPay")).setScale(2,BigDecimal.ROUND_HALF_UP); |
| | | BigDecimal other = new BigDecimal(map.get("otherPay")).setScale(2,BigDecimal.ROUND_HALF_UP); |
| | | data.setMoneyPayAmount(money); |
| | | data.setCardPayAmount(card); |
| | | data.setWeiXinPayAmount(weiXin); |
| | |
| | | PageInfo<TOrderSaleVO> pageInfo = orderSaleService.pageList(orderSaleQuery); |
| | | data.setOrderMealList(pageInfo); |
| | | // 统计支付金额 |
| | | Map<String, BigDecimal> map = orderSaleService.getDataGeneratorMealDetail(query); |
| | | BigDecimal money = map.get("moneyPay"); |
| | | BigDecimal card = map.get("cardPay"); |
| | | BigDecimal weiXin = map.get("weiXinPay"); |
| | | BigDecimal ali = map.get("aliPay"); |
| | | BigDecimal other = map.get("otherPay"); |
| | | Map<String, Double> map = orderSaleService.getDataGeneratorSaleDetail(query); |
| | | BigDecimal money = new BigDecimal(map.get("moneyPay")).setScale(2,BigDecimal.ROUND_HALF_UP); |
| | | BigDecimal card = new BigDecimal(map.get("cardPay")).setScale(2,BigDecimal.ROUND_HALF_UP); |
| | | BigDecimal weiXin = new BigDecimal(map.get("weiXinPay")).setScale(2,BigDecimal.ROUND_HALF_UP); |
| | | BigDecimal ali = new BigDecimal(map.get("aliPay")).setScale(2,BigDecimal.ROUND_HALF_UP); |
| | | BigDecimal other = new BigDecimal(map.get("otherPay")).setScale(2,BigDecimal.ROUND_HALF_UP); |
| | | data.setMoneyPayAmount(money); |
| | | data.setCardPayAmount(card); |
| | | data.setWeiXinPayAmount(weiXin); |
| | |
| | | } |
| | | |
| | | private int getRandomPayType(Integer size,BigDecimal count) { |
| | | BigDecimal bigDecimal = new BigDecimal(size).multiply(count.divide(new BigDecimal(100))).setScale(0, RoundingMode.HALF_UP); |
| | | BigDecimal bigDecimal = new BigDecimal(size).multiply(count.divide(new BigDecimal(100))).setScale(0, BigDecimal.ROUND_FLOOR); |
| | | return Integer.parseInt(bigDecimal.toString()); |
| | | } |
| | | |