Exemplo n.º 1
0
        /// <summary>
        /// 通过商品ID获取商品图片信息
        /// </summary>
        public string GetItemImageInfoByItemIdData()
        {
            var imageService = new ObjectImagesBLL(CurrentUserInfo);
            IList <ObjectImagesEntity> data = new List <ObjectImagesEntity>();
            string content = string.Empty;

            string key = string.Empty;

            if (Request("item_id") != null && Request("item_id") != string.Empty)
            {
                key = Request("item_id").ToString().Trim();//商品标识
            }
            //根据实体条件查询实体
            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    = itemObj.OrderBy(item => item.DisplayIndex).ToList();
            }

            var jsonData = new JsonData();

            jsonData.totalCount = data.Count.ToString();
            jsonData.data       = data;

            content = jsonData.ToJSON();
            return(content);
        }
Exemplo n.º 2
0
        /// <summary>
        /// 通过商品ID获取商品图片信息
        /// </summary>
        public string GetItemImageInfoByItemIdData()
        {
            var imageService = new ObjectImagesBLL(CurrentUserInfo);
            IList <ObjectImagesEntity> data = new List <ObjectImagesEntity>();
            string content = string.Empty;

            string key = string.Empty;

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

            var itemObj = imageService.QueryByEntity(new ObjectImagesEntity()
            {
                ObjectId = key
            }, null);

            if (itemObj != null && itemObj.Length > 0)
            {
                data = itemObj.OrderBy(item => item.DisplayIndex).ToList();
            }

            var jsonData = new JsonData();

            jsonData.totalCount = data.Count.ToString();
            jsonData.data       = data;

            content = jsonData.ToJSON();
            return(content);
        }
Exemplo n.º 3
0
        protected override SetoffPosterRD ProcessRequest(DTO.Base.APIRequest <SetoffPosterRP> pRequest)
        {
            var rd   = new SetoffPosterRD();
            var para = pRequest.Parameters;
            var loggingSessionInfo = new SessionManager().CurrentUserLoginInfo;
            var SetoffPosterBll    = new SetoffPosterBLL(loggingSessionInfo);
            var ObjectImagesBll    = new ObjectImagesBLL(loggingSessionInfo);
            //
            var pTran = SetoffPosterBll.GetTran();
            var Data  = SetoffPosterBll.GetByID(para.SetoffPosterID);

            if (Data == null)
            {
                throw new APIException("数据异常,找不到集客海报!")
                      {
                          ErrorCode = ERROR_CODES.INVALID_BUSINESS
                      }
            }
            ;
            using (pTran.Connection)
            {
                try
                {
                    //图片表
                    var ObjectImageData = ObjectImagesBll.GetByID(Data.ImageId);
                    if (Data == null)
                    {
                        throw new APIException("数据异常,找不到集客海报Url!")
                              {
                                  ErrorCode = ERROR_CODES.INVALID_BUSINESS
                              }
                    }
                    ;

                    ObjectImageData.ImageURL = para.ImageUrl;
                    ObjectImagesBll.Update(ObjectImageData, pTran);//

                    Data.Name    = para.Name;
                    Data.ImageId = ObjectImageData.ImageId;
                    SetoffPosterBll.Update(Data, pTran);//

                    //
                    pTran.Commit();
                    //
                    rd.SetoffPosterID = Data.SetoffPosterID.ToString();
                    rd.Name           = Data.Name;
                    rd.ImageUrl       = ObjectImageData.ImageURL;
                }
                catch (Exception ex)
                {
                    pTran.Rollback();
                    throw ex;
                }
            }
            return(rd);
        }
    }
Exemplo n.º 4
0
        public string SellUserMainAchieve(string pRequest)
        {
            var rp = pRequest.DeserializeJSONTo <APIRequest <SellUserMainAchieveRP> >();

            if (string.IsNullOrEmpty(rp.UserID))
            {
                throw new APIException("缺少参数【UserID】或参数值为空")
                      {
                          ErrorCode = 135
                      };
            }

            var loggingSessionInfo = Default.GetBSLoggingSession(rp.CustomerID, "1");
            var bll = new RetailTraderBLL(loggingSessionInfo);
            var rd  = new SellUserMainAchieveRD();
            var rsp = new SuccessResponse <IAPIResponseData>(rd);
            //获取分销商的信息,loggingSessionInfo.ClientID
            var ds = bll.GetRetailTradersBySellUser("", rp.UserID, loggingSessionInfo.ClientID);   //获取

            //判断账号是否存在
            if (ds != null && ds.Tables.Count > 0 && ds.Tables[0].Rows.Count > 0)
            {
                rd.RetailTraderCount = ds.Tables[0].Rows.Count;
            }
            else
            {
                rd.RetailTraderCount = 0;
            }
            //取该账号下面的分销商的会员的数量
            int VipCount = bll.GetVipCountBySellUser(rp.UserID, loggingSessionInfo.ClientID);   //获取

            rd.VipCount = VipCount;

            //销售员头像
            ObjectImagesBLL    _ObjectImagesBLL = new ObjectImagesBLL(loggingSessionInfo);
            ObjectImagesEntity en = new ObjectImagesEntity();

            en.ObjectId = rp.UserID;
            List <ObjectImagesEntity> ImgList = _ObjectImagesBLL.QueryByEntity(en, null).OrderByDescending(p => p.CreateTime).ToList();

            if (ImgList != null && ImgList.Count != 0)
            {
                // string fileDNS = customerBasicSettingBll.GetSettingValueByCode("FileDNS"); ;//http://182.254.156.57:811
                rd.HeadImg = ImgList[0].ImageURL;
            }


            return(rsp.ToJSON());
        }
Exemplo n.º 5
0
        public void syncwelFareObjectImages()
        {
            var interfaceName      = "syncwelFareObjectImages";
            var loggingSessionInfo = BaseService.GetLoggingSession();
            var imageService       = new ObjectImagesBLL(loggingSessionInfo);

            var dsImages = new DataSet();
            var images   = new ImageList();

            images.mapping = new List <Image>();

            //更新接口同步表
            var queryList = UpdateInterfaceTimestamp(interfaceName, loggingSessionInfo);

            if (queryList != null && queryList.Length > 0)
            {
                //存在,根据日期条件查询
                dsImages = imageService.GetSynWelfareObjectImageList(queryList.FirstOrDefault().LatestTime.ToString());
            }
            else
            {
                //不存在,查询所有数据
                dsImages = imageService.GetSynWelfareObjectImageList(string.Empty);
            }

            if (dsImages != null && dsImages.Tables.Count > 0 && dsImages.Tables[0].Rows.Count > 0)
            {
                images.mapping = DataTableToObject.ConvertToList <Image>(dsImages.Tables[0]);

                //上传数据
                var content = images.ToJSON();
                var result  = UploadData(interfaceName, images.ToJSON());

                //写入接口日志
                var logEntity = new ZInterfaceLogEntity()
                {
                    LogId         = Utils.NewGuid(),
                    InterfaceName = interfaceName,
                    Params        = content,
                    ResultCode    = result.code,
                    ResultDesc    = result.description
                };

                InsertInterfaceLog(logEntity, loggingSessionInfo);
            }
        }
Exemplo n.º 6
0
        public void CreateQRCode(SetCTWEventRP para, WApplicationInterfaceEntity wapentity, string strPageParamJson, out string strQRCode, out string QRCodeUrl, out string RedirectUrl)
        {
            #region 获取Page信息
            var pageBll = new SysPageBLL(loggingSessionInfo);

            //根据活动的抽奖方式获取:“HB” “BigDial“
            string strPageKey = string.Empty;
            switch (para.DrawMethodCode)
            {
            case "HB":
                strPageKey = "RedPacket";
                break;

            case "DZP":
                strPageKey = "BigDial";
                break;

            case "QN":
                strPageKey = "Questionnaire";
                break;

            default:
                strPageKey = "NewsActivityList";
                break;
            }
            #endregion
            #region 生成URL
            var    Domain  = ConfigurationManager.AppSettings["interfacehost"].Replace("http://", "");
            var    Domain1 = ConfigurationManager.AppSettings["interfacehost1"].Replace("http://", "");
            string URL     = string.Empty;

            #region 系统模块
            var page = pageBll.GetPageByCustomerIdAndPageKey(loggingSessionInfo.ClientID, strPageKey).SingleOrDefault();
            if (page == null)
            {
                throw new APIException("未找到Page信息")
                      {
                          ErrorCode = 341
                      }
            }
            ;
            string path        = string.Empty;                                                                           //要替换的路径
            string urlTemplate = page.URLTemplate;                                                                       //模板URL
            string json        = page.JsonValue;                                                                         // JSON体
            var    jsonDic     = json.DeserializeJSONTo <Dictionary <string, object> >();                                //转换后的字典
            var    htmls       = jsonDic["htmls"].ToJSON().DeserializeJSONTo <Dictionary <string, object>[]>().ToList(); //htmls是一个数组,里面有他的很多属性
            Dictionary <string, object> html = null;                                                                     //选择的html信息
            var defaultHtmlId = jsonDic["defaultHtml"].ToString();
            html = htmls.Find(t => t["id"].ToString() == defaultHtmlId);                                                 //默认的htmlid*****
            if (html != null)
            {
                path = html["path"].ToString();
            }
            //判断高级oauth认证
            var scope = "snsapi_userinfo";
            //if (jsonDic.ContainsKey("scope"))//必须要判断key里是否包含scope
            //{
            //    scope = (jsonDic["scope"] == null || jsonDic["scope"].ToString() == "") ? "snsapi_base" : "snsapi_userinfo";
            //}

            //判断是否有定制,没有则取JSON体中的默认
            //找出订制内容
            if (page != null)
            {
                //看是否有htmls的定制(Node值=2)
                if (page.Node == "2")
                {
                    var nodeValue = page.NodeValue;
                    //在Json解析后的集合中找到path
                    html = htmls.Find(t => t["id"].ToString() == nodeValue);
                    if (html != null)
                    {
                        path = html["path"].ToString();
                    }
                }
            }

            //读取配置信息域名,检查不用http://开头,如果有则去除
            var IsAuth = false;
            //TODO:判断页面是否需要Auth认证,如果页面需要证则再判断这个客户有没有Auth认证,Type=3
            if (page.IsAuth == 1)
            {
                //判断这个客户是否是认证客户,type=3
                var applicationBll = new WApplicationInterfaceBLL(loggingSessionInfo);
                var application    = applicationBll.GetByID(wapentity.ApplicationId);//取默认的第一个
                if (application.WeiXinTypeId == "3")
                {
                    IsAuth = true;
                }
            }

            //替换URL模板
            #region 替换URL模板
            urlTemplate = urlTemplate.Replace("_pageName_", path); //用path替换掉_pageName_***(可以查看红包或者客服的path信息即可以知道)
            var paraDic = strPageParamJson.DeserializeJSONTo <Dictionary <string, object>[]>();
            foreach (var item in paraDic)                          //这里key和value对于活动来说,其实就是活动的eventId,和eventId的值
            {
                if (item.ContainsKey("key") && item.ContainsKey("value"))
                {
                    urlTemplate = urlTemplate.Replace("{" + item["key"] + "}", item["value"].ToString());
                }
            }

            #endregion

            //根据规则组织URL
            #region 组织URL
            //读取配置文件中的域名

            if (string.IsNullOrEmpty(Domain))
            {
                throw new APIException("微信管理:未配置域名,请在web.config中添加<add key='host' value=''/>")
                      {
                          ErrorCode = 342
                      }
            }
            ;
            if (IsAuth)
            {
                //需要认证(传参数时,需要传递applicationId,对于一个商户有多个微信服务号的,不能取默认的第一个,而是精确地取固定的微信服务号)
                //通过urlTemplate(用path替换了_pageName_),生成了goUrl
                URL = string.Format("http://{0}/WXOAuth/AuthUniversal.aspx?customerId={1}&applicationId={2}&goUrl={3}&scope={4}", Domain.Trim('/'), loggingSessionInfo.ClientID, wapentity.ApplicationId, HttpUtility.UrlEncode(string.Format("{0}{1}", Domain.Trim('/'), urlTemplate)), scope);
            }
            else
            {
                //不需要认证
                URL = string.Format("http://{0}/WXOAuth/NoAuthGoto.aspx?customerId={1}&goUrl={2}", Domain.Trim('/'), loggingSessionInfo.ClientID, HttpUtility.UrlEncode(string.Format("{0}{1}", Domain.Trim('/'), urlTemplate.Trim('/'))));
            }
            RedirectUrl = URL;
            #endregion
            #endregion

            #endregion
            string sourcePath    = HttpContext.Current.Server.MapPath("/QRCodeImage/qrcode.jpg");
            string targetPath    = HttpContext.Current.Server.MapPath("/QRCodeImage/");
            string currentDomain = "http://" + HttpContext.Current.Request.Url.Host;//当前项目域名

            QRCodeUrl = Utils.GenerateQRCode(URL, currentDomain, sourcePath, targetPath);

            ObjectImagesBLL    bllObjectImages    = new ObjectImagesBLL(loggingSessionInfo);
            ObjectImagesEntity entityObjectImages = new ObjectImagesEntity();

            entityObjectImages = new ObjectImagesEntity()
            {
                ImageId     = Utils.NewGuid(),
                CustomerId  = loggingSessionInfo.ClientID,
                ImageURL    = QRCodeUrl,
                ObjectId    = strCTWEventId,
                Title       = "",
                Description = "创意仓库活动二维码"
            };
            //把下载下来的图片的地址存到ObjectImages
            bllObjectImages.Create(entityObjectImages);
            strQRCode = entityObjectImages.ImageId.ToString();
        }
Exemplo n.º 7
0
        /// <summary>
        /// 推广分享设置
        /// </summary>
        /// <param name="para"></param>
        /// <param name="bllSpreadSetting"></param>
        /// <param name="imageBll"></param>
        public void SaveSpreadSetting(SetCTWEventRP para, T_CTW_SpreadSettingBLL bllSpreadSetting, ObjectImagesBLL imageBll, WApplicationInterfaceEntity wapentity, out string QRCodeUrl)
        {
            QRCodeUrl = string.Empty;
            string QRCodeId = string.Empty;

            if (!string.IsNullOrEmpty(para.CTWEventId))
            {
                bllSpreadSetting.DeleteByCTWEventID(para.CTWEventId);
            }
            foreach (var sItem in para.SpreadSettingList)
            {
                var bgimageEntity = new ObjectImagesEntity();
                bgimageEntity.ImageURL   = sItem.BGImageUrl;
                bgimageEntity.ObjectId   = "";
                bgimageEntity.CreateBy   = loggingSessionInfo.UserID;
                bgimageEntity.IsDelete   = 0;
                bgimageEntity.CustomerId = loggingSessionInfo.ClientID;
                bgimageEntity.ImageId    = Guid.NewGuid().ToString();
                imageBll.Create(bgimageEntity);

                if (sItem.SpreadType == "Focus")
                {
                    bool IsSuccess = true;
                    CreateFocusQRCode(para, sItem.LogoUrl, wapentity, out QRCodeUrl, out QRCodeId, out IsSuccess);
                    if (!IsSuccess)
                    {
                        throw new APIException(111, "关注二维码生成失败!请重新提交");
                    }
                    //imageEntity = new ObjectImagesEntity();
                    //imageEntity.ImageURL = QRCodeUrl;
                    //imageEntity.ObjectId = "";
                    //imageEntity.CreateBy = loggingSessionInfo.UserID;
                    //imageEntity.IsDelete = 0;
                    //imageEntity.CustomerId = loggingSessionInfo.ClientID;
                    //imageEntity.ImageId = Guid.NewGuid().ToString();
                    //imageBll.Create(imageEntity);
                }

                entitySpreadSetting = new T_CTW_SpreadSettingEntity()
                {
                    SpreadType              = sItem.SpreadType,
                    Title                   = sItem.Title,
                    ImageId                 = bgimageEntity.ImageId,
                    Summary                 = sItem.Summary,
                    PromptText              = sItem.PromptText,
                    LeadPageQRCodeImageId   = QRCodeId,
                    LeadPageSharePromptText = sItem.LeadPageSharePromptText,
                    LeadPageFocusPromptText = sItem.LeadPageFocusPromptText,
                    LeadPageRegPromptText   = sItem.LeadPageRegPromptText,
                    LogoUrl                 = sItem.LogoUrl,
                    CustomerId              = loggingSessionInfo.ClientID,
                    CTWEventId              = new Guid(strCTWEventId)
                };
                bllSpreadSetting.Create(entitySpreadSetting);
            }
        }
Exemplo n.º 8
0
        /// <summary>
        /// 保存更新促销活动信息
        /// </summary>
        /// <param name="para"></param>
        /// <returns></returns>
        public void SavePanicbuyingEvent(SetCTWEventRP para, T_CTW_PanicbuyingEventKVBLL bllPanicbuyingEventKV, ObjectImagesBLL imageBll, T_CTW_LEventInteractionBLL bllCustomerInteraction, string strThemeId, out string strStartDate, out string strEndDate)
        {
            strStartDate = string.Empty;
            strEndDate   = string.Empty;

            var PanicbuyingEvent = para.PanicbuyingEventInfo;

            imageEntity            = new ObjectImagesEntity();
            imageEntity.ImageURL   = PanicbuyingEvent.ImageUrl;
            imageEntity.ObjectId   = "";
            imageEntity.CreateBy   = loggingSessionInfo.UserID;
            imageEntity.IsDelete   = 0;
            imageEntity.CustomerId = loggingSessionInfo.ClientID;
            imageEntity.ImageId    = Guid.NewGuid().ToString();
            imageBll.Create(imageEntity);
            if (!string.IsNullOrEmpty(para.CTWEventId))
            {
                bllPanicbuyingEventKV.DeleteByCTWEventID(para.CTWEventId);
            }
            entityPanicbuyingEventKV = new T_CTW_PanicbuyingEventKVEntity()
            {
                CTWEventId = new Guid(strCTWEventId),
                EventName  = PanicbuyingEvent.EventName,
                ImageId    = imageEntity.ImageId
            };
            bllPanicbuyingEventKV.Create(entityPanicbuyingEventKV);

            if (!string.IsNullOrEmpty(para.CTWEventId))
            {
                bllCustomerInteraction.DeleteByCTWEventID(para.CTWEventId);
            }
            foreach (var eventid in PanicbuyingEvent.PanicbuyingEventId)
            {
                ///互动类型与(游戏或促销)关联
                entityInteraction = new T_CTW_LEventInteractionEntity()
                {
                    CTWEventId      = new Guid(strCTWEventId),
                    ThemeId         = new Guid(strThemeId),
                    InteractionType = para.InteractionType,
                    DrawMethodCode  = para.DrawMethodCode,
                    LeventId        = eventid.ToString(),
                    CustomerId      = loggingSessionInfo.ClientID
                };
                bllCustomerInteraction.Create(entityInteraction);
            }

            DataSet ds = bllCustomerInteraction.GetPanicbuyingEventDate(strCTWEventId);

            if (ds != null && ds.Tables[0].Rows.Count > 0)
            {
                strStartDate = ds.Tables[0].Rows[0]["BeginTime"].ToString();
                strEndDate   = ds.Tables[0].Rows[0]["EndTime"].ToString();
            }
        }
Exemplo n.º 9
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);
        }
Exemplo n.º 10
0
        protected override SetSignInRD ProcessRequest(DTO.Base.APIRequest <SetSignInRP> pRequest)
        {
            SetSignInRD rd = new SetSignInRD();

            string customerCode = pRequest.Parameters.CustomerCode;

            string phone = pRequest.Parameters.LoginName;

            string password = pRequest.Parameters.Password;

            if (string.IsNullOrEmpty(customerCode))
            {
                throw new APIException("客户代码不能为空")
                      {
                          ErrorCode = Error_CustomerCode_NotNull
                      };
            }

            WMenuBLL menuServer = new WMenuBLL(Default.GetAPLoggingSession(""));
            string   customerId = menuServer.GetCustomerIDByCustomerCode(customerCode);

            if (string.IsNullOrEmpty(customerId))
            {
                throw new APIException("客户代码对应的客户不存在")
                      {
                          ErrorCode = Error_CustomerCode_NotExist
                      };
            }
            var currentUserInfo = Default.GetBSLoggingSession(customerId, "1");

            VipBLL vipBll = new VipBLL(currentUserInfo);

            #region 判断用户是否存在
            if (!vipBll.JudgeUserExist(phone, customerId))
            {
                throw new APIException("用户名无效")
                      {
                          ErrorCode = Error_UserName_InValid
                      };
            }

            #endregion

            #region 判断密码是否正确
            if (!vipBll.JudgeUserPasswordExist(phone, customerId, password))
            {
                throw new APIException("登录密码错误")
                      {
                          ErrorCode = Error_Password_InValid
                      };
            }

            #endregion
            #region 判断是否有登录连锁掌柜App权限
            var  userRolesDs = vipBll.GetUserRoles(phone, customerId, password);
            bool flag        = false;
            foreach (DataRow row in userRolesDs.Tables[0].Rows)
            {
                if (row["Def_App_Code"].ToString().ToUpper() == "APP")
                {
                    flag = true;
                    break;
                }
            }
            if (!flag)
            {
                throw new APIException("该账号无权登录本系统")
                      {
                          ErrorCode = Error_Password_InValid
                      };
            }
            #endregion
            #region 判断该客服人员是否有客服或操作订单的权限
            //if (!vipBll.JudgeUserRoleExist(phone, customerId, password))
            //{
            //    throw new APIException("该账号无权登录本系统") { ErrorCode = Error_Password_InValid };
            //}
            #endregion

            #region 获取UserId
            var ds = vipBll.GetUserIdByUserNameAndPassword(phone, customerId, password);
            rd.UserId     = ds.Tables[0].Rows[0]["user_id"].ToString();
            rd.UserName   = ds.Tables[0].Rows[0]["user_name"].ToString();
            rd.Status     = int.Parse(ds.Tables[0].Rows[0]["user_status"].ToString());
            rd.CustomerId = customerId;
            var T_SuperRetailTraderbll  = new T_SuperRetailTraderBLL(currentUserInfo);
            var T_SuperRetailTraderInfo = T_SuperRetailTraderbll.QueryByEntity(new T_SuperRetailTraderEntity()
            {
                CustomerId = customerId, SuperRetailTraderFromId = rd.UserId, SuperRetailTraderFrom = "User"
            }, new OrderBy[] { new OrderBy()
                               {
                                   FieldName = "CreateTime", Direction = OrderByDirections.Desc
                               } }).FirstOrDefault();
            if (T_SuperRetailTraderInfo != null)
            {
                rd.SuperRetailTraderID = T_SuperRetailTraderInfo.SuperRetailTraderID.ToString();
            }
            #endregion
            //如果状态不等于1,就说明已经停用,
            if (rd.Status != 1)
            {
                throw new APIException("该员工已经被停用,请联系管理员")
                      {
                          ErrorCode = Error_Password_InValid
                      };
            }


            #region 获取角色列表
            var roleCodeDs = vipBll.GetRoleCodeByUserId(rd.UserId, customerId);

            var tmp = roleCodeDs.Tables[0].AsEnumerable().Select(t => new RoleCodeInfo()
            {
                RoleCode = t["role_code"].ToString()
            });

            #endregion
            rd.UnitId = vipBll.GetUnitByUserId(rd.UserId);//获取会集店
            TUnitBLL tUnitBLL = new TUnitBLL(currentUserInfo);
            if (!string.IsNullOrEmpty(rd.UnitId))
            {
                rd.UnitName = tUnitBLL.GetByID(rd.UnitId).UnitName;
            }
            else
            {
                rd.UnitName = "";
            }


            //app登陆用户权限 add by henry 2015-3-26
            var roleCodeList = vipBll.GetAppMenuByUserId(rd.UserId);


            //app登陆用户权限 add by henry 2015-3-26
            List <string> lst = new List <string>();
            if (roleCodeDs.Tables[0] != null && roleCodeDs.Tables[0].Rows.Count > 0)
            {
                foreach (DataRow item in roleCodeDs.Tables[0].Rows)
                {
                    var menuList = new JIT.CPOS.BS.DataAccess.AppSysService(currentUserInfo).GetRoleMenus(currentUserInfo.ClientID, item["role_id"] + "");
                    if (menuList != null)
                    {
                        lst.AddRange(menuList.Select(m => m.Menu_Code).Distinct().ToList());
                    }
                }
            }

            rd.MenuCodeList = new List <Menu>();
            foreach (var item in lst.Distinct().ToList())
            {
                rd.MenuCodeList.Add(new Menu()
                {
                    MenuCode = item
                });
            }

            //if (roleCodeList != null)
            //{
            //    rd.MenuCodeList = DataTableToObject.ConvertToList<Menu>(roleCodeList.Tables[0]);
            //}

            rd.RoleCodeList = tmp.ToArray();
            rd.CustomerName = currentUserInfo.ClientName;


            //销售员头像
            ObjectImagesBLL    _ObjectImagesBLL = new ObjectImagesBLL(currentUserInfo);
            ObjectImagesEntity en = new ObjectImagesEntity();
            en.ObjectId = rd.UserId;//根据获取的用户ID
            List <ObjectImagesEntity> ImgList = _ObjectImagesBLL.QueryByEntity(en, null).OrderByDescending(p => p.CreateTime).ToList();
            if (ImgList != null && ImgList.Count != 0)
            {
                // string fileDNS = customerBasicSettingBll.GetSettingValueByCode("FileDNS"); ;//http://182.254.156.57:811
                rd.HeadImg = ImgList[0].ImageURL;
            }


            #region 获取appLogo
            //基础数据初始化
            CustomerBasicSettingBLL      customerBasicSettingBLL = new CustomerBasicSettingBLL(currentUserInfo);
            List <CustomerBasicCodeInfo> customerBasicCodeList   = new List <CustomerBasicCodeInfo>();
            //查询条件
            CustomerBasicSettingEntity customerBasicSettingEntity = new CustomerBasicSettingEntity()
            {
                CustomerID  = currentUserInfo.ClientID,
                SettingCode = "WebLogo"
            };
            //执行查询
            List <CustomerBasicSettingEntity> customerBasicSettingEntityList = customerBasicSettingBLL.QueryByEntity(customerBasicSettingEntity, null).ToList();

            foreach (var a in customerBasicSettingEntityList)
            {
                CustomerBasicCodeInfo customerBasicCodeInfo = new CustomerBasicCodeInfo();

                if (a.SettingCode.Equals("WebLogo"))
                {
                    customerBasicCodeInfo.WebLogo = a.SettingValue.ToString();
                }
                customerBasicCodeList.Add(customerBasicCodeInfo);
            }

            rd.CustomerBasicCodeList = customerBasicCodeList;


            #endregion
            return(rd);
        }
Exemplo n.º 11
0
        public string SaveRetailTrader(string pRequest)
        {
            var rp = pRequest.DeserializeJSONTo <APIRequest <SaveRetailTraderRP> >();

            if (rp.Parameters.RetailTraderInfo == null)
            {
                throw new APIException("缺少参数【RetailTraderInfo】或参数值为空")
                      {
                          ErrorCode = 135
                      };
            }
            if (rp.Parameters.IsNewHeadImg == null)
            {
                throw new APIException("缺少参数【IsNewHeadImg】或参数值为空")
                      {
                          ErrorCode = 135
                      };
            }
            var loggingSessionInfo = Default.GetBSLoggingSession(rp.CustomerID, "1");
            var bll = new RetailTraderBLL(loggingSessionInfo);
            var rd  = new SaveRetailTraderRD();
            var rsp = new SuccessResponse <IAPIResponseData>(rd);
            //判断登陆名是否有重复的,要从ap库里取
            var ds = bll.getRetailTraderInfoByLogin2(rp.Parameters.RetailTraderInfo.RetailTraderLogin, "", loggingSessionInfo.ClientID);
            var retailTraderInfo = new RetailTraderInfo();

            //判断账号是否存在
            if (ds != null && ds.Tables.Count > 0 && ds.Tables[0].Rows.Count > 0)
            {
                var tempDt = ds.Tables[0];
                retailTraderInfo = DataTableToObject.ConvertToObject <RetailTraderInfo>(tempDt.Rows[0]); //直接根据所需要的字段反序列化
                if (retailTraderInfo.RetailTraderID != rp.Parameters.RetailTraderInfo.RetailTraderID)    //如果取出来的实体的id和传过来的参数的id不一样,说明不是同一个实体
                {
                    rsp.Message    = "该登陆账号已经存在,不能重复使用";
                    rsp.ResultCode = 137;
                    return(rsp.ToJSON());//这里要返回
                }
            }


            //从RetailTraderInfo转到RetailTraderEntity
            RetailTraderEntity en = new RetailTraderEntity();

            en.RetailTraderID = rp.Parameters.RetailTraderInfo.RetailTraderID;
            if (rp.Parameters.RetailTraderInfo.RetailTraderID == null || rp.Parameters.RetailTraderInfo.RetailTraderID.ToString() == "")
            {
                en.RetailTraderID = Guid.NewGuid().ToString();
                //获取当前最大的
                //如果是新增,则取本客户下的最大编号作为分销商编号
                en.RetailTraderCode = bll.getMaxRetailTraderCode(rp.CustomerID) + 1;

                en.CreateTime = DateTime.Now;
                en.CreateBy   = rp.UserID;
            }
            en.RetailTraderName  = rp.Parameters.RetailTraderInfo.RetailTraderName;
            en.RetailTraderLogin = rp.Parameters.RetailTraderInfo.RetailTraderLogin;
            if (!string.IsNullOrEmpty(rp.Parameters.RetailTraderInfo.RetailTraderPass))
            {
                en.RetailTraderPass = MD5Helper.Encryption(rp.Parameters.RetailTraderInfo.RetailTraderPass);
            }
            en.RetailTraderMan     = rp.Parameters.RetailTraderInfo.RetailTraderMan;
            en.RetailTraderPhone   = rp.Parameters.RetailTraderInfo.RetailTraderPhone;
            en.RetailTraderAddress = rp.Parameters.RetailTraderInfo.RetailTraderAddress;
            en.CooperateType       = rp.Parameters.RetailTraderInfo.CooperateType;
            en.SalesType           = rp.Parameters.RetailTraderInfo.SalesType;
            en.SellUserID          = rp.Parameters.RetailTraderInfo.SellUserID;
            en.UnitID = rp.Parameters.RetailTraderInfo.UnitID;
            en.Status = "1";//启用状态

            en.LastUpdateTime = DateTime.Now;
            en.LastUpdateBy   = rp.UserID;
            en.IsDelete       = 0;
            en.CustomerId     = rp.CustomerID;
            if (rp.Parameters.RetailTraderInfo.RetailTraderID == null || rp.Parameters.RetailTraderInfo.RetailTraderID.ToString() == "")
            {
                bll.Create(en);
                //  rp.Parameters.RetailTraderInfo.RetailTraderID = en.RetailTraderID;//为了返回数据时使用
            }
            else
            {
                bll.Update(en, null, false);//不更新空值的字段
            }
            //另外要保存到ap库里,这样才能登陆时从ap库里统一取出分销商信息,和对应的customerid
            if (rp.Parameters.RetailTraderInfo.RetailTraderID == null || rp.Parameters.RetailTraderInfo.RetailTraderID.ToString() == "")
            {
                bll.Create2Ap(en);                                                 //ap库里的RetailTraderID和商户里的RetailTraderID是一样的
                rp.Parameters.RetailTraderInfo.RetailTraderID = en.RetailTraderID; //为了返回数据时使用,到这里才赋值***
            }
            else
            {
                bll.Update2Ap(en, null, false);//不更新空值的字段
            }

            //如果IsNewHeadImg为1时,即上传图片时,则删除之前的关联图片(逻辑删除)
            if (rp.Parameters.IsNewHeadImg == 1)
            {
                ObjectImagesBLL    _ObjectImagesBLL = new ObjectImagesBLL(loggingSessionInfo);
                ObjectImagesEntity ObjectImagesEn   = new ObjectImagesEntity();

                _ObjectImagesBLL.DeleteByObjectID(en.RetailTraderID.ToString());
            }

            rd.RetailTraderInfo = rp.Parameters.RetailTraderInfo;


            return(rsp.ToJSON());
        }
Exemplo n.º 12
0
        protected override EmptyResponseData ProcessRequest(APIRequest <SetExtendRP> pRequest)
        {
            //SessionManager.GetLoggingSessionByCustomerId(pRequest.CustomerID);
            var loggingSessionInfo = new SessionManager().CurrentUserLoginInfo;

            if (loggingSessionInfo == null)
            {
                throw new APIException("用户未登录")
                      {
                          ErrorCode = ERROR_CODES.INVALID_REQUEST
                      }
            }
            ;
            var bll             = new SetoffEventBLL(this.CurrentUserInfo);
            var objectImagesBll = new ObjectImagesBLL(this.CurrentUserInfo);
            var setoffToolsBll  = new SetoffToolsBLL(this.CurrentUserInfo);
            var setoffPosterBll = new SetoffPosterBLL(this.CurrentUserInfo);
            var setoffEventBll  = new SetoffEventBLL(this.CurrentUserInfo);
            var pTran           = bll.GetTran();

            //获取已发布的集客行动
            var SetoffEvenResult = bll.QueryByEntity(new SetoffEventEntity()
            {
                SetoffType = 3, Status = "10"
            }, null).ToList();

            if (SetoffEvenResult.Count > 1)
            {
                throw new APIException("数据异常,只能一条分销拓展!")
                      {
                          ErrorCode = ERROR_CODES.INVALID_BUSINESS
                      }
            }
            ;
            else if (SetoffEvenResult.Count == 1)
            {
                var Result = SetoffEvenResult.First();

                #region 新增招募海报、海报集客工具关系
                foreach (var PosterItem in pRequest.Parameters.PosterList)
                {
                    //图片表
                    var ObjectImageData = new ObjectImagesEntity();
                    ObjectImageData.ImageId     = System.Guid.NewGuid().ToString("N");
                    ObjectImageData.ImageURL    = PosterItem.ImageUrl;
                    ObjectImageData.Description = "招募海报";
                    ObjectImageData.CustomerId  = loggingSessionInfo.ClientID;

                    objectImagesBll.Create(ObjectImageData);//
                    //招募海报
                    var SetoffPosterData = new SetoffPosterEntity();
                    SetoffPosterData.SetoffPosterID = System.Guid.NewGuid();
                    SetoffPosterData.Name           = PosterItem.Name;
                    SetoffPosterData.Desc           = "招募海报";
                    SetoffPosterData.ImageId        = ObjectImageData.ImageId;
                    SetoffPosterData.Status         = "10";
                    SetoffPosterData.CustomerId     = loggingSessionInfo.ClientID;

                    setoffPosterBll.Create(SetoffPosterData);

                    //海报工具关系
                    var SetoffToolsData = new SetoffToolsEntity();
                    SetoffToolsData.SetoffToolID  = System.Guid.NewGuid();
                    SetoffToolsData.SetoffEventID = Result.SetoffEventID;
                    SetoffToolsData.ToolType      = "SetoffPoster";
                    SetoffToolsData.ObjectId      = SetoffPosterData.SetoffPosterID.ToString();
                    SetoffToolsData.Status        = "10";
                    SetoffToolsData.CustomerId    = loggingSessionInfo.ClientID;

                    setoffToolsBll.Create(SetoffToolsData);//
                }
                #endregion

                #region 新增集客工具关系
                foreach (var ToolsItem in pRequest.Parameters.CommonList)
                {
                    if (Result == null)
                    {
                        throw new APIException("数据异常,未找到集客行动!")
                              {
                                  ErrorCode = ERROR_CODES.INVALID_BUSINESS
                              }
                    }
                    ;
                    //判断是否添加重复集客工具
                    bool Flag = setoffEventBll.IsToolsRepeat(Result.SetoffEventID.ToString(), ToolsItem.ObjectId);
                    if (Flag)
                    {
                        throw new APIException("集客行动不能添加项同的集客工具!")
                              {
                                  ErrorCode = ERROR_CODES.INVALID_BUSINESS
                              }
                    }
                    ;

                    var SetoffToolsData = new SetoffToolsEntity();
                    SetoffToolsData.SetoffToolID  = System.Guid.NewGuid();
                    SetoffToolsData.SetoffEventID = Result.SetoffEventID;
                    SetoffToolsData.ToolType      = ToolsItem.ToolType;
                    SetoffToolsData.ObjectId      = ToolsItem.ObjectId;
                    SetoffToolsData.Status        = "10";
                    SetoffToolsData.CustomerId    = loggingSessionInfo.ClientID;
                    setoffToolsBll.Create(SetoffToolsData);//
                }
                #endregion
            }
            else
            {
                //原集客行动状态设置为失效
                setoffEventBll.SetFailStatus(3);

                #region 新建集客行动
                //集客行动
                var SetoffEvenData = new SetoffEventEntity();//集客行动
                SetoffEvenData.SetoffEventID = System.Guid.NewGuid();
                SetoffEvenData.SetoffType    = 3;
                SetoffEvenData.Status        = "10";
                SetoffEvenData.CustomerId    = loggingSessionInfo.ClientID;
                setoffEventBll.Create(SetoffEvenData);//

                #region 新增集客海报、海报集客工具关系
                foreach (var PosterItem in pRequest.Parameters.PosterList)
                {
                    //图片表
                    var ObjectImageData = new ObjectImagesEntity();
                    ObjectImageData.ImageId     = System.Guid.NewGuid().ToString("N");
                    ObjectImageData.ImageURL    = PosterItem.ImageUrl;
                    ObjectImageData.Description = "招募海报";
                    ObjectImageData.CustomerId  = loggingSessionInfo.ClientID;
                    objectImagesBll.Create(ObjectImageData);//
                    //集客海报
                    var SetoffPosterData = new SetoffPosterEntity();
                    SetoffPosterData.SetoffPosterID = System.Guid.NewGuid();
                    SetoffPosterData.Name           = PosterItem.Name;
                    SetoffPosterData.Desc           = "招募海报";
                    SetoffPosterData.ImageId        = ObjectImageData.ImageId;
                    SetoffPosterData.Status         = "10";
                    SetoffPosterData.CustomerId     = loggingSessionInfo.ClientID;
                    setoffPosterBll.Create(SetoffPosterData);

                    //海报工具关系
                    var SetoffToolsData = new SetoffToolsEntity();
                    SetoffToolsData.SetoffToolID  = System.Guid.NewGuid();
                    SetoffToolsData.SetoffEventID = SetoffEvenData.SetoffEventID;
                    SetoffToolsData.ToolType      = "SetoffPoster";
                    SetoffToolsData.ObjectId      = SetoffPosterData.SetoffPosterID.ToString();
                    SetoffToolsData.Status        = "10";
                    SetoffToolsData.CustomerId    = loggingSessionInfo.ClientID;
                    setoffToolsBll.Create(SetoffToolsData);//
                }
                #endregion

                #region 新增集客工具关系
                foreach (var ToolsItem in pRequest.Parameters.CommonList)
                {
                    //判断是否添加重复集客工具
                    bool Flag = setoffEventBll.IsToolsRepeat(SetoffEvenData.SetoffEventID.ToString(), ToolsItem.ObjectId);
                    if (Flag)
                    {
                        throw new APIException("集客行动不能添加相同的集客工具!")
                              {
                                  ErrorCode = ERROR_CODES.INVALID_BUSINESS
                              }
                    }
                    ;

                    var SetoffToolsData = new SetoffToolsEntity();
                    SetoffToolsData.SetoffToolID  = System.Guid.NewGuid();
                    SetoffToolsData.SetoffEventID = SetoffEvenData.SetoffEventID;
                    SetoffToolsData.ToolType      = ToolsItem.ToolType;
                    SetoffToolsData.ObjectId      = ToolsItem.ObjectId;
                    SetoffToolsData.Status        = "10";
                    SetoffToolsData.CustomerId    = loggingSessionInfo.ClientID;
                    setoffToolsBll.Create(SetoffToolsData);//
                }
                #endregion


                #endregion
            }
            return(new EmptyResponseData());
        }
    }
}
Exemplo n.º 13
0
        private void DownloadQRCode()
        {
            string weixinDomain  = ConfigurationManager.AppSettings["original_url"];
            string sourcePath    = this.CurrentContext.Server.MapPath("/QRCodeImage/qrcode.jpg");
            string targetPath    = this.CurrentContext.Server.MapPath("/QRCodeImage/");
            string currentDomain = this.CurrentContext.Request.Url.Host;//当前项目域名

            if (currentDomain == "localhost")
            {
                currentDomain += ":2330";
            }
            string itemId   = FormatParamValue(Request("item_id"));   //商品ID
            string itemName = FormatParamValue(Request("item_name")); //商品名
            string imageURL;



            ObjectImagesBLL objectImagesBLL = new ObjectImagesBLL(CurrentUserInfo);

            //查找是否已经生成了二维码
            ObjectImagesEntity[] objectImagesEntityArray = objectImagesBLL.QueryByEntity(new ObjectImagesEntity()
            {
                ObjectId = itemId, Description = "自动生成的产品二维码"
            }, null);

            if (objectImagesEntityArray.Length == 0)
            {
                string applicationId = "";
                //根据CustomerId去取公众号信息

                var list = new WApplicationInterfaceBLL(CurrentUserInfo).QueryByEntity(new WApplicationInterfaceEntity {
                    CustomerId = CurrentUserInfo.ClientID, IsDelete = 0
                }, null).ToList();

                if (list != null && list.Count > 0)
                {
                    applicationId = list.FirstOrDefault().ApplicationId;
                }
                else
                {
                    //Response.Write("<br>");
                    //Response.Write("没有获取微信标识");
                    throw new Exception("该商户没有绑定微信公众号,无法生成商品二维码");
                }
                var wapentity = list.FirstOrDefault();//获取公众号信息

                //http://api.dev.chainclouds.com
                //    http://api.dev.chainclouds.com/WXOAuth/AuthUniversal.aspx?customerId=049b0a8f641f4ca7b17b0b7b6291de1f&applicationId=1D7A01FC1E7D41ECBAC2696D0D363315&goUrl=api.dev.chainclouds.com/HtmlApps/html/public/shop/goods_detail.html?rootPage=true&rootPage=true&goodsId=DBF5326F4C5B4B0F8508AB54B0B0EBD4&ver=1448273310707&scope=snsapi_userinfo

                string itemUrl = weixinDomain + "/WXOAuth/AuthUniversal.aspx?customerId=" + CurrentUserInfo.ClientID
                                 + "&applicationId=" + applicationId
                                 + "&goUrl=" + weixinDomain + "/HtmlApps/html/public/shop/goods_detail.html?goodsId="
                                 + itemId + "&scope=snsapi_userinfo";

                //  string itemUrl = "http://*****:*****@"/HeadImage/qrcodeBack.jpg", imageURL, itemName);
                }

                //把下载下来的图片的地址存到ObjectImages
                objectImagesBLL.Create(new ObjectImagesEntity()
                {
                    ImageId    = Utils.NewGuid(),
                    CustomerId = CurrentUserInfo.ClientID,
                    ImageURL   = imageURL,
                    ObjectId   = itemId,
                    Title      = itemName
                    ,
                    Description = "自动生成的产品二维码"
                });

                Loggers.Debug(new DebugLogInfo()
                {
                    Message = "二维码已生成,imageURL:" + imageURL
                });
            }
            else
            {
                imageURL = objectImagesEntityArray[0].ImageURL;
            }
            string imagePath = "";

            if (imageURL.IndexOf("HeadImage") > -1)
            {
                string dirPath   = System.AppDomain.CurrentDomain.BaseDirectory;
                var    imageName = imageURL.Substring(imageURL.IndexOf("HeadImage")).Replace("/", @"\");
                imagePath = dirPath + imageName;//整个
            }
            else
            {  //兼容老的存放地址
                imagePath = targetPath + imageURL.Substring(imageURL.LastIndexOf("/"));
            }

            Loggers.Debug(new DebugLogInfo()
            {
                Message = "二维码路径,imagePath:" + imageURL
            });

            try
            {
                //要下载的文件名
                FileInfo DownloadFile = new FileInfo(imagePath);

                if (DownloadFile.Exists)
                {
                    CurrentContext.Response.Clear();
                    CurrentContext.Response.AddHeader("Content-Disposition", "attachment;filename=\"" + System.Web.HttpUtility.UrlEncode(itemName, System.Text.Encoding.UTF8) + ".jpg" + "\"");
                    CurrentContext.Response.AddHeader("Content-Length", DownloadFile.Length.ToString());
                    CurrentContext.Response.ContentType = "application/octet-stream";
                    CurrentContext.Response.TransmitFile(DownloadFile.FullName);
                    CurrentContext.Response.Flush();
                }
                else
                {
                    Loggers.Debug(new DebugLogInfo()
                    {
                        Message = "二维码未找到"
                    });
                }
            }
            catch (Exception ex)
            {
                CurrentContext.Response.ContentType = "text/plain";
                CurrentContext.Response.Write(ex.Message);
            }
            finally
            {
                CurrentContext.Response.End();
            }
        }
Exemplo n.º 14
0
        private void DownloadQRCode()
        {
            string weixinDomain  = ConfigurationManager.AppSettings["original_url"];
            string sourcePath    = this.CurrentContext.Server.MapPath("/QRCodeImage/qrcode.jpg");
            string targetPath    = this.CurrentContext.Server.MapPath("/QRCodeImage/");
            string currentDomain = this.CurrentContext.Request.Url.Host;
            string itemId        = FormatParamValue(Request("item_id"));   //商品ID
            string itemName      = FormatParamValue(Request("item_name")); //商品名
            string imageURL;

            ObjectImagesBLL objectImagesBLL = new ObjectImagesBLL(CurrentUserInfo);

            //查找是否已经生成了二维码
            ObjectImagesEntity[] objectImagesEntityArray = objectImagesBLL.QueryByEntity(new ObjectImagesEntity()
            {
                ObjectId = itemId, Description = "自动生成的产品二维码"
            }, null);

            if (objectImagesEntityArray.Length == 0)
            {
                imageURL = Utils.GenerateQRCode(weixinDomain + "/HtmlApps/Auth.html?pageName=GoodsDetail&rootPage=true&customerId=" + CurrentUserInfo.ClientID + "&goodsId=" + itemId, currentDomain, sourcePath, targetPath);
                //把下载下来的图片的地址存到ObjectImages
                objectImagesBLL.Create(new ObjectImagesEntity()
                {
                    ImageId    = Utils.NewGuid(),
                    CustomerId = CurrentUserInfo.ClientID,
                    ImageURL   = imageURL,
                    ObjectId   = itemId,
                    Title      = itemName
                    ,
                    Description = "自动生成的产品二维码"
                });

                Loggers.Debug(new DebugLogInfo()
                {
                    Message = "二维码已生成,imageURL:" + imageURL
                });
            }
            else
            {
                imageURL = objectImagesEntityArray[0].ImageURL;
            }

            string imagePath = targetPath + imageURL.Substring(imageURL.LastIndexOf("/"));

            Loggers.Debug(new DebugLogInfo()
            {
                Message = "二维码路径,imagePath:" + imageURL
            });

            try
            {
                //要下载的文件名
                FileInfo DownloadFile = new FileInfo(imagePath);

                if (DownloadFile.Exists)
                {
                    CurrentContext.Response.Clear();
                    CurrentContext.Response.AddHeader("Content-Disposition", "attachment;filename=\"" + System.Web.HttpUtility.UrlEncode(itemName, System.Text.Encoding.UTF8) + ".jpg" + "\"");
                    CurrentContext.Response.AddHeader("Content-Length", DownloadFile.Length.ToString());
                    CurrentContext.Response.ContentType = "application/octet-stream";
                    CurrentContext.Response.TransmitFile(DownloadFile.FullName);
                    CurrentContext.Response.Flush();
                }
                else
                {
                    Loggers.Debug(new DebugLogInfo()
                    {
                        Message = "二维码未找到"
                    });
                }
            }
            catch (Exception ex)
            {
                CurrentContext.Response.ContentType = "text/plain";
                CurrentContext.Response.Write(ex.Message);
            }
            finally
            {
                CurrentContext.Response.End();
            }
        }
Exemplo n.º 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);
        }
Exemplo n.º 16
0
        protected override EmptyResponseData ProcessRequest(APIRequest <SetVipIntegralRP> pRequest)
        {
            var rd   = new EmptyResponseData();
            var para = pRequest.Parameters;
            var loggingSessionInfo = new SessionManager().CurrentUserLoginInfo;    //登录状态信息
            var vipIntegralDetail  = new VipIntegralDetailBLL(loggingSessionInfo); //积分变更业务对象实例化
            var objectImagesBLL    = new ObjectImagesBLL(loggingSessionInfo);      //图片表业务对象实例化
            var unitBLL            = new t_unitBLL(loggingSessionInfo);
            var vipIntegralBLL     = new VipIntegralBLL(loggingSessionInfo);
            var vipBLL             = new VipBLL(loggingSessionInfo);

            var vipInfo     = vipBLL.GetByID(para.VipID);
            var unitInfo    = unitBLL.GetByID(loggingSessionInfo.CurrentUserRole.UnitId);
            var pTran       = vipIntegralDetail.GetTran(); //事务
            var vipIntegral = vipIntegralBLL.GetByID(para.VipID);

            using (pTran.Connection)
            {
                try
                {
                    var IntegralDetail = new VipIntegralDetailEntity()
                    {
                        Integral         = para.Qty,
                        IntegralSourceID = para.IntegralSourceID,
                        ObjectId         = "",
                        Reason           = para.Reason,
                        Remark           = para.Remark
                    };
                    if (IntegralDetail.Integral != 0)
                    {
                        //变动前积分
                        string OldIntegral = string.Empty;
                        if (vipIntegral != null)
                        {
                            OldIntegral = (vipIntegral.ValidIntegral ?? 0).ToString();
                        }
                        else
                        {
                            OldIntegral = "0";
                        }

                        //变动积分
                        string ChangeIntegral      = (IntegralDetail.Integral ?? 0).ToString();
                        string vipIntegralDetailId = vipIntegralBLL.AddIntegral(ref vipInfo, unitInfo, IntegralDetail, pTran, loggingSessionInfo);
                        //发送微信积分变动通知模板消息
                        if (!string.IsNullOrWhiteSpace(vipIntegralDetailId))
                        {
                            var CommonBLL = new CommonBLL();
                            CommonBLL.PointsChangeMessage(OldIntegral, vipInfo, ChangeIntegral, vipInfo.WeiXinUserId, loggingSessionInfo);
                        }
                        //增加图片上传
                        if (!string.IsNullOrEmpty(para.ImageUrl))
                        {
                            var objectImagesEntity = new ObjectImagesEntity()
                            {
                                ImageId  = Guid.NewGuid().ToString(),
                                ObjectId = vipIntegralDetailId,
                                ImageURL = para.ImageUrl
                            };
                            objectImagesBLL.Create(objectImagesEntity);
                        }
                    }
                    pTran.Commit();  //提交事物
                }
                catch (APIException apiEx)
                {
                    pTran.Rollback();//回滚事物
                    throw new APIException(apiEx.ErrorCode, apiEx.Message);
                }
                catch (Exception ex)
                {
                    pTran.Rollback();//回滚事物
                    throw new Exception(ex.Message);
                }
            }
            return(rd);
        }
Exemplo n.º 17
0
        protected override GetConfigRD ProcessRequest(DTO.Base.APIRequest <GetConfigRP> pRequest)
        {
            var rd         = new GetConfigRD();
            var customerId = CurrentUserInfo.ClientID;
            var trrBll     = new T_RewardRecordBLL(CurrentUserInfo);//打赏记录
            var userBll    = new T_UserBLL(CurrentUserInfo);
            var cbsBll     = new CustomerBasicSettingBLL(CurrentUserInfo);
            var trcBll     = new T_RewardConfigBLL(CurrentUserInfo);
            var cbsEntity  = cbsBll.QueryByEntity(new CustomerBasicSettingEntity()
            {
                CustomerID = customerId
            }, null).FirstOrDefault();
            var trcEntitys = trcBll.QueryByEntity(new T_RewardConfigEntity()
            {
                CustomerId = customerId
            }, null);
            //获取员工
            var userInfo   = new T_UserEntity();
            var employeeId = pRequest.Parameters.EmployeeID;

            if (!string.IsNullOrEmpty(employeeId))
            {
                userInfo = userBll.QueryByEntity(new T_UserEntity()
                {
                    user_id = employeeId, customer_id = customerId
                }, null).FirstOrDefault();

                //员工头像
                var _ObjectImagesBLL = new ObjectImagesBLL(CurrentUserInfo);
                var userImg          = _ObjectImagesBLL.QueryByEntity(new ObjectImagesEntity()
                {
                    ObjectId = employeeId, CustomerId = customerId
                }, null).OrderByDescending(p => p.CreateTime).FirstOrDefault();

                //星级
                var oeBll  = new ObjectEvaluationBLL(CurrentUserInfo);
                var oeList = oeBll.QueryByEntity(new ObjectEvaluationEntity()
                {
                    ObjectID = employeeId, Type = 4, CustomerID = customerId
                }, null);
                var oeinfo = (from p in oeList.AsEnumerable()
                              group p by p.ObjectID into g
                              select new
                {
                    g.Key,
                    SumValue = g.Average(p => p.StarLevel)
                }).ToArray().FirstOrDefault();

                //打赏数据
                var rewardCount = trrBll.QueryByEntity(new T_RewardRecordEntity()
                {
                    RewardedOP = employeeId, PayStatus = 2, CustomerId = customerId
                }, null).Length;

                //员工信息
                rd.UserInfo = new List <UserInfo>();
                rd.UserInfo.Add(new UserInfo()
                {
                    UserName    = userInfo.user_name,
                    UserPhoto   = userImg != null ? userImg.ImageURL : string.Empty,
                    StarLevel   = oeinfo != null ? Convert.ToInt32(oeinfo.SumValue) : 0,
                    RewardCount = rewardCount
                });
            }

            //打赏类型
            if (cbsEntity != null)
            {
                switch (cbsEntity.SettingValue)
                {
                case "1":
                    rd.Type = 1;
                    break;

                case "2":
                    rd.Type = 2;
                    break;

                default:
                    rd.Type = 0;    //0或空(null)为两者
                    break;
                }
            }
            else
            {
                rd.Type = 0;//两者
            }

            //打赏金额列表
            rd.AmountList = new List <RewardAmountInfo>();
            foreach (var item in trcEntitys)
            {
                rd.AmountList.Add(new RewardAmountInfo()
                {
                    Amount = item.RewardAmount
                });
            }

            return(rd);
        }
Exemplo n.º 18
0
        /// <summary>
        /// 上传图片通用方法
        /// </summary>
        /// <param name="pRequest"></param>
        /// <returns></returns>
        protected string UploadFiles(string pRequest)
        {
            var rp = pRequest.DeserializeJSONTo <APIRequest <UploadFilesRP> >();

            rp.Parameters.Validate();

            var loggingSessionInfo = Default.GetBSLoggingSession(rp.CustomerID, rp.UserID);


            var rd = new EmptyRD();

            var objectImageBll = new ObjectImagesBLL(loggingSessionInfo);   //图片BLL实例化

            var    customerBasicSettingBll = new CustomerBasicSettingBLL(loggingSessionInfo);
            string expandName = rp.Parameters.ExpandName;

            //随机生成文件名称
            string fileName = StringUtil.GetRandomStr(18).ToLower() + "." + expandName;

            //允许上传的扩展名
            string allowExpandName = customerBasicSettingBll.GetSettingValueByCode("AllowUploadExpandName");

            allowExpandName = !string.IsNullOrEmpty(allowExpandName) ? allowExpandName : "gif,jpg,jpeg,png,bmp";//设置缺省图片格式
            //不允许
            if (allowExpandName.IndexOf(expandName) == -1)
            {
                var rsp = new SuccessResponse <IAPIResponseData>(rd);
                rsp.ResultCode = 1;
                rsp.Message    = "请上传" + allowExpandName + "格式的文件";
                return(rsp.ToJSON());
            }
            //转base64的编码,获取流
            MemoryStream stream = new MemoryStream(Convert.FromBase64String(rp.Parameters.Base64str));

            byte[] bytes = new byte[stream.Length];
            stream.Read(bytes, 0, bytes.Length);
            stream.Seek(0, SeekOrigin.Begin);

            if (allowExpandName.IndexOf(expandName) > -1)
            {
                //允许上传的图片最大限制
                string uploadImageMax = customerBasicSettingBll.GetSettingValueByCode("UploadImageMax");
                if (!string.IsNullOrEmpty(uploadImageMax))
                {
                    int maxSize = int.Parse(uploadImageMax);
                    if (stream.Length > maxSize)
                    {
                        var rsp = new SuccessResponse <IAPIResponseData>(rd);
                        rsp.ResultCode = 1;
                        rsp.Message    = "请上传" + maxSize + "M以内的图片";
                        return(rsp.ToJSON());
                    }
                }
            }
            //文件目录
            string uploadFilePath = customerBasicSettingBll.GetSettingValueByCode("UploadFilePath");

            uploadFilePath = string.IsNullOrEmpty(uploadFilePath)? "/Images/":uploadFilePath;//如果为空,就取默认的

            uploadFilePath += DateTime.Now.Year + "/" + DateTime.Now.Month + "." + DateTime.Now.Day + "/";
            if (!IOUtil.ExistsFile(IOUtil.MapPath(uploadFilePath)))
            {
                IOUtil.CreateDirectoryIfNotExists(IOUtil.MapPath(uploadFilePath));
            }

            // 把 byte[] 写入文件
            FileStream   fs = new FileStream(IOUtil.MapPath(uploadFilePath) + fileName, FileMode.Create);//通过IOUtil.MapPath由网络目录转换成物理目录
            BinaryWriter bw = new BinaryWriter(fs);

            bw.Write(bytes);
            bw.Close();
            fs.Close();

            objectImageBll.Create(new ObjectImagesEntity()
            {
                ImageId = Guid.NewGuid().ToString(), ObjectId = rp.Parameters.ObjectID, ImageURL = uploadFilePath + fileName
            });

            //文件DNS地址
            string fileDNS = customerBasicSettingBll.GetSettingValueByCode("FileDNS");;

            var rsp1 = new SuccessResponse <IAPIResponseData>(rd);

            rsp1.Message = fileDNS + uploadFilePath + fileName;//当前上传的图片路径
            return(rsp1.ToJSON());
        }
Exemplo n.º 19
0
        protected override SetVipCardRD ProcessRequest(DTO.Base.APIRequest <SetVipCardRP> pRequest)
        {
            var rd   = new SetVipCardRD();
            var para = pRequest.Parameters;
            var loggingSessionInfo = new SessionManager().CurrentUserLoginInfo;

            #region 业务对象
            //会员卡
            var VipCardBLL = new VipCardBLL(loggingSessionInfo);
            //余额变动记录
            var VipCardBalanceChangeBLL = new VipCardBalanceChangeBLL(loggingSessionInfo);
            //卡状态变更记录
            var VipCardStatusChangeLogBLL = new VipCardStatusChangeLogBLL(loggingSessionInfo);
            //卡关系
            var VipCardVipMappingBLL = new VipCardVipMappingBLL(loggingSessionInfo);
            //图片
            var objectImagesBLL = new ObjectImagesBLL(loggingSessionInfo);
            //会员
            var VipBLL = new VipBLL(loggingSessionInfo);

            var vipCardTransLogBLL = new VipCardTransLogBLL(loggingSessionInfo); //丰收日交易记录对象示例化
            var unitBLL            = new TUnitBLL(loggingSessionInfo);           //门店业务对象
            //事务
            var pTran = VipCardBLL.GetTran();
            #endregion



            using (pTran.Connection)
            {
                try
                {
                    if (string.IsNullOrWhiteSpace(para.VipCardID) || para.OperationType <= 0)
                    {
                        throw new APIException("卡ID或者操作类型参数不合法!")
                              {
                                  ErrorCode = ERROR_CODES.INVALID_REQUEST_LACK_REQUEST_PARAMETER
                              };
                    }

                    //定位当前卡业务对象
                    VipCardEntity changeEntity = VipCardBLL.GetByID(para.VipCardID);

                    if (changeEntity == null)
                    {
                        throw new APIException("当前卡信息对象为NULL!")
                              {
                                  ErrorCode = ERROR_CODES.INVALID_BUSINESS
                              };
                    }
                    #region 返回卡ID
                    rd.VipCardID = changeEntity.VipCardID;
                    #endregion
                    changeEntity.RechargeTotalAmount = changeEntity.RechargeTotalAmount ?? 0;
                    changeEntity.BalanceAmount       = changeEntity.BalanceAmount ?? 0;
                    string  OldVipCardCode = changeEntity.VipCardCode ?? "";                       //原卡号
                    string  NewVipCardCode = "";                                                   //新卡号,获取新卡赋值
                    decimal OldMoney       = changeEntity.BalanceAmount.Value;                     //原卡当前余额
                    decimal NewMoney       = changeEntity.BalanceAmount.Value + para.BalanceMoney; //原卡当余额+调整金额

                    //原卡会员映射关系
                    VipCardVipMappingEntity OldVipCardVipMappingData = VipCardVipMappingBLL.QueryByEntity(new VipCardVipMappingEntity()
                    {
                        VipCardID = para.VipCardID
                    }, null).FirstOrDefault();
                    if (OldVipCardVipMappingData == null)
                    {
                        throw new APIException("原卡会员关系映射对象为NULL!")
                              {
                                  ErrorCode = ERROR_CODES.INVALID_BUSINESS
                              };
                    }

                    //门店Entity
                    var UnitData = unitBLL.GetByID(loggingSessionInfo.CurrentUserRole.UnitId);
                    //会员
                    VipEntity VipData = VipBLL.GetByID(OldVipCardVipMappingData.VIPID);

                    #region 卡状态记录对象
                    VipCardStatusChangeLogEntity AddVCStatusEntity = new VipCardStatusChangeLogEntity();
                    AddVCStatusEntity.LogID       = System.Guid.NewGuid().ToString();
                    AddVCStatusEntity.VipCardID   = para.VipCardID;
                    AddVCStatusEntity.Reason      = para.ChangeReason;
                    AddVCStatusEntity.OldStatusID = changeEntity.VipCardStatusId;
                    AddVCStatusEntity.CustomerID  = loggingSessionInfo.ClientID;
                    AddVCStatusEntity.Remark      = para.Remark;
                    AddVCStatusEntity.UnitID      = loggingSessionInfo.CurrentUserRole.UnitId;
                    #endregion



                    #region 新卡
                    VipCardEntity NewChangeVipCardData = new VipCardEntity();
                    if (!string.IsNullOrWhiteSpace(para.NewCardCode))
                    {
                        //查询参数
                        List <IWhereCondition> complexCondition = new List <IWhereCondition> {
                        };
                        if (!string.IsNullOrEmpty(para.NewCardCode))
                        {
                            complexCondition.Add(new DirectCondition("VipCardCode='" + para.NewCardCode + "' or VipCardISN='" + para.NewCardCode.ToString() + "' "));
                        }
                        //新卡对象
                        NewChangeVipCardData = VipCardBLL.Query(complexCondition.ToArray(), null).FirstOrDefault();
                        if (NewChangeVipCardData == null)
                        {
                            throw new APIException("新卡不存在!")
                                  {
                                      ErrorCode = ERROR_CODES.INVALID_BUSINESS
                                  };
                        }
                        //新卡号赋值
                        NewVipCardCode = NewChangeVipCardData.VipCardCode ?? "";
                        //新卡数据赋值
                        NewChangeVipCardData.VipCardGradeID      = changeEntity.VipCardGradeID;
                        NewChangeVipCardData.BatchNo             = changeEntity.BatchNo;
                        NewChangeVipCardData.BeginDate           = changeEntity.BeginDate;
                        NewChangeVipCardData.EndDate             = changeEntity.EndDate;
                        NewChangeVipCardData.TotalAmount         = changeEntity.TotalAmount == null ? 0 : changeEntity.TotalAmount.Value;
                        NewChangeVipCardData.BalanceAmount       = changeEntity.BalanceAmount == null ? 0 : changeEntity.BalanceAmount.Value;
                        NewChangeVipCardData.BalancePoints       = changeEntity.BalancePoints == null ? 0 : changeEntity.BalancePoints.Value;
                        NewChangeVipCardData.BalanceBonus        = changeEntity.BalanceBonus == null ? 0 : changeEntity.BalanceBonus.Value;
                        NewChangeVipCardData.CumulativeBonus     = changeEntity.CumulativeBonus == null ? 0 : changeEntity.CumulativeBonus.Value;
                        NewChangeVipCardData.PurchaseTotalAmount = changeEntity.PurchaseTotalAmount == null ? 0 : changeEntity.PurchaseTotalAmount.Value;
                        NewChangeVipCardData.PurchaseTotalCount  = changeEntity.PurchaseTotalCount == null ? 0 : changeEntity.PurchaseTotalCount.Value;
                        NewChangeVipCardData.CheckCode           = changeEntity.CheckCode;
                        NewChangeVipCardData.SingleTransLimit    = changeEntity.SingleTransLimit == null ? 0 : changeEntity.SingleTransLimit.Value;
                        NewChangeVipCardData.IsOverrunValid      = changeEntity.IsOverrunValid == null ? 0 : changeEntity.IsOverrunValid.Value;
                        NewChangeVipCardData.RechargeTotalAmount = changeEntity.RechargeTotalAmount == null ? 0 : changeEntity.RechargeTotalAmount.Value;
                        NewChangeVipCardData.LastSalesTime       = changeEntity.LastSalesTime;
                        NewChangeVipCardData.IsGift         = changeEntity.IsGift == null ? 0 : changeEntity.IsGift.Value;
                        NewChangeVipCardData.SalesAmount    = changeEntity.SalesAmount;
                        NewChangeVipCardData.SalesUserId    = changeEntity.SalesUserId;
                        NewChangeVipCardData.CustomerID     = changeEntity.CustomerID;
                        NewChangeVipCardData.MembershipTime = changeEntity.MembershipTime;
                        NewChangeVipCardData.SalesUserName  = changeEntity.SalesUserName == null ? "" : changeEntity.SalesUserName;
                        NewChangeVipCardData.CreateBy       = changeEntity.CreateBy;
                    }
                    #endregion


                    switch (para.OperationType)
                    {
                    case 1:
                        #region 调整卡余额
                        //卡更新

                        //卡内总金额
                        if (para.BalanceMoney > 0)
                        {
                            changeEntity.RechargeTotalAmount += para.BalanceMoney;
                            if (changeEntity.RechargeTotalAmount < 0)
                            {
                                throw new APIException("调整后的余额小于0!")
                                      {
                                          ErrorCode = ERROR_CODES.INVALID_BUSINESS
                                      };
                            }
                        }
                        //changeEntity.BalanceAmount = changeEntity.BalanceAmount ?? 0;
                        //
                        changeEntity.BalanceAmount = NewMoney;
                        //执行更新
                        VipCardBLL.Update(changeEntity, pTran);

                        //新增余额变动记录
                        VipCardBalanceChangeEntity AddEntity = new VipCardBalanceChangeEntity();
                        AddEntity.ChangeID     = System.Guid.NewGuid().ToString();
                        AddEntity.VipCardCode  = changeEntity.VipCardCode;
                        AddEntity.ChangeAmount = para.BalanceMoney;
                        //变动前卡内余额
                        AddEntity.ChangeBeforeBalance = OldMoney;
                        //变动后卡内余额
                        AddEntity.ChangeAfterBalance = NewMoney;
                        AddEntity.ChangeReason       = para.ChangeReason;
                        AddEntity.Status             = 1;
                        AddEntity.Remark             = para.Remark;
                        AddEntity.CustomerID         = loggingSessionInfo.ClientID;
                        AddEntity.UnitID             = loggingSessionInfo.CurrentUserRole.UnitId;
                        //执行新增
                        VipCardBalanceChangeBLL.Create(AddEntity, pTran);

                        //增加图片上传
                        if (!string.IsNullOrEmpty(para.ImageUrl))
                        {
                            var objectImagesEntity = new ObjectImagesEntity()
                            {
                                ImageId  = Guid.NewGuid().ToString(),
                                ObjectId = AddEntity.ChangeID,
                                ImageURL = para.ImageUrl
                            };
                            objectImagesBLL.Create(objectImagesEntity, pTran);
                        }
                        #region 充值记录
                        //读取最近一次积分变更记录
                        List <OrderBy> lstOrder = new List <OrderBy> {
                        };                                                   //排序参数
                        lstOrder.Add(new OrderBy()
                        {
                            FieldName = "TransTime", Direction = OrderByDirections.Desc
                        });
                        var transLogInfo = vipCardTransLogBLL.QueryByEntity(new VipCardTransLogEntity()
                        {
                            VipCardCode = changeEntity.VipCardCode, TransType = "C"
                        }, lstOrder.ToArray()).FirstOrDefault();
                        //期末积分
                        int newValue = transLogInfo != null ? (transLogInfo.NewValue ?? 0) : 0;
                        var vipCardTransLogEntity = new VipCardTransLogEntity()
                        {
                            VipCardCode  = VipData == null ? "" : VipData.VipCode,
                            UnitCode     = UnitData == null ? "" : UnitData.UnitCode,
                            TransContent = "余额",
                            TransType    = "C",
                            TransTime    = DateTime.Now,
                            TransAmount  = para.BalanceMoney,
                            LastValue    = newValue,                                      //期初金额
                            NewValue     = Convert.ToInt32(para.BalanceMoney) + newValue, //期末金额
                            CustomerID   = loggingSessionInfo.ClientID
                        };
                        vipCardTransLogBLL.Create(vipCardTransLogEntity, pTran);

                        #endregion


                        #endregion
                        break;

                    case 2:
                        #region 卡升级

                        //卡类型升级
                        if (para.VipCardTypeId != 0)
                        {
                            VipCardVipMappingBLL.updateVipCardByType(VipData.VIPID, para.VipCardTypeId, para.ChangeReason, para.Remark, VipData.VipCode, pTran);
                        }
                        //卡号升级
                        else
                        {
                            #region 原卡

                            #region 更新原卡
                            changeEntity.VipCardStatusId = 3;
                            //当前月,累计金额清0
                            //changeEntity.BalanceAmount = 0;
                            //changeEntity.TotalAmount = 0;
                            VipCardBLL.Update(changeEntity, pTran);    //执行
                            #endregion

                            #region 新增原卡状态记录
                            AddVCStatusEntity.VipCardStatusID = 3;
                            AddVCStatusEntity.Action          = "卡升级";
                            AddVCStatusEntity.Remark         += "已升级为:" + NewChangeVipCardData.VipCardCode;
                            VipCardStatusChangeLogBLL.Create(AddVCStatusEntity, pTran);    //执行
                            #endregion

                            #region 新增原卡余额变动记录
                            //if (OldMoney > 0)
                            //{
                            //    VipCardBalanceChangeEntity AddOldCardBalanceData = new VipCardBalanceChangeEntity();
                            //    AddOldCardBalanceData.ChangeID = System.Guid.NewGuid().ToString();
                            //    AddOldCardBalanceData.VipCardCode = changeEntity.VipCardCode;
                            //    AddOldCardBalanceData.ChangeAmount = -OldMoney;
                            //    //变动前卡内余额
                            //    AddOldCardBalanceData.ChangeBeforeBalance = OldMoney;
                            //    //变动后卡内余额
                            //    AddOldCardBalanceData.ChangeAfterBalance = 0;
                            //    AddOldCardBalanceData.ChangeReason = para.ChangeReason;
                            //    AddOldCardBalanceData.Status = 1;
                            //    AddOldCardBalanceData.Remark = para.Remark;
                            //    AddOldCardBalanceData.CustomerID = loggingSessionInfo.ClientID;
                            //    AddOldCardBalanceData.UnitID = loggingSessionInfo.CurrentUserRole.UnitId;
                            //    VipCardBalanceChangeBLL.Create(AddOldCardBalanceData, pTran);//执行
                            //    //增加图片上传
                            //    if (!string.IsNullOrEmpty(para.ImageUrl))
                            //    {
                            //        var objectImagesEntity = new ObjectImagesEntity()
                            //        {
                            //            ImageId = Guid.NewGuid().ToString(),
                            //            ObjectId = AddOldCardBalanceData.ChangeID,
                            //            ImageURL = para.ImageUrl
                            //        };
                            //        objectImagesBLL.Create(objectImagesEntity, pTran);
                            //    }
                            //}
                            #endregion

                            #endregion

                            #region 新卡

                            VipData.VipCode = para.NewCardCode;
                            VipBLL.Update(VipData, pTran);

                            #region 更新新卡
                            if (!string.IsNullOrEmpty(NewChangeVipCardData.MembershipUnit))
                            {
                                throw new APIException("该会员卡已绑定会员!")
                                      {
                                          ErrorCode = ERROR_CODES.INVALID_BUSINESS
                                      }
                            }
                            ;
                            if (NewChangeVipCardData.VipCardStatusId != 0)
                            {
                                throw new APIException("该会员卡已激活!")
                                      {
                                          ErrorCode = ERROR_CODES.INVALID_BUSINESS
                                      }
                            }
                            ;
                            if (NewChangeVipCardData.VipCardTypeID.Value == changeEntity.VipCardTypeID.Value)
                            {
                                throw new APIException("该卡号与原卡等级相同,请更换卡号后重新尝试!")
                                      {
                                          ErrorCode = ERROR_CODES.INVALID_BUSINESS
                                      }
                            }
                            ;

                            #region 返回新卡卡ID
                            rd.VipCardID = NewChangeVipCardData.VipCardID;
                            #endregion
                            NewChangeVipCardData.MembershipUnit  = changeEntity.MembershipUnit;
                            NewChangeVipCardData.VipCardStatusId = 1;
                            VipCardBLL.Update(NewChangeVipCardData, pTran);    //执行
                            #endregion

                            #region 新增新卡卡关系
                            VipCardVipMappingEntity AddVipCardVipMappingData = new VipCardVipMappingEntity();
                            AddVipCardVipMappingData.MappingID  = System.Guid.NewGuid().ToString();
                            AddVipCardVipMappingData.VIPID      = OldVipCardVipMappingData.VIPID;
                            AddVipCardVipMappingData.VipCardID  = NewChangeVipCardData.VipCardID;
                            AddVipCardVipMappingData.CustomerID = loggingSessionInfo.ClientID;
                            VipCardVipMappingBLL.Create(AddVipCardVipMappingData, pTran);    //执行
                            #endregion

                            #region 更新会员编号
                            //VipEntity SJ_VipData = VipBLL.GetByID(OldVipCardVipMappingData.VIPID);
                            //if (VipData == null)
                            //    throw new APIException("会员不存在!") { ErrorCode = ERROR_CODES.INVALID_BUSINESS };

                            //VipData.VipCode = NewChangeVipCardData.VipCardCode;
                            //VipBLL.Update(VipData, pTran);//执行
                            #endregion

                            #region 新增新卡状态记录
                            //新增新卡状态记录

                            VipCardStatusChangeLogEntity AddNewVCStatusEntity = new VipCardStatusChangeLogEntity();
                            AddNewVCStatusEntity.LogID           = System.Guid.NewGuid().ToString();
                            AddNewVCStatusEntity.VipCardID       = NewChangeVipCardData.VipCardID;
                            AddNewVCStatusEntity.VipCardStatusID = 1;
                            AddNewVCStatusEntity.Reason          = para.ChangeReason;
                            AddNewVCStatusEntity.OldStatusID     = 0;
                            AddNewVCStatusEntity.CustomerID      = loggingSessionInfo.ClientID;
                            AddNewVCStatusEntity.Action          = "卡升级";
                            AddNewVCStatusEntity.Remark          = para.Remark + "由旧卡:" + changeEntity.VipCardCode + "升级";
                            AddNewVCStatusEntity.UnitID          = loggingSessionInfo.CurrentUserRole.UnitId;
                            VipCardStatusChangeLogBLL.Create(AddNewVCStatusEntity, pTran);    //执行

                            #endregion

                            #region 新增新卡余额记录
                            //新增余额记录
                            //if (OldMoney > 0)
                            //{
                            //    VipCardBalanceChangeEntity AddNewCardBalanceData = new VipCardBalanceChangeEntity();
                            //    AddNewCardBalanceData.ChangeID = System.Guid.NewGuid().ToString();
                            //    AddNewCardBalanceData.VipCardCode = NewChangeVipCardData.VipCardCode;
                            //    AddNewCardBalanceData.ChangeAmount = OldMoney;
                            //    //变动前卡内余额
                            //    AddNewCardBalanceData.ChangeBeforeBalance = 0;
                            //    //变动后卡内余额
                            //    AddNewCardBalanceData.ChangeAfterBalance = NewChangeVipCardData.BalanceAmount == null ? 0 : NewChangeVipCardData.BalanceAmount.Value;
                            //    AddNewCardBalanceData.ChangeReason = para.ChangeReason;
                            //    AddNewCardBalanceData.Status = 1;
                            //    AddNewCardBalanceData.Remark = para.Remark;
                            //    AddNewCardBalanceData.CustomerID = loggingSessionInfo.ClientID;
                            //    VipCardBalanceChangeBLL.Create(AddNewCardBalanceData, pTran);//执行
                            //    //增加图片上传
                            //    if (!string.IsNullOrEmpty(para.ImageUrl))
                            //    {
                            //        var objectImagesEntity = new ObjectImagesEntity()
                            //        {
                            //            ImageId = Guid.NewGuid().ToString(),
                            //            ObjectId = AddNewCardBalanceData.ChangeID,
                            //            ImageURL = para.ImageUrl
                            //        };
                            //        objectImagesBLL.Create(objectImagesEntity, pTran);
                            //    }
                            //}
                            #endregion

                            #endregion
                        }
                        #endregion

                        break;

                    case 3:
                        #region 挂失
                        changeEntity.VipCardStatusId = 4;
                        //执行更新
                        VipCardBLL.Update(changeEntity, pTran);
                        //执行
                        AddVCStatusEntity.VipCardStatusID = 4;
                        AddVCStatusEntity.PicUrl          = para.ImageUrl;
                        AddVCStatusEntity.Action          = "挂失";
                        VipCardStatusChangeLogBLL.Create(AddVCStatusEntity, pTran);
                        #endregion

                        break;

                    case 4:

                        #region 冻结
                        changeEntity.VipCardStatusId = 2;
                        //执行更新
                        VipCardBLL.Update(changeEntity, pTran);
                        //执行新增
                        AddVCStatusEntity.VipCardStatusID = 2;
                        AddVCStatusEntity.Action          = "冻结";
                        VipCardStatusChangeLogBLL.Create(AddVCStatusEntity, pTran);
                        #endregion
                        break;

                    case 5:
                        #region 转卡
                        #region 原卡
                        #region 更新原卡
                        changeEntity.VipCardStatusId = 3;
                        //当前月,累计金额清0
                        changeEntity.BalanceAmount = 0;
                        changeEntity.TotalAmount   = 0;
                        VipCardBLL.Update(changeEntity, pTran);    //执行
                        #endregion

                        #region 新增原卡状态记录
                        AddVCStatusEntity.VipCardStatusID = 3;
                        AddVCStatusEntity.Action          = "转卡";
                        AddVCStatusEntity.Remark         += "已转移为:" + NewChangeVipCardData.VipCardCode;
                        VipCardStatusChangeLogBLL.Create(AddVCStatusEntity, pTran);    //执行
                        #endregion


                        #region 新增原卡余额变动记录
                        if (OldMoney > 0)
                        {
                            VipCardBalanceChangeEntity AddOldZKCardBalanceData = new VipCardBalanceChangeEntity();
                            AddOldZKCardBalanceData.ChangeID     = System.Guid.NewGuid().ToString();
                            AddOldZKCardBalanceData.VipCardCode  = changeEntity.VipCardCode;
                            AddOldZKCardBalanceData.ChangeAmount = -OldMoney;
                            //变动前卡内余额
                            AddOldZKCardBalanceData.ChangeBeforeBalance = OldMoney;
                            //变动后卡内余额
                            AddOldZKCardBalanceData.ChangeAfterBalance = 0;
                            AddOldZKCardBalanceData.ChangeReason       = para.ChangeReason;
                            AddOldZKCardBalanceData.Status             = 1;
                            AddOldZKCardBalanceData.Remark             = para.Remark;
                            AddOldZKCardBalanceData.CustomerID         = loggingSessionInfo.ClientID;
                            AddOldZKCardBalanceData.UnitID             = loggingSessionInfo.CurrentUserRole.UnitId;
                            VipCardBalanceChangeBLL.Create(AddOldZKCardBalanceData, pTran);     //执行
                            //增加图片上传
                            if (!string.IsNullOrEmpty(para.ImageUrl))
                            {
                                var objectImagesEntity = new ObjectImagesEntity()
                                {
                                    ImageId  = Guid.NewGuid().ToString(),
                                    ObjectId = AddOldZKCardBalanceData.ChangeID,
                                    ImageURL = para.ImageUrl
                                };
                                objectImagesBLL.Create(objectImagesEntity, pTran);
                            }
                        }
                        #endregion

                        #endregion
                        #region 新卡

                        #region 更新新卡
                        if (!string.IsNullOrEmpty(NewChangeVipCardData.MembershipUnit))
                        {
                            throw new APIException("该会员卡已绑定会员!")
                                  {
                                      ErrorCode = ERROR_CODES.INVALID_BUSINESS
                                  }
                        }
                        ;
                        if (NewChangeVipCardData.VipCardStatusId != 0)
                        {
                            throw new APIException("该会员卡已激活!")
                                  {
                                      ErrorCode = ERROR_CODES.INVALID_BUSINESS
                                  }
                        }
                        ;
                        if (NewChangeVipCardData.VipCardTypeID.Value != changeEntity.VipCardTypeID.Value)
                        {
                            throw new APIException("该卡号与原卡等级不同,请更换卡号后重新尝试!")
                                  {
                                      ErrorCode = ERROR_CODES.INVALID_BUSINESS
                                  }
                        }
                        ;

                        #region 返回新卡卡ID
                        rd.VipCardID = NewChangeVipCardData.VipCardID;
                        #endregion
                        NewChangeVipCardData.MembershipUnit  = changeEntity.MembershipUnit;
                        NewChangeVipCardData.VipCardStatusId = 1;
                        VipCardBLL.Update(NewChangeVipCardData, pTran);    //执行
                        #endregion



                        #region 新增新卡卡关系
                        VipCardVipMappingEntity AddZKVipCardVipMappingData = new VipCardVipMappingEntity();
                        AddZKVipCardVipMappingData.MappingID  = System.Guid.NewGuid().ToString();
                        AddZKVipCardVipMappingData.VIPID      = OldVipCardVipMappingData.VIPID;
                        AddZKVipCardVipMappingData.VipCardID  = NewChangeVipCardData.VipCardID;
                        AddZKVipCardVipMappingData.CustomerID = loggingSessionInfo.ClientID;
                        VipCardVipMappingBLL.Create(AddZKVipCardVipMappingData, pTran);    //执行
                        #endregion

                        #region 更新会员编号
                        //VipEntity ZK_VipData = VipBLL.GetByID(OldVipCardVipMappingData.VIPID);
                        if (VipData == null)
                        {
                            throw new APIException("会员不存在!")
                                  {
                                      ErrorCode = ERROR_CODES.INVALID_BUSINESS
                                  }
                        }
                        ;

                        VipData.VipCode = NewChangeVipCardData.VipCardCode;
                        VipBLL.Update(VipData, pTran);    //执行
                        #endregion

                        #region 新增新卡状态记录
                        VipCardStatusChangeLogEntity AddNewZKVCStatusEntity = new VipCardStatusChangeLogEntity();
                        AddNewZKVCStatusEntity.LogID           = System.Guid.NewGuid().ToString();
                        AddNewZKVCStatusEntity.VipCardID       = NewChangeVipCardData.VipCardID;
                        AddNewZKVCStatusEntity.VipCardStatusID = 1;
                        AddNewZKVCStatusEntity.Reason          = para.ChangeReason;
                        AddNewZKVCStatusEntity.OldStatusID     = 0;
                        AddNewZKVCStatusEntity.CustomerID      = loggingSessionInfo.ClientID;
                        AddNewZKVCStatusEntity.Action          = "转卡";
                        AddNewZKVCStatusEntity.Remark          = para.Remark + para.Remark + "由旧卡:" + changeEntity.VipCardCode + "转移";
                        AddNewZKVCStatusEntity.UnitID          = loggingSessionInfo.CurrentUserRole.UnitId;
                        VipCardStatusChangeLogBLL.Create(AddNewZKVCStatusEntity, pTran);    //执行
                        #endregion

                        #region 新增新卡余额记录
                        if (OldMoney > 0)
                        {
                            VipCardBalanceChangeEntity AddNewZKCardBalanceData = new VipCardBalanceChangeEntity();
                            AddNewZKCardBalanceData.ChangeID     = System.Guid.NewGuid().ToString();
                            AddNewZKCardBalanceData.VipCardCode  = NewChangeVipCardData.VipCardCode;
                            AddNewZKCardBalanceData.ChangeAmount = OldMoney;
                            //变动前卡内余额
                            AddNewZKCardBalanceData.ChangeBeforeBalance = 0;
                            //变动后卡内余额
                            AddNewZKCardBalanceData.ChangeAfterBalance = NewChangeVipCardData.BalanceAmount == null ? 0 : NewChangeVipCardData.BalanceAmount.Value;
                            AddNewZKCardBalanceData.ChangeReason       = para.ChangeReason;
                            AddNewZKCardBalanceData.Status             = 1;
                            AddNewZKCardBalanceData.Remark             = para.Remark;
                            AddNewZKCardBalanceData.CustomerID         = loggingSessionInfo.ClientID;
                            AddNewZKCardBalanceData.UnitID             = loggingSessionInfo.CurrentUserRole.UnitId;
                            VipCardBalanceChangeBLL.Create(AddNewZKCardBalanceData, pTran);    //执行
                            //增加图片上传
                            if (!string.IsNullOrEmpty(para.ImageUrl))
                            {
                                var objectImagesEntity = new ObjectImagesEntity()
                                {
                                    ImageId  = Guid.NewGuid().ToString(),
                                    ObjectId = AddNewZKCardBalanceData.ChangeID,
                                    ImageURL = para.ImageUrl
                                };
                                objectImagesBLL.Create(objectImagesEntity, pTran);
                            }
                        }
                        #endregion



                        #endregion
                        #endregion
                        break;

                    case 6:

                        #region 解挂
                        changeEntity.VipCardStatusId = 1;
                        //执行更新
                        VipCardBLL.Update(changeEntity, pTran);
                        //执行新增
                        AddVCStatusEntity.VipCardStatusID = 1;
                        AddVCStatusEntity.Action          = "解挂";
                        VipCardStatusChangeLogBLL.Create(AddVCStatusEntity, pTran);
                        #endregion
                        break;

                    case 7:

                        #region 解冻
                        changeEntity.VipCardStatusId = 1;
                        //执行更新
                        VipCardBLL.Update(changeEntity, pTran);
                        //执行新增
                        AddVCStatusEntity.VipCardStatusID = 1;
                        AddVCStatusEntity.Action          = "解冻";
                        VipCardStatusChangeLogBLL.Create(AddVCStatusEntity, pTran);
                        #endregion
                        break;

                    case 8:
                        #region 作废
                        changeEntity.VipCardStatusId = 3;
                        //执行更新
                        VipCardBLL.Update(changeEntity, pTran);


                        //执行新增
                        AddVCStatusEntity.VipCardStatusID = 3;
                        AddVCStatusEntity.Action          = "作废";
                        VipCardStatusChangeLogBLL.Create(AddVCStatusEntity, pTran);
                        #endregion
                        break;

                    case 9:
                        #region 唤醒
                        changeEntity.VipCardStatusId = 1;
                        //执行更新
                        VipCardBLL.Update(changeEntity, pTran);
                        //执行新增
                        AddVCStatusEntity.VipCardStatusID = 1;
                        AddVCStatusEntity.Action          = "唤醒";
                        VipCardStatusChangeLogBLL.Create(AddVCStatusEntity, pTran);
                        #endregion
                        break;

                    case 10:
                        #region 激活
                        changeEntity.VipCardStatusId = 1;
                        //执行更新
                        VipCardBLL.Update(changeEntity, pTran);
                        //执行新增
                        AddVCStatusEntity.VipCardStatusID = 1;
                        AddVCStatusEntity.Action          = "激活";
                        VipCardStatusChangeLogBLL.Create(AddVCStatusEntity, pTran);
                        #endregion
                        break;

                    default:
                        throw new APIException("当前操作类型不匹配!")
                              {
                                  ErrorCode = ERROR_CODES.INVALID_REQUEST_LACK_REQUEST_PARAMETER
                              };
                        break;
                    }
                    ;
                    pTran.Commit();
                    #region 卡升级,转卡操作转移消费记录表
                    if ((para.OperationType == 2 || para.OperationType == 5) && string.IsNullOrEmpty(para.VipCardTypeId.ToString())) //卡类型升级不执行此操作
                    {
                        string StrSql = string.Format("update VipCardTransLog set VipCardCode='{0}',OldVipCardCode='{1}' where VipCardCode='{1}'", NewVipCardCode, OldVipCardCode);
                        vipCardTransLogBLL.UpdateVipCardTransLog(StrSql);//执行
                    }
                    #endregion

                    var eventService = new EventService();
                    var vipMsg       = new EventContract
                    {
                        Operation  = OptEnum.Update,
                        EntityType = EntityTypeEnum.Vip,
                        Id         = VipData.VIPID
                    };
                    eventService.PublishMsg(vipMsg);
                }
                catch (APIException apiEx)
                {
                    pTran.Rollback();//回滚事物
                    throw new APIException(apiEx.ErrorCode, apiEx.Message);
                }
                catch (Exception ex)
                {
                    pTran.Rollback();//回滚事务
                    throw new APIException(ex.Message);
                }
            }
            return(rd);
        }
Exemplo n.º 20
0
        protected override EmptyResponseData ProcessRequest(DTO.Base.APIRequest <SetOffActionRP> pRequest)
        {
            var rd   = new EmptyResponseData();
            var para = pRequest.Parameters;
            var loggingSessionInfo      = new SessionManager().CurrentUserLoginInfo;
            var SetoffEventBll          = new SetoffEventBLL(loggingSessionInfo);
            var IincentiveRuleBll       = new IincentiveRuleBLL(loggingSessionInfo);
            var ObjectImagesBll         = new ObjectImagesBLL(loggingSessionInfo);
            var SetoffToolsBll          = new SetoffToolsBLL(loggingSessionInfo);
            var SetoffPosterBll         = new SetoffPosterBLL(loggingSessionInfo);
            var CustomerBasicSettingBll = new CustomerBasicSettingBLL(loggingSessionInfo);
            //
            var    pTran       = SetoffEventBll.GetTran();
            string _CustomerId = loggingSessionInfo.ClientID;

            if (para.SetOffActionList.Count > 0)
            {
                //using (pTran.Connection)
                //{
                try
                {
                    foreach (var item in para.SetOffActionList)
                    {
                        List <CustomerBasicSettingEntity> settingList = new List <CustomerBasicSettingEntity>();  //基础配置数据

                        //获取已发布的集客行动
                        var SetoffEvenResult = SetoffEventBll.QueryByEntity(new SetoffEventEntity()
                        {
                            SetoffType = item.SetoffType, Status = "10", CustomerId = loggingSessionInfo.ClientID
                        }, null).ToList();
                        if (SetoffEvenResult.Count > 1)
                        {
                            throw new APIException("数据异常,只能有一种集客行动!")
                                  {
                                      ErrorCode = ERROR_CODES.INVALID_BUSINESS
                                  }
                        }
                        ;

                        if (SetoffEvenResult.Count > 0)
                        {
                            var Result   = SetoffEvenResult.First();  //集客行动
                            var RuleData = IincentiveRuleBll.QueryByEntity(new IincentiveRuleEntity()
                            {
                                SetoffEventID = Result.SetoffEventID, CustomerId = loggingSessionInfo.ClientID
                            }, null).FirstOrDefault();
                            if (RuleData == null)
                            {
                                throw new APIException("数据异常,找不到奖励规则!")
                                      {
                                          ErrorCode = ERROR_CODES.INVALID_BUSINESS
                                      }
                            }
                            ;
                            //判断奖励是否变动
                            if (item.SetoffRegAwardType != RuleData.SetoffRegAwardType ||
                                item.SetoffRegPrize != RuleData.SetoffRegPrize || item.SetoffOrderPer != RuleData.SetoffOrderPer ||
                                item.SetoffOrderTimers != RuleData.SetoffOrderTimers || item.IsEnabled != Convert.ToInt32(RuleData.Status))
                            {
                                //原集客行动状态设置为失效
                                SetoffEventBll.SetFailStatus(item.SetoffType, loggingSessionInfo.ClientID);

                                #region 规则变动,重新新建集客行动
                                //集客行动
                                //集客行动
                                var SetoffEvenData = new SetoffEventEntity();    //集客行动
                                SetoffEvenData.SetoffEventID = System.Guid.NewGuid();
                                SetoffEvenData.SetoffType    = item.SetoffType;
                                SetoffEvenData.Status        = "10";
                                SetoffEvenData.CustomerId    = _CustomerId;
                                SetoffEventBll.Create(SetoffEvenData);               //

                                var IincentiveRuleData = new IincentiveRuleEntity(); //奖励规则
                                IincentiveRuleData.IincentiveRuleID   = System.Guid.NewGuid();
                                IincentiveRuleData.SetoffEventID      = SetoffEvenData.SetoffEventID;
                                IincentiveRuleData.SetoffType         = item.SetoffType;
                                IincentiveRuleData.ApplyUnit          = 0;
                                IincentiveRuleData.SetoffRegAwardType = item.SetoffRegAwardType;
                                IincentiveRuleData.SetoffRegPrize     = item.SetoffRegPrize;
                                IincentiveRuleData.SetoffOrderPer     = item.SetoffOrderPer;
                                IincentiveRuleData.SetoffOrderTimers  = item.SetoffOrderTimers;
                                IincentiveRuleData.Status             = item.IsEnabled.ToString();
                                IincentiveRuleData.CustomerId         = _CustomerId;
                                IincentiveRuleBll.Create(IincentiveRuleData);    //

                                #region 新增集客海报、海报集客工具关系
                                foreach (var PosterItem in item.SetoffPosterList)
                                {
                                    //图片表
                                    var ObjectImageData = new ObjectImagesEntity();
                                    ObjectImageData.ImageId     = System.Guid.NewGuid().ToString("N");
                                    ObjectImageData.ImageURL    = PosterItem.ImageUrl;
                                    ObjectImageData.Description = "集客海报";
                                    ObjectImageData.CustomerId  = _CustomerId;
                                    ObjectImagesBll.Create(ObjectImageData);    //
                                    //集客海报
                                    var SetoffPosterData = new SetoffPosterEntity();
                                    SetoffPosterData.SetoffPosterID = System.Guid.NewGuid();
                                    SetoffPosterData.Name           = PosterItem.Name;
                                    SetoffPosterData.Desc           = "集客海报";
                                    SetoffPosterData.ImageId        = ObjectImageData.ImageId;
                                    SetoffPosterData.Status         = "10";
                                    SetoffPosterData.CustomerId     = _CustomerId;
                                    SetoffPosterBll.Create(SetoffPosterData);

                                    //海报工具关系
                                    var SetoffToolsData = new SetoffToolsEntity();
                                    SetoffToolsData.SetoffToolID  = System.Guid.NewGuid();
                                    SetoffToolsData.SetoffEventID = SetoffEvenData.SetoffEventID;
                                    SetoffToolsData.ToolType      = "SetoffPoster";
                                    SetoffToolsData.ObjectId      = SetoffPosterData.SetoffPosterID.ToString();
                                    SetoffToolsData.Status        = "10";
                                    SetoffToolsData.CustomerId    = _CustomerId;
                                    SetoffToolsBll.Create(SetoffToolsData);    //
                                }
                                #endregion

                                #region 新增集客工具关系
                                foreach (var ToolsItem in item.SetoffTools)
                                {
                                    //判断是否添加重复集客工具
                                    bool Flag = SetoffEventBll.IsToolsRepeat(SetoffEvenData.SetoffEventID.ToString(), ToolsItem.ObjectId);
                                    if (Flag)
                                    {
                                        throw new APIException("集客行动不能添加相同的集客工具!")
                                              {
                                                  ErrorCode = ERROR_CODES.INVALID_BUSINESS
                                              }
                                    }
                                    ;

                                    var SetoffToolsData = new SetoffToolsEntity();
                                    SetoffToolsData.SetoffToolID  = System.Guid.NewGuid();
                                    SetoffToolsData.SetoffEventID = SetoffEvenData.SetoffEventID;
                                    SetoffToolsData.ToolType      = ToolsItem.ToolType;
                                    SetoffToolsData.ObjectId      = ToolsItem.ObjectId;
                                    SetoffToolsData.Status        = "10";
                                    SetoffToolsData.CustomerId    = _CustomerId;
                                    SetoffToolsBll.Create(SetoffToolsData);    //
                                }
                                #endregion

                                #endregion

                                #region 更新配置奖励系数
                                //集客销售订单分润配置
                                //var SettingData = CustomerBasicSettingBll.QueryByEntity(new CustomerBasicSettingEntity() { SettingCode = "GetVipUserOrderPer", CustomerID = CurrentUserInfo.ClientID, IsDelete = 0 }, null).FirstOrDefault();
                                //if (SettingData != null)
                                //{
                                //    SettingData.SettingValue = IincentiveRuleData.SetoffOrderPer.ToString();
                                //    CustomerBasicSettingBll.Update(SettingData);
                                //}
                                if (IincentiveRuleData.SetoffType == 2)
                                {
                                    settingList.Add(new CustomerBasicSettingEntity()
                                    {
                                        SettingCode  = "GetVipUserOrderPer",
                                        SettingValue = (IincentiveRuleData.SetoffOrderPer ?? 0).ToString()
                                    });
                                }
                                if (IincentiveRuleData.SetoffRegAwardType == 2)
                                {
                                    settingList.Add(new CustomerBasicSettingEntity()
                                    {
                                        SettingCode  = "InvitePartnersPoints",
                                        SettingValue = (IincentiveRuleData.SetoffRegPrize ?? 0).ToString()
                                    });
                                }
                                CustomerBasicSettingBll.SaveCustomerBasicInfo(loggingSessionInfo.ClientID, settingList);
                                //集客注册奖励配置
                                #endregion
                            }
                            else
                            {
                                #region 新增集客海报、海报集客工具关系
                                foreach (var PosterItem in item.SetoffPosterList)
                                {
                                    //图片表
                                    var ObjectImageData = new ObjectImagesEntity();
                                    ObjectImageData.ImageId     = System.Guid.NewGuid().ToString("N");
                                    ObjectImageData.ImageURL    = PosterItem.ImageUrl;
                                    ObjectImageData.Description = "集客海报";
                                    ObjectImageData.CustomerId  = _CustomerId;
                                    ObjectImagesBll.Create(ObjectImageData);    //
                                    //集客海报
                                    var SetoffPosterData = new SetoffPosterEntity();
                                    SetoffPosterData.SetoffPosterID = System.Guid.NewGuid();
                                    SetoffPosterData.Name           = PosterItem.Name;
                                    SetoffPosterData.Desc           = "集客海报";
                                    SetoffPosterData.ImageId        = ObjectImageData.ImageId;
                                    SetoffPosterData.Status         = "10";
                                    SetoffPosterData.CustomerId     = _CustomerId;
                                    SetoffPosterBll.Create(SetoffPosterData);

                                    //海报工具关系
                                    var SetoffToolsData = new SetoffToolsEntity();
                                    SetoffToolsData.SetoffToolID  = System.Guid.NewGuid();
                                    SetoffToolsData.SetoffEventID = Result.SetoffEventID;
                                    SetoffToolsData.ToolType      = "SetoffPoster";
                                    SetoffToolsData.ObjectId      = SetoffPosterData.SetoffPosterID.ToString();
                                    SetoffToolsData.Status        = "10";
                                    SetoffToolsData.CustomerId    = _CustomerId;
                                    SetoffToolsBll.Create(SetoffToolsData);    //
                                }
                                #endregion

                                #region 新增集客工具关系
                                foreach (var ToolsItem in item.SetoffTools)
                                {
                                    //
                                    if (Result == null)
                                    {
                                        throw new APIException("数据异常,未找到集客行动!")
                                              {
                                                  ErrorCode = ERROR_CODES.INVALID_BUSINESS
                                              }
                                    }
                                    ;
                                    //判断是否添加重复集客工具
                                    bool Flag = SetoffEventBll.IsToolsRepeat(Result.SetoffEventID.ToString(), ToolsItem.ObjectId);
                                    if (Flag)
                                    {
                                        throw new APIException("集客行动不能添加相同的集客工具!")
                                              {
                                                  ErrorCode = ERROR_CODES.INVALID_BUSINESS
                                              }
                                    }
                                    ;

                                    var SetoffToolsData = new SetoffToolsEntity();
                                    SetoffToolsData.SetoffToolID  = System.Guid.NewGuid();
                                    SetoffToolsData.SetoffEventID = Result.SetoffEventID;
                                    SetoffToolsData.ToolType      = ToolsItem.ToolType;
                                    SetoffToolsData.ObjectId      = ToolsItem.ObjectId;
                                    SetoffToolsData.Status        = "10";
                                    SetoffToolsData.CustomerId    = _CustomerId;
                                    SetoffToolsBll.Create(SetoffToolsData);    //
                                }
                                #endregion
                            }
                        }
                        else
                        {
                            //原集客行动状态设置为失效
                            SetoffEventBll.SetFailStatus(item.SetoffType, loggingSessionInfo.ClientID);

                            #region 新建集客行动
                            //集客行动
                            var SetoffEvenData = new SetoffEventEntity();    //集客行动
                            SetoffEvenData.SetoffEventID = System.Guid.NewGuid();
                            SetoffEvenData.SetoffType    = item.SetoffType;
                            SetoffEvenData.Status        = "10";
                            SetoffEvenData.CustomerId    = _CustomerId;
                            SetoffEventBll.Create(SetoffEvenData);               //

                            var IincentiveRuleData = new IincentiveRuleEntity(); //奖励规则
                            IincentiveRuleData.IincentiveRuleID   = System.Guid.NewGuid();
                            IincentiveRuleData.SetoffEventID      = SetoffEvenData.SetoffEventID;
                            IincentiveRuleData.SetoffType         = item.SetoffType;
                            IincentiveRuleData.ApplyUnit          = 0;
                            IincentiveRuleData.SetoffRegAwardType = item.SetoffRegAwardType;
                            IincentiveRuleData.SetoffRegPrize     = item.SetoffRegPrize;
                            IincentiveRuleData.SetoffOrderPer     = item.SetoffOrderPer;
                            IincentiveRuleData.SetoffOrderTimers  = item.SetoffOrderTimers;
                            IincentiveRuleData.Status             = item.IsEnabled.ToString();
                            IincentiveRuleData.CustomerId         = _CustomerId;
                            IincentiveRuleBll.Create(IincentiveRuleData);    //

                            #region 新增集客海报、海报集客工具关系
                            foreach (var PosterItem in item.SetoffPosterList)
                            {
                                //图片表
                                var ObjectImageData = new ObjectImagesEntity();
                                ObjectImageData.ImageId     = System.Guid.NewGuid().ToString("N");
                                ObjectImageData.ImageURL    = PosterItem.ImageUrl;
                                ObjectImageData.Description = "集客海报";
                                ObjectImageData.CustomerId  = _CustomerId;
                                ObjectImagesBll.Create(ObjectImageData);    //
                                //集客海报
                                var SetoffPosterData = new SetoffPosterEntity();
                                SetoffPosterData.SetoffPosterID = System.Guid.NewGuid();
                                SetoffPosterData.Name           = PosterItem.Name;
                                SetoffPosterData.Desc           = "集客海报";
                                SetoffPosterData.ImageId        = ObjectImageData.ImageId;
                                SetoffPosterData.Status         = "10";
                                SetoffPosterData.CustomerId     = _CustomerId;
                                SetoffPosterBll.Create(SetoffPosterData);

                                //海报工具关系
                                var SetoffToolsData = new SetoffToolsEntity();
                                SetoffToolsData.SetoffToolID  = System.Guid.NewGuid();
                                SetoffToolsData.SetoffEventID = SetoffEvenData.SetoffEventID;
                                SetoffToolsData.ToolType      = "SetoffPoster";
                                SetoffToolsData.ObjectId      = SetoffPosterData.SetoffPosterID.ToString();
                                SetoffToolsData.Status        = "10";
                                SetoffToolsData.CustomerId    = _CustomerId;
                                SetoffToolsBll.Create(SetoffToolsData);    //
                            }
                            #endregion

                            #region 新增集客工具关系
                            foreach (var ToolsItem in item.SetoffTools)
                            {
                                //判断是否添加重复集客工具
                                bool Flag = SetoffEventBll.IsToolsRepeat(SetoffEvenData.SetoffEventID.ToString(), ToolsItem.ObjectId);
                                if (Flag)
                                {
                                    throw new APIException("集客行动不能添加相同的集客工具!")
                                          {
                                              ErrorCode = ERROR_CODES.INVALID_BUSINESS
                                          }
                                }
                                ;

                                var SetoffToolsData = new SetoffToolsEntity();
                                SetoffToolsData.SetoffToolID  = System.Guid.NewGuid();
                                SetoffToolsData.SetoffEventID = SetoffEvenData.SetoffEventID;
                                SetoffToolsData.ToolType      = ToolsItem.ToolType;
                                SetoffToolsData.ObjectId      = ToolsItem.ObjectId;
                                SetoffToolsData.Status        = "10";
                                SetoffToolsData.CustomerId    = _CustomerId;
                                SetoffToolsBll.Create(SetoffToolsData);    //
                            }
                            #endregion


                            #endregion


                            #region 更新配置奖励系数

                            if (IincentiveRuleData.SetoffType == 2)
                            {
                                //同步到原CustomerBasicSetting集客销售订单分润配置
                                //var SettingData = CustomerBasicSettingBll.QueryByEntity(new CustomerBasicSettingEntity() { SettingCode = "GetVipUserOrderPer", CustomerID = CurrentUserInfo.ClientID, IsDelete = 0 }, null).FirstOrDefault();
                                //if (SettingData != null)
                                //{
                                //    SettingData.SettingValue = (IincentiveRuleData.SetoffOrderPer ?? 0).ToString();
                                //    CustomerBasicSettingBll.Update(SettingData);
                                //}
                                settingList.Add(new CustomerBasicSettingEntity()
                                {
                                    SettingCode  = "GetVipUserOrderPer",
                                    SettingValue = (IincentiveRuleData.SetoffOrderPer ?? 0).ToString()
                                });
                            }
                            if (IincentiveRuleData.SetoffRegAwardType == 2)
                            {
                                //同步到原CustomerBasicSetting集客销售订单分润配置
                                //var SettingData = CustomerBasicSettingBll.QueryByEntity(new CustomerBasicSettingEntity() { SettingCode = "InvitePartnersPoints", CustomerID = CurrentUserInfo.ClientID, IsDelete = 0 }, null).FirstOrDefault();
                                //if (SettingData != null)
                                //{
                                //    SettingData.SettingValue = (IincentiveRuleData.SetoffRegPrize ?? 0).ToString();
                                //    CustomerBasicSettingBll.Update(SettingData);
                                //}
                                settingList.Add(new CustomerBasicSettingEntity()
                                {
                                    SettingCode  = "InvitePartnersPoints",
                                    SettingValue = (IincentiveRuleData.SetoffRegPrize ?? 0).ToString()
                                });
                            }
                            CustomerBasicSettingBll.SaveCustomerBasicInfo(loggingSessionInfo.ClientID, settingList);
                            #endregion
                        }
                    }
                    //
                    //pTran.Commit();
                }
                catch (APIException ex)
                {
                    //pTran.Rollback();
                    throw ex;
                }
                //}
            }
            return(rd);
        }
Exemplo n.º 21
0
        protected override GetImageRD ProcessRequest(APIRequest <GetImageRP> pRequest)
        {
            var             rd       = new GetImageRD();
            ObjectImagesBLL bllImage = new ObjectImagesBLL(this.CurrentUserInfo);
            LEventsBLL      bllEvent = new LEventsBLL(this.CurrentUserInfo);
            LCoverBLL       bllCover = new LCoverBLL(CurrentUserInfo);

            string strEventId           = pRequest.Parameters.EventId;
            string strCTWEventId        = string.Empty;
            string strOnLineRedirectUrl = string.Empty;

            rd.EventId = strEventId;
            rd.IsCTW   = 0;
            //if (!string.IsNullOrEmpty(pRequest.Parameters.CTWEventId))
            //{
            T_CTW_LEventInteractionBLL bllLEventInteraction = new T_CTW_LEventInteractionBLL(this.CurrentUserInfo);
            DataSet ds = bllLEventInteraction.GetCTWLEventInteraction(strEventId);

            if (ds != null && ds.Tables[0].Rows.Count > 0)
            {
                strEventId           = ds.Tables[0].Rows[0]["LeventId"].ToString();
                strCTWEventId        = ds.Tables[0].Rows[0]["CTWEventId"].ToString();
                strOnLineRedirectUrl = ds.Tables[0].Rows[0]["OnLineRedirectUrl"].ToString();
                ContactEventBLL bllContact = new ContactEventBLL(this.CurrentUserInfo);
                LPrizesBLL      bllPrize   = new LPrizesBLL(this.CurrentUserInfo);

                var contactList = bllContact.QueryByEntity(new ContactEventEntity()
                {
                    EventId = strCTWEventId, IsCTW = 1, IsDelete = 0
                }, null).ToList();

                T_CTW_SpreadSettingBLL bllSpreadSetting = new T_CTW_SpreadSettingBLL(this.CurrentUserInfo);

                DataSet    dsFocus    = bllSpreadSetting.GetSpreadSettingQRImageByCTWEventId(strCTWEventId, "Focus");
                var        regContact = contactList.Where(a => a.ContactTypeCode == "Reg").SingleOrDefault();
                ButtonInfo reg        = new ButtonInfo();
                reg.Text = "注册";
                if (regContact != null)
                {
                    if (dsFocus != null && dsFocus.Tables[0].Rows.Count > 0)
                    {
                        reg.Text = dsFocus.Tables[0].Rows[0]["LeadPageRegPromptText"].ToString();
                    }

                    if (bllPrize.QueryByEntity(new LPrizesEntity()
                    {
                        EventId = regContact.EventId
                    }, null).SingleOrDefault() != null)
                    {
                        reg.Text = "注册有惊喜";
                    }
                }
                rd.Reg = reg;

                ButtonInfo share = new ButtonInfo();
                share.Text = "分享";
                DataSet dsShare = bllSpreadSetting.GetSpreadSettingQRImageByCTWEventId(strCTWEventId, "Share");
                if (dsShare != null && dsShare.Tables.Count > 0 && dsShare.Tables[0].Rows.Count > 0)
                {
                    share.Title      = dsShare.Tables[0].Rows[0]["Title"].ToString();
                    share.Summary    = dsShare.Tables[0].Rows[0]["Summary"].ToString();
                    share.BGImageUrl = dsShare.Tables[0].Rows[0]["BGImageUrl"].ToString();
                }
                var shareContact = contactList.Where(a => a.ContactTypeCode == "Share").SingleOrDefault();
                if (shareContact != null)
                {
                    if (bllPrize.QueryByEntity(new LPrizesEntity()
                    {
                        EventId = shareContact.EventId
                    }, null).SingleOrDefault() != null)
                    {
                        share.Text = "分享有惊喜";
                    }
                    //if (dsFocus != null && dsFocus.Tables[0].Rows.Count > 0)
                    //{
                    //    share.Text = dsFocus.Tables[0].Rows[0]["LeadPageSharePromptText"].ToString();
                    //}
                }
                rd.Share = share;

                ButtonInfo focus = new ButtonInfo();
                focus.Text = "扫码关注";

                if (dsFocus != null && dsFocus.Tables.Count > 0 && dsFocus.Tables[0].Rows.Count > 0)
                {
                    focus.BGImageUrl             = dsFocus.Tables[0].Rows[0]["BGImageUrl"].ToString();
                    focus.LeadPageQRCodeImageUrl = dsFocus.Tables[0].Rows[0]["LeadPageQRCodeImageUrl"].ToString();
                    var focusContact = contactList.Where(a => a.ContactTypeCode == "Focus").SingleOrDefault();
                    if (focusContact != null)
                    {
                        focus.Text = dsFocus.Tables[0].Rows[0]["LeadPageFocusPromptText"].ToString();
                    }
                }

                rd.Focus = focus;

                rd.IsCTW             = 1;
                rd.CTWEventId        = strCTWEventId;
                rd.EventId           = strEventId;
                rd.OnLineRedirectUrl = strOnLineRedirectUrl;
            }
            //}

            var image = bllImage.QueryByEntity(new ObjectImagesEntity()
            {
                ObjectId = strEventId, IsDelete = 0
            }, null).ToList();
            var eventInfo = bllEvent.GetByID(strEventId);

            if (image.Count != 0)
            {
                foreach (var i in image)
                {
                    if (i.BatId == "BackGround")
                    {
                        rd.BackGround = i.ImageURL;
                    }
                    if (i.BatId == "BeforeGround")
                    {
                        rd.BeforeGround = i.ImageURL;
                    }
                    if (i.BatId == "Logo")
                    {
                        rd.Logo = i.ImageURL;
                    }
                    if (i.BatId == "Rule")
                    {
                        rd.Rule = i.ImageURL;
                    }
                    if (i.BatId == "LT_kvPic")
                    {
                        rd.LT_kvPic = i.ImageURL;
                    }
                    if (i.BatId == "LT_Rule")
                    {
                        rd.LT_Rule = i.ImageURL;
                    }
                    if (i.BatId == "LT_bgpic1")
                    {
                        rd.LT_bgpic1 = i.ImageURL;
                    }
                    if (i.BatId == "LT_bgpic2")
                    {
                        rd.LT_bgpic2 = i.ImageURL;
                    }
                    if (i.BatId == "LT_regularpic")
                    {
                        rd.LT_regularpic = i.ImageURL;
                    }
                    if (i.BatId == "Receive")
                    {
                        rd.Receive = i.ImageURL;
                    }
                    if (i.BatId == "NotReceive")
                    {
                        rd.NotReceive = i.ImageURL;
                    }
                }
                ;
                rd.RuleContent = image.FirstOrDefault().RuleContent;
                rd.RuleId      = image.FirstOrDefault().RuleId ?? 0;
                rd.ImageList   = bllImage.QueryByEntity(new ObjectImagesEntity()
                {
                    ObjectId = strEventId, BatId = "list", IsDelete = 0
                }, null).ToList();
            }
            rd.EventTitle     = eventInfo.Title;
            rd.EventContent   = eventInfo.Content;
            rd.BootUrl        = eventInfo.BootURL;
            rd.ShareRemark    = eventInfo.ShareRemark;
            rd.PosterImageUrl = eventInfo.PosterImageUrl;
            rd.OverRemark     = eventInfo.OverRemark;
            rd.ShareLogoUrl   = eventInfo.ShareLogoUrl;
            rd.IsShare        = eventInfo.IsShare == null ? 0 : (int)eventInfo.IsShare;

            var entityCover = bllCover.QueryByEntity(new LCoverEntity()
            {
                EventId = strEventId, IsDelete = 0, IsShow = 1
            }, null).FirstOrDefault();

            if (entityCover != null)
            {
                rd.CoverInfo = entityCover;
            }

            return(rd);
        }
Exemplo n.º 22
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);
        }
Exemplo n.º 23
0
        protected override EmptyResponseData ProcessRequest(APIRequest <SetVipAmountRP> pRequest)
        {
            var rd   = new EmptyResponseData();
            var para = pRequest.Parameters;
            var loggingSessionInfo = new SessionManager().CurrentUserLoginInfo; //登录状态信息
            var vipAmountBLL       = new VipAmountBLL(loggingSessionInfo);
            var vipAmountDetailBLL = new VipAmountDetailBLL(loggingSessionInfo);
            var objectImagesBLL    = new ObjectImagesBLL(loggingSessionInfo);    //图片表业务对象实例化
            var unitBLL            = new t_unitBLL(loggingSessionInfo);

            var vipBLL = new VipBLL(loggingSessionInfo);

            var vipInfo  = vipBLL.GetByID(para.VipID);
            var unitInfo = unitBLL.GetByID(loggingSessionInfo.CurrentUserRole.UnitId);
            var pTran    = vipAmountBLL.GetTran(); //事务

            var vipAmountEntity = vipAmountBLL.QueryByEntity(new VipAmountEntity()
            {
                VipId = vipInfo.VIPID, VipCardCode = vipInfo.VipCode
            }, null).FirstOrDefault();

            using (pTran.Connection)
            {
                try
                {
                    var amountDetail = new VipAmountDetailEntity()
                    {
                        Amount         = para.Amount,
                        AmountSourceId = para.AmountSourceID,
                        ObjectId       = "",
                        Reason         = para.Reason,
                        Remark         = para.Remark
                    };
                    string vipAmountDetailId = string.Empty;
                    if (para.AmountSourceID == "23")
                    {      //人工调整余额
                        vipAmountDetailId = vipAmountBLL.AddVipAmount(vipInfo, unitInfo, ref vipAmountEntity, amountDetail, pTran, loggingSessionInfo);

                        if (!string.IsNullOrWhiteSpace(vipAmountDetailId))
                        {//发送微信账户余额变动模板消息
                            var CommonBLL = new CommonBLL();
                            CommonBLL.BalanceChangedMessage("人工调整", vipAmountEntity, amountDetail, vipInfo.WeiXinUserId, vipInfo.VIPID, loggingSessionInfo);
                        }
                    }
                    else if (para.AmountSourceID == "24")
                    {  //人工调整返现
                        vipAmountDetailId = vipAmountBLL.AddReturnAmount(vipInfo, unitInfo, vipAmountEntity, ref amountDetail, pTran, loggingSessionInfo);
                        if (!string.IsNullOrWhiteSpace(vipAmountDetailId))
                        {//发送返现到账通知微信模板消息
                            var CommonBLL = new CommonBLL();
                            CommonBLL.CashBackMessage("人工调整", amountDetail.Amount, vipInfo.WeiXinUserId, vipInfo.VIPID, loggingSessionInfo);
                        }
                    }
                    //增加图片上传
                    if (!string.IsNullOrEmpty(para.ImageUrl))
                    {
                        var objectImagesEntity = new ObjectImagesEntity()
                        {
                            ImageId  = Guid.NewGuid().ToString(),
                            ObjectId = vipAmountDetailId,
                            ImageURL = para.ImageUrl
                        };
                        objectImagesBLL.Create(objectImagesEntity);
                    }
                    pTran.Commit();  //提交事物
                }
                catch (APIException apiEx)
                {
                    pTran.Rollback();//回滚事物
                    throw new APIException(apiEx.ErrorCode, apiEx.Message);
                }
                catch (Exception ex)
                {
                    pTran.Rollback();//回滚事物
                    throw new Exception(ex.Message);
                }
            }
            return(rd);
        }
Exemplo n.º 24
0
        /// <summary>
        /// 保存更新游戏信息
        /// </summary>
        /// <param name="para"></param>
        /// <returns></returns>
        public void SaveGameEvent(SetCTWEventRP para, LPrizesBLL bllPrize, T_CTW_LEventInteractionBLL bllCustomerInteraction, string strThemeId, out string strStartDate, out string strEndDate, out string strGameEventGuid)
        {
            strGameEventGuid = string.Empty;

            var imageBll = new ObjectImagesBLL(loggingSessionInfo);

            LEventsBLL bllGameEvent = new LEventsBLL(loggingSessionInfo);

            var eventEntity = new LEventsEntity();

            strStartDate = para.GameEventInfo.BeginTime;
            strEndDate   = para.GameEventInfo.EndTime + " 23:59:59";
            if (string.IsNullOrEmpty(para.GameEventInfo.LeventId))
            {
                strGameEventGuid          = Guid.NewGuid().ToString();
                eventEntity.EventID       = strGameEventGuid;
                eventEntity.Title         = para.GameEventInfo.Title;
                eventEntity.BeginTime     = para.GameEventInfo.BeginTime;
                eventEntity.EndTime       = para.GameEventInfo.EndTime;
                eventEntity.DrawMethodId  = GetDrawMethodIdByDrawMethodCode(para.DrawMethodCode);
                eventEntity.PersonCount   = para.GameEventInfo.PersonCount;
                eventEntity.PointsLottery = para.GameEventInfo.PointsLottery;
                eventEntity.LotteryNum    = para.GameEventInfo.LotteryNum;
                eventEntity.IsDelete      = 0;

                if (DateTime.Compare(Convert.ToDateTime(para.GameEventInfo.BeginTime), Convert.ToDateTime(DateTime.Now.ToString("yyyy-MM-dd"))) <= 0 && DateTime.Compare(Convert.ToDateTime(para.GameEventInfo.EndTime), Convert.ToDateTime(DateTime.Now.ToString("yyyy-MM-dd"))) >= 0)
                {
                    eventEntity.EventStatus = 20;    //10=未开始,20=运行中,30=暂停,40=结束
                }
                else if (DateTime.Compare(Convert.ToDateTime(para.GameEventInfo.BeginTime), Convert.ToDateTime(DateTime.Now.ToString("yyyy-MM-dd"))) > 0)
                {
                    eventEntity.EventStatus = 10;    //10=未开始,20=运行中,30=暂停,40=结束
                }
                eventEntity.IsCTW      = 1;
                eventEntity.CustomerId = loggingSessionInfo.ClientID;
                bllGameEvent.Create(eventEntity);
            }
            else
            {
                strGameEventGuid          = para.GameEventInfo.LeventId;
                eventEntity               = bllGameEvent.GetByID(strGameEventGuid);
                eventEntity.Title         = para.GameEventInfo.Title;
                eventEntity.BeginTime     = para.GameEventInfo.BeginTime;
                eventEntity.EndTime       = para.GameEventInfo.EndTime;
                eventEntity.DrawMethodId  = GetDrawMethodIdByDrawMethodCode(para.DrawMethodCode);
                eventEntity.PersonCount   = para.GameEventInfo.PersonCount;
                eventEntity.PointsLottery = para.GameEventInfo.PointsLottery;
                eventEntity.LotteryNum    = para.GameEventInfo.LotteryNum;

                bllGameEvent.Update(eventEntity);
            }

            ///图片
            if (para.GameEventInfo.ImageList.Count > 0)
            {
                imageBll.DeleteByObjectID(strGameEventGuid);

                foreach (var i in para.GameEventInfo.ImageList)
                {
                    imageEntity             = new ObjectImagesEntity();
                    imageEntity.ImageURL    = i.ImageURL;
                    imageEntity.ObjectId    = strGameEventGuid;
                    imageEntity.CreateBy    = loggingSessionInfo.UserID;
                    imageEntity.ImageId     = Guid.NewGuid().ToString();
                    imageEntity.BatId       = i.BatId;
                    imageEntity.RuleId      = para.GameEventInfo.RuleId ?? 1;
                    imageEntity.RuleContent = para.GameEventInfo.RuleContent;
                    imageEntity.IsDelete    = 0;
                    imageEntity.CustomerId  = loggingSessionInfo.ClientID;
                    imageBll.Create(imageEntity);
                }
            }
            //奖品信息
            var entityPrize        = new LPrizesEntity();
            var redisPrizePoolsBLL = new JIT.CPOS.BS.BLL.RedisOperationBLL.PrizePools.RedisPrizePoolsBLL();

            if (!string.IsNullOrEmpty(para.GameEventInfo.LeventId))
            {
                //bllPrize.Delete(new LPrizesEntity() { EventId = para.GameEventInfo.LeventId });
                bllPrize.DeletePrizesByEventId(para.GameEventInfo.LeventId);

                CC_PrizePool prizePool = new CC_PrizePool();
                prizePool.CustomerId = loggingSessionInfo.ClientID;
                prizePool.EventId    = para.GameEventInfo.LeventId;
                redisPrizePoolsBLL.DeletePrizePoolsList(prizePool);
            }
            if (para.GameEventInfo.PrizeList.Count > 0)
            {
                foreach (var i in para.GameEventInfo.PrizeList)
                {
                    entityPrize.EventId      = strGameEventGuid;
                    entityPrize.PrizeTypeId  = i.PrizeTypeId;
                    entityPrize.Point        = i.Point;
                    entityPrize.CouponTypeID = i.CouponTypeID;
                    entityPrize.PrizeName    = i.PrizeName;
                    entityPrize.CountTotal   = i.PrizeCount;
                    entityPrize.CreateBy     = loggingSessionInfo.UserID;
                    entityPrize.PrizesID     = Guid.NewGuid().ToString();

                    bllPrize.SavePrize(entityPrize);
                }

                //入奖品池队列
                LPrizePoolsBLL bllPools = new LPrizePoolsBLL(loggingSessionInfo);
                DataSet        dsPools  = bllPools.GetPrizePoolsByEvent(loggingSessionInfo.ClientID, strGameEventGuid);
                if (dsPools != null && dsPools.Tables.Count > 0 && dsPools.Tables[0].Rows.Count > 0)
                {
                    var poolTemp  = DataTableToObject.ConvertToList <CC_PrizePool>(dsPools.Tables[0]);
                    var poolsList = Utils.GetRandomList <CC_PrizePool>(poolTemp);   //随机列表
                    if (poolsList != null && poolsList.Count > 0)
                    {
                        CC_PrizePool prizePool = new CC_PrizePool();
                        prizePool.CustomerId = loggingSessionInfo.ClientID;
                        prizePool.EventId    = strGameEventGuid;

                        redisPrizePoolsBLL.DeletePrizePoolsList(prizePool);
                        redisPrizePoolsBLL.SetPrizePoolsToRedis(poolsList);
                    }
                }
            }
            if (!string.IsNullOrEmpty(para.CTWEventId))
            {
                bllCustomerInteraction.DeleteByCTWEventID(para.CTWEventId);
            }
            ///互动类型与(游戏或促销)关联
            entityInteraction = new T_CTW_LEventInteractionEntity()
            {
                CTWEventId       = new Guid(strCTWEventId),
                ThemeId          = new Guid(strThemeId),
                InteractionType  = para.InteractionType,
                DrawMethodCode   = para.DrawMethodCode,
                LeventId         = strGameEventGuid,
                OriginalLeventId = new Guid(para.OriginalLeventId),
                CustomerId       = loggingSessionInfo.ClientID
            };
            bllCustomerInteraction.Create(entityInteraction);
        }
Exemplo n.º 25
0
        /// <summary>
        /// 保存
        /// </summary>
        public string SaveBrandDetailData()
        {
            var service               = new BrandDetailBLL(CurrentUserInfo);
            var objectImagesBLL       = new ObjectImagesBLL(CurrentUserInfo);
            var propService           = new PropService(CurrentUserInfo);
            BrandDetailEntity obj     = new BrandDetailEntity();
            string            content = string.Empty;
            string            error   = "";
            var responseData          = new ResponseData();

            string key     = string.Empty;
            string item_id = string.Empty;

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

            obj = key.DeserializeJSONTo <BrandDetailEntity>();

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

            if (item_id.Trim().Length == 0)
            {
                obj.BrandId    = Utils.NewGuid();
                obj.CustomerId = this.CurrentUserInfo.CurrentUser.customer_id;
                service.Create(obj);

                var tmpImageList = objectImagesBLL.QueryByEntity(new ObjectImagesEntity()
                {
                    ObjectId = obj.BrandId
                }, null);
                if (tmpImageList != null && tmpImageList.Length > 0)
                {
                    foreach (var tmpImageItem in tmpImageList)
                    {
                        objectImagesBLL.Delete(tmpImageItem);
                    }
                }
                if (obj.ItemImageList != null)
                {
                    foreach (var tmpImageItem in obj.ItemImageList)
                    {
                        tmpImageItem.ObjectId   = obj.BrandId;
                        tmpImageItem.CustomerId = this.CurrentUserInfo.CurrentUser.customer_id;
                        objectImagesBLL.Create(tmpImageItem);
                    }
                }

                service.SetBrandAndPropSyn(obj.BrandId, obj.BrandName, 1, 0, out error);
            }
            else
            {
                obj.BrandId    = item_id;
                obj.CustomerId = CurrentUserInfo.CurrentUser.customer_id;
                service.Update(obj, false);

                var tmpImageList = objectImagesBLL.QueryByEntity(
                    new ObjectImagesEntity()
                {
                    ObjectId = obj.BrandId
                }, null);
                if (tmpImageList != null && tmpImageList.Length > 0)
                {
                    foreach (var tmpImageItem in tmpImageList)
                    {
                        objectImagesBLL.Delete(tmpImageItem);
                    }
                }
                if (obj.ItemImageList != null)
                {
                    foreach (var tmpImageItem in obj.ItemImageList)
                    {
                        tmpImageItem.ObjectId   = obj.BrandId;
                        tmpImageItem.CustomerId = this.CurrentUserInfo.CurrentUser.customer_id;
                        objectImagesBLL.Create(tmpImageItem);
                    }
                }

                service.SetBrandAndPropSyn(obj.BrandId, obj.BrandName, 1, 0, out error);
            }

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

            content = responseData.ToJSON();
            return(content);
        }
Exemplo n.º 26
0
        protected override GetSetoffToolsRD ProcessRequest(APIRequest <GetSetoffToolsRP> pRequest)
        {
            SetoffToolsBLL    setOffToolsBLL   = new SetoffToolsBLL(CurrentUserInfo);
            IincentiveRuleBLL incentiveRuleBLL = new IincentiveRuleBLL(CurrentUserInfo);
            var para = pRequest.Parameters;
            var setoffToolsEntity = new SetoffToolsEntity();

            if (para.ToolsType != null)
            {
                setoffToolsEntity.ToolType = para.ToolsType.ToString();
            }
            GetSetoffToolsRD setoffToolsRD = new GetSetoffToolsRD();
            var setoffEventBLL             = new SetoffEventBLL(CurrentUserInfo);
            //获取集客活动信息
            string NoticePlatType = string.Empty;

            if (string.IsNullOrEmpty(para.ApplicationType))
            {
                para.ApplicationType = "0";
            }
            else
            {
                switch (para.ApplicationType)
                {
                case "1":
                    NoticePlatType = "1";
                    break;

                case "2":
                    NoticePlatType = "2";
                    break;

                case "3":
                    NoticePlatType = "2";    //传3需要进行平台类型处理 等于3时获取员工集客行动平台
                    break;

                case "4":
                    NoticePlatType = "3";    //传4需要进行平台类型处理 等于4时获取超级分销商推广行动平台
                    break;
                }
            }
            var setOffEventInfo = setoffEventBLL.QueryByEntity(new SetoffEventEntity()
            {
                Status = "10", IsDelete = 0, SetoffType = Convert.ToInt32(NoticePlatType), CustomerId = CurrentUserInfo.CurrentUser.customer_id
            }, null);
            int     SetoffToolsTotalCount = 0;
            DataSet SetoffToolsList       = null;

            if (setOffEventInfo.Length != 0)
            {
                //获取集客活动工具数量
                SetoffToolsTotalCount = setOffToolsBLL.GeSetoffToolsListCount(setoffToolsEntity, para.ApplicationType, para.BeShareVipID, setOffEventInfo[0].SetoffEventID.ToString());
                //获取集客活动工具列表
                SetoffToolsList = setOffToolsBLL.GetSetoffToolsList(setoffToolsEntity, para.ApplicationType, para.BeShareVipID, para.PageIndex, para.PageSize, setOffEventInfo[0].SetoffEventID.ToString());
            }

            //获取集客奖励信息
            var IncentiveRule = incentiveRuleBLL.GetIncentiveRule(para.ApplicationType);

            setoffToolsRD.TotalCount = SetoffToolsTotalCount;
            int remainder = 0;

            if (para.PageSize == 0)
            {
                para.PageSize = 10;
            }
            setoffToolsRD.TotalPageCount = Math.DivRem(SetoffToolsTotalCount, para.PageSize, out remainder);
            if (remainder > 0)
            {
                setoffToolsRD.TotalPageCount++;
            }
            string strHost = ConfigurationManager.AppSettings["website_url"].Trim();

            if (SetoffToolsList != null && SetoffToolsList.Tables[0].Rows.Count > 0)
            {
                //为优惠券和海报添加图片路径
                SetoffToolsList.Tables[0].Columns.Add("ImageUrl", typeof(string));
                var CustomerBasicSettingBLL = new CustomerBasicSettingBLL(CurrentUserInfo);
                var CustomerBasicInfo       = CustomerBasicSettingBLL.QueryByEntity(new CustomerBasicSettingEntity()
                {
                    CustomerID = CurrentUserInfo.CurrentUser.customer_id, SettingCode = "SetoffPosterWeChatDefaultPhoto"
                }, null).FirstOrDefault();
                var    setOffPosterBLL  = new SetoffPosterBLL(CurrentUserInfo);
                var    ObjectImagesBLL  = new ObjectImagesBLL(CurrentUserInfo);
                var    T_CTW_LEventBLL  = new T_CTW_LEventBLL(CurrentUserInfo);
                var    wMaterialTextBLL = new WMaterialTextBLL(CurrentUserInfo);
                string SourceId         = string.Empty;
                if (!string.IsNullOrEmpty(para.ApplicationType))
                {
                    switch (para.ApplicationType)
                    {
                    case "1":
                        SourceId = "3";    //会员集客
                        break;

                    case "2":
                        SourceId = "1";    //APP会员服务;
                        break;

                    case "3":
                        SourceId = "3";    //APP会员服务;
                        break;

                    case "4":
                        SourceId = "4";    //超级分销商;
                        break;
                    }
                }
                string goUrl       = string.Empty;
                string goCouponUrl = strHost + "/HtmlApps/html/common/GatheringClient/Coupon.html?customerId=";                           //拼优惠券详细页面
                string goPosterUrl = strHost + "/HtmlApps/html/common/GatheringClient/poster.html?customerId=";                           //拼海报详细页面
                string strOAuthUrl = strHost + "/WXOAuth/AuthUniversal.aspx?scope=snsapi_userinfo&SourceId=" + SourceId + "&customerId="; //拼OAuth认证
                foreach (DataRow dr in SetoffToolsList.Tables[0].Rows)
                {
                    if (dr["ToolType"].ToString() == "Coupon")
                    {
                        if (CustomerBasicInfo != null)
                        {
                            dr["ImageUrl"] = CustomerBasicInfo.SettingValue;
                        }
                        if (para.ApplicationType == "4")
                        {
                            goUrl     = goCouponUrl + CurrentUserInfo.CurrentUser.customer_id + "&pushType=IsSuperRetail&ShareVipId=" + CurrentUserInfo.UserID + "&couponId=" + dr["ObjectId"] + "&version=";
                            dr["URL"] = strOAuthUrl + CurrentUserInfo.CurrentUser.customer_id + "&objectType=Coupon&ObjectID=" + dr["ObjectId"] + "&ShareVipID=" + CurrentUserInfo.UserID + "&goUrl=" + System.Web.HttpUtility.UrlEncode(goUrl);
                        }
                        else
                        {
                            //Oauth认证加商品详情页
                            goUrl     = goCouponUrl + CurrentUserInfo.CurrentUser.customer_id + "&ShareVipId=" + CurrentUserInfo.UserID + "&couponId=" + dr["ObjectId"] + "&version=";
                            dr["URL"] = strOAuthUrl + CurrentUserInfo.CurrentUser.customer_id + "&ShareVipID=" + CurrentUserInfo.UserID + "&goUrl=" + System.Web.HttpUtility.UrlEncode(goUrl);
                        }
                    }
                    if (dr["ToolType"].ToString() == "SetoffPoster")
                    {
                        var setOffPosterInfo = setOffPosterBLL.QueryByEntity(new SetoffPosterEntity()
                        {
                            SetoffPosterID = new Guid(dr["ObjectId"].ToString())
                        }, null).FirstOrDefault();
                        if (setOffPosterInfo != null)
                        {
                            var ObjectImgsInfo = ObjectImagesBLL.QueryByEntity(new ObjectImagesEntity()
                            {
                                ImageId = setOffPosterInfo.ImageId
                            }, null).FirstOrDefault();
                            if (ObjectImgsInfo != null)
                            {
                                dr["ImageUrl"] = ObjectImgsInfo.ImageURL;
                            }
                        }
                        if (para.ApplicationType == "4")
                        {
                            goUrl     = goPosterUrl + CurrentUserInfo.CurrentUser.customer_id + "&pushType=IsSuperRetail&ShareVipId=" + CurrentUserInfo.UserID + "&ObjectId=" + dr["ObjectId"] + "&version=";
                            dr["URL"] = strOAuthUrl + CurrentUserInfo.CurrentUser.customer_id + "&objectType=SetoffPoster&ObjectID=" + dr["ObjectId"] + "&ShareVipID=" + CurrentUserInfo.UserID + "&goUrl=" + System.Web.HttpUtility.UrlEncode(goUrl);
                        }
                        else
                        {
                            //Oauth认证加海报详情页
                            goUrl     = goPosterUrl + CurrentUserInfo.CurrentUser.customer_id + "&ShareVipId=" + CurrentUserInfo.UserID + "&ObjectId=" + dr["ObjectId"] + "&version=";
                            dr["URL"] = strOAuthUrl + CurrentUserInfo.CurrentUser.customer_id + "&ShareVipID=" + CurrentUserInfo.UserID + "&goUrl=" + System.Web.HttpUtility.UrlEncode(goUrl);
                        }
                    }
                    if (dr["ToolType"].ToString() == "CTW")
                    {
                        var T_CTW_LEventInfo = T_CTW_LEventBLL.QueryByEntity(new T_CTW_LEventEntity()
                        {
                            CTWEventId = new Guid(dr["ObjectId"].ToString())
                        }, null).FirstOrDefault();
                        if (T_CTW_LEventInfo != null)
                        {
                            dr["ImageUrl"] = T_CTW_LEventInfo.ImageURL;
                        }
                        if (para.ApplicationType == "4")
                        {
                            goUrl     = dr["URL"].ToString() + "&pushType=IsSuperRetail&ShareVipId=" + CurrentUserInfo.UserID + "&ObjectId=" + dr["ObjectId"] + "&version=";
                            dr["URL"] = strOAuthUrl + CurrentUserInfo.CurrentUser.customer_id + "&objectType=CTW&ObjectID=" + dr["ObjectId"] + "&ShareVipID=" + CurrentUserInfo.UserID + "&goUrl=" + System.Web.HttpUtility.UrlEncode(goUrl);
                        }
                        else
                        {
                            goUrl     = dr["URL"].ToString() + "&ShareVipId=" + CurrentUserInfo.UserID + "&ObjectId=" + dr["ObjectId"] + "&version=";
                            dr["URL"] = strOAuthUrl + CurrentUserInfo.CurrentUser.customer_id + "&ShareVipID=" + CurrentUserInfo.UserID + "&goUrl=" + System.Web.HttpUtility.UrlEncode(goUrl);
                        }
                    }
                    if (dr["ToolType"].ToString() == "Material")//如果是图文素材
                    {
                        var wMaterialTextInfo = wMaterialTextBLL.QueryByEntity(new WMaterialTextEntity()
                        {
                            TextId = dr["ObjectId"].ToString()
                        }, null).FirstOrDefault();
                        if (wMaterialTextInfo != null)
                        {
                            dr["ImageUrl"] = wMaterialTextInfo.CoverImageUrl;
                        }
                        goUrl     = dr["URL"].ToString();
                        dr["URL"] = strOAuthUrl + CurrentUserInfo.CurrentUser.customer_id + "&objectType=Material&ObjectID=" + dr["ObjectId"] + "&ShareVipID=" + CurrentUserInfo.UserID + "&goUrl=" + System.Web.HttpUtility.UrlEncode(goUrl);
                    }
                }
                setoffToolsRD.SetOffToolsList = DataTableToObject.ConvertToList <SetOffToolsInfo>(SetoffToolsList.Tables[0]);
            }
            if (IncentiveRule != null && IncentiveRule.Tables[0].Rows.Count > 0)
            {
                setoffToolsRD.SetoffRegAwardType = Convert.ToInt32(IncentiveRule.Tables[0].Rows[0]["SetoffRegAwardType"].ToString()); //激励类型
                setoffToolsRD.SetoffRegPrize     = IncentiveRule.Tables[0].Rows[0]["SetoffRegPrize"].ToString();                      //激励值
                setoffToolsRD.SetoffOrderPer     = Convert.ToDecimal(IncentiveRule.Tables[0].Rows[0]["SetoffOrderPer"].ToString());   //订单成交提成比例
            }
            return(setoffToolsRD);
        }
        public void ProcessRequest(HttpContext context)
        {
            context.Response.ContentType = "text/plain";
            try
            {
                string xmlStr = string.Empty;
                using (var stream = context.Request.InputStream)
                {
                    using (var rd = new StreamReader(stream, System.Text.Encoding.UTF8))
                    {
                        xmlStr = rd.ReadToEnd();
                        JIT.Utility.Log.Loggers.Debug(new Utility.Log.DebugLogInfo()
                        {
                            Message = string.Format("用户维权:收到的通知信息:{0}", xmlStr)
                        });
                    }
                }
                var doc = new XmlDocument();
                doc.LoadXml(xmlStr);
                var dic = new Dictionary <string, string>();

                var ds = new DataSet();

                //遍历参数节点
                var list = doc.SelectNodes("xml/*");
                foreach (XmlNode item in list)
                {
                    if (item.Name != "PicInfo")
                    {
                        dic[item.Name] = item.InnerText;
                    }
                    else
                    {
                        //将图片读取到DS中
                        var stream = new StringReader("<PicInfo>" + item.InnerXml + "</PicInfo>");
                        var reader = new XmlTextReader(stream);
                        ds.ReadXml(reader);
                    }
                }

                #region 维权对象,不带图片

                #endregion

                #region 图片对象

                //遍历ds,向图片表插入数据

                #endregion

                var notify = dic.ToJSON().DeserializeJSONTo <WXRightOrdersEntity>();

                var customerWxMappingBll = new TCustomerWeiXinMappingBLL(Default.GetAPLoggingSession(""));


                var customerId = customerWxMappingBll.GetCustomerIdByAppId(notify.AppId);
                if (customerId == "")
                {
                    throw new APIException("客户ID为空")
                          {
                              ErrorCode = 121
                          };
                }


                var currentUserInfo = Default.GetBSLoggingSession(customerId, "1");

                var bll = new WXRightOrdersBLL(currentUserInfo);
                //根据维权单号,查询是否有数据
                var entity = bll.QueryByEntity(new WXRightOrdersEntity()
                {
                    FeedBackId = notify.FeedBackId
                }, null);


                #region 验签

                ////支付中心URL
                //var url = System.Configuration.ConfigurationManager.AppSettings["paymentcenterUrl"];
                //url = "http://121.199.42.125:6002/DevPayTest.ashx";//测试,正式需删除此行
                //var customerID = "e703dbedadd943abacf864531decdac1";//先写死测试

                //var paraSign = new Dictionary<string, string>();
                //paraSign["openid"] = notify.OpenId;
                //paraSign["timestamp"] = notify.TimeStamp;

                //var request = new
                //{
                //    AppID = notify.AppId,
                //    ClientID = customerID,
                //    UserID = notify.OpenId,
                //    Parameters = paraSign
                //};
                //string content = string.Format("action=WXGetSign&request={0}", request.ToJSON());
                //string resStr = string.Empty;
                //try
                //{
                //    resStr = JIT.Utility.Web.HttpClient.PostQueryString(url, content);
                //}
                //catch (Exception ex)
                //{
                //    JIT.Utility.Log.Loggers.Exception(new Utility.Log.ExceptionLogInfo(ex));
                //    throw ex;
                //}
                //var dicGetSign = resStr.DeserializeJSONTo<Dictionary<string, object>>();
                //if (Convert.ToInt32(dicGetSign["ResultCode"]) < 100)
                //{
                //    var dicData = dicGetSign["Datas"].ToJSON().DeserializeJSONTo<Dictionary<string, string>>();
                //    var sign = dicData["Sign"].ToString();
                //    if (sign != notify.AppSignature)
                //        throw new Exception(string.Format("验签失败,原:{0}\t新:{1}", notify.AppSignature, sign));
                //}
                //else
                //{
                //    throw new Exception(string.Format("错误信息:{0}", dicGetSign["Message"]));
                //}

                #endregion


                var conEntity = bll.QueryByEntity(new WXRightOrdersEntity()
                {
                    FeedBackId = notify.FeedBackId
                }, null).FirstOrDefault();

                switch (notify.MsgType)
                {
                case "request":     //新的维权
                    //TODO:新增记录
                    JIT.Utility.Log.Loggers.Debug(new Utility.Log.DebugLogInfo()
                    {
                        Message = string.Format("新增一条用户维权:{0}", notify.ToJSON())
                    });

                    if (entity != null)
                    {
                        //删除原有的维权单
                        bll.Delete(entity);
                    }
                    notify.Status = 10;
                    var rightOrderId = Guid.NewGuid();
                    notify.RightOrdersId = rightOrderId;
                    notify.CustomerId    = customerId;
                    bll.Create(notify);
                    var objectImages    = new ObjectImagesEntity();
                    var objectImageList = new List <ObjectImagesEntity>();
                    var imageBll        = new ObjectImagesBLL(currentUserInfo);
                    int i = 0;
                    foreach (DataRow row in ds.Tables[0].Rows)
                    {
                        i++;
                        objectImages.ImageURL     = row[0].ToString();
                        objectImages.ObjectId     = Convert.ToString(rightOrderId);
                        objectImages.ImageId      = Convert.ToString(Guid.NewGuid());
                        objectImages.DisplayIndex = i;
                        objectImages.CustomerId   = customerId;
                        //将维权单的url插入到图片表中
                        imageBll.Create(objectImages);
                    }

                    //var feedBackPara = new
                    //{
                    //    PayChannelID = 9,
                    //    FeedBackID = notify.FeedBackId,
                    //    OpenID = notify.OpenId
                    //};
                    //var feedBackRequest = new
                    //{
                    //    AppID = notify.AppId,
                    //    ClientID = customerID,
                    //    UserID = notify.OpenId,
                    //    Parameters = paraSign
                    //};
                    //content = string.Format("action=WXGetUpdateFeedBackUrl&request={0}", feedBackRequest.ToJSON());
                    //resStr = string.Empty;
                    //try
                    //{
                    //    resStr = JIT.Utility.Web.HttpClient.PostQueryString(url, content);
                    //}
                    //catch (Exception ex)
                    //{
                    //    throw ex;
                    //}

                    //var dicFeedBack = resStr.DeserializeJSONTo<Dictionary<string, object>>();
                    //if (Convert.ToInt32(dicFeedBack["ResultCode"]) < 100)
                    //{
                    //    var dicData = dicFeedBack["Datas"].ToJSON().DeserializeJSONTo<Dictionary<string, string>>();
                    //    var feedBackUrl = dicData["Url"].ToString();
                    //    string resStrFeedBack = string.Empty;
                    //    try
                    //    {
                    //        resStrFeedBack = JIT.Utility.Web.HttpClient.GetQueryString(feedBackUrl);
                    //        dicFeedBack = resStrFeedBack.DeserializeJSONTo<Dictionary<string, object>>();
                    //    }
                    //    catch (Exception ex)
                    //    {
                    //        throw ex;
                    //    }
                    //}
                    //else
                    //{
                    //    throw new Exception(string.Format("错误信息:{0}", dicGetSign["Message"]));
                    //}
                    break;

                case "confirm":     //客户同意解决
                    //TODO:对已有的记录Update
                    JIT.Utility.Log.Loggers.Debug(new Utility.Log.DebugLogInfo()
                    {
                        Message = string.Format("客户同意维权解决:{0}", notify.ToJSON())
                    });


                    if (conEntity != null)
                    {
                        conEntity.Status    = 50;
                        conEntity.MsgType   = "confirm";
                        conEntity.Reason    = notify.Reason;
                        conEntity.TimeStamp = notify.TimeStamp;

                        bll.Update(conEntity);
                    }
                    break;

                case "reject":     //客户拒绝解决
                    //TODO:对已有的记录Update,同时如何处理??
                    JIT.Utility.Log.Loggers.Debug(new Utility.Log.DebugLogInfo()
                    {
                        Message = string.Format("客户拒绝维权解决:{0}", notify.ToJSON())
                    });

                    if (conEntity != null)
                    {
                        conEntity.Status    = 60;
                        conEntity.MsgType   = "reject";
                        conEntity.Reason    = notify.Reason;
                        conEntity.TimeStamp = notify.TimeStamp;

                        bll.Update(conEntity);
                    }
                    break;

                default:
                    break;
                }

                #region 向表中记录调用的微信接口

                var wxInterfaceLogBll    = new WXInterfaceLogBLL(currentUserInfo);
                var wxInterfaceLogEntity = new WXInterfaceLogEntity();
                wxInterfaceLogEntity.LogId        = Guid.NewGuid();
                wxInterfaceLogEntity.InterfaceUrl = "微信公众号配置的维权URL";
                wxInterfaceLogEntity.AppId        = notify.AppId;
                wxInterfaceLogEntity.OpenId       = notify.OpenId;
                wxInterfaceLogEntity.RequestParam = notify.ToJSON();
                wxInterfaceLogEntity.IsSuccess    = 1;
                wxInterfaceLogBll.Create(wxInterfaceLogEntity);

                #endregion
            }
            catch (Exception ex)
            {
                JIT.Utility.Log.Loggers.Exception(new Utility.Log.ExceptionLogInfo(ex));
                context.Response.Write(ex);
            }
        }
Exemplo n.º 28
0
        protected override TemplateDetailRD ProcessRequest(APIRequest <TemplateDetailRP> pRequest)
        {
            var rd = new TemplateDetailRD();

            var para = pRequest.Parameters;
            var loggingSessionInfo = new SessionManager().CurrentUserLoginInfo;

            CTW_LEventThemeBLL        bllTheme         = new CTW_LEventThemeBLL(loggingSessionInfo);
            CTW_LEventInteractionBLL  bllInteraction   = new CTW_LEventInteractionBLL(loggingSessionInfo);
            CTW_SpreadSettingBLL      bllSpreadSetting = new CTW_SpreadSettingBLL(loggingSessionInfo);
            T_CTW_LEventsBLL          bllEvents        = new T_CTW_LEventsBLL(loggingSessionInfo);
            T_CTW_PanicbuyingEventBLL bllPanicbuying   = new T_CTW_PanicbuyingEventBLL(loggingSessionInfo);
            //更新模板点击数量
            T_CTW_LEventTemplateBLL bllTemplate = new T_CTW_LEventTemplateBLL(loggingSessionInfo);

            try
            {
                bllTemplate.UpdateTemplateInfo(para.TemplateId, 2);
            }
            catch { }
            ///获取模版信息
            DataSet dsInteraction = bllInteraction.GetEventInteractionByTemplateId(para.TemplateId);

            if (dsInteraction != null && dsInteraction.Tables[0].Rows.Count > 0)
            {
                var entityInteraction = DataTableToObject.ConvertToList <EventInteractionInfo>(dsInteraction.Tables[0]);

                var entityTheme = DataTableToObject.ConvertToList <CTW_LEventThemeEntity>(bllTheme.GetThemeInfo(para.TemplateId).Tables[0]);//.QueryByEntity(new CTW_LEventThemeEntity() { TemplateId = new Guid(para.TemplateId), IsDelete = 0 }, null);
                List <CTW_LEventThemeEntity> listTheme = new List <CTW_LEventThemeEntity>();
                foreach (var theme in entityTheme)
                {
                    List <EventInteractionInfo> listEventInteractionInfo = new List <EventInteractionInfo>();

                    ///互动信息
                    foreach (var itemAction in entityInteraction.Where(a => a.ThemeId == theme.ThemeId.ToString() && a.TemplateId == theme.TemplateId.ToString()))
                    {
                        listEventInteractionInfo.Add(itemAction);
                        if (itemAction.InteractionType == 1)
                        {
                            itemAction.GameEventImageList = DataTableToObject.ConvertToList <GameEventImageInfo>(bllEvents.GetImageList(itemAction.LeventId).Tables[0]);
                        }
                        if (itemAction.InteractionType == 2)//促销
                        {
                            itemAction.PanicbuyingEventImage = DataTableToObject.ConvertToObject <PanicbuyingEventImageInfo>(bllPanicbuying.GetPanicbuyingEventImage(itemAction.LeventId).Tables[0].Rows[0]);
                        }
                        theme.EventInteractionList = listEventInteractionInfo;
                    }
                    ;
                    listTheme.Add(theme);
                    rd.TemplateThemeList = listTheme;
                }
                rd.ActivityGroupId = entityTheme.FirstOrDefault().ActivityGroupId;
                rd.TemplateId      = entityTheme.FirstOrDefault().TemplateId.ToString();
                rd.TemplateName    = entityTheme.FirstOrDefault().TemplateName;
                rd.ImageURL        = dsInteraction.Tables[0].Rows[0]["ImageURL"].ToString();
                //推广设置
                DataSet dsSpresd = bllSpreadSetting.GetSpreadSettingInfoByTemplateId(para.TemplateId);
                if (dsSpresd != null && dsSpresd.Tables[0].Rows.Count > 0)
                {
                    rd.TemplateSpreadSettingList = DataTableToObject.ConvertToList <CTW_SpreadSettingEntity>(dsSpresd.Tables[0]);
                }

                ///获取商户所有信息
                if (!string.IsNullOrEmpty(para.CTWEventId))
                {
                    T_CTW_LEventBLL bllCTWEvent = new T_CTW_LEventBLL(loggingSessionInfo);
                    DataSet         dsCTWEvent  = bllCTWEvent.GetLeventInfoByCTWEventId(para.CTWEventId);
                    ObjectImagesBLL bllImage    = new ObjectImagesBLL(loggingSessionInfo);
                    var             bllPrizes   = new LPrizesBLL(loggingSessionInfo);

                    T_CTW_SpreadSettingBLL bllCustomerSpreadSetting = new T_CTW_SpreadSettingBLL(loggingSessionInfo);
                    if (dsCTWEvent != null && dsCTWEvent.Tables.Count > 0 && dsCTWEvent.Tables[0].Rows.Count > 0)
                    {
                        rd.CustomerCTWEventInfo = DataTableToObject.ConvertToObject <CustomerCTWEventInfo>(dsCTWEvent.Tables[0].Rows[0]);
                        //游戏活动信息
                        if (dsCTWEvent.Tables[0].Rows[0]["InteractionType"].ToString() == "1")
                        {
                            LEventsBLL bllLevents = new LEventsBLL(loggingSessionInfo);
                            string     strEventId = dsCTWEvent.Tables[0].Rows[0]["LeventId"].ToString();
                            var        ds         = bllLevents.GetNewEventInfo(strEventId);
                            if (ds != null && ds.Tables.Count > 0 && ds.Tables[0].Rows.Count > 0)
                            {
                                rd.CustomerCTWEventInfo.EventInfo = DataTableToObject.ConvertToObject <LEventsInfo>(ds.Tables[0].Rows[0]);//直接根据所需要的字段反序列化
                            }
                            DataSet dsPrizes = bllPrizes.GetPirzeList(strEventId);
                            if (dsPrizes.Tables != null && dsPrizes.Tables.Count > 0 && dsPrizes.Tables[0] != null && dsPrizes.Tables[0].Rows.Count > 0)
                            {
                                rd.CustomerCTWEventInfo.EventInfo.PrizeList = DataTableToObject.ConvertToList <Prize>(dsPrizes.Tables[0]);
                            }


                            rd.CustomerCTWEventInfo.EventInfo.ImageList = bllImage.QueryByEntity(new ObjectImagesEntity()
                            {
                                ObjectId = strEventId, IsDelete = 0
                            }, null).ToList();
                        }
                        //促销活动信息
                        if (dsCTWEvent.Tables[0].Rows[0]["InteractionType"].ToString() == "2")
                        {
                            T_CTW_PanicbuyingEventKVBLL bllPanicbuyingEventKV = new T_CTW_PanicbuyingEventKVBLL(loggingSessionInfo);
                            rd.CustomerCTWEventInfo.PanicbuyingEventInfo = DataTableToObject.ConvertToObject <T_CTW_PanicbuyingEventKVEntity>(bllPanicbuyingEventKV.GetPanicbuyingEventKV(para.CTWEventId).Tables[0].Rows[0]);
                            T_CTW_LEventInteractionBLL bllEventInteraction = new T_CTW_LEventInteractionBLL(loggingSessionInfo);
                            DataSet dsP = bllEventInteraction.GetPanicbuyingEventId(para.CTWEventId);
                            if (dsP != null && dsP.Tables.Count > 0 && dsP.Tables[0].Rows.Count > 0)
                            {
                                rd.CustomerCTWEventInfo.PanicbuyingEventInfo.PanicbuyingEventList = DataTableToObject.ConvertToList <PanicbuyingEventId>(dsP.Tables[0]);
                            }
                        }

                        //图文信息
                        var ds2 = bllCTWEvent.GetMaterialTextInfo(dsCTWEvent.Tables[0].Rows[0]["OnlineQRCodeId"].ToString());//活动图文素材对应的keyword其实是这个活动的标识,也就是生成二维码的关键字
                        if (ds2 != null && ds2.Tables.Count > 0 && ds2.Tables[0].Rows.Count > 0)
                        {
                            rd.CustomerCTWEventInfo.MaterialText = DataTableToObject.ConvertToObject <WMaterialTextEntity>(ds2.Tables[0].Rows[0]);//直接根据所需要的字段反序列化
                            rd.CustomerCTWEventInfo.MappingId    = ds2.Tables[0].Rows[0]["MappingId"].ToString();
                        }
                        //推广设置

                        DataSet dsCustomerSpread = bllCustomerSpreadSetting.GetSpreadSettingByCTWEventId(para.CTWEventId);
                        if (dsCustomerSpread != null && dsCustomerSpread.Tables[0].Rows.Count > 0)
                        {
                            rd.CustomerCTWEventInfo.SpreadSettingList = DataTableToObject.ConvertToList <T_CTW_SpreadSettingEntity>(dsCustomerSpread.Tables[0]);
                        }
                        //触点
                        ContactEventBLL bllContactEvent = new ContactEventBLL(loggingSessionInfo);
                        DataSet         dsContact       = bllContactEvent.GetContactEventByCTWEventId(para.CTWEventId);
                        if (dsContact != null && dsContact.Tables[0].Rows.Count > 0)
                        {
                            List <ContactEventInfo> ContactInfoList = new List <ContactEventInfo>();
                            ContactEventInfo        ContactInfo     = new ContactEventInfo();
                            foreach (DataRow dr in dsContact.Tables[0].Rows)
                            {
                                ContactInfo = new ContactEventInfo();
                                ContactInfo.ContactTypeCode = dr["ContactTypeCode"].ToString();
                                DataSet dsPrizes = bllPrizes.GetPirzeListForCTW(dr["ContactEventId"].ToString());
                                if (dsPrizes.Tables != null && dsPrizes.Tables.Count > 0 && dsPrizes.Tables[0] != null && dsPrizes.Tables[0].Rows.Count > 0)
                                {
                                    ContactInfo.ContactPrizeList = DataTableToObject.ConvertToList <Prize>(dsPrizes.Tables[0]);
                                }
                                ContactInfoList.Add(ContactInfo);
                            }
                            rd.CustomerCTWEventInfo.ContactEventList = ContactInfoList;
                        }
                    }


                    rd.CTWEventId = para.CTWEventId;
                }
                else
                {
                    rd.CTWEventId = Guid.NewGuid().ToString();
                }
            }
            return(rd);
        }