Пример #1
0
        public AjaxMessage CreateInviteContent(FL_InviteDetails inviteDetail)
        {
            AjaxMessage ajax = new AjaxMessage();

            ajax.IsSuccess = false;
            ajax.Message   = "数据异常,请稍候再试...";

            try
            {
                if (inviteDetail != null)
                {
                    int selfEmployeeId = LoginInfo.UserInfo.EmployeeId;
                    inviteDetail.CreateDate = DateTime.Now;
                    inviteDetail.EmployeeId = selfEmployeeId;
                    inviteDetail.StateName  = inviteDetail.StateValue.GetDisplayName();

                    //客户表  修改相应的状态
                    FL_Customer m_customer = _customerService.GetByGuid(new Guid(inviteDetail.CustomerId.ToString()));
                    m_customer.State = inviteDetail.InviteState;

                    //邀约表
                    FL_Invite m_invite = _inviteService.GetById(inviteDetail.InviteId);
                    m_invite.FollowCount   += 1;
                    m_invite.LastFollowDate = inviteDetail.CreateDate;
                    m_invite.NextFollowDate = inviteDetail.NextFollowDate;

                    //统计表(客户)
                    SS_Report report = _reportService.GetByCustomerId(new Guid(inviteDetail.CustomerId.ToString()));


                    if (inviteDetail.InviteState == 4)     //流失
                    {
                        m_invite.IsLose   = true;
                        m_invite.LoseDate = DateTime.Now;

                        report.InviteLoseDate = m_invite.LoseDate;
                    }

                    using (TransactionScope scope = new TransactionScope())
                    {
                        //客户表
                        _customerService.Update(m_customer);

                        //邀约详细
                        _invteiContentService.Add(inviteDetail);

                        //邀约表
                        _inviteService.Update(m_invite);

                        //统计
                        _reportService.Update(report);

                        scope.Complete();
                    }
                    ajax.IsSuccess = true;
                    ajax.Message   = "记录成功";
                }
            }
            catch (Exception e)
            {
                ajax.Message = e.Message;
            }

            return(ajax);
        }