Ejemplo n.º 1
0
        public void Delete(long id)
        {
            WXCardLogInfo wXCardLogInfo = context.WXCardLogInfo.FirstOrDefault((WXCardLogInfo d) => d.Id == id);

            if (wXCardLogInfo != null)
            {
                string accessToken            = GetAccessToken(wXCardLogInfo.AppId, wXCardLogInfo.AppSecret);
                List <WXCardCodeLogInfo> list = (
                    from d in context.WXCardCodeLogInfo
                    where d.CardId == wXCardLogInfo.CardId
                    select d).ToList();
                foreach (WXCardCodeLogInfo wXCardCodeLogInfo in list)
                {
                    Consume(wXCardCodeLogInfo.Id);
                }
                context.WXCardLogInfo.Remove(wXCardLogInfo);
                CardDeleteResultJson cardDeleteResultJson = CardApi.CardDelete(accessToken, wXCardLogInfo.CardId, 10000);
                if (cardDeleteResultJson.errcode != ReturnCode.请求成功)
                {
                    int num = (int)cardDeleteResultJson.errcode;
                    Log.Error("微信同步删除卡券失败", new Exception(num.ToString()));
                }
                context.SaveChanges();
            }
        }
Ejemplo n.º 2
0
        /// <summary>
        /// 删除卡券
        /// </summary>
        /// <param name="id"></param>
        public void Delete(long id)
        {
            var card = Context.WXCardLogInfo.FirstOrDefault(d => d.Id == id);

            if (card != null)
            {
                string acctoken = GetAccessToken(card.AppId, card.AppSecret);

                #region 先核销所有已领卡券
                //同步核销
                List <WXCardCodeLogInfo> wxclist = Context.WXCardCodeLogInfo.Where(d => d.CardId == card.CardId).ToList();
                foreach (var item in wxclist)
                {
                    Consume(item.Id);
                }
                #endregion

                Context.WXCardLogInfo.Remove(card);
                var wxResultJson = CardApi.CardDelete(acctoken, card.CardId);
                if (wxResultJson.errcode != Senparc.Weixin.ReturnCode.请求成功)
                {
                    Core.Log.Error("微信同步删除卡券失败", new Exception(((int)wxResultJson.errcode).ToString()));
                }

                Context.SaveChanges();
            }
        }
Ejemplo n.º 3
0
        protected void rptList_ItemCommand(object source, RepeaterCommandEventArgs e)
        {
            if (e.CommandName == "toufang")
            {
                //  int dd = int.Parse(lbtn_Update.CommandArgument.ToString());
                int    dd          = int.Parse(e.Item.ItemIndex.ToString());
                string Cardid      = ((HiddenField)rptList.Items[dd].FindControl("HiddenField1")).Value;
                var    cardId      = Cardid;
                string accessToken = Token();
                var    result      = CardApi.CreateQR(accessToken, cardId);


                string ticket    = result.ticket;
                string url_image = GetShowQrCodeUrl(ticket);
                int    ss        = int.Parse(e.Item.ItemIndex.ToString());
                Image  sss       = (Image)rptList.Items[ss].FindControl("Image2");
                sss.ImageUrl = url_image;
            }
            else if (e.CommandName == "deletecard")
            {
                DropDownList dr = new DropDownList();
                dr = (DropDownList)rptList.Controls[0].FindControl("DropDownList2");
                string dd         = dr.SelectedValue;
                int    cardid     = int.Parse(e.Item.ItemIndex.ToString());
                string card_wx_id = ((HiddenField)rptList.Items[cardid].FindControl("HiddenField1")).Value;
                var    result     = CardApi.CardDelete(Token(), card_wx_id);
                if (result.errmsg == "ok")
                {
                    bll.delete(card_wx_id);
                }
                else
                {
                    string ss = result.errmsg;
                }
                string where = "wid=" + wid() + " and Card_type=团购券";
                Rqlistb(where);
            }
            else if (e.CommandName == "update_q")
            {
                int     dd          = int.Parse(e.Item.ItemIndex.ToString());
                string  Cardid      = ((HiddenField)rptList.Items[dd].FindControl("HiddenField1")).Value;
                var     cardId      = Cardid;
                string  Cardtype    = ((HiddenField)rptList.Items[dd].FindControl("hd2")).Value;
                string  accessToken = Token();
                int     ss          = int.Parse(e.Item.ItemIndex.ToString());
                TextBox sss         = (TextBox)rptList.Items[ss].FindControl("quantity");

                var result = CardApi.CardDetailGet(accessToken, cardId);
                if (Cardtype == "团购券")
                {
                    sss.Text = result.card.groupon.base_info.sku.quantity.ToString();
                }
                else if (Cardtype == "代金券")
                {
                    sss.Text = result.card.cash.base_info.sku.quantity.ToString();
                }
                else if (Cardtype == "折扣券")
                {
                    sss.Text = result.card.discount.base_info.sku.quantity.ToString();
                }
                else if (Cardtype == "优惠券")
                {
                    sss.Text = result.card.general_coupon.base_info.sku.quantity.ToString();
                }

                Model.Card_wx.Card_BaseInfo Base = new Model.Card_wx.Card_BaseInfo();
                Base.quantity   = int.Parse(sss.Text);
                Base.Wx_Card_id = cardId;
                Base.wid        = wid();
                bll.Upadata_kucun(Base);

                //  var result= CardApi.ModifyStock(Token(), Cardid, int.Parse(sss.Text));
                //  try
                //  {
                //      if (result.errmsg == "ok")
                //      {

                //      }
                //  }
                //  catch (Exception ex)
                //  {
                //  }
            }
            else if (e.CommandName == "exit")
            {
                int    dd       = int.Parse(e.Item.ItemIndex.ToString());
                string Cardid   = ((HiddenField)rptList.Items[dd].FindControl("HiddenField1")).Value;
                var    cardId   = Cardid;
                string Cardtype = ((HiddenField)rptList.Items[dd].FindControl("hd2")).Value;
                Response.Redirect("Card_wx_exid.aspx?cardtype=" + Cardtype + "&cardid=" + cardId + "&type=exit");
            }
        }