app/views/educode_sales/sales/index.json.jbuilder in educode_sales-0.5.9 vs app/views/educode_sales/sales/index.json.jbuilder in educode_sales-0.6.0
- old
+ new
@@ -2,10 +2,11 @@
businesses_b_count = 0
businesses_c_count = 0
businesses_d_count = 0
businesses_e_count = 0
businesses_o_count = 0
+school_counts = 0
area_ids = EducodeSales::Common.where(clazz: 'area').ids.sort.to_s
json.data do
json.array! @staffs do |d|
part_a_ids = EducodeSales::Business.where("educode_sales_businesses.last_follow_up_id is null AND staff_id = ?",d.id).ids
part_b_ids = EducodeSales::Business.where("educode_sales_businesses.last_follow_up_id is not null").joins("
@@ -31,23 +32,27 @@
business_b = @businesses.joins("JOIN educode_sales_follow_ups on educode_sales_follow_ups.id = educode_sales_businesses.last_follow_up_id").where("educode_sales_follow_ups.clazz_id = ?", @b_clazz&.id).count
business_c = @businesses.joins("JOIN educode_sales_follow_ups on educode_sales_follow_ups.id = educode_sales_businesses.last_follow_up_id").where("educode_sales_follow_ups.clazz_id = ?", @c_clazz&.id).count
business_d = @businesses.joins("JOIN educode_sales_follow_ups on educode_sales_follow_ups.id = educode_sales_businesses.last_follow_up_id").where("educode_sales_follow_ups.clazz_id = ?", @d_clazz&.id).count
business_e = @businesses.joins("JOIN educode_sales_follow_ups on educode_sales_follow_ups.id = educode_sales_businesses.last_follow_up_id").where("educode_sales_follow_ups.clazz_id = ?", @e_clazz&.id).count
business_o = @businesses.joins("JOIN educode_sales_follow_ups on educode_sales_follow_ups.id = educode_sales_businesses.last_follow_up_id").where("educode_sales_follow_ups.clazz_id = ?", @o_clazz&.id).count
+ school_count = EducodeSales::CustomerExtension.where(customer_staff_id: d.id).size
json.goal @businesses.joins("JOIN educode_sales_follow_ups on educode_sales_follow_ups.id = educode_sales_businesses.last_follow_up_id").where("educode_sales_follow_ups.clazz_id != ? AND educode_sales_follow_ups.stage_id in (?)", @x, @step_ids).sum(:total_amount).round(2)
json.return_money @businesses.joins(last_follow_up: :money_plans).where("educode_sales_follow_ups.clazz_id != ?", @x).where.not("educode_sales_money_plans.clazz!= ?", 1).sum(:amount).round(2)
- json.school_count EducodeSales::CustomerExtension.where(customer_staff_id: d.id).size
+ json.school_count school_count
+ # json.follow_school_counts EducodeSales::CustomerFollow.where(staff_id: d.id).size + EducodeSales::FollowUp.where(staff_id: d.id).size
else
business_a = @businesses.joins("JOIN educode_sales_follow_ups on educode_sales_follow_ups.id = educode_sales_businesses.last_follow_up_id").where("educode_sales_follow_ups.clazz_id = ?", @a_clazz&.id).where("educode_sales_follow_ups.year = ?", @year).count
business_b = @businesses.joins("JOIN educode_sales_follow_ups on educode_sales_follow_ups.id = educode_sales_businesses.last_follow_up_id").where("educode_sales_follow_ups.clazz_id = ?", @b_clazz&.id).where("educode_sales_follow_ups.year = ?", @year).count
business_c = @businesses.joins("JOIN educode_sales_follow_ups on educode_sales_follow_ups.id = educode_sales_businesses.last_follow_up_id").where("educode_sales_follow_ups.clazz_id = ?", @c_clazz&.id).where("educode_sales_follow_ups.year = ?", @year).count
business_d = @businesses.joins("JOIN educode_sales_follow_ups on educode_sales_follow_ups.id = educode_sales_businesses.last_follow_up_id").where("educode_sales_follow_ups.clazz_id = ?", @d_clazz&.id).where("educode_sales_follow_ups.year = ?", @year).count
business_e = @businesses.joins("JOIN educode_sales_follow_ups on educode_sales_follow_ups.id = educode_sales_businesses.last_follow_up_id").where("educode_sales_follow_ups.clazz_id = ?", @e_clazz&.id).where("educode_sales_follow_ups.year = ?", @year).count
business_o = @businesses.joins("JOIN educode_sales_follow_ups on educode_sales_follow_ups.id = educode_sales_businesses.last_follow_up_id").where("educode_sales_follow_ups.clazz_id = ?", @o_clazz&.id).where("educode_sales_follow_ups.year = ?", @year).count
+ school_count = EducodeSales::CustomerExtension.where(customer_staff_id: d.id).size
json.goal @businesses.joins("JOIN educode_sales_follow_ups on educode_sales_follow_ups.id = educode_sales_businesses.last_follow_up_id").where("educode_sales_follow_ups.clazz_id != ? AND educode_sales_follow_ups.stage_id in (?)", @x, @step_ids).where("educode_sales_follow_ups.bidded_date >= ? AND educode_sales_follow_ups.bidded_date <= ?", "#{@year}-01-01", "#{@year}-12-31").sum(:total_amount).round(2)
json.return_money @businesses.joins(last_follow_up: :money_plans).where("educode_sales_follow_ups.clazz_id != ?", @x).where.not("educode_sales_money_plans.clazz!= ?", 1).where("educode_sales_money_plans.date_at >= ? AND educode_sales_money_plans.date_at <= ? ", "#{@year}-01-01 00:00:00", "#{@year}-12-31 23:59:59").sum(:amount).round(2)
- json.school_count EducodeSales::CustomerExtension.where(customer_staff_id: d.id).size
+ json.school_count school_count
+ # json.follow_school_counts EducodeSales::CustomerFollow.where(staff_id: d.id).size + EducodeSales::FollowUp.where(staff_id: d.id).size
end
json.business_a business_a
json.business_b business_b
json.business_c business_c
@@ -65,18 +70,20 @@
businesses_b_count += business_b
businesses_c_count += business_c
businesses_d_count += business_d
businesses_e_count += business_e
businesses_o_count += business_o
+ school_counts += school_count
end
end
json.totalRow do
json.business_a businesses_a_count.to_s
json.business_b businesses_b_count.to_s
json.business_c businesses_c_count.to_s
json.business_d businesses_d_count.to_s
json.business_e businesses_e_count.to_s
json.business_o businesses_o_count.to_s
+ json.school_count school_counts.to_s
end
json.code 0
json.count @staffs.total_count
\ No newline at end of file