Ejemplo n.º 1
0
        /// <summary>
        /// 保存表单(新增)
        /// </summary>
        /// <param name="keyValue">主键值</param>
        /// <param name="entity">实体对象</param>
        /// <returns></returns>
        public void SaveForm(ExpensesEntity entity)
        {
            ICashBalanceService icashbalanceservice = new CashBalanceService();

            IRepository db = new RepositoryFactory().BaseRepository().BeginTrans();

            try
            {
                //支出
                entity.Create();
                db.Insert(entity);


                //添加账户余额
                icashbalanceservice.AddBalance(db, new CashBalanceEntity
                {
                    ObjectId      = entity.ExpensesId,
                    ExecutionDate = entity.ExpensesDate,
                    CashAccount   = entity.ExpensesAccount,
                    Expenses      = entity.ExpensesPrice,
                    Abstract      = entity.ExpensesAbstract
                });

                db.Commit();
            }
            catch (Exception)
            {
                db.Rollback();
                throw;
            }
        }
Ejemplo n.º 2
0
        /// <summary>
        /// 保存表单(新增)
        /// </summary>
        /// <param name="entity">实体对象</param>
        /// <returns></returns>
        public void SaveForm(ReceivableEntity entity)
        {
            ICashBalanceService icashbalanceservice = new CashBalanceService();
            OrderEntity         orderEntity         = orderIService.GetEntity(entity.OrderId);

            IRepository db = new RepositoryFactory().BaseRepository().BeginTrans();

            try
            {
                //更改订单状态
                orderEntity.ReceivedAmount = orderEntity.ReceivedAmount + entity.PaymentPrice;
                if (orderEntity.ReceivedAmount == orderEntity.Accounts)
                {
                    orderEntity.PaymentState = 3;
                }
                else
                {
                    orderEntity.PaymentState = 2;
                }
                db.Update(orderEntity);
                //添加收款
                entity.Create();
                db.Insert(entity);
                //添加账户余额
                icashbalanceservice.AddBalance(db, new CashBalanceEntity
                {
                    ObjectId      = entity.ReceivableId,
                    ExecutionDate = entity.PaymentTime,
                    CashAccount   = entity.PaymentAccount,
                    Receivable    = entity.PaymentPrice,
                    Abstract      = entity.Description
                });

                db.Commit();
            }
            catch (Exception)
            {
                db.Rollback();
                throw;
            }
        }
Ejemplo n.º 3
0
        /// <summary>
        /// 保存表单(新增、修改)
        /// </summary>
        /// <param name="keyValue">主键值</param>
        /// <param name="entity">实体对象</param>
        /// <returns></returns>
        public void UpdateStateForm(string keyValue, ReceivableEntity entity)
        {
            ICashBalanceService icashbalanceservice = new CashBalanceService();
            DZ_OrderEntity      orderEntity         = orderIService.GetEntity(entity.OrderId);

            IRepository db = new RepositoryFactory().BaseRepository().BeginTrans();

            try
            {
                if (!string.IsNullOrEmpty(keyValue))
                {
                    ReceivableEntity oldEntity = GetEntity(keyValue);

                    //第一次确认付款才真正修改金额
                    if (entity.EnabledMark == 1 && oldEntity.EnabledMark != 1)
                    {
                        //更改订单状态
                        orderEntity.ReceivedAmount = orderEntity.ReceivedAmount + entity.PaymentPrice; //收款金额
                        orderEntity.PaymentDate    = oldEntity.PaymentTime;                            //收款日期=业务员填的日期

                        //已收款金额=订单金额
                        if (orderEntity.ReceivedAmount == orderEntity.Accounts)
                        {
                            orderEntity.PaymentState = 3;//全部收款

                            //发微信模板消息
                            if (!string.IsNullOrEmpty(oldEntity.CreateUserName))
                            {
                                var hsf_CardList = db.IQueryable <Hsf_CardEntity>(t => t.Name.Equals(oldEntity.CreateUserName));//发送给创建订单的人,店长代替店员创建,所以店长能看见拆单报价
                                if (hsf_CardList.Count() != 0)
                                {
                                    var hsf_CardEntity = hsf_CardList.First();
                                    //发微信模板消息---营销收款之后,给销售员提醒--(收款确认提醒:已全部收款)
                                    string backMsg = TemplateWxApp.SendTemplateReceivableOk(hsf_CardEntity.OpenId, "您好,有的收款已经确认!", "通过", "已全部收款");
                                    RecordHelp.AddRecord(4, entity.OrderId, "收款确认(全部收款)");
                                    if (backMsg != "ok")
                                    {
                                        //业务员没有关注公众号,报错:微信Post请求发生错误!错误代码:43004,说明:require subscribe hint: [ziWtva03011295]
                                        LogHelper.AddLog(entity.SalesmanUserName + "没有关注公众号");//记录日志
                                    }
                                }
                            }

                            //全部收款之后更新【入库单】中的【尾款】状态
                            Buys_OrderEntity buyEntity = buyIService.GetEntityByOrderId(orderEntity.Id);
                            if (buyEntity != null)
                            {
                                buyEntity.PaymentDate  = DateTime.Now; //付款确认时间
                                buyEntity.PaymentState = 3;            //全部收款
                                db.Update(buyEntity);
                            }
                        }
                        else
                        {
                            orderEntity.PaymentState = 2;//部分收款

                            //发微信模板消息
                            if (!string.IsNullOrEmpty(oldEntity.CreateUserName))
                            {
                                var hsf_CardList = db.IQueryable <Hsf_CardEntity>(t => t.Name.Equals(oldEntity.CreateUserName));//发送给创建订单的人,店长代替店员创建,所以店长能看见拆单报价
                                if (hsf_CardList.Count() != 0)
                                {
                                    var hsf_CardEntity = hsf_CardList.First();
                                    //发微信模板消息---营销收款之后,给销售员提醒--(收款确认提醒:部分收款)
                                    string backMsg = TemplateWxApp.SendTemplateReceivableOk(hsf_CardEntity.OpenId, "您好,您的收款已经确认!", "通过", oldEntity.Code + "部分收款");
                                    RecordHelp.AddRecord(4, entity.OrderId, "收款确认(部分收款)");
                                    if (backMsg != "ok")
                                    {
                                        //业务员没有关注公众号,报错:微信Post请求发生错误!错误代码:43004,说明:require subscribe hint: [ziWtva03011295]
                                        LogHelper.AddLog(entity.SalesmanUserName + "没有关注公众号");//记录日志
                                    }
                                }
                            }
                        }
                        db.Update(orderEntity);

                        //修改【下单状态】,第一次收款的时候才创建
                        if (orderEntity.DownMark != 1)
                        {
                            //付了预付款,自动创建【生产单】主单部分*****************
                            Sale_Customer_Main.SaveSaleMain(db, orderEntity);//如果下单不及时,可能重复创建
                        }
                    }
                    if (entity.EnabledMark == -1 && oldEntity.EnabledMark != -1)
                    {
                        RecordHelp.AddRecord(4, entity.OrderId, "收款确认驳回");
                        var hsf_CardList = db.IQueryable <Hsf_CardEntity>(t => t.Name.Equals(oldEntity.CreateUserName));//发送给创建订单的人,店长代替店员创建,所以店长能看见拆单报价
                        if (hsf_CardList.Count() != 0)
                        {
                            var hsf_CardEntity = hsf_CardList.First();
                            //发微信模板消息---营销收款之后,给销售员提醒--(收款确认提醒:部分收款)
                            string backMsg = TemplateWxApp.SendTemplateReject(hsf_CardEntity.OpenId, "您好,收款确认人驳回订单!", oldEntity.Code, oldEntity.OrderTitle);
                            if (backMsg != "ok")
                            {
                                //业务员没有关注公众号,报错:微信Post请求发生错误!错误代码:43004,说明:require subscribe hint: [ziWtva03011295]
                                LogHelper.AddLog(entity.SalesmanUserName + "没有关注公众号");//记录日志
                            }
                        }
                    }

                    entity.Modify(keyValue);
                    this.BaseRepository().Update(entity);
                }

                db.Commit();
            }
            catch (Exception)
            {
                db.Rollback();
                throw;
            }
        }