OwnerPriceOperation.php 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. <?php
  2. namespace App;
  3. use Illuminate\Database\Eloquent\Model;
  4. use App\Traits\ModelLogChanging;
  5. class OwnerPriceOperation extends Model
  6. {
  7. use ModelLogChanging;
  8. protected $fillable = [
  9. "operation_type", //操作类型
  10. "name", //名称
  11. "strategy", //策略
  12. "feature", //特征
  13. "remark", //备注
  14. "priority", //优先级 值越大越高
  15. "discount_count", //减免值 array
  16. "total_price", //按单计价
  17. "total_discount_price",//按单计价减免 array
  18. "operation", //操作
  19. "target_id", //目标ID
  20. "type_mark", //类型标记 用于某些特殊项的匹配限制 0:退货 例:退货模块的单据进入模型匹配时仅匹配为0的项
  21. "surcharge", //附加费
  22. "surcharge_unit_id",//附加费单位
  23. "max_fee", //封顶费
  24. "tax_rate_id", //税率
  25. ];
  26. public static $features = null;
  27. public static $columnMapping = null;
  28. const MARK=[
  29. 0 => "退货单",
  30. ];
  31. public function items()
  32. { //出库规则
  33. return $this->hasMany(OwnerPriceOperationItem::class,"owner_price_operation_id","id");
  34. }
  35. public function owners()
  36. { //货主
  37. return $this->belongsToMany(Owner::class,"owner_price_operation_owner","owner_price_operation_id","owner_id");
  38. }
  39. public function taxRate()
  40. { //税率
  41. return $this->belongsTo(TaxRate::class);
  42. }
  43. public function getFeatureFormatAttribute()
  44. {
  45. if ($this->strategy == '默认')return "/";
  46. return app("FeatureService")->formatFeature(self::$features,$this->feature,self::$columnMapping);
  47. }
  48. }