public List<card_info> GetCardlist(card_status status, int offset, int count) { card_id_list_data id_list = this.GetCardIdlist(status, offset, count); if (id_list == null) return null; if (id_list.no_error == false) throw new sns_api_exception(id_list); List<card_info> card_list = new List<card_info>(id_list.card_id_list.Count); for (int i = 0; i < id_list.card_id_list.Count; i++) { card_info card = null; try { card = this.GetCardInfoById(id_list.card_id_list[i]); } catch(Exception ex) { continue; } if(card != null) { card_list.Add(card); } } return card_list; }
public static string get_card_status_string(card_status status) { switch(status) { case card_status.CARD_STATUS_DISPATCH: return "已投放"; case card_status.CARD_STATUS_VERIFY_OK: return "待投放"; case card_status.CARD_STATUS_VERIFY_FALL: return "审核失败"; case card_status.CARD_STATUS_NOT_VERIFY: return "待审核"; case card_status.CARD_STATUS_USER_DELETE: return "用户删除"; case card_status.CARD_STATUS_USER_DISPATCH: return "已投放"; default: return "未知状态"; } }
public card_id_list_data GetCardIdlist(card_status status, int offset, int count) { access_token_data token_obj = this.GetAccessToken(); if (token_obj == null) return null; if (token_obj.no_error == false) throw new sns_api_exception(token_obj); card_list_arg post_arg_obj = new card_list_arg(); post_arg_obj.count = count; post_arg_obj.offset = offset; post_arg_obj.status_list = new List<string>(); if((status & card_status.CARD_STATUS_DISPATCH) > 0) { post_arg_obj.status_list.Add("CARD_STATUS_DISPATCH"); } if((status & card_status.CARD_STATUS_VERIFY_OK) > 0) { post_arg_obj.status_list.Add("CARD_STATUS_VERIFY_OK"); } if((status & card_status.CARD_STATUS_VERIFY_FALL) > 0) { post_arg_obj.status_list.Add("CARD_STATUS_VERIFY_FALL"); } if((status & card_status.CARD_STATUS_NOT_VERIFY) > 0) { post_arg_obj.status_list.Add("CARD_STATUS_NOT_VERIFY"); } string post_data = JsonConvert.SerializeObject(post_arg_obj); string response_data = GetResponseStringByPost(string.Format("https://api.weixin.qq.com/card/batchget?access_token={0}", token_obj.access_token), post_data); card_id_list_data list_obj = JsonConvert.DeserializeObject<card_id_list_data>(response_data); if (list_obj == null) return null; if (list_obj.no_error == false) throw new sns_api_exception(list_obj); return list_obj; }