Subversion Repositories SmartDukaan

Rev

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

Rev 30003 Rev 30017
Line 25... Line 25...
25
				+ "join LineItem li on li.orderId = o.id left join Provider p on p.id = o.logisticsProviderId join Item i on i.id=li.itemId where o.transactionId = :transactionId"),
25
				+ "join LineItem li on li.orderId = o.id left join Provider p on p.id = o.logisticsProviderId join Item i on i.id=li.itemId where o.transactionId = :transactionId"),
26
 
26
 
27
		@NamedQuery(name = "Order.selectItemIdTypeQuantity", query = "select new com.spice.profitmandi.dao.model.ItemIdTypeQuantity(li.itemId, i.type, li.quantity) from Order o join LineItem li on li.orderId = o.id join Item i on i.id = li.itemId where o.invoiceNumber = :invoiceNumber and o.retailerId = :retailerId"),
27
		@NamedQuery(name = "Order.selectItemIdTypeQuantity", query = "select new com.spice.profitmandi.dao.model.ItemIdTypeQuantity(li.itemId, i.type, li.quantity) from Order o join LineItem li on li.orderId = o.id join Item i on i.id = li.itemId where o.invoiceNumber = :invoiceNumber and o.retailerId = :retailerId"),
28
 
28
 
29
		@NamedQuery(name = "Order.selectAllBilledOrderGroupByBrand", query = "select new com.spice.profitmandi.dao.model.SecondaryOrderBillingModel(li.brand, "
29
		@NamedQuery(name = "Order.selectAllBilledOrderGroupByBrand", query = "select new com.spice.profitmandi.dao.model.SecondaryOrderBillingModel(li.brand, "
30
				+ "sum(case when o.billingTimestamp >= :today then CAST(o.totalAmount  AS int) else 0 end),"
30
				+ "sum(case when o.billingTimestamp >= :today then CAST(o.totalAmount  AS integer) else 0 end),"
31
				+ "sum(case when o.billingTimestamp >= :threedays  and o.billingTimestamp < :endDate  then CAST(o.totalAmount  AS int) else 0 end),"
31
				+ "sum(case when o.billingTimestamp >= :threedays  and o.billingTimestamp < :endDate  then CAST(o.totalAmount  AS integer) else 0 end),"
32
				+ "sum(case when concat(year(o.billingTimestamp ), month(o.billingTimestamp ))= :mtd  then CAST(o.totalAmount AS int) else 0 end),"
32
				+ "sum(case when concat(year(o.billingTimestamp ), month(o.billingTimestamp ))= :mtd  then CAST(o.totalAmount AS integer) else 0 end),"
33
				+ "sum(case when o.billingTimestamp between  :lmtdStartDate and :lmtdEndDate  then CAST(o.totalAmount  AS int) else 0 end),"
33
				+ "sum(case when o.billingTimestamp between  :lmtdStartDate and :lmtdEndDate  then CAST(o.totalAmount  AS integer) else 0 end),"
34
				+ "sum(case when o.billingTimestamp between  :lmtdStartDate and :lmsEndDate  then CAST(o.totalAmount  AS int) else 0 end),"
34
				+ "sum(case when o.billingTimestamp between  :lmtdStartDate and :lmsEndDate  then CAST(o.totalAmount  AS integer) else 0 end),"
35
				+ "	sum(case when o.billingTimestamp >= :today then li.quantity else 0 end),"
35
				+ "	sum(case when o.billingTimestamp >= :today then li.quantity else 0 end),"
36
				+ "	sum(case when o.billingTimestamp >= :threedays and o.billingTimestamp < :endDate then li.quantity else 0 end),"
36
				+ "	sum(case when o.billingTimestamp >= :threedays and o.billingTimestamp < :endDate then li.quantity else 0 end),"
37
				+ " sum(case when concat(year(o.billingTimestamp), month(o.billingTimestamp))= :mtd  then li.quantity else 0 end),"
37
				+ " sum(case when concat(year(o.billingTimestamp), month(o.billingTimestamp))= :mtd  then li.quantity else 0 end),"
38
				+ "	sum(case when o.billingTimestamp between  :lmtdStartDate and :lmtdEndDate then li.quantity else 0 end),"
38
				+ "	sum(case when o.billingTimestamp between  :lmtdStartDate and :lmtdEndDate then li.quantity else 0 end),"
39
				+ "	sum(case when o.billingTimestamp between  :lmtdStartDate and :lmsEndDate  then li.quantity else 0 end)"
39
				+ "	sum(case when o.billingTimestamp between  :lmtdStartDate and :lmsEndDate  then li.quantity else 0 end)"
40
				+ " )"
40
				+ " )"
41
				+ "	 from Order o join LineItem li on o.id = li.orderId join FofoStore fs on fs.id = o.retailerId where o.status in (7,9,10,12)"
41
				+ "	 from Order o join LineItem li on o.id = li.orderId join FofoStore fs on fs.id = o.retailerId where o.status in (7,9,10,12)"
42
				+ "	and o.billingTimestamp >= :lmtdStartDate and fs.warehouseId in :warehouseId and fs.internal = 0 group by li.brand"),
42
				+ "	and o.billingTimestamp >= :lmtdStartDate and fs.warehouseId in :warehouseId and fs.internal = 0 group by li.brand"),
43
 
43
 
44
		@NamedQuery(name = "Order.selectAllBilledOrderGroupByBrandFofoId", query = "select new com.spice.profitmandi.dao.model.BrandWiseModel(li.brand,"
44
		@NamedQuery(name = "Order.selectAllBilledOrderGroupByBrandFofoId", query = "select new com.spice.profitmandi.dao.model.BrandWiseModel(li.brand,"
45
				+ "	DATE_FORMAT(o.billingTimestamp, '%m-%Y'),sum(cast(o.totalAmount As int)))"
45
				+ "	DATE_FORMAT(o.billingTimestamp, '%m-%Y'),sum(cast(o.totalAmount AS integer)))"
46
				+ "	 from Order o join LineItem li on o.id = li.orderId join FofoStore fs on fs.id = o.retailerId where o.status in (7,9,10,12)"
46
				+ "	 from Order o join LineItem li on o.id = li.orderId join FofoStore fs on fs.id = o.retailerId where o.status in (7,9,10,12)"
47
				+ "	and o.billingTimestamp >= :startDate and o.retailerId =:fofoId  group by li.brand,DATE_FORMAT(o.billingTimestamp, '%m-%Y')"),
47
				+ "	and o.billingTimestamp >= :startDate and o.retailerId =:fofoId  group by li.brand,DATE_FORMAT(o.billingTimestamp, '%m-%Y')"),
48
 
48
 
49
		@NamedQuery(name = "Order.selectAllBilledOrderGroupByBrandWarehouse", query = "select new com.spice.profitmandi.dao.model.SecondaryWarehouseWiseOrderBilllingModel(fs.warehouseId,date(o.billingTimestamp), li.brand, "
49
		@NamedQuery(name = "Order.selectAllBilledOrderGroupByBrandWarehouse", query = "select new com.spice.profitmandi.dao.model.SecondaryWarehouseWiseOrderBilllingModel(fs.warehouseId,date(o.billingTimestamp), li.brand, "
50
				+ "sum(CAST(o.totalAmount  AS int)),sum( li.quantity))"
50
				+ "sum(CAST(o.totalAmount  AS integer)),sum( li.quantity))"
51
				+ "	 from Order o join LineItem li on o.id = li.orderId join FofoStore fs on fs.id = o.retailerId where o.status in (7,9,10,12)"
51
				+ "	 from Order o join LineItem li on o.id = li.orderId join FofoStore fs on fs.id = o.retailerId where o.status in (7,9,10,12)"
52
				+ "	and o.billingTimestamp >= :startDate and  o.billingTimestamp < :endDate and (null is :brand or li.brand = :brand) and fs.internal = 0 group by fs.warehouseId, date(o.billingTimestamp), li.brand"),
52
				+ "	and o.billingTimestamp >= :startDate and  o.billingTimestamp < :endDate and (null is :brand or li.brand = :brand) and fs.internal = 0 group by fs.warehouseId, date(o.billingTimestamp), li.brand"),
53
 
53
 
54
		@NamedQuery(name = "Order.selectAllBilledOrderItemByBrand", query = "select new com.spice.profitmandi.dao.model.SecondaryOrderItemBillingModel(o.retailerName,li.brand,i.modelName, "
54
		@NamedQuery(name = "Order.selectAllBilledOrderItemByBrand", query = "select new com.spice.profitmandi.dao.model.SecondaryOrderItemBillingModel(o.retailerName,li.brand,i.modelName, "
55
				+ " i.modelNumber, i.color," + "o.totalAmount," + "	 li.quantity)"
55
				+ " i.modelNumber, i.color," + "o.totalAmount," + "	 li.quantity)"
Line 60... Line 60...
60
				+ " i.modelNumber, i.color," + "o.totalAmount," + "	 li.quantity)"
60
				+ " i.modelNumber, i.color," + "o.totalAmount," + "	 li.quantity)"
61
				+ "	 from Order o join LineItem li on o.id = li.orderId join Item i on i.id = li.itemId join FofoStore fs on fs.id = o.retailerId where o.status in (7,9,10,12)"
61
				+ "	 from Order o join LineItem li on o.id = li.orderId join Item i on i.id = li.itemId join FofoStore fs on fs.id = o.retailerId where o.status in (7,9,10,12)"
62
				+ "	and o.billingTimestamp >= :startDate and fs.warehouseId in :warehouseId and li.brand in :brand order by li.itemId desc"),
62
				+ "	and o.billingTimestamp >= :startDate and fs.warehouseId in :warehouseId and li.brand in :brand order by li.itemId desc"),
63
 
63
 
64
		@NamedQuery(name = "Order.selectAllBilledOrderBrandByFofoId", query = "select new com.spice.profitmandi.dao.model.InStockBrandModel(li.brand,"
64
		@NamedQuery(name = "Order.selectAllBilledOrderBrandByFofoId", query = "select new com.spice.profitmandi.dao.model.InStockBrandModel(li.brand,"
65
				+ "	 Sum(li.quantity),Sum(CAST(o.totalAmount As int)))"
65
				+ "	 Sum(li.quantity),Sum(CAST(o.totalAmount AS integer)))"
66
				+ "	 from Order o join LineItem li on o.id = li.orderId where o.status in (7,9,10,12)"
66
				+ "	 from Order o join LineItem li on o.id = li.orderId where o.status in (7,9,10,12)"
67
				+ "	and o.billingTimestamp >= :startDate and o.billingTimestamp <= :endDate and o.retailerId = :fofoId group by li.brand"),
67
				+ "	and o.billingTimestamp >= :startDate and o.billingTimestamp <= :endDate and o.retailerId = :fofoId group by li.brand"),
68
 
68
 
69
		@NamedQuery(name = "Order.selectAllBilledOrderBrandItemByFofoId", query = "select new com.spice.profitmandi.dao.model.InStockBrandItemModel("
69
		@NamedQuery(name = "Order.selectAllBilledOrderBrandItemByFofoId", query = "select new com.spice.profitmandi.dao.model.InStockBrandItemModel("
70
				+ " i.brand, i.modelName, i.modelNumber, i.color,Sum(li.quantity), Sum(CAST(o.totalAmount As int)))"
70
				+ " i.brand, i.modelName, i.modelNumber, i.color,Sum(li.quantity), Sum(CAST(o.totalAmount AS integer)))"
71
				+ "	 from Order o join LineItem li on o.id = li.orderId join Item i on i.id = li.itemId where o.status in (7,9,10,12)"
71
				+ "	 from Order o join LineItem li on o.id = li.orderId join Item i on i.id = li.itemId where o.status in (7,9,10,12)"
72
				+ "	and o.billingTimestamp >= :startDate and o.billingTimestamp <= :endDate and o.retailerId = :fofoId  group by i.id"),
72
				+ "	and o.billingTimestamp >= :startDate and o.billingTimestamp <= :endDate and o.retailerId = :fofoId  group by i.id"),
73
 
73
 
74
		@NamedQuery(name = "Order.selectAllGrnPendingOrderByCatalogId", query = "select new com.spice.profitmandi.dao.model.FofoIdQtyModel("
74
		@NamedQuery(name = "Order.selectAllGrnPendingOrderByCatalogId", query = "select new com.spice.profitmandi.dao.model.FofoIdQtyModel("
75
				+ "  fs.warehouseId,fs.id,sum(li.quantity )) from FofoStore fs join  Order o on fs.id = o.retailerId "
75
				+ "  fs.warehouseId,fs.id,sum(li.quantity )) from FofoStore fs join  Order o on fs.id = o.retailerId "
Line 114... Line 114...
114
				+ "	 fs.active = 1 and fs.internal = 0 and o.status in (3,4) and tl.mop between :startPrice and :endPrice  and i.categoryId=10006 group by fs.id,i.catalogItemId,i.brand,i.modelName,i.modelNumber"),
114
				+ "	 fs.active = 1 and fs.internal = 0 and o.status in (3,4) and tl.mop between :startPrice and :endPrice  and i.categoryId=10006 group by fs.id,i.catalogItemId,i.brand,i.modelName,i.modelNumber"),
115
 
115
 
116
		@NamedQuery(name = "Order.selectAllGrnPendingOrderItemByCatalogIdFofoId", query = "select new com.spice.profitmandi.dao.model.FofoIdItemDetailModel("
116
		@NamedQuery(name = "Order.selectAllGrnPendingOrderItemByCatalogIdFofoId", query = "select new com.spice.profitmandi.dao.model.FofoIdItemDetailModel("
117
				+ "  fs.warehouseId, fs.id, sum(li.quantity), i.brand, i.modelName, i.modelNumber, i.catalogItemId) from FofoStore fs join  Order o on fs.id = o.retailerId "
117
				+ "  fs.warehouseId, fs.id, sum(li.quantity), i.brand, i.modelName, i.modelNumber, i.catalogItemId) from FofoStore fs join  Order o on fs.id = o.retailerId "
118
				+ "  join LineItem li on o.id = li.orderId  join TagListing tl on tl.itemId = li.itemId "
118
				+ "  join LineItem li on o.id = li.orderId  join TagListing tl on tl.itemId = li.itemId "
119
				+ "  join Item i on (i.id = tl.itemId ) where " + "	 fs.active = 1 and fs.internal = 0 and"
119
				+ "  join Item i on (i.id = tl.itemId ) where " + "	 fs.active = true and fs.internal = 0 and"
120
				+ "  o.billingTimestamp is not null and o.refundTimestamp is null and o.partnerGrnTimestamp is null"
120
				+ "  o.billingTimestamp is not null and o.refundTimestamp is null and o.partnerGrnTimestamp is null"
121
				+ "  and i.catalogItemId in :catalogItemId and  i.categoryId=10006 and fs.id = :fofoId group by i.catalogItemId, i.brand,i.modelName,i.modelNumber"),
121
				+ "  and i.catalogItemId in :catalogItemId and  i.categoryId=10006 and fs.id = :fofoId group by i.catalogItemId, i.brand,i.modelName,i.modelNumber"),
122
 
122
 
123
		@NamedQuery(name = "Order.selectAllPendingIndentOrderItemByCatalogIdFofoId", query = "select new com.spice.profitmandi.dao.model.FofoIdItemDetailModel("
123
		@NamedQuery(name = "Order.selectAllPendingIndentOrderItemByCatalogIdFofoId", query = "select new com.spice.profitmandi.dao.model.FofoIdItemDetailModel("
124
				+ "   fs.warehouseId, fs.id, sum(li.quantity), i.brand, i.modelName, i.modelNumber, i.catalogItemId)"
124
				+ "   fs.warehouseId, fs.id, sum(li.quantity), i.brand, i.modelName, i.modelNumber, i.catalogItemId)"
Line 126... Line 126...
126
				+ "  join LineItem li on o.id = li.orderId " + "  join TagListing tl on tl.itemId = li.itemId "
126
				+ "  join LineItem li on o.id = li.orderId " + "  join TagListing tl on tl.itemId = li.itemId "
127
				+ "  join Item i on i.id = tl.itemId  where "
127
				+ "  join Item i on i.id = tl.itemId  where "
128
				+ "	 fs.active = 1 and fs.internal = 0 and o.status in (3,4) and i.catalogItemId in :catalogItemId and  i.categoryId=10006 and fs.id = :fofoId group by i.catalogItemId, i.brand,i.modelName,i.modelNumber"),
128
				+ "	 fs.active = 1 and fs.internal = 0 and o.status in (3,4) and i.catalogItemId in :catalogItemId and  i.categoryId=10006 and fs.id = :fofoId group by i.catalogItemId, i.brand,i.modelName,i.modelNumber"),
129
 
129
 
130
		@NamedQuery(name = "Order.selectGroupByBrandLmp", query = "select new com.spice.profitmandi.dao.model.BrandWiseModel(li.brand,"
130
		@NamedQuery(name = "Order.selectGroupByBrandLmp", query = "select new com.spice.profitmandi.dao.model.BrandWiseModel(li.brand,"
131
				+ " DATE_FORMAT(o.billingTimestamp, '%m-%Y'),sum(cast(o.totalAmount As int)))"
131
				+ " DATE_FORMAT(o.billingTimestamp, '%m-%Y'),sum(cast(o.totalAmount AS integer)))"
132
				+ "	 from Order o join LineItem li on o.id = li.orderId join FofoStore fs on fs.id = o.retailerId where o.status in (7,9,10,12)"
132
				+ "	 from Order o join LineItem li on o.id = li.orderId join FofoStore fs on fs.id = o.retailerId where o.status in (7,9,10,12)"
133
				+ "	and o.billingTimestamp >= :lmsStartDate and fs.id in :fofoId and fs.warehouseId in :warehouseId and fs.internal = 0 group by li.brand,DATE_FORMAT(o.billingTimestamp, '%m-%Y')"),
133
				+ "	and o.billingTimestamp >= :lmsStartDate and fs.id in :fofoId and fs.warehouseId in :warehouseId and fs.internal = 0 group by li.brand,DATE_FORMAT(o.billingTimestamp, '%m-%Y')"),
134
 
134
 
135
		@NamedQuery(name = "Order.selectGrnPendingOrderQtyByCatalogId", query = "select sum(case when li.quantity is null then 0 else  li.quantity end)"
135
		@NamedQuery(name = "Order.selectGrnPendingOrderQtyByCatalogId", query = "select sum(case when li.quantity is null then 0 else  li.quantity end)"
136
				+ "  from FofoStore fs join  Order o on fs.id = o.retailerId "
136
				+ "  from FofoStore fs join  Order o on fs.id = o.retailerId "
Line 144... Line 144...
144
				+ "  join LineItem li on o.id = li.orderId " + "  join TagListing tl on tl.itemId = li.itemId "
144
				+ "  join LineItem li on o.id = li.orderId " + "  join TagListing tl on tl.itemId = li.itemId "
145
				+ "  join Item i on i.id = tl.itemId  where "
145
				+ "  join Item i on i.id = tl.itemId  where "
146
				+ "	 fs.active = 1 and fs.internal = 0 and o.status in (3,4)and i.catalogItemId = :catalogItemId and fs.id = :fofoId group by i.catalogItemId, fs.id"),
146
				+ "	 fs.active = 1 and fs.internal = 0 and o.status in (3,4)and i.catalogItemId = :catalogItemId and fs.id = :fofoId group by i.catalogItemId, fs.id"),
147
 
147
 
148
		@NamedQuery(name = "Order.selectTodayOrders", query = "select new com.spice.profitmandi.dao.model.BrandRegionPOModel(fs.warehouseId, li.brand, "
148
		@NamedQuery(name = "Order.selectTodayOrders", query = "select new com.spice.profitmandi.dao.model.BrandRegionPOModel(fs.warehouseId, li.brand, "
149
				+ " sum(case when (o.createTimestamp between :startDate and :endDate) then cast(o.totalAmount as integer) else 0 end),"
149
				+ " sum(case when (o.createTimestamp between :startDate and :endDate) then cast(o.totalAmount AS integer ) else 0 end),"
150
				+ " sum(case when (o.billingTimestamp is not null and (o.createTimestamp between :startDate and :endDate)) then cast(o.totalAmount as integer) else 0 end),"
150
				+ " sum(case when (o.billingTimestamp is not null and (o.createTimestamp between :startDate and :endDate)) then cast(o.totalAmount AS integer) else 0 end),"
151
				+ " sum(case when o.billingTimestamp is not null then cast(o.totalAmount as integer) else 0 end))"
151
				+ " sum(case when o.billingTimestamp is not null then cast(o.totalAmount AS integer ) else 0 end))"
152
				+ "	from Order o join LineItem li on o.id = li.orderId join FofoStore fs on fs.id = o.retailerId "
152
				+ "	from Order o join LineItem li on o.id = li.orderId join FofoStore fs on fs.id = o.retailerId "
153
				+ " where o.refundTimestamp is null and ((o.createTimestamp between :startDate and :endDate) or (o.billingTimestamp between :startDate and :endDate)) and fs.internal = 0 and li.brand not in ('Smartdukaan','Dummy')"
153
				+ " where o.refundTimestamp is null and ((o.createTimestamp between :startDate and :endDate) or (o.billingTimestamp between :startDate and :endDate)) and fs.internal = 0 and li.brand not in ('Smartdukaan','Dummy')"
154
				+ " group by fs.warehouseId , li.brand"),
154
				+ " group by fs.warehouseId , li.brand"),
155
 
155
 
156
		@NamedQuery(name = "Order.selectAllPendingIndentAccessoriesTvGroupByFofoId", query = "select new com.spice.profitmandi.dao.model.InStockAccessoriesTvFofoIdModel("
156
		@NamedQuery(name = "Order.selectAllPendingIndentAccessoriesTvGroupByFofoId", query = "select new com.spice.profitmandi.dao.model.InStockAccessoriesTvFofoIdModel("
157
				+ "  o.retailerId, SUM(case when c.parentCategoryId  = 10011 then CAST(o.totalAmount  AS int) else 0 end), SUM(case when c.parentCategoryId  = 14200 then  CAST(o.totalAmount  AS int) else 0 end))"
157
				+ "  o.retailerId, SUM(case when c.parentCategoryId  = 10011 then CAST(o.totalAmount  AS integer) else 0 end), SUM(case when c.parentCategoryId  = 14200 then  CAST(o.totalAmount  AS integer) else 0 end))"
158
				+ "	 from  Order o join LineItem li on o.id = li.orderId join Item i on i.id = li.itemId  join Category c on c.id = i.categoryId "
158
				+ "	 from  Order o join LineItem li on o.id = li.orderId join Item i on i.id = li.itemId  join Category c on c.id = i.categoryId "
159
				+ "  where o.retailerId in :fofoIds and o.status in (3,4) and i.categoryId != 10006 group by o.retailerId"),
159
				+ "  where o.retailerId in :fofoIds and o.status in (3,4) and i.categoryId != 10006 group by o.retailerId"),
160
 
160
 
161
		@NamedQuery(name = "Order.selectAllGrnPendingAccessoriesTvGroupByFofoId", query = "select new com.spice.profitmandi.dao.model.InStockAccessoriesTvFofoIdModel("
161
		@NamedQuery(name = "Order.selectAllGrnPendingAccessoriesTvGroupByFofoId", query = "select new com.spice.profitmandi.dao.model.InStockAccessoriesTvFofoIdModel("
162
				+ "  o.retailerId, SUM(case when c.parentCategoryId  = 10011 then CAST(o.totalAmount  AS int) else 0 end), SUM(case when c.parentCategoryId  = 14200 then  CAST(o.totalAmount  AS int) else 0 end))"
162
				+ "  o.retailerId, SUM(case when c.parentCategoryId  = 10011 then CAST(o.totalAmount  AS integer) else 0 end), SUM(case when c.parentCategoryId  = 14200 then  CAST(o.totalAmount  AS integer) else 0 end))"
163
				+ "	 from  Order o join LineItem li on o.id = li.orderId join Item i on i.id = li.itemId  join Category c on c.id = i.categoryId "
163
				+ "	 from  Order o join LineItem li on o.id = li.orderId join Item i on i.id = li.itemId  join Category c on c.id = i.categoryId "
164
				+ "  where o.retailerId in :fofoIds and o.billingTimestamp is not null and o.refundTimestamp is null and o.partnerGrnTimestamp is null and i.categoryId != 10006 group by o.retailerId"),
164
				+ "  where o.retailerId in :fofoIds and o.billingTimestamp is not null and o.refundTimestamp is null and o.partnerGrnTimestamp is null and i.categoryId != 10006 group by o.retailerId"),
165
 
165
 
166
})
166
})
167
public class Order implements Serializable {
167
public class Order implements Serializable {