RecycleChannelAccount.java 11.1 KB
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454
package com.reyun.model;

import com.reyun.service.impl.RecycleUcttServiceImpl;
import com.reyun.util.StringUtil;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import javax.persistence.*;
import java.net.URLDecoder;
import java.net.URLEncoder;
import java.nio.charset.Charset;
import java.util.ArrayList;
import java.util.Base64;
import java.util.Date;
import java.util.List;

/**
 * Created by sunhao on 18/5/16.
 * 回本分析渠道账号
 * ps:广点通,神马此处只存账号信息(即从页面上应用了账号之后,把channel_account的账号信息拷贝过来,用作lizard程序扫描需要爬取的账号)。
 *    具体的token和refresh token按照原来的方式维护。
 */
@Entity
public class RecycleChannelAccount {

    private Logger logger = LoggerFactory.getLogger(RecycleChannelAccount.class);


    public final static String LOGIN_CHECK_PHONE = "1";//login_check的type=1为手机验证
    public final static String LOGIN_CHECK_QUESTION = "2";//login_check的type=2为问题验证

    public final static int CHANNEL_LIMIT = 3;//非付费用户(或者过期未续费)的账号限制
    public final static int VALID_FLAG_VALID = 1;  //对应validFlag字段
    public final static int VALID_FLAG_INVALID = 0;

    private Long id;

    private Long account;

    private Long rootAccount = 0L;
    //渠道ID
    private Long cid = 0L ;
    //渠道唯一标示
    private String uniqueName;
    //渠道名称
    private String channelName;
    //渠道别名
    private String channelAlias;
    //账户名
    private String userName;
    //密码
    private String password;
    //渠道账号ID
    private String channelAccountId;
    //token
    private String token;
    //token有效期
    private Long tokenExpire;
    //refresh token
    private String refreshToken;
    //refresh token有效期
    private Long refreshTokenExpire;

    private Date insertDate;

    private Date modifyDate;//存储token刷新时间
    //账号状态
    private Integer status;

    //账号授权方式   1.爬虫 
    private Integer tpye;

    //Transient
    //第一级推广数量
    private Long firstLevelNumber;
    //第二级推广数量
    private Long secondLevelNumber;
    //第三级推广数量
    private Long thirdLevelNumber;
    //虚拟账户金额
    private Double virtualAccountAmount;
    //现金账户金额
    private Double cashAccountAmount;

    //登陆凭证(目前存储cookie)
    private String loginLicense;
    //    登陆校验的信息,格式如下:(type=1的只是前端传入校验用的,不做存储,type=2的存储)
//{
//    "type": 1,
//        "content": {
//    "mobile ": "18310832936 ",
//            "vcode ": "456 "
//}
//}
//
//    {
//        "type": 2,
//            "content": {
//        "id": "1",
//                "question ": "你的爱好是什么?",
//                "answer": "王者荣耀"
//    }
//    }
    private String loginCheck;

    private String uniqueAccount = "0";//唯一的账户值(级联数据获取的账户值,api渠道是channel_account_id,爬虫的是user_name)

    private String loginFailMes = "0";//账号失效的原因

    private String n;//存储前端传递的账号(base64处理)

    private String w;//存储前端传递的密码(base64处理)

    private int validFlag = 1;//登陆有效标记:1有效  0无效

    private String mcCid;//用于区分一个账号下多个渠道的情况

    private String mcUniqueName;//多渠道对应的渠道id,中间用逗号分隔(如百度)

    private Date utime;//修改时间

    public RecycleChannelAccount(){}

    public RecycleChannelAccount(ChannelAccount channelAccount){

        this.channelAlias = channelAccount.getAlias();
        this.uniqueName = channelAccount.getUniqueName();
        this.channelAccountId = channelAccount.getThirdAccountCode();
        this.token = channelAccount.getAccessToken();
        this.userName = channelAccount.getName();
        this.cid = channelAccount.getChannel();
        
        this.refreshToken = channelAccount.getRefreshToken();
        this.tokenExpire = channelAccount.getAccessTokenExpire();
        this.refreshTokenExpire = channelAccount.getRefreshTokenExpire();
    }

    @Id
    @GeneratedValue
    public Long getId() {
        return id;
    }

    public void setId(Long id) {
        this.id = id;
    }

    public Long getAccount() {
        return account;
    }

    public void setAccount(Long account) {
        this.account = account;
    }

    public Long getRootAccount() {
        return rootAccount;
    }

    public void setRootAccount(Long rootAccount) {
        this.rootAccount = rootAccount;
    }

    public Long getCid() {
        return cid;
    }

    public void setCid(Long cid) {
        this.cid = cid;
    }

    public String getUniqueName() {
        return uniqueName;
    }

    public void setUniqueName(String uniqueName) {
        this.uniqueName = uniqueName;
    }

    public String getChannelName() {
        return channelName;
    }

    public void setChannelName(String channelName) {
        this.channelName = channelName;
    }

    public String getChannelAlias() {
        return channelAlias;
    }

    public void setChannelAlias(String channelAlias) {
        try{
            this.channelAlias = URLDecoder.decode(channelAlias, "utf-8");
        }catch (Exception e){
            this.channelAlias = channelAlias;
        }
    }

    public String getUserName() {
        return userName;
    }

    public void setUserName(String userName) {

        try{
            if(!StringUtil.isEmpty(userName)){
                this.userName = URLDecoder.decode(userName, "utf-8");
            }
        }catch (Exception e){
            logger.info("记录解码错误的原始信息:userName:{} ",userName,e);
        }
    }

    public String getPassword() {
        return password;
    }

    public void setPassword(String password) {
        this.password = password;
    }

    public String getChannelAccountId() {
        return channelAccountId;
    }

    public void setChannelAccountId(String channelAccountId) {
        this.channelAccountId = channelAccountId;
    }

    public String getToken() {
        return token;
    }

    public void setToken(String token) {
        this.token = token;
    }

    public Long getTokenExpire() {
        return tokenExpire;
    }

    public void setTokenExpire(Long tokenExpire) {
        this.tokenExpire = tokenExpire;
    }

    public String getRefreshToken() {
        return refreshToken;
    }

    public void setRefreshToken(String refreshToken) {
        this.refreshToken = refreshToken;
    }

    public Long getRefreshTokenExpire() {
        return refreshTokenExpire;
    }

    public void setRefreshTokenExpire(Long refreshTokenExpire) {
        this.refreshTokenExpire = refreshTokenExpire;
    }

    public Date getInsertDate() {
        return insertDate;
    }

    public void setInsertDate(Date insertDate) {
        this.insertDate = insertDate;
    }

    public Date getModifyDate() {
        return modifyDate;
    }

    public void setModifyDate(Date modifyDate) {
        this.modifyDate = modifyDate;
    }

    public Integer getStatus() {
        return status;
    }

    public void setStatus(Integer status) {
        this.status = status;
    }

    @Transient
    public Integer getTpye() {
        return tpye;
    }

    public void setTpye(Integer tpye) {
        this.tpye = tpye;
    }

    @Transient
    public Long getFirstLevelNumber() {
        return firstLevelNumber;
    }

    public void setFirstLevelNumber(Long firstLevelNumber) {
        this.firstLevelNumber = firstLevelNumber;
    }

    @Transient
    public Long getSecondLevelNumber() {
        return secondLevelNumber;
    }

    public void setSecondLevelNumber(Long secondLevelNumber) {
        this.secondLevelNumber = secondLevelNumber;
    }

    @Transient
    public Long getThirdLevelNumber() {
        return thirdLevelNumber;
    }

    public void setThirdLevelNumber(Long thirdLevelNumber) {
        this.thirdLevelNumber = thirdLevelNumber;
    }

    @Transient
    public Double getVirtualAccountAmount() {
        return virtualAccountAmount;
    }

    public void setVirtualAccountAmount(Double virtualAccountAmount) {
        this.virtualAccountAmount = virtualAccountAmount;
    }

    @Transient
    public Double getCashAccountAmount() {
        return cashAccountAmount;
    }

    public void setCashAccountAmount(Double cashAccountAmount) {
        this.cashAccountAmount = cashAccountAmount;
    }

    public String getLoginLicense() {
        return loginLicense;
    }

    public void setLoginLicense(String loginLicense) {
        this.loginLicense = loginLicense;
    }

    public String getLoginCheck() {
        return loginCheck;
    }

    public void setLoginCheck(String loginCheck) {
        this.loginCheck = loginCheck;
    }

    public String getUniqueAccount() {
        return uniqueAccount;
    }

    public void setUniqueAccount(String uniqueAccount) {
        this.uniqueAccount = uniqueAccount;
    }

    public String getLoginFailMes() {
        return loginFailMes;
    }

    public void setLoginFailMes(String loginFailMes) {
        this.loginFailMes = loginFailMes;
    }

    @Transient
    public String getN() {
        return n;
    }

    public void setN(String n) {

            this.n = n;
            try{
                if(!StringUtil.isEmpty(n)){
                    String base64Name = new String(Base64.getDecoder().decode(n));
                    this.userName = URLDecoder.decode(base64Name, "utf-8");
                }
            }catch (Exception e){
                logger.info("记录解码错误的原始信息:n:{} e:{}",n,e);
            }

    }

    @Transient
    public String getW() {
        return w;
    }

    public void setW(String w) {

            this.w = w;//new String(w.getBytes("ISO8859-1"),"utf-8")
            try{
                if(!StringUtil.isEmpty(w)){
                   String base64Password = new String(Base64.getDecoder().decode(w));
                    this.password = URLDecoder.decode(base64Password, "utf-8");
                }
            }catch (Exception e){
                logger.info("记录解码错误的原始信息:w:{} e:{}",w,e);
            }
    }

    public int getValidFlag() {
        return validFlag;
    }

    public void setValidFlag(int validFlag) {
        this.validFlag = validFlag;
    }

    @Transient
    public String getMcCid() {
        return mcCid;
    }

    public void setMcCid(String mcCid) {
        this.mcCid = mcCid;
    }

    @Transient
    public String getMcUniqueName() {
        return mcUniqueName;
    }

    public void setMcUniqueName(String mcUniqueName) {
        this.mcUniqueName = mcUniqueName;
    }

    public Date getUtime() {
        return utime;
    }

    public void setUtime(Date utime) {
        this.utime = utime;
    }

    public static void main(String[] args){
        List<Long> cids = new ArrayList<>();
        cids.add(8999L);
        cids.add(530L);
        boolean cidIsExist = cids.contains(8999L);

        Double t = (Double)35266.43;

        System.out.println("--------------"+t);
    }
}