Exemplo n.º 1
0
        /// <summary>
        /// 设置收单渠道信息状态
        /// </summary>
        /// <param name="id"></param>
        /// <param name="state"></param>
        /// <returns></returns>
        public OpResult SetState(int id, short state)
        {
            var entity = PCManageRepost.GetQuery(o => o.Id == id).FirstOrDefault();

            if (entity != null)
            {
                entity.State    = state;
                entity.AuditDT  = DateTime.Now;
                entity.AuditUID = CurrentUser.UID;
                return(OpResult.Result(PCManageRepost.SaveChanges()));
            }
            else
            {
                return(OpResult.Fail("所选项状态已失效!"));
            }
        }
Exemplo n.º 2
0
        /// <summary>
        /// 保存或更新收单渠道信息
        /// </summary>
        /// <param name="model"></param>
        /// <returns></returns>
        public OpResult SaveOrUpdate(PayChannelManage model)
        {
            var source    = model;
            var existsObj = PCManageRepost.GetQuery(o => o.Id != model.Id && o.ChannelCode == model.ChannelCode).FirstOrDefault();

            if (existsObj != null)
            {
                return(OpResult.Fail(message: "收单渠道已经存在,不可重复"));
            }
            if (source.Id > 0)
            {
                source = PCManageRepost.GetQuery(o => o.Id == model.Id).FirstOrDefault();
                model.ToCopyProperty(source, new List <string>()
                {
                    "Id", "ChannelNo", "ChannelCode", "State", "CreateDT", "CreateUID", "AuditDT", "AuditUID"
                });
            }
            else
            {
                var existsCodeObj = PCManageRepost.GetQuery(o => o.ChannelCode == model.ChannelCode).FirstOrDefault();
                if (existsCodeObj != null)
                {
                    return(OpResult.Fail(message: "收单渠道已经存在,不可重复"));
                }

                source.CreateDT  = DateTime.Now;
                source.CreateUID = CurrentUser.UID;
                source.ChannelNo = PayRules.GetMaxNo("PayChannelManages", "ChannelNo");
                PCManageRepost.Add(source, false);
            }

            var result = PCManageRepost.SaveChanges();

            if (result)
            {
                return(OpResult.Success(data: source));
            }
            else
            {
                return(OpResult.Fail(message: "数据未修改,不可保存"));
            }
        }
Exemplo n.º 3
0
        /// <summary>
        /// 设置注销数据(注销逻辑todo:dddd)
        /// </summary>
        /// <param name="id"></param>
        /// <param name="status"></param>
        /// <returns></returns>
        public OpResult CancelPayChannel(int id)
        {
            var entity = PCManageRepost.GetQuery(o => o.Id == id && (o.State == (short)PayChannelState.NotAuditing || o.State == (short)PayChannelState.Disabled)).FirstOrDefault();

            if (entity != null)
            {
                if (entity.State == (short)PayChannelState.NotAuditing)
                { //如果状态为0未审核则直接删除
                    PCManageRepost.Remove(entity, true);
                    return(OpResult.Result(true));
                }
                else
                {//如果状态为2停用则逻辑删除
                    entity.State    = (short)PayChannelState.Cancel;
                    entity.AuditDT  = DateTime.Now;
                    entity.AuditUID = CurrentUser.UID;
                    return(OpResult.Result(PCManageRepost.SaveChanges()));
                }
            }
            else
            {
                return(OpResult.Fail("所选项状态已失效!"));
            }
        }