作者 王智

daima

@@ -175,5 +175,9 @@ @@ -175,5 +175,9 @@
175 $("#c-zhao_id_text").data("selectPageObject").option.data = 'user/index?pid=2'; 175 $("#c-zhao_id_text").data("selectPageObject").option.data = 'user/index?pid=2';
176 176
177 } 177 }
  178 +
  179 + var value = $('#c-type').val();
  180 + console.log(value);
  181 +
178 </script> 182 </script>
179 183
@@ -196,6 +196,8 @@ class Common extends Api @@ -196,6 +196,8 @@ class Common extends Api
196 //订单生成 196 //订单生成
197 public function addOrder() 197 public function addOrder()
198 { 198 {
  199 + $map2['endtime'] = ['LT', time()];
  200 + Db::name('renwu')->where($map2)->delete();
199 $map['type'] = ['eq', 1]; 201 $map['type'] = ['eq', 1];
200 $map1['updatetime'] = ['GT', time() - 86400]; 202 $map1['updatetime'] = ['GT', time() - 86400];
201 Db::name('renwu')->where($map)->where($map1)->update( 203 Db::name('renwu')->where($map)->where($map1)->update(
@@ -248,18 +248,30 @@ class User extends Api @@ -248,18 +248,30 @@ class User extends Api
248 { 248 {
249 $param = $this->request->param(); 249 $param = $this->request->param();
250 $user_id = $this->is_token($this->request->header()); 250 $user_id = $this->is_token($this->request->header());
251 - $mobile = Db::name('user')->where('id', $user_id)->value('mobile');  
252 - $this->CheckCode($mobile, $param['code']);  
253 - $data = [  
254 - 'mobile' => $param['mobile'],  
255 - 'car_num' => $param['car_num'],  
256 - 'car_type' => $param['car_type'],  
257 - 'color' => $param['color'],  
258 - 'address' => $param['address'],  
259 - 'address_con' => $param['address_con'],  
260 - 'lng' => $param['lng'],  
261 - 'lat' => $param['lat'],  
262 - ]; 251 + if (!empty($param['mobile']) || $param['mobile'] != '' || $param['mobile'] != "" || $param['mobile'] != null) {
  252 + $mobile = Db::name('user')->where('id', $user_id)->value('mobile');
  253 + $this->CheckCode($mobile, $param['code']);
  254 + $data = [
  255 + 'mobile' => $param['mobile'],
  256 + 'car_num' => $param['car_num'],
  257 + 'car_type' => $param['car_type'],
  258 + 'color' => $param['color'],
  259 + 'address' => $param['address'],
  260 + 'address_con' => $param['address_con'],
  261 + 'lng' => $param['lng'],
  262 + 'lat' => $param['lat'],
  263 + ];
  264 + } else {
  265 + $data = [
  266 + 'car_num' => $param['car_num'],
  267 + 'car_type' => $param['car_type'],
  268 + 'color' => $param['color'],
  269 + 'address' => $param['address'],
  270 + 'address_con' => $param['address_con'],
  271 + 'lng' => $param['lng'],
  272 + 'lat' => $param['lat'],
  273 + ];
  274 + }
263 $res = Db::name('user')->where('id', $user_id)->update($data); 275 $res = Db::name('user')->where('id', $user_id)->update($data);
264 if (!$res) { 276 if (!$res) {
265 $this->error('请填写完整信息', 0); 277 $this->error('请填写完整信息', 0);
@@ -418,6 +430,7 @@ class User extends Api @@ -418,6 +430,7 @@ class User extends Api
418 public function MyOrder() 430 public function MyOrder()
419 { 431 {
420 $user_id = $this->is_token($this->request->header()); 432 $user_id = $this->is_token($this->request->header());
  433 + $this->orderTime($user_id);
421 $param = $this->request->param(); 434 $param = $this->request->param();
422 if ($param['type'] == 1) { 435 if ($param['type'] == 1) {
423 $map = []; 436 $map = [];
@@ -350,7 +350,6 @@ class Api @@ -350,7 +350,6 @@ class Api
350 } 350 }
351 351
352 352
353 -  
354 //计算距离 353 //计算距离
355 function getDistance($lng1, $lat1, $lng2, $lat2, $unit = 2, $decimal = 2) 354 function getDistance($lng1, $lat1, $lng2, $lat2, $unit = 2, $decimal = 2)
356 { 355 {
@@ -454,4 +453,29 @@ class Api @@ -454,4 +453,29 @@ class Api
454 $this->error(__('验证码不正确')); 453 $this->error(__('验证码不正确'));
455 } 454 }
456 } 455 }
  456 +
  457 +
  458 + //检查到期订单
  459 + public function orderTime($UserId)
  460 + {
  461 + $map['createtime'] = ['LT', time() - 60 * 30];
  462 + $Arr = Db::name('order')->where('user_id', $UserId)
  463 + ->where('status', 0)
  464 + ->where($map)
  465 + ->select();
  466 + if (!empty($Arr)) {
  467 + $res = Db::name('order')->where('user_id', $UserId)
  468 + ->where('status', 0)
  469 + ->where($map)
  470 + ->update(
  471 + [
  472 + 'status' => 2,
  473 + 'updatetime' => time()
  474 + ]
  475 + );
  476 + if (!$res) {
  477 + $this->error('订单状态获取失败', 0);
  478 + }
  479 + }
  480 + }
457 } 481 }