public async Task <IActionResult> Get(string code) { //订单信息 var orderDetail = _yxOrderlistRpt.FindBy(f => f.HouseCode == code && f.IsValid).OrderByDescending(f => f.Id) .First(); if (orderDetail == null) { return(BadRequest($"未找到房号{code}的订单")); } //房屋状态 var houseInfo = _fwHouseinfoRpt.GetSingle(f => f.Code == code); if (houseInfo.State != 1003 && houseInfo.State != 1004) { var state = _sysDicRpt.GetSingle(houseInfo.State); return(BadRequest($"房号{code}状态为{state.DicName},不能结算。")); } //订单信息 var orderInfo = _yxOrderRpt.GetSingle(orderDetail.OrderId); if (orderInfo == null) { return(BadRequest($"未找到房号{code}订单信息。")); } //订单列表 var houseTypeList = this._setHouseTypeRepository.GetAll(); var orderDetailList = _yxOrderlistRpt.FindBy(f => f.OrderId == orderInfo.Id).ToList(); var orderDetaiDTOlList = _mapper.Map <List <yx_orderlist>, List <OrderListDto> >(orderDetailList).ToList(); foreach (var odt in orderDetaiDTOlList) { odt.HouseTypeTxt = houseTypeList.FirstOrDefault(f => f.Id == odt.HouseType).TypeName; } var orderDto = _mapper.Map <yx_order, OrderDto>(orderInfo); var payTypeList = this._setPaytypeRepository.GetAll(); orderDto.PayTypeTxt = payTypeList.FirstOrDefault(f => f.Id == orderDto.PayType).Name; if (orderDto.ComeType > 0 && _sysDicRpt.GetSingle(orderDto.ComeType) != null) { orderDto.ComeTypeTxt = _sysDicRpt.GetSingle(orderDto.ComeType).DicName; } var orderObj = new OrderDataDto { OrderList = new List <OrderDto>() { orderDto }, OrderDetailList = orderDetaiDTOlList }; return(new OkObjectResult(orderObj)); }
public async Task <IActionResult> Delete(int id) { var single = _yxOrderRpt.GetSingle(id); if (single == null) { return(new NotFoundResult()); } string createBy = string.Empty; if (User.Identity is ClaimsIdentity identity) { createBy = identity.Name ?? "admin"; } single.Status = "已取消"; var orderDetail = _yxOrderlistRpt.FindBy(f => f.OrderId == id); using (var tran = _context.Database.BeginTransaction()) { try { _yxOrderRpt.Commit(); foreach (var item in orderDetail) { var house = _fwHouseinfoRpt.GetSingle(f => f.Code == item.HouseCode); //新增房态日志 _fwStatelogRepository.Add(new fw_statelog() { HouseCode = item.HouseCode, OldState = house.State, NewState = 1001, OrderNo = single.OrderNo, CreatedAt = DateTime.Now, UpdatedAt = DateTime.Now, IsValid = true, CreatedBy = createBy }); house.State = 1001; //空净 house.CusName = string.Empty; house.OrderNo = string.Empty; _fwHouseinfoRpt.Update(house); } _fwStatelogRepository.Commit(); _fwHouseinfoRpt.Commit(); tran.Commit(); } catch (Exception e) { Console.WriteLine(e); tran.Rollback(); return(new BadRequestResult()); } } return(new NoContentResult()); }
public async Task <IActionResult> Get(int id) { var single = _fwHouseinfoRpt.GetSingle(id); return(new OkObjectResult(single)); }