Exemple #1
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;
            }
        }
Exemple #2
0
        /// <summary>
        /// 下单
        /// </summary>
        /// <param name="keyValue">主键值</param>
        /// <param name="entity">实体对象</param>
        /// <returns></returns>
        public void SaveDownForm(string keyValue, Sale_CustomerEntity entity)
        {
            IRepository db = this.BaseRepository().BeginTrans();

            try
            {
                if (!string.IsNullOrEmpty(keyValue))
                {
                    Sale_CustomerEntity oldEntity      = GetEntity(keyValue);
                    DZ_OrderEntity      dZ_OrderEntity = new DZ_OrderEntity();
                    //原生产单没有下单文件,第一次上传下单文件,则修改下单状态
                    if (entity.DownMark == 1 && oldEntity.DownMark != 1)// && string.IsNullOrEmpty(oldEntity.DownPath)//不管之前有没有上传都修改下单状态
                    {
                        //发微信模板消息---下单之后,给程东彩发消息提醒oA-EC1W1BQZ46Wc8HPCZZUUFbE9M
                        //订单生成通知(8下单提醒)
                        TemplateWxApp.SendTemplateNew("oA-EC1W1BQZ46Wc8HPCZZUUFbE9M", "您好,有新的订单需要推单!", entity.OrderTitle, entity.OrderCode, "请进行审核推单。");
                        RecordHelp.AddRecord(4, entity.OrderId, "生产下单");

                        if (entity.OrderType == 3)
                        {
                            dZ_OrderEntity.PushMark = 1;
                            dZ_OrderEntity.PushDate = DateTime.Now;
                            entity.PushMark         = 1;
                            entity.PushDate         = DateTime.Now;
                            RecordHelp.AddRecord(4, entity.OrderId, "客诉单跳过推单");
                        }
                    }

                    if (entity.DownMark == -1 && oldEntity.DownMark != -1)// && string.IsNullOrEmpty(oldEntity.DownPath)//不管之前有没有上传都修改下单状态
                    {
                        //给刘一珠改刘庆莉发驳回提醒
                        string backMsg = TemplateWxApp.SendTemplateReject("oA-EC1bg4U16c63kR6yj51lA5AiM", "您好,下单人驳回订单!", oldEntity.OrderCode, oldEntity.OrderTitle);
                        RecordHelp.AddRecord(4, entity.OrderId, "生产下单驳回");

                        entity.DownPath = null;//下单驳回,下单附件路径清空
                    }

                    //修改销售单下单状态
                    dZ_OrderEntity.DownMark     = entity.DownMark;
                    dZ_OrderEntity.DownDate     = DateTime.Now;
                    dZ_OrderEntity.DownUserId   = OperatorProvider.Provider.Current().UserId;
                    dZ_OrderEntity.DownUserName = OperatorProvider.Provider.Current().UserName;
                    dZ_OrderEntity.DownPath     = entity.DownPath;
                    dZ_OrderEntity.Modify(entity.OrderId);//原生产单实体才对
                    db.Update <DZ_OrderEntity>(dZ_OrderEntity);


                    //修改生产单下单状态
                    entity.DownDate     = DateTime.Now;
                    entity.DownUserId   = OperatorProvider.Provider.Current().UserId;
                    entity.DownUserName = OperatorProvider.Provider.Current().UserName;
                    entity.Modify(keyValue);
                    db.Update <Sale_CustomerEntity>(entity);
                    db.Commit();
                }
            }
            catch (Exception)
            {
                db.Rollback();
                throw;
            }
        }