正在显示
7 个修改的文件
包含
92 行增加
和
12 行删除
@@ -22,14 +22,15 @@ class Specificaddress extends Backend | @@ -22,14 +22,15 @@ class Specificaddress extends Backend | ||
22 | * @var \app\admin\model\Specificaddress | 22 | * @var \app\admin\model\Specificaddress |
23 | */ | 23 | */ |
24 | protected $model = null; | 24 | protected $model = null; |
25 | + protected $routemodel = null; | ||
25 | 26 | ||
26 | public function _initialize() | 27 | public function _initialize() |
27 | { | 28 | { |
28 | parent::_initialize(); | 29 | parent::_initialize(); |
29 | $this->model = new \app\admin\model\Specificaddress; | 30 | $this->model = new \app\admin\model\Specificaddress; |
31 | + $this->routemodel=new \app\admin\model\Route(); | ||
30 | $route_id = $this->request->param("route_id"); | 32 | $route_id = $this->request->param("route_id"); |
31 | $this->view->assign("route_id", $route_id); | 33 | $this->view->assign("route_id", $route_id); |
32 | - | ||
33 | } | 34 | } |
34 | 35 | ||
35 | 36 | ||
@@ -60,9 +61,15 @@ class Specificaddress extends Backend | @@ -60,9 +61,15 @@ class Specificaddress extends Backend | ||
60 | } | 61 | } |
61 | [$where, $sort, $order, $offset, $limit] = $this->buildparams(); | 62 | [$where, $sort, $order, $offset, $limit] = $this->buildparams(); |
62 | $list = $this->model | 63 | $list = $this->model |
64 | + ->with(['route']) | ||
63 | ->where($where) | 65 | ->where($where) |
64 | ->order($sort, $order) | 66 | ->order($sort, $order) |
65 | ->paginate($limit); | 67 | ->paginate($limit); |
68 | + foreach ($list as $row) { | ||
69 | + $row->visible(['id','specific_address','route_id']); | ||
70 | + $row->visible(['route']); | ||
71 | + $row->getRelation('route')->visible(['name']); | ||
72 | + } | ||
66 | $result = ['total' => $list->total(), 'rows' => $list->items()]; | 73 | $result = ['total' => $list->total(), 'rows' => $list->items()]; |
67 | return json($result); | 74 | return json($result); |
68 | } | 75 | } |
@@ -74,7 +81,11 @@ class Specificaddress extends Backend | @@ -74,7 +81,11 @@ class Specificaddress extends Backend | ||
74 | */ | 81 | */ |
75 | public function add() | 82 | public function add() |
76 | { | 83 | { |
84 | + | ||
77 | if (false === $this->request->isPost()) { | 85 | if (false === $this->request->isPost()) { |
86 | + $route_id = $this->request->param("route_id"); | ||
87 | + $route=$this->routemodel->find($route_id); | ||
88 | + $this->view->assign("route", $route); | ||
78 | return $this->view->fetch(); | 89 | return $this->view->fetch(); |
79 | } | 90 | } |
80 | $params = $this->request->post('row/a'); | 91 | $params = $this->request->post('row/a'); |
@@ -104,7 +115,57 @@ class Specificaddress extends Backend | @@ -104,7 +115,57 @@ class Specificaddress extends Backend | ||
104 | if ($result === false) { | 115 | if ($result === false) { |
105 | $this->error(__('No rows were inserted')); | 116 | $this->error(__('No rows were inserted')); |
106 | } | 117 | } |
118 | + | ||
119 | + $this->success(); | ||
120 | + } | ||
121 | + /** | ||
122 | + * 编辑 | ||
123 | + * | ||
124 | + * @param $ids | ||
125 | + * @return string | ||
126 | + * @throws DbException | ||
127 | + * @throws \think\Exception | ||
128 | + */ | ||
129 | + public function edit($ids = null) | ||
130 | + { | ||
131 | + $row = $this->model->get($ids); | ||
132 | + if (!$row) { | ||
133 | + $this->error(__('No Results were found')); | ||
134 | + } | ||
135 | + $adminIds = $this->getDataLimitAdminIds(); | ||
136 | + if (is_array($adminIds) && !in_array($row[$this->dataLimitField], $adminIds)) { | ||
137 | + $this->error(__('You have no permission')); | ||
138 | + } | ||
139 | + if (false === $this->request->isPost()) { | ||
140 | + $this->view->assign('row', $row); | ||
141 | + $route_id = $this->request->param("route_id"); | ||
142 | + $route=$this->routemodel->find($route_id); | ||
143 | + $this->view->assign("route", $route); | ||
144 | + return $this->view->fetch(); | ||
145 | + } | ||
146 | + $params = $this->request->post('row/a'); | ||
147 | + if (empty($params)) { | ||
148 | + $this->error(__('Parameter %s can not be empty', '')); | ||
149 | + } | ||
150 | + $params = $this->preExcludeFields($params); | ||
151 | + $result = false; | ||
152 | + Db::startTrans(); | ||
153 | + try { | ||
154 | + //是否采用模型验证 | ||
155 | + if ($this->modelValidate) { | ||
156 | + $name = str_replace("\\model\\", "\\validate\\", get_class($this->model)); | ||
157 | + $validate = is_bool($this->modelValidate) ? ($this->modelSceneValidate ? $name . '.edit' : $name) : $this->modelValidate; | ||
158 | + $row->validateFailException()->validate($validate); | ||
159 | + } | ||
160 | + $result = $row->allowField(true)->save($params); | ||
161 | + Db::commit(); | ||
162 | + } catch (ValidateException|PDOException|Exception $e) { | ||
163 | + Db::rollback(); | ||
164 | + $this->error($e->getMessage()); | ||
165 | + } | ||
166 | + if (false === $result) { | ||
167 | + $this->error(__('No rows were updated')); | ||
168 | + } | ||
107 | $this->success(); | 169 | $this->success(); |
108 | } | 170 | } |
109 | - | ||
110 | } | 171 | } |
@@ -27,13 +27,16 @@ class Specificaddress extends Model | @@ -27,13 +27,16 @@ class Specificaddress extends Model | ||
27 | protected $append = [ | 27 | protected $append = [ |
28 | 28 | ||
29 | ]; | 29 | ]; |
30 | - | ||
31 | 30 | ||
32 | - | ||
33 | 31 | ||
34 | 32 | ||
35 | 33 | ||
36 | 34 | ||
35 | + public function route() | ||
36 | + { | ||
37 | + return $this->belongsTo('Route', 'route_id', 'id', [], 'LEFT')->setEagerlyType(0); | ||
38 | + } | ||
39 | + | ||
37 | 40 | ||
38 | 41 | ||
39 | 42 |
@@ -8,7 +8,11 @@ | @@ -8,7 +8,11 @@ | ||
8 | 8 | ||
9 | </div> | 9 | </div> |
10 | <div class="form-group"> | 10 | <div class="form-group"> |
11 | - <label class="control-label col-xs-12 col-sm-2">{:__('Specific_address')}:</label> | 11 | + {if $route.type==1} |
12 | + <label class="control-label col-xs-12 col-sm-2">目的地:</label> | ||
13 | + {else} | ||
14 | + <label class="control-label col-xs-12 col-sm-2">上车点:</label> | ||
15 | + {/if} | ||
12 | <div class="col-xs-12 col-sm-8"> | 16 | <div class="col-xs-12 col-sm-8"> |
13 | <input id="c-specific_address" class="form-control" name="row[specific_address]" type="text"> | 17 | <input id="c-specific_address" class="form-control" name="row[specific_address]" type="text"> |
14 | </div> | 18 | </div> |
@@ -7,7 +7,11 @@ | @@ -7,7 +7,11 @@ | ||
7 | </div> | 7 | </div> |
8 | </div> | 8 | </div> |
9 | <div class="form-group"> | 9 | <div class="form-group"> |
10 | - <label class="control-label col-xs-12 col-sm-2">{:__('Specific_address')}:</label> | 10 | + {if $route.type==1} |
11 | + <label class="control-label col-xs-12 col-sm-2">目的地:</label> | ||
12 | + {else} | ||
13 | + <label class="control-label col-xs-12 col-sm-2">上车点:</label> | ||
14 | + {/if} | ||
11 | <div class="col-xs-12 col-sm-8"> | 15 | <div class="col-xs-12 col-sm-8"> |
12 | <input id="c-specific_address" class="form-control" name="row[specific_address]" type="text" value="{$row.specific_address|htmlentities}"> | 16 | <input id="c-specific_address" class="form-control" name="row[specific_address]" type="text" value="{$row.specific_address|htmlentities}"> |
13 | </div> | 17 | </div> |
@@ -90,6 +90,7 @@ class Car extends Base | @@ -90,6 +90,7 @@ class Car extends Base | ||
90 | $phone = $this->request->param("phone");//联系手机号码 | 90 | $phone = $this->request->param("phone");//联系手机号码 |
91 | $user_name = $this->request->param("user_name");//联系人 | 91 | $user_name = $this->request->param("user_name");//联系人 |
92 | $position = $this->request->param("position");//上车地址 | 92 | $position = $this->request->param("position");//上车地址 |
93 | + $specificaddress_id = $this->request->param("specificaddress_id");//上车地址 | ||
93 | $seat_no = $this->request->param("seat_no");//座位 | 94 | $seat_no = $this->request->param("seat_no");//座位 |
94 | $lat = $this->request->param("lat");//经度 | 95 | $lat = $this->request->param("lat");//经度 |
95 | $lng = $this->request->param("lng");//维度 | 96 | $lng = $this->request->param("lng");//维度 |
@@ -150,6 +151,7 @@ class Car extends Base | @@ -150,6 +151,7 @@ class Car extends Base | ||
150 | "car_id"=>$car_id, | 151 | "car_id"=>$car_id, |
151 | "order_review_id"=>$order_review_id, | 152 | "order_review_id"=>$order_review_id, |
152 | "route_id"=>$route_id, | 153 | "route_id"=>$route_id, |
154 | + "specificaddress_id"=>$specificaddress_id, | ||
153 | "user_id"=>$this->auth->id, | 155 | "user_id"=>$this->auth->id, |
154 | "phone"=>$phone, | 156 | "phone"=>$phone, |
155 | "user_name"=>$user_name, | 157 | "user_name"=>$user_name, |
@@ -961,6 +963,7 @@ class Car extends Base | @@ -961,6 +963,7 @@ class Car extends Base | ||
961 | $route_id = $this->request->param("route_id");//线路 | 963 | $route_id = $this->request->param("route_id");//线路 |
962 | $position = $this->request->param("position");//上车地址 | 964 | $position = $this->request->param("position");//上车地址 |
963 | $lat = $this->request->param("lat");//经度 | 965 | $lat = $this->request->param("lat");//经度 |
966 | + $specificaddress_id = $this->request->param("specificaddress_id");//区域id | ||
964 | $lng = $this->request->param("lng");//维度 | 967 | $lng = $this->request->param("lng");//维度 |
965 | $number = $this->request->param("number");//乘车人数 | 968 | $number = $this->request->param("number");//乘车人数 |
966 | $carmodel_id = $this->request->param("carmodel_id");//乘车人数 | 969 | $carmodel_id = $this->request->param("carmodel_id");//乘车人数 |
@@ -978,6 +981,7 @@ class Car extends Base | @@ -978,6 +981,7 @@ class Car extends Base | ||
978 | "price"=>$price, | 981 | "price"=>$price, |
979 | "driver_id"=>$driver['id'], | 982 | "driver_id"=>$driver['id'], |
980 | "is_qrcode"=>$is_qrcode, | 983 | "is_qrcode"=>$is_qrcode, |
984 | + "specificaddress_id"=>$specificaddress_id, | ||
981 | "reservation_time"=>$reservation_time, | 985 | "reservation_time"=>$reservation_time, |
982 | "is_pay"=>"2",//未支付 | 986 | "is_pay"=>"2",//未支付 |
983 | "route_id"=>$route_id, | 987 | "route_id"=>$route_id, |
@@ -1025,6 +1029,7 @@ class Car extends Base | @@ -1025,6 +1029,7 @@ class Car extends Base | ||
1025 | $carmodel_id = $this->request->param("carmodel_id");//乘车人数 | 1029 | $carmodel_id = $this->request->param("carmodel_id");//乘车人数 |
1026 | $reservation_time = $this->request->param("reservation_time");//预约时间 | 1030 | $reservation_time = $this->request->param("reservation_time");//预约时间 |
1027 | $phone = $this->request->param("phone");//联系电话 | 1031 | $phone = $this->request->param("phone");//联系电话 |
1032 | + $specificaddress_id = $this->request->param("specificaddress_id");//区域id | ||
1028 | $intended_driver_id = $this->request->param("intended_driver_id");//意向司机 | 1033 | $intended_driver_id = $this->request->param("intended_driver_id");//意向司机 |
1029 | $remarks = $this->request->param("remarks");//备注 | 1034 | $remarks = $this->request->param("remarks");//备注 |
1030 | $driver=Db::name("driver")->where("id",$intended_driver_id)->find(); | 1035 | $driver=Db::name("driver")->where("id",$intended_driver_id)->find(); |
@@ -1036,6 +1041,7 @@ class Car extends Base | @@ -1036,6 +1041,7 @@ class Car extends Base | ||
1036 | "order_no"=>getOrderSn(), | 1041 | "order_no"=>getOrderSn(), |
1037 | "price"=>$price, | 1042 | "price"=>$price, |
1038 | "is_qrcode"=>$is_qrcode, | 1043 | "is_qrcode"=>$is_qrcode, |
1044 | + "specificaddress_id"=>$specificaddress_id, | ||
1039 | "reservation_time"=>$reservation_time, | 1045 | "reservation_time"=>$reservation_time, |
1040 | "is_pay"=>"1",//未支付 | 1046 | "is_pay"=>"1",//未支付 |
1041 | "route_id"=>$route_id, | 1047 | "route_id"=>$route_id, |
@@ -1144,10 +1150,8 @@ class Car extends Base | @@ -1144,10 +1150,8 @@ class Car extends Base | ||
1144 | $indexList = array_keys($charArray); | 1150 | $indexList = array_keys($charArray); |
1145 | $itemArr = array_values($charArray); | 1151 | $itemArr = array_values($charArray); |
1146 | } | 1152 | } |
1147 | - | ||
1148 | array_unshift($indexList, "*"); | 1153 | array_unshift($indexList, "*"); |
1149 | $this->success("数据获取成功", ["indexList" => $indexList, "itemArr" => $itemArr]); | 1154 | $this->success("数据获取成功", ["indexList" => $indexList, "itemArr" => $itemArr]); |
1150 | - | ||
1151 | } | 1155 | } |
1152 | 1156 | ||
1153 | 1157 | ||
@@ -1208,14 +1212,15 @@ class Car extends Base | @@ -1208,14 +1212,15 @@ class Car extends Base | ||
1208 | "order_no"=>getOrderSn(), | 1212 | "order_no"=>getOrderSn(), |
1209 | ]; | 1213 | ]; |
1210 | $res=Db::name("order")->where("id",$order['id'])->update($data); | 1214 | $res=Db::name("order")->where("id",$order['id'])->update($data); |
1211 | - $userinfo = Db::name('user') | 1215 | + $order=Db::name("order")->where("order_no",$order_no)->find(); |
1216 | + $userinfo = Db::name('user') | ||
1212 | ->where(['id' => $this->auth->id]) | 1217 | ->where(['id' => $this->auth->id]) |
1213 | ->field('id,wx_xcx_openid') | 1218 | ->field('id,wx_xcx_openid') |
1214 | ->find(); | 1219 | ->find(); |
1215 | $notifyURI = $this->doman . '/addons/epay/api/OrderPayNtf'; | 1220 | $notifyURI = $this->doman . '/addons/epay/api/OrderPayNtf'; |
1216 | $params = [ | 1221 | $params = [ |
1217 | - 'amount' => $data['price'], | ||
1218 | - 'orderid' => $data['order_no'], | 1222 | + 'amount' => $order['price'], |
1223 | + 'orderid' => $order['order_no'], | ||
1219 | 'type' => 'wechat', | 1224 | 'type' => 'wechat', |
1220 | 'notifyurl' => $notifyURI, | 1225 | 'notifyurl' => $notifyURI, |
1221 | 'method' => 'miniapp', | 1226 | 'method' => 'miniapp', |
@@ -29,6 +29,8 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefin | @@ -29,6 +29,8 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefin | ||
29 | [ | 29 | [ |
30 | {checkbox: true}, | 30 | {checkbox: true}, |
31 | {field: 'id', title: __('Id')}, | 31 | {field: 'id', title: __('Id')}, |
32 | + {field: 'route_id', title: __('Route_id')}, | ||
33 | + {field: 'route.name', title: __('Route.name')}, | ||
32 | {field: 'specific_address', title: __('Specific_address'), operate: 'LIKE', table: table, class: 'autocontent', formatter: Table.api.formatter.content}, | 34 | {field: 'specific_address', title: __('Specific_address'), operate: 'LIKE', table: table, class: 'autocontent', formatter: Table.api.formatter.content}, |
33 | {field: 'operate', title: __('Operate'), table: table, events: Table.api.events.operate, formatter: Table.api.formatter.operate} | 35 | {field: 'operate', title: __('Operate'), table: table, events: Table.api.events.operate, formatter: Table.api.formatter.operate} |
34 | ] | 36 | ] |
-
请 注册 或 登录 后发表评论