コード例 #1
0
        /// <summary>
        /// 获取波段列表
        /// </summary>
        public string GetIntegralRuleListData()
        {
            var    form    = Request("form").DeserializeJSONTo <IntegralRuleEntity>();
            var    service = new IntegralRuleBLL(CurrentUserInfo);
            string content = string.Empty;

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

            var queryEntity = new IntegralRuleEntity();

            queryEntity.IntegralSourceID = form.IntegralSourceID;
            queryEntity.Integral         = form.Integral;
            int pageIndex = Utils.GetIntVal(FormatParamValue(Request("page"))) - 1;

            var data           = service.GetList(queryEntity, pageIndex, PageSize);
            var dataTotalCount = service.GetListCount(queryEntity);

            content = string.Format("{{\"totalCount\":{1},\"topics\":{0}}}",
                                    data.ToJSON(),
                                    dataTotalCount);
            return(content);
        }
コード例 #2
0
        /// <summary>
        ///
        /// </summary>
        public string SaveIntegralRule()
        {
            var integralRuleBLL = new IntegralRuleBLL(this.CurrentUserInfo);

            string content      = string.Empty;
            string error        = "";
            var    responseData = new ResponseData();

            string key  = string.Empty;
            var    item = Request("item");

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

            var integralRuleEntity = key.DeserializeJSONTo <IntegralRuleEntity>();

            if (integralRuleEntity.BeginDateStr != null && integralRuleEntity.BeginDateStr.Length > 0)
            {
                integralRuleEntity.BeginDate = Convert.ToDateTime(integralRuleEntity.BeginDateStr);
            }
            if (integralRuleEntity.EndDateStr != null && integralRuleEntity.EndDateStr.Length > 0)
            {
                integralRuleEntity.EndDate = Convert.ToDateTime(integralRuleEntity.EndDateStr);
            }

            if (integralRuleEntity.Integral == null || integralRuleEntity.Integral.Length == 0)
            {
                responseData.success = false;
                responseData.msg     = "积分公式不能为空";
                return(responseData.ToJSON());
            }

            if (integralRuleEntity.IntegralRuleID == null || integralRuleEntity.IntegralRuleID.Trim().Length == 0)
            {
                integralRuleEntity.IntegralRuleID = Utils.NewGuid();
                integralRuleEntity.CustomerId     = CurrentUserInfo.CurrentUser.customer_id;
                integralRuleBLL.Create(integralRuleEntity);
            }
            else
            {
                integralRuleBLL.Update(integralRuleEntity, null);
            }


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

            content = responseData.ToJSON();
            return(content);
        }
コード例 #3
0
        /// <summary>
        /// 获取信息
        /// </summary>
        public string GetIntegralRuleInfoById()
        {
            var service                = new IntegralRuleBLL(CurrentUserInfo);
            IntegralRuleEntity obj     = new IntegralRuleEntity();
            string             content = string.Empty;

            string key = string.Empty;

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

            obj = service.GetByID(key);

            var jsonData = new JsonData();

            jsonData.totalCount = obj == null ? "0" : "1";
            jsonData.data       = obj;

            content = jsonData.ToJSON();
            return(content);
        }
コード例 #4
0
        /// <summary>
        /// 验证真伪得积分
        /// </summary>
        public string SetCheckReal()
        {
            string content  = string.Empty;
            var    respData = new SetCheckRealRespData();

            try
            {
                string openId = Request["openID"];
                //openId = "o8Y7Ejl1zl5RHXDvPONCNqoC5Md8";

                Loggers.Debug(new DebugLogInfo()
                {
                    Message = string.Format(
                        "OpenID:{0}", openId)
                });

                var currentUser = Default.GetLoggingSession();

                VipBLL               vipBLL               = new VipBLL(currentUser);
                IntegralRuleBLL      integralRuleBLL      = new IntegralRuleBLL(currentUser);
                VipIntegralDetailBLL vipIntegralDetailBLL = new VipIntegralDetailBLL(currentUser);
                VipIntegralBLL       vipIntegralBLL       = new VipIntegralBLL(currentUser);

                string vipId = null;
                if (true)
                {
                    VipEntity vipIdData     = null;
                    var       vipIdDataList = vipBLL.QueryByEntity(new VipEntity()
                    {
                        WeiXinUserId = openId
                    }, null);
                    if (vipIdDataList == null || vipIdDataList.Length == 0 || vipIdDataList[0] == null ||
                        vipIdDataList[0].VIPID == null)
                    {
                        respData.Code        = "103";
                        respData.Description = "数据库操作错误";
                        respData.Exception   = "未查询到Vip会员";
                        return(respData.ToJSON());
                    }
                    else
                    {
                        vipIdData = vipIdDataList[0];
                        vipId     = vipIdData.VIPID;
                    }
                }

                // SysIntegralSource: 10
                string integralSourceId = "10";
                int    integralValue    = 0;
                if (true)
                {
                    IntegralRuleEntity integralRuleData = null;
                    var integralRuleDataList            = integralRuleBLL.QueryByEntity(new IntegralRuleEntity()
                    {
                        IntegralSourceID = integralSourceId
                    }, null);
                    if (integralRuleDataList == null || integralRuleDataList.Length == 0 || integralRuleDataList[0] == null)
                    {
                        respData.Code        = "103";
                        respData.Description = "数据库操作错误";
                        respData.Exception   = "未查询到积分规则";
                        return(respData.ToJSON());
                    }
                    else
                    {
                        integralRuleData = integralRuleDataList[0];
                        integralValue    = int.Parse(integralRuleData.Integral);
                    }
                }

                #region 保存积分
                if (true)
                {
                    string tmpVipId            = vipId;
                    int    tmpIntegralValue    = integralValue;
                    string tmpIntegralSourceId = integralSourceId;
                    string tmpOpenId           = openId;
                    string msgModel            = "【验真品,送积分】活动,您本次验证赢得{0}点积分。您当前的总积分是{1}点。";

                    // 插入积分明细
                    VipIntegralDetailEntity vipIntegralDetailEntity = new VipIntegralDetailEntity();
                    vipIntegralDetailEntity.VipIntegralDetailID = CPOS.Common.Utils.NewGuid();
                    vipIntegralDetailEntity.VIPID            = tmpVipId;
                    vipIntegralDetailEntity.FromVipID        = tmpVipId;
                    vipIntegralDetailEntity.SalesAmount      = 0;
                    vipIntegralDetailEntity.Integral         = tmpIntegralValue;
                    vipIntegralDetailEntity.IntegralSourceID = tmpIntegralSourceId;
                    vipIntegralDetailEntity.IsAdd            = 1;
                    //vipIntegralDetailBLL.Create(vipIntegralDetailEntity);

                    // 更新积分
                    VipIntegralEntity vipIntegralEntity = new VipIntegralEntity();
                    var vipIntegralDataList             = vipIntegralBLL.QueryByEntity(
                        new VipIntegralEntity()
                    {
                        VipID = vipId
                    }, null);
                    if (vipIntegralDataList == null || vipIntegralDataList.Length == 0 || vipIntegralDataList[0] == null)
                    {
                        vipIntegralEntity.VipID           = tmpVipId;
                        vipIntegralEntity.BeginIntegral   = 0;                // 期初积分
                        vipIntegralEntity.InIntegral      = tmpIntegralValue; // 增加积分
                        vipIntegralEntity.OutIntegral     = 0;                //消费积分
                        vipIntegralEntity.EndIntegral     = tmpIntegralValue; //积分余额
                        vipIntegralEntity.InvalidIntegral = 0;                // 累计失效积分
                        vipIntegralEntity.ValidIntegral   = tmpIntegralValue; // 当前有效积分
                        //vipIntegralBLL.Create(vipIntegralEntity);
                    }
                    else
                    {
                        vipIntegralEntity.VipID      = tmpVipId;
                        vipIntegralEntity.InIntegral = vipIntegralDataList[0].InIntegral + tmpIntegralValue;;      // 增加积分
                        //vipIntegralEntity.OutIntegral = 0; //消费积分
                        vipIntegralEntity.EndIntegral = vipIntegralDataList[0].EndIntegral + tmpIntegralValue;     //积分余额
                        //vipIntegralEntity.InvalidIntegral = 0; // 累计失效积分
                        vipIntegralEntity.ValidIntegral = vipIntegralDataList[0].ValidIntegral + tmpIntegralValue; // 当前有效积分
                        //vipIntegralBLL.Update(vipIntegralEntity, false);
                    }

                    // 更新VIP
                    VipEntity vipEntity         = new VipEntity();
                    var       vipEntityDataList = vipBLL.QueryByEntity(
                        new VipEntity()
                    {
                        VIPID = tmpVipId
                    }, null);
                    if (vipEntityDataList == null || vipEntityDataList.Length == 0 || vipEntityDataList[0] == null)
                    {
                        vipEntity.VIPID       = tmpVipId;
                        vipEntity.Integration = vipIntegralEntity.ValidIntegral;
                        //vipEntity.HigherVipID = highOpenId;
                        vipEntity.ClientID = currentUser.CurrentUser.customer_id;
                        vipEntity.Status   = 1;
                        vipBLL.Create(vipEntity);
                    }
                    else
                    {
                        vipEntity.VIPID       = tmpVipId;
                        vipEntity.Integration = vipIntegralEntity.ValidIntegral;
                        //vipEntity.HigherVipID = highOpenId;
                        vipEntity.ClientID = currentUser.CurrentUser.customer_id;
                        vipBLL.Update(vipEntity, false);
                    }

                    // 推送消息
                    string msgUrl  = ConfigurationManager.AppSettings["push_weixin_msg_url"].Trim();
                    string msgText = string.Format(msgModel, tmpIntegralValue, vipEntity.Integration);
                    string msgData = "<xml><OpenID><![CDATA[" + tmpOpenId + "]]></OpenID><Content><![CDATA[" + msgText + "]]></Content></xml>";

                    var msgResult = Common.Utils.GetRemoteData(msgUrl, "POST", msgData);
                    Loggers.Debug(new DebugLogInfo()
                    {
                        Message = string.Format("PushMsgResult:{0}", msgResult)
                    });

                    respData.Data = tmpIntegralValue.ToString();
                }
                #endregion
            }
            catch (Exception ex)
            {
                respData.Code        = "103";
                respData.Description = "数据库操作错误";
                respData.Exception   = ex.ToString();
            }
            content = respData.ToJSON();
            return(content);
        }