Sha256: 4ea90a498b813a63fe552017b26137b6d0b61934f6a83bd74994a8fcbae41c47

Contents?: true

Size: 1.27 KB

Versions: 4

Compression:

Stored size: 1.27 KB

Contents

all_businesses_count = 0
area_ids = EducodeSales::Common.where(clazz: 'area').ids.sort.to_s
json.data do
  json.array! @places do |d|
    json.id d.id
    json.name d.name
    # json.area_id d.areas.present? ? d.areas.pluck(:name).join("、") : ''
    if d.areas.present?
      if d.areas.ids.sort.to_s == area_ids
        json.area_id '全国'
      else
        json.area_id  d.areas.pluck(:name).join("、")
      end
    else
      json.area_id  ''
    end
    business_count = EducodeSales::Business.joins(:last_follow_up).where("educode_sales_follow_ups.clazz_id != ?", @x).where("educode_sales_follow_ups.place_id = #{d.id}").count
    json.businesses_count business_count
    all_businesses_count += business_count
    json.amount EducodeSales::Business.joins(:last_follow_up).where("educode_sales_follow_ups.clazz_id != ?", @x).where("educode_sales_follow_ups.place_id = #{d.id} AND educode_sales_follow_ups.stage_id IN (?)", @stage_ids).sum(:profit_amount).round(2)
    json.return_mount EducodeSales::Business.joins(:last_follow_up).where("educode_sales_follow_ups.clazz_id != ?", @x).where("educode_sales_follow_ups.place_id = #{d.id}").sum(:return_money).round(2)
  end
end

json.totalRow do
  json.businesses_count all_businesses_count.to_s
end
json.code 0
json.count @places.total_count

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
educode_sales-0.5.8 app/views/educode_sales/places/index.json.jbuilder
educode_sales-0.5.7 app/views/educode_sales/places/index.json.jbuilder
educode_sales-0.5.6 app/views/educode_sales/places/index.json.jbuilder
educode_sales-0.5.5 app/views/educode_sales/places/index.json.jbuilder