is_system === 1) { return; } if ((int)$template->factory_id !== (int)$factoryId) { throw new Exception('模板不属于当前工厂'); } if ($template->license_type === 'market_single' && (int)$template->locked === 1) { throw new Exception('该模板为单次购买,已使用过,不允许再次套打'); } } /** * 确认套打后消耗单次授权 * @param Template $template * @param int $factoryId */ public static function consumeOnConfirm(Template $template, $factoryId) { if ($template->license_type !== 'market_single' || (int)$template->locked === 1) { return; } $template->save([ 'locked' => 1, 'locked_time' => time(), ]); MarketLicense::where('factory_id', $factoryId) ->where('template_id', $template->id) ->where('license_type', 'single') ->update([ 'remain_times' => 0, 'locked' => 1, 'used_time' => time(), ]); } }