Beispiel #1
0
        public void UpdateInternalState(long uid, BatchInternalTrade batchInternalTrade)
        {
            ExceptionHelper.ThrowIfNull(batchInternalTrade, "batchInternalTrade");

            var user = _UserManager.GetUser(uid);
            IBillManagerUser manager = new BillUser(user, _BillRepository, _BillStateHistoryRepository);

            using (var scope = new System.Transactions.TransactionScope())
            {
                foreach (var item in batchInternalTrade)
                {
                    var bill = _BillManager.GetBill(item.Key);
                    var authority = new BillAuthority(user, bill);
                    if (!authority.AllowUpdateState)
                        throw new BHException(ErrorCode.NotAllow, "没有权限更新运单状态");

                    manager.UpdateBillInternalState(bill, item.Value.InternalTrade, item.Value.Remarks, item.Value.Date);
                }
                scope.Complete();
            }
        }
Beispiel #2
0
 public IBill UpdateBill(long uid, long bid, string sender, string senderTel, string receiver, string receiverTel, string address, string post, decimal insurance, string goods, string remarks, long? agentUid, DateTime? created, string internalNo, string internalExpress)
 {
     var user = _UserManager.GetUser(uid);
     var bill = _BillManager.GetBill(bid);
     var authority = new BillAuthority(user, bill);
     if (authority.AllowUpdateSenderOrReceiver || authority.AllowSetAgent || authority.AllowUpdateState || authority.AllowSetCreateDate)
     {
         IBillManagerUser updater = new BillUser(user, _BillRepository, _BillStateHistoryRepository);
         if (authority.AllowUpdateSenderOrReceiver)
             updater.UpdateBill(bill, new ContactInfo(sender, senderTel), new ContactInfoWithAddress(receiver, receiverTel, new Address(address, post)), insurance, goods, remarks);
         if (authority.AllowSetAgent)
             updater.UpdateAgent(bill, agentUid);
         if (authority.AllowUpdateState)
         {
             if (!String.IsNullOrWhiteSpace(internalNo) || !String.IsNullOrWhiteSpace(internalExpress))
             {
                 updater.UpdateBillInternalState(bill, new InternalTrade(internalNo, internalExpress), String.Empty, null);
             }
         }
         if(created.HasValue && authority.AllowSetCreateDate)
         {
             updater.UpdateCreated(bill, created.Value);
         }
     }
     else if (authority.AllowUpdateMinorInfo)
     {
         IBillUser updater = new BillUser(user, _BillRepository, _BillStateHistoryRepository);
         updater.UpdateBill(bill, insurance, goods, remarks);
     }
     return bill;
 }