コード例 #1
0
        public void ProcessRequest(HttpContext context)
        {
            string relation_id  = context.Request["relation_id"];
            string pms_ids      = context.Request["pms_ids"];
            string rel_type     = context.Request["rel_type"];
            int    relationType = 2;

            if (!string.IsNullOrWhiteSpace(rel_type))
            {
                relationType = int.Parse(rel_type);
            }

            if (string.IsNullOrWhiteSpace(pms_ids))
            {
                pms_ids = "0";
            }
            List <long> pms_id_list = pms_ids.Split(',').Select(p => Convert.ToInt64(p)).ToList();
            List <BLLPermission.Model.PermissionRelationInfo> relOList = bllPermission.GetPermissionRelationList(relation_id, relationType);
            List <long> pmso_id_list = relOList.Select(p => p.PermissionID).ToList();
            List <BLLPermission.Model.PermissionRelationInfo> relDelList = relOList.Where(p => !pms_id_list.Contains(p.PermissionID)).ToList();
            List <BLLPermission.Model.PermissionRelationInfo> relAddList = new List <BLLPermission.Model.PermissionRelationInfo>();

            foreach (long item in pms_id_list.Where(p => !pmso_id_list.Contains(p) && p != 0))
            {
                BLLPermission.Model.PermissionRelationInfo nPerRel = new BLLPermission.Model.PermissionRelationInfo();
                nPerRel.RelationType = relationType;
                nPerRel.PermissionID = item;
                nPerRel.RelationID   = relation_id;
                relAddList.Add(nPerRel);
            }
            BLLTransaction tran = new BLLTransaction();

            foreach (BLLPermission.Model.PermissionRelationInfo item in relDelList)
            {
                if (bllPermission.Delete(item, tran) < 0)
                {
                    tran.Rollback();
                    apiResp.code = (int)APIErrCode.OperateFail;
                    apiResp.msg  = "删除原权限关系失败。";
                    bllPermission.ContextResponse(context, apiResp);
                    return;
                }
            }
            foreach (BLLPermission.Model.PermissionRelationInfo item in relAddList)
            {
                if (!bllPermission.Add(item, tran))
                {
                    tran.Rollback();
                    apiResp.code = (int)APIErrCode.OperateFail;
                    apiResp.msg  = "保存新权限关系失败。";
                    bllPermission.ContextResponse(context, apiResp);
                    return;
                }
            }
            tran.Commit();
            apiResp.status = true;
            apiResp.code   = (int)APIErrCode.IsSuccess;
            apiResp.msg    = "保存完成。";
            bllPermission.ContextResponse(context, apiResp);
        }
コード例 #2
0
ファイル: BLLMenuInfo.cs プロジェクト: uvbs/mmp
 /// <summary>
 /// 修改菜单
 /// </summary>
 /// <param name="postMenus"></param>
 /// <param name="preId"></param>
 /// <param name="tran"></param>
 /// <param name="needDelMenuIds"></param>
 /// <returns></returns>
 public bool UpdateMenus(List <MenuInfo> postMenus, long preId, BLLTransaction tran, string needDelMenuIds = null)
 {
     foreach (MenuInfo item in postMenus)
     {
         if (item.IsNew)
         {
             item.PreID  = preId;
             item.MenuID = Convert.ToInt64(GetGUID(TransacType.MenuAdd));
             if (!Add(item, tran) || !UpdateMenus(item.ChildMenus, item.MenuID, tran))
             {
                 throw new Exception("新增菜单失败!");
             }
         }
         else
         {
             item.PreID = preId;
             if (!Update(item, tran) || !UpdateMenus(item.ChildMenus, item.MenuID, tran))
             {
                 throw new Exception("修改菜单失败!");
             }
         }
     }
     if (preId == 0 && !string.IsNullOrWhiteSpace(needDelMenuIds))
     {
         if (DeleteMultByKey <MenuInfo>("MenuID", needDelMenuIds, tran) == -1)
         {
             throw new Exception("删除旧菜单失败!");
         }
     }
     return(true);
 }
コード例 #3
0
ファイル: SetSort.ashx.cs プロジェクト: uvbs/mmp
        public void ProcessRequest(HttpContext context)
        {
            string id         = context.Request["id"];
            string sort       = context.Request["sort"];
            string other_id   = context.Request["other_id"];
            string other_sort = context.Request["other_sort"];

            if (sort == other_sort)
            {
                other_sort = (int.Parse(other_sort) + 1).ToString();
            }

            BLLTransaction tran = new BLLTransaction();

            if (bll.UpdateByKey <TableFieldMapping>("AutoId", id, "Sort", sort, tran) > 0 &&
                bll.UpdateByKey <TableFieldMapping>("AutoId", other_id, "Sort", other_sort, tran) > 0)
            {
                tran.Commit();
                apiResp.status = true;
                apiResp.msg    = "排序完成";
                apiResp.code   = (int)APIErrCode.IsSuccess;
            }
            else
            {
                tran.Rollback();
                apiResp.status = true;
                apiResp.msg    = "排序失败";
                apiResp.code   = (int)APIErrCode.OperateFail;
            }
            bll.ContextResponse(context, apiResp);
        }
コード例 #4
0
        /// <summary>
        /// 发送验证码
        /// </summary>
        /// <param name="phone"></param>
        /// <param name="verificationCode"></param>
        /// <param name="isSuccess"></param>
        /// <param name="msg"></param>
        public void SendSmsVerificationCode(string phone, string msgContent, string smsSignature, string verificationCode, out bool isSuccess, out string msg)
        {
            isSuccess = false;
            msg       = "";
            if (string.IsNullOrEmpty(smsSignature))
            {
                smsSignature = "至云";
            }
            string sendContent = string.Format("{0}【{1}】", msgContent, smsSignature);

            ZentCloud.ZCBLLEngine.BLLTransaction tran = new BLLTransaction();
            SmsVerificationCode model = new SmsVerificationCode();

            model.Phone            = phone;
            model.InsertDate       = DateTime.Now;
            model.VerificationCode = verificationCode;
            model.WebsiteOwner     = WebsiteOwner;
            if (Add(model, tran))
            {
                if (SendSms(WebsiteOwner, phone, sendContent))
                {
                    isSuccess = true;
                    tran.Commit();
                }
                else
                {
                    msg = "短信发送失败";
                    tran.Rollback();
                }
            }
            else
            {
                tran.Rollback();
            }
        }
コード例 #5
0
ファイル: BLLUserScore.cs プロジェクト: uvbs/mmp
        //保存加分历史记录,返回加分值,0为保存失败。
        private double SaveScoreRecord(UserScore userScore, BLLTransaction transaction)
        {
            string deltaScoreStr = string.Empty;

            if (userScore.Score > 0)
            {
                deltaScoreStr = string.Format("+{0}", userScore.Score);
            }
            else
            {
                deltaScoreStr = string.Format("{0}", userScore.Score);
            }
            BLLJIMP.Model.WBHScoreRecord srInfo = new BLLJIMP.Model.WBHScoreRecord()
            {
                InsertDate = DateTime.Now,

                ScoreNum     = deltaScoreStr,
                WebsiteOwner = this.userInfo.WebsiteOwner,
                UserId       = this.UserID,
                NameStr      = userScore.RecordTypeString,
                Nums         = userScore.nums,
                RecordType   = userScore.RecordType,
            };

            if (this.Add(srInfo))
            {
                return(userScore.Score);
            }
            return(0);
        }
コード例 #6
0
ファイル: BLLMenuInfo.cs プロジェクト: uvbs/mmp
        /// <summary>
        /// 批量修改关系
        /// </summary>
        /// <param name="relationID"></param>
        /// <param name="relationType"></param>
        /// <param name="addList"></param>
        /// <param name="delList"></param>
        /// <returns></returns>
        public bool UpdateMenuRelations(List <MenuRelationInfo> addList, List <MenuRelationInfo> delList, out string msg)
        {
            msg = "修改成功";
            BLLTransaction tran = new BLLTransaction();

            foreach (var item in delList)
            {
                if (Delete(item, tran) < 0)
                {
                    msg = "删除出错";
                    tran.Rollback();
                    return(false);
                }
            }
            foreach (var item in addList)
            {
                if (!Add(item, tran))
                {
                    msg = "新增失败";
                    tran.Rollback();
                    return(false);
                }
            }
            tran.Commit();
            return(true);
        }
コード例 #7
0
ファイル: BLLPermission.cs プロジェクト: uvbs/mmp
 /// <summary>
 /// 添加权限组
 /// </summary>
 /// <param name="groupInfo"></param>
 /// <param name="relations"></param>
 /// <returns></returns>
 public long AddGroupInfo(PermissionGroupInfo groupInfo, List <long> pmsIds, BLLTransaction tran)
 {
     if (Get <PermissionGroupInfo>(string.Format(" GroupName='{0}' AND WebsiteOwner='{1}' "
                                                 , groupInfo.GroupName, groupInfo.WebsiteOwner)) != null)
     {
         throw new Exception("权限组名称已被使用");
     }
     groupInfo.GroupID = Convert.ToInt64(GetGUID(TransacType.PermissionGroupAdd));
     if (!Add(groupInfo, tran))
     {
         throw new Exception("添加权限组失败");
     }
     foreach (long pmsId in pmsIds)
     {
         PermissionRelationInfo relation = new PermissionRelationInfo();
         relation.RelationID   = groupInfo.GroupID.ToString();
         relation.PermissionID = pmsId;
         relation.RelationType = 0;
         if (!Add(relation, tran))
         {
             throw new Exception("添加权限关系失败");
         }
     }
     return(groupInfo.GroupID);
 }
コード例 #8
0
ファイル: UpdatePassword.ashx.cs プロジェクト: uvbs/mmp
        public void ProcessRequest(HttpContext context)
        {
            int      uid   = int.Parse(context.Request["AutoID"]);
            UserInfo tUser = bllUser.GetUserInfoByAutoID(uid);

            tUser.Password = context.Request["Password"];
            if (string.IsNullOrWhiteSpace(tUser.Password))
            {
                apiResp.code = (int)APIErrCode.PrimaryKeyIncomplete;
                apiResp.msg  = "密码不能为空";
                bllUser.ContextResponse(context, apiResp);
                return;
            }
            BLLTransaction tran = new BLLTransaction();

            if (!bllUser.Update(tUser, tran))
            {
                tran.Rollback();
                apiResp.code = (int)APIErrCode.OperateFail;
                apiResp.msg  = "修改密码出错";
                bllUser.ContextResponse(context, apiResp);
                return;
            }
            tran.Commit();
            apiResp.code   = (int)APIErrCode.IsSuccess;
            apiResp.status = true;
            apiResp.msg    = "修改完成";
            bllUser.ContextResponse(context, apiResp);
        }
コード例 #9
0
        public void ProcessRequest(HttpContext context)
        {
            string relation_id = context.Request["relation_id"];
            string menu_ids    = context.Request["menu_ids"];

            if (string.IsNullOrWhiteSpace(menu_ids))
            {
                menu_ids = "0";
            }
            List <long> menu_id_list = menu_ids.Split(',').Select(p => Convert.ToInt64(p)).ToList();
            List <BLLPermission.Model.MenuRelationInfo> relOList = bllMenu.GetMenuRelationList(relation_id, 5);
            List <long> menuo_id_list = relOList.Select(p => p.MenuID).ToList();
            List <BLLPermission.Model.MenuRelationInfo> relDelList = relOList.Where(p => !menu_id_list.Contains(p.MenuID)).ToList();
            List <BLLPermission.Model.MenuRelationInfo> relAddList = new List <BLLPermission.Model.MenuRelationInfo>();

            foreach (long item in menu_id_list.Where(p => !menuo_id_list.Contains(p) && p != 0))
            {
                BLLPermission.Model.MenuRelationInfo nPerRel = new BLLPermission.Model.MenuRelationInfo();
                nPerRel.RelationType = 5;
                nPerRel.MenuID       = item;
                nPerRel.RelationID   = relation_id;
                relAddList.Add(nPerRel);
            }
            BLLTransaction tran = new BLLTransaction();

            foreach (BLLPermission.Model.MenuRelationInfo item in relDelList)
            {
                if (bllMenu.Delete(item, tran) < 0)
                {
                    tran.Rollback();
                    apiResp.code = (int)APIErrCode.OperateFail;
                    apiResp.msg  = "删除原菜单失败。";
                    bllMenu.ContextResponse(context, apiResp);
                    return;
                }
            }
            foreach (BLLPermission.Model.MenuRelationInfo item in relAddList)
            {
                if (!bllMenu.Add(item, tran))
                {
                    tran.Rollback();
                    apiResp.code = (int)APIErrCode.OperateFail;
                    apiResp.msg  = "保存新菜单失败。";
                    bllMenu.ContextResponse(context, apiResp);
                    return;
                }
            }
            tran.Commit();
            apiResp.status = true;
            apiResp.code   = (int)APIErrCode.IsSuccess;
            apiResp.msg    = "保存完成。";
            bllMenu.ContextResponse(context, apiResp);
        }
コード例 #10
0
        private string Copy(HttpContext context)
        {
            string idStr = context.Request["id"];
            long   id    = Convert.ToInt64(idStr);
            PermissionGroupInfo model = bllPms.GetPermissionGroup(null, id);
            string newIdStr           = bllPer.GetGUID(TransacType.PermissionGroupAdd);

            model.GroupID   = Convert.ToInt64(newIdStr);
            model.GroupName = model.GroupName + "—复制";
            //权限组权限关系
            List <PermissionRelationInfo> listPermissionRelation = bllPms.GetPermissionRelationList(idStr, 0);
            //权限组权限栏目关系
            List <PermissionRelationInfo> listPermissionRelation3 = bllPms.GetPermissionRelationList(idStr, 3);

            listPermissionRelation.AddRange(listPermissionRelation3);
            foreach (var item in listPermissionRelation)
            {
                item.RelationID = newIdStr;
            }
            List <MenuRelationInfo> listMenuRelation = bllMenu.GetMenuRelationList(idStr, 0);

            foreach (var item in listMenuRelation)
            {
                item.RelationID = newIdStr;
            }

            BLLTransaction tran   = new BLLTransaction();
            bool           result = bllPer.Add(model, tran);

            if (!result)
            {
                tran.Rollback();
                return("复制权限组失败");
            }
            foreach (var item in listPermissionRelation)
            {
                if (!bllPer.Add(item, tran))
                {
                    tran.Rollback();
                    return("复制权限组权限失败");
                }
            }
            foreach (var item in listMenuRelation)
            {
                if (!bllPer.Add(item, tran))
                {
                    tran.Rollback();
                    return("复制权限组菜单失败");
                }
            }
            tran.Commit();
            return(result.ToString().ToLower());
        }
コード例 #11
0
ファイル: UpdateGroupName.ashx.cs プロジェクト: uvbs/mmp
        public void ProcessRequest(HttpContext context)
        {
            string ids       = context.Request["ids"];
            string groupName = context.Request["GroupName"];

            List <CompanyWebsite_ToolBar> oList = bll.GetMultListByKey <CompanyWebsite_ToolBar>("AutoID", ids);

            List <CompanyWebsite_ToolBar> addList    = new List <CompanyWebsite_ToolBar>();
            List <CompanyWebsite_ToolBar> updateList = new List <CompanyWebsite_ToolBar>();
            BLLTransaction tran   = new BLLTransaction();
            bool           result = false;

            foreach (CompanyWebsite_ToolBar item in oList)
            {
                if (item.IsSystem == 1)
                {
                    item.IsSystem     = 0;
                    item.WebsiteOwner = bll.WebsiteOwner;
                    item.KeyType      = groupName;
                    item.BaseID       = item.AutoID;
                    result            = bll.Add(item, tran);
                }
                else
                {
                    item.KeyType = groupName;
                    result       = bll.Update(item, tran);
                }
                if (!result)
                {
                    tran.Rollback();
                    break;
                }
            }
            if (result)
            {
                tran.Commit();
                apiResp.status = true;
                apiResp.msg    = "编辑完成";
                apiResp.code   = (int)APIErrCode.IsSuccess;
            }
            else
            {
                apiResp.msg  = "编辑失败";
                apiResp.code = (int)APIErrCode.OperateFail;
            }

            bll.ContextResponse(context, apiResp);
        }
コード例 #12
0
ファイル: BLLComponent.cs プロジェクト: uvbs/mmp
        /// <summary>
        /// 修改页面
        /// </summary>
        /// <param name="componentModel"></param>
        /// <param name="componentModelFields"></param>
        /// <param name="errmsg"></param>
        /// <returns></returns>
        public bool UpdateComponentModel(ComponentModel UpdateComponentModel, List <ComponentModelField> AddComponentModelFields
                                         , List <ComponentModelField> UpdateComponentModelFields, List <ComponentModelField> DeleteComponentModelFields, out string errmsg)
        {
            BLLTransaction tran = new BLLTransaction();

            errmsg = "";
            if (!Update(UpdateComponentModel, tran))
            {
                errmsg = "页面修改失败";
                tran.Rollback();
                return(false);
            }
            foreach (var item in DeleteComponentModelFields)
            {
                if (Delete(item, tran) <= 0)
                {
                    errmsg = string.Format("页面字段删除[{0}]失败", item.ComponentField);
                    tran.Rollback();
                    return(false);
                }
            }
            foreach (var item in UpdateComponentModelFields)
            {
                if (!Update(item, tran))
                {
                    errmsg = string.Format("页面字段修改[{0}]失败", item.ComponentField);
                    tran.Rollback();
                    return(false);
                }
            }
            foreach (var item in AddComponentModelFields)
            {
                if (!Add(item, tran))
                {
                    errmsg = string.Format("页面字段添加[{0}]失败", item.ComponentField);
                    tran.Rollback();
                    return(false);
                }
            }
            tran.Commit();
            return(true);
        }
コード例 #13
0
ファイル: BLLKeyValueData.cs プロジェクト: uvbs/mmp
        /// <summary>
        /// 提交
        /// </summary>
        /// <param name="vlueData"></param>
        /// <param name="tran"></param>
        /// <returns></returns>
        public bool PutDataValue(Model.KeyVauleDataInfo vlueData, BLLTransaction tran = null)
        {
            if (string.IsNullOrWhiteSpace(vlueData.DataValue))
            {
                return(true);
            }

            Model.KeyVauleDataInfo data = Get <Model.KeyVauleDataInfo>(string.Format(" DataType='{0}' AND DataKey='{1}' AND WebsiteOwner='{2}'  ",
                                                                                     vlueData.DataType, vlueData.DataKey, vlueData.WebsiteOwner), tran);
            if (data != null)
            {
                vlueData.AutoId = data.AutoId;
            }
            if (vlueData.AutoId == 0)
            {
                return(tran == null?Add(vlueData) : Add(vlueData, tran));
            }
            else
            {
                return(tran == null?Update(vlueData) : Update(vlueData, tran));
            }
        }
コード例 #14
0
        /// <summary>
        /// 查询分类总积分
        /// </summary>
        /// <param name="scoreType"></param>
        /// <param name="relationID"></param>
        /// <param name="userID"></param>
        /// <returns></returns>
        public double GetSumScore(string websiteOwner, string scoreType = "", string relationID = "", string userIDs = "",
                                  BLLTransaction trans = null, string scoreEvents  = "", string month          = "", string sumColName = "", string startTime      = "",
                                  string endTime       = "", string scoreWinStatus = "", string relationUserID = "", string isPrint    = "", string scoreNotEvents = "", string moreQuery = "")
        {
            double result = 0;

            if (string.IsNullOrWhiteSpace(sumColName))
            {
                sumColName = "Score";
            }
            StringBuilder sbSql = new StringBuilder();

            sbSql.AppendFormat(" Select Sum({0}) From  ZCJ_UserScoreDetailsInfo ", sumColName);
            sbSql.AppendFormat(" Where {0} ", GetWhereString(websiteOwner, scoreType, relationID, userIDs, scoreEvents, month,
                                                             startTime, endTime, scoreWinStatus, relationUserID, isPrint, scoreNotEvents, moreQuery));
            object resultObj = GetSingle(sbSql.ToString(), trans, "UserScoreDetailsInfo");

            if (resultObj != null)
            {
                result = Convert.ToDouble(resultObj);
            }
            return(result);
        }
コード例 #15
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="orderId"></param>
        /// <param name="memo"></param>
        /// <param name="tran"></param>
        /// <returns></returns>
        public bool CancelLockScoreByOrder(string orderId, string memo, BLLTransaction tran)
        {
            //取出原记录
            var model = GetLockScoreByOrder(orderId);

            if (model == null)
            {
                return(false);
            }

            //追加备注
            if (string.IsNullOrWhiteSpace(model.Memo))
            {
                memo = ";" + memo;
            }

            return(Update(
                       new ScoreLockInfo(),
                       string.Format(" Memo+='{0}',LockStatus=2,CancelTime=GETDATE() ", memo),
                       string.Format(" ForeignkeyId='{0}' AND LockType = 1 ", orderId),
                       tran
                       ) > 0);
        }
コード例 #16
0
ファイル: BLLComponent.cs プロジェクト: uvbs/mmp
        /// <summary>
        /// 添加页面
        /// </summary>
        /// <param name="componentModel"></param>
        /// <param name="componentModelFields"></param>
        /// <param name="errmsg"></param>
        /// <returns></returns>
        public bool AddComponentModel(ComponentModel componentModel, List <ComponentModelField> componentModelFields, out string errmsg)
        {
            BLLTransaction tran = new BLLTransaction();

            errmsg = "";
            if (!Add(componentModel, tran))
            {
                errmsg = "页面添加失败";
                tran.Rollback();
                return(false);
            }
            foreach (var item in componentModelFields)
            {
                if (!Add(item, tran))
                {
                    errmsg = string.Format("页面字段添加[{0}]失败", item.ComponentField);
                    tran.Rollback();
                    return(false);
                }
            }
            tran.Commit();
            return(true);
        }
コード例 #17
0
ファイル: ApplyPass.ashx.cs プロジェクト: uvbs/mmp
        public void ProcessRequest(HttpContext context)
        {
            string          ids  = context.Request["ids"];
            List <UserInfo> list = bllUser.GetList <UserInfo>(string.Format(" AutoID In ({0}) ", ids));

            list = list.Where(p => p.MemberApplyStatus < 9 || p.AccessLevel < 1).ToList();
            if (list.Count > 0)
            {
                BLLTransaction tran = new BLLTransaction();
                foreach (var item in list)
                {
                    if (item.AccessLevel < 1)
                    {
                        item.AccessLevel = 1;
                    }
                    item.MemberStartTime   = DateTime.Now;
                    item.MemberApplyStatus = 9;
                    if (!bllUser.Update(item, tran))
                    {
                        tran.Rollback();
                        apiResp.code = (int)APIErrCode.OperateFail;
                        apiResp.msg  = "提交失败";
                        bllUser.ContextResponse(context, apiResp);
                        return;
                    }
                }
                tran.Commit();
                foreach (var user in list)
                {
                    bllWeixin.SendTemplateMessageNotifyComm(user, "审核通过", "您已经通过会员审核");
                }
            }
            apiResp.status = true;
            apiResp.code   = (int)APIErrCode.IsSuccess;
            apiResp.msg    = "提交完成";
            bllUser.ContextResponse(context, apiResp);
        }
コード例 #18
0
        public void ProcessRequest(HttpContext context)
        {
            int    id           = Convert.ToInt32(context.Request["id"]);
            string websiteOwner = bll.WebsiteOwner;
            string flow_key     = context.Request["flow_key"];
            string content      = context.Request["content"];

            BLLJIMP.Model.Flow flow = bllFlow.GetFlowByKey(flow_key, websiteOwner);
            if (flow == null)
            {
                apiResp.code = (int)APIErrCode.IsNotFound;
                apiResp.msg  = "流程未定义";
                bllFlow.ContextResponse(context, apiResp);
                return;
            }
            if (flow.IsDelete == 1)
            {
                apiResp.code = (int)APIErrCode.IsNotFound;
                apiResp.msg  = flow.FlowName + "已停用";
                bllFlow.ContextResponse(context, apiResp);
                return;
            }
            List <BLLJIMP.Model.FlowStep> steps = bllFlow.GetStepList(2, 1, websiteOwner, flow.AutoID);

            if (steps.Count == 0)
            {
                apiResp.code = (int)APIErrCode.IsNotFound;
                apiResp.msg  = flow.FlowName + "环节未设置";
                bllFlow.ContextResponse(context, apiResp);
                return;
            }

            UserInfo tUser = bllUser.GetUserInfoByAutoID(id, websiteOwner);

            if (tUser == null)
            {
                apiResp.code = (int)APIErrCode.IsNotFound;
                apiResp.msg  = "会员未找到";
                bll.ContextResponse(context, apiResp);
                return;
            }
            if (tUser.MemberLevel <= 0)
            {
                apiResp.code = (int)APIErrCode.IsNotFound;
                apiResp.msg  = "该会员已经撤单";
                bll.ContextResponse(context, apiResp);
                return;
            }
            if (bllFlow.ExistsMemberPhoneAction(websiteOwner, flow.FlowKey, "0", memberUserId: tUser.UserID))
            {
                apiResp.code = (int)APIErrCode.OperateFail;
                apiResp.msg  = "该会员正在申请撤单";
                bll.ContextResponse(context, apiResp);
                return;
            }

            BLLJIMP.Model.FlowStep step1 = steps[0];
            BLLJIMP.Model.FlowStep step2 = null;
            if (steps.Count == 2)
            {
                step2 = steps[1];
            }

            BLLJIMP.Model.FlowAction action = new BLLJIMP.Model.FlowAction();
            action.CreateDate   = DateTime.Now;
            action.CreateUserID = currentUserInfo.UserID;
            action.WebsiteOwner = websiteOwner;
            action.StartStepID  = step1.AutoID;
            action.FlowID       = flow.AutoID;
            action.FlowKey      = flow.FlowKey;
            if (!string.IsNullOrWhiteSpace(content))
            {
                action.StartContent = content;
            }

            action.MemberAutoID = tUser.AutoID;
            action.MemberID     = tUser.UserID;
            action.MemberName   = tUser.TrueName;
            action.MemberPhone  = tUser.Phone;
            action.MemberLevel  = tUser.MemberLevel;
            action.TrueAmount   = tUser.TotalAmount;
            action.Amount       = tUser.AccountAmountEstimate;
            action.DeductAmount = tUser.AccumulationFund;
            UserLevelConfig levelConfig = bll.QueryUserLevel(websiteOwner, "DistributionOnLine", tUser.MemberLevel.ToString());

            action.MemberLevelName = levelConfig == null?"": levelConfig.LevelString;
            action.FlowName        = flow.FlowName;

            if (step2 != null)
            {
                action.StepID   = step2.AutoID;
                action.StepName = step2.StepName;
            }
            else
            {
                action.Status  = 9;
                action.EndDate = DateTime.Now;
            }

            BLLJIMP.Model.FlowActionDetail actionDetail1 = new BLLJIMP.Model.FlowActionDetail();
            actionDetail1.WebsiteOwner = websiteOwner;
            actionDetail1.FlowID       = flow.AutoID;
            actionDetail1.StepID       = step1.AutoID;
            actionDetail1.StepName     = step1.StepName;
            actionDetail1.HandleUserID = currentUserInfo.UserID;
            actionDetail1.HandleDate   = DateTime.Now;
            if (!string.IsNullOrWhiteSpace(action.StartContent))
            {
                actionDetail1.HandleContent = action.StartContent;
            }

            BLLTransaction tran = new BLLTransaction();

            if (bllUser.Update(tUser,
                               string.Format("IsDisable=1"),
                               string.Format("WebsiteOwner='{0}' And AutoID={1}", websiteOwner, tUser.AutoID),
                               tran) <= 0)
            {
                tran.Rollback();
                apiResp.code = (int)APIErrCode.OperateFail;
                apiResp.msg  = flow.FlowName + "冻结失败";
                bllFlow.ContextResponse(context, apiResp);
                return;
            }
            int rId = Convert.ToInt32(bllFlow.AddReturnID(action, tran));

            if (rId <= 0)
            {
                tran.Rollback();
                apiResp.code = (int)APIErrCode.OperateFail;
                apiResp.msg  = flow.FlowName + "失败";
                bllFlow.ContextResponse(context, apiResp);
                return;
            }
            actionDetail1.ActionID = rId;
            if (!bllFlow.Add(actionDetail1, tran))
            {
                tran.Rollback();
                apiResp.code = (int)APIErrCode.OperateFail;
                apiResp.msg  = flow.FlowName + ",记录失败";
                bllFlow.ContextResponse(context, apiResp);
                return;
            }
            tran.Commit();
            apiResp.msg    = "撤单申请提交成功";
            apiResp.status = true;
            apiResp.code   = (int)APIErrCode.IsSuccess;
            bllFlow.ContextResponse(context, apiResp);
        }
コード例 #19
0
        public void ProcessRequest(HttpContext context)
        {
            Add.ProductModel productRequestModel = new Add.ProductModel();//订单模型
            try
            {
                productRequestModel = bllMall.ConvertRequestToModel <Add.ProductModel>(productRequestModel);
            }
            catch (Exception ex)
            {
                apiResp.msg  = "提交格式错误";
                apiResp.code = (int)APIErrCode.OperateFail;
                bllMall.ContextResponse(context, apiResp);
                return;
            }
            //数据检查
            if (string.IsNullOrEmpty(productRequestModel.product_title))
            {
                apiResp.msg  = "商品名称必填";
                apiResp.code = (int)APIErrCode.OperateFail;
                bllMall.ContextResponse(context, apiResp);
                return;
            }
            //if (productRequestModel.price == 0)
            //{
            //    apiResp.msg = "商品价格必填";
            //    apiResp.code = (int)APIErrCode.OperateFail;
            //    bllMall.ContextResponse(context, apiResp);
            //    return;
            //}
            //if (string.IsNullOrWhiteSpace(productRequestModel.show_imgs) && !productRequestModel.article_category_type.Contains("Added"))
            //{
            //    apiResp.msg = "请上传商品图片";
            //    apiResp.code = (int)APIErrCode.OperateFail;
            //    bllMall.ContextResponse(context, apiResp);
            //    return;
            //}
            WXMallProductInfo productInfo = bllMall.GetByKey <WXMallProductInfo>("PID", productRequestModel.product_id, true);

            if (productInfo == null)
            {
                apiResp.msg  = "数据未找到";
                apiResp.code = (int)APIErrCode.IsNotFound;
                bllMall.ContextResponse(context, apiResp);
                return;
            }
            productInfo.PName        = productRequestModel.product_title;
            productInfo.PDescription = productRequestModel.product_desc;
            productInfo.Price        = productRequestModel.price;
            productInfo.CategoryId   = productRequestModel.category_id;
            productInfo.IsOnSale     = productRequestModel.is_onsale.ToString();
            productInfo.Stock        = productRequestModel.totalcount;//(容纳人数)
            productInfo.Sort         = productRequestModel.sort;
            //productInfo.UserID = currentUserInfo.UserID;
            productInfo.PreviousPrice     = productRequestModel.price;
            productInfo.Summary           = productRequestModel.product_summary;
            productInfo.LastUpdate        = DateTime.Now;
            productInfo.RelationProductId = productRequestModel.relation_product_id;
            productInfo.AccessLevel       = productRequestModel.access_Level;
            productInfo.Unit = productRequestModel.unit;
            if (!string.IsNullOrWhiteSpace(productRequestModel.show_imgs))
            {
                productInfo.ShowImage = productRequestModel.show_imgs;
                List <string> imgs = productRequestModel.show_imgs.Split(',').Where(p => !string.IsNullOrWhiteSpace(p)).ToList();
                productInfo.RecommendImg = imgs[0];
                int max = imgs.Count > 5 ? 5 : imgs.Count;
                for (int i = 0; i < max; i++)
                {
                    if (i == 0)
                    {
                        productInfo.ShowImage1 = imgs[0];
                    }
                    else if (i == 1)
                    {
                        productInfo.ShowImage2 = imgs[1];
                    }
                    else if (i == 2)
                    {
                        productInfo.ShowImage3 = imgs[2];
                    }
                    else if (i == 3)
                    {
                        productInfo.ShowImage4 = imgs[3];
                    }
                    else if (i == 4)
                    {
                        productInfo.ShowImage5 = imgs[4];
                    }
                }
            }

            string dSkuIds = "";
            //默认第一条sku
            ProductSku productSku = bllMall.GetProductSku(productRequestModel.product_id);

            if (productSku == null)
            {
                //增加系统默认sku
                productSku                     = new ProductSku();//
                productSku.InsertDate          = DateTime.Now;
                productSku.Stock               = 1;
                productSku.WebSiteOwner        = bllMall.WebsiteOwner;
                productSku.ArticleCategoryType = productInfo.ArticleCategoryType;
            }
            List <ProductSku> addSkuList    = new List <ProductSku>();
            List <ProductSku> updateSkuList = new List <ProductSku>();

            if (productRequestModel.time_set_method == 0)
            {
                productSku.Price = productInfo.Price;
                updateSkuList.Add(productSku);

                List <ProductSku> dSkuList = bllMall.GetColList <ProductSku>(int.MaxValue, 1, string.Format("ProductId={0} AND SkuId!={1} ", productInfo.PID, productSku.SkuId), "SkuId");
                if (dSkuList.Count > 0)
                {
                    dSkuIds = ZentCloud.Common.MyStringHelper.ListToStr(dSkuList.Select(p => p.SkuId).ToList(), "", ",");
                }
            }
            else if (productRequestModel.time_set_method == 1 || productRequestModel.time_set_method == 2)
            {
                List <Add.timeModel> skuModelList = JSONHelper.JsonToModel <List <Add.timeModel> >(productRequestModel.time_data);
                string pSkuIds = ZentCloud.Common.MyStringHelper.ListToStr(skuModelList.Select(p => p.sku_id).ToList(), "", ",");
                if (string.IsNullOrWhiteSpace(pSkuIds))
                {
                    pSkuIds = "0";
                }
                List <ProductSku> dSkuList = bllMall.GetColList <ProductSku>(int.MaxValue, 1, string.Format("ProductId={0} AND SkuId Not In ({1}) ", productInfo.PID, pSkuIds), "SkuId");
                if (dSkuList.Count > 0)
                {
                    dSkuIds = ZentCloud.Common.MyStringHelper.ListToStr(dSkuList.Select(p => p.SkuId).ToList(), "", ",");
                }
                foreach (Add.timeModel item in skuModelList)
                {
                    ProductSku nSku = (ProductSku)productSku.Clone();
                    if (item.sku_id != 0)
                    {
                        nSku = bllMall.GetByKey <ProductSku>("SkuId", item.sku_id.ToString());
                    }
                    nSku.PropValueIdEx1 = item.ex1;
                    nSku.PropValueIdEx2 = item.ex2;
                    nSku.PropValueIdEx3 = item.ex3;
                    nSku.Price          = item.price;
                    if (item.sku_id != 0)
                    {
                        updateSkuList.Add(nSku);
                    }
                    else
                    {
                        addSkuList.Add(nSku);
                    }
                }
            }

            BLLTransaction tran   = new BLLTransaction();
            bool           result = bllMall.Update(productInfo, tran);

            if (!result)
            {
                tran.Rollback();
                apiResp.msg  = "更新失败";
                apiResp.code = (int)APIErrCode.OperateFail;
                bllMall.ContextResponse(context, apiResp);
                return;
            }
            if (!string.IsNullOrWhiteSpace(dSkuIds))
            {
                result = bllMall.DeleteMultByKey <ProductSku>("SkuId", dSkuIds, tran) >= 0;
                if (!result)
                {
                    tran.Rollback();
                    apiResp.msg  = "删除旧时间段失败";
                    apiResp.code = (int)APIErrCode.OperateFail;
                    bllMall.ContextResponse(context, apiResp);
                    return;
                }
            }
            foreach (ProductSku item in updateSkuList)
            {
                result = bllMall.Update(item, tran);
                if (!result)
                {
                    tran.Rollback();
                    apiResp.msg  = "修改Sku失败";
                    apiResp.code = (int)APIErrCode.OperateFail;
                    bllMall.ContextResponse(context, apiResp);
                    return;
                }
            }
            int productId = int.Parse(productInfo.PID);

            foreach (ProductSku item in addSkuList)
            {
                item.ProductId = productId;
                item.SkuId     = int.Parse(bllMall.GetGUID(BLLJIMP.TransacType.AddProductSku));
                result         = bllMall.Add(item, tran);
                if (!result)
                {
                    tran.Rollback();
                    apiResp.msg  = "新增Sku失败";
                    apiResp.code = (int)APIErrCode.OperateFail;
                    bllMall.ContextResponse(context, apiResp);
                    return;
                }
            }
            tran.Commit();
            apiResp.status = true;
            apiResp.msg    = "更新完成";
            apiResp.code   = (int)APIErrCode.IsSuccess;
            bllMall.ContextResponse(context, apiResp);
        }
コード例 #20
0
ファイル: Start.ashx.cs プロジェクト: uvbs/mmp
        public void ProcessRequest(HttpContext context)
        {
            BLLJIMP.Model.API.Flow.PostAction requestPost = bllFlow.ConvertRequestToModel <BLLJIMP.Model.API.Flow.PostAction>(new BLLJIMP.Model.API.Flow.PostAction());
            string[] limit = new string[] { "OfflineRecharge", "OfflineUpgrade" };
            if (!limit.Contains(requestPost.flow_key))
            {
                apiResp.code = (int)APIErrCode.IsNotFound;
                apiResp.msg  = "该流程不支持";
                bllFlow.ContextResponse(context, apiResp);
                return;
            }
            string websiteOwner = bllFlow.WebsiteOwner;

            BLLJIMP.Model.Flow flow = bllFlow.GetFlowByKey(requestPost.flow_key, websiteOwner);
            if (flow == null)
            {
                apiResp.code = (int)APIErrCode.IsNotFound;
                apiResp.msg  = "流程未定义";
                bllFlow.ContextResponse(context, apiResp);
                return;
            }
            if (flow.IsDelete == 1)
            {
                apiResp.code = (int)APIErrCode.IsNotFound;
                apiResp.msg  = flow.FlowName + "已停用";
                bllFlow.ContextResponse(context, apiResp);
                return;
            }
            List <BLLJIMP.Model.FlowStep> steps = bllFlow.GetStepList(2, 1, websiteOwner, flow.AutoID);

            if (steps.Count == 0)
            {
                apiResp.code = (int)APIErrCode.IsNotFound;
                apiResp.msg  = flow.FlowName + "环节未设置";
                bllFlow.ContextResponse(context, apiResp);
                return;
            }

            UserInfo member = bllUser.GetUserInfo(requestPost.member_userid, websiteOwner);

            if (requestPost.flow_key == "OfflineUpgrade")
            {
                if (member.MemberLevel >= Convert.ToInt32(requestPost.ex2))
                {
                    apiResp.code = (int)APIErrCode.OperateFail;
                    apiResp.msg  = "所选级别低于会员当前级别";
                    bllFlow.ContextResponse(context, apiResp);
                    return;
                }
                UserLevelConfig mlevelConfig  = bll.QueryUserLevel(websiteOwner, "DistributionOnLine", member.MemberLevel.ToString());
                UserLevelConfig toLevelConfig = bll.QueryUserLevel(websiteOwner, "DistributionOnLine", requestPost.ex2.ToString());
                if (toLevelConfig == null)
                {
                    apiResp.code = (int)APIErrCode.IsNotFound;
                    apiResp.msg  = "等级未找到";
                    bll.ContextResponse(context, apiResp);
                    return;
                }
                if (toLevelConfig.IsDisable == 1)
                {
                    apiResp.code = (int)APIErrCode.IsNotFound;
                    apiResp.msg  = "级别禁止升级";
                    bll.ContextResponse(context, apiResp);
                    return;
                }
                requestPost.amount = Convert.ToDecimal(toLevelConfig.FromHistoryScore) - Convert.ToDecimal(mlevelConfig.FromHistoryScore);
                if (requestPost.amount < 0)
                {
                    apiResp.code = (int)APIErrCode.OperateFail;
                    apiResp.msg  = "所选级别低于会员当前级别";
                    bllFlow.ContextResponse(context, apiResp);
                    return;
                }
                requestPost.ex3 = toLevelConfig.LevelString;
            }

            WebsiteInfo website = bllUser.GetWebsiteInfoModelFromDataBase(websiteOwner);

            BLLJIMP.Model.FlowStep step1 = steps[0];
            BLLJIMP.Model.FlowStep step2 = null;
            if (steps.Count == 2)
            {
                step2 = steps[1];
            }

            BLLJIMP.Model.FlowAction action = new BLLJIMP.Model.FlowAction();
            action.CreateDate   = DateTime.Now;
            action.CreateUserID = currentUserInfo.UserID;
            action.WebsiteOwner = websiteOwner;
            action.StartStepID  = step1.AutoID;
            action.FlowID       = flow.AutoID;
            action.FlowKey      = flow.FlowKey;
            if (requestPost.amount > 0)
            {
                action.Amount = requestPost.amount;
            }
            if (!string.IsNullOrWhiteSpace(requestPost.content))
            {
                action.StartContent = requestPost.content;
            }
            if (!string.IsNullOrWhiteSpace(requestPost.ex1))
            {
                action.StartEx1 = requestPost.ex1;
            }
            if (!string.IsNullOrWhiteSpace(requestPost.ex2))
            {
                action.StartEx2 = requestPost.ex2;
            }
            if (!string.IsNullOrWhiteSpace(requestPost.ex3))
            {
                action.StartEx3 = requestPost.ex3;
            }
            if (requestPost.select_date.HasValue)
            {
                action.StartSelectDate = requestPost.select_date.Value;
            }

            action.MemberAutoID = member.AutoID;
            action.MemberID     = member.UserID;
            action.MemberName   = bllUser.GetUserDispalyName(member);
            action.MemberAvatar = bllUser.GetUserDispalyAvatar(member);
            action.MemberPhone  = member.Phone;

            ZentCloud.BLLJIMP.Model.UserLevelConfig levelConfig = bll.QueryUserLevel(websiteOwner, "DistributionOnLine", member.MemberLevel.ToString());
            action.MemberLevel     = levelConfig.LevelNumber;
            action.MemberLevelName = levelConfig.LevelString;

            action.FlowName = flow.FlowName;
            if (step2 != null)
            {
                action.StepID   = step2.AutoID;
                action.StepName = step2.StepName;
            }
            else
            {
                action.Status  = 9;
                action.EndDate = DateTime.Now;
            }
            BLLJIMP.Model.FlowActionDetail actionDetail1 = new BLLJIMP.Model.FlowActionDetail();
            actionDetail1.WebsiteOwner = websiteOwner;
            actionDetail1.FlowID       = flow.AutoID;
            actionDetail1.StepID       = step1.AutoID;
            actionDetail1.StepName     = step1.StepName;
            actionDetail1.HandleUserID = currentUserInfo.UserID;
            actionDetail1.HandleDate   = DateTime.Now;
            if (!string.IsNullOrWhiteSpace(action.StartContent))
            {
                actionDetail1.HandleContent = action.StartContent;
            }
            if (requestPost.select_date.HasValue)
            {
                actionDetail1.HandleSelectDate = requestPost.select_date.Value;
            }
            if (!string.IsNullOrWhiteSpace(action.StartEx1))
            {
                actionDetail1.Ex1 = action.StartEx1;
            }
            if (!string.IsNullOrWhiteSpace(action.StartEx2))
            {
                actionDetail1.Ex2 = action.StartEx2;
            }
            if (!string.IsNullOrWhiteSpace(action.StartEx3))
            {
                actionDetail1.Ex3 = action.StartEx3;
            }

            List <BLLJIMP.Model.FlowActionFile> files = new List <BLLJIMP.Model.FlowActionFile>();

            if (!string.IsNullOrWhiteSpace(requestPost.files))
            {
                List <string> fileUrls = requestPost.files.Split(',').Where(p => !string.IsNullOrWhiteSpace(p)).ToList();
                if (fileUrls.Count > 0)
                {
                    foreach (var item in fileUrls)
                    {
                        files.Add(new BLLJIMP.Model.FlowActionFile()
                        {
                            FlowID       = flow.AutoID,
                            StepID       = step1.AutoID,
                            WebsiteOwner = websiteOwner,
                            FilePath     = item
                        });
                    }
                }
            }
            BLLTransaction tran = new BLLTransaction();
            int            rId  = Convert.ToInt32(bllFlow.AddReturnID(action, tran));

            if (rId <= 0)
            {
                tran.Rollback();
                apiResp.code = (int)APIErrCode.OperateFail;
                apiResp.msg  = flow.FlowName + "失败";
                bllFlow.ContextResponse(context, apiResp);
                return;
            }
            actionDetail1.ActionID = rId;
            if (!bllFlow.Add(actionDetail1, tran))
            {
                tran.Rollback();
                apiResp.code = (int)APIErrCode.OperateFail;
                apiResp.msg  = flow.FlowName + ",记录失败";
                bllFlow.ContextResponse(context, apiResp);
                return;
            }
            foreach (var item in files)
            {
                item.ActionID = rId;
                if (!bllFlow.Add(item, tran))
                {
                    tran.Rollback();
                    apiResp.code = (int)APIErrCode.OperateFail;
                    apiResp.msg  = flow.FlowName + ",保存附件失败";
                    bllFlow.ContextResponse(context, apiResp);
                    return;
                }
            }
            tran.Commit();
            apiResp.status = true;
            apiResp.code   = (int)APIErrCode.IsSuccess;
            apiResp.msg    = flow.FlowName + "提交成功";
            bllFlow.ContextResponse(context, apiResp);
        }
コード例 #21
0
        public void ProcessRequest(HttpContext context)
        {
            Add.PostModel        requestModel = new Add.PostModel();//模型
            List <Add.FileModel> nFiles       = new List <Add.FileModel>();

            try
            {
                requestModel = bllJuActivity.ConvertRequestToModel <Add.PostModel>(requestModel);
                nFiles       = ZentCloud.Common.JSONHelper.JsonToModel <List <Add.FileModel> >(requestModel.file_list);
            }
            catch (Exception ex)
            {
                apiResp.msg  = "提交格式错误";
                apiResp.code = (int)APIErrCode.OperateFail;
                bllJuActivity.ContextResponse(context, apiResp);
                return;
            }
            //数据检查
            if (string.IsNullOrEmpty(requestModel.policy_name))
            {
                apiResp.msg  = "政策名称必填";
                apiResp.code = (int)APIErrCode.OperateFail;
                bllJuActivity.ContextResponse(context, apiResp);
                return;
            }
            JuActivityInfo pInfo = bllJuActivity.GetByKey <JuActivityInfo>("JuActivityID", requestModel.id.ToString());

            if (pInfo == null)
            {
                apiResp.msg  = "原记录不存在";
                apiResp.code = (int)APIErrCode.OperateFail;
                bllJuActivity.ContextResponse(context, apiResp);
                return;
            }
            pInfo.ActivityName   = requestModel.policy_name;
            pInfo.Summary        = requestModel.summary;
            pInfo.K2             = requestModel.policy_object;
            pInfo.K3             = requestModel.subsidy_standard;
            pInfo.K4             = requestModel.subsidy_period;
            pInfo.K5             = requestModel.policy_number;
            pInfo.K6             = requestModel.policy_level;
            pInfo.K7             = requestModel.domicile_place;
            pInfo.K8             = requestModel.sex;
            pInfo.K9             = string.IsNullOrWhiteSpace(requestModel.male_age_min) ? null : requestModel.male_age_min;
            pInfo.K10            = string.IsNullOrWhiteSpace(requestModel.male_age_max) ? null : requestModel.male_age_max;
            pInfo.K11            = string.IsNullOrWhiteSpace(requestModel.famale_age_min) ? null : requestModel.famale_age_min;
            pInfo.K12            = string.IsNullOrWhiteSpace(requestModel.famale_age_max) ? null : requestModel.famale_age_max;
            pInfo.K13            = requestModel.education;
            pInfo.K14            = string.IsNullOrWhiteSpace(requestModel.graduation_year_min) ? null : requestModel.graduation_year_min;
            pInfo.K15            = string.IsNullOrWhiteSpace(requestModel.graduation_year_max) ? null : requestModel.graduation_year_max;
            pInfo.K16            = requestModel.employment_status;
            pInfo.K17            = string.IsNullOrWhiteSpace(requestModel.current_job_life_min) ? null : requestModel.current_job_life_min;
            pInfo.K18            = string.IsNullOrWhiteSpace(requestModel.current_job_life_max) ? null : requestModel.current_job_life_max;
            pInfo.K19            = string.IsNullOrWhiteSpace(requestModel.unemployment_period_min) ? null : requestModel.unemployment_period_min;
            pInfo.K20            = string.IsNullOrWhiteSpace(requestModel.unemployment_period_max) ? null : requestModel.unemployment_period_max;
            pInfo.K21            = requestModel.company_type;
            pInfo.K22            = string.IsNullOrWhiteSpace(requestModel.registered_capital_min) ? null : requestModel.registered_capital_min;
            pInfo.K23            = string.IsNullOrWhiteSpace(requestModel.registered_capital_max) ? null : requestModel.registered_capital_max;
            pInfo.K24            = string.IsNullOrWhiteSpace(requestModel.personnel_size_min) ? null : requestModel.personnel_size_min;
            pInfo.K25            = string.IsNullOrWhiteSpace(requestModel.personnel_size_max) ? null : requestModel.personnel_size_max;
            pInfo.K26            = requestModel.company_size;
            pInfo.K27            = requestModel.industry;
            pInfo.Sort           = requestModel.sort;
            pInfo.LastUpdateDate = DateTime.Now;


            List <JuActivityFiles> files = new List <JuActivityFiles>();

            foreach (var item in nFiles.Where(p => p.id == 0))
            {
                files.Add(new JuActivityFiles()
                {
                    AddDate      = DateTime.Now,
                    FileClass    = item.file_class,
                    JuActivityID = pInfo.JuActivityID,
                    FileName     = item.file_name,
                    FilePath     = item.file_path,
                    UserID       = currentUserInfo.UserID
                });
            }

            bool           result = false;
            BLLTransaction tran   = new BLLTransaction();

            result = bllJuActivity.Update(pInfo, tran);
            if (!result)
            {
                tran.Rollback();
                apiResp.msg  = "提交失败";
                apiResp.code = (int)APIErrCode.OperateFail;
                bllJuActivity.ContextResponse(context, apiResp);
                return;
            }
            string noDeleteFileIds = "0";

            if (nFiles.Where(p => p.id != 0).Count() > 0)
            {
                noDeleteFileIds = ZentCloud.Common.MyStringHelper.ListToStr(nFiles.Where(p => p.id != 0).Select(p => p.id).ToList(), "", ",");
            }
            result = bllJuActivity.Delete(new JuActivityFiles(), string.Format(" AutoID Not In ({0}) AND JuActivityID={1}", noDeleteFileIds, pInfo.JuActivityID.ToString()), tran) >= 0;

            foreach (var item in files)
            {
                if (!result)
                {
                    break;
                }
                result = bllJuActivity.Add(item, tran);
            }
            if (!result)
            {
                tran.Rollback();
                apiResp.msg  = "提交失败";
                apiResp.code = (int)APIErrCode.OperateFail;
            }

            tran.Commit();
            apiResp.status = true;
            apiResp.msg    = "提交完成";
            apiResp.code   = (int)APIErrCode.IsSuccess;

            bllJuActivity.ContextResponse(context, apiResp);
        }
コード例 #22
0
        public void ProcessRequest(HttpContext context)
        {
            PostModel requestModel = new PostModel();//订单模型

            try
            {
                requestModel = bllJuActivity.ConvertRequestToModel <PostModel>(requestModel);
            }
            catch (Exception ex)
            {
                apiResp.msg  = "提交格式错误";
                apiResp.code = (int)APIErrCode.OperateFail;
                bllJuActivity.ContextResponse(context, apiResp);
                return;
            }
            //数据检查
            if (string.IsNullOrEmpty(requestModel.title))
            {
                apiResp.msg  = "名称必填";
                apiResp.code = (int)APIErrCode.OperateFail;
                bllJuActivity.ContextResponse(context, apiResp);
                return;
            }
            //if (string.IsNullOrEmpty(requestModel.city))
            //{
            //    apiResp.msg = "城市必选";
            //    apiResp.code = (int)APIErrCode.OperateFail;
            //    bllJuActivity.ContextResponse(context, apiResp);
            //    return;
            //}
            //if (string.IsNullOrEmpty(requestModel.district))
            //{
            //    apiResp.msg = "区域必选";
            //    apiResp.code = (int)APIErrCode.OperateFail;
            //    bllJuActivity.ContextResponse(context, apiResp);
            //    return;
            //}
            if (string.IsNullOrEmpty(requestModel.address))
            {
                apiResp.msg  = "地址必填";
                apiResp.code = (int)APIErrCode.OperateFail;
                bllJuActivity.ContextResponse(context, apiResp);
                return;
            }
            if (string.IsNullOrEmpty(requestModel.k4))
            {
                apiResp.msg  = "电话必填";
                apiResp.code = (int)APIErrCode.OperateFail;
                bllJuActivity.ContextResponse(context, apiResp);
                return;
            }
            if (string.IsNullOrEmpty(requestModel.longitude))
            {
                apiResp.msg  = "请选择坐标";
                apiResp.code = (int)APIErrCode.OperateFail;
                bllJuActivity.ContextResponse(context, apiResp);
                return;
            }
            if (string.IsNullOrEmpty(requestModel.latitude))
            {
                apiResp.msg  = "请选择坐标";
                apiResp.code = (int)APIErrCode.OperateFail;
                bllJuActivity.ContextResponse(context, apiResp);
                return;
            }
            JuActivityInfo pInfo = new JuActivityInfo();

            pInfo.JuActivityID    = int.Parse(bllJuActivity.GetGUID(BLLJIMP.TransacType.ActivityAdd));
            pInfo.ActivityName    = requestModel.title;
            pInfo.ActivityAddress = requestModel.address;
            pInfo.ServerTimeMsg   = requestModel.server_time;
            pInfo.ServicesMsg     = requestModel.server_msg;
            pInfo.ThumbnailsPath  = requestModel.img;
            pInfo.ArticleType     = "Outlets";
            pInfo.CategoryId      = requestModel.cate_id;
            pInfo.Province        = requestModel.province;
            pInfo.ProvinceCode    = requestModel.province_code;
            pInfo.City            = requestModel.city;
            pInfo.CityCode        = requestModel.city_code;
            pInfo.District        = requestModel.district;
            pInfo.DistrictCode    = requestModel.district_code;
            pInfo.K1             = requestModel.k1;
            pInfo.K4             = requestModel.k4;
            pInfo.K5             = requestModel.k5;
            pInfo.Tags           = requestModel.tags;
            pInfo.Sort           = requestModel.sort;
            pInfo.UserLongitude  = requestModel.longitude;
            pInfo.UserLatitude   = requestModel.latitude;
            pInfo.IsHide         = 0;
            pInfo.CreateDate     = DateTime.Now;
            pInfo.LastUpdateDate = DateTime.Now;
            pInfo.WebsiteOwner   = bllJuActivity.WebsiteOwner;
            pInfo.UserID         = currentUserInfo.UserID;
            List <string> tagList = null;

            if (!string.IsNullOrWhiteSpace(pInfo.Tags))
            {
                tagList = pInfo.Tags.Split(',').ToList();
            }

            bool           result = false;
            BLLTransaction tran   = new BLLTransaction();

            result = bllJuActivity.Add(pInfo, tran);
            if (!result)
            {
                tran.Rollback();
                apiResp.msg  = "提交失败";
                apiResp.code = (int)APIErrCode.OperateFail;
                bllJuActivity.ContextResponse(context, apiResp);
                return;
            }
            result = bllJuActivity.SetJuActivityContentTags(pInfo.JuActivityID, tagList);
            if (result)
            {
                tran.Commit();
                apiResp.status = true;
                apiResp.msg    = "提交完成";
                apiResp.code   = (int)APIErrCode.IsSuccess;
                string polId = "";
                ZentCloud.BLLJIMP.Model.Weixin.WeixinStore model = new BLLJIMP.Model.Weixin.WeixinStore();
                model.business_name = pInfo.ActivityName;
                model.branch_name   = pInfo.ActivityName;
                model.province      = pInfo.Province;
                model.city          = pInfo.City;
                model.district      = pInfo.District;
                model.address       = pInfo.ActivityAddress;
                model.telephone     = pInfo.K4;
                model.categories    = new List <string>();
                model.categories.Add("购物,综合商场");
                model.offset_type = 1;
                model.longitude   = double.Parse(pInfo.UserLongitude);
                model.latitude    = double.Parse(pInfo.UserLatitude);

                string msg = "";
                if (bllWeixinCard.CreateStore(model, out polId, out msg))
                {
                    bllJuActivity.Update(pInfo, string.Format("K30='{0}'", polId), string.Format("JuActivityID={0}", pInfo.JuActivityID));
                }
                else
                {
                    apiResp.msg  = msg;
                    apiResp.code = (int)APIErrCode.OperateFail;
                    bllJuActivity.ContextResponse(context, apiResp);
                    return;
                }
            }
            else
            {
                tran.Rollback();
                apiResp.msg  = "提交失败";
                apiResp.code = (int)APIErrCode.OperateFail;
            }
            bllJuActivity.ContextResponse(context, apiResp);
        }
コード例 #23
0
        public void ProcessRequest(HttpContext context)
        {
            if (CurrentUserInfo.IsLock == 1)
            {
                apiResp.code = (int)APIErrCode.NoPms;
                apiResp.msg  = "账号已被锁定";
                bllUser.ContextResponse(context, apiResp);
                return;
            }
            if (CurrentUserInfo.MemberApplyStatus != 9)
            {
                apiResp.code = (int)APIErrCode.NoPms;
                apiResp.msg  = "您的账号正在审核中";
                bllUser.ContextResponse(context, apiResp);
                return;
            }
            decimal     amount       = Convert.ToDecimal(context.Request["amount"]);
            int         spreadid     = Convert.ToInt32(context.Request["spreadid"]);
            string      websiteOwner = bllUser.WebsiteOwner;
            WebsiteInfo website      = bllUser.GetWebsiteInfoModelFromDataBase(websiteOwner);

            if (amount <= 0)
            {
                apiResp.code = (int)APIErrCode.PrimaryKeyIncomplete;
                apiResp.msg  = string.Format("转账{0}必须大于0", website.TotalAmountShowName);
                bllUser.ContextResponse(context, apiResp);
                return;
            }
            if (CurrentUserInfo.TotalAmount < amount)
            {
                apiResp.code = (int)APIErrCode.OperateFail;
                apiResp.msg  = string.Format("您的{0}不足", website.TotalAmountShowName);
                bllUser.ContextResponse(context, apiResp);
                return;
            }
            UserInfo spread = bllUser.GetUserInfoByAutoID(spreadid, websiteOwner);

            if (spread == null)
            {
                apiResp.code = (int)APIErrCode.PrimaryKeyIncomplete;
                apiResp.msg  = "会员未找到";
                bllUser.ContextResponse(context, apiResp);
                return;
            }
            if (spread.AutoID == CurrentUserInfo.AutoID)
            {
                apiResp.code = (int)APIErrCode.OperateFail;
                apiResp.msg  = "禁止转账给自己";
                bllUser.ContextResponse(context, apiResp);
                return;
            }
            string         spreadname = bllUser.GetUserDispalyName(spread);
            string         curname    = bllUser.GetUserDispalyName(CurrentUserInfo);
            BLLTransaction tran       = new BLLTransaction();

            #region 消耗操作人金额
            if (bllUser.AddScoreDetail(CurrentUserInfo.UserID, websiteOwner, (double)(0 - amount),
                                       string.Format("转给{0}[{1}]", spreadname, spread.Phone),
                                       "TotalAmount", (double)(CurrentUserInfo.TotalAmount - amount),
                                       "", "转账", "", "", (double)amount, 0, spread.UserID,
                                       tran) <= 0)
            {
                tran.Rollback();
                apiResp.msg  = "记录转账明细出错";
                apiResp.code = (int)APIErrCode.OperateFail;
                bllUser.ContextResponse(context, apiResp);
                return;
            }
            if (bllUser.Update(CurrentUserInfo, string.Format("TotalAmount=ISNULL(TotalAmount,0)-{0},AccountAmountEstimate=ISNULL(AccountAmountEstimate,0)-{0}", amount),
                               string.Format("AutoID={0} And WebsiteOwner='{1}' And ISNULL(TotalAmount,0)-{2}>=0 ",
                                             CurrentUserInfo.AutoID, websiteOwner, amount),
                               tran) <= 0)
            {
                tran.Rollback();
                apiResp.msg  = string.Format("消耗报单人可用{0}出错", website.TotalAmountShowName);
                apiResp.code = (int)APIErrCode.OperateFail;
                bllUser.ContextResponse(context, apiResp);
                return;
            }
            #endregion
            #region 指定会员获得金额
            if (bllUser.AddScoreDetail(spread.UserID, websiteOwner, (double)(amount),
                                       string.Format("{0}[{1}]转入", curname, CurrentUserInfo.Phone),
                                       "TotalAmount", (double)(spread.TotalAmount + amount),
                                       "", "获得转账", "", "", (double)amount, 0, CurrentUserInfo.UserID,
                                       tran) <= 0)
            {
                tran.Rollback();
                apiResp.msg  = "记录获得转账明细出错";
                apiResp.code = (int)APIErrCode.OperateFail;
                bllUser.ContextResponse(context, apiResp);
                return;
            }
            if (bllUser.Update(spread, string.Format("TotalAmount=ISNULL(TotalAmount,0)+{0},AccountAmountEstimate=ISNULL(AccountAmountEstimate,0)+{0}", amount),
                               string.Format("AutoID={0} And WebsiteOwner='{1}'",
                                             spread.AutoID, websiteOwner),
                               tran) <= 0)
            {
                tran.Rollback();
                apiResp.msg  = string.Format("增加会员可用{0}出错", website.TotalAmountShowName);
                apiResp.code = (int)APIErrCode.OperateFail;
                bllUser.ContextResponse(context, apiResp);
                return;
            }
            #endregion
            tran.Commit();

            //异步计算金额
            Thread th1 = new Thread(delegate()
            {
                bll.CheckTotalAmount(spread.AutoID, websiteOwner, 7);
            });
            th1.Start();

            apiResp.msg    = "转账成功";
            apiResp.code   = (int)APIErrCode.IsSuccess;
            apiResp.status = true;
            bllUser.ContextResponse(context, apiResp);
        }
コード例 #24
0
        private string EditRechargeConfig(HttpContext context)
        {
            string           recharge                  = context.Request["Recharge"];
            string           vipPrice                  = context.Request["VIPPrice"];
            string           sendNoticePrice           = context.Request["SendNoticePrice"];
            string           minScore                  = context.Request["MinScore"];
            string           minWithdrawCashScore      = context.Request["MinWithdrawCashScore"];
            string           vipPrice0                 = context.Request["VIPPrice0"];
            string           vipDatelong               = context.Request["VIPDatelong"];
            string           vipInterestID             = context.Request["VIPInterestID"];
            string           vipInterestDescription    = context.Request["VIPInterestDescription"];
            string           websiteOwner              = bllkeyValueData.WebsiteOwner;
            KeyVauleDataInfo rechargeKeyValue          = new KeyVauleDataInfo("Recharge", "100", recharge, websiteOwner, null, currentUserInfo.UserID);
            KeyVauleDataInfo sendNoticePriceValue      = new KeyVauleDataInfo("SendNoticePrice", "1", sendNoticePrice, websiteOwner, null, currentUserInfo.UserID);
            KeyVauleDataInfo minScoreValue             = new KeyVauleDataInfo("MinScore", "1", minScore, websiteOwner, null, currentUserInfo.UserID);
            KeyVauleDataInfo minWithdrawCashScoreValue = new KeyVauleDataInfo("MinWithdrawCashScore", "1", minWithdrawCashScore, websiteOwner, null, currentUserInfo.UserID);
            KeyVauleDataInfo VIPPriceKeyValue          = new KeyVauleDataInfo("VIPPrice", "1", vipPrice, websiteOwner, null, currentUserInfo.UserID);
            KeyVauleDataInfo VIPPrice0KeyValue         = new KeyVauleDataInfo("VIPPrice", "0", vipPrice0, websiteOwner, null, currentUserInfo.UserID);
            KeyVauleDataInfo VIPDatelongKeyValue       = new KeyVauleDataInfo("VIPDatelong", "1", vipDatelong, websiteOwner, null, currentUserInfo.UserID);
            KeyVauleDataInfo VIPInterestIDKeyValue     = new KeyVauleDataInfo("VIPInterestID", "1", vipInterestID, websiteOwner, null, currentUserInfo.UserID);
            JuActivityInfo   juAct    = new JuActivityInfo();
            BLLJuActivity    bllJuAct = new BLLJuActivity();

            if (!string.IsNullOrWhiteSpace(vipInterestID) && vipInterestID != "0")
            {
                juAct = bllJuAct.GetJuActivity(Convert.ToInt32(vipInterestID));
                juAct.ActivityDescription = vipInterestDescription;
                if (!bllJuAct.PutArticle(juAct))
                {
                    resp.Status = -1;
                    resp.Msg    = "提交VIP权益失败";
                    return(Common.JSONHelper.ObjectToJson(resp));
                }
            }
            else if (!string.IsNullOrWhiteSpace(vipInterestDescription))
            {
                vipInterestID = bllJuAct.GetGUID(TransacType.CommAdd);
                VIPInterestIDKeyValue.DataValue = vipInterestID;

                juAct.JuActivityID        = Convert.ToInt32(vipInterestID);
                juAct.ActivityName        = "VIP权益";
                juAct.ArticleType         = "ConfigContent";
                juAct.UserID              = currentUserInfo.UserID;
                juAct.WebsiteOwner        = websiteOwner;
                juAct.CreateDate          = DateTime.Now;
                juAct.ActivityDescription = vipInterestDescription;
                if (!bllJuAct.Add(juAct))
                {
                    resp.Status = -1;
                    resp.Msg    = "提交VIP权益失败";
                    return(Common.JSONHelper.ObjectToJson(resp));
                }
            }

            BLLTransaction tran = new BLLTransaction();

            if (bllkeyValueData.PutDataValue(rechargeKeyValue, tran) &&
                bllkeyValueData.PutDataValue(sendNoticePriceValue, tran) &&
                bllkeyValueData.PutDataValue(minScoreValue, tran) &&
                bllkeyValueData.PutDataValue(minWithdrawCashScoreValue, tran) &&
                bllkeyValueData.PutDataValue(VIPPriceKeyValue, tran) &&
                bllkeyValueData.PutDataValue(VIPPrice0KeyValue, tran) &&
                bllkeyValueData.PutDataValue(VIPDatelongKeyValue, tran) &&
                bllkeyValueData.PutDataValue(VIPInterestIDKeyValue, tran))
            {
                tran.Commit();
                resp.Status = 1;
                resp.Msg    = "提交成功";
            }
            else
            {
                tran.Rollback();
                resp.Status = -1;
                resp.Msg    = "提交失败";
            }
            return(Common.JSONHelper.ObjectToJson(resp));
        }
コード例 #25
0
        public void ProcessRequest(HttpContext context)
        {
            RequestModel requestModel = new RequestModel();

            try
            {
                requestModel = JsonConvert.DeserializeObject <RequestModel>(context.Request["data"]);
            }
            catch (Exception ex)
            {
                resp.errcode = (int)APIErrCode.OperateFail;
                resp.errmsg  = ex.Message;
                bllQuestion.ContextResponse(context, resp);
                return;
            }
            if (string.IsNullOrWhiteSpace(requestModel.questionnaire_name))
            {
                resp.errcode = (int)APIErrCode.PrimaryKeyIncomplete;
                resp.errmsg  = "请输入问卷名称";
                bllQuestion.ContextResponse(context, resp);
                return;
            }
            if (requestModel.question_list == null || requestModel.question_list.Count <= 0)
            {
                resp.errcode = (int)APIErrCode.PrimaryKeyIncomplete;
                resp.errmsg  = "请至少添加一个问题";
                bllQuestion.ContextResponse(context, resp);
                return;
            }
            foreach (var item in requestModel.question_list)
            {
                if (item.question_type != 2 && (item.answer_list == null || item.answer_list.Count <= 0))
                {
                    resp.errcode = (int)APIErrCode.PrimaryKeyIncomplete;
                    resp.errmsg  = "选择题至少需要一个选项";
                    bllQuestion.ContextResponse(context, resp);
                    return;
                }
            }

            BLLTransaction tran = new BLLTransaction();//事务

            try
            {
                Questionnaire QuestionnaireModel = new Questionnaire();//数据库问卷表模型
                QuestionnaireModel.QuestionnaireID       = int.Parse(bllQuestion.GetGUID(TransacType.AddQuestionnaire));
                QuestionnaireModel.QuestionnaireName     = requestModel.questionnaire_name;
                QuestionnaireModel.QuestionnaireContent  = requestModel.questionnaire_content;
                QuestionnaireModel.QuestionnaireStopDate = requestModel.questionnaire_stopdate;
                QuestionnaireModel.QuestionnaireVisible  = requestModel.questionnaire_visible;
                QuestionnaireModel.QuestionnaireImage    = requestModel.questionnaire_image;
                QuestionnaireModel.QuestionnaireSummary  = requestModel.questionnaire_summary;
                QuestionnaireModel.WebsiteOwner          = bllQuestion.WebsiteOwner;
                QuestionnaireModel.InsertDate            = DateTime.Now;
                QuestionnaireModel.AddScore = requestModel.add_score;

                if (!bllQuestion.Add(QuestionnaireModel, tran))//添加问卷表
                {
                    tran.Rollback();
                    resp.errcode = (int)APIErrCode.OperateFail;
                    resp.errmsg  = "添加问卷失败";
                    bllQuestion.ContextResponse(context, resp);
                    return;
                }
                foreach (var item in requestModel.question_list)//添加问题表
                {
                    ZentCloud.BLLJIMP.Model.Question question = new ZentCloud.BLLJIMP.Model.Question();
                    question.QuestionID      = int.Parse(bllQuestion.GetGUID(TransacType.AddQuestion));
                    question.QuestionnaireID = QuestionnaireModel.QuestionnaireID;
                    question.QuestionName    = item.question_name;
                    question.QuestionType    = item.question_type;
                    question.IsRequired      = item.is_required;
                    if (!bllQuestion.Add(question, tran))
                    {
                        tran.Rollback();
                        resp.errcode = (int)APIErrCode.OperateFail;
                        resp.errmsg  = "添加问题失败";
                        bllQuestion.ContextResponse(context, resp);
                        return;
                    }
                    foreach (var AnswerItem in item.answer_list)
                    {
                        Answer answer = new Answer();
                        answer.AnswerID        = int.Parse(bllQuestion.GetGUID(TransacType.AddAnswer));
                        answer.AnswerName      = AnswerItem.answer_name;
                        answer.IsCorrect       = AnswerItem.is_correct;
                        answer.QuestionID      = question.QuestionID;
                        answer.QuestionnaireID = QuestionnaireModel.QuestionnaireID;
                        if (!bllQuestion.Add(answer, tran))
                        {
                            tran.Rollback();
                            resp.errcode = (int)APIErrCode.OperateFail;
                            resp.errmsg  = "添加选项失败";
                            bllQuestion.ContextResponse(context, resp);
                            return;
                        }
                    }
                }


                tran.Commit();
                resp.isSuccess = true;
                resp.errcode   = (int)APIErrCode.IsSuccess;
            }
            catch (Exception ex)
            {
                tran.Rollback();
                resp.errcode = (int)APIErrCode.OperateFail;
                resp.errmsg  = ex.Message;
            }
            bllQuestion.ContextResponse(context, resp);
        }
コード例 #26
0
        public void ProcessRequest(HttpContext context)
        {
            UserInfo tUser = new UserInfo();

            tUser                 = bllUser.ConvertRequestToModel <UserInfo>(tUser);
            tUser.UserType        = 2;
            tUser.RegIP           = ZentCloud.Common.MySpider.GetClientIP();
            tUser.Regtime         = DateTime.Now;
            tUser.LoginTotalCount = 0;
            tUser.IsSubAccount    = "1";
            tUser.WebsiteOwner    = bllUser.WebsiteOwner;
            tUser.LastLoginDate   = DateTime.Now;
            if (string.IsNullOrWhiteSpace(tUser.UserID) || string.IsNullOrWhiteSpace(tUser.Password))
            {
                apiResp.code = (int)APIErrCode.PrimaryKeyIncomplete;
                apiResp.msg  = "账户和密码不能为空";
                bllUser.ContextResponse(context, apiResp);
                return;
            }
            if (!string.IsNullOrWhiteSpace(tUser.Phone) && !ZentCloud.Common.MyRegex.PhoneNumLogicJudge(tUser.Phone))
            {
                apiResp.code = (int)APIErrCode.PrimaryKeyIncomplete;
                apiResp.msg  = "请输入正确的手机号码";
                bllUser.ContextResponse(context, apiResp);
                return;
            }
            if (!string.IsNullOrWhiteSpace(tUser.Phone3) && !ZentCloud.Common.MyRegex.PhoneNumLogicJudge(tUser.Phone3))
            {
                apiResp.code = (int)APIErrCode.PrimaryKeyIncomplete;
                apiResp.msg  = "请输入正确的手机号码";
                bllUser.ContextResponse(context, apiResp);
                return;
            }
            UserInfo oUser = bllUser.GetUserInfo(tUser.UserID, bllUser.WebsiteOwner);

            if (oUser != null)
            {
                apiResp.code = (int)APIErrCode.OperateFail;
                apiResp.msg  = "账户名已存在";
                bllUser.ContextResponse(context, apiResp);
                return;
            }
            if (!string.IsNullOrWhiteSpace(tUser.Phone))
            {
                oUser = bllUser.GetUserInfoByPhone(tUser.Phone, bllUser.WebsiteOwner);
                if (oUser != null)
                {
                    apiResp.code = (int)APIErrCode.OperateFail;
                    apiResp.msg  = "联系手机,已有账号";
                    bllUser.ContextResponse(context, apiResp);
                    return;
                }
            }
            if (!string.IsNullOrWhiteSpace(tUser.Email) && !ZentCloud.Common.MyRegex.EmailLogicJudge(tUser.Email))
            {
                apiResp.code = (int)APIErrCode.PrimaryKeyIncomplete;
                apiResp.msg  = "请输入正确的邮箱地址";
                bllUser.ContextResponse(context, apiResp);
                return;
            }
            if (!tUser.PermissionGroupID.HasValue)
            {
                apiResp.code = (int)APIErrCode.PrimaryKeyIncomplete;
                apiResp.msg  = "请选择角色";
                bllUser.ContextResponse(context, apiResp);
                return;
            }
            ZentCloud.BLLPermission.Model.PermissionGroupInfo perGroup = bllUser.Get <ZentCloud.BLLPermission.Model.PermissionGroupInfo>(string.Format(" GroupID={0}", tUser.PermissionGroupID));
            if (perGroup.GroupType == 4)
            {
                tUser.DistributionOwner = bllUser.WebsiteOwner;
            }
            BLLTransaction tran = new BLLTransaction();

            if (!bllUser.Add(tUser, tran))
            {
                tran.Rollback();
                apiResp.code = (int)APIErrCode.OperateFail;
                apiResp.msg  = "添加用户出错";
                bllUser.ContextResponse(context, apiResp);
                return;
            }

            var group = new BLLPermission.Model.UserPmsGroupRelationInfo()
            {
                UserID  = tUser.UserID,
                GroupID = tUser.PermissionGroupID.Value
            };

            if (!bllUser.Add(group, tran))//添加权限组
            {
                tran.Rollback();
                apiResp.code = (int)APIErrCode.OperateFail;
                apiResp.msg  = "添加权限组出错";
                bllUser.ContextResponse(context, apiResp);
                return;
            }
            tran.Commit();
            apiResp.code   = (int)APIErrCode.IsSuccess;
            apiResp.status = true;
            apiResp.msg    = "添加完成";
            bllUser.ContextResponse(context, apiResp);
        }
コード例 #27
0
        public void ProcessRequest(HttpContext context)
        {
            string     data = context.Request["data"];
            OrderModel orderRequestModel;//订单模型

            try
            {
                orderRequestModel = JSONHelper.JsonToModel <OrderModel>(data);
            }
            catch (Exception ex)
            {
                apiResp.msg  = "提交格式错误";
                apiResp.code = (int)APIErrCode.OperateFail;
                bllMall.ContextResponse(context, apiResp);
                return;
            }

            WXMallProductInfo productInfo = bllMall.GetProduct(orderRequestModel.product_id.ToString());

            if (productInfo == null)
            {
                apiResp.msg  = "记录没有找到";
                apiResp.code = (int)APIErrCode.IsNotFound;
                bllMall.ContextResponse(context, apiResp);
                return;
            }
            WXMallOrderInfo orderInfo = new WXMallOrderInfo();//订单表

            orderInfo.ArticleCategoryType = productInfo.ArticleCategoryType;
            orderInfo.InsertDate          = DateTime.Now;
            orderInfo.OrderUserID         = CurrentUserInfo.UserID;
            orderInfo.WebsiteOwner        = bllMall.WebsiteOwner;
            orderInfo.OrderMemo           = orderRequestModel.buyer_memo;
            orderInfo.UseAmount           = orderRequestModel.use_amount;
            if (orderRequestModel.receiver_id == 0)
            {
                orderInfo.Consignee = CurrentUserInfo.TrueName;
                orderInfo.Phone     = CurrentUserInfo.Phone;
            }
            else
            {
                WXConsigneeAddress nUserAddress = bllMall.GetByKey <WXConsigneeAddress>("AutoID", orderRequestModel.receiver_id.ToString());
                orderInfo.Consignee            = nUserAddress.ConsigneeName;
                orderInfo.Phone                = nUserAddress.Phone;
                orderInfo.Address              = nUserAddress.Address;
                orderInfo.ZipCode              = nUserAddress.ZipCode;
                orderInfo.ReceiverProvince     = nUserAddress.Province;
                orderInfo.ReceiverProvinceCode = nUserAddress.ProvinceCode;
                orderInfo.ReceiverCity         = nUserAddress.City;
                orderInfo.ReceiverCityCode     = nUserAddress.CityCode;
                orderInfo.ReceiverDist         = nUserAddress.Dist;
                orderInfo.ReceiverDistCode     = nUserAddress.DistCode;
            }

            orderInfo.Transport_Fee = 0;
            orderInfo.Status        = "待付款";
            if (orderRequestModel.pay_type == "WEIXIN")//微信支付
            {
                orderInfo.PaymentType = 2;
            }
            else if (orderRequestModel.pay_type == "ALIPAY")//支付宝支付
            {
                orderInfo.PaymentType = 1;
            }
            if (orderRequestModel.skus == null || orderRequestModel.skus.Count == 0)
            {
                apiResp.msg  = "Skus不能为空";
                apiResp.code = (int)APIErrCode.OperateFail;
                bllMall.ContextResponse(context, apiResp);
                return;
            }

            #region 商品检查 订单详情生成
            //订单详情
            List <WXMallOrderDetailsInfo> detailList      = new List <WXMallOrderDetailsInfo>(); //主商品订单明细
            List <WXMallOrderDetailsInfo> detailAddedList = new List <WXMallOrderDetailsInfo>(); //增值服务订单明细
            orderRequestModel.skus = orderRequestModel.skus.Distinct().ToList();
            #region 购买的商品
            foreach (var sku in orderRequestModel.skus)
            {
                ProductSku             productSku  = bllMall.GetProductSku(sku.sku_id);
                WXMallOrderDetailsInfo detailModel = new WXMallOrderDetailsInfo();
                detailModel.TotalCount          = sku.count;
                detailModel.OrderPrice          = bllMall.GetSkuPrice(productSku);
                detailModel.SkuId               = productSku.SkuId;
                detailModel.ArticleCategoryType = productSku.ArticleCategoryType;
                if (productSku.ArticleCategoryType.Contains("Added"))
                {
                    WXMallProductInfo rproductInfo = bllMall.GetProduct(productSku.ProductId.ToString());
                    detailModel.PID         = rproductInfo.PID;
                    detailModel.ProductName = rproductInfo.PName;
                    detailModel.Unit        = rproductInfo.Unit;
                    detailAddedList.Add(detailModel);
                }
                else
                {
                    detailModel.PID         = productInfo.PID;
                    detailModel.ProductName = productInfo.PName;
                    detailModel.StartDate   = sku.start_date;
                    detailModel.EndDate     = sku.end_date;
                    detailModel.Unit        = productInfo.Unit;
                    detailList.Add(detailModel);
                }
            }
            #endregion
            if (detailList.Count == 0)
            {
                apiResp.msg  = "请选择预约时间";
                apiResp.code = (int)APIErrCode.OperateFail;
                bllMall.ContextResponse(context, apiResp);
                return;
            }
            //已有订单详情
            List <WXMallOrderDetailsInfo> oDetailList = bllMall.GetOrderDetailsList(null, productInfo.PID, productInfo.ArticleCategoryType, detailList.Min(p => p.StartDate), detailList.Max(p => p.EndDate));
            List <string> hasOrderID_List             = new List <string>();
            string        hasOrderIDs = "";
            int           maxCount    = productInfo.Stock;
            foreach (var item in detailList)
            {
                List <WXMallOrderDetailsInfo> hasOrderDetailList = oDetailList.Where(p => !((item.StartDate >= p.EndDate && item.EndDate > p.EndDate) || (item.StartDate < p.StartDate && item.EndDate <= p.StartDate))).ToList();
                if (hasOrderDetailList.Count >= maxCount)
                {
                    hasOrderID_List.AddRange(hasOrderDetailList.Select(p => p.OrderID).Distinct());
                }
            }
            if (hasOrderID_List.Count > 0)
            {
                hasOrderID_List = hasOrderID_List.Distinct().ToList();
                hasOrderIDs     = MyStringHelper.ListToStr(hasOrderID_List, "'", ",");
                int tempCount = 0;
                List <WXMallOrderInfo> tempList = bllMall.GetOrderList(0, 1, "", out tempCount, "预约成功", null, null, null,
                                                                       null, null, null, null, null, null, null, orderInfo.ArticleCategoryType, hasOrderIDs);
                if (tempCount >= maxCount)
                {
                    apiResp.msg  = "所选时间已有成功的预约";
                    apiResp.code = (int)APIErrCode.OperateFail;
                    bllMall.ContextResponse(context, apiResp);
                    return;
                }
            }
            //增值服务合并到主订单明细列表
            detailList.AddRange(detailAddedList);
            //合计计算
            orderInfo.Product_Fee = detailList.Sum(p => p.OrderPrice * p.TotalCount).Value;

            #region 积分计算

            decimal scoreExchangeAmount = 0;//积分抵扣的金额
            //积分计算
            if (orderRequestModel.use_score > 0 && orderInfo.Product_Fee > 0)
            {
                orderInfo.UseScore = orderRequestModel.use_score;
                if (CurrentUserInfo.TotalScore < orderRequestModel.use_score)
                {
                    apiResp.msg  = "积分不足";
                    apiResp.code = (int)APIErrCode.OperateFail;
                    bllMall.ContextResponse(context, apiResp);
                    return;
                }
                ScoreConfig scoreConfig = bllScore.GetScoreConfig();
                scoreExchangeAmount = Math.Round(orderRequestModel.use_score / (scoreConfig.ExchangeScore / scoreConfig.ExchangeAmount), 2);
            }
            //积分计算
            #endregion

            #region 使用账户余额
            if (orderRequestModel.use_amount > 0)
            {
                if (!bllMall.IsEnableAccountAmountPay())
                {
                    apiResp.msg  = "未开启余额支付";
                    apiResp.code = (int)APIErrCode.OperateFail;
                    bllMall.ContextResponse(context, apiResp);
                    return;
                }
                if (CurrentUserInfo.AccountAmount < orderRequestModel.use_amount)
                {
                    apiResp.msg  = "您的账户余额不足";
                    apiResp.code = (int)APIErrCode.OperateFail;
                    bllMall.ContextResponse(context, apiResp);
                    return;
                }
            }
            #endregion

            orderInfo.TotalAmount   = orderInfo.Product_Fee + orderInfo.Transport_Fee;
            orderInfo.TotalAmount  -= scoreExchangeAmount;                             //积分优惠金额
            orderInfo.TotalAmount  -= orderRequestModel.use_amount;                    //余额抵扣金额
            orderInfo.PayableAmount = orderInfo.TotalAmount - orderInfo.Transport_Fee; //应付金额
            if ((orderInfo.Product_Fee + orderInfo.Transport_Fee - scoreExchangeAmount) < orderInfo.TotalAmount)
            {
                apiResp.msg  = "积分兑换金额不能大于订单总金额,请减少积分兑换";
                apiResp.code = (int)APIErrCode.OperateFail;
                bllMall.ContextResponse(context, apiResp);
                return;
            }

            if (orderInfo.TotalAmount < 0)
            {
                orderInfo.TotalAmount = 0;
            }
            if (orderInfo.TotalAmount == 0 && orderInfo.UseScore == 0)
            {
                orderInfo.Status = "待审核";
            }
            else if (orderInfo.TotalAmount == 0 && (orderInfo.UseAmount > 0 || orderInfo.UseScore > 0))
            {
                orderInfo.PaymentStatus = 1;
                orderInfo.PayTime       = DateTime.Now;
                orderInfo.Status        = "预约成功";
            }

            #endregion

            //生成订单ID
            orderInfo.OrderID = bllMall.GetGUID(BLLJIMP.TransacType.AddMallOrder);
            BLLTransaction tran = new BLLTransaction();
            if (!this.bllMall.Add(orderInfo, tran))
            {
                tran.Rollback();
                apiResp.msg  = "提交失败";
                apiResp.code = (int)APIErrCode.OperateFail;
                bllMall.ContextResponse(context, apiResp);
                return;
            }
            foreach (var item in detailList)
            {
                item.OrderID = orderInfo.OrderID;
                if (!this.bllMall.Add(item, tran))
                {
                    tran.Rollback();
                    apiResp.msg  = "提交失败";
                    apiResp.code = (int)APIErrCode.OperateFail;
                    bllMall.ContextResponse(context, apiResp);
                    return;
                }
            }

            #region 积分抵扣
            //积分扣除
            if (orderRequestModel.use_score > 0)
            {
                CurrentUserInfo.TotalScore -= orderRequestModel.use_score;
                if (bllMall.Update(CurrentUserInfo,
                                   string.Format(" TotalScore-={0}", orderRequestModel.use_score),
                                   string.Format(" AutoID={0}", CurrentUserInfo.AutoID)
                                   , tran) < 0)
                {
                    tran.Rollback();
                    apiResp.msg  = "更新用户积分失败";
                    apiResp.code = (int)APIErrCode.OperateFail;
                    bllMall.ContextResponse(context, apiResp);
                    return;
                }

                //积分记录
                UserScoreDetailsInfo scoreRecord = new UserScoreDetailsInfo();
                scoreRecord.AddTime      = DateTime.Now;
                scoreRecord.Score        = -orderRequestModel.use_score;
                scoreRecord.TotalScore   = CurrentUserInfo.TotalScore;
                scoreRecord.ScoreType    = "OrderSubmit";
                scoreRecord.UserID       = CurrentUserInfo.UserID;
                scoreRecord.AddNote      = "预约-下单使用积分";
                scoreRecord.RelationID   = orderInfo.OrderID;
                scoreRecord.WebSiteOwner = CurrentUserInfo.WebsiteOwner;
                if (!bllMall.Add(scoreRecord))
                {
                    tran.Rollback();
                    apiResp.msg  = "插入积分记录失败";
                    apiResp.code = (int)APIErrCode.OperateFail;
                    bllMall.ContextResponse(context, apiResp);
                    return;
                }
            }
            //积分扣除
            #endregion

            #region 余额抵扣

            if (orderRequestModel.use_amount > 0 && bllMall.IsEnableAccountAmountPay())
            {
                CurrentUserInfo.AccountAmount -= orderRequestModel.use_amount;
                if (bllMall.Update(CurrentUserInfo, string.Format(" AccountAmount={0}", CurrentUserInfo.AccountAmount), string.Format(" AutoID={0}", CurrentUserInfo.AutoID)) < 0)
                {
                    tran.Rollback();
                    apiResp.msg  = "更新用户余额失败";
                    apiResp.code = (int)APIErrCode.OperateFail;
                    bllMall.ContextResponse(context, apiResp);
                    return;
                }


                UserScoreDetailsInfo scoreRecord = new UserScoreDetailsInfo();
                scoreRecord.AddTime      = DateTime.Now;
                scoreRecord.Score        = -(double)orderRequestModel.use_amount;
                scoreRecord.TotalScore   = (double)CurrentUserInfo.AccountAmount;
                scoreRecord.UserID       = CurrentUserInfo.UserID;
                scoreRecord.AddNote      = "账户余额变动-下单使用余额";
                scoreRecord.RelationID   = orderInfo.OrderID;
                scoreRecord.WebSiteOwner = bllMall.WebsiteOwner;
                scoreRecord.ScoreType    = "AccountAmount";
                if (!bllMall.Add(scoreRecord))
                {
                    tran.Rollback();
                    apiResp.code = (int)APIErrCode.OperateFail;
                    apiResp.msg  = "插入余额记录失败";
                    context.Response.Write(ZentCloud.Common.JSONHelper.ObjectToJson(apiResp));
                    return;
                }

                UserCreditAcountDetails record = new UserCreditAcountDetails();
                record.WebsiteOwner = bllMall.WebsiteOwner;
                record.Operator     = CurrentUserInfo.UserID;
                record.UserID       = CurrentUserInfo.UserID;
                record.CreditAcount = -orderRequestModel.use_amount;
                record.SysType      = "AccountAmount";
                record.AddTime      = DateTime.Now;
                record.AddNote      = "账户余额变动-" + orderRequestModel.use_amount;
                if (!bllMall.Add(record))
                {
                    tran.Rollback();

                    apiResp.msg  = "插入余额记录失败";
                    apiResp.code = (int)APIErrCode.OperateFail;
                    bllMall.ContextResponse(context, apiResp);
                    return;
                }
            }


            #endregion
            tran.Commit();//提交订单事务

            if (orderInfo.Status == "预约成功")
            {
                int tempCount = 0;
                if (string.IsNullOrWhiteSpace(hasOrderIDs))
                {
                    hasOrderIDs = "'0'";
                }
                List <WXMallOrderInfo> tempList = bllMall.GetOrderList(0, 1, "", out tempCount, "预约成功", null, null, null,
                                                                       null, null, null, null, null, null, null, orderInfo.ArticleCategoryType, hasOrderIDs);
                tempCount = tempCount + 1; //加上当前订单的数量
                if (tempCount >= maxCount)
                {
                    tempList = bllMall.GetColOrderListInStatus("'待付款','待审核'", hasOrderIDs, "OrderID,OrderUserID,UseScore", bllMall.WebsiteOwner);
                    if (tempList.Count > 0)
                    {
                        string stopOrderIds = MyStringHelper.ListToStr(tempList.Select(p => p.OrderID).ToList(), "'", ",");
                        tempList = tempList.Where(p => p.UseScore > 0).ToList();
                        foreach (var item in tempList)
                        {
                            UserInfo orderUserInfo = bllUser.GetUserInfo(orderInfo.OrderUserID, bllMall.WebsiteOwner);//下单用户信息
                            if (orderUserInfo == null)
                            {
                                continue;
                            }
                            orderUserInfo.TotalScore += item.UseScore;
                            if (bllMall.Update(orderUserInfo, string.Format(" TotalScore+={0}", item.UseScore),
                                               string.Format(" UserID='{0}'", item.OrderUserID)) > 0)
                            {
                                UserScoreDetailsInfo scoreRecord = new UserScoreDetailsInfo();
                                scoreRecord.AddTime      = DateTime.Now;
                                scoreRecord.Score        = item.UseScore;
                                scoreRecord.TotalScore   = orderUserInfo.TotalScore;
                                scoreRecord.ScoreType    = "OrderCancel";
                                scoreRecord.UserID       = item.OrderUserID;
                                scoreRecord.RelationID   = item.OrderID;
                                scoreRecord.AddNote      = "预约-订单失败返还积分";
                                scoreRecord.WebSiteOwner = item.WebsiteOwner;
                                bllMall.Add(scoreRecord);
                            }
                        }
                        bllMall.Update(new WXMallOrderInfo(),
                                       string.Format("Status='{0}'", "预约失败"),
                                       string.Format("OrderID In ({0}) and WebsiteOwner='{1}'", stopOrderIds, bllMall.WebsiteOwner));
                    }
                }
            }


            //预约通知
            bllWeiXin.SendTemplateMessageNotifyComm(CurrentUserInfo, orderInfo.Status, string.Format("预约:{2}\\n订单号:{0}\\n订单金额:{1}元", orderInfo.OrderID, orderInfo.TotalAmount, productInfo.PName));

            apiResp.result = new
            {
                order_id = orderInfo.OrderID
            };
            apiResp.msg    = "提交完成";
            apiResp.code   = (int)APIErrCode.IsSuccess;
            apiResp.status = true;
            bllMall.ContextResponse(context, apiResp);
        }
コード例 #28
0
ファイル: Delete.ashx.cs プロジェクト: uvbs/mmp
        public void ProcessRequest(HttpContext context)
        {
            string id          = context.Request["id"];
            string forceDelete = context.Request["force_delete"];

            //force_delete等于1时,则不管是否存在中奖记录,进行强制删除
            if (forceDelete != "1")
            {
                if (bllLottery.GetCountByKey <WXLotteryRecordV1>("LotteryId", id) > 0)
                {
                    resp.errcode = (int)APIErrCode.LotteryHaveRecord;
                    resp.errmsg  = string.Format("已经有人中奖,不能删除");
                    bllLottery.ContextResponse(context, resp);
                    return;
                }
            }
            BLLTransaction tran = new BLLTransaction();

            try
            {
                if (bllLottery.DeleteByKey <WXLotteryV1>("LotteryID", id, tran) == -1)
                {
                    tran.Rollback();
                    resp.errcode = (int)APIErrCode.OperateFail;
                    resp.errmsg  = "删除活动主表失败";
                    bllLottery.ContextResponse(context, resp);
                    return;
                }

                if (bllLottery.DeleteByKey <WXAwardsV1>("LotteryId", id, tran) == -1)
                {
                    tran.Rollback();
                    resp.errcode = (int)APIErrCode.OperateFail;
                    resp.errmsg  = "删除奖项失败";
                    bllLottery.ContextResponse(context, resp);
                    return;
                }
                if (bllLottery.DeleteByKey <WXLotteryRecordV1>("LotteryId", id, tran) == -1)
                {
                    tran.Rollback();
                    resp.errcode = (int)APIErrCode.OperateFail;
                    resp.errmsg  = "删除中奖记录失败";
                    bllLottery.ContextResponse(context, resp);
                    return;
                }
                if (bllLottery.DeleteByKey <WXLotteryLogV1>("LotteryId", id, tran) == -1)
                {
                    tran.Rollback();
                    resp.errcode = (int)APIErrCode.OperateFail;
                    resp.errmsg  = "删除抽奖记录失败";
                    bllLottery.ContextResponse(context, resp);
                    return;
                }
                if (bllLottery.DeleteByKey <WXLotteryWinningDataV1>("LotteryId", id, tran) == -1)
                {
                    tran.Rollback();
                    resp.errcode = (int)APIErrCode.OperateFail;
                    resp.errmsg  = "删除默认中奖设置失败";
                    bllLottery.ContextResponse(context, resp);
                    return;
                }
                tran.Commit();
                resp.isSuccess = true;
            }
            catch (Exception ex)
            {
                tran.Rollback();
                resp.errcode = (int)APIErrCode.OperateFail;
                resp.errmsg  = ex.Message;
            }
            bllLottery.ContextResponse(context, resp);
        }
コード例 #29
0
ファイル: BLLQuestion.cs プロジェクト: uvbs/mmp
        /// <summary>
        /// 提交答题数据
        /// </summary>
        /// <param name="postList">提交的答题数据</param>
        /// <param name="QuestionnaireIDStr">当前问卷ID</param>
        /// <param name="userId">用户ID</param>
        /// <param name="websiteOwner">站点ID</param>
        /// <param name="correctCount">正确数</param>
        /// <param name="msg">信息</param>
        /// <returns></returns>
        public bool PostQuestion(List <QuestionPostModel> postList, int questionnaireSetID, string userId, string websiteOwner, string userHostAddress,
                                 out int correctCount, out string msg, int questionnaireId)
        {
            correctCount = 0;
            msg          = "";
            List <QuestionnaireRecordDetail> listRecordDetail = new List <QuestionnaireRecordDetail>();
            QuestionnaireRecord record = new QuestionnaireRecord();

            #region 检查 格式化答案
            if (postList == null || postList.Count == 0)
            {
                msg = "请提交答案";
                return(false);
            }

            record.QuestionnaireID = questionnaireId;
            record.UserId          = userId;
            record.WebsiteOwner    = websiteOwner;
            record.AnswerCount     = postList.Count;
            record.InsertDate      = DateTime.Now;
            record.IP = userHostAddress;
            record.QuestionnaireSetID = questionnaireSetID;
            try
            {
                foreach (var item in postList)
                {
                    if (string.IsNullOrWhiteSpace(item.Answer))
                    {
                        continue;
                    }
                    Question nQuestion = Get <Question>(string.Format("QuestionID={0}", item.QuestionID));
                    if (nQuestion == null)
                    {
                        continue;
                    }
                    if (record.QuestionnaireID == 0)
                    {
                        record.QuestionnaireID = nQuestion.QuestionnaireID;
                    }
                    if (nQuestion.QuestionType == 0)
                    {
                        listRecordDetail.Add(new QuestionnaireRecordDetail(userId, questionnaireId, nQuestion.QuestionID, Convert.ToInt32(item.Answer), null, questionnaireSetID));
                        Answer nAnswer = Get <Answer>(string.Format("AnswerID={0}", item.Answer));
                        if (nAnswer == null)
                        {
                            continue;
                        }
                        if (nAnswer.IsCorrect == 1)
                        {
                            correctCount++;
                        }
                    }
                    else if (nQuestion.QuestionType == 1)
                    {
                        List <int> pAnswers = item.Answer.Split('|').Select(p => Convert.ToInt32(p)).ToList();
                        foreach (var nitem in pAnswers)
                        {
                            listRecordDetail.Add(new QuestionnaireRecordDetail(userId, questionnaireId, nQuestion.QuestionID, nitem, null, questionnaireSetID));
                        }
                        string pAnswerIDs = Common.MyStringHelper.ListToStr(pAnswers.OrderBy(p => p).ToList(), "", ",");
                        string nAnswerIDs = Common.MyStringHelper.ListToStr(GetList <Answer>(string.Format("QuestionID={0} AND IsCorrect=1 ", item.QuestionID))
                                                                            .Select(p => p.AnswerID).OrderBy(p => p).ToList(), "", ",");

                        if (pAnswerIDs == nAnswerIDs)
                        {
                            correctCount++;
                        }
                    }
                    else if (nQuestion.QuestionType == 2)
                    {
                        listRecordDetail.Add(new QuestionnaireRecordDetail(userId, questionnaireId, nQuestion.QuestionID, 0, item.Answer, questionnaireSetID));
                    }
                }
                record.CorrectCount = correctCount;
            }
            catch (Exception ex)
            {
                msg = "格式化提交答案出错";
                return(false);
            }
            #endregion

            BLLTransaction tran = new BLLTransaction();//事务
            try
            {
                record.RecordID = Convert.ToInt64(GetRecordGUID());
                if (!Add(record, tran))
                {
                    tran.Rollback();
                    msg = "提交数据库出错";
                    return(false);
                }
                foreach (var item in listRecordDetail)
                {
                    item.RecordID = record.RecordID;
                    if (!Add(item, tran))
                    {
                        tran.Rollback();
                        msg = "提交数据库出错";
                        return(false);
                    }
                }
            }
            catch (Exception ex)
            {
                tran.Rollback();
                msg = "提交数据库出错";
                return(false);
            }
            tran.Commit();
            msg = "提交完成";
            return(true);
        }
コード例 #30
0
ファイル: BLLPermission.cs プロジェクト: uvbs/mmp
        /// <summary>
        /// 添加权限组
        /// </summary>
        /// <param name="groupInfo"></param>
        /// <param name="relations"></param>
        /// <returns></returns>
        public void UpdateGroupInfo(PermissionGroupInfo groupInfo, List <long> pmsIds, BLLTransaction tran)
        {
            PermissionGroupInfo tempOld = Get <PermissionGroupInfo>(string.Format(" GroupName='{0}' AND WebsiteOwner='{1}' "
                                                                                  , groupInfo.GroupName, groupInfo.WebsiteOwner));

            if (tempOld != null && tempOld.GroupID != groupInfo.GroupID)
            {
                throw new Exception("权限组名称已被使用");
            }
            if (!Update(groupInfo, tran))
            {
                throw new Exception("编辑权限组失败");
            }
            List <PermissionRelationInfo> oldList = GetList <PermissionRelationInfo>(
                string.Format(" RelationType=0 AND RelationID='{0}' ", groupInfo.GroupID));

            foreach (PermissionRelationInfo item in oldList)
            {
                if (!pmsIds.Exists(p => p == item.PermissionID))
                {
                    if (Delete(item, tran) == -1)
                    {
                        throw new Exception("删除旧权限关系失败失败");
                    }
                }
            }
            foreach (long pmsId in pmsIds)
            {
                if (!oldList.Exists(p => p.PermissionID == pmsId))
                {
                    PermissionRelationInfo relation = new PermissionRelationInfo();
                    relation.RelationID   = groupInfo.GroupID.ToString();
                    relation.PermissionID = pmsId;
                    relation.RelationType = 0;
                    if (!Add(relation, tran))
                    {
                        throw new Exception("添加新权限关系失败");
                    }
                }
            }
        }