| | |
| | | private readonly IFiMemberService _fiMemberService; |
| | | private readonly IConfiguration _configuration; |
| | | private readonly IHttpClientFactory _clientFactory; |
| | | private readonly IAskService _askService; |
| | | private readonly IAskService _askService; |
| | | private readonly IAdmGoodsRecordService _admGoodsRecordService; |
| | | |
| | | private readonly IAdmGoodsManageService _admGoodsManageService; |
| | | |
| | | |
| | | public CooperOrderController(ILogger<CooperOrderController> logger, ILiaotianService liaotianService, IUserService userService, ICooperOrderService cooperOrderService |
| | |
| | | , IFiServiceService fiServiceService, IFiMemberService fiMemberService |
| | | , IConfiguration configuration |
| | | , IHttpClientFactory clientFactory |
| | | , IAskService askService) |
| | | , IAskService askService |
| | | , IAdmGoodsRecordService admGoodsRecordService |
| | | , IAdmGoodsManageService admGoodsManageService |
| | | ) |
| | | { |
| | | _logger = logger; |
| | | _liaotianService = liaotianService; |
| | |
| | | _configuration = configuration; |
| | | _clientFactory = clientFactory; |
| | | _askService = askService; |
| | | _admGoodsRecordService = admGoodsRecordService; |
| | | _admGoodsManageService = admGoodsManageService; |
| | | } |
| | | |
| | | [CheckLogin] |
| | |
| | | ResultEntity resultEntity = new ResultEntity(); |
| | | resultEntity.Result = false; |
| | | |
| | | CooperOrderDTO dto = _cooperOrderService.Get(id); |
| | | if(dto.ShouliStatus != "1") |
| | | using (TransactionScope scope = new TransactionScope()) |
| | | { |
| | | resultEntity.Result = false; |
| | | resultEntity.Message = "只有已下单状态的订单才能受理"; |
| | | return new JsonResult(resultEntity); |
| | | |
| | | CooperOrderDTO dto = _cooperOrderService.Get(id); |
| | | if (dto.ShouliStatus != "1") |
| | | { |
| | | resultEntity.Result = false; |
| | | resultEntity.Message = "只有已下单状态的订单才能受理"; |
| | | return new JsonResult(resultEntity); |
| | | } |
| | | |
| | | |
| | | if (dto.OrderType == "01") |
| | | { |
| | | var shi = _fiBookService.Get(dto.OrderType1); |
| | | if (string.IsNullOrEmpty(shi.Id)) |
| | | { |
| | | resultEntity.Result = false; |
| | | resultEntity.Message = "未找到该商品"; |
| | | return new JsonResult(resultEntity); |
| | | } |
| | | var admGoodsManageDTOs = _admGoodsManageService.GetList().Where(x => x.ISBN == shi.BookNo).FirstOrDefault(); |
| | | |
| | | if (admGoodsManageDTOs == null) |
| | | { |
| | | |
| | | |
| | | resultEntity.Result = false; |
| | | resultEntity.Message = "没有找到该商品"; |
| | | return new JsonResult(resultEntity); |
| | | |
| | | } |
| | | else if (!admGoodsManageDTOs.GoodsLeft.HasValue) |
| | | { |
| | | resultEntity.Result = false; |
| | | resultEntity.Message = "该商品没有库存"; |
| | | return new JsonResult(resultEntity); |
| | | |
| | | } |
| | | else if (admGoodsManageDTOs.GoodsLeft.Value < dto.OrderNum) |
| | | { |
| | | resultEntity.Result = false; |
| | | resultEntity.Message = "该商品库存不足"; |
| | | return new JsonResult(resultEntity); |
| | | |
| | | } |
| | | var left = admGoodsManageDTOs.GoodsLeft - dto.OrderNum; |
| | | admGoodsManageDTOs.GoodsLeft = left; |
| | | |
| | | resultEntity = _admGoodsManageService.save(admGoodsManageDTOs); |
| | | |
| | | AdmGoodsRecordDTO dto1 = new AdmGoodsRecordDTO(); |
| | | dto1.GoodsId = admGoodsManageDTOs.Id; |
| | | dto1.GoodsNum = dto.OrderNum; |
| | | dto1.GoodsLeft = admGoodsManageDTOs.GoodsLeft; |
| | | dto1.RecordTypeId = "02"; |
| | | dto1.RecStatus = "A"; |
| | | dto1.Creater = curentuser.Id; |
| | | dto1.Createtime = DateTime.Now; |
| | | dto1.Modifier = curentuser.Id; |
| | | dto1.Modifytime = DateTime.Now; |
| | | dto1.OperationalMatters = "订单:" + dto.OrderNo + " 购买书籍"; |
| | | resultEntity = _admGoodsRecordService.save(dto1); |
| | | |
| | | } |
| | | |
| | | |
| | | |
| | | dto.Shoulier = curentuser.Id; |
| | | dto.Shoulitime = DateTime.Now; |
| | | dto.ShouliStatus = "2"; |
| | | |
| | | resultEntity = _cooperOrderService.shouli(dto); |
| | | |
| | | scope.Complete(); |
| | | } |
| | | |
| | | dto.Shoulier = curentuser.Id; |
| | | dto.Shoulitime = DateTime.Now; |
| | | dto.ShouliStatus = "2"; |
| | | |
| | | resultEntity = _cooperOrderService.shouli(dto); |
| | | |
| | | return new JsonResult(resultEntity); |
| | | } |
| | |
| | | |
| | | ResultEntity resultEntity = new ResultEntity(); |
| | | resultEntity.Result = false; |
| | | |
| | | CooperOrderDTO dto = _cooperOrderService.Get(Chedanid); |
| | | if (dto.ShouliStatus != "2") |
| | | using (TransactionScope scope = new TransactionScope()) |
| | | { |
| | | resultEntity.Result = false; |
| | | resultEntity.Message = "只有受理状态的订单才能撤单"; |
| | | return new JsonResult(resultEntity); |
| | | |
| | | CooperOrderDTO dto = _cooperOrderService.Get(Chedanid); |
| | | if (dto.ShouliStatus != "2") |
| | | { |
| | | resultEntity.Result = false; |
| | | resultEntity.Message = "只有受理状态的订单才能撤单"; |
| | | return new JsonResult(resultEntity); |
| | | } |
| | | |
| | | |
| | | if (dto.OrderType == "01") |
| | | { |
| | | var shi = _fiBookService.Get(dto.OrderType1); |
| | | if (string.IsNullOrEmpty(shi.Id)) |
| | | { |
| | | resultEntity.Result = false; |
| | | resultEntity.Message = "未找到该商品"; |
| | | return new JsonResult(resultEntity); |
| | | } |
| | | var admGoodsManageDTOs = _admGoodsManageService.GetList().Where(x => x.ISBN == shi.BookNo).FirstOrDefault(); |
| | | |
| | | if (admGoodsManageDTOs == null) |
| | | { |
| | | |
| | | |
| | | resultEntity.Result = false; |
| | | resultEntity.Message = "没有找到该商品"; |
| | | return new JsonResult(resultEntity); |
| | | |
| | | } |
| | | |
| | | var left = admGoodsManageDTOs.GoodsLeft + dto.OrderNum; |
| | | admGoodsManageDTOs.GoodsLeft = left; |
| | | |
| | | resultEntity = _admGoodsManageService.save(admGoodsManageDTOs); |
| | | |
| | | AdmGoodsRecordDTO dto1 = new AdmGoodsRecordDTO(); |
| | | dto1.GoodsId = admGoodsManageDTOs.Id; |
| | | dto1.GoodsNum = dto.OrderNum; |
| | | dto1.GoodsLeft = admGoodsManageDTOs.GoodsLeft; |
| | | dto1.RecordTypeId = "01"; |
| | | dto1.RecStatus = "A"; |
| | | dto1.Creater = curentuser.Id; |
| | | dto1.Createtime = DateTime.Now; |
| | | dto1.Modifier = curentuser.Id; |
| | | dto1.Modifytime = DateTime.Now; |
| | | dto1.OperationalMatters = "订单:" + dto.OrderNo + " 撤单"; |
| | | resultEntity = _admGoodsRecordService.save(dto1); |
| | | |
| | | } |
| | | |
| | | |
| | | dto.Chedaner = curentuser.Id; |
| | | dto.Chedantime = DateTime.Now; |
| | | dto.ChedanStatus = "A"; |
| | | dto.Chedan = Price; |
| | | dto.ShouliStatus = "0"; |
| | | |
| | | resultEntity = _cooperOrderService.chedan(dto); |
| | | scope.Complete(); |
| | | } |
| | | |
| | | |
| | | dto.Chedaner = curentuser.Id; |
| | | dto.Chedantime = DateTime.Now; |
| | | dto.ChedanStatus = "A"; |
| | | dto.Chedan = Price; |
| | | dto.ShouliStatus = "0"; |
| | | |
| | | resultEntity = _cooperOrderService.chedan(dto); |
| | | |
| | | return new JsonResult(resultEntity); |
| | | } |
| | | [CheckLogin] |