Пример #1
0
		public bool Delete(CFBBillEntity entity)
		{
			try
            {
                _cfbbillRepository.Delete(entity);
                return true;
            }
            catch (Exception e)
            {
				_log.Error(e,"数据库操作出错");
                return false;
            }
		}
Пример #2
0
		public CFBBillEntity Update (CFBBillEntity entity)
		{
			try
            {
                _cfbbillRepository.Update(entity);
                return entity;
            }
            catch (Exception e)
            {
				_log.Error(e,"数据库操作出错");
                return null;
            }
		}
Пример #3
0
 //===================================================================pengguifei start========================================================================//
 public HttpResponseMessage CreateBill(BillModel model)
 {
     OrderEntity oe = _orderService.GetOrderById(model.orderId);
     var broker = _brokerService.GetBrokerById(oe.AgentId);
     var newAmount = GetCommission(oe);
     if (newAmount == null)
     {
         return PageHelper.toJson(PageHelper.ReturnValue(false, "不存在佣金分成,账单无法生成"));
     }         
     var partner = GetPartner(broker.UserId);
     //创富宝平台账单
     var CBE = new CFBBillEntity
     {
         Actualamount = model.Actualamount,
         Amount = newAmount.CFBamount,
         AgentId = oe.AgentId, //经纪人Id;
         Agentname = oe.Agentname, //经纪人名字;
         LandagentId = oe.BusId, //地产商Id;
         Landagentname = oe.Busname, //地产商名字;
         Beneficiary = oe.Agentname,
         Beneficiarynumber = model.beneficiarynumber,
         Cardnumber = model.beneficiarynumber,
         Checkoutdate = DateTime.Now,
         Customname = oe.Agentname,
         Isinvoice = false,
         Order = oe,
         Remark = model.remark,
         Addtime = DateTime.Now,
         Adduser = _workContext.CurrentUser.Id.ToString(),
         Updtime = DateTime.Now,
         Upduser = _workContext.CurrentUser.Id.ToString()
     };
     //地产商账单
     var LABE = new LandAgentBillEntity
     {
         Actualamount = null,
         Amount = newAmount.LandAgentamount,
         AgentId = oe.AgentId, //经纪人Id;
         Agentname = oe.Agentname, //经纪人名字;
         LandagentId = oe.BusId, //地产商Id;
         Landagentname = oe.Busname, //地产商名字;
         Beneficiary = oe.Agentname,
         Beneficiarynumber = null,
         Cardnumber = null,
         Checkoutdate = DateTime.Now,
         Customname = oe.Agentname,
         Isinvoice = false,
         Order = oe,
         Remark = model.remark,
         Addtime = DateTime.Now,
         Adduser = _workContext.CurrentUser.Id.ToString(),
         Updtime = DateTime.Now,
         Upduser = _workContext.CurrentUser.Id.ToString()
     };
     //经济人账单                           
     var ABE = new AgentBillEntity
     {
         Actualamount = null,
         Amount = newAmount.Agentamount,
         AgentId = oe.AgentId, //经纪人Id;
         Agentname = oe.Agentname, //经纪人名字;
         LandagentId = oe.BusId, //地产商Id;
         Landagentname = oe.Busname, //地产商名字;
         Beneficiary = oe.Agentname,
         Beneficiarynumber = null,
         Cardnumber = null,
         Checkoutdate = DateTime.Now,
         Customname = oe.Agentname,
         Isinvoice = false,
         Order = oe,
         Remark = model.remark,
         Addtime = DateTime.Now,
         Adduser = _workContext.CurrentUser.Id.ToString(),
         Updtime = DateTime.Now,
         Upduser = _workContext.CurrentUser.Id.ToString()
     };
     AgentBillEntity PBE = null;          
     BrokeAccountEntity BAE = null, PAE = null;
     //经济人账户明细
     switch (oe.Ordertype)
     {
         case EnumOrderType.带客订单:
             BAE = new BrokeAccountEntity
             {
                 Balancenum = newAmount.Agentamount,
                 Broker = broker,
                 Type = 0,
                 MoneyDesc = model.MoneyDesc,
                 Adduser = _workContext.CurrentUser.Id,
                 Addtime = DateTime.Now,
                 Upuser = _workContext.CurrentUser.Id,
                 Uptime = DateTime.Now
             };
             break;
         case EnumOrderType.推荐订单:
             BAE = new BrokeAccountEntity
             {
                 Balancenum = newAmount.Agentamount,
                 Broker = broker,
                 Type = 1,
                 MoneyDesc = model.MoneyDesc,
                 Adduser = _workContext.CurrentUser.Id,
                 Addtime = DateTime.Now,
                 Upuser = _workContext.CurrentUser.Id,
                 Uptime = DateTime.Now
             };
             break;
     }
     //if (oe.Ordertype == EnumOrderType.带客订单)
     //{
     //    BAE = new BrokeAccountEntity
     //    {
     //        Balancenum = newAmount.Agentamount,
     //        Broker = broker,
     //        Type = 0,
     //        MoneyDesc = model.MoneyDesc,
     //        Adduser = _workContext.CurrentUser.Id,
     //        Addtime = DateTime.Now,
     //        Upuser = _workContext.CurrentUser.Id,
     //        Uptime = DateTime.Now
     //    };
     //}
     //else
     //{
     //    BAE = new BrokeAccountEntity
     //    {
     //        Balancenum = newAmount.Agentamount,
     //        Broker = broker,
     //        Type = 1,
     //        MoneyDesc = model.MoneyDesc,
     //        Adduser = _workContext.CurrentUser.Id,
     //        Addtime = DateTime.Now,
     //        Upuser = _workContext.CurrentUser.Id,
     //        Uptime = DateTime.Now
     //    };
     //}
     //成交并且有合伙人时创建合伙人账单和账户明细
     if (oe.Shipstatus == 3 &&partner != null)
     {
         //合伙人账单
         PBE = new AgentBillEntity
         {
             Actualamount = null,
             Amount = newAmount.Partneramount,
             AgentId = partner.PartnersId, //经纪人Id;
             Agentname = partner.Brokername, //经纪人名字;
             LandagentId = oe.BusId, //地产商Id;
             Landagentname = oe.Busname, //地产商名字;
             Beneficiary = partner.Brokername,
             Beneficiarynumber = null,
             Cardnumber = null,
             Checkoutdate = DateTime.Now,
             Customname = oe.Agentname,
             Isinvoice = false,
             Order = oe,
             Remark = model.remark,
             Addtime = DateTime.Now,
             Adduser = _workContext.CurrentUser.Id.ToString(),
             Updtime = DateTime.Now,
             Upduser = _workContext.CurrentUser.Id.ToString()
         };
         //合伙人账户明细
         switch (oe.Ordertype)
         {
                 case EnumOrderType.带客订单:
                 PAE = new BrokeAccountEntity
                 {
                     Balancenum = newAmount.Partneramount,
                     Broker = _brokerService.GetBrokerById(partner.PartnersId),
                     Type = 0,
                     MoneyDesc = model.MoneyDesc,
                     Adduser = _workContext.CurrentUser.Id,
                     Addtime = DateTime.Now,
                     Upuser = _workContext.CurrentUser.Id,
                     Uptime = DateTime.Now
                 };
                 break;
                 case EnumOrderType.推荐订单:
                 PAE = new BrokeAccountEntity
                 {
                     Balancenum = newAmount.Partneramount,
                     Broker = _brokerService.GetBrokerById(partner.PartnersId),
                     Type = 1,
                     MoneyDesc = model.MoneyDesc,
                     Adduser = _workContext.CurrentUser.Id,
                     Addtime = DateTime.Now,
                     Upuser = _workContext.CurrentUser.Id,
                     Uptime = DateTime.Now
                 };
                 break;
         }
         _agentBillService.Create(PBE);
         _brokeAccountService.Create(PAE);
         //if (oe.Ordertype == EnumOrderType.带客订单)
         //{
         //    PAE = new BrokeAccountEntity
         //    {
         //        Balancenum = newAmount.Partneramount,
         //        Broker = _brokerService.GetBrokerById(partner.PartnersId),
         //        Type = 0,
         //        MoneyDesc = model.MoneyDesc,
         //        Adduser = _workContext.CurrentUser.Id,
         //        Addtime = DateTime.Now,
         //        Upuser = _workContext.CurrentUser.Id,
         //        Uptime = DateTime.Now
         //    };
         //}
         //else
         //{                  
         //    PAE = new BrokeAccountEntity
         //    {
         //        Balancenum = newAmount.Partneramount,
         //        Broker = _brokerService.GetBrokerById(partner.PartnersId),
         //        Type = 1,
         //        MoneyDesc = model.MoneyDesc,
         //        Adduser = _workContext.CurrentUser.Id,
         //        Addtime = DateTime.Now,
         //        Upuser = _workContext.CurrentUser.Id,
         //        Uptime = DateTime.Now
         //    };
         //}
     }
     //broker.Amount = broker.Amount + BAE.Balancenum;
     //broker.Uptime=DateTime.Now;
     //broker.Upuser = _workContext.CurrentUser.Id;
     //_brokerService.Update(broker);
     _CFBBillService.Create(CBE);
     _landAgentBillService.Create(LABE);
     _agentBillService.Create(ABE);
     _brokeAccountService.Create(BAE);
     //成交并且有合伙人时创建合伙人账单和账户明细
     //if (oe.Shipstatus == 3 && partner != null)
     //{
     //    _agentBillService.Create(PBE);
     //    _brokeAccountService.Create(PAE);
     //}
     return PageHelper.toJson(PageHelper.ReturnValue(true, "账单生成成功"));
 }