コード例 #1
0
        public async Task <JsonResult> Create(ShipmentOrderViewModel shipmentOrderViewModel)
        {
            var shipmentOrder = new ShipmentOrder();

            shipmentOrder = Mapper.Map <ShipmentOrderViewModel, ShipmentOrder>(shipmentOrderViewModel);

            var usermanager = new UserManager();
            var customer    = usermanager.FindByIdByCache(shipmentOrder.CustomerId);

            shipmentOrder.CustomerName = customer.Name;

            var serialNumberManager = new SerialNumberManager(User);

            shipmentOrder.Id = SaleManagentConstants.Misc.ShipmentOrderPrefix + await serialNumberManager.NextSNAsync(SaleManagentConstants.SerialNames.ShipmentOrder);

            shipmentOrder.CompanyId = User.CompanyId;
            shipmentOrder.ShipmentOrderInfos.Each(r => r.ShipmentOrderId = shipmentOrder.Id);
            var shipmentManager = new ShipmentManager(User);
            var result          = await shipmentManager.CreateAsync(shipmentOrder);

            if (result.Succeeded)
            {
                var orderIds = shipmentOrder.ShipmentOrderInfos.Select(r => r.Id);
                await new OrderManager(User).UpdateOrderStatusAsync(OrderStatus.Shipmenting, orderIds);
                await new OrderOperationLogManager(User).AddLogAsync(OrderStatus.Shipmenting, orderIds);
            }
            return(Json(result.Succeeded, "", result.Data));
        }
コード例 #2
0
        public async Task <JsonResult> Booking(OrderEditViewModel request, [NamedModelBinder(typeof(CommaSeparatedModelBinder), "attachmentIds")] string[] attachmentIds)
        {
            if (!ModelState.IsValid)
            {
                return(Json(false, data: ErrorToDictionary()));
            }

            var order = Mapper.Map <OrderEditViewModel, Order>(request);
            var serialNumberManager = new SerialNumberManager(User);
            var manager             = new OrderManager(User);

            if (string.IsNullOrEmpty(order.Id))
            {
                order.Id = SaleManagentConstants.Misc.OrderPrefix + await serialNumberManager.NextSNAsync(SaleManagentConstants.SerialNames.Order);
            }
            else
            {
                order.Id = order.Id.Trim();

                if (order.Id.Length != 12)
                {
                    return(Json(false, "订单号格式不正确"));
                }

                if (await manager.GetOrderAsync(order.Id) != null)
                {
                    return(Json(false, "订单号已存在"));
                }
            }
            if (attachmentIds.Any())
            {
                order.Attachments = new List <OrderAttachment>();
                attachmentIds.ForEach <string>(a =>
                                               order.Attachments.Add(new OrderAttachment
                {
                    FileInfoId = a,
                    OrderId    = order.Id,
                    CreatorId  = User.Id
                }));
            }
            var result = await manager.CreateOrder(order);

            if (result.Succeeded)
            {
                var operationLogManager = new OrderOperationLogManager(User);
                await operationLogManager.AddLogAsync(OrderStatus.UnConfirmed, order.Id);

                return(Json(result.Succeeded, data:
                            new
                {
                    orderId = order.Id
                }));
            }

            return(Json(result));
        }
コード例 #3
0
 public BillAppService(IBarcodeLogRepository barcodeLogRepository, SerialNumberManager serialNumberManager, ILetterRepository letterRepository, IExchangeListDetailRepository exchangeListDetailRepository, IExchangeListRepository exchangeListRepository, UnitOfWork unitOfWork, IExchangeObjectRepository exchangeObjectRepository, IUserRepository userRepository, IDepartmentRepository departmentRepository, IPlaceWardenRepository placeWardenRepository, ILogger <BillAppService> logger)
 {
     _barcodeLogRepository         = barcodeLogRepository;
     _serialNumberManager          = serialNumberManager;
     _letterRepository             = letterRepository;
     _exchangeListDetailRepository = exchangeListDetailRepository;
     _exchangeListRepository       = exchangeListRepository;
     _unitOfWork = unitOfWork;
     _exchangeObjectRepository = exchangeObjectRepository;
     _userRepository           = userRepository;
     _departmentRepository     = departmentRepository;
     _placeWardenRepository    = placeWardenRepository;
     _logger = logger;
 }
コード例 #4
0
        public async Task <JsonResult> Create(SpotGoodsEditViewModel request)
        {
            if (!ModelState.IsValid)
            {
                return(Json(false, data: ErrorToDictionary()));
            }

            var basicDataManager = new BasicDataManager();
            var matchStones      = await basicDataManager.GetMatchStonesAsync();

            JArray jarry = JArray.Parse(Request.Form["SetStoneInfos"]);
            List <SpotGoodsSetStoneInfo> SpotGoodsSetStoneInfos = new List <SpotGoodsSetStoneInfo>();

            var spotGoods = Mapper.Map <SpotGoodsEditViewModel, SpotGoods>(request);

            var serialNumberManager = new SerialNumberManager(User);
            var manager             = new SpotGoodsManager(User);

            if (string.IsNullOrEmpty(spotGoods.Id))
            {
                spotGoods.Id = SaleManagentConstants.Misc.SpotGoodsPrefix + await serialNumberManager.NextSNAsync(SaleManagentConstants.SerialNames.SpotGoods);
            }
            for (int i = 0; i < jarry.Count; ++i)  //遍历JArray
            {
                var setStoneInfo = Newtonsoft.Json.JsonConvert.DeserializeObject <SpotGoodsSetStoneInfo>(jarry[i].ToString());
                var matchStone   = matchStones.FirstOrDefault(r => r.Id == setStoneInfo.MatchStoneId);
                if (matchStone == null)
                {
                    break;
                }

                setStoneInfo.Price       = matchStone.Price;
                setStoneInfo.WorkingCost = (int)matchStone.WorkingCost * setStoneInfo.Number;
                setStoneInfo.CreatorId   = User.Id;
                setStoneInfo.SpotGoodsId = spotGoods.Id;
                SpotGoodsSetStoneInfos.Add(setStoneInfo);
            }
            spotGoods.SetStoneInfos = SpotGoodsSetStoneInfos;
            var result = await manager.CreateSpotGoods(spotGoods);

            return(Json(result));
        }
コード例 #5
0
 public LetterAppService(DepartmentManager departmentManager, SerialNumberManager serialNumberManager, BarcodeManager barcodeManager, ILetterRepository letterRepository, UnitOfWork unitOfWork, IOptions <CommonSettings> commonSettings, IBarcodeLogRepository barcodeLogRepository, IBarcodeRepository barcodeRepository, IBackLetterRepository backLetterRepository, ICancelLetterRepository cancelLetterRepository, BoxManager boxManager, ISortingListDetailRepository sortingListDetailRepository, ISortingListRepository sortingListRepository, ISortingRepository sortingRepository, IPlaceRepository placeRepository, IPlaceWardenRepository placeWardenRepository, IExchangeObjectRepository exchangeObjectRepository, IExchangeObjectSignerRepository objectSignerRepository)
 {
     _departmentManager           = departmentManager;
     _serialNumberManager         = serialNumberManager;
     _barcodeManager              = barcodeManager;
     _letterRepository            = letterRepository;
     _unitOfWork                  = unitOfWork;
     _commonSettings              = commonSettings;
     _barcodeLogRepository        = barcodeLogRepository;
     _barcodeRepository           = barcodeRepository;
     _backLetterRepository        = backLetterRepository;
     _cancelLetterRepository      = cancelLetterRepository;
     _boxManager                  = boxManager;
     _sortingListDetailRepository = sortingListDetailRepository;
     _sortingListRepository       = sortingListRepository;
     _sortingRepository           = sortingRepository;
     _placeRepository             = placeRepository;
     _placeWardenRepository       = placeWardenRepository;
     _exchangeObjectRepository    = exchangeObjectRepository;
     _objectSignerRepository      = objectSignerRepository;
 }
コード例 #6
0
 public SerialNumberAppService(SerialNumberManager serialNumberManager, UnitOfWork unitOfWork)
 {
     _serialNumberManager = serialNumberManager;
     _unitOfWork          = unitOfWork;
 }