public TransactionController(IServiceGroupService serviceGr, IErrorService errorService, IServiceService serviceService, ITransactionDetailService transactionDetailService, ITransactionService transactionService, IApplicationUserService userService) : base(errorService)
 {
     this._transactionService  = transactionService;
     _transactionDetailService = transactionDetailService;
     this._errorService        = errorService;
     _serviceService           = serviceService;
     _userService = userService;
     _serviceGr   = serviceGr;
 }
 public MainServiceGroupController(IErrorService errorService,
                                   IServiceService serviceService,
                                   IMainServiceGroupService mainServiceGroupService,
                                   IServiceGroupService serviceGroupService)
     : base(errorService)
 {
     this._mainServiceGroupService = mainServiceGroupService;
     this._serviceService          = serviceService;
     _serviceGroupService          = serviceGroupService;
 }
Beispiel #3
0
 public StatisticController(IServiceGroupService serviceGroupService, IMainServiceGroupService mainGroupService, ITransactionDetailService transactionDetailService, ITransactionService trasactionService, IServiceService serviceService, IApplicationUserService userService, IErrorService errorService, IStatisticService statisticService, IDistrictService districtService, IPOService poService) : base(errorService)
 {
     _serviceGroupService      = serviceGroupService;
     _mainGroupService         = mainGroupService;
     _transactionDetailService = transactionDetailService;
     _trasactionService        = trasactionService;
     _serviceService           = serviceService;
     _userService      = userService;
     _statisticService = statisticService;
     _districtService  = districtService;
     _poService        = poService;
 }
        public BaseResponse SaveResidentServicePlan(ServiceGroupOrderModel request)
        {
            BaseResponse         response                          = new BaseResponse();
            var                  depositRepository                 = unitOfWork.GetRepository <DC_Deposit>();
            var                  serviceGroupRepository            = unitOfWork.GetRepository <DC_ServiceGroup>();
            var                  serviceOrderRepository            = unitOfWork.GetRepository <DC_ServiceOrder>();
            var                  residentServicePlanRepository     = unitOfWork.GetRepository <DC_ResidentServicePlan>();
            var                  residentServicePlanItemRepository = unitOfWork.GetRepository <DC_ResidentServicePlanItem>();
            var                  feeDetailRepository               = unitOfWork.GetRepository <DC_FeeDetail>();
            IServiceGroupService grpService                        = KM.Common.IOCContainer.Instance.Resolve <IServiceGroupService>();

            var serviceGroup = grpService.GetServiceGroup(request.ServiceGroupID);

            var deposit = depositRepository.dbSet.FirstOrDefault(it => it.ResidentID == request.ResidentID);

            if (serviceGroup.Data.SumPrice > 0)
            {
                if (deposit != null)
                {
                    var remainingMoney = deposit.Amount - deposit.TotalConSpeMonth;
                    if (serviceGroup.Data.SumPrice > remainingMoney)
                    {
                        response.IsSuccess = false;
                    }
                }
                else
                {
                    response.IsSuccess = false;
                }
            }

            if (!response.IsSuccess)
            {
                response.ResultMessage = "账户期初余额不足,请充值后完成操作";
                return(response);
            }

            unitOfWork.BeginTransaction();
            // 扣钱
            if (serviceGroup.Data.SumPrice > 0)
            {
                deposit.TotalConSpeMonth = deposit.TotalConSpeMonth + serviceGroup.Data.SumPrice;
                depositRepository.Update(deposit);
            }

            if (serviceGroup.Data != null && serviceGroup.Data.GroupItems != null)
            {
                var residentServicePlan = new DC_ResidentServicePlan();
                residentServicePlan.ResidentID     = request.ResidentID;
                residentServicePlan.ServiceGroupID = serviceGroup.Data.ServiceGroupID;
                residentServicePlan.SGNo           = serviceGroup.Data.SGNo;
                residentServicePlan.SGName         = serviceGroup.Data.SGName;
                residentServicePlan.SumPrice       = serviceGroup.Data.SumPrice;
                residentServicePlan.Remark         = serviceGroup.Data.Remark;
                residentServicePlan.Description    = serviceGroup.Data.Description;
                residentServicePlan.SStartDate     = DateTime.Now;
                if (serviceGroup.Data.ExpiryDate.HasValue)
                {
                    if (serviceGroup.Data.ExpiryUnit == Enum.GetName(typeof(EnumPeriod), EnumPeriod.Day))
                    {
                        residentServicePlan.SEndDate = DateTime.Now.AddDays(serviceGroup.Data.ExpiryDate.Value);
                    }
                    else
                    {
                        residentServicePlan.SEndDate = DateTime.Now.AddMonths(serviceGroup.Data.ExpiryDate.Value);
                    }
                }
                else
                {
                    residentServicePlan.SEndDate = DateTime.Now.AddMonths(1200);
                }
                residentServicePlan.CreatedTime  = DateTime.Now;
                residentServicePlan.ModifiedTime = DateTime.Now;
                serviceGroup.Data.GroupItems.ForEach(it => {
                    var residentServicePlanItem           = new DC_ResidentServicePlanItem();
                    residentServicePlanItem.ServiceItemID = it.ServiceItemID;
                    residentServicePlanItem.SINo          = it.SINo;
                    residentServicePlanItem.SIName        = it.SIName;
                    residentServicePlanItem.SIType        = it.SIType;
                    residentServicePlanItem.ServiceTimes  = it.ServiceTimes.Value;
                    residentServicePlanItem.RestTimes     = it.ServiceTimes.Value;
                    residentServicePlanItem.Remark        = it.Remark;
                    residentServicePlanItem.CreatedTime   = DateTime.Now;
                    residentServicePlanItem.ModifiedTime  = DateTime.Now;
                    residentServicePlan.DC_ResidentServicePlanItem.Add(residentServicePlanItem);
                });

                residentServicePlanRepository.Insert(residentServicePlan);

                var feeDetail = new DC_FeeDetail();
                feeDetail.FeeNo      = base.GenerateCode(EnumCodeKey.FeeDetailCode, EnumCodeRule.YearMonthDay, "F", 6, serviceGroup.Data.OrganizationID);
                feeDetail.FeeName    = serviceGroup.Data.SGName;
                feeDetail.TotalPrice = -serviceGroup.Data.SumPrice;
                feeDetail.FeeDate    = DateTime.Now;
                feeDetail.ResidentID = request.ResidentID;
                feeDetailRepository.Insert(feeDetail);
            }
            unitOfWork.Commit();
            return(response);
        }
 public ServiceGroupController(IServiceGroupService serviceGroupService)
 {
     this._serviceGroupService = serviceGroupService;
 }
 public ServiceController(IErrorService errorService, IServiceService service, IServiceGroupService serviceGroupService) : base(errorService)
 {
     this._serviceService      = service;
     this._serviceGroupService = serviceGroupService;
 }