/// <summary>
        /// 根据服务码或手机号查询服务码详情
        /// </summary>
        /// <param name="serviceCode"></param>
        /// <param name="mobile"></param>
        /// <returns></returns>
        public async Task <ActionResult> SearchServiceCode(string serviceCode, string mobile, int pageIndex = 1, int pageSize = 1000, string tabValue = "BeautyCode")
        {
            var log = new DataAccess.Entity.BeautyOprLog
            {
                LogType     = "SearchServiceCode",
                IdentityID  = $"{serviceCode}|{mobile}",
                OldValue    = null,
                NewValue    = null,
                Remarks     = $"根据服务码[{serviceCode}]或手机号[{mobile}]查询服务码详情[{tabValue}]",
                OperateUser = User.Identity.Name,
            };

            LoggerManager.InsertLog("BeautyOprLog", log);
            if (String.Equals(tabValue, "BeautyCode"))
            {
                Tuple <List <ServiceCodeDetail>, int> result = null;
                result = await SearchCodeManager.GetBeautyServicePackageDetailCodes(mobile, serviceCode, pageIndex, pageSize);

                var shopDic = await SearchCodeManager.GetShopInfoByShopIds(result.Item1.Where(w => !string.IsNullOrEmpty(w.VerifyShop)).Select(s => int.Parse(s.VerifyShop)));

                if (shopDic.Any())
                {
                    result.Item1.ForEach(f =>
                    {
                        if (!string.IsNullOrEmpty(f.VerifyShop) && shopDic.ContainsKey(f.VerifyShop))
                        {
                            f.VerifyShop = shopDic[f.VerifyShop];
                        }
                        if (!string.IsNullOrEmpty(f.OrderNo))
                        {
                            f.OrderNoLink = IsOnline ?
                                            "https://oms.tuhu.cn/Order/Details/" + f.OrderNo.Remove(0, 2) :
                                            "https://oms.tuhu.work/Order/Details/" + f.OrderNo.Remove(0, 2);
                        }
                    });
                }
                return(Json(new { Status = true, Data = result.Item1, TotalCount = result.Item2, TotalPage = 0 }, JsonRequestBehavior.AllowGet));
            }
            else if (String.Equals(tabValue, "GeneralServiceCode"))
            {
                var result = await GeneralBeautyServerCodeManager.GetGeneralBeautyServerCodes(mobile, serviceCode, pageIndex, pageSize);

                return(Json(new { Status = true, Data = result, TotalCount = 0, TotalPage = 0 }, JsonRequestBehavior.AllowGet));
            }
            else if (String.Equals(tabValue, "GeneralRedemtionCode"))
            {
                var result = await UnivRedemptionCodeManager.GetRedeemMrServerCodes(mobile, serviceCode, pageIndex, pageSize);

                return(Json(new { Status = true, Data = result, TotalCount = 0, TotalPage = 0 }, JsonRequestBehavior.AllowGet));
            }
            else
            {
                return(Json(new { Status = true, Data = new List <ServiceCodeDetail>(), TotalCount = 0, TotalPage = 0 }, JsonRequestBehavior.AllowGet));
            }
        }
        /// <summary>
        /// 根据服务码或手机号查询服务码详情
        /// </summary>
        /// <param name="serviceCode"></param>
        /// <param name="mobile"></param>
        /// <returns></returns>
        public async Task <ActionResult> SearchServiceCode(string serviceCode, string mobile, int pageIndex = 1, int pageSize = 1000)
        {
            Tuple <List <ServiceCodeDetail>, int> result = null;

            if (!string.IsNullOrEmpty(mobile))
            {
                result = await SearchCodeManager.GetServiceCodeDetailByMobile(mobile, pageIndex, pageSize);
            }
            else
            {
                result = await SearchCodeManager.GetServiceCodeDetailByCode(serviceCode);
            }
            if (result.Item1.Any())
            {
                var shopDic = await SearchCodeManager.GetShopInfoByShopIds(result.Item1.Where(w => !string.IsNullOrEmpty(w.VerifyShop)).Select(s => int.Parse(s.VerifyShop)));

                if (shopDic.Any())
                {
                    result.Item1.ForEach(f =>
                    {
                        if (!string.IsNullOrEmpty(f.VerifyShop) && shopDic.ContainsKey(f.VerifyShop))
                        {
                            f.VerifyShop = shopDic[f.VerifyShop];
                        }
                        if (!string.IsNullOrEmpty(f.OrderNo))
                        {
                            f.OrderNoLink = IsOnline ?
                                            "https://oms.tuhu.cn/Order/Details/" + f.OrderNo.Remove(0, 2) :
                                            "https://oms.tuhu.work/Order/Details/" + f.OrderNo.Remove(0, 2);
                        }
                    });
                }
                var log = new DataAccess.Entity.BeautyOprLog
                {
                    LogType     = "SearchServiceCode",
                    IdentityID  = $"{serviceCode}|{mobile}",
                    OldValue    = null,
                    NewValue    = null,
                    Remarks     = $"根据服务码[{serviceCode}]或手机号[{mobile}]查询服务码详情",
                    OperateUser = User.Identity.Name,
                };
                LoggerManager.InsertLog("BeautyOprLog", log);
            }
            var totalPage = (result.Item2 % pageSize == 0) ? ((int)result.Item2 / pageSize) : ((int)result.Item2 / pageSize + 1);

            return(Json(new { Status = true, Data = result.Item1, TotalCount = result.Item2, TotalPage = totalPage }, JsonRequestBehavior.AllowGet));
        }
        /// <summary>
        /// 更新美容大客户服务码
        /// </summary>
        /// <param name="model"></param>
        /// <param name="pkids"></param>
        /// <returns></returns>
        public async Task <ActionResult> UpdateBeautyServicePackageDetailCodes(ServiceCodeDetail model)
        {
            if (model == null || string.IsNullOrWhiteSpace(model.ServiceCode))
            {
                return(Json(new { Status = false, Msg = "未知的编辑对象" }, JsonRequestBehavior.AllowGet));
            }
            if (model.StartTime == null || model.EndTime == null)
            {
                return(Json(new { Status = false, Msg = "请选择有效期" }, JsonRequestBehavior.AllowGet));
            }

            ServiceCodeDetail codeDetail = null;

            if (model.PackageDetailCodeId > 0)
            {
                codeDetail = (await SearchCodeManager.GetServiceCodeDetail(new List <string>()
                {
                    model.ServiceCode
                }))?.FirstOrDefault();
            }
            else
            {
                var bankRecords = BankMRManager.GetBankMRActivityCodeRecordByServiceCode(new List <string>()
                {
                    model.ServiceCode
                });
                codeDetail = (await BankMRManager.SearchBankMRActivityCodeDetailByRecords(bankRecords))?.FirstOrDefault();
                if (codeDetail.StartTime.Date != model.StartTime.Date)
                {
                    return(Json(new { Status = false, Msg = $"银行服务码开始时间不能修改" }, JsonRequestBehavior.AllowGet));
                }
            }

            if (codeDetail == null || string.IsNullOrWhiteSpace(codeDetail.Status))
            {
                return(Json(new { Status = false, Msg = "无法获取服务码详情" }, JsonRequestBehavior.AllowGet));
            }
            if (!(codeDetail.Status == "Created" || codeDetail.Status == "SmsSent"))
            {
                return(Json(new { Status = false, Msg = $"服务码:{model.ServiceCode}信息无法更改,请确认服务码状态" }, JsonRequestBehavior.AllowGet));
            }
            var userName = User.Identity.Name;
            var result   = SearchCodeManager.UpdateBeautyServicePackageDetailCodes(model, userName, codeDetail);

            return(Json(new { Status = result, Msg = "修改" + (result ? "成功" : "失败") }, JsonRequestBehavior.AllowGet));
        }