blsm-vd-core 0.8.1 → 0.8.2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 3d55f917867d36eeae772420209a25f91aaef6c4
4
- data.tar.gz: 940c62e5d74e1c1a4abe0ffb3c029cf6d0baa97c
3
+ metadata.gz: 0ed35c25312f8bc4f1e715c54554ae8e2aaaafb5
4
+ data.tar.gz: 63704b0c3ca6a19b365f475889bb8024aa4e5606
5
5
  SHA512:
6
- metadata.gz: 5f14cd881d9a0d6ca5b3f538ccb7ff7b8995b38ee33b20cd6f515373a37f2b7c0227328f40c1c4bf3440d0b2e1669bcec8877498398f1e1a40b8af1b31b7235f
7
- data.tar.gz: 16296f56e85dc3768532bf66f843801e491955696318101a3c39dc261b2f8cc2af140893d519fae1b9199761c3964175876e05243c7a5f7d11f3cdea0e26dd6e
6
+ metadata.gz: 533f878ce21ea6a33d423c488d6fd5b867e0d09aa426533bbdc8cb4f356b6a4d359b5457cea765662cf2b3f03ff978d54c0a8f16bea8316215778891b720b7d4
7
+ data.tar.gz: 1499447b01bac90fe08a8cac6d283e87d1311d922d578bcf182fa14afaf018f6abd3a4d54c93c35e71ca4d5b73f1ccb53709d11c56fb9578d67c249de4712d2c
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- blsm-vd-core (0.8.0)
4
+ blsm-vd-core (0.8.2)
5
5
 
6
6
  GEM
7
7
  remote: https://ruby.taobao.org/
@@ -4,5 +4,19 @@ module BlsmVdCore
4
4
  self.table_name='applications'
5
5
  belongs_to :user, class_name: "::BlsmVdCore::User"
6
6
  has_many :orders, class_name: "::BlsmVdCore::Order"
7
+
8
+
9
+ #到付押金开关状态
10
+ def toggle_delivery_deposit
11
+ (self.toggle_setting.to_i & 0b00000001) == 1
12
+ end
13
+
14
+ #更新状态
15
+ def toggle_delivery_deposit=(toggle)
16
+ reload
17
+ update_attribute(:toggle_setting, (toggle ? (self.toggle_setting.to_i | 0b00000001) : (self.toggle_setting.to_i ^ 0b00000001)))
18
+ reload
19
+ end
20
+
7
21
  end
8
22
  end
@@ -39,10 +39,14 @@ module BlsmVdCore
39
39
  #利润率,跟销售额有关系
40
40
  def profit_rate
41
41
  return 1 if level>=2
42
- return 0.5 if self.distribute_sum.to_f<750
43
- return 0.7 if self.distribute_sum.to_f<1500
42
+ vd_wx_pay = VdWxPay.where(:user_id=>self.user_id,:return_code=>'SUCCESS',:result_code=>'SUCCESS',:vd_service_id=>2).first
43
+ #是否是交98元开店的店主
44
+ if vd_wx_pay.blank?
45
+ return 0.5 if self.distribute_sum.to_f<1500
46
+ else
47
+ return 0.65 if self.distribute_sum.to_f<1500
48
+ end
44
49
  1
45
50
  end
46
-
47
51
  end
48
52
  end
@@ -1,3 +1,3 @@
1
1
  module BlsmVdCore
2
- VERSION = "0.8.1"
2
+ VERSION = "0.8.2"
3
3
  end
data/lib/blsm-vd-core.rb CHANGED
@@ -100,10 +100,27 @@ module BlsmVdCore
100
100
  if !user.rc_user.blank?
101
101
  VdRcMsgNotify.create_order_finish_notify(user.username)
102
102
  end
103
- # 给邀请人
103
+ # 进货费返还
104
+ user_info = user.create_vd_user_info
105
+ if !order.line_items.blank? && user_info.purchase_fee > 0
106
+ franchise_price = order.line_items.inject(0){|result,item| result+item.franchise_price}
107
+ earn_amount = franchise_price < user_info.purchase_fee ? franchise_price : user_info.purchase_fee
108
+ #创建结算项
109
+ ClearingItem.create({
110
+ state: 'CASH_BACK',
111
+ pay_type: "ZXZF",
112
+ user_id: user.id,
113
+ order_id: -13,
114
+ rate_of_profit: 1,
115
+ earn_amount: earn_amount
116
+ })
117
+ user_info.update_attributes(:purchase_fee=> (user_info.purchase_fee - earn_amount))
118
+ end
119
+ # 给邀请人奖励
104
120
  inviter = User.where(:invication_code=>user.invicated_from).first if user.invicated_from
105
121
  vd_transaction = "inviter_#{order.id}_reward"
106
- if user.create_vd_user_info.channel == "market_invite" && !inviter.blank? && !BlsmVdCore::VdInfoSec.dangerous?(vd_transaction)
122
+ #被邀请人,金牌店主以下,渠道邀请,邀请人不为空,一个订单只能有一个结算项
123
+ if user.vd_user_info.level < 2 && user.create_vd_user_info.channel == "market_invite" && !inviter.blank? && !BlsmVdCore::VdInfoSec.dangerous?(vd_transaction)
107
124
 
108
125
  #发送给邀请人微信提醒
109
126
  content = "您邀请的店主 #{user.username}(注册电话号为#{user.phone})与#{Time.now.strftime("%Y-%m-%d %H:%M:%S")}成功成交一笔订单,订单金额为#{order.total_fee.to_f}元, 您将同步获取邀请奖励#{(order.total_fee.to_f * 0.1).round(2)}元,特此通知"
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: blsm-vd-core
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.8.1
4
+ version: 0.8.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - saxer
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: exe
11
11
  cert_chain: []
12
- date: 2016-12-13 00:00:00.000000000 Z
12
+ date: 2016-12-15 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rspec