Exemplo n.º 1
0
        /// <summary>
        /// 对账
        /// </summary>
        /// <param name="lstModify">需要修改状态的往来账列表</param>
        /// <param name="lstAdd">需要增加的往来账列表</param>
        /// <param name="wastBookinfo">需要添加的资金流信息</param>
        public void Checking(IList <ReckoningInfo> lstModify, IList <ReckoningInfo> lstAdd, WasteBookInfo wastBookinfo)
        {
            using (var scop = new TransactionScope())
            {
                try
                {
                    //1.更新被对账往来为已对账
                    if (lstModify.Count > 0)
                    {
                        _reckoningDao.UpdateCheckState(lstModify, 1);
                    }

                    //2.新增往来账(包括调账)
                    foreach (ReckoningInfo reckoningInfo in lstAdd)
                    {
                        reckoningInfo.AuditingState = (int)AuditingState.Yes;
                        string errorMessage;
                        _reckoningDao.Insert(reckoningInfo, out errorMessage);
                    }

                    //3.资金流 增加一条数据
                    if (wastBookinfo.Income != 0)
                    {
                        _wasteBookManager.Insert(wastBookinfo);
                    }
                    scop.Complete();
                }
                catch (Exception ex)
                {
                    throw new Exception("对账失败!", ex);
                }
            }
        }
        protected bool ExecuteFinishHandle(CostReportInfo model, PersonnelInfo personnelInfo, out string errorMsg)
        {
            errorMsg = string.Empty;
            if (model.ReportKind.Equals((int)CostReportKind.FeeIncome))
            {
                model.RealityCost = -model.RealityCost;
            }

            var costReportBll = new BLL.Implement.Inventory.CostReport(_bankAccounts, _personnelSao, _costReckoning);

            #region 新增资金流
            var wasteBookInfo = costReportBll.AddWasteBookInfo(model, personnelInfo, false);
            if (_wasteBook.Insert(wasteBookInfo) <= 0)
            {
                errorMsg = "新增资金流失败!";
                return(false);
            }
            #endregion

            #region 新增帐务记录
            var costReckoningInfo = costReportBll.AddCostReckoningInfo(model, personnelInfo, false);
            if (_costReckoning.Insert(costReckoningInfo) <= 0)
            {
                errorMsg = "新增帐务记录失败!";
                return(false);
            }
            #endregion

            #region 与门店费用交互
            if (model.AssumeBranchId == new Guid(ShopBranchId) && !model.AssumeShopId.Equals(Guid.Empty))
            {
                string strErrorMsg;
                var    description = string.Format("费用申报{0}{1}可用余额!", model.ReceiptNo, model.RealityCost < 0 ? "添加" : "扣除");
                var    parentId    = FilialeManager.GetShopHeadFilialeId(model.AssumeShopId);//获取门店所属公司
                if (!ShopSao.DeductBalance(parentId, model.AssumeShopId, model.RealityCost, description, out strErrorMsg))
                {
                    errorMsg = strErrorMsg;
                    return(false);
                }

                var costRecordDto = costReportBll.AddCostRecordDto(model);
                if (!ShopSao.InsertCostRecord(parentId, costRecordDto))
                {
                    errorMsg = "扣除门店费用失败!";
                    return(false);
                }
            }
            #endregion

            #region 新增资金流(手续费)
            if (model.RealityCost >= 0 && model.Poundage > 0 && !model.ReportKind.Equals((int)CostReportKind.FeeIncome))
            {
                var wasteBookInfoPoundage = costReportBll.AddWasteBookInfo(model, personnelInfo, true);
                if (_wasteBook.Insert(wasteBookInfoPoundage) <= 0)
                {
                    errorMsg = "新增手续费失败!";
                    return(false);
                }
            }
            #endregion

            return(true);
        }
Exemplo n.º 3
0
        /// <summary>
        /// 打款完成
        /// </summary>
        /// <param name="salePlatformId"></param>
        /// <param name="applyId"></param>
        protected void PayFinish(Guid salePlatformId, Guid applyId)
        {
            var errorMsg = new StringBuilder();
            MemberMentionApplyInfo memberMentionApplyInfo = MemberCenterSao.GetMemberMentionApply(salePlatformId, applyId);

            if (memberMentionApplyInfo.State == (int)MemberMentionState.Process)
            {
                var orderNoStr = string.Empty;
                if (!string.IsNullOrWhiteSpace(memberMentionApplyInfo.OrderNo))
                {
                    orderNoStr = string.Format("[订单号:{0}]", memberMentionApplyInfo.OrderNo);
                }
                if (!string.IsNullOrWhiteSpace(memberMentionApplyInfo.ThirdPartyOrderNo) || memberMentionApplyInfo.ThirdPartyOrderNo == "-")
                {
                    orderNoStr = string.Format("{0}[第三方平台订单号:{1}]", orderNoStr, memberMentionApplyInfo.ThirdPartyOrderNo);
                }
                var rdescription = string.Format("[余额提现(提现会员:{0};提现申请单号:{1};提现到:{2};操作人:{3}),资金减少,{4})]", memberMentionApplyInfo.UserName, memberMentionApplyInfo.ApplyNo, memberMentionApplyInfo.BankName, Personnel.RealName, DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"));

                var info = new WasteBookInfo(Guid.NewGuid(), new Guid(RCB_BankAccountsId.SelectedValue),
                                             memberMentionApplyInfo.ApplyNo, rdescription + orderNoStr,
                                             -memberMentionApplyInfo.Amount, (Int32)AuditingState.Yes,
                                             (Int32)WasteBookType.Decrease, memberMentionApplyInfo.SaleFilialeId)
                {
                    LinkTradeCode = memberMentionApplyInfo.ApplyNo,
                    LinkTradeType = (int)WasteBookLinkTradeType.WithdrawDeposit,
                    BankTradeCode = string.Empty,
                    State         = (int)WasteBookState.Currently,
                    IsOut         = false
                };

                var memo        = "提现" + memberMentionApplyInfo.ApplyNo + "取走余额;";
                var description = "提现" + memberMentionApplyInfo.ApplyNo + ",提走余额;" + Common.WebControl.RetrunUserAndTime("提现受理");

                #region 提现
                using (var ts = new TransactionScope(TransactionScopeOption.Required))
                {
                    try
                    {
                        if (info.Income != 0)
                        {
                            _wasteBook.Insert(info);
                        }
                        string errorMessage;
                        var    result = MemberCenterSao.CompleteWithdrawApply(salePlatformId, applyId, memo, description, out errorMessage);
                        if (!result)
                        {
                            throw new Exception("会员名:" + memberMentionApplyInfo.UserName + "提现单号:" + memberMentionApplyInfo.ApplyNo + "   " + errorMessage);
                        }
                        //提现打款完成增加操作记录添加
                        Common.WebControl.AddOperationLog(Personnel.PersonnelId, Personnel.RealName, info.WasteBookId, info.TradeCode, OperationPoint.MemberWithdrawCash.PaySuccess.GetBusinessInfo(), string.Empty);
                        ts.Complete();
                    }
                    catch (Exception ex)
                    {
                        errorMsg.Append("提现失败!" + ex.Message).Append("\\n");
                    }
                    finally
                    {
                        ts.Dispose();
                    }
                }
                #endregion

                #region 发送短信
                try
                {
                    MemberBaseInfo memberBaseInfo = MemberCenterSao.GetUserBase(salePlatformId, memberMentionApplyInfo.MemberId);
                    if (memberBaseInfo != null)
                    {
                        if (!string.IsNullOrEmpty(memberBaseInfo.Mobile))
                        {
                            //可得完成打款发送短信
                            var keedeFilialeId = FilialeManager.GetList().First(f => f.Code.ToLower() == "kede").ID;
                            if (memberMentionApplyInfo.SaleFilialeId == keedeFilialeId)
                            {
                                const string MSG = "您好,您的提现申请已收到,现已完成打款,一般2-5个工作日到账,请注意查收。详情可致电4006202020咨询。感谢您对可得网支持!";
                                MailSMSSao.SendShortMessage(memberMentionApplyInfo.SaleFilialeId, memberMentionApplyInfo.SalePlatformId, memberBaseInfo.Mobile, MSG);
                            }
                        }
                    }
                }
                catch (Exception ex)
                {
                    errorMsg.Append("提现成功,短信发送失败! " + "会员名:" + memberMentionApplyInfo.UserName + "提现单号:" + memberMentionApplyInfo.ApplyNo + "   " + ex.Message).Append("\\n");
                }
                #endregion
            }

            if (!string.IsNullOrEmpty(errorMsg.ToString()))
            {
                throw new Exception(errorMsg.ToString());
            }
        }
Exemplo n.º 4
0
        /// <summary>转帐
        /// </summary>
        /// <param name="inBankAccountsId">转入帐号Id</param>
        /// <param name="outBankAccountsId">转出帐号Id</param>
        /// <param name="sum">金额</param>
        /// <param name="poundage"></param>
        /// <param name="description">说明</param>
        /// <param name="tradeCode"></param>
        /// <param name="filialeId"> </param>
        public void Virement(Guid inBankAccountsId, Guid outBankAccountsId, decimal sum, decimal poundage, string description, string tradeCode, Guid filialeId)
        {
            if (inBankAccountsId != Guid.Empty && outBankAccountsId != Guid.Empty && sum > 0)
            {
                DateTime dateCreated         = DateTime.Now;
                decimal  inNonceBalance      = _wasteBookDao.GetBalance(inBankAccountsId);
                decimal  outNonceBalance     = _wasteBookDao.GetBalance(outBankAccountsId);
                var      outBankAccountsInfo = _bankAccounts.GetBankAccounts(outBankAccountsId);
                var      intBankAccountsInfo = _bankAccounts.GetBankAccounts(inBankAccountsId);
                if (outBankAccountsInfo == null || intBankAccountsInfo == null)
                {
                    return;
                }
                string inDescription   = "[转入] [" + outBankAccountsInfo.BankName + "]" + description;
                var    inWasteBookInfo = new WasteBookInfo(Guid.NewGuid(), inBankAccountsId, tradeCode, dateCreated,
                                                           inDescription, sum, inNonceBalance, (int)AuditingState.Hide,
                                                           (int)WasteBookType.Increase, filialeId)
                {
                    LinkTradeCode = string.Empty,
                    LinkTradeType = (int)WasteBookLinkTradeType.Other
                };

                const string PD_DESC         = "[转出] [手续费]";
                var          pdWasteBookInfo = new WasteBookInfo(Guid.NewGuid(), outBankAccountsId, tradeCode, dateCreated,
                                                                 PD_DESC, -poundage, outNonceBalance, (int)AuditingState.Hide,
                                                                 (int)WasteBookType.Decrease, filialeId)
                {
                    LinkTradeCode = string.Empty,
                    LinkTradeType = (int)WasteBookLinkTradeType.Other
                };


                string outDescription   = "[转出] [" + intBankAccountsInfo.BankName + "]" + description;
                var    outWasteBookInfo = new WasteBookInfo(Guid.NewGuid(), outBankAccountsId, tradeCode, dateCreated,
                                                            outDescription, -sum, outNonceBalance, (int)AuditingState.No,
                                                            (int)WasteBookType.Decrease, filialeId)
                {
                    LinkTradeCode = string.Empty,
                    LinkTradeType = (int)WasteBookLinkTradeType.Other
                };

                using (var ts = new TransactionScope(TransactionScopeOption.Required))
                {
                    try
                    {
                        _wasteBookDao.Insert(inWasteBookInfo);

                        if (poundage > 0)
                        {
                            _wasteBookDao.Insert(pdWasteBookInfo);
                        }

                        _wasteBookDao.Insert(outWasteBookInfo);
                        ts.Complete();
                    }
                    catch
                    {
                        throw new ApplicationException("转帐同步失败!");
                    }
                }
            }
        }