Пример #1
0
 public ActionResult ViewRMA(string rmaNo)
 {
     var rmaEntity = _rmaRepo.Get(r => r.RMANo == rmaNo)
                  .GroupJoin(_rmaitemRepo.Get(ri => ri.RMANo == rmaNo),
                           o => o.RMANo,
                           i => i.RMANo,
                           (o, i) => new { R = o, RI = i.FirstOrDefault() })
                   .FirstOrDefault();
     string errorMsg;
     var orderEntity = _orderRepo.Get(o => o.OrderNo == rmaEntity.R.OrderNo).First();
     if (!OrderViewModel.IsAuthorized(orderEntity.StoreId, orderEntity.BrandId, out errorMsg))
     {
         throw new ArgumentException(errorMsg);
     }
     var model = new RMAViewModel().FromEntity<RMAViewModel>(rmaEntity.R, p =>
     {
         p.Item = new RMAItemViewModel().FromEntity<RMAItemViewModel>(rmaEntity.RI);
         p.Logs = Context.Set<RMALogEntity>().Where(rl => rl.RMANo == rmaNo).OrderByDescending(rl => rl.CreateDate)
                  .ToList()
                  .Select(rl => new RMALogViewModel().FromEntity<RMALogViewModel>(rl));
     });
     return View(model);
 }
Пример #2
0
 public ActionResult PrintRMA(string rmaNo)
 {
     var rmaEntity = _rmaRepo.Get(r=>r.RMANo == rmaNo)
                    .GroupJoin(_rmaitemRepo.Get(ri=>ri.RMANo == rmaNo),
                             o=>o.RMANo,
                             i=>i.RMANo,
                             (o,i)=>new {R=o,RI=i.FirstOrDefault()})
                     .FirstOrDefault();
     string errorMsg;
     var orderEntity = _orderRepo.Get(o => o.OrderNo == rmaEntity.R.OrderNo).First();
     if (!OrderViewModel.IsAuthorized(orderEntity.StoreId, orderEntity.BrandId, out errorMsg))
     {
         throw new ArgumentException(errorMsg);
     }
     var model = new RMAViewModel().FromEntity<RMAViewModel>(rmaEntity.R, p => {
         p.Item = new RMAItemViewModel().FromEntity<RMAItemViewModel>(rmaEntity.RI,pi=>{
             pi.SalesPerson = Context.Set<OrderItemEntity>().Where(o => o.OrderNo == rmaEntity.R.OrderNo)
                             .Select(o => o.SalesPerson).FirstOrDefault();
         });
     });
     return View(model);
 }
Пример #3
0
        public JsonResult PrintRMA(RMAViewModel model)
        {
            string errorMsg;
            var confirmModel = _orderRepo.Get(o => o.OrderNo == model.OrderNo).FirstOrDefault();
            if (!OrderViewModel.IsAuthorized(confirmModel.StoreId, confirmModel.BrandId, out errorMsg))
            {
                return FailResponse(errorMsg);
            }
            using (var ts = new TransactionScope())
            {
                var entity = _rmaRepo.Get(r => r.RMANo == model.RMANo).First();
                entity.GiftReason = model.GiftReason;
                entity.PostalFeeReason = model.PostalFeeReason;
                entity.InvoiceReason = model.InvoiceReason;
                entity.RebatePointReason = model.RebatePointReason;
                entity.rebatepostfee = model.rebatepostfee;
                entity.chargepostfee = model.chargepostfee;
                entity.ChargeGiftFee = model.ChargeGiftFee;
                entity.ActualAmount = entity.RMAAmount - (entity.chargepostfee ?? 0) + (entity.rebatepostfee ?? 0) - (entity.ChargeGiftFee ?? 0);
                entity.Status = (int)RMAStatus.PrintRMA;
                entity.UpdateDate = DateTime.Now;
                entity.UpdateUser = CurrentUser.CustomerId;
                _rmaRepo.Update(entity);

                _rmalogRepo.Insert(new RMALogEntity()
                {
                    CreateDate = DateTime.Now,
                    CreateUser = CurrentUser.CustomerId,
                    Operation = "打印退货单",
                    RMANo = model.RMANo
                });

                ts.Complete();

            }
            return SuccessResponse();
        }
Пример #4
0
        public ActionResult Reject2Customer(RMAViewModel model)
        {
            if (!ModelState.IsValid)
            {
                return View(new RMAViewModel().FromEntity<RMAViewModel>(_rmaRepo.Get(o => o.RMANo == model.RMANo).FirstOrDefault()));
            }
            var rmaEntity = _rmaRepo.Get(o => o.RMANo == model.RMANo).FirstOrDefault();
            if (rmaEntity == null)
                throw new ArgumentException("rmano");
            string errorMsg;
            var orderEntity = _orderRepo.Get(o => o.OrderNo == rmaEntity.OrderNo).First();
            if (!OrderViewModel.IsAuthorized(orderEntity.StoreId, orderEntity.BrandId, out errorMsg))
            {
                ModelState.AddModelError(string.Empty, errorMsg);
                return View(model);
            }
            using (var ts = new TransactionScope())
            {
                rmaEntity.RejectReason = model.RejectReason;
                rmaEntity.UpdateDate = DateTime.Now;
                rmaEntity.Status = (int)RMAStatus.Reject2Customer;
                rmaEntity.UpdateUser = CurrentUser.CustomerId;
                _rmaRepo.Update(rmaEntity);

                _rmalogRepo.Insert(new RMALogEntity()
                {
                    CreateDate = DateTime.Now,
                    CreateUser = CurrentUser.CustomerId,
                    Operation = "不符合退货要求,退回客户!",
                    RMANo = model.RMANo
                });
                ts.Complete();
            }
            return RedirectToAction("details", new { orderNo = model.OrderNo });

        }