Exemple #1
0
        /// <summary>
        /// 企业智推版开通日志整理
        /// </summary>
        /// <param name="openType"></param>
        /// <param name="cost"></param>
        /// <param name="desc"></param>
        /// <param name="xcx"></param>
        /// <param name="userName"></param>
        /// <param name="dname"></param>
        /// <param name="isDistribution"></param>
        public void GetOpenQYStoreInfo(int openType, ref int cost, ref string desc, XcxTemplate xcx, string userName, string dname, int isDistribution)
        {
            switch (openType)
            {
            case (int)AgentDepositLogType.变更企业智推版员工:
                //企业智推版员工数量
                cost = 0;
                if (xcx.buycount > xcx.SCount)
                {
                    cost += (xcx.buycount - xcx.SCount) * xcx.SPrice;
                    desc  = isDistribution == 0?($"客户:{userName}  开通{xcx.TName}员工数量:{xcx.buycount - xcx.SCount}"):($"分销商:{dname} 为客户{userName}新开通{xcx.TName}员工数量:{xcx.buycount - xcx.SCount}");
                }
                else
                {
                    desc = isDistribution == 0 ? ($"客户:{userName}  减少了{xcx.TName}员工数量:{xcx.SCount - xcx.buycount}"):($"分销商:{dname} 为客户{userName}减少{xcx.TName}员工数量:{xcx.SCount - xcx.buycount}");
                }
                break;

            default:
                //开通企业智推版
                cost += (xcx.storecount - xcx.SCount) * xcx.SPrice * xcx.buycount;
                desc  = isDistribution == 0 ? ($"客户:{userName}  开通模板:{xcx.TName} 开通数量:" + xcx.buycount + " 员工数量:" + xcx.storecount):(desc = $"分销商:{dname}  开通模板:{xcx.TName} 开通数量:" + xcx.buycount + " 员工数量:" + xcx.storecount);
                break;
            }
        }
        public List <XcxAppAccountRelation> GetListByTemplateType(string accountId, TmpType templateType)
        {
            XcxTemplate template = XcxTemplateBLL.SingleModel.GetModelByType((int)templateType);
            string      whereSql = $"AccountId='{accountId}' and TId={template.Id} and state>=0 and outtime>'{DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")}'";

            return(base.GetList(whereSql));
        }
Exemple #3
0
        /// <summary>
        /// 收货
        /// </summary>
        /// <param name="buid">参团ID</param>
        /// <param name="AppId"></param>
        /// <param name="UserId">分享者ID</param>
        /// <returns></returns>
        public ActionResult RecieveGoods(int guid)
        {
            GroupUser groupuser = GroupUserBLL.SingleModel.GetModel(guid);

            if (groupuser == null)
            {
                return(Json(new { isok = false, msg = "没找到拼团订单" }, JsonRequestBehavior.AllowGet));
            }

            groupuser.State           = (int)MiniappPayState.已收货;
            groupuser.RecieveGoodTime = DateTime.Now;
            Groups groupgoods = GroupsBLL.SingleModel.GetModel(groupuser.GroupId);

            if (groupgoods == null)
            {
                return(Json(new { isok = false, msg = "没有找到拼团商品,请刷新重试" }, JsonRequestBehavior.AllowGet));
            }

            Store store = StoreBLL.SingleModel.GetModel(groupgoods.StoreId);

            if (store == null)
            {
                return(Json(new { isok = false, msg = "没有找到店铺,请刷新重试" }, JsonRequestBehavior.AllowGet));
            }
            XcxAppAccountRelation xcxmodel = _xcxAppAccountRelationBLL.GetModel(store.appId);

            if (xcxmodel == null)
            {
                return(Json(new { isok = false, msg = "还没授权,请刷新重试" }, JsonRequestBehavior.AllowGet));
            }
            XcxTemplate xcxtemplate = XcxTemplateBLL.SingleModel.GetModel(xcxmodel.TId);

            if (xcxtemplate == null)
            {
                return(Json(new { isok = false, msg = "找不到模板,请刷新重试" }, JsonRequestBehavior.AllowGet));
            }
            string updateLeveType = string.Empty;

            if (xcxtemplate.Type == (int)TmpType.小程序专业模板)
            {
                updateLeveType = "entpro";
            }
            else if (xcxtemplate.Type == (int)TmpType.小程序多门店模板)
            {
                updateLeveType = "store";
            }

            if (GroupUserBLL.SingleModel.Update(groupuser, "State,RecieveGoodTime"))
            {
                if (!VipRelationBLL.SingleModel.updatelevel(groupuser.ObtainUserId, updateLeveType, groupuser.BuyPrice))
                {
                    log4net.LogHelper.WriteError(GetType(), new Exception(" 用户自动升级逻辑异常" + guid));
                }
                return(Json(new { isok = true, msg = "已确认收货" }, JsonRequestBehavior.AllowGet));
            }
            return(Json(new { isok = false, msg = "已确认收货失败" }, JsonRequestBehavior.AllowGet));
        }
Exemple #4
0
        /// <summary>
        /// 获取UU配送运费
        /// </summary>
        /// <param name="storeId"></param>
        /// <param name="aid"></param>
        /// <param name="lat"></param>
        /// <param name="lnt"></param>
        /// <param name="orderPrice"></param>
        /// <returns></returns>
        public UUOrderFee GetUUFee(int storeId, int aid, string toAddress, ref string msg)
        {
            msg = "获取运费出错";
            UUOrderFee         feeResult        = new UUOrderFee();
            UUCustomerRelation customerRelation = UUCustomerRelationBLL.SingleModel.GetModelByAid(aid, storeId, 0);

            if (customerRelation == null)
            {
                msg = "UU配送:未设置UU配置";
                return(feeResult);
            }
            XcxAppAccountRelation xcxrelation = XcxAppAccountRelationBLL.SingleModel.GetModel(aid);

            if (xcxrelation == null)
            {
                msg = "UU配送:权限模板不存在";
                return(feeResult);
            }

            XcxTemplate xcxtemplate = XcxTemplateBLL.SingleModel.GetModel(xcxrelation.TId);

            if (xcxtemplate == null)
            {
                msg = "UU配送:小程序模板不存在";
                return(feeResult);
            }

            //店铺信息
            ShopInfo shopinfo = GetStoreAddressPoint(aid, storeId, xcxtemplate.Type);

            UUGetPriceResult result = UUApi.GetOrderPrice(customerRelation.OpenId, shopinfo.ShopAddress, "", toAddress, "", shopinfo.CityName, shopinfo.CountyName);

            if (result == null)
            {
                LogHelper.WriteInfo(this.GetType(), "UU配送:返回结果为null,");
                return(feeResult);
            }
            if (result.return_code != "ok")
            {
                LogHelper.WriteInfo(this.GetType(), $"UU配送配送:请求参数,aid【{aid}】storeid【{storeId}】" + JsonConvert.SerializeObject(result));
                msg = result.return_msg;
                return(feeResult);
            }
            else
            {
                decimal maxFee = Math.Max(Convert.ToDecimal(result.total_money), Convert.ToDecimal(result.need_paymoney));
                int     fee    = Convert.ToInt32(maxFee * 100);
                feeResult.Fee           = fee;
                feeResult.price_token   = result.price_token;
                feeResult.total_money   = result.total_money;
                feeResult.need_paymoney = result.need_paymoney;
                msg = "";
                return(feeResult);
            }
        }
Exemple #5
0
        public ActionResult editoradd(XcxTemplate data)
        {
            try
            {
                if (data.Id > 0)
                {
                    data.UpdateTime = DateTime.Now;
                    var model = XcxTemplateBLL.SingleModel.GetModel(data.Id);
                    model.TName        = data.TName;
                    model.TImgurl      = data.TImgurl;
                    model.Version      = data.Version;
                    model.Desc         = data.Desc;
                    model.Address      = data.Address;
                    model.Tag          = data.Tag;
                    model.First_class  = data.First_class;
                    model.Second_class = data.Second_class;
                    model.Third_class  = data.Third_class;
                    model.Title        = data.Title;
                    model.UpdateTime   = data.UpdateTime;
                    string upstr = "TName,TImgurl,Version,Price,Desc,Address,Tag,First_class,Second_class,Third_class,Title,UpdateTime";
                    if (XcxTemplateBLL.SingleModel.Update(data, upstr))
                    {
                        return(Json(new { isok = 1, msg = "修改成功", obj = data }, JsonRequestBehavior.AllowGet));
                    }

                    return(Json(new { isok = -1, msg = "修改失败" }, JsonRequestBehavior.AllowGet));
                }
                else
                {
                    var model = XcxTemplateBLL.SingleModel.GetModel("TId=" + data.TId);
                    if (model != null)
                    {
                        return(Json(new { isok = -1, msg = "请不要重复添加" }, JsonRequestBehavior.AllowGet));
                    }
                    data.AddTime    = DateTime.Now;
                    data.UpdateTime = DateTime.Now;
                    //data.State = 0;
                    if (Convert.ToInt32(XcxTemplateBLL.SingleModel.Add(data)) > 0)
                    {
                        return(Json(new { isok = 1, msg = "添加成功", obj = data }, JsonRequestBehavior.AllowGet));
                    }

                    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));
        }
Exemple #6
0
        public ActionResult GetDataList()
        {
            _returnData = new Return_Msg();

            int    pageSize     = Context.GetRequestInt("pageSize", 10);
            int    pageIndex    = Context.GetRequestInt("pageIndex", 1);
            int    aid          = Context.GetRequestInt("aid", 0);
            int    openState    = Context.GetRequestInt("openstate", -1);
            int    xcxappState  = Context.GetRequestInt("xcxappstate", -2);
            int    dayLength    = Context.GetRequestInt("daylength", 0);
            string customerName = Context.GetRequest("customername", string.Empty);
            string storeName    = Context.GetRequest("storename", string.Empty);
            string loginId      = Context.GetRequest("loginid", string.Empty);

            if (aid <= 0)
            {
                _returnData.Msg = "参数错误";
                return(Json(_returnData));
            }
            XcxAppAccountRelation xcxrelation = XcxAppAccountRelationBLL.SingleModel.GetModel(aid);

            if (xcxrelation == null)
            {
                _returnData.Msg = "还未开通小未平台模板";
                return(Json(_returnData));
            }

            Agentinfo agentinfoModel = AgentinfoBLL.SingleModel.GetModelByAccoundId(xcxrelation.AccountId.ToString());

            int count = 0;
            List <PlatApplyApp> list = PlatApplyAppBLL.SingleModel.GetDataList(xcxrelation.AppId, dayLength, customerName, loginId, storeName, openState, xcxappState, aid, pageSize, pageIndex, ref count);

            XcxTemplate tempInfo = XcxTemplateBLL.SingleModel.GetModelByType((int)TmpType.小未平台子模版);

            if (tempInfo != null && agentinfoModel != null)
            {
                List <XcxTemplate> xcxList = XcxTemplateBLL.SingleModel.GetRealPriceTemplateList($" id in ({tempInfo.Id})", agentinfoModel.id);
                if (xcxList != null && xcxList.Count > 0)
                {
                    tempInfo = xcxList[0];
                }
            }
            _returnData.isok    = true;
            _returnData.dataObj = new { data = list, count = count, tempinfo = tempInfo };

            return(Json(_returnData));
        }
Exemple #7
0
        /// <summary>
        /// 获取平台店铺二维码
        /// </summary>
        /// <param name="aid"></param>
        /// <param name="pageurl"></param>
        /// <param name="scene"></param>
        /// <returns></returns>
        public string GetStoreCode(int storeid, string pageurl, ref string msg)
        {
            PlatStore store = base.GetModel(storeid);

            if (store == null)
            {
                msg = "店铺二维码:找不到店铺数据";
                return("");
            }

            XcxAppAccountRelation xcxrelation = XcxAppAccountRelationBLL.SingleModel.GetModel(store.BindPlatAid);

            if (xcxrelation == null)
            {
                msg = "平台店铺二维码:模板过期";
                return("");
            }

            XcxTemplate xcxTemplate = XcxTemplateBLL.SingleModel.GetModel(xcxrelation.TId);

            if (xcxTemplate == null)
            {
                msg = "无效模板";
                return("");
            }

            string token = "";

            if (!XcxApiBLL.SingleModel.GetToken(xcxrelation, ref token))
            {
                msg = token;
                return("");
            }

            //店铺没有开通小程序
            //平台小程序二维码
            string      scen        = $"{storeid}";
            qrcodeclass qrcodemodel = CommondHelper.GetMiniAppQrcode(token, pageurl, scen);

            if (qrcodemodel == null || string.IsNullOrEmpty(qrcodemodel.url))
            {
                msg = qrcodemodel != null ? qrcodemodel.msg : "生成名片码失败";
                return("");
            }

            return(qrcodemodel.url);
        }
Exemple #8
0
        public ActionResult JoinExchangeActivityList(int appId = 0)
        {
            if (appId <= 0)
            {
                return(View("PageError", new Return_Msg()
                {
                    Msg = "参数错误!", code = "500"
                }));
            }
            if (dzaccount == null)
            {
                return(Redirect("/dzhome/login"));
            }
            XcxAppAccountRelation xcx = XcxAppAccountRelationBLL.SingleModel.GetModelByaccountidAndAppid(appId, dzaccount.Id.ToString());

            if (xcx == null)
            {
                return(View("PageError", new Return_Msg()
                {
                    Msg = "小程序未授权!", code = "403"
                }));
            }
            XcxTemplate xcxTemplate = XcxTemplateBLL.SingleModel.GetModel($"id={xcx.TId}");

            if (xcxTemplate == null)
            {
                return(View("PageError", new Return_Msg()
                {
                    Msg = "小程序模板不存在!", code = "500"
                }));
            }

            int versionId = 0;

            if (xcxTemplate.Type == (int)TmpType.小程序专业模板)
            {
                versionId = xcx.VersionId;
            }
            ViewBag.versionId = versionId;

            ViewBag.PageType = xcxTemplate.Type;
            ViewBag.appId    = appId;
            return(View());
        }
Exemple #9
0
        public ActionResult Admin(XcxAppAccountRelation authData)
        {
            if (authData == null)
            {
                return(View("PageError", new Return_Msg()
                {
                    Msg = "无效参数!", code = "500"
                }));
            }

            XcxTemplate xcxTemplate = XcxTemplateBLL.SingleModel.GetModel(authData.TId);
            bool        isAvailable = false;

            if (xcxTemplate.Type == (int)TmpType.小程序专业模板)
            {
                FunctionList functionList = new FunctionList();
                functionList = FunctionListBLL.SingleModel.GetModel($"TemplateType={xcxTemplate.Type} and VersionId={authData.VersionId}");
                if (functionList == null)
                {
                    return(View("PageError", new Return_Msg()
                    {
                        Msg = "功能权限未设置!", code = "500"
                    }));
                }
                if (!string.IsNullOrEmpty(functionList.ComsConfig))
                {
                    functionList.ComsConfigModel = JsonConvert.DeserializeObject <ComsConfig>(functionList.ComsConfig);
                }
                isAvailable = functionList.ComsConfigModel?.FlashDeal == 0;
            }
            ViewBag.appId       = authData.Id;
            ViewBag.PageType    = xcxTemplate.Type;
            ViewBag.isAvailable = isAvailable;
            ViewBag.versionId   = authData.VersionId;
            return(View());
        }
Exemple #10
0
        /// <summary>
        /// 检验上级代理预存
        /// </summary>
        /// <param name="agentId">分销商ID</param>
        /// <param name="tids">模板ID</param>
        /// <param name="industryid"></param>
        /// <param name="industr"></param>
        /// <param name="xcxtemplates"></param>
        /// <param name="parent_sum"></param>
        /// <param name="msg"></param>
        public List <XcxTemplate> CheckParentAgentDeposit(int agentId, int industryid, string industr, List <XcxTemplate> xcxtemplates, ref int parent_sum, ref string msg)
        {
            List <XcxTemplate> xcxList = new List <XcxTemplate>();

            if (xcxtemplates == null || xcxtemplates.Count <= 0)
            {
                msg = "请选择开通模板";
                return(xcxList);
            }
            string    tids      = string.Join(",", xcxtemplates.Select(s => s.Id));
            Agentinfo agentinfo = base.GetModel(agentId);

            if (agentinfo == null)
            {
                msg = "无效代理";
                return(xcxList);
            }

            xcxList = XcxTemplateBLL.SingleModel.GetRealPriceTemplateList($" id in ({tids})", agentId);
            if (xcxList != null && xcxList.Count > 0)
            {
                #region 判断代理商合同是否已过期,已过期不给开免费版
                CheckOutTime(ref xcxList, agentinfo, industryid, ref msg);
                #endregion

                foreach (XcxTemplate xcxmodel in xcxList)
                {
                    XcxTemplate tempmodel = xcxtemplates.Where(w => w.Id == xcxmodel.Id).FirstOrDefault();
                    //判断是否为行业小程序模板
                    xcxmodel.industr   = xcxmodel.Type == (int)TmpType.小程序专业模板 ? industr : "";
                    xcxmodel.VersionId = industryid;
                    //判断是否为小程序多店铺模板
                    if (xcxmodel.Type == (int)TmpType.小程序多门店模板 || xcxmodel.Type == (int)TmpType.小程序餐饮多门店模板 || xcxmodel.Type == (int)TmpType.智慧餐厅 || xcxmodel.Type == (int)TmpType.企业智推版)
                    {
                        xcxmodel.storecount = tempmodel.storecount;
                        if (xcxmodel.storecount <= 0)
                        {
                            xcxmodel.storecount = xcxmodel.SCount;
                        }
                        //判断开通的多门店的分店是否有超过预定值
                        xcxmodel.sumprice = (xcxmodel.storecount - xcxmodel.SCount) * xcxmodel.SPrice;
                        parent_sum       += xcxmodel.sumprice;
                    }

                    //有效期
                    xcxmodel.year     = tempmodel != null ? tempmodel.year : 1;
                    xcxmodel.buycount = tempmodel.buycount;
                    if (xcxmodel.Type == (int)TmpType.小程序专业模板)
                    {
                        //重新计算价格专业版版本级别
                        VersionType model = XcxTemplateBLL.SingleModel.GetRealPriceVersionTemplateList(xcxmodel.Type, agentinfo.id).FirstOrDefault(x => x.VersionId == xcxmodel.VersionId);
                        xcxmodel.sumprice   = Convert.ToInt32(model.VersionPrice) * xcxmodel.year * tempmodel.buycount;
                        parent_sum         += xcxmodel.sumprice;
                        xcxmodel.Price      = Convert.ToInt32(model.VersionPrice);
                        xcxmodel.LimitCount = model.LimitCount;
                    }
                    else
                    {
                        xcxmodel.sumprice += xcxmodel.Price * xcxmodel.year * tempmodel.buycount;
                        parent_sum        += xcxmodel.Price * xcxmodel.year * tempmodel.buycount;
                    }
                }

                if (parent_sum > agentinfo.deposit)
                {
                    msg = $"创建失败,请联系上级代理";
                }
            }
            else
            {
                msg = "数据错误!";
            }

            return(xcxList);
        }
Exemple #11
0
        /// <summary>
        /// 子模版获取小程序二维码
        /// </summary>
        /// <param name="storeid"></param>
        /// <param name="msg"></param>
        /// <returns></returns>
        public string GetStoreCode(int storeid, ref string msg)
        {
            PlatStore store = base.GetModel(storeid);

            if (store == null)
            {
                msg = "店铺二维码:找不到店铺数据";
                return("");
            }

            string url = RedisUtil.Get <string>(string.Format(_redis_PlatStoreCodeUrlKey, storeid));

            if (!string.IsNullOrEmpty(url))
            {
                return(url);
            }

            XcxAppAccountRelation xcxrelation = XcxAppAccountRelationBLL.SingleModel.GetModel(store.Aid);

            if (xcxrelation == null || string.IsNullOrEmpty(xcxrelation.AppId))
            {
                msg = "店铺二维码:店铺没绑定小程序";
                return("");
            }
            //OpenAuthorizerConfig XUserList = openAuthorizerConfigBLL.GetModelByAppids(xcxrelation.AppId);
            //if (XUserList == null)
            //{
            //    msg = "店铺二维码:店铺小程序还未授权";
            //    return "";
            //}

            XcxTemplate xcxTemplate = XcxTemplateBLL.SingleModel.GetModel(xcxrelation.TId);

            if (xcxTemplate == null)
            {
                msg = "店铺二维码:无效模板";
                return("");
            }

            string token = "";

            if (!XcxApiBLL.SingleModel.GetToken(xcxrelation, ref token))
            {
                msg = token;
                return("");
            }

            //小程序二维码

            qrcodeclass result = CommondHelper.GetMiniAppQrcode(token, xcxTemplate.Address);

            if (result != null && result.isok > 0)
            {
                url = result.url;
                if (string.IsNullOrEmpty(url))
                {
                    return("");
                }
                url = url.Replace("http:", "https:");
                RedisUtil.Set <string>(string.Format(_redis_PlatStoreCodeUrlKey, storeid), url, TimeSpan.FromSeconds(5));
                return(url);
            }

            msg = "店铺二维码:获取失败";
            return("");
        }
Exemple #12
0
        /// <summary>
        /// 续期
        /// </summary>
        /// <param name="platApplyAppModel"></param>
        /// <param name="accountid"></param>
        /// <param name="uselength"></param>
        /// <param name="tid"></param>
        /// <param name="msg"></param>
        /// <returns></returns>
        public bool AddTimeLength(PlatApplyApp platApplyAppModel, string accountid, int uselength, int tid, ref string msg)
        {
            DateTime         nowtime = DateTime.Now;
            TransactionModel tran    = new TransactionModel();

            #region 基础验证
            bool success = false;
            if (platApplyAppModel == null)
            {
                msg = "申请记录为空";
                return(false);
            }
            //名片管理登陆账号

            PlatMyCard mycardmodel = PlatMyCardBLL.SingleModel.GetModel(platApplyAppModel.MycardId);
            if (mycardmodel == null)
            {
                msg = "名片过期";
                return(false);
            }
            //判断是否已开通
            if (string.IsNullOrEmpty(mycardmodel.LoginId))
            {
                msg = "该用户还没开通小程序";
                return(false);
            }

            //店铺数据

            PlatStore platStore = PlatStoreBLL.SingleModel.GetModel(platApplyAppModel.StoreId);
            if (platStore == null)
            {
                msg = "店铺过期,请刷新重试";
                return(false);
            }
            #endregion

            #region 使用中的模板数据
            XcxAppAccountRelation xcxrelation = XcxAppAccountRelationBLL.SingleModel.GetModel(platStore.Aid);
            if (xcxrelation == null)
            {
                msg = "模板数据过期";
                return(false);
            }
            if (xcxrelation.outtime < nowtime)
            {
                xcxrelation.outtime = nowtime.AddYears(uselength);
            }
            else
            {
                xcxrelation.outtime = xcxrelation.outtime.AddYears(uselength);
            }
            tran.Add($"update XcxAppAccountRelation set outtime='{xcxrelation.outtime}',state=1 where id={xcxrelation.Id}");
            #endregion

            //用户基础数据,获取普通预存款

            AccountRelation accountrelation = AccountRelationBLL.SingleModel.GetModelByAccountId(accountid);

            //代理数据
            Agentinfo agentinfo = AgentinfoBLL.SingleModel.GetModelByAccoundId(accountid);

            #region 模板跟模板价格
            XcxTemplate tempinfo = XcxTemplateBLL.SingleModel.GetModelByType((int)TmpType.小未平台子模版);
            if (tempinfo != null && agentinfo != null)
            {
                List <XcxTemplate> xcxlist = XcxTemplateBLL.SingleModel.GetRealPriceTemplateList($" id in ({tempinfo.Id})", agentinfo.id);
                if (xcxlist != null && xcxlist.Count > 0)
                {
                    //代理过期检验
                    AgentinfoBLL.SingleModel.CheckOutTime(ref xcxlist, agentinfo, 0, ref msg);
                    tempinfo = xcxlist[0];
                }
            }
            if (tempinfo == null)
            {
                msg = "模板数据为空";
                return(false);
            }
            #endregion

            #region 扣费
            //扣除总费用
            int sum = tempinfo.Price * uselength;
            //变更前金额
            int deposit = 0;
            //变更后的金额
            int afterdeposit = 0;
            //扣除代理费用
            if (agentinfo != null)
            {
                //变更前金额
                deposit = agentinfo.deposit;
                //判断余额是否满足扣费
                if (deposit + accountrelation.Deposit < sum)
                {
                    msg = "余额不足";
                    return(false);
                }
                //变更后金额
                if (deposit >= sum)
                {
                    afterdeposit = deposit - sum;
                    tran.Add($"UPDATE Agentinfo set deposit={afterdeposit} ,updateitme='{nowtime}' where id={agentinfo.id}");
                }
                else if (accountrelation.Deposit >= sum)
                {
                    afterdeposit = accountrelation.Deposit - sum;
                    tran.Add($"UPDATE AccountRelation set deposit={afterdeposit} ,updatetime='{nowtime}' where id={accountrelation.Id}");
                }
                else
                {
                    //先扣除普通用户预存,再扣除代理商预存
                    afterdeposit = agentinfo.deposit - (sum - accountrelation.Deposit);
                    tran.Add($"UPDATE Agentinfo set deposit={afterdeposit} ,updateitme='{nowtime}' where id={agentinfo.id}");
                    tran.Add($"UPDATE AccountRelation set deposit=0 ,updatetime='{nowtime}' where id={accountrelation.Id}");
                }
            }
            //扣除普通账号预存款
            else
            {
                sum = 100 * uselength;
                //变更前金额
                deposit = accountrelation.Deposit;
                //判断余额是否满足扣费
                if (deposit < sum)
                {
                    msg = "余额不足";
                    return(false);
                }
                //变更后金额
                afterdeposit = deposit - sum;
                tran.Add($"UPDATE AccountRelation set deposit={afterdeposit} ,updatetime='{nowtime}' where id={accountrelation.Id}");
            }
            #endregion

            #region 开通流水

            AgentdepositLog agentLog = new AgentdepositLog();
            agentLog.agentid       = agentinfo != null ? agentinfo.id : 0;
            agentLog.addtime       = nowtime;
            agentLog.templateCount = 1;
            agentLog.customerid    = xcxrelation.AccountId.ToString();
            agentLog.tid           = tempinfo.Id;
            agentLog.type          = agentinfo != null ? (int)AgentDepositLogType.代理商续费 : (int)AgentDepositLogType.普通用户续费模板;
            agentLog.templateCount = 1;
            agentLog.beforeDeposit = deposit;
            agentLog.cost          = sum;
            agentLog.acid          = agentinfo != null ? 0 : accountrelation.Id;
            agentLog.Rid           = platApplyAppModel.BindAId;
            agentLog.afterDeposit  = afterdeposit;
            string desc = $"客户:{mycardmodel.Name}  续期模板:{tempinfo.TName} 续期年限:{uselength}年";
            agentLog.costdetail = desc;
            tran.Add(AgentdepositLogBLL.SingleModel.BuildAddSql(agentLog));
            #endregion

            success = base.ExecuteTransactionDataCorect(tran.sqlArray, tran.ParameterArray);

            //清除缓存
            XcxAppAccountRelationBLL.SingleModel.RemoveRedis(xcxrelation.Id);
            return(success);
        }
Exemple #13
0
        public ActionResult GetMyCouponList()
        {
            int    userId      = Context.GetRequestInt("userId", 0);
            string appId       = Context.GetRequest("appId", string.Empty);
            string goodsId     = Context.GetRequest("goodsId", string.Empty); //商品ID,用于用户下单时获取可用优惠券,默认0获取我的优惠列表
            int    pageIndex   = Context.GetRequestInt("pageIndex", 1);
            int    state       = Context.GetRequestInt("state", 0);           //0:未使用,1:已使用,2:已过期,3:已失效,可使用:4
            int    ticketType  = Context.GetRequestInt("ticketType", 0);
            int    storeId     = Context.GetRequestInt("storeid", 0);
            int    platStoreId = 0;

            if (storeId > 0)
            {
                platStoreId = storeId;
            }
            string goodsInfo = Context.GetRequest("goodsInfo", string.Empty);
            XcxAppAccountRelation xcxrelation = _xcxAppAccountRelationBLL.GetModelByAppid(appId);

            if (xcxrelation == null)
            {
                return(Json(new { isok = false, msg = "未找到小程序授权资料" }, JsonRequestBehavior.AllowGet));
            }
            XcxTemplate xcxtemplat = XcxTemplateBLL.SingleModel.GetModel(xcxrelation.TId);

            if (xcxtemplat == null)
            {
                return(Json(new { isok = false, msg = "未找到模板" }, JsonRequestBehavior.AllowGet));
            }

            C_UserInfo userInfo = C_UserInfoBLL.SingleModel.GetModel(userId);

            if (userInfo == null)
            {
                return(Json(new { isok = false, msg = "未找到用户" }, JsonRequestBehavior.AllowGet));
            }

            string errMsg  = string.Empty;
            string aids    = "";
            string userids = userId.ToString();

            storeId = _xcxAppAccountRelationBLL.ReturnStoreIdByAId(xcxrelation.Id, ref errMsg, ref aids, ref userids, userInfo.TelePhone);

            if (!string.IsNullOrWhiteSpace(errMsg))
            {
                return(Json(new { isok = false, errMsg }, JsonRequestBehavior.AllowGet));
            }

            List <CouponLog> couponloglist = CouponLogBLL.SingleModel.GetListByApi(state, userids, storeId, aids, 10, pageIndex, "p.storeid desc,l.addtime desc", goodsId, goodsInfo);

            switch (xcxtemplat.Type)
            {
            case (int)TmpType.小未平台:
                List <PlatCoupons> platpostdata = new List <PlatCoupons>();
                string             storeids     = string.Join(",", couponloglist?.Select(s => s.StoreId).Distinct());
                //下单时,获取优惠券应该根据storeId获取,避免获取别的店铺优惠券
                if (platStoreId > 0)
                {
                    storeids = platStoreId.ToString();
                }
                List <PlatStore> platstorelist = PlatStoreBLL.SingleModel.GetListByIds(storeids);
                if (platstorelist != null && platstorelist.Count > 0)
                {
                    foreach (PlatStore item in platstorelist)
                    {
                        PlatCoupons platcoupon = new PlatCoupons();
                        platcoupon.StoreId   = item.Id;
                        platcoupon.AId       = item.Aid;
                        platcoupon.StoreName = item.Name;

                        List <CouponLog> temploglist = couponloglist.Where(w => w.StoreId == item.Id).ToList();
                        platcoupon.couponloglist = temploglist;

                        platpostdata.Add(platcoupon);
                    }
                }
                return(Json(new { isok = true, msg = "平台获取优惠券成功", postdata = platpostdata }, JsonRequestBehavior.AllowGet));

            default:
                var postdata = couponloglist?.Select(s => new
                {
                    s.Id,
                    s.CouponId,
                    s.CouponName,
                    EndUseTimeStr   = s.EndUseTime.ToString("yyyy.MM.dd"),
                    StartUseTimeStr = s.StartUseTime.ToString("yyyy.MM.dd"),
                    State           = state,
                    s.Money,
                    s.Money_fmt,
                    s.CouponWay,
                    s.LimitMoney,
                    s.LimitMoneyStr,
                    s.UserId,
                    s.ValType,
                    s.CanUse,
                    s.GoodsIdStr,
                    s.StoreId,
                    s.StoreName,
                    s.discountType
                });

                return(Json(new { isok = true, msg = "成功", postdata = postdata }, JsonRequestBehavior.AllowGet));
            }
        }
Exemple #14
0
        /// <summary>
        /// 将 CommonSetting 逆推更入数据库
        /// </summary>
        /// <param name="commonSetting"></param>
        /// <param name="aId"></param>
        /// <param name="storeId"></param>
        /// <returns></returns>
        public static Return_Msg UpdateCommonSetting(CommonSetting commonSetting, int aId, int storeId = 0)
        {
            Return_Msg handingResult = new Return_Msg();

            handingResult.isok = false;

            XcxAppAccountRelation xcxrelation = XcxAppAccountRelationBLL.SingleModel.GetModel(aId);

            if (xcxrelation == null)
            {
                handingResult.code = "1";
                handingResult.Msg  = "未找到小程序授权资料";
                return(handingResult);
            }
            XcxTemplate xcxTemplate = XcxTemplateBLL.SingleModel.GetModel(xcxrelation.TId);

            if (xcxTemplate == null)
            {
                handingResult.code = "2";
                handingResult.Msg  = "未找到小程序的模板";
                return(handingResult);
            }

            switch (xcxTemplate.Type)
            {
            case (int)TmpType.小程序餐饮模板:
                Food store_Food = FoodBLL.SingleModel.GetModel($" appId = {xcxrelation.Id} {(storeId > 0 ? $" and Id = {storeId}" : "")} ");
                if (store_Food == null)
                {
                    handingResult.code = "3";
                    handingResult.Msg  = "还未开通店铺";
                    return(handingResult);
                }

                //修改设定
                FoodConfigModel foodConfig = store_Food.funJoinModel;
                foodConfig.discountRuleSwitch             = commonSetting.discountRuleSwitch;
                foodConfig.newUserFirstOrderDiscountMoney = commonSetting.newUserFirstOrderDiscountMoney;
                foodConfig.userFirstOrderDiscountMoney    = commonSetting.userFirstOrderDiscountMoney;
                foodConfig.sortQueueSwitch = commonSetting.sortQueueSwitch;
                foodConfig.sortNo_next     = commonSetting.sortNo_next;

                store_Food.configJson = JsonConvert.SerializeObject(foodConfig);
                store_Food.UpdateDate = DateTime.Now;

                handingResult.isok = FoodBLL.SingleModel.Update(store_Food, "configJson,UpdateDate");
                handingResult.Msg  = handingResult.isok ? "配置变更成功" : "配置变更失败";
                return(handingResult);

            case (int)TmpType.小程序多门店模板:
                FootBath store_MultiStore = FootBathBLL.SingleModel.GetModel($" appId = {xcxrelation.Id} {(storeId > 0 ? $" and Id = {storeId}" : " and HomeId = 0 ")}");
                if (store_MultiStore == null)
                {
                    handingResult.code = "3";
                    handingResult.Msg  = "还未开通店铺";
                    return(handingResult);
                }

                //读取配置
                SwitchModel switchModel = null;
                try
                {
                    switchModel = JsonConvert.DeserializeObject <SwitchModel>(store_MultiStore.SwitchConfig);
                }
                catch (Exception)
                {
                    switchModel = new SwitchModel();
                }
                switchModel.discountRuleSwitch             = commonSetting.discountRuleSwitch;
                switchModel.newUserFirstOrderDiscountMoney = commonSetting.newUserFirstOrderDiscountMoney;
                switchModel.userFirstOrderDiscountMoney    = commonSetting.userFirstOrderDiscountMoney;

                //修改设定
                store_MultiStore.SwitchConfig = JsonConvert.SerializeObject(switchModel);
                store_MultiStore.UpdateDate   = DateTime.Now;
                handingResult.isok            = FootBathBLL.SingleModel.Update(store_MultiStore, "SwitchConfig,UpdateDate");
                handingResult.Msg             = handingResult.isok ? "配置变更成功" : "配置变更失败";
                return(handingResult);

            case (int)TmpType.小程序电商模板:
            case (int)TmpType.小程序专业模板:
                Store store = StoreBLL.SingleModel.GetModel($" appId = {xcxrelation.Id} {(storeId > 0 ? $" and Id = {storeId}" : "")} ");
                if (store == null)
                {
                    handingResult.code = "3";
                    handingResult.Msg  = "还未开通店铺";
                    return(handingResult);
                }
                try
                {
                    store.funJoinModel = JsonConvert.DeserializeObject <StoreConfigModel>(store.configJson);
                }
                catch (Exception)
                {
                    store.funJoinModel = new StoreConfigModel();
                }

                storeId = store.Id;
                store.funJoinModel.sortQueueSwitch = commonSetting.sortQueueSwitch;
                store.funJoinModel.sortNo_next     = commonSetting.sortNo_next;
                store.configJson = JsonConvert.SerializeObject(store.funJoinModel);

                store.UpdateDate   = DateTime.Now;
                handingResult.isok = StoreBLL.SingleModel.Update(store, "configJson,UpdateDate");
                handingResult.Msg  = handingResult.isok ? "配置变更成功" : "配置变更失败";
                return(handingResult);

            default:
                handingResult.code = "3";
                handingResult.Msg  = "还未开通店铺";
                return(handingResult);
            }
        }
Exemple #15
0
        /// <summary>
        /// 开通独立小程序
        /// </summary>
        /// <param name="platApplyAppModel"></param>
        /// <param name="accountid"></param>
        /// <param name="uselength"></param>
        /// <param name="tid"></param>
        /// <param name="msg"></param>
        /// <returns></returns>
        public bool OpenStore(PlatApplyApp platApplyAppModel, string accountid, int uselength, int tid, ref string msg)
        {
            DateTime         nowtime = DateTime.Now;
            TransactionModel tran    = new TransactionModel();


            bool success = false;

            if (platApplyAppModel == null)
            {
                msg = "申请记录为空";
                return(false);
            }

            //用户基础数据,获取普通预存款

            AccountRelation accountrelation = AccountRelationBLL.SingleModel.GetModelByAccountId(accountid);

            Agentinfo agentinfo = AgentinfoBLL.SingleModel.GetModelByAccoundId(accountid);

            #region 模板跟模板价格
            XcxTemplate tempinfo = XcxTemplateBLL.SingleModel.GetModelByType((int)TmpType.小未平台子模版);
            if (tempinfo != null && agentinfo != null)
            {
                List <XcxTemplate> xcxlist = XcxTemplateBLL.SingleModel.GetRealPriceTemplateList($" id in ({tempinfo.Id})", agentinfo.id);
                if (xcxlist != null && xcxlist.Count > 0)
                {
                    //代理过期检验
                    AgentinfoBLL.SingleModel.CheckOutTime(ref xcxlist, agentinfo, 0, ref msg);
                    tempinfo = xcxlist[0];
                }
            }
            if (tempinfo == null)
            {
                msg = "模板数据为空";
                return(false);
            }
            #endregion

            #region 扣费
            //扣除总费用
            int sum = tempinfo.Price * uselength;
            //变更前金额
            int deposit = 0;
            //变更后的金额
            int afterdeposit = 0;
            //扣除代理费用
            if (agentinfo != null)
            {
                //首次开通免费
                if (AgentdepositLogBLL.SingleModel.IsFirstOpen(agentinfo.id, 2, 0))
                {
                    sum       = 0;
                    uselength = 1;
                }
                //变更前金额
                deposit = agentinfo.deposit;
                //判断余额是否满足扣费
                if (deposit + accountrelation.Deposit < sum)
                {
                    msg = "余额不足";
                    return(false);
                }

                //变更后金额,先扣除普通用户账号预存款
                if (accountrelation.Deposit > 0)
                {
                    if (accountrelation.Deposit >= sum)
                    {
                        afterdeposit = accountrelation.Deposit - sum;
                        tran.Add($"UPDATE AccountRelation set deposit={afterdeposit} ,updatetime='{nowtime}' where id={accountrelation.Id}");
                    }
                    else
                    {
                        //先扣除普通用户预存,再扣除代理商预存
                        afterdeposit = agentinfo.deposit - (sum - accountrelation.Deposit);
                        tran.Add($"UPDATE Agentinfo set deposit={afterdeposit} ,updateitme='{nowtime}' where id={agentinfo.id}");
                        tran.Add($"UPDATE AccountRelation set deposit=0 ,updatetime='{nowtime}' where id={accountrelation.Id}");
                    }
                }
                else
                {
                    afterdeposit = deposit - sum;
                    tran.Add($"UPDATE Agentinfo set deposit={afterdeposit} ,updateitme='{nowtime}' where id={agentinfo.id}");
                }
            }
            //扣除普通账号预存款
            else
            {
                //首次开通免费
                if (AgentdepositLogBLL.SingleModel.IsFirstOpen(0, 13, accountrelation.Id))
                {
                    sum = 0;
                }
                else
                {
                    sum = 100 * uselength;
                }
                //变更前金额
                deposit = accountrelation.Deposit;
                //判断余额是否满足扣费
                if (deposit < sum)
                {
                    msg = "余额不足";
                    return(false);
                }
                //变更后金额
                afterdeposit = deposit - sum;
                tran.Add($"UPDATE AccountRelation set deposit={afterdeposit} ,updatetime='{nowtime}' where id={accountrelation.Id}");
            }
            #endregion

            //名片管理登陆账号

            PlatMyCard mycardmodel = PlatMyCardBLL.SingleModel.GetModel(platApplyAppModel.MycardId);
            if (mycardmodel == null)
            {
                msg = "名片过期";
                return(false);
            }
            //判断是否已开通
            if (!string.IsNullOrEmpty(mycardmodel.LoginId))
            {
                msg = "该用户已开通过,请刷新看看";
                return(false);
            }

            //开通后台账号
            Account account = AccountBLL.SingleModel.WeiXinRegister("", 0, "", true, "", "", "小未平台开通独立小程序");
            if (account == null)
            {
                msg = "注册后台账号失败";
                return(false);
            }

            mycardmodel.LoginId    = account.LoginId;
            mycardmodel.UpdateTime = nowtime;
            tran.Add(PlatMyCardBLL.SingleModel.BuildUpdateSql(mycardmodel, "LoginId,UpdateTime"));

            //申请开通记录
            platApplyAppModel.UserId     = mycardmodel.UserId;
            platApplyAppModel.OpenState  = 1;
            platApplyAppModel.OpenTime   = nowtime;
            platApplyAppModel.UpdateTime = nowtime;
            tran.Add(base.BuildUpdateSql(platApplyAppModel, "OpenState,OpenTime,UpdateTime,UserId"));

            //开通独立小程序模板
            tran.Add($@"insert into XcxAppAccountRelation(TId,AccountId,AddTime,Url,price,outtime,agentid) 
            values({tempinfo.Id}, '{account.Id}', '{nowtime}', '{tempinfo.Link}', {tempinfo.Price}, '{nowtime.AddYears(uselength)}',{(agentinfo != null ? agentinfo.id : 0)})");

            //绑定店铺

            PlatStore platstoremodel = PlatStoreBLL.SingleModel.GetModel(platApplyAppModel.StoreId);
            if (platstoremodel == null)
            {
                msg = "店铺已过期,请刷新重试";
                return(false);
            }
            tran.Add($"update PlatStore set aid=(select last_insert_id()),UpdateTime='{nowtime}' where id={platstoremodel.Id}");

            #region 开通流水
            AgentdepositLog agentLog = new AgentdepositLog();
            agentLog.agentid       = agentinfo != null ? agentinfo.id : 0;
            agentLog.addtime       = nowtime;
            agentLog.templateCount = 1;
            agentLog.customerid    = account.Id.ToString();
            agentLog.tid           = tempinfo.Id;
            agentLog.type          = agentinfo != null ? (int)AgentDepositLogType.开通客户模板 : (int)AgentDepositLogType.普通用户开通模板;
            agentLog.templateCount = 1;
            agentLog.beforeDeposit = deposit;
            agentLog.cost          = sum;
            agentLog.Rid           = platApplyAppModel.BindAId;
            agentLog.acid          = agentinfo != null ? 0 : accountrelation.Id;
            agentLog.afterDeposit  = afterdeposit;
            string desc = $"客户:{mycardmodel.Name}  开通模板:{tempinfo.TName} 开通数量:1";
            agentLog.costdetail = desc;
            tran.Add(AgentdepositLogBLL.SingleModel.BuildAddSql(agentLog));
            #endregion

            //执行事务
            success = base.ExecuteTransactionDataCorect(tran.sqlArray, tran.ParameterArray);

            return(success);
        }
Exemple #16
0
        public ActionResult SaveExchangeRule(ExchangeRule exchangeRule)
        {
            if (exchangeRule.appId <= 0)
            {
                return(Json(new { isok = false, msg = "appId非法" }, JsonRequestBehavior.AllowGet));
            }
            if (dzaccount == null)
            {
                return(Json(new { isok = false, msg = "登录信息超时" }, JsonRequestBehavior.AllowGet));
            }
            XcxAppAccountRelation xcx = XcxAppAccountRelationBLL.SingleModel.GetModelByaccountidAndAppid(exchangeRule.appId, dzaccount.Id.ToString());

            if (xcx == null)
            {
                return(Json(new { isok = false, msg = "小程序未授权" }, JsonRequestBehavior.AllowGet));
            }

            XcxTemplate xcxTemplate = XcxTemplateBLL.SingleModel.GetModel($"id={xcx.TId}");

            if (xcxTemplate == null)
            {
                return(Json(new { isok = false, msg = "找不到小程序模板" }, JsonRequestBehavior.AllowGet));
            }



            int ruleTotalCount = ExchangeRuleBLL.SingleModel.GetCount($"appId={exchangeRule.appId} and state=0");

            if (ruleTotalCount >= 10)
            {
                return(Json(new { isok = false, msg = "最多设置10条规则" }, JsonRequestBehavior.AllowGet));
            }

            if (!Regex.IsMatch(exchangeRule.integral.ToString(), @"^\+?[1-9][0-9]*$"))
            {
                return(Json(new { isok = false, msg = "积分必须为大于零的整数" }, JsonRequestBehavior.AllowGet));
            }

            if (!Regex.IsMatch(exchangeRule.price.ToString(), @"^\+?[0-9][0-9]*$"))
            {
                return(Json(new { isok = false, msg = "金额不合法!" }, JsonRequestBehavior.AllowGet));
            }

            if (exchangeRule.ruleType == 1)
            {
                //表示选择部分商品消费赠送积分
                if (!StringHelper.IsNumByStrs(',', exchangeRule.goodids))
                {
                    return(Json(new { isok = false, msg = "请选择消费赠送金额的商品!" }, JsonRequestBehavior.AllowGet));
                }
            }

            if (exchangeRule.Id > 0)
            {
                ExchangeRule model = ExchangeRuleBLL.SingleModel.GetModel(exchangeRule.Id);
                if (model == null)
                {
                    return(Json(new { isok = false, msg = "数据不存在!" }, JsonRequestBehavior.AllowGet));
                }
                //表示更新
                exchangeRule.UpdateDate = DateTime.Now;
                if (ExchangeRuleBLL.SingleModel.Update(exchangeRule))
                {
                    return(Json(new { isok = true, msg = "更新成功!" }, JsonRequestBehavior.AllowGet));
                }
                return(Json(new { isok = false, msg = "更新失败!" }, JsonRequestBehavior.AllowGet));
            }
            else
            {
                if (xcxTemplate.Type == (int)TmpType.小程序专业模板)
                {
                    FunctionList functionList = new FunctionList();
                    int          industr      = xcx.VersionId;
                    functionList = FunctionListBLL.SingleModel.GetModel($"TemplateType={xcxTemplate.Type} and VersionId={industr}");
                    if (functionList == null)
                    {
                        return(Json(new { isok = false, msg = $"功能权限未设置" }, JsonRequestBehavior.AllowGet));
                    }
                    OperationMgr operationMgr = new OperationMgr();
                    if (!string.IsNullOrEmpty(functionList.OperationMgr))
                    {
                        operationMgr = JsonConvert.DeserializeObject <OperationMgr>(functionList.OperationMgr);
                    }

                    if (operationMgr.Integral == 1)
                    {
                        return(Json(new { isok = false, msg = $"请先升级到更高版本才能开启此功能" }, JsonRequestBehavior.AllowGet));
                    }
                }


                //表示新增
                exchangeRule.AddTime    = DateTime.Now;
                exchangeRule.UpdateDate = DateTime.Now;
                int ruleId = Convert.ToInt32(ExchangeRuleBLL.SingleModel.Add(exchangeRule));
                if (ruleId > 0)
                {
                    return(Json(new { isok = true, msg = "新增成功!", obj = ruleId }, JsonRequestBehavior.AllowGet));
                }
                return(Json(new { isok = false, msg = "新增失败!" }, JsonRequestBehavior.AllowGet));
            }
        }
Exemple #17
0
        public ActionResult OpenStore()
        {
            _returnData = new Return_Msg();

            int         aid              = Context.GetRequestInt("aid", 0);
            int         id               = Context.GetRequestInt("id", 0);
            int         type             = Context.GetRequestInt("type", 0);
            int         useLength        = Context.GetRequestInt("uselength", 0);
            XcxTemplate xcxtemplateModel = XcxTemplateBLL.SingleModel.GetModelByType((int)TmpType.小未平台子模版);

            if (xcxtemplateModel == null)
            {
                _returnData.Msg = "改模板还未上线";
                return(Json(_returnData));
            }
            if (id <= 0)
            {
                _returnData.Msg = "参数错误";
                return(Json(_returnData));
            }

            PlatApplyApp platApplyAppModel = PlatApplyAppBLL.SingleModel.GetModel(id);

            if (platApplyAppModel == null)
            {
                _returnData.Msg = "数据过期,请刷新重试";
                return(Json(_returnData));
            }

            XcxAppAccountRelation xcxrelation = XcxAppAccountRelationBLL.SingleModel.GetModel(aid);

            if (xcxrelation == null)
            {
                _returnData.Msg = "还未开通小未平台模板";
                return(Json(_returnData));
            }

            try
            {
                if (type == 0)
                {
                    string msg = "";
                    _returnData.isok = PlatApplyAppBLL.SingleModel.OpenStore(platApplyAppModel, xcxrelation.AccountId.ToString(), useLength, xcxtemplateModel.Id, ref msg);
                    _returnData.Msg  = _returnData.isok ? "开通成功" : (msg.Length <= 0 ? "开通失败" : msg);
                }
                else if (type == 1)
                {
                    string msg = "";
                    _returnData.isok = PlatApplyAppBLL.SingleModel.AddTimeLength(platApplyAppModel, xcxrelation.AccountId.ToString(), useLength, xcxtemplateModel.Id, ref msg);
                    _returnData.Msg  = _returnData.isok ? "续期成功" : (msg.Length <= 0 ? "续期失败" : msg);
                }
                else
                {
                    _returnData.Msg = "无效类型";
                }
            }
            catch (Exception ex)
            {
                log4net.LogHelper.WriteError(this.GetType(), ex);
                _returnData.Msg = "系统繁忙";
            }


            return(Json(_returnData));
        }
Exemple #18
0
        public ActionResult MiniAppSaveMoneySetManager(int appId, int?projectType = null, int?pageType = null)
        {
            if (dzaccount == null)
            {
                return(Json(new { isok = false, msg = "系统繁忙auth_null!" }, JsonRequestBehavior.AllowGet));
            }
            XcxAppAccountRelation app = XcxAppAccountRelationBLL.SingleModel.GetModelByaccountidAndAppid(appId, dzaccount.Id.ToString());

            if (app == null)
            {
                return(Json(new { isok = false, msg = "系统繁忙null!" }, JsonRequestBehavior.AllowGet));
            }
            XcxTemplate _tempLate = XcxTemplateBLL.SingleModel.GetModel(app.TId);

            if (_tempLate == null)
            {
                return(Json(new { isok = false, msg = "系统繁忙tempLate_null!" }, JsonRequestBehavior.AllowGet));
            }

            int saveMoneySwtich = 0;//储值开关
            int versionId       = 0;

            if (_tempLate.Type == (int)TmpType.小程序专业模板)
            {
                FunctionList functionList = new FunctionList();
                versionId    = app.VersionId;
                functionList = FunctionListBLL.SingleModel.GetModel($"TemplateType={_tempLate.Type} and VersionId={versionId}");
                if (functionList == null)
                {
                    return(View("PageError", new Return_Msg()
                    {
                        Msg = "功能权限未设置!", code = "500"
                    }));
                }
                if (!string.IsNullOrEmpty(functionList.ProductMgr))
                {
                    OperationMgr operationMgr = JsonConvert.DeserializeObject <OperationMgr>(functionList.OperationMgr);
                    saveMoneySwtich = operationMgr.SaveMoney;
                }
            }
            string souceFrom = Context.GetRequest("SouceFrom", string.Empty);

            ViewBag.SouceFrom       = souceFrom;
            ViewBag.saveMoneySwtich = saveMoneySwtich;
            ViewBag.versionId       = versionId;

            bool canSaveMoneyFunction = true;

            switch (_tempLate.Type)
            {
            case (int)TmpType.小程序电商模板:
                Store store = StoreBLL.SingleModel.GetModel($"appId={appId}");
                if (store == null)
                {
                    return(Json(new { isok = false, msg = "系统繁忙store_null!" }, JsonRequestBehavior.AllowGet));
                }
                try
                {
                    store.funJoinModel = JsonConvert.DeserializeObject <StoreConfigModel>(store.configJson);
                }
                catch (Exception)
                {
                    store.funJoinModel = new StoreConfigModel();
                }
                canSaveMoneyFunction = store.funJoinModel.canSaveMoneyFunction;
                break;

            case (int)TmpType.小程序餐饮模板:
                Food food = FoodBLL.SingleModel.GetModel($"appId={appId}");
                if (food == null)
                {
                    return(Json(new { isok = false, msg = "系统繁忙store_null!" }, JsonRequestBehavior.AllowGet));
                }
                canSaveMoneyFunction = food.funJoinModel.canSaveMoneyFunction;
                break;

            case (int)TmpType.小程序专业模板:
                EntSetting ent = EntSettingBLL.SingleModel.GetModel($"aid={appId}");
                if (ent == null)
                {
                    return(Json(new { isok = false, msg = "系统繁忙store_null!" }, JsonRequestBehavior.AllowGet));
                }

                canSaveMoneyFunction = ent.funJoinModel.canSaveMoneyFunction;
                break;

            case (int)TmpType.小程序足浴模板:
                FootBath footbath = FootBathBLL.SingleModel.GetModel($"appId={appId}");
                if (footbath == null)
                {
                    return(Json(new { isok = false, msg = "系统繁忙store_null!" }, JsonRequestBehavior.AllowGet));
                }
                footbath.switchModel = JsonConvert.DeserializeObject <SwitchModel>(footbath.SwitchConfig);
                canSaveMoneyFunction = footbath.switchModel.canSaveMoneyFunction;
                break;

            case (int)TmpType.小程序多门店模板:
                FootBath multiStore = FootBathBLL.SingleModel.GetModel($"appId={appId} and HomeId = 0 ");
                if (multiStore == null)
                {
                    return(Json(new { isok = false, msg = "系统繁忙store_null!" }, JsonRequestBehavior.AllowGet));
                }
                multiStore.switchModel = JsonConvert.DeserializeObject <SwitchModel>(multiStore.SwitchConfig) ?? new SwitchModel();
                canSaveMoneyFunction   = multiStore.switchModel.canSaveMoneyFunction;
                break;

            case (int)TmpType.小未平台子模版:
                PlatStore platStore = PlatStoreBLL.SingleModel.GetPlatStore(app.Id, 2);

                if (platStore == null)
                {
                    return(Json(new { isok = false, msg = "店铺不存在!" }, JsonRequestBehavior.AllowGet));
                }
                PlatStoreSwitchModel switchModel = new PlatStoreSwitchModel();

                if (!string.IsNullOrEmpty(platStore.SwitchConfig))
                {
                    switchModel = Newtonsoft.Json.JsonConvert.DeserializeObject <PlatStoreSwitchModel>(platStore.SwitchConfig);
                }
                canSaveMoneyFunction = switchModel.SaveMoneyPay;
                break;
            }

            ViewBag.canSaveMoneyFuntion = canSaveMoneyFunction;
            ViewBag.appId = appId;
            if (projectType.HasValue)
            {
                ViewBag.typeId = projectType.Value;
            }
            if (pageType.HasValue)
            {
                ViewBag.typeId = pageType.Value;
            }

            return(View());
        }
Exemple #19
0
        public ActionResult ModifyMeetMoneySwitchState(int appId, int storeId = 0, bool discountRuleSwitch = false)
        {
            Return_Msg handingResult = new Return_Msg();

            handingResult.isok = true;
            handingResult.code = "0";
            handingResult.Msg  = discountRuleSwitch ? "已开启" : "已关闭";

            XcxAppAccountRelation xcxrelation = XcxAppAccountRelationBLL.SingleModel.GetModel(appId);

            if (xcxrelation == null)
            {
                handingResult.code = "1";
                handingResult.Msg  = "未找到小程序授权资料";
                return(Json(handingResult, JsonRequestBehavior.AllowGet));
            }
            XcxTemplate xcxTemplate = XcxTemplateBLL.SingleModel.GetModel(xcxrelation.TId);

            if (xcxTemplate == null)
            {
                handingResult.code = "2";
                handingResult.Msg  = "未找到小程序的模板";
                return(Json(handingResult, JsonRequestBehavior.AllowGet));
            }

            bool isUpdateSuccess = false;

            switch (xcxTemplate.Type)
            {
            case (int)TmpType.小程序餐饮模板:
                Food store_Food = FoodBLL.SingleModel.GetModel($" appId = {xcxrelation.Id} {(storeId > 0 ? $" and Id = {storeId}" : "")} ");
                if (store_Food == null)
                {
                    handingResult.code = "3";
                    handingResult.Msg  = "还未开通店铺";
                    return(Json(handingResult, JsonRequestBehavior.AllowGet));
                }

                //修改设定
                FoodConfigModel foodConfig = store_Food.funJoinModel;
                foodConfig.discountRuleSwitch = discountRuleSwitch;

                store_Food.configJson = JsonConvert.SerializeObject(foodConfig);
                store_Food.UpdateDate = DateTime.Now;

                isUpdateSuccess = FoodBLL.SingleModel.Update(store_Food, "configJson,UpdateDate");
                break;

            case (int)TmpType.小程序多门店模板:
                FootBath store_MultiStore = FootBathBLL.SingleModel.GetModel($" appId = {xcxrelation.Id} {(storeId > 0 ? $" and Id = {storeId}" : " and HomeId = 0 ")}");
                if (store_MultiStore == null)
                {
                    handingResult.code = "3";
                    handingResult.Msg  = "还未开通店铺";
                    return(Json(handingResult, JsonRequestBehavior.AllowGet));
                }

                //读取配置
                SwitchModel switchModel = null;
                try
                {
                    switchModel = JsonConvert.DeserializeObject <SwitchModel>(store_MultiStore.SwitchConfig);
                }
                catch (Exception)
                {
                    switchModel = new SwitchModel();
                }
                switchModel.discountRuleSwitch = discountRuleSwitch;

                //修改设定
                store_MultiStore.SwitchConfig = JsonConvert.SerializeObject(switchModel);
                store_MultiStore.UpdateDate   = DateTime.Now;
                isUpdateSuccess = FootBathBLL.SingleModel.Update(store_MultiStore, "SwitchConfig,UpdateDate");
                break;

            default:
                handingResult.code = "3";
                handingResult.Msg  = "还未开通店铺";
                return(Json(handingResult, JsonRequestBehavior.AllowGet));
            }

            if (!isUpdateSuccess)
            {
                handingResult.isok = false;
                handingResult.code = "-1";
                handingResult.Msg  = "修改失败,请重试!";
            }
            return(Json(handingResult, JsonRequestBehavior.AllowGet));
        }
Exemple #20
0
        public ActionResult AddMiniAppSaveMoneySet(int appId, SaveMoneySet model)
        {
            XcxAppAccountRelation app = XcxAppAccountRelationBLL.SingleModel.GetModelByaccountidAndAppid(appId, dzaccount.Id.ToString());

            if (app == null)
            {
                return(Json(new { isok = false, msg = "系统繁忙null!" }, JsonRequestBehavior.AllowGet));
            }

            XcxTemplate _tempLate = XcxTemplateBLL.SingleModel.GetModel(app.TId);

            if (_tempLate == null)
            {
                return(Json(new { isok = false, msg = "系统繁忙tempLate_null!" }));
            }
            if (_tempLate.Type == (int)TmpType.小程序专业模板)
            {
                FunctionList functionList = new FunctionList();
                int          industr      = app.VersionId;
                functionList = FunctionListBLL.SingleModel.GetModel($"TemplateType={_tempLate.Type} and VersionId={industr}");
                if (functionList == null)
                {
                    return(Json(new { isok = false, msg = "此功能未开启" }));
                }

                OperationMgr operationMgr = new OperationMgr();
                if (!string.IsNullOrEmpty(functionList.OperationMgr))
                {
                    operationMgr = JsonConvert.DeserializeObject <OperationMgr>(functionList.OperationMgr);
                }
                if (operationMgr.SaveMoney == 1)//表示关闭了储值使用功能
                {
                    return(Json(new { isok = false, msg = "请升级更高版本才能使用此功能!" }));
                }
            }
            if (dzaccount == null)
            {
                return(Json(new { isok = false, msg = "系统繁忙auth_null!" }, JsonRequestBehavior.AllowGet));
            }

            if (model.JoinMoney <= 0 || model.JoinMoney > 9999999)
            {
                return(Json(new { isok = false, msg = "充值金额请设定0.01 ~ 99999.99!" }, JsonRequestBehavior.AllowGet));
            }

            if (model.GiveMoney < 0 || model.GiveMoney > 9999999)
            {
                return(Json(new { isok = false, msg = "赠送金额请设定0.00 ~ 99999.99!" }, JsonRequestBehavior.AllowGet));
            }
            //int resultInt = 0;//
            List <SaveMoneySet> List = SaveMoneySetBLL.SingleModel.getListByAppId(app.AppId);

            if (model.Id == 0)//添加
            {
                if (List.Count >= 20)
                {
                    return(Json(new { isok = false, msg = "目前最多能添加20个储值项目" }));
                }
                if (List.Any(m => m.JoinMoney == model.JoinMoney && m.GiveMoney == model.GiveMoney))
                {
                    return(Json(new { isok = false, msg = "已存在相同储值项目 , 请重新添加" }));
                }
                model.AppId       = app.AppId;
                model.SetName     = $"充{model.JoinMoneyStr}送{model.GiveMoneyStr}";
                model.AmountMoney = model.JoinMoney + model.GiveMoney;
                model.CreateDate  = DateTime.Now;
                model.State       = 1;
                object result = SaveMoneySetBLL.SingleModel.Add(model);
                if (int.Parse(result.ToString()) > 0)
                {
                    return(Json(new { isok = true, msg = "添加成功!", newid = result }, JsonRequestBehavior.AllowGet));
                }
            }


            return(Json(new { isok = false, msg = "系统错误!" }));
        }
Exemple #21
0
        public ActionResult changeCanSaveMoenySetting(int appId, bool canSaveMoneyFunction)
        {
            if (dzaccount == null)
            {
                return(Json(new { isok = false, msg = "系统繁忙auth_null!" }));
            }
            XcxAppAccountRelation app = XcxAppAccountRelationBLL.SingleModel.GetModelByaccountidAndAppid(appId, dzaccount.Id.ToString());

            if (app == null)
            {
                return(Json(new { isok = false, msg = "系统繁忙null!" }));
            }
            XcxTemplate _tempLate = XcxTemplateBLL.SingleModel.GetModel(app.TId);

            if (_tempLate == null)
            {
                return(Json(new { isok = false, msg = "系统繁忙tempLate_null!" }));
            }

            #region 专业版 版本控制
            if (_tempLate.Type == (int)TmpType.小程序专业模板)
            {
                FunctionList functionList = new FunctionList();
                int          industr      = app.VersionId;
                functionList = FunctionListBLL.SingleModel.GetModel($"TemplateType={_tempLate.Type} and VersionId={industr}");
                if (functionList == null)
                {
                    return(Json(new { isok = false, msg = "此功能未开启" }));
                }

                OperationMgr operationMgr = new OperationMgr();
                if (!string.IsNullOrEmpty(functionList.OperationMgr))
                {
                    operationMgr = JsonConvert.DeserializeObject <OperationMgr>(functionList.OperationMgr);
                }
                if (operationMgr.SaveMoney == 1)//表示关闭了储值使用功能
                {
                    return(Json(new { isok = false, msg = "请升级更高版本才能使用此功能!" }));
                }
            }
            #endregion

            bool isSuccess = true;

            switch (_tempLate.Type)
            {
            case (int)TmpType.小程序电商模板:
                Store store = StoreBLL.SingleModel.GetModel($"appId={appId}");
                if (store == null)
                {
                    return(Json(new { isok = false, msg = "系统繁忙store_null!" }, JsonRequestBehavior.AllowGet));
                }
                StoreConfigModel newConfig = null;
                try
                {
                    newConfig = JsonConvert.DeserializeObject <StoreConfigModel>(store.configJson);
                }
                catch (Exception)
                {
                    newConfig = new StoreConfigModel();
                }

                newConfig.canSaveMoneyFunction = canSaveMoneyFunction;
                store.configJson = JsonConvert.SerializeObject(newConfig);

                isSuccess = StoreBLL.SingleModel.Update(store, "configJson");
                break;

            case (int)TmpType.小程序餐饮模板:
                Food food = FoodBLL.SingleModel.GetModel($"appId={appId}");
                if (food == null)
                {
                    return(Json(new { isok = false, msg = "系统繁忙store_null!" }, JsonRequestBehavior.AllowGet));
                }
                FoodConfigModel foodConfig = food.funJoinModel;
                foodConfig.canSaveMoneyFunction = canSaveMoneyFunction;
                food.configJson = JsonConvert.SerializeObject(foodConfig);

                isSuccess = FoodBLL.SingleModel.Update(food, "configJson");
                break;

            case (int)TmpType.小程序专业模板:
                EntSetting ent = EntSettingBLL.SingleModel.GetModel($"aid={appId}");
                if (ent == null)
                {
                    return(Json(new { isok = false, msg = "系统繁忙store_null!" }, JsonRequestBehavior.AllowGet));
                }


                EntConfigModel entConfig = ent.funJoinModel;
                entConfig.canSaveMoneyFunction = canSaveMoneyFunction;
                ent.configJson = JsonConvert.SerializeObject(entConfig);

                isSuccess = EntSettingBLL.SingleModel.Update(ent, "configJson");
                break;

            case (int)TmpType.小程序足浴模板:
                FootBath footbath = FootBathBLL.SingleModel.GetModel($"appId={appId}");
                if (footbath == null)
                {
                    return(Json(new { isok = false, msg = "系统繁忙store_null!" }, JsonRequestBehavior.AllowGet));
                }
                footbath.switchModel = JsonConvert.DeserializeObject <SwitchModel>(footbath.SwitchConfig);
                footbath.switchModel.canSaveMoneyFunction = canSaveMoneyFunction;
                footbath.SwitchConfig = JsonConvert.SerializeObject(footbath.switchModel);
                isSuccess             = FootBathBLL.SingleModel.Update(footbath, "SwitchConfig");
                break;

            case (int)TmpType.小程序多门店模板:
                FootBath multiStore = FootBathBLL.SingleModel.GetModel($"appId={appId} and HomeId = 0 ");
                if (multiStore == null)
                {
                    return(Json(new { isok = false, msg = "系统繁忙store_null!" }, JsonRequestBehavior.AllowGet));
                }
                multiStore.switchModel = JsonConvert.DeserializeObject <SwitchModel>(multiStore.SwitchConfig) ?? new SwitchModel();
                multiStore.switchModel.canSaveMoneyFunction = canSaveMoneyFunction;
                multiStore.SwitchConfig = JsonConvert.SerializeObject(multiStore.switchModel);
                isSuccess = FootBathBLL.SingleModel.Update(multiStore, "SwitchConfig");
                break;

            case (int)TmpType.小未平台子模版:
                PlatStore platStore = PlatStoreBLL.SingleModel.GetPlatStore(app.Id, 2);

                if (platStore == null)
                {
                    return(Json(new { isok = false, msg = "店铺不存在!" }, JsonRequestBehavior.AllowGet));
                }
                PlatStoreSwitchModel switchModel = new PlatStoreSwitchModel();

                if (!string.IsNullOrEmpty(platStore.SwitchConfig))
                {
                    switchModel = JsonConvert.DeserializeObject <PlatStoreSwitchModel>(platStore.SwitchConfig);
                }
                switchModel.SaveMoneyPay = canSaveMoneyFunction;
                platStore.SwitchConfig   = JsonConvert.SerializeObject(switchModel);
                platStore.UpdateTime     = DateTime.Now;
                isSuccess = PlatStoreBLL.SingleModel.Update(platStore, "UpdateTime,SwitchConfig");
                break;
            }
            return(Json(new { isok = isSuccess, msg = isSuccess ? "修改成功" : "修改失败" }));
        }
Exemple #22
0
        public ActionResult SaveExchangePlayCardConfig(ExchangePlayCardConfig model)
        {
            result = new Return_Msg();
            int appId = Context.GetRequestInt("appId", 0);

            if (dzaccount == null)
            {
                result.Msg = "登录信息超时";
                return(Json(result));
            }

            XcxAppAccountRelation xcx = XcxAppAccountRelationBLL.SingleModel.GetModelByaccountidAndAppid(appId, dzaccount.Id.ToString());

            if (xcx == null)
            {
                result.Msg = "小程序未授权";
                return(Json(result));
            }


            XcxTemplate xcxTemplate = XcxTemplateBLL.SingleModel.GetModel($"id={xcx.TId}");

            if (xcxTemplate == null)
            {
                result.Msg = "找不到小程序模板";
                return(Json(result));
            }

            if (xcxTemplate.Type == (int)TmpType.小程序专业模板)
            {
                FunctionList functionList = new FunctionList();
                int          industr      = xcx.VersionId;
                functionList = FunctionListBLL.SingleModel.GetModel($"TemplateType={xcxTemplate.Type} and VersionId={industr}");
                if (functionList == null)
                {
                    result.Msg = "功能权限未设置";
                    return(Json(result));
                }

                OperationMgr operationMgr = new OperationMgr();
                if (!string.IsNullOrEmpty(functionList.OperationMgr))
                {
                    operationMgr = JsonConvert.DeserializeObject <OperationMgr>(functionList.OperationMgr);
                }

                if (operationMgr.Integral == 1)
                {
                    result.Msg = "请先升级到更高版本才能开启此功能";
                    return(Json(result));
                }
            }

            Store store = StoreBLL.SingleModel.GetModelByRid(appId);

            if (store == null)
            {
                result.Msg = $"店铺配置不存在";
                return(Json(result));
            }
            ExchangePlayCardConfig exchangePlayCardConfig = new ExchangePlayCardConfig();

            store.funJoinModel = JsonConvert.DeserializeObject <StoreConfigModel>(store.configJson) ?? new StoreConfigModel();//若为 null 则new一个新的配置
            if (store.funJoinModel != null)
            {
                store.funJoinModel.ExchangePlayCardConfig = JsonConvert.SerializeObject(model);
                store.configJson = JsonConvert.SerializeObject(store.funJoinModel);
            }

            if (StoreBLL.SingleModel.Update(store, "configJson"))
            {
                result.Msg = $"保存成功";
                return(Json(result));
            }
            else
            {
                result.Msg = $"保存失败";
                return(Json(result));
            }
        }
Exemple #23
0
        /// <summary>
        /// 获取运费
        /// </summary>
        /// <param name="storeid"></param>
        /// <param name="aid"></param>
        /// <param name="lat"></param>
        /// <param name="lnt"></param>
        /// <param name="orderprice"></param>
        /// <returns></returns>
        public int GetKPZFee(int storeid, int aid, string address, string lat, string lnt, int orderprice, ref string msg)
        {
            int fee = 0;
            KPZResult <KPZFee> result = new KPZResult <KPZFee>();

            if (!string.IsNullOrEmpty(address))
            {
                //再请求一次腾讯地图,获取准确的坐标
                AddressApi addressModel = AddressHelper.GetLngAndLatByAddress(address);
                if (addressModel != null && addressModel.result != null && addressModel.result.location != null)
                {
                    lnt = addressModel.result.location.lng.ToString();
                    lat = addressModel.result.location.lat.ToString();
                }
                else
                {
                    msg = "快跑者配送:获取腾讯地址失败";
                    return(0);
                }
            }

            XcxAppAccountRelation xcxrelation = XcxAppAccountRelationBLL.SingleModel.GetModel(aid);

            if (xcxrelation == null)
            {
                msg = "快跑者配送:权限模板不存在";
                return(fee);
            }

            XcxTemplate xcxtemplate = XcxTemplateBLL.SingleModel.GetModel(xcxrelation.TId);

            if (xcxtemplate == null)
            {
                msg = "快跑者配送:小程序模板不存在";
                return(fee);
            }

            KPZStoreRelation storerelation = KPZStoreRelationBLL.SingleModel.GetModelBySidAndAid(aid, storeid);

            if (storerelation == null)
            {
                msg = "快跑者配送:未设置快跑者配送配置";
                return(fee);
            }

            int    shopid  = storerelation.Id;
            string sendtag = lnt + "," + lat;
            //店铺信息
            ShopInfo shopinfo = GetStoreAddressPoint(storerelation.AId, storerelation.StoreId, xcxtemplate.Type);
            string   payfee   = "0";

            if (shopinfo.ShopTag.Length <= 0)
            {
                msg = "快跑者配送:店铺经纬不能为空";
                return(fee);
            }

            if (sendtag.Length <= 1)
            {
                msg = "快跑者配送:取货经纬不能为空";
                return(fee);
            }
            result = KPZApi.GetFee(shopid, sendtag, shopinfo.ShopTag, (orderprice * 0.01).ToString("0.00"), payfee, storerelation.TeamToken);

            if (result == null)
            {
                log4net.LogHelper.WriteInfo(this.GetType(), "快跑者配送:返回结果为null,");
                return(fee);
            }
            if (result.data == null)
            {
                log4net.LogHelper.WriteInfo(this.GetType(), "快跑者配送:返回运费为null,");
                return(fee);
            }
            if (result.code == 200)
            {
                fee = Convert.ToInt32(result.data.pay_fee);
                return(fee);
            }
            else
            {
                msg = result.message;
            }

            if (result == null)
            {
                result      = new KPZResult <KPZFee>();
                result.code = 204;
            }
            //msg = "获取运费出错";

            log4net.LogHelper.WriteInfo(this.GetType(), $"快跑者配送:请求参数,shopid【{shopid}】sendtag【{sendtag}】gettag【{shopinfo.ShopTag}】orderprice【{orderprice}】payfee【{payfee}】" + JsonConvert.SerializeObject(result));

            return(fee);
        }
Exemple #24
0
        /// <summary>
        /// 根据传入aId及storeId去读取店铺资料配置,自动查出默认关联的店铺的配置
        /// </summary>
        /// <param name="aId"></param>
        /// <param name="storeId">店铺ID,可传0,传0默认查出关联的店铺</param>
        /// <param name="errorMsg"></param>
        /// <param name="CommonSetting">公共配置</param>
        /// <returns></returns>
        public static CommonSetting GetCommonSetting(int aId, ref int storeId, ref string errorMsg)
        {
            CommonSetting         setting     = new CommonSetting();
            XcxAppAccountRelation xcxrelation = XcxAppAccountRelationBLL.SingleModel.GetModel(aId);

            if (xcxrelation == null)
            {
                errorMsg = "未找到小程序授权资料";
                return(setting);
            }
            XcxTemplate xcxTemplate = XcxTemplateBLL.SingleModel.GetModel(xcxrelation.TId);

            if (xcxTemplate == null)
            {
                errorMsg = "未找到小程序的模板";
                return(setting);
            }
            switch (xcxTemplate.Type)
            {
            case (int)TmpType.小程序餐饮模板:
                Food store_Food = FoodBLL.SingleModel.GetModel($" appId = {xcxrelation.Id} {(storeId > 0 ? $" and Id = {storeId}" : "")} ");
                if (store_Food == null)
                {
                    errorMsg = "还未开通店铺";
                    return(setting);
                }
                storeId = store_Food.Id;

                setting.discountRuleSwitch             = store_Food.funJoinModel.discountRuleSwitch;
                setting.newUserFirstOrderDiscountMoney = store_Food.funJoinModel.newUserFirstOrderDiscountMoney;
                setting.userFirstOrderDiscountMoney    = store_Food.funJoinModel.userFirstOrderDiscountMoney;
                setting.sortQueueSwitch = store_Food.funJoinModel.sortQueueSwitch;
                setting.sortNo_next     = store_Food.funJoinModel.sortNo_next;
                break;

            case (int)TmpType.小程序多门店模板:
                FootBath store_MultiStore = FootBathBLL.SingleModel.GetModel($" appId = {xcxrelation.Id} {(storeId > 0 ? $" and Id = {storeId}" : " and HomeId = 0 ")}");
                if (store_MultiStore == null)
                {
                    errorMsg = "还未开通店铺";
                    return(setting);
                }
                storeId = store_MultiStore.Id;

                //读取配置
                SwitchModel switchModel = null;
                try
                {
                    switchModel = JsonConvert.DeserializeObject <SwitchModel>(store_MultiStore.SwitchConfig);
                }
                catch (Exception)
                {
                    switchModel = new SwitchModel();
                }
                setting.discountRuleSwitch             = switchModel.discountRuleSwitch;
                setting.newUserFirstOrderDiscountMoney = switchModel.newUserFirstOrderDiscountMoney;
                setting.userFirstOrderDiscountMoney    = switchModel.userFirstOrderDiscountMoney;
                break;

            case (int)TmpType.小程序电商模板:
            case (int)TmpType.小程序专业模板:
                Store store = StoreBLL.SingleModel.GetModel($" appId = {xcxrelation.Id} {(storeId > 0 ? $" and Id = {storeId}" : "")} ");
                if (store == null)
                {
                    errorMsg = "还未开通店铺";
                    return(setting);
                }
                try
                {
                    store.funJoinModel = JsonConvert.DeserializeObject <StoreConfigModel>(store.configJson);
                }
                catch (Exception)
                {
                    store.funJoinModel = new StoreConfigModel();
                }

                storeId = store.Id;
                setting.sortQueueSwitch = store.funJoinModel.sortQueueSwitch;
                setting.sortNo_next     = store.funJoinModel.sortNo_next;
                break;

            default:
                errorMsg = "还未开通店铺";
                return(setting);
            }
            return(setting);
        }
Exemple #25
0
        public ActionResult ExchangeRuleList(int appId = 0)
        {
            if (appId <= 0)
            {
                return(View("PageError", new Return_Msg()
                {
                    Msg = "参数错误!", code = "500"
                }));
            }
            if (dzaccount == null)
            {
                return(Redirect("/dzhome/login"));
            }
            XcxAppAccountRelation xcx = XcxAppAccountRelationBLL.SingleModel.GetModelByaccountidAndAppid(appId, dzaccount.Id.ToString());

            if (xcx == null)
            {
                return(View("PageError", new Return_Msg()
                {
                    Msg = "小程序未授权!", code = "403"
                }));
            }
            XcxTemplate xcxTemplate = XcxTemplateBLL.SingleModel.GetModel($"id={xcx.TId}");

            if (xcxTemplate == null)
            {
                return(View("PageError", new Return_Msg()
                {
                    Msg = "小程序模板不存在!", code = "500"
                }));
            }

            Store storeModel = StoreBLL.SingleModel.GetModelByAId(appId);

            if (storeModel == null)
            {
                return(View("PageError", new Return_Msg()
                {
                    Msg = "店铺信息错误!", code = "403"
                }));
            }

            int integralSwtich = 0;//积分开关
            int versionId      = 0;

            if (xcxTemplate.Type == (int)TmpType.小程序专业模板)
            {
                FunctionList functionList = new FunctionList();
                versionId    = xcx.VersionId;
                functionList = FunctionListBLL.SingleModel.GetModel($"TemplateType={xcxTemplate.Type} and VersionId={versionId}");
                if (functionList == null)
                {
                    return(View("PageError", new Return_Msg()
                    {
                        Msg = "功能权限未设置!", code = "500"
                    }));
                }
                if (!string.IsNullOrEmpty(functionList.OperationMgr))
                {
                    OperationMgr operationMgr = JsonConvert.DeserializeObject <OperationMgr>(functionList.OperationMgr);
                    integralSwtich = operationMgr.Integral;
                }
            }

            ViewBag.integralSwtich = integralSwtich;
            ViewBag.versionId      = versionId;

            ViewBag.PageType = xcxTemplate.Type;
            ViewBag.appId    = appId;

            List <ExchangeRule> listRule = ExchangeRuleBLL.SingleModel.GetList($"appId={appId} and state=0");

            listRule.ForEach(x =>
            {
                if (x.ruleType == 1 && !string.IsNullOrEmpty(x.goodids))
                {
                    List <EntGoods> listgoods = EntGoodsBLL.SingleModel.GetList($" id in({x.goodids})");
                    listgoods.ForEach(y =>
                    {
                        x.goodslist.Add(new PickGood {
                            Id = y.id, GoodsName = y.name, ImgUrl = y.img, sel = true, showtime = y.showUpdateTime
                        });
                    });
                }
            });
            ExchangePlayCardConfig exchangePlayCardConfig = new ExchangePlayCardConfig();

            if (string.IsNullOrEmpty(storeModel.configJson))
            {
                storeModel.funJoinModel = new StoreConfigModel();
            }
            else
            {
                storeModel.funJoinModel = JsonConvert.DeserializeObject <StoreConfigModel>(storeModel.configJson);
            }
            if (!string.IsNullOrEmpty(storeModel.funJoinModel.ExchangePlayCardConfig))
            {
                exchangePlayCardConfig = JsonConvert.DeserializeObject <ExchangePlayCardConfig>(storeModel.funJoinModel.ExchangePlayCardConfig);
            }

            ViewBag.ExchangePlayCardConfig = exchangePlayCardConfig;

            return(View(listRule));
        }
Exemple #26
0
        /// <summary>
        /// 多门店版开通日志整理
        /// </summary>
        /// <param name="openType"></param>
        /// <param name="cost"></param>
        /// <param name="desc"></param>
        /// <param name="agentLog"></param>
        /// <param name="xcx"></param>
        /// <param name="userName"></param>
        /// <param name="dName"></param>
        /// <param name="isDistribution"></param>
        public void GetOpenMulStoreInfo(int openType, ref int cost, ref string desc, ref AgentdepositLog agentLog, XcxTemplate xcx, string userName, string dName, int isDistribution)
        {
            switch (openType)
            {
            case (int)AgentDepositLogType.开通新门店:
                //帮客户开通分店
                cost             = xcx.sumprice;
                agentLog.OutTime = DateTime.Now.AddYears(1);
                desc             = isDistribution == 0?($"客户:{userName}  新开通门店数量:{xcx.storecount}"):($"分销商:{dName} 为客户{userName}新开通门店数量:{xcx.storecount}");
                break;

            case 7:
                //帮客户续费门店
                cost             = xcx.sumprice;
                agentLog.OutTime = DateTime.Parse(xcx.outtime);
                desc             = $"客户:{userName}  {xcx.TName}门店续期至{xcx.outtime}";
                break;

            default:
                //开通多门店模板
                cost += (xcx.storecount - xcx.SCount) * xcx.SPrice;
                desc  = isDistribution == 0 ? ($"客户:{userName}  开通模板:{xcx.TName} 开通数量:{xcx.buycount} 门店数量:{xcx.storecount}"):($"分销商:{dName}  开通模板:{xcx.TName} 开通数量:{xcx.buycount} 门店数量:{xcx.storecount}");
                break;
            }
        }
Exemple #27
0
        public void AddagentinfoLog(Agentinfo agentinfo, List <XcxTemplate> xcxList, int deposit, int parentDeposit, string userName, string userId, int openType = 0, int aid = 0)
        {
            if (xcxList == null || xcxList.Count <= 0)
            {
                return;
            }
            StringBuilder   sb       = new StringBuilder();
            AgentdepositLog agentLog = new AgentdepositLog();
            DateTime        date     = DateTime.Now;

            agentLog.agentid       = agentinfo.id;
            agentLog.addtime       = date;
            agentLog.templateCount = 1;
            agentLog.customerid    = userId;
            agentLog.Rid           = aid;
            foreach (XcxTemplate xcx in xcxList)
            {
                int cost = xcx.Price * xcx.year * xcx.buycount;
                if (xcx.Type == (int)TmpType.小程序专业模板)
                {
                    xcx.TName += GetVerName(xcx.VersionId);
                }

                string desc = $"客户:{userName}  开通模板:{xcx.TName} 开通数量:" + xcx.buycount;
                //整理消费日志
                GetCommondLog(ref openType, ref cost, ref desc, ref agentLog, xcx, userName, "", 0);

                agentLog.tid           = xcx.Id;
                agentLog.type          = openType > 0 ? openType : 2;
                agentLog.templateCount = openType > 0 ? xcx.storecount : xcx.buycount;
                agentLog.beforeDeposit = deposit;
                agentLog.cost          = cost;
                agentLog.afterDeposit  = deposit - cost;
                deposit             = deposit - cost;
                agentLog.costdetail = desc;
                sb.Append(base.BuildAddSql(agentLog));
            }
            if (agentinfo.userLevel == 1)
            {
                try
                {
                    Distribution       distribution    = DistributionBLL.SingleModel.GetModel($"agentid={agentinfo.id}");
                    string             tids            = string.Join(",", xcxList.Select(x => x.Id).ToArray());
                    List <XcxTemplate> parent_xcxlist  = XcxTemplateBLL.SingleModel.GetRealPriceTemplateList($" id in ({tids})", distribution.parentAgentId);
                    AgentdepositLog    parent_agentLog = new AgentdepositLog();
                    parent_agentLog.agentid       = distribution.parentAgentId;
                    parent_agentLog.addtime       = date;
                    parent_agentLog.templateCount = 1;
                    parent_agentLog.customerid    = agentinfo.id.ToString();
                    foreach (XcxTemplate xcx in parent_xcxlist)
                    {
                        XcxTemplate model = xcxList.Where(w => w.Id == xcx.Id).FirstOrDefault();
                        xcx.year       = model != null ? model.year : 1;
                        xcx.storecount = model.storecount;
                        xcx.buycount   = model.buycount;
                        xcx.VersionId  = model.VersionId;
                        xcx.SCount     = model.SCount;
                        if (xcx.Type == (int)TmpType.小程序专业模板)
                        {
                            xcx.TName += GetVerName(xcx.VersionId);
                        }

                        int cost = xcx.Price * xcx.year * xcx.buycount;
                        if (xcx.Type == (int)TmpType.小程序专业模板)
                        {
                            //重新计算价格专业版版本级别

                            VersionType m = XcxTemplateBLL.SingleModel.GetRealPriceVersionTemplateList(xcx.Type, distribution.parentAgentId).FirstOrDefault(x => x.VersionId == xcx.VersionId);
                            cost = Convert.ToInt32(m.VersionPrice) * xcx.year * xcx.buycount;
                        }

                        string desc = $"分销商:{distribution.name}  开通模板:{xcx.TName} 开通数量:" + xcx.buycount;
                        //整理消费日志
                        GetCommondLog(ref openType, ref cost, ref desc, ref agentLog, xcx, userName, distribution.name, 1);

                        parent_agentLog.tid           = xcx.Id;
                        parent_agentLog.type          = openType > 0 ? openType : 3;
                        parent_agentLog.templateCount = xcx.buycount;
                        parent_agentLog.beforeDeposit = parentDeposit;
                        parent_agentLog.cost          = cost;
                        parent_agentLog.afterDeposit  = parentDeposit - cost;
                        parentDeposit = parentDeposit - cost;
                        parent_agentLog.costdetail = desc;
                        sb.Append(base.BuildAddSql(parent_agentLog));
                    }
                }
                catch (Exception ex)
                {
                    log4net.LogHelper.WriteInfo(this.GetType(), ex.Message);
                }
            }
            base.ExecuteNonQuery(sb.ToString());
        }
Exemple #28
0
        /// <summary>
        /// 砍价发货
        /// </summary>
        /// <param name="bargainUser"></param>
        /// <param name="bargain"></param>
        /// <param name="appId"></param>
        /// <param name="msg"></param>
        /// <returns></returns>
        public bool SendGoods(BargainUser bargainUser, Bargain bargain, int aid, out string msg, string attachData = "")
        {
            bool result           = false;
            bool addExpressResult = false;

            if (bargainUser.State == 6)
            {
                msg = "已经发货了,不能修改!";
                return(result);
            }
            //if (!string.IsNullOrEmpty(bargainUser.WayBillNo) || !string.IsNullOrEmpty(bargainUser.SendGoodsName))
            //{
            //    msg = "已经发货了,不能修改!";
            //    return result;
            //}
            //if (string.IsNullOrEmpty(WayBillNo) || string.IsNullOrEmpty(SendGoodsName))
            //{
            //    return Json(new { code = -1, msg = "快递单号或者名称不能为空!" });
            //}
            //if (SendGoodsName.Length > 8)
            //{
            //    return Json(new { code = -1, msg = "快递名称过长" });
            //}

            if (!string.IsNullOrEmpty(attachData))
            {
                DeliveryUpdatePost DeliveryInfo = System.Web.Helpers.Json.Decode <DeliveryUpdatePost>(attachData);
                if (DeliveryInfo != null)
                {
                    addExpressResult = DeliveryFeedbackBLL.SingleModel.AddOrderFeed(bargainUser.Id, DeliveryInfo, DeliveryOrderType.专业版砍价发货);
                    if (!addExpressResult)
                    {
                        msg = "物流信息添加失败,发货失败!";
                        return(result);
                    }
                }
            }

            bargainUser.State = 6;
            //bargainUser.WayBillNo = WayBillNo;
            //bargainUser.SendGoodsName = SendGoodsName;
            bargainUser.SendGoodsTime = DateTime.Now;
            if (Update(bargainUser, "SendGoodsTime,State"))
            {
                var storeName = "";
                if (bargain != null)
                {
                    switch (bargain.BargainType)
                    {
                    case 0:
                        var store = StoreBLL.SingleModel.GetModel(bargain.StoreId);
                        if (store != null)
                        {
                            var paramslist = ConfParamBLL.SingleModel.GetListByRId(aid) ?? new List <ConfParam>();
                            storeName = paramslist.Where(w => w.Param == "nparam").FirstOrDefault()?.Value;
                        }
                        break;

                    case 1:
                        storeName = OpenAuthorizerConfigBLL.SingleModel.GetModel($" rid = {aid} ")?.nick_name;
                        break;

                    default:
                        storeName = "";
                        break;
                    }
                }

                #region 模板消息

                try
                {
                    XcxAppAccountRelation app = XcxAppAccountRelationBLL.SingleModel.GetModel(aid);
                    if (app == null)
                    {
                        throw new Exception($"发送砍价发货模板消息参数错误 app_null :aid = {aid}");
                    }
                    XcxTemplate xcxTemp = XcxTemplateBLL.SingleModel.GetModel(app.TId);
                    if (xcxTemp == null)
                    {
                        throw new Exception($"发送砍价发货模板消息参数错误 xcxTemp_null :xcxTempId = {app.TId}");
                    }
                    Account account = AccountBLL.SingleModel.GetModel(app.AccountId);
                    if (account == null)
                    {
                        throw new Exception($"发送砍价发货模板消息参数错误 account_null :accountId = {app.AccountId}");
                    }
                    //电商为旧做法,兼容电商
                    switch (xcxTemp.Type)
                    {
                    case (int)TmpType.小程序电商模板:

                        #region 购买者模板消息

                        var postData = new BargainUserBLL().GetTemplateMessageData_SendGoods(bargainUser.Id, storeName);
                        TemplateMsg_Miniapp.SendTemplateMessage(bargainUser.UserId, SendTemplateMessageTypeEnum.电商订单配送通知, (int)TmpType.小程序电商模板, postData);

                        #endregion 购买者模板消息

                        break;

                    default:
                        object orderData = TemplateMsg_Miniapp.BargainGetTemplateMessageData(bargainUser, SendTemplateMessageTypeEnum.价订单发货提醒);
                        TemplateMsg_Miniapp.SendTemplateMessage(bargainUser.UserId, SendTemplateMessageTypeEnum.价订单发货提醒, xcxTemp.Type, orderData);
                        break;
                    }
                }
                catch (Exception ex)
                {
                    log4net.LogHelper.WriteError(GetType(), ex);
                }

                #endregion 模板消息

                result = true;
                msg    = "发货成功!";
                return(result);
            }
            else
            {
                result = false;
                msg    = "发货异常!";
                return(result);
            }
        }
Exemple #29
0
        public ActionResult ModifyFirstOrderDiscountMoneySetting(int appId, int storeId = 0, float newUserFirstOrderDiscountMoney = 0.00f, float userFirstOrderDiscountMoney = 0.00f)
        {
            Return_Msg handingResult = new Return_Msg();

            handingResult.isok = true;
            handingResult.code = "0";
            handingResult.Msg  = "保存成功";

            if (newUserFirstOrderDiscountMoney < 0 || newUserFirstOrderDiscountMoney > 99999.99)
            {
                handingResult.code = "201";
                handingResult.Msg  = "新用户首单立减金额请设定 0.00 ~ 99999.99 区间的值";
                return(Json(handingResult, JsonRequestBehavior.AllowGet));
            }
            if (userFirstOrderDiscountMoney < 0 || userFirstOrderDiscountMoney > 99999.99)
            {
                handingResult.code = "202";
                handingResult.Msg  = "用户首单立减金额请设定 0.00 ~ 99999.99 区间的值";
                return(Json(handingResult, JsonRequestBehavior.AllowGet));
            }

            XcxAppAccountRelation xcxrelation = XcxAppAccountRelationBLL.SingleModel.GetModel(appId);

            if (xcxrelation == null)
            {
                handingResult.code = "1";
                handingResult.Msg  = "未找到小程序授权资料";
                return(Json(handingResult, JsonRequestBehavior.AllowGet));
            }
            XcxTemplate xcxTemplate = XcxTemplateBLL.SingleModel.GetModel(xcxrelation.TId);

            if (xcxTemplate == null)
            {
                handingResult.code = "2";
                handingResult.Msg  = "未找到小程序的模板";
                return(Json(handingResult, JsonRequestBehavior.AllowGet));
            }

            bool isUpdateSuccess = false;

            switch (xcxTemplate.Type)
            {
            case (int)TmpType.小程序餐饮模板:
                Food store_Food = FoodBLL.SingleModel.GetModel($" appId = {xcxrelation.Id} {(storeId > 0 ? $" and Id = {storeId}" : "")} ");
                if (store_Food == null)
                {
                    handingResult.code = "3";
                    handingResult.Msg  = "还未开通店铺";
                    return(Json(handingResult, JsonRequestBehavior.AllowGet));
                }

                //修改设定
                FoodConfigModel foodConfig = store_Food.funJoinModel;
                foodConfig.newUserFirstOrderDiscountMoney = newUserFirstOrderDiscountMoney;
                foodConfig.userFirstOrderDiscountMoney    = userFirstOrderDiscountMoney;

                store_Food.configJson = JsonConvert.SerializeObject(foodConfig);
                store_Food.UpdateDate = DateTime.Now;

                isUpdateSuccess = FoodBLL.SingleModel.Update(store_Food, "configJson,UpdateDate");
                break;

            case (int)TmpType.小程序多门店模板:
                FootBath store_MultiStore = FootBathBLL.SingleModel.GetModel($" appId = {xcxrelation.Id} {(storeId > 0 ? $" and Id = {storeId}" : " and HomeId = 0 ")}");
                if (store_MultiStore == null)
                {
                    handingResult.code = "3";
                    handingResult.Msg  = "还未开通店铺";
                    return(Json(handingResult, JsonRequestBehavior.AllowGet));
                }

                //读取配置
                SwitchModel switchModel = null;
                try
                {
                    switchModel = JsonConvert.DeserializeObject <SwitchModel>(store_MultiStore.SwitchConfig);
                }
                catch (Exception)
                {
                    switchModel = new SwitchModel();
                }
                //修改设定
                switchModel.newUserFirstOrderDiscountMoney = newUserFirstOrderDiscountMoney;
                switchModel.userFirstOrderDiscountMoney    = userFirstOrderDiscountMoney;

                store_MultiStore.SwitchConfig = JsonConvert.SerializeObject(switchModel);
                store_MultiStore.UpdateDate   = DateTime.Now;

                isUpdateSuccess = FootBathBLL.SingleModel.Update(store_MultiStore, "SwitchConfig,UpdateDate");
                break;

            default:
                handingResult.code = "3";
                handingResult.Msg  = "还未开通店铺";
                return(Json(handingResult, JsonRequestBehavior.AllowGet));
            }

            if (!isUpdateSuccess)
            {
                handingResult.isok = false;
                handingResult.code = "-1";
                handingResult.Msg  = "修改失败,请重试!";
            }
            return(Json(handingResult, JsonRequestBehavior.AllowGet));
        }
Exemple #30
0
        /// <summary>
        ////整理消费日志
        /// </summary>
        /// <param name="openType"></param>
        /// <param name="cost"></param>
        /// <param name="desc"></param>
        /// <param name="agentLog"></param>
        /// <param name="xcx"></param>
        /// <param name="userName"></param>
        /// <param name="dName"></param>
        /// <param name="isDistribution"></param>
        public void GetCommondLog(ref int openType, ref int cost, ref string desc, ref AgentdepositLog agentLog, XcxTemplate xcx, string userName, string dName, int isDistribution)
        {
            switch (xcx.Type)
            {
            case (int)TmpType.小程序餐饮多门店模板:
            case (int)TmpType.小程序多门店模板:
                GetOpenMulStoreInfo(openType, ref cost, ref desc, ref agentLog, xcx, userName, dName, isDistribution);
                break;

            case (int)TmpType.智慧餐厅:
                GetOpenZHStoreInfo(openType, ref cost, ref desc, xcx, userName, dName, isDistribution);
                if (isDistribution == 1 && openType != (int)AgentDepositLogType.分销商开通客户模板 && openType != (int)AgentDepositLogType.开通客户模板)
                {
                    openType = (int)AgentDepositLogType.分销商变更智慧餐厅门店;
                }
                break;

            case (int)TmpType.企业智推版:
                GetOpenQYStoreInfo(openType, ref cost, ref desc, xcx, userName, dName, isDistribution);
                if (isDistribution == 1 && openType != (int)AgentDepositLogType.分销商开通客户模板 && openType != (int)AgentDepositLogType.开通客户模板)
                {
                    openType = (int)AgentDepositLogType.分销商变更企业智推版员工;
                }
                break;
            }
        }