| Line 8... |
Line 8... |
| 8 |
import in.shop2020.model.v1.catalog.SnapdealItem;
|
8 |
import in.shop2020.model.v1.catalog.SnapdealItem;
|
| 9 |
import in.shop2020.model.v1.catalog.SnapdealItemDetails;
|
9 |
import in.shop2020.model.v1.catalog.SnapdealItemDetails;
|
| 10 |
import in.shop2020.model.v1.inventory.InventoryServiceException;
|
10 |
import in.shop2020.model.v1.inventory.InventoryServiceException;
|
| 11 |
import in.shop2020.model.v1.inventory.InventoryType;
|
11 |
import in.shop2020.model.v1.inventory.InventoryType;
|
| 12 |
import in.shop2020.model.v1.inventory.ItemInventory;
|
12 |
import in.shop2020.model.v1.inventory.ItemInventory;
|
| - |
|
13 |
import in.shop2020.model.v1.inventory.OOSStatus;
|
| 13 |
import in.shop2020.model.v1.inventory.Warehouse;
|
14 |
import in.shop2020.model.v1.inventory.Warehouse;
|
| 14 |
import in.shop2020.model.v1.inventory.WarehouseType;
|
15 |
import in.shop2020.model.v1.inventory.WarehouseType;
|
| 15 |
import in.shop2020.model.v1.order.SnapdealOrder;
|
16 |
import in.shop2020.model.v1.order.SnapdealOrder;
|
| 16 |
import in.shop2020.support.utils.ReportsUtils;
|
17 |
import in.shop2020.support.utils.ReportsUtils;
|
| 17 |
import in.shop2020.thrift.clients.CatalogClient;
|
18 |
import in.shop2020.thrift.clients.CatalogClient;
|
| Line 121... |
Line 122... |
| 121 |
private String currentTp;
|
122 |
private String currentTp;
|
| 122 |
private String minPosSp;
|
123 |
private String minPosSp;
|
| 123 |
private String minPosTp;
|
124 |
private String minPosTp;
|
| 124 |
private String vat;
|
125 |
private String vat;
|
| 125 |
private String comparsionResult;
|
126 |
private String comparsionResult;
|
| - |
|
127 |
private String maxSp;
|
| - |
|
128 |
private String nDaySale;
|
| - |
|
129 |
|
| - |
|
130 |
public String getnDaySale() {
|
| - |
|
131 |
return nDaySale;
|
| - |
|
132 |
}
|
| - |
|
133 |
|
| - |
|
134 |
public void setnDaySale(String nDaySale) {
|
| - |
|
135 |
this.nDaySale = nDaySale;
|
| - |
|
136 |
}
|
| - |
|
137 |
|
| - |
|
138 |
private String avgSale;
|
| - |
|
139 |
|
| - |
|
140 |
public String getAvgSale() {
|
| - |
|
141 |
return avgSale;
|
| - |
|
142 |
}
|
| - |
|
143 |
|
| - |
|
144 |
public void setAvgSale(String avgSale) {
|
| - |
|
145 |
this.avgSale = avgSale;
|
| - |
|
146 |
}
|
| - |
|
147 |
|
| - |
|
148 |
public String getMaxSp() {
|
| - |
|
149 |
return maxSp;
|
| - |
|
150 |
}
|
| - |
|
151 |
|
| - |
|
152 |
public void setMaxSp(String maxSp) {
|
| - |
|
153 |
this.maxSp = maxSp;
|
| - |
|
154 |
}
|
| - |
|
155 |
|
| 126 |
public String getComparsionResult() {
|
156 |
public String getComparsionResult() {
|
| 127 |
return comparsionResult;
|
157 |
return comparsionResult;
|
| 128 |
}
|
158 |
}
|
| 129 |
|
159 |
|
| 130 |
public void setComparsionResult(String comparsionResult) {
|
160 |
public void setComparsionResult(String comparsionResult) {
|
| Line 371... |
Line 401... |
| 371 |
if (t_mpItem.getCurrentSp()< t_mpItem.getMinimumPossibleSp()){
|
401 |
if (t_mpItem.getCurrentSp()< t_mpItem.getMinimumPossibleSp()){
|
| 372 |
sendAlert(t_mpItem.getItemId(),t_mpItem.getCurrentSp(),t_mpItem.getMinimumPossibleSp());
|
402 |
sendAlert(t_mpItem.getItemId(),t_mpItem.getCurrentSp(),t_mpItem.getMinimumPossibleSp());
|
| 373 |
}
|
403 |
}
|
| 374 |
return "snapdeal-update-result";
|
404 |
return "snapdeal-update-result";
|
| 375 |
}
|
405 |
}
|
| 376 |
|
406 |
|
| 377 |
|
407 |
|
| 378 |
public boolean compareParameters(MarketplaceItems mpItem, SnapdealItem snapdealItem, Warehouse warehouse,double weight) throws TException, JSONException, CatalogServiceException{
|
408 |
public boolean compareParameters(MarketplaceItems mpItem, SnapdealItem snapdealItem, Warehouse warehouse,double weight) throws TException, JSONException, CatalogServiceException{
|
| 379 |
double nlc =getNlcForWarehouse(snapdealItem.getWarehouseId(),snapdealItem.getItem_id());
|
409 |
double nlc =getNlcForWarehouse(snapdealItem.getWarehouseId(),snapdealItem.getItem_id());
|
| 380 |
double vat = (snapdealItem.getSellingPrice()/(1+(mpItem.getVat()/100))-(nlc/(1+(mpItem.getVat()/100))))*(mpItem.getVat()/100);
|
410 |
double vat = (snapdealItem.getSellingPrice()/(1+(mpItem.getVat()/100))-(nlc/(1+(mpItem.getVat()/100))))*(mpItem.getVat()/100);
|
| 381 |
double inHouseCost = 15+vat+(mpItem.getReturnProvision()/100)*snapdealItem.getSellingPrice()+mpItem.getOtherCost();
|
411 |
double inHouseCost = 15+vat+(mpItem.getReturnProvision()/100)*snapdealItem.getSellingPrice()+mpItem.getOtherCost();
|
| 382 |
double lowest_possible_tp = nlc+inHouseCost;
|
412 |
double lowest_possible_tp = nlc+inHouseCost;
|
| 383 |
double our_tp = snapdealItem.getSellingPrice()- snapdealItem.getSellingPrice()*(mpItem.getCommission()/100+mpItem.getEmiFee()/100)*(1+(mpItem.getServiceTax()/100))-(snapdealItem.getCourierCost()+mpItem.getClosingFee())*(1+(mpItem.getServiceTax()/100));
|
413 |
double our_tp = snapdealItem.getSellingPrice()- snapdealItem.getSellingPrice()*(mpItem.getCommission()/100+mpItem.getEmiFee()/100)*(1+(mpItem.getServiceTax()/100))-(snapdealItem.getCourierCost()+mpItem.getClosingFee())*(1+(mpItem.getServiceTax()/100));
|
| 384 |
double commission = ((mpItem.getCommission()/100)*snapdealItem.getSellingPrice());
|
414 |
double commission = ((mpItem.getCommission()/100)*snapdealItem.getSellingPrice());
|
| 385 |
double service_tax = (mpItem.getServiceTax()/100)*(snapdealItem.getCommission()+snapdealItem.getCourierCost());
|
415 |
double service_tax = (mpItem.getServiceTax()/100)*(snapdealItem.getCommission()+snapdealItem.getCourierCost());
|
| 386 |
double lowest_possible_sp = (nlc+(snapdealItem.getCourierCost()+mpItem.getClosingFee())*(1+(mpItem.getServiceTax()/100))*(1+(mpItem.getVat()/100))+(15+mpItem.getOtherCost())*(1+(mpItem.getVat())/100))/(1-(mpItem.getCommission()/100+mpItem.getEmiFee()/100)*(1+(mpItem.getServiceTax()/100))*(1+(mpItem.getVat())/100)-(mpItem.getReturnProvision()/100)*(1+(mpItem.getVat())/100));
|
416 |
double lowest_possible_sp = (nlc+(snapdealItem.getCourierCost()+mpItem.getClosingFee())*(1+(mpItem.getServiceTax()/100))*(1+(mpItem.getVat()/100))+(15+mpItem.getOtherCost())*(1+(mpItem.getVat())/100))/(1-(mpItem.getCommission()/100+mpItem.getEmiFee()/100)*(1+(mpItem.getServiceTax()/100))*(1+(mpItem.getVat())/100)-(mpItem.getReturnProvision()/100)*(1+(mpItem.getVat())/100));
|
| - |
|
417 |
double vat_rate_prod = getVatRateForItem(warehouse,snapdealItem.getSellingPrice(),snapdealItem.getItem_id());
|
| 387 |
JSONObject x = new JSONObject();
|
418 |
JSONObject x = new JSONObject();
|
| 388 |
x.put("NLC", nlc);
|
419 |
x.put("NLC", nlc);
|
| 389 |
x.put("VAT", vat);
|
420 |
x.put("VAT", vat);
|
| - |
|
421 |
x.put("COURIER COST",getCourierCost(weight));
|
| 390 |
x.put("LOWEST POS TP", lowest_possible_tp);
|
422 |
x.put("LOWEST POS TP", lowest_possible_tp);
|
| 391 |
x.put("TP", our_tp);
|
423 |
x.put("TP", our_tp);
|
| 392 |
x.put("COMMISSION", commission);
|
424 |
x.put("COMMISSION", commission);
|
| 393 |
x.put("SERVICE TAX", service_tax);
|
425 |
x.put("SERVICE TAX", service_tax);
|
| 394 |
x.put("LOWEST POS SP", lowest_possible_sp);
|
426 |
x.put("LOWEST POS SP", lowest_possible_sp);
|
| - |
|
427 |
x.put("VAT RATE",vat_rate_prod);
|
| 395 |
logger.info("Snapdeal Backend validation "+x.toString());
|
428 |
logger.info("Snapdeal Backend validation "+x.toString());
|
| 396 |
boolean compare_result=true;
|
429 |
boolean compare_result=true;
|
| 397 |
|
430 |
|
| 398 |
if(!(getCourierCost(weight)==snapdealItem.getCourierCost())){
|
431 |
if(!(getCourierCost(weight)==snapdealItem.getCourierCost())){
|
| 399 |
compare_result=false;
|
432 |
compare_result=false;
|
| 400 |
}
|
433 |
}
|
| 401 |
|
434 |
|
| 402 |
if(!(getVatRateForItem(warehouse,snapdealItem.getSellingPrice(),snapdealItem.getItem_id())==mpItem.getVat())){
|
435 |
if(!(vat_rate_prod==mpItem.getVat())){
|
| 403 |
compare_result=false;
|
436 |
compare_result=false;
|
| 404 |
}
|
437 |
}
|
| 405 |
|
438 |
|
| 406 |
if(!(nlc==snapdealItem.getMaxNlc())){
|
439 |
if(!(nlc==snapdealItem.getMaxNlc())){
|
| 407 |
compare_result=false;
|
440 |
compare_result=false;
|
| 408 |
}
|
441 |
}
|
| 409 |
if(!(lowest_possible_tp-mpItem.getMinimumPossibleTp()>-1 && lowest_possible_tp-mpItem.getMinimumPossibleTp()<1)){
|
442 |
if(!(lowest_possible_tp-mpItem.getMinimumPossibleTp()>-1 && lowest_possible_tp-mpItem.getMinimumPossibleTp()<1)){
|
| 410 |
compare_result=false;
|
443 |
compare_result=false;
|
| Line 422... |
Line 455... |
| 422 |
compare_result=false;
|
455 |
compare_result=false;
|
| 423 |
}
|
456 |
}
|
| 424 |
return compare_result;
|
457 |
return compare_result;
|
| 425 |
|
458 |
|
| 426 |
}
|
459 |
}
|
| 427 |
|
460 |
|
| 428 |
public double getVatRateForItem(Warehouse warehouse, double sellingPrice,long itemId) throws CatalogServiceException, TException{
|
461 |
public double getVatRateForItem(Warehouse warehouse, double sellingPrice,long itemId) throws CatalogServiceException, TException{
|
| 429 |
Client catalogClientProd = new CatalogClient().getClient();
|
462 |
Client catalogClientProd = new CatalogClient().getClient();
|
| 430 |
return catalogClientProd.getVatPercentageForItem(itemId, warehouse.getStateId(), sellingPrice);
|
463 |
return catalogClientProd.getVatPercentageForItem(itemId, warehouse.getStateId(), sellingPrice);
|
| 431 |
}
|
464 |
}
|
| 432 |
|
465 |
|
| Line 443... |
Line 476... |
| 443 |
cCost = cCost + 35;
|
476 |
cCost = cCost + 35;
|
| 444 |
}
|
477 |
}
|
| 445 |
return cCost;
|
478 |
return cCost;
|
| 446 |
}
|
479 |
}
|
| 447 |
|
480 |
|
| - |
|
481 |
public void getLastNDaySaleForItem(String itemId,String days) {
|
| - |
|
482 |
try{
|
| - |
|
483 |
InventoryClient inventoryServiceClient = new InventoryClient();
|
| - |
|
484 |
in.shop2020.model.v1.inventory.InventoryService.Client inventoryClient = inventoryServiceClient.getClient();
|
| - |
|
485 |
List<OOSStatus> oosStatuses = inventoryClient.getOosStatusesForXDaysForItem(Long.valueOf(itemId), 7, Integer.valueOf(days));
|
| - |
|
486 |
String lastNdaySale="";
|
| - |
|
487 |
double avgSale = 0.0;
|
| - |
|
488 |
long count = 0,sale = 0;
|
| - |
|
489 |
for(OOSStatus oosStatus : oosStatuses){
|
| - |
|
490 |
if(oosStatus.isIs_oos()){
|
| - |
|
491 |
lastNdaySale += "X-";
|
| - |
|
492 |
}else{
|
| - |
|
493 |
lastNdaySale += oosStatus.getNum_orders() + "-";
|
| - |
|
494 |
sale = sale + oosStatus.getNum_orders();
|
| - |
|
495 |
count+=1;
|
| - |
|
496 |
}
|
| - |
|
497 |
}
|
| - |
|
498 |
lastNdaySale = lastNdaySale.substring(0, lastNdaySale.length()-1);
|
| - |
|
499 |
lastNdaySale += "\n";
|
| - |
|
500 |
setnDaySale(lastNdaySale);
|
| - |
|
501 |
if (count!=0){
|
| - |
|
502 |
setAvgSale(String.valueOf(roundTwoDecimals(sale/count)));
|
| - |
|
503 |
}
|
| - |
|
504 |
else{
|
| - |
|
505 |
setAvgSale("0");
|
| - |
|
506 |
}
|
| - |
|
507 |
}
|
| - |
|
508 |
catch (Exception e){
|
| - |
|
509 |
setAvgSale("0");
|
| - |
|
510 |
setnDaySale("Unable to fetch");
|
| - |
|
511 |
logger.error("Unable to get last n day sale",e);
|
| - |
|
512 |
}
|
| - |
|
513 |
|
| - |
|
514 |
}
|
| - |
|
515 |
|
| 448 |
|
516 |
|
| 449 |
private MarketplaceItems updateMarketplaceItemDetails(MarketplaceItems mpItem){
|
517 |
private MarketplaceItems updateMarketplaceItemDetails(MarketplaceItems mpItem){
|
| 450 |
mpItem.setItemId(Long.valueOf(itemId));
|
518 |
mpItem.setItemId(Long.valueOf(itemId));
|
| 451 |
mpItem.setSource(7);
|
519 |
mpItem.setSource(7);
|
| 452 |
mpItem.setVat(Double.valueOf(vat));
|
520 |
mpItem.setVat(Double.valueOf(vat));
|
| Line 457... |
Line 525... |
| 457 |
mpItem.setAutoDecrement(Boolean.valueOf(isAutoDecrement));
|
525 |
mpItem.setAutoDecrement(Boolean.valueOf(isAutoDecrement));
|
| 458 |
mpItem.setAutoIncrement(Boolean.valueOf(isAutoIncrement));
|
526 |
mpItem.setAutoIncrement(Boolean.valueOf(isAutoIncrement));
|
| 459 |
mpItem.setManualFavourite(Boolean.valueOf(isManualFavourite));
|
527 |
mpItem.setManualFavourite(Boolean.valueOf(isManualFavourite));
|
| 460 |
mpItem.setMinimumPossibleSp(Double.valueOf(minPosSp));
|
528 |
mpItem.setMinimumPossibleSp(Double.valueOf(minPosSp));
|
| 461 |
mpItem.setMinimumPossibleTp(Double.valueOf(minPosTp));
|
529 |
mpItem.setMinimumPossibleTp(Double.valueOf(minPosTp));
|
| - |
|
530 |
mpItem.setMaximumSellingPrice(Double.valueOf(maxSp));
|
| 462 |
return mpItem;
|
531 |
return mpItem;
|
| 463 |
}
|
532 |
}
|
| 464 |
|
533 |
|
| 465 |
private void sendAlert(long itemId,double sp,double minSp){
|
534 |
private void sendAlert(long itemId,double sp,double minSp){
|
| 466 |
Item item;
|
535 |
Item item;
|
| Line 492... |
Line 561... |
| 492 |
in.shop2020.model.v1.inventory.InventoryService.Client inventoryClient = inventoryServiceClient.getClient();
|
561 |
in.shop2020.model.v1.inventory.InventoryService.Client inventoryClient = inventoryServiceClient.getClient();
|
| 493 |
Client catalogClient = new CatalogClient("catalog_service_server_host_amazon","catalog_service_server_port").getClient();
|
562 |
Client catalogClient = new CatalogClient("catalog_service_server_host_amazon","catalog_service_server_port").getClient();
|
| 494 |
Item item = catalogClient.getItem(Long.valueOf(itemId));
|
563 |
Item item = catalogClient.getItem(Long.valueOf(itemId));
|
| 495 |
//Client catalogClientProd = new CatalogClient().getClient();
|
564 |
//Client catalogClientProd = new CatalogClient().getClient();
|
| 496 |
MarketplacePercentage mpCosting = catalogClient.getCostingForMarketplace(7, Long.valueOf(itemId));
|
565 |
MarketplacePercentage mpCosting = catalogClient.getCostingForMarketplace(7, Long.valueOf(itemId));
|
| 497 |
|
566 |
|
| 498 |
if (mpCosting.getSource()==0){
|
567 |
if (mpCosting.getSource()==0){
|
| 499 |
throw new CatalogServiceException();
|
568 |
throw new CatalogServiceException();
|
| 500 |
}
|
569 |
}
|
| 501 |
Warehouse warehouse = inventoryClient.getWarehouse(Long.valueOf(warehouseId));
|
570 |
Warehouse warehouse = inventoryClient.getWarehouse(Long.valueOf(warehouseId));
|
| 502 |
/*if (!(warehouse.getWarehouseType()==WarehouseType.OURS && warehouse.getInventoryType() == InventoryType.GOOD)){
|
571 |
/*if (!(warehouse.getWarehouseType()==WarehouseType.OURS && warehouse.getInventoryType() == InventoryType.GOOD)){
|
| Line 1327... |
Line 1396... |
| 1327 |
}
|
1396 |
}
|
| 1328 |
|
1397 |
|
| 1329 |
public double getRoundOfValue(String val){
|
1398 |
public double getRoundOfValue(String val){
|
| 1330 |
return roundTwoDecimals(Double.valueOf(val));
|
1399 |
return roundTwoDecimals(Double.valueOf(val));
|
| 1331 |
}
|
1400 |
}
|
| 1332 |
|
1401 |
|
| 1333 |
public String getVaildName(String name){
|
1402 |
public String getVaildName(String name){
|
| 1334 |
return name!=null?name:"";
|
1403 |
return name!=null?name:"";
|
| 1335 |
}
|
1404 |
}
|
| 1336 |
|
1405 |
|
| 1337 |
|
1406 |
|