| | |
| | | package com.panzhihua.service_community.service.impl; |
| | | |
| | | import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
| | | import com.baomidou.mybatisplus.core.metadata.IPage; |
| | | import com.baomidou.mybatisplus.extension.plugins.pagination.Page; |
| | | import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; |
| | | import com.panzhihua.common.model.dtos.property.CommonPage; |
| | | import com.panzhihua.common.model.vos.R; |
| | | import com.panzhihua.service_community.entity.ComActWarehouseApply; |
| | | import com.panzhihua.common.model.vos.community.warehouse.ComActWarehouseApplyVO; |
| | | import com.panzhihua.common.model.vos.community.warehouse.ComActWarehouseOperationVO; |
| | | import com.panzhihua.service_community.dao.ComActWarehouseDonatesDao; |
| | | import com.panzhihua.service_community.dao.ComActWarehouseOperationDao; |
| | | import com.panzhihua.service_community.dao.ComPbServiceTeamDao; |
| | | import com.panzhihua.service_community.dao.ComActWarehouseApplyDao; |
| | | import com.panzhihua.service_community.entity.ComActWarehouseApply; |
| | | import com.panzhihua.service_community.entity.ComActWarehouseDonates; |
| | | import com.panzhihua.service_community.entity.ComActWarehouseOperation; |
| | | import com.panzhihua.service_community.entity.ComPbServiceTeam; |
| | | import com.panzhihua.service_community.service.ComActWarehouseApplyService; |
| | | import lombok.extern.slf4j.Slf4j; |
| | | import org.springframework.stereotype.Service; |
| | | import org.springframework.transaction.annotation.Transactional; |
| | | |
| | | import javax.annotation.Resource; |
| | | import java.util.Date; |
| | | |
| | | /** |
| | | * 物品申请表(ComActWarehouseApply)表服务实现类 |
| | |
| | | @Slf4j |
| | | @Service |
| | | public class ComActWarehouseApplyServiceImpl extends ServiceImpl<ComActWarehouseApplyDao, ComActWarehouseApply> implements ComActWarehouseApplyService { |
| | | |
| | | @Resource |
| | | private ComActWarehouseApplyDao comActWarehouseApplyDao; |
| | | @Resource |
| | | private ComPbServiceTeamDao comPbServiceTeamDao; |
| | | @Resource |
| | | private ComActWarehouseDonatesDao comActWarehouseDonatesDao; |
| | | @Resource |
| | | private ComActWarehouseOperationDao comActWarehouseOperationDao; |
| | | @Override |
| | | public R pageList(CommonPage commonPage) { |
| | | return null; |
| | | IPage<ComActWarehouseApplyVO> iPage=this.comActWarehouseApplyDao.queryAll(new Page<>(commonPage.getPage(),commonPage.getSize()),commonPage); |
| | | return R.ok(iPage); |
| | | } |
| | | |
| | | @Override |
| | | public R selectStatics(Long communityId) { |
| | | return R.ok(this.comActWarehouseApplyDao.selectStatics(communityId)); |
| | | } |
| | | |
| | | @Override |
| | | public R selectById(Integer id) { |
| | | return R.ok(this.comActWarehouseApplyDao.selectById(id)); |
| | | } |
| | | |
| | | @Override |
| | | public R check(String phone) { |
| | | Integer count=comPbServiceTeamDao.selectCount(new QueryWrapper<ComPbServiceTeam>().lambda().eq(ComPbServiceTeam::getPhone,phone)); |
| | | return count>0? R.ok():R.fail("无权限"); |
| | | } |
| | | @Transactional(rollbackFor = Exception.class) |
| | | @Override |
| | | public R update(ComActWarehouseApply comActWarehouseApply) { |
| | | ComActWarehouseApplyVO comActWarehouseApply1=this.comActWarehouseApplyDao.selectById(comActWarehouseApply.getId()); |
| | | if(comActWarehouseApply.getStatus().equals(ComActWarehouseApplyVO.status.ylq)){ |
| | | ComActWarehouseDonates comActWarehouseDonates=this.comActWarehouseDonatesDao.selectById(comActWarehouseApply1.getGoodsId()); |
| | | if(comActWarehouseDonates!=null&&comActWarehouseDonates.getSurplusQuantity()>=comActWarehouseApply1.getGoodsNum()){ |
| | | comActWarehouseDonates.setSurplusQuantity(comActWarehouseDonates.getSurplusQuantity()-comActWarehouseApply1.getGoodsNum()); |
| | | this.comActWarehouseDonatesDao.updateById(comActWarehouseDonates); |
| | | ComActWarehouseOperation comActWarehouseOperation=new ComActWarehouseOperation(); |
| | | comActWarehouseOperation.setGoodsId(comActWarehouseApply1.getGoodsId()); |
| | | comActWarehouseOperation.setCreateTime(new Date()); |
| | | comActWarehouseOperation.setType(ComActWarehouseOperation.type.xs); |
| | | comActWarehouseOperation.setApplyId(comActWarehouseApply.getId()); |
| | | this.comActWarehouseOperationDao.insert(comActWarehouseOperation); |
| | | } |
| | | else { |
| | | return R.fail("库存不足"); |
| | | } |
| | | } |
| | | return R.ok(this.comActWarehouseApplyDao.updateById(comActWarehouseApply)); |
| | | } |
| | | |
| | | @Override |
| | | public R export(CommonPage commonPage) { |
| | | return R.ok(this.comActWarehouseApplyDao.queryAll(commonPage)); |
| | | } |
| | | } |