Subversion Repositories SmartDukaan

Rev

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

Rev 15164 Rev 15183
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.services.UserMessagePojo;
7
import in.shop2020.model.v1.dtr.DtrService.Client;
8
import in.shop2020.model.v1.dtr.DtrService.Client;
8
import in.shop2020.thrift.clients.DtrClient;
9
import in.shop2020.thrift.clients.DtrClient;
9
 
10
 
10
import com.google.gson.Gson;
11
import com.google.gson.Gson;
11
import com.mongodb.util.JSON;
12
import com.mongodb.util.JSON;
12
 
13
 
13
 
14
 
14
public class LivePricingController extends BaseController{
15
public class LivePricingController extends BaseController{
15
    private static Logger log = Logger.getLogger(Class.class);
16
	private static Logger log = Logger.getLogger(Class.class);
16
    
17
 
17
    private static final long serialVersionUID = 1L;
18
	private static final long serialVersionUID = 1L;
18
    
19
 
19
    private String skuBundleId;
20
	private String skuBundleId;
20
    private String source_id;
21
	private String source_id;
21
    private String id;
22
	private String id;
22
    
23
	private String url;
23
 
24
 
24
    public String index(){
25
	public String index(){
25
        Gson gs = new Gson();
26
		Gson gs = new Gson();
26
        Client dc = null;
27
		Client dc = null;
27
        try {
28
		try {
28
            dc = new DtrClient().getClient();
29
			dc = new DtrClient().getClient();
29
            List<in.shop2020.model.v1.dtr.LivePricing> pricingObj = dc.getLatestPricing(Long.valueOf(skuBundleId), Long.valueOf(source_id));
30
			List<in.shop2020.model.v1.dtr.LivePricing> pricingObj = dc.getLatestPricing(Long.valueOf(skuBundleId), Long.valueOf(source_id));
30
            setResultJson(JSON.parse(gs.toJson(pricingObj)).toString());
31
			setResultJson(JSON.parse(gs.toJson(pricingObj)).toString());
31
        } catch (Exception e) {
32
		} catch (Exception e) {
32
            log.info(e);
33
			log.info(e);
33
        }
34
		}
34
        return "index";
35
		return "index";
35
    }
36
	}
36
    
37
 
37
    public String latestPriceById(){
38
	public String latestPriceById(){
38
    	Client dc = null;
39
		Client dc = null;
39
    	try {
40
		try {
40
            dc = new DtrClient().getClient();
41
			dc = new DtrClient().getClient();
41
            dc.updateLatestPriceForItem(Long.valueOf(id));
42
			dc.updateLatestPriceForItem(Long.valueOf(id));
-
 
43
			if (Long.valueOf(source_id) == 3){
-
 
44
				SnapdealProductPageParserController spp = new SnapdealProductPageParserController();
-
 
45
				spp.setUrl(url);
-
 
46
				spp.getColorMessage();
-
 
47
			}
-
 
48
			else{
42
            setResultJson("{1:'Updated Successfully'}");
49
				UserMessagePojo ump = new UserMessagePojo();
-
 
50
				ump.setMessage("");
-
 
51
				ump.setResult(false);
-
 
52
				setResultJson(ump);
-
 
53
			}
43
        } catch (Exception e) {
54
		} catch (Exception e) {
44
            log.info(e);
55
			log.info(e);
45
            setResultJson("{0:'Unable to update'}");
-
 
46
        }
56
		}
47
        return "index";
57
		return "index";
48
   
58
 
49
    }
59
	}
50
    
60
 
51
    public String getSkuBundleId() {
61
	public String getSkuBundleId() {
52
        return skuBundleId;
62
		return skuBundleId;
53
    }
63
	}
54
 
64
 
55
 
65
 
56
    public void setSkuBundleId(String skuBundleId) {
66
	public void setSkuBundleId(String skuBundleId) {
57
        this.skuBundleId = skuBundleId;
67
		this.skuBundleId = skuBundleId;
58
    }
68
	}
59
    
69
 
60
    public String getSource_id() {
70
	public String getSource_id() {
61
        return source_id;
71
		return source_id;
62
    }
72
	}
63
 
73
 
64
    public void setSource_id(String source_id) {
74
	public void setSource_id(String source_id) {
65
        this.source_id = source_id;
75
		this.source_id = source_id;
66
    }
76
	}
67
 
77
 
68
	public void setId(String id) {
78
	public void setId(String id) {
69
		this.id = id;
79
		this.id = id;
70
	}
80
	}
71
 
81
 
72
	public String getId() {
82
	public String getId() {
73
		return id;
83
		return id;
74
	}
84
	}
-
 
85
 
-
 
86
	public String getUrl() {
-
 
87
		return url;
75
	
88
	}
-
 
89
 
-
 
90
	public void setUrl(String url) {
-
 
91
		this.url = url;
-
 
92
	}
-
 
93
 
76
	public static void main (String[] args){
94
	public static void main (String[] args){
77
		LivePricingController live = new LivePricingController();
95
		LivePricingController live = new LivePricingController();
78
		live.setId("84");
96
		live.setId("84");
79
		live.latestPriceById();
97
		live.latestPriceById();
80
		System.out.println(live.getResultJson());
98
		System.out.println(live.getResultJson());