Ejemplo n.º 1
0
        public ChargeItemsResponse Get(ChargeSearchRequest request)
        {
            if (string.IsNullOrEmpty(request.reference))
            {
#pragma warning disable 0612
                request.reference = request.transaction_external_id;
#pragma warning restore 0612
            }

            var url = "charges/";
            url = url.AppendParameter("skip", request.skip);
            url = url.AppendParameter("limit", request.limit);
            url = url.AppendParameter("subscription_id", request.subscription_id);
            url = url.AppendParameter("gateway_id", request.gateway_id);
            url = url.AppendParameter("company_id", request.company_id);
            url = url.AppendParameter("created_at.from", request.created_at_from);
            url = url.AppendParameter("created_at.to", request.created_at_to);
            url = url.AppendParameter("search", request.search);
            url = url.AppendParameter("status", request.status);
            url = url.AppendParameter("archived", request.archived);
            url = url.AppendParameter("reference", request.reference);

            var responseJson = _serviceHelper.CallPaydock(url, HttpMethod.GET, "", overrideConfigSecretKey: _overrideConfigSecretKey);

            return(SerializeHelper.Deserialize <ChargeItemsResponse>(responseJson));
        }
Ejemplo n.º 2
0
        public async Task <ChargeItemsResponse> Get(ChargeSearchRequest request)
        {
            if (string.IsNullOrEmpty(request.reference))
            {
#pragma warning disable 0612
                request.reference = request.transaction_external_id;
#pragma warning restore 0612
            }

            var url = "charges/";
            url = url.AppendParameter("skip", request.skip);
            url = url.AppendParameter("limit", request.limit);
            url = url.AppendParameter("subscription_id", request.subscription_id);
            url = url.AppendParameter("gateway_id", request.gateway_id);
            url = url.AppendParameter("company_id", request.company_id);
            url = url.AppendParameter("created_at.from", request.created_at_from);
            url = url.AppendParameter("created_at.to", request.created_at_to);
            url = url.AppendParameter("search", request.search);
            url = url.AppendParameter("status", request.status);
            url = url.AppendParameter("archived", request.archived);
            url = url.AppendParameter("reference", request.reference);
            url = url.AppendParameter("authorization", request.authorization);

            return(await _serviceHelper.Get <ChargeItemsResponse>(url, overrideConfigSecretKey : _overrideConfigSecretKey));
        }
Ejemplo n.º 3
0
        public async Task <PagingResponseMessage <ChargeInfoResponse> > Search(UserInfo User, [FromBody] ChargeSearchRequest request, [FromQuery] string permissionId)
        {
            var r = new PagingResponseMessage <ChargeInfoResponse>();

            try
            {
                r = await _chargeManager.Search(User, request, permissionId);
            }
            catch (Exception e)
            {
                r.Code    = ResponseCodeDefines.ServiceError;
                r.Message = "服务器错误:" + e.Message;
                Logger.Error("查询报销单失败:\r\n{0}", e.ToString());
            }
            return(r);
        }
Ejemplo n.º 4
0
        public async Task <PagingResponseMessage <ChargeInfoResponse> > Search(UserInfo user, ChargeSearchRequest request, string permissionId)
        {
            PagingResponseMessage <ChargeInfoResponse> r = new PagingResponseMessage <ChargeInfoResponse>();

            if (String.IsNullOrEmpty(permissionId))
            {
                permissionId = PERMISSION_FYGL;
            }

            var orgList = await _permissionExpansion.GetOrganizationOfPermission(user.Id, permissionId);

            var query = _Store.SimpleQuery;

            query = query.Where(c => c.IsDeleted == false);
            if (orgList.Count == 0)
            {
                query = query.Where(x => x.CreateUser == user.Id);
            }
            else
            {
                if (request != null)
                {
                    if (!String.IsNullOrEmpty(request.ReimburseDepartment))
                    {
                        var orgChildren = await _permissionExpansion.GetLowerDepartments(request.ReimburseDepartment);

                        orgList = orgList.Where(x => orgChildren.Contains(x)).ToList();
                    }
                }

                query = query.Where(c => orgList.Contains(c.ReimburseDepartment));
            }


            if (request != null)
            {
                if (request.StartDate != null)
                {
                    var dt = request.StartDate.Value.Date;
                    query = query.Where(c => c.CreateTime >= dt);
                }
                if (request.EndDate != null)
                {
                    var dt = request.EndDate.Value.Date.AddDays(1);
                    query = query.Where(c => c.CreateTime < dt);
                }
                if (request.IsPayment != null)
                {
                    query = query.Where(c => c.IsPayment == request.IsPayment);
                }
                if (request.IsBackup != null)
                {
                    query = query.Where(c => c.IsBackup == request.IsBackup);
                }
                if (!String.IsNullOrWhiteSpace(request.Keyword))
                {
                    query = query.Where(c => (c.ReimburseUserInfo.Name.Contains(request.Keyword) || c.ReimburseUserInfo.UserID.Contains(request.Keyword) || c.Memo.Contains(request.Keyword) || c.ChargeNo.Contains(request.Keyword)));
                }
                if (request.Status != null && request.Status.Count > 0)
                {
                    query = query.Where(c => request.Status.Contains(c.Status));
                }
                if (request.BillStatus != null && request.BillStatus.Count > 0)
                {
                    query = query.Where(c => request.BillStatus.Contains(c.BillStatus));
                }

                if (request.PageIndex > 0 && request.PageSize > 0)
                {
                    r.TotalCount = await query.CountAsync();

                    r.PageSize  = request.PageSize;
                    r.PageIndex = request.PageIndex;
                    query       = query.Skip((request.PageIndex - 1) * request.PageSize).Take(request.PageSize);
                }
            }



            var list = await query.ToListAsync();

            r.Extension = _mapper.Map <List <ChargeInfoResponse> >(list);
            if (r.TotalCount == 0)
            {
                r.TotalCount = r.Extension.Count;
            }

            return(r);
        }