Beispiel #1
0
        /// <summary>
        /// 提交费用报表
        /// </summary>
        public bool SubmitReport(long eid, long userId, ref string faileReason)
        {
            try
            {
                var thisReport = _dal.FindNoDeleteById(eid);
                if (thisReport != null)
                {
                    if (thisReport.status_id == (int)DTO.DicEnum.EXPENSE_REPORT_STATUS.HAVE_IN_HAND || thisReport.status_id == (int)DTO.DicEnum.EXPENSE_REPORT_STATUS.REJECTED)
                    {
                        var timeNow = Tools.Date.DateHelper.ToUniversalTimeStamp(DateTime.Now);
                        #region 修改费用报表状态
                        var oldRep = _dal.FindNoDeleteById(eid);
                        thisReport.submit_time    = timeNow;
                        thisReport.submit_user_id = userId;
                        thisReport.update_time    = timeNow;
                        thisReport.update_user_id = userId;
                        thisReport.status_id      = (int)DTO.DicEnum.EXPENSE_REPORT_STATUS.WAITING_FOR_APPROVAL;
                        _dal.Update(thisReport);
                        OperLogBLL.OperLogUpdate <sdk_expense_report>(thisReport, oldRep, thisReport.id, userId, OPER_LOG_OBJ_CATE.SDK_EXPENSE_REPORT, "修改费用报表");
                        #endregion

                        #region 记录操作日志
                        var expLog = new tst_expense_report_log()
                        {
                            id = _dal.GetNextIdCom(),
                            expense_report_id = thisReport.id,
                            oper_user_id      = userId,
                            oper_time         = timeNow,
                            oper_type_id      = (int)DTO.DicEnum.EXPENSE_RECORD_OPER.SUBMIT,
                        };
                        new tst_expense_report_log_dal().Insert(expLog);
                        #endregion

                        #region 发送邮件相关
                        var srDal      = new sys_resource_dal();
                        var thisRes    = srDal.FindNoDeleteById(userId);
                        var thisCreate = srDal.FindNoDeleteById(thisReport.create_user_id);
                        if (thisRes != null && thisCreate != null)
                        {
                            var toEmail       = thisCreate.email;
                            var ensDateString = thisReport.end_date != null ? ((DateTime)thisReport.end_date).ToString("yyyy-MM-dd") : "";
                            var notify        = new com_notify_email()
                            {
                                id              = _dal.GetNextIdCom(),
                                cate_id         = (int)NOTIFY_CATE.TIME_SHEET,
                                from_email      = thisRes.email,
                                from_email_name = thisRes.name,
                                subject         = $"{thisCreate.name}费用报表(周期{ensDateString})需要审批",
                                body_text       = $"我提交了费用报表(周期{ensDateString}),请审批",
                                to_email        = toEmail,
                                create_user_id  = userId,
                                update_user_id  = userId,
                                create_time     = timeNow,
                                update_time     = timeNow,
                            };
                            notify.is_success = (sbyte)(new ProjectBLL().SendEmail(notify) ? 1 : 0);
                            new com_notify_email_dal().Insert(notify);
                            OperLogBLL.OperLogAdd <com_notify_email>(notify, notify.id, userId, OPER_LOG_OBJ_CATE.NOTIFY, "新增通知信息");
                        }
                        #endregion
                    }
                    else
                    {
                        faileReason = "只有进行中或者已拒绝的报表报表才可以进行提交操作!";
                        return(false);
                    }
                }
                else
                {
                    faileReason = "未找到相关费用报表";
                    return(false);
                }
            }
            catch (Exception msg)
            {
                faileReason = msg.Message;
                return(false);
            }
            return(true);
        }
Beispiel #2
0
        /// <summary>
        /// 审批通过-费用
        /// </summary>
        public bool Approval(long eid, long user_id, out string failReason, string notiIds = "")
        {
            failReason = "";
            var thisExp = _dal.FindNoDeleteById(eid);

            if (thisExp != null && thisExp.status_id == (int)DTO.DicEnum.EXPENSE_REPORT_STATUS.WAITING_FOR_APPROVAL)
            {
                var timeNow = Tools.Date.DateHelper.ToUniversalTimeStamp(DateTime.Now);

                #region 审批 插入工时表日志
                var expLog = new tst_expense_report_log()
                {
                    id = _dal.GetNextIdCom(),
                    expense_report_id = thisExp.id,
                    oper_user_id      = user_id,
                    oper_time         = timeNow,
                    oper_type_id      = (int)DTO.DicEnum.EXPENSE_RECORD_OPER.APPROVAL_PASS,
                };
                new tst_expense_report_log_dal().Insert(expLog);
                // 日志表无需再存储日志
                #endregion

                var oldExp = _dal.FindNoDeleteById(eid);
                thisExp.status_id      = (int)DTO.DicEnum.EXPENSE_REPORT_STATUS.PAYMENT_BEEN_APPROVED;
                thisExp.update_time    = timeNow;
                thisExp.update_user_id = user_id;
                if (_dal.Update(thisExp))
                {
                    OperLogBLL.OperLogUpdate <sdk_expense_report>(thisExp, oldExp, thisExp.id, user_id, OPER_LOG_OBJ_CATE.SDK_EXPENSE_REPORT, "修改费用报表");
                    #region 发送邮件相关
                    var srDal      = new sys_resource_dal();
                    var thisRes    = srDal.FindNoDeleteById(user_id);
                    var thisCreate = srDal.FindNoDeleteById(thisExp.create_user_id);
                    if (thisRes != null && thisCreate != null)
                    {
                        var toEmail = thisCreate.email;
                        if (!string.IsNullOrEmpty(notiIds))
                        {
                            var notiArr = notiIds.Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries);
                            foreach (var notiID in notiArr)
                            {
                                var notiRes = srDal.FindNoDeleteById(long.Parse(notiID));
                                if (notiRes != null)
                                {
                                    toEmail += notiRes.email + ";";
                                }
                            }
                        }

                        var notify = new com_notify_email()
                        {
                            id              = _dal.GetNextIdCom(),
                            cate_id         = (int)NOTIFY_CATE.TIME_SHEET,
                            from_email      = thisRes.email,
                            from_email_name = thisRes.name,
                            subject         = $"费用报表被{thisRes.name}审批通过",
                            body_text       = $"员工姓名的费用报表被审批通过\r名称:{thisExp.title}\r费用总额:{(thisExp.amount??0).ToString("#0.00")}\r",
                            to_email        = toEmail,
                            create_user_id  = user_id,
                            update_user_id  = user_id,
                            create_time     = timeNow,
                            update_time     = timeNow,
                        };
                        notify.is_success = (sbyte)(new ProjectBLL().SendEmail(notify)?1:0);
                        new com_notify_email_dal().Insert(notify);
                        OperLogBLL.OperLogAdd <com_notify_email>(notify, notify.id, user_id, OPER_LOG_OBJ_CATE.NOTIFY, "新增通知信息");
                    }
                    #endregion

                    return(true);
                }
            }
            else
            {
                if (thisExp == null)
                {
                    failReason = "未查询到审批的费用报表";
                }
                else
                {
                    failReason = thisExp.title + "费用报表的状态必须是待审批。";
                }
            }
            return(false);
        }
Beispiel #3
0
        /// <summary>
        /// 审批拒绝-费用
        /// </summary>
        /// <returns></returns>
        public bool ApprovalRefuse(long eid, string reason, long userId, out string failReason, string notiIds = "", string refIds = "", bool isRecord = false)
        {
            failReason = "";
            try
            {
                var thisReport = _dal.FindNoDeleteById(eid);
                if (thisReport != null && thisReport.status_id == (int)DTO.DicEnum.EXPENSE_REPORT_STATUS.WAITING_FOR_APPROVAL)
                {
                    var timeNow = Tools.Date.DateHelper.ToUniversalTimeStamp(DateTime.Now);

                    #region 审批 插入工时表日志
                    var expLog = new tst_expense_report_log()
                    {
                        id = _dal.GetNextIdCom(),
                        expense_report_id = thisReport.id,
                        oper_user_id      = userId,
                        oper_time         = timeNow,
                        oper_type_id      = (int)DTO.DicEnum.EXPENSE_RECORD_OPER.APPROVAL_REFUSE,
                        description       = reason
                    };
                    if (isRecord && !string.IsNullOrEmpty(refIds))
                    {
                        expLog.rejection_expense_id_list = refIds;
                    }
                    new tst_expense_report_log_dal().Insert(expLog);
                    // 日志表无需再存储日志
                    #endregion

                    var oldExp = _dal.FindNoDeleteById(eid);
                    thisReport.status_id        = (int)DTO.DicEnum.EXPENSE_REPORT_STATUS.REJECTED;
                    thisReport.update_time      = timeNow;
                    thisReport.update_user_id   = userId;
                    thisReport.rejection_reason = reason;
                    if (isRecord && !string.IsNullOrEmpty(refIds))
                    {
                        var oldExpIds = thisReport.rejection_expense_id_list;
                        if (!string.IsNullOrEmpty(oldExpIds))
                        {
                            var    oldIdArr = oldExpIds.Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries);
                            var    newArr   = refIds.Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries);
                            var    result   = oldIdArr.Union(newArr).ToArray();
                            string ids      = "";
                            foreach (var thisId in result)
                            {
                                ids += thisId + ",";
                            }
                            if (ids != "")
                            {
                                ids = ids.Substring(0, ids.Length - 1);
                                thisReport.rejection_expense_id_list = ids;
                            }
                        }
                        else
                        {
                            thisReport.rejection_expense_id_list = refIds;
                        }
                    }
                    if (_dal.Update(thisReport))
                    {
                        OperLogBLL.OperLogUpdate <sdk_expense_report>(thisReport, oldExp, thisReport.id, userId, OPER_LOG_OBJ_CATE.SDK_EXPENSE_REPORT, "修改费用报表");

                        #region 发送邮件相关
                        var srDal      = new sys_resource_dal();
                        var thisRes    = srDal.FindNoDeleteById(userId);
                        var thisCreate = srDal.FindNoDeleteById(thisReport.create_user_id);
                        if (thisRes != null && thisCreate != null)
                        {
                            var toEmail = thisCreate.email;
                            if (!string.IsNullOrEmpty(notiIds))
                            {
                                var notiArr = notiIds.Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries);
                                foreach (var notiID in notiArr)
                                {
                                    var notiRes = srDal.FindNoDeleteById(long.Parse(notiID));
                                    if (notiRes != null)
                                    {
                                        toEmail += notiRes.email + ";";
                                    }
                                }
                            }
                            var notify = new com_notify_email()
                            {
                                id              = _dal.GetNextIdCom(),
                                cate_id         = (int)NOTIFY_CATE.TIME_SHEET,
                                from_email      = thisRes.email,
                                from_email_name = thisRes.name,
                                to_email        = toEmail,
                                subject         = $"费用报表被{thisRes.name}审批时被拒绝",
                                body_text       = $"员工姓名的费用报表被审批通过\r名称:{thisReport.title}\r费用总额:{(thisReport.amount ?? 0).ToString("#0.00")}\r说明:{reason}",
                                create_user_id  = userId,
                                update_user_id  = userId,
                                create_time     = timeNow,
                                update_time     = timeNow,
                            };
                            notify.is_success = (sbyte)(new ProjectBLL().SendEmail(notify) ? 1 : 0);
                            new com_notify_email_dal().Insert(notify);
                            OperLogBLL.OperLogAdd <com_notify_email>(notify, notify.id, userId, OPER_LOG_OBJ_CATE.NOTIFY, "新增通知信息");
                        }
                        #endregion
                    }
                }
                else
                {
                    if (thisReport == null)
                    {
                        failReason = "未查询到拒绝的费用报表";
                    }
                    else
                    {
                        failReason = "费用报表的状态必须是待审批";
                    }
                    return(false);
                }
            }
            catch (Exception e)
            {
                failReason = e.Message;
                return(false);
            }
            return(true);
        }
Beispiel #4
0
        /// <summary>
        /// 丢失报价
        /// </summary>
        /// <param name="userId"></param>
        /// <param name="quoteId"></param>
        /// <param name="reasonType">丢失原因类型</param>
        /// <param name="reasonDetail">丢失原因详情</param>
        /// <returns></returns>
        public string LossQuote(long userId, long quoteId, int reasonType, string reasonDetail)
        {
            DicEnum.SYS_CLOSE_OPPORTUNITY needReasonType;
            var type  = new SysSettingBLL().GetValueById(SysSettingEnum.CRM_OPPORTUNITY_LOSS_REASON);
            int value = 0;

            if (!int.TryParse(type, out value))
            {
                needReasonType = DicEnum.SYS_CLOSE_OPPORTUNITY.NEED_NONE;
            }
            else
            {
                needReasonType = (DicEnum.SYS_CLOSE_OPPORTUNITY)value;
            }

            // 更新商机状态为丢失
            var opporDal = new crm_opportunity_dal();
            var quote    = _dal.FindById(quoteId);
            var oppor    = opporDal.FindById(quote.opportunity_id);
            var oldOppor = opporDal.FindById(quote.opportunity_id);

            oppor.status_id      = (int)DicEnum.OPPORTUNITY_STATUS.LOST;
            oppor.update_time    = Tools.Date.DateHelper.ToUniversalTimeStamp(DateTime.Now);
            oppor.update_user_id = userId;
            if (needReasonType == SYS_CLOSE_OPPORTUNITY.NEED_TYPE_DETAIL)
            {
                oppor.loss_reason = reasonDetail;
            }
            if (needReasonType != SYS_CLOSE_OPPORTUNITY.NEED_NONE)
            {
                oppor.loss_reason_type_id = reasonType;
            }
            opporDal.Update(oppor);

            // 保存操作商机日志
            var user = UserInfoBLL.GetUserInfo(userId);

            new sys_oper_log_dal().Insert(new sys_oper_log()
            {
                user_cate           = "用户",
                user_id             = userId,
                name                = user.name,
                phone               = user.mobile == null ? "" : user.mobile,
                oper_time           = Tools.Date.DateHelper.ToUniversalTimeStamp(DateTime.Now),
                oper_object_cate_id = (int)OPER_LOG_OBJ_CATE.OPPORTUNITY,
                oper_object_id      = oppor.id,// 操作对象id
                oper_type_id        = (int)OPER_LOG_TYPE.UPDATE,
                oper_description    = opporDal.CompareValue(oldOppor, oppor),
                remark              = "丢失报价"
            });

            // 新增通知信息
            var notify_email_dal = new com_notify_email_dal();
            var notify_email     = new com_notify_email()
            {
                id              = notify_email_dal.GetNextIdCom(),
                cate_id         = (int)NOTIFY_CATE.CRM,
                event_id        = 1,          // TODO:
                to_email        = "",         // TODO:
                notify_tmpl_id  = 1,          // TODO:
                from_email      = user.email, // todo
                from_email_name = user.name,  // todo
                subject         = "",         // TODO:
                body_text       = "",         // TODO:
                is_html_format  = 0,          // 内容是否是html格式,0纯文本 1html
                create_user_id  = user.id,
                update_user_id  = user.id,
                create_time     = Tools.Date.DateHelper.ToUniversalTimeStamp(DateTime.Now),
                update_time     = Tools.Date.DateHelper.ToUniversalTimeStamp(DateTime.Now),
            };

            notify_email_dal.Insert(notify_email);
            new sys_oper_log_dal().Insert(new sys_oper_log()
            {
                user_cate           = "用户",
                user_id             = user.id,
                name                = user.name,
                phone               = user.mobile == null ? "" : user.mobile,
                oper_time           = Tools.Date.DateHelper.ToUniversalTimeStamp(DateTime.Now),
                oper_object_cate_id = (int)OPER_LOG_OBJ_CATE.OPPORTUNITY,
                oper_object_id      = notify_email.id,
                oper_type_id        = (int)OPER_LOG_TYPE.ADD,
                oper_description    = notify_email_dal.AddValue(notify_email),
                remark              = "新增通知",
            });  // 插入日志

            return("");
        }