From fb8f99587701d0f82c0c106a0af88a49f92e03fc Mon Sep 17 00:00:00 2001
From: puhanshu <a9236326>
Date: 星期一, 27 十二月 2021 09:39:09 +0800
Subject: [PATCH] 活动相关大屏提交
---
springcloud_k8s_panzhihuazhihuishequ/service_community/src/main/java/com/panzhihua/service_community/service/impl/ComActWarehouseDonatesServiceImpl.java | 66 +++++++++++++++++++++++++++++++-
1 files changed, 63 insertions(+), 3 deletions(-)
diff --git a/springcloud_k8s_panzhihuazhihuishequ/service_community/src/main/java/com/panzhihua/service_community/service/impl/ComActWarehouseDonatesServiceImpl.java b/springcloud_k8s_panzhihuazhihuishequ/service_community/src/main/java/com/panzhihua/service_community/service/impl/ComActWarehouseDonatesServiceImpl.java
index 69896c0..1519cb7 100644
--- a/springcloud_k8s_panzhihuazhihuishequ/service_community/src/main/java/com/panzhihua/service_community/service/impl/ComActWarehouseDonatesServiceImpl.java
+++ b/springcloud_k8s_panzhihuazhihuishequ/service_community/src/main/java/com/panzhihua/service_community/service/impl/ComActWarehouseDonatesServiceImpl.java
@@ -14,28 +14,32 @@
import org.springframework.beans.BeanUtils;
import org.springframework.stereotype.Service;
+import org.springframework.transaction.annotation.Transactional;
-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.exceptions.ServiceException;
+import com.panzhihua.common.model.dtos.community.warehouse.ComActWarehouseApplyDTO;
import com.panzhihua.common.model.dtos.community.warehouse.ComActWarehouseDonatesDTO;
import com.panzhihua.common.model.dtos.community.warehouse.ExportDonatesDTO;
import com.panzhihua.common.model.dtos.community.warehouse.PageDonatesDTO;
import com.panzhihua.common.model.dtos.property.CommonPage;
import com.panzhihua.common.model.vos.R;
+import com.panzhihua.common.model.vos.community.warehouse.ComActWarehouseApplyVO;
import com.panzhihua.common.model.vos.community.warehouse.ComActWarehouseDonatesVO;
import com.panzhihua.common.model.vos.community.warehouse.ComActWarehouseOperationVO;
import com.panzhihua.common.model.vos.community.warehouse.DonatesStatisticsVO;
import com.panzhihua.common.model.vos.community.warehouse.WarehouseDonatesExcelVO;
+import com.panzhihua.service_community.dao.ComActWarehouseApplyDao;
import com.panzhihua.service_community.dao.ComActWarehouseDonatesDao;
import com.panzhihua.service_community.dao.ComActWarehouseOperationDao;
+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.service.ComActWarehouseDonatesService;
import lombok.extern.slf4j.Slf4j;
-import org.springframework.transaction.annotation.Transactional;
/**
* 爱心义仓/物品捐赠表(ComActWarehouseDonates)表服务实现类
@@ -49,6 +53,8 @@
@Resource
private ComActWarehouseOperationDao comActWarehouseOperationDao;
+ @Resource
+ private ComActWarehouseApplyDao comActWarehouseApplyDao;
@Override
public R pageList(CommonPage commonPage) {
@@ -68,6 +74,11 @@
List<ComActWarehouseDonates> donateList = list.stream().map(excelVO -> {
ComActWarehouseDonates donates = new ComActWarehouseDonates();
BeanUtils.copyProperties(excelVO, donates);
+ if (excelVO.getIsAnonymous().equals("是")) {
+ donates.setIsAnonymous(1);
+ } else {
+ donates.setIsAnonymous(2);
+ }
return donates;
}).collect(Collectors.toList());
this.baseMapper.batchInsertDonates(donateList);
@@ -225,6 +236,9 @@
}
BeanUtils.copyProperties(comActWarehouseDonatesDTO, comActWarehouseDonates);
Date nowDate = new Date();
+ if (nonNull(comActWarehouseDonatesDTO.getQuantity())) {
+ comActWarehouseDonates.setSurplusQuantity(comActWarehouseDonatesDTO.getQuantity());
+ }
comActWarehouseDonates.setSigningAt(nowDate);
comActWarehouseDonates.setStatus(2);
int result = this.baseMapper.updateById(comActWarehouseDonates);
@@ -234,8 +248,8 @@
comActWarehouseOperation.setUserId(comActWarehouseDonates.getSigningBy().intValue());
comActWarehouseOperation.setContent("工作人员完成了物品签收");
comActWarehouseOperation.setCreateTime(nowDate);
- comActWarehouseOperationDao.insert(comActWarehouseOperation);
comActWarehouseOperation.setType(ComActWarehouseOperation.type.bxs);
+ comActWarehouseOperationDao.insert(comActWarehouseOperation);
return R.ok();
}
return R.fail("签收失败");
@@ -291,4 +305,50 @@
donatesStatisticsVO.setTotalDec(donatesStatisticsVO.getTotalInc().intValue() - donatesStatisticsVO.getSurplus().intValue());
return R.ok(donatesStatisticsVO);
}
+
+ /**
+ * 社区后台物品领用
+ * @param comActWarehouseApplyDTO
+ * @return
+ */
+ @Override
+ @Transactional(rollbackFor = Exception.class)
+ public R applyDonates(ComActWarehouseApplyDTO comActWarehouseApplyDTO) {
+ List<ComActWarehouseApplyVO> applyItems = comActWarehouseApplyDTO.getApplyItems();
+ if (!applyItems.isEmpty()) {
+ Date nowDate = new Date();
+ applyItems.forEach(item -> {
+ Integer goodsId = item.getGoodsId();
+ Integer goodsNum = item.getGoodsNum();
+ if (isNull(goodsId) || isNull(goodsNum)) {
+ throw new ServiceException("请求参数有误");
+ }
+ ComActWarehouseDonates warehouseDonates = this.baseMapper.selectById(goodsId);
+ if (nonNull(warehouseDonates) && warehouseDonates.getSurplusQuantity() - goodsNum >= 0) {
+ warehouseDonates.setSurplusQuantity(warehouseDonates.getSurplusQuantity() - goodsNum);
+ this.baseMapper.updateById(warehouseDonates);
+
+ ComActWarehouseApply apply = new ComActWarehouseApply();
+ BeanUtils.copyProperties(comActWarehouseApplyDTO, apply);
+ apply.setActualTime(nowDate);
+ apply.setCreateTime(nowDate);
+ apply.setGoodsId(goodsId);
+ apply.setGoodsNum(goodsNum);
+ apply.setReserveTime(nowDate);
+ apply.setStatus(ComActWarehouseApplyVO.status.ylq);
+ apply.setWriteOffUserId(comActWarehouseApplyDTO.getOperateUserId());
+ comActWarehouseApplyDao.insert(apply);
+
+ ComActWarehouseOperation comActWarehouseOperation=new ComActWarehouseOperation();
+ comActWarehouseOperation.setGoodsId(goodsId);
+ comActWarehouseOperation.setCreateTime(nowDate);
+ comActWarehouseOperation.setContent("爱心传递给了"+comActWarehouseApplyDTO.getApplyName().charAt(0)+"**,"+"减少了"+comActWarehouseApplyDTO.getReason()+"的困难,谢谢你的帮助");
+ comActWarehouseOperation.setType(ComActWarehouseOperation.type.xs);
+ comActWarehouseOperation.setApplyId(apply.getId());
+ comActWarehouseOperationDao.insert(comActWarehouseOperation);
+ }
+ });
+ }
+ return R.ok("领取成功,部分物品可能因剩余数量不足领取失败,请以实际领取记录为准");
+ }
}
--
Gitblit v1.7.1