Пример #1
0
 public string AddRecommonOrder([FromBody]JObject jOject)
 {
     try
     {
         dynamic json = jOject;
         JObject jOrder = json.order;
         JObject jOrderDetail = json.orderDetail;
         var orderModel = jOrder.ToObject<OrderModel>();
         var orderDetailModel = jOrderDetail.ToObject<OrderDetailModel>();
         ProductEntity PE = _productService.GetProductById(orderDetailModel.ProductId);
         OrderDetailEntity ODE = new OrderDetailEntity()
         {
             Adddate = DateTime.Now,
             Adduser = orderDetailModel.Adduser,
             Commission = PE.Commission,
             Dealcommission = PE.Dealcommission,
             Price = PE.Price,
             Product = PE,
             Productname = PE.Productname,
             Remark = orderDetailModel.Remark,
             Snapshoturl = orderDetailModel.Snapshoturl,
             Upddate = DateTime.Now,
             Upduser = orderDetailModel.Upduser
         };
         OrderDetailEntity ODEResult = _orderDetailService.Create(ODE);//创建订单详情;
         //生成当前订单编号
         Random rd = new Random();
         string OrderNumber = "YJYDD" + DateTime.Now.ToString("yyyyMMddHHmmssffff") + rd.Next(100, 999).ToString();
         OrderEntity OE = new OrderEntity()
         {
             Adddate = DateTime.Now,
             Adduser = orderModel.Adduser,
             AgentId = orderModel.AgentId,
             Agentname = orderModel.Agentname,
             Agenttel = orderModel.Agenttel,
             BusId = PE.Bussnessid,
             Busname = "YooPoon",
             Customname = orderModel.Customname,
             Ordercode = OrderNumber,
             OrderDetail = ODEResult,
             //该条字段属性变更,因方法无使用,故注释
             //Ordertype = orderModel.Ordertype,
             Remark = orderModel.Remark,
             Shipstatus = orderModel.Shipstatus,
             Status = orderModel.Status,
             Upddate = DateTime.Now,
             Upduser = orderModel.Adduser
         };
         _orderService.Create(OE);//添加订单;
         return "生成订单成功";
     }
     catch (Exception e)
     {
         return "生成订单失败";
     }
 }
Пример #2
0
		public OrderDetailEntity Update (OrderDetailEntity entity)
		{
			try
            {
                _orderdetailRepository.Update(entity);
                return entity;
            }
            catch (Exception e)
            {
				_log.Error(e,"数据库操作出错");
                return null;
            }
		}
Пример #3
0
		public bool Delete(OrderDetailEntity entity)
		{
			try
            {
                _orderdetailRepository.Delete(entity);
                return true;
            }
            catch (Exception e)
            {
				_log.Error(e,"数据库操作出错");
                return false;
            }
		}
Пример #4
0
        public HttpResponseMessage PassAudit([FromBody]BrokerRECClientModel brokerRecClientModel)
        {
            if (brokerRecClientModel.Id == 0)
            {
                return PageHelper.toJson(PageHelper.ReturnValue(false, "Id不能为空"));
            }

            var model = _brokerRecClientService.GetBrokerRECClientById(brokerRecClientModel.Id);
            model.Status = brokerRecClientModel.Status;

            //if (brokerRecClientModel.Status == EnumBRECCType.等待上访)
            //{
            //    //查询商品详情
            //    var product = _productService.GetProductById(model.Projectid);

            //    //创建订单详情
            //    OrderDetailEntity ode = new OrderDetailEntity();
            //    ode.Adddate = DateTime.Now;
            //    ode.Adduser = model.Adduser.ToString(CultureInfo.InvariantCulture);
            //    ode.Commission = product.Commission;
            //    ode.RecCommission = product.RecCommission;
            //    ode.Dealcommission = product.Dealcommission;
            //    ode.Price = product.Price;
            //    ode.Product = product;
            //    ode.Productname = product.Productname;
            //    //ode.Remark = product.
            //    //ode.Snapshoturl = orderDetailModel.Snapshoturl,
            //    ode.Upddate = DateTime.Now;
            //    ode.Upduser = model.Adduser.ToString(CultureInfo.InvariantCulture);

            //    //创建订单
            //    OrderEntity oe = new OrderEntity();
            //    oe.Adddate = DateTime.Now;
            //    oe.Adduser = model.Adduser.ToString(CultureInfo.InvariantCulture);
            //    oe.AgentId = model.Broker.Id;//model.Adduser;此处存的应该是经纪人ID
            //    oe.Agentname = _brokerService.GetBrokerByUserId(model.Adduser).Brokername;
            //    oe.Agenttel = model.Phone;
            //    oe.BusId = product.Bussnessid;
            //    oe.Busname = product.BussnessName;
            //    oe.Customname = model.Clientname;
            //    oe.Ordercode = _orderService.CreateOrderNumber(1);
            //    oe.OrderDetail = ode;//订单详情;
            //    oe.Ordertype = EnumOrderType.推荐订单;
            //    oe.Remark = "前端经纪人提交";
            //    oe.Shipstatus = (int)EnumBRECCType.审核中;
            //    oe.Status = (int)EnumOrderStatus.默认;
            //    oe.Upddate = DateTime.Now;
            //    oe.Upduser = model.Adduser.ToString(CultureInfo.InvariantCulture);
               
            //    _orderService.Create(oe);
            //    model.RecOrder = oe.Id;
            //     _brokerRecClientService.Update(model);
            //}
            //else if (brokerRecClientModel.Status == EnumBRECCType.审核不通过) { return PageHelper.toJson(PageHelper.ReturnValue(false, "审核不通过")); }
                  
            //else if (brokerRecClientModel.Status == EnumBRECCType.审核中)
            //{}
            //else if (brokerRecClientModel.Status == EnumBRECCType.洽谈中) 
            //{
            //    var recOrder = _orderService.GetOrderById(model.RecOrder);
            //    int a = (int)Enum.Parse(typeof(EnumBRECCType), brokerRecClientModel.Status.ToString());
            //    recOrder.Shipstatus = a;
            //    recOrder.Status = (int)EnumOrderStatus.审核通过;
            //    recOrder.Upduser = _workContext.CurrentUser.Id.ToString(CultureInfo.InvariantCulture);
            //    recOrder.Upddate = DateTime.Now;
            //    _orderService.Update(recOrder);
            //}
            //else if (brokerRecClientModel.Status == EnumBRECCType.洽谈成功) 
            //{
            //    var recOrder = _orderService.GetOrderById(model.RecOrder);
            //    int a = (int)Enum.Parse(typeof(EnumBRECCType), brokerRecClientModel.Status.ToString());
            //    recOrder.Shipstatus = a;
            //    recOrder.Status = (int)EnumOrderStatus.审核通过;
            //    recOrder.Upduser = _workContext.CurrentUser.Id.ToString(CultureInfo.InvariantCulture);
            //    recOrder.Upddate = DateTime.Now;
            //    _orderService.Update(recOrder);
            //}
            //else if (brokerRecClientModel.Status == EnumBRECCType.洽谈失败) 
            //{
            //    var recOrder = _orderService.GetOrderById(model.RecOrder);
            //    int a = (int)Enum.Parse(typeof(EnumBRECCType), brokerRecClientModel.Status.ToString());
            //    recOrder.Shipstatus = a;
            //    model.DelFlag = EnumDelFlag.删除;
            //    recOrder.Upduser = _workContext.CurrentUser.Id.ToString(CultureInfo.InvariantCulture);
            //    recOrder.Upddate = DateTime.Now;
            //    _orderService.Update(recOrder);
            //}
            //else if (brokerRecClientModel.Status == EnumBRECCType.客人未到) 
            //{
            //    var recOrder = _orderService.GetOrderById(model.RecOrder);
            //    int a = (int)Enum.Parse(typeof(EnumBRECCType), brokerRecClientModel.Status.ToString());
            //    recOrder.Shipstatus = a;
            //    recOrder.Status = (int)EnumOrderStatus.审核失败;
            //    recOrder.Upduser = _workContext.CurrentUser.Id.ToString(CultureInfo.InvariantCulture);
            //    recOrder.Upddate = DateTime.Now;
            //    _orderService.Update(recOrder);
            //}
            switch (brokerRecClientModel.Status) 
            {
                case EnumBRECCType.审核中:
                  
                    break;
                case EnumBRECCType.审核不通过:
                    _brokerRecClientService.Delete(model);
                    return PageHelper.toJson(PageHelper.ReturnValue(false, "操作成功"));
                case EnumBRECCType.等待上访:
                    //查询商品详情
                    var product = _productService.GetProductById(model.Projectid);
                    //创建订单详情
                    OrderDetailEntity ode = new OrderDetailEntity();
                    ode.Adddate = DateTime.Now;
                    ode.Adduser = model.Adduser.ToString(CultureInfo.InvariantCulture);
                    ode.Commission = product.Commission;
                    ode.RecCommission = product.RecCommission;
                    ode.Dealcommission = product.Dealcommission;
                    ode.Price = product.Price;
                    ode.Product = product;
                    ode.Productname = product.Productname;
                    //ode.Remark = product.
                    //ode.Snapshoturl = orderDetailModel.Snapshoturl,
                    ode.Upddate = DateTime.Now;
                    ode.Upduser = model.Adduser.ToString(CultureInfo.InvariantCulture);
                    //创建订单
                    OrderEntity oe = new OrderEntity();
                    oe.Adddate = DateTime.Now;
                    oe.Adduser = model.Adduser.ToString(CultureInfo.InvariantCulture);
                    oe.AgentId = model.Broker.Id;//model.Adduser;此处存的应该是经纪人ID
                    oe.Agentname = _brokerService.GetBrokerByUserId(model.Adduser).Brokername;
                    oe.Agenttel = model.Phone;
                    oe.BusId = product.Bussnessid;
                    oe.Busname = product.BussnessName;
                    oe.Customname = model.Clientname;
                    oe.Ordercode = _orderService.CreateOrderNumber(1);
                    oe.OrderDetail = ode;//订单详情;
                    oe.Ordertype = EnumOrderType.推荐订单;
                    oe.Remark = "前端经纪人提交";
                    oe.Shipstatus = (int)EnumBRECCType.审核中;
                    oe.Status = (int)EnumOrderStatus.默认;
                    oe.Upddate = DateTime.Now;
                    oe.Upduser = model.Adduser.ToString(CultureInfo.InvariantCulture);
                    _orderService.Create(oe);
                    model.RecOrder = oe.Id;
                    _brokerRecClientService.Update(model);
                    break;
                case EnumBRECCType.洽谈中:
                        var recOrder = _orderService.GetOrderById(model.RecOrder);
                        int a = (int)Enum.Parse(typeof(EnumBRECCType), brokerRecClientModel.Status.ToString());
                        recOrder.Shipstatus = a;
                        recOrder.Status = (int)EnumOrderStatus.审核通过;
                        recOrder.Upduser = _workContext.CurrentUser.Id.ToString(CultureInfo.InvariantCulture);
                        recOrder.Upddate = DateTime.Now;
                        _orderService.Update(recOrder);
                    break;
                case EnumBRECCType.洽谈成功:
                        recOrder = _orderService.GetOrderById(model.RecOrder);
                        a = (int)Enum.Parse(typeof(EnumBRECCType), brokerRecClientModel.Status.ToString());
                        recOrder.Shipstatus = a;
                        recOrder.Status = (int)EnumOrderStatus.审核通过;
                        recOrder.Upduser = _workContext.CurrentUser.Id.ToString(CultureInfo.InvariantCulture);
                        recOrder.Upddate = DateTime.Now;
                        _orderService.Update(recOrder);
                    break;
                case EnumBRECCType.洽谈失败:
                        recOrder = _orderService.GetOrderById(model.RecOrder);
                        a = (int)Enum.Parse(typeof(EnumBRECCType), brokerRecClientModel.Status.ToString());
                        recOrder.Shipstatus = a;
                        model.DelFlag = EnumDelFlag.删除;
                        recOrder.Upduser = _workContext.CurrentUser.Id.ToString(CultureInfo.InvariantCulture);
                        recOrder.Upddate = DateTime.Now;
                        _orderService.Update(recOrder);
                    break;
                case EnumBRECCType.客人未到:
                        recOrder = _orderService.GetOrderById(model.RecOrder);
                        a = (int)Enum.Parse(typeof(EnumBRECCType), brokerRecClientModel.Status.ToString());
                        recOrder.Shipstatus = a;
                        recOrder.Status = (int)EnumOrderStatus.审核失败;
                        recOrder.Upduser = _workContext.CurrentUser.Id.ToString(CultureInfo.InvariantCulture);
                        recOrder.Upddate = DateTime.Now;
                        _orderService.Update(recOrder);
                    break;
            }
            model.Uptime = DateTime.Now;
            model.Upuser = _workContext.CurrentUser.Id;
            _brokerRecClientService.Update(model);
            return PageHelper.toJson(PageHelper.ReturnValue(true, "确认成功"));
        }
        public HttpResponseMessage UpdateLeadClient([FromBody]BrokerLeadClientModel model)
        {
            if (model.Id == 0)
            {
                return PageHelper.toJson(PageHelper.ReturnValue(false, "Id不能为空"));
            }
            var entity = _brokerleadclientService.GetBrokerLeadClientById(model.Id);
            entity.Status = model.Status;
            model.Uptime = DateTime.Now;

            //if (model.Status == EnumBLeadType.等待上访) 
            //{
            //    entity.SecretaryId = _brokerService.GetBrokerByUserId(model.SecretaryId);
            //    //查询商品详情
            //    var product = _productService.GetProductById(model.Projectid);

            //    //创建订单详情
            //    OrderDetailEntity ode = new OrderDetailEntity
            //    {
            //        Adddate = DateTime.Now,
            //        Adduser = model.Adduser.ToString(CultureInfo.InvariantCulture),
            //        Commission = product.Commission,
            //        RecCommission = product.RecCommission,
            //        Dealcommission = product.Dealcommission,
            //        Price = product.Price,
            //        Product = product,
            //        Productname = product.Productname,
            //        Upddate = DateTime.Now,
            //        Upduser = model.Adduser.ToString(CultureInfo.InvariantCulture)
            //    };

            //    //创建订单
            //    OrderEntity oe = new OrderEntity
            //    {
            //        Adddate = DateTime.Now,
            //        Adduser = entity.Adduser.ToString(CultureInfo.InvariantCulture),
            //        AgentId = entity.Broker.Id,//model.Broker,//model.Adduser,
            //        Agenttel = model.Phone,
            //        Agentname = _brokerService.GetBrokerByUserId(entity.Adduser).Brokername,
            //        BusId = product.Bussnessid,
            //        Busname = product.BussnessName,
            //        Customname = entity.ClientInfo.Clientname,
            //        Ordercode = _orderService.CreateOrderNumber(2),
            //        OrderDetail = ode,
            //        Ordertype = EnumOrderType.带客订单,
            //        Remark = "前端经纪人提交",
            //        Shipstatus = (int)EnumBLeadType.等待上访,
            //        Status = (int)EnumOrderStatus.审核通过,
            //        Upddate = DateTime.Now,
            //        Upduser = entity.Adduser.ToString(),//model.Adduser.ToString(CultureInfo.InvariantCulture)
            //    };
            //    _orderService.Create(oe);
            //    entity.ComOrder = oe.Id;
            //    _brokerleadclientService.Update(entity);
            //}
            //else if (model.Status == EnumBLeadType.预约不通过) { return PageHelper.toJson(PageHelper.ReturnValue(false, "预约不通过")); }
            //else if (model.Status == EnumBLeadType.预约中) {}
            //else if (model.Status == EnumBLeadType.洽谈中) 
            //{
            //    var comOrder = _orderService.GetOrderById(entity.ComOrder);
            //    //变更订单状态
            //    int a = (int)Enum.Parse(typeof(EnumBLeadType), model.Status.ToString());
            //    comOrder.Shipstatus = a;
            //    //comOrder.Shipstatus = (int)EnumBRECCType.洽谈中;
            //    comOrder.Status = (int)EnumOrderStatus.审核通过;
            //    comOrder.Upduser = _workContext.CurrentUser.Id.ToString(CultureInfo.InvariantCulture);
            //    comOrder.Upddate = DateTime.Now;
            //    _orderService.Update(comOrder);
            //}
            //else if (model.Status == EnumBLeadType.洽谈成功) 
            //{
            //    var comOrder = _orderService.GetOrderById(entity.ComOrder);
            //    //变更订单状态
            //    int a = (int)Enum.Parse(typeof(EnumBLeadType), model.Status.ToString());
            //    comOrder.Shipstatus = a;
            //    comOrder.Status = (int)EnumOrderStatus.审核通过;
            //    comOrder.Upduser = _workContext.CurrentUser.Id.ToString(CultureInfo.InvariantCulture);
            //    comOrder.Upddate = DateTime.Now;
            //    _orderService.Update(comOrder);

            //}
            //else if (model.Status == EnumBLeadType.洽谈失败) 
            //{
            //    var comOrder = _orderService.GetOrderById(entity.ComOrder);
            //    //变更订单状态
            //    int a = (int)Enum.Parse(typeof(EnumBLeadType), model.Status.ToString());
            //    comOrder.Shipstatus = a;
            //    //comOrder.Shipstatus = (int)EnumBRECCType.洽谈失败;
            //    comOrder.Status = (int)EnumOrderStatus.审核失败;
            //    comOrder.Upduser = _workContext.CurrentUser.Id.ToString(CultureInfo.InvariantCulture);
            //    comOrder.Upddate = DateTime.Now;
            //    model.DelFlag = (int)EnumDelFlag.删除;
            //    _orderService.Update(comOrder);
            //}
            //else if (model.Status == EnumBLeadType.客人未到) 
            //{
            //    //订单作废
            //    var comOrder = _orderService.GetOrderById(entity.ComOrder);
            //    //变更订单状态
            //    int a = (int)Enum.Parse(typeof(EnumBLeadType), model.Status.ToString());
            //    comOrder.Shipstatus = a;
            //    //comOrder.Shipstatus = (int)EnumBRECCType.客人未到;
            //    comOrder.Status = (int)EnumOrderStatus.审核失败;
            //    comOrder.Upduser = _workContext.CurrentUser.Id.ToString(CultureInfo.InvariantCulture);
            //    comOrder.Upddate = DateTime.Now;
            //    _orderService.Update(comOrder);
            //}
            switch (model.Status) 
            {
              
                case EnumBLeadType.预约中:
                    break;
                case EnumBLeadType.预约不通过:
                    _brokerleadclientService.Delete(entity);
                    return PageHelper.toJson(PageHelper.ReturnValue(false, "操作成功"));
                case EnumBLeadType.等待上访:
                        entity.SecretaryId = _brokerService.GetBrokerByUserId(model.SecretaryId);
                        //查询商品详情
                        var product = _productService.GetProductById(model.Projectid);

                        //创建订单详情
                        OrderDetailEntity ode = new OrderDetailEntity
                        {
                            Adddate = DateTime.Now,
                            Adduser = model.Adduser.ToString(CultureInfo.InvariantCulture),
                            Commission = product.Commission,
                            RecCommission = product.RecCommission,
                            Dealcommission = product.Dealcommission,
                            Price = product.Price,
                            Product = product,
                            Productname = product.Productname,
                            Upddate = DateTime.Now,
                            Upduser = model.Adduser.ToString(CultureInfo.InvariantCulture)
                        };

                        //创建订单
                        OrderEntity oe = new OrderEntity
                        {
                            Adddate = DateTime.Now,
                            Adduser = entity.Adduser.ToString(CultureInfo.InvariantCulture),
                            AgentId = entity.Broker.Id,//model.Broker,//model.Adduser,
                            Agenttel = model.Phone,
                            Agentname = _brokerService.GetBrokerByUserId(entity.Adduser).Brokername,
                            BusId = product.Bussnessid,
                            Busname = product.BussnessName,
                            Customname = entity.ClientInfo.Clientname,
                            Ordercode = _orderService.CreateOrderNumber(2),
                            OrderDetail = ode,
                            Ordertype = EnumOrderType.带客订单,
                            Remark = "前端经纪人提交",
                            Shipstatus = (int)EnumBLeadType.等待上访,
                            Status = (int)EnumOrderStatus.审核通过,
                            Upddate = DateTime.Now,
                            Upduser = entity.Adduser.ToString(),//model.Adduser.ToString(CultureInfo.InvariantCulture)
                        };
                        _orderService.Create(oe);
                        entity.ComOrder = oe.Id;
                        _brokerleadclientService.Update(entity);
                    break;
                case EnumBLeadType.洽谈中:
                        var comOrder = _orderService.GetOrderById(entity.ComOrder);
                        //变更订单状态
                        int a = (int)Enum.Parse(typeof(EnumBLeadType), model.Status.ToString());
                        comOrder.Shipstatus = a;
                        //comOrder.Shipstatus = (int)EnumBRECCType.洽谈中;
                        comOrder.Status = (int)EnumOrderStatus.审核通过;
                        comOrder.Upduser = _workContext.CurrentUser.Id.ToString(CultureInfo.InvariantCulture);
                        comOrder.Upddate = DateTime.Now;
                        _orderService.Update(comOrder);
                    break;
                case EnumBLeadType.洽谈成功:
                        comOrder = _orderService.GetOrderById(entity.ComOrder);
                        //变更订单状态
                        a = (int)Enum.Parse(typeof(EnumBLeadType), model.Status.ToString());
                        comOrder.Shipstatus = a;
                        comOrder.Status = (int)EnumOrderStatus.审核通过;
                        comOrder.Upduser = _workContext.CurrentUser.Id.ToString(CultureInfo.InvariantCulture);
                        comOrder.Upddate = DateTime.Now;
                        _orderService.Update(comOrder);
                    break;
                case EnumBLeadType.洽谈失败:
                        comOrder = _orderService.GetOrderById(entity.ComOrder);
                        //变更订单状态
                        a = (int)Enum.Parse(typeof(EnumBLeadType), model.Status.ToString());
                        comOrder.Shipstatus = a;
                        //comOrder.Shipstatus = (int)EnumBRECCType.洽谈失败;
                        comOrder.Status = (int)EnumOrderStatus.审核失败;
                        comOrder.Upduser = _workContext.CurrentUser.Id.ToString(CultureInfo.InvariantCulture);
                        comOrder.Upddate = DateTime.Now;
                        model.DelFlag = (int)EnumDelFlag.删除;
                        _orderService.Update(comOrder);
                    break;
                case EnumBLeadType.客人未到:
                    //订单作废
                    comOrder = _orderService.GetOrderById(entity.ComOrder);
                    //变更订单状态
                    a = (int)Enum.Parse(typeof(EnumBLeadType), model.Status.ToString());
                    comOrder.Shipstatus = a;
                    //comOrder.Shipstatus = (int)EnumBRECCType.客人未到;
                    comOrder.Status = (int)EnumOrderStatus.审核失败;
                    comOrder.Upduser = _workContext.CurrentUser.Id.ToString(CultureInfo.InvariantCulture);
                    comOrder.Upddate = DateTime.Now;
                    model.DelFlag = (int)EnumDelFlag.删除;
                    _orderService.Update(comOrder);
                    break;
            }
            entity.Uptime = DateTime.Now;
            entity.Upuser = _workContext.CurrentUser.Id;
            _brokerleadclientService.Update(entity);
            return PageHelper.toJson(PageHelper.ReturnValue(true, "操作成功"));
        }