rails_ship 0.0.1 → 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/LICENSE +165 -20
- data/README.md +4 -8
- data/app/{views/ship/admin/home/index.html.erb → assets/config/rails_ship_manifest.js} +0 -0
- data/app/models/rails_ship/address.rb +13 -0
- data/app/models/rails_ship/area.rb +65 -0
- data/app/models/rails_ship/shipment.rb +8 -0
- data/config/routes.rb +0 -64
- data/lib/rails_ship/engine.rb +0 -17
- data/lib/rails_ship/version.rb +3 -0
- data/lib/rails_ship.rb +5 -2
- data/lib/tasks/rails_ship_tasks.rake +4 -0
- metadata +29 -185
- data/app/controllers/ship/admin/addresses_controller.rb +0 -48
- data/app/controllers/ship/admin/base_controller.rb +0 -5
- data/app/controllers/ship/admin/home_controller.rb +0 -8
- data/app/controllers/ship/admin/packages_controller.rb +0 -43
- data/app/controllers/ship/admin/trade_items_controller.rb +0 -72
- data/app/controllers/ship/driver/base_controller.rb +0 -9
- data/app/controllers/ship/driver/favorites_controller.rb +0 -39
- data/app/controllers/ship/my/addresses_controller.rb +0 -58
- data/app/controllers/ship/my/base_controller.rb +0 -5
- data/app/controllers/ship/my/cars_controller.rb +0 -54
- data/app/controllers/ship/my/drivers_controller.rb +0 -38
- data/app/controllers/ship/my/favorites_controller.rb +0 -40
- data/app/controllers/ship/my/lines_controller.rb +0 -71
- data/app/controllers/ship/my/locations_controller.rb +0 -60
- data/app/controllers/ship/my/packages_controller.rb +0 -53
- data/app/controllers/ship/my/principal_addresses_controller.rb +0 -26
- data/app/controllers/ship/panel/base_controller.rb +0 -5
- data/app/controllers/ship/panel/lines_controller.rb +0 -53
- data/app/controllers/ship/panel/similars_controller.rb +0 -61
- data/app/jobs/ship/car_ocr_job.rb +0 -11
- data/app/jobs/ship/driver_ocr_job.rb +0 -11
- data/app/jobs/ship/location_geo_job.rb +0 -10
- data/app/models/ship/address.rb +0 -7
- data/app/models/ship/car.rb +0 -5
- data/app/models/ship/driver.rb +0 -5
- data/app/models/ship/ext/order.rb +0 -7
- data/app/models/ship/ext/trade_item.rb +0 -11
- data/app/models/ship/ext/user.rb +0 -15
- data/app/models/ship/favorite.rb +0 -5
- data/app/models/ship/line.rb +0 -5
- data/app/models/ship/line_similar.rb +0 -5
- data/app/models/ship/location.rb +0 -5
- data/app/models/ship/model/address.rb +0 -10
- data/app/models/ship/model/car.rb +0 -34
- data/app/models/ship/model/driver.rb +0 -45
- data/app/models/ship/model/favorite.rb +0 -14
- data/app/models/ship/model/line.rb +0 -28
- data/app/models/ship/model/line_similar.rb +0 -16
- data/app/models/ship/model/location.rb +0 -53
- data/app/models/ship/model/package.rb +0 -28
- data/app/models/ship/model/packaged.rb +0 -29
- data/app/models/ship/model/shipment.rb +0 -22
- data/app/models/ship/model/shipping.rb +0 -9
- data/app/models/ship/package.rb +0 -6
- data/app/models/ship/packaged.rb +0 -5
- data/app/models/ship/shipment.rb +0 -5
- data/app/models/ship.rb +0 -11
- data/app/views/admin/_ship_nav.html.erb +0 -11
- data/app/views/panel/_ship_nav.html.erb +0 -10
- data/app/views/ship/admin/addresses/_address.html.erb +0 -24
- data/app/views/ship/admin/addresses/_edit_form.html.erb +0 -3
- data/app/views/ship/admin/addresses/_form.html.erb +0 -9
- data/app/views/ship/admin/addresses/index.html.erb +0 -36
- data/app/views/ship/admin/base/_nav.html.erb +0 -3
- data/app/views/ship/admin/packages/_button.html.erb +0 -0
- data/app/views/ship/admin/packages/_edit_form.html.erb +0 -4
- data/app/views/ship/admin/packages/_filter_form.html.erb +0 -9
- data/app/views/ship/admin/packages/_form.html.erb +0 -5
- data/app/views/ship/admin/packages/_index_tbody.html.erb +0 -8
- data/app/views/ship/admin/packages/_index_thead.html.erb +0 -5
- data/app/views/ship/admin/packages/_new_form.html.erb +0 -4
- data/app/views/ship/admin/packages/_show_table.html.erb +0 -16
- data/app/views/ship/admin/packages/index.html.erb +0 -5
- data/app/views/ship/admin/rallies/_filter.html.erb +0 -7
- data/app/views/ship/admin/rallies/_form.html+phone.erb +0 -17
- data/app/views/ship/admin/rallies/_show_table.html+phone.erb +0 -24
- data/app/views/ship/admin/rallies/_show_table.html.erb +0 -12
- data/app/views/ship/admin/rallies/index.html+phone.erb +0 -26
- data/app/views/ship/admin/rallies/show.html.erb +0 -26
- data/app/views/ship/admin/trade_items/_filter.html.erb +0 -9
- data/app/views/ship/admin/trade_items/_form.html.erb +0 -7
- data/app/views/ship/admin/trade_items/_show_table.html.erb +0 -24
- data/app/views/ship/admin/trade_items/index.html.erb +0 -51
- data/app/views/ship/driver/favorites/_button.html+phone.erb +0 -4
- data/app/views/ship/driver/favorites/_edit_form.html.erb +0 -4
- data/app/views/ship/driver/favorites/_filter_form.html+phone.erb +0 -14
- data/app/views/ship/driver/favorites/_filter_form.html.erb +0 -9
- data/app/views/ship/driver/favorites/_form.html.erb +0 -3
- data/app/views/ship/driver/favorites/_index_tbody.html.erb +0 -6
- data/app/views/ship/driver/favorites/_index_thead.html.erb +0 -3
- data/app/views/ship/driver/favorites/_index_tr.html.erb +0 -4
- data/app/views/ship/driver/favorites/_new_form.html.erb +0 -4
- data/app/views/ship/driver/favorites/_show_table.html.erb +0 -8
- data/app/views/ship/driver/favorites/index.html.erb +0 -5
- data/app/views/ship/my/addresses/_edit_form.html.erb +0 -21
- data/app/views/ship/my/addresses/_form.html.erb +0 -23
- data/app/views/ship/my/addresses/index.html.erb +0 -44
- data/app/views/ship/my/cars/_edit_form.html.erb +0 -6
- data/app/views/ship/my/cars/_filter_form.html.erb +0 -9
- data/app/views/ship/my/cars/_index_tbody.html.erb +0 -3
- data/app/views/ship/my/cars/_index_thead.html.erb +0 -4
- data/app/views/ship/my/cars/_new_form.html.erb +0 -4
- data/app/views/ship/my/cars/_show_table.html.erb +0 -16
- data/app/views/ship/my/cars/create.turbo_stream.erb +0 -1
- data/app/views/ship/my/cars/index.html+phone.erb +0 -19
- data/app/views/ship/my/cars/index.html.erb +0 -5
- data/app/views/ship/my/cars/new.html.erb +0 -25
- data/app/views/ship/my/drivers/_edit_form.html.erb +0 -6
- data/app/views/ship/my/drivers/_form.html.erb +0 -4
- data/app/views/ship/my/drivers/_index_tbody.html.erb +0 -3
- data/app/views/ship/my/drivers/_index_thead.html.erb +0 -4
- data/app/views/ship/my/drivers/_new_form.html.erb +0 -4
- data/app/views/ship/my/drivers/_show_table.html.erb +0 -12
- data/app/views/ship/my/drivers/_uploader.html.erb +0 -22
- data/app/views/ship/my/drivers/edit.html.erb +0 -20
- data/app/views/ship/my/drivers/show.html.erb +0 -33
- data/app/views/ship/my/favorites/_button.html+phone.erb +0 -4
- data/app/views/ship/my/favorites/_edit_form.html.erb +0 -4
- data/app/views/ship/my/favorites/_filter_form.html+phone.erb +0 -14
- data/app/views/ship/my/favorites/_filter_form.html.erb +0 -9
- data/app/views/ship/my/favorites/_form.html.erb +0 -3
- data/app/views/ship/my/favorites/_index_tbody.html.erb +0 -6
- data/app/views/ship/my/favorites/_index_thead.html.erb +0 -3
- data/app/views/ship/my/favorites/_new_form.html.erb +0 -4
- data/app/views/ship/my/favorites/_show_table.html.erb +0 -8
- data/app/views/ship/my/favorites/index.html.erb +0 -5
- data/app/views/ship/my/lines/_edit_form.html.erb +0 -4
- data/app/views/ship/my/lines/_filter_form.html.erb +0 -1
- data/app/views/ship/my/lines/_form.html.erb +0 -3
- data/app/views/ship/my/lines/_index_tbody.html.erb +0 -6
- data/app/views/ship/my/lines/_index_tr.html.erb +0 -4
- data/app/views/ship/my/lines/_item_field.html.erb +0 -8
- data/app/views/ship/my/lines/_item_location.html.erb +0 -13
- data/app/views/ship/my/lines/_new_form.html.erb +0 -15
- data/app/views/ship/my/lines/_select/_tab_bar.html.erb +0 -10
- data/app/views/ship/my/lines/_select.html.erb +0 -10
- data/app/views/ship/my/lines/_show/_index_tbody.html.erb +0 -6
- data/app/views/ship/my/lines/_show/_index_tr.html+phone.erb +0 -6
- data/app/views/ship/my/lines/_show_table.html.erb +0 -9
- data/app/views/ship/my/lines/add.turbo_stream.erb +0 -1
- data/app/views/ship/my/lines/index.html.erb +0 -5
- data/app/views/ship/my/lines/new.html.erb +0 -1
- data/app/views/ship/my/lines/requirement.html.erb +0 -5
- data/app/views/ship/my/lines/select.turbo_stream.erb +0 -1
- data/app/views/ship/my/lines/show.html+phone.erb +0 -30
- data/app/views/ship/my/locations/_edit_form.html.erb +0 -4
- data/app/views/ship/my/locations/_filter_form.html.erb +0 -9
- data/app/views/ship/my/locations/_form.html.erb +0 -6
- data/app/views/ship/my/locations/_index_tbody.html.erb +0 -5
- data/app/views/ship/my/locations/_index_thead.html.erb +0 -6
- data/app/views/ship/my/locations/_new_form.html.erb +0 -4
- data/app/views/ship/my/locations/_show_table.html.erb +0 -20
- data/app/views/ship/my/locations/index.html.erb +0 -5
- data/app/views/ship/my/packages/index.html.erb +0 -31
- data/app/views/ship/my/principal_addresses/index.html+phone.erb +0 -32
- data/app/views/ship/my/principal_addresses/plans.html+phone.erb +0 -23
- data/app/views/ship/my/principal_addresses/show.html+phone.erb +0 -27
- data/app/views/ship/panel/base/_nav.html.erb +0 -3
- data/app/views/ship/panel/lines/_edit_form.html.erb +0 -4
- data/app/views/ship/panel/lines/_filter_form.html.erb +0 -9
- data/app/views/ship/panel/lines/_form.html.erb +0 -4
- data/app/views/ship/panel/lines/_index_tbody.html.erb +0 -4
- data/app/views/ship/panel/lines/_index_thead.html.erb +0 -5
- data/app/views/ship/panel/lines/_index_tr.html.erb +0 -19
- data/app/views/ship/panel/lines/_new_form.html.erb +0 -4
- data/app/views/ship/panel/lines/_show_table.html.erb +0 -12
- data/app/views/ship/panel/lines/index.html.erb +0 -5
- data/app/views/ship/panel/similars/_breadcrumb.html.erb +0 -7
- data/app/views/ship/panel/similars/_button.html.erb +0 -3
- data/app/views/ship/panel/similars/_edit_form.html.erb +0 -4
- data/app/views/ship/panel/similars/_filter_form.html.erb +0 -9
- data/app/views/ship/panel/similars/_form.html.erb +0 -4
- data/app/views/ship/panel/similars/_index_tbody.html.erb +0 -3
- data/app/views/ship/panel/similars/_index_thead.html.erb +0 -4
- data/app/views/ship/panel/similars/_new/_button.html.erb +0 -0
- data/app/views/ship/panel/similars/_new/_index_tr.html.erb +0 -10
- data/app/views/ship/panel/similars/_new/_index_tr_remove.html.erb +0 -10
- data/app/views/ship/panel/similars/_new_form.html.erb +0 -4
- data/app/views/ship/panel/similars/_show_table.html.erb +0 -12
- data/app/views/ship/panel/similars/create.turbo_stream.erb +0 -3
- data/app/views/ship/panel/similars/destroy.turbo_stream.erb +0 -3
- data/app/views/ship/panel/similars/index.html.erb +0 -5
- data/app/views/ship/panel/similars/new.html.erb +0 -16
- data/config/locales/zh.attributes.yml +0 -15
- data/config/locales/zh.yml +0 -51
- data/lib/rails_ship/config.rb +0 -11
@@ -1,71 +0,0 @@
|
|
1
|
-
module Ship
|
2
|
-
class My::LinesController < My::BaseController
|
3
|
-
before_action :set_line, only: [:show, :edit, :update, :destroy]
|
4
|
-
|
5
|
-
def index
|
6
|
-
@lines = current_user.lines.order(id: :asc).page(params[:page])
|
7
|
-
end
|
8
|
-
|
9
|
-
def requirement
|
10
|
-
@lines = current_user.lines.order(id: :asc).page(params[:page])
|
11
|
-
end
|
12
|
-
|
13
|
-
def new
|
14
|
-
@line = current_user.lines.build
|
15
|
-
@line.locations.build(position: 1)
|
16
|
-
end
|
17
|
-
|
18
|
-
def add
|
19
|
-
@line = current_user.lines.build(line_params)
|
20
|
-
@line.locations.select(&->(i){ i.position > params[:position].to_i }).each do |i|
|
21
|
-
i.position += 1
|
22
|
-
end
|
23
|
-
@line.locations.build(position: params[:position].to_i + 1)
|
24
|
-
end
|
25
|
-
|
26
|
-
def select
|
27
|
-
@line = current_user.lines.build
|
28
|
-
end
|
29
|
-
|
30
|
-
def create
|
31
|
-
@line = current_user.lines.build(line_params)
|
32
|
-
|
33
|
-
unless @line.save
|
34
|
-
render :new, locals: { model: @line }, status: :unprocessable_entity
|
35
|
-
end
|
36
|
-
end
|
37
|
-
|
38
|
-
def show
|
39
|
-
@similars = @line.similars
|
40
|
-
end
|
41
|
-
|
42
|
-
def edit
|
43
|
-
end
|
44
|
-
|
45
|
-
def update
|
46
|
-
@line.assign_attributes(line_params)
|
47
|
-
|
48
|
-
unless @line.save
|
49
|
-
render :edit, locals: { model: @line }, status: :unprocessable_entity
|
50
|
-
end
|
51
|
-
end
|
52
|
-
|
53
|
-
def destroy
|
54
|
-
@line.destroy
|
55
|
-
end
|
56
|
-
|
57
|
-
private
|
58
|
-
def set_line
|
59
|
-
@line = current_user.lines.find(params[:id])
|
60
|
-
end
|
61
|
-
|
62
|
-
def line_params
|
63
|
-
params.fetch(:line, {}).permit(
|
64
|
-
:start_name,
|
65
|
-
:finish_name,
|
66
|
-
locations_attributes: {}
|
67
|
-
)
|
68
|
-
end
|
69
|
-
|
70
|
-
end
|
71
|
-
end
|
@@ -1,60 +0,0 @@
|
|
1
|
-
module Ship
|
2
|
-
class My::LocationsController < My::BaseController
|
3
|
-
before_action :set_line
|
4
|
-
before_action :set_location, only: [:show, :edit, :update, :destroy]
|
5
|
-
|
6
|
-
def index
|
7
|
-
@locations = Location.page(params[:page])
|
8
|
-
end
|
9
|
-
|
10
|
-
def new
|
11
|
-
@location = Location.new
|
12
|
-
end
|
13
|
-
|
14
|
-
def create
|
15
|
-
@location = Location.new(location_params)
|
16
|
-
|
17
|
-
unless @location.save
|
18
|
-
render :new, locals: { model: @location }, status: :unprocessable_entity
|
19
|
-
end
|
20
|
-
end
|
21
|
-
|
22
|
-
def show
|
23
|
-
end
|
24
|
-
|
25
|
-
def edit
|
26
|
-
end
|
27
|
-
|
28
|
-
def update
|
29
|
-
@location.assign_attributes(location_params)
|
30
|
-
|
31
|
-
unless @location.save
|
32
|
-
render :edit, locals: { model: @location }, status: :unprocessable_entity
|
33
|
-
end
|
34
|
-
end
|
35
|
-
|
36
|
-
def destroy
|
37
|
-
@location.destroy
|
38
|
-
end
|
39
|
-
|
40
|
-
private
|
41
|
-
def set_line
|
42
|
-
@line = Line.find params[:line_id]
|
43
|
-
end
|
44
|
-
|
45
|
-
def set_location
|
46
|
-
@location = Location.find(params[:id])
|
47
|
-
end
|
48
|
-
|
49
|
-
def location_params
|
50
|
-
params.fetch(:location, {}).permit(
|
51
|
-
:poiname,
|
52
|
-
:poiaddress,
|
53
|
-
:cityname,
|
54
|
-
:lat,
|
55
|
-
:lng
|
56
|
-
)
|
57
|
-
end
|
58
|
-
|
59
|
-
end
|
60
|
-
end
|
@@ -1,53 +0,0 @@
|
|
1
|
-
module Ship
|
2
|
-
class My::PackagesController < My::BaseController
|
3
|
-
before_action :set_address
|
4
|
-
before_action :set_package, only: [:show, :wait, :edit, :update, :destroy]
|
5
|
-
|
6
|
-
def index
|
7
|
-
q_params = {}
|
8
|
-
q_params.merge! params.permit(:produce_plan_id)
|
9
|
-
@produce_plan = ProducePlan.find params[:produce_plan_id]
|
10
|
-
@produce_plan.wait_lists.find_or_create_by(address_id: @address.id)
|
11
|
-
|
12
|
-
@packages = @address.packages.default_where(q_params).page(params[:page])
|
13
|
-
end
|
14
|
-
|
15
|
-
def show
|
16
|
-
end
|
17
|
-
|
18
|
-
def wait
|
19
|
-
wait_list = @address.wait_lists.find_by(wait_for_type: 'ProducePlan', wait_for_id: @package.produce_plan_id)
|
20
|
-
wait_item = wait_list.wait_items.find_or_initialize_by(user_id: @package.user_id)
|
21
|
-
@package.wait_item = wait_item
|
22
|
-
|
23
|
-
if @package.save
|
24
|
-
|
25
|
-
end
|
26
|
-
end
|
27
|
-
|
28
|
-
def edit
|
29
|
-
end
|
30
|
-
|
31
|
-
def update
|
32
|
-
@package.assign_attributes(package_params)
|
33
|
-
|
34
|
-
unless @package.save
|
35
|
-
render :edit, locals: { model: @package }, status: :unprocessable_entity
|
36
|
-
end
|
37
|
-
end
|
38
|
-
|
39
|
-
def destroy
|
40
|
-
@package.destroy
|
41
|
-
end
|
42
|
-
|
43
|
-
private
|
44
|
-
def set_address
|
45
|
-
@address = current_user.principal_addresses.find params[:principal_address_id]
|
46
|
-
end
|
47
|
-
|
48
|
-
def set_package
|
49
|
-
@package = @address.packages.find(params[:id])
|
50
|
-
end
|
51
|
-
|
52
|
-
end
|
53
|
-
end
|
@@ -1,26 +0,0 @@
|
|
1
|
-
module Ship
|
2
|
-
class My::PrincipalAddressesController < My::BaseController
|
3
|
-
before_action :set_principal_address, only: [:show, :plans]
|
4
|
-
|
5
|
-
def index
|
6
|
-
@addresses = current_user.principal_addresses.page(params[:page])
|
7
|
-
end
|
8
|
-
|
9
|
-
def show
|
10
|
-
@customs = @address.customs
|
11
|
-
end
|
12
|
-
|
13
|
-
def plans
|
14
|
-
q_params = {}
|
15
|
-
q_params.merge! default_params
|
16
|
-
|
17
|
-
@produce_plans = ProducePlan.default_where(q_params)
|
18
|
-
end
|
19
|
-
|
20
|
-
private
|
21
|
-
def set_principal_address
|
22
|
-
@address = current_user.principal_addresses.find(params[:id])
|
23
|
-
end
|
24
|
-
|
25
|
-
end
|
26
|
-
end
|
@@ -1,53 +0,0 @@
|
|
1
|
-
module Ship
|
2
|
-
class Panel::LinesController < Panel::BaseController
|
3
|
-
before_action :set_line, only: [:show, :edit, :update, :destroy]
|
4
|
-
|
5
|
-
def index
|
6
|
-
@lines = Line.page(params[:page])
|
7
|
-
end
|
8
|
-
|
9
|
-
def new
|
10
|
-
@line = Line.new
|
11
|
-
end
|
12
|
-
|
13
|
-
def create
|
14
|
-
@line = Line.new(line_params)
|
15
|
-
|
16
|
-
unless @line.save
|
17
|
-
render :new, locals: { model: @line }, status: :unprocessable_entity
|
18
|
-
end
|
19
|
-
end
|
20
|
-
|
21
|
-
def show
|
22
|
-
end
|
23
|
-
|
24
|
-
def edit
|
25
|
-
end
|
26
|
-
|
27
|
-
def update
|
28
|
-
@line.assign_attributes(line_params)
|
29
|
-
|
30
|
-
unless @line.save
|
31
|
-
render :edit, locals: { model: @line }, status: :unprocessable_entity
|
32
|
-
end
|
33
|
-
end
|
34
|
-
|
35
|
-
def destroy
|
36
|
-
@line.destroy
|
37
|
-
end
|
38
|
-
|
39
|
-
private
|
40
|
-
def set_line
|
41
|
-
@line = Line.find(params[:id])
|
42
|
-
end
|
43
|
-
|
44
|
-
def line_params
|
45
|
-
params.fetch(:line, {}).permit(
|
46
|
-
:name,
|
47
|
-
:start_name,
|
48
|
-
:finish_name
|
49
|
-
)
|
50
|
-
end
|
51
|
-
|
52
|
-
end
|
53
|
-
end
|
@@ -1,61 +0,0 @@
|
|
1
|
-
module Ship
|
2
|
-
class Panel::SimilarsController < Panel::BaseController
|
3
|
-
before_action :set_line
|
4
|
-
before_action :set_similar, only: [:show, :edit, :update, :destroy]
|
5
|
-
|
6
|
-
def index
|
7
|
-
@similars = @line.similars.page(params[:page])
|
8
|
-
end
|
9
|
-
|
10
|
-
def new
|
11
|
-
@similars = @line.similars.page(params[:page])
|
12
|
-
@lines = Line.where.not(id: @line.similar_ids).page(params[:page])
|
13
|
-
end
|
14
|
-
|
15
|
-
def create
|
16
|
-
@line_similar = @line.line_similars.build
|
17
|
-
@line_similar.similar_id = params[:similar_id]
|
18
|
-
|
19
|
-
unless @line_similar.save
|
20
|
-
render :new, locals: { model: @line_similar }, status: :unprocessable_entity
|
21
|
-
end
|
22
|
-
end
|
23
|
-
|
24
|
-
def show
|
25
|
-
end
|
26
|
-
|
27
|
-
def edit
|
28
|
-
end
|
29
|
-
|
30
|
-
def update
|
31
|
-
@similar.assign_attributes(similar_params)
|
32
|
-
|
33
|
-
unless @similar.save
|
34
|
-
render :edit, locals: { model: @similar }, status: :unprocessable_entity
|
35
|
-
end
|
36
|
-
end
|
37
|
-
|
38
|
-
def destroy
|
39
|
-
@line_similar = @line.line_similars.find_by(similar_id: params[:id])
|
40
|
-
@line_similar.destroy
|
41
|
-
end
|
42
|
-
|
43
|
-
private
|
44
|
-
def set_line
|
45
|
-
@line = Line.find params[:line_id]
|
46
|
-
end
|
47
|
-
|
48
|
-
def set_similar
|
49
|
-
@similar = Line.find(params[:id])
|
50
|
-
end
|
51
|
-
|
52
|
-
def similar_params
|
53
|
-
params.fetch(:line_similar, {}).permit(
|
54
|
-
:name,
|
55
|
-
:similar_id,
|
56
|
-
:position
|
57
|
-
)
|
58
|
-
end
|
59
|
-
|
60
|
-
end
|
61
|
-
end
|
data/app/models/ship/address.rb
DELETED
data/app/models/ship/car.rb
DELETED
data/app/models/ship/driver.rb
DELETED
data/app/models/ship/ext/user.rb
DELETED
@@ -1,15 +0,0 @@
|
|
1
|
-
module Ship
|
2
|
-
module Ext::User
|
3
|
-
extend ActiveSupport::Concern
|
4
|
-
|
5
|
-
included do
|
6
|
-
has_one :driver, class_name: 'Ship::Driver'
|
7
|
-
has_many :cars, class_name: 'Ship::Car'
|
8
|
-
has_many :lines, class_name: 'Ship::Line'
|
9
|
-
|
10
|
-
has_many :favorites, class_name: 'Ship::Favorite'
|
11
|
-
has_many :drivers, class_name: 'Ship::Driver', through: :favorites
|
12
|
-
end
|
13
|
-
|
14
|
-
end
|
15
|
-
end
|
data/app/models/ship/favorite.rb
DELETED
data/app/models/ship/line.rb
DELETED
data/app/models/ship/location.rb
DELETED
@@ -1,34 +0,0 @@
|
|
1
|
-
module Ship
|
2
|
-
module Model::Car
|
3
|
-
extend ActiveSupport::Concern
|
4
|
-
|
5
|
-
included do
|
6
|
-
attribute :location, :string
|
7
|
-
attribute :number, :string
|
8
|
-
attribute :detail, :json
|
9
|
-
|
10
|
-
belongs_to :user, class_name: 'Auth::User'
|
11
|
-
|
12
|
-
has_one_attached :registration
|
13
|
-
|
14
|
-
after_create_commit :ocr_later
|
15
|
-
end
|
16
|
-
|
17
|
-
def ocr_later
|
18
|
-
CarOcrJob.perform_later(self)
|
19
|
-
end
|
20
|
-
|
21
|
-
def ocr
|
22
|
-
r = TencentHelper.registration_ocr(registration.url)
|
23
|
-
self.detail = r['FrontInfo']
|
24
|
-
self.number = detail['PlateNo'] if detail.is_a?(Hash)
|
25
|
-
self.save
|
26
|
-
r
|
27
|
-
end
|
28
|
-
|
29
|
-
def for_update
|
30
|
-
broadcast_action_to 'car_new', action: :update, target: 'car_update', partial: 'ship/my/cars/edit_form', locals: { car: self }
|
31
|
-
end
|
32
|
-
|
33
|
-
end
|
34
|
-
end
|
@@ -1,45 +0,0 @@
|
|
1
|
-
module Ship
|
2
|
-
module Model::Driver
|
3
|
-
extend ActiveSupport::Concern
|
4
|
-
|
5
|
-
included do
|
6
|
-
attribute :name, :string
|
7
|
-
attribute :number, :string
|
8
|
-
attribute :detail, :jsonb, default: {}
|
9
|
-
|
10
|
-
belongs_to :user, class_name: 'Auth::User'
|
11
|
-
has_many :favorites, dependent: :delete_all
|
12
|
-
has_many :users, through: :favorites
|
13
|
-
|
14
|
-
has_one_attached :license
|
15
|
-
|
16
|
-
after_create_commit :ocr_later
|
17
|
-
after_create_commit :sync_to_favorite
|
18
|
-
end
|
19
|
-
|
20
|
-
def ocr_later
|
21
|
-
DriverOcrJob.perform_later(self)
|
22
|
-
end
|
23
|
-
|
24
|
-
def ocr
|
25
|
-
r = TencentHelper.license_ocr(license.url)
|
26
|
-
self.name = r['Name']
|
27
|
-
self.number = r['CardCode']
|
28
|
-
self.detail = r
|
29
|
-
self.save
|
30
|
-
r
|
31
|
-
end
|
32
|
-
|
33
|
-
def for_update
|
34
|
-
broadcast_action_to 'driver_edit', action: :update, target: 'driver_update', partial: 'ship/my/drivers/edit_form', locals: { driver: self }
|
35
|
-
end
|
36
|
-
|
37
|
-
def sync_to_favorite
|
38
|
-
if user.inviter_id
|
39
|
-
favorite = favorites.build(user_id: user.inviter_id)
|
40
|
-
favorite.save
|
41
|
-
end
|
42
|
-
end
|
43
|
-
|
44
|
-
end
|
45
|
-
end
|
@@ -1,28 +0,0 @@
|
|
1
|
-
module Ship
|
2
|
-
module Model::Line
|
3
|
-
extend ActiveSupport::Concern
|
4
|
-
|
5
|
-
included do
|
6
|
-
attribute :name, :string
|
7
|
-
attribute :start_name, :string
|
8
|
-
attribute :finish_name, :string
|
9
|
-
attribute :locations_count, :integer, default: 0
|
10
|
-
|
11
|
-
belongs_to :user, class_name: 'Auth::User'
|
12
|
-
|
13
|
-
has_many :locations, -> { order(position: :asc) }, dependent: :delete_all, inverse_of: :line
|
14
|
-
accepts_nested_attributes_for :locations
|
15
|
-
has_many :line_similars, dependent: :delete_all
|
16
|
-
has_many :similars, through: :line_similars
|
17
|
-
|
18
|
-
after_create_commit :sync_names
|
19
|
-
end
|
20
|
-
|
21
|
-
def sync_names
|
22
|
-
self.start_name = locations[0].poiname
|
23
|
-
self.finish_name = locations[1].poiname
|
24
|
-
self.save
|
25
|
-
end
|
26
|
-
|
27
|
-
end
|
28
|
-
end
|
@@ -1,16 +0,0 @@
|
|
1
|
-
module Ship
|
2
|
-
module Model::LineSimilar
|
3
|
-
extend ActiveSupport::Concern
|
4
|
-
|
5
|
-
included do
|
6
|
-
attribute :score, :decimal
|
7
|
-
attribute :position, :integer
|
8
|
-
|
9
|
-
belongs_to :line
|
10
|
-
belongs_to :similar, class_name: 'Line'
|
11
|
-
|
12
|
-
acts_as_list
|
13
|
-
end
|
14
|
-
|
15
|
-
end
|
16
|
-
end
|
@@ -1,53 +0,0 @@
|
|
1
|
-
module Ship
|
2
|
-
module Model::Location
|
3
|
-
extend ActiveSupport::Concern
|
4
|
-
|
5
|
-
included do
|
6
|
-
attribute :poiname, :string
|
7
|
-
attribute :poiaddress, :string
|
8
|
-
attribute :cityname, :string
|
9
|
-
attribute :lat, :decimal, precision: 10, scale: 8
|
10
|
-
attribute :lng, :decimal, precision: 11, scale: 8
|
11
|
-
attribute :position, :integer
|
12
|
-
attribute :coordinate, :point
|
13
|
-
|
14
|
-
belongs_to :area, class_name: 'Profiled::Area', optional: true
|
15
|
-
belongs_to :line, counter_cache: true
|
16
|
-
|
17
|
-
acts_as_list scope: [:line_id]
|
18
|
-
|
19
|
-
after_save_commit :geo_later, if: -> { saved_change_to_lat? || saved_change_to_lng? }
|
20
|
-
end
|
21
|
-
|
22
|
-
def position_text
|
23
|
-
if line.new_record?
|
24
|
-
count = line.locations.size
|
25
|
-
else
|
26
|
-
count = line.locations_count
|
27
|
-
end
|
28
|
-
|
29
|
-
if position == 1
|
30
|
-
'起点'
|
31
|
-
elsif position >= count
|
32
|
-
'终点'
|
33
|
-
else
|
34
|
-
"途经点#{position}"
|
35
|
-
end
|
36
|
-
end
|
37
|
-
|
38
|
-
def geo_later
|
39
|
-
LocationGeoJob.perform_later(self)
|
40
|
-
end
|
41
|
-
|
42
|
-
# todo 依赖 rails profiled
|
43
|
-
def geo
|
44
|
-
result = QqMapHelper.geocoder(lat: lat, lng: lng)
|
45
|
-
r = result['address_component']
|
46
|
-
area = Profiled::Area.sure_find [r['province'], r['city'], r['district']]
|
47
|
-
self.area = area
|
48
|
-
self.save
|
49
|
-
result
|
50
|
-
end
|
51
|
-
|
52
|
-
end
|
53
|
-
end
|
@@ -1,28 +0,0 @@
|
|
1
|
-
module Ship
|
2
|
-
module Model::Package
|
3
|
-
extend ActiveSupport::Concern
|
4
|
-
|
5
|
-
included do
|
6
|
-
attribute :state, :string
|
7
|
-
attribute :expected_on, :date
|
8
|
-
attribute :pick_mode, :string
|
9
|
-
|
10
|
-
belongs_to :address
|
11
|
-
belongs_to :user
|
12
|
-
belongs_to :produce_plan, optional: true
|
13
|
-
has_many :shipments, dependent: :delete_all
|
14
|
-
has_many :packageds, dependent: :destroy
|
15
|
-
has_many :trade_items, through: :packageds
|
16
|
-
|
17
|
-
enum pick_mode: {
|
18
|
-
by_self: 'by_self',
|
19
|
-
by_man: 'by_man'
|
20
|
-
}
|
21
|
-
enum state: {
|
22
|
-
|
23
|
-
}
|
24
|
-
|
25
|
-
end
|
26
|
-
|
27
|
-
end
|
28
|
-
end
|