Sha256: 32f0380c6a519ad9b4f9782ad72b4ab9fcbadc3b3deb937889a307c45229b4e4

Contents?: true

Size: 1.8 KB

Versions: 174

Compression:

Stored size: 1.8 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.total_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("total_amount").round(2)
    json.divide_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("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

174 entries across 174 versions & 1 rubygems

Version Path
educode_sales-1.10.26 app/views/educode_sales/places/index.json.jbuilder
educode_sales-1.10.25 app/views/educode_sales/places/index.json.jbuilder
educode_sales-1.10.24 app/views/educode_sales/places/index.json.jbuilder
educode_sales-1.10.23 app/views/educode_sales/places/index.json.jbuilder
educode_sales-1.10.22 app/views/educode_sales/places/index.json.jbuilder
educode_sales-1.10.21 app/views/educode_sales/places/index.json.jbuilder
educode_sales-1.10.20 app/views/educode_sales/places/index.json.jbuilder
educode_sales-1.10.19 app/views/educode_sales/places/index.json.jbuilder
educode_sales-1.10.18 app/views/educode_sales/places/index.json.jbuilder
educode_sales-1.10.17 app/views/educode_sales/places/index.json.jbuilder
educode_sales-1.10.16 app/views/educode_sales/places/index.json.jbuilder
educode_sales-1.10.15 app/views/educode_sales/places/index.json.jbuilder
educode_sales-1.10.14 app/views/educode_sales/places/index.json.jbuilder
educode_sales-1.10.13 app/views/educode_sales/places/index.json.jbuilder
educode_sales-1.10.12 app/views/educode_sales/places/index.json.jbuilder
educode_sales-1.10.11 app/views/educode_sales/places/index.json.jbuilder
educode_sales-1.10.10 app/views/educode_sales/places/index.json.jbuilder
educode_sales-1.10.9 app/views/educode_sales/places/index.json.jbuilder
educode_sales-1.10.8 app/views/educode_sales/places/index.json.jbuilder
educode_sales-1.10.7 app/views/educode_sales/places/index.json.jbuilder