Commit 98c98588 authored by hangjun83's avatar hangjun83

发票相关接口

parent 19ce92a9
......@@ -39,4 +39,21 @@ class RhawnInvoiceItemsRepositoryEloquent extends BaseRepository implements Rhaw
return $invoiceItemInfo;
}
public function getInvoiceSorderItemsBySoItemsId($itemId)
{
$invoiceItemInfo = null;
$invoiceItemInfo = $this->join('dpdetail', 'dpdetail.dpd_id', 'soidetail.dpd_id')
->join('soitems', 'soitems.si_id', 'dpdetail.si_id')
->join('sorders', 'sorders.so_id', 'soitems.so_id')
->join('products', 'products.p_id', 'soitems.p_id')
->whereIn('soidetail.soid_id', $itemId)
/*->select(
'soidetail.soi_id','soidetail.soid_id', 'soidetail.soid_amount', 'dpdetail.dpd_num',
'products.p_code', 'products.p_cn_name', 'products.p_pack', 'products.p_pack_unit', 'products.p_price'
)*/->get()->toArray();
return $invoiceItemInfo;
}
}
<?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\Http\Controllers\V1\Rhawn;
use App\Services\Api\RhawnInvoicesService;
use Illuminate\Http\Request;
use Jiannei\Response\Laravel\Support\Facades\Response;
use App\Http\Controllers\V1\Controller;
use App\Support\Traits\Helpers;
use OpenApi\Annotations\Post;
use OpenApi\Annotations\RequestBody;
use OpenApi\Annotations\MediaType;
use OpenApi\Annotations\Schema;
use OpenApi\Annotations\Property;
use OpenApi\Annotations\Response as AnnotationResponse;
use OpenApi\Annotations as OA;
class InvoiceController extends Controller
{
use Helpers;
public function __construct(RhawnInvoicesService $rhawnInvoicesService)
{
$this->rhawnInvoicesService= $rhawnInvoicesService;
$this->controllerType = 'rhawn';
}
/**
* @Post(
* path="/openapi/rhawn/invoice/getInvoiceSorderItems",
* tags={"罗恩 - 发票相关接口"},
* summary="发票订单列表数据",
* description="发票订单列表",
* @RequestBody(
* @MediaType(
* mediaType="application/json",
* @Schema(
* required={"invoiceNumber"},
* @Property(property="invoiceNumber", @Schema(type="string"),description="返回数据集数量"),
* example={"invoiceNumber" : 0999899011}
* ),
* )
* ),
* @OA\Parameter(
* description="用户获取的token值",
* in="header",
* name="authorization",
* required=true,
* @OA\Schema(type="string"),
* @OA\Examples(example="authorization", value="bearerNWJiNDhkNzlmNjg0N2FlMmZiYjliZWM3NGVkNzIyMjNleUpsZUhCcGNtVWlPakUyTmpRMk1EazJORGNzSW1oaGMyZ2lPaUl5ZEhsc1JIQlhkWFpNUVdaWGJVRllJbjA9",summary=""),
* ),
* @AnnotationResponse(
* response="200",
* description="正常操作响应",
* @MediaType(
* mediaType="application/json",
* @Schema(
* allOf={
* @Schema(ref="#/components/schemas/ApiResponse"),
* @Schema(
* type="object",
* @Property(property="data", ref="#/components/schemas/invoiceOrderItemsList")
* )
* }
* )
* )
* ),
* security={
* {"bearer_token":{}}
* }
* )
*/
public function getInvoiceSorderItems(Request $request)
{
$customerCode = $request->get('customer_code');
if(!$customerCode){
return Response::ok('客户编号不存在!');
}
$this->checkCustomerType($customerCode,$this->controllerType);
$requestParams = $this->formatKeysfromArray($request->all(),'toUnderScore');
$requestParams = array_merge($requestParams,['customer_code' => $customerCode]);
try{
$orderList = $this->rhawnInvoicesService->getInoviceItems($requestParams);
if($orderList){
$orderList = $this->formatKeysfromArray($orderList,'toCamelCase');
}
return Response::success($orderList,'操作成功');
}catch(\Throwable $exception){
return $this->returnErrorExecptionResponse($exception,'获取订单列表失败');
}
}
}
<?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\Rhawn\Repositories\Contracts;
use Prettus\Repository\Contracts\RepositoryInterface;
/**
* Interface UserRepository.
*/
interface RhawnInvoiceRepository extends RepositoryInterface
{
}
<?php
namespace App\Rhawn\Repositories\Eloquent;
use App\Rhawn\Repositories\Contracts\RhawnInvoiceRepository;
use App\Rhawn\Repositories\Models\RhawnInvoice;
use Illuminate\Support\Facades\DB;
use Illuminate\Validation\Rules\In;
class RhawnInvoiceRepositoryEloquent extends BaseRepository implements RhawnInvoiceRepository
{
/**
* Specify Model class name.
*
* @return string
*/
public function model()
{
return RhawnInvoice::class;
}
public function getInvoiceItemsByInvoiceNumber($invoiceNumber)
{
$invoiceDetailInfo = $this
->join('soidetail','soinvoice.soi_id','soidetail.soi_id')
->where('soinvoice.soi_no','=',$invoiceNumber)
->get()->toArray();
if(!$invoiceDetailInfo){
return null;
}
return $invoiceDetailInfo;
}
}
......@@ -54,8 +54,12 @@ class RhawnSoitemsRepositoryEloquent extends BaseRepository implements RhawnSoit
->join('sorders','sorders.so_id','soitems.so_id')
->join('products','soitems.p_id','products.p_id')
->join('chemicals','products.c_id','chemicals.c_id')
->join('brands','products.b_id','brands.b_id')
->where('soitems.si_id',$itemId);
->join('brands','products.b_id','brands.b_id');
if(is_array($itemId)){
$soItems->whereIn('soitems.si_id',$itemId);
}else{
$soItems->where('soitems.si_id',$itemId);
}
if(!is_null($pid)){
$soItems = $soItems->where('soitems.p_id',$pid);
}
......@@ -74,10 +78,10 @@ class RhawnSoitemsRepositoryEloquent extends BaseRepository implements RhawnSoit
*/
public function getSorderItemFromItemId($si_id)
{
$item = $this->find($si_id);
/*$item = $this->find($si_id);
if(!$item){
throw new \LogicException('该订单项不存在!',500);
}
}*/
//查询订单的详情
$soModel = RhawnSoitems::query()
......
<?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\Rhawn\Repositories\Models;
use App\Repositories\Models\Model;
class RhawnInvoice extends Model
{
// 销售订单
protected $table = 'soinvoice';
protected $connection = 'rhawn_mysql';
protected $primaryKey = 'soi_id';
/**
* The attributes that are mass assignable.
*
* @var array
*/
protected $fillable = [
];
protected $guarded = ['created_at', 'updated_at'];
/**
* The attributes excluded from the model's JSON form.
*
* @var array
*/
protected $hidden = [
];
/**
* update时不做自动更新时间操作
* @return null
*/
public function getUpdatedAtColumn()
{
return null;
}
public function getCreatedAtColumn()
{
return null;
}
}
\ No newline at end of file
......@@ -23,6 +23,7 @@ class RhawnOrdersService
public function __construct()
{
$this->rhawnSorderRepository = app(RhawnSordersRepositoryEloquent::class);
$this->rhawnSorderItemsRepository = app(RhawnSoitemsRepositoryEloquent::class);
}
public function getCustomerOrderItems($cusCode, $soItems)
......
......@@ -95,8 +95,8 @@ class BhuaProductsService
SimpleLogs::writeLog($exception->getMessage(),__CLASS__.':getProductsByBrandId','error');
throw $exception;
}
}
}
}
<?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\Services\Api;
use App\Finance\Services\InvoiceService;
use App\Rhawn\Repositories\Eloquent\RhawnInvoiceRepositoryEloquent;
use Illuminate\Support\Facades\DB;
class RhawnInvoicesService
{
public function __construct(InvoiceService $invoiceService)
{
$this->rhawnOrdersService = app(\App\Rhawn\Services\RhawnOrdersService::class);
$this->invoiceService = $invoiceService;
$this->invoiceRepository = app(RhawnInvoiceRepositoryEloquent::class);
}
public function getInoviceItems($requestParams)
{
if(!isset($requestParams['invoice_real_number']) || empty($requestParams['invoice_real_number'])){
throw new \Exception('发票号码为空',502);
}
$invoiceRecord = $this->invoiceService->invoiceRecordRepository->getInvoiceRecordByRealNumber($requestParams['invoice_real_number']);
if(!$invoiceRecord){
throw new \Exception('该发票号码无效',502);
}
$invoiceRecord = current($invoiceRecord);
switch($invoiceRecord['invoice_platform']){
case 'rhawn' : $invoiceItems = $this->invoiceRepository->getInvoiceItemsByInvoiceNumber($invoiceRecord['invoice_real_number']);break;
}
if(!$invoiceItems){
throw new \Exception('无法查询该发票号对应明细',502);
}
$invoiceItemsId = [];
foreach($invoiceItems as $item){
$invoiceItemsId[] = $item['soid_id'];
}
$sorderItems = $this->rhawnOrdersService->rhawnSorderItemsRepository->getInvoiceSorderItemsBySoItemsId($invoiceItemsId);
var_dump($sorderItems);
exit;
}
}
......@@ -36,6 +36,10 @@ $api->version('v1', function($api) {
$api->post('/openapi/rhawn/products/getProductByCas', ['permission' => 'orders.getProductByCas', 'uses'=>'ProductsController@getProductByCas']);
});
$api->group(['namespace'=>'App\Http\Controllers\V1\Rhawn','middleware' => ['throttle:60,1','apiAuth'], 'providers' => 'jwt'], function($api) {
$api->post('/openapi/rhawn/invoice/getInvoiceSorderItems', ['permission' => 'orders.getInvoiceSorderItems', 'uses'=>'InvoiceController@getInvoiceSorderItems']);
});
// 百化接口
$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