| | |
| | | import com.google.gson.Gson;
|
| | | import com.google.gson.GsonBuilder;
|
| | | import com.google.gson.reflect.TypeToken;
|
| | | import com.yeshi.fanli.entity.bus.user.CollectionGoods;
|
| | | import com.yeshi.fanli.entity.bus.user.UserInfo;
|
| | | import com.yeshi.fanli.entity.common.ImageInfo;
|
| | | import com.yeshi.fanli.entity.goods.CommonGoods;
|
| | | import com.yeshi.fanli.entity.taobao.ScanHistory;
|
| | |
| | | return tb;
|
| | | }
|
| | |
|
| | | public static TaoBaoGoodsBrief getTaoBaoGoodsBrief(CollectionGoods sh) {
|
| | | TaoBaoGoodsBrief tb = new TaoBaoGoodsBrief();
|
| | | Field[] fields = tb.getClass().getDeclaredFields();
|
| | | Field[] shFields = sh.getClass().getDeclaredFields();
|
| | | for (int i = 0; i < fields.length; i++) {
|
| | | Field field = fields[i];
|
| | | field.setAccessible(true);
|
| | | try {
|
| | | for (Field target : shFields) {
|
| | | target.setAccessible(true);
|
| | | if (target.getName().equalsIgnoreCase(field.getName())) {
|
| | | if (!"createtime".equalsIgnoreCase(field.getName()))
|
| | | field.set(tb, target.get(sh));
|
| | | break;
|
| | | }
|
| | | }
|
| | | } catch (IllegalArgumentException e) {
|
| | | e.printStackTrace();
|
| | | } catch (IllegalAccessException e) {
|
| | | e.printStackTrace();
|
| | | }
|
| | | }
|
| | | return tb;
|
| | | }
|
| | |
|
| | | public static ScanHistory getScanHistory(TaoBaoGoodsBrief tb) {
|
| | | ScanHistory sh = new ScanHistory();
|
| | |
| | | return taoBaoGoodsBrief;
|
| | | }
|
| | |
|
| | | public static CollectionGoods getCollectionGoods(long auctionId, UserInfo userInfo) {
|
| | | TaoBaoGoodsBrief taoBaoGoodsBrief = null;
|
| | | try {
|
| | | taoBaoGoodsBrief = TaoKeApiUtil.searchGoodsDetail(auctionId);
|
| | | } catch (TaobaoGoodsDownException e1) {
|
| | | e1.printStackTrace();
|
| | | }
|
| | | CollectionGoods collectionGoods = new CollectionGoods();
|
| | | Field[] fields = taoBaoGoodsBrief.getClass().getDeclaredFields();
|
| | | Field[] shFields = collectionGoods.getClass().getDeclaredFields();
|
| | | for (int i = 0; i < fields.length; i++) {
|
| | | Field field = fields[i];
|
| | | field.setAccessible(true);
|
| | | try {
|
| | | for (Field target : shFields) {
|
| | | target.setAccessible(true);
|
| | | if (target.getName().equalsIgnoreCase(field.getName())) {
|
| | | if (!field.getName().equalsIgnoreCase("createTime"))
|
| | | target.set(collectionGoods, field.get(taoBaoGoodsBrief));
|
| | | break;
|
| | | }
|
| | | }
|
| | | } catch (IllegalArgumentException e) {
|
| | | e.printStackTrace();
|
| | | } catch (IllegalAccessException e) {
|
| | | e.printStackTrace();
|
| | | }
|
| | | }
|
| | | collectionGoods.setUserInfo(userInfo);
|
| | | return collectionGoods;
|
| | | }
|
| | |
|
| | | public static CollectionGoods getCollectionGoods(TaoBaoGoodsBrief taoBaoGoodsBrief, UserInfo userInfo) {
|
| | | if (taoBaoGoodsBrief == null)
|
| | | return null;
|
| | |
|
| | | CollectionGoods collectionGoods = new CollectionGoods();
|
| | | Field[] fields = taoBaoGoodsBrief.getClass().getDeclaredFields();
|
| | | Field[] shFields = collectionGoods.getClass().getDeclaredFields();
|
| | | for (int i = 0; i < fields.length; i++) {
|
| | | Field field = fields[i];
|
| | | field.setAccessible(true);
|
| | | try {
|
| | | for (Field target : shFields) {
|
| | | target.setAccessible(true);
|
| | | if (target.getName().equalsIgnoreCase(field.getName())) {
|
| | | if (!field.getName().equalsIgnoreCase("createTime"))
|
| | | target.set(collectionGoods, field.get(taoBaoGoodsBrief));
|
| | | break;
|
| | | }
|
| | | }
|
| | | } catch (IllegalArgumentException e) {
|
| | | e.printStackTrace();
|
| | | } catch (IllegalAccessException e) {
|
| | | e.printStackTrace();
|
| | | }
|
| | | }
|
| | | collectionGoods.setUserInfo(userInfo);
|
| | | return collectionGoods;
|
| | | }
|
| | |
|
| | | /**
|
| | | * 获取商品的用户分成比例
|