|
@@ -1046,6 +1046,210 @@ namespace OASystem.API.Controllers
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+
|
|
|
+
|
|
|
+ /// <summary>
|
|
|
+ /// 接团流程操作(增改)
|
|
|
+ /// 安卓端使用 建团时添加客户名单
|
|
|
+ /// </summary>
|
|
|
+ /// <param name="dto"></param>
|
|
|
+ /// <returns></returns>
|
|
|
+ [HttpPost]
|
|
|
+ [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
|
|
|
+ public async Task<IActionResult> GroupProcessOperation1(GroupProcessOperationDto dto)
|
|
|
+ {
|
|
|
+
|
|
|
+ #region 参数验证
|
|
|
+ if (dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数"));
|
|
|
+ PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
|
|
|
+
|
|
|
+ #region 页面操作权限验证
|
|
|
+ //pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(dto.UserId, 104);
|
|
|
+ //if (pageFunAuthView.AddAuth == 0) return Ok(JsonView(false, "客户名单您没有添加权限!"));
|
|
|
+ pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(dto.UserId, 27);
|
|
|
+ if (pageFunAuthView.AddAuth == 0) return Ok(JsonView(false, "团组操作您没有添加权限!"));
|
|
|
+ #endregion
|
|
|
+
|
|
|
+ #endregion
|
|
|
+
|
|
|
+ _sqlSugar.BeginTran();
|
|
|
+
|
|
|
+ decimal ffrPrice = 0.00M;
|
|
|
+ DateTime? visitDt = null;
|
|
|
+ if (dto.Status == 2)
|
|
|
+ {
|
|
|
+ var groupInfo = await _sqlSugar.Queryable<Grp_DelegationInfo>().FirstAsync(x => x.Id == dto.Id && x.IsDel == 0);
|
|
|
+ if (groupInfo != null)
|
|
|
+ {
|
|
|
+ ffrPrice = groupInfo.PaymentMoney;
|
|
|
+ visitDt = groupInfo.VisitDate.AddDays(-groupInfo.PayDay);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ var _dto = new GroupOperationDto();
|
|
|
+ _dto = _mapper.Map<GroupProcessOperationDto, GroupOperationDto>(dto);
|
|
|
+ var groupData = await _groupRepository.GroupOperation(_dto);
|
|
|
+ if (groupData.Code != 0)
|
|
|
+ {
|
|
|
+ _sqlSugar.RollbackTran();
|
|
|
+ return Ok(JsonView(false, "团组操作添加失败!" + groupData.Msg));
|
|
|
+ }
|
|
|
+
|
|
|
+ try
|
|
|
+ {
|
|
|
+ int diId = 0;
|
|
|
+ //添加时 默认加入团组汇率
|
|
|
+ if (dto.Status == 1) //添加
|
|
|
+ {
|
|
|
+ diId = groupData.Data;
|
|
|
+ //添加默认币种
|
|
|
+ await GeneralMethod.PostGroupRateAddInit(dto.UserId, diId);
|
|
|
+
|
|
|
+ //默认分配权限
|
|
|
+ await GeneralMethod.PostGroupAuthAddInit(dto.UserId, diId);
|
|
|
+
|
|
|
+ //消息提示 王鸽 主管号 2024-10-21 新增LZ UID
|
|
|
+ List<int> _managerIds = new List<int>() { 21, 22, 32 };
|
|
|
+ var userIds = _usersRep._sqlSugar.Queryable<Sys_Users>().Where(it => it.IsDel == 0 && _managerIds.Contains(it.JobPostId)).Select(it => it.Id).ToList();
|
|
|
+ if (userIds.Count > 0)
|
|
|
+ {
|
|
|
+ userIds.Add(208);
|
|
|
+ //创建团组管控
|
|
|
+ GroupStepForDelegation.CreateWorkStep(diId);
|
|
|
+ //发送消息
|
|
|
+ string groupName = dto.TeamName;
|
|
|
+ string createGroupUser = string.Empty;
|
|
|
+
|
|
|
+ var userInfo = _usersRep._sqlSugar.Queryable<Sys_Users>().Where(it => it.IsDel == 0 && it.Id == dto.UserId).First();
|
|
|
+ if (userInfo != null) createGroupUser = userInfo.CnName;
|
|
|
+
|
|
|
+ string title = $"系统通知";
|
|
|
+ string content = $"团组[{groupName}(创建人:{createGroupUser})]创建成功,请前往页面进行下一步操作!";
|
|
|
+ await GeneralMethod.MessageIssueAndNotification(MessageTypeEnum.GroupBusinessOperations, title, content, userIds, diId);
|
|
|
+ }
|
|
|
+
|
|
|
+ #region 应用推送
|
|
|
+ try
|
|
|
+ {
|
|
|
+ await AppNoticeLibrary.SendChatMsg_GroupStatus_Create(diId, QiyeWeChatEnum.CompanyCRMChat);
|
|
|
+ Sys_Users users = _airTicketResRep.Query<Sys_Users>(s => s.Id == dto.UserId).First();
|
|
|
+ Sys_Department department = _airTicketResRep.Query<Sys_Department>(s => s.Id == users.DepId).First();
|
|
|
+ if (department.Id == 6 && !string.IsNullOrEmpty(users.QiyeChatUserId))
|
|
|
+ {
|
|
|
+ List<string> userList = new List<string>() { users.QiyeChatUserId };
|
|
|
+ await AppNoticeLibrary.SendUserMsg_GroupStatus_Create(diId, userList);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ catch (Exception ex)
|
|
|
+ {
|
|
|
+
|
|
|
+ _sqlSugar.CommitTran();
|
|
|
+ return Ok(JsonView(true, "操作成功! 应用推送异常:" + groupData.Msg));
|
|
|
+
|
|
|
+ }
|
|
|
+ #endregion
|
|
|
+
|
|
|
+
|
|
|
+ //默认创建倒推表
|
|
|
+ await _invertedListRep._Create(dto.UserId, diId);
|
|
|
+ }
|
|
|
+ else if (dto.Status == 2)
|
|
|
+ {
|
|
|
+ diId = dto.Id;
|
|
|
+ if (diId == 0)
|
|
|
+ {
|
|
|
+ _sqlSugar.RollbackTran();
|
|
|
+ return Ok(JsonView(false, "操作失败! 未添加团组id" + groupData.Msg));
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ var viewData = await _tourClientListRep.OperMultiple(dto.TourClientListInfos, diId, dto.UserId);
|
|
|
+
|
|
|
+ if (viewData.Code != 0)
|
|
|
+ {
|
|
|
+ _sqlSugar.RollbackTran();
|
|
|
+ return Ok(JsonView(false, "客户名单添加失败!" + viewData.Msg));
|
|
|
+ }
|
|
|
+
|
|
|
+ #region 团组操作默认添加/修改收款账单
|
|
|
+ if (dto.PayDay > 0 && dto.PaymentMoney > 0)
|
|
|
+ {
|
|
|
+ var ffrInfo = await _sqlSugar.Queryable<Fin_ForeignReceivables>()
|
|
|
+ .Where(x => x.IsDel == 0 &&
|
|
|
+ x.Diid == diId &&
|
|
|
+ x.Remark.Equals("预付款")
|
|
|
+ )
|
|
|
+ .WhereIF(ffrPrice > 0, x => x.ItemSumPrice == ffrPrice)
|
|
|
+ .WhereIF(visitDt != null, x => x.CreateTime == visitDt)
|
|
|
+ .FirstAsync();
|
|
|
+
|
|
|
+ ffrInfo = new Fin_ForeignReceivables()
|
|
|
+ {
|
|
|
+ Diid = diId,
|
|
|
+ PriceName = dto.ClientUnit,
|
|
|
+ Price = dto.PaymentMoney,
|
|
|
+ Count = 1,
|
|
|
+ Unit = $"元",
|
|
|
+ ItemSumPrice = dto.PaymentMoney,
|
|
|
+ Rate = 1.0000M,
|
|
|
+ Currency = 836,
|
|
|
+ AddingWay = 0,
|
|
|
+ CreateUserId = dto.UserId,
|
|
|
+ CreateTime = Convert.ToDateTime(dto.VisitDate).AddDays(-dto.PayDay),
|
|
|
+ Remark = $"预付款"
|
|
|
+ };
|
|
|
+
|
|
|
+ if (ffrInfo == null) //Add
|
|
|
+ {
|
|
|
+ await _sqlSugar.Insertable(ffrInfo).ExecuteCommandAsync();
|
|
|
+ }
|
|
|
+ else //修改
|
|
|
+ {
|
|
|
+ await _sqlSugar.Updateable<Fin_ForeignReceivables>(ffrInfo)
|
|
|
+ .UpdateColumns(x => new
|
|
|
+ {
|
|
|
+ x.PriceName,
|
|
|
+ x.Price,
|
|
|
+ x.ItemSumPrice,
|
|
|
+ x.CreateTime,
|
|
|
+ x.CreateUserId
|
|
|
+ })
|
|
|
+ .WhereColumns(x => x.Id)
|
|
|
+ .ExecuteCommandAsync();
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ #endregion
|
|
|
+
|
|
|
+
|
|
|
+ #region 签证人员团组时间通知
|
|
|
+
|
|
|
+ #region 计算出访起止时间
|
|
|
+ var startTime = new DateTime();
|
|
|
+ var endTime = new DateTime();
|
|
|
+ if (DateTime.TryParse(dto.VisitDate, out startTime))
|
|
|
+ {
|
|
|
+ endTime = startTime.AddDays(dto.VisitDays - 1);//含当天
|
|
|
+ }
|
|
|
+ #endregion
|
|
|
+
|
|
|
+ if (diId > 0)
|
|
|
+ {
|
|
|
+ await AppNoticeLibrary.SendUserMsg_GroupTimeInfo_ToVisaUser(diId, startTime.ToString("yyyy-MM-dd"), endTime.ToString("yyyy-MM-dd"));
|
|
|
+ }
|
|
|
+
|
|
|
+ #endregion
|
|
|
+
|
|
|
+ _sqlSugar.CommitTran();
|
|
|
+ return Ok(JsonView(true));
|
|
|
+ }
|
|
|
+ catch (Exception ex)
|
|
|
+ {
|
|
|
+ _sqlSugar.RollbackTran();
|
|
|
+ return Ok(JsonView(false, ex.Message));
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
/// <summary>
|
|
|
/// 接团信息 操作(删除)
|
|
|
/// </summary>
|