pricing_observer 0.1.5 → 0.1.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/lib/pricing_observer.rb +41 -40
- data/lib/pricing_observer/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 3f0484f4c46d61a9bc1943a0da9a230cf45e7e92
|
4
|
+
data.tar.gz: 993a13bbd0fa6134af1b8d41fff0296da5f926fe
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c68cbd4e1d312e4f3c6be667a8950a1556b985d44a1b85d88baf4f0fa962dbaf737da38b56c2ea01494c180d5d322930858e2834cc4809d24453c5c8c778b0f3
|
7
|
+
data.tar.gz: 27d3fc366e97eda752f1b7c1aa3f50046700277ff34269b4a5110b62f82495da01039cea27be41e978f2f5ec2121ca61bfc9fb97e4b36d03e5c97d5fcd8c742b
|
data/lib/pricing_observer.rb
CHANGED
@@ -17,10 +17,10 @@ class OrderSend
|
|
17
17
|
end
|
18
18
|
|
19
19
|
#notify's the observer when an desired condition is triggered
|
20
|
-
def notify_observers
|
20
|
+
def notify_observers(check_store)
|
21
21
|
@observers.each do |observer|
|
22
22
|
puts "Notifying"
|
23
|
-
observer.pricing_by_hit
|
23
|
+
observer.pricing_by_hit(check_store)
|
24
24
|
puts "Notified the observer"
|
25
25
|
end
|
26
26
|
end
|
@@ -34,47 +34,48 @@ class Pricing
|
|
34
34
|
puts "observer initialized"
|
35
35
|
end
|
36
36
|
#this is the logical pricing method that is triggered by the observer when ever the condition is met to be executed.
|
37
|
-
def pricing_by_hit
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
37
|
+
def pricing_by_hit(check_store)
|
38
|
+
#order_record = OrderItem.last
|
39
|
+
#prod = Product.find(order_record.product_id)
|
40
|
+
check_store.each do |store_with_id|
|
41
|
+
puts("before product assumption")
|
42
|
+
products = Product.where(store_detail_id: store_with_id)
|
43
|
+
puts("after product assumption")
|
44
|
+
|
44
45
|
products.each do |prod|
|
45
|
-
prod.price =
|
46
|
+
#prod.price = 43
|
46
47
|
puts(prod.hit.inspect)
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
48
|
+
case prod.hit
|
49
|
+
when 1
|
50
|
+
prod.offerPrice = prod.offerPrice + (prod.offerPrice/4)
|
51
|
+
when 2
|
52
|
+
prod.offerPrice = prod.offerPrice - (prod.offerPrice/36)
|
53
|
+
when 3
|
54
|
+
prod.offerPrice = prod.offerPrice - (prod.offerPrice/32)
|
55
|
+
when 4
|
56
|
+
prod.offerPrice = prod.offerPrice - (prod.offerPrice/28)
|
57
|
+
when 5
|
58
|
+
prod.offerPrice = prod.offerPrice - (prod.offerPrice/24)
|
59
|
+
when 6
|
60
|
+
prod.offerPrice = prod.offerPrice - (prod.offerPrice/20)
|
61
|
+
when 7
|
62
|
+
prod.offerPrice = prod.offerPrice - (prod.offerPrice/16)
|
63
|
+
when 8
|
64
|
+
prod.offerPrice = prod.offerPrice - (prod.offerPrice/12)
|
65
|
+
when 9
|
66
|
+
prod.offerPrice = prod.offerPrice - (prod.offerPrice/8)
|
67
|
+
when 10
|
68
|
+
prod.offerPrice = prod.offerPrice - (prod.offerPrice/4)
|
69
|
+
else
|
70
|
+
prod.offerPrice = 18
|
71
|
+
end
|
72
|
+
if(prod.offerPrice < 15)
|
73
|
+
prod.offerPrice = 15
|
74
|
+
elsif(prod.offerPrice > 45)
|
75
|
+
prod.offerPrice = 30
|
76
|
+
end
|
76
77
|
prod.save
|
77
78
|
end
|
79
|
+
end
|
78
80
|
end
|
79
|
-
|
80
81
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: pricing_observer
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.6
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Kishore Kumar
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2017-04-
|
11
|
+
date: 2017-04-21 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|