Commit 702b1cb1 authored by hj's avatar hj

更新提交

parent f9ee1544
......@@ -92,11 +92,17 @@ class Authenticate
}
$customerService = app(CustomerService::class);
try{
$customer = $customerService->getCustomerInfoByToken($decodeToken['hash']);
list($token, $cusNumber) = explode(',', base64_decode($decodeToken['hash']));
$customer = $customerService->getCustomerInfoByToken($token);
if($customer['status'] == 0){
return Response::fail('用户已被禁用,请联系管理员',500,'');
}
if($customer['cus_type'] == 'chemsite'){
$request->attributes->add(['company_code' => $customer['cus_number'], 'cus_number' => $cusNumber]);
}else{
$request->attributes->add(['customer_code' => $customer['cus_number']]);
}
}catch(\Throwable $exception){
return Response::fail('客户token无效',500,'');
}
......
......@@ -77,7 +77,7 @@ class BhuaProductsDetailProperty
/**
* @Property(
* type="string",
* description="项目规格"
* description="浓度等级"
* )
*
* @var string
......@@ -117,7 +117,7 @@ class BhuaProductsDetailProperty
/**
* @Property(
* type="string",
* description="规格"
* description="包装规格"
* )
*
* @var string
......
......@@ -77,7 +77,7 @@ class ProductByCas
/**
* @Property(
* type="string",
* description="项目规格"
* description="浓度等级"
* )
*
* @var string
......@@ -137,7 +137,7 @@ class ProductByCas
/**
* @Property(
* type="string",
* description="包装"
* description="包装规格"
* )
*
* @var string
......@@ -164,16 +164,6 @@ class ProductByCas
*/
public $tag;
/**
* @Property(
* type="string",
* description="城市"
* )
*
* @var string
*/
public $city;
/**
* @Property(
* type="string",
......@@ -183,14 +173,4 @@ class ProductByCas
* @var string
*/
public $stock;
/**
* @Property(
* type="string",
* description="项目规格"
* )
*
* @var string
*/
public $pacs;
}
......@@ -77,7 +77,7 @@ class ProductDetailProperty
/**
* @Property(
* type="string",
* description="项目规格"
* description="浓度等级"
* )
*
* @var string
......
......@@ -77,7 +77,7 @@ class ProductsProperty
/**
* @Property(
* type="string",
* description="项目规格"
* description="浓度等级"
* )
*
* @var string
......@@ -157,7 +157,7 @@ class ProductsProperty
/**
* @Property(
* type="string",
* description="包装"
* description="包装规格"
* )
*
* @var string
......
<?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\Auth\Chemsite;
use App\Services\AuthService;
use Illuminate\Http\Request;
use App\Http\Controllers\V1\Controller;
use App\Support\Traits\Helpers;
use Jiannei\Response\Laravel\Support\Facades\Response;
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 CompanyAuthController extends Controller
{
use Helpers;
public function __construct(AuthService $authService)
{
$this->authService = $authService;
}
/**
* @Post(
* path="/openapi/auth/getToken",
* tags={"AuthToken"},
* summary="获取用户auth token,用于接口的用户权限验证",
* description="获取用户auth token",
* @RequestBody(
* @MediaType(
* mediaType="application/json",
* @Schema(
* required={"customerToken"},
* @Property(property="customerToken", @Schema(type="string"),description="用户私有key"),
* example={"customerToken":"cKCXPza6y23l_c0z"}
* ),
* )
* ),
* @AnnotationResponse(
* response="200",
* description="正常操作响应",
* @MediaType(
* mediaType="application/json",
* @Schema(
* allOf={
* @Schema(ref="#/components/schemas/ApiResponse"),
* }
* )
* )
* ),
* )
*/
public function getToken(Request $request)
{
$message = [
'companyToken.required' => "公司token必传",
'cusNumber.required' => "客户编号必传",
];
$this->validateRequest($request, $message);
$params = $request->all();
$params = $this->formatKeysfromArray($params,'toUnderScore');
try{
$params['customer_token'] = $params['company_token'];
$token = $this->authService->getToken($params);
return Response::success($token,'操作成功');
}catch(\Throwable $exception){
return Response::fail('获取token失败',500);
}
}
}
<?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\Chemsite;
use App\Exceptions\ServerRunTimeException;
use App\Rhawn\Services\Chemsite\ChemsiteCompanyService;
use App\Services\Api\Chemsite\ChemsiteCustomerService;
use App\Services\Api\Chemsite\ChemsiteOrdersService;
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 OrdersController extends Controller
{
use Helpers;
public function __construct(ChemsiteOrdersService $chemsiteOrdersService)
{
$this->chemsiteOrdersService = $chemsiteOrdersService;
$this->controllerType = 'chemsite';
}
/**
*
* @Post(
* path="/openapi/chemsite/orders/createOrders",
* tags={"chemsite - 订单相关接口"},
* summary="生成销售订单",
* description="生成销售订单",
* @RequestBody(
* @MediaType(
* mediaType="application/json",
* @Schema(
* required={"soCusPo", "soCaName","soCaMobile","soCaPhone","soCaProvince","soCaCity","soCaStreet","soNote","items"},
* @Property(property="soCusPo", @Schema(type="string"),description="客户编号"),
* @Property(property="soCaName", @Schema(type="string"),description="收货人"),
* @Property(property="soCaMobile", @Schema(type="string"),description="收货人手机"),
* @Property(property="soCaPhone", @Schema(type="string"),description="收货人电话"),
* @Property(property="soCaProvince", @Schema(type="string"),description="收货人省份"),
* @Property(property="soCaCity", @Schema(type="string"),description="收货人城市"),
* @Property(property="soCaStreet", @Schema(type="string"),description="收货人区县"),
* @Property(property="soNote", @Schema(type="string"),description="备注"),
* @Property(property="items", type="array",
* @OA\items(
* @Property(property="pCode", @Schema(type="string"),description="产品code"),
* @Property(property="brandId", @Schema(type="integer"),description="品牌id"),
* @Property(property="num", @Schema(type="integer"),description="产品数量"),
* ),description="当前页数"),
* example={
"soCusPo": "2000000011111",
"soCaName": "张三",
"soCaMobile": "13321686555",
"soCaPhone": "61111111",
"soCaProvince": "上海",
"soCaCity": "上海市",
"soCaStreet": "望园路88888号888室",
"soNote": "测试",
"items": {{
"pCode": "C10010520",
* "brandId" : "10",
"num" : "1",
* }}
* }
* )
* )
* ),
* @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/OrdersDetail")
* )
* }
* )
* )
* ),
* security={
* {"bearer_token":{}}
* }
* )
*/
public function createCustomerNewOrder(Request $request)
{
$companyCode = $request->get('company_code');
$cusNumber = $request->get('cus_number');
if(!$companyCode){
return Response::ok('验证失败,参数缺少!');
}
$this->checkCustomerType($companyCode,$this->controllerType);
$message = [
'soCusPo.required' => "客户订单号必传",
'soCaName.required' => "收货人必传",
'soCaMobile.required' => "收货人手机必传",
'soCaProvince.required' => "收货地省份必传",
'soCaCity.required' => "收货地城市必传",
'soCaStreet.required' => "收货地街道必传",
'items.required' => "订单详情必传",
];
$this->validateRequest($request, $message);
$requestParams = $this->formatKeysfromArray($request->all(),'toUnderScore');
$requestParams = array_merge($requestParams,['customer_code' => $companyCode]);
try{
$companyInfo = app(ChemsiteCompanyService::class)->getCompanyThroughCusCode($companyCode);
if(!$companyInfo){
throw new ServerRunTimeException('经销商不存在');
}
$customer = app(ChemsiteCustomerService::class)->getCustomerByNumber($cusNumber);
if(!$customer){
throw new ServerRunTimeException('客户不存在');
}
if($customer['com_id'] != $companyInfo['com_id']){
throw new ServerRunTimeException('不是该经销商的客户');
}
$requestParams['customer_code'] = $cusNumber;
$requestParams['company_code'] = $companyCode;
$orderDetail = $this->chemsiteOrdersService->createNewCustomerOrders($requestParams);
if($orderDetail){
$orderDetail = $this->formatKeysfromArray($orderDetail,'toCamelCase');
}
return Response::success($orderDetail,'操作成功');
}catch(\Throwable $exception){
return $this->returnErrorExecptionResponse($exception,'生成订单失败');
}
}
}
......@@ -92,6 +92,7 @@ abstract class Controller extends BaseController
switch($type){
case 'bh' : $this->returnErrorExecptionResponse(new AuthenticationException('不是百化用户,无法访问该类型接口'));break;
case 'rhawn' : $this->returnErrorExecptionResponse(new AuthenticationException('不是罗恩用户,无法访问该类型接口'));break;
case 'chemsite' : $this->returnErrorExecptionResponse(new AuthenticationException('不是chemsite用户,无法访问该类型接口'));break;
default : $this->returnErrorExecptionResponse(new AuthenticationException('用户类型未知'));
}
}
......
......@@ -23,11 +23,11 @@ class OtherCustomersTransformer extends TransformerAbstract
$temp = [];
$temp['cus_id'] = $customer->cus_id;
$temp['cus_number'] = $customer->cus_no;
$temp['cus_name'] = $customer->cus_name;
$temp['company_name'] = $customer->cus_company;
$temp['cus_email'] = $customer->cus_email;
$temp['cus_mobile'] = $customer->cus_mobile;
$temp['created_at'] = $customer->cus_createtime;
$temp['cus_name'] = $customer->cus_name ?? '';
$temp['company_name'] = $customer->cus_company ?? '';
$temp['cus_email'] = $customer->cus_email ?? '';
$temp['cus_mobile'] = $customer->cus_mobile ?? '';
$temp['created_at'] = $customer->cus_createtime ?? '';
array_push($customerTransReturn,$temp);
}
}
......
<?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\Chemsite;
use Prettus\Repository\Contracts\RepositoryInterface;
/**
* Interface UserRepository.
*/
interface ChemsiteCompanyRepository extends RepositoryInterface
{
}
<?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\Chemsite;
use Prettus\Repository\Contracts\RepositoryInterface;
/**
* Interface UserRepository.
*/
interface ChemsiteProductRepository extends RepositoryInterface
{
}
<?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\Chemsite;
use Prettus\Repository\Contracts\RepositoryInterface;
/**
* Interface UserRepository.
*/
interface ChemsiteSoitemsRepository extends RepositoryInterface
{
}
<?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\Chemsite;
use Prettus\Repository\Contracts\RepositoryInterface;
/**
* Interface UserRepository.
*/
interface ChemsiteSordersRepository extends RepositoryInterface
{
}
<?php
namespace App\Rhawn\Repositories\Eloquent\Chemsite;
use App\Rhawn\Repositories\Contracts\Chemsite\ChemsiteCompanyRepository;
use App\Rhawn\Repositories\Eloquent\BaseRepository;
use App\Rhawn\Repositories\Models\Chemsite\ChemsiteCompany;
use Illuminate\Support\Facades\DB;
/**
* Class UserRepositoryEloquent.
*/
class ChemsiteCompanyRepositoryEloquent extends BaseRepository implements ChemsiteCompanyRepository
{
/**
* Specify Model class name.
*
* @return string
*/
public function model(): string
{
return ChemsiteCompany::class;
}
public function getCompanyThroughCusCode($cusCode)
{
return $this->findWhere(['com_cus_no' => $cusCode])->first();
}
public function getCompanyList($where,$offset,$limit)
{
$customerModel = DB::connection($this->getConnectionName())->table($this->getTableName());
if(!empty($where)){
$customerModel = $customerModel->where($where);
}
$customerInfo = $customerModel->offset($offset)
->limit($limit)
->get();
if($customerInfo){
return $customerInfo->toArray();
}
return null;
}
}
<?php
namespace App\Rhawn\Repositories\Eloquent\Chemsite;
use App\Rhawn\Repositories\Contracts\Chemsite\ChemsiteProductRepository;
use App\Rhawn\Repositories\Eloquent\BaseRepository;
use App\Rhawn\Repositories\Models\BhuaProducts;
use App\Rhawn\Repositories\Models\Chemsite\ChemsiteProducts;
use Illuminate\Support\Facades\DB;
class ChemsiteProductRepositoryEloquent extends BaseRepository implements ChemsiteProductRepository
{
/**
* Specify Model class name.
*
* @return string
*/
public function model()
{
return ChemsiteProducts::class;
}
/**
* 根据p_code获取产品信息
* @param $pCode
* @return null
*/
public function getProductByPcode($pCode)
{
$productsModel = ChemsiteProducts::query();
if(!is_array($pCode)){
$productsModel->where('products.p_code','=',$pCode);
}else{
$productsModel->whereIn('products.p_code',$pCode);
}
$product = $productsModel->get();
if($product){
return $product->toArray();
}
return null;
}
public function getProductByPcodeAndBid($pCode,$bId)
{
$productsModel = ChemsiteProducts::query();
if(!is_array($pCode)){
$productsModel->where('products.p_code','=',$pCode);
}else{
$productsModel->whereIn('products.p_code',$pCode);
}
$productsModel->where('products.b_id',$bId);
$product = $productsModel->get();
if($product){
return $product->toArray();
}
return null;
}
public function getProductsByWhere(array $where)
{
$productsModel = ChemsiteProducts::query();
foreach($where as $key => $w){
if(!is_array($w)){
$productsModel->where($key,$w);
}else{
$productsModel->whereIn($key,$w);
}
}
$product = $productsModel->get();
if($product){
return $product->toArray();
}
return null;
}
/**
* 根据pid获取产品对应的促销信息
* @param $pId
* @return array|null
*/
public function getProductPromotionByPid($pId)
{
$promotionsModel = DB::connection($this->getConnectionName())
->table('promotions_products')
->join('promotions','promotions.pt_id','promotions_products.pt_id');
if(is_array($pId)){
$promotionsModel->whereIn('promotions_products.p_id',$pId);
}else{
$promotionsModel->where('promotions_products.p_id',$pId);
}
/*$promotions = $promotionsModel->where('promotions.pt_start','<=',time())
->where('promotions.pt_end','>=',time())
->get();*/
$promotions = $promotionsModel->get();
if($promotions){
$promotions = $promotions->toArray();
return $promotions;
}
return null;
}
/**
* 获取所有产品的包装规格
* @return array
*/
public function getProductPackagesThroughGroupByPackUnit()
{
$packages = ChemsiteProducts::query()
->select('p_pack','p_pack_unit')
->groupBy('p_pack','p_pack_unit')
->get();
return $packages->toArray();
}
/**
* 获取产品信息
* @param $where
* @param $offset
* @param $pageSize
* @return null
*/
public function getProductsList($where, $offset, $limit)
{
$productsModel = ChemsiteProducts::query();
if(!empty($where)){
foreach($where as $key => $w){
if(!is_array($w)){
$productsModel->where($key,$w);
}else{
$productsModel->whereIn($key,$w);
}
}
}
$product = $productsModel->offset($offset)->limit($limit)->get();
if($product){
return $product->toArray();
}
return null;
}
public function getProductsByCas($cas)
{
$productsModel = ChemsiteProducts::query();
$product = $productsModel->where('chemicals.c_cas',$cas)->get();
if($product){
return $product->toArray();
}
return null;
}
public function getProductCasByBidToGroupByCas($bId)
{
$productsModel = ChemsiteProducts::query()->select('chemicals.c_cas');
$productsModel = $productsModel->join('chemicals','chemicals.c_id','products.c_id');
$product = $productsModel->where('products.b_id',$bId)->groupBy('chemicals.c_cas')->get();
if($product){
return $product->toArray();
}
return null;
}
/**
* @param $brandId
* @param $offset
* @param $limit
* @return null
*/
public function getProductsListByBrandId($brandId, $offset, $limit)
{
$productsModel = $this->join('chemicals', 'chemicals.c_id','products.c_id');
$product = $productsModel->where('products.b_id',$brandId)
//->where('p_status',1)
->where('p_show',1)
->offset($offset)->limit($limit)->get();
if($product){
return $product->toArray();
}
return null;
}
}
<?php
namespace App\Rhawn\Repositories\Eloquent\Chemsite;
use App\Rhawn\Repositories\Contracts\Chemsite\ChemsiteSoitemsRepository;
use App\Rhawn\Repositories\Contracts\Chemsite\ChemsiteSordersRepository;
use App\Rhawn\Repositories\Eloquent\BaseRepository;
use App\Rhawn\Repositories\Models\Chemsite\ChemsiteSoitems;
/**
* Class UserRepositoryEloquent.
*/
class ChemsiteSoitemsRepositoryEloquent extends BaseRepository implements ChemsiteSoitemsRepository
{
/**
* Specify Model class name.
*
* @return string
*/
public function model()
{
return ChemsiteSoitems::class;
}
/**
* 获取订单详情
* @param $orderId
* @return \Illuminate\Database\Eloquent\Builder[]|\Illuminate\Database\Eloquent\Collection
*/
public function getSorderItemsDetailFromOrderId($orderId)
{
$order = app(ChemsiteSordersRepository::class)->find($orderId);
if(!$order){
throw new \LogicException('该订单不存在!',500);
}
//查询订单的详情
$soItems = $this
->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.so_id',$order->so_id)->get();
if($soItems){
return $soItems->toArray();
}
return null;
}
public function getSorderItemsDetailFromItemId($itemId,$pid=null)
{
//查询订单的详情
$soItems = $this
->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);
if(!is_null($pid)){
$soItems = $soItems->where('soitems.p_id',$pid);
}
$soItems = $soItems->get();
if($soItems){
return $soItems->toArray();
}
return null;
}
/**
* 根据si_id获取订单明细项
* @param $si_id
* @return \Illuminate\Database\Eloquent\Builder[]|\Illuminate\Database\Eloquent\Collection
*/
public function getSorderItemFromItemId($si_id)
{
$item = $this->find($si_id);
if(!$item){
throw new \LogicException('该订单项不存在!',500);
}
//查询订单的详情
$soModel = $this
->join('products','soitems.p_id','products.p_id')
->join('chemicals','chemicals.c_id','products.c_id');
if(is_array($si_id)){
$soModel->whereIn('soitems.si_id',$si_id);
}else{
$soModel->where('soitems.si_id',$si_id);
}
$soItems = $soModel->get();
if($soItems){
return $soItems->toArray();
}
return null;
}
public function getOrderItemsStockFromItemIds($id)
{
if(!is_array($id)){
$item = $this->find($id);
$id = (array)$id;
}else{
$item = $this->whereIn('si_id',$id)->get();
}
if(!$item){
throw new \LogicException('该订单项不存在!',500);
}
//查询订单的详情
$soItemStock = $this
->join('dpdetail','dpdetail.si_id','soitems.si_id')
->join('pstock','pstock.pstk_id','dpdetail.pstk_id')
->join('products','soitems.p_id','products.p_id')
->whereIn('soitems.si_id',$id)
->where('si_if_cancel',0)
//->where('dpdetail.dpd_invoiced','=',0)
->get();
if($soItemStock){
return $soItemStock->toArray();
}
return null;
}
}
<?php
namespace App\Rhawn\Repositories\Eloquent\Chemsite;
use App\Rhawn\Repositories\Contracts\Chemsite\ChemsiteSoitemsRepository;
use App\Rhawn\Repositories\Contracts\Chemsite\ChemsiteSordersRepository;
use App\Rhawn\Repositories\Eloquent\BaseRepository;
use App\Rhawn\Repositories\Models\Chemsite\ChemsiteSorders;
use Illuminate\Support\Facades\DB;
/**
* Class UserRepositoryEloquent.
*/
class ChemsiteSordersRepositoryEloquent extends BaseRepository implements ChemsiteSordersRepository
{
/**
* Specify Model class name.
*
* @return string
*/
public function model()
{
return ChemsiteSorders::class;
}
/**
* 返回指定订单编号的订单信息
* @param $order_no
* @return mixed
*/
public function getSorderFromOrderNo($orderNo)
{
$where = [
'so_no' => $orderNo
];
return $this->findWhere($where)->first();
}
public function getSorderFromOrderCusPo($orderNo)
{
$where = [
'so_cus_po' => $orderNo
];
return $this->findWhere($where)->first();
}
/**
* 获取订单详情
* @param $orderNo
* @return mixed
*/
public function getSorderItemsFromOrderNo($orderNo){
$soItems = $this
->join('soitems','soitems.so_id','sorders.so_id')
->where('sorders.so_no',$orderNo)->get();
if($soItems){
return $soItems->toArray();
}
return null;
}
/**
* 获取订单相关信息(包括,产品,客户,品牌等)
* @param $so_id
* @return mixed
*/
public function getSorderDetailFromOrderId($so_id)
{
$sOrderInfo = $this
->join('customers','sorders.cus_id','customers.cus_id')
->where('sorders.so_id',$so_id)
->get();
if(!$sOrderInfo){
return null;
}
$sOrderInfo = current($sOrderInfo->toArray());
$items = DB::connection($this->getConnectionName())->table('soitems')
->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.so_id',$so_id)
->get();
if(!$items){
$sOrderInfo['items'] = [];
}
$sOrderInfo['items'] = $items->toArray();
return $sOrderInfo;
}
/**
* 获取客户订单
* @param $userId
* @param $pageSize
* @param $offset
* @return array|null
*/
public function getOrdersListThroughtUserId($userId,$offset,$limit)
{
$sOrderInfo = DB::connection($this->getConnectionName())->table($this->getTableName())
->join('customers','customers.cus_id','sorders.cus_id')
->where('sorders.cus_id',$userId)
->offset($offset)
->limit($limit)
->get();
if($sOrderInfo){
return $sOrderInfo->toArray();
}
return null;
}
/**
* 获取客户订单详情
* @param $cusId
* @param $orderId
* @return null
*/
public function getCustomerOrderItemsByOrderId($cusId,$orderId)
{
$sOrderInfo = $this
->join('customers','sorders.cus_id','customers.cus_id')
->where('sorders.so_id',$orderId)
->where('sorders.cus_id',$cusId)
->first();
if(!$sOrderInfo){
return null;
}
$sOrderInfo = $sOrderInfo->toArray();
$itemRepository = app(ChemsiteSoitemsRepository::class);
$items = $itemRepository->getSorderItemsDetailFromOrderId($sOrderInfo['so_id']);
//获取运费
$freightItem = $itemRepository->findWhere(['so_id' => $sOrderInfo['so_id'], 'p_id' => 0])->first();
if($freightItem){
$freightItem = $freightItem->toArray();
$items = array_merge($items,[$freightItem]);
}
$sOrderInfo['items'] = [];
if($items){
$sOrderInfo['items'] = $items;
}
return $sOrderInfo;
}
public function getOrderDispatch($orderNumber)
{
$dpModel = $this->join('dispatch','dispatch.so_id','sorders.so_id')
->join('dpdetail','dpdetail.dp_id','dispatch.dp_id');
if(is_array($orderNumber)){
$dpModel->whereIn('sorders.so_no',$orderNumber);
}else{
$dpModel->where('sorders.so_no',$orderNumber);
}
$dpdetail = $dpModel->get();
if($dpdetail){
return $dpdetail->toArray();
}
return null;
}
}
<?php
namespace App\Rhawn\Repositories\Models\Chemsite;
use App\Repositories\Models\Model;
class ChemsiteCompany extends Model
{
protected $table = 'companys';
protected $connection = 'chemsite_mysql';
protected $primaryKey = 'com_id';
/**
* The attributes that are mass assignable.
*
* @var array
*/
protected $fillable = [
];
/**
* The attributes excluded from the model's JSON form.
*
* @var array
*/
protected $hidden = [
];
}
\ No newline at end of file
<?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\Chemsite;
use App\Repositories\Models\Model;
class ChemsiteProducts extends Model
{
// 产品
protected $table = 'products';
protected $connection = 'chemsite_mysql';
protected $primaryKey = 'p_id';
/**
* The attributes that are mass assignable.
*
* @var array
*/
protected $fillable = [
];
/**
* The attributes excluded from the model's JSON form.
*
* @var array
*/
protected $hidden = [
];
}
\ No newline at end of file
<?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\Chemsite;
use App\Repositories\Models\Model;
class ChemsiteSoitems extends Model
{
// 销售订单
protected $table = 'soitems';
protected $connection = 'chemsite_mysql';
protected $primaryKey = 'si_id';
/**
* The attributes that are mass assignable.
*
* @var array
*/
protected $fillable = [
];
/**
* The attributes excluded from the model's JSON form.
*
* @var array
*/
protected $hidden = [
];
}
\ No newline at end of file
<?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\Chemsite;
use App\Repositories\Models\Model;
class ChemsiteSorders extends Model
{
// 产品
protected $table = 'sorders';
protected $connection = 'chemsite_mysql';
protected $primaryKey = 'so_id';
/**
* The attributes that are mass assignable.
*
* @var array
*/
protected $fillable = [
];
/**
* The attributes excluded from the model's JSON form.
* @var array
*/
protected $hidden = [
];
}
\ No newline at end of file
<?php
namespace App\Rhawn\Services\Chemsite;
use App\Rhawn\Repositories\Contracts\Chemsite\ChemsiteCompanyRepository;
class ChemsiteCompanyService
{
private ChemsiteCompanyRepository $chemsiteCompanyRepository;
public function __construct(ChemsiteCompanyRepository $chemsiteCompanyRepository)
{
$this->chemsiteCompanyRepository = $chemsiteCompanyRepository;
}
public function getCompanyThroughCusCode($cusCode)
{
$company = $this->chemsiteCompanyRepository->getCompanyThroughCusCode($cusCode);
if($company){
$company = $company->toArray();
$company['cus_id'] = $company['com_id'];
$company['cus_no'] = $company['com_cus_no'];
$company['cus_company'] = $company['com_name'];
return $company;
}
return null;
}
public function getCustomerListByCusCode($cusNo,$offset,$limit)
{
$company = $this->chemsiteCompanyRepository->getCompanyList(['com_cus_no' => $cusNo],$offset,$limit);
if($company){
$company = $company->toArray();
foreach($company as &$c){
$c['cus_id'] = $c['com_id'];
$c['cus_no'] = $c['com_cus_no'];
$c['cus_company'] = $c['com_name'];
}
return $company;
}
return null;
}
}
......@@ -10,12 +10,22 @@ class ChemsiteCustomerService
public function __construct(ChemsiteCustomerRepository $chemsiteCustomerRepository)
{
$this->customerRepository = $chemsiteCustomerRepository;
$this->chemsiteCustomerRepository = $chemsiteCustomerRepository;
}
public function getCustomerThroughCusCode($cusCode)
{
$customer = $this->customerRepository->getCustomerThroughCusCode($cusCode);
$customer = $this->chemsiteCustomerRepository->getCustomerThroughCusCode($cusCode);
return $customer->toArray();
}
public function checkCustomerExist($cusCode)
{
//查询用户是否存在
$customer = $this->chemsiteCustomerRepository->getCustomerThroughCusCode($cusCode);
if(!$customer){
throw new \Exception('客户编号为:['.$cusCode.']的用户不存在!',500);
}
return $customer;
}
}
<?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\Services\Chemsite;
use App\Rhawn\Repositories\Contracts\BhuaSordersRepository;
use App\Rhawn\Repositories\Eloquent\BhuaCustomerRepositoryEloquent;
use App\Rhawn\Repositories\Eloquent\BhuaProductRepositoryEloquent;
use App\Rhawn\Repositories\Eloquent\BhuaSoitemsRepositoryEloquent;
use App\Support\Facades\SimpleLogs;
use Illuminate\Support\Facades\DB;
class ChemsiteOrdersService
{
public function __construct(BhuaSordersRepository $bhuaSorderRepository)
{
$this->bhuaSorderRepository = $bhuaSorderRepository;
}
public function getCustomerOrderItems($cusCode, $soItems)
{
if(empty($soItems)){
throw new \Exception('订单项为空',500);
}
$customerReopository = app(BhuaCustomerRepositoryEloquent::class);
$discount = $customerReopository->getCustomerDiscountByCusCode($cusCode);
$total = 0;
$weight = 0;
$productRepository = app(BhuaProductRepositoryEloquent::class);
foreach($soItems as $k => $v){
$productInfo = $productRepository->getProductByPcodeAndBid($v['p_code'],$v['brand_id']);
if(!$productInfo){
throw new \Exception($v['p_code'].'产品不存在!',500);
}
$productInfo = current($productInfo);
if($productInfo['p_status'] == 0 || $productInfo['p_show'] == 0){
throw new \Exception($v['p_code'].'产品已下架!',500);
}
if(isset($discount[$productInfo['b_id']])){
$productInfo['p_discount'] = round($discount[$productInfo['b_id']]['cd_discount'] * $productInfo['p_price']);
}else{
$productInfo['p_discount'] = $productInfo['p_price'];
}
$soItems[$k]['amount'] = round(bcmul($productInfo['p_discount'],$v['num'],3),2);
$soItems[$k]['weight'] = round(bcmul($productInfo['p_weight'],$v['num'],3),3);
//得到品牌
$brands = DB::connection($this->bhuaSorderRepository->getConnectionName())
->table('brands')
->where('b_id',$productInfo['b_id'])
->first();
if(!$brands){
throw new \Exception('品牌不存在',500);
}
$productInfo['b_cn_name'] = $brands->b_cn_name;
$soItems[$k]['product_info'] = $productInfo;
$total += $soItems[$k]['amount'];
$weight += $soItems[$k]['weight'];
}
$returnItems = [];
$returnItems['total'] = $total;
$returnItems['weight'] = $weight;
$returnItems['rows'] = $soItems;
return $returnItems;
}
/**
* 新增订单
* @param $data
* @return false
*/
public function createOrders($data)
{
$connection = DB::connection($this->bhuaSorderRepository->getConnectionName());
try{
$connection->beginTransaction();
$data['sorders']['so_no'] = '';
$data['sorders']['so_ctime'] = time();
//$data['sorders']['so_creater'] = $data['sorders']['creater'];
$orderId = $connection->table('sorders')->insertGetId($data['sorders']);
$soNo = 1000000 + $orderId;
$soNo = date('Ymd',time()).'-'.$soNo;
$connection->table('sorders')
->where('so_id',$orderId)
->update([
'so_no' => $soNo
]);
$soitems = [];
foreach($data['soitems'] as $k => $v){
$soitems[$k]['so_id'] = $orderId;
$soitems[$k]['p_id'] = $v['p_id'];
$soitems[$k]['si_price'] = $v['si_price'];
$soitems[$k]['si_discount'] = $v['si_discount'];
$soitems[$k]['si_num'] = $v['si_num'];
$soitems[$k]['si_amount'] = $v['si_amount'];
$soitems[$k]['si_p_tod'] = $v['si_p_tod'];
$soitems[$k]['si_note'] = '';
}
if($data['express'] > 0){
$soitems_count = count($soitems);
$soitems[$soitems_count]['so_id'] = $orderId;
$soitems[$soitems_count]['p_id'] = 0;
$soitems[$soitems_count]['si_price'] = 0;
$soitems[$soitems_count]['si_discount'] = 0;
$soitems[$soitems_count]['si_num'] = 0;
$soitems[$soitems_count]['si_amount'] = $data['express'];
$soitems[$soitems_count]['si_p_tod'] = '';
$soitems[$soitems_count]['si_note'] = '';
}
$connection->table('soitems')->insert($soitems);
$connection->table('logs')->insert(
[
'l_obj'=>$orderId,
'l_type'=>'sorders_mng',
'l_op'=>'add',
'l_op_name'=>'新增',
'l_note'=>$data['sorders']['so_note'],
'l_timestamp'=>time(),'u_id'=>$data['sorders']['so_creater']
]
);
$connection->commit();
return $orderId;
}catch(\Throwable $exception){
$connection->rollBack();
SimpleLogs::writeLog($exception->getMessage(),__CLASS__.':createOrders','error');
throw $exception;
}
}
/**
* 计算运费
* @param $weight
* @param $province
* @param $total
* @param $if_free_express
* @param $cus_level
* @return float|int
*/
public function getExpress($weight,$province,$total){
//计算运费 (运费=首重(1kg)*运输系数(首重)+续重(总重量-1kg)*运输系数(续重))
$express = 0;
if($weight == 0){
$weight = 0.1;
}
if($total < 99 && $weight > 0){
$weight = ceil($weight);
if($province == '江苏省' || $province == '浙江省' || $province == '上海' || $province == '江苏' || $province == '浙江'){
$express = ($weight - 1)*2 + 6;
}else{
$express = ($weight - 1)*8 + 10;
}
}
return $express;
}
public function getCustomerOrderItemsByOrderId($cusId, $orderId)
{
return $this->bhuaSorderRepository->getCustomerOrderItemsByOrderId($cusId, $orderId);
}
public function getSordersByOrderNo($orderNo)
{
$order = $this->bhuaSorderRepository->getSorderFromOrderNo($orderNo);
if($order){
return $order->toArray();
}
return null;
}
/**
* 获取订单配货单详情
* @param $orderNumber
*/
public function getOrderDispatchDetail($orderNumber)
{
try{
$dpdetail = $this->bhuaSorderRepository->getOrderDispatch($orderNumber);
$soItemIds = [];
if($dpdetail){
foreach($dpdetail as $detail){
$soItemIds[] = $detail['si_id'];
}
$soItems = app(BhuaSoitemsRepositoryEloquent::class)->getSorderItemFromItemId($soItemIds);
if(!$soItems){
throw new \Exception('订单项不存在',500);
}
$orderItems = [];
foreach($soItems as $item){
$orderItems[$item['si_id']] = $item;
}
foreach($dpdetail as &$detail){
if(isset($orderItems[$detail['si_id']]) && !empty($orderItems[$detail['si_id']])){
$detail['si_id'] = $orderItems[$detail['si_id']];
}
}
}
return $dpdetail;
}catch(\Throwable $exception){
SimpleLogs::writeLog($exception->getMessage(),__CLASS__.':getOrderDispatchDetail','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\Chemsite;
use App\Repositories\Transformers\Rhawn\OrderDetailTransformer;
use App\Repositories\Transformers\Rhawn\OrdersDispatchTransformer;
use App\Support\Facades\SimpleLogs;
class ChemsiteOrdersService
{
public function __construct(\App\Rhawn\Services\Chemsite\ChemsiteOrdersService $chemsiteOrdersService)
{
$this->chemsiteOrdersService = $chemsiteOrdersService;
$this->chemsiteCustomerService = app(\App\Rhawn\Services\Chemsite\ChemsiteCustomerService::class);
}
/**
* 新增订单
* @param $requestParams
*/
public function createNewCustomerOrders($requestParams)
{
try{
$customer = $this->chemsiteCustomerService->checkCustomerExist($requestParams['customer_code']);
if(!isset($requestParams['so_ca_county'])){
$requestParams['so_ca_county'] = '';
}
$orderItems = $this->chemsiteOrdersService->getCustomerOrderItems($customer['cus_no'],$requestParams['items']);
if(!$orderItems){
throw new \Exception('货号无法匹配',500);
}
$express = $this->bhuaOrdersService->getExpress(
$orderItems['weight'],$requestParams['so_ca_province'],$orderItems['total']
);
$order = $this->bhuaOrdersService->bhuaSorderRepository->getSorderFromOrderCusPo($requestParams['so_cus_po']);
if($order){
throw new \Exception('不能重复创建新订单!',500);
}
$data = [];
$data['sorders']['cus_id'] = $customer['cus_id'];
$data['sorders']['so_cus_po'] = $requestParams['so_cus_po'];
$data['sorders']['so_ca_name'] = $requestParams['so_ca_name'];
$data['sorders']['so_ca_mobile'] = $requestParams['so_ca_mobile'];
$data['sorders']['so_ca_phone'] = !isset($requestParams['so_ca_phone']) ? '' : $requestParams['so_ca_phone'];
if(!isset($requestParams['so_ca_province']) || empty($requestParams['so_ca_province'])){
throw new \Exception('省份必填');
}else{
$data['sorders']['so_ca_province'] = $requestParams['so_ca_province'];
}
if(!isset($requestParams['so_ca_city']) || empty($requestParams['so_ca_city'])){
throw new \Exception('城市必填');
}else{
$data['sorders']['so_ca_city'] = $requestParams['so_ca_city'];
}
if(!isset($requestParams['so_ca_county']) || empty($requestParams['so_ca_county'])){
throw new \Exception('区县必填');
}else{
$data['sorders']['so_ca_county'] = $requestParams['so_ca_county'];
}
if(!isset($requestParams['so_ca_street']) || empty($requestParams['so_ca_street'])){
throw new \Exception('街道必填');
}else{
$data['sorders']['so_ca_street'] = $requestParams['so_ca_street'];
}
//得到收票地址
$cusiaddrs_arr = $this->bhuaCustomerService->customerRepository->getCustomerAddressByCusCode($customer['cus_no']);
$cusinvoice_arr = $this->bhuaCustomerService->customerRepository->getCustomerInvoiceByCusCode($customer['cus_no']);
if(!$cusiaddrs_arr){
throw new \Exception('请至会员中心设置收票地址',500);
}
if(!$cusinvoice_arr){
throw new \Exception('请至会员中心设置发票信息',500);
}
$cusiaddrs_arr = current($cusiaddrs_arr);
$cusinvoice_arr = current($cusinvoice_arr);
$data['sorders']['so_cia_name'] = $cusiaddrs_arr['cia_name'];
$data['sorders']['so_cia_mobile'] = $cusiaddrs_arr['cia_mobile'];
$data['sorders']['so_cia_phone'] = $cusiaddrs_arr['cia_phone'];
$data['sorders']['so_cia_province'] = $cusiaddrs_arr['cia_province'];
$data['sorders']['so_cia_city'] = $cusiaddrs_arr['cia_city'];
$data['sorders']['so_cia_county'] = $cusiaddrs_arr['cia_county'];
$data['sorders']['so_cia_street'] = $cusiaddrs_arr['cia_street'];
$data['sorders']['so_cia_name'] = $cusiaddrs_arr['cia_name'];
$data['sorders']['so_ci_type'] = $cusinvoice_arr['ci_type'];
$data['sorders']['so_ci_title'] = $cusinvoice_arr['ci_title'];
$data['sorders']['so_ci_vatno'] = $cusinvoice_arr['ci_vatno'];
$data['sorders']['so_ci_bank'] = $cusinvoice_arr['ci_bank'];
$data['sorders']['so_ci_bknum'] = $cusinvoice_arr['ci_bknum'];
$data['sorders']['so_ci_addr'] = $cusinvoice_arr['ci_addr'];
$data['sorders']['so_ci_phone'] = $cusinvoice_arr['ci_phone'];
$data['sorders']['so_standard'] = 0;
$data['sorders']['so_from'] = 4;
$data['sorders']['so_creater'] = 0;//$customer['cus_id'];
if(!isset($requestParams['so_note'])){
$requestParams['so_note'] = '';
}
$data['sorders']['so_note'] = $requestParams['so_note'];
$data['sorders']['so_send_note'] = $customer['cus_send_note'];
$data['sorders']['so_ci_method'] = 1;
$data['sorders']['so_total'] = $orderItems['total'] + $express;
$data['express'] = $express;
$data['v_id'] = '';
$data['soitems'] = [];
foreach($orderItems['rows'] as $k => $v){
$soitem = [];
$soitem['p_id'] = $v['product_info']['p_id'];
$soitem['si_price'] = $v['product_info']['p_price'];
$soitem['si_discount'] = $v['product_info']['p_discount'];
$soitem['si_num'] = $v['num'];
$soitem['si_amount'] = $v['product_info']['p_discount'] * $v['num'];
$soitem['si_p_tod'] = $v['product_info']['p_tod'];
$soitem['si_vamount'] = 0;
array_push($data['soitems'],$soitem);
}
$orderId = $this->bhuaOrdersService->createOrders($data);
if($orderId){
$orderDetail = $this->bhuaOrdersService->getCustomerOrderItemsByOrderId($customer['cus_id'],$orderId);
//处理运费
if($orderDetail){
$orderDetail['so_freight_price'] = 0;
foreach($orderDetail['items'] as $key => $item){
if($item['p_id'] == 0){
$orderDetail['so_freight_price'] = $item['si_amount'];
unset($orderDetail['items'][$key]);
}
}
}
$orderDetail = app(OrderDetailTransformer::class)->transform([$orderDetail]);
return current($orderDetail);
}
return null;
}catch(\Throwable $exception){
SimpleLogs::writeLog($exception->getMessage(),__CLASS__.':createNewCustomerOrders','error');
throw $exception;
}
}
}
......@@ -15,6 +15,7 @@ use App\Repositories\Contracts\PlatformCustomerRepository;
use App\Rhawn\Services\RhawnCustomerService;
use App\Support\Facades\SimpleLogs;
use App\Support\Traits\Helpers;
use http\Env\Request;
use Illuminate\Support\Facades\DB;
class AuthService
......@@ -34,17 +35,23 @@ class AuthService
*/
public function getToken($requestParams)
{
$token = $requestParams['customer_token'];
$platformCustomer = $this->platformCustomerRepository->findWhere([
'token' => $token
'token' => $requestParams['customer_token']
]);
if(!$platformCustomer->toArray()){
throw new \Exception('token无效',500);
}
$platformCustomer = current($platformCustomer->toArray());
if($platformCustomer['cus_type'] == 'chemsite'){
$token['company_token'] = $requestParams['customer_token'];
$token['cus_number'] = $requestParams['cus_number'];
}else{
$token['customer_token'] = $requestParams['customer_token'];
}
$newToken = base64_encode(implode(',', $token));
$expTimestamp = strtotime(date('Y-m-d H:i:s', strtotime('+1 day')));
$jwtToken = $this->generateToken($token);
$jwtToken = $this->generateToken($newToken);
return [
'token' => $jwtToken,
......
......@@ -15,12 +15,13 @@ use App\Repositories\Contracts\PlatformCustomerRepository;
use App\Repositories\Transformers\CustomersTransformer;
use App\Repositories\Transformers\OtherCustomersTransformer;
use App\Rhawn\Repositories\Contracts\BhuaCustomerRepository;
use App\Rhawn\Repositories\Contracts\Chemsite\ChemsiteCompanyRepository;
use App\Rhawn\Repositories\Contracts\RhawnCustomerRepository;
use App\Rhawn\Services\BhuaCustomerService;
use App\Rhawn\Services\Chemsite\ChemsiteCompanyService;
use App\Rhawn\Services\RhawnCustomerService;
use App\Support\Facades\SimpleLogs;
use App\Support\Traits\Helpers;
use Illuminate\Support\Facades\DB;
class CustomerService
{
......@@ -31,6 +32,7 @@ class CustomerService
$this->platformCustomerRepository = $platformCustomerRepository;
$this->rhawnCustomerService = (new RhawnCustomerService(app(RhawnCustomerRepository::class)));
$this->bhuaCustomerService = (new BhuaCustomerService(app(BhuaCustomerRepository::class)));
$this->chemsiteCustomerService = (new ChemsiteCompanyService(app(ChemsiteCompanyRepository::class)));
}
/**
......@@ -48,6 +50,9 @@ class CustomerService
case 'bh' :
$customer = $this->bhuaCustomerService->getBhuaCustomerThroughtCusCode($requestParams['customer_code']);
break;
case 'chemsite' :
$customer = $this->chemsiteCustomerService->getCompanyThroughCusCode($requestParams['customer_code']);
break;
}
if(!$customer){
throw new \Exception('没有找到该客户',500);
......@@ -61,10 +66,11 @@ class CustomerService
throw new \Exception('平台用户已存在,无需重复注册',500);
}
$newCustomer = [];
$newCustomer['cus_id'] = $customer['cus_id'];
$newCustomer['cus_number'] = $customer['cus_no'];
$newCustomer['company_name'] = $requestParams['customer_company'];
$newCustomer['cus_number'] = $requestParams['customer_type'] == 'chemsite' ? $customer['com_cus_no'] : $customer['cus_no'];
$newCustomer['company_name'] = $requestParams['customer_type'] == 'chemsite' ? $customer['com_name'] : $requestParams['customer_company'];
$newCustomer['token'] = $this->randomFromDevice(16);
$newCustomer['cus_type'] = $requestParams['customer_type'];
$newCustomer['platform_params'] = isset($requestParams['platform_params']) ? $requestParams['platform_params'] : '';
......@@ -198,6 +204,7 @@ class CustomerService
switch($requestParams['customer_type']){
case 'bh' : $customerService = app(BhuaCustomerService::class);break;
case 'rhawn' : $customerService = app(RhawnCustomerService::class);break;
case 'chemsite' : $customerService = app(ChemsiteCompanyService::class);break;
}
if($customerService == null){
......
......@@ -9,5 +9,6 @@ $api = app('Dingo\Api\Routing\Router');
require __DIR__.'/../routes/api/zhenkunhang.php';
require __DIR__.'/../routes/api/rhawn.php';
require __DIR__.'/../routes/api/chemsite.php';
require __DIR__.'/../routes/api/customer.php';
require __DIR__.'/../routes/api/finance.php';
<?php
$api->version('v1', function($api) {
//获取token
$api->group(['namespace'=>'App\Http\Controllers\V1\Auth\Chemsite','middleware' => ['maintenance','throttle:60,1']], function($api) {
$api->post('/openapi/auth/chemsite/getToken', ['uses'=>'CompanyAuthController@getToken']);
});
$api->group(['namespace'=>'App\Http\Controllers\V1\Chemsite','middleware' => ['maintenance','throttle:60,1','apiAuth','requestlogs'], 'providers' => 'jwt'], function($api) {
// 新建订单
$api->post('/openapi/chemsite/orders/createOrders', ['permission' => 'chemsite.createOrders', 'uses'=>'OrdersController@createCustomerNewOrder']);
});
});
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