Ejemplo n.º 1
0
 public ActionResult ResultEdit(Guid pluginId, Guid id)
 {
     if (StringHelper.IsZeroGuid(pluginId))
     {
         return(Json(new { message = "参数有误,请检查!" }));
     }
     else
     {
         Plugin plugin = _pluginService.GetById(pluginId);
         if (plugin == null)
         {
             return(Json(new { message = "对不起,不存在该插件或未开通,请检查!" }));
         }
         else
         {
             ScorePluginResult pluginResult = _scorePluginResultService.GetById(id);
             if (pluginResult == null)
             {
                 return(Json(new { message = "对不起,不存在该中奖项,请检查!" }));
             }
             TryUpdateModel <ScorePluginResult>(pluginResult);
             _scorePluginResultService.Update(pluginResult);
             return(Json(new { isOK = false, isVertfy = true, message = "已发放" }));
         }
     }
 }
Ejemplo n.º 2
0
        public ActionResult StoreItemExchange(Guid baseId, Guid itemId, string t)
        {
            try
            {
                if (baseId == Guid.Empty)
                {
                    return(Json(new { isOK = false, error_code = "ERR_ArgNotExist" }));
                }

                if (MpUserID == Guid.Empty)
                {
                    string rawUrl = "http://wx.ssrcb.com/ScoreSys/StoreItem?id=" + WebHelper.GetGuid("baseId", Guid.Empty);
                    if (string.IsNullOrEmpty(RQuery["openid"]))
                    {
                        return(Json(new { isOK = false, isLogin = true, error_code = "ERR_NotLogin", message = string.Format("https://open.weixin.qq.com/connect/oauth2/authorize?appid={0}&redirect_uri=http://wx.ssrcb.com/mpuser/autologin?refUrl={1}&response_type=code&scope=snsapi_base&state=STATE#wechat_redirect", MpCenterCache.AppID, rawUrl) }));
                    }
                }

                ScoreStoreItem scoreStoreItem = _scoreStoreItemServiceService.GetUnique("from ScoreStoreItem where Id='" + itemId.ToString() + "'");
                if (scoreStoreItem == null)
                {
                    return(Json(new { isOK = false, error_code = "ERR_StoreItemNotExist" }));
                }
                if (scoreStoreItem.LeftCount <= 0)
                {
                    return(Json(new { isOK = false, error_code = "ERR_StoreItemScoreRunOut" }));
                }
                ScoreUser scoreUser = _scoreUserService.GetUnique("from ScoreUser where MpUserId = '" + MpUserID + "'");
                if (scoreUser == null)
                {
                    return(Json(new { isOK = false, error_code = "ERR_StoreItemUserNotExist" }));
                }
                if (scoreUser.CurrentScore < scoreStoreItem.NeedPoint)
                {
                    return(Json(new { isOK = false, error_code = "ERR_StoreItemScoreNotEnough" }));
                }
                string Name          = Request.Form["Name"];
                string Phone         = Request.Form["Phone"];
                string Address       = Request.Form["Address"];
                string ResultID      = Request.Form["resultId"];
                string isDefaultAddr = Request.Form["DefaultAddr"];
                if (isDefaultAddr == "true")
                {
                    scoreUser.RecvName    = Name;
                    scoreUser.RecvPhone   = Phone;
                    scoreUser.RecvAddress = Address;
                    _scoreUserService.Update(scoreUser);
                }
                ScorePluginResult scorePluginResult = null;
                if (ResultID == "0")
                {
                    scorePluginResult             = new ScorePluginResult();
                    scorePluginResult.MobilePhone = Phone;
                    scorePluginResult.Address     = Address;
                    scorePluginResult.Name        = Name;
                    scorePluginResult.Type        = 2;
                    scorePluginResult.CreateDate  = DateTime.Now;
                    scorePluginResult.MpUserId    = this.MpUserID;
                    scorePluginResult.PluginId    = baseId;
                    scorePluginResult.Summary     = "申请兑奖【" + scoreStoreItem.PluginName + "】" + scoreStoreItem.AliasName;
                    scorePluginResult.Value       = "" + scoreStoreItem.PluginName + "++" + scoreStoreItem.AliasName;
                    _scorePluginResultService.Insert(scorePluginResult);

                    ScoreConsumeInfo scoreConSumeInfo = new ScoreConsumeInfo();
                    scoreConSumeInfo.ConsumeDateTime = scoreConSumeInfo.CreateDate = DateTime.Now;
                    scoreConSumeInfo.MpUserId        = this.MpUserID;
                    scoreConSumeInfo.ConsumeType     = (int)(ScoreConsume.Exchange);
                    scoreConSumeInfo.ConsumePoints   = -Convert.ToInt32(scoreStoreItem.NeedPoint);
                    scoreConSumeInfo.Summary         = "兑换消耗了" + Convert.ToInt32(scoreStoreItem.NeedPoint) + "积分";
                    _scoreConsumeInfoService.Insert(scoreConSumeInfo);

                    scoreUser.CurrentScore -= scoreStoreItem.NeedPoint;
                    _scoreUserService.Update(scoreUser);

                    return(Json(new { isOK = true, error_code = "ERR_RequireSuccess" }));
                }
                else
                {
                    scorePluginResult = _scorePluginResultService.GetUnique("from ScorePluginResult where MpUserId='" + this.MpUserID.ToString() + "' and Id='" + ResultID.ToString() + "'");
                    if (scorePluginResult == null)
                    {
                        return(Json(new { isOK = false, error_code = "ERR_ScorePluginResultNotExist" }));
                    }
                    if (scorePluginResult.IsUse == 1)
                    {
                        return(Json(new { isOK = false, error_code = "ERR_AlreadySend" }));//对不起,您已经领取完奖!
                    }
                    scorePluginResult.MobilePhone = Phone;
                    scorePluginResult.Address     = Address;
                    scorePluginResult.Name        = Name;
                    _scorePluginResultService.Update(scorePluginResult);
                    return(Json(new { isOK = true, error_code = "ERR_ModifySuccess" }));
                }
            }
            catch (Exception ex)
            {
                throw new OceanException(ex.Message, ex);
            }
        }