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.74 app/views/educode_sales/places/index.json.jbuilder
educode_sales-1.10.73 app/views/educode_sales/places/index.json.jbuilder
educode_sales-1.10.72 app/views/educode_sales/places/index.json.jbuilder
educode_sales-1.10.71 app/views/educode_sales/places/index.json.jbuilder
educode_sales-1.10.70 app/views/educode_sales/places/index.json.jbuilder
educode_sales-1.10.59 app/views/educode_sales/places/index.json.jbuilder
educode_sales-1.10.58 app/views/educode_sales/places/index.json.jbuilder
educode_sales-1.10.49 app/views/educode_sales/places/index.json.jbuilder
educode_sales-1.10.48 app/views/educode_sales/places/index.json.jbuilder
educode_sales-1.10.46 app/views/educode_sales/places/index.json.jbuilder
educode_sales-1.10.41 app/views/educode_sales/places/index.json.jbuilder
educode_sales-1.10.37 app/views/educode_sales/places/index.json.jbuilder
educode_sales-1.10.36 app/views/educode_sales/places/index.json.jbuilder
educode_sales-1.10.35 app/views/educode_sales/places/index.json.jbuilder
educode_sales-1.10.34 app/views/educode_sales/places/index.json.jbuilder
educode_sales-1.10.33 app/views/educode_sales/places/index.json.jbuilder
educode_sales-1.10.31 app/views/educode_sales/places/index.json.jbuilder
educode_sales-1.10.30 app/views/educode_sales/places/index.json.jbuilder
educode_sales-1.10.29 app/views/educode_sales/places/index.json.jbuilder
educode_sales-1.10.28 app/views/educode_sales/places/index.json.jbuilder