Commit 96a158b0 authored by hj's avatar hj

更新

parent 8688428c
<?php
namespace App\Http\Controllers\V1\Bhua;
use App\Services\Api\BhuaCustomerService;
use Illuminate\Http\Request;
use Jiannei\Response\Laravel\Support\Facades\Response;
use App\Http\Controllers\V1\Controller;
use App\Support\Traits\Helpers;
class CustomerController extends Controller
{
use Helpers;
public function __construct(BhuaCustomerService $bhuaCustomerService)
{
$this->bhuaCustomerService= $bhuaCustomerService;
$this->controllerType = 'bhua';
}
public function getCustomer(Request $request)
{
$customerCode = $request->get('cusCode');
if(!$customerCode){
return Response::ok('客户编号不存在!');
}
try{
$customer = $this->bhuaCustomerService->getCustomerByNumber($customerCode);
return Response::success($this->formatKeysfromArray($customer),'操作成功');
}catch(\Throwable $exception){
return $this->returnErrorExecptionResponse($exception);
}
}
}
<?php
namespace App\Http\Controllers\V1\Rhawn;
use App\Services\Api\RhawnCustomerService;
use Illuminate\Http\Request;
use Jiannei\Response\Laravel\Support\Facades\Response;
use App\Http\Controllers\V1\Controller;
use App\Support\Traits\Helpers;
class CustomerController extends Controller
{
use Helpers;
public function __construct(RhawnCustomerService $rhawnCustomerService)
{
$this->rhawnCustomerService= $rhawnCustomerService;
$this->controllerType = 'rhawn';
}
public function getCustomer(Request $request)
{
$customerCode = $request->get('cusCode');
if(!$customerCode){
return Response::ok('客户编号不存在!');
}
try{
$customer = $this->rhawnCustomerService->getCustomerByNumber($customerCode);
return Response::success($this->formatKeysfromArray($customer),'操作成功');
}catch(\Throwable $exception){
return $this->returnErrorExecptionResponse($exception);
}
}
}
<?php <?php
/*
* This file is part of the Jiannei/lumen-api-starter.
*
* (c) Jiannei <longjian.huang@foxmail.com>
*
* This source file is subject to the MIT license that is bundled
* with this source code in the file LICENSE.
*/
namespace App\Repositories\Transformers\Chemsite; namespace App\Repositories\Transformers\Chemsite;
use App\Repositories\Models\Model; use App\Repositories\Models\Model;
...@@ -16,7 +7,7 @@ use League\Fractal\TransformerAbstract; ...@@ -16,7 +7,7 @@ use League\Fractal\TransformerAbstract;
class CustomersTransformer extends TransformerAbstract class CustomersTransformer extends TransformerAbstract
{ {
public function transform($customers) public function transform($customers): array
{ {
$customerTransReturn = []; $customerTransReturn = [];
if($customers){ if($customers){
...@@ -36,7 +27,7 @@ class CustomersTransformer extends TransformerAbstract ...@@ -36,7 +27,7 @@ class CustomersTransformer extends TransformerAbstract
$temp['cus_status'] = $customer['cus_status']; $temp['cus_status'] = $customer['cus_status'];
$temp['com_id'] = $customer['com_id']; $temp['com_id'] = $customer['com_id'];
array_push($customerTransReturn,$temp); $customerTransReturn[] = $temp;
} }
} }
return $customerTransReturn; return $customerTransReturn;
......
<?php
namespace App\Repositories\Transformers\Rhawn;
use App\Repositories\Models\Model;
use League\Fractal\TransformerAbstract;
class CustomersTransformer extends TransformerAbstract
{
public function transform($customers): array
{
$customerTransReturn = [];
if($customers){
foreach($customers as $customer){
if($customer instanceof Model){
$customer = $customer->toArray();
}
$temp = [];
$temp['cus_number'] = $customer['cus_no'];
$temp['cus_email'] = $customer['cus_email'];
$temp['cus_name'] = $customer['cus_name'];
$temp['cus_company'] = $customer['cus_company'];
$temp['cus_mobile'] = $customer['cus_mobile'];
$temp['cus_phone'] = $customer['cus_phone'];
$temp['cus_status'] = $customer['cus_status'];
$temp['com_id'] = $customer['com_id'];
$customerTransReturn[] = $temp;
}
}
return $customerTransReturn;
}
}
...@@ -18,9 +18,4 @@ class ChemsiteCustomerService ...@@ -18,9 +18,4 @@ class ChemsiteCustomerService
$customer = $this->customerRepository->getCustomerThroughCusCode($cusCode); $customer = $this->customerRepository->getCustomerThroughCusCode($cusCode);
return $customer->toArray(); return $customer->toArray();
} }
public function getCustomerListByCusCode($cusNo,$offset,$limit): ?array
{
return $this->customerRepository->getCustomerList(['cus_no' => $cusNo],$offset,$limit);
}
} }
<?php
namespace App\Services\Api;
use App\Repositories\Transformers\Rhawn\CustomersTransformer;
use App\Rhawn\Repositories\Eloquent\BhuaCustomerRepositoryEloquent;
class BhuaCustomerService
{
private $bhuaCustomerService;
public function __construct(\App\Rhawn\Services\BhuaCustomerService $bhuaCustomerService)
{
$this->bhuaCustomerService = $bhuaCustomerService;
}
public function getCustomerByNumber($customerNumber)
{
$customer = $this->bhuaCustomerService->getBhuaCustomerThroughtCusCode($customerNumber);
return current(app(BhuaCustomerRepositoryEloquent::class)->transformData([$customer], CustomersTransformer::class));
}
}
<?php
namespace App\Services\Api;
use App\Repositories\Transformers\Chemsite\CustomersTransformer;
use App\Rhawn\Repositories\Eloquent\RhawnCustomerRepositoryEloquent;
class RhawnCustomerService
{
private $rhawnCustomerService;
public function __construct(\App\Rhawn\Services\RhawnCustomerService $rhawnCustomerService)
{
$this->rhawnCustomerService = $rhawnCustomerService;
}
public function getCustomerByNumber($customerNumber)
{
$customer = $this->rhawnCustomerService->getRhawnCustomerThroughtCusCode($customerNumber);
return current(app(RhawnCustomerRepositoryEloquent::class)->transformData([$customer], CustomersTransformer::class));
}
}
...@@ -17,6 +17,9 @@ $api->version('v1', function($api) { ...@@ -17,6 +17,9 @@ $api->version('v1', function($api) {
// 取消订单 // 取消订单
//$api->post('/openapi/rhawn/orders/cancelRhawnOrders', ['permission' => 'orders.cancelRhawnOrders', 'uses'=>'OrdersController@cancelCustomerOrder']); //$api->post('/openapi/rhawn/orders/cancelRhawnOrders', ['permission' => 'orders.cancelRhawnOrders', 'uses'=>'OrdersController@cancelCustomerOrder']);
$api->post('/openapi/rhawn/orders/getOrdersDispatch', ['permission' => 'orders.getOrdersDispatch', 'uses'=>'OrdersController@getOrdersDispatch']); $api->post('/openapi/rhawn/orders/getOrdersDispatch', ['permission' => 'orders.getOrdersDispatch', 'uses'=>'OrdersController@getOrdersDispatch']);
//客户信息
$api->post('/openapi/rhawn/customer/getCustomer', ['permission' => 'chemsite.customer.search', 'uses'=>'CustomerController@getCustomer']);
}); });
$api->group(['namespace'=>'App\Http\Controllers\V1\Rhawn','middleware' => ['throttle:60,1','apiAuth'], 'providers' => 'jwt'], function($api) { $api->group(['namespace'=>'App\Http\Controllers\V1\Rhawn','middleware' => ['throttle:60,1','apiAuth'], 'providers' => 'jwt'], function($api) {
...@@ -34,6 +37,9 @@ $api->version('v1', function($api) { ...@@ -34,6 +37,9 @@ $api->version('v1', function($api) {
// 新建订单 // 新建订单
$api->post('/openapi/bhua/orders/createBhuaOrders', ['permission' => 'orders.createBhuaOrders', 'uses'=>'OrdersController@createCustomerNewOrder']); $api->post('/openapi/bhua/orders/createBhuaOrders', ['permission' => 'orders.createBhuaOrders', 'uses'=>'OrdersController@createCustomerNewOrder']);
$api->post('/openapi/bhua/orders/getOrdersDispatch', ['permission' => 'orders.getOrdersDispatch', 'uses'=>'OrdersController@getOrdersDispatch']); $api->post('/openapi/bhua/orders/getOrdersDispatch', ['permission' => 'orders.getOrdersDispatch', 'uses'=>'OrdersController@getOrdersDispatch']);
//客户信息
$api->post('/openapi/bhua/customer/getCustomer', ['permission' => 'chemsite.customer.search', 'uses'=>'CustomerController@getCustomer']);
}); });
$api->group(['namespace'=>'App\Http\Controllers\V1\Bhua','middleware' => ['throttle:60,1','apiAuth'], 'providers' => 'jwt'], function($api) { $api->group(['namespace'=>'App\Http\Controllers\V1\Bhua','middleware' => ['throttle:60,1','apiAuth'], 'providers' => 'jwt'], function($api) {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment