付款与收款
This commit is contained in:
@@ -62,4 +62,12 @@ class FinPaymentApply extends Model
|
|||||||
{
|
{
|
||||||
return $this->belongsToMany(StockOrders::class, 'fin_payment_stock', 'payment_apply_id', 'stock_id');
|
return $this->belongsToMany(StockOrders::class, 'fin_payment_stock', 'payment_apply_id', 'stock_id');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 关联的备货单(通过中间表)
|
||||||
|
*/
|
||||||
|
public function stocks()
|
||||||
|
{
|
||||||
|
return $this->belongsToMany(StockOrders::class, 'fin_payment_stock', 'payment_apply_id', 'stock_id');
|
||||||
|
}
|
||||||
}
|
}
|
||||||
@@ -40,7 +40,7 @@ class FinPaymentStock extends Model
|
|||||||
/**
|
/**
|
||||||
* 允许自动填充模型字段
|
* 允许自动填充模型字段
|
||||||
*/
|
*/
|
||||||
protected $fillable = ['id', 'payment_apply_id', 'receipt_id', 'stock_id', 'allocated_amount', 'allocated_amount_cny'];
|
protected $fillable = ['id', 'pi_no', 'payment_apply_id', 'receipt_id', 'stock_id', 'allocated_amount', 'allocated_amount_cny', 'updated_at', 'created_at'];
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 不允许自动填充模型字段
|
* 不允许自动填充模型字段
|
||||||
@@ -59,7 +59,7 @@ class FinPaymentStock extends Model
|
|||||||
return $this->belongsTo(FinReceipt::class, 'receipt_id', 'id');
|
return $this->belongsTo(FinReceipt::class, 'receipt_id', 'id');
|
||||||
}
|
}
|
||||||
|
|
||||||
// 付款申请
|
// 备货单
|
||||||
public function stock()
|
public function stock()
|
||||||
{
|
{
|
||||||
return $this->belongsTo(StockOrders::class, 'stock_id', 'id');
|
return $this->belongsTo(StockOrders::class, 'stock_id', 'id');
|
||||||
|
|||||||
@@ -40,7 +40,7 @@ class FinReceipt extends Model
|
|||||||
/**
|
/**
|
||||||
* 允许自动填充模型字段
|
* 允许自动填充模型字段
|
||||||
*/
|
*/
|
||||||
protected $fillable = ['id', 'receipt_no', 'payment_apply_id', 'country_id', 'remitter', 'account_id', 'currency_id', 'amount', 'discount_amount', 'total_amount_cny', 'exchange_rate', 'arrived_at', 'received_at', 'voucher_no', 'fx_receipt_file', 'is_domestic_return', 'created_at', 'updated_at'];
|
protected $fillable = ['id', 'receipt_no', 'payment_apply_id', 'country_id', 'remitter', 'account_id', 'currency_id', 'amount', 'discount_amount', 'total_amount_cny', 'exchange_rate', 'arrived_at', 'received_at', 'voucher_no', 'fx_receipt_file', 'is_domestic_return', 'created_by', 'updated_by', 'created_at', 'updated_at'];
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 不允许自动填充模型字段
|
* 不允许自动填充模型字段
|
||||||
@@ -48,11 +48,11 @@ class FinReceipt extends Model
|
|||||||
protected $guarded = [];
|
protected $guarded = [];
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 获取付款申请
|
* 对应的付款申请(1-1,可为空)
|
||||||
*/
|
*/
|
||||||
public function payment()
|
public function payment()
|
||||||
{
|
{
|
||||||
return $this->hasOne(FinPaymentApply::class, 'id', 'payment_apply_id');
|
return $this->belongsTo(FinPaymentApply::class, 'payment_apply_id', 'id');
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -62,4 +62,12 @@ class FinReceipt extends Model
|
|||||||
{
|
{
|
||||||
return $this->belongsToMany(StockOrders::class, 'fin_payment_stock', 'receipt_id', 'stock_id');
|
return $this->belongsToMany(StockOrders::class, 'fin_payment_stock', 'receipt_id', 'stock_id');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 关联的备货单(通过中间表)
|
||||||
|
*/
|
||||||
|
public function stocks()
|
||||||
|
{
|
||||||
|
return $this->belongsToMany(StockOrders::class, 'fin_payment_stock', 'receipt_id', 'stock_id');
|
||||||
|
}
|
||||||
}
|
}
|
||||||
@@ -0,0 +1,49 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace app\common\model;
|
||||||
|
|
||||||
|
use support\Model;
|
||||||
|
|
||||||
|
class FinReceiptHis extends Model
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* The connection name for the model.
|
||||||
|
*
|
||||||
|
* @var string|null
|
||||||
|
*/
|
||||||
|
protected $connection = 'mysql';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The table associated with the model.
|
||||||
|
*
|
||||||
|
* @var string
|
||||||
|
*/
|
||||||
|
protected $table = 'fin_receipt_his';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The primary key associated with the table.
|
||||||
|
*
|
||||||
|
* @var string
|
||||||
|
*/
|
||||||
|
protected $primaryKey = 'id';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Indicates if the model should be timestamped.
|
||||||
|
*
|
||||||
|
* @var bool
|
||||||
|
*/
|
||||||
|
public $timestamps = true;
|
||||||
|
|
||||||
|
|
||||||
|
protected $dateFormat = 'U';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 允许自动填充模型字段
|
||||||
|
*/
|
||||||
|
protected $fillable = ['id', 'receipt_id', 'receipt_no', 'payment_apply_id', 'country_id', 'remitter', 'account_id', 'currency_id', 'amount', 'discount_amount', 'total_amount_cny', 'exchange_rate', 'arrived_at', 'received_at', 'voucher_no', 'fx_receipt_file', 'is_domestic_return', 'created_by', 'updated_by', 'created_at', 'updated_at'];
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 不允许自动填充模型字段
|
||||||
|
*/
|
||||||
|
protected $guarded = [];
|
||||||
|
}
|
||||||
@@ -103,4 +103,12 @@ class StockOrders extends Model
|
|||||||
{
|
{
|
||||||
return $this->belongsToMany(FinPaymentApply::class, 'fin_payment_stock', 'stock_id', 'payment_apply_id');
|
return $this->belongsToMany(FinPaymentApply::class, 'fin_payment_stock', 'stock_id', 'payment_apply_id');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 关联收款记录(多对多,经由中间表)
|
||||||
|
*/
|
||||||
|
public function receipts()
|
||||||
|
{
|
||||||
|
return $this->belongsToMany(FinReceipt::class, 'fin_payment_stock', 'stock_id', 'receipt_id');
|
||||||
|
}
|
||||||
}
|
}
|
||||||
@@ -2,9 +2,11 @@
|
|||||||
|
|
||||||
namespace app\common\service;
|
namespace app\common\service;
|
||||||
|
|
||||||
|
use app\common\model\FinPaymentStock;
|
||||||
use app\common\validate\FinPaymentApplyValidate;
|
use app\common\validate\FinPaymentApplyValidate;
|
||||||
use app\common\traits\crud\CrudServiceTrait;
|
use app\common\traits\crud\CrudServiceTrait;
|
||||||
use app\common\model\FinPaymentApply;
|
use app\common\model\FinPaymentApply;
|
||||||
|
use support\Redis;
|
||||||
use support\Request;
|
use support\Request;
|
||||||
|
|
||||||
class FinPaymentApplyService
|
class FinPaymentApplyService
|
||||||
@@ -61,10 +63,27 @@ class FinPaymentApplyService
|
|||||||
public function beforeServiceStore($data, Request $request)
|
public function beforeServiceStore($data, Request $request)
|
||||||
{
|
{
|
||||||
$data['apply_no'] = $this->generateUniqueApplyNo();
|
$data['apply_no'] = $this->generateUniqueApplyNo();
|
||||||
|
$data['doc_user_id'] = $request->user->uid;
|
||||||
$data['submit_files'] = json_encode($data['submit_files']);
|
$data['submit_files'] = json_encode($data['submit_files']);
|
||||||
|
redis::set('stock'.$data['doc_user_id'],json_encode($request->post('stock')));
|
||||||
return $data;
|
return $data;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public function afterServiceStore($res)
|
||||||
|
{
|
||||||
|
$data = [
|
||||||
|
'payment_apply_id' => $res['id'],
|
||||||
|
];
|
||||||
|
$stock = json_decode(redis::get('stock'.$res['doc_user_id']), true);
|
||||||
|
redis::del('stock');
|
||||||
|
foreach ($stock as $k => $v) {
|
||||||
|
$data['stock_id'] = $v['stock_id'];
|
||||||
|
$data['pi_no'] = $v['pi_on'];
|
||||||
|
FinPaymentStock::create($data);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public function beforeServiceUpdate($data, Request $request)
|
public function beforeServiceUpdate($data, Request $request)
|
||||||
{
|
{
|
||||||
$data['submit_files'] = json_encode($data['submit_files']);
|
$data['submit_files'] = json_encode($data['submit_files']);
|
||||||
|
|||||||
@@ -80,12 +80,14 @@ class FinReceiptService
|
|||||||
unset($data['payment_apply_id']);
|
unset($data['payment_apply_id']);
|
||||||
}
|
}
|
||||||
$data['receipt_no'] = $this->generateUniqueReceipt();
|
$data['receipt_no'] = $this->generateUniqueReceipt();
|
||||||
$data['arrived_at'] = strtotime( $data['arrived_at']);
|
$data['arrived_at'] = $request->user->uid;
|
||||||
|
$data['updated_by'] = $request->user->uid;
|
||||||
return $data;
|
return $data;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function beforeServiceUpdate($data, Request $request)
|
public function beforeServiceUpdate($data, Request $request)
|
||||||
{
|
{
|
||||||
|
$data['updated_by'] = $request->user->uid;
|
||||||
$data['arrived_at'] = strtotime( $data['arrived_at']);
|
$data['arrived_at'] = strtotime( $data['arrived_at']);
|
||||||
$data['received_at'] = strtotime( $data['received_at']);
|
$data['received_at'] = strtotime( $data['received_at']);
|
||||||
return $data;
|
return $data;
|
||||||
|
|||||||
@@ -76,7 +76,7 @@ class IndexController
|
|||||||
// ],
|
// ],
|
||||||
'model' => [
|
'model' => [
|
||||||
'module' => 'common',
|
'module' => 'common',
|
||||||
'name' => 'fin_payment_stock'
|
'name' => 'fin_receipt_his'
|
||||||
],
|
],
|
||||||
// 'service' => [
|
// 'service' => [
|
||||||
// 'module' => 'common',
|
// 'module' => 'common',
|
||||||
@@ -90,7 +90,7 @@ class IndexController
|
|||||||
// 'module' => 'common',
|
// 'module' => 'common',
|
||||||
// 'name' => 'fin_payment_apply'
|
// 'name' => 'fin_payment_apply'
|
||||||
// ],
|
// ],
|
||||||
'table' => 'fin_payment_stock'
|
'table' => 'fin_receipt_his'
|
||||||
];
|
];
|
||||||
|
|
||||||
$result = (new Generate($options))->doGenerate();
|
$result = (new Generate($options))->doGenerate();
|
||||||
|
|||||||
Reference in New Issue
Block a user