コード例 #1
0
        public bool Add(WXCardLogInfo info)
        {
            string           str;
            bool             flag         = false;
            string           accessToken  = "";
            string           str1         = string.Concat("http://", WebHelper.GetHost());
            string           str2         = string.Concat(str1, "/images/defaultwxlogo.png");
            SiteSettingsInfo siteSettings = Instance <ISiteSettingService> .Create.GetSiteSettings();

            IShopService         create               = Instance <IShopService> .Create;
            IVShopService        vShopService         = Instance <IVShopService> .Create;
            CardCreateResultJson cardCreateResultJson = new CardCreateResultJson();
            Card_BaseInfoBase    cardBaseInfoBase     = new Card_BaseInfoBase()
            {
                logo_url   = str2,
                brand_name = siteSettings.SiteName,
                code_type  = Card_CodeType.CODE_TYPE_BARCODE,
                title      = info.CardTitle,
                sub_title  = info.CardSubTitle,
                color      = info.CardColor,
                notice     = string.Concat("专供", siteSettings.SiteName, "使用")
            };
            Card_BaseInfoBase cardBaseInfoBase1 = cardBaseInfoBase;

            string[] strArrays  = new string[5];
            string[] strArrays1 = strArrays;
            if (info.LeastCost > 0)
            {
                int leastCost = info.LeastCost / 100;
                str = string.Concat("满¥", leastCost.ToString("F2"), "使用");
            }
            else
            {
                str = "无门槛使用";
            }
            strArrays1[0] = str;
            strArrays[1]  = ",有效期至";
            strArrays[2]  = info.BeginTime.ToString("yyyy年MM月dd日");
            strArrays[3]  = "-";
            strArrays[4]  = info.EndTime.ToString("yyyy年MM月dd日");
            cardBaseInfoBase1.description = string.Concat(strArrays);
            Card_BaseInfo_DateInfo cardBaseInfoDateInfo = new Card_BaseInfo_DateInfo()
            {
                type            = Card_DateInfo_Type.DATE_TYPE_FIX_TIME_RANGE.ToString(),
                begin_timestamp = Senparc.Weixin.Helpers.DateTimeHelper.GetWeixinDateTime(info.BeginTime),
                end_timestamp   = Senparc.Weixin.Helpers.DateTimeHelper.GetWeixinDateTime(info.EndTime)
            };

            cardBaseInfoBase.date_info = cardBaseInfoDateInfo;
            Card_BaseInfoBase cardBaseInfoBase2 = cardBaseInfoBase;
            Card_BaseInfo_Sku cardBaseInfoSku   = new Card_BaseInfo_Sku()
            {
                quantity = (info.Quantity == 0 ? MaxStock : info.Quantity)
            };

            cardBaseInfoBase2.sku            = cardBaseInfoSku;
            cardBaseInfoBase.get_limit       = (info.GetLimit == 0 ? MaxStock : info.GetLimit);
            cardBaseInfoBase.use_custom_code = false;
            cardBaseInfoBase.bind_openid     = false;
            cardBaseInfoBase.can_share       = false;
            cardBaseInfoBase.can_give_friend = false;
            cardBaseInfoBase.custom_url_name = "立即使用";
            Card_BaseInfoBase      shopName = cardBaseInfoBase;
            Card_GeneralCouponData cardGeneralCouponDatum = new Card_GeneralCouponData()
            {
                base_info      = shopName,
                default_detail = info.DefaultDetail
            };
            Card_GeneralCouponData cardGeneralCouponDatum1 = cardGeneralCouponDatum;

            if (info.ShopId > 0)
            {
                long shopId = info.ShopId;
                shopName.custom_url = string.Concat(str1, "/Shop/Home/", shopId.ToString());
            }
            WXShopInfo vShopSetting  = vShopService.GetVShopSetting(info.ShopId);
            VShopInfo  vShopByShopId = vShopService.GetVShopByShopId(info.ShopId);
            ShopInfo   shop          = create.GetShop(info.ShopId, false);

            if (vShopSetting != null && shop != null && vShopByShopId != null && !string.IsNullOrWhiteSpace(vShopSetting.AppId) && !string.IsNullOrWhiteSpace(vShopSetting.AppSecret))
            {
                accessToken = GetAccessToken(vShopSetting.AppId, vShopSetting.AppSecret);
                if (!string.IsNullOrWhiteSpace(accessToken))
                {
                    shopName.brand_name = shop.ShopName;
                    if (!string.IsNullOrWhiteSpace(vShopByShopId.WXLogo))
                    {
                        shopName.logo_url = string.Concat(str1, vShopByShopId.WXLogo);
                    }
                    cardCreateResultJson = CardApi.CreateCard(accessToken, cardGeneralCouponDatum1, 10000);
                    if (cardCreateResultJson.errcode == ReturnCode.请求成功)
                    {
                        info.AppId     = vShopSetting.AppId;
                        info.AppSecret = vShopSetting.AppSecret;
                        info.CardId    = cardCreateResultJson.card_id;
                        flag           = true;
                    }
                }
            }
            if (!flag)
            {
                if (!string.IsNullOrWhiteSpace(siteSettings.WeixinAppId) && !string.IsNullOrWhiteSpace(siteSettings.WeixinAppSecret))
                {
                    accessToken = GetAccessToken(siteSettings.WeixinAppId, siteSettings.WeixinAppSecret);
                    if (!string.IsNullOrWhiteSpace(accessToken))
                    {
                        shopName.brand_name = shop.ShopName;
                        if (!string.IsNullOrWhiteSpace(siteSettings.WXLogo))
                        {
                            shopName.logo_url = string.Concat(str1, siteSettings.WXLogo);
                        }
                        cardCreateResultJson = CardApi.CreateCard(accessToken, cardGeneralCouponDatum1, 10000);
                        if (cardCreateResultJson.errcode == ReturnCode.请求成功)
                        {
                            info.AppId     = siteSettings.WeixinAppId;
                            info.AppSecret = siteSettings.WeixinAppSecret;
                            info.CardId    = cardCreateResultJson.card_id;
                            flag           = true;
                        }
                    }
                }
                if (info.ShopId < 1)
                {
                    shopName.custom_url = string.Concat(str1, "/");
                }
            }
            if (flag)
            {
                info.AuditStatus = new int?(0);
                context.WXCardLogInfo.Add(info);
                context.SaveChanges();
            }
            return(flag);
        }
コード例 #2
0
ファイル: WXCardService.cs プロジェクト: redpanda321/Mall
        /// <summary>
        /// 添加卡券
        /// </summary>
        /// <param name="info"></param>
        public bool Add(Entities.WXCardLogInfo info)
        {
            bool   issuccess = false;
            string acctoken  = "";
            string curHost   = Core.Helper.WebHelper.GetScheme() + "://" + Core.Helper.WebHelper.GetHost();
            string imagefile = "/images/defaultwxlogo.png";
            string wxlogo    = Core.MallIO.GetImagePath(imagefile);

            if (wxlogo.IndexOf("http") < 0)
            {
                wxlogo = curHost + imagefile;
            }
            var siteSetting = SiteSettingApplication.SiteSettings;
            var shopser     = ServiceProvider.Instance <IShopService> .Create;
            var vshopser    = ServiceProvider.Instance <IVShopService> .Create;
            CardCreateResultJson wxResultJson = new CardCreateResultJson();

            #region 组织数据
            //基础数据
            Card_BaseInfoBase _BaseInfo = new Card_BaseInfoBase()
            {
                logo_url    = wxlogo,
                brand_name  = siteSetting.SiteName,
                code_type   = Card_CodeType.CODE_TYPE_BARCODE,
                title       = info.CardTitle,
                sub_title   = info.CardSubTitle,
                color       = info.CardColor,
                notice      = "专供" + siteSetting.SiteName + "使用",
                description = @"" + (info.LeastCost > 0 ? "满¥" + (info.LeastCost / 100).ToString("F2") + "使用" : "无门槛使用") + ",有效期至" + info.BeginTime.ToString("yyyy年MM月dd日") + "-" + info.EndTime.ToString("yyyy年MM月dd日"),
                date_info   = new Card_BaseInfo_DateInfo()
                {
                    type = Card_DateInfo_Type.DATE_TYPE_FIX_TIME_RANGE.ToString(),
                    // begin_timestamp = DateTimeHelper.GetWeixinDateTime(info.BeginTime),
                    // end_timestamp = DateTimeHelper.GetWeixinDateTime(info.EndTime),
                    begin_timestamp = Senparc.CO2NET.Helpers.DateTimeHelper.GetWeixinDateTime(info.BeginTime),
                    end_timestamp   = Senparc.CO2NET.Helpers.DateTimeHelper.GetWeixinDateTime(info.EndTime),
                },
                sku = new Card_BaseInfo_Sku()
                {
                    quantity = info.Quantity == 0 ? MaxStock : info.Quantity
                },
                get_limit       = info.GetLimit == 0 ? MaxStock : info.GetLimit,
                use_custom_code = false,
                bind_openid     = false,
                can_share       = false,
                can_give_friend = false,
                custom_url_name = "立即使用",
            };
            //代金券数据
            var cardData = new Card_GeneralCouponData()
            {
                base_info      = _BaseInfo,
                default_detail = info.DefaultDetail
            };
            #endregion

            #region 商家发布
            if (info.ShopId > 0)
            {
                _BaseInfo.custom_url = curHost + "/Shop/Home/" + info.ShopId.ToString();
            }
            var vshopSetting = vshopser.GetVShopSetting(info.ShopId);
            var vshopinfo    = vshopser.GetVShopByShopId(info.ShopId);
            var shopinfo     = shopser.GetShop(info.ShopId);

            /*
             * if (vshopSetting != null && shopinfo != null && vshopinfo != null)
             * {
             *  if (!string.IsNullOrWhiteSpace(vshopSetting.AppId) && !string.IsNullOrWhiteSpace(vshopSetting.AppSecret))
             *  {
             *      acctoken = GetAccessToken(vshopSetting.AppId, vshopSetting.AppSecret);
             *      if (!string.IsNullOrWhiteSpace(acctoken))
             *      {
             *          _BaseInfo.brand_name = shopinfo.ShopName;
             *          if (!string.IsNullOrWhiteSpace(vshopinfo.WXLogo))
             *          {
             *              wxlogo = curHost + vshopinfo.WXLogo;
             *              _BaseInfo.logo_url = wxlogo;
             *          }
             *          wxResultJson = CardApi.CreateCard(acctoken, cardData);
             *          if (wxResultJson.errcode == Senparc.Weixin.ReturnCode.请求成功)
             *          {
             *              info.AppId = vshopSetting.AppId;
             *              info.AppSecret = vshopSetting.AppSecret;
             *              info.CardId = wxResultJson.card_id;
             *              issuccess = true;
             *          }
             *          else
             *          {
             *              Log.Debug(JsonConvert.SerializeObject(wxResultJson));
             *          }
             *      }
             *      else
             *      {
             *          Log.Debug("[WXC]Token失败");
             *      }
             *  }
             * }
             */
            #endregion

            if (!issuccess)
            {
                #region 平台发布
                if (!string.IsNullOrWhiteSpace(siteSetting.WeixinAppId) && !string.IsNullOrWhiteSpace(siteSetting.WeixinAppSecret))
                {
                    acctoken = GetAccessToken(siteSetting.WeixinAppId, siteSetting.WeixinAppSecret);
                    if (!string.IsNullOrWhiteSpace(acctoken))
                    {
                        _BaseInfo.brand_name = shopinfo.ShopName;
                        if (!string.IsNullOrWhiteSpace(siteSetting.WXLogo))
                        {
                            wxlogo             = curHost + siteSetting.WXLogo;
                            _BaseInfo.logo_url = wxlogo;
                        }
                        wxResultJson = CardApi.CreateCard(acctoken, cardData);
                        if (wxResultJson.errcode == Senparc.Weixin.ReturnCode.请求成功)
                        {
                            info.AppId     = siteSetting.WeixinAppId;
                            info.AppSecret = siteSetting.WeixinAppSecret;
                            info.CardId    = wxResultJson.card_id;
                            issuccess      = true;
                        }
                        else
                        {
                            Log.Debug(JsonConvert.SerializeObject(wxResultJson));
                        }
                    }
                    else
                    {
                        Log.Debug("[WXC]Token失败");
                    }
                }

                if (info.ShopId < 1)
                {
                    _BaseInfo.custom_url = curHost + "/";
                }
                #endregion
            }

            if (issuccess)
            {
                info.AuditStatus = (int)Entities.WXCardLogInfo.AuditStatusEnum.Auditin;    //初始审核状态
                //数据入库
                DbFactory.Default.Add(info);
            }
            return(issuccess);
        }
コード例 #3
0
ファイル: CardApiTests.cs プロジェクト: hydrogen-dev/SDK
 public void Init()
 {
     instance = new CardApi();
 }
コード例 #4
0
        public CipherRequest(Cipher cipher)
        {
            Type                  = cipher.Type;
            OrganizationId        = cipher.OrganizationId;
            FolderId              = cipher.FolderId;
            Name                  = cipher.Name?.EncryptedString;
            Notes                 = cipher.Notes?.EncryptedString;
            Favorite              = cipher.Favorite;
            LastKnownRevisionDate = cipher.RevisionDate;

            switch (Type)
            {
            case CipherType.Login:
                Login = new LoginApi
                {
                    Uris = cipher.Login.Uris?.Select(
                        u => new LoginUriApi {
                        Match = u.Match, Uri = u.Uri?.EncryptedString
                    }).ToList(),
                    Username             = cipher.Login.Username?.EncryptedString,
                    Password             = cipher.Login.Password?.EncryptedString,
                    PasswordRevisionDate = cipher.Login.PasswordRevisionDate,
                    Totp = cipher.Login.Totp?.EncryptedString
                };
                break;

            case CipherType.Card:
                Card = new CardApi
                {
                    CardholderName = cipher.Card.CardholderName?.EncryptedString,
                    Brand          = cipher.Card.Brand?.EncryptedString,
                    Number         = cipher.Card.Number?.EncryptedString,
                    ExpMonth       = cipher.Card.ExpMonth?.EncryptedString,
                    ExpYear        = cipher.Card.ExpYear?.EncryptedString,
                    Code           = cipher.Card.Code?.EncryptedString
                };
                break;

            case CipherType.Identity:
                Identity = new IdentityApi
                {
                    Title          = cipher.Identity.Title?.EncryptedString,
                    FirstName      = cipher.Identity.FirstName?.EncryptedString,
                    MiddleName     = cipher.Identity.MiddleName?.EncryptedString,
                    LastName       = cipher.Identity.LastName?.EncryptedString,
                    Address1       = cipher.Identity.Address1?.EncryptedString,
                    Address2       = cipher.Identity.Address2?.EncryptedString,
                    Address3       = cipher.Identity.Address3?.EncryptedString,
                    City           = cipher.Identity.City?.EncryptedString,
                    State          = cipher.Identity.State?.EncryptedString,
                    PostalCode     = cipher.Identity.PostalCode?.EncryptedString,
                    Country        = cipher.Identity.Country?.EncryptedString,
                    Company        = cipher.Identity.Company?.EncryptedString,
                    Email          = cipher.Identity.Email?.EncryptedString,
                    Phone          = cipher.Identity.Phone?.EncryptedString,
                    SSN            = cipher.Identity.SSN?.EncryptedString,
                    Username       = cipher.Identity.Username?.EncryptedString,
                    PassportNumber = cipher.Identity.PassportNumber?.EncryptedString,
                    LicenseNumber  = cipher.Identity.LicenseNumber?.EncryptedString
                };
                break;

            case CipherType.SecureNote:
                SecureNote = new SecureNoteApi
                {
                    Type = cipher.SecureNote.Type
                };
                break;

            default:
                break;
            }

            Fields = cipher.Fields?.Select(f => new FieldApi
            {
                Type  = f.Type,
                Name  = f.Name?.EncryptedString,
                Value = f.Value?.EncryptedString
            }).ToList();

            PasswordHistory = cipher.PasswordHistory?.Select(ph => new PasswordHistoryRequest
            {
                Password     = ph.Password?.EncryptedString,
                LastUsedDate = ph.LastUsedDate
            }).ToList();

            if (cipher.Attachments != null)
            {
                Attachments  = new Dictionary <string, string>();
                Attachments2 = new Dictionary <string, AttachmentRequest>();
                foreach (var attachment in cipher.Attachments)
                {
                    var fileName = attachment.FileName?.EncryptedString;
                    Attachments.Add(attachment.Id, fileName);
                    Attachments2.Add(attachment.Id, new AttachmentRequest
                    {
                        FileName = fileName,
                        Key      = attachment.Key?.EncryptedString
                    });
                }
            }
        }
コード例 #5
0
ファイル: Card_wx_add.aspx.cs プロジェクト: PageCard/WeChat
        protected void sub_save_Click(object sender, EventArgs e)
        {
            Model.Card_wx.Card_BaseInfo Fros = new Card_BaseInfo();
            if (Card_type.Text.Length == 0 || title.Text.Length == 0 || brand_name.Text.Length == 0 || imagetext.Text.Length == 0 || Card_color.Text.Length == 0 || notice.Text.Length == 0 || description.InnerText.Length == 0 || time_day.Text.Length == 0 || Cardnumber.Text.Length == 0)
            {
                JscriptMsg("参数不能为空!", "back", "Error");
            }
            else
            {
                _BaseInfo.code_type                 = Senparc.Weixin.MP.Card_CodeType.CODE_TYPE_QRCODE;
                Fros.logo_url                       = MyCommFun.getWebSite() + imagetext.Text;
                _BaseInfo.logo_url                  = MyCommFun.getWebSite() + imagetext.Text.ToString();
                _BaseInfo.brand_name                = brand_name.Text;
                Fros.brand_name                     = brand_name.Text;
                _BaseInfo.title                     = title.Text;
                Fros.title                          = title.Text;
                _BaseInfo.sub_title                 = sub_title.Text;
                Fros.sub_title                      = sub_title.Text;
                _BaseInfo.color                     = Card_color.Text;
                Fros.color                          = Card_color.Text;
                _BaseInfo.notice                    = notice.Text;
                Fros.notice                         = notice.Text;
                _BaseInfo.service_phone             = service_phone.Text;
                Fros.service_phone                  = service_phone.Text;
                _BaseInfo.description               = description.InnerText;
                Fros.description                    = description.InnerText;
                _BaseInfo.date_info.begin_timestamp = DateTimeHelper.GetWeixinDateTime(DateTime.Now);
                Fros.begin_timestamp                = (DateTimeHelper.GetWeixinDateTime(DateTime.Now)).ToString();;
                _BaseInfo.date_info.end_timestamp   = DateTimeHelper.GetWeixinDateTime(DateTime.Now.AddDays(int.Parse(time_day.Text)));
                Fros.end_timestamp                  = time_day.Text.ToString();
                _BaseInfo.sku.quantity              = int.Parse(Cardnumber.Text);
                Fros.quantity                       = int.Parse(Cardnumber.Text);;
                _BaseInfo.use_limit                 = int.Parse(user_limit.Text);
                Fros.use_limit                      = int.Parse(user_limit.Text);
                _BaseInfo.get_limit                 = int.Parse(get_limit.Text);
                Fros.get_limit                      = int.Parse(get_limit.Text);
                _BaseInfo.use_custom_code           = code.Checked;
                Fros.use_custom_code                = code.Checked;
                _BaseInfo.bind_openid               = false;
                Fros.bind_openid                    = false;
                _BaseInfo.can_share                 = share_page.Checked;
                Fros.can_share                      = share_page.Checked;
                _BaseInfo.can_give_friend           = share_card.Checked;
                _BaseInfo.url_name_type             = Senparc.Weixin.MP.Card_UrlNameType.URL_NAME_TYPE_RESERVATION;
                Fros.can_give_friend                = share_card.Checked;
                _BaseInfo.custom_url_name           = url_name.Text;
                Fros.custom_url_name                = url_name.Text;
                _BaseInfo.location_id_list          = fghj();
                _BaseInfo.custom_url_sub_title      = sub_url_name.Text;
                Fros.custom_url_sub_title           = sub_url_name.Text;
                _BaseInfo.custom_url                = custom_url.Text;
                Fros.custom_url                     = custom_url.Text;
                _BaseInfo.promotion_url_name        = pro_url_name.Text;
                Fros.promotion_url_name             = pro_url_name.Text;
                _BaseInfo.promotion_url             = pro_url.Text;
                Fros.promotion_url                  = pro_url.Text;

                if (Card_type.Text == "团购券")
                {
                    Model.wx_userweixin weixin = GetWeiXinCode();
                    int    wid         = weixin.id;
                    string accessToken = Token();
                    var    data        = new Senparc.Weixin.MP.AdvancedAPIs.Card.Card_GrouponData()
                    {
                        base_info   = _BaseInfo,
                        deal_detail = deal_detail.Text.ToString()
                    };
                    BLL.Card_wx.Card_BaseInfo Add = new BLL.Card_wx.Card_BaseInfo();
                    Fros.wid         = wid;
                    Fros.deal_detail = deal_detail.Text;
                    Fros.Card_type   = Card_type.Text;
                    Fros.Paycell     = paycell.Checked;
                    Fros.hexiao      = hexiao.Checked;
                    var result = CardApi.CreateCard(accessToken, data);
                    Fros.Wx_Card_id = result.card_id;
                    Add.Add(Fros);
                    if (paycell.Checked == true)
                    {
                        CardApi.PayCellSet(accessToken, Fros.Wx_Card_id, true);      ///设置微信买单功能
                    }
                    if (hexiao.Checked == true)
                    {
                        CardApi.SelfConsumecellSet(Token(), Fros.Wx_Card_id, true);      ///设置自助核销接口
                    }
                    Console.Write(result);
                    JscriptMsg("添加卡券成功!", "Card_wx_QR.aspx", "Success");
                }
                else if (Card_type.Text == "代金券")
                {
                    Model.wx_userweixin weixin = GetWeiXinCode();
                    int    wid         = weixin.id;
                    string accessToken = Token();
                    var    data        = new Senparc.Weixin.MP.AdvancedAPIs.Card.Card_CashData()
                    {
                        base_info   = _BaseInfo,
                        least_cost  = int.Parse(least_cost.Text),
                        reduce_cost = int.Parse(reduce_cost.Text)
                    };

                    BLL.Card_wx.Card_BaseInfo Add = new BLL.Card_wx.Card_BaseInfo();
                    Fros.wid         = wid;
                    Fros.Card_type   = Card_type.Text;
                    Fros.least_cost  = least_cost.Text;
                    Fros.reduce_cost = reduce_cost.Text;
                    Fros.Paycell     = paycell.Checked;
                    Fros.hexiao      = hexiao.Checked;
                    var result = CardApi.CreateCard(accessToken, data);
                    Fros.Wx_Card_id = result.card_id;
                    Add.Add(Fros);
                    if (paycell.Checked == true)
                    {
                        CardApi.PayCellSet(accessToken, Fros.Wx_Card_id, true);      ///设置微信买单功能
                    }
                    if (hexiao.Checked == true)
                    {
                        CardApi.SelfConsumecellSet(Token(), Fros.Wx_Card_id, true);      ///设置自助核 销接口
                    }
                    Console.Write(result);
                    JscriptMsg("添加卡券成功!", "Card_wx_QR.aspx", "Success");
                }
                else if (Card_type.Text == "折扣券")
                {
                    Model.wx_userweixin weixin = GetWeiXinCode();
                    int    wid         = weixin.id;
                    string accessToken = Token();
                    var    data        = new Senparc.Weixin.MP.AdvancedAPIs.Card.Card_DisCountData()
                    {
                        base_info = _BaseInfo,
                        discount  = float.Parse(discount.Text.ToString())
                    };
                    BLL.Card_wx.Card_BaseInfo Add = new BLL.Card_wx.Card_BaseInfo();
                    Fros.wid       = wid;
                    Fros.Card_type = Card_type.Text;
                    Fros.discount  = discount.Text;
                    Fros.Paycell   = paycell.Checked;
                    Fros.hexiao    = hexiao.Checked;
                    var result = CardApi.CreateCard(accessToken, data);
                    Fros.Wx_Card_id = result.card_id;
                    Add.Add(Fros);
                    if (paycell.Checked == true)
                    {
                        CardApi.PayCellSet(accessToken, Fros.Wx_Card_id, true);      ///设置微信买单功能
                    }
                    if (hexiao.Checked == true)
                    {
                        CardApi.SelfConsumecellSet(Token(), Fros.Wx_Card_id, true);      ///设置自助核销接口
                    }
                    Console.Write(result);
                    JscriptMsg("添加卡券成功!", "Card_wx_QR.aspx", "Success");
                }
                else if (Card_type.Text == "优惠券")
                {
                    Model.wx_userweixin weixin = GetWeiXinCode();
                    int    wid         = weixin.id;
                    string accessToken = Token();
                    var    data        = new Senparc.Weixin.MP.AdvancedAPIs.Card.Card_GeneralCouponData()
                    {
                        base_info      = _BaseInfo,
                        default_detail = default_detail.Text
                    };
                    BLL.Card_wx.Card_BaseInfo Add = new BLL.Card_wx.Card_BaseInfo();
                    Fros.wid            = wid;
                    Fros.Card_type      = Card_type.Text;
                    Fros.default_detail = default_detail.Text;
                    Fros.Paycell        = paycell.Checked;
                    Fros.hexiao         = hexiao.Checked;
                    var result = CardApi.CreateCard(accessToken, data);
                    Fros.Wx_Card_id = result.card_id;
                    Add.Add(Fros);
                    if (paycell.Checked == true)
                    {
                        CardApi.PayCellSet(accessToken, Fros.Wx_Card_id, true);     ///设置微信买单功能
                    }
                    if (hexiao.Checked == true)
                    {
                        CardApi.SelfConsumecellSet(Token(), Fros.Wx_Card_id, true);      ///设置自助核销接口
                    }
                    Console.Write(result);
                    JscriptMsg("添加卡券成功!", "Card_wx_QR.aspx", "Success");
                }
            }
        }
コード例 #6
0
ファイル: WeChatService.cs プロジェクト: iJzFan/backup
        /// <summary>
        /// 创建微信卡券
        /// </summary>
        /// <param name="gift"></param>
        /// <returns></returns>
        public async Task <string> CreateWeChatCardAsync(GiftInputModel gift)
        {
            if (gift.Type == 0)
            {
                return(null);               //实物不创建卡券
            }
            var infoBase = new Card_BaseInfoBase
            {
                brand_name = "天使健康积分平台",

                can_give_friend = false,

                can_share = false,

                color = "Color010",

                code_type = Card_CodeType.CODE_TYPE_QRCODE,

                description = gift.Description,

                logo_url = "http://www.lgstatic.com/thumbnail_300x300/image1/M00/44/07/Cgo8PFXT8p2AIiAvAAAnzQSZgWQ814.png",

                notice = "请出示二维码核销卡券",

                sku = new Card_BaseInfo_Sku
                {
                    quantity = 1000000,

                    total_quantity = 1000000
                }
            };

            var timeStampBegin = new DateTime(1970, 1, 1);

            if (gift.ExpiryDate.HasValue)
            {
                var beginTimestamp = (DateTime.Now.Ticks - timeStampBegin.Ticks) / 10000000;

                var endTimestamp = (DateTime.MaxValue.Ticks - timeStampBegin.Ticks) / 10000000;

                infoBase.date_info = new Card_BaseInfo_DateInfo {
                    begin_timestamp = beginTimestamp, end_timestamp = endTimestamp, type = "1"
                };
            }
            if (gift.AvailableDays.HasValue)
            {
                infoBase.date_info = new Card_BaseInfo_DateInfo {
                    fixed_begin_term = 0, fixed_term = gift.AvailableDays.Value, type = "2"
                };
            }

            if (gift.Type == 1)//满减类
            {
                infoBase.title = $"¥{gift.DiscountPrice} 代金券";

                var cardInfo = new Card_CashData
                {
                    least_cost = (int)(gift.OrderLimit.Value * 100),

                    reduce_cost = (int)(gift.DiscountPrice.Value * 100),

                    base_info = infoBase
                };

                var result = await CardApi.CreateCardAsync(_wxParams.AppId, cardInfo);

                return(result.card_id);
            }

            if (gift.Type == 2)//打折类
            {
                infoBase.title = $"{(long)gift.DiscountPrice.Value * 100}折 折扣券";

                if (gift.OrderLimit.HasValue)
                {
                    infoBase.title = $"满¥{(long)gift.OrderLimit}打{(long)gift.DiscountPrice.Value * 100}折";
                }
                else
                {
                    infoBase.title = $"{(long)gift.DiscountPrice.Value * 100}折优惠券";
                }

                var discount = 100L - (long)gift.DiscountRate.Value * 100;

                var cardInfo = new Card_DisCountData {
                    discount = discount
                };

                var result = await CardApi.CreateCardAsync(_wxParams.AppId, cardInfo);

                return(result.card_id);
            }

            return(null);
        }
コード例 #7
0
ファイル: FormWriteCard.cs プロジェクト: gaokaige/SmartGC
 public FormWriteCard(CardApi _api)
 {
     InitializeComponent();
     //tbxCardNo.Text = "CA0021FEFEFEFE000" + Common.GetRandomCardNo();
     api = _api;
 }
コード例 #8
0
ファイル: Card_wx_QR.aspx.cs プロジェクト: PageCard/WeChat
        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");
            }
        }
コード例 #9
0
        async Task <bool> EncodeDrivingLicense(ITask obj)
        {
            var o           = (DrivingLicense)obj;
            var holderPhoto = o.Holder.PhotoData;

            if (!String.IsNullOrEmpty(holderPhoto))
            {
                var photoData = Convert.FromBase64String(holderPhoto);
                using (var image = new MagickImage(photoData))
                {
                    image.Quality = 80;
                    image.Resize(275, 0);
                    o.Holder.PhotoData = image.ToBase64(MagickFormat.Jpeg);
                }
            }

            var holderSign = o.Holder.SignatureData;

            if (!String.IsNullOrEmpty(holderSign))
            {
                var signData = Convert.FromBase64String(holderSign);
                using (var image = new MagickImage(signData))
                {
                    image.Quality = 90;
                    image.Resize(165, 0);
                    image.BackgroundColor = MagickColors.White;
                    image.ColorAlpha(MagickColors.White);
                    o.Holder.SignatureData = image.ToBase64(MagickFormat.Jpeg);
                }
            }

            var jss = new JsonSerializerSettings
            {
                ContractResolver     = new DlPostContractResolver("card"),
                DateTimeZoneHandling = DateTimeZoneHandling.Local,
                DateFormatString     = "yyyyMMdd"
            };
            var json = JsonConvert.SerializeObject(o, Formatting.Indented, jss);

            int    rsCode;
            string cardSn;

            try
            {
                rsCode = await CardApi.WriteDriverInfo(json);

                cardSn = await CardApi.ReadUUidAsync();
            }
            catch
            {
                CurrentProdLine.SetPrinterPosition("RejectPosition");
                rtbLog.AppendText(String.Format(Texts.CardEncodingError, DateTime.Now.ToString("G")));
                rtbLog.AppendText(Environment.NewLine);
                return(false);
            }

            if (rsCode != 0)
            {
                CurrentProdLine.SetPrinterPosition("RejectPosition");
                rtbLog.AppendText(String.Format(Texts.CardEncodingError, DateTime.Now.ToString("G")));
                rtbLog.AppendText(Environment.NewLine);
                return(false);
            }

            o.CardSn               = cardSn;
            o.Holder.PhotoData     = holderPhoto;
            o.Holder.SignatureData = holderSign;
            return(true);
        }