예제 #1
0
        public void EditBuyer(RequestBuyer buyer)
        {
            if (buyer == null)
            {
                throw new CustomException(500, "输入信息丢失");
            }
            var currentBuyer = this.businessmanRepository.FindAll(p => p.Code == buyer.Code).OfType <Buyer>().FirstOrDefault();

            if (currentBuyer == null)
            {
                throw new CustomException(404, "修改商户不存在!");
            }
            currentBuyer.ContactWay  = AutoMapper.Mapper.Map <ContactWayDataObject, ContactWay>(buyer.ContactWay);
            currentBuyer.ContactName = buyer.ContactName;
            currentBuyer.Phone       = buyer.Phone;
            currentBuyer.Plane       = buyer.Plane;
            var curentUser = AuthManager.GetCurrentUser();

            accountClientProxy.UpdateCompany(curentUser.CashbagCode, curentUser.CashbagKey, new BPiaoBao.Cashbag.Domain.Models.CashCompanyInfo
            {
                ClientAccount = buyer.Code,
                CpyName       = buyer.Name,
                Contact       = buyer.ContactWay.Contact,
                Moblie        = buyer.ContactWay.Tel,
                Address       = buyer.ContactWay.Address,
                PayAccount    = currentBuyer.CashbagCode,
                Province      = buyer.ContactWay.Province,
                City          = buyer.ContactWay.City
            });
            unitOfWorkRepository.PersistUpdateOf(currentBuyer);
            unitOfWork.Commit();
        }
예제 #2
0
        public JsonResult BuyerInfo(string code)
        {
            RequestBuyer detail = null;

            CommunicateManager.Invoke <IConsoBusinessmanService>(p =>
            {
                detail = p.GetEditBuyerInfo(code);
            });
            return(Json(detail, JsonRequestBehavior.AllowGet));
        }
예제 #3
0
        public void OpenBuyer(RequestBuyer buyer)
        {
            if (buyer == null)
            {
                throw new CustomException(500, "输入信息丢失");
            }
            var isexist = this.businessmanRepository.FindAll(p => p.Code == buyer.Code).Count() > 0;

            if (isexist)
            {
                throw new CustomException(500, string.Format("{0}已存在", buyer.Code));
            }
            var curentUser         = AuthManager.GetCurrentUser();
            var businessmanBuilder = AggregationFactory.CreateBuiler <BusinessmanBuilder>();

            buyer.CarrierCode = curentUser.Code;
            Buyer by = businessmanBuilder.CreateBuyer(AutoMapper.Mapper.Map <RequestBuyer, Buyer>(buyer));

            by.CheckRule();
            var cashbagModel = accountClientProxy.AddCompany(curentUser.CashbagCode, curentUser.CashbagKey, new BPiaoBao.Cashbag.Domain.Models.CashCompanyInfo
            {
                ClientAccount = buyer.Code,
                Contact       = buyer.ContactWay.Contact,
                CpyName       = buyer.Name,
                Moblie        = buyer.ContactWay.Tel,
                Province      = buyer.ContactWay.Province,
                City          = buyer.ContactWay.City,
                Address       = buyer.ContactWay.Address
            });

            try
            {
                by.CashbagCode = cashbagModel.PayAccount;
                by.CashbagKey  = cashbagModel.Token;
                unitOfWorkRepository.PersistCreationOf(by);
                unitOfWork.Commit();
            }
            catch (Exception e)
            {
                Logger.WriteLog(LogType.ERROR, "添加商户发生异常", e);
                accountClientProxy.DeleteCashBagBusinessman(curentUser.CashbagCode, cashbagModel.PayAccount, curentUser.CashbagKey);
                throw new CustomException(500, "添加商户发生异常");
            }
        }
예제 #4
0
 public JsonResult EditBuyer(RequestBuyer buyer)
 {
     CommunicateManager.Invoke <IConsoBusinessmanService>(p => p.EditBuyer(buyer));
     return(Json(null, JsonRequestBehavior.DenyGet));
 }