Sha256: 57057c6d3187c97f8de8699510469d463af3263f805a27f950f5bf22a3f1f457

Contents?: true

Size: 1.29 KB

Versions: 6

Compression:

Stored size: 1.29 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("actual_amount - divide_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

6 entries across 6 versions & 1 rubygems

Version Path
educode_sales-0.6.4 app/views/educode_sales/places/index.json.jbuilder
educode_sales-0.6.3 app/views/educode_sales/places/index.json.jbuilder
educode_sales-0.6.2 app/views/educode_sales/places/index.json.jbuilder
educode_sales-0.6.1 app/views/educode_sales/places/index.json.jbuilder
educode_sales-0.6.0 app/views/educode_sales/places/index.json.jbuilder
educode_sales-0.5.9 app/views/educode_sales/places/index.json.jbuilder