Template.php 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. <?php
  2. namespace app\common\model\ps;
  3. use app\common\library\ps\FactoryContext;
  4. /**
  5. * 流程单模板。工厂端看本厂模板 + 官方模板。
  6. */
  7. class Template extends FactoryModel
  8. {
  9. protected $name = 'ps_template';
  10. protected function base($query)
  11. {
  12. if (FactoryContext::bypass()) {
  13. return;
  14. }
  15. $factoryId = (int)FactoryContext::id();
  16. if ($factoryId <= 0) {
  17. $query->where('factory_id', -1);
  18. return;
  19. }
  20. $query->where(function ($q) use ($factoryId) {
  21. $q->where('factory_id', $factoryId)
  22. ->whereOr(function ($q2) {
  23. $q2->where('factory_id', 0)->where('is_system', 1);
  24. });
  25. });
  26. }
  27. /**
  28. * 可套打:排除已锁定的单次购买副本
  29. * @param \think\db\Query $query
  30. * @return \think\db\Query
  31. */
  32. public function scopePrintable($query)
  33. {
  34. return $query->where('status', 'normal')->where(function ($q) {
  35. $q->where('license_type', '<>', 'market_single')
  36. ->whereOr('locked', 0);
  37. });
  38. }
  39. }