コード例 #1
0
        /// <summary>
        /// 查询角色列表
        /// </summary>
        public string QueryWQRCodeManagerListData()
        {
            var form = Request("form").DeserializeJSONTo <WQRCodeManagerQueryEntity>();

            var appSysService = new WQRCodeManagerBLL(CurrentUserInfo);
            IList <WQRCodeManagerEntity> list = new List <WQRCodeManagerEntity>();

            string content = string.Empty;
            string key     = string.Empty;

            int pageIndex = Utils.GetIntVal(FormatParamValue(Request("page"))) - 1;
            WQRCodeManagerEntity queryEntity = new WQRCodeManagerEntity();

            queryEntity.QRCode = form.QRCode;
            if (form.QRCodeTypeId != null && form.QRCodeTypeId.Length > 0)
            {
                queryEntity.QRCodeTypeId = Guid.Parse(form.QRCodeTypeId);
            }
            list = appSysService.GetList(queryEntity, pageIndex, PageSize);

            var jsonData = new JsonData();

            jsonData.totalCount = appSysService.GetListCount(queryEntity).ToString();
            jsonData.data       = list;

            content = string.Format("{{\"totalCount\":{1},\"topics\":{0}}}",
                                    list.ToJSON(),
                                    jsonData.totalCount);
            return(content);
        }
コード例 #2
0
        /// <summary>
        /// 通过ID获取角色信息
        /// </summary>
        public string GetWQRCodeManagerInfoByIdData()
        {
            var service = new WQRCodeManagerBLL(CurrentUserInfo);
            WQRCodeManagerEntity data = null;
            string content            = string.Empty;

            string key = string.Empty;

            if (Request("wQRCodeManager_id") != null && Request("wQRCodeManager_id") != string.Empty)
            {
                key = Request("wQRCodeManager_id").ToString().Trim();
            }

            WQRCodeManagerEntity queryEntity = new WQRCodeManagerEntity();

            queryEntity.QRCodeId = Guid.Parse(key);
            var list = service.GetList(queryEntity, 0, 1);

            if (list != null && list.Count > 0)
            {
                data = list[0];
            }

            var jsonData = new JsonData();

            jsonData.totalCount = "1";
            jsonData.data       = data;

            content = jsonData.ToJSON();
            return(content);
        }
コード例 #3
0
        /// <summary>
        /// 保存角色
        /// </summary>
        public string SaveWQRCodeManagerData()
        {
            var wQRCodeManagerService = new WQRCodeManagerBLL(CurrentUserInfo);
            WQRCodeManagerEntity obj  = new WQRCodeManagerEntity();
            string content            = string.Empty;
            string error        = "";
            var    responseData = new ResponseData();

            string key = string.Empty;
            string wQRCodeManager_id = string.Empty;

            if (Request("wQRCodeManager") != null && Request("wQRCodeManager") != string.Empty)
            {
                key = Request("wQRCodeManager").ToString().Trim();
            }
            if (Request("wQRCodeManager_id") != null && Request("wQRCodeManager_id") != string.Empty)
            {
                wQRCodeManager_id = Request("wQRCodeManager_id").ToString().Trim();
            }

            obj = key.DeserializeJSONTo <WQRCodeManagerEntity>();

            //if (obj.TypeCode == null || obj.TypeCode.Trim().Length == 0)
            //{
            //    responseData.success = false;
            //    responseData.msg = "编码不能为空";
            //    return responseData.ToJSON();
            //}
            //if (obj.TypeName == null || obj.TypeName.Trim().Length == 0)
            //{
            //    responseData.success = false;
            //    responseData.msg = "名称不能为空";
            //    return responseData.ToJSON();
            //}

            if (wQRCodeManager_id.Trim().Length == 0 || wQRCodeManager_id == "null" || wQRCodeManager_id == "undefined")
            {
                obj.QRCodeId   = Guid.NewGuid();
                obj.CustomerId = CurrentUserInfo.CurrentUser.customer_id;
                wQRCodeManagerService.Create(obj);
            }
            else
            {
                obj.QRCodeId = Guid.Parse(wQRCodeManager_id);
                wQRCodeManagerService.Update(obj, false);
            }

            responseData.success = true;
            responseData.msg     = error;

            content = responseData.ToJSON();
            return(content);
        }
コード例 #4
0
        /// <summary>
        /// GetList
        /// </summary>
        /// <param name="entity">entity</param>
        /// <param name="Page">分页页码。从0开始</param>
        /// <param name="PageSize">每页的数量。未指定时默认为15</param>
        /// <returns></returns>
        public IList <WQRCodeManagerEntity> GetList(WQRCodeManagerEntity entity, int Page, int PageSize)
        {
            if (PageSize <= 0)
            {
                PageSize = 15;
            }

            IList <WQRCodeManagerEntity> list = new List <WQRCodeManagerEntity>();
            DataSet ds = new DataSet();

            ds = _currentDAO.GetList(entity, Page, PageSize);
            if (ds != null && ds.Tables.Count > 0 && ds.Tables[0].Rows.Count > 0)
            {
                list = DataTableToObject.ConvertToList <WQRCodeManagerEntity>(ds.Tables[0]);
            }
            return(list);
        }
コード例 #5
0
 /// <summary>
 /// 分页根据实体条件查询实体
 /// </summary>
 /// <param name="pQueryEntity">以实体形式传入的参数</param>
 /// <param name="pOrderBys">排序组合</param>
 /// <returns>符合条件的实体集</returns>
 public PagedQueryResult <WQRCodeManagerEntity> PagedQueryByEntity(WQRCodeManagerEntity pQueryEntity, OrderBy[] pOrderBys, int pPageSize, int pCurrentPageIndex)
 {
     return(_currentDAO.PagedQueryByEntity(pQueryEntity, pOrderBys, pPageSize, pCurrentPageIndex));
 }
コード例 #6
0
 /// <summary>
 /// 根据实体条件查询实体
 /// </summary>
 /// <param name="pQueryEntity">以实体形式传入的参数</param>
 /// <param name="pOrderBys">排序组合</param>
 /// <returns>符合条件的实体集</returns>
 public WQRCodeManagerEntity[] QueryByEntity(WQRCodeManagerEntity pQueryEntity, OrderBy[] pOrderBys)
 {
     return(_currentDAO.QueryByEntity(pQueryEntity, pOrderBys));
 }
コード例 #7
0
 /// <summary>
 /// 删除
 /// </summary>
 /// <param name="pEntity"></param>
 public void Delete(WQRCodeManagerEntity pEntity)
 {
     _currentDAO.Delete(pEntity);
 }
コード例 #8
0
 public void Update(WQRCodeManagerEntity pEntity, bool pIsUpdateNullField)
 {
     _currentDAO.Update(pEntity, pIsUpdateNullField);
 }
コード例 #9
0
 /// <summary>
 /// 更新
 /// </summary>
 /// <param name="pEntity">实体实例</param>
 public void Update(WQRCodeManagerEntity pEntity)
 {
     Update(pEntity, true);
 }
コード例 #10
0
 /// <summary>
 /// 更新
 /// </summary>
 /// <param name="pEntity">实体实例</param>
 /// <param name="pTran">事务实例,可为null,如果为null,则不使用事务来更新</param>
 public void Update(WQRCodeManagerEntity pEntity, IDbTransaction pTran)
 {
     Update(pEntity, true, pTran);
 }
コード例 #11
0
        protected override DownloadQRCodeRD ProcessRequest(DTO.Base.APIRequest <DownloadQRCodeRP> pRequest)
        {
            string content    = string.Empty;
            string customerId = string.Empty;
            var    RD         = new DownloadQRCodeRD();

            try
            {
                #region 解析传入参数
                //解析请求字符串
                var RP = pRequest.Parameters;

                //判断客户ID是否传递

                customerId = CurrentUserInfo.CurrentUser.customer_id;


                #endregion
                var    imageUrl = string.Empty;
                Random ro       = new Random();
                var    iUp      = 100000000;
                var    iDown    = 50000000;

                if (string.IsNullOrEmpty(RP.VipDCode.ToString()) || RP.VipDCode == 0)
                {
                    throw new APIException("VipDCode参数不能为空");
                }
                var rpVipDCode = 0;                   //临时二维码
                var iResult    = ro.Next(iDown, iUp); //随机数

                if (RP.VipDCode == 9)                 //永久二维码
                {
                    var userQRCodeBll  = new WQRCodeManagerBLL(CurrentUserInfo);
                    var marketEventBll = new MarketEventBLL(CurrentUserInfo);

                    var marketEventEntity = marketEventBll.QueryByEntity(new MarketEventEntity()
                    {
                        EventCode = "CA00002433", CustomerId = CurrentUserInfo.ClientID
                    }, null).FirstOrDefault();
                    var userQRCode = userQRCodeBll.QueryByEntity(new WQRCodeManagerEntity()
                    {
                        ObjectId = marketEventEntity.MarketEventID, CustomerId = CurrentUserInfo.ClientID
                    }, null);                                                                                                                                                              //

                    if (userQRCode != null && userQRCode.Length > 0)
                    {
                        RD.imageUrl = userQRCode[0].ImageUrl;
                        return(RD);
                    }

                    //获取当前二维码 最大值
                    iResult    = new WQRCodeManagerBLL(CurrentUserInfo).GetMaxWQRCod() + 1;
                    rpVipDCode = 1;                 //永久

                    #region 获取微信帐号
                    //门店关联的公众号
                    var tueBll    = new TUnitExpandBLL(CurrentUserInfo);
                    var tueEntity = new TUnitExpandEntity();
                    if (!string.IsNullOrEmpty(CurrentUserInfo.CurrentUserRole.UnitId))
                    {
                        tueEntity = tueBll.QueryByEntity(new TUnitExpandEntity()
                        {
                            UnitId = CurrentUserInfo.CurrentUserRole.UnitId
                        }, null).FirstOrDefault();
                    }

                    var server = new WApplicationInterfaceBLL(CurrentUserInfo);
                    var wxObj  = new WApplicationInterfaceEntity();
                    if (tueEntity != null && !string.IsNullOrEmpty(tueEntity.Field1))
                    {
                        wxObj = server.QueryByEntity(new WApplicationInterfaceEntity {
                            AppID = tueEntity.Field1, CustomerId = customerId
                        }, null).FirstOrDefault();
                    }
                    else
                    {
                        wxObj = server.QueryByEntity(new WApplicationInterfaceEntity {
                            CustomerId = customerId
                        }, null).FirstOrDefault();
                    }

                    if (wxObj == null)
                    {
                        throw new APIException("没有对应公众号");
                    }
                    else
                    {
                        var commonServer = new CommonBLL();

                        imageUrl = commonServer.GetQrcodeUrl(wxObj.AppID
                                                             , wxObj.AppSecret
                                                             , rpVipDCode.ToString("")    //二维码类型  0: 临时二维码  1:永久二维码
                                                             , iResult, CurrentUserInfo); //iResult作为场景值ID,临时二维码时为32位整型,永久二维码时只支持1--100000
                        if (imageUrl != null && !imageUrl.Equals(""))
                        {
                            CPOS.Common.DownloadImage downloadServer = new DownloadImage();
                            string downloadImageUrl = ConfigurationManager.AppSettings["website_WWW"];
                            imageUrl = downloadServer.DownloadFile(imageUrl, downloadImageUrl);
                            //如果名称不为空,就把图片放在一定的背景下面
                            //if (!string.IsNullOrEmpty(RP.Parameters.RetailTraderName))
                            //{
                            //    string apiDomain = ConfigurationManager.AppSettings["website_url"];

                            //    imageUrl = CombinImage(apiDomain + @"/HeadImage/qrcodeBack.jpg", imageUrl, RP.Parameters.RetailTraderName + "合作二维码");
                            //}
                        }
                    }

                    #endregion

                    if (!string.IsNullOrEmpty(imageUrl))    //永久二维码
                    {
                        #region 创建店员永久二维码匹配表
                        var userQrTypeBll = new WQRCodeTypeBLL(CurrentUserInfo);
                        var userQrType    = userQrTypeBll.QueryByEntity(new WQRCodeTypeEntity()
                        {
                            TypeName = "签到"
                        }, null);                                                                                       //"UserQrCode"
                        if (userQrType != null && userQrType.Length > 0)
                        {
                            var userQrCodeBll = new WQRCodeManagerBLL(CurrentUserInfo);
                            var userQrCode    = new WQRCodeManagerEntity();
                            userQrCode.QRCode        = iResult.ToString();//记录传过去的二维码场景值
                            userQrCode.QRCodeTypeId  = userQrType[0].QRCodeTypeId;
                            userQrCode.IsUse         = 1;
                            userQrCode.CustomerId    = CurrentUserInfo.CurrentUser.customer_id;
                            userQrCode.ImageUrl      = imageUrl;
                            userQrCode.ApplicationId = wxObj.ApplicationId;
                            //objectId 为店员ID
                            userQrCode.ObjectId = marketEventEntity.MarketEventID;
                            userQrCodeBll.Create(userQrCode);
                        }
                        #endregion
                    }
                }

                RD.imageUrl = imageUrl;
            }
            catch
            {
                throw new APIException("生成二维码错误");
            }
            return(RD);
        }
コード例 #12
0
        protected override GetVipDealerSpreadCodeRD ProcessRequest(DTO.Base.APIRequest <GetVipDealerSpreadCodeRP> pRequest)
        {
            var rd                = new GetVipDealerSpreadCodeRD();
            var VipBLL            = new VipBLL(CurrentUserInfo);
            var WQRCodeManagerBLL = new WQRCodeManagerBLL(this.CurrentUserInfo);
            var WQRCodeTypeBLL    = new WQRCodeTypeBLL(this.CurrentUserInfo);

            try
            {
                var UserID = pRequest.UserID;
                //
                string imageUrl   = string.Empty;
                string QRCodeId   = string.Empty;
                string VipName    = string.Empty;
                string HeadImgUrl = string.Empty;
                //分享处理
                if (!string.IsNullOrWhiteSpace(pRequest.Parameters.ShareUserId))
                {
                    UserID = pRequest.Parameters.ShareUserId;
                }
                //微信 公共平台
                var wapentity = new WApplicationInterfaceBLL(this.CurrentUserInfo).QueryByEntity(new WApplicationInterfaceEntity
                {
                    CustomerId = this.CurrentUserInfo.ClientID,
                    IsDelete   = 0
                }, null).FirstOrDefault();

                var VipDealerType = WQRCodeTypeBLL.QueryByEntity(new WQRCodeTypeEntity()
                {
                    TypeCode = "VipDealerCode"
                }, null).FirstOrDefault();
                if (VipDealerType == null)
                {
                    throw new APIException("静态二位经销商类型无此类型!");
                }

                if (!string.IsNullOrWhiteSpace(pRequest.Parameters.QRCodeId))
                {
                    #region 分享出去的二维码
                    var WQRCodeManagerData = WQRCodeManagerBLL.GetByID(pRequest.Parameters.QRCodeId);
                    if (WQRCodeManagerData == null)
                    {
                        throw new APIException("此二维码不存在!");
                    }

                    var VipData = VipBLL.GetByID(WQRCodeManagerData.ObjectId);
                    if (VipData == null)
                    {
                        throw new APIException("此二维码会员不存在!");
                    }

                    //二维码图片地址,ID赋值,会员名称,头像地址赋值
                    imageUrl   = WQRCodeManagerData.ImageUrl;
                    QRCodeId   = WQRCodeManagerData.QRCodeId.ToString();
                    VipName    = VipData.VipName;
                    HeadImgUrl = VipData.HeadImgUrl;
                    #endregion
                }
                else
                {
                    #region 获取去自己静态推广二维码
                    var WQRCodeManagerData = WQRCodeManagerBLL.QueryByEntity(new WQRCodeManagerEntity()
                    {
                        ObjectId = UserID, QRCodeTypeId = VipDealerType.QRCodeTypeId
                    }, null).FirstOrDefault();
                    if (WQRCodeManagerData != null)
                    {
                        //二维码图片地址,ID赋值
                        imageUrl = WQRCodeManagerData.ImageUrl;
                        QRCodeId = WQRCodeManagerData.QRCodeId.ToString();
                    }
                    else
                    {
                        //获取当前二维码 最大值
                        var MaxWQRCod = new WQRCodeManagerBLL(this.CurrentUserInfo).GetMaxWQRCod() + 1;
                        if (wapentity == null)
                        {
                            throw new APIException("无设置微信公众平台!");
                        }

                        #region 生成二维码
                        JIT.CPOS.BS.BLL.WX.CommonBLL commonServer = new JIT.CPOS.BS.BLL.WX.CommonBLL();
                        imageUrl = commonServer.GetQrcodeUrl(wapentity.AppID.ToString().Trim()
                                                             , wapentity.AppSecret.Trim()
                                                             , "1", MaxWQRCod
                                                             , this.CurrentUserInfo);

                        if (string.IsNullOrEmpty(imageUrl))
                        {
                            throw new APIException("二维码生成失败!");
                        }
                        else
                        {
                            string host = ConfigurationManager.AppSettings["original_url"];
                            CPOS.Common.DownloadImage downloadServer = new DownloadImage();
                            //二维码赋值
                            imageUrl = downloadServer.DownloadFile(imageUrl, host);
                            if (!string.IsNullOrEmpty(UserID))
                            {
                                var WQRQrCode = new WQRCodeManagerEntity();
                                WQRQrCode.QRCodeId      = Guid.NewGuid();
                                WQRQrCode.QRCode        = MaxWQRCod.ToString();
                                WQRQrCode.QRCodeTypeId  = VipDealerType.QRCodeTypeId;
                                WQRQrCode.IsUse         = 1;
                                WQRQrCode.CustomerId    = this.CurrentUserInfo.ClientID;
                                WQRQrCode.ImageUrl      = imageUrl;
                                WQRQrCode.ApplicationId = wapentity.ApplicationId;//微信公众号的编号
                                //objectId 为会员ID
                                WQRQrCode.ObjectId = UserID;
                                WQRCodeManagerBLL.Create(WQRQrCode);

                                //二维码ID赋值
                                QRCodeId = WQRQrCode.QRCodeId.ToString();
                            }
                        }
                        #endregion
                    }
                    //会员名称,头像地址
                    var VipData = VipBLL.GetByID(UserID);
                    if (VipData == null)
                    {
                        throw new APIException("会员不存在!");
                    }

                    VipName    = VipData.VipName;
                    HeadImgUrl = VipData.HeadImgUrl;
                    #endregion
                }
                //响应参数赋值
                rd.imageUrl   = imageUrl;
                rd.VipName    = VipName;
                rd.HeadImgUrl = HeadImgUrl;
                rd.QRCodeId   = QRCodeId;
            }
            catch (Exception ex)
            {
                throw new APIException(ex.Message);
            }

            return(rd);
        }
コード例 #13
0
 /// <summary>
 /// GetListCount
 /// </summary>
 /// <param name="entity">entity</param>
 public int GetListCount(WQRCodeManagerEntity entity)
 {
     return(_currentDAO.GetListCount(entity));
 }
コード例 #14
0
 /// <summary>
 /// 创建一个新实例
 /// </summary>
 /// <param name="pEntity">实体实例</param>
 public void Create(WQRCodeManagerEntity pEntity)
 {
     _currentDAO.Create(pEntity);
 }
コード例 #15
0
        public void CreateH5QRCode(SetCTWEventRP para, WApplicationInterfaceEntity wapentity, out string strQRCode, out string QRCodeUrl, out string RedirectUrl)
        {
            #region 图文,二维码
            #region 生成图文素材

            #region 获取Page信息
            var pageBll = new SysPageBLL(loggingSessionInfo);
            var textBll = new WMaterialTextBLL(loggingSessionInfo);
            //组织图文实体
            var entity = new WMaterialTextEntity()
            {
                ApplicationId = wapentity.ApplicationId,         //用自己取出来的
                CoverImageUrl = para.MaterialText.ImageUrl,      //图片地址
                PageId        = Guid.NewGuid(),                  //页面模块的标识
                PageParamJson = para.MaterialText.PageParamJson, //这个比较重要
                Text          = para.MaterialText.Text,
                TextId        = "",                              //为空时在后面保存时生成
                Title         = para.MaterialText.Title,
                TypeId        = para.MaterialText.TypeId
            };
            #endregion
            #region 生成URL
            var    Domain  = ConfigurationManager.AppSettings["interfacehost"].Replace("http://", "");
            var    Domain1 = ConfigurationManager.AppSettings["interfacehost1"].Replace("http://", "");
            string URL     = string.Empty;
            bool   IsAuth  = false;

            URL = ConfigurationManager.AppSettings["LinKinUrl"] + "id=" + para.EventThemeInfo.WorksId;

            entity.IsAuth        = Convert.ToInt32(IsAuth);
            entity.PageParamJson = para.MaterialText.PageParamJson;
            #endregion
            #endregion

            entity.OriginalUrl = URL;//图文素材要跳转到的页面
            RedirectUrl        = URL;
            #endregion

            #region 保存
            var unionMappingBll = new WModelTextMappingBLL(loggingSessionInfo);

            entity.TextId = Guid.NewGuid().ToString("N");
            textBll.Create(entity);//创建图文素材


            #endregion

            string strQRCodeObjectId = Guid.NewGuid().ToString();
            //活动的二维码自己查找QRCodeId
            var wqrCodeManagerEntity = new WQRCodeManagerBLL(loggingSessionInfo).QueryByEntity(new WQRCodeManagerEntity()
            {
                ObjectId = strQRCodeObjectId
            }, null).FirstOrDefault();
            Guid QRCodeId;
            if (wqrCodeManagerEntity == null)
            {
                #region 生成二维码

                var wqrentity = new WQRCodeTypeBLL(loggingSessionInfo).QueryByEntity(

                    new WQRCodeTypeEntity {
                    TypeCode = "CreativeCode"
                }

                    , null).FirstOrDefault();
                var wxCode = CretaeWxCode();



                var WQRCodeManagerbll = new WQRCodeManagerBLL(loggingSessionInfo);

                QRCodeId = Guid.NewGuid();

                if (!string.IsNullOrEmpty(wxCode.ImageUrl))
                {
                    wqrCodeManagerEntity = new WQRCodeManagerEntity()
                    {
                        QRCodeId      = QRCodeId,
                        QRCode        = wxCode.MaxWQRCod.ToString(),
                        QRCodeTypeId  = wqrentity.QRCodeTypeId,
                        IsUse         = 1,
                        ObjectId      = strQRCodeObjectId,
                        CreateBy      = loggingSessionInfo.UserID,
                        ApplicationId = wapentity.ApplicationId,
                        IsDelete      = 0,
                        ImageUrl      = wxCode.ImageUrl,
                        CustomerId    = loggingSessionInfo.ClientID
                    };
                    WQRCodeManagerbll.Create(wqrCodeManagerEntity);
                }
                else
                {
                    throw new APIException(wxCode.msg)
                          {
                              ErrorCode = 342
                          };
                }
                #endregion

                //throw new APIException("活动没有生成二维码!") { ErrorCode = 342 };
            }
            QRCodeId = (Guid)wqrCodeManagerEntity.QRCodeId;//活动二维码的标识
            ////根据二维码标识查找是否有他的关键字回复
            var WKeywordReplyentity = new WKeywordReplyBLL(loggingSessionInfo).QueryByEntity(new WKeywordReplyEntity()
            {
                Keyword = QRCodeId.ToString()  //二维码的标识
            }, null).FirstOrDefault();
            var ReplyBLL = new WKeywordReplyBLL(loggingSessionInfo);
            var ReplyId  = Guid.NewGuid().ToString();//创建临时
            if (WKeywordReplyentity == null)
            {
                ReplyBLL.Create(new WKeywordReplyEntity()
                {
                    ReplyId       = ReplyId,
                    Keyword       = QRCodeId.ToString(),
                    ReplyType     = 3, //用图文素材
                    KeywordType   = 4, //标识
                    IsDelete      = 0,
                    CreateBy      = loggingSessionInfo.UserID,
                    ApplicationId = wapentity.ApplicationId,
                });
            }
            else
            {
                ReplyId = WKeywordReplyentity.ReplyId; //用取出来的数据查看
                WKeywordReplyentity.Text      = "";
                WKeywordReplyentity.ReplyType = 3;     //图文素材
                ReplyBLL.Update(WKeywordReplyentity);
            }
            #region 添加图文消息

            WMenuMTextMappingBLL MenuMTextMappingServer = new WMenuMTextMappingBLL(loggingSessionInfo);


            WMenuMTextMappingEntity MappingEntity = new WMenuMTextMappingEntity();
            MappingEntity.MenuId       = ReplyId;
            MappingEntity.TextId       = entity.TextId; // 用图文素材标识******
            MappingEntity.DisplayIndex = 1;             //排列顺序
            MappingEntity.CustomerId   = loggingSessionInfo.ClientID;
            MappingEntity.MappingId    = Guid.NewGuid();
            MenuMTextMappingServer.Create(MappingEntity);


            strQRCode = QRCodeId.ToString();
            QRCodeUrl = wqrCodeManagerEntity.ImageUrl;

            #endregion
        }
コード例 #16
0
 /// <summary>
 /// 在事务内创建一个新实例
 /// </summary>
 /// <param name="pEntity">实体实例</param>
 /// <param name="pTran">事务实例,可为null,如果为null,则不使用事务来更新</param>
 public void Create(WQRCodeManagerEntity pEntity, IDbTransaction pTran)
 {
     _currentDAO.Create(pEntity, pTran);
 }
コード例 #17
0
        /// <summary>
        /// 生成关注的二维码
        /// </summary>
        /// <param name="para"></param>
        /// <param name="wapentity"></param>
        /// <param name="strQRCode"></param>
        /// <param name="QRCodeUrl"></param>
        public void CreateFocusQRCode(SetCTWEventRP para, string strLogoUrl, WApplicationInterfaceEntity wapentity, out string QRCodeUrl, out string QRCodeId, out bool IsSuccess)
        {
            QRCodeUrl = string.Empty;
            QRCodeId  = string.Empty;

            var wqrCodeManagerEntity = new WQRCodeManagerBLL(loggingSessionInfo).QueryByEntity(new WQRCodeManagerEntity()
            {
                ObjectId = strCTWEventId
            }, null).FirstOrDefault();


            //#region 生成二维码

            var wqrentity = new WQRCodeTypeBLL(loggingSessionInfo).QueryByEntity(

                new WQRCodeTypeEntity {
                TypeCode = "CreativeCode"
            }

                , null).FirstOrDefault();
            var wxCode = CretaeWxCode();


            IsSuccess = true;
            if (string.IsNullOrEmpty(wxCode.ImageUrl))
            {
                IsSuccess = false;
            }
            QRCodeUrl = wxCode.ImageUrl;
            if (!string.IsNullOrEmpty(QRCodeUrl))
            {
                if (!string.IsNullOrEmpty(strLogoUrl))        //如果有值则生成二维码中间带图
                {
                    string targetPath = HttpContext.Current.Server.MapPath("/QRCodeImage/");
                    ////二维码中奖加图片
                    string currentDomain     = "http://" + HttpContext.Current.Request.Url.Host;    //当前项目域名
                    string strFileNmae       = QRCodeUrl.Substring(QRCodeUrl.LastIndexOf("/") + 1);
                    string strQRCodeFilePath = targetPath + strFileNmae;
                    string logoImage         = "~" + strLogoUrl.Substring(currentDomain.Length);

                    System.IO.MemoryStream MStream1 = new System.IO.MemoryStream();
                    Utils.CombinImage(QRCodeUrl, HttpContext.Current.Server.MapPath(logoImage)).Save(MStream1, System.Drawing.Imaging.ImageFormat.Png);
                    Image ii = Image.FromStream(MStream1);
                    ii.Save(strQRCodeFilePath, System.Drawing.Imaging.ImageFormat.Png);
                    MStream1.Dispose();

                    QRCodeUrl = currentDomain + "/QRCodeImage/" + strFileNmae;
                }
                var WQRCodeManagerbll = new WQRCodeManagerBLL(loggingSessionInfo);

                if (wqrCodeManagerEntity == null)
                {
                    wqrCodeManagerEntity = new WQRCodeManagerEntity()
                    {
                        QRCodeId      = Guid.NewGuid(),
                        QRCode        = wxCode.MaxWQRCod.ToString(),
                        QRCodeTypeId  = wqrentity.QRCodeTypeId,
                        IsUse         = 1,
                        ObjectId      = strCTWEventId,
                        Remark        = "CTW",
                        CreateBy      = loggingSessionInfo.UserID,
                        ApplicationId = wapentity.ApplicationId,
                        IsDelete      = 0,
                        ImageUrl      = QRCodeUrl,
                        CustomerId    = loggingSessionInfo.ClientID
                    };
                    WQRCodeManagerbll.Create(wqrCodeManagerEntity);
                }
                else
                {
                    wqrCodeManagerEntity.ImageUrl = QRCodeUrl;
                    WQRCodeManagerbll.Update(wqrCodeManagerEntity);
                }
                QRCodeId = wqrCodeManagerEntity.QRCodeId.ToString();
            }
        }
コード例 #18
0
 public void Update(WQRCodeManagerEntity pEntity, bool pIsUpdateNullField, IDbTransaction pTran)
 {
     _currentDAO.Update(pEntity, pIsUpdateNullField, pTran);
 }
コード例 #19
0
        const int ERROR_LOAD_WRONG  = 302; //打开出错
        protected override GetSetoffToolDetailRD ProcessRequest(APIRequest <GetSetoffToolDetailRP> pRequest)
        {
            string content    = string.Empty;
            string customerId = string.Empty;
            GetSetoffToolDetailRD setoffToolDetailRD = new GetSetoffToolDetailRD();
            var para = pRequest.Parameters;

            customerId = CurrentUserInfo.CurrentUser.customer_id;
            try
            {
                var    imageUrl              = string.Empty;
                Random ro                    = new Random();
                var    iUp                   = 100000000;
                var    iDown                 = 50000000;
                var    rpVipDCode            = 0;                   //临时二维码
                var    iResult               = ro.Next(iDown, iUp); //随机数
                var    userQrCodeBll         = new WQRCodeManagerBLL(CurrentUserInfo);
                var    imgBll                = new ObjectImagesBLL(CurrentUserInfo);
                var    setOffPosterBLL       = new SetoffPosterBLL(CurrentUserInfo);
                var    SetoffToolUserViewBLL = new SetoffToolUserViewBLL(CurrentUserInfo);
                var    SetoffToolsBll        = new SetoffToolsBLL(CurrentUserInfo);
                var    SetOffPosterInfo      = setOffPosterBLL.QueryByEntity(new SetoffPosterEntity()
                {
                    SetoffPosterID = new Guid(para.ObjectId)
                }, null);                                                                                                                         //获取集客海报信息
                var setoffEventBLL  = new SetoffEventBLL(CurrentUserInfo);
                var setoffEventInfo = setoffEventBLL.QueryByEntity(new SetoffEventEntity()
                {
                    Status = "10", SetoffType = 1, CustomerId = customerId
                }, null);
                //var SetoffToolsInfo = SetoffToolsBll.QueryByEntity(new SetoffToolsEntity() { ObjectId = para.ObjectId, Status = "10", ToolType = para.ToolType, SetoffEventID = setoffEventInfo[0].SetoffEventID }, null);//获取工具信息
                //VipDcode=9生成永久二维码
                if (para.VipDCode == 9)
                {
                    //根据分享人ID和对象ID获取永久二维码信息
                    var userQrCode = userQrCodeBll.QueryByEntity(new WQRCodeManagerEntity()
                    {
                        ObjectId = para.ObjectId
                    }, null);
                    if (userQrCode != null && userQrCode.Length > 0)
                    {
                        if (para.ToolType == "Coupon")//如果类型为优惠券则返回二维码
                        {
                            setoffToolDetailRD.ToolType = para.ToolType;
                        }
                        if (para.ToolType == "SetoffPoster")//如果为集客海报则返回背景图和二维码
                        {
                            if (SetOffPosterInfo != null)
                            {
                                var backImgInfo = imgBll.QueryByEntity(new ObjectImagesEntity()
                                {
                                    ObjectId = SetOffPosterInfo[0].ImageId
                                }, null);
                                setoffToolDetailRD.ToolType   = para.ToolType;
                                setoffToolDetailRD.imageUrl   = userQrCode[0].ImageUrl;
                                setoffToolDetailRD.paraTemp   = userQrCode[0].QRCode;
                                setoffToolDetailRD.backImgUrl = backImgInfo[0].ImageURL;
                            }
                        }
                        setoffToolDetailRD.imageUrl = userQrCode[0].ImageUrl;
                        setoffToolDetailRD.paraTemp = userQrCode[0].QRCode;
                        return(setoffToolDetailRD);
                    }
                    //获取当前二维码 最大值
                    iResult    = new WQRCodeManagerBLL(CurrentUserInfo).GetMaxWQRCod() + 1;
                    rpVipDCode = 1;
                }

                #region 获取微信帐号
                var server = new WApplicationInterfaceBLL(CurrentUserInfo);
                var wxObj  = new WApplicationInterfaceEntity();
                wxObj = server.QueryByEntity(new WApplicationInterfaceEntity {
                    CustomerId = customerId
                }, null).FirstOrDefault();
                if (wxObj == null)
                {
                    throw new APIException("不存在对应的微信帐号.")
                          {
                              ErrorCode = ERROR_NULL_WXOBJ
                          };
                }
                else
                {
                    var commonServer = new CommonBLL();
                    //rpVipDCode 二维码类型  0: 临时二维码  1:永久二维码
                    imageUrl = commonServer.GetQrcodeUrl(wxObj.AppID, wxObj.AppSecret, rpVipDCode.ToString(""), iResult, CurrentUserInfo);//iResult作为场景值ID,临时二维码时为32位整型,永久二维码时只支持1--100000
                    //供本地测试时使用  "https://mp.weixin.qq.com/cgi-bin/showqrcode?ticket=gQGN7zoAAAAAAAAAASxodHRwOi8vd2VpeGluLnFxLmNvbS9xL1dreENCS1htX0xxQk94SEJ6MktIAAIEUk88VwMECAcAAA==";
                }
                #endregion

                if (para.VipDCode == 9 && !string.IsNullOrEmpty(imageUrl))    //永久二维码
                {
                    #region 创建店员永久二维码匹配表
                    var    userQrTypeBll = new WQRCodeTypeBLL(CurrentUserInfo);
                    string pTypeCode     = string.Empty;
                    if (para.ToolType.ToLower() == "coupon")
                    {
                        pTypeCode = "CouponQrCode";
                    }
                    if (para.ToolType.ToLower() == "setoffposter")
                    {
                        pTypeCode = "SetoffPosterQrCode";
                    }
                    if (para.ToolType.ToLower() == "superretail")
                    {
                        pTypeCode = "SuperRetailQrCode";
                    }
                    var userQrType = userQrTypeBll.QueryByEntity(new WQRCodeTypeEntity()
                    {
                        TypeCode = pTypeCode
                    }, null);                                                                                            //"SuperRetailQrCode=超级分销商二维码"
                    if (userQrType != null && userQrType.Length > 0)
                    {
                        var userQrcodeBll = new WQRCodeManagerBLL(CurrentUserInfo);
                        var userQrCode    = new WQRCodeManagerEntity();
                        userQrCode.QRCode        = iResult.ToString();//记录传过去的二维码场景值
                        userQrCode.QRCodeTypeId  = userQrType[0].QRCodeTypeId;
                        userQrCode.IsUse         = 1;
                        userQrCode.CustomerId    = customerId;
                        userQrCode.ImageUrl      = imageUrl;
                        userQrCode.ApplicationId = wxObj.ApplicationId;
                        //objectId 为集客海报ID或者优惠券ID
                        userQrCode.ObjectId = para.ObjectId;
                        userQrcodeBll.Create(userQrCode);
                    }
                    #endregion
                }
                else
                {
                    #region 创建临时匹配表
                    VipDCodeBLL    vipDCodeServer = new VipDCodeBLL(CurrentUserInfo);
                    VipDCodeEntity info           = new VipDCodeEntity();
                    info.DCodeId    = iResult.ToString();//记录传过去的二维码场景值****(保存到数据库时没加空格)
                    info.CustomerId = customerId;
                    VipBLL vipBll = new VipBLL(CurrentUserInfo);
                    info.UnitId      = "";
                    info.Status      = "0";
                    info.IsReturn    = 0;
                    info.DCodeType   = para.VipDCode;
                    info.CreateBy    = CurrentUserInfo.UserID;
                    info.ImageUrl    = imageUrl;
                    info.VipId       = "";
                    info.ObjectId    = para.ObjectId;   //工具对象ID(优惠券或集客海报对象ID)
                    info.OwnerUserId = para.ShareVipId; //分享人ID
                    vipDCodeServer.Create(info);
                    #endregion
                }
                int flag         = 0;//定义是否需要新增打开数据,0=不需要新增,1=需要新增
                var UserViewData = SetoffToolUserViewBLL.QueryByEntity(new SetoffToolUserViewEntity()
                {
                    ObjectId = para.ObjectId, UserID = CurrentUserInfo.UserID
                }, null);
                if (!string.IsNullOrEmpty(para.SetoffToolID))
                {
                    UserViewData = SetoffToolUserViewBLL.QueryByEntity(new SetoffToolUserViewEntity()
                    {
                        ObjectId = para.ObjectId, UserID = CurrentUserInfo.UserID, SetoffToolID = new Guid(para.SetoffToolID)
                    }, null);
                }
                if (UserViewData.Length == 0 && !string.IsNullOrEmpty(para.SetoffToolID) && para.PlatformType != "3")
                {
                    flag = 1;                  //当为1时进行增加打开工具记录
                }
                if (para.ToolType == "Coupon") //如果类型为优惠券则返回二维码
                {
                    #region 用户领优惠券过程
                    var CouponTypeBLL       = new CouponTypeBLL(CurrentUserInfo);
                    var couponBLL           = new CouponBLL(CurrentUserInfo);
                    var CouponSourceBLL     = new CouponSourceBLL(CurrentUserInfo);
                    var VipCouponMappingBLL = new VipCouponMappingBLL(CurrentUserInfo);

                    int?SurplusCount   = 0; //先获得剩余张数
                    int hasCouponCount = 0; //已领张数 如果>0表示已领取过就不让他领,=0就领取
                    var couponTypeInfo = CouponTypeBLL.QueryByEntity(new CouponTypeEntity()
                    {
                        CouponTypeID = new Guid(para.ObjectId)
                    }, null);

                    if (couponTypeInfo != null)
                    {
                        string couponIsVocher = string.Empty;
                        if (couponTypeInfo[0].IsVoucher == null)
                        {
                            SurplusCount = couponTypeInfo[0].IssuedQty - 0;
                        }
                        else
                        {
                            SurplusCount = couponTypeInfo[0].IssuedQty - couponTypeInfo[0].IsVoucher;
                        }
                        if (SurplusCount != 0 && para.ShareVipId != null && para.ShareVipId != "")// 通过列表进详细自己不能领券
                        {
                            //当剩余数量不为0时,进行下一步判断是否存在已领券的信息
                            hasCouponCount = VipCouponMappingBLL.GetReceiveCouponCount(CurrentUserInfo.UserID, para.ObjectId, "Share");
                            if (hasCouponCount == 0)//如果等于零,开始领券流程
                            {
                                //关联优惠券让用户领券
                                var redisVipMappingCouponBLL = new JIT.CPOS.BS.BLL.RedisOperationBLL.Coupon.RedisVipMappingCouponBLL();
                                try
                                {
                                    //执行领取操作
                                    redisVipMappingCouponBLL.InsertDataBase(CurrentUserInfo.CurrentUser.customer_id, CurrentUserInfo.UserID, para.SetoffToolID, "Share", new CC_Coupon()
                                    {
                                        CustomerId   = CurrentUserInfo.CurrentUser.customer_id,
                                        CouponTypeId = para.ObjectId
                                    });
                                    setoffToolDetailRD.Name = couponTypeInfo[0].CouponTypeName + ",已飞入您的账户";
                                }
                                catch (Exception ex)
                                {
                                    setoffToolDetailRD.Name = "很遗憾此次优惠券" + couponTypeInfo[0].CouponTypeName + "的分享已失效,下次请及时领取.";
                                }
                            }
                        }
                        else
                        {
                            //如果剩余数量为0时,给出已领完提示
                            if (para.ShareVipId != null && para.ShareVipId != "")
                            {
                                setoffToolDetailRD.Name = "很遗憾您来迟一步优惠券" + couponTypeInfo[0].CouponTypeName + "已被领完.";
                                //throw new APIException("很遗憾您来迟一步券已被领完.") { ErrorCode = ERROR_LOAD_WRONG };
                            }
                        }
                        if (setoffToolDetailRD.Name == null || setoffToolDetailRD.Name == "")
                        {
                            setoffToolDetailRD.Name = couponTypeInfo[0].CouponTypeName;
                        }
                        setoffToolDetailRD.StartTime = couponTypeInfo[0].BeginTime == null?Convert.ToDateTime(couponTypeInfo[0].CreateTime).ToString("yyyy-MM-dd") : Convert.ToDateTime(couponTypeInfo[0].BeginTime).ToString("yyyy-MM-dd");

                        setoffToolDetailRD.EndTime     = couponTypeInfo[0].EndTime == null ? "" : Convert.ToDateTime(couponTypeInfo[0].EndTime).ToString("yyyy-MM-dd");
                        setoffToolDetailRD.ServiceLife = couponTypeInfo[0].ServiceLife.ToString();
                    }
                    #endregion
                    setoffToolDetailRD.ToolType = para.ToolType;                     //返回工具类别
                    setoffToolDetailRD.imageUrl = imageUrl;                          //返回临时二维码
                    setoffToolDetailRD.paraTemp = iResult.ToString().Insert(4, " "); //加空格,加空格有什么作用?
                }
                if (para.ToolType == "SetoffPoster")                                 //如果为集客海报则返回背景图和二维码
                {
                    if (SetOffPosterInfo != null && SetOffPosterInfo.Length > 0)
                    {
                        var backImgInfo = imgBll.QueryByEntity(new ObjectImagesEntity()
                        {
                            ImageId = SetOffPosterInfo[0].ImageId
                        }, null);
                        setoffToolDetailRD.ToolType   = para.ToolType;
                        setoffToolDetailRD.imageUrl   = imageUrl;
                        setoffToolDetailRD.paraTemp   = iResult.ToString().Insert(4, " "); //加空格,加空格有什么作用?
                        setoffToolDetailRD.backImgUrl = backImgInfo[0].ImageURL;
                        setoffToolDetailRD.Name       = SetOffPosterInfo[0].Name;
                    }
                }
                if (flag == 1)//当为1是需进行打开工具的记录
                {
                    var SetoffToolUserView = new SetoffToolUserViewEntity();
                    SetoffToolUserView.SetoffToolUserViewID = Guid.NewGuid();
                    SetoffToolUserView.SetoffEventID        = setoffEventInfo[0].SetoffEventID;
                    SetoffToolUserView.SetoffToolID         = new Guid(para.SetoffToolID);
                    SetoffToolUserView.ToolType             = para.ToolType;
                    SetoffToolUserView.ObjectId             = para.ObjectId;
                    SetoffToolUserView.NoticePlatformType   = 1;
                    SetoffToolUserView.UserID         = CurrentUserInfo.UserID;
                    SetoffToolUserView.IsOpen         = 1;
                    SetoffToolUserView.OpenTime       = System.DateTime.Now;
                    SetoffToolUserView.CustomerId     = customerId;
                    SetoffToolUserView.CreateTime     = System.DateTime.Now;
                    SetoffToolUserView.CreateBy       = CurrentUserInfo.UserID;
                    SetoffToolUserView.LastUpdateTime = System.DateTime.Now;
                    SetoffToolUserView.LastUpdateBy   = CurrentUserInfo.UserID;
                    SetoffToolUserView.IsDelete       = 0;
                    SetoffToolUserViewBLL.Create(SetoffToolUserView);
                }
            }
            catch (Exception ex)
            {
                throw new APIException(ex.Message)
                      {
                          ErrorCode = ERROR_CODES.DEFAULT_ERROR
                      };
            }
            return(setoffToolDetailRD);
        }