| 1234567891011121314151617181920212223242526272829303132333435363738394041424344 |
- <?php
- namespace app\common\model\ps;
- use app\common\library\ps\FactoryContext;
- /**
- * 流程单模板。工厂端看本厂模板 + 官方模板。
- */
- class Template extends FactoryModel
- {
- protected $name = 'ps_template';
- protected function base($query)
- {
- if (FactoryContext::bypass()) {
- return;
- }
- $factoryId = (int)FactoryContext::id();
- if ($factoryId <= 0) {
- $query->where('factory_id', -1);
- return;
- }
- $query->where(function ($q) use ($factoryId) {
- $q->where('factory_id', $factoryId)
- ->whereOr(function ($q2) {
- $q2->where('factory_id', 0)->where('is_system', 1);
- });
- });
- }
- /**
- * 可套打:排除已锁定的单次购买副本
- * @param \think\db\Query $query
- * @return \think\db\Query
- */
- public function scopePrintable($query)
- {
- return $query->where('status', 'normal')->where(function ($q) {
- $q->where('license_type', '<>', 'market_single')
- ->whereOr('locked', 0);
- });
- }
- }
|