|
|
@ -8,6 +8,7 @@ import com.ruoyi.common.utils.DateUtils; |
|
|
|
import com.ruoyi.common.utils.ShiroUtils; |
|
|
|
import com.ruoyi.common.utils.StringUtils; |
|
|
|
import com.ruoyi.system.domain.SysAttach; |
|
|
|
import com.ruoyi.system.mapper.SysAttachMapper; |
|
|
|
import com.ruoyi.system.service.ISysAttachFileService; |
|
|
|
import com.ruoyi.system.service.ISysAttachService; |
|
|
|
import org.springframework.beans.factory.annotation.Autowired; |
|
|
@ -16,6 +17,7 @@ import com.ruoyi.aftersales.mapper.AftersalesOrderMapper; |
|
|
|
import com.ruoyi.aftersales.domain.AftersalesOrder; |
|
|
|
import com.ruoyi.aftersales.service.IAftersalesOrderService; |
|
|
|
import com.ruoyi.common.core.text.Convert; |
|
|
|
import org.springframework.transaction.annotation.Transactional; |
|
|
|
|
|
|
|
/** |
|
|
|
* 售后单Service业务层处理 |
|
|
@ -35,6 +37,10 @@ public class AftersalesOrderServiceImpl implements IAftersalesOrderService |
|
|
|
@Autowired |
|
|
|
private ISysAttachFileService attachFileService; |
|
|
|
|
|
|
|
|
|
|
|
@Autowired |
|
|
|
private SysAttachMapper sysAttachMapper; |
|
|
|
|
|
|
|
/** |
|
|
|
* 查询售后单 |
|
|
|
* |
|
|
@ -96,6 +102,7 @@ public class AftersalesOrderServiceImpl implements IAftersalesOrderService |
|
|
|
* @param aftersalesOrder 售后单 |
|
|
|
* @return 结果 |
|
|
|
*/ |
|
|
|
@Transactional |
|
|
|
@Override |
|
|
|
public int updateAftersalesOrder(AftersalesOrder aftersalesOrder) |
|
|
|
{ |
|
|
@ -104,17 +111,33 @@ public class AftersalesOrderServiceImpl implements IAftersalesOrderService |
|
|
|
aftersalesOrder.setUpdateTime(DateUtils.getNowDate()); |
|
|
|
Long aftersalesOrderId = aftersalesOrder.getAftersalesOrderId(); |
|
|
|
String fileIdStr = aftersalesOrder.getFileIdStr(); |
|
|
|
Long attachId = null; |
|
|
|
if (StringUtils.isNotEmpty(fileIdStr)){ |
|
|
|
//保存文件附件关联
|
|
|
|
SysAttach sysAttach = new SysAttach(); |
|
|
|
sysAttach.setCreateBy(ShiroUtils.getLoginName()); |
|
|
|
sysAttach.setCreateTime(new Date()); |
|
|
|
sysAttach.setSourceType("aftersalesOrder"); |
|
|
|
sysAttach.setSourceSubType("photo"); |
|
|
|
sysAttach.setRelId(aftersalesOrderId); |
|
|
|
attachService.insertSysAttach(sysAttach); |
|
|
|
SysAttach tempSysAttach = new SysAttach(); |
|
|
|
tempSysAttach.setSourceType("aftersalesOrder"); |
|
|
|
tempSysAttach.setSourceSubType("photo"); |
|
|
|
tempSysAttach.setRelId(aftersalesOrderId); |
|
|
|
List<SysAttach> sysAttaches = attachService.selectSysAttachList(tempSysAttach); |
|
|
|
if (StringUtils.isEmpty(sysAttaches)){ |
|
|
|
// 保存新的文件附件关联
|
|
|
|
SysAttach newSysAttach = new SysAttach(); |
|
|
|
newSysAttach.setCreateBy(loginName); |
|
|
|
newSysAttach.setCreateTime(new Date()); |
|
|
|
newSysAttach.setSourceType("aftersalesOrder"); |
|
|
|
newSysAttach.setSourceSubType("photo"); |
|
|
|
newSysAttach.setRelId(aftersalesOrderId); |
|
|
|
attachService.insertSysAttach(newSysAttach); |
|
|
|
// 假设insert后可以通过某种方式(如返回值)获取到新生成的ID,这里需要根据实际情况调整
|
|
|
|
attachId = newSysAttach.getId(); // 确保这里能正确获取到ID
|
|
|
|
}else { |
|
|
|
// 更新已存在的附件信息
|
|
|
|
SysAttach sysAttachToUpdate = sysAttaches.get(0); // 假设只有一条记录,或按需处理多条
|
|
|
|
sysAttachToUpdate.setUpdateBy(loginName); |
|
|
|
sysAttachToUpdate.setUpdateTime(new Date()); |
|
|
|
attachService.updateSysAttach(sysAttachToUpdate); // 假定有一个通用的更新方法
|
|
|
|
attachId = sysAttachToUpdate.getId(); |
|
|
|
} |
|
|
|
//更新附件与文件关联
|
|
|
|
Long attachId = sysAttach.getId(); |
|
|
|
List<String> fileIdList = Arrays.asList(fileIdStr.split(",")); |
|
|
|
attachFileService.updateAttachIdByIdList(attachId,fileIdList); |
|
|
|
} |
|
|
|