ProductSeal.php 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. <?php
  2. namespace app\cxinv\model;
  3. use think\model\concern\SoftDelete;
  4. class ProductSeal extends Base
  5. {
  6. use SoftDelete;
  7. //设置字段信息
  8. protected $schema = [
  9. 'id' =>'bigint',//
  10. 'product_id' =>'bigint',//商品id
  11. 'skuCode' =>'varchar',//商品编号
  12. 'goodName' =>'varchar',//商品名称
  13. 'spec' =>'varchar',//规格
  14. 'unit' =>'varchar',//单位
  15. 'unit_price' =>'decimal',//单价
  16. 'begin_num' =>'decimal',//期初数据
  17. 'in_num' =>'decimal',//收入数据
  18. 'out_num' =>'decimal',//发出数据
  19. 'balance_num' =>'decimal',//结存数据
  20. 'fz_id' =>'bigint',//封账id
  21. 'create_time' =>'datetime',//
  22. 'update_time' =>'datetime',//
  23. 'delete_time' =>'datetime',//
  24. ];
  25. protected $createTime = 'create_time';
  26. protected $updateTime = 'update_time';
  27. protected $deleteTime = 'delete_time';
  28. protected $append=['begin_total_price','in_total_price','out_total_price','balance_total_price'];
  29. public function PorductFz(){
  30. return $this->belongsTo(ProductFz::class,'fz_id','id');
  31. }
  32. public function Porduct(){
  33. return $this->belongsTo(FinancialProducts::class,'product_id','id');
  34. }
  35. public function getBeginTotalPriceAttr($value,$data){
  36. return bcmul($data['begin_num'],$data['unit_price'],15);
  37. }
  38. public function getInTotalPriceAttr($value,$data){
  39. return bcmul($data['in_num'],$data['unit_price'],15);
  40. }
  41. public function getOutTotalPriceAttr($value,$data){
  42. return bcmul($data['out_num'],$data['unit_price'],15);
  43. }
  44. public function getBalanceTotalPriceAttr($value,$data){
  45. return bcmul($data['balance_num'],$data['unit_price'],15);
  46. }
  47. }