118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
|
# File 'app/controllers/educode_sales/money_plans_controller.rb', line 118
def create
business = Business.find(params[:business_id])
data = []
week = Time.now.strftime('%W').to_i
current_week = ""
(params[:num].to_i+1).times do |i|
_week = params["date_at[#{i}]"].to_date.strftime('%W').to_i
current_week = _week if _week == week
business.money_plans.create(category: params["category[#{i}]"], amount: params["amount[#{i}]"], payment_clause: params["payment_clause[#{i}]"], date_at: params["date_at[#{i}]"], follow_up_id: business.last_follow_up_id, staff_id: @current_admin.id )
end
if current_week.present?
staff_manage_ids = business&.last_follow_up&.assign_follow_ups.present? ? business.last_follow_up.assign_follow_ups.pluck(:staff_id) : [business.staff_id]
common_id = EducodeSales::Common.find_by(clazz: '计划类型', name: '回款计划')&.id
staff_manage_ids.each do |staff_id|
EducodeSales::SalePlan.create(month: Time.now.beginning_of_month, weekly: week, content: "提醒:请补充回款计划内容!", business: business, staff_id: staff_id, finish_rate: '0', common_id: common_id )
EducodeSales::SalePlan.create(month: Time.now.beginning_of_month, content: "提醒:请补充回款计划内容!", business: business, staff_id: staff_id, finish_rate: '0', common_id: common_id )
end
end
render_success
end
|