|
@@ -91,10 +91,13 @@ public class ExpenseSheetServiceImpl extends ServiceImpl<ExpenseSheetMapper, Exp
|
|
HttpRespMsg msg = new HttpRespMsg();
|
|
HttpRespMsg msg = new HttpRespMsg();
|
|
User user = userMapper.selectById(userId);
|
|
User user = userMapper.selectById(userId);
|
|
List<SysRichFunction> functionDeptList = sysFunctionMapper.getRoleFunctions(user.getRoleId(), "费用审核");
|
|
List<SysRichFunction> functionDeptList = sysFunctionMapper.getRoleFunctions(user.getRoleId(), "费用审核");
|
|
|
|
+ boolean isAuditor = functionDeptList.size() > 0;
|
|
boolean isNew = false;
|
|
boolean isNew = false;
|
|
if (sheet.getId() == null) {
|
|
if (sheet.getId() == null) {
|
|
- if(functionDeptList.size()>0){
|
|
|
|
|
|
+ if (isAuditor) {
|
|
sheet.setStatus(0);
|
|
sheet.setStatus(0);
|
|
|
|
+ } else {
|
|
|
|
+ sheet.setStatus(1);
|
|
}
|
|
}
|
|
isNew = true;
|
|
isNew = true;
|
|
//检查code不能重复
|
|
//检查code不能重复
|
|
@@ -104,8 +107,18 @@ public class ExpenseSheetServiceImpl extends ServiceImpl<ExpenseSheetMapper, Exp
|
|
msg.setError(MessageUtils.message("other.billNoExist"));
|
|
msg.setError(MessageUtils.message("other.billNoExist"));
|
|
return msg;
|
|
return msg;
|
|
}
|
|
}
|
|
|
|
+ } else {
|
|
|
|
+ //如果是驳回状态,改成待审核,否则不变
|
|
|
|
+ if (sheet.getStatus() == 2) {
|
|
|
|
+ if (isAuditor) {
|
|
|
|
+ sheet.setStatus(0);
|
|
|
|
+ } else {
|
|
|
|
+ sheet.setStatus(1);
|
|
|
|
+ }
|
|
|
|
+ }
|
|
}
|
|
}
|
|
- sheet.setStatus(1);
|
|
|
|
|
|
+
|
|
|
|
+
|
|
sheet.setDenyReason(null);
|
|
sheet.setDenyReason(null);
|
|
sheet.setOperatorId(userId);//设置操作人id
|
|
sheet.setOperatorId(userId);//设置操作人id
|
|
JSONArray array = JSONArray.parseArray(items);
|
|
JSONArray array = JSONArray.parseArray(items);
|
|
@@ -113,55 +126,57 @@ public class ExpenseSheetServiceImpl extends ServiceImpl<ExpenseSheetMapper, Exp
|
|
sheet.setCompanyId(user.getCompanyId());
|
|
sheet.setCompanyId(user.getCompanyId());
|
|
if (isNew) {
|
|
if (isNew) {
|
|
expenseSheetMapper.insert(sheet);
|
|
expenseSheetMapper.insert(sheet);
|
|
- WxCorpInfo wxCorpInfo = wxCorpInfoMapper.selectOne(new QueryWrapper<WxCorpInfo>().eq("company_id", user.getCompanyId()));
|
|
|
|
- if(wxCorpInfo!=null){
|
|
|
|
- //获取具有费用报销审核权限的人员
|
|
|
|
- SysFunction sysFunction = sysFunctionMapper.selectOne(new QueryWrapper<SysFunction>().eq("name", "费用审核"));
|
|
|
|
- List<SysRoleFunction> sysRoleFunctions = sysRoleFunctionMapper.selectList(new QueryWrapper<SysRoleFunction>().eq("function_id", sysFunction.getId()));
|
|
|
|
- List<Integer> roleIds = sysRoleFunctions.stream().map(sf -> sf.getRoleId()).distinct().collect(Collectors.toList());
|
|
|
|
- List<Integer> targetRoleIds = sysRoleMapper.selectList(new QueryWrapper<SysRole>().eq("company_id", user.getCompanyId()).in("id", roleIds))
|
|
|
|
- .stream().map(sl -> sl.getId()).distinct().collect(Collectors.toList());
|
|
|
|
- List<User> targetUserList = userMapper.selectList(new QueryWrapper<User>().in("role_id", targetRoleIds));
|
|
|
|
- String corpUserString = targetUserList.stream().map(tl -> tl.getCorpwxUserid()).collect(Collectors.joining("|"));
|
|
|
|
- User targetUser = userMapper.selectById(sheet.getOwnerId());
|
|
|
|
- //推送到企业微信
|
|
|
|
- JSONObject json=new JSONObject();
|
|
|
|
- JSONArray dataJson=new JSONArray();
|
|
|
|
- JSONObject jsonObj=new JSONObject();
|
|
|
|
- jsonObj.put("key", "报销人");
|
|
|
|
- jsonObj.put("value",("$userName="+targetUser.getCorpwxUserid()+"$"));
|
|
|
|
- JSONObject jsonObj1=new JSONObject();
|
|
|
|
- jsonObj1.put("key", "填报日期");
|
|
|
|
- jsonObj1.put("value",sheet.getCreateDate());
|
|
|
|
- JSONObject jsonObj2=new JSONObject();
|
|
|
|
- jsonObj2.put("key", "票据类型");
|
|
|
|
- jsonObj2.put("value",sheetTypes[sheet.getType()]);
|
|
|
|
- JSONObject jsonObj3=new JSONObject();
|
|
|
|
- jsonObj3.put("key", "金额");
|
|
|
|
- jsonObj3.put("value",sheet.getTotalAmount());
|
|
|
|
- JSONObject jsonObj4=new JSONObject();
|
|
|
|
- jsonObj4.put("key", "备注");
|
|
|
|
- jsonObj4.put("value",sheet.getRemark()==null?"":sheet.getRemark());
|
|
|
|
- dataJson.add(jsonObj);
|
|
|
|
- dataJson.add(jsonObj1);
|
|
|
|
- dataJson.add(jsonObj2);
|
|
|
|
- dataJson.add(jsonObj3);
|
|
|
|
- dataJson.add(jsonObj4);
|
|
|
|
- json.put("template_id","tty9TkCAAALUiWvjdoDg_PZf48gwucZA");
|
|
|
|
- json.put("url","https://open.weixin.qq.com/connect/oauth2/authorize?appid=ww4e237fd6abb635af&redirect_uri=http://worktime.ttkuaiban.com/api/corpWXAuth&response_type=code&scope=snsapi_base&state=expense#wechat_redirect");
|
|
|
|
- json.put("content_item",dataJson);
|
|
|
|
- wxCorpInfoService.sendWXCorpTemplateMsg(wxCorpInfo,corpUserString, json);
|
|
|
|
- List<Information> informationList=new ArrayList<>();
|
|
|
|
- for (User item : targetUserList) {
|
|
|
|
- Information information=new Information();
|
|
|
|
- information.setUserId(item.getId());
|
|
|
|
- information.setTime(LocalDateTime.now());
|
|
|
|
- information.setMsg("费用报销待审核");
|
|
|
|
- information.setType(3);
|
|
|
|
- information.setContent(sheet.getCreateDate()+"");
|
|
|
|
- informationList.add(information);
|
|
|
|
|
|
+ if (!isAuditor) {
|
|
|
|
+ WxCorpInfo wxCorpInfo = wxCorpInfoMapper.selectOne(new QueryWrapper<WxCorpInfo>().eq("company_id", user.getCompanyId()));
|
|
|
|
+ if(wxCorpInfo!=null){
|
|
|
|
+ //获取具有费用报销审核权限的人员
|
|
|
|
+ SysFunction sysFunction = sysFunctionMapper.selectOne(new QueryWrapper<SysFunction>().eq("name", "费用审核"));
|
|
|
|
+ List<SysRoleFunction> sysRoleFunctions = sysRoleFunctionMapper.selectList(new QueryWrapper<SysRoleFunction>().eq("function_id", sysFunction.getId()));
|
|
|
|
+ List<Integer> roleIds = sysRoleFunctions.stream().map(sf -> sf.getRoleId()).distinct().collect(Collectors.toList());
|
|
|
|
+ List<Integer> targetRoleIds = sysRoleMapper.selectList(new QueryWrapper<SysRole>().eq("company_id", user.getCompanyId()).in("id", roleIds))
|
|
|
|
+ .stream().map(sl -> sl.getId()).distinct().collect(Collectors.toList());
|
|
|
|
+ List<User> targetUserList = userMapper.selectList(new QueryWrapper<User>().in("role_id", targetRoleIds));
|
|
|
|
+ String corpUserString = targetUserList.stream().map(tl -> tl.getCorpwxUserid()).collect(Collectors.joining("|"));
|
|
|
|
+ User targetUser = userMapper.selectById(sheet.getOwnerId());
|
|
|
|
+ //推送到企业微信
|
|
|
|
+ JSONObject json=new JSONObject();
|
|
|
|
+ JSONArray dataJson=new JSONArray();
|
|
|
|
+ JSONObject jsonObj=new JSONObject();
|
|
|
|
+ jsonObj.put("key", "报销人");
|
|
|
|
+ jsonObj.put("value",("$userName="+targetUser.getCorpwxUserid()+"$"));
|
|
|
|
+ JSONObject jsonObj1=new JSONObject();
|
|
|
|
+ jsonObj1.put("key", "填报日期");
|
|
|
|
+ jsonObj1.put("value",sheet.getCreateDate());
|
|
|
|
+ JSONObject jsonObj2=new JSONObject();
|
|
|
|
+ jsonObj2.put("key", "票据类型");
|
|
|
|
+ jsonObj2.put("value",sheetTypes[sheet.getType()]);
|
|
|
|
+ JSONObject jsonObj3=new JSONObject();
|
|
|
|
+ jsonObj3.put("key", "金额");
|
|
|
|
+ jsonObj3.put("value",sheet.getTotalAmount());
|
|
|
|
+ JSONObject jsonObj4=new JSONObject();
|
|
|
|
+ jsonObj4.put("key", "备注");
|
|
|
|
+ jsonObj4.put("value",sheet.getRemark()==null?"":sheet.getRemark());
|
|
|
|
+ dataJson.add(jsonObj);
|
|
|
|
+ dataJson.add(jsonObj1);
|
|
|
|
+ dataJson.add(jsonObj2);
|
|
|
|
+ dataJson.add(jsonObj3);
|
|
|
|
+ dataJson.add(jsonObj4);
|
|
|
|
+ json.put("template_id","tty9TkCAAALUiWvjdoDg_PZf48gwucZA");
|
|
|
|
+ json.put("url","https://open.weixin.qq.com/connect/oauth2/authorize?appid=ww4e237fd6abb635af&redirect_uri=http://worktime.ttkuaiban.com/api/corpWXAuth&response_type=code&scope=snsapi_base&state=expense#wechat_redirect");
|
|
|
|
+ json.put("content_item",dataJson);
|
|
|
|
+ wxCorpInfoService.sendWXCorpTemplateMsg(wxCorpInfo,corpUserString, json);
|
|
|
|
+ List<Information> informationList=new ArrayList<>();
|
|
|
|
+ for (User item : targetUserList) {
|
|
|
|
+ Information information=new Information();
|
|
|
|
+ information.setUserId(item.getId());
|
|
|
|
+ information.setTime(LocalDateTime.now());
|
|
|
|
+ information.setMsg("费用报销待审核");
|
|
|
|
+ information.setType(3);
|
|
|
|
+ information.setContent(sheet.getCreateDate()+"");
|
|
|
|
+ informationList.add(information);
|
|
|
|
+ }
|
|
|
|
+ informationService.saveBatch(informationList);
|
|
}
|
|
}
|
|
- informationService.saveBatch(informationList);
|
|
|
|
}
|
|
}
|
|
} else {
|
|
} else {
|
|
expenseSheetMapper.updateById(sheet);
|
|
expenseSheetMapper.updateById(sheet);
|