Esempio n. 1
0
        /// <summary>
        /// 排产(主单)
        /// </summary>
        /// <param name="keyValue">主键值</param>
        /// <param name="entity">实体对象</param>
        /// <returns></returns>
        public void SavePlanForm(string keyValue, Sale_CustomerEntity entity)
        {
            try
            {
                if (!string.IsNullOrEmpty(keyValue))
                {
                    if (entity.StatePlanDate != null || entity.EndPlanDate != null)
                    {
                        IRepository db = this.BaseRepository().BeginTrans();
                        entity.PlanMark = 1;
                        entity.Modify(keyValue);
                        db.Update <Sale_CustomerEntity>(entity);


                        //修改销售单排产状态
                        DZ_OrderEntity dZ_OrderEntity = new DZ_OrderEntity
                        {
                            PlanMark = 1,
                        };
                        dZ_OrderEntity.Modify(entity.OrderId);//原生产单实体才对
                        db.Update <DZ_OrderEntity>(dZ_OrderEntity);
                        db.Commit();

                        RecordHelp.AddRecord(4, entity.OrderId, "生产排产:" + entity.StatePlanDate.ToString().Replace(" 0:00:00", "") + "至" + entity.EndPlanDate.ToString().Replace(" 0:00:00", ""));
                    }
                }
            }
            catch (Exception)
            {
                throw;
            }
        }
Esempio n. 2
0
 /// <summary>
 /// 完成
 /// </summary>
 /// <param name="keyValue">主键值</param>
 /// <returns></returns>
 public void UpdateOverState(string keyValue, int?state)
 {
     try
     {
         if (!string.IsNullOrEmpty(keyValue))
         {
             Sale_CustomerEntity entity = new Sale_CustomerEntity()
             {
                 OverMark = state
             };
             entity.Modify(keyValue);
             this.BaseRepository().Update(entity);
         }
     }
     catch (Exception)
     {
         throw;
     }
 }
Esempio n. 3
0
        /// <summary>
        /// 推单
        /// </summary>
        /// <param name="keyValue">主键值</param>
        /// <param name="state">状态1推单-1撤单</param>
        /// <param name="orderId">销售单id</param>
        /// <returns></returns>
        public void UpdatePushState(string keyValue, int?state, string orderId)
        {
            IRepository db = this.BaseRepository().BeginTrans();

            try
            {
                if (!string.IsNullOrEmpty(keyValue))
                {
                    Sale_CustomerEntity entity = new Sale_CustomerEntity()
                    {
                        PushMark     = state,
                        PushDate     = DateTime.Now,
                        EndDate      = DateTime.Now.AddDays(30).Date,//最迟交付日期
                        PushUserId   = OperatorProvider.Provider.Current().UserId,
                        PushUserName = OperatorProvider.Provider.Current().UserName
                    };
                    entity.Modify(keyValue);
                    db.Update <Sale_CustomerEntity>(entity);

                    if (!string.IsNullOrEmpty(orderId))
                    {
                        //修改销售单推单状态
                        DZ_OrderEntity dZ_OrderEntity = new DZ_OrderEntity
                        {
                            PushMark = state,
                            PushDate = DateTime.Now
                        };
                        dZ_OrderEntity.Modify(orderId);//原生产单实体才对
                        db.Update <DZ_OrderEntity>(dZ_OrderEntity);
                    }
                    db.Commit();

                    RecordHelp.AddRecord(4, orderId, "生产推单");
                }
            }
            catch (Exception)
            {
                db.Rollback();
                throw;
            }
        }
Esempio n. 4
0
        /// <summary>
        /// 保存表单(新增、修改)
        /// </summary>
        /// <param name="keyValue">主键值</param>
        /// <param name="entity">实体对象</param>
        /// <returns></returns>
        public void SaveForm(string keyValue, Sale_CustomerEntity entity, List <Sale_Customer_ItemEntity> entryList)
        {
            IRepository db = this.BaseRepository().BeginTrans();

            try
            {
                if (!string.IsNullOrEmpty(keyValue))
                {
                    //主表
                    entity.Modify(keyValue);
                    db.Update(entity);
                    //明细
                    db.Delete <Sale_Customer_ItemEntity>(t => t.CustomerId.Equals(keyValue));
                    foreach (Sale_Customer_ItemEntity item in entryList)
                    {
                        item.Create();
                        item.CustomerId = entity.CustomerId;
                        db.Insert(item);
                    }
                }
                else
                {
                    //主表
                    entity.Create();
                    db.Insert(entity);
                    //明细
                    foreach (Sale_Customer_ItemEntity item in entryList)
                    {
                        item.Create();
                        item.CustomerId = entity.CustomerId;
                        db.Insert(item);
                    }
                }
                db.Commit();
            }
            catch (Exception)
            {
                db.Rollback();
                throw;
            }
        }
Esempio n. 5
0
        /// <summary>
        /// 撤单
        /// </summary>
        /// <param name="keyValue">主键值</param>
        /// <param name="entity">实体对象</param>
        /// <returns></returns>
        public void SavePushBackForm(string keyValue, Sale_CustomerEntity entity)
        {
            IRepository db = this.BaseRepository().BeginTrans();

            try
            {
                if (!string.IsNullOrEmpty(keyValue))
                {
                    if (!string.IsNullOrEmpty(entity.PushBackPath))
                    {
                        //修改生产单撤单状态
                        entity.PushMark     = -1;
                        entity.PushDate     = DateTime.Now;
                        entity.PushUserId   = OperatorProvider.Provider.Current().UserId;
                        entity.PushUserName = OperatorProvider.Provider.Current().UserName;

                        //修改销售单撤单状态
                        DZ_OrderEntity dZ_OrderEntity = new DZ_OrderEntity
                        {
                            PushMark       = -1,
                            PushDate       = DateTime.Now,
                            PushBackReason = entity.PushBackReason,
                            PushBackPath   = entity.PushBackPath
                        };
                        dZ_OrderEntity.Modify(entity.OrderId);//原生产单实体才对
                        db.Update <DZ_OrderEntity>(dZ_OrderEntity);
                    }
                    entity.Modify(keyValue);
                    db.Update <Sale_CustomerEntity>(entity);
                    db.Commit();
                    RecordHelp.AddRecord(4, entity.OrderId, "生产撤单");
                }
            }
            catch (Exception)
            {
                db.Rollback();
                throw;
            }
        }
Esempio n. 6
0
        /// <summary>
        /// 删除数据
        /// </summary>
        /// <param name="keyValue">主键</param>
        public void RemoveForm(string keyValue)
        {
            Sale_CustomerEntity entity = GetEntity(keyValue);

            entity.Modify(keyValue);
            entity.DeleteMark = 1;
            this.BaseRepository().Update(entity);


            //IRepository db = new RepositoryFactory().BaseRepository().BeginTrans();
            //try
            //{
            //    db.Delete<Sale_CustomerEntity>(keyValue);
            //    db.Delete<Sale_Customer_ItemEntity>(t => t.MainId.Equals(keyValue));
            //    db.Commit();
            //}
            //catch (Exception)
            //{
            //    db.Rollback();
            //    throw;
            //}
        }
Esempio n. 7
0
        /// <summary>
        /// 保存表单(新增、修改)
        /// </summary>
        /// <param name="keyValue">主键值</param>
        /// <param name="entity">实体对象</param>
        /// <param name="entryList">明细对象</param>
        /// <returns></returns>
        public void SaveForm(string keyValue, Sales_ContractEntity entity, List <Sales_Contract_ItemEntity> entryList)
        {
            IRepository db = this.BaseRepository().BeginTrans();

            try
            {
                if (!string.IsNullOrEmpty(keyValue))
                {
                    //主表
                    entity.Modify(keyValue);
                    db.Update(entity);

                    //明细
                    db.Delete <Sales_Contract_ItemEntity>(t => t.ContractId.Equals(keyValue));

                    foreach (Sales_Contract_ItemEntity item in entryList)
                    {
                        item.Create();
                        item.ContractId = entity.Id;
                        db.Insert(item);
                        //出库才减库存
                        if (entity.Status == 1)
                        {
                            MinusWareGoods(db, item);
                        }
                    }
                }
                else
                {
                    //主表
                    entity.Create();
                    db.Insert(entity);

                    //出库再操作,初始化余量主表
                    if (entity.Status == 1)
                    {
                        Sale_CustomerEntity saleCustomer = db.FindEntity <Sale_CustomerEntity>(t => t.CustomerId.Equals(entity.CustomerId));

                        if (saleCustomer != null)
                        {
                            saleCustomer.SumTotalAmount = saleCustomer.SumTotalAmount + entity.TotalAmount;
                            saleCustomer.SumTotalCount  = saleCustomer.SumTotalCount + entity.TotalCount;
                            saleCustomer.ModifyUserId   = entity.UserId;
                            saleCustomer.ModifyUserName = entity.UserName;
                            saleCustomer.Modify(saleCustomer.CustomerId);
                            db.Update(saleCustomer);
                        }
                        else
                        {
                            Sale_CustomerEntity saleCustomerEntity = new Sale_CustomerEntity()
                            {
                                CustomerId      = entity.CustomerId,
                                CustomerCompany = entity.CustomerCompany,
                                SumTotalAmount  = entity.TotalAmount,
                                SumTotalCount   = entity.TotalCount,
                                CreateUserId    = entity.UserId,
                                CreateUserName  = entity.UserName,
                            };
                            saleCustomerEntity.Create();
                            db.Insert(saleCustomerEntity);
                        }
                    }



                    //明细
                    int sort = 0;
                    foreach (Sales_Contract_ItemEntity item in entryList)
                    {
                        item.Sort = sort++;
                        item.Create();
                        item.ContractId = entity.Id;
                        db.Insert(item);
                        //出库才减库存
                        if (entity.Status == 1)
                        {
                            //出库才减库存
                            MinusWareGoods(db, item);

                            #region 余量信息
                            //出库才初始化余量子表
                            Sale_Customer_ItemEntity saleCustomerItem = db.FindEntity <Sale_Customer_ItemEntity>(t => t.CustomerId.Equals(entity.CustomerId) && t.ProductId.Equals(item.ProductId));
                            //商品已经进过一次货,在上次进货基础上累加总进货量
                            if (saleCustomerItem != null)
                            {
                                saleCustomerItem.UnitPrice = item.UnitPrice;
                                saleCustomerItem.SumAmount = saleCustomerItem.SumAmount + item.Amount;
                                saleCustomerItem.SumCount  = saleCustomerItem.SumCount + item.Count;
                                saleCustomerItem.Modify(saleCustomerItem.Id);
                                db.Update(saleCustomerItem);
                            }
                            else
                            {
                                //第一次进货,新增此商品
                                Sale_Customer_ItemEntity saleCustomerItemEntity = new Sale_Customer_ItemEntity()
                                {
                                    CustomerId  = entity.CustomerId,
                                    ProductId   = item.ProductId,
                                    ProductCode = item.ProductCode,
                                    ProductName = item.ProductName,
                                    UnitPrice   = item.UnitPrice,
                                    SumAmount   = item.Amount,
                                    SumCount    = item.Count,
                                    Sort        = item.Sort,
                                };
                                saleCustomerItemEntity.Create();
                                db.Insert(saleCustomerItemEntity);
                            }

                            #endregion
                        }
                    }
                    //占用单据号
                    coderuleService.UseRuleSeed(SystemInfo.CurrentModuleId, db);
                }
                db.Commit();
            }
            catch (Exception ex)
            {
                db.Rollback();
                throw;
            }
        }
Esempio n. 8
0
        /// <summary>
        /// 工序撤销
        /// </summary>
        /// <param name="keyValue">主键值</param>
        /// <param name="step">工序</param>
        /// <param name="name">姓名</param>
        /// <returns></returns>
        public void SaveStepBackForm(string keyValue, int?step, string name)
        {
            try
            {
                if (!string.IsNullOrEmpty(keyValue))
                {
                    Sale_CustomerEntity oldEntity = GetEntity(keyValue);
                    if (oldEntity != null)
                    {
                        if (step != null)
                        {
                            switch (step)
                            {
                            case 0:
                                oldEntity.BeiLiaoUserName = oldEntity.BeiLiaoUserName.Replace(name, "");
                                if (string.IsNullOrEmpty(oldEntity.BeiLiaoUserName))
                                {
                                    oldEntity.BeiLiaoMark = 1;
                                }
                                break;

                            case 1:
                                oldEntity.KaiLiaoUserName = oldEntity.KaiLiaoUserName.Replace(name, "");
                                if (string.IsNullOrEmpty(oldEntity.KaiLiaoUserName))
                                {
                                    oldEntity.KaiLiaoMark = 1;
                                }
                                break;

                            case 2:
                                oldEntity.FengBianUserName = oldEntity.FengBianUserName.Replace(name, "");
                                if (string.IsNullOrEmpty(oldEntity.FengBianUserName))
                                {
                                    oldEntity.FengBianMark = 1;
                                }
                                break;

                            case 3:
                                oldEntity.PaiZuanUserName = oldEntity.PaiZuanUserName.Replace(name, "");
                                if (string.IsNullOrEmpty(oldEntity.PaiZuanUserName))
                                {
                                    oldEntity.PaiZuanMark = 1;
                                }
                                break;

                            case 4:
                                oldEntity.ShiZhuangUserName = oldEntity.ShiZhuangUserName.Replace(name, "");
                                if (string.IsNullOrEmpty(oldEntity.ShiZhuangUserName))
                                {
                                    oldEntity.ShiZhuangMark = 1;
                                }
                                break;

                            case 5:
                                oldEntity.BaoZhuangUserName = oldEntity.BaoZhuangUserName.Replace(name, "");
                                if (string.IsNullOrEmpty(oldEntity.BaoZhuangUserName))
                                {
                                    oldEntity.BaoZhuangMark = 1;
                                }
                                break;

                            default:
                                break;
                            }
                            oldEntity.Modify(keyValue);
                            this.BaseRepository().Update(oldEntity);
                            RecordHelp.AddRecord(4, oldEntity.OrderId, "工序撤销:" + name);
                        }
                    }
                }
            }
            catch (Exception)
            {
                throw;
            }
        }
Esempio n. 9
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;
            }
        }
Esempio n. 10
0
        /// <summary>
        /// 生产单修改编辑
        /// </summary>
        /// <param name="keyValue">主键值</param>
        /// <param name="entity">实体对象</param>
        /// <param name="entryList">实体子对象</param>
        /// <returns></returns>
        public void SaveForm(string keyValue, Sale_CustomerEntity entity, List <Sale_Customer_ItemEntity> entryList)
        {
            IRepository db = this.BaseRepository().BeginTrans();

            try
            {
                //生产扫码之后编辑
                Sale_CustomerEntity oldEntity = GetEntity(keyValue);
                if (oldEntity != null)
                {
                    if (entity.BeiLiaoMark == 0 && entity.KaiLiaoMark == 0 && entity.FengBianMark == 0 && entity.PaiZuanMark == 0 && entity.ShiZhuangMark == 0 && entity.BaoZhuangMark == 0)
                    {
                        //都没有选中工序,则不需要柜体入库,自动创建一条入库单,仓库进行门板入库或五金外协入库,自db
                        buyService.SaveBuyMain(entity);
                    }

                    if (oldEntity.BeiLiaoMark == 2 || oldEntity.KaiLiaoMark == 2 || oldEntity.FengBianMark == 2 || oldEntity.PaiZuanMark == 2 || oldEntity.ShiZhuangMark == 2 || oldEntity.BaoZhuangMark == 2)
                    {
                        //如果生产扫码之后又修改编辑,工序的勾选状态默认==1,但是扫码之后的状态为2,不能因为编辑修改为2
                        entity.BeiLiaoMark   = oldEntity.BeiLiaoMark == 2 ? 2 : entity.BeiLiaoMark;
                        entity.KaiLiaoMark   = oldEntity.KaiLiaoMark == 2 ? 2 : entity.KaiLiaoMark;
                        entity.FengBianMark  = oldEntity.FengBianMark == 2 ? 2 : entity.FengBianMark;
                        entity.PaiZuanMark   = oldEntity.PaiZuanMark == 2 ? 2 : entity.PaiZuanMark;
                        entity.ShiZhuangMark = oldEntity.ShiZhuangMark == 2 ? 2 : entity.ShiZhuangMark;
                        entity.BaoZhuangMark = oldEntity.BaoZhuangMark == 2 ? 2 : entity.BaoZhuangMark;
                        LogHelper.AddLog("生产扫码之后-又编辑," + oldEntity.ProduceCode);
                    }
                    //包装扫码生成入库单之后-发现勾选材料错误--又编辑
                    Buys_OrderEntity oldBuysEntity = buyService.GetEntity(keyValue);
                    if (oldBuysEntity != null)
                    {
                        //如果已经入库了,勾选材料错误,发现少勾选了,需要修改,要同步到入库单
                        if (entity.GuiTiMark == 1 && oldBuysEntity.GuiEnterMark == null)
                        {
                            oldBuysEntity.GuiEnterMark = 0;//修改柜体状态为需要入库
                            LogHelper.AddLog("修改柜体状态为需要入库," + oldEntity.ProduceCode);
                        }
                        if (entity.WuJinMark == 1 && oldBuysEntity.WuEnterMark == null)
                        {
                            oldBuysEntity.WuEnterMark = 0;//修改五金状态为需要入库
                            LogHelper.AddLog("修改五金状态为需要入库," + oldEntity.ProduceCode);
                        }
                        if (entity.MenBanMark == 1 && oldBuysEntity.MenEnterMark == null)
                        {
                            oldBuysEntity.MenEnterMark = 0;//修改门板状态为需要入库
                            LogHelper.AddLog("修改门板状态为需要入库," + oldEntity.ProduceCode);
                        }
                        if (entity.WaiXieMark == 1 && oldBuysEntity.WaiEnterMark == null)
                        {
                            oldBuysEntity.WaiEnterMark = 0;//修改外协状态为需要入库
                            LogHelper.AddLog("修改外协状态为需要入库," + oldEntity.ProduceCode);
                        }

                        //如果已经入库了,勾选材料错误,发现多勾选了,需要去掉,要同步到入库单
                        if (entity.GuiTiMark == 0 && oldBuysEntity.GuiEnterMark == 1)
                        {
                            oldBuysEntity.GuiEnterMark = -1;//修改柜体状态为不需要入库
                            LogHelper.AddLog("修改柜体状态为不需要入库," + oldEntity.ProduceCode);
                        }
                        if (entity.WuJinMark == 0 && oldBuysEntity.WuEnterMark == 1)
                        {
                            oldBuysEntity.WuEnterMark = -1;//修改五金状态为不需要入库
                            LogHelper.AddLog("修改五金状态为不需要入库," + oldEntity.ProduceCode);
                        }
                        if (entity.MenBanMark == 0 && oldBuysEntity.MenEnterMark == 1)
                        {
                            oldBuysEntity.MenEnterMark = -1;//修改门板状态为不需要入库
                            LogHelper.AddLog("修改门板状态为不需要入库," + oldEntity.ProduceCode);
                        }
                        if (entity.WaiXieMark == 0 && oldBuysEntity.WaiEnterMark == 1)
                        {
                            oldBuysEntity.WaiEnterMark = -1;//修改外协状态为不需要入库
                            LogHelper.AddLog("修改外协状态为不需要入库," + oldEntity.ProduceCode);
                        }

                        db.Update <Buys_OrderEntity>(oldBuysEntity);
                    }

                    //主表
                    entity.Modify(keyValue);
                    db.Update(entity);
                    //明细
                    db.Delete <Sale_Customer_ItemEntity>(t => t.MainId.Equals(keyValue));

                    foreach (Sale_Customer_ItemEntity item in entryList)
                    {
                        item.Create();
                        item.MainId = entity.ProduceId;
                        db.Insert(entryList);
                    }

                    db.Commit();
                    RecordHelp.AddRecord(4, entity.OrderId, "补充生产单");
                }
            }
            catch (Exception)
            {
                db.Rollback();
                throw;
            }
        }
Esempio n. 11
0
        /// <summary>
        /// 实际发货
        /// </summary>
        /// <param name="keyValue">主键值</param>
        /// <param name="SendOutImg">主键值</param>
        /// <returns></returns>
        public void UpdateSendState(string keyValue, string SendOutImg)
        {
            IRepository db = this.BaseRepository().BeginTrans();

            try
            {
                if (!string.IsNullOrEmpty(keyValue))
                {
                    Buys_OrderEntity entity = GetEntity(keyValue);
                    entity.Modify(keyValue);
                    entity.SendOutMark     = 1;
                    entity.SendOutImg      = SendOutImg;
                    entity.SendOutDate     = DateTime.Now;
                    entity.SendOutUserId   = OperatorProvider.Provider.Current().UserId;
                    entity.SendOutUserName = OperatorProvider.Provider.Current().UserName;
                    //this.BaseRepository().Update(entity);
                    db.Update <Buys_OrderEntity>(entity);

                    //同步到销售单-发货状态
                    DZ_OrderEntity dZ_OrderEntity = new DZ_OrderEntity
                    {
                        SendOutMark     = 1,
                        SendOutImg      = SendOutImg,
                        SendOutDate     = DateTime.Now,
                        SendOutUserId   = entity.SendOutUserId,
                        SendOutUserName = entity.SendOutUserName
                    };
                    dZ_OrderEntity.Modify(entity.OrderId);
                    db.Update <DZ_OrderEntity>(dZ_OrderEntity);

                    //同步到生产表-实际发货状态
                    Sale_CustomerEntity produceEntity = new Sale_CustomerEntity
                    {
                        SendOutMark     = 1,
                        SendOutDate     = DateTime.Now,
                        SendOutUserId   = entity.SendOutUserId,
                        SendOutUserName = entity.SendOutUserName
                    };
                    produceEntity.Modify(entity.ProduceId);
                    db.Update <Sale_CustomerEntity>(produceEntity);


                    //发微信模板消息--给销售人提醒(10实际发货提醒)
                    if (!string.IsNullOrEmpty(entity.SalesmanUserName))
                    {
                        var hsf_CardList = db.IQueryable <Hsf_CardEntity>(t => t.Name.Equals(entity.SalesmanUserName));
                        if (hsf_CardList.Count() != 0)
                        {
                            var hsf_CardEntity = hsf_CardList.First();
                            //订单生成通知,只有关注公众号的业务员才能收到消息(11实际发货提醒)
                            string backMsg = TemplateWxApp.SendTemplateSendOut(hsf_CardEntity.OpenId, "您好,您的订单已经发货!", entity.Code, entity.OrderTitle + ":共" + entity.TotalQty + "包。");
                            if (backMsg != "ok")
                            {
                                //业务员没有关注公众号,报错:微信Post请求发生错误!错误代码:43004,说明:require subscribe hint: [ziWtva03011295]
                                LogHelper.AddLog(entity.SalesmanUserName + "没有关注公众号");//记录日志
                            }
                        }
                    }
                    db.Commit();//此db需要用到查询销售人
                    RecordHelp.AddRecord(4, entity.OrderId, "发货");
                }
            }
            catch (Exception)
            {
                db.Rollback();
                throw;
            }
        }
Esempio n. 12
0
        /// <summary>
        /// 发货通知
        /// </summary>
        /// <param name="keyValue">主键值</param>
        /// <param name="entity">实体对象</param>
        /// <returns></returns>
        public void SaveSend(string keyValue, Buys_OrderEntity entity)
        {
            IRepository db = this.BaseRepository().BeginTrans();

            try
            {
                if (!string.IsNullOrEmpty(keyValue))
                {
                    Buys_OrderEntity oldEntity = GetEntity(keyValue);
                    //发货通知时间不为null,老发货通知时间为null
                    if (entity.SendPlanDate != null && entity.SendPlanDate != oldEntity.SendPlanDate)
                    {
                        //发微信模板消息---发货通知之后,给公维才发消息提醒?????
                        //订单生成通知(10发货通知提醒)
                        //公维才
                        TemplateWxApp.SendTemplateSend("oA-EC1Z5tDaD1-ejnQe_l_gJK1Us", "您好,有新的发货通知!", entity.Code, entity.OrderTitle + ",计划发货时间:" + entity.SendPlanDate);
                        //金志花
                        TemplateWxApp.SendTemplateSend("oA-EC1UWi8i4sSkHsWV6BK7CuopA", "您好,有新的发货通知!", entity.Code, entity.OrderTitle + ",计划发货时间:" + entity.SendPlanDate);
                        //牛霞
                        TemplateWxApp.SendTemplateSend("oA-EC1TDoDKimuejhFlBV1U6M5bI", "您好,有新的发货通知!", entity.Code, entity.OrderTitle + ",计划发货时间:" + entity.SendPlanDate);
                        //胡鲁鲁
                        TemplateWxApp.SendTemplateSend("oA-EC1aaKOSNdW2wL8lHSsr3R4Dg", "您好,有新的发货通知!", entity.Code, entity.OrderTitle + ",计划发货时间:" + entity.SendPlanDate);
                    }

                    entity.Modify(keyValue);
                    entity.SendMark     = 1;
                    entity.SendDate     = DateTime.Now;
                    entity.SendUserId   = OperatorProvider.Provider.Current().UserId;
                    entity.SendUserName = OperatorProvider.Provider.Current().UserName;
                    //this.BaseRepository().Update(entity);
                    db.Update <Buys_OrderEntity>(entity);

                    //同步到销售单-发货通知状态
                    DZ_OrderEntity dZ_OrderEntity = new DZ_OrderEntity
                    {
                        SendMark     = 1,
                        SendDate     = DateTime.Now,
                        SendPlanDate = entity.SendPlanDate,
                        SendUserId   = entity.SendUserId,
                        SendUserName = entity.SendUserName
                    };
                    dZ_OrderEntity.Modify(entity.OrderId);
                    db.Update <DZ_OrderEntity>(dZ_OrderEntity);

                    //同步到生产表-发货通知状态
                    Sale_CustomerEntity produceEntity = new Sale_CustomerEntity
                    {
                        SendMark     = 1,
                        SendDate     = DateTime.Now,
                        SendPlanDate = entity.SendPlanDate,
                        SendUserId   = entity.SendUserId,
                        SendUserName = entity.SendUserName
                    };
                    produceEntity.Modify(entity.ProduceId);
                    db.Update <Sale_CustomerEntity>(produceEntity);
                    db.Commit();
                    RecordHelp.AddRecord(4, entity.OrderId, "发货通知:" + entity.SendPlanDate.ToString().Replace(" 0:00:00", ""));
                }
            }
            catch (Exception)
            {
                db.Rollback();
                throw;
            }
        }
Esempio n. 13
0
        /// <summary>
        /// 分柜体,门板,五金,添加入库之后,判断是否完全入库
        /// </summary>
        /// <param name="itemEntity">实体对象</param>
        /// <returns></returns>
        public void SaveInForm(Buys_OrderItemEntity itemEntity)
        {
            IRepository db = new RepositoryFactory().BaseRepository().BeginTrans();

            try
            {
                Buys_OrderItemEntity oldItemEntity = GetDetail(itemEntity.OrderId, itemEntity.SortCode);
                Buys_OrderEntity     buyEntity     = GetEntity(itemEntity.OrderId);

                //先删除再创建
                if (oldItemEntity != null)
                {
                    db.Delete <Buys_OrderItemEntity>(oldItemEntity.OrderEntryId);

                    buyEntity.TotalQty -= oldItemEntity.Qty;//减去老库存
                    if (itemEntity.Qty == 0)
                    {
                        //等于0的情况,直接删掉当前入库记录,当前材料的,入库状态改成null
                        switch (itemEntity.SortCode)
                        {
                        case 1: buyEntity.GuiEnterMark = -1; break;

                        case 2: buyEntity.MenEnterMark = -1; break;

                        case 3: buyEntity.WuEnterMark = -1; break;

                        case 4: buyEntity.WaiEnterMark = -1; break;

                        default:
                            break;
                        }
                    }
                }

                if (itemEntity.Qty > 0)
                {
                    //新增入库单从表,新增要新增,初始化id,用户跳过
                    itemEntity.Create();
                    db.Insert <Buys_OrderItemEntity>(itemEntity);

                    buyEntity.TotalQty += itemEntity.Qty; //加上新库存
                                                          //修改入库状态,分柜体,门板,五金,外协
                    switch (itemEntity.SortCode)
                    {
                    case 1: buyEntity.GuiEnterMark = 1; break;

                    case 2: buyEntity.MenEnterMark = 1; break;

                    case 3: buyEntity.WuEnterMark = 1; break;

                    case 4: buyEntity.WaiEnterMark = 1; break;

                    default:
                        break;
                    }

                    //判断是否完全入库
                    if (buyEntity.GuiEnterMark == 0 || buyEntity.MenEnterMark == 0 || buyEntity.WuEnterMark == 0 || buyEntity.WaiEnterMark == 0)
                    {
                        //还没有完全入库
                        buyEntity.AllEnterMark = 0;
                    }
                    else
                    {
                        //完全入库修改状态
                        buyEntity.AllEnterMark = 1;
                        buyEntity.AllEnterDate = DateTime.Now;

                        //同步到接单表-入库状态
                        DZ_OrderEntity dZ_OrderEntity = new DZ_OrderEntity
                        {
                            EnterMark = 1,
                            EnterDate = DateTime.Now
                        };
                        dZ_OrderEntity.Modify(buyEntity.OrderId);
                        db.Update <DZ_OrderEntity>(dZ_OrderEntity);

                        //同步到生产表-入库状态
                        Sale_CustomerEntity produceEntity = new Sale_CustomerEntity
                        {
                            EnterMark = 1,
                            EnterDate = DateTime.Now
                        };
                        produceEntity.Modify(buyEntity.ProduceId);
                        db.Update <Sale_CustomerEntity>(produceEntity);

                        string wk = "";
                        //发微信模板消息--给销售人提醒(完全入库提醒)
                        if (buyEntity.PaymentState == 3 || buyEntity.AfterMark == 0)
                        {
                            //发微信模板消息---完全入库+(收齐尾款或者不需要收取尾款)之后,给胡鲁鲁发消息提醒????给程东彩发全部入库提醒
                            //订单生成通知(9完全入库提醒)
                            TemplateWxApp.SendTemplateAllIn("oA-EC1W1BQZ46Wc8HPCZZUUFbE9M", "您好,有新的订单已经入库!", buyEntity.OrderTitle, "共" + buyEntity.TotalQty + "包,请进行发货通知");
                            if (buyEntity.CompanyId == "0e4ad85a-7bd3-4cba-a390-26ba6d3bf6a2")
                            {
                                //整装部订单全部入库,给戴宝华提醒
                                TemplateWxApp.SendTemplateAllIn("oA-EC1ZrUuePIU9bIapbYnAVe6EU", "您好,有新的订单已经入库!", buyEntity.OrderTitle, "共" + buyEntity.TotalQty + "包,请进行发货通知");
                            }
                        }
                        else
                        {
                            wk = "请确认尾款。";
                        }

                        //发微信模板消息--给销售人提醒(完全入库提醒)
                        if (!string.IsNullOrEmpty(buyEntity.SalesmanUserName))
                        {
                            var hsf_CardList = db.IQueryable <Hsf_CardEntity>(t => t.Name.Equals(buyEntity.SalesmanUserName));
                            if (hsf_CardList.Count() != 0)
                            {
                                var hsf_CardEntity = hsf_CardList.First();
                                //订单生成通知,只有关注公众号的业务员才能收到消息(8完全入库提醒)
                                string backMsg = TemplateWxApp.SendTemplateAllIn(hsf_CardEntity.OpenId, "您好,您的订单已经全部入库!", buyEntity.Code, buyEntity.OrderTitle + ":共" + buyEntity.TotalQty + "包。" + wk);
                                if (backMsg != "ok")
                                {
                                    //业务员没有关注公众号,报错:微信Post请求发生错误!错误代码:43004,说明:require subscribe hint: [ziWtva03011295]
                                    LogHelper.AddLog(buyEntity.SalesmanUserName + "没有关注公众号");//记录日志
                                }
                            }
                        }
                    }
                }

                buyEntity.Modify(buyEntity.Id);
                db.Update <Buys_OrderEntity>(buyEntity);
                db.Commit();

                RecordHelp.AddRecord(4, buyEntity.OrderId, itemEntity.ProductName + "入库" + itemEntity.Qty + "包");
            }
            catch (Exception)
            {
                db.Rollback();
                throw;
            }
        }
Esempio n. 14
0
        /// <summary>
        /// 保存表单(新增、修改)
        /// </summary>
        /// <param name="keyValue">主键值</param>
        /// <param name="entity">实体对象</param>
        /// <param name="entryList">明细对象</param>
        /// <returns></returns>
        public void SaveForm(string keyValue, Buys_OrderEntity entity, List <Buys_OrderItemEntity> entryList)
        {
            IRepository db = this.BaseRepository().BeginTrans();

            try
            {
                if (!string.IsNullOrEmpty(keyValue))
                {
                    //主表
                    entity.Modify(keyValue);
                    db.Update(entity);
                    //明细
                    db.Delete <Buys_OrderItemEntity>(t => t.OrderId.Equals(keyValue));

                    foreach (Buys_OrderItemEntity item in entryList)
                    {
                        item.Create();
                        item.OrderId = entity.Id;
                        db.Insert(item);
                    }
                }
                else
                {
                    //新增入库单(自动添加之后,取消使用**************)

                    //主表
                    entity.Create();
                    db.Insert(entity);
                    coderuleService.UseRuleSeed(entity.CreateUserId, "", ((int)CodeRuleEnum.Buy_Order).ToString(), db);//占用单据号
                    //明细
                    foreach (Buys_OrderItemEntity item in entryList)
                    {
                        item.Create();
                        item.OrderId = entity.Id;
                        db.Insert(item);
                    }


                    //同步到接单表-入库状态
                    DZ_OrderEntity dZ_OrderEntity = new DZ_OrderEntity
                    {
                        EnterMark = 1,
                        EnterDate = DateTime.Now
                    };
                    dZ_OrderEntity.Modify(entity.OrderId);
                    db.Update <DZ_OrderEntity>(dZ_OrderEntity);
                    //同步到生产表-入库状态
                    Sale_CustomerEntity produceEntity = new Sale_CustomerEntity
                    {
                        EnterMark = 1,
                        EnterDate = DateTime.Now
                    };
                    produceEntity.Modify(entity.ProduceId);
                    db.Update <Sale_CustomerEntity>(produceEntity);
                }
                db.Commit();
            }
            catch (Exception)
            {
                db.Rollback();
                throw;
            }
        }
Esempio n. 15
0
        /// <summary>
        /// 保存生产单主单
        /// </summary>
        /// <param name="orderEntity">实体对象</param>
        /// <returns></returns>
        public static void SaveSaleMain(IRepository db, DZ_OrderEntity orderEntity)
        {
            try
            {
                //判断是否创建过这个生产单Id(跟生产编号一致,方便实体查询)
                Sale_CustomerEntity oldSale = db.FindEntity <Sale_CustomerEntity>(orderEntity.Code);
                //没创建过的才新增,避免下单不及时创建两个生产单初始单
                if (oldSale == null)
                {
                    //自动创建【生产单】主单部分
                    Sale_CustomerEntity sale_CustomerEntity = new Sale_CustomerEntity
                    {
                        ProduceCode      = orderEntity.Code, //生产单号默认和销售单号一样
                        OrderId          = orderEntity.Id,
                        OrderCode        = orderEntity.Code, //销售单号
                        OrderTitle       = orderEntity.OrderTitle,
                        OrderType        = orderEntity.OrderType,
                        CompanyId        = orderEntity.CompanyId,
                        CompanyName      = orderEntity.CompanyName,
                        CustomerId       = orderEntity.CustomerId,
                        CustomerName     = orderEntity.CustomerName,
                        SalesmanUserId   = orderEntity.SalesmanUserId,
                        SalesmanUserName = orderEntity.SalesmanUserName,
                        CustomerTelphone = orderEntity.CustomerTelphone,
                        SendPlanDate     = orderEntity.SendPlanDate,
                        Address          = orderEntity.Address,
                        ShippingType     = orderEntity.ShippingType,
                        Carrier          = orderEntity.Carrier,

                        //MoneyOkMark = orderEntity.MoneyOkMark == null ? 0 : orderEntity.MoneyOkMark,//报价审核
                        MoneyOkMark = orderEntity.MoneyOkMark,
                        MoneyOkDate = orderEntity.MoneyOkDate
                    };
                    sale_CustomerEntity.Create();//付款时间

                    //主表
                    db.Insert(sale_CustomerEntity);

                    //生成生产单id二维码
                    string url = "http://www.sikelai.cn/WeChatManage/Produce/StepSweepcode?id=" + sale_CustomerEntity.ProduceId;
                    CommonHelper.QRCode(url, sale_CustomerEntity.ProduceCode);

                    if (sale_CustomerEntity.MoneyOkMark == 1)
                    {
                        //发微信模板消息---财务已经报价审核并收款确认之后,给张宝莲发消息提醒oA-EC1bJnd0KFBuOy0joJvUOGwwk
                        //订单生成通知(7下单提醒)
                        TemplateWxApp.SendTemplateNew("oA-EC1bJnd0KFBuOy0joJvUOGwwk",
                                                      "您好,有新的订单需要下单!", sale_CustomerEntity.OrderTitle, sale_CustomerEntity.OrderCode, "请进行生产下单。");
                    }
                    RecordHelp.AddRecord(4, orderEntity.Id, "初始化生产单");
                }
                else
                {
                    //客诉单需要修改报价审核状态
                    oldSale.MoneyOkMark = orderEntity.MoneyOkMark;
                    oldSale.MoneyOkDate = orderEntity.MoneyOkDate;
                    oldSale.Modify(orderEntity.Code);
                    db.Update(oldSale);
                }
            }
            catch (Exception)
            {
                throw;
            }
        }