...
|
...
|
@@ -6,6 +6,8 @@ namespace app\api\controller; |
|
|
|
|
|
use app\api\model\RiderOrder;
|
|
|
use app\common\controller\Api;
|
|
|
use think\Config;
|
|
|
use think\Db;
|
|
|
|
|
|
/**
|
|
|
* 骑手
|
...
|
...
|
@@ -13,7 +15,7 @@ use app\common\controller\Api; |
|
|
class Rider extends Api
|
|
|
{
|
|
|
protected $noNeedRight = ['*'];
|
|
|
// protected $noNeedLogin = ['*'];
|
|
|
protected $noNeedLogin = ['*'];
|
|
|
|
|
|
/**
|
|
|
* @ApiTitle (骑手订单页)
|
...
|
...
|
@@ -142,4 +144,155 @@ class Rider extends Api |
|
|
$data['all_order'] = $allcount;
|
|
|
$this->success('骑手个人页',$data);
|
|
|
}
|
|
|
|
|
|
|
|
|
/**
|
|
|
* @ApiTitle (骑手订单详情)
|
|
|
* @ApiMethod (POST)
|
|
|
* @ApiHeaders (name=token, type=string, required=true, description="请求的Token")
|
|
|
* @ApiHeaders (name=id, type=integer, required=true, description="骑手订单id")
|
|
|
* @ApiHeaders (name=lat, type=float, required=true, description="纬度")
|
|
|
* @ApiHeaders (name=lng, type=float, required=true, description="经度")
|
|
|
* @ApiReturn ({
|
|
|
'code':'1',
|
|
|
'msg':'返回成功'
|
|
|
'data':
|
|
|
"id": 7,
|
|
|
"order_no": "LQ-16420622494781", 订单编号
|
|
|
"distance": 111.3195, 距离
|
|
|
"address": {
|
|
|
"id": 1,
|
|
|
"name": "1", 姓名
|
|
|
"phone": "13549059988",
|
|
|
"detail": "阿松大1", 门牌号
|
|
|
"address": "阿松大", 地址
|
|
|
"order_id": 7,
|
|
|
"user_id": 1,
|
|
|
"lat": "116.397128",
|
|
|
"lng": "39.916527",
|
|
|
"createtime": 0,
|
|
|
"province_id": 1,
|
|
|
"city_id": 2,
|
|
|
"region_id": 3,
|
|
|
"mobile_hide": "135****9988" 电话号码
|
|
|
},
|
|
|
"goods": [
|
|
|
{
|
|
|
"goods_name": "Mate 20 华为 HUAWEI ",
|
|
|
"goods_attr": "极光色 8GB+128GB",
|
|
|
"image_text": "http://temporaryfood.qiniu.broing.cn123132"
|
|
|
},
|
|
|
{
|
|
|
"goods_name": "MacBook Pro 13寸",
|
|
|
"goods_attr": "天空灰",
|
|
|
"image_text": "http://temporaryfood.qiniu.broing.cn123132"
|
|
|
}
|
|
|
],
|
|
|
"createtime_text": ""
|
|
|
})
|
|
|
*/
|
|
|
public function orderDetail()
|
|
|
{
|
|
|
$id = $this->request->post('id');
|
|
|
$lat = $this->request->post('lat');
|
|
|
$lng = $this->request->post('lng');
|
|
|
$rider_order = RiderOrder::get($id);
|
|
|
$ordermodel = new \app\api\model\Order();
|
|
|
$order = $ordermodel
|
|
|
->with(['address','goods'])
|
|
|
->where('fa_litestore_order.id',$rider_order['order_id'])
|
|
|
->find();
|
|
|
$order->visible(['order_no','address','goods','id','distance']);
|
|
|
foreach ($order->getRelation('goods') as $key => $value){
|
|
|
$value->visible(['goods_name','goods_attr']);
|
|
|
}
|
|
|
$lat1 = $order['address']['lat'];
|
|
|
$lng1 = $order['address']['lng'];
|
|
|
$lat2 = $lat;
|
|
|
$lng2 = $lng;
|
|
|
$order['distance'] = getDistance($lat1,$lng1,$lat2,$lng2);
|
|
|
$this->success('骑手个人页',$order);
|
|
|
}
|
|
|
|
|
|
|
|
|
/**
|
|
|
* @ApiTitle (骑手已送达)
|
|
|
* @ApiMethod (POST)
|
|
|
* @ApiHeaders (name=token, type=string, required=true, description="请求的Token")
|
|
|
* @ApiHeaders (name=id, type=integer, required=true, description="骑手订单id")
|
|
|
* @ApiReturn ({
|
|
|
'code':'1',
|
|
|
'msg':'送达成功'
|
|
|
})
|
|
|
*/
|
|
|
public function orderService()
|
|
|
{
|
|
|
$id = $this->request->post('id');
|
|
|
$rider_order = RiderOrder::get($id);
|
|
|
$ordermodel = new \app\api\model\Order();
|
|
|
$order = $ordermodel
|
|
|
->where('id',$rider_order['order_id'])
|
|
|
->find();
|
|
|
if ($order['rider_status'] == 20) $this->error('该订单已送达');
|
|
|
$order->rider_status = '20';
|
|
|
$order->isUpdate()->save();
|
|
|
$rider_order->status = '2';
|
|
|
$rider_order->sendtime = time();
|
|
|
$rider_order->isUpdate()->save();
|
|
|
$data = [
|
|
|
'user_id' => $this->auth->id,
|
|
|
'money' => $order->express_price,
|
|
|
'memo' => '订单运费',
|
|
|
'createtime' => time()
|
|
|
];
|
|
|
Db::name('user_money_log')->insert($data);
|
|
|
$this->success('送达成功',$order);
|
|
|
}
|
|
|
|
|
|
|
|
|
/**
|
|
|
* @ApiTitle (骑手提现)
|
|
|
* @ApiMethod (POST)
|
|
|
* @ApiHeaders (name=token, type=string, required=true, description="请求的Token")
|
|
|
* @ApiHeaders (name=money, type=integer, required=true, description="提现金额")
|
|
|
* @ApiReturn ({
|
|
|
'code':'1',
|
|
|
'msg':'送达成功'
|
|
|
})
|
|
|
*/
|
|
|
public function withdraw()
|
|
|
{
|
|
|
$money = $this->request->post('money');
|
|
|
$user = $this->auth->getUser();
|
|
|
if ($user['money'] < $money) $this->error('可提现金额不足');
|
|
|
$user->setDec('money',$money);
|
|
|
$data = [
|
|
|
'user_id' => $this->auth->id,
|
|
|
'money' => $money,
|
|
|
'memo' => '提现',
|
|
|
'createtime' => time()
|
|
|
];
|
|
|
Db::name('user_money_log')->insert($data);
|
|
|
$this->success('提现成功');
|
|
|
}
|
|
|
|
|
|
|
|
|
/**
|
|
|
* @ApiTitle (联系客服)
|
|
|
* @ApiMethod (POST)
|
|
|
* @ApiHeaders (name=token, type=string, required=true, description="请求的Token")
|
|
|
* @ApiReturn ({
|
|
|
'code':'1',
|
|
|
'msg':'送达成功'
|
|
|
})
|
|
|
*/
|
|
|
public function service()
|
|
|
{
|
|
|
$data = [
|
|
|
'qrcode' => cdnurl(Config::get('site.work_qrcode'),true),
|
|
|
'time' => Config::get('site.work_time'),
|
|
|
'mobile' => Config::get('site.work_mobile')
|
|
|
];
|
|
|
$this->success('客服信息',$data);
|
|
|
}
|
|
|
} |
|
|
\ No newline at end of file |
...
|
...
|
|