示例#1
0
        /// <summary>
        /// 根据模板类型返回填充模板内容(餐饮)
        /// </summary>
        /// <param name="OrderId"></param>
        /// <param name="sendMsgType"></param>
        /// <returns></returns>
        public object getTemplateMessageData(int OrderId, SendTemplateMessageTypeEnum sendMsgType)
        {
            StoreGoodsOrder       model    = GetModel(OrderId) ?? new StoreGoodsOrder();
            List <StoreGoodsCart> modelDtl = StoreGoodsCartBLL.SingleModel.GetList($" GoodsOrderId = {model.Id} ") ?? new List <StoreGoodsCart>();

            string            modelDtlName   = "";
            string            goodsIds       = string.Join(",", modelDtl.Select(s => s.GoodsId).Distinct());
            List <StoreGoods> storeGoodsList = StoreGoodsBLL.SingleModel.GetListByIds(goodsIds);

            modelDtl.ForEach(x =>
            {
                StoreGoods good = storeGoodsList?.FirstOrDefault(f => f.Id == x.GoodsId) ?? new StoreGoods();
                x.goodsMsg      = good;
            });
            modelDtlName = string.Join("+", modelDtl.Select(x => x.goodsMsg.GoodsName));

            //店名
            string           storeName  = "";
            Store            stroe      = StoreBLL.SingleModel.GetModel(model.StoreId) ?? new Store();
            List <ConfParam> paramslist = ConfParamBLL.SingleModel.GetListByRId(stroe.appId);
            ConfParam        cinfo      = paramslist?.Where(w => w.Param == "nparam").FirstOrDefault();

            if (cinfo != null)
            {
                storeName = cinfo.Value;
            }

            object postData = new object();

            switch (sendMsgType)
            {
            case SendTemplateMessageTypeEnum.电商订单支付成功通知:
                postData = new
                {
                    keyword1 = new { value = model.OrderNum, color = "#000000" },
                    keyword2 = new { value = model.CreateDateStr, color = "#000000" },
                    keyword3 = new { value = modelDtlName, color = "#000000" },
                    keyword4 = new { value = model.PayDateStr, color = "#000000" },
                    keyword5 = new { value = Enum.GetName(typeof(miniAppBuyMode), model.buyMode), color = "#000000" },
                    keyword6 = new { value = model.BuyPriceStr, color = "#000000" },
                    keyword7 = new { value = Enum.GetName(typeof(OrderState), model.State), color = "#000000" },
                };
                break;

            case SendTemplateMessageTypeEnum.电商订单配送通知:
                postData = new
                {
                    keyword1 = new { value = model.CreateDateStr, color = "#000000" },
                    keyword2 = new { value = storeName, color = "#000000" },
                    keyword3 = new { value = model.OrderNum, color = "#000000" },
                    keyword4 = new { value = model.Address, color = "#000000" },
                    keyword5 = new { value = model.DistributeDateStr, color = "#000000" },
                    keyword6 = new { value = modelDtlName, color = "#000000" },
                    keyword7 = new { value = Enum.GetName(typeof(OrderState), model.State), color = "#000000" },
                };
                break;
            }
            return(postData);
        }
示例#2
0
        public ActionResult Config(int Id)
        {
            if (dzaccount == null)
            {
                return(Redirect("/dzhome/login"));
            }
            if (Id <= 0)
            {
                return(View("PageError", new Return_Msg()
                {
                    Msg = "参数错误!", code = "500"
                }));
            }
            ViewBag.rappId = Id;

            //小程序广告图
            ViewBag.shouquan   = 0;
            ViewBag.ImgUrlList = new List <object>();
            ViewBag.ImgUrl     = "";
            ViewBag.XcxName    = "";
            ViewBag.shouquan   = 0;

            List <OpenAuthorizerConfig> umodel = OpenAuthorizerConfigBLL.SingleModel.GetListByaccoundidAndRid(dzaccount.Id.ToString(), Id);

            if (umodel != null && umodel.Count > 0)
            {
                ViewBag.shouquan = 1;
                List <ConfParam> paramslist = ConfParamBLL.SingleModel.GetListByRId(Id);
                //var paramslist = _miniappparamBll.GetModelByappids("'" + umodel[0].appid + "'");


                if (paramslist != null && paramslist.Count > 0)
                {
                    List <object> imgurl  = new List <object>();
                    ConfParam     imginfo = paramslist.Where(w => w.Param == "img").FirstOrDefault();
                    if (imginfo != null)
                    {
                        ViewBag.ImgUrl = imginfo.Value;
                        imgurl.Add(new { id = imginfo.Id, url = imginfo.Value });
                    }

                    ConfParam cinfo = paramslist.Where(w => w.Param == "nparam").FirstOrDefault();
                    if (cinfo != null)
                    {
                        ViewBag.XcxName = cinfo.Value;
                    }

                    ViewBag.ImgUrlList = imgurl;
                }
            }

            return(View());
        }
示例#3
0
        /// <summary>
        /// Initialize sar paprameter related with search region
        /// </summary>
        public void InitializeSearchRegion()
        {
            // Calculate the number of grids in each axis

            /*
             * int gridNumX = (int)((Convert.ToInt32(tbxSRXEnd.Text.Trim()) - Convert.ToInt32(tbxSRXStart.Text.Trim())) / Convert.ToDouble(tbxSRXInterval.Text.Trim())) + 1;
             * int gridNumY = (int)((Convert.ToInt32(tbxSRYEnd.Text.Trim()) - Convert.ToInt32(tbxSRYStart.Text.Trim())) / Convert.ToDouble(tbxSRYInterval.Text.Trim())) + 1;
             * int gridNumZ = (int)((Convert.ToInt32(tbxSRZEnd.Text.Trim()) - Convert.ToInt32(tbxSRZStart.Text.Trim())) / Convert.ToDouble(tbxSRZInterval.Text.Trim())) + 1;
             *
             * for (int i = 0; i < gridNumX; i++)
             * {
             *  SARParameter.GridX.Add(Convert.ToDouble(tbxSRXStart.Text.Trim()) + i * Convert.ToDouble(tbxSRXInterval.Text.Trim()));
             *
             * }
             * //Console.WriteLine("****X" + SARParameter.GridX.Count);
             *
             * for (int i = 0; i < gridNumY; i++)
             * {
             *  SARParameter.GridY.Add(Convert.ToDouble(tbxSRYStart.Text.Trim()) + i * Convert.ToDouble(tbxSRYInterval.Text.Trim()));
             *  //Console.WriteLine("****Y" + SARParameter.GridY[i]);
             * }
             * //Console.WriteLine("****Y" + SARParameter.GridY.Count);
             *
             * for (int i = 0; i < gridNumZ; i++)
             * {
             *  SARParameter.GridZ.Add(Convert.ToDouble(tbxSRZStart.Text.Trim()) + i * Convert.ToDouble(tbxSRZInterval.Text.Trim()));
             *  //Console.WriteLine("****Z" + SARParameter.GridZ[i]);
             * }
             */
            int       xStart    = Convert.ToInt32(tbxSRXStart.Text.Trim());
            int       xEnd      = Convert.ToInt32(tbxSRXEnd.Text.Trim());
            double    xInterval = Convert.ToDouble(tbxSRXInterval.Text.Trim());
            int       yStart    = Convert.ToInt32(tbxSRYStart.Text.Trim());
            int       yEnd      = Convert.ToInt32(tbxSRYEnd.Text.Trim());
            double    yInterval = Convert.ToDouble(tbxSRYInterval.Text.Trim());
            int       zStart    = Convert.ToInt32(tbxSRZStart.Text.Trim());
            int       zEnd      = Convert.ToInt32(tbxSRZEnd.Text.Trim());
            double    zInterval = Convert.ToDouble(tbxSRZInterval.Text.Trim());
            ConfParam confParam = new ConfParam();

            confParam.xStart       = xStart;
            confParam.xEnd         = xEnd;
            confParam.xInterval    = xInterval;
            confParam.yStart       = yStart;
            confParam.yEnd         = yEnd;
            confParam.yInterval    = yInterval;
            confParam.zStart       = zStart;
            confParam.zEnd         = zEnd;
            confParam.zInterval    = zInterval;
            SARParameter.confParam = confParam;
            SARParameter.epcSet.Clear();
        }
示例#4
0
        public ActionResult GetAppConfig(string appid = "")
        {
            if (string.IsNullOrEmpty(appid))
            {
                return(ApiResult(false, "未找到配置"));
            }
            ConfParam config = ConfParamBLL.SingleModel.GetModel($"appid='{appid}' and param='appconfig'");

            if (config == null)
            {
                return(ApiResult(false, "未找到'appconfig'配置"));
            }
            return(ApiResult(true, config.Value));
        }
示例#5
0
        /// <summary>
        /// 门店信息
        /// </summary>
        /// <returns></returns>
        public ActionResult Index()
        {
            int appId = Context.GetRequestInt("appId", 0);

            if (appId <= 0)
            {
                return(View("PageError", new Return_Msg()
                {
                    Msg = "参数错误!", code = "500"
                }));
            }
            ViewBag.appId = appId;
            if (dzaccount == null)
            {
                return(Redirect("/dzhome/login"));
            }
            XcxAppAccountRelation appAcountRelation = XcxAppAccountRelationBLL.SingleModel.GetModelByaccountidAndAppid(appId, dzaccount.Id.ToString());

            if (appAcountRelation == null)
            {
                return(View("PageError", new Return_Msg()
                {
                    Msg = "没有权限!", code = "403"
                }));
            }
            FootBath storeModel = FootBathBLL.SingleModel.GetModel($"appId={appId}");

            if (storeModel != null)
            {
                if (!string.IsNullOrEmpty(storeModel.SwitchConfig))
                {
                    try
                    {
                        storeModel.switchModel = JsonConvert.DeserializeObject <SwitchModel>(storeModel.SwitchConfig);
                    }
                    catch (Exception ex)
                    {
                        log4net.LogHelper.WriteError(this.GetType(), ex);
                        return(View("PageError", new Return_Msg()
                        {
                            Msg = "系统繁忙!", code = "500"
                        }));
                    }
                }
                else
                {
                    storeModel.switchModel = new SwitchModel();
                }
                //店铺Logo
                List <C_Attachment> LogoList = C_AttachmentBLL.SingleModel.GetListByCache(storeModel.Id, (int)AttachmentItemType.小程序足浴版店铺logo);
                if (LogoList != null && LogoList.Count > 0)
                {
                    ViewBag.Logo = new List <object>()
                    {
                        new { id = LogoList[0].id, filepath = LogoList[0].filepath }
                    };
                }
                //门店图片
                List <C_Attachment> storePicList = C_AttachmentBLL.SingleModel.GetListByCache(storeModel.Id, (int)AttachmentItemType.小程序足浴版门店图片);
                if (storePicList != null && storePicList.Count > 0)
                {
                    List <object> storePicObjList = new List <object>();
                    storePicList.ForEach(x =>
                    {
                        storePicObjList.Add(new { id = x.id, filepath = x.filepath });
                    });
                    ViewBag.storePicList = storePicObjList;
                }
            }
            else
            {
                storeModel              = new FootBath();
                storeModel.GiftPrice    = 200;//默认一朵花2块钱
                storeModel.switchModel  = new SwitchModel();
                storeModel.SwitchConfig = JsonConvert.SerializeObject(storeModel.switchModel);
                storeModel.appId        = appId;
                int Id = Convert.ToInt32(FootBathBLL.SingleModel.Add(storeModel));
                if (Id > 0)
                {
                    storeModel.Id = Id;
                }
                else
                {
                    return(View("PageError", new Return_Msg()
                    {
                        Msg = "后台初始化异常!", code = "500"
                    }));
                }
            }
            //小程序配置
            ViewBag.isAuthorize = 0;
            ViewBag.XcxName     = "";
            List <ConfParam> paramslist = ConfParamBLL.SingleModel.GetListByRId(Convert.ToInt32(appId));

            if (appAcountRelation != null && !string.IsNullOrWhiteSpace(appAcountRelation.AppId))
            {
                ViewBag.isAuthorize = 1;
                if (paramslist != null && paramslist.Count > 0)
                {
                    ConfParam cinfo = paramslist.Where(w => w.Param == "nparam").FirstOrDefault();
                    if (cinfo != null)
                    {
                        ViewBag.XcxName = cinfo.Value;
                    }
                }
            }


            return(View(storeModel));
        }
示例#6
0
        public bool OpenCustomBotton(Agentinfo agentInfo, Agentinfo parentInfo, string userName, XcxAppAccountRelation xcxrelation, int cost, string parm)
        {
            bool success = false;

            if (agentInfo == null)
            {
                return(success);
            }
            TransactionModel tran = new TransactionModel();
            DateTime         date = DateTime.Now;

            //代理商扣费
            tran.Add($"UPDATE Agentinfo set deposit={agentInfo.deposit-cost} ,updateitme='{date}' where id={agentInfo.id}");
            //添加自定义水印数据
            ConfParam model = new ConfParam();

            model.AppId      = xcxrelation.AppId;
            model.Param      = parm;
            model.Value      = "";
            model.State      = 0;
            model.UpdateTime = date;
            model.AddTime    = date;
            model.RId        = xcxrelation.Id;
            tran.Add(ConfParamBLL.SingleModel.BuildAddSql(model));
            //扣费记录
            AgentdepositLog agentLog = new AgentdepositLog();

            agentLog.agentid       = agentInfo.id;
            agentLog.addtime       = date;
            agentLog.templateCount = 1;
            agentLog.customerid    = xcxrelation.AccountId.ToString();
            agentLog.Rid           = xcxrelation.Id;
            agentLog.OutTime       = date;
            agentLog.tid           = 0;
            agentLog.type          = (int)AgentDepositLogType.开启水印;
            agentLog.templateCount = 0;
            agentLog.beforeDeposit = agentInfo.deposit;
            agentLog.cost          = cost;
            agentLog.afterDeposit  = agentInfo.deposit - cost;
            agentLog.costdetail    = $"客户:{userName}开启自定义小程序水印";
            tran.Add(base.BuildAddSql(agentLog));

            //判断是否是二级分销商
            if (agentInfo.userLevel > 0)
            {
                if (parentInfo == null)
                {
                    return(success);
                }
                //上级代理商扣费
                tran.Add($"UPDATE Agentinfo set deposit={parentInfo.deposit - cost} ,updateitme='{date}' where id={parentInfo.id}");

                agentLog               = new AgentdepositLog();
                agentLog.agentid       = parentInfo.id;
                agentLog.addtime       = date;
                agentLog.templateCount = 1;
                agentLog.customerid    = xcxrelation.AccountId.ToString();
                agentLog.Rid           = xcxrelation.Id;
                agentLog.OutTime       = date;
                agentLog.tid           = 0;
                agentLog.type          = (int)AgentDepositLogType.开启水印;
                agentLog.templateCount = 0;
                agentLog.beforeDeposit = parentInfo.deposit;
                agentLog.cost          = cost;
                agentLog.afterDeposit  = parentInfo.deposit - cost;
                agentLog.costdetail    = $"分销商{parentInfo.name}为客户{userName}开启自定义小程序水印";
                tran.Add(base.BuildAddSql(agentLog));
            }

            success = base.ExecuteTransactionDataCorect(tran.sqlArray);
            return(success);
        }
示例#7
0
        public CreateCardResult AddWxCoupons(Coupons coupons, XcxAppAccountRelation xcx, string accountId)
        {
            //默认专业版的
            string           center_app_brand_pass = "******";   //专业版 个人中心
            string           custom_app_brand_pass = "******"; //首页 专业版
            string           logo_url          = string.Empty;
            string           brand_name        = string.Empty;
            string           appOriginalId     = string.Empty;
            CreateCardResult _createCardResult = new CreateCardResult();
            XcxTemplate      xcxTemplate       = XcxTemplateBLL.SingleModel.GetModel($"id={xcx.TId}");

            if (xcxTemplate == null)
            {
                _createCardResult.errcode = 1;
                _createCardResult.errmsg  = "小程序模板不存在";
                return(_createCardResult);
            }

            List <OpenAuthorizerConfig> listOpenAuthorizerConfig = OpenAuthorizerConfigBLL.SingleModel.GetListByaccoundidAndRid(accountId, xcx.Id, 4);

            if (listOpenAuthorizerConfig == null)
            {
                _createCardResult.errcode = 1;
                _createCardResult.errmsg  = "请先绑定认证服务号才有生成卡券权限";
                return(_createCardResult);
            }
            OpenAuthorizerConfig umodel = listOpenAuthorizerConfig[0];

            switch (xcxTemplate.Type)
            {
            case (int)TmpType.小程序专业模板:
                EntSetting ent = EntSettingBLL.SingleModel.GetModel(coupons.appId);
                if (ent == null)
                {
                    _createCardResult.errcode = 1;
                    _createCardResult.errmsg  = "该专业版信息找不到";
                    return(_createCardResult);
                }
                OpenAuthorizerConfig XUserList = OpenAuthorizerConfigBLL.SingleModel.GetModelByAppids(xcx.AppId);
                if (XUserList == null)
                {
                    _createCardResult.errcode = 1;
                    _createCardResult.errmsg  = "请先授权给平台";
                    return(_createCardResult);
                }
                ConfParam imginfo = ConfParamBLL.SingleModel.GetModelByParamappid("logoimg", xcx.AppId);
                if (imginfo == null)
                {
                    _createCardResult.errcode = 1;
                    _createCardResult.errmsg  = "请先到小程序管理配置底部Logo";
                    return(_createCardResult);
                }
                logo_url   = imginfo.Value;
                brand_name = XUserList.nick_name;

                break;

            case (int)TmpType.小程序电商模板:
                center_app_brand_pass = "******";    //个人中心页面
                Store store = StoreBLL.SingleModel.GetModelByAId(xcx.Id);
                if (store == null)
                {
                    _createCardResult.errcode = 1;
                    _createCardResult.errmsg  = "电商版店铺不存在";
                    return(_createCardResult);
                }
                logo_url   = store.logo;
                brand_name = store.name;
                break;

            case (int)TmpType.小程序餐饮模板:
                center_app_brand_pass = "******";     //个人中心页面
                custom_app_brand_pass = "******"; //首页
                Food miAppFood = FoodBLL.SingleModel.GetModel($"appId={xcx.Id}");
                if (miAppFood == null)
                {
                    _createCardResult.errcode = 1;
                    _createCardResult.errmsg  = "餐饮版店铺不存在";
                    return(_createCardResult);
                }

                logo_url   = miAppFood.Logo;
                brand_name = miAppFood.FoodsName;
                break;

            case (int)TmpType.小程序足浴模板:
            case (int)TmpType.小程序多门店模板:
                int t = 0;
                if ((int)TmpType.小程序足浴模板 == xcxTemplate.Type)
                {
                    center_app_brand_pass = "******";     //个人中心页面
                    custom_app_brand_pass = "******"; //首页
                }
                else
                {
                    center_app_brand_pass = "******";    //个人中心页面
                    t = 1;
                }
                FootBath storeModel = FootBathBLL.SingleModel.GetModel($"appId={xcx.Id}");
                if (storeModel == null)
                {
                    _createCardResult.errcode = 1;
                    _createCardResult.errmsg  = "找不到该足浴版";
                    return(_createCardResult);
                }
                brand_name = storeModel.StoreName;
                List <C_Attachment> LogoList = C_AttachmentBLL.SingleModel.GetListByCache(storeModel.Id, t == 0 ? (int)AttachmentItemType.小程序足浴版店铺logo : (int)AttachmentItemType.小程序多门店版门店logo);
                if (LogoList != null && LogoList.Count > 0)
                {
                    logo_url = LogoList[0].filepath;
                }
                break;

            case (int)TmpType.小未平台子模版:
                center_app_brand_pass = "******";      //个人中心页面
                custom_app_brand_pass = "******"; //首页
                PlatStore platStore = PlatStoreBLL.SingleModel.GetPlatStore(xcx.Id, 2);
                if (platStore == null)
                {
                    _createCardResult.errcode = 1;
                    _createCardResult.errmsg  = "平台版店铺不存在";
                    return(_createCardResult);
                }
                brand_name = platStore.Name;
                logo_url   = platStore.StoreHeaderImg;
                break;
            }

            if (string.IsNullOrEmpty(logo_url) || string.IsNullOrEmpty(brand_name))
            {
                _createCardResult.errcode = 1;
                _createCardResult.errmsg  = "请先配置Logo以及名称";
                return(_createCardResult);
            }

            //这里可能会出现token失效 个人发布的未授权给我们第三方平台的卡券会生成不了
            string xcxapiurl = XcxApiBLL.SingleModel.GetOpenAuthodModel(umodel.user_name);
            string authorizer_access_token = CommondHelper.GetAuthorizer_Access_Token(xcxapiurl);

            string uploadImgResult = CommondHelper.WxUploadImg(authorizer_access_token, logo_url);

            if (!uploadImgResult.Contains("url"))
            {
                _createCardResult.errcode = 1;
                _createCardResult.errmsg  = $"上传Logo到微信失败uploadImgResult={uploadImgResult}";
                return(_createCardResult);
            }
            if (brand_name.Length >= 12)
            {
                brand_name = brand_name.Substring(0, 12);
            }



            WxUploadImgResult wxUploadImgResult = JsonConvert.DeserializeObject <WxUploadImgResult>(uploadImgResult);

            logo_url = wxUploadImgResult.url;

            base_info _base_info = new base_info();

            _base_info.logo_url   = logo_url;
            _base_info.code_type  = "CODE_TYPE_TEXT";
            _base_info.brand_name = brand_name;
            _base_info.title      = coupons.CouponName.Length > 9 ? Utility.StringHelper.strSubstring(coupons.CouponName, 0, 8) : coupons.CouponName;
            _base_info.color      = "Color010";

            _base_info.center_title = "立即使用";
            _base_info.center_app_brand_user_name = $"{appOriginalId}@app";
            _base_info.center_app_brand_pass      = center_app_brand_pass;

            _base_info.custom_url_name            = "小程序";
            _base_info.custom_app_brand_user_name = $"{appOriginalId}@app";
            _base_info.custom_app_brand_pass      = custom_app_brand_pass;
            _base_info.custom_url_sub_title       = "点击进入";


            _base_info.description  = coupons.Desc.Length > 1024 ? Utility.StringHelper.strSubstring(coupons.Desc, 0, 1023) : coupons.Desc;
            _base_info.notice       = "使用时向服务员出示此券";
            _base_info.sku.quantity = coupons.CreateNum;
            if (coupons.LimitReceive > 0)
            {
                //大于0表示限制,0表示无限制
                _base_info.get_limit = coupons.LimitReceive;
            }


            if (coupons.ValType == 0)
            {
                //表示固定日期
                _base_info.date_info = new Firstdate_infoItem()
                {
                    begin_timestamp = WxUtils.GetWeixinDateTime(coupons.StartUseTime),
                    end_timestamp   = WxUtils.GetWeixinDateTime(coupons.EndUseTime)
                };
            }
            if (coupons.ValType == 2 || coupons.ValType == 1)
            {
                //fixed_begin_term=0表示领取后当天开始生效 1表示次日后开始生效 领取当日N天内有效
                _base_info.date_info = new Seconddate_infoItem()
                {
                    fixed_begin_term = coupons.ValType == 2?0:1,
                    fixed_term       = coupons.ValDay
                };
            }


            string json = string.Empty;

            if (coupons.CouponWay == 0)
            {
                //表示是需要生成微信代金券
                WxCashCoupons wxCashCoupons = new WxCashCoupons();
                Cash          cash          = new Cash();
                cash.base_info = _base_info;//基础字段信息

                Use_condition use_condition = new Use_condition();

                use_condition.accept_category = coupons.GoodsType == 0 ? "全部产品" : "部分产品";
                if (coupons.LimitMoney > 0)
                {
                    cash.least_cost = coupons.LimitMoney;
                    //满减门槛
                    use_condition.least_cost = coupons.LimitMoney;
                }
                use_condition.can_use_with_other_discount = coupons.discountType == 0;

                cash.reduce_cost   = coupons.Money;
                cash.advanced_info = new Advanced_info()
                {
                    use_condition = use_condition
                };
                wxCashCoupons.cash = cash;
                json = JsonConvert.SerializeObject(new { card = wxCashCoupons });
            }
            else
            {
                //表示是需要生成微信折扣券
                WxDiscountCoupons wxDiscountCoupons = new WxDiscountCoupons();
                Discount          discount          = new Discount();
                discount.base_info         = _base_info;
                discount.discount          = (int)(100 - coupons.Money * 0.1);
                wxDiscountCoupons.discount = discount;
                json = JsonConvert.SerializeObject(new { card = wxDiscountCoupons });
            }

            string result = Utility.IO.Context.PostData($"https://api.weixin.qq.com/card/create?access_token={authorizer_access_token}", json);

            if (string.IsNullOrEmpty(result))
            {
                return(_createCardResult);
            }
            _createCardResult = JsonConvert.DeserializeObject <CreateCardResult>(result);
            return(_createCardResult);
        }
示例#8
0
        public ActionResult SaveConfig(int id, string datajson)
        {
            if (dzaccount == null)
            {
                return(Redirect("/dzhome/login"));
            }
            XcxAppAccountRelation umodel = XcxAppAccountRelationBLL.SingleModel.GetModel(id);

            if (umodel == null)
            {
                return(View("PageError", new Return_Msg()
                {
                    Msg = "没有权限!", code = "403"
                }));
            }

            List <ConfParam> paramslist = ConfParamBLL.SingleModel.GetListByRId(id);

            try
            {
                if (paramslist != null && paramslist.Count > 0)
                {
                    List <ConfParam> data = JsonConvert.DeserializeObject <List <ConfParam> >(datajson);
                    if (data != null && data.Count > 0)
                    {
                        foreach (ConfParam item in data)
                        {
                            ConfParam list = paramslist.FirstOrDefault(f => f.Param == item.Param);
                            if (list != null)
                            {
                                if (ConfParamBLL.SingleModel.UpdateList(id, item.Value, item.Param, umodel.AppId) <= 0)
                                {
                                    return(Json(new { isok = -1, msg = "修改失败_" + item.Param }, JsonRequestBehavior.AllowGet));
                                }
                            }
                            else
                            {
                                ConfParam model = new ConfParam();
                                model.AppId      = umodel.AppId;
                                model.Param      = item.Param;
                                model.Value      = item.Value;
                                model.State      = 0;
                                model.UpdateTime = DateTime.Now;
                                model.AddTime    = DateTime.Now;
                                model.RId        = id;
                                if (Convert.ToInt32(ConfParamBLL.SingleModel.Add(model)) <= 0)
                                {
                                    return(Json(new { isok = -1, msg = "添加失败" }, JsonRequestBehavior.AllowGet));
                                }
                            }
                        }
                    }
                }
                else
                {
                    List <ConfParam> data = JsonConvert.DeserializeObject <List <ConfParam> >(datajson);
                    if (data != null && data.Count > 0)
                    {
                        foreach (ConfParam item in data)
                        {
                            ConfParam model = new ConfParam();
                            model.AppId      = umodel.AppId;
                            model.Param      = item.Param;
                            model.Value      = item.Value;
                            model.State      = 0;
                            model.UpdateTime = DateTime.Now;
                            model.AddTime    = DateTime.Now;
                            model.RId        = id;
                            if (Convert.ToInt32(ConfParamBLL.SingleModel.Add(model)) <= 0)
                            {
                                return(Json(new { isok = -1, msg = "添加失败" }, JsonRequestBehavior.AllowGet));
                            }
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                return(Json(new { isok = -1, msg = "系统繁忙" + ex.Message }, JsonRequestBehavior.AllowGet));
            }


            return(Json(new { isok = 1, msg = "保存成功" }, JsonRequestBehavior.AllowGet));
        }