5 changed files with 189 additions and 1 deletions
-
35app/Controller/OrderListController.php
-
138app/Service/OrderListService.php
-
12app/Service/OrderListServiceInterface.php
-
3config/autoload/dependencies.php
-
2config/routes.php
@ -0,0 +1,35 @@ |
|||||
|
<?php |
||||
|
|
||||
|
namespace App\Controller; |
||||
|
|
||||
|
use App\Constants\ErrorCode; |
||||
|
use App\Exception\BusinessException; |
||||
|
use App\Service\OrderListServiceInterface; |
||||
|
use http\Client\Curl\User; |
||||
|
use Hyperf\Di\Annotation\Inject; |
||||
|
|
||||
|
class OrderListController extends BaseController |
||||
|
{ |
||||
|
/** |
||||
|
* @Inject |
||||
|
* @var OrderListServiceInterface |
||||
|
*/ |
||||
|
protected $orderListService; |
||||
|
/** |
||||
|
* 店铺订单列表 |
||||
|
*/ |
||||
|
public function storeOrderList() |
||||
|
{ |
||||
|
$res = $this->orderListService->storeOrderList($this->request->all()); |
||||
|
return $this->success($res); |
||||
|
} |
||||
|
/** |
||||
|
* 用户订单列表 |
||||
|
*/ |
||||
|
public function userOrderList() |
||||
|
{ |
||||
|
$res = $this->orderListService->userOrderList($this->request->all()); |
||||
|
return $this->success($res); |
||||
|
} |
||||
|
|
||||
|
} |
||||
@ -0,0 +1,138 @@ |
|||||
|
<?php |
||||
|
|
||||
|
namespace App\Service; |
||||
|
|
||||
|
use App\Model\ServiceEvaluate; |
||||
|
use App\Model\ServicePersonnel; |
||||
|
use App\Model\Users; |
||||
|
use Hyperf\DbConnection\Db; |
||||
|
use Hyperf\HttpServer\Contract\RequestInterface; |
||||
|
use Hyperf\Di\Annotation\Inject; |
||||
|
use Hyperf\Paginator\Paginator; |
||||
|
|
||||
|
class OrderListService implements OrderListServiceInterface |
||||
|
{ |
||||
|
|
||||
|
public function storeOrderList($data) |
||||
|
{ |
||||
|
$data['pagesize'] = intval($data['pagesize']); |
||||
|
$order_main = Db::table('ims_cjdc_order as o') |
||||
|
->join('ims_cjdc_order_main as m','o.order_main_id','=','m.id') |
||||
|
->join('ims_cjdc_storeset as s','s.store_id','=','o.store_id') |
||||
|
->where([ |
||||
|
['o.store_id','=',$data['id']], |
||||
|
['o.type','=',1], |
||||
|
]) |
||||
|
->whereIn('o.state',[$data['state']]) |
||||
|
->select( |
||||
|
's.id', |
||||
|
's.ps_mode', |
||||
|
'm.order_shipping_code', |
||||
|
'o.id as order_id', |
||||
|
'o.address', |
||||
|
'o.delivery_time', |
||||
|
'o.lat', |
||||
|
'o.lng', |
||||
|
'o.money', |
||||
|
'o.name', |
||||
|
'o.note', |
||||
|
'o.order_num', |
||||
|
'o.order_type', |
||||
|
'o.pay_type', |
||||
|
'o.state', |
||||
|
'o.store_id', |
||||
|
'o.time', |
||||
|
'm.dada_status' |
||||
|
) |
||||
|
->paginate($data['pagesize']); |
||||
|
$res = array(); |
||||
|
foreach ($order_main as $k => $v){ |
||||
|
if($v->dada_status > 0){ |
||||
|
$v->ps_mode = '达达配送'; |
||||
|
}else{ |
||||
|
$v->ps_mode = '服务站配送'; |
||||
|
} |
||||
|
$goods = Db::table('ims_cjdc_order_goods') |
||||
|
->where('order_id',$v->order_id) |
||||
|
->select('img','number','name','money') |
||||
|
->get(); |
||||
|
$num = Db::table('ims_cjdc_order_goods') |
||||
|
->where('order_id',$v->order_id) |
||||
|
->sum('number'); |
||||
|
$order_data = array( |
||||
|
'good' => $goods, |
||||
|
'order' => $v, |
||||
|
'num' => $num, |
||||
|
); |
||||
|
$res[$k] = $order_data; |
||||
|
} |
||||
|
return $res; |
||||
|
|
||||
|
} |
||||
|
|
||||
|
public function userOrderList($data) |
||||
|
{ |
||||
|
$order_main = Db::table('ims_cjdc_order_main') |
||||
|
->where([ |
||||
|
['id','=',$data['id']], |
||||
|
['type','=',1], |
||||
|
]) |
||||
|
->select( |
||||
|
'address', |
||||
|
'box_money', |
||||
|
'delivery_time', |
||||
|
'dn_state', |
||||
|
'money', |
||||
|
'name', |
||||
|
'note', |
||||
|
'order_num', |
||||
|
'order_type', |
||||
|
'pay_time', |
||||
|
'pay_type', |
||||
|
'state', |
||||
|
'dada_fee as ps_money', |
||||
|
'time', |
||||
|
'type', |
||||
|
'yhq_money2', |
||||
|
'tel', |
||||
|
'dada_status' |
||||
|
) |
||||
|
->first(); |
||||
|
$order = Db::table('ims_cjdc_order as o') |
||||
|
->join('ims_cjdc_store as s','o.store_id','=','s.id') |
||||
|
->where('o.order_main_id',$data['id']) |
||||
|
->select( |
||||
|
'o.id', |
||||
|
'o.store_id', |
||||
|
'o.name as store_name', |
||||
|
'o.box_money as store_box_money', |
||||
|
'o.mj_money as store_mj_money', |
||||
|
'o.money as store_money', |
||||
|
'o.note as store_note', |
||||
|
's.tel as store_tel', |
||||
|
's.logo as store_logo' |
||||
|
) |
||||
|
->get(); |
||||
|
$store_list = array(); |
||||
|
foreach ($order as $k => $v){ |
||||
|
$goods = Db::table('ims_cjdc_order_goods as og') |
||||
|
->join('ims_cjdc_goods as g','g.id','=','og.good_id') |
||||
|
->where('og.order_id',$v->id) |
||||
|
->select( |
||||
|
'og.id as good_id', |
||||
|
'og.img as good_logo', |
||||
|
'og.money as good_money', |
||||
|
'og.name as good_name', |
||||
|
'og.number as good_num', |
||||
|
'og.spec as good_spec', |
||||
|
'g.is_show' |
||||
|
) |
||||
|
->get(); |
||||
|
$v->good_list = $goods; |
||||
|
$store_list[$v->store_id] = $v; |
||||
|
} |
||||
|
$order_main->store_list = $store_list; |
||||
|
return $order_main; |
||||
|
} |
||||
|
|
||||
|
} |
||||
@ -0,0 +1,12 @@ |
|||||
|
<?php |
||||
|
|
||||
|
namespace App\Service; |
||||
|
|
||||
|
interface OrderListServiceInterface |
||||
|
{ |
||||
|
|
||||
|
public function storeOrderList($data); |
||||
|
|
||||
|
public function userOrderList($data); |
||||
|
|
||||
|
} |
||||
Write
Preview
Loading…
Cancel
Save
Reference in new issue