Subversion Repositories SmartDukaan

Rev

Rev 15238 | Rev 20499 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 15238 Rev 15272
Line 2... Line 2...
2
 
2
 
3
import java.util.List;
3
import java.util.List;
4
 
4
 
5
import org.apache.log4j.Logger;
5
import org.apache.log4j.Logger;
6
 
6
 
-
 
7
import in.shop2020.dtrapi.Storage.Mongo;
-
 
8
import in.shop2020.dtrapi.models.MasterData;
7
import in.shop2020.dtrapi.services.UserMessagePojo;
9
import in.shop2020.dtrapi.services.UserMessagePojo;
8
import in.shop2020.model.v1.dtr.DtrService.Client;
10
import in.shop2020.model.v1.dtr.DtrService.Client;
9
import in.shop2020.thrift.clients.DtrClient;
11
import in.shop2020.thrift.clients.DtrClient;
10
 
12
 
11
import com.google.gson.Gson;
13
import com.google.gson.Gson;
-
 
14
import com.mongodb.DBObject;
12
import com.mongodb.util.JSON;
15
import com.mongodb.util.JSON;
13
 
16
 
14
 
17
 
15
public class LivePricingController extends BaseController{
18
public class LivePricingController extends BaseController{
16
	private static Logger log = Logger.getLogger(Class.class);
19
	private static Logger log = Logger.getLogger(Class.class);
Line 53... Line 56...
53
			dc = new DtrClient();
56
			dc = new DtrClient();
54
			dc.getClient().updateLatestPriceForItem(Long.valueOf(id));
57
			dc.getClient().updateLatestPriceForItem(Long.valueOf(id));
55
			if (Long.valueOf(source_id) == 3){
58
			if (Long.valueOf(source_id) == 3){
56
				SnapdealProductPageParserController spp = new SnapdealProductPageParserController();
59
				SnapdealProductPageParserController spp = new SnapdealProductPageParserController();
57
				spp.setUrl(url);
60
				spp.setUrl(url);
58
				setResultJson(spp.getColorMessage());
61
				UserMessagePojo ump_color = spp.getColorMessage();
-
 
62
				UserMessagePojo ump_seller = getSellerMessage(Long.valueOf(id));
-
 
63
				ump.setResult(ump_color.isResult() || ump_seller.isResult());
-
 
64
				ump.setMessage(ump_color.getMessage()+ump_seller.getMessage());
-
 
65
				setResultJson(ump);
-
 
66
			}
-
 
67
			else if(Long.valueOf(source_id) == 2){
-
 
68
				setResultJson(getSellerMessage(Long.valueOf(id)));
59
			}
69
			}
60
			else{
70
			else{
61
				throw new Exception();
71
				throw new Exception();
62
			}
72
			}
63
		} catch (Exception e) {
73
		} catch (Exception e) {
Line 66... Line 76...
66
		finally{
76
		finally{
67
			dc.closeConnection();
77
			dc.closeConnection();
68
		}
78
		}
69
		return "index";
79
		return "index";
70
	}
80
	}
-
 
81
	
-
 
82
	private UserMessagePojo getSellerMessage(long item_id){
-
 
83
		UserMessagePojo ump = new UserMessagePojo();
-
 
84
		ump.setMessage("");
-
 
85
		ump.setResult(false);
-
 
86
		MasterData result;
-
 
87
		try {
-
 
88
			result = Mongo.getItemByID(item_id);
-
 
89
		} catch (Exception e) {
-
 
90
			return ump;
-
 
91
		}
-
 
92
		if (result.getBuyBoxFlag()==0){
-
 
93
			ump.setResult(true);
-
 
94
			ump.setMessage("Check all sellers to get this price");
-
 
95
		}
-
 
96
		return ump;
-
 
97
	}
71
 
98
 
72
	public String getSkuBundleId() {
99
	public String getSkuBundleId() {
73
		return skuBundleId;
100
		return skuBundleId;
74
	}
101
	}
75
 
102
 
76
 
-
 
77
	public void setSkuBundleId(String skuBundleId) {
103
	public void setSkuBundleId(String skuBundleId) {
78
		this.skuBundleId = skuBundleId;
104
		this.skuBundleId = skuBundleId;
79
	}
105
	}
80
 
106
 
81
	public String getSource_id() {
107
	public String getSource_id() {
Line 103... Line 129...
103
	}
129
	}
104
	
130
	
105
 
131
 
106
	public static void main (String[] args){
132
	public static void main (String[] args){
107
		LivePricingController live = new LivePricingController();
133
		LivePricingController live = new LivePricingController();
108
		live.setId("84");
-
 
109
		live.setUrl("aHR0cDovL20uc25hcGRlYWwuY29tL3Byb2R1Y3Qvc3BpY2UtYm9zcy1lbnRlcnRhaW5lci0zLW01NDA2LzEwNTA2ODk2MjM/c3VwYz1TREw3MDA0MzYzMTUmdXRtX3NvdXJjZT1hZmZfcHJvZyZ1dG1fY2FtcGFpZ249YWZ0cyZvZmZlcl9pZD0xNyZhZmZfaWQ9MTc5MTUmYWZmX3N1Yj1TSEEzMTQzMTY3NzM0NQ==");
-
 
110
		live.setSource_id("3");
134
		live.getSellerMessage(10000000);
111
		live.latestPriceById();
-
 
112
		System.out.println(live.getResultJson());
-
 
113
	}
135
	}
114
	
136
	
115
}
137
}