123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137 |
- package com.tencent.protocol.downloadbill_protocol;
- import com.tencent.common.Configure;
- import com.tencent.common.RandomStringGenerator;
- import com.tencent.common.Signature;
- import java.lang.reflect.Field;
- import java.util.HashMap;
- import java.util.Map;
- /**
- * User: rizenguo
- * Date: 2014/10/25
- * Time: 16:48
- */
- public class DownloadBillReqData {
- //每个字段具体的意思请查看API文档
- private String appid = "";
- private String mch_id = "";
- private String device_info = "";
- private String nonce_str = "";
- private String sign = "";
- private String bill_date = "";
- private String bill_type = "";
- /**
- * 请求对账单下载服务
- * @param deviceInfo 商户自己定义的扫码支付终端设备号,方便追溯这笔交易发生在哪台终端设备上
- * @param billDate 下载对账单的日期,格式:yyyyMMdd 例如:20140603
- * @param billType 账单类型
- * ALL,返回当日所有订单信息,默认值
- SUCCESS,返回当日成功支付的订单
- REFUND,返回当日退款订单
- REVOKED,已撤销的订单
- */
- public DownloadBillReqData(String deviceInfo,String billDate,String billType){
- //微信分配的公众号ID(开通公众号之后可以获取到)
- setAppid(Configure.getAppid());
- //微信支付分配的商户号ID(开通公众号的微信支付功能之后可以获取到)
- setMch_id(Configure.getMchid());
- //商户自己定义的扫码支付终端设备号,方便追溯这笔交易发生在哪台终端设备上
- setDevice_info(deviceInfo);
- setBill_date(billDate);
- setBill_type(billType);
- //随机字符串,不长于32 位
- setNonce_str(RandomStringGenerator.getRandomStringByLength(32));
- //根据API给的签名规则进行签名
- String sign = Signature.getSign(toMap());
- setSign(sign);//把签名数据设置到Sign这个属性中
- }
- public String getAppid() {
- return appid;
- }
- public void setAppid(String appid) {
- this.appid = appid;
- }
- public String getMch_id() {
- return mch_id;
- }
- public void setMch_id(String mch_id) {
- this.mch_id = mch_id;
- }
- public String getDevice_info() {
- return device_info;
- }
- public void setDevice_info(String device_info) {
- this.device_info = device_info;
- }
- public String getNonce_str() {
- return nonce_str;
- }
- public void setNonce_str(String nonce_str) {
- this.nonce_str = nonce_str;
- }
- public String getSign() {
- return sign;
- }
- public void setSign(String sign) {
- this.sign = sign;
- }
- public String getBill_date() {
- return bill_date;
- }
- public void setBill_date(String bill_date) {
- this.bill_date = bill_date;
- }
- public String getBill_type() {
- return bill_type;
- }
- public void setBill_type(String bill_type) {
- this.bill_type = bill_type;
- }
- public Map<String,Object> toMap(){
- Map<String,Object> map = new HashMap<String, Object>();
- Field[] fields = this.getClass().getDeclaredFields();
- for (Field field : fields) {
- Object obj;
- try {
- obj = field.get(this);
- if(obj!=null){
- map.put(field.getName(), obj);
- }
- } catch (IllegalArgumentException e) {
- e.printStackTrace();
- } catch (IllegalAccessException e) {
- e.printStackTrace();
- }
- }
- return map;
- }
- }
|