Ejemplo n.º 1
0
        public ActionResult DelExchangeRule(int appId, int Id)
        {
            if (appId <= 0 || Id <= 0)
            {
                return(Json(new { isok = false, msg = "删除失败!" }, JsonRequestBehavior.AllowGet));
            }
            if (dzaccount == null)
            {
                return(Json(new { isok = false, msg = "登录信息超时" }, JsonRequestBehavior.AllowGet));
            }
            XcxAppAccountRelation xcx = XcxAppAccountRelationBLL.SingleModel.GetModelByaccountidAndAppid(appId, dzaccount.Id.ToString());

            if (xcx == null)
            {
                return(Json(new { isok = false, msg = "小程序未授权" }, JsonRequestBehavior.AllowGet));
            }
            ExchangeRule model = ExchangeRuleBLL.SingleModel.GetModel($"appId={appId} and Id={Id}");

            if (model == null)
            {
                return(Json(new { isok = false, msg = "数据不存在" }, JsonRequestBehavior.AllowGet));
            }
            model.state      = 1;
            model.UpdateDate = DateTime.Now;
            bool result = ExchangeRuleBLL.SingleModel.Update(model, "state,UpdateDate");

            return(Json(new { isok = result, msg = result ? "删除成功" : "删除失败" }, JsonRequestBehavior.AllowGet));
        }
        /// <summary>
        /// 立即兑换按钮点击事件
        /// 作者:姚东
        /// 时间:20101015
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        protected void btnExchange_Click(object sender, EventArgs e)
        {
            ////判断会员是否登录系统了
            //if (Session["UserGUID"] == null)
            //{
            //    PageHelper.ShowExceptionMessage("登录系统后才能进行礼品兑换!");
            //    return;
            //}

            BLL.Entity.GiftsEntity giftEntity  = new BLL.Entity.GiftsEntity(GiftGuid);
            BLL.Entity.PointEntity pointEntity = new BLL.Entity.PointEntity(Session["UserGUID"].ToString());

            //判断剩余积分是否够兑换礼品
            if (giftEntity.NeedPoint > pointEntity.RemainPoint)
            {
                PageHelper.ShowExceptionMessage(string.Format("您的余额为{0}个积分,兑换此礼品需要{1}个积分!",
                                                              pointEntity.RemainPoint.ToString(), giftEntity.NeedPoint.ToString()));
                return;
            }

            //判断礼品余量是否够兑换
            if (giftEntity.RemainAmount <= 0)
            {
                PageHelper.ShowExceptionMessage("暂时没有多余的礼品可被兑换,请稍后再试!");
                return;
            }

            //更新兑换记录
            BLL.Entity.ExchangeEntity exchangeEntity = new BLL.Entity.ExchangeEntity();
            exchangeEntity.ApplyTime   = DateTime.Now;
            exchangeEntity.GiftGuid    = GiftGuid;
            exchangeEntity.HuiYuanGuid = Session["UserGUID"].ToString();
            exchangeEntity.Memo        = "";
            exchangeEntity.Status      = 1;
            exchangeEntity.UsedPoint   = giftEntity.NeedPoint;

            ExchangeRule exchangeRule = new ExchangeRule();

            exchangeRule.Add(exchangeEntity);

            //更新积分信息
            pointEntity.RemainPoint = pointEntity.RemainPoint - giftEntity.NeedPoint;
            PointRule pointRule = new PointRule();

            pointRule.Update(pointEntity);

            //更新礼品余量
            giftEntity.RemainAmount -= 1;
            new GiftsRule().Update(giftEntity);

            PageHelper.ShowExceptionMessage("已发送兑换申请。");
        }
Ejemplo n.º 3
0
 private void Convert(int multiplier, ExchangeRule rule, CurrencyTrigger trigger)
 {
     if (!IsInitialized)
     {
         HandleUninitializedCurrency(trigger, OnConvertError);
         return;
     }
     Model.Convert(currencyName, multiplier, rule.Name, (Dictionary <string, BankReceipt> receipts, NPNFError error) => {
         if (error != null && OnConvertError != null)
         {
             OnConvertError(this, trigger, error);
         }
         FinishTrigger(trigger, error);
     });
 }
Ejemplo n.º 4
0
 /// <summary>
 /// 积分增加日志记录
 /// </summary>
 /// <param name="rule">对应的积分规则</param>
 /// <param name="userId">用户Id</param>
 /// <param name="orderId">订单Id 到店储值消费为0</param>
 /// <param name="usegoodid">本次符合规则的产品Id 到店储值消费为0</param>
 /// <param name="curintegral">本次增加的积分</param>
 /// <returns></returns>
 public ExchangeUserIntegralLog GetAddUserIntegralLog(ExchangeRule rule, int userId, int orderId, string usegoodid, int curintegral, int ordertype, int buyPrice)
 {
     return(new ExchangeUserIntegralLog
     {
         ruleId = rule.Id,
         appId = rule.appId,
         integral = rule.integral,
         price = rule.price,
         ruleType = rule.ruleType,
         goodids = rule.goodids,
         orderId = orderId,
         usegoodids = usegoodid,
         userId = userId,
         actiontype = 0,
         curintegral = curintegral,
         AddTime = DateTime.Now,
         UpdateDate = DateTime.Now,
         ordertype = ordertype,
         buyPrice = buyPrice
     });
 }
Ejemplo n.º 5
0
 /**
  * Convert this currency to another based on an ExchangeRule
  * @param multiplier - how much of this currency to convert
  * @param rule - the ExchangeRule to be used for the conversion
  */
 public void Convert(int multiplier, ExchangeRule rule)
 {
     Convert(multiplier, rule, null);
 }
Ejemplo n.º 6
0
        public ActionResult SaveExchangeRule(ExchangeRule exchangeRule)
        {
            if (exchangeRule.appId <= 0)
            {
                return(Json(new { isok = false, msg = "appId非法" }, JsonRequestBehavior.AllowGet));
            }
            if (dzaccount == null)
            {
                return(Json(new { isok = false, msg = "登录信息超时" }, JsonRequestBehavior.AllowGet));
            }
            XcxAppAccountRelation xcx = XcxAppAccountRelationBLL.SingleModel.GetModelByaccountidAndAppid(exchangeRule.appId, dzaccount.Id.ToString());

            if (xcx == null)
            {
                return(Json(new { isok = false, msg = "小程序未授权" }, JsonRequestBehavior.AllowGet));
            }

            XcxTemplate xcxTemplate = XcxTemplateBLL.SingleModel.GetModel($"id={xcx.TId}");

            if (xcxTemplate == null)
            {
                return(Json(new { isok = false, msg = "找不到小程序模板" }, JsonRequestBehavior.AllowGet));
            }



            int ruleTotalCount = ExchangeRuleBLL.SingleModel.GetCount($"appId={exchangeRule.appId} and state=0");

            if (ruleTotalCount >= 10)
            {
                return(Json(new { isok = false, msg = "最多设置10条规则" }, JsonRequestBehavior.AllowGet));
            }

            if (!Regex.IsMatch(exchangeRule.integral.ToString(), @"^\+?[1-9][0-9]*$"))
            {
                return(Json(new { isok = false, msg = "积分必须为大于零的整数" }, JsonRequestBehavior.AllowGet));
            }

            if (!Regex.IsMatch(exchangeRule.price.ToString(), @"^\+?[0-9][0-9]*$"))
            {
                return(Json(new { isok = false, msg = "金额不合法!" }, JsonRequestBehavior.AllowGet));
            }

            if (exchangeRule.ruleType == 1)
            {
                //表示选择部分商品消费赠送积分
                if (!StringHelper.IsNumByStrs(',', exchangeRule.goodids))
                {
                    return(Json(new { isok = false, msg = "请选择消费赠送金额的商品!" }, JsonRequestBehavior.AllowGet));
                }
            }

            if (exchangeRule.Id > 0)
            {
                ExchangeRule model = ExchangeRuleBLL.SingleModel.GetModel(exchangeRule.Id);
                if (model == null)
                {
                    return(Json(new { isok = false, msg = "数据不存在!" }, JsonRequestBehavior.AllowGet));
                }
                //表示更新
                exchangeRule.UpdateDate = DateTime.Now;
                if (ExchangeRuleBLL.SingleModel.Update(exchangeRule))
                {
                    return(Json(new { isok = true, msg = "更新成功!" }, JsonRequestBehavior.AllowGet));
                }
                return(Json(new { isok = false, msg = "更新失败!" }, JsonRequestBehavior.AllowGet));
            }
            else
            {
                if (xcxTemplate.Type == (int)TmpType.小程序专业模板)
                {
                    FunctionList functionList = new FunctionList();
                    int          industr      = xcx.VersionId;
                    functionList = FunctionListBLL.SingleModel.GetModel($"TemplateType={xcxTemplate.Type} and VersionId={industr}");
                    if (functionList == null)
                    {
                        return(Json(new { isok = false, msg = $"功能权限未设置" }, JsonRequestBehavior.AllowGet));
                    }
                    OperationMgr operationMgr = new OperationMgr();
                    if (!string.IsNullOrEmpty(functionList.OperationMgr))
                    {
                        operationMgr = JsonConvert.DeserializeObject <OperationMgr>(functionList.OperationMgr);
                    }

                    if (operationMgr.Integral == 1)
                    {
                        return(Json(new { isok = false, msg = $"请先升级到更高版本才能开启此功能" }, JsonRequestBehavior.AllowGet));
                    }
                }


                //表示新增
                exchangeRule.AddTime    = DateTime.Now;
                exchangeRule.UpdateDate = DateTime.Now;
                int ruleId = Convert.ToInt32(ExchangeRuleBLL.SingleModel.Add(exchangeRule));
                if (ruleId > 0)
                {
                    return(Json(new { isok = true, msg = "新增成功!", obj = ruleId }, JsonRequestBehavior.AllowGet));
                }
                return(Json(new { isok = false, msg = "新增失败!" }, JsonRequestBehavior.AllowGet));
            }
        }