| | |
| | | import org.springframework.beans.BeanUtils; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.web.bind.annotation.*; |
| | | import oshi.driver.unix.aix.Ls; |
| | | |
| | | import java.time.LocalDateTime; |
| | | import java.util.List; |
| | |
| | | */ |
| | | @ApiOperation( value = "添加基础设置") |
| | | @PostMapping(value = "/add") |
| | | public AjaxResult<Boolean> add(@RequestBody TFoundationPersonDTO dto) { |
| | | dto.setCreateTime(LocalDateTime.now()); |
| | | public AjaxResult<Boolean> add(@RequestBody List<TFoundationPersonDTO> dto) { |
| | | foundationPersonService.add(dto); |
| | | return AjaxResult.success(); |
| | | } |
| | |
| | | */ |
| | | @ApiOperation( value = "修改基础设置") |
| | | @PostMapping(value = "/update") |
| | | public AjaxResult<Boolean> update(@RequestBody TFoundationPersonDTO dto) { |
| | | public AjaxResult<Boolean> update(@RequestBody List<TFoundationPersonDTO> dto) { |
| | | foundationPersonService.edit(dto); |
| | | return AjaxResult.success(); |
| | | } |
| | |
| | | import com.ruoyi.common.core.domain.AjaxResult; |
| | | import com.ruoyi.framework.web.service.TokenService; |
| | | import com.ruoyi.system.domain.TGoodsType; |
| | | import com.ruoyi.system.domain.TShop; |
| | | import com.ruoyi.system.service.TGoodsTypeService; |
| | | import com.ruoyi.system.service.TShopService; |
| | | import io.swagger.annotations.Api; |
| | | import io.swagger.annotations.ApiOperation; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | |
| | | |
| | | private final TGoodsTypeService goodsTypeService; |
| | | private final TokenService tokenService; |
| | | private final TShopService shopService; |
| | | |
| | | @Autowired |
| | | public TGoodsTypeController(TGoodsTypeService goodsTypeService, TokenService tokenService) { |
| | | public TGoodsTypeController(TGoodsTypeService goodsTypeService, TokenService tokenService, TShopService shopService) { |
| | | this.goodsTypeService = goodsTypeService; |
| | | this.tokenService = tokenService; |
| | | this.shopService = shopService; |
| | | } |
| | | |
| | | /** |
| | |
| | | */ |
| | | @ApiOperation( value = "查询商品分类列表-后台使用") |
| | | @GetMapping(value = "/getList") |
| | | public AjaxResult<List<TGoodsType>> getList(@RequestParam("shopId") Long shopId) { |
| | | public AjaxResult<List<TGoodsType>> getList(@RequestParam("mealType") Integer mealType) { |
| | | // 获取餐饮分类店铺id |
| | | TShop one = shopService.getOne(Wrappers.lambdaQuery(TShop.class) |
| | | .eq(TShop::getMealType, mealType) |
| | | .last("LIMIT 1")); |
| | | LambdaQueryWrapper<TGoodsType> wrapper = new LambdaQueryWrapper<>(); |
| | | wrapper.eq(TGoodsType::getShopId, shopId); |
| | | wrapper.eq(TGoodsType::getShopId, one.getId()); |
| | | return AjaxResult.success(goodsTypeService.list(wrapper)); |
| | | } |
| | | |
| | |
| | | @ApiModelProperty(value = "店铺id") |
| | | @TableField("shopId") |
| | | private Long shopId; |
| | | |
| | | @ApiModelProperty(value = "餐饮类型 1=中餐 2=火锅") |
| | | @TableField("mealType") |
| | | private Integer mealType; |
| | | @ApiModelProperty(value = "创建时间") |
| | | @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8") |
| | | @TableField("createTime") |
| | |
| | | @TableField("userId") |
| | | private Long userId; |
| | | |
| | | @ApiModelProperty(value = "餐饮类型 1=中餐 2=火锅") |
| | | @TableField("mealType") |
| | | private Integer mealType; |
| | | |
| | | } |
| | |
| | | * 查询所有的人数用餐标准 |
| | | * @return |
| | | */ |
| | | List<TFoundationConfigVO> getList(@Param("shopId") Long shopId); |
| | | List<TFoundationConfigVO> getList(@Param("mealType") Integer mealType); |
| | | |
| | | } |
| | |
| | | * 查询所有的人数用餐标准 |
| | | * @return |
| | | */ |
| | | List<TFoundationConfigVO> getList(Long shopId); |
| | | List<TFoundationConfigVO> getList(Integer mealType); |
| | | |
| | | } |
| | |
| | | |
| | | import com.baomidou.mybatisplus.extension.service.IService; |
| | | import com.ruoyi.common.basic.PageInfo; |
| | | import com.ruoyi.system.domain.TFoundationConfig; |
| | | import com.ruoyi.system.domain.TFoundationPerson; |
| | | import com.ruoyi.system.dto.TFoundationPersonDTO; |
| | | import com.ruoyi.system.query.TFoundationPersonQuery; |
| | |
| | | * @param dto |
| | | * @return |
| | | */ |
| | | void add(TFoundationPersonDTO dto); |
| | | void add(List<TFoundationPersonDTO> dto); |
| | | |
| | | /** |
| | | * 修改基础设置 |
| | | * @param dto |
| | | */ |
| | | void edit(TFoundationPersonDTO dto); |
| | | void edit(List<TFoundationPersonDTO> dto); |
| | | |
| | | /** |
| | | * 查询基础设置列表 |
| | |
| | | */ |
| | | PageInfo<TFoundationPersonVO> getList(TFoundationPersonQuery query); |
| | | |
| | | /** |
| | | * 判断是否有重复人数 |
| | | * @param list |
| | | * @return |
| | | */ |
| | | boolean hasDuplicateId(List<TFoundationPersonDTO> list); |
| | | |
| | | } |
| | |
| | | @Autowired |
| | | private TFoundationConfigService foundationConfigService; |
| | | @Autowired |
| | | private TFoundationPersonService foundationPersonService; |
| | | @Autowired |
| | | private TGoodsService goodsService; |
| | | @Autowired |
| | | private TOrderMealService orderMealService; |
| | |
| | | dataGenerator.setOtherPay(dto.getOtherProportion()); |
| | | this.save(dataGenerator); |
| | | long start = System.currentTimeMillis(); |
| | | // 查询所有的人数用餐标准 |
| | | List<TFoundationConfigVO> foundationConfigs = foundationConfigService.getList(dto.getShopId()); |
| | | TShop shop = shopService.getById(dto.getShopId()); |
| | | List<TFoundationConfigVO> foundationConfigs = foundationConfigService.getList(shop.getMealType()); |
| | | if(CollectionUtils.isEmpty(foundationConfigs)){ |
| | | throw new ServiceException("请先添加该店铺用餐标准"); |
| | | throw new ServiceException("请先添加中餐或火锅用餐标准"); |
| | | } |
| | | // 查询所有桌子 |
| | | List<TBoard> boards = boardService.list(Wrappers.lambdaQuery(TBoard.class) |
| | |
| | | public class TFoundationConfigServiceImpl extends ServiceImpl<TFoundationConfigMapper, TFoundationConfig> implements TFoundationConfigService { |
| | | |
| | | @Override |
| | | public List<TFoundationConfigVO> getList(Long shopId) { |
| | | return this.baseMapper.getList(shopId); |
| | | public List<TFoundationConfigVO> getList(Integer mealType) { |
| | | return this.baseMapper.getList(mealType); |
| | | } |
| | | } |
| | |
| | | import com.ruoyi.system.vo.TFoundationPersonVO; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.stereotype.Service; |
| | | import org.springframework.transaction.annotation.Transactional; |
| | | import org.springframework.util.CollectionUtils; |
| | | |
| | | import java.util.Comparator; |
| | | import java.util.HashSet; |
| | | import java.util.List; |
| | | import java.util.stream.Collectors; |
| | | |
| | |
| | | private TFoundationConfigService foundationConfigService; |
| | | |
| | | @Override |
| | | public void add(TFoundationPersonDTO dto) { |
| | | |
| | | long count1 = this.count(Wrappers.lambdaQuery(TFoundationPerson.class) |
| | | .eq(TFoundationPerson::getShopId, dto.getShopId()) |
| | | .eq(TFoundationPerson::getMealCount, dto.getMealCount())); |
| | | if(count1>0){ |
| | | throw new ServiceException("该店铺已存在该用餐人数设置"); |
| | | @Transactional(rollbackFor = Exception.class) |
| | | public void add(List<TFoundationPersonDTO> dto) { |
| | | for (TFoundationPersonDTO tFoundationPersonDTO : dto) { |
| | | List<TFoundationConfig> foundationConfigs = tFoundationPersonDTO.getFoundationConfigs(); |
| | | long count = foundationConfigs.stream().map(TFoundationConfig::getTypeId).distinct().count(); |
| | | if(foundationConfigs.size()!=count){ |
| | | throw new ServiceException("菜品重复设置"); |
| | | } |
| | | this.save(tFoundationPersonDTO); |
| | | // 添加菜品 |
| | | foundationConfigs.forEach(item -> { |
| | | item.setPersonId(tFoundationPersonDTO.getId()); |
| | | }); |
| | | foundationConfigService.saveBatch(foundationConfigs); |
| | | } |
| | | |
| | | List<TFoundationConfig> foundationConfigs = dto.getFoundationConfigs(); |
| | | long count = foundationConfigs.stream().map(TFoundationConfig::getTypeId).distinct().count(); |
| | | if(foundationConfigs.size()!=count){ |
| | | throw new ServiceException("菜品重复设置"); |
| | | } |
| | | // 添加人数 |
| | | this.save(dto); |
| | | // 添加菜品 |
| | | foundationConfigs.forEach(item -> { |
| | | item.setPersonId(dto.getId()); |
| | | }); |
| | | foundationConfigService.saveBatch(foundationConfigs); |
| | | } |
| | | |
| | | @Override |
| | | public void edit(TFoundationPersonDTO dto) { |
| | | long count1 = this.count(Wrappers.lambdaQuery(TFoundationPerson.class) |
| | | .eq(TFoundationPerson::getShopId, dto.getShopId()) |
| | | .eq(TFoundationPerson::getMealCount, dto.getMealCount()) |
| | | .ne(TFoundationPerson::getId,dto.getId())); |
| | | if(count1>0){ |
| | | throw new ServiceException("该店铺已存在该用餐人数设置"); |
| | | @Transactional(rollbackFor = Exception.class) |
| | | public void edit(List<TFoundationPersonDTO> dto) { |
| | | |
| | | for (TFoundationPersonDTO tFoundationPersonDTO : dto) { |
| | | List<TFoundationConfig> foundationConfigs = tFoundationPersonDTO.getFoundationConfigs(); |
| | | long count = foundationConfigs.stream().map(TFoundationConfig::getTypeId).distinct().count(); |
| | | if(foundationConfigs.size()!=count){ |
| | | throw new ServiceException("菜品重复设置"); |
| | | } |
| | | // 添加人数 |
| | | this.updateById(tFoundationPersonDTO); |
| | | // 删除菜品 |
| | | foundationConfigService.remove(Wrappers.lambdaQuery(TFoundationConfig.class) |
| | | .eq(TFoundationConfig::getPersonId,tFoundationPersonDTO.getId())); |
| | | // 添加菜品 |
| | | foundationConfigs.forEach(item -> { |
| | | item.setPersonId(tFoundationPersonDTO.getId()); |
| | | }); |
| | | foundationConfigService.saveBatch(foundationConfigs); |
| | | } |
| | | |
| | | List<TFoundationConfig> foundationConfigs = dto.getFoundationConfigs(); |
| | | long count = foundationConfigs.stream().map(TFoundationConfig::getTypeId).distinct().count(); |
| | | if(foundationConfigs.size()!=count){ |
| | | throw new ServiceException("菜品重复设置"); |
| | | } |
| | | // 添加人数 |
| | | this.updateById(dto); |
| | | // 删除菜品 |
| | | foundationConfigService.remove(Wrappers.lambdaQuery(TFoundationConfig.class) |
| | | .eq(TFoundationConfig::getPersonId,dto.getId())); |
| | | // 添加菜品 |
| | | foundationConfigs.forEach(item -> { |
| | | item.setPersonId(dto.getId()); |
| | | }); |
| | | foundationConfigService.saveBatch(foundationConfigs); |
| | | } |
| | | |
| | | @Override |
| | |
| | | pageInfo.setRecords(list); |
| | | return pageInfo; |
| | | } |
| | | |
| | | @Override |
| | | public boolean hasDuplicateId(List<TFoundationPersonDTO> list) { |
| | | HashSet<Integer> countSet = new HashSet<>(); |
| | | for (TFoundationPersonDTO dto : list) { |
| | | if (!countSet.add(dto.getMealCount())) { |
| | | return true; // 发现重复的人数 |
| | | } |
| | | } |
| | | return false; // 没有发现重复的人数 |
| | | } |
| | | } |
| | |
| | | |
| | | @ApiModelProperty(value = "用餐人数") |
| | | private Integer mealCount; |
| | | @ApiModelProperty(value = "餐饮类型") |
| | | private Integer mealType; |
| | | @ApiModelProperty(value = "店铺id") |
| | | private Long shopId; |
| | | |
| | |
| | | id, personId,typeId, minCount, maxCount |
| | | </sql> |
| | | <select id="getList" resultType="com.ruoyi.system.vo.TFoundationConfigVO"> |
| | | SELECT tfc.id, tfc.personId,tfc.typeId, tfc.minCount, tfc.maxCount,tfp.mealCount,tfp.shopId |
| | | SELECT tfc.id, tfc.personId,tfc.typeId, tfc.minCount, tfc.maxCount,tfp.mealCount,tfp.shopId,tfp.mealType |
| | | FROM t_foundation_config tfc |
| | | LEFT JOIN t_foundation_person tfp ON tfp.id = tfc.personId |
| | | where tfp.shopId = #{shopId} |
| | | where tfp.mealType = #{mealType} |
| | | </select> |
| | | |
| | | </mapper> |
| | |
| | | <result column="mealCount" property="mealCount" /> |
| | | <result column="createTime" property="createTime" /> |
| | | <result column="shopId" property="shopId" /> |
| | | <result column="mealType" property="mealType" /> |
| | | </resultMap> |
| | | |
| | | <!-- 通用查询结果列 --> |
| | |
| | | </sql> |
| | | <select id="getList" resultType="com.ruoyi.system.vo.TFoundationPersonVO"> |
| | | select |
| | | tfp.id, tfp.mealCount,tfp.createTime,tfp.shopId,ts.shopName |
| | | tfp.id, tfp.mealCount,tfp.createTime,tfp.shopId,tfp.mealType,ts.shopName |
| | | from t_foundation_person tfp |
| | | left join t_shop ts on ts.id = tfp.shopId |
| | | <where> |
| | |
| | | <result column="createBy" property="createBy" /> |
| | | <result column="updateBy" property="updateBy" /> |
| | | <result column="userId" property="userId" /> |
| | | <result column="mealType" property="mealType" /> |
| | | </resultMap> |
| | | |
| | | <!-- 通用查询结果列 --> |
| | | <sql id="Base_Column_List"> |
| | | id, shopType, shopName,shopHead, shopStyle, systemName, systemLogo, businessLicense,status,account, createTime, updateTime, disabled, createBy, updateBy,userId |
| | | id, shopType, shopName,shopHead, shopStyle, systemName, systemLogo, businessLicense,status,account, |
| | | createTime, updateTime, disabled, createBy, updateBy,userId,mealType |
| | | </sql> |
| | | <select id="pageList" resultType="com.ruoyi.system.vo.TShopVO"> |
| | | select id, shopType, shopName,shopHead, shopStyle, systemName, systemLogo, businessLicense, |
| | | status,account, createTime, updateTime, disabled, createBy, updateBy,userId |
| | | status,account, createTime, updateTime, disabled, createBy, updateBy,userId,mealType |
| | | from t_shop ts |
| | | <where> |
| | | <if test="query.shopType != null"> |