Commit 85d33e7e authored by hangjun83's avatar hangjun83

百化产品接口更新

parent 581e4a80
<?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\Finance\Repositories\Contracts;
use Prettus\Repository\Contracts\RepositoryInterface;
/**
* Interface UserRepository.
*/
interface BhuaInvoiceItemsRepository 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\Finance\Repositories\Contracts;
use Prettus\Repository\Contracts\RepositoryInterface;
/**
* Interface UserRepository.
*/
interface BhuaInvoiceRepository extends RepositoryInterface
{
}
<?php
namespace App\Finance\Repositories\Eloquent;
use App\Finance\Repositories\Contracts\BhuaInvoiceItemsRepository;
use App\Finance\Repositories\Models\BhuaInvoiceItems;
/**
* Class UserRepositoryEloquent.
*/
class BhuaInvoiceItemsRepositoryEloquent extends BaseRepository implements BhuaInvoiceItemsRepository
{
protected $fieldSearchable = [
];
/**
* Specify Model class name.
*
* @return string
*/
public function model()
{
return BhuaInvoiceItems::class;
}
public function getInvoiceItemsByIdAndItemId($id, $itemId)
{
$invoiceItemInfo = null;
$invoiceItemInfo = $this->join('dpdetail', 'dpdetail.dpd_id', 'soidetail.dpd_id')
->join('soitems', 'soitems.si_id', 'dpdetail.si_id')
->join('products', 'products.p_id', 'soitems.p_id')
->whereIn('soidetail.soid_id', $itemId)
->where('soidetail.soi_id', $id)
->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
namespace App\Finance\Repositories\Eloquent;
use App\Finance\Repositories\Contracts\BhuaInvoiceRepository;
use App\Finance\Repositories\Models\BhuaInvoice;
/**
* Class UserRepositoryEloquent.
*/
class BhuaInvoiceRepositoryEloquent extends BaseRepository implements BhuaInvoiceRepository
{
protected $fieldSearchable = [
];
/**
* Specify Model class name.
*
* @return string
*/
public function model()
{
return BhuaInvoice::class;
}
public function getInvoiceById($id)
{
$invoice = $this->where('soi_id',$id)->get()->toArray();
if($invoice){
return current($invoice);
}
return null;
}
public function updateInvoiceById($id,$updateParams)
{
$invoice = $this->getInvoiceById($id);
if($invoice){
return $this->updateOrCreate(['soi_id' => $id],$updateParams)->toArray();
}
return null;
}
public function queryCustomerInfoByInvoiceId($invoiceId)
{
$customerInfo = null;
$customerInfo = $this->join('customers', 'soinvoice.cus_id', 'customers.cus_id')
->where('soinvoice.soi_id', $invoiceId)
->get()->toArray();
return $customerInfo;
}
}
<?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\Finance\Repositories\Models;
use App\Repositories\Models\Model;
class BhuaInvoice extends Model
{
// 销售订单
protected $table = 'soinvoice';
protected $connection = 'bh_mysql';
protected $primaryKey = 'soi_id';
/**
* The attributes that are mass assignable.
*
* @var array
*/
protected $fillable = [
'soi_api_status','soi_no','soi_date','soi_tax','soi_amount'
];
/**
* 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
<?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\Finance\Repositories\Models;
use App\Repositories\Models\Model;
class BhuaInvoiceItems extends Model
{
// 销售订单
protected $table = 'soidetail';
protected $connection = 'bh_mysql';
protected $primaryKey = 'soid_id';
/**
* The attributes that are mass assignable.
*
* @var array
*/
protected $fillable = [
];
/**
* 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
<?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\Rhawn\Bhua;
use League\Fractal\TransformerAbstract;
class ProductsTransformer extends TransformerAbstract
{
/**
* 格式化结
* @param $rhawnSorders
* @return array
*/
public function transform($products,$type = 'all')
{
$productTransReturn = [];
if($products){
foreach($products as $product){
$temp = [];
$temp['code'] = $product['p_code'];//中文别名
$temp['cas'] = $product['c_cas'];//CAS号
$temp['chem_cn_name'] = $product['c_cn_name'];//中文名
$temp['chem_en_name'] = $product['c_en_name'];//中文名
$temp['cn_name'] = $product['p_cn_name'];//中文名
$temp['en_name'] = $product['p_en_name'];//英文名
$temp['level'] = $product['p_level'];//项目规格
if($type == 'all'){
$temp['delivery'] = $product['p_tod'];//货期
}
$temp['price'] = $product['p_price'];//单价
$temp['market_price'] = $product['m_price'];//目录价格
if($product['r_gz_type'] == 2){
$temp['if_explode'] = 1;//是否易制爆
}else{
$temp['if_explode'] = 0;//是否易制爆
}
if($type == 'all'){
if($product['r_gz_type'] == 1){
$temp['if_drag'] = 1;//是否易制毒
}else{
$temp['if_drag'] = 0;//是否易制毒
}
}
if($product['c_if_dangers'] == 1){
$temp['if_dangers'] = 1;//是否危化品
}else{
$temp['if_dangers'] = 0;//是否危化品
}
if($product['r_status'] == 0 || $product['p_status'] == 0 || $product['p_show'] == 0 || $product['p_if_big'] == 1){
$temp['status'] = 0;
$temp['price'] = 0;
$temp['market_price'] = 0;
}else{
$temp['status'] = 1;
}
$temp['pack'] = $product['p_pack'].$product['p_pack_unit'];//包装规格
$temp['weight'] = $product['p_weight'];//产品重量kg
if($product['p_stock'] > 0){
$temp['tag'] = '当天发货';
}else{
$temp['tag'] = '';
}
if($type == 'bycas'){
$temp['city'] = '上海';
$temp['stock'] = $product['p_tod'];//货期
$temp['pacs'] = $product['p_pack'].$product['p_pack_unit'];//项目规格
}
array_push($productTransReturn,$temp);
}
}
return $productTransReturn;
}
}
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