예제 #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
        public string CretaeWxCode()
        {
            var responseData = new ResponseData();

            try
            {
                //微信 公共平台
                var wapentity = new WApplicationInterfaceBLL(this.CurrentUserInfo).QueryByEntity(new WApplicationInterfaceEntity
                {
                    CustomerId = this.CurrentUserInfo.ClientID,
                    IsDelete   = 0
                }, null).FirstOrDefault();

                //获取当前二维码 最大值
                var MaxWQRCod = new WQRCodeManagerBLL(this.CurrentUserInfo).GetMaxWQRCod() + 1;

                if (wapentity == null || wapentity.ApplicationId == null)
                {
                    responseData.success = false;
                    responseData.msg     = "无设置微信公众平台!";
                    return(responseData.ToJSON());
                }

                string imageUrl = string.Empty;

                #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))
                {
                    responseData.success = false;
                    responseData.msg     = "二维码生成失败!";
                }
                else
                {
                    string host = ConfigurationManager.AppSettings["DownloadImageUrl"];
                    CPOS.Common.DownloadImage downloadServer = new DownloadImage();
                    imageUrl = downloadServer.DownloadFile(imageUrl, host);
                }
                #endregion
                responseData.success = true;
                responseData.msg     = "二维码生成成功!";
                var rp = new ReposeData()
                {
                    imageUrl  = imageUrl,
                    MaxWQRCod = MaxWQRCod
                };
                responseData.data = rp;
                return(responseData.ToJSON());
            }
            catch (Exception ex)
            {
                throw new APIException(ex.Message);
            }
        }
예제 #4
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);
        }
예제 #5
0
        public string DeleteData()
        {
            var    service      = new WQRCodeManagerBLL(CurrentUserInfo);
            string content      = string.Empty;
            string error        = "删除成功";
            var    responseData = new ResponseData();
            string key          = string.Empty;

            try
            {
                if (Request("ids") != null && Request("ids") != string.Empty)
                {
                    key = Request("ids").ToString().Trim();
                }
                if (key == null || key.Length == 0)
                {
                    responseData.success = false;
                    responseData.msg     = "请选择分类";
                    return(responseData.ToJSON());;
                }

                var status = "-1";
                if (FormatParamValue(Request("status")) != null && FormatParamValue(Request("status")) != string.Empty)
                {
                    status = FormatParamValue(Request("status")).ToString().Trim();
                }

                var idList = key.Split(',');
                foreach (var tmpId in idList)
                {
                    if (tmpId.Trim().Length > 0)
                    {
                        service.Delete(new WQRCodeManagerEntity()
                        {
                            QRCodeId = Guid.Parse(tmpId.Trim())
                        });
                    }
                }
                responseData.success = true;
                responseData.msg     = error;
            }
            catch (Exception ex)
            {
                responseData.success = false;
                responseData.msg     = ex.Message;
            }
            content = responseData.ToJSON();
            return(content);
        }
예제 #6
0
        protected override ActivityListRD ProcessRequest(APIRequest <ActivityListRP> pRequest)
        {
            var rd = new ActivityListRD();

            var               para = pRequest.Parameters;
            var               loggingSessionInfo = new SessionManager().CurrentUserLoginInfo;
            T_CTW_LEventBLL   bllCTWEvent        = new T_CTW_LEventBLL(loggingSessionInfo);
            WQRCodeManagerBLL bllWQRCode         = new WQRCodeManagerBLL(loggingSessionInfo);
            DataSet           ds = bllCTWEvent.GetLeventInfo(para.Status, para.ActivityGroupCode, para.EventName);

            if (ds != null && ds.Tables.Count > 0)
            {
                //var activity = new MyActivity();
                //List<MyActivity> ActiviyList = new List<MyActivity>();
                //foreach (DataRow dr in ds.Tables[0].Rows)
                //{
                //    activity = DataTableToObject.ConvertToObject<MyActivity>(dr);
                //    if (dr["DrawMethodCode"].ToString() == "HB" || dr["DrawMethodCode"].ToString() == "DZP" || dr["DrawMethodCode"].ToString() == "QN")
                //    {
                //        activity.EventInfo = DataTableToObject.ConvertToObject<EventInfo>(bllCTWEvent.GetEventInfoByLEventId(1, dr["LeventId"].ToString()).Tables[0].Rows[0]);
                //    }
                //    if (dr["DrawMethodCode"].ToString() == "QG" || dr["DrawMethodCode"].ToString() == "TG" || dr["DrawMethodCode"].ToString() == "RX")
                //    {
                //        activity.EventInfo = DataTableToObject.ConvertToObject<EventInfo>(bllCTWEvent.GetEventInfoByLEventId(2, dr["LeventId"].ToString()).Tables[0].Rows[0]);
                //    }
                //    //WQRCodeManagerEntity entityQRCode = bllWQRCode.QueryByEntity(new WQRCodeManagerEntity() { ObjectId = dr["CTWEventId"].ToString() }, null).FirstOrDefault();
                //    //activity.QRCodeImageUrlForOnline = entityQRCode == null ? "" : entityQRCode.ImageUrl;

                //    //entityQRCode = bllWQRCode.QueryByEntity(new WQRCodeManagerEntity() { ObjectId = dr["LeventId"].ToString() }, null).FirstOrDefault();
                //    //activity.QRCodeImageUrlForUnit = entityQRCode == null ? "" : entityQRCode.ImageUrl;
                //    ActiviyList.Add(activity);
                //}
                rd.MyActivityList = DataTableToObject.ConvertToList <MyActivity>(ds.Tables[0]);
            }
            DataSet dsEvent = new DataSet();

            dsEvent = bllCTWEvent.GetEventStatusCount(loggingSessionInfo.CurrentUser.customer_id);
            if (dsEvent != null && dsEvent.Tables.Count > 0)
            {
                rd.EventStatusCoountList = DataTableToObject.ConvertToList <EventStatusCoount>(dsEvent.Tables[0]);
            }
            return(rd);
        }
예제 #7
0
        //生成员工二维码
        public string CreateUserWxCode(UserInfo user, string unitName, LoggingSessionInfo loggingSessionInfo, out string errorMsg)
        {
            errorMsg = "";
            #region  生成员工二维码
            //微信 公共平台
            //兼容模式
            var wapentity = new WApplicationInterfaceBLL(loggingSessionInfo).QueryByEntity(new WApplicationInterfaceEntity
            {
                CustomerId = loggingSessionInfo.ClientID,
                IsDelete   = 0
            }, null).FirstOrDefault();//取默认的第一个微信

            var QRCodeId            = Guid.NewGuid();
            var QRCodeManagerentity = new WQRCodeManagerBLL(loggingSessionInfo).QueryByEntity(new WQRCodeManagerEntity
            {
                ObjectId = user.User_Id
            }, null).FirstOrDefault();
            if (QRCodeManagerentity != null)
            {
                QRCodeId = (Guid)QRCodeManagerentity.QRCodeId;
            }
            if (QRCodeManagerentity == null)
            {
                //二维码类别
                var wqrentity = new WQRCodeTypeBLL(loggingSessionInfo).QueryByEntity(
                    new WQRCodeTypeEntity {
                    TypeCode = "UserQrCode"
                }
                    , null).FirstOrDefault();
                if (wqrentity == null)
                {
                    //responseData.success = false;
                    //responseData.msg = "无法获取员工二维码类别";
                    //return responseData.ToJSON();
                    errorMsg = "无法获取员工二维码类别";
                }
                //生成了微信二维码
                var wxCode = CretaeWxCode(loggingSessionInfo);//***
                //如果名称不为空,就把图片放在一定的背景下面
                if (!string.IsNullOrEmpty(user.User_Name) && wxCode.success == true)
                {
                    try
                    {
                        string apiDomain = ConfigurationManager.AppSettings["original_url"];
                        wxCode.ImageUrl = CombinImage(apiDomain + @"/HeadImage/qrcodeBack.jpg", wxCode.ImageUrl, unitName + "-" + user.User_Name);
                    }
                    catch
                    {
                        errorMsg = "生成二维码失败";
                    }
                }
                else
                {
                    errorMsg = "生成二维码失败";
                }

                var WQRCodeManagerbll = new WQRCodeManagerBLL(loggingSessionInfo);//兼容模式

                //    Guid QRCodeId = Guid.NewGuid();

                if (!string.IsNullOrEmpty(wxCode.ImageUrl))
                {
                    WQRCodeManagerbll.Create(new WQRCodeManagerEntity
                    {
                        QRCodeId      = QRCodeId,
                        QRCode        = wxCode.MaxWQRCod.ToString(),
                        QRCodeTypeId  = wqrentity.QRCodeTypeId,
                        IsUse         = 1,
                        ObjectId      = user.User_Id,
                        CreateBy      = loggingSessionInfo.UserID,//兼容模式
                        ApplicationId = wapentity.ApplicationId,
                        IsDelete      = 0,
                        ImageUrl      = wxCode.ImageUrl,
                        CustomerId    = loggingSessionInfo.ClientID
                    });
                }

                return(wxCode.ImageUrl);//生成新的二维码地址
            }
            else
            {
                return(QRCodeManagerentity.ImageUrl);
            }



            #endregion
        }
예제 #8
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();
            }
        }
예제 #9
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
        }
예제 #10
0
        protected override SetCTWEventRD ProcessRequest(APIRequest <SetCTWEventRP> pRequest)
        {
            //图文信息
            //微信 公共平台
            var wapentity = new WApplicationInterfaceBLL(loggingSessionInfo).QueryByEntity(new WApplicationInterfaceEntity
            {
                CustomerId = loggingSessionInfo.ClientID,
                IsDelete   = 0
            }, null).FirstOrDefault();//取默认的第一个微信

            if (wapentity == null)
            {
                throw new APIException("微信公众号未授权")
                      {
                          ErrorCode = 343
                      };
            }

            var rd = new SetCTWEventRD();

            var para = pRequest.Parameters;

            strCTWEventId = para.CTWEventId;
            string strThemeId       = string.Empty;
            string strStartDate     = string.Empty;
            string strEndDate       = string.Empty;
            string strGameEventGuid = string.Empty;
            string strPageParamJson = string.Empty;

            T_CTW_LEventBLL             bllCustomerEvent       = new T_CTW_LEventBLL(loggingSessionInfo);
            T_CTW_LEventThemeBLL        bllCustomerTheme       = new T_CTW_LEventThemeBLL(loggingSessionInfo);
            T_CTW_LEventInteractionBLL  bllCustomerInteraction = new T_CTW_LEventInteractionBLL(loggingSessionInfo);
            T_CTW_PanicbuyingEventKVBLL bllPanicbuyingEventKV  = new T_CTW_PanicbuyingEventKVBLL(loggingSessionInfo);
            T_CTW_SpreadSettingBLL      bllSpreadSetting       = new T_CTW_SpreadSettingBLL(loggingSessionInfo);
            LPrizesBLL      bllPrize = new LPrizesBLL(loggingSessionInfo);
            ObjectImagesBLL imageBll = new ObjectImagesBLL(loggingSessionInfo);


            entityCustomerEvent = bllCustomerEvent.GetByID(strCTWEventId);
            if (entityCustomerEvent != null)
            {
                ///风格
                entityTheme = bllCustomerTheme.QueryByEntity(new T_CTW_LEventThemeEntity()
                {
                    CTWEventId = new Guid(strCTWEventId), OriginalThemeId = new Guid(para.OriginalThemeId)
                }, null).FirstOrDefault();
                //互动方式
                entityInteraction = bllCustomerInteraction.QueryByEntity(new T_CTW_LEventInteractionEntity {
                    CTWEventId = new Guid(strCTWEventId), OriginalLeventId = new Guid(para.OriginalLeventId)
                }, null).FirstOrDefault();
            }
            //保存风格
            SaveAndUpdateTheme(para, entityTheme, out strThemeId);
            //互动类型--游戏
            if (para.InteractionType == 1 && para.GameEventInfo != null)
            {
                SaveGameEvent(para, bllPrize, bllCustomerInteraction, strThemeId, out strStartDate, out strEndDate, out strGameEventGuid);
                para.MaterialText.PageParamJson = "[{\"key\":\"eventId\",\"value\":\"" + strCTWEventId + "\"}]";
                strPageParamJson = "[{\"key\":\"eventId\",\"value\":\"" + strCTWEventId + "\"}]";
            }
            //互动类型--促销
            if (para.InteractionType == 2 && para.PanicbuyingEventInfo != null)
            {
                SavePanicbuyingEvent(para, bllPanicbuyingEventKV, imageBll, bllCustomerInteraction, strThemeId, out strStartDate, out strEndDate);
                string strEventType = string.Empty;
                switch (para.DrawMethodCode)
                {
                case "TG":
                    strEventType = "1";
                    break;

                case "QG":
                    strEventType = "2";
                    break;

                case "RX":
                    strEventType = "3";
                    break;

                default:
                    strEventType = "99";
                    break;
                }
                para.MaterialText.PageParamJson = "[{\"key\":\"CTWEventId\",\"value\":\"" + strCTWEventId + "\"},{\"key\":\"eventTypeId\",\"value\":\"" + strEventType + "\"}]";
                strPageParamJson = "[{\"key\":\"CTWEventId\",\"value\":\"" + strCTWEventId + "\"},{\"key\":\"eventTypeId\",\"value\":\"" + strEventType + "\"}]";


                //SaveAndUpdatePanicbuyingEvent(para,bllPrize,bllPanicbuyingEventKV,imageBll,bllCustomerInteraction, strThemeId, out strStartDate, out strEndDate);
            }
            string strFocesQRCodeUrl = string.Empty;

            //分享,推广
            if (para.SpreadSettingList.Count > 0)
            {
                SaveSpreadSetting(para, bllSpreadSetting, imageBll, wapentity, out strFocesQRCodeUrl);
            }
            ///推广关注的奖励设置入 触点活动数据表
            if (para.ContactPrizeList != null && para.ContactPrizeList.Count > 0)
            {
                SaveContactPrize(para, bllPrize, strStartDate, strEndDate);
            }
            string strOnlineQRCodeId     = string.Empty;
            string strOfflineQRCodeId    = string.Empty;
            string strOnlineQRCodeUrl    = string.Empty;
            string strOfflineQRCodeUrl   = string.Empty;
            string strOnlineRedirectUrl  = string.Empty;
            string strOfflineRedirectUrl = string.Empty;

            var WQRCodeManagerbll = new WQRCodeManagerBLL(loggingSessionInfo);

            if (!string.IsNullOrEmpty(para.OfflineQRCodeId))
            {
                WQRCodeManagerbll.Delete(new WQRCodeManagerEntity()
                {
                    QRCodeId = new Guid(para.OfflineQRCodeId)
                });
            }
            if (!string.IsNullOrEmpty(para.OnlineQRCodeId))
            {
                WQRCodeManagerbll.Delete(new WQRCodeManagerEntity()
                {
                    QRCodeId = new Guid(para.OnlineQRCodeId)
                });
            }
            CreateQRCode(para, wapentity, strPageParamJson, out strOfflineQRCodeId, out strOfflineQRCodeUrl, out strOfflineRedirectUrl);
            CreateH5QRCode(para, wapentity, out strOnlineQRCodeId, out strOnlineQRCodeUrl, out strOnlineRedirectUrl);

            rd.OfflineQRCodeUrl   = strOfflineQRCodeUrl;
            rd.OnlineQRCodeUrl    = strOnlineQRCodeUrl;
            rd.OfflineRedirectUrl = strOfflineRedirectUrl;
            rd.OnlineRedirectUrl  = strOnlineRedirectUrl;//strFocesQRCodeUrl;

            if (entityCustomerEvent != null)
            {   //活动主表
                entityCustomerEvent.Name               = para.TemplateName;
                entityCustomerEvent.Desc               = para.TemplateDesc;
                entityCustomerEvent.InteractionType    = para.InteractionType;
                entityCustomerEvent.ActivityGroupId    = new Guid(para.ActivityGroupId);
                entityCustomerEvent.ImageURL           = para.TemplateImageURL;
                entityCustomerEvent.StartDate          = Convert.ToDateTime(strStartDate);
                entityCustomerEvent.EndDate            = Convert.ToDateTime(strEndDate);
                entityCustomerEvent.OnlineQRCodeId     = strOnlineQRCodeId;
                entityCustomerEvent.OfflineQRCodeId    = strOfflineQRCodeId;
                entityCustomerEvent.OffLineRedirectUrl = strOfflineRedirectUrl;
                entityCustomerEvent.OnLineRedirectUrl  = strOnlineRedirectUrl;
                bllCustomerEvent.Update(entityCustomerEvent);
            }
            else
            {
                entityCustomerEvent = new T_CTW_LEventEntity()
                {
                    CTWEventId         = new Guid(para.CTWEventId),
                    TemplateId         = new Guid(para.TemplateId),
                    Name               = para.TemplateName,
                    Desc               = para.TemplateDesc,
                    ActivityGroupId    = new Guid(para.ActivityGroupId),
                    InteractionType    = para.InteractionType,
                    ImageURL           = para.TemplateImageURL,
                    Status             = 10,
                    CustomerId         = loggingSessionInfo.ClientID,
                    StartDate          = Convert.ToDateTime(strStartDate),
                    EndDate            = Convert.ToDateTime(strEndDate),
                    OfflineQRCodeId    = strOfflineQRCodeId,
                    OnlineQRCodeId     = strOnlineQRCodeId,
                    OffLineRedirectUrl = strOfflineRedirectUrl,
                    OnLineRedirectUrl  = strOnlineRedirectUrl
                };
                bllCustomerEvent.Create(entityCustomerEvent);
            }
            return(rd);
        }
예제 #11
0
        public WxCode CretaeWxCode()
        {
            var responseData = new WxCode();

            responseData.success = false;
            responseData.msg     = "二维码生成失败!";
            var loggingSessionInfo = new SessionManager().CurrentUserLoginInfo;

            try
            {
                //微信 公共平台
                var wapentity = new WApplicationInterfaceBLL(loggingSessionInfo).QueryByEntity(new WApplicationInterfaceEntity
                {
                    CustomerId = loggingSessionInfo.ClientID,
                    IsDelete   = 0
                }, null).FirstOrDefault();

                //获取当前二维码 最大值
                var MaxWQRCod = new WQRCodeManagerBLL(loggingSessionInfo).GetMaxWQRCod() + 1;

                if (wapentity == null)
                {
                    responseData.success = false;
                    responseData.msg     = "无设置微信公众平台!";
                    return(responseData);
                }

                string imageUrl = string.Empty;

                #region 生成二维码
                JIT.CPOS.BS.BLL.WX.CommonBLL commonServer = new JIT.CPOS.BS.BLL.WX.CommonBLL();
                try
                {
                    imageUrl = commonServer.GetQrcodeUrl(wapentity.AppID.ToString().Trim()
                                                         , wapentity.AppSecret.Trim()
                                                         , "1", MaxWQRCod
                                                         , loggingSessionInfo);
                }
                catch (Exception e)
                {
                    responseData.success = false;
                    responseData.msg     = e.Message;// "二维码生成失败!";
                    return(responseData);
                }

                if (!string.IsNullOrEmpty(imageUrl))
                {
                    string host = ConfigurationManager.AppSettings["DownloadImageUrl"];
                    CPOS.Common.DownloadImage downloadServer = new DownloadImage();
                    imageUrl = downloadServer.DownloadFile(imageUrl, host);
                }
                #endregion
                responseData.success   = true;
                responseData.msg       = "";
                responseData.ImageUrl  = imageUrl;
                responseData.MaxWQRCod = MaxWQRCod;


                return(responseData);
            }
            catch (Exception ex)
            {
                //throw new APIException(ex.Message);
                return(responseData);
            }
        }
예제 #12
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);
        }
예제 #13
0
        /// <summary>
        /// 获取商品信息
        /// </summary>
        public string GetItemInfoById()
        {
            var      itemService = new ItemService(CurrentUserInfo);
            ItemInfo data        = new ItemInfo();
            string   content     = string.Empty;

            string key = string.Empty;

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

            data = itemService.GetItemInfoById(CurrentUserInfo, key);
            WQRCodeManagerBLL wQRCodeManagerBLL = new WQRCodeManagerBLL(CurrentUserInfo);
            var entity = wQRCodeManagerBLL.QueryByEntity(new WQRCodeManagerEntity
            {
                ObjectId = key
                ,
                IsDelete = 0
            }, null).FirstOrDefault();

            #region 图文|二维码


            if (entity != null)
            {
                data.imageUrl = entity.ImageUrl;
                var WKeywordReplyentity = new WKeywordReplyBLL(this.CurrentUserInfo).QueryByEntity(new WKeywordReplyEntity()
                {
                    Keyword = entity.QRCodeId.ToString()
                }, null).FirstOrDefault();
                if (WKeywordReplyentity != null)
                {
                    if (WKeywordReplyentity.ReplyType == 1)
                    {
                        data.ReplyType = "1";
                        data.Text      = WKeywordReplyentity.Text;
                    }
                    else if (WKeywordReplyentity.ReplyType == 3)
                    {
                        data.ReplyType = "3";
                        WMenuMTextMappingBLL bll       = new WMenuMTextMappingBLL(this.CurrentUserInfo);
                        WMaterialTextBLL     wmbll     = new WMaterialTextBLL(this.CurrentUserInfo);
                        OrderBy[]            pOrderBys = new OrderBy[] {
                            new OrderBy()
                            {
                                FieldName = "CreateTime", Direction = OrderByDirections.Asc
                            }
                        };
                        var textMapping = bll.QueryByEntity(new WMenuMTextMappingEntity
                        {
                            MenuId   = WKeywordReplyentity.ReplyId,
                            IsDelete = 0
                        }, pOrderBys);
                        if (textMapping != null && textMapping.Length > 0)
                        {
                            List <WMaterialTextEntity> list = new List <WMaterialTextEntity>();
                            foreach (var item in textMapping)
                            {
                                WMaterialTextEntity WMaterialTextentity = wmbll.QueryByEntity(new WMaterialTextEntity {
                                    TextId = item.TextId, IsDelete = 0
                                }, null)[0];
                                list.Add(WMaterialTextentity);
                            }
                            data.listMenutext = list;
                        }
                    }
                }
            }
            #endregion


            var jsonData = new JsonData();
            jsonData.totalCount = data == null ? "0" : "1";
            jsonData.data       = data;

            content = jsonData.ToJSON();
            return(content);
        }
예제 #14
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);
        }
예제 #15
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);
        }
예제 #16
0
        /// <summary>
        /// 获取商品信息
        /// </summary>
        public string GetItemInfoById()
        {
            var      itemService = new ItemService(CurrentUserInfo);
            ItemInfo data        = new ItemInfo();
            string   content     = string.Empty;

            string key = string.Empty;

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

            data = itemService.GetItemInfoById(CurrentUserInfo, key);

            if (data.ifservice == 0)
            {
                data.ItemDeliverySettings = new T_Item_Delivery_MappingBLL(CurrentUserInfo).QueryByEntity(new T_Item_Delivery_MappingEntity()
                {
                    Item_Id = data.Item_Id
                }, null);
            }
            else if (data.ifservice == 1)
            {
                data.VirtualItems = new T_VirtualItemTypeSettingBLL(CurrentUserInfo).QueryByEntity(new T_VirtualItemTypeSettingEntity()
                {
                    ItemId = data.Item_Id
                }, null);
            }

            //图片信息
            //根据实体条件查询实体
            var imageService = new ObjectImagesBLL(CurrentUserInfo);
            var itemObj      = imageService.QueryByEntity(new ObjectImagesEntity()
            {
                ObjectId = key
            }, null);

            if (itemObj != null && itemObj.Length > 0)
            {
                //itemObj竟然是个数组,把自动生成的产品二维码给过滤掉,不显示出来
                itemObj            = itemObj.Where <ObjectImagesEntity>(t => t.Description != "自动生成的产品二维码").ToArray <ObjectImagesEntity>();
                data.ItemImageList = itemObj.OrderBy(item => item.DisplayIndex).ToList();
            }

            WQRCodeManagerBLL wQRCodeManagerBLL = new WQRCodeManagerBLL(CurrentUserInfo);
            var entity = wQRCodeManagerBLL.QueryByEntity(new WQRCodeManagerEntity
            {
                ObjectId = key
                ,
                IsDelete = 0
            }, null).FirstOrDefault();

            #region 图文|二维码


            if (entity != null)
            {
                data.imageUrl = entity.ImageUrl;
                var WKeywordReplyentity = new WKeywordReplyBLL(this.CurrentUserInfo).QueryByEntity(new WKeywordReplyEntity()
                {
                    Keyword = entity.QRCodeId.ToString()
                }, null).FirstOrDefault();
                if (WKeywordReplyentity != null)
                {
                    if (WKeywordReplyentity.ReplyType == 1)
                    {
                        data.ReplyType = "1";
                        data.Text      = WKeywordReplyentity.Text;
                    }
                    else if (WKeywordReplyentity.ReplyType == 3)
                    {
                        data.ReplyType = "3";
                        WMenuMTextMappingBLL bll       = new WMenuMTextMappingBLL(this.CurrentUserInfo);
                        WMaterialTextBLL     wmbll     = new WMaterialTextBLL(this.CurrentUserInfo);
                        OrderBy[]            pOrderBys = new OrderBy[] {
                            new OrderBy()
                            {
                                FieldName = "CreateTime", Direction = OrderByDirections.Asc
                            }
                        };
                        var textMapping = bll.QueryByEntity(new WMenuMTextMappingEntity
                        {
                            MenuId   = WKeywordReplyentity.ReplyId,
                            IsDelete = 0
                        }, pOrderBys);
                        if (textMapping != null && textMapping.Length > 0)
                        {
                            List <WMaterialTextEntity> list = new List <WMaterialTextEntity>();
                            foreach (var item in textMapping)
                            {
                                WMaterialTextEntity WMaterialTextentity = wmbll.QueryByEntity(new WMaterialTextEntity {
                                    TextId = item.TextId, IsDelete = 0
                                }, null)[0];
                                list.Add(WMaterialTextentity);
                            }
                            data.listMenutext = list;
                        }
                    }
                }
            }
            #endregion


            var jsonData = new JsonData();
            jsonData.totalCount = data == null ? "0" : "1";
            jsonData.data       = data;

            content = jsonData.ToJSON();
            return(content);
        }