|
|
|
@ -1,16 +1,27 @@ |
|
|
|
|
package com.daqing.financial.guarantee.service.impl; |
|
|
|
|
|
|
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
|
|
|
|
import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper; |
|
|
|
|
import com.baomidou.mybatisplus.core.metadata.IPage; |
|
|
|
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page; |
|
|
|
|
import com.daqing.financial.guarantee.feign.HrmsFeignService; |
|
|
|
|
import com.daqing.financial.guarantee.mapper.DgGuaranteeLetterAssignUserMapper; |
|
|
|
|
import com.daqing.financial.guarantee.model.request.GuaranteeLetterRequest; |
|
|
|
|
import com.daqing.financial.guarantee.model.request.GuaranteeLetterAddRequest; |
|
|
|
|
import com.daqing.financial.guarantee.model.request.GuaranteeLetterQueryRequest; |
|
|
|
|
import com.daqing.financial.guarantee.model.request.GuaranteeLetterUpdateStatusRequest; |
|
|
|
|
import com.daqing.financial.guarantee.model.response.GuaranteeLetterResponse; |
|
|
|
|
import com.daqing.financial.guarantee.service.IDgGuaranteeLetterAssignUserService; |
|
|
|
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; |
|
|
|
|
import com.daqing.framework.domain.guarantee.DgGuaranteeLetterAssignUser; |
|
|
|
|
import com.daqing.framework.domain.guarantee.response.EmployeeMessageResponse; |
|
|
|
|
import com.daqing.framework.model.response.PromptSuccess; |
|
|
|
|
import com.daqing.framework.model.response.ResponseResult; |
|
|
|
|
import com.daqing.framework.utils.PageUtils; |
|
|
|
|
import org.apache.commons.lang3.StringUtils; |
|
|
|
|
import org.springframework.beans.factory.annotation.Autowired; |
|
|
|
|
import org.springframework.stereotype.Service; |
|
|
|
|
import org.springframework.transaction.annotation.Transactional; |
|
|
|
|
|
|
|
|
|
import java.util.List; |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* <p> |
|
|
|
@ -22,15 +33,93 @@ import org.springframework.stereotype.Service; |
|
|
|
|
*/ |
|
|
|
|
@Service |
|
|
|
|
public class DgGuaranteeLetterAssignUserServiceImpl extends ServiceImpl<DgGuaranteeLetterAssignUserMapper, DgGuaranteeLetterAssignUser> implements IDgGuaranteeLetterAssignUserService { |
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
|
public PageUtils queryPage(Integer page, Integer size, String customerNumberOrName, Integer status) { |
|
|
|
|
if (page==null){ |
|
|
|
|
page=1; |
|
|
|
|
public PageUtils queryPage(GuaranteeLetterQueryRequest guaranteeLetterQueryRequest) { |
|
|
|
|
//取出条件
|
|
|
|
|
Integer page = guaranteeLetterQueryRequest.getPage(); |
|
|
|
|
Integer size = guaranteeLetterQueryRequest.getSize(); |
|
|
|
|
Integer status = guaranteeLetterQueryRequest.getStatus(); |
|
|
|
|
//a角和b角根据用户id查询,经理根据角色id查询
|
|
|
|
|
Integer userId = guaranteeLetterQueryRequest.getUserId(); |
|
|
|
|
Integer roleId = guaranteeLetterQueryRequest.getRoleId(); |
|
|
|
|
String customerNumberOrName = guaranteeLetterQueryRequest.getCustomerNumberOrName(); |
|
|
|
|
//分页条件查询
|
|
|
|
|
IPage<GuaranteeLetterResponse> guaranteeLetterVO = baseMapper.pageByCondition(new Page(page,size),userId,roleId,status,customerNumberOrName); |
|
|
|
|
|
|
|
|
|
return new PageUtils(guaranteeLetterVO); |
|
|
|
|
} |
|
|
|
|
if (size==null){ |
|
|
|
|
size=10; |
|
|
|
|
|
|
|
|
|
@Transactional |
|
|
|
|
@Override |
|
|
|
|
public boolean saveGuaranteeLetter(GuaranteeLetterAddRequest guaranteeLetterAddRequest) { |
|
|
|
|
//获取A角用户
|
|
|
|
|
Integer aRole = guaranteeLetterAddRequest.getARole(); |
|
|
|
|
//获取B角用户
|
|
|
|
|
Integer bRole = guaranteeLetterAddRequest.getBRole(); |
|
|
|
|
//获取担保函信息
|
|
|
|
|
DgGuaranteeLetterAssignUser guaranteeLetterAssignUser = guaranteeLetterAddRequest.getDgGuaranteeLetterAssignUser(); |
|
|
|
|
//添加A角用户
|
|
|
|
|
guaranteeLetterAssignUser.setUserId(aRole); |
|
|
|
|
baseMapper.insert(guaranteeLetterAssignUser); |
|
|
|
|
//添加B角用户
|
|
|
|
|
guaranteeLetterAssignUser.setUserId(bRole); |
|
|
|
|
int insert = baseMapper.insert(guaranteeLetterAssignUser); |
|
|
|
|
return insert>0; |
|
|
|
|
} |
|
|
|
|
IPage<GuaranteeLetterResponse> guaranteeLetterVO = baseMapper.pageByCondition(new Page(page, size), customerNumberOrName, status); |
|
|
|
|
return new PageUtils(guaranteeLetterVO); |
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
|
public boolean updateGuaranteeLetterStatus(GuaranteeLetterUpdateStatusRequest guaranteeLetterUpdateStatusRequest) { |
|
|
|
|
Integer businessId = guaranteeLetterUpdateStatusRequest.getBusinessId(); |
|
|
|
|
Integer currentUser = guaranteeLetterUpdateStatusRequest.getCurrentUser(); |
|
|
|
|
Integer status = guaranteeLetterUpdateStatusRequest.getStatus(); |
|
|
|
|
|
|
|
|
|
//根据业务id查询记录数
|
|
|
|
|
QueryWrapper<DgGuaranteeLetterAssignUser> wrapper = new QueryWrapper<>(); |
|
|
|
|
wrapper.eq("business_id",businessId); |
|
|
|
|
Integer count = baseMapper.selectCount(wrapper); |
|
|
|
|
//只有两条数据,经理还未有数据
|
|
|
|
|
if (count==2){ |
|
|
|
|
//查询当前用户
|
|
|
|
|
QueryWrapper<DgGuaranteeLetterAssignUser> queryWrapper = new QueryWrapper<>(); |
|
|
|
|
queryWrapper.eq("business_id",businessId).eq("user_id",currentUser); |
|
|
|
|
DgGuaranteeLetterAssignUser guaranteeLetterAssignUser = baseMapper.selectOne(queryWrapper); |
|
|
|
|
guaranteeLetterAssignUser.setStatus(status); |
|
|
|
|
//根据当前用户更新状态
|
|
|
|
|
int i = baseMapper.updateById(guaranteeLetterAssignUser); |
|
|
|
|
//当状态为确认时,判断另一个用户是否确认
|
|
|
|
|
if (status==3){ |
|
|
|
|
//查询另一个用户
|
|
|
|
|
QueryWrapper<DgGuaranteeLetterAssignUser> anotherQueryWrapper = new QueryWrapper<>(); |
|
|
|
|
anotherQueryWrapper.eq("business_id",businessId).ne("user_id",currentUser); |
|
|
|
|
DgGuaranteeLetterAssignUser anotherGuaranteeLetterAssignUser = baseMapper.selectOne(anotherQueryWrapper); |
|
|
|
|
Integer anotherStatus = anotherGuaranteeLetterAssignUser.getStatus(); |
|
|
|
|
//如果另一个用户也确认,为资产部经理添加数据
|
|
|
|
|
if (anotherStatus==3){ |
|
|
|
|
Integer companyId = anotherGuaranteeLetterAssignUser.getCompanyId(); |
|
|
|
|
DgGuaranteeLetterAssignUser dgGuaranteeLetterAssignUser = new DgGuaranteeLetterAssignUser(); |
|
|
|
|
dgGuaranteeLetterAssignUser.setBusinessId(businessId); |
|
|
|
|
dgGuaranteeLetterAssignUser.setCompanyId(companyId); |
|
|
|
|
//添加资产部经理角色
|
|
|
|
|
dgGuaranteeLetterAssignUser.setRoleId(PromptSuccess.ZC_JL_ID); |
|
|
|
|
int insert = baseMapper.insert(dgGuaranteeLetterAssignUser); |
|
|
|
|
return insert > 0; |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
return i > 0; |
|
|
|
|
//经理有数据,当前确认用户拥有经理角色,确认担保函
|
|
|
|
|
}else { |
|
|
|
|
//当前用户角色为经理
|
|
|
|
|
QueryWrapper<DgGuaranteeLetterAssignUser> queryRoleWrapper = new QueryWrapper<>(); |
|
|
|
|
queryRoleWrapper.eq("business_id",businessId).eq("role_id",PromptSuccess.ZC_JL_ID); |
|
|
|
|
DgGuaranteeLetterAssignUser guaranteeLetterAssignRole = baseMapper.selectOne(queryRoleWrapper); |
|
|
|
|
guaranteeLetterAssignRole.setUserId(currentUser); |
|
|
|
|
guaranteeLetterAssignRole.setStatus(status); |
|
|
|
|
//根据当前用户角色更新状态
|
|
|
|
|
int i = baseMapper.updateById(guaranteeLetterAssignRole); |
|
|
|
|
//TODO 经理确认成功后,向回款确认添加数据
|
|
|
|
|
return i > 0; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|