|
|
@@ -17,12 +17,10 @@
|
|
|
package org.springblade.box.tube.service.impl;
|
|
|
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
|
-import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
|
|
|
import com.baomidou.mybatisplus.core.metadata.IPage;
|
|
|
import com.baomidou.mybatisplus.core.toolkit.CollectionUtils;
|
|
|
import com.baomidou.mybatisplus.core.toolkit.ObjectUtils;
|
|
|
import com.baomidou.mybatisplus.core.toolkit.StringUtils;
|
|
|
-import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
|
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
|
import io.seata.spring.annotation.GlobalTransactional;
|
|
|
import lombok.AllArgsConstructor;
|
|
|
@@ -198,6 +196,16 @@ public class TradingBoxServiceImpl extends ServiceImpl<TradingBoxMapper, Trading
|
|
|
List<TradingBoxItem> tradingBoxItemList = tradingBox.getTradingBoxItemsList();
|
|
|
if (ObjectUtils.isNotNull(tradingBoxItemList) && tradingBoxItemList.size() > 0) {
|
|
|
for (TradingBoxItem tradingBoxItem : tradingBoxItemList) {
|
|
|
+ if ("BUY".equals(tradingBox.getType())) {
|
|
|
+ tradingBoxItem.setBoxSource("购买");
|
|
|
+ tradingBoxItem.setBoxStatus("待使用");
|
|
|
+ } else {
|
|
|
+ if (tradingBoxItem.getBoxSource().equals("购买")) {
|
|
|
+ tradingBoxItem.setBoxStatus("卖出");
|
|
|
+ } else {
|
|
|
+ tradingBoxItem.setBoxStatus("退租");
|
|
|
+ }
|
|
|
+ }
|
|
|
if (tradingBoxItem.getId() == null) {
|
|
|
tradingBoxItem.setCreateUser(AuthUtil.getUserId());
|
|
|
tradingBoxItem.setCreateTime(new Date());
|
|
|
@@ -777,6 +785,119 @@ public class TradingBoxServiceImpl extends ServiceImpl<TradingBoxMapper, Trading
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
+ * 起租,退租
|
|
|
+ *
|
|
|
+ * @param tradingBox
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ @Override
|
|
|
+ @Transactional(rollbackFor = Exception.class)
|
|
|
+ @GlobalTransactional(rollbackFor = Exception.class, timeoutMills = 12000000)
|
|
|
+ public TradingBox startingRent(TradingBox tradingBox) {
|
|
|
+ if ("1".equals(tradingBox.getRentType())) {
|
|
|
+ List<TradingBoxItem> tradingBoxItemList = tradingBox.getTradingBoxItemsList();
|
|
|
+ if (tradingBoxItemList.size() < 1) {
|
|
|
+ throw new RuntimeException("明细不能为空");
|
|
|
+ }
|
|
|
+ for (TradingBoxItem tradingBoxItem : tradingBoxItemList) {
|
|
|
+ tradingBoxItem.setLeaseCommencementDate(tradingBox.getRentDate());
|
|
|
+ tradingBoxItem.setUpdateUser(AuthUtil.getUserId());
|
|
|
+ tradingBoxItem.setUpdateTime(new Date());
|
|
|
+ tradingBoxItem.setUpdateUserName(AuthUtil.getUserName());
|
|
|
+ tradingBoxItemMapper.updateById(tradingBoxItem);
|
|
|
+ if (ObjectUtils.isNotNull(tradingBoxItem.getCode())) {
|
|
|
+ //更新箱档案信息
|
|
|
+ Archives archivesR = archivesMapper.selectOne(new LambdaQueryWrapper<Archives>().eq(Archives::getIsDeleted, 0).eq(Archives::getTenantId, AuthUtil.getTenantId()).eq(Archives::getCode, tradingBoxItem.getCode()));
|
|
|
+ Archives archives = new Archives();
|
|
|
+ if (ObjectUtils.isNotNull(archivesR)) {
|
|
|
+ BeanUtil.copy(archivesR, archives);
|
|
|
+ }
|
|
|
+
|
|
|
+ if (tradingBox.getType().equals("ZR")){
|
|
|
+ archives.setCode(tradingBoxItem.getCode());
|
|
|
+ archives.setName(tradingBoxItem.getBoxType());
|
|
|
+ archives.setVolume(tradingBoxItem.getVolume());
|
|
|
+ archives.setGorssWeight(tradingBoxItem.getGrossWeight());
|
|
|
+ archives.setStatus(tradingBoxItem.getStatus());
|
|
|
+ archives.setTypeId(tradingBoxItem.getBoxTypeId());
|
|
|
+ archives.setAddressId(tradingBoxItem.getAddressId());
|
|
|
+ archives.setAddress(tradingBoxItem.getAddress());
|
|
|
+ archives.setNewDate(tradingBoxItem.getNewDate());
|
|
|
+ archives.setEmptyWeight(tradingBoxItem.getEmptyWeight());
|
|
|
+ archives.setTare(tradingBoxItem.getTare());
|
|
|
+ archives.setLoadingWeight(tradingBoxItem.getLoadingWeight());
|
|
|
+ archives.setBoxMakingCompany(tradingBoxItem.getBoxMakingCompany());
|
|
|
+ archives.setBoxMakingCompanyId(tradingBoxItem.getBoxMakingCompanyId());
|
|
|
+ archives.setBoxMakingDate(tradingBoxItem.getBoxMakingDate());
|
|
|
+ archives.setLeaseCommencementDate(tradingBoxItem.getLeaseCommencementDate());
|
|
|
+ archives.setBoxAge(tradingBoxItem.getBoxAge());
|
|
|
+ archives.setPurchaseDate(tradingBox.getPurchaseDate());
|
|
|
+ archives.setContractNo(tradingBox.getContractNo());
|
|
|
+ archives.setBoxSource("租入");
|
|
|
+ archives.setBoxStatus("待使用");
|
|
|
+ archives.setLeasingCompanyId(tradingBox.getPurchaseCompanyId());
|
|
|
+ archives.setLeasingCompany(tradingBox.getPurchaseCompanyName());
|
|
|
+ if (ObjectUtils.isNotNull(archivesR)) {
|
|
|
+ archives.setUpdateTime(new Date());
|
|
|
+ archives.setUpdateUserName(AuthUtil.getUserName());
|
|
|
+ archives.setUpdateUser(AuthUtil.getUserId());
|
|
|
+ archivesMapper.updateById(archives);
|
|
|
+
|
|
|
+ } else {
|
|
|
+ archives.setBoxSource(tradingBoxItem.getBoxSource());
|
|
|
+ archives.setBoxStatus(tradingBoxItem.getBoxStatus());
|
|
|
+ archives.setCreateUser(AuthUtil.getUserId());
|
|
|
+ archives.setCreateTime(new Date());
|
|
|
+ archives.setCreateUserName(AuthUtil.getUserName());
|
|
|
+ archives.setTenantId(AuthUtil.getTenantId());
|
|
|
+ archivesMapper.insert(archives);
|
|
|
+ List<ArchivesFiles> archivesFilesList = BeanUtil.copy(tradingBoxItem.getTradingBoxFilesList(), ArchivesFiles.class);
|
|
|
+ for (ArchivesFiles archivesFiles : archivesFilesList) {
|
|
|
+ archivesFiles.setId(null);
|
|
|
+ archivesFiles.setPid(archives.getId());
|
|
|
+ archivesFiles.setFileName(archivesFiles.getLabel());
|
|
|
+ archivesFiles.setUrl(archivesFiles.getValue());
|
|
|
+ archivesFiles.setCreateUser(AuthUtil.getUserId());
|
|
|
+ archivesFiles.setCreateTime(new Date());
|
|
|
+ archivesFilesMapper.insert(archivesFiles);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }else{
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ //记录箱轨迹信息
|
|
|
+ ArchivesTrajectory archivesTrajectory = new ArchivesTrajectory();
|
|
|
+ if ("ZR".equals(tradingBox.getType())) {
|
|
|
+ archivesTrajectory.setStatus("租入");
|
|
|
+ } else if ("ZC".equals(tradingBox.getType())) {
|
|
|
+ archivesTrajectory.setStatus("租出");
|
|
|
+ }
|
|
|
+ archivesTrajectory.setContractNo(tradingBox.getContractNo());
|
|
|
+ archivesTrajectory.setBillType(tradingBox.getType());
|
|
|
+ archivesTrajectory.setCode(tradingBoxItem.getCode());
|
|
|
+ archivesTrajectory.setAddress(tradingBoxItem.getAddress());
|
|
|
+ archivesTrajectory.setNewDate(tradingBoxItem.getNewDate());
|
|
|
+ archivesTrajectory.setCreateTime(new Date());
|
|
|
+ archivesTrajectory.setCreateUser(AuthUtil.getUserId());
|
|
|
+ archivesTrajectory.setCreateUserName(AuthUtil.getUserName());
|
|
|
+ archivesTrajectory.setTenantId(AuthUtil.getTenantId());
|
|
|
+ archivesTrajectoryMapper.insert(archivesTrajectory);
|
|
|
+ } else {
|
|
|
+ throw new RuntimeException("箱号不能为空");
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ } else {
|
|
|
+
|
|
|
+ }
|
|
|
+ return null;
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
* 订单生成账单 并且推送财务消息
|
|
|
*
|
|
|
* @param billType 货款类型: 申请 收费 付费
|