1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950 |
- <?php
- namespace app\cxinv\model;
- use think\model\concern\SoftDelete;
- class ProductSeal extends Base
- {
- use SoftDelete;
- //设置字段信息
- protected $schema = [
- 'id' =>'bigint',//
- 'product_id' =>'bigint',//商品id
- 'skuCode' =>'varchar',//商品编号
- 'goodName' =>'varchar',//商品名称
- 'spec' =>'varchar',//规格
- 'unit' =>'varchar',//单位
- 'unit_price' =>'decimal',//单价
- 'begin_num' =>'decimal',//期初数据
- 'in_num' =>'decimal',//收入数据
- 'out_num' =>'decimal',//发出数据
- 'balance_num' =>'decimal',//结存数据
- 'fz_id' =>'bigint',//封账id
- 'create_time' =>'datetime',//
- 'update_time' =>'datetime',//
- 'delete_time' =>'datetime',//
- ];
- protected $createTime = 'create_time';
- protected $updateTime = 'update_time';
- protected $deleteTime = 'delete_time';
- protected $append=['begin_total_price','in_total_price','out_total_price','balance_total_price'];
- public function PorductFz(){
- return $this->belongsTo(ProductFz::class,'fz_id','id');
- }
- public function Porduct(){
- return $this->belongsTo(FinancialProducts::class,'product_id','id');
- }
- public function getBeginTotalPriceAttr($value,$data){
- return bcmul($data['begin_num'],$data['unit_price'],15);
- }
- public function getInTotalPriceAttr($value,$data){
- return bcmul($data['in_num'],$data['unit_price'],15);
- }
- public function getOutTotalPriceAttr($value,$data){
- return bcmul($data['out_num'],$data['unit_price'],15);
- }
- public function getBalanceTotalPriceAttr($value,$data){
- return bcmul($data['balance_num'],$data['unit_price'],15);
- }
- }
|